diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index 3a4096b9..6ebc72d9 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -436,8 +436,8 @@ class Inwardgateregister extends BaseController $TareWeight= $this->request->getPost('txtTareWeight' . $i); $tareWeightDate= $this->request->getPost('txtTareWeightDate' . $i); $NetWeight= $this->request->getPost('txtNetWeight' . $i); - var_dump($grossWeightDate); - var_dump($tareWeightDate); + // var_dump($grossWeightDate); + // var_dump($tareWeightDate); if (is_string($grossWeightDate) && is_string($tareWeightDate)) { $GrossWeightDate = date('Y-m-d H:i:s', strtotime($grossWeightDate)); @@ -612,246 +612,247 @@ function viewIGRDetails() $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,'VehicleNo'=>$VehicleNo,'DriverMobileNumber'=>$DriverMobileNumber,'DriverName'=>$DriverName, 'Status' => $IGRStatus,'UpdateBY' => $updateby); + $igrarr = array('DeliveryChellanDate' => $DeliveryChellanDate, 'MaterialRcvdDate' => $MaterialRcvdDt,'VehicleNo'=>$VehicleNo,'DriverMobileNumber'=>$DriverMobileNumber,'DriverName'=>$DriverName, 'IGRStatus' => $IGRStatus,'UpdateBY' => $updateby); + log_message('error', 'UpdateIGR igrarr: ' . json_encode($igrarr)); + $updateigrmaster = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo); + if(!empty($tableData )){ + if($VehicleNo){ + $vecno = $this->inwardgateregister_model->get_igr_history('VehicleNo',$IGRNo); - $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($vecno)){ - $old_data = NULL; - foreach ($vecno as $row) { - if ($row->field == 'VehicleNo') { - $old_data = $row->new_data; - } + 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) { + $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( + 'QuantityAsPerInvoice' => $quantityAsPerInvoice, + 'Remarks' => $remarks, + 'GrossWeight' => $grossWeight, + 'GrossWeightDate' => $GrossWtDt, + 'TareWeight' => $tareWeight, + 'TareWeightDate' => $TareWtDt, + 'NetWeight' => $netWeight, + 'IGRItemNo' => $igrItemNo, + 'UpdateBY' => $updateby + ); + $updateigrlineitem = $this->inwardgateregister_model->updateIGRLineItem($igrline, $igrItemNo); + log_message('error', "lineitem updated successfully: " . $updateigrlineitem); + log_message('error', 'UpdateIGR updateigrlineitem: ' . json_encode($igrline)); + + 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); + } + } + + } - $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) { + } + if ($updateigrmaster > 0) { echo "Updated Succefully!"; - } else { + } else if($updateigrlineitem >0){ + echo "Updated Succefully!"; + }else{ echo "Not Updated!"; } } diff --git a/app/Views/inwardgateregister.php b/app/Views/inwardgateregister.php index baaeaec3..4398131a 100755 --- a/app/Views/inwardgateregister.php +++ b/app/Views/inwardgateregister.php @@ -793,10 +793,10 @@ function Save(status) //var tablevalue = $('#specialtable').tableToJSON(); // Convert the table into a javascript object //var jsondata = JSON.stringify(tablevalue); //$('#tablevalues').val(jsondata); - $("#IGR").attr("method", "post"); - $("#IGR").attr("enctype", "multipart/form-data"); - $("#IGR").attr("action", "SaveIGR"); - $('#IGR').submit(); + // $("#IGR").attr("method", "post"); + // $("#IGR").attr("enctype", "multipart/form-data"); + // $("#IGR").attr("action", "SaveIGR"); + // $('#IGR').submit(); }//validate if closed }//save function closed diff --git a/app/Views/viewinwardgateregister.php b/app/Views/viewinwardgateregister.php index fe566347..e237022d 100644 --- a/app/Views/viewinwardgateregister.php +++ b/app/Views/viewinwardgateregister.php @@ -67,7 +67,7 @@
-

View Inward Gate Register

+

View Inward Gate Register

@@ -119,8 +119,10 @@   - - + + + +
- + + +