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

"; + $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