From e007d6a299bcfb205804a9917c2e2e4659332426 Mon Sep 17 00:00:00 2001 From: vadivel J Date: Thu, 7 Nov 2024 12:12:42 +0530 Subject: [PATCH] bag stock changes --- app/Controllers/StockController.php | 32 ++++-- app/Views/bagStockDetails.php | 166 +++++++++++++++------------- 2 files changed, 116 insertions(+), 82 deletions(-) diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 1a9278c8..ea126722 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -281,6 +281,22 @@ class StockController extends BaseController $this->global['pageTitle']='Bag Stock Details'; + + $previousMonth = DateTime::createFromFormat('Y-m', $month)->modify('-1 month')->format('Y-m'); + $previousMonthStartDate = "$previousMonth-01"; + $previousMonthEndDate = date("Y-m-t", strtotime($previousMonthStartDate)); + $data['previousMonthBagStockDetails'] = $this->bagStockDetails_model + ->select(['materialCode', 'date' ,'balanceStock']) + ->distinct() + ->where('date =', $previousMonthEndDate) + ->groupBy(['materialCode','date']) + ->orderBy('date','desc') + ->orderBy('materialCode','asc') + ->findAll(); + + + + $startDate = "$month-01"; $endDate = date("Y-m-t", strtotime($startDate)); $data['bagStockDetails'] = $this->bagStockDetails_model @@ -322,16 +338,16 @@ class StockController extends BaseController foreach($bagMaterials as $key => $bagMaterial){ $materialCode = $bagMaterial['MaterialCode']; $bagMaterials[$key]['customers'] = $this->bagStockDetails_model - ->select('customer') + ->select('customer') ->where('date >=', $startDate) ->where('date <=', $endDate) - ->where('materialCode', $materialCode) - ->first()['customer'] ?? ''; - } - - $bagMaterialcount = count($bagMaterials); - - $data['bagMaterialcount'] = $bagMaterialcount; + ->where('materialCode', $materialCode) + ->first()['customer'] ?? ''; + } + + $bagMaterialcount = count($bagMaterials); + + $data['bagMaterialcount'] = $bagMaterialcount; $data['bagMaterials'] = $bagMaterials; $date = DateTime::createFromFormat('Y-m', $month); diff --git a/app/Views/bagStockDetails.php b/app/Views/bagStockDetails.php index ff8bd25c..620639f7 100644 --- a/app/Views/bagStockDetails.php +++ b/app/Views/bagStockDetails.php @@ -217,9 +217,7 @@ material - - - + @@ -230,11 +228,12 @@ - Customer - + Customer - + @@ -268,11 +267,7 @@ //dd($groupedBagStockDetails); foreach($groupedBagStockDetails as $groupedBagStockDetailsIndex => $bagStockDetails){ ?> - - - - - + $bagStock){ ?> - + + + - + - + + - 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'); + } - ?> + ?> - $dateInMonth){ ?> - - $bagMaterial){ ?> - + $dateInMonth){ ?> + + $bagMaterial){ ?> + - - format('d-m-Y'); - ?> - - + + format('d-m-Y'); + ?> + + + + + + + - - - - - - - - + + + - - - + + + - - - oninput="openingStockChange(this)" - contenteditable="true" + + + oninput="openingStockChange(this)" + contenteditable="true" - - >0 + + > - 0 + 0 - 0 + 0 - 0 + 0 + + - - @@ -490,13 +493,15 @@ const table = $('#bagStockDetailsTableId'); const rows = []; - + //this table to json is customized for bagstock not for all + table.find('tbody tr').each(function() { const rowCells = $(this).find('td'); const date = rowCells.eq(0).text().trim(); - + /** we get eight entries against a material so we loop from 1 to 7 and so on + in a single row **/ for (let i = 1; i < rowCells.length; i += 7) { const rowData = { date: rowCells.eq(i).text().trim(), @@ -620,6 +625,19 @@ } }) } + + function updateCustomerForMaterial(){ + return + } + + function customerChange(thElement){ + let materialCode = thElement.getAttribute('data-materialCode'); + let newCustomerValue = thElement.innerText; + let matchingCustomerData = document.querySelectorAll(`td.customer[data-materialCode="${materialCode}"]`); + matchingCustomerData.forEach((element,index)=>{ + element.innerText=newCustomerValue; + }) + }