FIX_igr changes 3rd commit

This commit is contained in:
VE10-Sanjeev 2024-07-26 04:17:25 +00:00
parent 2519bd8fd6
commit 71017a7c79
4 changed files with 659 additions and 94 deletions

View File

@ -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');

View File

@ -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 "<script>
alert('$finalstatement');
window.location.href='viewIGRDetails';
</script>";
echo "<script>
alert('$finalstatement');
window.location.href = 'ViewIGR';
</script>";
}
@ -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";

View File

@ -77,7 +77,7 @@
<section class="content" style="margin: 15px;"><br/>
<div style="border:2px solid #333;">
<form action ="<?php echo base_url()?>inwardgateregister/addNewigr"
<form action ="<?php echo base_url()?>SaveIGR"
method="post" enctype="multipart/form-data">
<div class="row"><br/><br/>
<div id="content" > </div>
@ -294,7 +294,7 @@
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4>Weight Calculator</h4><div id="material"></div></center>
<center><h4>Weight Calculator</h4><div id="WeightTitle"></div></center>
<div class="pull-right hidden-xs">
<b><div id="clock"></div></b>
</div>
@ -323,7 +323,7 @@
<label for="TareWeight" class="col-md-2 col-form-label">Tare Weight</label>
<div class="col-md-5">
<?php
$data = array('name' => 'TareWeight', 'value' => set_value('TareWeight'), 'id' => 'TareWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'WeightDiffer(this);' ,'placeholder' => 'Enter your username','placeholder' => 'Tare Weight Value (B)');
$data = array('name' => 'TareWeight', 'value' => set_value('TareWeight'), 'id' => 'TareWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'validateTareWeight(this);' ,'placeholder' => 'Enter your username','placeholder' => 'Tare Weight Value (B)');
echo form_input($data);
?>
</div>
@ -771,7 +771,7 @@ function Save(status)
// $.ajax({
// data:$('.IGR').serialize(),
// type:"POST",
// url:"<?php echo base_url() ?>inwardgateregister/addNewigr",
// url:"<?php echo base_url() ?>SaveIGR",
// success:function(data) {
@ -795,7 +795,7 @@ function Save(status)
//$('#tablevalues').val(jsondata);
$("#IGR").attr("method", "post");
$("#IGR").attr("enctype", "multipart/form-data");
$("#IGR").attr("action", "inwardgateregister/addNewigr");
$("#IGR").attr("action", "SaveIGR");
$('#IGR').submit();
}//validate if closed
}//save function closed
@ -1026,6 +1026,19 @@ function removeRows(inputs) {
}
</script>
<script>
function validateTareWeight(element) {
var grossWeight = parseFloat(document.getElementById('GrossWeight').value);
var tareWeight = parseFloat(document.getElementById('TareWeight').value);
if (tareWeight > grossWeight) {
alert("Tare Weight must be less than or equal to Gross Weight.");
document.getElementById('TareWeight').value = '';
document.getElementById('TareWeightDate').value = '';
return false;
}
WeightDiffer(element)
return true;
}
function updateTime() {
const now = new Date();
const year = now.getFullYear();
@ -1039,24 +1052,23 @@ function removeRows(inputs) {
document.getElementById('clock').textContent = dateString+" "+timeString;
document.getElementById('wizard_clock').textContent = dateString+" "+timeString;
}
setInterval(updateTime, 1000); // Update every second
updateTime(); // Initial call to display time immediately
function WeightDiffer(element)
{
// console.log(element);
var v1 = $("#GrossWeight").val();
var v2 = $("#TareWeight").val();
var v3 = v1-v2;
$("#NetWeight").val(v3);
if (element.id === 'GrossWeight') {
$("#GrossWeightDate").val($("#clock").text());
}
{
// console.log(element);
var v1 = $("#GrossWeight").val();
var v2 = $("#TareWeight").val();
var v3 = v1-v2;
$("#NetWeight").val(v3);
if (element.id === 'GrossWeight') {
$("#GrossWeightDate").val($("#clock").text());
}
if (element.id === 'TareWeight') {
$("#TareWeightDate").val($("#clock").text());
}
}
if (element.id === 'TareWeight') {
$("#TareWeightDate").val($("#clock").text());
}
}
</script>
<script>
@ -1064,7 +1076,7 @@ function removeRows(inputs) {
var inx = $(e.relatedTarget).data('index');
var material = $(e.relatedTarget).data('material');
document.getElementById('material').textContent = " ( "+material+" )";
document.getElementById('WeightTitle').textContent = " ( "+material+" )";
// Clear the modal inputs

View File

@ -54,19 +54,20 @@
var mindt = year-70;
var maxdt = year-15;
$("#Invoice_Date , #MaterialRcvdDate ").datepicker({
$("#Invoice_Date , #MaterialRcvdDate").datepicker({
minDate : new Date(year-SIAStartYear,1,1),
maxDate :'now',
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,yearRange: '-100:+0'
});
});
</script>
<div class="content-wrapper">
<section class="content"><br/>
<div class="box">
<div class="container-fluid">
<div class="box-header">
<center><b><h3 class="box-title">View Inward Gate Register</h3></b></center>
<center><b><h3 class="box-title">View Inward Gate Register <?php echo $DEPCode; ?></h3></b></center>
</div>
<div class="row">
<div class="col-md-12">
@ -118,7 +119,7 @@
<i class="fa fa-history" style="text-align: center;"></i>
</a>
&nbsp;
<a href="<?php echo base_url().'MRIRcontroller/igrdatavalues?IGRNO='.$record->IGRNO; ?>" target="_blank" data-id="<%=index%>" title="Generate MRIR"><i class="fa fa-external-link" style="text-align: center;"></i></a>
<a class="a_tag_for_mrir" href="<?php echo base_url().'MRIRcontroller/igrdatavalues?IGRNO='.$record->IGRNO; ?>" target="_blank" data-id="<%=index%>" title="Generate MRIR"><i class="fa fa-external-link" style="text-align: center;"></i></a>
</td>
</tr>
@ -173,14 +174,14 @@
?>
</div>
<div class="col-md-4">
<label>Invoice Date </label>
<label>Invoice Date <span class="requiredsymbol" style="color:red; font-size: 15px;">*</span></label>
<?php
$data = array('name' => 'InvoiceDate','value' => set_value('InvoiceDate'),'id'=>'Invoice_Date', 'class' => 'form-control', 'required=>"true"');
echo form_input($data);
?>
</div>
<div class="col-md-4">
<label>Material Received Date </label>
<label>Material Received Date <span class="requiredsymbol" style="color:red; font-size: 15px;">*</span> </label>
<?php
$data = array('name' => 'MaterialRcvdDate','value' => set_value('MaterialRcvdDate'),'id'=>'MaterialRcvdDate', 'class' => 'form-control');
echo form_input($data);
@ -293,7 +294,7 @@
<label for="TareWeight" class="col-md-2 col-form-label">Tare Weight</label>
<div class="col-md-5">
<?php
$data = array('name' => 'TareWeight', 'value' => set_value('TareWeight'), 'id' => 'TareWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'WeightDiffer(this);' ,'placeholder' => 'Enter your username','placeholder' => 'Tare Weight Value (B)');
$data = array('name' => 'TareWeight', 'value' => set_value('TareWeight'), 'id' => 'TareWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50','onchange' => 'validateTareWeight(this);' ,'placeholder' => 'Tare Weight Value (B)');
echo form_input($data);
?>
</div>
@ -367,8 +368,8 @@
<input type="button" class="btn btn-primary" id="addmorebutton" value=" ADD FILES..">
</div>
<div id="newdiv"></div>
<input type="text" name="hidecounter" id="hidecounter" value="0" />
<input type="text" name="counts" id="counts" value="0" />
<input type="hidden" name="hidecounter" id="hidecounter" value="0" />
<input type="hidden" name="hidegrandcounter" id="hidegrandcounter" value="0" />
<input type="hidden" name="hiddenIGRNO" id="hiddenIGRNO" />
<input type="hidden" name="hiddenPONO" id="hiddenPONO" />
</div>
@ -444,7 +445,7 @@
var igr = $(e.relatedTarget).data('userid');
var igrstatus = $(e.relatedTarget).data('igrstatus');
alert(igrstatus);
// alert(igrstatus);
var buttonContainer = $(".buttonContainer");
var modal = $(this); // Reference to the modal itself
var invoiceDateInput = modal.find('#Invoice_Date');
@ -452,23 +453,34 @@
var VehicleNoInput = modal.find('#Vehicle_No');
var DriverInput = modal.find('#Driver_Name');
var DriverMobileNumberInput = modal.find('#DriverMobileNumber');
var depCode = "<?php echo $DEPCode; ?>";
if (igrstatus == "ST074") {
buttonContainer.find("#draftIGR, #generateIGR").css("display", "inline-block");
VehicleNoInput.prop('readonly', false);
DriverInput.prop('readonly', false);
DriverMobileNumberInput.prop('readonly', false);
} else {
// Hide buttons in the container
buttonContainer.find("#draftIGR, #generateIGR").css("display", "none");
VehicleNoInput.prop('readonly', true);
DriverInput.prop('readonly', true);
DriverMobileNumberInput.prop('readonly', true);
// depCode != "DEP27"
if(depCode == "DEP27"){
if (igrstatus == "ST074") {
buttonContainer.find("#draftIGR, #generateIGR").css("display", "inline-block");
// $(".a_tag_for_mrir).css("display", "inline-block");
VehicleNoInput.prop('readonly', false);
DriverInput.prop('readonly', false);
DriverMobileNumberInput.prop('readonly', false);
MaterialRcvdDateInput.prop('readonly', false);
invoiceDateInput.prop('readonly', false);
} else {
buttonContainer.find("#draftIGR, #generateIGR").css("display", "none");
// $(".a_tag_for_mrir).css("display", "inline-block");
VehicleNoInput.prop('readonly', true);
DriverInput.prop('readonly', true);
DriverMobileNumberInput.prop('readonly', true);
MaterialRcvdDateInput.prop('readonly', true);
invoiceDateInput.prop('readonly', true);
}
}else{
if (igrstatus == "ST074") {
buttonContainer.find("#draftIGR, #generateIGR").css("display", "inline-block");
// $(".a_tag_for_mrir).css("display", "inline-block");
} else {
buttonContainer.find("#draftIGR").css("display", "none");
}
}
$("#tbleIGRAppend").empty();
@ -483,6 +495,7 @@
var trIGRHTML = '';
$.each(JSON.parse(data), function(i, item) {
if (igr == item.IGRNO) {
console.log(item);
$('#IgrshowTitle').text(" ( "+item.IGRNO+" ) ");
$("#IGRNO1").val(item.IGRNO);
$("#IGRItemNo").val(item.IGRItemNo);
@ -501,16 +514,17 @@
$("#Supplier").val(item.SupplierName);
$("#Add1").val(item.Address);
$("#Invoice_No").val(item.DeliveryChellanOrInvoiceNo);
alert(item.DeliveryChellanDate);
// alert(item.DeliveryChellanDate);
var dcd = new Date(item.DeliveryChellanDate);
//alert(dcd.getDate()+ '.' + (dcd.getMonth() + 1)+ '.' + dcd.getFullYear());
var dcd2 = (dcd.getDate() + '/' + (dcd.getMonth() + 1) + '/' + dcd.getFullYear());
// var dcd2 = (dcd.getDate() + '/' + (dcd.getMonth() + 1) + '/' + dcd.getFullYear());
var dcd2 = (String(dcd.getDate()).padStart(2, '0') + '-' + (String(dcd.getMonth() + 1).padStart(2, '0')) + '-' + dcd.getFullYear());
$("#Invoice_Date").val(dcd2);
if (item.MaterialRcvdDate === null) {
var Mat_rcv_date = ' ';
} else {
var MR_dt = new Date(item.MaterialRcvdDate);
var Mat_rcv_date = (MR_dt.getDate() + '/' + (MR_dt.getMonth() + 1) + '/' + MR_dt.getFullYear());
var Mat_rcv_date = (String(MR_dt.getDate()).padStart(2, '0') + '-' + (String(MR_dt.getMonth() + 1).padStart(2, '0')) + '-' + MR_dt.getFullYear());
}
$("#MaterialRcvdDate").val(Mat_rcv_date);
if (item.GrossWeightDate === null) {
@ -524,7 +538,7 @@
i = i + 1;
if (igrstatus === "ST074") {
alert("here");
// alert("here");
// document.getElementById('pendingQuantityHeader').style.display = 'table-cell';
$("#pendingQuantityHeader").css("display", "table-cell");
@ -551,7 +565,8 @@
'<input type="hidden" id="txtTareWeight' + i + '" name="txtTareWeight' + i + '" value="' + item.TareWeight + '">' +
'<input type="hidden" id="txtTareWeightDate' + i + '" name="txtTareWeightDate' + i + '" value="' + item.TareWeightDate + '">' +
'<input type="hidden" id="txtNetWeight' + i + '" name="txtNetWeight' + i + '"value="' + item.NetWeight + '">' +
'<input type="hidden" id="txtRemarks' + i + '" name="txtRemarks' + i + '">'; // Example with no initial value
'<input type="hidden" id="txtRemarks' + i + '" name="txtRemarks' + i + '"value="' + item.Remarks + '">' + // Example with no initial value
'<input type="hidden" id="txtIGRLineItem' + i + '" name="txtIGRLineItem' + i + '"value="' + item.IGRItemNo + '">' +
'</tr>';
//alert(item.PendingQty);
if ((item.Quantity - item.QuantityAsPerInvoice) == 0.00) {
@ -570,11 +585,17 @@
'<td align="right" data-name="sel" >' + item.QuantityAsPerInvoice + '</td>' +
'<td>' + item.Remarks + '</td>' +
'<td><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="'+i+'" data-material="'+item.MaterialName+'" data-igrstatus = "'+igrstatus+'"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
'<input type="hidden" id="IGRNO' + i + '" name="IGRNO' + i + '" value="' + item.IGRNO + '">' +
'<input type="hidden" id="IGRItemNo' + i + '" name="IGRItemNo' + i + '" value="' + item.IGRItemNo + '">' +
'<input type="hidden" id="MaterialCode' + i + '" name="MaterialCode' + i + '" value="' + item.MaterialCode + '">' +
'<input type="hidden" id="txtQuantityAsPerInvoice' + i + '" name="txtQuantityAsPerInvoice' + i + '" value="' + item.QuantityAsPerInvoice + '">' +
'<input type="hidden" id="txtOrderedQuantity' + i + '" name="txtOrderedQuantity' + i + '" value="' + item.Quantity + '">' +
'<input type="hidden" id="txtGrossWeight' + i + '" name="txtGrossWeight' + i + '" value="' + item.GrossWeight + '">' +
'<input type="hidden" id="txtGrossWeightDate' + i + '" name="txtGrossWeightDate' + i + '" value="' + item.GrossWeightDate + '">' +
'<input type="hidden" id="txtTareWeight' + i + '" name="txtTareWeight' + i + '" value="' + item.TareWeight + '">' +
'<input type="hidden" id="txtTareWeightDate' + i + '" name="txtTareWeightDate' + i + '" value="' + item.TareWeightDate + '">' +
'<input type="hidden" id="txtNetWeight' + i + '" name="txtNetWeight' + i + '"value="' + item.NetWeight + '">' +
'<input type="hidden" id="txtIGRLineItem' + i + '" name="txtIGRLineItem' + i + '"value="' + item.IGRItemNo + '">' +
'</tr>';
}
@ -600,39 +621,79 @@
$.ajax({
data:{igr:igrno,mrc:materialrcv_date,invdate:inv_date},
type:"POST",
url:"<?php echo base_url() ?>inwardgateregister/UpdateIGR",
url:"<?php echo base_url() ?>UpdateIGR",
success:function(data) {
$('#content').loader('hide');
alert(data);
}
});
});
$('#update').click(function(){
$('#draftIGR').click(function(){
$('#content').loader('show');
var igrno = $("#IGRNO1").val();
var materialrcv_date = $("#MaterialRcvdDate").val();
var inv_date = $("#Invoice_Date").val();
var vehicle_no = $('#Vehicle_No').val();
var driver = $('#Driver_Name').val();
var driver_mobile = $('#DriverMobileNumber').val();
var status = 0;
var tableData = [];
$('#tbleIGRAppend tr').each(function() {
var row = $(this);
var rowData = {
MaterialCode: row.find('#MaterialCode' + row.index()).val(),
Quantity: row.find('#txtOrderedQuantity' + row.index()).val(),
QuantityAsPerInvoice: row.find('#txtQuantityAsPerInvoice' + row.index()).val(),
Remarks: row.find('#txtGrossWeight' + row.index()).val(),
GrossWeight: row.find('#txtGrossWeight' + row.index()).val(),
GrossWeightDate: row.find('#txtGrossWeightDate' + row.index()).val(),
TareWeight: row.find('#txtTareWeight' + row.index()).val(),
TareWeightDate: row.find('#txtTareWeightDate' + row.index()).val(),
NetWeight: row.find('#txtNetWeight' + row.index()).val(),
IGRItemNo: row.find('#txtIGRLineItem' + row.index()).val()
};
tableData.push(rowData);
});
$.ajax({
data:{igr:igrno,mrc:materialrcv_date,invdate:inv_date},
data:{igr:igrno,mrc:materialrcv_date,invdate:inv_date,vehicle_no:vehicle_no,driver:driver,driver_mobile:driver_mobile,status:status,tableData: tableData},
type:"POST",
url:"<?php echo base_url() ?>inwardgateregister/UpdateIGR",
url:"<?php echo base_url() ?>UpdateIGR",
success:function(data) {
$('#content').loader('hide');
alert(data);
}
});
});
$('#update').click(function(){
$('#generateIGR').click(function(){
$('#content').loader('show');
var igrno = $("#IGRNO1").val();
var materialrcv_date = $("#MaterialRcvdDate").val();
var inv_date = $("#Invoice_Date").val();
var vehicle_no = $('#Vehicle_No').val();
var driver = $('#Driver_Name').val();
var driver_mobile = $('#DriverMobileNumber').val();
var status = 1;
var tableData = [];
$('#tbleIGRAppend tr').each(function() {
var row = $(this);
var rowData = {
MaterialCode: row.find('#MaterialCode' + row.index()).val(),
Quantity: row.find('#txtOrderedQuantity' + row.index()).val(),
QuantityAsPerInvoice: row.find('#txtQuantityAsPerInvoice' + row.index()).val(),
GrossWeight: row.find('#txtGrossWeight' + row.index()).val(),
GrossWeightDate: row.find('#txtGrossWeightDate' + row.index()).val(),
TareWeight: row.find('#txtTareWeight' + row.index()).val(),
TareWeightDate: row.find('#txtTareWeightDate' + row.index()).val(),
NetWeight: row.find('#txtNetWeight' + row.index()).val(),
IGRItemNo: row.find('#txtIGRLineItem' + row.index()).val()
};
tableData.push(rowData);
});
$.ajax({
data:{igr:igrno,mrc:materialrcv_date,invdate:inv_date},
type:"POST",
url:"<?php echo base_url() ?>inwardgateregister/UpdateIGR",
data:{igr:igrno,mrc:materialrcv_date,invdate:inv_date,vehicle_no:vehicle_no,driver:driver,driver_mobile:driver_mobile,status:status,tableData: tableData},
type:"POST",
url:"<?php echo base_url() ?>UpdateIGR",
success:function(data) {
$('#content').loader('hide');
alert(data);
@ -651,7 +712,7 @@
$.ajax({
data: { igr: igr },
type: "POST",
url: "<?php echo base_url() ?>inwardgateregister/ViewIGRHistory",
url: "<?php echo base_url() ?>ViewIGRHistory",
success: function(data) {
var output = '';
if (data && data.length > 0) {
@ -771,10 +832,10 @@ $("#Fileshow").on("shown.bs.modal", function(e) {
id1: po
},
type: "POST",
url: "<?php echo base_url() ?>inwardgateregister/ViewIGRfile",
url: "<?php echo base_url() ?>ViewIGRfile",
success: function(file) {
$("#counts").val(JSON.parse(file).length);
$("#hidegrandcounter").val(JSON.parse(file).length);
var trFileHTML = '';
var FilePath = '';
@ -878,6 +939,145 @@ function deleteBill(Billno,i){
});
}
</script>
<script>
function validateTareWeight(element) {
var grossWeight = parseFloat(document.getElementById('GrossWeight').value);
var tareWeight = parseFloat(document.getElementById('TareWeight').value);
if (tareWeight > grossWeight) {
alert("Tare Weight must be less than or equal to Gross Weight.");
document.getElementById('TareWeight').value = '';
document.getElementById('TareWeightDate').value = '';
return false;
}
WeightDiffer(element)
return true;
}
function updateTime() {
const now = new Date();
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const todaydate = now.getDate().toString().padStart(2, '0');
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
const dateString = todaydate+'-'+month+'-'+year;
const timeString = hours+":"+minutes+":"+seconds;
document.getElementById('clock').textContent = dateString+" "+timeString;
}
setInterval(updateTime, 1000); // Update every second
updateTime(); // Initial call to display time immediately
function WeightDiffer(element)
{
// console.log(element);
var v1 = $("#GrossWeight").val();
var v2 = $("#TareWeight").val();
var v3 = v1-v2;
$("#NetWeight").val(v3);
if (element.id === 'GrossWeight') {
$("#GrossWeightDate").val($("#clock").text());
}
if (element.id === 'TareWeight') {
$("#TareWeightDate").val($("#clock").text());
}
}
$("#WeightCalculator").on("shown.bs.modal", function(e) {
var inx = $(e.relatedTarget).data('index');
var material = $(e.relatedTarget).data('material');
document.getElementById('WeightTitle').textContent = " ( "+material+" )";
// Clear the modal inputs
$("#GrossWeight").val('');
$("#GrossWeightDate").val('');
$("#TareWeight").val('');
$("#TareWeightDate").val('');
$("#NetWeight").val('');
// Retrieve values from hidden inputs
var v1 = $("#txtGrossWeight" + inx).val();
var v2 = $("#txtGrossWeightDate" + inx).val();
var v3 = $("#txtTareWeight" + inx).val();
var v4 = $("#txtTareWeightDate" + inx).val();
var v5 = $("#txtNetWeight" + inx).val();
// Debugging alerts
// console.log("v1:", v1);
// console.log("v2:", v2);
// console.log("v3:", v3);
// console.log("v4:", v4);
// console.log("v5:", v5);
console.log("Selected values for index:", typeof inx,inx);
// Set modal inputs with the retrieved values
$("#GrossWeight").val(v1);
$("#GrossWeightDate").val(v2);
$("#TareWeight").val(v3);
$("#TareWeightDate").val(v4);
$("#NetWeight").val(v5);
$("#CurrentInx").val(inx);
});
function modalSave() {
var v1 = $("#GrossWeight").val();
var v2 = $("#GrossWeightDate").val();
var v3 = $("#TareWeight").val();
var v4 = $("#TareWeightDate").val();
var v5 = $("#NetWeight").val();
var v6 = $("#CurrentInx").val();
var IGRNO1 = $("#IGRNO1").val();
// Debugging alerts
// console.log("v1:", v1);
// console.log("v2:", v2);
// console.log("v3:", v3);
// console.log("v4:", v4);
// console.log("v5:", v5);
if (v6 !== undefined && v6 !== '') {
console.log("Saving values for index:", v6);
// Set the values back to the hidden inputs
$("#txtGrossWeight" + v6).val(v1);
$("#txtGrossWeightDate" + v6).val(v2);
$("#txtTareWeight" + v6).val(v3);
$("#txtTareWeightDate" + v6).val(v4);
$("#txtNetWeight" + v6).val(v5);
var txtIGRLineItem = $("#txtIGRLineItem" + v6).val();
$.ajax({
data:{GrossWeight:v1,GrossWeightDate:v2,TareWeight:v3,TareWeightDate:v4,NetWeight:v5,IGR:IGRNO1,IGRlineitem:txtIGRLineItem},
//dataType:"json",
type:"POST",
url: "<?php echo base_url() ?>updateIGRWeight",
success:function(data) {
if(data)
{
alert(data);
}
}
});
// Clear modal inputs
$("#GrossWeight").val('');
$("#GrossWeightDate").val('');
$("#TareWeight").val('');
$("#TareWeightDate").val('');
$("#NetWeight").val('');
// Close the modal
$("#WeightCalculator").modal('hide');
} else {
console.log("Saving values for index: "+v6+" undefined");
}
}
</script>
<script>
function formatDateTime(dateString) {
@ -957,7 +1157,7 @@ function deleteBill(Billno,i){
$("#addmorebutton").click(function() {
$('#newdiv').empty();
var file_count = $("#counts").val();
var file_count = $("#hidegrandcounter").val();
counter++;
var bil_count = +counter + +file_count;
if (bil_count >= 6) {
@ -1032,8 +1232,8 @@ function deleteBill(Billno,i){
});
}
function addToTable(counter,billNo, fileName) {
var file_count = $("#counts").val();
alert(file_count);
var hidecounter = $("#hidecounter").val();
var file_count = $("#hidegrandcounter").val();
var newRow = '<tr id="row' + counter + '">' +
'<td>' + counter + '</td>' +
@ -1053,8 +1253,6 @@ function deleteBill(Billno,i){
</script>
<!-- Latest jQuery -->
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<!-- Latest DataTables JS -->
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<!-- Latest DataTables Buttons JS -->