diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 8a8ce5fd..705348c8 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -254,19 +254,14 @@ $routes->get('ViewIGR', 'Inwardgateregister::viewIGR'); // View IGR PAGE - Worki $routes->post('ViewIGRDetails', 'Inwardgateregister::viewIGRDetails'); $routes->post('GetIGRLineItemDetails', 'Inwardgateregister::getIGRLineItemDetails'); $routes->post('deleteBillFile', 'Inwardgateregister::deleteBillFile'); - - - -$routes->post('inwardgateregister/addNewigr', 'Inwardgateregister::addNewigr'); -$routes->post('inwardgateregister/ViewIGRfile', 'Inwardgateregister::ViewIGRfile'); +$routes->post('SaveIGR', 'Inwardgateregister::SaveIGR');// Save IGR PAGE - Working +$routes->post('UpdateIGR', 'Inwardgateregister::UpdateIGR'); +$routes->post('updateIGRWeight', 'Inwardgateregister::updateIGRWeight'); +$routes->post('UpdateIGRLineItem', 'Inwardgateregister::updateIGRLineItem'); +$routes->post('ViewIGRHistory', 'Inwardgateregister::ViewIGRHistory'); +$routes->post('ViewIGRfile', 'Inwardgateregister::ViewIGRfile'); $routes->post('inwardgateregister/addloadfile', 'Inwardgateregister::addloadfile'); $routes->post('inwardgateregister/edituploadfile', 'Inwardgateregister::edituploadfile'); -$routes->post('inwardgateregister/ViewIGRHistory', 'Inwardgateregister::ViewIGRHistory'); - - - -$routes->post('inwardgateregister/UpdateIGR', 'Inwardgateregister::UpdateIGR'); -$routes->post('inwardgateregister/updateIGRLineItem', 'Inwardgateregister::updateIGRLineItem'); // Application OGR Page $routes->match(['GET', 'POST', 'PUT', 'DELETE'],'AddOgr', 'Inwardgateregister::addoutwardgateregister'); diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index 71748e61..3a4096b9 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -50,6 +50,7 @@ class Inwardgateregister extends BaseController $this->global['pageTitle'] = 'View Inward Gate Register'; $data['IGR'] = $this->inwardgateregister_model->ViewigrListing(); + $data['DEPCode'] = $this->session->get('DEPCode'); $this->loadViews("viewinwardgateregister", $this->global, $data, NULL); // $this->global['pageTitle'] = 'Inward Gate Register Details'; // $data['IGR'] = $this->inwardgateregister_model->igrListing(); @@ -304,7 +305,7 @@ class Inwardgateregister extends BaseController // } } - function addNewigr() + function SaveIGR() { #Step 1 IGR Details $PONO = $this->request->getPost('PONO'); @@ -431,12 +432,20 @@ class Inwardgateregister extends BaseController $PendingQty = $this->request->getPost('txtPendingQty' . $i); $TotalPendingQty = $TotalPendingQty + $PendingQty; $GrossWeight = $this->request->getPost('txtGrossWeight' . $i); - $GrossWeightDate= $this->request->getPost('txtGrossWeightDate' . $i); + $grossWeightDate= $this->request->getPost('txtGrossWeightDate' . $i); $TareWeight= $this->request->getPost('txtTareWeight' . $i); - $TareWeightDate= $this->request->getPost('txtTareWeightDate' . $i); + $tareWeightDate= $this->request->getPost('txtTareWeightDate' . $i); $NetWeight= $this->request->getPost('txtNetWeight' . $i); - + var_dump($grossWeightDate); + var_dump($tareWeightDate); + if (is_string($grossWeightDate) && is_string($tareWeightDate)) { + $GrossWeightDate = date('Y-m-d H:i:s', strtotime($grossWeightDate)); + $TareWeightDate = date('Y-m-d H:i:s', strtotime($tareWeightDate)); + } else { + $GrossWeightDate = null; + $TareWeightDate = null; + } if (strlen($QuantityAsPerInvoice) > 0 && $QuantityAsPerInvoice != '0') { $Remarks = $this->request->getPost('txtRemarks' . $i); $ItemStatus = ''; @@ -447,12 +456,8 @@ class Inwardgateregister extends BaseController } $CreatedBy = $this->session->get('userId'); - $igrDetails = array('IGRNO' => $IGRNO, 'MaterialCode' => $MaterialCode, 'QuantityAsPerInvoice' => $QuantityAsPerInvoice, 'Remarks' => $Remarks, 'IGRItemStatus' => $IGRItemStatus, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt); - $igrDetails['GrossWeight'] = $GrossWeight ; - $igrDetails['GrossWeightDate'] = $GrossWeightDate; - $igrDetails['TareWeight'] = $TareWeight; - $igrDetails['TareWeightDate'] = $TareWeightDate; - $igrDetails['NetWeight'] = $NetWeight; + $igrDetails = array('IGRNO' => $IGRNO, 'MaterialCode' => $MaterialCode, 'QuantityAsPerInvoice' => $QuantityAsPerInvoice, 'Remarks' => $Remarks, 'IGRItemStatus' => $IGRItemStatus,'GrossWeight' => (float)$GrossWeight ,'GrossWeightDate'=> $GrossWeightDate,'TareWeight' => (float)$TareWeight ,'TareWeightDate' => $TareWeightDate ,'NetWeight' => (float)$NetWeight, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt); + log_message('error', 'SaveIGR igrDetails result : ' . json_encode($igrDetails)); $igrD = $this->inwardgateregister_model->addigrD($igrDetails); $igrlineno = !empty($igrD) ? $igrD : ''; @@ -554,10 +559,10 @@ class Inwardgateregister extends BaseController $finalstatement = json_encode($finalstatement); -echo ""; + echo ""; } @@ -600,11 +605,249 @@ function viewIGRDetails() $Mat_Rcvd_Dt = $this->request->getPost('mrc'); $MaterialRcvdDt = get_date_time_format($Mat_Rcvd_Dt); + $VehicleNo = $this->request->getPost('vehicle_no'); + $DriverName = $this->request->getPost('driver'); + $DriverMobileNumber = $this->request->getPost('driver_mobile'); + + $IGRStatus = (int)$this->request->getPost('status') == 1 ? IGR_CREATED : IGR_DRAFT; + + $tableData = $this->request->getPost('tableData'); + $updateby = $this->session->get('userId'); - $igrarr = array('DeliveryChellanDate' => $DeliveryChellanDate, 'MaterialRcvdDate' => $MaterialRcvdDt, 'UpdateBY' => $updateby); + $igrarr = array('DeliveryChellanDate' => $DeliveryChellanDate, 'MaterialRcvdDate' => $MaterialRcvdDt,'VehicleNo'=>$VehicleNo,'DriverMobileNumber'=>$DriverMobileNumber,'DriverName'=>$DriverName, 'Status' => $IGRStatus,'UpdateBY' => $updateby); $data = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo); + if($VehicleNo){ + $vecno = $this->inwardgateregister_model->get_igr_history('VehicleNo',$IGRNo); + + if(!empty($vecno)){ + $old_data = NULL; + foreach ($vecno as $row) { + if ($row->field == 'VehicleNo') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'VehicleNo','new_data' => $VehicleNo,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } else{$igr_history = array('field' => 'VehicleNo','is_edit' => 1,'new_data' => $VehicleNo,'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($DriverName){ + $drname = $this->inwardgateregister_model->get_igr_history('DriverName',$IGRNo); + + if(!empty($drname)){ + $old_data = NULL; + foreach ($drname as $row) { + if ($row->field == 'DriverName') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'DriverName','new_data' => $DriverName,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } else{ + $igr_history = array('field' => 'DriverName','is_edit' => 1,'new_data' => $DriverName,'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($DriverMobileNumber){ + $drmob = $this->inwardgateregister_model->get_igr_history('DriverMobileNumber',$IGRNo); + + if(!empty($drmob)){ + $old_data = NULL; + foreach ($drmob as $row) { + if ($row->field == 'GrossWeight') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'DriverMobileNumber','new_data' => $DriverMobileNumber,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } else{ + $igr_history = array('field' => 'DriverMobileNumber','is_edit' => 1,'new_data' => $DriverMobileNumber,'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); + }} + foreach ($tableData as $row) { + $materialCode = $row['MaterialCode']; + $quantityAsPerInvoice = $row['QuantityAsPerInvoice']; + $remarks = $row['Remarks']; + $grossWeight = $row['GrossWeight']; + $grossWeightDate = $row['GrossWeightDate']; + $tareWeight = $row['TareWeight']; + $tareWeightDate = $row['TareWeightDate']; + $netWeight = $row['NetWeight']; + $igrItemNo = $row['IGRItemNo']; + $GrossWtDt = get_date_time_format($grossWeightDate); + $TareWtDt = get_date_time_format($tareWeightDate); + + $igrline = array( + 'IGRNO' => $IGRNo, + 'MaterialCode' => $materialCode, + 'QuantityAsPerInvoice' => $quantityAsPerInvoice, + 'Remarks' => $remarks, + 'GrossWeight' => $grossWeight, + 'GrossWeightDate' => $grossWeightDate, + 'TareWeight' => $tareWeight, + 'TareWeightDate' => $tareWeightDate, + 'NetWeight' => $netWeight, + 'IGRItemNo' => $igrItemNo, + 'UpdateBY' => $updateby + ); + $lineitemupdated = $this->inwardgateregister_model->updateIGRLineItem($igrline, $igrItemNo); + log_message('error', "lineitem updated successfully: " . $$lineitemupdated); + if($quantityAsPerInvoice){ + $qu = $this->inwardgateregister_model->get_igr_history('QuantityAsPerInvoice',$IGRNo,$igrItemNo); + + if(!empty($qu)){ + $old_data = NULL; + foreach ($qu as $row) { + if ($row->field == 'QuantityAsPerInvoice') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'QuantityAsPerInvoice','new_data' => $quantityAsPerInvoice,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No' => $igrItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } else{ + $igr_history = array('field' => 'QuantityAsPerInvoice','is_add' => 1,'new_data' => $quantityAsPerInvoice,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No' => $igrItemNo); + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + }} + if($Remarks){ + $remak = $this->inwardgateregister_model->get_igr_history('Remarks',$IGRNo,$igrItemNo); + + if(!empty($remak)){ + $old_data = NULL; + foreach ($remak as $row) { + if ($row->field == 'Remarks') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'Remarks','new_data' => $Remarks,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No' => $igrItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } else{$igr_history = array('field' => 'Remarks','is_add' => 1,'new_data' => $Remarks,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No' => $igrItemNo); + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + }} + if($grossWeight){ + $gross = $this->inwardgateregister_model->get_igr_history('GrossWeight',$IGRNo,$igrItemNo); + if(!empty($gross)){ + $old_data = NULL; + foreach ($gross as $row) { + if ($row->field == 'GrossWeight') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'GrossWeight','new_data' => $grossWeight,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No'=>$igrItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + }else{ + $igr_history = array('field' => 'GrossWeight','is_add' => 1,'new_data' => $grossWeight,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No'=>$igrItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + + } + } + if($tareWeight){ + $tare = $this->inwardgateregister_model->get_igr_history('TareWeight',$IGRNo,$igrItemNo); + if(!empty($tare)){ + $old_data = NULL; + foreach ($gross as $row) { + if ($row->field == 'TareWeight') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'TareWeight','new_data' => $tareWeight,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No'=>$igrItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + }else{ + $igr_history = array('field' => 'TareWeight','is_edit' => 1,'new_data' => $tareWeight,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No'=>$igrItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } + } + if($netWeight){ + $net = $this->inwardgateregister_model->get_igr_history('NetWeight',$IGRNo,$igrItemNo); + if(!empty($net)){ + $old_data = NULL; + foreach ($gross as $row) { + if ($row->field == 'NetWeight') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'NetWeight','new_data' => $netWeight,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No'=>$igrItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } else{ + $igr_history = array('field' => 'NetWeight','is_edit' => 1,'new_data' => $netWeight,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No'=>$igrItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } + } + if($GrossWtDt){ + $grossdate = $this->inwardgateregister_model->get_igr_history('GrossWeightDate',$IGRNo,$igrItemNo); + if(!empty($grossdate)){ + $old_data = NULL; + foreach ($gross as $row) { + if ($row->field == 'GrossWeightDate') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'GrossWeightDate','new_data' => $GrossWtDt,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No'=>$igrItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } else{ + $igr_history = array('field' => 'GrossWeightDate','is_edit' => 1,'new_data' => $GrossWtDt,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No'=>$igrItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } + } + if($TareWtDt){ + $taredate = $this->inwardgateregister_model->get_igr_history('TareWeightDate',$IGRNo,$igrItemNo); + + if(!empty($taredate)){ + $old_data = NULL; + foreach ($taredate as $row) { + if ($row->field == 'TareWeightDate') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'TareWeightDate','new_data' => $TareWtDt,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No'=>$igrItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } else{ + $igr_history = array('field' => 'TareWeightDate','is_edit' => 1,'new_data' => $TareWtDt,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNo,'IGRItem_No'=>$igrItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } + } + + + } if ($data > 0) { echo "Updated Succefully!"; @@ -882,6 +1125,123 @@ function viewIGRDetails() } } +function updateIGRWeight(){ + $GrossWeight = $this->request->getPost('GrossWeight'); + $GrossWeightDate = $this->request->getPost('GrossWeightDate'); + $TareWeight = $this->request->getPost('TareWeight'); + $TareWeightDate = $this->request->getPost('TareWeightDate'); + $NetWeight = $this->request->getPost('NetWeight'); + $IGRNO = $this->request->getPost('IGR'); + $IGRItemNo = $this->request->getPost('IGRlineitem'); + $updateby = $this->session->get('userId'); + if($GrossWeight){ + $gross = $this->inwardgateregister_model->get_igr_history('GrossWeight',$IGRNO, $IGRItemNo); + if(!empty($gross)){ + $old_data = NULL; + foreach ($gross as $row) { + if ($row->field == 'GrossWeight') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'GrossWeight','new_data' => $GrossWeight,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$IGRItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + }else{ + $igr_history = array('field' => 'GrossWeight','is_add' => 1,'new_data' => $GrossWeight,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$IGRItemNo); + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + + } + } + if($TareWeight){ + $tare = $this->inwardgateregister_model->get_igr_history('TareWeight',$IGRNO, $IGRItemNo); + if(!empty($tare)){ + $old_data = NULL; + foreach ($gross as $row) { + if ($row->field == 'TareWeight') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'TareWeight','new_data' => $TareWeight,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$IGRItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + }else{ + $igr_history = array('field' => 'TareWeight','is_edit' => 1,'new_data' => $TareWeight,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$IGRItemNo); + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } + } + if($NetWeight){ + $net = $this->inwardgateregister_model->get_igr_history('NetWeight',$IGRNO, $IGRItemNo); + if(!empty($net)){ + $old_data = NULL; + foreach ($gross as $row) { + if ($row->field == 'NetWeight') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'NetWeight','new_data' => $NetWeight,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$IGRItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } else{ + $igr_history = array('field' => 'NetWeight','is_edit' => 1,'new_data' => $NetWeight,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$IGRItemNo); + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } + } + if($GrossWeightDate){ + $grossdate = $this->inwardgateregister_model->get_igr_history('GrossWeightDate',$IGRNO, $IGRItemNo); + if(!empty($grossdate)){ + $old_data = NULL; + foreach ($gross as $row) { + if ($row->field == 'GrossWeightDate') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'GrossWeightDate','new_data' => $GrossWeightDate,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$IGRItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } else{ + $igr_history = array('field' => 'GrossWeightDate','is_edit' => 1,'new_data' => $GrossWeightDate,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$IGRItemNo); + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } + } + if($TareWeightDate){ + $taredate = $this->inwardgateregister_model->get_igr_history('TareWeightDate',$IGRNO, $IGRItemNo); + + if(!empty($taredate)){ + $old_data = NULL; + foreach ($taredate as $row) { + if ($row->field == 'TareWeightDate') { + $old_data = $row->new_data; + } + } + $igr_history = array('field' => 'TareWeightDate','new_data' => $TareWeightDate,'old_data' => $old_data,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$IGRItemNo); + ($old_data != NULL) ? $igr_history['is_edit'] = 1 : $igr_history['is_add'] = 1 ; + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } else{ + $igr_history = array('field' => 'TareWeightDate','is_edit' => 1,'new_data' => $TareWeightDate,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$IGRItemNo); + $history_id = $this->inwardgateregister_model->igr_history($igr_history); + log_message('error', "History updated successfully. History id: " . $history_id); + } + } + + + $IGRItemNo = $this->request->getPost('IGRlineitem'); + $igr_lineitem = array('GrossWeight' => $GrossWeight,'GrossWeightDate' => $GrossWeightDate,'TareWeightDate' => $TareWeightDate,'TareWeight' => $TareWeight,'NetWeight' => $NetWeight,'UpdateBY' => $updateby); + + $update = $this->inwardgateregister_model->updateIGRLineItem($igr_lineitem, $IGRItemNo); + + if ($update) { + echo "Details update successfully!"; + } +} function AddOgr() { //echo "string"; diff --git a/app/Views/inwardgateregister.php b/app/Views/inwardgateregister.php index 944a26ff..baaeaec3 100755 --- a/app/Views/inwardgateregister.php +++ b/app/Views/inwardgateregister.php @@ -77,7 +77,7 @@

-


@@ -294,7 +294,7 @@