FIX_igr Changes : ps

This commit is contained in:
VE10-Sanjeev 2024-07-17 09:00:37 +00:00
parent 873a206fa7
commit f861d6635d
9 changed files with 2050 additions and 1145 deletions

View File

@ -141,9 +141,9 @@ define('REQ_READYFORDELIVERY','ST049');
define('REQ_DELIVERED','ST050'); define('REQ_DELIVERED','ST050');
/* IGR Status */ /* IGR Status */
define('IGR_DRAFT','ST074');
define('IGR_CREATED','ST027'); define('IGR_CREATED','ST027');
define('IGR_CLOSED','ST028'); define('IGR_CLOSED','ST028');
define('IGR_DRAFT','ST074');
define('IGR_CANCELLED','ST029'); define('IGR_CANCELLED','ST029');
define('POLINEITEM_IGRPARTIAL_CREATED','ST042'); define('POLINEITEM_IGRPARTIAL_CREATED','ST042');

View File

@ -261,6 +261,7 @@ $routes->post('inwardgateregister/edituploadfile', 'Inwardgateregister::edituplo
$routes->post('inwardgateregister/addloadfile', 'Inwardgateregister::addloadfile'); $routes->post('inwardgateregister/addloadfile', 'Inwardgateregister::addloadfile');
$routes->post('inwardgateregister/UpdateIGR', 'Inwardgateregister::UpdateIGR'); $routes->post('inwardgateregister/UpdateIGR', 'Inwardgateregister::UpdateIGR');
$routes->post('inwardgateregister/updateIGRLineItem', 'Inwardgateregister::updateIGRLineItem'); $routes->post('inwardgateregister/updateIGRLineItem', 'Inwardgateregister::updateIGRLineItem');
$routes->post('inwardgateregister/ViewIGRHistory', 'Inwardgateregister::ViewIGRHistory');
// Application OGR Page // Application OGR Page
$routes->match(['get', 'post', 'put', 'delete'],'AddOgr', 'Inwardgateregister::addoutwardgateregister'); $routes->match(['get', 'post', 'put', 'delete'],'AddOgr', 'Inwardgateregister::addoutwardgateregister');

View File

@ -67,7 +67,6 @@ class Inwardgateregister extends BaseController
return !($item->status === 'ST027' && $item->IsOpenOrder === null); return !($item->status === 'ST027' && $item->IsOpenOrder === null);
}); });
$this->loadViews("inwardgateregister", $this->global, $data, NULL); $this->loadViews("inwardgateregister", $this->global, $data, NULL);
} }
@ -314,11 +313,81 @@ class Inwardgateregister extends BaseController
$prefile = array(); $prefile = array();
$fileupdated_count = 0; $fileupdated_count = 0;
$fileupdated_name = []; $fileupdated_name = [];
$GrossWeight = $this->request->getPost('GrossWeight');
$TareWeight = $this->request->getPost('TareWeight');
$NetWeight = $this->request->getPost('NetWeight');
$GrossWeightDate = (string)$this->request->getPost('GrossWeightDate');
$GrossWtDt = get_date_time_format($GrossWeightDate);
$TareWeightDate = (string)$this->request->getPost('TareWeightDate');
$TareWtDt = get_date_time_format($TareWeightDate);
// $igr = array('PONO' => $PONO, 'VehicleNo' => $VehicleNo, 'DeliveryChellanOrInvoiceNo' => $DeliveryChellanOrInvoiceNo, 'DeliveryChellanDate' => $DeliveryChellanDate, 'MaterialRcvdDate' => $MaterialRcvdDt, 'DriverName' => $DriverName, 'DriverMobileNumber' => $DriverMobileNumber,'IGRStatus' => $IGRStatus, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt, 'PaymentStatus' => $paymentstatus);
$igr = array('PONO' => $PONO, 'VehicleNo' => $VehicleNo, 'DeliveryChellanOrInvoiceNo' => $DeliveryChellanOrInvoiceNo, 'DeliveryChellanDate' => $DeliveryChellanDate, 'MaterialRcvdDate' => $MaterialRcvdDt, 'DriverName' => $DriverName, 'DriverMobileNumber' => $DriverMobileNumber,'IGRStatus' => $IGRStatus, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt, 'PaymentStatus' => $paymentstatus,'GrossWeight'=>$GrossWeight,'TareWeight'=>$TareWeight,'NetWeight'=>$NetWeight,'GrossWeightDate'=>$GrossWtDt,'TareWeightDate'=>$TareWtDt);
$igr = array('PONO' => $PONO, 'VehicleNo' => $VehicleNo, 'DeliveryChellanOrInvoiceNo' => $DeliveryChellanOrInvoiceNo, 'DeliveryChellanDate' => $DeliveryChellanDate, 'MaterialRcvdDate' => $MaterialRcvdDt, 'DriverName' => $DriverName, 'DriverMobileNumber' => $DriverMobileNumber,'IGRStatus' => $IGRStatus, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt, 'PaymentStatus' => $paymentstatus);
//Saving IGR details Here //Saving IGR details Here
$IGRNO = $this->inwardgateregister_model->addigrM($igr); $IGRNO = $this->inwardgateregister_model->addigrM($igr);
if($IGRNO){ if($IGRNO){
#Step 1.1 Fetch On History
if($GrossWeight){
$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);
$history_id = $this->inwardgateregister_model->igr_history($igr_history);
log_message('error', "History updated successfully. History id: " . $history_id);
}
if($TareWeight){
$igr_history = array('field' => 'TareWeight','is_add' => 1,'new_data' => $TareWeight,'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($NetWeight){
$igr_history = array('field' => 'NetWeight','is_add' => 1,'new_data' => $NetWeight,'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($GrossWtDt){
$igr_history = array('field' => 'GrossWeightDate','is_add' => 1,'new_data' => $GrossWtDt,'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($TareWtDt){
$igr_history = array('field' => 'TareWeightDate','is_add' => 1,'new_data' => $TareWtDt,'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($DeliveryChellanOrInvoiceNo){
// $igr_history = array('field' => 'DeliveryChellanOrInvoiceNo','is_add' => 1,'new_data' => $DeliveryChellanOrInvoiceNo,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO);
// $history_id = $this->inwardgateregister_model->igr_history($igr_history);
// log_message('error', "History updated successfully. History id: " . $history_id);
// }
// if($DeliveryChellanDate){
// $igr_history = array('field' => 'DeliveryChellanDate','is_add' => 1,'new_data' => $DeliveryChellanDate,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO);
// $history_id = $this->inwardgateregister_model->igr_history($igr_history);
// log_message('error', "History updated successfully. History id: " . $history_id);
// }
// if($MaterialRcvdDt){
// $igr_history = array('field' => 'MaterialRcvdDate','is_add' => 1,'new_data' => $MaterialRcvdDt,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO);
// $history_id = $this->inwardgateregister_model->igr_history($igr_history);
// log_message('error', "History updated successfully. History id: " . $history_id);
// }
if($VehicleNo){
$igr_history = array('field' => 'VehicleNo','is_add' => 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){
$igr_history = array('field' => 'DriverName','is_add' => 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){
$igr_history = array('field' => 'DriverMobileNumber','is_add' => 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);
}
#Step 2 File Details Gathering #Step 2 File Details Gathering
if($constant){ if($constant){
for ($i = 1; $i <= $constant; $i++) { for ($i = 1; $i <= $constant; $i++) {
@ -411,6 +480,7 @@ class Inwardgateregister extends BaseController
$igrDetails = array('IGRNO' => $IGRNO, 'MaterialCode' => $MaterialCode, 'QuantityAsPerInvoice' => $QuantityAsPerInvoice, 'Remarks' => $Remarks, 'IGRItemStatus' => $IGRItemStatus, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt); $igrDetails = array('IGRNO' => $IGRNO, 'MaterialCode' => $MaterialCode, 'QuantityAsPerInvoice' => $QuantityAsPerInvoice, 'Remarks' => $Remarks, 'IGRItemStatus' => $IGRItemStatus, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt);
$igrD = $this->inwardgateregister_model->addigrD($igrDetails); $igrD = $this->inwardgateregister_model->addigrD($igrDetails);
$igrlineno = !empty($igrD) ? $igrD : ''; $igrlineno = !empty($igrD) ? $igrD : '';
$itemvalue = ''; $itemvalue = '';
$SupplierId = ''; $SupplierId = '';
$polineitemvalue = $this->inwardgateregister_model->getitemvalue($PONO, $MaterialCode); $polineitemvalue = $this->inwardgateregister_model->getitemvalue($PONO, $MaterialCode);
@ -420,6 +490,16 @@ class Inwardgateregister extends BaseController
} }
$historydetails = array('MaterialCode' => $MaterialCode, 'Transaction_type' => "Add", 'Ref_Type' => "IGR", 'Ref_No' => $igrlineno, 'Quantity' => $QuantityAsPerInvoice, 'CreatedBy' => $CreatedBy, 'CreatedOn' => $createddt, 'SupplierID' => $SupplierId, 'ItemValue' => $itemvalue); $historydetails = array('MaterialCode' => $MaterialCode, 'Transaction_type' => "Add", 'Ref_Type' => "IGR", 'Ref_No' => $igrlineno, 'Quantity' => $QuantityAsPerInvoice, 'CreatedBy' => $CreatedBy, 'CreatedOn' => $createddt, 'SupplierID' => $SupplierId, 'ItemValue' => $itemvalue);
$this->inwardgateregister_model->addmaterialhistory($historydetails); $this->inwardgateregister_model->addmaterialhistory($historydetails);
if($QuantityAsPerInvoice){
$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'=>$igrlineno);
$history_id = $this->inwardgateregister_model->igr_history($igr_history);
log_message('error', "History updated successfully. History id: " . $history_id);
}
if($Remarks){
$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'=>$igrlineno);
$history_id = $this->inwardgateregister_model->igr_history($igr_history);
log_message('error', "History updated successfully. History id: " . $history_id);
}
$get_pre_qty = $this->inwardgateregister_model->get_CurrentQty($MaterialCode); $get_pre_qty = $this->inwardgateregister_model->get_CurrentQty($MaterialCode);
$av_qty = 0; $av_qty = 0;
if (!empty($get_pre_qty)) { if (!empty($get_pre_qty)) {
@ -668,6 +748,7 @@ echo "<script>
$IGRNO = $this->request->getPost('id'); $IGRNO = $this->request->getPost('id');
$data = $this->inwardgateregister_model->viewigr($IGRNO); $data = $this->inwardgateregister_model->viewigr($IGRNO);
// echo $IGRNO;
// print_r($data);die; // print_r($data);die;
echo json_encode($data); echo json_encode($data);
@ -680,6 +761,12 @@ echo "<script>
$data = array_merge($igrfile, $billfile); $data = array_merge($igrfile, $billfile);
echo json_encode($data); echo json_encode($data);
} }
function ViewIGRHistory()
{
$IGRNO = $this->request->getPost('igr');
$result = $this->inwardgateregister_model->ViewIGRHistory($IGRNO);
return $this->response->setJSON($result);
}
function UpdateIGR() function UpdateIGR()
@ -706,17 +793,198 @@ echo "<script>
} }
} }
function updateIGRLineItem() { function updateIGRLineItem() {
$IGRNo = $this->request->getPost('igr');
$Status = $this->request->getPost('status'); $IGRNo = $this->request->getPost('IGRNO');
$Status = $this->request->getPost('IGRStatus');
$DriverName = $this->request->getPost('DriverName');
$DriverMobileNumber = $this->request->getPost('DriverMobileNumber');
$GrossWeight = $this->request->getPost('GrossWeight');
$TareWeight = $this->request->getPost('TareWeight');
$NetWeight = $this->request->getPost('NetWeight');
$VehicleNo = $this->request->getPost('VehicleNo');
$requestdata = $this->request->getPost('data'); $requestdata = $this->request->getPost('data');
$updateby = $this->session->get('userId'); $updateby = $this->session->get('userId');
$GrossWeightDate = (string)$this->request->getPost('GrossWeightDate');
$GrossWtDt = get_date_time_format($GrossWeightDate);
$TareWeightDate = (string)$this->request->getPost('TareWeightDate');
$TareWtDt = get_date_time_format($TareWeightDate);
// Check if request data is not null and is a string // Check if request data is not null and is a string
if (is_string($requestdata)) { if (is_string($requestdata)) {
$lineitemdata = json_decode($requestdata, true); // Decode JSON data $lineitemdata = json_decode($requestdata, true); // Decode JSON data
if (is_array($lineitemdata)) { if (is_array($lineitemdata)) {
$igrarr = array('IGRStatus' => $Status, 'UpdateBY' => $updateby); if($GrossWeight){
$gross = $this->inwardgateregister_model->get_igr_history('GrossWeight',$IGRNo);
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);
($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);
$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);
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);
($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);
$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);
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);
($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);
$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);
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);
($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);
$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);
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);
($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);
$history_id = $this->inwardgateregister_model->igr_history($igr_history);
log_message('error', "History updated successfully. History id: " . $history_id);
}
}
// if($DeliveryChellanOrInvoiceNo){
// $igr_history = array('field' => 'DeliveryChellanOrInvoiceNo','is_edit' => 1,'new_data' => $DeliveryChellanOrInvoiceNo,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO);
// $history_id = $this->inwardgateregister_model->igr_history($igr_history);
// log_message('error', "History updated successfully. History id: " . $history_id);
// }
// if($DeliveryChellanDate){
// $igr_history = array('field' => 'DeliveryChellanDate','is_edit' => 1,'new_data' => $DeliveryChellanDate,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO);
// $history_id = $this->inwardgateregister_model->igr_history($igr_history);
// log_message('error', "History updated successfully. History id: " . $history_id);
// }
// if($MaterialRcvdDt){
// $igr_history = array('field' => 'MaterialRcvdDate','is_edit' => 1,'new_data' => $MaterialRcvdDt,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO);
// $history_id = $this->inwardgateregister_model->igr_history($igr_history);
// log_message('error', "History updated successfully. History id: " . $history_id);
// }
if($VehicleNo){
$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);
}}
$igrarr = array('VehicleNo' => $VehicleNo, 'DriverName' => $DriverName, 'DriverMobileNumber' => $DriverMobileNumber,'IGRStatus' => $Status, 'UpdateBY' => $updateby,'GrossWeight'=>$GrossWeight,'TareWeight'=>$TareWeight,'NetWeight'=>$NetWeight,'GrossWeightDate'=>$GrossWtDt,'TareWeightDate'=>$TareWtDt);
$masterdata = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo); $masterdata = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo);
$dummy = 0; $dummy = 0;
$i=1; $i=1;
@ -738,6 +1006,43 @@ echo "<script>
); );
// print_r($igrline); // print_r($igrline);
$lineitemdata = $this->inwardgateregister_model->updateIGRLineItem($igrline, $IGRItemNo); $lineitemdata = $this->inwardgateregister_model->updateIGRLineItem($igrline, $IGRItemNo);
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);
}}
$i++; $i++;
if ($lineitemdata > 0) { if ($lineitemdata > 0) {
$dummy++; $dummy++;

View File

@ -197,6 +197,38 @@ class Inwardgateregister_model extends Model
return $result; */ return $result; */
} }
public function igr_history($hsty_arr) {
$this->db->transStart();
$builder = $this->db->table('T_IGR_History');
$builder->insert($hsty_arr);
$this->db->transComplete();
if ($this->db->transStatus() === FALSE) {
return false;
} else {
return $this->db->insertID();
}
}
function get_igr_history($col,$IGR,$IGRITEM = null)
{
$builder = $this->db->table('T_IGR_History Hist')
->select("Hist.*");
$builder->where('Hist.field', $col);
if($IGR){
$builder->where('Hist.IGR_No', $IGR);
}
if ($IGRITEM !== null) {
$builder->where('Hist.IGRItem_No', $IGRITEM);
}
$query = $builder->get();
$result = $query->getResult();
return $result;
// $result = $model->get_igr_history('001');
// $result = $model->get_igr_history('001', 1);
}
function addigrM($igrM) function addigrM($igrM)
{ {
@ -289,6 +321,11 @@ class Inwardgateregister_model extends Model
function viewigr($IGRNO) function viewigr($IGRNO)
{ {
// ->select('igr.IGRNO','igr.PONO','igr.DeliveryChellanOrInvoiceNo','igr.DeliveryChellanDate','igr.MaterialRcvdDate','igr.VehicleNo','igr.CourierNo','igr.Remarks','igr.IGRStatus','igr.CreatedDate','igr.CreatedBy','igr.UpdateBY','igr.UpdatedOn','igr.file','igr.Paymentstatus','igr.DriverName','igr.DriverMobileNumber','igr.NetWeight','igr.GrossWeight','igr.TareWeight','igr.GrossWeightDate','igr.TareWeightDate')
// ->select('igrd.IGRItemNo','igrd.IGRNO','igrd.MaterialCode','igrd.QuantityAsPerInvoice')
// ->select('igrd.Remarks','igrd.IGRItemStatus','igrd.CancelNote','igrd.BankStatus')
// ->select('MM.MaterialName,MM.UOM,sup.Address,sup.SupplierName,POM.ServiceDescription,POL.Quantity,POM.POType')
$builder = $this->db->table('T_IGR_Master igr') $builder = $this->db->table('T_IGR_Master igr')
->distinct() ->distinct()
->select('igr.IGRNO,igr.*,igrd.*,MM.MaterialName,MM.UOM,sup.Address,sup.SupplierName,POM.ServiceDescription,POL.Quantity,POM.POType') ->select('igr.IGRNO,igr.*,igrd.*,MM.MaterialName,MM.UOM,sup.Address,sup.SupplierName,POM.ServiceDescription,POL.Quantity,POM.POType')
@ -302,7 +339,7 @@ class Inwardgateregister_model extends Model
$query = $builder->get(); $query = $builder->get();
$result = $query->getResult(); $result = $query->getResult();
// echo $this->db->getLastQuery()->getQuery();
return $result; return $result;
} }
@ -823,4 +860,21 @@ class Inwardgateregister_model extends Model
$update = $this->db->affectedRows(); $update = $this->db->affectedRows();
return $update; return $update;
} }
public function ViewIGRHistory($igr)
{
$builder = $this->db->table('T_IGR_History');
$builder->select('T_IGR_History.*, CONCAT_WS(" ", T_Employee_Details.FirstName, T_Employee_Details.LastName) AS FullName');
$builder->join('tbl_users', 'tbl_users.userId = T_IGR_History.by', 'left');
$builder->join('T_Employee_Details', 'tbl_users.EmpID = T_Employee_Details.EmpID', 'left');
$builder->where('IGR_No', $igr);
$query = $builder->get();
$result = $query->getResult();
return $result;
// Pass the result to the view or return it as JSON
// return $this->response->setJSON($result);
}
} }

View File

@ -30,9 +30,8 @@ class Mrir_model extends Model
function ViewigrListing() function ViewigrListing()
{ {
$builder = $this->db->table('T_IGR_Master igr') $builder = $this->db->table('T_IGR_Master igr')
->select('igr.*,PO.DeliveryDate,sup.SupplierName') ->select('igr.*,PO.DeliveryDate,sup.SupplierName,PO.POType')
->join('T_PurchaseOrder_Master PO', 'igr.PONO = PO.PONO') ->join('T_PurchaseOrder_Master PO', 'igr.PONO = PO.PONO')
->join('T_SupplierDetailsN` sup', 'PO.SupplierID = sup.SupplierID') ->join('T_SupplierDetailsN` sup', 'PO.SupplierID = sup.SupplierID')
->where('igr.IGRStatus !=', MRIR_CREATED) ->where('igr.IGRStatus !=', MRIR_CREATED)

View File

@ -1489,7 +1489,7 @@
<?php $link = ($DEPCode == SECURITY) ? base_url() . 'ViewigrDetails' : base_url() . 'Viewigr'; ?> <?php $link = ($DEPCode == SECURITY) ? base_url() . 'ViewigrDetails' : base_url() . 'Viewigr'; ?>
<a href="<?php echo $link; ?>"> <a href="<?php echo $link; ?>">
<i class="fa fa-upload"></i> <i class="fa fa-upload"></i>
<span>View Inward Gate Register</span> <span>View Inward Gate Register 1</span>
</a> </a>
</li> </li>
<li> <li>
@ -1548,7 +1548,7 @@
<!-- <li class="treeview"> <!-- <li class="treeview">
<a href="<?php echo base_url(); ?>ViewigrDetails"> <a href="<?php echo base_url(); ?>ViewigrDetails">
<i class="fa fa-upload"></i> <i class="fa fa-upload"></i>
<span>View Inward Gate Register</span> <span>View Inward Gate Register 2</span>
</a> </a>
</li> --> </li> -->
<?php } ?> <?php } ?>
@ -1563,7 +1563,7 @@
<li class="treeview"> <li class="treeview">
<a href="<?php echo base_url(); ?>ViewigrDetails"> <a href="<?php echo base_url(); ?>ViewigrDetails">
<i class="fa fa-upload"></i> <i class="fa fa-upload"></i>
<span>View Inward Gate Register</span> <span>View Inward Gate Register 3</span>
</a> </a>
</li> </li>
<?php } ?> --> <?php } ?> -->
@ -1607,7 +1607,7 @@
<?php $link = ($DEPCode == SECURITY) ? base_url() . 'ViewigrDetails' : base_url() . 'Viewigr'; ?> <?php $link = ($DEPCode == SECURITY) ? base_url() . 'ViewigrDetails' : base_url() . 'Viewigr'; ?>
<a href="<?php echo $link; ?>"> <a href="<?php echo $link; ?>">
<i class="fa fa-eye"></i> <i class="fa fa-eye"></i>
<span>View Inward Gate Register</span> <span>View Inward Gate Register 4</span>
</a> </a>
</li> </li>
<li> <li>
@ -1704,7 +1704,7 @@
<?php $link = ($DEPCode == SECURITY) ? base_url() . 'ViewigrDetails' : base_url() . 'Viewigr'; ?> <?php $link = ($DEPCode == SECURITY) ? base_url() . 'ViewigrDetails' : base_url() . 'Viewigr'; ?>
<a href="<?php echo $link; ?>"> <a href="<?php echo $link; ?>">
<i class="fa fa-upload"></i> <i class="fa fa-upload"></i>
<span>View Inward Gate Register</span> <span>View Inward Gate Register 5</span>
</a> </a>
</li> </li>
<?php } ?> <?php } ?>
@ -1743,19 +1743,14 @@
<span>Inward Gate Register Entry</span> <span>Inward Gate Register Entry</span>
</a> </a>
</li> </li>
<li> <li>
<a href="<?php echo base_url(); ?>ViewigrDetails"> <?php $link = ($DEPCode == SECURITY) ? base_url() . 'ViewigrDetails' : base_url() . 'Viewigr'; ?>
<a href="<?php echo $link; ?>">
<i class="fa fa-eye"></i> <i class="fa fa-eye"></i>
<span>View Inward Gate Register</span> <span>View Inward Gate Register</span>
</a> </a>
</li> </li>
<!-- <li>
<?php // $link = ($DEPCode !== SECURITY) ? base_url() . 'ViewigrDetails' : base_url() . 'Viewigr'; ?>
<a href="<?php // echo $link; ?>">
<i class="fa fa-eye"></i>
<span>View Inward Gate Register</span>
</a>
</li> -->
</ul> </ul>
</li> </li>

View File

@ -55,6 +55,10 @@
<div class="content-wrapper" style="min-height:537px;"> <div class="content-wrapper" style="min-height:537px;">
<section class="content-header"> <section class="content-header">
<div class="pull-right hidden-xs">
<!-- <b><?php // $date = date('Y-m-d H:i:s'); echo $date; ?> </b> -->
<b><div id="clock"></div></b>
</div>
<h1> <h1>
<center> Inward Gate Register</center> <center> Inward Gate Register</center>
</h1> </h1>
@ -161,7 +165,6 @@
</div> </div>
</div> </div>
<!-- <div class="col-md-12"> <!-- <div class="col-md-12">
<div class="col-md-offset-4"> <div class="col-md-offset-4">
<div class="box-header"> <div class="box-header">
@ -186,6 +189,8 @@
<input type="hidden" name="hidecounters" id="hidecounters" value="0" /> <input type="hidden" name="hidecounters" id="hidecounters" value="0" />
<input type="hidden" name="hideconstants" id="hideconstants" value="0" /> <input type="hidden" name="hideconstants" id="hideconstants" value="0" />
<input type="hidden" name="hideIGRStatus" id="hideIGRStatus" value="0" /> <input type="hidden" name="hideIGRStatus" id="hideIGRStatus" value="0" />
<input type="hidden" name="hideIGRRemarks" id="hideIGRRemarks" value="" />
</div> </div>
@ -202,8 +207,8 @@
<th>UOM</th> <th>UOM</th>
<th>Ordered Quantity</th> <th>Ordered Quantity</th>
<th>Received Quantity</th> <th>Received Quantity</th>
<th>Advised Quantity</th>
<th>Balance Quantity</th> <th>Balance Quantity</th>
<th>Pending Quantity</th>
<th>Remarks</th> <th>Remarks</th>
</tr> </tr>
@ -245,10 +250,64 @@
</div> --> </div> -->
<div class="col-md-4 col-md-offset-8"> <div class="container">
<div class="form-group row">
<label for="GrossWeight" class="col-md-2 col-form-label">Gross Weight</label>
<div class="col-md-3">
<?php
$data = array('name' => 'GrossWeight', 'value' => set_value('GrossWeight'), 'id' => 'GrossWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'WeightDiffer(this);');
echo form_input($data);
?>
</div>
<div class="col-md-3">
<?php
$data = array('name' => 'GrossWeightDate', 'value' => set_value('GrossWeightDate'), 'id' => 'GrossWeightDate', 'class' => 'form-control', 'readonly' => true);
echo form_input($data);
?>
</div>
</div>
<div class="form-group row">
<label for="TareWeight" class="col-md-2 col-form-label">Tare Weight</label>
<div class="col-md-3">
<?php
$data = array('name' => 'TareWeight', 'value' => set_value('TareWeight'), 'id' => 'TareWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'WeightDiffer(this);');
echo form_input($data);
?>
</div>
<div class="col-md-3">
<?php
$data = array('name' => 'TareWeightDate', 'value' => set_value('TareWeightDate'), 'id' => 'TareWeightDate', 'class' => 'form-control', 'readonly' => true);
echo form_input($data);
?>
</div>
</div>
<div class="form-group row">
<label for="NetWeight" class="col-md-2 col-form-label">Net Weight</label>
<div class="col-md-3">
<?php
$data = array('name' => 'NetWeight', 'value' => set_value('NetWeight'), 'id' => 'NetWeight', 'class' => 'form-control', 'maxlength' => '50', 'readonly' => true);
echo form_input($data);
?>
</div>
</div>
</div>
<?php if ($DEPCode == ADMIN) { $class = "col-md-5 col-md-offset-7"; }else{ $class="col-md-4 col-md-offset-8";} ?>
<div class="<?php echo $class; ?>">
<input type="file" name="browseFiles1" id="images1" onchange="Copyfilenames(this.name); "><br> <input type="file" name="browseFiles1" id="images1" onchange="Copyfilenames(this.name); "><br>
<?php if (($DEPCode == SECURITY || $DEPCode == ADMIN)) { ?>
<button class="btn btn-success" id='IGRDraftLink' type="submit" name='IGRDraftLink' onclick="filecheck(0);">Draft IGR</button> <button class="btn btn-success" id='IGRDraftLink' type="submit" name='IGRDraftLink' onclick="filecheck(0);">Draft IGR</button>
<button class="btn btn-success" id='IGRLink' type="submit" name='IGRLink' onclick="filecheck(1);">Generate IGR</button> <?php } if (($DEPCode == SECURITY || $DEPCode == ADMIN && 1)) { ?>
<button class="btn btn-success" id='IGRCreatedLink' type="submit" name='IGRCreatedLink' onclick="filecheck(1);">Generate IGR</button>
<?php } if ($DEPCode == ADMIN) { ?>
<button class="btn btn-success" id='IGRCompleteLink' type="submit" name='IGRCompleteLink' onclick="filecheck(2);">Complete IGR</button>
<?php } if ($DEPCode == ADMIN) { ?>
<button class="btn btn-success" id='IGRCancelLink' type="submit" name='IGRCancelLink' onclick="filecheck(3);">Cancel IGR</button>
<?php } ?>
</div> </div>
</div> </div>
</div> </div>
@ -311,13 +370,13 @@ function validate()
var isExceed = 0; var isExceed = 0;
for(k=1;k<=rowcount ; k++) for(k=1;k<=rowcount ; k++)
{ {
var AdvisedQty = parseFloat( $('#QuantityAsPerInvoice'+k).val() == '' ? '0.00' : $('#QuantityAsPerInvoice'+k).val()); var PendingQty = parseFloat( $('#QuantityAsPerInvoice'+k).val() == '' ? '0.00' : $('#QuantityAsPerInvoice'+k).val());
var RecQty = parseFloat( $('#txtReceivedQuantity'+k).val() == '' ? '0.00' : $('#txtReceivedQuantity'+k).val()); var RecQty = parseFloat( $('#txtReceivedQuantity'+k).val() == '' ? '0.00' : $('#txtReceivedQuantity'+k).val());
var OrderedQty =parseFloat($('#Quantity_1'+k).text()); var OrderedQty =parseFloat($('#Quantity_1'+k).text());
if(AdvisedQty != '0.00') if(PendingQty != '0.00')
{ {
if(OrderedQty < (AdvisedQty+RecQty)) if(OrderedQty < (PendingQty+RecQty))
{ {
isExceed = 1; isExceed = 1;
return false; return false;
@ -355,13 +414,13 @@ function validate()
else if (Noval == 0 ) else if (Noval == 0 )
{ {
alert('Advised Quantity is Empty.Please Enter the value'); alert('Pending Quantity is Empty.Please Enter the value');
return false; return false;
} }
else if(isExceed == 1 ){ else if(isExceed == 1 ){
alert("Advised Quantity is exceeding the Ordered Quantity.Please Contact Purchase Team for further Process ") alert("Pending Quantity is exceeding the Ordered Quantity.Please Contact Purchase Team for further Process ")
return false; return false;
} }
else else
@ -477,8 +536,8 @@ function validate()
'<td name="UOM">' + item.UOM + '</td>' + '<td name="UOM">' + item.UOM + '</td>' +
'<td name="Quantity1'+i+'" id="Quantity_1'+i+'">' + item.Quantity + '</td>' + '<td name="Quantity1'+i+'" id="Quantity_1'+i+'">' + item.Quantity + '</td>' +
'<td name="ReceivedQuantity'+i+'" id="ReceivedQuantity'+i+'">'+ item.ReceivedQuantity +'</td>'+ '<td name="ReceivedQuantity'+i+'" id="ReceivedQuantity'+i+'">'+ item.ReceivedQuantity +'</td>'+
'<td name="PendingQuantity'+i+'" id="PendingQuantity'+i+'">'+ item.PendingQty +'</td>'+
'<td data-name="sel" ><input type="text" onchange="validateReceivedQuantity('+i+')"id="QuantityAsPerInvoice'+ i +'" name="QuantityAsPerInvoice'+ i +'" value="" onkeypress="return isNumberKey(event);"></td>' + '<td data-name="sel" ><input type="text" onchange="validateReceivedQuantity('+i+')"id="QuantityAsPerInvoice'+ i +'" name="QuantityAsPerInvoice'+ i +'" value="" onkeypress="return isNumberKey(event);"></td>' +
'<td name="PendingQuantity'+i+'" id="PendingQuantity'+i+'">'+ item.PendingQty +'</td>'+
'<td><input type="text" id="Remark'+ i +'" name="Remark'+ i +'" class="form" onchange="SetRemarks('+i+')"> </td>' + '<td><input type="text" id="Remark'+ i +'" name="Remark'+ i +'" class="form" onchange="SetRemarks('+i+')"> </td>' +
'</tr>'; '</tr>';
@ -496,12 +555,12 @@ function validate()
$('#QuantityAsPerInvoice'+i).attr('readonly', 'true'); $('#QuantityAsPerInvoice'+i).attr('readonly', 'true');
// $('#txtEditFreight').attr('readonly', 'true'); // $('#txtEditFreight').attr('readonly', 'true');
} }
$("#IGRLink").show(); $("#IGRCreatedLink").show();
}else{ }else{
if(JSON.parse(data).length == 1 && item.PendingQty == 0){ if(JSON.parse(data).length == 1 && item.PendingQty == 0){
$("#IGRLink").hide(); $("#IGRCreatedLink").hide();
//alert('The Order is new completed!!'); //alert('The Order is new completed!!');
} }
@ -526,11 +585,11 @@ function validate()
if((status == '<?php echo IGR_CREATED ?>' || status == '<?php echo MRIR_CREATED ?>' || status == '<?php echo MRIR_APPROVED ?>') && ((hiddenIsOpenOrder === null || hiddenIsOpenOrder === "")) ) if((status == '<?php echo IGR_CREATED ?>' || status == '<?php echo MRIR_CREATED ?>' || status == '<?php echo MRIR_APPROVED ?>') && ((hiddenIsOpenOrder === null || hiddenIsOpenOrder === "")) )
{ {
alert('The Order is completed!!'); alert('The Order is completed!!');
$("#IGRLink").hide(); $("#IGRCreatedLink").hide();
} }
else else
{ {
$("#IGRLink").show(); $("#IGRCreatedLink").show();
} }
} }
@ -563,7 +622,7 @@ function validateReceivedQuantity(Rowid){
if (parseInt(OrderedQty) !== 0) { if (parseInt(OrderedQty) !== 0) {
if((InvoiceQty+RecQty) > OrderedQty){ if((InvoiceQty+RecQty) > OrderedQty){
alert("Advised Quantity is exceeding the Ordered Quantity.Please Contact Purchase Team for further Process ") alert("Pending Quantity is exceeding the Ordered Quantity.Please Contact Purchase Team for further Process ")
$("#QuantityAsPerInvoice"+Rowid).focus(); $("#QuantityAsPerInvoice"+Rowid).focus();
$("#QuantityAsPerInvoice"+Rowid).val(''); $("#QuantityAsPerInvoice"+Rowid).val('');
return false; return false;
@ -606,10 +665,10 @@ function isNumberKey(evt)
function Save(status) function Save(status)
{ {
alert("save function worked "+status); alert("save function worked "+status);
return true; if(status == '3'){
$('#cancelIGR').modal('show');
} }
function S(){
//alert("save function worked "); //alert("save function worked ");
// var file = $('#images'+counterConstants).val() // var file = $('#images'+counterConstants).val()
@ -845,6 +904,21 @@ function Copyfilenames(id)
} }
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());
}
}
@ -876,3 +950,20 @@ function removeRows(inputs) {
} }
} }
</script> </script>
<script>
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
</script>

View File

@ -1,19 +1,23 @@
<style> <style>
.modal .modal {
{
padding-right: 25% ! important; padding-right: 25% ! important;
} }
.num { .num {
text-align: right; text-align: right;
} }
.modal-content
{ .modal-content {
width: 800px ! important; width: 800px ! important;
} }
.modal-footer .btn { .modal-footer .btn {
margin-right: 10px; /* Add some spacing between buttons */ margin-right: 10px;
/* Add some spacing between buttons */
}
.modal-footer {
border-top-color: #fff ! important;
} }
</style> </style>
<div class="content-wrapper"> <div class="content-wrapper">
@ -21,7 +25,9 @@
<section class="content"><br /> <section class="content"><br />
<div class="box"> <div class="box">
<div class="box-header"> <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</h3>
</b></center>
</div> </div>
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
@ -53,20 +59,19 @@
<tbody> <tbody>
<?php <?php
if(!empty($IGR)) if (!empty($IGR)) {
{ $index = 0; $index = 0;
// print_r($IGR); // print_r($IGR);
// die; // die;
foreach($IGR as $record) foreach ($IGR as $record) {
{
$index = $index + 1; $index = $index + 1;
?> ?>
<tr id="<?php echo $index ?>"> <tr id="<?php echo $index ?>">
<!-- <td style="text-align: center;"><?php echo $index ?></td> --> <!-- <td style="text-align: center;"><?php echo $index ?></td> -->
<td><a data-toggle="modal" data-target="#Igrshow" data-id="<%=index%>" data-userid="<?php echo $record->IGRNO ?>" data-igrstatus="<?php echo $record->IGRStatus ?>" > <u><?php echo $record->IGRNO ?></u></a></td> <td><a data-toggle="modal" data-target="#Igrshow" data-id="<%=index%>" data-userid="<?php echo $record->IGRNO ?>" data-igrstatus="<?php echo $record->IGRStatus ?>" title="View Generated IGR details/edit Draft IGR details"> <u><?php echo $record->IGRNO ?></u></a></td>
<td><?php echo $record->PONO ?></a></td> <td><?php echo $record->PONO ?></a></td>
<td><?php echo $record->SupplierName ?></td> <td><?php echo $record->SupplierName ?></td>
@ -79,16 +84,19 @@
<td><?php echo $record->CourierNo ?></td> <td><?php echo $record->CourierNo ?></td>
<td><?php if (!empty($record->FilePath)) { ?> <td><?php if (!empty($record->FilePath)) { ?>
<!-- <a target="_blank" href="<?php echo base_url() . $record->file ?>"><i class="fa fa-download" ></i></a> --> <!-- <a target="_blank" href="<?php echo base_url() . $record->file ?>"><i class="fa fa-download" ></i></a> -->
<a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Attachment Available for Download/View" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>"><button class="btn btn-success btn-sm ">Download</button></a> <a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Attachment Available for Download/View" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>"><button class="btn btn-success btn-sm ">Download <i class="fa fa-download"></i></button></a>
<?php } else if (!empty($record->file)) { ?> <?php } else if (!empty($record->file)) { ?>
<a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Attachment Available for Download/View" data-igrno="<?php echo $record->IGRNO ?>" ><button class="btn btn-success btn-sm ">Download</button></a> <a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Attachment Available for Download/View" data-igrno="<?php echo $record->IGRNO ?>"><button class="btn btn-success btn-sm ">Download <i class="fa fa-download"></i></button></a>
<?php } else { ?> <?php } else { ?>
<!-- echo "NO FILE"; --> <!-- echo "NO FILE"; -->
<a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Attachment Available for Download/View" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>"><button class="btn btn-success btn-sm ">Upload</button></a> <a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Attachment Available for Upload" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>"><button class="btn btn-success btn-sm ">Upload <i class="fa fa-upload"></i></button></a>
<?php } ?> <?php } ?>
<?php if($record->IGRStatus !== "ST074") { ?> <!-- <?php if ($record->IGRStatus !== "ST074") { ?>
<div style="padding-top:10px"> <a href="<?php echo base_url() . 'MRIRcontroller/igrdatavalues?IGRNO=' . $record->IGRNO; ?>"><button style="font-size:12px;" id="generated" name="generated">Generate MRIR <i class="fa fa-file-text"></i></button></div></a> <div style="padding-top:10px"> <a href="<?php echo base_url() . 'MRIRcontroller/igrdatavalues?IGRNO=' . $record->IGRNO; ?>"><button style="font-size:12px;" id="generated" name="generated">Generate MRIR <i class="fa fa-file-text"></i></button></div></a>
<?php } ?> <?php } ?> -->
<!-- <span style="margin: 10px 10px 0 0;"></span> -->
<a target="_blank" data-toggle="modal" data-target="#Historyshow" title="IGR History" data-igrno="<?php echo $record->IGRNO ?>"><button class="btn btn-success btn-sm">History <i class="fa fa-history"></i></button></a>
</td> </td>
<!--<td><?php echo $record->file ?></td>--> <!--<td><?php echo $record->file ?></td>-->
</tr> </tr>
@ -119,7 +127,9 @@
<div class="modal-content" style="width:800px;"> <div class="modal-content" style="width:800px;">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4>Inward Gate File Details <span id="title"></span></h4></center> <!-- IGR number should display here--> <center>
<h4>Inward Gate File Details <span id="title"></span></h4>
</center> <!-- IGR number should display here-->
</div> </div>
<!-- Table to show the line item of po --> <!-- Table to show the line item of po -->
@ -155,6 +165,28 @@
</div> </div>
</div> </div>
<div class="modal fade" id="Historyshow" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content" style="width:800px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center>
<h4>IGR History Details <span id="HisTitle"></span></h4>
</center> <!-- IGR number should display here-->
</div>
<div id="contents"> </div>
<table class="table table-bordered" id="Inwardgateregisterhistory" style="background-color:#fff;font-size:12px;">
<tbody id="tblehistory"></tbody>
</table>
<div style="text-align: right; margin:5px;">
<a class="btn btn-success" data-dismiss="modal" value="Close">Close</a>
</div>
<br />
</div>
</div>
</div>
@ -183,8 +215,7 @@
</div> </div>
</div> </div>
<input type="hidden" name="hideoldfile" id="hideoldfile" class="form-control" readonly> <input type="hidden" name="hideoldfile" id="hideoldfile" class="form-control" readonly>
<input type="hidden" name="hidebillno" id="hidebillno" class="form-control" <input type="hidden" name="hidebillno" id="hidebillno" class="form-control" readonly>
readonly>
</div><!-- /.modal body --> </div><!-- /.modal body -->
@ -210,7 +241,14 @@
<div class="modal-content" style="width:800px;"> <div class="modal-content" style="width:800px;">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4>Inward Gate Register Details</h4></center> <!-- IGR number should display here--> <center>
<h4>Inward Gate Register Details.</h4>
</center> <!-- IGR number should display here-->
<div class="pull-right hidden-xs">
<b>
<div id="clock"></div>
</b>
</div>
</div> </div>
<input type="hidden" id="counts"> <input type="hidden" id="counts">
<!--<div class="col-md-12"> <!--<div class="col-md-12">
@ -311,23 +349,21 @@
<div class="col-md-4"> <div class="col-md-4">
<label>Vehicle Number</label> <label>Vehicle Number</label>
<?php <?php
$data = array('name' => 'VehicleNo','value' => set_value('VehicleNo'),'id'=>'Vehicle_No', 'class' => 'form-control', 'required=>"true"' , 'readonly'=>'true' ); $data = array('name' => 'VehicleNo', 'value' => set_value('VehicleNo'), 'id' => 'Vehicle_No', 'class' => 'form-control');
echo form_input($data); echo form_input($data);
?> ?>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<label>Driver Name </label> <label>Driver Name </label>
<?php <?php
$data = array('name' => 'DriverName','value' => set_value('DriverName'),'id'=>'Driver_Name', 'class' => 'form-control', 'required=>"true"' , 'readonly'=>'true' ); $data = array('name' => 'DriverName', 'value' => set_value('DriverName'), 'id' => 'Driver_Name', 'class' => 'form-control');
echo form_input($data); echo form_input($data);
?> ?>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<label>Driver Mobile Number </label> <label>Driver Mobile Number </label>
<?php <?php
$data = array('name' => 'DriverMobileNumber','value' => set_value('DriverMobileNumber'),'id'=>'DriverMobileNumber', 'class' => 'form-control' , 'readonly'=>'true' ); $data = array('name' => 'DriverMobileNumber', 'value' => set_value('DriverMobileNumber'), 'id' => 'DriverMobileNumber', 'class' => 'form-control');
echo form_input($data); echo form_input($data);
?> ?>
</div> </div>
@ -357,14 +393,55 @@
</tbody> </tbody>
</table> </table>
<div class="container">
<div class="form-group row">
<label for="GrossWeight" class="col-md-2 col-form-label">Gross Weight</label>
<div class="col-md-3">
<?php
$data = array('name' => 'GrossWeight', 'value' => set_value('GrossWeight'), 'id' => 'GrossWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'WeightDiffer(this);');
echo form_input($data);
?>
</div>
<div class="col-md-3">
<?php
$data = array('name' => 'GrossWeightDate', 'value' => set_value('GrossWeightDate'), 'id' => 'GrossWeightDate', 'class' => 'form-control', 'readonly' => true);
echo form_input($data);
?>
</div>
</div>
<div class="form-group row">
<label for="TareWeight" class="col-md-2 col-form-label">Tare Weight</label>
<div class="col-md-3">
<?php
$data = array('name' => 'TareWeight', 'value' => set_value('TareWeight'), 'id' => 'TareWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'WeightDiffer(this);');
echo form_input($data);
?>
</div>
<div class="col-md-3">
<?php
$data = array('name' => 'TareWeightDate', 'value' => set_value('TareWeightDate'), 'id' => 'TareWeightDate', 'class' => 'form-control', 'readonly' => true);
echo form_input($data);
?>
</div>
</div>
<div class="form-group row">
<label for="NetWeight" class="col-md-2 col-form-label">Net Weight</label>
<div class="col-md-3">
<?php
$data = array('name' => 'NetWeight', 'value' => set_value('NetWeight'), 'id' => 'NetWeight', 'class' => 'form-control', 'maxlength' => '50', 'readonly' => true);
echo form_input($data);
?>
</div>
</div>
</div>
<div class="modal-footer" id="buttonContainer"> <div class="modal-footer" id="buttonContainer">
<!-- <a class="btn btn-success" data-dismiss="modal" value="Cancel">Cancel</a> --> <!-- <a class="btn btn-success" data-dismiss="modal" value="Cancel">Cancel</a> -->
<!-- <a class="btn btn-success" id="update" value="Update">Update IGR</a> --> <!-- <a class="btn btn-success" id="update" value="Update">Update IGR</a> -->
<a class="btn btn-success" id="draftIGR" onclick="setStatusAndSubmit('draft')">Draft IGR</a> <a class="btn btn-success" id="draftIGR" onclick="setStatusAndSubmit('draft')">Draft IGR</a>
<a class="btn btn-success" id="generateIGR" onclick="setStatusAndSubmit('generate')">Generate IGR</a> <a class="btn btn-success" id="generateIGR" onclick="setStatusAndSubmit('generate')">Generate IGR</a>
<a class="btn btn-success" data-dismiss="modal" value="Close">Close IGR</a>
<a class="btn btn-success" data-dismiss="modal" value="Cancel">Cancel IGR</a>
</div> </div>
</div><!-- .modal-content --> </div><!-- .modal-content -->
</form> </form>
@ -380,35 +457,25 @@
</div><!-- .content-wrapper --> </div><!-- .content-wrapper -->
<script> <script>
function filecheck() {
function filecheck()
{
var sizef = document.getElementById('billimag').files[0].size; var sizef = document.getElementById('billimag').files[0].size;
var file = $('#billimag').val(); var file = $('#billimag').val();
if(file!='' && sizef < 2100000) if (file != '' && sizef < 2100000) { // alert('Your file added successfully');
{ // alert('Your file added successfully'); } else {
}
else
{
alert('Sorry Your File is Large To 2MB'); alert('Sorry Your File is Large To 2MB');
$('#billimag').val(''); $('#billimag').val('');
} }
} }
function fileupdate() { function fileupdate() {
var formData = new FormData(); var formData = new FormData();
//var file = document.getElementById('billimag').files[0]; //var file = document.getElementById('billimag').files[0];
var file = $("#billimag").prop('files')[0]; var file = $("#billimag").prop('files')[0];
var param1 = $('#hidebillno').val(); var param1 = $('#hidebillno').val();
// alert(param1); // alert(param1);
var param2 = $('#hideoldfile').val(); var param2 = $('#hideoldfile').val();
// alert(param2); // alert(param2);
@ -435,21 +502,14 @@
// $('#spl').find('td').eq(5).text(filename[2]); // $('#spl').find('td').eq(5).text(filename[2]);
$('#billModel').modal('hide'); $('#billModel').modal('hide');
} }
} }
}); });
} }
//$(function () {
$(document).ready(function() { $(document).ready(function() {
$("#Fileshow").on("shown.bs.modal", function(e) { $("#Fileshow").on("shown.bs.modal", function(e) {
var id = $(this).attr('id'); var id = $(this).attr('id');
var igr = $(e.relatedTarget).data('igrno'); var igr = $(e.relatedTarget).data('igrno');
var po = $(e.relatedTarget).data('pono'); var po = $(e.relatedTarget).data('pono');
$('#igrfileform')[0].reset(); $('#igrfileform')[0].reset();
@ -457,31 +517,27 @@ $('#title').text(" ("+igr+") ");
$("#hiddenIGRNO").val(igr); $("#hiddenIGRNO").val(igr);
$("#hiddenPONO").val(po); $("#hiddenPONO").val(po);
if (igr != "" && po != "") { if (igr != "" && po != "") {
$.ajax({ $.ajax({
data:{id:igr,id1:po}, data: {
id: igr,
id1: po
},
type: "POST", type: "POST",
//dataType: 'json', //dataType: 'json',
url: "<?php echo base_url() ?>inwardgateregister/ViewIGRfile", url: "<?php echo base_url() ?>inwardgateregister/ViewIGRfile",
success: function(file) success: function(file) {
{
$("#counts").val(JSON.parse(file).length); $("#counts").val(JSON.parse(file).length);
var trHTML = ''; var trHTML = '';
var FilePath = ''; var FilePath = '';
var Filename = ''; var Filename = '';
var PONO = ''; var PONO = '';
var BillNO = ''; var BillNO = '';
$.each(JSON.parse(file), function (i, item) $.each(JSON.parse(file), function(i, item) {
{ if (item.file == null) {
if(item.file == null) if (item.Remarks == null) {
{ if(item.Remarks ==null)
{
console.log("<?php echo base_url() ?>public/uploads/Igrfiles/" + item.FilePath); console.log("<?php echo base_url() ?>public/uploads/Igrfiles/" + item.FilePath);
//alert() //alert()
PONO = item.PONO; PONO = item.PONO;
@ -500,8 +556,7 @@ $("#hiddenPONO").val(po);
BillNO = '-'; BillNO = '-';
FilePath = item.file; FilePath = item.file;
} }
if(Filename != null) if (Filename != null) {
{
i = i + 1; i = i + 1;
trHTML += '<tr id=' + i + '>' + trHTML += '<tr id=' + i + '>' +
'<td align="right">' + i + '</td>' + '<td align="right">' + i + '</td>' +
@ -512,33 +567,66 @@ $("#hiddenPONO").val(po);
'</tr>'; '</tr>';
} }
}); }); // foreach
$("#tblefile").empty(); $("#tblefile").empty();
if (trHTML == '') { if (trHTML == '') {
trHTML = '<tr><td colspan="5" style="text-align: center;">NO FILE</td></tr>'; trHTML = '<tr><td colspan="5" style="text-align: center;">NO FILE</td></tr>';
} }
$("#tblefile").append(trHTML); $("#tblefile").append(trHTML);
} } // success
}); });
} }
}); });
$("#Historyshow").on("shown.bs.modal", function(e) {
// alert("Historyshow");
var igr = $(e.relatedTarget).data('igrno');
$('#HisTitle').text(" (" + igr + ") ");
$("#tblehistory").empty();
if (igr != "") {
$.ajax({
data: {
igr: igr
},
type: "POST",
//dataType: 'json',
url: "<?php echo base_url() ?>inwardgateregister/ViewIGRHistory",
success: function(data) {
if (!empty(data)) {
var output = '';
data.forEach(function(record) {
var sentence = constructSentence(record);
output += '<p>' + sentence + '</p>';
}); });
trHTML = '<tr><td style="text-align: center;">' + output + '</td></tr>';
$("#tblehistory").append(trHTML);
} else {
trHTML = '<tr><td style="text-align: center;">No History Data Available</td></tr>';
$("#tblehistory").append(trHTML);
}
},
error: function(xhr, status, error) {
trHTML = '<tr><td style="text-align: center;">No History Data Available</td></tr>';
$("#tblehistory").append(trHTML);
console.error('AJAX Error: ' + status + error);
}
});
} else {
trHTML = '<tr><td style="text-align: center;">No History Data Available.</td></tr>';
$("#tblehistory").append(trHTML);
}
});
});
function openbillmodel(i) { function openbillmodel(i) {
// alert(i); // alert(i);
// return false; // return false;
var igr = $("#tblefile").find('tr').find('td').eq(2).text(); var igr = $("#tblefile").find('tr').find('td').eq(2).text();
// alert(igr); // alert(igr);
var Billno = $("#billno" + i).text(); var Billno = $("#billno" + i).text();
// alert(Billno); // alert(Billno);
@ -551,14 +639,27 @@ $("#hiddenPONO").val(po);
$("#hideoldfile").val(file); $("#hideoldfile").val(file);
$("#hidebillno").val(Billno); $("#hidebillno").val(Billno);
} }
function constructSentence(record) {
// var sentence = "Record ID " + record.id + ": Field '" + record.field + "' ";
var sentence = "Field '" + record.field + "' ";
sentence += (parseInt(record.is_add) == 1) ? "was added, " : "";
sentence += (parseInt(record.is_edit) == 1) ? "was edited, " : "";
sentence += (parseInt(record.is_delete) == 1) ? "was deleted, " : "";
sentence += "<br> new data: '" + record.new_data + "', ";
sentence += (record.old_data) ? "old data: '" + record.old_data + "', " : "old data: ' - ', ";
sentence += "<br> recorded on " + formatDateTime(record.history_dated) + " ";
sentence += "by " + record.FullName + ", ";
sentence += "<br> IGR No: " + record.IGR_No;
sentence += (record.IGRItem_No) ? ", IGR Item No: " + record.IGRItem_No + "." : ".";
return sentence;
}
</script> </script>
<script src="https://cdn.datatables.net/plug-ins/1.10.16/sorting/datetime-moment.js"></script> <script src="https://cdn.datatables.net/plug-ins/1.10.16/sorting/datetime-moment.js"></script>
<script> <script>
<!-- script for table , It works under the datatable plugin--> //<!-- script for table , It works under the datatable plugin-->
$(function() { $(function() {
$.fn.dataTable.moment('DD-MM-YYYY'); $.fn.dataTable.moment('DD-MM-YYYY');
$('#Inwardgateregistertable').DataTable({ $('#Inwardgateregistertable').DataTable({
@ -566,46 +667,71 @@ $("#hiddenPONO").val(po);
"lengthChange": true, "lengthChange": true,
"searching": true, "searching": true,
"ordering": true, "ordering": true,
"aaSorting": [[ 6, "desc" ]], "aaSorting": [
[6, "desc"]
],
"info": true, "info": true,
"autoWidth": true "autoWidth": true
}); });
}); });
</script> </script>
<script> <script>
$("#Igrshow").on("shown.bs.modal", function(e) { $("#Igrshow").on("shown.bs.modal", function(e) {
var igr = $(e.relatedTarget).data('userid'); var igr = $(e.relatedTarget).data('userid');
var igrstatus = $(e.relatedTarget).data('igrstatus'); var igrstatus = $(e.relatedTarget).data('igrstatus');
// alert(igrstatus);
var buttonContainer = $("#buttonContainer"); var buttonContainer = $("#buttonContainer");
var modal = $(this); // Reference to the modal itself
// var invoiceDateInput = modal.find('#Invoice_Date');
// var MaterialRcvdDateInput = modal.find('#MaterialRcvdDate');
var VehicleNoInput = modal.find('#Vehicle_No');
var DriverInput = modal.find('#Driver_Name');
var DriverMobileNumberInput = modal.find('#DriverMobileNumber');
var GrossWeightInput = modal.find('#GrossWeight');
var TareWeightInput = modal.find('#TareWeight');
if (igrstatus == "ST074") { if (igrstatus == "ST074") {
// Show buttons in the container // Show buttons in the container
buttonContainer.find("#draftIGR, #generateIGR").css("display", "inline-block"); buttonContainer.find("#draftIGR, #generateIGR").css("display", "inline-block");
// Changed into Readonly = false
// invoiceDateInput.prop('readonly', false);
// MaterialRcvdDateInput.prop('readonly', false);
VehicleNoInput.prop('readonly', false);
DriverInput.prop('readonly', false);
DriverMobileNumberInput.prop('readonly', false);
GrossWeightInput.prop('readonly', false);
TareWeightInput.prop('readonly', false);
} else { } else {
// Hide buttons in the container // Hide buttons in the container
buttonContainer.find("#draftIGR, #generateIGR").css("display", "none"); buttonContainer.find("#draftIGR, #generateIGR").css("display", "none");
// Changed into Readonly = true
// invoiceDateInput.prop('readonly', true);
// MaterialRcvdDateInput.prop('readonly', true);
VehicleNoInput.prop('readonly', true);
DriverInput.prop('readonly', true);
DriverMobileNumberInput.prop('readonly', true);
GrossWeightInput.prop('readonly', true);
TareWeightInput.prop('readonly', true);
} }
$("#tbleAppend1").empty(); $("#tbleAppend1").empty();
$('#content').loader('show'); $('#content').loader('show');
$.ajax({ $.ajax({
data:{id:igr}, data: {
id: igr
},
type: "POST", type: "POST",
//dataType: 'json', //dataType: 'json',
url: "<?php echo base_url() ?>inwardgateregister/ViewIGR", url: "<?php echo base_url() ?>inwardgateregister/ViewIGR",
success: function(data) { success: function(data) {
console.log(data); console.log(data);
console.log('d'); console.log('d');
// success:function(data) {
$('#content').loader('hide'); $('#content').loader('hide');
var trHTML = ''; var trHTML = '';
$.each(JSON.parse(data), function(i, item) { $.each(JSON.parse(data), function(i, item) {
if(igr == item.IGRNO) if (igr == item.IGRNO) {
{
$("#IGRNO1").val(item.IGRNO); $("#IGRNO1").val(item.IGRNO);
$("#IGRItemNo").val(item.IGRItemNo); $("#IGRItemNo").val(item.IGRItemNo);
@ -626,20 +752,35 @@ if (igrstatus == "ST074") {
var dcd2 = (dcd.getDate() + '/' + (dcd.getMonth() + 1) + '/' + dcd.getFullYear()); var dcd2 = (dcd.getDate() + '/' + (dcd.getMonth() + 1) + '/' + dcd.getFullYear());
$("#Invoice_Date").val(dcd2); $("#Invoice_Date").val(dcd2);
if (item.MaterialRcvdDate === null) { if (item.MaterialRcvdDate === null) {
var Mat_rcv_date = ' '; } var Mat_rcv_date = ' ';
else { } else {
var MR_dt = new Date(item.MaterialRcvdDate); 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 = (MR_dt.getDate() + '/' + (MR_dt.getMonth() + 1) + '/' + MR_dt.getFullYear());
} }
$("#MaterialRcvdDate").val(Mat_rcv_date); $("#MaterialRcvdDate").val(Mat_rcv_date);
if (item.GrossWeightDate === null) {
var gross_rcv_date = ' ';
} else {
var G_dt = new Date(item.GrossWeightDate);
var gross_rcv_date = formatDateTime(G_dt);
}
$("#GrossWeight").val(parseFloat(item.GrossWeight));
$("#GrossWeightDate").val(gross_rcv_date);
if (item.TareWeightDate === null) {
var tare_rcv_date = ' ';
} else {
var T_dt = new Date(item.TareWeightDate);
var tare_rcv_date = formatDateTime(T_dt);
}
$("#TareWeight").val(parseFloat(item.TareWeight));
$("#TareWeightDate").val(tare_rcv_date);
$("#NetWeight").val(parseFloat(item.NetWeight));
$("#ser").val(item.ServiceDescription); $("#ser").val(item.ServiceDescription);
i = i + 1; i = i + 1;
if (igrstatus == "ST074") { if (igrstatus == "ST074") {
// document.getElementById('pendingQuantityHeader').style.display = 'table-cell'; // document.getElementById('pendingQuantityHeader').style.display = 'table-cell';
$("#pendingQuantityHeader").css("display", "table-cell"); $("#pendingQuantityHeader").css("display", "table-cell");
trHTML += '<tr>' + trHTML += '<tr>' +
'<td align="right">' + i + '</td>' + '<td align="right">' + i + '</td>' +
'<td name="MaterialName" onchange="test(' + i + ')">' + item.MaterialCode + '</td>' + '<td name="MaterialName" onchange="test(' + i + ')">' + item.MaterialCode + '</td>' +
@ -659,8 +800,7 @@ if (igrstatus == "ST074") {
'</tr>'; '</tr>';
//alert(item.PendingQty); //alert(item.PendingQty);
if((item.Quantity-item.QuantityAsPerInvoice) == 0.00) if ((item.Quantity - item.QuantityAsPerInvoice) == 0.00) {
{
$('#QuantityAsPerInvoice' + i).attr('readonly', 'true'); $('#QuantityAsPerInvoice' + i).attr('readonly', 'true');
} }
} else { } else {
@ -680,48 +820,44 @@ if (igrstatus == "ST074") {
//alert(item.QuantityAsPerInvoice); //alert(item.QuantityAsPerInvoice);
} }
}); });
$("#tbleAppend1").empty(); $("#tbleAppend1").empty();
$('#Inwardgateregistertable1 > tbody').append(trHTML); $('#Inwardgateregistertable1 > tbody').append(trHTML);
} }
}); });
}); });
</script> </script>
<script> <script>
var counter = 0;
var counter = 0;
var counter = 0; var counter = 0;
//var counterConstant = 0; //var counterConstant = 0;
$("#addmorebutton").click(function() { $("#addmorebutton").click(function() {
var file_count = $("#counts").val(); var file_count = $("#counts").val();
counter++;
counter++;
counter++; counter++;
var bil_count = +counter + +file_count;
var bil_count = +counter + +file_count;
var bil_count = +counter + +file_count; var bil_count = +counter + +file_count;
// alert(bil_count); // alert(bil_count);
// alert(file_count); // alert(file_count);
if (bil_count >= 6) { if (bil_count >= 6) {
alert("You have to upload five files only"); //this allows only 5 files; alert("You have to upload five files only"); //this allows only 5 files;
$('#addmorebutton').hide(); $('#addmorebutton').hide();
return false; return false;
} }
var div = document.createElement('div'); var div = document.createElement('div');
div.id = "divid"; div.id = "divid";
div.className = "row"; div.className = "row";
@ -742,7 +878,6 @@ counter++;
'<label><br><br></label>' + '<label><br><br></label>' +
'<button class="btn btn-success" type ="button" id="addbtn" onclick="addRow()">ADD</button></div>' + '<button class="btn btn-success" type ="button" id="addbtn" onclick="addRow()">ADD</button></div>' +
'</div>' + '</div>' +
'</div>'; '</div>';
$('#newdiv').append(div); $('#newdiv').append(div);
@ -751,35 +886,32 @@ counter++;
if (counter > 1) { if (counter > 1) {
alert("Add button click here"); //this allows only 5 files; alert("Add button click here"); //this allows only 5 files;
return false; return false;
} } else {
else{
$('#addmorebutton').hide(); $('#addmorebutton').hide();
} }
//} //}
}); });
function addRow() function addRow() {
{ //var file = $('#imag').val();
//var file = $('#imag').val();
//var file = $('#imag').val(); //var file = $('#imag').val();
var file = $('#images' + counter).val(); var file = $('#images' + counter).val();
if (file == '') {
if (file == '')
{
alert('File not found'); alert('File not found');
} else {
}
else {
fileupload(counter); fileupload(counter);
} }
} }
// function Copyfilename(id) // function Copyfilename(id)
// { // {
// var size = $('input[name='+id+']')[0].files[0].size;
// var size = $('input[name='+id+']')[0].files[0].size;
// var size = $('input[name='+id+']')[0].files[0].size; // var size = $('input[name='+id+']')[0].files[0].size;
// var number = id.replace(/[^0-9]+/ig,""); // var number = id.replace(/[^0-9]+/ig,"");
@ -795,26 +927,21 @@ counter++;
// } // }
// } // }
function fileupload(counter) {
function fileupload(counter)
{
//alert(counter); //alert(counter);
var formData = new FormData(); var formData = new FormData();
// var file = $("#images"+counter).prop('file')[0]; // var file = $("#images"+counter).prop('file')[0];
var file = document.getElementById('images' + counter).files[0]; var file = document.getElementById('images' + counter).files[0];
// alert(file);
// alert(file);
// alert(file); // alert(file);
var PONO = $('#hiddenPONO').val(); var PONO = $('#hiddenPONO').val();
// alert(PONO); // alert(PONO);
var igr = $('#hiddenIGRNO').val(); var igr = $('#hiddenIGRNO').val();
// alert(igr); // alert(igr);
formData.append('file', file); formData.append('file', file);
formData.append('PONO', PONO); formData.append('PONO', PONO);
formData.append('count', counter); formData.append('count', counter);
@ -836,28 +963,26 @@ counter++;
// $('#spl').find('td').eq(5).text(filename[2]); // $('#spl').find('td').eq(5).text(filename[2]);
$('#billModel').modal('hide'); $('#billModel').modal('hide');
} }
} }
}); });
} }
</script> </script>
<script> <script>
function SetRemarks(RowId) function SetRemarks(RowId) {
{
var remks = $("#Remark" + RowId).val(); var remks = $("#Remark" + RowId).val();
if( remks != '') if (remks != '') {
{
$("#txtRemarks" + RowId).val(remks); $("#txtRemarks" + RowId).val(remks);
} }
} }
function validateReceivedQuantity(Rowid) { function validateReceivedQuantity(Rowid) {
var InvoiceQty = parseFloat($('#QuantityAsPerInvoice' + Rowid).val() || '0.00'); // working fine var InvoiceQty = parseFloat($('#QuantityAsPerInvoice' + Rowid).val() || '0.00'); // working fine
var OrderedQty = parseFloat($("#Quantity" + Rowid).text()); var OrderedQty = parseFloat($("#Quantity" + Rowid).text());
if (parseInt(OrderedQty) !== 0) { if (parseInt(OrderedQty) !== 0) {
if ((InvoiceQty) > OrderedQty) { if ((InvoiceQty) > OrderedQty) {
alert("Advised Quantity is exceeding the Ordered Quantity. Please contact the Purchase Team for further process."); alert("Pending Quantity is exceeding the Ordered Quantity. Please contact the Purchase Team for further process.");
$("#QuantityAsPerInvoice" + Rowid).focus().val(''); $("#QuantityAsPerInvoice" + Rowid).focus().val('');
return false; return false;
} else if ((InvoiceQty) - OrderedQty > 0.00) { } else if ((InvoiceQty) - OrderedQty > 0.00) {
@ -882,24 +1007,29 @@ function SetRemarks(RowId)
</script> </script>
<script> <script>
function isNumberKey(evt) {
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode; var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31 if (charCode != 46 && charCode > 31 &&
&& (charCode < 48 || charCode > 57)) (charCode < 48 || charCode > 57))
return false; return false;
return true; return true;
} }
</script> </script>
<script> <script>
function setStatusAndSubmit(status) { function setStatusAndSubmit(status) {
var statuscode = (status == "draft") ? 'ST074' : 'ST027'; var statuscode = (status == "draft") ? 'ST074' : 'ST027';
// alert('updated function entered'); alert('updated function entered');
$('#content').loader('show'); $('#content').loader('show');
var igrno = $("#IGRNO1").val(); var igrno = $("#IGRNO1").val();
var VehicleNo = $("#Vehicle_No").val();
var DriverName = $("#Driver_Name").val();
var DriverMobileNumber = $("#DriverMobileNumber").val();
var GrossWeight = $("#GrossWeight").val()
var TareWeight = $("#TareWeight").val()
var NetWeight = $("#NetWeight").val()
var GrossWeightDate = $("#GrossWeightDate").val()
var TareWeightDate = $("#TareWeightDate").val()
var dataToSend = []; var dataToSend = [];
@ -914,14 +1044,22 @@ function setStatusAndSubmit(status) {
dataToSend.push(rowData); dataToSend.push(rowData);
}); });
console.log(dataToSend);
$.ajax({ $.ajax({
url: "<?php echo base_url() ?>inwardgateregister/updateIGRLineItem", url: "<?php echo base_url() ?>inwardgateregister/updateIGRLineItem",
type: "POST", type: "POST",
dataType: 'json', dataType: 'json',
data: { data: {
igr: igrno, IGRNO: igrno,
status: statuscode, IGRStatus: statuscode,
VehicleNo: VehicleNo,
DriverName: DriverName,
DriverMobileNumber: DriverMobileNumber,
GrossWeight: GrossWeight,
TareWeight: TareWeight,
NetWeight: NetWeight,
GrossWeightDate: GrossWeightDate,
TareWeightDate: TareWeightDate,
data: JSON.stringify(dataToSend) data: JSON.stringify(dataToSend)
}, },
success: function(response) { success: function(response) {
@ -943,5 +1081,63 @@ function setStatusAndSubmit(status) {
} }
}); });
} }
</script>
<script>
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());
}
}
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
</script>
<script>
function formatDateTime(dateString) {
// Check if the date string is null
if (dateString === null) {
return ' ';
} else {
// Create a new Date object from the date string
var date = new Date(dateString);
// Extract date components
var day = date.getDate().toString().padStart(2, '0');
var month = (date.getMonth() + 1).toString().padStart(2, '0'); // Months are zero-based
var year = date.getFullYear();
// Extract time components
var hours = date.getHours().toString().padStart(2, '0');
var minutes = date.getMinutes().toString().padStart(2, '0');
var seconds = date.getSeconds().toString().padStart(2, '0');
// Format the date and time in DD-MM-YYYY HH:MM:SS format
var formattedDate = `${day}-${month}-${year} ${hours}:${minutes}:${seconds}`;
return formattedDate;
}
}
</script> </script>

View File

@ -1,15 +1,19 @@
<style> <style>
.modal .modal {
{
padding-right: 25% ! important; padding-right: 25% ! important;
} }
.num { .num {
text-align: right; text-align: right;
} }
.modal-content
{ .modal-content {
width: 800px ! important; width: 800px ! important;
} }
.modal-footer {
border-top-color: #fff ! important;
}
</style> </style>
<script> <script>
$(function() { $(function() {
@ -25,7 +29,9 @@
$("#Invoice_Date , #MaterialRcvdDate ").datepicker({ $("#Invoice_Date , #MaterialRcvdDate ").datepicker({
minDate: new Date(year - SIAStartYear, 1, 1), minDate: new Date(year - SIAStartYear, 1, 1),
maxDate: 'now', maxDate: 'now',
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true, dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
}); });
}); });
</script> </script>
@ -35,7 +41,9 @@
<div class="box"> <div class="box">
<div class=" container-fluid"> <div class=" container-fluid">
<div class="box-header"> <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</h3>
</b></center>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@ -58,16 +66,15 @@
<tbody> <tbody>
<?php <?php
if(!empty($IGR)) if (!empty($IGR)) {
{ $index = 0; $index = 0;
foreach($IGR as $record) foreach ($IGR as $record) {
{
$index = $index + 1; $index = $index + 1;
?> ?>
<tr id="<?php echo $index ?>"> <tr id="<?php echo $index ?>">
<!-- <td style="text-align: center;"><?php echo $index ?></td> --> <!-- <td style="text-align: center;"><?php echo $index ?></td> -->
<td><a data-toggle="modal" data-target="#Igrshow" data-id="<%=index%>" data-userid="<?php echo $record->IGRNO ?>" > <u><?php echo $record->IGRNO ?></u></a></td> <td><a data-toggle="modal" data-target="#Igrshow" data-id="<%=index%>" data-userid="<?php echo $record->IGRNO ?>" data-igrstatus="<?php echo $record->IGRStatus ?>" title="View Generated IGR details/edit Draft IGR details"> <u><?php echo $record->IGRNO ?></u></a></td>
<td><?php echo $record->PONO ?></a></td> <td><?php echo $record->PONO ?></a></td>
<td><?php echo $record->SupplierName ?></td> <td><?php echo $record->SupplierName ?></td>
<td><?php echo $record->DeliveryChellanOrInvoiceNo ?></td> <td><?php echo $record->DeliveryChellanOrInvoiceNo ?></td>
@ -77,6 +84,7 @@
<td><?php echo $record->VehicleNo ?></td> <td><?php echo $record->VehicleNo ?></td>
<td><?php echo $record->CreatedDate ?></td> <td><?php echo $record->CreatedDate ?></td>
<td> <td>
<a target="_blank" data-toggle="modal" data-target="#Historyshow" title="IGR History" data-igrno="<?php echo $record->IGRNO ?>"><button class="btn btn-success btn-sm">History <i class="fa fa-history"></i></button></a>
<a href="<?php echo base_url() . 'MRIRcontroller/igrdatavalues?IGRNO=' . $record->IGRNO; ?>"><button style="font-size:12px" id="generated" name="generated">Generate MRIR <i class="fa fa-file-text"></i></button></a> <a href="<?php echo base_url() . 'MRIRcontroller/igrdatavalues?IGRNO=' . $record->IGRNO; ?>"><button style="font-size:12px" id="generated" name="generated">Generate MRIR <i class="fa fa-file-text"></i></button></a>
</td> </td>
</tr> </tr>
@ -103,8 +111,16 @@
<div class="modal-content" style="width:800px;"> <div class="modal-content" style="width:800px;">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4>Inward Gate Register Details</h4></center> <!-- IGR number should display here--> <center>
<h4>Inward Gate Register Details</h4>
</center> <!-- IGR number should display here-->
<div class="pull-right hidden-xs">
<b>
<div id="clock"></div>
</b>
</div> </div>
</div>
<!--<div class="col-md-12"> <!--<div class="col-md-12">
<div class="col-md-3"> <div class="col-md-3">
<label>IGR Number :</label> <label>IGR Number :</label>
@ -238,16 +254,62 @@
<th>UOM</th> <th>UOM</th>
<th>Ordred Quantity</th> <th>Ordred Quantity</th>
<th>Received Quantity</th> <th>Received Quantity</th>
<th>Balance Quantity</th> <th id="pendingQuantityHeader" style="display:none;">Balance Quantity</th>
<th>Remarks</th> <th>Remarks</th>
</tr> </tr>
</thead> </thead>
<tbody id="tbleAppend1"></tbody> <tbody id="tbleAppend1"></tbody>
</table> </table>
<div class="container">
<div class="form-group row">
<label for="GrossWeight" class="col-md-2 col-form-label">Gross Weight</label>
<div class="col-md-3">
<?php
$data = array('name' => 'GrossWeight', 'value' => set_value('GrossWeight'), 'id' => 'GrossWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'WeightDiffer(this);');
echo form_input($data);
?>
</div>
<div class="col-md-3">
<?php
$data = array('name' => 'GrossWeightDate', 'value' => set_value('GrossWeightDate'), 'id' => 'GrossWeightDate', 'class' => 'form-control', 'readonly' => true);
echo form_input($data);
?>
</div>
</div>
<div class="form-group row">
<label for="TareWeight" class="col-md-2 col-form-label">Tare Weight</label>
<div class="col-md-3">
<?php
$data = array('name' => 'TareWeight', 'value' => set_value('TareWeight'), 'id' => 'TareWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'WeightDiffer(this);');
echo form_input($data);
?>
</div>
<div class="col-md-3">
<?php
$data = array('name' => 'TareWeightDate', 'value' => set_value('TareWeightDate'), 'id' => 'TareWeightDate', 'class' => 'form-control', 'readonly' => true);
echo form_input($data);
?>
</div>
</div>
<div class="form-group row">
<label for="NetWeight" class="col-md-2 col-form-label">Net Weight</label>
<div class="col-md-3">
<?php
$data = array('name' => 'NetWeight', 'value' => set_value('NetWeight'), 'id' => 'NetWeight', 'class' => 'form-control', 'maxlength' => '50', 'readonly' => true);
echo form_input($data);
?>
</div>
</div>
</div>
<div class="modal-footer"> <div class="modal-footer">
<a class="btn btn-success" id="update" value="Update">Update</a> <!-- <a class="btn btn-success" id="update" value="Update">Update</a>
<a class="btn btn-success" data-dismiss="modal" value="Cancel">Cancel</a> <a class="btn btn-success" data-dismiss="modal" value="Cancel">Cancel</a> -->
<a class="btn btn-success" id="draftIGR" onclick="setStatusAndSubmit('draft')">Draft IGR</a>
<a class="btn btn-success" id="generateIGR" onclick="setStatusAndSubmit('generate')">Generate IGR</a>
<a class="btn btn-success" data-dismiss="modal" value="Close">Close IGR</a>
</div> </div>
</div> </div>
</form> </form>
@ -257,7 +319,6 @@
</div><!-- content-wrapper --> </div><!-- content-wrapper -->
<script> <script>
<!-- script for table , It works under the datatable plugin-->
$(function(){ $(function(){
$.fn.dataTable.moment('DD-MM-YYYY'); $.fn.dataTable.moment('DD-MM-YYYY');
@ -267,42 +328,75 @@
"searching":true, "searching":true,
"ordering":true, "ordering":true,
//"columnDefs":[{ "targets": 5,"type": "date-eu"}], //"columnDefs":[{ "targets": 5,"type": "date-eu"}],
// "aaSorting": [[ 4, "desc" ]], "aaSorting":[[4,"desc"]],
"info":true, "info":true,
"autoWidth":true "autoWidth":true
}); });
}); });
</script><!-- </script><!-- <script src="https://cdn.datatables.net/plug-ins/1.10.11/sorting/date-eu.js"></script> -->
<script src="https://cdn.datatables.net/plug-ins/1.10.11/sorting/date-eu.js"></script> -->
<script src="https://cdn.datatables.net/plug-ins/1.10.16/sorting/datetime-moment.js"></script> <script src="https://cdn.datatables.net/plug-ins/1.10.16/sorting/datetime-moment.js"></script>
<script> <script>
$("#Igrshow").on("shown.bs.modal", function(e) { $("#Igrshow").on("shown.bs.modal", function(e) {
var igr = $(e.relatedTarget).data('userid'); var igr = $(e.relatedTarget).data('userid');
var igrstatus = $(e.relatedTarget).data('igrstatus');
// alert(igrstatus);
var buttonContainer = $("#buttonContainer");
var modal = $(this); // Reference to the modal itself
var invoiceDateInput = modal.find('#Invoice_Date');
var MaterialRcvdDateInput = modal.find('#MaterialRcvdDate');
var VehicleNoInput = modal.find('#Vehicle_No');
var DriverInput = modal.find('#Driver_Name');
var DriverMobileNumberInput = modal.find('#DriverMobileNumber');
var GrossWeightInput = modal.find('#GrossWeight');
var TareWeightInput = modal.find('#TareWeight');
if (igrstatus == "ST074") {
// Show buttons in the container
buttonContainer.find("#draftIGR, #generateIGR").css("display", "inline-block");
// Changed into Readonly = false
invoiceDateInput.prop('readonly', false);
MaterialRcvdDateInput.prop('readonly', false);
VehicleNoInput.prop('readonly', false);
DriverInput.prop('readonly', false);
DriverMobileNumberInput.prop('readonly', false);
GrossWeightInput.prop('readonly', false);
TareWeightInput.prop('readonly', false);
} else {
// Hide buttons in the container
buttonContainer.find("#draftIGR, #generateIGR").css("display", "none");
// Changed into Readonly = true
invoiceDateInput.prop('readonly', true);
MaterialRcvdDateInput.prop('readonly', true);
VehicleNoInput.prop('readonly', true);
DriverInput.prop('readonly', true);
DriverMobileNumberInput.prop('readonly', true);
GrossWeightInput.prop('readonly', true);
TareWeightInput.prop('readonly', true);
}
$("#tbleAppend1").empty();
$('#content').loader('show'); $('#content').loader('show');
$.ajax({ $.ajax({
data:{id:igr}, data: {
id: igr
},
type: "POST", type: "POST",
//dataType: 'json', //dataType: 'json',
url: "<?php echo base_url() ?>inwardgateregister/ViewIGR", url: "<?php echo base_url() ?>inwardgateregister/ViewIGR",
success: function(data) { success: function(data) {
// success:function(data) { console.log(data);
console.log('d');
$('#content').loader('hide'); $('#content').loader('hide');
var trHTML = ''; var trHTML = '';
$.each(JSON.parse(data), function(i, item) { $.each(JSON.parse(data), function(i, item) {
if(igr == item.IGRNO) if (igr == item.IGRNO) {
{
$("#IGRNO1").val(item.IGRNO); $("#IGRNO1").val(item.IGRNO);
$("#IGRItemNo").val(item.IGRItemNo);
var baseUrl = '<?php echo base_url(); ?>purchaseorder/CreatePOPrint'; var baseUrl = '<?php echo base_url(); ?>purchaseorder/CreatePOPrint';
var newUrl = baseUrl + '?PONO=' + item.PONO + '&ReqType=' + item.POType; var newUrl = baseUrl + '?PONO=' + item.PONO + '&ReqType=' + item.POType;
$('#printLink').attr('href', newUrl); $('#printLink').attr('href', newUrl);
//alert(item.IGRNO);
$("#Vehicle_No").val(item.VehicleNo); $("#Vehicle_No").val(item.VehicleNo);
$("#Driver_Name").val(item.DriverName); $("#Driver_Name").val(item.DriverName);
$("#DriverMobileNumber").val(item.DriverMobileNumber); $("#DriverMobileNumber").val(item.DriverMobileNumber);
@ -313,25 +407,64 @@ $("#Igrshow").on("shown.bs.modal", function(e) {
$("#Invoice_No").val(item.DeliveryChellanOrInvoiceNo); $("#Invoice_No").val(item.DeliveryChellanOrInvoiceNo);
//alert(item.DeliveryChellanDate); //alert(item.DeliveryChellanDate);
var dcd = new Date(item.DeliveryChellanDate); var dcd = new Date(item.DeliveryChellanDate);
console.log(item.MaterialRcvdDate) ;
//alert(item.MaterialRcvdDate);
//alert(dcd.getDate()+ '.' + (dcd.getMonth() + 1)+ '.' + dcd.getFullYear()); //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()); $("#Invoice_Date").val(dcd2);
//var MR_dt = item.MaterialRcvdDate === null ? ' - ' : new Date(item.MaterialRcvdDate).toDateString("d-m-Y");
if (item.MaterialRcvdDate === null) { if (item.MaterialRcvdDate === null) {
var Mat_rcv_date = ' '; } var Mat_rcv_date = ' ';
else { } else {
var MR_dt = new Date(item.MaterialRcvdDate); 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 = (MR_dt.getDate() + '/' + (MR_dt.getMonth() + 1) + '/' + MR_dt.getFullYear());
} }
$("#MaterialRcvdDate").val(Mat_rcv_date); $("#MaterialRcvdDate").val(Mat_rcv_date);
$("#Invoice_Date").val(dcd2); if (item.GrossWeightDate === null) {
var gross_rcv_date = ' ';
} else {
var G_dt = new Date(item.GrossWeightDate);
var gross_rcv_date = formatDateTime(G_dt);
}
$("#GrossWeight").val(parseFloat(item.GrossWeight));
$("#GrossWeightDate").val(gross_rcv_date);
if (item.TareWeightDate === null) {
var tare_rcv_date = ' ';
} else {
var T_dt = new Date(item.TareWeightDate);
var tare_rcv_date = formatDateTime(T_dt);
}
$("#TareWeight").val(parseFloat(item.TareWeight));
$("#TareWeightDate").val(tare_rcv_date);
$("#NetWeight").val(parseFloat(item.NetWeight));
$("#ser").val(item.ServiceDescription); $("#ser").val(item.ServiceDescription);
i = i + 1; i = i + 1;
if (igrstatus == "ST074") {
// document.getElementById('pendingQuantityHeader').style.display = 'table-cell';
$("#pendingQuantityHeader").css("display", "table-cell");
trHTML += '<tr>' +
'<td align="right">' + i + '</td>' +
'<td name="MaterialName" onchange="test(' + i + ')">' + item.MaterialCode + '</td>' +
'<td>' + item.MaterialName + '</td>' +
'<td name="UOM">' + item.UOM + '</td>' +
'<td align="right" id="Quantity' + i + '" name="Quantity">' + parseInt(item.Quantity) + '</td>' +
'<td align="right" data-name="sel" ><input type="text" onchange="validateReceivedQuantity(' + i + ')"id="QuantityAsPerInvoice' + i + '" name="QuantityAsPerInvoice' + i + '" value="' + parseInt(item.QuantityAsPerInvoice) + '" onkeypress="return isNumberKey(event);"></td>' +
'<td name="PendingQuantity' + i + '" id="PendingQuantity' + i + '">' + parseInt(item.Quantity - item.QuantityAsPerInvoice) + '</td>' +
'<td><input type="text" id="Remark' + i + '" name="Remark' + i + '" class="form" onchange="SetRemarks(' + i + ')"> </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="txtRemarks' + i + '" name="txtRemarks' + i + '">'; // Example with no initial value
'</tr>';
//alert(item.PendingQty);
if ((item.Quantity - item.QuantityAsPerInvoice) == 0.00) {
$('#QuantityAsPerInvoice' + i).attr('readonly', 'true');
}
} else {
$("#pendingQuantityHeader").css("display", "none");
trHTML += '<tr>' + trHTML += '<tr>' +
'<td align="right">' + i + '</td>' + '<td align="right">' + i + '</td>' +
'<td name="MaterialName" id="MaterialCode" onchange="test(' + i + ')">' + item.MaterialCode + '</td>' + '<td name="MaterialName" id="MaterialCode" onchange="test(' + i + ')">' + item.MaterialCode + '</td>' +
@ -341,17 +474,23 @@ $("#Igrshow").on("shown.bs.modal", function(e) {
'<td align="right" data-name="sel" >' + item.QuantityAsPerInvoice + '</td>' + '<td align="right" data-name="sel" >' + item.QuantityAsPerInvoice + '</td>' +
'<td>' + item.Remarks + '</td>' + '<td>' + item.Remarks + '</td>' +
'</tr>'; '</tr>';
}
//alert(item.QuantityAsPerInvoice); //alert(item.QuantityAsPerInvoice);
} }
}); });
$("#tbleAppend1").empty(); $("#tbleAppend1").empty();
$('#Inwardgateregistertable1 > tbody').append(trHTML); $('#Inwardgateregistertable1 > tbody').append(trHTML);
} }
}); });
}); });
</script>
<script>
$('#update').click(function() { $('#update').click(function() {
//alert('updated function entered'); alert('updated function entered');
$('#content').loader('show'); $('#content').loader('show');
var igrno = $("#IGRNO1").val(); var igrno = $("#IGRNO1").val();
var materialrcv_date = $("#MaterialRcvdDate").val(); var materialrcv_date = $("#MaterialRcvdDate").val();
@ -368,3 +507,128 @@ $('#update').click(function(){
}); });
}); });
</script> </script>
<script>
function setStatusAndSubmit(status) {
var statuscode = (status == "draft") ? 'ST074' : 'ST027';
alert('updated function entered');
$('#content').loader('show');
var igrno = $("#IGRNO1").val();
var VehicleNo = $("#Vehicle_No").val();
var DriverName = $("#Driver_Name").val();
var DriverMobileNumber = $("#DriverMobileNumber").val();
var GrossWeight = $("#GrossWeight").val()
var TareWeight = $("#TareWeight").val()
var NetWeight = $("#NetWeight").val()
var GrossWeightDate = $("#GrossWeightDate").val()
var TareWeightDate = $("#TareWeightDate").val()
var dataToSend = [];
$('#tbleAppend1 tr').each(function(index, row) {
var rowData = {};
$(row).find('input[type="hidden"]').each(function() {
var fieldName = $(this).attr('name');
var fieldValue = $(this).val();
rowData[fieldName] = fieldValue;
});
dataToSend.push(rowData);
});
console.log(dataToSend);
$.ajax({
url: "<?php echo base_url() ?>inwardgateregister/updateIGRLineItem",
type: "POST",
dataType: 'json',
data: {
IGRNO: igrno,
IGRStatus: statuscode,
VehicleNo: VehicleNo,
DriverName: DriverName,
DriverMobileNumber: DriverMobileNumber,
GrossWeight: GrossWeight,
TareWeight: TareWeight,
NetWeight: NetWeight,
GrossWeightDate: GrossWeightDate,
TareWeightDate: TareWeightDate,
data: JSON.stringify(dataToSend)
},
success: function(response) {
$('#content').loader('hide');
console.log('Data saved successfully:', response);
alert(response.message);
// Close the modal
$('#Igrshow').modal('hide');
// location.reload();
setTimeout(function() {
location.reload();
}, 500);
},
error: function(jqXHR, textStatus, errorThrown) {
$('#content').loader('hide');
console.error('Error saving data:', textStatus, errorThrown);
alert(response.message);
$('#Igrshow').modal('hide');
}
});
}
</script>
<script>
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());
}
}
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
</script>
<script>
function formatDateTime(dateString) {
// Check if the date string is null
if (dateString === null) {
return ' ';
} else {
// Create a new Date object from the date string
var date = new Date(dateString);
// Extract date components
var day = date.getDate().toString().padStart(2, '0');
var month = (date.getMonth() + 1).toString().padStart(2, '0'); // Months are zero-based
var year = date.getFullYear();
// Extract time components
var hours = date.getHours().toString().padStart(2, '0');
var minutes = date.getMinutes().toString().padStart(2, '0');
var seconds = date.getSeconds().toString().padStart(2, '0');
// Format the date and time in DD-MM-YYYY HH:MM:SS format
var formattedDate = `${day}-${month}-${year} ${hours}:${minutes}:${seconds}`;
return formattedDate;
}
}
</script>