From cc39f48ae54eebfa7f2450c0c77d2b51934392e8 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Sat, 15 Feb 2025 15:52:51 +0530 Subject: [PATCH 01/26] stock module latest today vadivel J 15-02-2025 --- app/Models/TrpProductionModel.php | 18 ++++++++++++------ app/Views/stock/trpProductionStockDetails.php | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/Models/TrpProductionModel.php b/app/Models/TrpProductionModel.php index 3b854187..e9d85b5d 100644 --- a/app/Models/TrpProductionModel.php +++ b/app/Models/TrpProductionModel.php @@ -54,18 +54,19 @@ class TrpProductionModel extends Model public function trpProductionDetails($startDate,$endDate){ + $data =[]; - - - + // Subquery definition $subquery = $this->db->table('t_materialmaster') ->select('materialCode') - ->where('Category', 'waste core') + ->where('Category = 328') ->get() ->getResultArray(); $materialCodes = array_column($subquery, 'materialCode'); // Extracts 'materialCode' values + + // dd($this->db->getLastQuery()); // Convert the array of material codes to a comma-separated string // $materialCodesString = "'" . implode("','", $materialCodes) . "'"; @@ -185,7 +186,7 @@ class TrpProductionModel extends Model $subquery3 = $this->db->table('ip_invoice_items invItems') ->select([ - 'invItems.*', + 'invItems.item_date_added', $caseSQL ]) ->join('ip_invoices inv', 'inv.invoice_id = invItems.invoice_id', 'left') @@ -205,6 +206,7 @@ class TrpProductionModel extends Model + $materialCodes = ! empty($materialCodes) ? $materialCodes : [''] ; // Subquery: Waste Core Sand Suppliers $subquery4 = $this->db->table('t_igr_details tigrd') @@ -221,7 +223,7 @@ class TrpProductionModel extends Model ->join('t_igr_master tigm', 'tigm.IGRNo = tigrd.IGRNo', 'left') ->join('t_purchaseorder_master tpom', 'tpom.PONO = tigm.PONO', 'left') ->join('t_supplierdetailsn ts', 'tpom.SupplierID = ts.SupplierID', 'left') - ->whereIn('tigrd.MaterialCode', $materialCodes) // FIXED: Now correctly formatted + ->whereIn('tigrd.MaterialCode', $materialCodes) ->where('tigrd.CreatedDate >=', $startDate) ->where('tigrd.CreatedDate <=', $endDate) ->groupBy('DATE(tigrd.CreatedDate)') @@ -237,9 +239,13 @@ class TrpProductionModel extends Model $builder->where('tpmd.date >=', $startDate); $builder->where('tpmd.date <=', $endDate); + + // Order by date $builder->orderBy('tpmd.date', 'ASC'); + + // Execute the query $query = $builder->get(); $result = $query->getResultArray(); diff --git a/app/Views/stock/trpProductionStockDetails.php b/app/Views/stock/trpProductionStockDetails.php index 73604cba..31f5cc6f 100644 --- a/app/Views/stock/trpProductionStockDetails.php +++ b/app/Views/stock/trpProductionStockDetails.php @@ -485,8 +485,8 @@ $timeOtions[] = "12:00 AM"; From 255aba3cb3cb87cdcd3833dd4229702a92ea84e1 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Sat, 15 Feb 2025 18:02:36 +0530 Subject: [PATCH 02/26] stock module latest today vadivel J 15-02-2025 --- app/Models/TrpProductionModel.php | 12 ++++++++---- app/Views/stock/trpProductionStockDetails.php | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Models/TrpProductionModel.php b/app/Models/TrpProductionModel.php index e9d85b5d..8cf96e23 100644 --- a/app/Models/TrpProductionModel.php +++ b/app/Models/TrpProductionModel.php @@ -151,6 +151,8 @@ class TrpProductionModel extends Model $builder->join("({$subquery2}) tdmd", 'tdmd.date = tpmd.date', 'left'); + + // Subquery: Core Sand Reclaimed by Clients $crsClientList = $this->db->table('ip_clients clients') @@ -164,7 +166,7 @@ class TrpProductionModel extends Model ->get() ->getResultArray(); - if(!empty($crsClientList)){ + $crsClientList = array_column($crsClientList, 'client_name'); // Initialize an empty array for dynamic SQL conditions @@ -202,11 +204,13 @@ class TrpProductionModel extends Model $builder->join("({$subquery3}) invItems", 'invItems.item_date_added = tpmd.date', 'left'); - } + + + - - $materialCodes = ! empty($materialCodes) ? $materialCodes : [''] ; + $materialCodes = ! empty($materialCodes) ? $materialCodes : ['600374','600422','600434']; + // Subquery: Waste Core Sand Suppliers $subquery4 = $this->db->table('t_igr_details tigrd') diff --git a/app/Views/stock/trpProductionStockDetails.php b/app/Views/stock/trpProductionStockDetails.php index 31f5cc6f..9c863f62 100644 --- a/app/Views/stock/trpProductionStockDetails.php +++ b/app/Views/stock/trpProductionStockDetails.php @@ -485,7 +485,7 @@ $timeOtions[] = "12:00 AM"; From 860646c758c692a5ba6471021df2e3023f9209a4 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 15 Feb 2025 12:41:55 +0000 Subject: [PATCH 03/26] Issues fixes : ps --- app/Controllers/Inwardgateregister.php | 262 ++++++++---------------- app/Controllers/Rawmaterialdetails.php | 4 +- app/Models/Inwardgateregister_model.php | 43 ++-- app/Models/Rawmaterialdetails_model.php | 3 +- app/Views/addRawMaterial.php | 3 +- app/Views/configlisting.php | 4 +- app/Views/editRawmaterial.php | 4 +- app/Views/viewinwardgateregister.php | 23 ++- 8 files changed, 137 insertions(+), 209 deletions(-) diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index 8e48dd03..9a338ea4 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -830,19 +830,12 @@ function viewIGRDetails() } } - log_message('error', 'UpdateIGR igrarr: ' . json_encode($igrarr)); + $this->saveIGRMasterHistory($igrarr,$IGRNo); $getigrstatus = $this->inwardgateregister_model->getigrstatus($IGRNo); $getigrstatus = $getigrstatus->IGRStatus; $updateigrmaster = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo); log_message('error', "Master updated successfully: " . $updateigrmaster); if(!empty($tableData )){ - #Save IGR Master On History Table - foreach ($igrarr as $key => $value) { - if (!empty($value)) { // Ensure the value is not empty - $hist = array( 'key' => $key, 'value' => $value, 'igr_no' => $IGRNo,'igr_item_no' => NULL); - $this->saveIGRHistory($hist); - } - } foreach ($tableData as $row) { $quantityAsPerInvoice = $row['QuantityAsPerInvoice']; @@ -867,6 +860,7 @@ function viewIGRDetails() 'IGRItemNo' => $igrItemNo, 'UpdateBY' => $updateby ); + $this->saveIGRLineitemHistory($igrline, $IGRNo,$igrItemNo); // $WeightFile = $this->request->getfile('WeightFile'); // $requestWeightFileName = $WeightFile->getName(); @@ -883,24 +877,6 @@ function viewIGRDetails() // } $updateigrlineitem = $this->inwardgateregister_model->updateIGRLineItem($igrline, $igrItemNo); - if($updateigrlineitem){ - foreach ($igrline as $key => $value) { - if (!empty($value)) { // Ensure the value is not empty - if($key == 'IGRNO'){ $key = 'LineItemIGRNO'; } - - $hist = array( 'key' => $key, 'value' => $value, 'igr_no' => $IGRNo,'igr_item_no' => NULL); - $this->saveIGRHistory($hist); - } - } - } - if($grossWeight){ - $hist = array('key' => 'GrossWeight', 'value' => $grossWeight, 'igr_no' => $IGRNo, 'igr_item_no' => $igrItemNo); - $this->saveIGRHistory($hist); - } - if($grossWeight){ - $hist = array('key' => 'GrossWeight', 'value' => $grossWeight, 'igr_no' => $IGRNo, 'igr_item_no' => $igrItemNo); - $this->saveIGRHistory($hist); - } log_message('error', "lineitem updated successfully: " . $updateigrlineitem); log_message('error', 'UpdateIGR updateigrlineitem: ' . json_encode($igrline)); } @@ -913,30 +889,15 @@ function viewIGRDetails() $result_for_email = $this->inwardgateregister_model->getDetailsforEmail($this->session->get('userId')); $result_for_history = $this->inwardgateregister_model->getHistoryDetailsforEmail($IGRNo); - print_r($result_for_history);die; + $notification = new Notification(); - $history_content = NULL; - $history = $result_for_history; + $history_content = "IGR History


"; + $history = $result_for_history['history']; $field_labels = [ - "IGRItemNo" => "IGRItemNo", "IGRNO" => "IGRNO", - "MaterialCode" => "MaterialCode", - "QuantityAsPerInvoice" => "Received Qty", - "Remarks" => "Remarks", - "IGRItemStatus" => "IGRItemStatus", - "CancelNote" => "CancelNote", - "BankStatus" => "BankStatus", - "GrossWeight" => "Gross Weight", - "GrossWeightDate" => "Gross Weight Date", - "TareWeight" => "Tare Weight", - "TareWeightDate" => "Tare Weight Date", - "NetWeight" => "Net Weight", - "WeightFile" => "WeightFile", - "IGRID" => "IGRID", - "IGRNO" => "IGRNO", - "PONO" => "PONO", + "PONO" => "PONO", "DeliveryChellanOrInvoiceNo" => "Invoice NO", "DeliveryChellanDate" => "Invoice Date", "MaterialRcvdDate" => "Material Received Date", @@ -951,26 +912,40 @@ function viewIGRDetails() "DriverName" => "Driver Name", "DriverMobileNumber" => "Driver Mobile Number", "MasterFile" => "Master File", + "IGRItemNo" => "IGR Item No", + "MaterialCode" => "Material Code", + "QuantityAsPerInvoice" => "Received Qty", + "Remarks" => "Remarks", + "IGRItemStatus" => "IGR Item Status", + "CancelNote" => "Cancel Note", + "BankStatus" => "Bank Status", + "GrossWeight" => "Gross Weight", + "GrossWeightDate" => "Gross Weight Date", + "TareWeight" => "Tare Weight", + "TareWeightDate" => "Tare Weight Date", + "NetWeight" => "Net Weight", + "WeightFile" => "Weight File" ]; - $history_content = "
The following values have been edited:"; + // $history_content = "
The following values have been edited:"; for ($j = 0; $j < count($history); $j++) { $field_name = $history[$j]->field; $readable_field = isset($field_labels[$field_name]) ? $field_labels[$field_name] : $field_name; - - $history_content .= "
" . $readable_field . ": `" . $history[$j]->old_data . "` was updated to `" . $history[$j]->new_data . "` ."; + $history_content .= "
" . $readable_field . " `" . $history[$j]->old_data . "` was updated into `" . $history[$j]->new_data . "` by ".$history[$j]->history_by." on ".$history[$j]->indian_date." at ".$history[$j]->indian_time; + // $history_content .= "
" . $readable_field . ": `" . $history[$j]->old_data . "` was updated to `" . $history[$j]->new_data . "` ."; } $email = ""; for ($i = 0; $i < count($result_for_email['emails']); $i++) { $email .= $result_for_email['emails'][$i]->email . " , "; } $email = rtrim($email, " ,"); - + $email_response = $notification->sendEmail([ 'recipient_email' => $email, 'subject' => $result_for_email['company'].' - IGR Notification', - 'description' => 'IGR Number : '.$IGRNo.' is Edited By '.($result_for_email['full_name'] ?? $this->session->get('name'))." On ".date('d-m-Y H:i A', strtotime(get_current_date_time() . ' +30 seconds')). $history_content, + // 'description' => 'IGR Number : '.$IGRNo.' is Edited By '.($result_for_email['full_name'] ?? $this->session->get('name'))." On ".date('d-m-Y H:i A', strtotime(get_current_date_time() . ' +30 seconds')). $history_content, + 'description' => 'PONO '.$PONo.$result_for_history['first_line'].$history_content, 'company' => $result_for_email['company'], 'from_mail'=> $result_for_email['from_mail'] ]); @@ -1029,13 +1004,8 @@ function updateIGRWeight(){ $IGRItemNo = $this->request->getPost('IGRlineitem'); $igr_lineitem = array('GrossWeight' => $GrossWeight,'GrossWeightDate' => $GrossWtDt,'TareWeightDate' => $TareWtDt,'TareWeight' => $TareWeight,'NetWeight' => $NetWeight,'UpdateBY' => $updateby); + $this->saveIGRLineitemHistory($igr_lineitem, $IGRNO,$IGRItemNo); - foreach ($igr_lineitem as $key => $value) { - if (!empty($value)) { // Ensure the value is not empty - $hist = array( 'key' => $key, 'value' => $value, 'igr_no' => $IGRNO,'igr_item_no' => $IGRItemNo); - $this->saveIGRHistory($hist); - } - } $requestWeightFileName =null ; if($WeightFile){ if (!empty($requestWeightFileName)) { @@ -1422,134 +1392,70 @@ function updateIGRWeight(){ } + public function saveIGRMasterHistory($request, $IGRNo) { + $dbIGRMaster = $this->inwardgateregister_model->get_igr_master_for_history($IGRNo); + $history_entries = []; - // public function saveIGRHistory($hist) { - - // // Extract fields from the input array - // $field = $hist['key']; - - // $igr_no = $hist['igr_no']; - // $igr_item_no = $hist['igr_item_no']; - // $new_data = $hist['value']; // Incoming new value - // $old_data = NULL; // Default old value is null - - // log_message('error', "Save History function entered for IGR No: $igr_no, Item No: $igr_item_no, Field: $field."); - - // $latestHist = $this->inwardgateregister_model->get_igr_history($field, $igr_no, $igr_item_no); - // $latestIGRMasterForHist = $this->inwardgateregister_model->get_igr_master_for_history($field, $igr_no); // it have value - // $latestIGRChildForHist = $this->inwardgateregister_model->get_igr_child_for_history($field, $igr_no, $igr_item_no); - - // if(empty($igr_item_no)){ - // if(!empty($latestIGRMasterForHist)){ - // if (!empty($latestHist)) { - // if ($latestHist->new_data == $new_data) { - // log_message('error', "No update needed for IGR No: $igr_no, Item No: $igr_item_no, Field: $field. Data already exists: $new_data"); - // return; - // } else { - // $old_data = $latestHist->new_data; - // } - // }else{ - // $old_data = $latestIGRMasterForHist; - // } - // }} - - // if(!empty($igr_item_no)){ - // if(!empty($latestIGRChildForHist)){ - // if (!empty($latestHist)) { - // if ($latestHist->new_data == $new_data) { - // log_message('error', "No update needed for IGR No: $igr_no, Item No: $igr_item_no, Field: $field. Data already exists: $new_data"); - // return; - // } else { - // $old_data = $latestHist->new_data; - // } - // }else{ - // $old_data = $latestIGRChildForHist; - // } - // }} - - - - // // Prepare history entry - // $igr_history = [ - // 'field' => $field, - // 'new_data' => $new_data, - // 'old_data' => $old_data, - // 'history_dated' => get_current_date_time(), - // 'by' => $this->session->get('userId'), - // 'IGR_No' => $igr_no, - // 'IGRItem_No' => $igr_item_no, - // 'is_edit' => ($old_data !== NULL) ? 1 : 0, - // 'is_add' => ($old_data === NULL) ? 1 : 0 - // ]; - - // // Insert history entry - // $history_id = $this->inwardgateregister_model->igr_history($igr_history); - // if ($history_id) { - // log_message('error', "History updated successfully for IGR No: $igr_no, Item No: $igr_item_no, Field: $field. History ID: $history_id"); - // } else { - // log_message('error', "Failed to update history for IGR No: $igr_no, Item No: $igr_item_no, Field: $field."); - // } - // } - public function saveIGRHistory($hist) { - - // Extract fields from the input array - $field = $hist['key']; - $igr_no = $hist['igr_no']; - $igr_item_no = $hist['igr_item_no']; - $new_data = $hist['value']; // Incoming new value - $old_data = null; // Default old value is null - - log_message('error', "Save History function entered for IGR No: $igr_no, Item No: $igr_item_no, Field: $field."); - - // Fetch the latest history record for the field - $latestHist = $this->inwardgateregister_model->get_igr_history($field, $igr_no, $igr_item_no); - - - // Fetch the current value from the master or child table - if (empty($igr_item_no)) { - $current_data = $this->inwardgateregister_model->get_igr_master_for_history($field, $igr_no); - } else { - $current_data = $this->inwardgateregister_model->get_igr_child_for_history($field, $igr_no, $igr_item_no); + foreach ($request as $key => $value) { + foreach ($dbIGRMaster as $key1 => $value1) { + if ($value1 != $value && $key1 == $key) { + // Store each changed field in an array + $history_entries[] = [ + 'field' => $key1, + 'new_data' => $value, + 'old_data' => $value1, + 'history_dated' => get_current_date_time(), + 'by' => $this->session->get('userId'), + 'IGR_No' => $IGRNo, + 'IGRItem_No' => NULL, + 'is_edit' => 1, + ]; + } + } } - // Determine the old_data - if (!empty($latestHist)) { - // If history exists, use the latest new_data as old_data - $old_data = $latestHist->new_data; - } else { - // If no history exists, use the current data from the master/child table as old_data - $old_data = $current_data; + // Insert all history entries + foreach ($history_entries as $entry) { + $history_id = $this->inwardgateregister_model->igr_history($entry); + if ($history_id) { + log_message('error', "History updated successfully for IGR No: $IGRNo, Field: {$entry['field']}. History ID: $history_id"); + } else { + log_message('error', "Failed to update history for IGR No: $IGRNo, Field: {$entry['field']}"); + } } + } - // Check if the new_data is different from the old_data - if ($new_data == $old_data) { - log_message('error', "No update needed for IGR No: $igr_no, Item No: $igr_item_no, Field: $field. Data already exists: $new_data"); - return; // No need to insert history if data hasn't changed - } + public function saveIGRLineitemHistory($request, $IGRNo, $IGRLineItem) { + $dbIGRChild = $this->inwardgateregister_model->get_igr_child_for_history($IGRNo, $IGRLineItem); + $history_entries = []; - // Prepare history entry - $igr_history = [ - 'field' => $field, - 'new_data' => $new_data, - 'old_data' => $old_data, - 'history_dated' => get_current_date_time(), - 'by' => $this->session->get('userId'), - 'IGR_No' => $igr_no, - 'IGRItem_No' => $igr_item_no, - 'is_edit' => ($old_data !== null) ? 1 : 0, // 1 if it's an edit, 0 if it's an add - 'is_add' => ($old_data === null) ? 1 : 0 // 1 if it's an add, 0 if it's an edit - ]; + foreach ($request as $key => $value) { + foreach ($dbIGRChild as $key1 => $value1) { + if ($value1 != $value && $key1 == $key) { + // Store each changed field in an array + $history_entries[] = [ + 'field' => $key1, + 'new_data' => $value, + 'old_data' => $value1, + 'history_dated' => get_current_date_time(), + 'by' => $this->session->get('userId'), + 'IGR_No' => $IGRNo, + 'IGRItem_No' => $IGRLineItem, + 'is_edit' => 1, + ]; + } + } + } - // Insert history entry - $history_id = $this->inwardgateregister_model->igr_history($igr_history); - if ($history_id) { - log_message('error', "History updated successfully for IGR No: $igr_no, Item No: $igr_item_no, Field: $field. History ID: $history_id"); - } else { - log_message('error', "Failed to update history for IGR No: $igr_no, Item No: $igr_item_no, Field: $field."); - } -} - - - + // Insert all history entries + foreach ($history_entries as $entry) { + $history_id = $this->inwardgateregister_model->igr_history($entry); + if ($history_id) { + log_message('error', "History updated successfully for IGR No: $IGRNo, Item No: $IGRLineItem, Field: {$entry['field']}. History ID: $history_id"); + } else { + log_message('error', "Failed to update history for IGR No: $IGRNo, Item No: $IGRLineItem, Field: {$entry['field']}"); + } + } + } } \ No newline at end of file diff --git a/app/Controllers/Rawmaterialdetails.php b/app/Controllers/Rawmaterialdetails.php index e05b1b11..a4586d0d 100755 --- a/app/Controllers/Rawmaterialdetails.php +++ b/app/Controllers/Rawmaterialdetails.php @@ -370,8 +370,10 @@ class Rawmaterialdetails extends BaseController $materialCode = $data['materialCode'] ?? ''; $materialName = str_replace(' ', '', $data['materialName']); $materialCategory = $data['materialCategory'] ?? ''; + $materialType = $data['materialType'] ?? ''; + - $query = $this->rawmaterialdetails_model->checkMaterialExists($materialCode , $materialName , $materialCategory); + $query = $this->rawmaterialdetails_model->checkMaterialExists($materialCode , $materialName , $materialCategory,$materialType); return $this->response->setJSON($query); diff --git a/app/Models/Inwardgateregister_model.php b/app/Models/Inwardgateregister_model.php index 4ec07343..5a4d67be 100755 --- a/app/Models/Inwardgateregister_model.php +++ b/app/Models/Inwardgateregister_model.php @@ -249,20 +249,12 @@ class Inwardgateregister_model extends Model return $result; } - function get_igr_master_for_history($field, $igr_no) { - $builder = $this->db->table('t_igr_master Master') - ->select("Master.$field"); // Select only the required field - if ($igr_no) { - $builder->where('Master.IGRNO', $igr_no); - } - $query = $builder->get(); - $result = $query->getRow(); - return $result ? $result->$field : null; // Return the field value directly + function get_igr_master_for_history($igr_no) { + return $this->db->table('t_igr_master Master')->where('Master.IGRNO', $igr_no)->get()->getRow(); } - function get_igr_child_for_history($field, $igr_no, $igr_item_no) { - $builder = $this->db->table('t_igr_details Child') - ->select("Child.$field"); // Select only the required field + function get_igr_child_for_history($igr_no, $igr_item_no) { + $builder = $this->db->table('t_igr_details Child'); // Select only the required field if ($igr_no) { $builder->where('Child.IGRNO', $igr_no); } @@ -271,7 +263,7 @@ class Inwardgateregister_model extends Model } $query = $builder->get(); $result = $query->getRow(); - return $result ? $result->$field : null; // Return the field value directly + return $result; // Return the field value directly } function addigrM($igrM) @@ -1095,7 +1087,7 @@ class Inwardgateregister_model extends Model { $builder = $this->db->table('t_igr_history'); - $builder->select('t_igr_history.*, CONCAT_WS(" ", t_employee_details.FirstName, t_employee_details.LastName) AS FullName'); + $builder->select('t_igr_history.*, DATE_FORMAT(t_igr_history.history_dated, "%d-%m-%Y") AS indian_date, DATE_FORMAT(t_igr_history.history_dated, "%h:%i:%s %p") AS indian_time, CONCAT_WS(" ", t_employee_details.FirstName, t_employee_details.LastName) AS FullName'); $builder->join('tbl_users', 'tbl_users.userId = t_igr_history.by', 'left'); $builder->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID', 'left'); $builder->where('IGR_No', $igr); @@ -1219,7 +1211,15 @@ class Inwardgateregister_model extends Model $to = date('Y-m-d H:i:s', strtotime($date . ' +30 seconds')); $from = date('Y-m-d H:i:s', strtotime($date . ' -30 seconds')); - + $query3 = $this->db->query("Select t_igr_history.history_dated,DATE_FORMAT(t_igr_history.history_dated, '%d-%m-%Y') AS indian_date,DATE_FORMAT(t_igr_history.history_dated, '%h:%i:%s %p') AS indian_time , + t_igr_history.by,CONCAT_WS(' ', t_employee_details.FirstName, t_employee_details.LastName) AS history_by + from t_igr_history + LEFT JOIN tbl_users ON tbl_users.userId = t_igr_history.by + LEFT JOIN t_employee_details ON tbl_users.EmpID = t_employee_details.EmpID + where is_add = 1 and IGR_No = '".$igr."'"); + $first_line = $query3->getRow(); + + // 392 po $builder = $this->db->table('t_igr_history') ->select(' @@ -1232,7 +1232,9 @@ $builder = $this->db->table('t_igr_history') t_igr_history.by, t_igr_history.IGR_No, t_igr_history.IGRItem_No, - + DATE_FORMAT(t_igr_history.history_dated, "%d-%m-%Y") AS indian_date, + DATE_FORMAT(t_igr_history.history_dated, "%h:%i:%s %p") AS indian_time, + CONCAT_WS(" ", t_employee_details.FirstName, t_employee_details.LastName) AS history_by, CASE WHEN t_igr_history.field = "TransporterId" THEN (SELECT name FROM t_transporter WHERE id = t_igr_history.new_data LIMIT 1) @@ -1257,13 +1259,20 @@ $builder = $this->db->table('t_igr_history') ') // ->join('t_igr_details IGRD', 'IGRD.IGRItemNo = t_igr_history.IGRItem_No','left') // ->join('t_materialmaster MM','MM.MaterialCode = IGRD.MaterialCode','left') + ->join('tbl_users', 'tbl_users.userId = t_igr_history.by','left') + ->join('t_employee_details','tbl_users.EmpID = t_employee_details.EmpID','left') ->where('t_igr_history.IGR_No', $igr) ->where('t_igr_history.is_edit', 1) ->where('t_igr_history.history_dated BETWEEN "'.$from.'" AND "'.$to.'"'); $query = $builder->get(); + $result = $query->getResult(); + // echo $this->db->getLastQuery()->getQuery(); die; - return $query->getResult(); + return [ + 'history' => $result, + 'first_line' => $first_line ? " was added by ". $first_line->history_by ." on ". $first_line->indian_date ." at ". $first_line->indian_time : null, + ]; } public function getDetailsforEmail($userId,$roleId = 2) diff --git a/app/Models/Rawmaterialdetails_model.php b/app/Models/Rawmaterialdetails_model.php index f530ada6..edc073e5 100755 --- a/app/Models/Rawmaterialdetails_model.php +++ b/app/Models/Rawmaterialdetails_model.php @@ -331,7 +331,7 @@ class Rawmaterialdetails_model extends Model // on 28/jan/2025. both add and edit. category condition added. // on 13/Feb/2025. Change based On Config Child Values. - function checkMaterialExists($materialCode , $materialName ,$materialCategory) + function checkMaterialExists($materialCode , $materialName ,$materialCategory,$materialType) { $builder = $this->db->table('t_materialmaster MM') @@ -341,6 +341,7 @@ class Rawmaterialdetails_model extends Model $builder = $builder->where('MM.MaterialCode !=' , $materialCode); } $builder->where('MM.Category' , $materialCategory); + $builder->where('MM.MaterialType' , $materialType); $builder->where('REPLACE(MM.MaterialName, " ", "")' , $materialName); $query = $builder->get(); diff --git a/app/Views/addRawMaterial.php b/app/Views/addRawMaterial.php index 5334b70a..76de4439 100755 --- a/app/Views/addRawMaterial.php +++ b/app/Views/addRawMaterial.php @@ -305,6 +305,7 @@ var materialName = $('#MaterialName').val().trim(); var materialCode = ''; var materialCategory = $('#MatCate').val(); + var materialType = $('MaterialType').val(); if(materialName == ''){ return; } @@ -314,7 +315,7 @@ $('#loader').show(); $.ajax({ data: { - materialCode, + materialCode,materialType, materialName,materialCategory }, type: "POST", diff --git a/app/Views/configlisting.php b/app/Views/configlisting.php index 21bbde54..692f8580 100755 --- a/app/Views/configlisting.php +++ b/app/Views/configlisting.php @@ -192,12 +192,12 @@    - - + --> diff --git a/app/Views/editRawmaterial.php b/app/Views/editRawmaterial.php index 0275935b..67a0832a 100755 --- a/app/Views/editRawmaterial.php +++ b/app/Views/editRawmaterial.php @@ -404,6 +404,7 @@ if ($total <= $reorder) { var materialName = $('#MaterialName').val(); var materialCode = $('#RMcode').val(); var materialCategory = $('#MaterialCategory').val(); + var materialType = $('#MaterialType').val(); if(materialName == ''){ return; @@ -416,7 +417,8 @@ if ($total <= $reorder) { data: { materialCode, materialName, - materialCategory + materialCategory, + materialType }, type: "POST", url: "materialExist", diff --git a/app/Views/viewinwardgateregister.php b/app/Views/viewinwardgateregister.php index bf6ab9c7..5fbeaf6c 100755 --- a/app/Views/viewinwardgateregister.php +++ b/app/Views/viewinwardgateregister.php @@ -1183,7 +1183,7 @@ success: function(data) { alert(data); - location.reload(); + // location.reload(); } }); }); @@ -1251,7 +1251,7 @@ success: function(data) { alert(data); - location.reload(); + // location.reload(); }, error: function(xhr, status, error) { // Error callback console.error('AJAX Error:', status, error); @@ -1346,15 +1346,22 @@ }); function constructSentence(record) { - let str = record.field; - let fieldName = str.replace(/([a-z])([A-Z])/g, '$1 $2'); - let sentence = record.FullName + ' on ' + formatDateTime(record.history_dated, 2) + " " + fieldName + " "; + + // let str = record.field; + // let fieldName = str.replace(/([a-z])([A-Z])/g, '$1 $2'); + let sentence = " "; if (parseInt(record.is_add) === 1) { - sentence += record.new_data + " was added."; + sentence += record.IGR_No + " was added by "+record.FullName+ " on "+record.indian_date+" at "+record.indian_time; } else if (parseInt(record.is_edit) === 1) { - sentence += record.old_data + " was updated into " + record.new_data + "."; + if(record.field != "UpdateBY"){ + let str = record.field; + let fieldName = str.replace(/([a-z])([A-Z])/g, '$1 $2'); + sentence += fieldName+" "+record.old_data + " was updated into " + record.new_data + " by "+record.FullName+ " on "+record.indian_date+" at "+record.indian_time; + } } else if (parseInt(record.is_delete) === 1) { - sentence += record.new_data + " was deleted."; + let str = record.field; + let fieldName = str.replace(/([a-z])([A-Z])/g, '$1 $2'); + sentence += fieldName+" "+record.new_data + " was deleted by "+record.FullName+ " on "+record.indian_date+" at "+record.indian_time; } return sentence; } From 173f8df6432896fb1f3d4f387ccf8a47c115a509 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Mon, 17 Feb 2025 10:23:32 +0000 Subject: [PATCH 04/26] issues in bug tracker : ps --- app/Models/Config_model.php | 37 +++++++++++++++++++++++------- app/Models/Purchaseorder_model.php | 4 ++-- app/Views/capitalpurchaseorder.php | 3 +-- app/Views/importpo.php | 4 ++-- app/Views/servicePurchaseorder.php | 3 +-- 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/app/Models/Config_model.php b/app/Models/Config_model.php index ef2109e9..960118d6 100755 --- a/app/Models/Config_model.php +++ b/app/Models/Config_model.php @@ -229,15 +229,36 @@ class Config_model extends Model } public function getPONOcreatedBasedOnConfig($key_id){ - $builder = $this->db->table('t_purchaseorder_lineitem PL') - ->select('PL.PONO, MM.MaterialName, CD.ConfigValue as CategoryName') - ->join('t_materialmaster MM', 'MM.MaterialCode = PL.MaterialCode', 'left') - ->join('t_configdetails CD', 'CD.Key = MM.Category', 'left') - ->where('CD.Key', $key_id); + // $builder = $this->db->table('t_purchaseorder_lineitem PL') + // ->select('PL.PONO, MM.MaterialName, CD.ConfigValue as CategoryName') + // ->join('t_materialmaster MM', 'MM.MaterialCode = PL.MaterialCode', 'left') + // ->join('t_configdetails CD', 'CD.Key = MM.Category', 'left') + // ->where('CD.Key', $key_id); - $query = $builder->get(); - $result = $query->getResultArray(); - return $result; + // $query = $builder->get(); + // $result = $query->getResultArray(); + // return $result; + $builder = $this->db->table('t_purchaseorder_lineitem pl') + ->select(['po.PONO',"DATE_FORMAT(po.PODate, '%d-%m-%Y') as PODate",'mm.MaterialName','CD.Key','CD.ConfigValue as CategoryName','s.StatusName','s.statusCode']) + ->join('t_purchaseorder_master po', 'po.PONO = pl.PONO') + ->join('t_materialmaster mm', 'mm.MaterialCode = pl.MaterialCode') + ->join('t_configdetails CD', 'CD.Key = mm.Category') + ->join('t_status s', 's.statusCode = po.Status', 'left') + ->where('CD.Key', $key_id) + ->whereIn('po.Status', [PO_DRAFT,PO_CREATED,REQ_PO_CREATED,PO_RELEASED,REQITEM_Emergency_PO_CREATED,IGR_DRAFT,IGR_DRAFT,OPEN_ORDER_PO]) + ->groupBy('po.PONO') + ->orderBy('po.CreatedDate', 'DESC'); + $query = $builder->get(); + $result = $query->getResultArray(); + return $result; + // 'OPEN_ORDER_PO','ST073' + // 'IGR_DRAFT','ST074' + // 'IGR_CREATED','ST027' + // 'REQITEM_Emergency_PO_CREATED','ST024' + // 'PO_DRAFT','ST014' + // 'PO_CREATED','ST015' + // 'REQ_PO_CREATED','ST005' + // 'PO_RELEASED','ST026' } } \ No newline at end of file diff --git a/app/Models/Purchaseorder_model.php b/app/Models/Purchaseorder_model.php index 0ad9e8fd..cc0eb274 100755 --- a/app/Models/Purchaseorder_model.php +++ b/app/Models/Purchaseorder_model.php @@ -1740,7 +1740,7 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath, $subQuery = 'SELECT distinct LineItem.LineItemNo,LineItem.Per,LineItem.ServiceMaterialDescription,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName,LineItem.ServiceMaterialDescription,LineItem.ServiceFrequency, Mat.UOM,Quantity,ReceivedQuantity,Rate,Req.Status,Tax.*, ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount,LandingCharge,HighSeasSalesCharge,CustomDuty,ExciseDuty,ExciseDutyEdCess,CustomEdCess,POMast.ExchangeRate,POMast.ExchangeRateCalculatedon,POMast.TotalOrderValue as BasicValue,POMast.CapitalRange,AfterLandingCharge,AfterHighSeasSalesCharge,AfterCustomDuty,AfterExciseDuty,AfterExciseDutyEdCess,AddlExciseDuty,AfterAddlExciseDuty,Grossdutypayable,AvailableModvat,Grossexpensesduetocustomduty,purchaseratePerKG,CustomDutyExpensesPerKG,RMCIncludingCustomersPerKG,QuantityKG,BasicPriceInMTon,ProductPrice,CustomSHCess,AfterCustomSHCess,AfterExciseDutySHCess,ExciseDutySHCess,AfterCustomEdCess,ROUND((POMast.ExchangeRate*BasicPriceInMTon*Quantity),2) as BasicINRValue,Tax.TotalValue as ImportTotalValue,Tax.FreightType,Tax.NoOfTrip,Tax.FreightValue,Tax.AfterFreightValue,POMast.CurrencyType, - + LineItem.LineitemAuditorNotes, Req.CostCenterCode,Dept.DepartmentName FROM t_purchaseorder_lineitem LineItem join t_purchaseorder_master POMast on POMast.PONO = LineItem.PONO join t_materialmaster Mat on Mat.MaterialCode = LineItem.MaterialCode @@ -1799,7 +1799,7 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath, Mat.UOM,Quantity,ReceivedQuantity,Rate,Req.Status,ROUND((ServiceTax.After_CGST + ServiceTax.After_SGST + ServiceTax.After_IGST),2) as ServiceTaxamount ,ServiceTax.TotalValue,ServiceTax.CGST,ServiceTax.After_CGST,ServiceTax.SGST,ServiceTax.After_SGST,ServiceTax.IGST,ServiceTax.After_IGST,ServiceTax.otherallowance,ServiceTax.discount,ServiceTax.discountval,ServiceTax.Afterdiscountval, POMast.ExchangeRate,POMast.ExchangeRateCalculatedon,POMast.TotalOrderValue as BasicValue,POMast.CapitalRange,ROUND((POMast.TotalOrderValue),2) as BasicINRValue,POMast.CurrencyType,FreightType as Ftype,NoOfTrip as NoTrip,FreightValue as Fvalue,AfterFreightValue as Afvalue, - + LineItem.LineitemAuditorNotes, Req.CostCenterCode,Dept.DepartmentName FROM t_purchaseorder_lineitem LineItem join t_purchaseorder_master POMast on POMast.PONO = LineItem.PONO join t_materialmaster Mat on Mat.MaterialCode = LineItem.MaterialCode diff --git a/app/Views/capitalpurchaseorder.php b/app/Views/capitalpurchaseorder.php index 734384d6..e035a431 100755 --- a/app/Views/capitalpurchaseorder.php +++ b/app/Views/capitalpurchaseorder.php @@ -78,9 +78,8 @@ const LineItemNoteForAuditor = $link.data('notes'); const id = $link.data('id'); var theForm = $(".CreatePO"); - - addHidden(theForm, "LineItemNoteForAuditor" + id, value); $link.text(value).show(); + $("#LineItemNoteForAuditor" + id).val(value); $editContainer.hide(); }); diff --git a/app/Views/importpo.php b/app/Views/importpo.php index 29c1f73d..2649fe30 100755 --- a/app/Views/importpo.php +++ b/app/Views/importpo.php @@ -158,8 +158,7 @@ if (isset($AvlimportBudAmt) && !empty($AvlimportBudAmt)) { const LineItemNoteForAuditor = $link.data('notes'); const id = $link.data('id'); var theForm = $(".CreatePO"); - - addHidden(theForm, "LineItemNoteForAuditor" + id, value); + $("#LineItemNoteForAuditor" + id).val(value); $link.text(value).show(); $editContainer.hide(); }); @@ -4205,6 +4204,7 @@ if (isset($AvlimportBudAmt) && !empty($AvlimportBudAmt)) { formData.append('txtRowCount', txtRowCount); formData.append('txtDeletedRow', txtDeletedRow); formData.append('textStatus', stat); + $.ajax({ // data:$('.ImportPO').serialize()+"&txtRowCount="+txtRowCount+"&txtDeletedRow="+txtDeletedRow+"&textStatus="+stat, //data:$('.CreatealterPO').serialize()+"&TextRowCount="+TextRowCount+"&TextDeQletedRowCount="+TextDeletedRowCount+"&TextTotalOrderValueSummaryService="+TextTotalOrderValueSummaryService+"&TextSpcialInstruction="+TextSpcialInstruction+"&TextExchangerate"+ExcLandingCharge="+hangerate+"Status="+TextStatus, diff --git a/app/Views/servicePurchaseorder.php b/app/Views/servicePurchaseorder.php index 04501577..ca1c1f45 100755 --- a/app/Views/servicePurchaseorder.php +++ b/app/Views/servicePurchaseorder.php @@ -78,8 +78,7 @@ const LineItemNoteForAuditor = $link.data('notes'); const id = $link.data('id'); var theForm = $(".ServicePO"); - - addHidden(theForm, "LineItemNoteForAuditor" + id, value); + $("#LineItemNoteForAuditor" + id).val(value); $link.text(value).show(); $editContainer.hide(); }); From 768d985e4f8f6227ca59afca3d333bd694eecca6 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Mon, 17 Feb 2025 18:10:59 +0530 Subject: [PATCH 05/26] stock module latest today vadivel J 17-02-2025 --- app/Controllers/StockController.php | 10 +- app/Models/TrpProductionModel.php | 164 +++++---- app/Views/stock/trpProductionStockDetails.php | 317 ++++++------------ 3 files changed, 203 insertions(+), 288 deletions(-) diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 08de9d9d..a16a4e52 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -1717,12 +1717,14 @@ class StockController extends BaseController - $data['trpProductionDetails'] = $this->TrpProduction_model->trpProductionDetails($startDate,$endDate); + $result = $this->TrpProduction_model->trpProductionDetails($startDate,$endDate); + $data['trpProductionDetails'] = $result[0] ; - // dd($data['trpProductionDetails']); + $data['crsClientList'] = $result[1] ; + + $data['wcsSupplierList'] = $result[2] ; - // dd($this->db->getLastQuery()); $date = DateTime::createFromFormat('Y-m', $month); @@ -1737,8 +1739,6 @@ class StockController extends BaseController return $this->loadViews("stock/trpProductionStockDetails", $this->global, $data, NULL); - - } diff --git a/app/Models/TrpProductionModel.php b/app/Models/TrpProductionModel.php index 8cf96e23..0b498b98 100644 --- a/app/Models/TrpProductionModel.php +++ b/app/Models/TrpProductionModel.php @@ -60,7 +60,7 @@ class TrpProductionModel extends Model // Subquery definition $subquery = $this->db->table('t_materialmaster') ->select('materialCode') - ->where('Category = 328') + ->where('Category' ,'waste core') //328 - is for waste core in config master ->get() ->getResultArray(); @@ -78,57 +78,65 @@ class TrpProductionModel extends Model $builder = $this->db->table('t_trpProductionMaintenanceDetails tpmd'); // Select required columns - $builder->select([ - 'tpmd.date', - 'tpmd.openingTime', - 'tpmd.closingTime', - 'tpmd.totalHours', - 'tpmd.coldStart', - 'tpmd.breakdownHours', - 'tpmd.burnerFiringHours', - 'tpmd.sandFeedingHours', - 'tpmd.workingPersonEngineers', - 'tpmd.workingPersonSupervisiors', - 'tpmd.workingPersonOperators', - 'tpmd.rollerDrivers', - 'tpmd.natureOfMaintenance', - 'tpmd.location', - 'tpmd.description', + $builder->select( + 'tpmd.date, + tpmd.openingTime, + tpmd.closingTime, + tpmd.totalHours, + tpmd.coldStart, + tpmd.breakdownHours, + tpmd.burnerFiringHours, + tpmd.sandFeedingHours, + tpd.gasReceiptBg, + tpd.gasReceiptPg, + + + tpd.physicalGasConsumption, + IFNULL(tdmd.totalGasConsumption, 0) AS drierGasConsumption, + IFNULL(tcmd.totalGasConsumption, 0) AS coatingGasConsumption, + tpd.trpPlusDrierGasConsumption, + tpd.trpPhysicalGasPerTon, + tpd.panelGasConsumption, + tpd.panelGasPerTon, + + tigrdot.* , - 'tpd.gasReceiptBg', - 'tpd.gasReceiptPg', - 'tpd.physicalGasConsumption', - 'tpd.trpPlusDrierGasConsumption', - 'tpd.trpPhysicalGasPerTon', - 'tpd.panelGasConsumption', - 'tpd.panelGasPerTon', - 'tpd.edRunningHours', - 'tpd.edProduction', - 'tpd.edUsage', - 'tpd.trpProduction', - 'tpd.trpProductionPerHour', - 'tpd.waterReceipt', - 'tpd.waterConsumption', - 'tpd.ebReading', - 'tpd.ebReadingPerUnitTon', - - 'tpwd.msSeperation', - 'tpwd.edWaste', - 'tpwd.coolerBags', - 'tpwd.edPlus20Waste', - 'tpwd.cycloneWaste', + tpd.edRunningHours, + tpd.edProduction, + tpd.edUsage, - // Aggregated gas consumption - 'IFNULL(tcmd.totalGasConsumption, 0) AS coatingGasConsumption', - 'IFNULL(tdmd.totalGasConsumption, 0) AS drierGasConsumption', + tpd.trpProduction, + tpd.trpProductionPerHour, - 'tsu.total_kgs AS coating' , - - 'tigrdot.*', - 'invItems.*' + tsu.total_kgs AS coating, + invItems.* , + tpd.waterReceipt, + tpd.waterConsumption, + tpd.ebReading, + tpd.ebReadingPerUnitTon, - ]); + + tpmd.workingPersonEngineers, + tpmd.workingPersonSupervisiors, + tpmd.workingPersonOperators, + tpmd.rollerDrivers, + tpmd.natureOfMaintenance, + tpmd.location, + tpmd.description, + + tpwd.msSeperation, + tpwd.edWaste, + tpwd.coolerBags, + tpwd.edPlus20Waste, + tpwd.cycloneWaste, + + + +' + + ); + // Join with other tables $builder->join('t_trpProductionDetails tpd', 'tpd.date = tpmd.date', 'inner'); @@ -170,26 +178,27 @@ class TrpProductionModel extends Model $crsClientList = array_column($crsClientList, 'client_name'); // Initialize an empty array for dynamic SQL conditions - $caseStatements = []; + $caseStatementsCrs = []; // Loop through the client list and build dynamic SUM(CASE WHEN...) - foreach ($crsClientList as $client) { - // Escape column name (remove spaces and special characters) - $safeClient = str_replace(' ', '_', $client); - + foreach ($crsClientList as $index => $client) { + + $crsClientList[$index] = $client."_crs"; + $clientCrs = $client."_crs"; + // Add the condition to the array - $caseStatements[] = "SUM(CASE WHEN clients.client_name = " . $this->db->escape($client) . " THEN invItems.item_quantity ELSE 0 END) AS `$safeClient`"; + $caseStatementsCrs[] = "SUM(CASE WHEN clients.client_name = " . $this->db->escape($client) . " THEN invItems.item_quantity ELSE 0 END) AS `$clientCrs`"; } // Convert array to a comma-separated string - $caseSQL = implode(', ', $caseStatements); + $caseSQLCrs = implode(', ', $caseStatementsCrs); $subquery3 = $this->db->table('ip_invoice_items invItems') ->select([ 'invItems.item_date_added', - $caseSQL + $caseSQLCrs ]) ->join('ip_invoices inv', 'inv.invoice_id = invItems.invoice_id', 'left') ->join('ip_clients clients', 'clients.client_id = inv.client_id', 'left') @@ -210,19 +219,46 @@ class TrpProductionModel extends Model $materialCodes = ! empty($materialCodes) ? $materialCodes : ['600374','600422','600434']; - + + + $wcsSupplierList = $this->db->table('t_igr_details tigrd') + ->distinct() + ->select('ts.SupplierName as supplierName') + ->join('t_igr_master tigm', 'tigm.IGRNo = tigrd.IGRNo', 'left') + ->join('t_purchaseorder_master tpom', 'tpom.PONO = tigm.PONO', 'left') + ->join('t_supplierdetailsn ts', 'tpom.SupplierID = ts.SupplierID', 'left') + ->whereIn('tigrd.MaterialCode', $materialCodes) + ->where('tigrd.CreatedDate >=', $startDate) + ->where('tigrd.CreatedDate <=', $endDate) + ->groupBy('DATE(tigrd.CreatedDate)') + ->get() + ->getResultArray(); + + + $wcsSupplierList = array_column($wcsSupplierList, 'supplierName'); + + // Initialize an empty array for dynamic SQL conditions + $caseStatementsWcs = []; + + // Loop through the client list and build dynamic SUM(CASE WHEN...) + foreach ($wcsSupplierList as $index => $supplier) { + + $wcsSupplierList[$index] = $supplier."_wcs"; + $supplierWcs = $supplier."_wcs"; + + // Add the condition to the array + $caseStatementsWcs[] = "SUM(CASE WHEN ts.SupplierName = " . $this->db->escape($supplier) . " THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `$supplierWcs` "; + } + + // Convert array to a comma-separated string + $caseSQLWcs = implode(', ', $caseStatementsWcs); + // Subquery: Waste Core Sand Suppliers $subquery4 = $this->db->table('t_igr_details tigrd') ->select([ 'DATE(tigrd.CreatedDate) AS CreatedDate', // Convert CreatedDate to DATE format - "SUM(CASE WHEN ts.SupplierName = 'Ashok leyland limited foundry divn-SPU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS ALs_wcs", - "SUM(CASE WHEN ts.SupplierName = 'Ashok leyland limited foundry divn-ENU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS ALe_wcs", - "SUM(CASE WHEN ts.SupplierName = 'MADRAS ENGINEERING INDUSTRIES PRIVATE LIMITED' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS ME_wcs", - "SUM(CASE WHEN ts.SupplierName = 'SIDDHARTH INDUSTRIES' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS SI_wcs", - "SUM(CASE WHEN ts.SupplierName = 'Caparo Engineering India Limited' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS caparo_wcs", - "SUM(CASE WHEN ts.SupplierName = 'NEMAK ALUMINIUM CASTING INDIA PVT LTD' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS Nemak_wcs", - "SUM(CASE WHEN ts.SupplierName = 'DR Axion India Private Limited' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS DR_wcs" + $caseSQLWcs ]) ->join('t_igr_master tigm', 'tigm.IGRNo = tigrd.IGRNo', 'left') ->join('t_purchaseorder_master tpom', 'tpom.PONO = tigm.PONO', 'left') @@ -254,7 +290,7 @@ class TrpProductionModel extends Model $query = $builder->get(); $result = $query->getResultArray(); - return $result; + return [$result,$crsClientList,$wcsSupplierList]; } diff --git a/app/Views/stock/trpProductionStockDetails.php b/app/Views/stock/trpProductionStockDetails.php index 9c863f62..135af237 100644 --- a/app/Views/stock/trpProductionStockDetails.php +++ b/app/Views/stock/trpProductionStockDetails.php @@ -380,13 +380,15 @@ $timeOtions[] = "12:00 AM"; Panel Gas Per Ton - Incoming Sand/ Lump details + Incoming Sand/ Lump details ED details TRP Sand + + Coating - Usage + Usage Water @@ -420,20 +422,16 @@ $timeOtions[] = "12:00 AM"; BG PG - - AL(S) - - AL(E) - - ME - - SI - - caparo - - Nemak - - DR + + + + + + + + + + Running Hours @@ -445,17 +443,16 @@ $timeOtions[] = "12:00 AM"; Production Per Hour - Coating - - Hindhuja - - Nemak - - ME - - BI - - Karmen + + + + + + + + + + Receipt @@ -485,8 +482,8 @@ $timeOtions[] = "12:00 AM"; @@ -667,56 +664,18 @@ $timeOtions[] = "12:00 AM"; - - - - - + - - - - - + - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - + @@ -767,40 +726,22 @@ $timeOtions[] = "12:00 AM"; - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + @@ -942,8 +883,11 @@ $timeOtions[] = "12:00 AM"; $eachDate = $trpProductionDetail['date']; // Unique identifier + + // Initialize the date entry if it doesn't exist if (!isset($summary['totalHours'])) { + $summary = [ 'totalHours' => 0, 'coldStart' => 0, @@ -959,24 +903,12 @@ $timeOtions[] = "12:00 AM"; 'trpPhysicalGasPerTon' => 0, 'panelGasConsumption' => 0, 'panelGasPerTon' => 0, - 'ALs_wcs' => 0, - 'ALe_wcs' => 0, - 'ME_wcs' => 0, - 'SI_wcs' => 0, - 'caparo_wcs' => 0, - 'Nemak_wcs' => 0, - 'DR_wcs' => 0, 'edRunningHours' => 0, 'edProduction' => 0, 'edUsage' => 0, 'trpProduction' => 0, 'trpProductionPerHour' => 0, 'coating' => 0, - 'ALs_crs' => 0, - 'Nemak_crs' => 0, - 'ME_crs' => 0, - 'BI_crs' => 0, - 'Karmen_crs' => 0, 'waterReceipt' => 0, 'waterConsumption' => 0, 'ebReading' => 0, @@ -991,6 +923,15 @@ $timeOtions[] = "12:00 AM"; 'cycloneWaste' => 0 ]; + + foreach($crsClientList as $client){ + $summary[$client] = 0; + } + + foreach($wcsSupplierList as $supplier){ + $summary[$supplier] = 0; + } + } // Sum values for the material @@ -1009,24 +950,22 @@ $timeOtions[] = "12:00 AM"; $summary['trpPhysicalGasPerTon'] += is_numeric($trpProductionDetail['trpPhysicalGasPerTon']) ? $trpProductionDetail['trpPhysicalGasPerTon'] : 0; $summary['panelGasConsumption'] += is_numeric($trpProductionDetail['panelGasConsumption']) ? $trpProductionDetail['panelGasConsumption'] : 0; $summary['panelGasPerTon'] += is_numeric($trpProductionDetail['panelGasPerTon']) ? $trpProductionDetail['panelGasPerTon'] : 0; - $summary['ALs_wcs'] += is_numeric($trpProductionDetail['ALs_wcs']) ? $trpProductionDetail['ALs_wcs'] : 0; - $summary['ALe_wcs'] += is_numeric($trpProductionDetail['ALe_wcs']) ? $trpProductionDetail['ALe_wcs'] : 0; - $summary['ME_wcs'] += is_numeric($trpProductionDetail['ME_wcs']) ? $trpProductionDetail['ME_wcs'] : 0; - $summary['SI_wcs'] += is_numeric($trpProductionDetail['SI_wcs']) ? $trpProductionDetail['SI_wcs'] : 0; - $summary['caparo_wcs'] += is_numeric($trpProductionDetail['caparo_wcs']) ? $trpProductionDetail['caparo_wcs'] : 0; - $summary['Nemak_wcs'] += is_numeric($trpProductionDetail['Nemak_wcs']) ? $trpProductionDetail['Nemak_wcs'] : 0; - $summary['DR_wcs'] += is_numeric($trpProductionDetail['DR_wcs']) ? $trpProductionDetail['DR_wcs'] : 0; + + foreach($wcsSupplierList as $supplier){ + $summary[$supplier] += is_numeric($trpProductionDetail[$supplier]) ? $trpProductionDetail[$supplier] : 0; + } + $summary['edRunningHours'] += is_numeric($trpProductionDetail['edRunningHours']) ? $trpProductionDetail['edRunningHours'] : 0; $summary['edProduction'] += is_numeric($trpProductionDetail['edProduction']) ? $trpProductionDetail['edProduction'] : 0; $summary['edUsage'] += is_numeric($trpProductionDetail['edUsage']) ? $trpProductionDetail['edUsage'] : 0; $summary['trpProduction'] += is_numeric($trpProductionDetail['trpProduction']) ? $trpProductionDetail['trpProduction'] : 0; $summary['trpProductionPerHour'] += is_numeric($trpProductionDetail['trpProductionPerHour']) ? $trpProductionDetail['trpProductionPerHour'] : 0; $summary['coating'] += is_numeric($trpProductionDetail['coating']) ? $trpProductionDetail['coating'] : 0; - $summary['ALs_crs'] += is_numeric($trpProductionDetail['ALs_crs']) ? $trpProductionDetail['ALs_crs'] : 0; - $summary['Nemak_crs'] += is_numeric($trpProductionDetail['Nemak_crs']) ? $trpProductionDetail['Nemak_crs'] : 0; - $summary['ME_crs'] += is_numeric($trpProductionDetail['ME_crs']) ? $trpProductionDetail['ME_crs'] : 0; - $summary['BI_crs'] += is_numeric($trpProductionDetail['BI_crs']) ? $trpProductionDetail['BI_crs'] : 0; - $summary['Karmen_crs'] += is_numeric($trpProductionDetail['Karmen_crs']) ? $trpProductionDetail['Karmen_crs'] : 0; + + foreach($crsClientList as $client){ + $summary[$client] += is_numeric($trpProductionDetail[$client]) ? $trpProductionDetail[$client] : 0; + } + $summary['waterReceipt'] += is_numeric($trpProductionDetail['waterReceipt']) ? $trpProductionDetail['waterReceipt'] : 0; $summary['waterConsumption'] += is_numeric($trpProductionDetail['waterConsumption']) ? $trpProductionDetail['waterConsumption'] : 0; $summary['ebReading'] += is_numeric($trpProductionDetail['ebReading']) ? $trpProductionDetail['ebReading'] : 0; @@ -1122,20 +1061,13 @@ $timeOtions[] = "12:00 AM"; BG PG - - AL(S) - - AL(E) - - ME - - SI - - caparo - - Nemak - - DR + + + + + + + Running Hours @@ -1149,15 +1081,14 @@ $timeOtions[] = "12:00 AM"; Coating - Hindhuja - - Nemak - - ME - - BI - - Karmen + + + + + + + + Receipt @@ -1296,48 +1227,14 @@ $timeOtions[] = "12:00 AM"; - - - - - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1377,32 +1274,14 @@ $timeOtions[] = "12:00 AM"; - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - From 7429251ec5ea2710ee174999eae389a78c7d205b Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Tue, 18 Feb 2025 18:18:57 +0530 Subject: [PATCH 06/26] stock module latest today vadivel J 18-02-2025 --- app/Views/stock/trpProductionStockDetails.php | 226 +++++++++++------- 1 file changed, 138 insertions(+), 88 deletions(-) diff --git a/app/Views/stock/trpProductionStockDetails.php b/app/Views/stock/trpProductionStockDetails.php index 135af237..86fff64e 100644 --- a/app/Views/stock/trpProductionStockDetails.php +++ b/app/Views/stock/trpProductionStockDetails.php @@ -191,7 +191,7 @@ background-color: #50bbd9; /* Green background */ color: #ffffff; border: 1px solid #ddd; - padding: 10px; + padding: 1px; white-space: normal; /* Allows text to wrap */ word-wrap: break-word; /* Breaks long words if needed */ text-align: center; /* Centers text for better alignment */ @@ -221,11 +221,15 @@ max-width: 100px; } + .location{ + min-width:200px; + min-height: 200px; + } - - - - + .description{ + min-width:400px; + min-height: 200px; + } @@ -264,7 +268,7 @@ foreach ($period as $day) { $timeOptions = []; foreach (["AM", "PM"] as $meridian) { - for ($hour = 0; $hour < 12; $hour++) { + for ($hour = 0; $hour < 12; $hour++) { for ($minute = 0; $minute < 60; $minute += 15) { $formattedHour = $hour === 0 ? 12 : $hour; $timeOptions[] = sprintf("%02d:%02d %s", $formattedHour, $minute, $meridian); @@ -380,15 +384,25 @@ $timeOtions[] = "12:00 AM"; Panel Gas Per Ton - Incoming Sand/ Lump details + + 0){?> + Incoming Sand/ Lump details + + ED details TRP Sand Coating + - Usage + + 0){?> + Usage + + + Water @@ -410,8 +424,7 @@ $timeOtions[] = "12:00 AM"; ED +20 Waste - Cyclone Waste - + Cyclone Waste @@ -552,14 +565,14 @@ $timeOtions[] = "12:00 AM"; + data-id=" totalHours"> @@ -706,7 +719,7 @@ $timeOtions[] = "12:00 AM"; @@ -1020,14 +1033,26 @@ $timeOtions[] = "12:00 AM"; Panel Gas Consumption Panel Gas Per Ton + - Incoming Sand/ Lump details + + 0){?> + Incoming Sand/ Lump details + + ED details TRP Sand + + Coating + - Usage + + 0){?> + Usage + + Water @@ -1050,7 +1075,7 @@ $timeOtions[] = "12:00 AM"; ED +20 Waste Cyclone Waste - + @@ -1079,7 +1104,7 @@ $timeOtions[] = "12:00 AM"; Production Per Hour - Coating + @@ -1340,13 +1365,13 @@ $timeOtions[] = "12:00 AM"; - + - + @@ -1451,7 +1476,7 @@ $timeOtions[] = "12:00 AM"; - + @@ -1533,42 +1558,42 @@ $timeOtions[] = "12:00 AM"; const rowData = { - Date : rowCells.eq(0).text().trim() , + Date : rowCells.eq(0).text().trim() , openingTime : openingTime , closingTime : closingTime , - totalHours : rowCells.eq(3).text().trim() , - coldStart : rowCells.eq(4).text().trim() , - breakdownHours : rowCells.eq(5).text().trim() , - burnerFiringHours : rowCells.eq(6).text().trim() , - sandFeedingHours : rowCells.eq(7).text().trim() , - gasReceiptBg : rowCells.eq(8).text().trim() , - gasReceiptPg : rowCells.eq(9).text().trim() , - physicalGasConsumption : rowCells.eq(10).text().trim() , - trpPlusDrierGasConsumption : rowCells.eq(13).text().trim() , - trpPhysicalGasPerTon : rowCells.eq(14).text().trim() , - panelGasConsumption : rowCells.eq(15).text().trim() , - panelGasPerTon : rowCells.eq(16).text().trim() , - edRunningHours : rowCells.eq(24).text().trim() , - edProduction : rowCells.eq(25).text().trim() , - edUsage : rowCells.eq(26).text().trim() , - waterConsumption : rowCells.eq(26).text().trim() , - trpProduction : rowCells.eq(27).text().trim() , - trpProductionPerHour : rowCells.eq(28).text().trim() , - waterReceipt : rowCells.eq(35).text().trim() , - ebReading : rowCells.eq(37).text().trim() , - ebReadingPerUnitTon : rowCells.eq(38).text().trim() , - workingPersonEngineers : rowCells.eq(39).text().trim() , - workingPersonSupervisiors : rowCells.eq(40).text().trim() , - workingPersonOperators : rowCells.eq(41).text().trim() , - rollerDrivers : rowCells.eq(42).text().trim() , - natureOfMaintenance : rowCells.eq(43).text().trim() , - location : rowCells.eq(44).text().trim() , - description : rowCells.eq(45).text().trim() , - msSeperation : rowCells.eq(46).text().trim() , - edWaste : rowCells.eq(47).text().trim() , - coolerBags : rowCells.eq(48).text().trim() , - edPlus20Waste : rowCells.eq(49).text().trim() , - cycloneWaste : rowCells.eq(50).text().trim() + totalHours : $(this).find(`td[data-id='${dateInYmD} totalHours']`), + coldStart : $(this).find(`td[data-id='${dateInYmD} coldStart']`) , + breakdownHours : $(this).find(`td[data-id='${dateInYmD} breakdownHours']`) , + burnerFiringHours : $(this).find(`td[data-id='${dateInYmD} burnerFiringHours']`) , + sandFeedingHours : $(this).find(`td[data-id='${dateInYmD} sandFeedingHours']`) , + gasReceiptBg : $(this).find(`td[data-id='${dateInYmD} gasReceiptBg']`) , + gasReceiptPg : $(this).find(`td[data-id='${dateInYmD} gasReceiptPg']`) , + physicalGasConsumption : $(this).find(`td[data-id='${dateInYmD} physicalGasConsumption']`) , + trpPlusDrierGasConsumption : $(this).find(`td[data-id='${dateInYmD} trpPlusDrierGasConsumption']`) , + trpPhysicalGasPerTon : $(this).find(`td[data-id='${dateInYmD} trpPhysicalGasPerTon']`) , + panelGasConsumption : $(this).find(`td[data-id='${dateInYmD} panelGasConsumption']`) , + panelGasPerTon : $(this).find(`td[data-id='${dateInYmD} panelGasPerTon']`) , + edRunningHours : $(this).find(`td[data-id='${dateInYmD} edRunningHours']`) , + edProduction : $(this).find(`td[data-id='${dateInYmD} edProduction']`) , + edUsage : $(this).find(`td[data-id='${dateInYmD} edUsage']`) , + waterConsumption : $(this).find(`td[data-id='${dateInYmD} waterConsumption']`) , + trpProduction : $(this).find(`td[data-id='${dateInYmD} trpProduction']`) , + trpProductionPerHour : $(this).find(`td[data-id='${dateInYmD} trpProductionPerHour']`) , + waterReceipt : $(this).find(`td[data-id='${dateInYmD} waterReceipt']`) , + ebReading : $(this).find(`td[data-id='${dateInYmD} ebReading']`) , + ebReadingPerUnitTon : $(this).find(`td[data-id='${dateInYmD} ebReadingPerUnitTon']`) , + workingPersonEngineers : $(this).find(`td[data-id='${dateInYmD} workingPersonEngineers']`) , + workingPersonSupervisiors : $(this).find(`td[data-id='${dateInYmD} workingPersonSupervisiors']`) , + workingPersonOperators : $(this).find(`td[data-id='${dateInYmD} workingPersonOperators']`) , + rollerDrivers : $(this).find(`td[data-id='${dateInYmD} rollerDrivers']`) , + natureOfMaintenance : $(this).find(`td[data-id='${dateInYmD} natureOfMaintenance']`) , + location : $(this).find(`td[data-id='${dateInYmD} location']`) , + description : $(this).find(`td[data-id='${dateInYmD} description']`) , + msSeperation : $(this).find(`td[data-id='${dateInYmD} msSeperation']`) , + edWaste : $(this).find(`td[data-id='${dateInYmD} edWaste']`) , + coolerBags : $(this).find(`td[data-id='${dateInYmD} coolerBags']`) , + edPlus20Waste : $(this).find(`td[data-id='${dateInYmD} edPlus20Waste']`) , + cycloneWaste : $(this).find(`td[data-id='${dateInYmD} cycloneWaste']`) , }; @@ -1657,38 +1682,57 @@ $timeOtions[] = "12:00 AM"; let tr = $(tdElement).closest('tr'); + let date = tr.find('td:eq(0)').text().trim() ; - let totalHours = validateInput(tr.find('td:eq(3)').text().trim()) ?? 0; - let coldStart = validateInput(tr.find('td:eq(4)').text().trim()) ?? 0; - let breakdownHours = validateInput(tr.find('td:eq(5)').text().trim()) ?? 0; - let burnerFiringHours = tr.find('td:eq(6)').text().trim() ?? 0; - let sandFeedingHours = tr.find('td:eq(7)').text().trim() ?? 0; + date = `${date.split('-')[2]}-${date.split('-')[1]}-${date.split('-')[0]}`; + + let totalHours = validateInput(document.querySelector(`td.totalHours[data-id="${date} totalHours"]`).innerText) ?? 0; + + let coldStart = validateInput(document.querySelector(`td.coldStart[data-id="${date} coldStart"]`).innerText) ?? 0; + + let breakdownHours = validateInput(document.querySelector(`td.breakdownHours[data-id="${date} breakdownHours"]`).innerText) ?? 0; + + let burnerFiringHours = validateInput(document.querySelector(`td.burnerFiringHours[data-id="${date} burnerFiringHours"]`).innerText) ?? 0; + + let sandFeedingHours = validateInput(document.querySelector(`td.sandFeedingHours[data-id="${date} sandFeedingHours"]`).innerText) ?? 0; - let gasReceiptBg = tr.find('td:eq(8)').text().trim() ?? 0; - let gasReceiptPg = tr.find('td:eq(9)').text().trim() ?? 0; - let physicalGasConsumption = validateInput(tr.find('td:eq(10)').text().trim()) ?? 0; - let drierGasConsumption = validateInput(tr.find('td:eq(11)').text().trim()) ?? 0; - let coatingGasConsumption = validateInput(tr.find('td:eq(12)').text().trim()) ?? 0; - let trpPlusDrierGasConsumption = tr.find('td:eq(13)').text().trim() ?? 0; - let trpPhysicalGasPerTon = tr.find('td:eq(14)').text().trim() ?? 0; - let panelGasConsumption = (tr.find('td:eq(15)').text().trim()) ?? 0; - let panelGasPerTon = tr.find('td:eq(16)').text().trim() ?? 0; + let gasReceiptBg = validateInput(document.querySelector(`td.gasReceiptBg[data-id="${date} gasReceiptBg"]`).innerText) ?? 0; + + let gasReceiptPg = validateInput(document.querySelector(`td.gasReceiptPg[data-id="${date} gasReceiptPg"]`).innerText) ?? 0; + + let physicalGasConsumption = validateInput(document.querySelector(`td.physicalGasConsumption[data-id="${date} physicalGasConsumption"]`).innerText) ?? 0; + + let drierGasConsumption = validateInput(document.querySelector(`td.drierGasConsumption[data-id="${date} drierGasConsumption"]`).innerText) ?? 0; + + let coatingGasConsumption = validateInput(document.querySelector(`td.coatingGasConsumption[data-id="${date} coatingGasConsumption"]`).innerText) ?? 0; + + let trpPlusDrierGasConsumption = validateInput(document.querySelector(`td.trpPlusDrierGasConsumption[data-id="${date} trpPlusDrierGasConsumption"]`).innerText) ?? 0; + + let trpPhysicalGasPerTon = validateInput(document.querySelector(`td.trpPhysicalGasPerTon[data-id="${date} trpPhysicalGasPerTon"]`).innerText) ?? 0; + + let panelGasConsumption = validateInput(document.querySelector(`td.panelGasConsumption[data-id="${date} panelGasConsumption"]`).innerText) ?? 0; + + let panelGasPerTon = validateInput(document.querySelector(`td.panelGasPerTon[data-id="${date} panelGasPerTon"]`).innerText) ?? 0; + + let edRunningHours = validateInput(document.querySelector(`td.edRunningHours[data-id="${date} edRunningHours"]`).innerText) ?? 0; + + let edProduction = validateInput(document.querySelector(`td.edProduction[data-id="${date} edProduction"]`).innerText) ?? 0; + + let edUsage = validateInput(document.querySelector(`td.edUsage[data-id="${date} edUsage"]`).innerText) ?? 0; + + let trpProduction = validateInput(document.querySelector(`td.trpProduction[data-id="${date} trpProduction"]`).innerText) ?? 0; + + let trpProductionPerHour = validateInput(document.querySelector(`td.trpProductionPerHour[data-id="${date} trpProductionPerHour"]`).innerText) ?? 0; + + let coating = validateInput(document.querySelector(`td.coating[data-id="${date} coating"]`).innerText) ?? 0; - let edRunningHours = tr.find('td:eq(24)').text().trim() ?? 0; - let edProduction = tr.find('td:eq(25)').text().trim() ?? 0; - let edUsage = tr.find('td:eq(26)').text().trim() ?? 0; - let trpProduction = validateInput(tr.find('td:eq(27)').text().trim()) ?? 0; - let trpProductionPerHour = tr.find('td:eq(28)').text().trim() ?? 0; - let coating = tr.find('td:eq(29)').text().trim() ?? 0; - - let ebReading = tr.find('td:eq(37)').text().trim() ?? 0; - let ebReadingPerUnitTon = tr.find('td:eq(38)').text().trim() ?? 0; + let ebReading = validateInput(document.querySelector(`td.ebReading[data-id="${date} ebReading"]`).innerText) ?? 0; + + let ebReadingPerUnitTon = validateInput(document.querySelector(`td.ebReadingPerUnitTon[data-id="${date} ebReadingPerUnitTon"]`).innerText) ?? 0; - - - let result = calculateSandFeedingHours(totalHours, coldStart, breakdownHours, burnerFiringHours); + let result = calculateSandFeedingHours(totalHours, coldStart, breakdownHours, burnerFiringHours); sandFeedingHours = result[0]; @@ -1709,19 +1753,22 @@ $timeOtions[] = "12:00 AM"; // Final updation of value into td - tr.find('td:eq(7)').text(Number.isNaN(sandFeedingHours) ? " " : sandFeedingHours); + document.querySelector(`td.sandFeedingHours[data-id="${date} sandFeedingHours"]`).innerText = isFinite(sandFeedingHours) ? sandFeedingHours : " "; - tr.find('td:eq(6)').text(Number.isNaN(burnerFiringHours) ? " " : burnerFiringHours); + document.querySelector(`td.burnerFiringHours[data-id="${date} burnerFiringHours"]`).innerText = isFinite(burnerFiringHours) ? burnerFiringHours : " "; - tr.find('td:eq(13)').text(Number.isNaN(trpPlusDrierGasConsumption) ? " " : (trpPlusDrierGasConsumption).toFixed(2)); + document.querySelector(`td.trpPlusDrierGasConsumption[data-id="${date} trpPlusDrierGasConsumption"]`).innerText = isFinite(trpPlusDrierGasConsumption) ? trpPlusDrierGasConsumption : " "; - tr.find('td:eq(14)').text(Number.isNaN(trpPhysicalGasPerTon) ? " " : (trpPhysicalGasPerTon).toFixed(2)); + document.querySelector(`td.trpPhysicalGasPerTon[data-id="${date} trpPhysicalGasPerTon"]`).innerText = isFinite(trpPhysicalGasPerTon) ? (trpPhysicalGasPerTon).toFixed(2) : " "; - tr.find('td:eq(16)').text(Number.isNaN(panelGasPerTon) ? " " : (panelGasPerTon.toFixed(2))); + document.querySelector(`td.sandFeedingHours[data-id="${date} sandFeedingHours"]`).innerText = isFinite(sandFeedingHours) ? sandFeedingHours : " "; - tr.find('td:eq(28)').text(Number.isNaN(trpProductionPerHour) ? " " : (trpProductionPerHour).toFixed(2)); + document.querySelector(`td.panelGasPerTon[data-id="${date} panelGasPerTon"]`).innerText = isFinite(panelGasPerTon) ? (panelGasPerTon).toFixed(2) : " "; + + document.querySelector(`td.trpProductionPerHour[data-id="${date} trpProductionPerHour"]`).innerText = isFinite(trpProductionPerHour) ? trpProductionPerHour : " "; + + document.querySelector(`td.ebReadingPerUnitTon[data-id="${date} ebReadingPerUnitTon"]`).innerText = isFinite(ebReadingPerUnitTon) ? (ebReadingPerUnitTon).toFixed(2) : " "; - tr.find('td:eq(38)').text(Number.isNaN(ebReadingPerUnitTon) ? " " : (ebReadingPerUnitTon).toFixed(2)); @@ -1749,6 +1796,9 @@ $timeOtions[] = "12:00 AM"; var tr = $(this).closest('tr'); + let date = tr.find('td:eq(0)').text().trim() ; + + date = `${date.split('-')[2]}-${date.split('-')[1]}-${date.split('-')[0]}`; var trpOnTime = tr.find('.trp_on_time').val(); var trpOffTime = tr.find('.trp_off_time').val(); @@ -1777,7 +1827,7 @@ $timeOtions[] = "12:00 AM"; const totalHours = hours + "." + minutes; - tr.find('td:eq(3)').text(totalHours); + document.querySelector(`td.totalHours[data-id="${date} totalHours"]`).innerText = totalHours; trpStockChange(this); From 41f6ac2d5e6b28df4d588249156cbf4beded33f9 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 19 Feb 2025 09:27:48 +0000 Subject: [PATCH 07/26] bug fixes --- app/Controllers/Inwardgateregister.php | 148 +++++++++++++----------- app/Controllers/Rawmaterialdetails.php | 4 +- app/Models/Config_model.php | 43 ++++--- app/Models/Inwardgateregister_model.php | 27 +++-- app/Models/Rawmaterialdetails_model.php | 4 +- app/Views/addRawMaterial.php | 5 +- app/Views/editEmployeenew.php | 50 ++++---- app/Views/editRawmaterial.php | 7 +- app/Views/editconfig.php | 109 ++++++++++++++++- app/Views/po_pdf.php | 10 +- app/Views/viewinwardgateregister.php | 12 +- 11 files changed, 279 insertions(+), 140 deletions(-) diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index 9a338ea4..209ca1bc 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -402,9 +402,9 @@ class Inwardgateregister extends BaseController $IsThisOpenOrderPO = $this->request->getPost('hiddenIsOpenOrder'); $DeliveryChellanOrInvoiceNo = $this->request->getPost('InvoiceNo'); $DeliveryChellan = (string)$this->request->getPost('InvoiceDate'); - $DeliveryChellanDate = get_date_time_dynamical_format('d-m-Y','',$DeliveryChellan); + $DeliveryChellanDate = !$DeliveryChellan || $DeliveryChellan === null ? NULL : get_date_time_format($DeliveryChellan); $Mat_Rcvd_Dt = (string)$this->request->getPost('MaterialRcvdDate'); - $MaterialRcvdDt = get_date_time_dynamical_format('d-m-Y','',$Mat_Rcvd_Dt); + $MaterialRcvdDt = !$Mat_Rcvd_Dt || $Mat_Rcvd_Dt === null ? NULL : get_date_time_format($Mat_Rcvd_Dt); $VehicleNo = $this->request->getPost('VehicleNo'); $TransporterId = $this->request->getPost('TransporterId'); $DriverName = $this->request->getPost('DriverName'); @@ -834,6 +834,7 @@ function viewIGRDetails() $getigrstatus = $this->inwardgateregister_model->getigrstatus($IGRNo); $getigrstatus = $getigrstatus->IGRStatus; $updateigrmaster = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo); + log_message('error', "Master updated successfully: " . $updateigrmaster); if(!empty($tableData )){ @@ -893,76 +894,89 @@ function viewIGRDetails() $notification = new Notification(); - $history_content = "IGR History


"; + $history_content = "
IGR History

    "; $history = $result_for_history['history']; - $field_labels = [ - "IGRNO" => "IGRNO", - "PONO" => "PONO", - "DeliveryChellanOrInvoiceNo" => "Invoice NO", - "DeliveryChellanDate" => "Invoice Date", - "MaterialRcvdDate" => "Material Received Date", - "VehicleNo" => "Vehicle Number", - "VehicleType" => "Vehicle Type", - "TransporterId" => "Transporter Id", - "CourierNo" => "Courier No", - "Remark" => "Master Remark", - "IGRStatus" => "IGR Status", - "file" => "File", - "Paymentstatus" => "Payment Status", - "DriverName" => "Driver Name", - "DriverMobileNumber" => "Driver Mobile Number", - "MasterFile" => "Master File", - "IGRItemNo" => "IGR Item No", - "MaterialCode" => "Material Code", - "QuantityAsPerInvoice" => "Received Qty", - "Remarks" => "Remarks", - "IGRItemStatus" => "IGR Item Status", - "CancelNote" => "Cancel Note", - "BankStatus" => "Bank Status", - "GrossWeight" => "Gross Weight", - "GrossWeightDate" => "Gross Weight Date", - "TareWeight" => "Tare Weight", - "TareWeightDate" => "Tare Weight Date", - "NetWeight" => "Net Weight", - "WeightFile" => "Weight File" - ]; - // $history_content = "
    The following values have been edited:"; + if(!empty($history)){ - for ($j = 0; $j < count($history); $j++) { - - $field_name = $history[$j]->field; - $readable_field = isset($field_labels[$field_name]) ? $field_labels[$field_name] : $field_name; - $history_content .= "
    " . $readable_field . " `" . $history[$j]->old_data . "` was updated into `" . $history[$j]->new_data . "` by ".$history[$j]->history_by." on ".$history[$j]->indian_date." at ".$history[$j]->indian_time; - // $history_content .= "
    " . $readable_field . ": `" . $history[$j]->old_data . "` was updated to `" . $history[$j]->new_data . "` ."; - } - $email = ""; - for ($i = 0; $i < count($result_for_email['emails']); $i++) { - $email .= $result_for_email['emails'][$i]->email . " , "; - } - $email = rtrim($email, " ,"); - - $email_response = $notification->sendEmail([ - 'recipient_email' => $email, - 'subject' => $result_for_email['company'].' - IGR Notification', - // 'description' => 'IGR Number : '.$IGRNo.' is Edited By '.($result_for_email['full_name'] ?? $this->session->get('name'))." On ".date('d-m-Y H:i A', strtotime(get_current_date_time() . ' +30 seconds')). $history_content, - 'description' => 'PONO '.$PONo.$result_for_history['first_line'].$history_content, - 'company' => $result_for_email['company'], - 'from_mail'=> $result_for_email['from_mail'] - ]); + $field_labels = [ + "IGRNO" => "IGRNO", + "PONO" => "PONO", + "DeliveryChellanOrInvoiceNo" => "Invoice NO", + // "DeliveryChellanDate" => "Invoice Date", + // "MaterialRcvdDate" => "Material Received Date", + "VehicleNo" => "Vehicle Number", + "VehicleType" => "Vehicle Type", + "TransporterId" => "Transporter Id", + "CourierNo" => "Courier No", + "Remark" => "Master Remark", + "IGRStatus" => "IGR Status", + "file" => "File", + "Paymentstatus" => "Payment Status", + "DriverName" => "Driver Name", + "DriverMobileNumber" => "Driver Mobile Number", + "MasterFile" => "Master File", + "IGRItemNo" => "IGR Item No", + "MaterialCode" => "Material Code", + "QuantityAsPerInvoice" => "Received Qty", + "Remarks" => "Remarks", + "IGRItemStatus" => "IGR Item Status", + "CancelNote" => "Cancel Note", + "BankStatus" => "Bank Status", + "GrossWeight" => "Gross Weight", + "GrossWeightDate" => "Gross Weight Date", + "TareWeight" => "Tare Weight", + "TareWeightDate" => "Tare Weight Date", + "NetWeight" => "Net Weight", + "WeightFile" => "Weight File" + ]; + // $history_content = "
    The following values have been edited:"; //old Format + + for ($j = 0; $j < count($history); $j++) { + $field_name = $history[$j]->field; + $readable_field = isset($field_labels[$field_name]) ? $field_labels[$field_name] : $field_name; + $history_content .= "
  • " . + (($history[$j]->IGRItem_No) + ? $history[$j]->MaterialName . " (" . $history[$j]->MaterialCode . ") - " + : "") . + $readable_field . " " . $history[$j]->old_data . + " was updated into " . $history[$j]->new_data . + " by " . $history[$j]->history_by . + " on " . $history[$j]->indian_date . + " at " . $history[$j]->indian_time . + "

  • "; + // $history_content .= "
    " . $readable_field . ": `" . $history[$j]->old_data . "` was updated to `" . $history[$j]->new_data . "` ."; + } + $history_content .= "
"; + $email = ""; + for ($i = 0; $i < count($result_for_email['emails']); $i++) { + $email .= $result_for_email['emails'][$i]->email . " , "; + } + $email = rtrim($email, " ,"); + $email_response = $notification->sendEmail([ + 'recipient_email' => "sanjeev.p@venbainfotech.com", + 'subject' => $result_for_email['company'].' - IGR Notification', + // 'description' => 'IGR Number : '.$IGRNo.' is Edited By '.($result_for_email['full_name'] ?? $this->session->get('name'))." On ".date('d-m-Y H:i A', strtotime(get_current_date_time() . ' +30 seconds')). $history_content, + 'description' => $result_for_history['first_line']."
" .$history_content, + 'company' => $result_for_email['company'], + 'from_mail'=> $result_for_email['from_mail'] + ]); - log_message('error', 'email reponse : ' . json_encode($email_response)); - // Determine the email response - $mail_log = isset($email_response['success']) ? 'Email sent successfully' : 'Failed to send email'; - $receiving_status = isset($email_response['success']) ? 1 : 0; + log_message('error', 'email reponse : ' . json_encode($email_response)); + // Determine the email response + $mail_log = isset($email_response['success']) ? 'Email sent successfully' : 'Failed to send email'; + $receiving_status = isset($email_response['success']) ? 1 : 0; - // Log the result - if ($receiving_status) { - $this->logger->info("Email IDs = " . $email . " " . $mail_log); - } else { - $this->logger->error("Email IDs = " . $email . " " . $mail_log); - } + // Log the result + if ($receiving_status) { + $this->logger->info("Email IDs = " . $email . " " . $mail_log); + } else { + $this->logger->error("Email IDs = " . $email . " " . $mail_log); + } - // echo "***".$history_content;die; + // echo "***".$history_content;die; + }else{ + $this->logger->info("History content Not Founded...."); + } } if ($updateigrmaster > 0) { diff --git a/app/Controllers/Rawmaterialdetails.php b/app/Controllers/Rawmaterialdetails.php index a4586d0d..738e2c69 100755 --- a/app/Controllers/Rawmaterialdetails.php +++ b/app/Controllers/Rawmaterialdetails.php @@ -370,10 +370,8 @@ class Rawmaterialdetails extends BaseController $materialCode = $data['materialCode'] ?? ''; $materialName = str_replace(' ', '', $data['materialName']); $materialCategory = $data['materialCategory'] ?? ''; - $materialType = $data['materialType'] ?? ''; - - $query = $this->rawmaterialdetails_model->checkMaterialExists($materialCode , $materialName , $materialCategory,$materialType); + $query = $this->rawmaterialdetails_model->checkMaterialExists($materialCode , $materialName , $materialCategory); return $this->response->setJSON($query); diff --git a/app/Models/Config_model.php b/app/Models/Config_model.php index 960118d6..f5a9ef3e 100755 --- a/app/Models/Config_model.php +++ b/app/Models/Config_model.php @@ -238,19 +238,36 @@ class Config_model extends Model // $query = $builder->get(); // $result = $query->getResultArray(); // return $result; - $builder = $this->db->table('t_purchaseorder_lineitem pl') - ->select(['po.PONO',"DATE_FORMAT(po.PODate, '%d-%m-%Y') as PODate",'mm.MaterialName','CD.Key','CD.ConfigValue as CategoryName','s.StatusName','s.statusCode']) - ->join('t_purchaseorder_master po', 'po.PONO = pl.PONO') - ->join('t_materialmaster mm', 'mm.MaterialCode = pl.MaterialCode') - ->join('t_configdetails CD', 'CD.Key = mm.Category') - ->join('t_status s', 's.statusCode = po.Status', 'left') - ->where('CD.Key', $key_id) - ->whereIn('po.Status', [PO_DRAFT,PO_CREATED,REQ_PO_CREATED,PO_RELEASED,REQITEM_Emergency_PO_CREATED,IGR_DRAFT,IGR_DRAFT,OPEN_ORDER_PO]) - ->groupBy('po.PONO') - ->orderBy('po.CreatedDate', 'DESC'); - $query = $builder->get(); - $result = $query->getResultArray(); - return $result; + + + // return $this->db->table('t_purchaseorder_lineitem as pl') + // ->select('DISTINCT po.PONO, DATE_FORMAT(po.PODate, "%d-%m-%Y") as PODate, mm.MaterialName, CD.Key, CD.ConfigValue as CategoryName, s.StatusName, s.statusCode, po.POType, po.CapitalRange') + // ->join('t_purchaseorder_master po', 'po.PONO = pl.PONO') + // ->join('t_materialmaster mm', 'mm.MaterialCode = pl.MaterialCode') + // ->join('t_configdetails CD', 'CD.Key = mm.Category') + // ->join('t_status s', 's.statusCode = po.Status', 'left') // Left join + // ->where('CD.Key', $key_id) + // ->whereIn('po.Status', ['ST014', 'ST015', 'ST005', 'ST026', 'ST024', 'ST074', 'ST073']) + // ->orderBy('po.CreatedDate', 'DESC') + // ->get() + // ->getResultArray(); + + $subQuery = "SELECT DISTINCT po.PONO, DATE_FORMAT(po.PODate, '%d-%m-%Y') as PODate, + mm.MaterialName, CD.Key, CD.ConfigValue as CategoryName, + s.StatusName, s.statusCode, po.POType, po.CapitalRange + FROM t_purchaseorder_lineitem pl + JOIN t_purchaseorder_master po ON po.PONO = pl.PONO + JOIN t_materialmaster mm ON mm.MaterialCode = pl.MaterialCode + JOIN t_configdetails CD ON CD.Key = mm.Category + LEFT JOIN t_status s ON s.statusCode = po.Status + WHERE CD.Key = ? + AND po.Status IN (?, ?, ?, ?, ?, ?, ?) + ORDER BY po.CreatedDate DESC"; + +$query = $this->db->query($subQuery, [$key_id, 'ST014', 'ST015', 'ST005', 'ST026', 'ST024', 'ST074', 'ST073']); +$result = $query->getResultArray(); +return $result; + // 'OPEN_ORDER_PO','ST073' // 'IGR_DRAFT','ST074' // 'IGR_CREATED','ST027' diff --git a/app/Models/Inwardgateregister_model.php b/app/Models/Inwardgateregister_model.php index 5a4d67be..d8e6aa41 100755 --- a/app/Models/Inwardgateregister_model.php +++ b/app/Models/Inwardgateregister_model.php @@ -221,6 +221,13 @@ class Inwardgateregister_model extends Model } public function igr_history($hsty_arr) { + $keysToRemove = ["UpdateBY", "MaterialRcvdDate", "DeliveryChellanDate"]; + foreach ($keysToRemove as $key) { + if (isset($hsty_arr[$key])) { + unset($hsty_arr[$key]); + } + } + $builder = $this->db->table('t_igr_history'); $builder->insert($hsty_arr); @@ -1087,17 +1094,19 @@ class Inwardgateregister_model extends Model { $builder = $this->db->table('t_igr_history'); - $builder->select('t_igr_history.*, DATE_FORMAT(t_igr_history.history_dated, "%d-%m-%Y") AS indian_date, DATE_FORMAT(t_igr_history.history_dated, "%h:%i:%s %p") AS indian_time, CONCAT_WS(" ", t_employee_details.FirstName, t_employee_details.LastName) AS FullName'); + $builder->select('t_igr_history.*, DATE_FORMAT(t_igr_history.history_dated, "%d-%m-%Y") AS indian_date, DATE_FORMAT(t_igr_history.history_dated, "%h:%i:%s %p") AS indian_time, CONCAT_WS(" ", t_employee_details.FirstName, t_employee_details.LastName) AS FullName,t_materialmaster.MaterialName,t_materialmaster.MaterialName,t_materialmaster.MaterialCode'); $builder->join('tbl_users', 'tbl_users.userId = t_igr_history.by', 'left'); $builder->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID', 'left'); - $builder->where('IGR_No', $igr); + $builder->join('t_igr_details', 'CONVERT(t_igr_history.IGRItem_No USING utf8) = CONVERT(t_igr_details.IGRItemNo USING utf8)', 'left'); + $builder->join('t_materialmaster', 'CONVERT(t_materialmaster.MaterialCode USING utf8) = CONVERT(t_igr_details.MaterialCode USING utf8)', 'left'); + $builder->where('CONVERT(IGR_No USING utf8)', $igr); + $builder->orderBy('t_igr_history.history_dated', 'asc'); + // $builder->where('IGR_No', $igr); $query = $builder->get(); $result = $query->getResult(); return $result; - // Pass the result to the view or return it as JSON - // return $this->response->setJSON($result); } public function isFileExistsInIGRmaster($filename) { @@ -1211,7 +1220,7 @@ class Inwardgateregister_model extends Model $to = date('Y-m-d H:i:s', strtotime($date . ' +30 seconds')); $from = date('Y-m-d H:i:s', strtotime($date . ' -30 seconds')); - $query3 = $this->db->query("Select t_igr_history.history_dated,DATE_FORMAT(t_igr_history.history_dated, '%d-%m-%Y') AS indian_date,DATE_FORMAT(t_igr_history.history_dated, '%h:%i:%s %p') AS indian_time , + $query3 = $this->db->query("Select t_igr_history.IGR_No,t_igr_history.history_dated,DATE_FORMAT(t_igr_history.history_dated, '%d-%m-%Y') AS indian_date,DATE_FORMAT(t_igr_history.history_dated, '%h:%i:%s %p') AS indian_time , t_igr_history.by,CONCAT_WS(' ', t_employee_details.FirstName, t_employee_details.LastName) AS history_by from t_igr_history LEFT JOIN tbl_users ON tbl_users.userId = t_igr_history.by @@ -1255,13 +1264,15 @@ $builder = $this->db->table('t_igr_history') THEN (SELECT StatusName FROM t_status WHERE StatusCode = t_igr_history.old_data LIMIT 1) ELSE t_igr_history.old_data END AS old_data, - t_igr_history.old_data as original_old_data + t_igr_history.old_data as original_old_data,t_materialmaster.MaterialName,t_materialmaster.MaterialCode ') // ->join('t_igr_details IGRD', 'IGRD.IGRItemNo = t_igr_history.IGRItem_No','left') // ->join('t_materialmaster MM','MM.MaterialCode = IGRD.MaterialCode','left') ->join('tbl_users', 'tbl_users.userId = t_igr_history.by','left') ->join('t_employee_details','tbl_users.EmpID = t_employee_details.EmpID','left') - ->where('t_igr_history.IGR_No', $igr) + ->join('t_igr_details', 'CONVERT(t_igr_history.IGRItem_No USING utf8) = CONVERT(t_igr_details.IGRItemNo USING utf8)', 'left') + ->join('t_materialmaster', 'CONVERT(t_materialmaster.MaterialCode USING utf8) = CONVERT(t_igr_details.MaterialCode USING utf8)', 'left') + ->where('CONVERT(t_igr_history.IGR_No USING utf8)', $igr) ->where('t_igr_history.is_edit', 1) ->where('t_igr_history.history_dated BETWEEN "'.$from.'" AND "'.$to.'"'); @@ -1271,7 +1282,7 @@ $builder = $this->db->table('t_igr_history') // echo $this->db->getLastQuery()->getQuery(); die; return [ 'history' => $result, - 'first_line' => $first_line ? " was added by ". $first_line->history_by ." on ". $first_line->indian_date ." at ". $first_line->indian_time : null, + 'first_line' => $first_line ? $first_line->IGR_No ." was Created by ". $first_line->history_by ." on ". $first_line->indian_date ." at ". $first_line->indian_time : null, ]; } diff --git a/app/Models/Rawmaterialdetails_model.php b/app/Models/Rawmaterialdetails_model.php index edc073e5..31db025e 100755 --- a/app/Models/Rawmaterialdetails_model.php +++ b/app/Models/Rawmaterialdetails_model.php @@ -330,8 +330,7 @@ class Rawmaterialdetails_model extends Model // on 28/jan/2025. both add and edit. category condition added. - // on 13/Feb/2025. Change based On Config Child Values. - function checkMaterialExists($materialCode , $materialName ,$materialCategory,$materialType) + function checkMaterialExists($materialCode,$materialName ,$materialCategory) { $builder = $this->db->table('t_materialmaster MM') @@ -341,7 +340,6 @@ class Rawmaterialdetails_model extends Model $builder = $builder->where('MM.MaterialCode !=' , $materialCode); } $builder->where('MM.Category' , $materialCategory); - $builder->where('MM.MaterialType' , $materialType); $builder->where('REPLACE(MM.MaterialName, " ", "")' , $materialName); $query = $builder->get(); diff --git a/app/Views/addRawMaterial.php b/app/Views/addRawMaterial.php index 76de4439..66c40e91 100755 --- a/app/Views/addRawMaterial.php +++ b/app/Views/addRawMaterial.php @@ -314,10 +314,7 @@ $('#loader').show(); $.ajax({ - data: { - materialCode,materialType, - materialName,materialCategory - }, + data: {materialCode,materialName,materialCategory}, type: "POST", url: "materialExist", success: function(data) { diff --git a/app/Views/editEmployeenew.php b/app/Views/editEmployeenew.php index e8a326ce..8c593f3c 100755 --- a/app/Views/editEmployeenew.php +++ b/app/Views/editEmployeenew.php @@ -779,31 +779,6 @@ if (!empty($EmpDetails)) {
-
-
- - -
-
-
-
- - * - - - -
-
@@ -827,6 +802,31 @@ if (!empty($EmpDetails)) { title="Enter the valid PF Rate, Minimum 1 digit, Maximum 2 digits" readonly /> +
+
+
+
+ + +
+
+
+
+ + * + + +
diff --git a/app/Views/editRawmaterial.php b/app/Views/editRawmaterial.php index 67a0832a..5f4ac772 100755 --- a/app/Views/editRawmaterial.php +++ b/app/Views/editRawmaterial.php @@ -414,12 +414,7 @@ if ($total <= $reorder) { $('#loader').show(); $.ajax({ - data: { - materialCode, - materialName, - materialCategory, - materialType - }, + data: {materialCode,materialName,materialCategory}, type: "POST", url: "materialExist", success: function(data) { diff --git a/app/Views/editconfig.php b/app/Views/editconfig.php index 20bf6e67..e5a198d9 100755 --- a/app/Views/editconfig.php +++ b/app/Views/editconfig.php @@ -149,7 +149,11 @@ if (!empty($master)) { } ?>"> - ConfigValue; ?> + Config_ID === 'C023'){ ?> + ConfigValue ?> + + ConfigValue; ?> + isActive == 0) { ?> @@ -308,6 +312,25 @@ if (!empty($master)) {
+ + @@ -489,6 +512,90 @@ if (!empty($master)) { } } + + $(".config-category").click(function () { + + const key_id = $(this).data("key"); + const value = $(this).data("value"); + $('#loader').show(); + + $('#scrollableModalTitle').text(`List of PO created using ${value} `); + // AJAX API call + $.ajax({ + url: "", + data: { key_id: key_id }, + method: 'POST', + dataType: 'json', + success: function (response) { + if (response.length > 0) { + let tableHtml = ` + + + + + + + + + + + + + `; + + response.forEach(item => { + + tableHtml += ` + + + + + + + + + `; + }); + + tableHtml += ` + +
PO NumberPO DateMaterial NamePO TypePO Status
+ ${item.PONO} + ${item.PODate}${item.MaterialName}${item.POType}${item.StatusName}
+ `; + + // Insert the table into the modal body + $('#scrollable-modal .modal-body').html(tableHtml); + + // Show the modal + $('#scrollable-modal').modal('show'); + + // Attach click event to PONO cells after the table is rendered + $('.pono-cell').click(function () { + const pono = $(this).data('pono'); + const ReqType = $(this).data('potype'); + const CapitalRange = $(this).data('capitalrange'); + const url = 'EditPO?PONO=' + pono +'&ReqType='+ReqType+'&CapitalRange='+CapitalRange; + + window.open(url, '_blank'); + // window.location.href = url; + }); + + } else { + $('#scrollable-modal .modal-body').html('

No data found.

'); + $('#scrollable-modal').modal('show'); + } + + $('#loader').hide(); + }, + error: function (xhr, status, error) { + // Handle any errors + console.error("API Error:", error); + alert("Failed to load material data."); + } + }); + }); + }); diff --git a/app/Views/po_pdf.php b/app/Views/po_pdf.php index 683d364f..b2b75fd7 100755 --- a/app/Views/po_pdf.php +++ b/app/Views/po_pdf.php @@ -519,7 +519,6 @@
-
@@ -581,19 +580,23 @@ MaterialCode . ' - ') . ($item->MaterialName . $item->ServiceMaterialDescription); + echo ($item->LineitemAuditorNotes == '-' ? '' : '
( ' . $item->LineitemAuditorNotes. ' )
'); } ?> MaterialCode . ' - ') . ($item->MaterialName ? $item->MaterialName : $item->ServiceMaterialDescription); + echo ($item->LineitemAuditorNotes == '-' ? '' : '
( ' . $item->LineitemAuditorNotes. ' )
'); } ?> MaterialCode . ' - ') . ($item->MaterialName); + echo ($item->LineitemAuditorNotes == '-' ? '' : '
( ' . $item->LineitemAuditorNotes. ' )
'); } ?> MaterialCode . ' - ') . ($item->MaterialName); + echo ($item->LineitemAuditorNotes == '-' ? '' : '
( ' . $item->LineitemAuditorNotes. ' )
'); + //old -- echo ($item->LineitemAuditorNotes == '-' ? '' : '
'.$item->LineitemAuditorNotes ); } ?> HSNCODE ?? 'N/A'; ?> - LineitemAuditorNotes; ?> Quantity > 0) { echo number_alignment($item->Quantity); if ($item->Per) : ?> @@ -658,14 +661,13 @@ -   -  TOTAL +  TOTAL