diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php
index 0e4d43e9..61271b8a 100644
--- a/app/Controllers/StockController.php
+++ b/app/Controllers/StockController.php
@@ -869,11 +869,11 @@ class StockController extends BaseController
// getting customer for creating table headers
// checking already existing stock if yes then get customer from the existing stock
- // if not set customer as '' empty string
+ // if not set customer in db , then set '' empty string
foreach ($resinMaterials as $key => $resinMaterial) {
$materialCode = $resinMaterial['MaterialCode'];
- $resinMaterials[$key]['customers'] = $this->bagStockDetails_model
+ $resinMaterials[$key]['customers'] = $this->resinStockDetails_model
->select('customer')
->where('date >=', $startDate)
->where('date <=', $endDate)
diff --git a/app/Models/BagStockDetailsModel.php b/app/Models/BagStockDetailsModel.php
index 4a4e9993..bb287b8c 100644
--- a/app/Models/BagStockDetailsModel.php
+++ b/app/Models/BagStockDetailsModel.php
@@ -32,30 +32,5 @@ class BagStockDetailsModel extends Model
* @param array $data Array of records to be updated in bulk.
* @return bool
*/
- public function updateBatchWithCompositeKey(array $data)
- {
- $db = \Config\Database::connect();
- $db->transBegin();
- foreach ($data as $record) {
- $db->table($this->table)
- ->where('date', $record['date'])
- ->where('materialCode', $record['materialCode'])
- ->update([
- 'customer' => $record['customer'],
- 'opening' => $record['opening'],
- 'receipt' => $record['receipt'],
- 'used' => $record['used'],
- 'balanceStock' => $record['balanceStock']
- ]);
- }
-
- if ($db->transStatus() === FALSE) {
- $db->transRollback();
- return false;
- } else {
- $db->transCommit();
- return true;
- }
- }
}
diff --git a/app/Views/bagStockDetails.php b/app/Views/bagStockDetails.php
index ee9342db..33c2e357 100644
--- a/app/Views/bagStockDetails.php
+++ b/app/Views/bagStockDetails.php
@@ -349,11 +349,12 @@
oninput="openingStockChange(this)"
- contenteditable="true"
+ contenteditable="true"
>= $bagStock['opening']?>
@@ -362,14 +363,18 @@
|
+ contenteditable="true"
+ >
= $bagStock['receipt']?>
|
= $bagStock['used']?>
+ contenteditable="true"
+
+ >
+ = $bagStock['used']?>
|
- >= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'0' ?> |
+ >= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'-' ?>
0 |
+ contenteditable="true"> -
- 0 |
+ oninput="usedStockChange(this)" contenteditable="true"> -
= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'0' ?> |
+ >= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'-' ?>
@@ -694,11 +698,17 @@
try{
let dataId = tdElement.getAttribute('data-id');
+
let [date,materialCode] = tdElement.getAttribute('data-id').split(' ');
- let openingStock = tdElement.innerText;
- let usedStock = document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText;
- let receiptStock = document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText;
+
+ let openingStock = validateInput( tdElement.innerText );
+
+ let usedStock = validateInput(document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText);
+
+ let receiptStock = validateInput(document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText);
+
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
+
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
updateStockValue( date,materialCode,currentBalanceStock )
@@ -713,12 +723,19 @@
function receiptStockChange(tdElement) {
try{
+
let dataId = tdElement.getAttribute('data-id');
+
let [date,materialCode] = tdElement.getAttribute('data-id').split(' ');
- let openingStock = document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText;
- let receiptStock = tdElement.innerText;
- let usedStock = document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText;
+
+ let openingStock = validateInput(document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText);
+
+ let receiptStock = validateInput(tdElement.innerText);
+
+ let usedStock = validateInput(document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText);
+
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
+
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
updateStockValue( date,materialCode,currentBalanceStock )
@@ -736,12 +753,19 @@
function usedStockChange(tdElement) {
try {
+
let dataId = tdElement.getAttribute('data-id');
+
let [date,materialCode] = tdElement.getAttribute('data-id').split(' ');
- let openingStock = document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText;
- let receiptStock = document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText;
- let usedStock = tdElement.innerText;
+
+ let openingStock = validateInput(document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText);
+
+ let receiptStock = validateInput(document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText);
+
+ let usedStock = validateInput(tdElement.innerText);
+
let currentBalanceStock = ( Number(openingStock) + Number(receiptStock) ) - Number(usedStock);
+
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
updateStockValue( date,materialCode,currentBalanceStock )
@@ -776,9 +800,9 @@
document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
- let usedStock = document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText;
+ let usedStock = validateInput(document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText);
- let receiptStock = document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText;
+ let receiptStock = validateInput(document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText);
currentBalanceStock = (Number(currentBalanceStock) + Number(receiptStock)) - Number(usedStock);
@@ -800,6 +824,31 @@
})
}
+
+ function validateInput(input) {
+
+
+ if ( input == '' || input == ' ' || input == '-' ) {
+ return 0;
+ }
+
+ if(typeof input === 'string' && input.split('').map(char => char.charCodeAt(0))[0] == 10 ){
+ return 0 ;
+ }
+
+ // Validate against the regex
+ const isValid = /^-?\d*\.?\d*$/.test(input);
+ if (!isValid) {
+ alert('Invalid input! Please enter a valid number.');
+ return 0;
+ }
+
+ return input;
+}
+
+
+
+
diff --git a/app/Views/resinStockDetails.php b/app/Views/resinStockDetails.php
index 6a298f35..e035e394 100644
--- a/app/Views/resinStockDetails.php
+++ b/app/Views/resinStockDetails.php
@@ -105,10 +105,11 @@
border: 1px solid #ccc;
color: #ffffff;
font-weight: bold;
- padding: 6px 10px;;
+ padding: 6px 10px;
+ ;
text-align: center;
}
-
+
._Separador {
background-color: #fff;
@@ -173,27 +174,27 @@
- modify('first day of this month')->format('Y-m-d');
- $endDate = $date->modify('last day of this month')->format('Y-m-d');
+$startDate = $date->modify('first day of this month')->format('Y-m-d');
+$endDate = $date->modify('last day of this month')->format('Y-m-d');
- $datesInMonth = [];
+$datesInMonth = [];
- $period = new DatePeriod(
- new DateTime($startDate),
- new DateInterval('P1D'),
- (new DateTime($endDate))->modify('+1 day')
- );
+$period = new DatePeriod(
+ new DateTime($startDate),
+ new DateInterval('P1D'),
+ (new DateTime($endDate))->modify('+1 day')
+);
- foreach ($period as $day) {
- $datesInMonth[] = $day->format('Y-m-d');
- }
+foreach ($period as $day) {
+ $datesInMonth[] = $day->format('Y-m-d');
+}
- ?>
+?>
@@ -242,207 +243,204 @@
-
+
-
+
-
+
- | material |
-
-
-
-
- = $resinMaterial['MaterialName']?>
-
+ | material |
+
+
+
+
+ = $resinMaterial['MaterialName'] ?>
+
|
-
+
-
-
- | Date |
-
-
- Date |
- material |
- customer |
- Opening Stock |
- Receipt |
- Used |
- Balance Stock |
-
+
+ | Date |
+
+
+
+ Date |
+ material |
+ customer |
+ Opening Stock |
+ Receipt |
+ Used |
+ Balance Stock |
+
-
+
-
+
- $resinStockDetails){
- ?>
- format('d-m-Y');
- if ($dateInMonthDmYFormat === $currentDate) { echo 'style="background: #cef0ad;"';}
- ?>
- >
- $resinStock){ ?>
-
- format('d-m-Y');
- ?>
- |
- = $startDate ?>
- |
-
-
-
- = $resinStock['date']?>
- |
- = $resinStock['materialCode']?>
- |
-
-
- = $resinStock['customer']?>
- |
-
-
- oninput="openingStockChange(this)"
- contenteditable="true"
-
-
- >= $resinStock['opening']?>
- |
-
-
- = $resinStock['receipt']?>
- |
-
- = $resinStock['used']?>
- |
-
-
- = $resinStock['balanceStock']?>
- |
-
-
-
-
-
-
-
-
-
-
- $dateInMonth){ ?>
- $resinStockDetails) {
+ ?>
+
format('d-m-Y');
- if ($dateInMonthDmYFormat === $currentDate) { echo 'style="background: #cef0ad;"';}
- ?>
- >
- $resinMaterial){ ?>
-
+ $dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $resinStockDetails[0]['date'])->format('d-m-Y');
+ if ($dateInMonthDmYFormat === $currentDate) {
+ echo 'style="background: #cef0ad;"';
+ }
+ ?>>
+ $resinStock) { ?>
+
+ format('d-m-Y');
+ ?>
+ |
+ = $startDate ?>
+ |
+
-
- format('d-m-Y');
- ?>
-
- = $startDate ?>
- |
-
-
-
- = $dateInMonth?>
+ |
+ = $resinStock['date'] ?>
+ |
+ = $resinStock['materialCode'] ?>
|
-
- = $resinMaterial['MaterialCode']?>
- |
-
-
- = $resinMaterial['customers']?>
+ |
+ = $resinStock['customer'] ?>
|
-
- oninput="openingStockChange(this)"
- contenteditable="true"
+ data-id="= $resinStock['date'] ?> = $resinStock['materialCode'] ?>"
-
- >= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock']??'0' ?> |
+
+ oninput="openingStockChange(this)"
+ contenteditable="true"
+ >= $resinStock['opening'] ?>
+
0 |
+ data-id="= $resinStock['date'] ?> = $resinStock['materialCode'] ?>"
+ oninput="receiptStockChange(this)"
+ contenteditable="true">
+ = $resinStock['receipt'] ?>
+
0 |
+ data-id="= $resinStock['date'] ?> = $resinStock['materialCode'] ?>"
+ oninput="usedStockChange(this)"
+ contenteditable="true">= $resinStock['used'] ?>
+
= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock']??'0' ?> |
+ data-id="= $resinStock['date'] ?> = $resinStock['materialCode'] ?>">
+ = $resinStock['balanceStock'] ?>
+
+
+
+
+
+
+
+
+
+
+
+ $dateInMonth) { ?>
+ format('d-m-Y');
+ if ($dateInMonthDmYFormat === $currentDate) {
+ echo 'style="background: #cef0ad;"';
+ }
+ ?>>
+ $resinMaterial) { ?>
+
+
+
+ format('d-m-Y');
+ ?>
+ |
+ = $startDate ?>
+ |
+
+
+
+ = $dateInMonth ?>
+ |
+
+
+ = $resinMaterial['MaterialCode'] ?>
+ |
+
+
+ = $resinMaterial['customers'] ?>
+ |
+
+
+
+ oninput="openingStockChange(this)"
+ contenteditable="true"
+
+ >= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock'] ?? '-' ?> |
+
+ - |
+
+ - |
+
+ = $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock'] ?? '-' ?> |
-
+
+
-
@@ -465,58 +463,58 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
\ No newline at end of file