diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 7070883c..a6c7e695 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -332,6 +332,7 @@ $routes->post('updateGasShortage','Inwardgateregister::updateGasShortage'); $routes->get('gasCylinderEntered','Inwardgateregister::gasCylinderEntered'); $routes->get('gasCylinderPending','Inwardgateregister::gasCylinderPending'); $routes->get('gasCylinderReturned','Inwardgateregister::gasCylinderReturned'); +$routes->post('gasCylindersByIgr','Inwardgateregister::gasCylindersByIgr'); $routes->post('getGasShortageDetail',"Inwardgateregister::getGasShortageDetail"); diff --git a/app/Controllers/Configurationctrl.php b/app/Controllers/Configurationctrl.php index 33b81260..0bcbc51c 100755 --- a/app/Controllers/Configurationctrl.php +++ b/app/Controllers/Configurationctrl.php @@ -107,6 +107,7 @@ class Configurationctrl extends BaseController $data['master'] = $this->configmodel->GetConfigCenterMaster($ConfigID); $data['child'] = $this->configmodel->GetConfigCenterDetails($ConfigID,$isActiveFilter); + $data['ConfigID'] = $ConfigID; $this->global['pageTitle'] = 'Edit Config'; @@ -252,8 +253,10 @@ class Configurationctrl extends BaseController $configId = $data['ConfigID']; $configValue = $data['ConfigValue']; $key = $data['key']??''; + $userId = $data['userId']; - $result = $this->configmodel->saveConfigValue($key,$configId, $configValue); + + $result = $this->configmodel->saveConfigValue($key,$configId, $configValue,$userId); if($result){ return $this->response->setJSON(['status'=>true]); diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index 7d50bf69..696df7f7 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -1696,6 +1696,26 @@ function updateIGRWeight(){ ]); } } + + public function gasCylindersByIgr(){ + + $IGRNO = $this->request->getPost('IGRNO'); + + $gasMaterialCodes = $this->rawMaterialDetails_model->getAllGasMaterialCode(); + + $gasMaterialCodes = array_column($gasMaterialCodes,'MaterialCode'); + + $cylinderDetails = $this->inwardgateregister_model->gasCylindersByIgr($IGRNO , $gasMaterialCodes); + + $response = [ + 'status' => 'success', + 'message' => 'Gas cylinders retrieved successfully.', + 'data' => $cylinderDetails + ]; + + return $this->response->setJSON($response); + + } /* ********************************************************* sec_gas_shortage_ends ************************************************************** diff --git a/app/Controllers/Rawmaterialdetails.php b/app/Controllers/Rawmaterialdetails.php index 990f37ef..e79e5a68 100755 --- a/app/Controllers/Rawmaterialdetails.php +++ b/app/Controllers/Rawmaterialdetails.php @@ -289,7 +289,7 @@ class Rawmaterialdetails extends BaseController $data['assetcode'] = $this->rawmaterialdetails_model->getAssetcode(); $data['avg_price'] = $this->rawmaterialdetails_model->getMaterialAvg($RawMaterialID); $data['materialRateHistory'] = $this->rawmaterialdetails_model->getMaterialRateHistory($RawMaterialID); - $data['materialListPage'] = $_GET['page']; + $data['materialListPage'] = $_GET['page']??1; //print_r($data['avg_price']);die(); $this->global['pageTitle'] = 'Edit Material Master'; @@ -318,7 +318,7 @@ class Rawmaterialdetails extends BaseController $stock = $this->request->getPost('openstock'); $reorder = $this->request->getPost('reorder'); $stockdate = $this->request->getPost('Date'); - $materialListPage = $this->request->getPost('materialListPage'); + $materialListPage = $this->request->getPost('materialListPage') ?? 1; $stockdate = (empty($stockdate)) ? NULL : get_date_time_dynamical_format('d-m-Y','Y-m-d',"$stockdate"); $chked = $this->request->getPost('isactive'); diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 8d423624..5edbd472 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -1344,21 +1344,6 @@ class StockController extends BaseController 'machine_category' => "diesel", 'machine_id' => $customisedMachineCode ]; - - - //checking filtered material code present in table , if not create dummy one for whole month - $findMachineCode = $this->factoryVehicleDieselDetails_model - ->where('date >=', $startDate) - ->where('date <=', $endDate) - ->where('machine_id',$customisedMachineCode) - ->findAll(); - - //check any material code is not present in stock table but applied in filter - if(empty($findMachineCode)){ - - //create dummy entry for this - $this->createDummyEntryForDieselMachine($customisedMachineCode,$startDate,$endDate); - } } @@ -1396,6 +1381,24 @@ class StockController extends BaseController $machineCodeList = array_column($existingCustomMachineCodes, 'id'); + foreach($machineCodeList as $index => $machineCode){ + + //checking filtered present in table , if not create dummy one for whole month + $findMachineCode = $this->factoryVehicleDieselDetails_model + ->where('date >=', $startDate) + ->where('date <=', $endDate) + ->where('machine_id',$machineCode) + ->findAll(); + + + //check any material code is not present in stock table but applied in filter + if(empty($findMachineCode)){ + //create dummy entry for this + $this->createDummyEntryForDieselMachine($machineCode,$startDate,$endDate); + } + + } + $dieselMachines = $existingCustomMachineCodes; $data['activeDieselMachines'] = $this->factoryMachine_model->getAllActiveDieselMachines(); @@ -1761,23 +1764,6 @@ class StockController extends BaseController 'machine_category' => "electric", 'machine_id' => $customisedMachineCode ]; - - - //checking filtered material code present in table , if not create dummy one for whole month - $findMachineCode = $this->powerConsumptionDetails_model - ->where('date >=', $startDate) - ->where('date <=', $endDate) - ->where('machine_id',$customisedMachineCode) - ->findAll(); - - - //check any material code is not present in stock table but applied in filter - if(empty($findMachineCode)){ - - - //create dummy entry for this - $this->createDummyEntryForElectricMachine($customisedMachineCode,$startDate,$endDate); - } } @@ -1811,9 +1797,28 @@ class StockController extends BaseController + //this existingCustomMachineCodes gets its machine after visiting factory machine master table $machineCodeList = array_column($existingCustomMachineCodes, 'id'); + foreach($machineCodeList as $index => $machineCode){ + + //checking filtered material code present in table , if not create dummy one for whole month + $findMachineCode = $this->powerConsumptionDetails_model + ->where('date >=', $startDate) + ->where('date <=', $endDate) + ->where('machine_id',$machineCode) + ->findAll(); + + + //check any material code is not present in stock table but applied in filter + if(empty($findMachineCode)){ + //create dummy entry for this + $this->createDummyEntryForElectricMachine($machineCode,$startDate,$endDate); + } + + } + $electricMachines = $existingCustomMachineCodes; $data['activeElectricMachines'] = $this->factoryMachine_model->getAllActiveElectricMachines(); @@ -2284,19 +2289,6 @@ class StockController extends BaseController 'stock_category' => "resin", 'materialCode' => $customisedMaterialCode ]; - - //checking filtered material code present in table , if not create dummy one for whole month - $findMaterialCode = $this->resinStockDetails_model - ->where('date >=', $startDate) - ->where('date <=', $endDate) - ->where('materialCode',$customisedMaterialCode) - ->findAll(); - - //check any material code is not present in stock table but applied in filter - if(empty($findMaterialCode)){ - //create dummy entry for that - $this->createDummyEntryForResin($customisedMaterialCode,$startDate,$endDate); - } } @@ -2329,6 +2321,25 @@ class StockController extends BaseController $materialCodeList = array_column($existingCustomMaterialCodes, 'MaterialCode'); + foreach($materialCodeList as $index => $materialCode){ + + + //checking filtered material code present in table , if not create dummy one for whole month + $findMachineCode = $this->resinStockDetails_model + ->where('date >=', $startDate) + ->where('date <=', $endDate) + ->where('materialCode',$materialCode) + ->findAll(); + + + //check any material code is not present in stock table but applied in filter + if(empty($findMachineCode)){ + //create dummy entry for this + $this->createDummyEntryForResin($materialCode,$startDate,$endDate); + } + + } + $resinMaterials = $existingCustomMaterialCodes ; $data['activeResinMaterials'] = $this->rawmaterialdetails_model->getAllResinMaterialCode(); @@ -2663,19 +2674,6 @@ class StockController extends BaseController 'stock_category' => "packing_material", 'materialCode' => $customisedMaterialCode ]; - - //checking filtered material code present in table , if not create dummy one for whole month - $findMaterialCode = $this->bagStockDetails_model - ->where('date >=', $startDate) - ->where('date <=', $endDate) - ->where('materialCode',$customisedMaterialCode) - ->findAll(); - - //check any material code is not present in stock table but applied in filter - if(empty($findMaterialCode)){ - //create dummy entry for that - $this->createDummyEntryForBag($customisedMaterialCode,$startDate,$endDate); - } } @@ -2701,7 +2699,7 @@ class StockController extends BaseController $existingCustomMaterialCodes = $this->rawmaterialdetails_model ->getAllBagMaterialCode(); }else{ - //if filter present,get that material codes + //if filter present,get that material codes $existingCustomMaterialCodes = $this->rawmaterialdetails_model ->getSelectedBagMaterialCode(array_column($existingCustomMaterialCodes, 'materialCode')); } @@ -2709,6 +2707,25 @@ class StockController extends BaseController $materialCodeList = array_column($existingCustomMaterialCodes, 'MaterialCode'); + foreach($materialCodeList as $index => $materialCode){ + + + //checking filtered material code present in table , if not create dummy one for whole month + $findMachineCode = $this->bagStockDetails_model + ->where('date >=', $startDate) + ->where('date <=', $endDate) + ->where('materialCode',$materialCode) + ->findAll(); + + + //check any material code is not present in stock table but applied in filter + if(empty($findMachineCode)){ + //create dummy entry for this + $this->createDummyEntryForBag($materialCode,$startDate,$endDate); + } + + } + $bagMaterials = $existingCustomMaterialCodes ; $data['activeBagMaterials'] = $this->rawmaterialdetails_model->getAllBagMaterialCode(); diff --git a/app/Models/Config_model.php b/app/Models/Config_model.php index 32e0d7a4..cd16446c 100755 --- a/app/Models/Config_model.php +++ b/app/Models/Config_model.php @@ -96,10 +96,25 @@ class Config_model extends Model { //echo $ConfigID ;die(); $builder = $this->db->table('t_configmaster COM') - ->select('*') - ->join('t_configdetails con', 'con.Config_ID = COM.Config_ID', 'left') - ->where('COM.Config_ID', $ConfigID) - ->where('con.isActive', $isActiveFilter); + ->select('COM.*, + con.*, + creator_emp.FirstName AS created_by, + updater_emp.FirstName AS updated_by + ') + ->join('t_configdetails con', 'con.Config_ID = COM.Config_ID', 'left') + + // Join for Created By + ->join('tbl_users creator', 'creator.userId = con.created_by', 'left') + ->join('t_employee_details creator_emp', 'creator_emp.EmpID = creator.EmpID', 'left') + // Join for Updated By + ->join('tbl_users updater', 'updater.userId = con.updated_by', 'left') + ->join('t_employee_details updater_emp', 'updater_emp.EmpID = updater.EmpID', 'left') + + ->where('COM.Config_ID', $ConfigID) + ->where('con.isActive', $isActiveFilter) + ->orderBy('con.Key', 'desc'); + + $query = $builder->get(); return $query->getResult(); @@ -288,7 +303,7 @@ return $result; } - public function saveConfigValue($key,$configId, $configValue){ + public function saveConfigValue($key,$configId, $configValue,$userId){ @@ -297,7 +312,8 @@ return $result; ->where('Config_ID', $configId) ->where('key',$key) ->update([ - 'ConfigValue'=> $configValue + 'ConfigValue'=> $configValue, + 'updated_by' => $userId ]); $res = $this->db->affectedRows(); return $res; @@ -308,6 +324,7 @@ return $result; [ 'ConfigValue'=>$configValue, 'Config_ID'=>$configId, + 'created_by'=> $userId, 'isActive'=> 1]); $res = $this->db->affectedRows(); return $res; diff --git a/app/Models/Inwardgateregister_model.php b/app/Models/Inwardgateregister_model.php index c162bb3a..a7983aa8 100755 --- a/app/Models/Inwardgateregister_model.php +++ b/app/Models/Inwardgateregister_model.php @@ -1515,4 +1515,41 @@ class Inwardgateregister_model extends Model return $result; } + + public function gasCylindersByIgr($IGRNO, $gasMaterialCodes) { + + $builder = $this->db->table('t_igr_master as t_igrm') + ->select(" + t_igrm.IGRNO, + tgsd.fullCylinderDate, + tgsd.cylinderNo, + tgsd.grossWeight, + tgsd.emptyCylinderDate, + tgsd.tareWeight, + tgsd.netWeight, + tgsd.actualWeight, + tgsd.shortage, + tgsd.invoiceNo, + t_igrm.DeliveryChellanDate, + t_igrm.DriverName, + t_igrm.VehicleNo + + ") + + ->join('t_igr_details tigrd', 'tigrd.IGRNO = t_igrm.IGRNO') + ->join('t_purchaseorder_master tpom', 'tpom.PONO = t_igrm.PONO', 'left') + ->join('t_supplierdetailsn tsd', 'tsd.SupplierID = tpom.SupplierID') + ->join('t_gasshortagedetails tgsd', 'tgsd.IGRNO = t_igrm.IGRNO', 'left') + + ->whereIn('tigrd.MaterialCode', $gasMaterialCodes) + ->where("DATE(tigrd.CreatedDate) >= '2025-04-01'") + ->where('tgsd.gas_cylinder_status', 'gas_returned') + ->where('t_igrm.IGRNO', $IGRNO); // Direct where clause on IGRNO in master table + + $result = $builder->get()->getResultArray(); + + return $result; + } + + } diff --git a/app/Views/attendance.php b/app/Views/attendance.php index 8d32e346..f476585e 100755 --- a/app/Views/attendance.php +++ b/app/Views/attendance.php @@ -256,16 +256,19 @@ $currentday = date('d');
- + - + - + - +
@@ -633,7 +636,6 @@ $currentday = date('d'); }); - @@ -148,14 +148,14 @@
-
- -
+
+ +
@@ -171,30 +171,30 @@
-
- - - + - - + + - - - - - -
-
-
+ + + + + + + + +
+ +
@@ -203,76 +203,92 @@ - - + + - + - + - - + + + - + + - -

No Gas Cylinder Returned in the Given Dates..!!

- + +

No Gas Cylinder Returned in the Given Dates..!!

+ - $gasCylinder): - $gasCylinder['MaterialRcvdDate'] = date('d-m-Y',strtotime($gasCylinder['MaterialRcvdDate'])); - $gasCylinder['DeliveryChellanDate'] = date('d-m-Y',strtotime($gasCylinder['DeliveryChellanDate'])); - $gasCylinder['emptyCylinderDate'] = date('d-m-Y',strtotime($gasCylinder['emptyCylinderDate'])); - ?> + $gasCylinder): + $gasCylinder['MaterialRcvdDate'] = date('d-m-Y', strtotime($gasCylinder['MaterialRcvdDate'])); + $gasCylinder['DeliveryChellanDate'] = date('d-m-Y', strtotime($gasCylinder['DeliveryChellanDate'])); + $gasCylinder['emptyCylinderDate'] = date('d-m-Y', strtotime($gasCylinder['emptyCylinderDate'])); + ?> - - - - - - - - - - - - - - - - - + - + + + + + + - - - - + + + + + + + + + - - - - - + + + + + + + + + + + + +
Full Cylinder DateFull Cylinder Date IGR NoSupplierSupplier Bill/Invoice No Cylinder Name Gross Weight Empty Cylinder DateTare WeightNet WeightTare WeightNet Weight Actual Weight ShortageCylinder Count Cylinder Pending Bill Date Driver Name Vehicle NoDownload
+ +
+
+ +
+
@@ -304,31 +320,41 @@ console.log("Received date string:", dateString); // Split the date string into date and time components - var dateTimeParts = dateString.split(' '); - var dateParts = dateTimeParts[0].split('-'); - var timeParts = dateTimeParts[1].split(':'); + var dateTimeParts = dateString?.split(' '); + var dateParts = dateTimeParts[0]?.split('-'); + var timeParts = dateTimeParts[1]?.split(':'); // Extract individual components var year = parseInt(dateParts[0], 10); var month = parseInt(dateParts[1], 10) - 1; // Months are zero-based in JavaScript var day = parseInt(dateParts[2], 10); - var hours = parseInt(timeParts[0], 10); - var minutes = parseInt(timeParts[1], 10); - var seconds = parseInt(timeParts[2], 10); + var hours = 0; + var minutes = 0; + var seconds = 0; + + + if(timeParts){ + // Extract time components + hours = parseInt(timeParts[0], 10); + minutes = parseInt(timeParts[1], 10); + seconds = parseInt(timeParts[2], 10); + } + // Create a new Date object var date = new Date(year, month, day, hours, minutes, seconds); // Extract date components - var day = date.getDate().toString().padStart(2, '0'); - var month = (date.getMonth() + 1).toString().padStart(2, '0'); // Months are zero-based - var year = date.getFullYear(); + day = date.getDate().toString().padStart(2, '0'); + month = (date.getMonth() + 1).toString().padStart(2, '0'); // Months are zero-based + year = date.getFullYear(); // Extract time components - var hours = date.getHours().toString().padStart(2, '0'); - var minutes = date.getMinutes().toString().padStart(2, '0'); - var seconds = date.getSeconds().toString().padStart(2, '0'); + hours = date.getHours().toString().padStart(2, '0'); + minutes = date.getMinutes().toString().padStart(2, '0'); + seconds = date.getSeconds().toString().padStart(2, '0'); + var formattedDate = ''; // Format the date and time in DD-MM-YYYY HH:MM:SS format if (flag == 1) { @@ -355,9 +381,8 @@ + let fromDateObj = new Date(fromDate.split('-').reverse().join('-')); + let toDateObj = new Date(toDate.split('-').reverse().join('-')); + if (fromDateObj > toDateObj) { + alert('Incorrect Date Applied For Filter..!!'); + $('#toDate').attr('min', fromDate); + $('#toDate').val(''); - - - - - - - - - - - - - - - + if (cylinderPendingCount > 0) { + alert("Please clear the " + cylinderPendingCount + " pending cylinders before downloading the Excel file."); + return false; + } + $("#loader").show(); + $.ajax({ + type: "POST", + url: "gasCylindersByIgr", + data: { + IGRNO: igrNo + }, + success: function(response) { + $("#loader").hide(); + if (response.status === "success") { + console.log(response.data); // Debugging - Check if data is correct + + let tableHTML = ` + + + + + + + + + + + + + + + + + + + + + `; + + let totalShortage = 0; + let totalNetWeight = 0; + let totalActualWeight = 0; + + response.data.forEach(item => { + + totalShortage += Number(item.shortage); + + totalNetWeight += Number(item.netWeight); + + totalActualWeight += Number(item.actualWeight); + + item.fullCylinderDate = formatDateTime(item.fullCylinderDate, 1); + item.emptyCylinderDate = formatDateTime(item.emptyCylinderDate, 1); + item.DeliveryChellanDate = formatDateTime(item.DeliveryChellanDate, 1); + + tableHTML += ` + + + + + + + + + + + + + + + + + + `; + }); + + tableHTML += ` + + + + + + + + + + + + + + + + + + + + + +
IGRNOFull Cylinder DateCylinder NoGross WeightEmpty Cylinder Return DateTare WeightNet WeightActual WeightShortageBill NoBill DateDriver NameVehicle No
${item.IGRNO}${item.fullCylinderDate}${item.cylinderNo}${item.grossWeight}${item.emptyCylinderDate}${item.tareWeight}${item.netWeight}${item.actualWeight}${item.shortage}${item.invoiceNo}${item.DeliveryChellanDate}${item.DriverName}${item.VehicleNo}
 
Weight${totalNetWeight}${totalActualWeight}${totalShortage}
+ `; + + $("#excelTableDiv").html(tableHTML); + + let table = document.getElementById('excelTable'); + + let filename = "GasCylinderReturned_" + igrNo + ".xlsx"; + + let rows = []; + + // Extract table data row-by-row + $(table).find('tr').each(function(rowIndex) { + let rowData = []; + + $(this).find('th, td').each(function(colIndex) { + // Skip hidden columns + if ($(this).css('display') === 'none') return; + let cellText = $(this).text().trim(); + rowData.push(cellText); + }); + + // Add the cleaned row only if it has data + if (rowData.length > 0) { + rows.push(rowData); + } + }); + + // Create a worksheet from array (no DOM needed!) + let ws = XLSX.utils.aoa_to_sheet(rows); + + // Define column widths (in character units) + const columnWidth = 15; // Set your desired width here + const wscols = []; + for (let i = 0; i < Object.keys(response.data[0]).length; i++) { + wscols.push({ + wch: columnWidth + }); + } + ws['!cols'] = wscols; + + let wb = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(wb, ws, 'Sheet1'); + XLSX.writeFile(wb, filename || 'export.xlsx'); + } + }, + + error: function(xhr, status, error) { + console.log(xhr.responseText); + alert("Something went wrong! Please try again."); + }, + complete: function() { + console.log("AJAX request completed."); + $("#loader").hide(); // Hide loader + } + }); + } + \ No newline at end of file diff --git a/app/Views/monthlypayinputs.php b/app/Views/monthlypayinputs.php index cc6704ee..620a5413 100755 --- a/app/Views/monthlypayinputs.php +++ b/app/Views/monthlypayinputs.php @@ -198,7 +198,9 @@
- + " @@ -208,11 +210,11 @@ - + - + - +
@@ -776,7 +778,7 @@ - +