From 946d4706e2f737a811df9c9804564e88ebb39f49 Mon Sep 17 00:00:00 2001 From: vadivel J Date: Wed, 30 Oct 2024 17:29:23 +0530 Subject: [PATCH 1/7] finished bugs from tracker -vadivel J --- app/Controllers/StockController.php | 34 ++++++++++++++++++++++++++++- app/Views/bagStockDetails.php | 5 +---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index b3ce6677..0728316c 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -11,6 +11,7 @@ use App\Models\FactoryVehicleDieselStockSummaryModel; use App\Models\IncomingSilicaSandDetailsModel; use App\Models\Inwardgateregister_model; use App\Models\Rawmaterialdetails_model; +use App\Models\BagStockDetailsModel; use CodeIgniter\HTTP\ResponseInterface; use DateTime; @@ -26,6 +27,7 @@ class StockController extends BaseController protected $incomingSilicaSandDetails_model; protected $inwardGateRegister_model; protected $rawmaterialdetails_model; + protected $bagStockDetails_model; /** * This is default constructor of the class @@ -42,6 +44,7 @@ class StockController extends BaseController $this->rawmaterialdetails_model = new Rawmaterialdetails_model(); $this->incomingSilicaSandDetails_model = new IncomingSilicaSandDetailsModel(); $this->inwardGateRegister_model = new Inwardgateregister_model(); + $this->bagStockDetails_model = new BagStockDetailsModel(); $this->session = session(); helper('form'); @@ -257,12 +260,41 @@ class StockController extends BaseController public function loadView_bagStockDetails(){ + if ($this->request->getMethod() === 'POST'){ + $month = $this->request->getPost('month'); + + $date = DateTime::createFromFormat('M-Y', $month); + + $formattedDate = $date->format('Y-m'); + + $month=$formattedDate; + } + else{ + $month = date('Y-m'); + } + $data=[]; + $data['month']=$month; + $this->global['pageTitle']='Bag Stock Details'; - return $this->loadViews("bagStockDetails", $this->global, $data, NULL); + $startDate = "$month-01"; + $endDate = date("Y-m-t", strtotime($startDate)); + $data['bagStockDetails'] = $this->bagStockDetails_model + ->where('date >=', $startDate) + ->where('date <=', $endDate) + ->groupBy(['materialCode','date']) + ->orderBy('date','desc') + ->findAll(); + $date = DateTime::createFromFormat('Y-m', $month); + + $formattedDate = $date->format('M-Y'); + + $data['month']=$formattedDate; + + return $this->loadViews("bagStockDetails", $this->global, $data, NULL); } public function updateBagStockDetails(){} diff --git a/app/Views/bagStockDetails.php b/app/Views/bagStockDetails.php index cfde7953..7d09ddb5 100644 --- a/app/Views/bagStockDetails.php +++ b/app/Views/bagStockDetails.php @@ -195,12 +195,9 @@
- - - " class="form-control mt-2" data-provide="datepicker" data-date-format="M-yyyy" data-date-min-view-mode="1"> -
From 2a9204f6fd7ca312e2061a19c17c7fc11abc4d24 Mon Sep 17 00:00:00 2001 From: vadivel J Date: Mon, 4 Nov 2024 12:27:54 +0530 Subject: [PATCH 2/7] bag stock details view completed -vadivel J --- app/Controllers/StockController.php | 30 ++++++- app/Views/bagStockDetails.php | 122 ++++++++++++---------------- 2 files changed, 80 insertions(+), 72 deletions(-) diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 0728316c..31739345 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -285,9 +285,37 @@ class StockController extends BaseController ->where('date >=', $startDate) ->where('date <=', $endDate) ->groupBy(['materialCode','date']) - ->orderBy('date','desc') + ->orderBy('date','asc') + ->orderBy('materialCode','asc') ->findAll(); + // Initialize an empty array to hold the grouped data + $data['groupedBagStockDetails'] = []; + + // Temporary array to store grouped data by date + $groupedByDate = []; + + // Group by 'date' + foreach ($data['bagStockDetails'] as $detail) { + $date = $detail['date']; + + // Initialize the array for this date if it doesn't exist + if (!isset($groupedByDate[$date])) { + $groupedByDate[$date] = []; + } + + // Append the detail to the sub-array for this date + $groupedByDate[$date][] = $detail; + } + + // Reset the structure to have indexed arrays without the date keys + $data['groupedBagStockDetails'] = array_values($groupedByDate); + + $data['distinctMaterialCodes'] = $this->bagStockDetails_model + ->distinct() + ->select('materialCode') + ->findAll(); + $date = DateTime::createFromFormat('Y-m', $month); $formattedDate = $date->format('M-Y'); diff --git a/app/Views/bagStockDetails.php b/app/Views/bagStockDetails.php index 7d09ddb5..d95514c5 100644 --- a/app/Views/bagStockDetails.php +++ b/app/Views/bagStockDetails.php @@ -205,104 +205,84 @@
+ +
- +
- - - - - - + + $distinctMaterialCode){ ?> + + + + - + + $distinctMaterialCode){ ?> - - - + + + - - - - - - - - - - - - - - - - - - + + $distinctMaterialCode){ ?> + + + + + + + + + + - - - - - - - - - - + $bagStockDetails){ + ?> - - - - - - - - + + $bagStockDetail){ ?> + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - +
material material 1material 2material material
Customer Customer - + + -
Date Date material customerOpeningReceiptUsedBalance StockDate material customerOpeningReceiptUsedBalance StockDate OpeningReceiptUsedBalance Stock
23-10-202423-10-2024 material 1 customer 147211212-47223-10-2024 material 2 customer 247211212-472
24-10-202424-10-2024 material 1 customer 147211212-47224-10-2024 material 2 customer 247211212-472
From 96b90d6de7c4aa2fd9e31c6d279737875b8b90c1 Mon Sep 17 00:00:00 2001 From: vadivel J Date: Mon, 4 Nov 2024 16:44:20 +0530 Subject: [PATCH 3/7] gas stock module changes -vadivel J --- app/Controllers/StockController.php | 4 +- app/Views/bagStockDetails.php | 58 ++++++++++++++++++------- app/Views/incomingSilicaSandDetails.php | 12 ++++- 3 files changed, 57 insertions(+), 17 deletions(-) diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 31739345..15e24e05 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -325,7 +325,9 @@ class StockController extends BaseController return $this->loadViews("bagStockDetails", $this->global, $data, NULL); } - public function updateBagStockDetails(){} + public function updateBagStockDetails(){ + + } diff --git a/app/Views/bagStockDetails.php b/app/Views/bagStockDetails.php index d95514c5..f28e7b4f 100644 --- a/app/Views/bagStockDetails.php +++ b/app/Views/bagStockDetails.php @@ -245,7 +245,7 @@ Date material customer - Opening + Opening Stock Receipt Used Balance Stock @@ -260,23 +260,27 @@ $bagStockDetails){ + foreach($groupedBagStockDetails as $groupedBagStockDetailsIndex => $bagStockDetails){ ?> - $bagStockDetail){ ?> - - + + $bagStock){ ?> + + - - - - - + + + + - + oninput="openingStockChange(this)" + contenteditable="true"> + + + @@ -322,7 +326,7 @@ //table to json function - var updateBagStockDetails = tableToJSON(); + var updateBagStockDetails = tableToJson(); $('#loader').show(); $.ajax({ @@ -340,6 +344,16 @@ } + }, + error: function(xhr, status, error) { + + alert("An error occurred while processing the request. Please try again."); + console.error("Error Code:", xhr.status); + console.error("Error Message:", error); + console.error("Response Text:", xhr.responseText); + }, + complete: function() { + $('#loader').hide(); } }); @@ -385,4 +399,18 @@ console.log(tableToJson()); - \ No newline at end of file + + + + + diff --git a/app/Views/incomingSilicaSandDetails.php b/app/Views/incomingSilicaSandDetails.php index ec8a92c7..fc720e10 100644 --- a/app/Views/incomingSilicaSandDetails.php +++ b/app/Views/incomingSilicaSandDetails.php @@ -528,7 +528,17 @@ alert(data); - } + }, + error: function(xhr, status, error) { + + alert("An error occurred while processing the request. Please try again."); + console.error("Error Code:", xhr.status); + console.error("Error Message:", error); + console.error("Response Text:", xhr.responseText); + }, + complete: function() { + $('#loader').hide(); + } } }); From 088157dd4d2f8bf679d4c7f40c4fbb9355566ac1 Mon Sep 17 00:00:00 2001 From: vadivel J Date: Mon, 4 Nov 2024 17:46:42 +0530 Subject: [PATCH 4/7] calculation in gas stock --- app/Views/bagStockDetails.php | 61 ++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/app/Views/bagStockDetails.php b/app/Views/bagStockDetails.php index f28e7b4f..c0263e8e 100644 --- a/app/Views/bagStockDetails.php +++ b/app/Views/bagStockDetails.php @@ -273,11 +273,13 @@ - @@ -396,20 +398,63 @@ return JSON.stringify(rows, null, 2); } - console.log(tableToJson()); + + + From 439909fda00114810db98dfb2c54034041225d48 Mon Sep 17 00:00:00 2001 From: vadivel J Date: Tue, 5 Nov 2024 18:01:58 +0530 Subject: [PATCH 5/7] gas stock module changes --- app/Controllers/StockController.php | 42 +++++++ app/Views/bagStockDetails.php | 163 ++++++++++++++++++---------- 2 files changed, 150 insertions(+), 55 deletions(-) diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 15e24e05..8fa2cc56 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -326,6 +326,48 @@ class StockController extends BaseController } public function updateBagStockDetails(){ + + $postData = $this->request->getPost(); + + $updateBagStockDetailsData = json_decode($postData['updateBagStockDetails'], true); + + foreach($updateBagStockDetailsData as $data){ + + $date = $data['date']; + $materialCode = $data['materialCode']; + + + $dbData= [ + 'date' =>$data['date'], + 'materialCode' =>$data['materialCode'], + 'customer' =>$data['customer'], + 'opening' =>$data['opening'], + 'receipt' =>$data['receipt'], + 'used' =>$data['used'], + 'balanceStock' =>$data['balanceStock'], + ]; + + $resultExists=$this->bagStockDetails_model + ->where('date',$date) + ->where('materialCode',$materialCode) + ->first(); + + + if(!empty($resultExists)){ + + $updated=$this->bagStockDetails_model + ->where('date',$date) + ->where('materialCode',$materialCode) + ->set($dbData) + ->update(); + + }else{ + $inserted = $this->bagStockDetails_model->insert($dbData); + } + + } + + echo "Data Saved Successfully"; } diff --git a/app/Views/bagStockDetails.php b/app/Views/bagStockDetails.php index c0263e8e..45b4510d 100644 --- a/app/Views/bagStockDetails.php +++ b/app/Views/bagStockDetails.php @@ -267,22 +267,43 @@ $bagStock){ ?> - + + + - - + + + + + + - - - + + + + + + + - + contenteditable="true"> + + + + + + @@ -330,6 +351,8 @@ var updateBagStockDetails = tableToJson(); + alert('Updation may take a while, And we appreciate your patience..!!'); + $('#loader').show(); $.ajax({ data: { @@ -341,9 +364,8 @@ success: function (data) { if (data) { $('#loader').hide(); - + console.log(data); alert(data); - } }, @@ -382,7 +404,7 @@ for (let i = 1; i < rowCells.length; i += 7) { const rowData = { date: rowCells.eq(i).text().trim(), - material: rowCells.eq(i+1).text().trim(), + materialCode: rowCells.eq(i+1).text().trim(), customer: rowCells.eq(i+2).text().trim(), opening: rowCells.eq(i+3).text().trim(), receipt: rowCells.eq(i+4).text().trim(), @@ -404,58 +426,89 @@ + + - - From 4a28f03d1a0e534acfdced8f2c1462dec2e3747c Mon Sep 17 00:00:00 2001 From: vadivel J Date: Wed, 6 Nov 2024 13:03:10 +0530 Subject: [PATCH 6/7] changes in bag stock module - vadivel J --- app/Controllers/StockController.php | 37 +++++++++--- app/Models/Rawmaterialdetails_model.php | 14 +++++ app/Views/bagStockDetails.php | 79 +++++++++++++++++++++---- 3 files changed, 110 insertions(+), 20 deletions(-) diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 8fa2cc56..1a9278c8 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -28,6 +28,7 @@ class StockController extends BaseController protected $inwardGateRegister_model; protected $rawmaterialdetails_model; protected $bagStockDetails_model; + protected $Rawmaterialdetails_model; /** * This is default constructor of the class @@ -45,6 +46,7 @@ class StockController extends BaseController $this->incomingSilicaSandDetails_model = new IncomingSilicaSandDetailsModel(); $this->inwardGateRegister_model = new Inwardgateregister_model(); $this->bagStockDetails_model = new BagStockDetailsModel(); + $this->session = session(); helper('form'); @@ -285,7 +287,7 @@ class StockController extends BaseController ->where('date >=', $startDate) ->where('date <=', $endDate) ->groupBy(['materialCode','date']) - ->orderBy('date','asc') + ->orderBy('date','asc') ->orderBy('materialCode','asc') ->findAll(); @@ -311,18 +313,35 @@ class StockController extends BaseController // Reset the structure to have indexed arrays without the date keys $data['groupedBagStockDetails'] = array_values($groupedByDate); - $data['distinctMaterialCodes'] = $this->bagStockDetails_model - ->distinct() - ->select('materialCode') - ->findAll(); - $date = DateTime::createFromFormat('Y-m', $month); - $formattedDate = $date->format('M-Y'); + $bagMaterials= $this->rawmaterialdetails_model->getAllBagMaterialCode(); - $data['month']=$formattedDate; + + + foreach($bagMaterials as $key => $bagMaterial){ + $materialCode = $bagMaterial['MaterialCode']; + $bagMaterials[$key]['customers'] = $this->bagStockDetails_model + ->select('customer') + ->where('date >=', $startDate) + ->where('date <=', $endDate) + ->where('materialCode', $materialCode) + ->first()['customer'] ?? ''; + } + + $bagMaterialcount = count($bagMaterials); + + $data['bagMaterialcount'] = $bagMaterialcount; + $data['bagMaterials'] = $bagMaterials; + + $date = DateTime::createFromFormat('Y-m', $month); + + $formattedDate = $date->format('M-Y'); + + $data['month']=$formattedDate; + + return $this->loadViews("bagStockDetails", $this->global, $data, NULL); - return $this->loadViews("bagStockDetails", $this->global, $data, NULL); } public function updateBagStockDetails(){ diff --git a/app/Models/Rawmaterialdetails_model.php b/app/Models/Rawmaterialdetails_model.php index f5d792f3..45981afe 100755 --- a/app/Models/Rawmaterialdetails_model.php +++ b/app/Models/Rawmaterialdetails_model.php @@ -136,6 +136,20 @@ class Rawmaterialdetails_model extends Model return $materialCodes = array_column($materialResults, 'MaterialCode'); } + function getAllBagMaterialCode(){ + + $builder = $this->db->table('t_materialmaster') + ->select('MaterialCode , MaterialName') + ->where('IsActive', 1) + ->where('Category', 'bag') + ->orderBy('MaterialCode', 'asc'); + $query = $builder->get(); + $materialResults = $query->getResultArray(); + + return $materialResults; + + } + function getMaterialstock($MaterialCode, $currentdate) diff --git a/app/Views/bagStockDetails.php b/app/Views/bagStockDetails.php index 45b4510d..a8a10082 100644 --- a/app/Views/bagStockDetails.php +++ b/app/Views/bagStockDetails.php @@ -105,9 +105,10 @@ border: 1px solid #ccc; color: #ffffff; font-weight: bold; - padding: 2px 4px; + padding: 6px 10px;; text-align: center; } + ._Separador { background-color: #fff; @@ -124,6 +125,7 @@ .celda_normal { /*background-color: #fff;*/ /* */ + text-align: center; border: 1px solid #ccc; padding: 2px 4px; } @@ -216,19 +218,24 @@ material - $distinctMaterialCode){ ?> + + + - material + + + + Customer - $distinctMaterialCode){ ?> + - + @@ -236,11 +243,10 @@ - - + Date - $distinctMaterialCode){ ?> + Date material @@ -266,7 +272,7 @@ $bagStock){ ?> - + @@ -285,7 +291,10 @@ + + contenteditable="true" + + > - + + + format('m-Y'); + $startDate = "01-$month"; + + ?> + + + + + + + + + + + + + + + + + + 0 + + 0>0 + + 0 + + 0 + + + From 3eef21a4643badc62eeb73f40ac816054b79a2f8 Mon Sep 17 00:00:00 2001 From: vadivel J Date: Wed, 6 Nov 2024 17:18:47 +0530 Subject: [PATCH 7/7] bag stock changes -vadivel J --- app/Views/bagStockDetails.php | 203 +++++++++++++++++++++------------- 1 file changed, 129 insertions(+), 74 deletions(-) diff --git a/app/Views/bagStockDetails.php b/app/Views/bagStockDetails.php index a8a10082..ff8bd25c 100644 --- a/app/Views/bagStockDetails.php +++ b/app/Views/bagStockDetails.php @@ -271,10 +271,15 @@ + + $bagStock){ ?> + format('d-m-Y'); + ?> - + @@ -290,15 +295,19 @@ + oninput="openingStockChange(this)" contenteditable="true" + > + data-id=" " + oninput="receiptStockChange(this)" + contenteditable="true"> @@ -319,52 +328,83 @@ - + modify('first day of this month')->format('Y-m-d'); + $endDate = $date->modify('last day of this month')->format('Y-m-d'); + + $datesInMonth = []; + + + $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'); + } + + ?> + + $dateInMonth){ ?> + + $bagMaterial){ ?> + + + + format('d-m-Y'); + ?> + + + + - $date = DateTime::createFromFormat('M-Y', $month); - $month = $date->format('m-Y'); - $startDate = "01-$month"; + + + - ?> - + + + - - - - - - - - - - + + + - - - + + + oninput="openingStockChange(this)" + contenteditable="true" - 0 + + >0 - 0>0 + 0 - 0 + 0 - 0 - + 0 + + + @@ -400,13 +440,13 @@ $(document).ready(function () { - - + $('#saveId').click(function () { //table to json function var updateBagStockDetails = tableToJson(); + alert('Updation may take a while, And we appreciate your patience..!!'); @@ -441,7 +481,6 @@ }); - }); @@ -476,39 +515,57 @@ return JSON.stringify(rows, null, 2); } - - - - +