diff --git a/CounterSales.php b/CounterSales.php
index 39cbb8e45..090049f21 100644
--- a/CounterSales.php
+++ b/CounterSales.php
@@ -2417,95 +2417,20 @@ functionalexrate,
}
echo '';
}
+echo '';
?>
-
-
ReceiveQty . "',
stdcostunit='" . $_SESSION['PO'.$identifier]->LineItems[$OrderLine->LineNo]->StandardCost . "',
- completed='" . $_SESSION['PO'.$identifier]->LineItems[$OrderLine->LineNo]->Completed . "'
+ completed='1'
WHERE podetailitem = '" . $OrderLine->PODetailRec . "'";
$ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The purchase order detail record could not be updated with the quantity received because');
diff --git a/javascripts/CounterSalesFunctions.js b/javascripts/CounterSalesFunctions.js
new file mode 100644
index 000000000..084ab10ee
--- /dev/null
+++ b/javascripts/CounterSalesFunctions.js
@@ -0,0 +1,147 @@
+var CounterSales = {
+
+ itemlist: Array(),
+ SetItemList: function(val)
+ {
+ this.itemlist = val;
+ },
+
+ quickentrytableid: "",
+ SetQuickEntryTableId: function(val)
+ {
+ this.quickentrytableid = val;
+ },
+
+ quickentryrowid: "",
+ SetTotalQuickEntryRowsId: function(val)
+ {
+ this.quickentryrowid = val;
+ },
+
+ rowcounter: 0,
+ SetRowCounter: function(val)
+ {
+ this.rowcounter = val;
+ },
+
+ IncreaseRowCounter: function()
+ {
+ this.rowcounter++;
+ },
+
+ defaultdeliverydate: "",
+ SetDefaultDeliveryDate: function(val)
+ {
+ this.defaultdeliverydate = val;
+ },
+
+ AddQuickEntry: function(itemcode)
+ {
+ // prevent form submitting
+ event.preventDefault();
+ var itemlist = this.itemlist;
+
+ if(itemlist.includes(itemcode.value.trim()))
+ {
+ var table = document.getElementById(this.quickentrytableid);
+
+ // loop quick entry table rows
+ for (var j = 0, row; row = table.rows[j]; j++)
+ {
+ found = false;
+ col = row.cells[0];
+ var input_itemcode = col.firstElementChild;
+ if(input_itemcode)
+ {
+ // check if item already in list or fill in the first empty row
+ if(input_itemcode.value == '' || input_itemcode.value == itemcode.value.trim())
+ {
+ // set item code
+ input_itemcode.value = itemcode.value.trim();
+ // set qty
+ row.cells[1].firstElementChild.value = row.cells[1].firstElementChild.value ? parseInt(row.cells[1].firstElementChild.value) + 1 : '1';
+ found = true;
+ break;
+ }
+ }
+ }
+
+ // when no rows matched and no more empty rows
+ if(!found)
+ {
+ this.AddQuickEntryRow(itemcode)
+ }
+ }
+ else
+ {
+ alert("item code not found!");
+ }
+
+ itemcode.value = "";
+ },
+
+ AddQuickEntryRow: function (itemcode)
+ {
+ var table = document.getElementById(this.quickentrytableid);
+ var row = table.insertRow(-1);
+ var cell1 = row.insertCell(0);
+ var cell2 = row.insertCell(1);
+
+ cell1.innerHTML = "";
+ cell2.innerHTML = "";
+
+ totalquickentry = document.getElementById(this.quickentryrowid);
+ totalquickentry.value = parseInt(totalquickentry.value) + 1;
+
+ this.IncreaseRowCounter();
+ },
+
+
+ totaldue: 0,
+ SetTotalDue: function(val)
+ {
+ this.totaldue = val;
+ },
+
+ decimal: 2,
+ SetDecimal: function(val)
+ {
+ this.decimal = val;
+ },
+
+ cashreceivedid: "",
+ SetCashReceivedId: function(val)
+ {
+ this.cashreceivedid = val;
+ },
+
+ amountpaidid: "",
+ SetAmountPaidId: function(val)
+ {
+ this.amountpaidid = val;
+ },
+
+ changedueid: "",
+ SetChangeDueId: function(val)
+ {
+ this.changedueid = val;
+ },
+
+ CalculateChangeDue: function ()
+ {
+ received_amount = document.getElementById(this.cashreceivedid);
+ paid_amount = document.getElementById(this.amountpaidid);
+ change_due = document.getElementById(this.changedueid);
+
+ if(received_amount.value >= this.totaldue)
+ {
+ paid_amount.value = Number(this.totaldue).toFixed(this.decimal);
+ change_due.value = Number(received_amount.value - this.totaldue).toFixed(this.decimal);
+ }
+ else
+ {
+ paid_amount.value = 0;
+ change_due.value = 0;
+ }
+ }
+}
\ No newline at end of file