Merge branch 'new_theme' of bitbucket.org:venbainformationtechnology/ria into new_theme
This commit is contained in:
commit
02f7a51594
@ -147,8 +147,8 @@ $routes->get('configurationctrl/reActivateConfigValue', 'Configurationctrl::reAc
|
|||||||
$routes->get('configurationctrl/editconfig', 'Configurationctrl::editconfig');
|
$routes->get('configurationctrl/editconfig', 'Configurationctrl::editconfig');
|
||||||
$routes->post('configurationctrl/updateconfig', 'Configurationctrl::updateconfig');
|
$routes->post('configurationctrl/updateconfig', 'Configurationctrl::updateconfig');
|
||||||
$routes->post('configurationctrl/configNameCheck', 'Configurationctrl::configNameCheck');
|
$routes->post('configurationctrl/configNameCheck', 'Configurationctrl::configNameCheck');
|
||||||
$routes->get('configurationctrl/deleteConfig', 'configurationctrl::deleteConfig');
|
$routes->get('configurationctrl/deleteConfig', 'Configurationctrl::deleteConfig');
|
||||||
$routes->get('configurationctrl/reActivateConfig', 'configurationctrl::reActivateConfig');
|
$routes->get('configurationctrl/reActivateConfig', 'Configurationctrl::reActivateConfig');
|
||||||
|
|
||||||
// Department Master Routes
|
// Department Master Routes
|
||||||
$routes->get('departmentListing', 'Department::index');
|
$routes->get('departmentListing', 'Department::index');
|
||||||
@ -304,7 +304,6 @@ $routes->post('GetIGRLineItemDetails', 'Inwardgateregister::getIGRLineItemDetail
|
|||||||
$routes->post('SaveIGR', 'Inwardgateregister::SaveIGR');// Save IGR PAGE - Working
|
$routes->post('SaveIGR', 'Inwardgateregister::SaveIGR');// Save IGR PAGE - Working
|
||||||
$routes->post('UpdateIGR', 'Inwardgateregister::UpdateIGR');
|
$routes->post('UpdateIGR', 'Inwardgateregister::UpdateIGR');
|
||||||
$routes->post('updateIGRWeight', 'Inwardgateregister::updateIGRWeight');
|
$routes->post('updateIGRWeight', 'Inwardgateregister::updateIGRWeight');
|
||||||
$routes->post('UpdateIGRLineItem', 'Inwardgateregister::updateIGRLineItem');
|
|
||||||
$routes->post('ViewIGRHistory', 'Inwardgateregister::ViewIGRHistory');
|
$routes->post('ViewIGRHistory', 'Inwardgateregister::ViewIGRHistory');
|
||||||
$routes->post('getCostCenterData', 'Inwardgateregister::getCostCenterData');
|
$routes->post('getCostCenterData', 'Inwardgateregister::getCostCenterData');
|
||||||
$routes->post('ViewIGRfile', 'Inwardgateregister::ViewIGRfile');
|
$routes->post('ViewIGRfile', 'Inwardgateregister::ViewIGRfile');
|
||||||
|
|||||||
@ -450,6 +450,7 @@ class Inwardgateregister extends BaseController
|
|||||||
$IGRNO = $this->inwardgateregister_model->addigrM($igr);
|
$IGRNO = $this->inwardgateregister_model->addigrM($igr);
|
||||||
|
|
||||||
if($IGRNO){
|
if($IGRNO){
|
||||||
|
|
||||||
$files = $this->request->getFiles();
|
$files = $this->request->getFiles();
|
||||||
$fileNames = $this->request->getPost('file_name'); // Get user-entered file names
|
$fileNames = $this->request->getPost('file_name'); // Get user-entered file names
|
||||||
if(isset($files['emp_file']))
|
if(isset($files['emp_file']))
|
||||||
@ -476,19 +477,17 @@ class Inwardgateregister extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Step 5 Save Master Detail On History Table
|
#Step 5 Save Master Detail On Stored on History Table
|
||||||
if($VehicleNo){
|
foreach ($igr as $key => $value) {
|
||||||
$hist = array('key' => 'VehicleNo', 'value' => $VehicleNo, 'igr_no' => $IGRNO, 'igr_item_no' => NULL);
|
if (!empty($value)) { // Ensure the value is not empty
|
||||||
$this->saveIGRHistory($hist);
|
if($key == 'CreatedBy'){ $key = 'MasterCreatedBy'; }
|
||||||
}
|
if($key == 'UpdateBY'){ $key = 'MasterUpdatedBy'; }
|
||||||
if($DriverName){
|
if($key == 'CreatedDate'){ $key = 'MasterCreatedDate'; }
|
||||||
$hist = array('key' => 'DriverName', 'value' => $DriverName, 'igr_no' => $IGRNO, 'igr_item_no' => NULL);
|
if($key == 'UpdatedOn'){ $key = 'MasterUpdatedDate'; }
|
||||||
$this->saveIGRHistory($hist);
|
$hist = array( 'key' => $key, 'value' => $value, 'igr_no' => $IGRNO,'igr_item_no' => NULL);
|
||||||
}
|
$this->saveIGRHistory($hist);
|
||||||
if($DriverMobileNumber){
|
}
|
||||||
$hist = array('key' => 'DriverMobileNumber', 'value' => $DriverMobileNumber, 'igr_no' => $IGRNO, 'igr_item_no' => NULL);
|
}
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
|
|
||||||
#Step 6 Updating OGR Details
|
#Step 6 Updating OGR Details
|
||||||
$OGRStatus = $IGRStatus;
|
$OGRStatus = $IGRStatus;
|
||||||
@ -580,33 +579,17 @@ class Inwardgateregister extends BaseController
|
|||||||
}
|
}
|
||||||
$historydetails = array('MaterialCode' => $MaterialCode, 'Transaction_type' => "Add", 'Ref_Type' => "IGR", 'Ref_No' => $igrlineno, 'Quantity' => $QuantityAsPerInvoice, 'CreatedBy' => $CreatedBy, 'CreatedOn' => $createddt, 'SupplierID' => $SupplierId, 'ItemValue' => $itemvalue);
|
$historydetails = array('MaterialCode' => $MaterialCode, 'Transaction_type' => "Add", 'Ref_Type' => "IGR", 'Ref_No' => $igrlineno, 'Quantity' => $QuantityAsPerInvoice, 'CreatedBy' => $CreatedBy, 'CreatedOn' => $createddt, 'SupplierID' => $SupplierId, 'ItemValue' => $itemvalue);
|
||||||
$this->inwardgateregister_model->addmaterialhistory($historydetails);
|
$this->inwardgateregister_model->addmaterialhistory($historydetails);
|
||||||
if($GrossWeight){
|
#Save IGR Detail On History Table
|
||||||
$hist = array('key' => 'GrossWeight', 'value' => $GrossWeight, 'igr_no' => $IGRNO, 'igr_item_no' => $igrlineno);
|
foreach ($igrDetails as $key => $value) {
|
||||||
$this->saveIGRHistory($hist);
|
if (!empty($value)) { // Ensure the value is not empty
|
||||||
}
|
if($key == 'CreatedBy'){ $key = 'LineItemCreatedBy'; }
|
||||||
if($TareWeight){
|
if($key == 'UpdateBY'){ $key = 'LineItemUpdatedBy'; }
|
||||||
$hist = array('key' => 'TareWeight', 'value' => $TareWeight, 'igr_no' => $IGRNO, 'igr_item_no' => $igrlineno);
|
if($key == 'IGRNO'){ $key = 'LineItemIGRNO'; }
|
||||||
$this->saveIGRHistory($hist);
|
if($key == 'CreatedDate'){ $key = 'LineItemCreatedDate'; }
|
||||||
}
|
if($key == 'UpdatedOn'){ $key = 'LineItemUpdatedDate'; }
|
||||||
if($NetWeight){
|
$hist = array( 'key' => $key, 'value' => $value, 'igr_no' => $IGRNO,'igr_item_no' => $igrlineno);
|
||||||
$hist = array('key' => 'NetWeight', 'value' => $NetWeight, 'igr_no' => $IGRNO, 'igr_item_no' => $igrlineno);
|
$this->saveIGRHistory($hist);
|
||||||
$this->saveIGRHistory($hist);
|
}
|
||||||
}
|
|
||||||
if($GrossWeightDate){
|
|
||||||
$hist = array('key' => 'GrossWeightDate', 'value' => $GrossWeightDate, 'igr_no' => $IGRNO, 'igr_item_no' => $igrlineno);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($TareWeightDate){
|
|
||||||
$hist = array('key' => 'TareWeightDate', 'value' => $TareWeightDate, 'igr_no' => $IGRNO, 'igr_item_no' => $igrlineno);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($QuantityAsPerInvoice){
|
|
||||||
$hist = array('key' => 'QuantityAsPerInvoice', 'value' => $QuantityAsPerInvoice, 'igr_no' => $IGRNO, 'igr_item_no' => $igrlineno);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($Remarks){
|
|
||||||
$hist = array('key' => 'Remarks', 'value' => $Remarks, 'igr_no' => $IGRNO, 'igr_item_no' => $igrlineno);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
}
|
||||||
$get_pre_qty = $this->inwardgateregister_model->get_CurrentQty($MaterialCode);
|
$get_pre_qty = $this->inwardgateregister_model->get_CurrentQty($MaterialCode);
|
||||||
$av_qty = 0; //$av_qty means Avaliable Quantity
|
$av_qty = 0; //$av_qty means Avaliable Quantity
|
||||||
@ -618,7 +601,7 @@ class Inwardgateregister extends BaseController
|
|||||||
$currentav_qty = (int)$QuantityAsPerInvoice + (int)$av_qty;
|
$currentav_qty = (int)$QuantityAsPerInvoice + (int)$av_qty;
|
||||||
$current_qty = array('Current_stock' => $currentav_qty);
|
$current_qty = array('Current_stock' => $currentav_qty);
|
||||||
$this->inwardgateregister_model->addmaterialmaster($current_qty, $MaterialCode);
|
$this->inwardgateregister_model->addmaterialmaster($current_qty, $MaterialCode);
|
||||||
$Recqty = $this->inwardgateregister_model->getPOLineItemReceivedQty($PONO, $MaterialCode);
|
$Recqty = $this->inwardgateregister_model->getPOLineItemReceivedQty($PONO, $MaterialCode);
|
||||||
$ReceivedQuantity = 0.00;
|
$ReceivedQuantity = 0.00;
|
||||||
if (count($Recqty) > 0) {
|
if (count($Recqty) > 0) {
|
||||||
foreach ($Recqty as $key) {
|
foreach ($Recqty as $key) {
|
||||||
@ -855,18 +838,19 @@ function viewIGRDetails()
|
|||||||
$updateigrmaster = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo);
|
$updateigrmaster = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo);
|
||||||
log_message('error', "Master updated successfully: " . $updateigrmaster);
|
log_message('error', "Master updated successfully: " . $updateigrmaster);
|
||||||
if(!empty($tableData )){
|
if(!empty($tableData )){
|
||||||
if($VehicleNo){
|
#Save IGR Master On History Table
|
||||||
$hist = array('key' => 'VehicleNo', 'value' => $VehicleNo, 'igr_no' => $IGRNo, 'igr_item_no' => NULL);
|
foreach ($igrarr as $key => $value) {
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
if (!empty($value)) { // Ensure the value is not empty
|
||||||
if($DriverName){
|
if($key == 'CreatedBy'){ $key = 'MasterCreatedBy'; }
|
||||||
$hist = array('key' => 'DriverName', 'value' => $DriverName, 'igr_no' => $IGRNo, 'igr_item_no' => NULL);
|
if($key == 'UpdateBY'){ $key = 'MasterUpdatedBy'; }
|
||||||
$this->saveIGRHistory($hist);
|
if($key == 'CreatedDate'){ $key = 'MasterCreatedDate'; }
|
||||||
}
|
if($key == 'UpdatedOn'){ $key = 'MasterUpdatedDate'; }
|
||||||
if($DriverMobileNumber){
|
$hist = array( 'key' => $key, 'value' => $value, 'igr_no' => $IGRNo,'igr_item_no' => NULL);
|
||||||
$hist = array('key' => 'DriverMobileNumber', 'value' => $DriverMobileNumber, 'igr_no' => $IGRNo, 'igr_item_no' => NULL);
|
$this->saveIGRHistory($hist);
|
||||||
$this->saveIGRHistory($hist);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($tableData as $row) {
|
foreach ($tableData as $row) {
|
||||||
$quantityAsPerInvoice = $row['QuantityAsPerInvoice'];
|
$quantityAsPerInvoice = $row['QuantityAsPerInvoice'];
|
||||||
$remarks = $row['Remarks'];
|
$remarks = $row['Remarks'];
|
||||||
@ -906,63 +890,76 @@ function viewIGRDetails()
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
$updateigrlineitem = $this->inwardgateregister_model->updateIGRLineItem($igrline, $igrItemNo);
|
$updateigrlineitem = $this->inwardgateregister_model->updateIGRLineItem($igrline, $igrItemNo);
|
||||||
log_message('error', "lineitem updated successfully: " . $updateigrlineitem);
|
if($updateigrlineitem){
|
||||||
log_message('error', 'UpdateIGR updateigrlineitem: ' . json_encode($igrline));
|
foreach ($igrline as $key => $value) {
|
||||||
|
if (!empty($value)) { // Ensure the value is not empty
|
||||||
if ($quantityAsPerInvoice) {
|
if($key == 'CreatedBy'){ $key = 'LineItemCreatedBy'; }
|
||||||
$hist = array('key' => 'QuantityAsPerInvoice', 'value' => $quantityAsPerInvoice, 'igr_no' => $IGRNo, 'igr_item_no' => $igrItemNo);
|
if($key == 'UpdateBY'){ $key = 'LineItemUpdatedBy'; }
|
||||||
$this->saveIGRHistory($hist);
|
if($key == 'IGRNO'){ $key = 'LineItemIGRNO'; }
|
||||||
|
|
||||||
|
$hist = array( 'key' => $key, 'value' => $value, 'igr_no' => $IGRNo,'igr_item_no' => NULL);
|
||||||
|
$this->saveIGRHistory($hist);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if($remarks){
|
|
||||||
$hist = array('key' => 'Remarks', 'value' => $remarks, 'igr_no' => $IGRNo, 'igr_item_no' => $igrItemNo);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
}
|
||||||
if($grossWeight){
|
if($grossWeight){
|
||||||
$hist = array('key' => 'GrossWeight', 'value' => $grossWeight, 'igr_no' => $IGRNo, 'igr_item_no' => $igrItemNo);
|
$hist = array('key' => 'GrossWeight', 'value' => $grossWeight, 'igr_no' => $IGRNo, 'igr_item_no' => $igrItemNo);
|
||||||
$this->saveIGRHistory($hist);
|
$this->saveIGRHistory($hist);
|
||||||
}
|
}
|
||||||
if($tareWeight){
|
if($grossWeight){
|
||||||
$hist = array('key' => 'TareWeight', 'value' => $tareWeight, 'igr_no' => $IGRNo, 'igr_item_no' => $igrItemNo);
|
$hist = array('key' => 'GrossWeight', 'value' => $grossWeight, 'igr_no' => $IGRNo, 'igr_item_no' => $igrItemNo);
|
||||||
$this->saveIGRHistory($hist);
|
$this->saveIGRHistory($hist);
|
||||||
}
|
}
|
||||||
if($netWeight){
|
log_message('error', "lineitem updated successfully: " . $updateigrlineitem);
|
||||||
$hist = array('key' => 'NetWeight', 'value' => $netWeight, 'igr_no' => $IGRNo, 'igr_item_no' => $igrItemNo);
|
log_message('error', 'UpdateIGR updateigrlineitem: ' . json_encode($igrline));
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($GrossWtDt){
|
|
||||||
$hist = array('key' => 'GrossWeightDate', 'value' => $GrossWtDt, 'igr_no' => $IGRNo, 'igr_item_no' => $igrItemNo);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($TareWtDt){
|
|
||||||
$hist = array('key' => 'TareWeightDate', 'value' => $TareWtDt, 'igr_no' => $IGRNo, 'igr_item_no' => $igrItemNo);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($getigrstatus == 'ST027' && ($updateigrmaster > 0 || $updateigrlineitem > 0)) {
|
if ($getigrstatus == 'ST027' && ($updateigrmaster > 0 || $updateigrlineitem > 0)) {
|
||||||
|
|
||||||
|
|
||||||
$result_for_email = $this->inwardgateregister_model->getDetailsforEmail($this->session->get('userId'));
|
$result_for_email = $this->inwardgateregister_model->getDetailsforEmail($this->session->get('userId'));
|
||||||
$result_for_history = $this->inwardgateregister_model->getHistoryDetailsforEmail($IGRNo);
|
$result_for_history = $this->inwardgateregister_model->getHistoryDetailsforEmail($IGRNo);
|
||||||
// print_r($result_for_email);
|
print_r($result_for_history);die;
|
||||||
|
|
||||||
$notification = new Notification();
|
$notification = new Notification();
|
||||||
|
|
||||||
$history_content = NULL;
|
$history_content = NULL;
|
||||||
$history = $result_for_history;
|
$history = $result_for_history;
|
||||||
$field_labels = [
|
$field_labels = [
|
||||||
"Remarks" => "Remarks",
|
"IGRItemNo" => "IGRItemNo",
|
||||||
|
"IGRNO" => "IGRNO",
|
||||||
|
"MaterialCode" => "MaterialCode",
|
||||||
"QuantityAsPerInvoice" => "Received Qty",
|
"QuantityAsPerInvoice" => "Received Qty",
|
||||||
|
"Remarks" => "Remarks",
|
||||||
|
"IGRItemStatus" => "IGRItemStatus",
|
||||||
|
"CancelNote" => "CancelNote",
|
||||||
|
"BankStatus" => "BankStatus",
|
||||||
"GrossWeight" => "Gross Weight",
|
"GrossWeight" => "Gross Weight",
|
||||||
"TareWeight" => "Tare Weight",
|
|
||||||
"NetWeight" => "Net Weight",
|
|
||||||
"GrossWeightDate" => "Gross Weight Date",
|
"GrossWeightDate" => "Gross Weight Date",
|
||||||
|
"TareWeight" => "Tare Weight",
|
||||||
"TareWeightDate" => "Tare Weight Date",
|
"TareWeightDate" => "Tare Weight Date",
|
||||||
|
"NetWeight" => "Net Weight",
|
||||||
|
"WeightFile" => "WeightFile",
|
||||||
|
"IGRID" => "IGRID",
|
||||||
|
"IGRNO" => "IGRNO",
|
||||||
|
"PONO" => "PONO",
|
||||||
|
"DeliveryChellanOrInvoiceNo" => "Invoice NO",
|
||||||
|
"DeliveryChellanDate" => "Invoice Date",
|
||||||
|
"MaterialRcvdDate" => "Material Received Date",
|
||||||
"VehicleNo" => "Vehicle Number",
|
"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",
|
"DriverName" => "Driver Name",
|
||||||
"DriverMobileNumber" => "Driver Mobile Number"
|
"DriverMobileNumber" => "Driver Mobile Number",
|
||||||
|
"MasterFile" => "Master File",
|
||||||
];
|
];
|
||||||
$history_content = "<br>The following values have been edited:";
|
$history_content = "<br>The following values have been edited:";
|
||||||
|
|
||||||
@ -973,11 +970,14 @@ function viewIGRDetails()
|
|||||||
|
|
||||||
$history_content .= "<br>" . $readable_field . ": `" . $history[$j]->old_data . "` was updated to `" . $history[$j]->new_data . "` .";
|
$history_content .= "<br>" . $readable_field . ": `" . $history[$j]->old_data . "` was updated to `" . $history[$j]->new_data . "` .";
|
||||||
}
|
}
|
||||||
|
$email = "";
|
||||||
for ($i = 0; $i < count($result_for_email['emails']); $i++) {
|
for ($i = 0; $i < count($result_for_email['emails']); $i++) {
|
||||||
|
$email .= $result_for_email['emails'][$i]->email . " , ";
|
||||||
|
}
|
||||||
|
$email = rtrim($email, " ,");
|
||||||
|
|
||||||
$email_response = $notification->sendEmail([
|
$email_response = $notification->sendEmail([
|
||||||
'recipient_email' => $result_for_email['emails'][$i]->email,
|
'recipient_email' => $email,
|
||||||
'subject' => $result_for_email['company'].' - IGR Notification',
|
'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,
|
||||||
'company' => $result_for_email['company'],
|
'company' => $result_for_email['company'],
|
||||||
@ -991,11 +991,11 @@ function viewIGRDetails()
|
|||||||
|
|
||||||
// Log the result
|
// Log the result
|
||||||
if ($receiving_status) {
|
if ($receiving_status) {
|
||||||
$this->logger->info("Email ID = " . $result_for_email['emails'][$i]->email . " " . $mail_log);
|
$this->logger->info("Email IDs = " . $email . " " . $mail_log);
|
||||||
} else {
|
} else {
|
||||||
$this->logger->error("Email ID = " . $result_for_email['emails'][$i]->email . " " . $mail_log);
|
$this->logger->error("Email IDs = " . $email . " " . $mail_log);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// echo "***".$history_content;die;
|
// echo "***".$history_content;die;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1016,129 +1016,7 @@ function viewIGRDetails()
|
|||||||
|
|
||||||
echo $finalstatement;
|
echo $finalstatement;
|
||||||
}
|
}
|
||||||
function updateIGRLineItem() {
|
|
||||||
|
|
||||||
$IGRNo = $this->request->getPost('IGRNO');
|
|
||||||
$Status = $this->request->getPost('IGRStatus');
|
|
||||||
$DriverName = $this->request->getPost('DriverName');
|
|
||||||
$DriverMobileNumber = $this->request->getPost('DriverMobileNumber');
|
|
||||||
$GrossWeight = $this->request->getPost('GrossWeight');
|
|
||||||
$TareWeight = $this->request->getPost('TareWeight');
|
|
||||||
$NetWeight = $this->request->getPost('NetWeight');
|
|
||||||
$VehicleNo = $this->request->getPost('VehicleNo');
|
|
||||||
$requestdata = $this->request->getPost('data');
|
|
||||||
$updateby = $this->session->get('userId');
|
|
||||||
$GrossWeightDate = (string)$this->request->getPost('GrossWeightDate');
|
|
||||||
$GrossWtDt = !empty($GrossWeightDate) ? get_date_time_format($GrossWeightDate) : NULL;
|
|
||||||
|
|
||||||
$TareWeightDate = (string)$this->request->getPost('TareWeightDate');
|
|
||||||
$TareWtDt = !empty($TareWeightDate) ? get_date_time_format($TareWeightDate) : NULL;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Check if request data is not null and is a string
|
|
||||||
if (is_string($requestdata)) {
|
|
||||||
$lineitemdata = json_decode($requestdata, true); // Decode JSON data
|
|
||||||
|
|
||||||
if (is_array($lineitemdata)) {
|
|
||||||
if($GrossWeight){
|
|
||||||
$hist = array('key' => 'GrossWeight', 'value' => $GrossWeight, 'igr_no' => $IGRNo, 'igr_item_no' => NULL);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($TareWeight){
|
|
||||||
$hist = array('key' => 'TareWeight', 'value' => $TareWeight, 'igr_no' => $IGRNo, 'igr_item_no' => NULL);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($NetWeight){
|
|
||||||
$hist = array('key' => 'NetWeight', 'value' => $NetWeight, 'igr_no' => $IGRNo, 'igr_item_no' => NULL);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($GrossWtDt){
|
|
||||||
$hist = array('key' => 'GrossWeightDate', 'value' => $GrossWtDt, 'igr_no' => $IGRNo, 'igr_item_no' => NULL);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($TareWtDt){
|
|
||||||
$hist = array('key' => 'TareWeightDate', 'value' => $TareWtDt, 'igr_no' => $IGRNo, 'igr_item_no' => NULL);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if($DeliveryChellanOrInvoiceNo){
|
|
||||||
// $igr_history = array('field' => 'DeliveryChellanOrInvoiceNo','is_edit' => 1,'new_data' => $DeliveryChellanOrInvoiceNo,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO);
|
|
||||||
// $history_id = $this->inwardgateregister_model->igr_history($igr_history);
|
|
||||||
// log_message('error', "History updated successfully. History id: " . $history_id);
|
|
||||||
// }
|
|
||||||
// if($DeliveryChellanDate){
|
|
||||||
// $igr_history = array('field' => 'DeliveryChellanDate','is_edit' => 1,'new_data' => $DeliveryChellanDate,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO);
|
|
||||||
// $history_id = $this->inwardgateregister_model->igr_history($igr_history);
|
|
||||||
// log_message('error', "History updated successfully. History id: " . $history_id);
|
|
||||||
// }
|
|
||||||
// if($MaterialRcvdDt){
|
|
||||||
// $igr_history = array('field' => 'MaterialRcvdDate','is_edit' => 1,'new_data' => $MaterialRcvdDt,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO);
|
|
||||||
// $history_id = $this->inwardgateregister_model->igr_history($igr_history);
|
|
||||||
// log_message('error', "History updated successfully. History id: " . $history_id);
|
|
||||||
// }
|
|
||||||
if($VehicleNo){
|
|
||||||
$hist = array('key' => 'VehicleNo', 'value' => $VehicleNo, 'igr_no' => $IGRNo, 'igr_item_no' => NULL);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($DriverName){
|
|
||||||
$hist = array('key' => 'DriverName', 'value' => $DriverName, 'igr_no' => $IGRNo, 'igr_item_no' => NULL);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($DriverMobileNumber){
|
|
||||||
$hist = array('key' => 'DriverMobileNumber', 'value' => $DriverMobileNumber, 'igr_no' => $IGRNo, 'igr_item_no' => NULL);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
|
|
||||||
$igrarr = array('VehicleNo' => $VehicleNo, 'DriverName' => $DriverName, 'DriverMobileNumber' => $DriverMobileNumber,'IGRStatus' => $Status, 'UpdateBY' => $updateby,'GrossWeight'=>$GrossWeight,'TareWeight'=>$TareWeight,'NetWeight'=>$NetWeight,'GrossWeightDate'=>$GrossWtDt,'TareWeightDate'=>$TareWtDt);
|
|
||||||
|
|
||||||
$masterdata = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo);
|
|
||||||
$dummy = 0;
|
|
||||||
$i=1;
|
|
||||||
|
|
||||||
foreach ($lineitemdata as $item) {
|
|
||||||
$IGRNO = $item['IGRNO'.$i];
|
|
||||||
$IGRItemNo = $item['IGRItemNo'.$i];
|
|
||||||
$MaterialCode = $item['MaterialCode'.$i];
|
|
||||||
$QuantityAsPerInvoice = $item['txtQuantityAsPerInvoice'.$i];
|
|
||||||
$Remarks = $item['txtRemarks'.$i];
|
|
||||||
|
|
||||||
$igrline = array(
|
|
||||||
'IGRNO' => $IGRNO,
|
|
||||||
'MaterialCode' => $MaterialCode,
|
|
||||||
'IGRItemNo' => $IGRItemNo,
|
|
||||||
'QuantityAsPerInvoice' => $QuantityAsPerInvoice,
|
|
||||||
'Remarks' => $Remarks,
|
|
||||||
'UpdateBY' => $updateby
|
|
||||||
);
|
|
||||||
// print_r($igrline);
|
|
||||||
$lineitemdata = $this->inwardgateregister_model->updateIGRLineItem($igrline, $IGRItemNo);
|
|
||||||
if($QuantityAsPerInvoice){
|
|
||||||
$hist = array('key' => 'QuantityAsPerInvoice', 'value' => $QuantityAsPerInvoice, 'igr_no' => $IGRNo, 'igr_item_no' => $IGRItemNo);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($Remarks){
|
|
||||||
$hist = array('key' => 'Remarks', 'value' => $Remarks, 'igr_no' => $IGRNo, 'igr_item_no' => $IGRItemNo);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
$i++;
|
|
||||||
if ($lineitemdata > 0) {
|
|
||||||
$dummy++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($dummy > 0) {
|
|
||||||
echo json_encode(array('message' => 'Updated Successfully!'));
|
|
||||||
} else {
|
|
||||||
echo json_encode(array('message' => 'Not Updated!'));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
echo json_encode(array('message' => 'Invalid data format!'));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
echo json_encode(array('message' => 'Invalid request data!'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function updateIGRWeight(){
|
function updateIGRWeight(){
|
||||||
@ -1158,30 +1036,18 @@ function updateIGRWeight(){
|
|||||||
$path = ROOTPATH.'public/uploads/Igrfiles/';
|
$path = ROOTPATH.'public/uploads/Igrfiles/';
|
||||||
if(!is_dir($path)) { mkdir($path, 0777, true); }
|
if(!is_dir($path)) { mkdir($path, 0777, true); }
|
||||||
|
|
||||||
if($GrossWeight){
|
|
||||||
$hist = array('key' => 'GrossWeight', 'value' => $GrossWeight, 'igr_no' => $IGRNO, 'igr_item_no' => $IGRItemNo);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($GrossWeight){
|
|
||||||
$hist = array('key' => 'TareWeight', 'value' => $TareWeight, 'igr_no' => $IGRNO, 'igr_item_no' => $IGRItemNo);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($NetWeight){
|
|
||||||
$hist = array('key' => 'NetWeight', 'value' => $NetWeight, 'igr_no' => $IGRNO, 'igr_item_no' => $IGRItemNo);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($GrossWtDt){
|
|
||||||
$hist = array('key' => 'GrossWeightDate', 'value' => $GrossWtDt, 'igr_no' => $IGRNO, 'igr_item_no' => $IGRItemNo);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
if($TareWtDt){
|
|
||||||
$hist = array('key' => 'TareWeightDate', 'value' => $TareWtDt, 'igr_no' => $IGRNO, 'igr_item_no' => $IGRItemNo);
|
|
||||||
$this->saveIGRHistory($hist);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$IGRItemNo = $this->request->getPost('IGRlineitem');
|
$IGRItemNo = $this->request->getPost('IGRlineitem');
|
||||||
$igr_lineitem = array('GrossWeight' => $GrossWeight,'GrossWeightDate' => $GrossWtDt,'TareWeightDate' => $TareWtDt,'TareWeight' => $TareWeight,'NetWeight' => $NetWeight,'UpdateBY' => $updateby);
|
$igr_lineitem = array('GrossWeight' => $GrossWeight,'GrossWeightDate' => $GrossWtDt,'TareWeightDate' => $TareWtDt,'TareWeight' => $TareWeight,'NetWeight' => $NetWeight,'UpdateBY' => $updateby);
|
||||||
|
|
||||||
|
foreach ($igr_lineitem as $key => $value) {
|
||||||
|
if (!empty($value)) { // Ensure the value is not empty
|
||||||
|
if($key == 'CreatedBy'){ $key = 'LineItemCreatedBy'; }
|
||||||
|
if($key == 'UpdateBY'){ $key = 'LineItemUpdatedBy'; }
|
||||||
|
if($key == 'IGRNO'){ $key = 'LineItemIGRNO'; }
|
||||||
|
$hist = array( 'key' => $key, 'value' => $value, 'igr_no' => $IGRNO,'igr_item_no' => $IGRItemNo);
|
||||||
|
$this->saveIGRHistory($hist);
|
||||||
|
}
|
||||||
|
}
|
||||||
$requestWeightFileName =null ;
|
$requestWeightFileName =null ;
|
||||||
if($WeightFile){
|
if($WeightFile){
|
||||||
if (!empty($requestWeightFileName)) {
|
if (!empty($requestWeightFileName)) {
|
||||||
@ -1568,62 +1434,53 @@ function updateIGRWeight(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveIGRHistory($hist){
|
|
||||||
|
public function saveIGRHistory($hist) {
|
||||||
$field = $hist['key'];
|
|
||||||
|
|
||||||
$igr_no = $hist['igr_no'];
|
// Extract fields from the input array
|
||||||
$igr_item_no = $hist['igr_item_no'];
|
$field = $hist['key'];
|
||||||
|
|
||||||
$new_data = $hist['value'];
|
$igr_no = $hist['igr_no'];
|
||||||
$old_data = NULL;
|
$igr_item_no = $hist['igr_item_no'];
|
||||||
|
$new_data = $hist['value']; // Incoming new value
|
||||||
$same = false; // Flag to check if the same data exists
|
$old_data = NULL; // Default old value is null
|
||||||
|
|
||||||
log_message('error', "$igr_no Save History function entered.");
|
|
||||||
|
|
||||||
// Get existing history
|
|
||||||
$existingHist = $this->inwardgateregister_model->get_igr_history($field, $igr_no, $igr_item_no);
|
|
||||||
|
|
||||||
if (!empty($existingHist)) {
|
|
||||||
foreach ($existingHist as $row) {
|
|
||||||
if ($row->new_data == $new_data) {
|
|
||||||
$same = true; // The same data already exists
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
$old_data = $row->new_data; // Keep track of the latest `new_data`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$same) {
|
log_message('error', "Save History function entered for IGR No: $igr_no, Item No: $igr_item_no, Field: $field.");
|
||||||
// Insert or update history since data is different
|
|
||||||
$igr_history = array(
|
$latestHist = $this->inwardgateregister_model->get_igr_history($field, $igr_no, $igr_item_no);
|
||||||
'field' => $field,
|
|
||||||
'new_data' => $new_data,
|
if (!empty($latestHist)) {
|
||||||
'old_data' => $old_data,
|
if ($latestHist->new_data == $new_data) {
|
||||||
'history_dated' => get_current_date_time(),
|
log_message('error', "No update needed for IGR No: $igr_no, Item No: $igr_item_no, Field: $field. Data already exists: $new_data");
|
||||||
'by' => $this->session->get('userId'),
|
return;
|
||||||
'IGR_No' => $igr_no,
|
|
||||||
'IGRItem_No' => $igr_item_no
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($old_data !== NULL) {
|
|
||||||
$igr_history['is_edit'] = 1; // Update existing record
|
|
||||||
} else {
|
} else {
|
||||||
$igr_history['is_add'] = 1; // Insert new record
|
$old_data = $latestHist->new_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$history_id = $this->inwardgateregister_model->igr_history($igr_history);
|
|
||||||
log_message('error', "History updated successfully. History ID: $history_id" );
|
|
||||||
} else {
|
|
||||||
// echo "No update needed: ".$param['key']." ($value) already exists.";
|
|
||||||
log_message('error', "No update needed: $field ($new_data) already exists.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -231,20 +231,22 @@ class Inwardgateregister_model extends Model
|
|||||||
{
|
{
|
||||||
|
|
||||||
$builder = $this->db->table('t_igr_history Hist')
|
$builder = $this->db->table('t_igr_history Hist')
|
||||||
->select("Hist.*");
|
->select("Hist.*")
|
||||||
$builder->where('Hist.field', $col);
|
->where('Hist.field', $col);
|
||||||
if($IGR){
|
|
||||||
$builder->where('Hist.IGR_No', $IGR);
|
|
||||||
}
|
|
||||||
if ($IGRITEM !== null) {
|
|
||||||
$builder->where('Hist.IGRItem_No', $IGRITEM);
|
|
||||||
}
|
|
||||||
$query = $builder->get();
|
|
||||||
$result = $query->getResult();
|
|
||||||
return $result;
|
|
||||||
// $result = $model->get_igr_history('001');
|
|
||||||
// $result = $model->get_igr_history('001', 1);
|
|
||||||
|
|
||||||
|
if ($IGR) {
|
||||||
|
$builder->where('Hist.IGR_No', $IGR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($IGRITEM !== null) {
|
||||||
|
$builder->where('Hist.IGRItem_No', $IGRITEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
$builder->orderBy('Hist.history_dated', 'DESC');
|
||||||
|
$builder->limit(1);
|
||||||
|
$query = $builder->get();
|
||||||
|
$result = $query->getRow();
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addigrM($igrM)
|
function addigrM($igrM)
|
||||||
@ -1192,9 +1194,48 @@ class Inwardgateregister_model extends Model
|
|||||||
$to = date('Y-m-d H:i:s', strtotime($date . ' +30 seconds'));
|
$to = date('Y-m-d H:i:s', strtotime($date . ' +30 seconds'));
|
||||||
$from = date('Y-m-d H:i:s', strtotime($date . ' -30 seconds'));
|
$from = date('Y-m-d H:i:s', strtotime($date . ' -30 seconds'));
|
||||||
|
|
||||||
$builder = $this->db->table('t_igr_history')->where('IGR_NO', $igr)
|
|
||||||
->where('is_edit', 1)
|
|
||||||
->where('history_dated BETWEEN "'.$from.'" AND "'.$to.'"');
|
$builder = $this->db->table('t_igr_history')
|
||||||
|
->select('
|
||||||
|
t_igr_history.id,
|
||||||
|
t_igr_history.field,
|
||||||
|
t_igr_history.is_add,
|
||||||
|
t_igr_history.is_edit,
|
||||||
|
t_igr_history.is_delete,
|
||||||
|
t_igr_history.history_dated,
|
||||||
|
t_igr_history.by,
|
||||||
|
t_igr_history.IGR_No,
|
||||||
|
t_igr_history.IGRItem_No,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN t_igr_history.field = "TransporterId"
|
||||||
|
THEN (SELECT name FROM t_transporter WHERE id = t_igr_history.new_data LIMIT 1)
|
||||||
|
WHEN t_igr_history.field = "MaterialCode"
|
||||||
|
THEN (SELECT MaterialName FROM t_materialmaster WHERE MaterialCode = t_igr_history.new_data LIMIT 1)
|
||||||
|
WHEN t_igr_history.field IN ("IGRStatus", "PaymentStatus", "IGRItemStatus")
|
||||||
|
THEN (SELECT StatusName FROM t_status WHERE StatusCode = t_igr_history.new_data LIMIT 1)
|
||||||
|
ELSE t_igr_history.new_data
|
||||||
|
END AS new_data,
|
||||||
|
t_igr_history.new_data as original_new_data,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN t_igr_history.field = "TransporterId"
|
||||||
|
THEN (SELECT name FROM t_transporter WHERE id = t_igr_history.old_data LIMIT 1)
|
||||||
|
WHEN t_igr_history.field = "MaterialCode"
|
||||||
|
THEN (SELECT MaterialName FROM t_materialmaster WHERE MaterialCode = t_igr_history.old_data LIMIT 1)
|
||||||
|
WHEN t_igr_history.field IN ("IGRStatus", "PaymentStatus", "IGRItemStatus")
|
||||||
|
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
|
||||||
|
')
|
||||||
|
// ->join('t_igr_details IGRD', 'IGRD.IGRItemNo = t_igr_history.IGRItem_No','left')
|
||||||
|
// ->join('t_materialmaster MM','MM.MaterialCode = IGRD.MaterialCode','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();
|
$query = $builder->get();
|
||||||
// echo $this->db->getLastQuery()->getQuery(); die;
|
// echo $this->db->getLastQuery()->getQuery(); die;
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user