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/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/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/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/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/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/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/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(); }); 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; }