diff --git a/interface/forms/fee_sheet/new.php b/interface/forms/fee_sheet/new.php
index e5d5892a4d1..409c5b6aaa9 100644
--- a/interface/forms/fee_sheet/new.php
+++ b/interface/forms/fee_sheet/new.php
@@ -220,7 +220,7 @@ function echoServiceLines()
if ($codetype != 'COPAY' && (!empty($code_types[$codetype]['mod']) || $modifier)) {
echo "
| \n";
+ "value='" . attr($modifier) . "' size='" . attr($code_types[$codetype]['mod']) . "' onkeyup='policykeyup(this)' onblur='formatModifier(this)' />\n";
} else {
echo " | \n";
}
@@ -670,7 +670,12 @@ function echoProductLines()
$arrcode = explode('|', $codestring);
if (strpos($arrcode[1], ':') !== false) {
- list($code, $modifier) = explode(":", $arrcode[1]);
+ $tmp = explode(':', $arrcode[1]);
+ $code = $tmp[0] ?? '';
+ $modifier = $tmp[1] ?? '';
+ $modifier .= ($tmp[2] ?? '') ? ":" . $tmp[2] : '';
+ $modifier .= ($tmp[3] ?? '') ? ":" . $tmp[3] : '';
+ $modifier .= ($tmp[4] ?? '') ? ":" . $tmp[4] : '';
} else {
$code = $arrcode[1];
$modifier = '';
@@ -906,6 +911,38 @@ function defaultPriceLevelChanged(sel) {
}
}
+function formatModifier(e) {
+ let mods = e.value;
+ mods = mods.substring(0, 11).trim();
+ let modArray = mods.includes(':') ? mods.split(":") : mods.split(" ");
+ let cntr = 0;
+ modArray.forEach( function(m) {
+ let l = m.length;
+ if (l) {
+ cntr++;
+ if (l !== 2) {
+ alert("Removing invalid modifier " + m);
+ modArray.pop();
+ }
+ } else {
+ modArray.pop();
+ }
+ });
+
+ let modString = modArray.join(":");
+ e.value = checkLastChar(modString);
+}
+
+function checkLastChar(s) {
+ let last_char = s.slice(-1);
+ if (last_char === ':') {
+ s = s.substring(0, s.length - 1);
+ return checkLastChar(s);
+ } else {
+ return s;
+ }
+}
+