From 8c6f13975f496c5ba676ab4eebb35050d47cd1c8 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Mon, 7 Apr 2025 18:46:15 +0530 Subject: [PATCH 1/5] stock changes 07-04-2025 --- app/Controllers/Configurationctrl.php | 5 ++- app/Controllers/Rawmaterialdetails.php | 4 +- app/Models/Config_model.php | 28 +++++++++++--- app/Views/attendance.php | 35 ++++++----------- app/Views/configlisting.php | 6 +-- app/Views/editconfig.php | 53 +++++++++++++++++--------- app/Views/monthlypayinputs.php | 36 ++++++----------- 7 files changed, 91 insertions(+), 76 deletions(-) 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/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/Models/Config_model.php b/app/Models/Config_model.php index 32e0d7a4..9531473c 100755 --- a/app/Models/Config_model.php +++ b/app/Models/Config_model.php @@ -96,10 +96,24 @@ 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); + + $query = $builder->get(); return $query->getResult(); @@ -288,7 +302,7 @@ return $result; } - public function saveConfigValue($key,$configId, $configValue){ + public function saveConfigValue($key,$configId, $configValue,$userId){ @@ -297,7 +311,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 +323,7 @@ return $result; [ 'ConfigValue'=>$configValue, 'Config_ID'=>$configId, + 'created_by'=> $userId, 'isActive'=> 1]); $res = $this->db->affectedRows(); return $res; 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