FIX_IGR file Uploads
This commit is contained in:
parent
2e5af50997
commit
85a32a3879
@ -322,22 +322,47 @@ class Inwardgateregister extends BaseController
|
|||||||
$createddt = get_current_date_time();
|
$createddt = get_current_date_time();
|
||||||
//$IGRStatus = IGR_CREATED;//old
|
//$IGRStatus = IGR_CREATED;//old
|
||||||
$IGRStatus = (int)$this->request->getPost('hideIGRStatus') == 1 ? IGR_CREATED : IGR_DRAFT;
|
$IGRStatus = (int)$this->request->getPost('hideIGRStatus') == 1 ? IGR_CREATED : IGR_DRAFT;
|
||||||
$document = null;
|
|
||||||
$igr = array(); // For IGR Master
|
$igr = array(); // For IGR Master
|
||||||
$paymentstatus = NO_PAIDIGR;
|
$paymentstatus = NO_PAIDIGR;
|
||||||
$constant = $this->request->getPost('hideconstants');
|
|
||||||
$arr = []; // For File to Save
|
|
||||||
$prefile = array();
|
|
||||||
$fileupdated_count = 0;
|
$fileupdated_count = 0;
|
||||||
$fileupdated_name = [];
|
$fileupdated_name = [];
|
||||||
|
|
||||||
|
#Step 1 File Path Creation
|
||||||
|
$path = ROOTPATH.'public/uploads/Igrfiles/';
|
||||||
|
if(!is_dir($path)) { mkdir($path, 0777, true); }
|
||||||
|
|
||||||
|
#Step 2 Master File and Its Details Gathering
|
||||||
|
$MasterFile = $this->request->getFile('MasterFile');
|
||||||
|
$requestMasterFileName = $MasterFile->getName();
|
||||||
|
|
||||||
|
if (!empty($requestMasterFileName)) {
|
||||||
|
if ($MasterFile && $MasterFile->isValid() && !$MasterFile->hasMoved()) {
|
||||||
|
if (!empty($this->inwardgateregister_model->isFileExistsInIGRmaster($requestMasterFileName))) {
|
||||||
|
log_message('error', 'File already exists in the database'.$requestMasterFileName);
|
||||||
|
$requestMasterFileName = NULL;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$MasterFile->move($path, $requestMasterFileName);
|
||||||
|
$fileupdated_count++;
|
||||||
|
$fileupdated_name[] = $requestMasterFileName;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$requestMasterFileName = NULL;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$requestMasterFileName = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#Step 3 Master Details Gathering to Save In DB
|
||||||
$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);
|
||||||
|
$igr['MasterFile'] = $requestMasterFileName;
|
||||||
//Saving IGR details Here
|
#Step 4 Calling DB to Save IGR Master
|
||||||
$IGRNO = $this->inwardgateregister_model->addigrM($igr);
|
$IGRNO = $this->inwardgateregister_model->addigrM($igr);
|
||||||
|
// $IGRNO = "IGRNO02734";
|
||||||
if($IGRNO){
|
if($IGRNO){
|
||||||
#Step 1.1 Fetch On History
|
#Step 5 Save Master Detail On History Table
|
||||||
if($VehicleNo){
|
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);
|
$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);
|
$history_id = $this->inwardgateregister_model->igr_history($igr_history);
|
||||||
@ -353,73 +378,15 @@ class Inwardgateregister extends BaseController
|
|||||||
$history_id = $this->inwardgateregister_model->igr_history($igr_history);
|
$history_id = $this->inwardgateregister_model->igr_history($igr_history);
|
||||||
log_message('error', "History updated successfully. History id: " . $history_id);
|
log_message('error', "History updated successfully. History id: " . $history_id);
|
||||||
}
|
}
|
||||||
#Step 2 File Details Gathering
|
|
||||||
if($constant){
|
|
||||||
for ($i = 1; $i <= $constant; $i++) {
|
|
||||||
$pathname = 'browseFiles' . $i;
|
|
||||||
$file = $this->request->getFile($pathname);
|
|
||||||
if ($file && $file->isValid()) {
|
|
||||||
$requestfilename = $file->getName();
|
|
||||||
if (!empty($requestfilename)) {
|
|
||||||
|
|
||||||
$files = str_replace(" ", "", $_FILES[$pathname]['name']);
|
#Step 6 Updating OGR Details
|
||||||
$fcount = 0;
|
|
||||||
|
|
||||||
foreach ($prefile as $value) {
|
|
||||||
if ($value == $files) { $fcount++; }
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($fcount == 0) {
|
|
||||||
if ($file->isValid() && !$file->hasMoved()) {
|
|
||||||
$path = ROOTPATH.'public/uploads/Igrfiles/';
|
|
||||||
if(!is_dir($path)) { mkdir($path, 0777, true); }
|
|
||||||
$Picture = $file->getName();
|
|
||||||
$file->move($path,$Picture);
|
|
||||||
log_message('error', "File new" . $i . " uploaded successfully. File name: " . $requestfilename);
|
|
||||||
}
|
|
||||||
$arr[] = array($Picture);
|
|
||||||
}
|
|
||||||
|
|
||||||
$prefile[] = $files;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
log_message('error', "No file uploaded for new" . $i . " or there was an error uploading the file.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#Step 2.1 Saving File Details
|
|
||||||
if (!empty($arr)) {
|
|
||||||
foreach ($arr as $ma) {
|
|
||||||
$index = 0;
|
|
||||||
foreach ($ma as $key => $value) {
|
|
||||||
$index++;
|
|
||||||
if ($index == 1) {
|
|
||||||
$filename = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!empty($filename)) {
|
|
||||||
|
|
||||||
$myfile = array('FilePath' => $filename, 'PONO' => $PONO, 'IGRNO' => $IGRNO);
|
|
||||||
$fileupdated = $this->inwardgateregister_model->fileupload($myfile);
|
|
||||||
if ($fileupdated) {
|
|
||||||
$fileupdated_count++;
|
|
||||||
$fileupdated_name[] = $filename;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#Step 3 Updating OGR Details
|
|
||||||
$OGRStatus = $IGRStatus;
|
$OGRStatus = $IGRStatus;
|
||||||
$check_OGRPO = $this->inwardgateregister_model->update_OGR($PONO, $OGRStatus);
|
$check_OGRPO = $this->inwardgateregister_model->update_OGR($PONO, $OGRStatus);
|
||||||
// echo "step3";
|
|
||||||
// echo "uuu".(int)$check_OGRPO;
|
// echo "uuu".(int)$check_OGRPO;
|
||||||
$IGRItemStatus = REQITEM_NEW;
|
$IGRItemStatus = REQITEM_NEW;
|
||||||
$TotalPendingQty = '';
|
$TotalPendingQty = '';
|
||||||
$TotalPendingQty = (int)$TotalPendingQty;
|
$TotalPendingQty = (int)$TotalPendingQty;
|
||||||
// echo "step4";
|
#Step 7 To Update the Date PO MASTER , Material Master , Historydetails and IGR line Item Details Updating OGR Details
|
||||||
#Step 4 To Update the Date PO MASTER , Material Master , Historydetails and IGR line Item Details Updating OGR Details
|
|
||||||
for ($i = 1; $i <= (int)$RowCount; $i++) {
|
for ($i = 1; $i <= (int)$RowCount; $i++) {
|
||||||
$MaterialCode = $this->request->getPost('MaterialCode' . $i);
|
$MaterialCode = $this->request->getPost('MaterialCode' . $i);
|
||||||
$MaterialCode = $MaterialCode !== null && is_string($MaterialCode) ? trim($MaterialCode) : null;
|
$MaterialCode = $MaterialCode !== null && is_string($MaterialCode) ? trim($MaterialCode) : null;
|
||||||
@ -438,6 +405,29 @@ class Inwardgateregister extends BaseController
|
|||||||
$NetWeight= $this->request->getPost('txtNetWeight' . $i);
|
$NetWeight= $this->request->getPost('txtNetWeight' . $i);
|
||||||
// var_dump($grossWeightDate);
|
// var_dump($grossWeightDate);
|
||||||
// var_dump($tareWeightDate);
|
// var_dump($tareWeightDate);
|
||||||
|
#Step 8 Saving Weight File and Its Details Gathering
|
||||||
|
$WeightFile = $this->request->getFile('txtWeightFile' . $i);
|
||||||
|
$requestWeightFileName = $WeightFile->getName();
|
||||||
|
// echo $i.$requestWeightFileName;die;
|
||||||
|
|
||||||
|
if (!empty($requestWeightFileName)) {
|
||||||
|
if ($WeightFile && $WeightFile->isValid() && !$WeightFile->hasMoved()) {
|
||||||
|
// $WeightFile->move($path, $requestWeightFileName);
|
||||||
|
if (!empty($this->inwardgateregister_model->isFileExistsInIGRdetails($requestWeightFileName))) {
|
||||||
|
log_message('error', 'File already exists in the database'.$requestWeightFileName);
|
||||||
|
$requestWeightFileName = NULL;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$WeightFile->move($path, $requestWeightFileName);
|
||||||
|
$fileupdated_count++;
|
||||||
|
$fileupdated_name[] = $requestWeightFileName;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$requestWeightFileName = NULL;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$requestWeightFileName = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
$GrossWeightDate = !empty($grossWeightDate) && is_string($grossWeightDate) ? date('Y-m-d H:i:s', strtotime($grossWeightDate)) : null;
|
$GrossWeightDate = !empty($grossWeightDate) && is_string($grossWeightDate) ? date('Y-m-d H:i:s', strtotime($grossWeightDate)) : null;
|
||||||
$TareWeightDate = !empty($tareWeightDate) && is_string($tareWeightDate) ? date('Y-m-d H:i:s', strtotime($tareWeightDate)) : null;
|
$TareWeightDate = !empty($tareWeightDate) && is_string($tareWeightDate) ? date('Y-m-d H:i:s', strtotime($tareWeightDate)) : null;
|
||||||
@ -454,6 +444,7 @@ class Inwardgateregister extends BaseController
|
|||||||
|
|
||||||
$CreatedBy = $this->session->get('userId');
|
$CreatedBy = $this->session->get('userId');
|
||||||
$igrDetails = array('IGRNO' => $IGRNO, 'MaterialCode' => $MaterialCode, 'QuantityAsPerInvoice' => $QuantityAsPerInvoice, 'Remarks' => $Remarks, 'IGRItemStatus' => $IGRItemStatus,'GrossWeight' => (float)$GrossWeight ,'GrossWeightDate'=> $GrossWeightDate,'TareWeight' => (float)$TareWeight ,'TareWeightDate' => $TareWeightDate ,'NetWeight' => (float)$NetWeight, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt);
|
$igrDetails = array('IGRNO' => $IGRNO, 'MaterialCode' => $MaterialCode, 'QuantityAsPerInvoice' => $QuantityAsPerInvoice, 'Remarks' => $Remarks, 'IGRItemStatus' => $IGRItemStatus,'GrossWeight' => (float)$GrossWeight ,'GrossWeightDate'=> $GrossWeightDate,'TareWeight' => (float)$TareWeight ,'TareWeightDate' => $TareWeightDate ,'NetWeight' => (float)$NetWeight, 'CreatedBy' => $CreatedBy, 'CreatedDate' => $createddt);
|
||||||
|
$igrDetails['WeightFile'] = $requestWeightFileName;
|
||||||
log_message('error', 'SaveIGR igrDetails result : ' . json_encode($igrDetails));
|
log_message('error', 'SaveIGR igrDetails result : ' . json_encode($igrDetails));
|
||||||
|
|
||||||
$igrD = $this->inwardgateregister_model->addigrD($igrDetails);
|
$igrD = $this->inwardgateregister_model->addigrD($igrDetails);
|
||||||
@ -532,7 +523,7 @@ class Inwardgateregister extends BaseController
|
|||||||
|
|
||||||
$this->inwardgateregister_model->UpdatePOMaster($PONO, $CreatedBy);
|
$this->inwardgateregister_model->UpdatePOMaster($PONO, $CreatedBy);
|
||||||
|
|
||||||
#Step 6 Updating Pending Quantity IN PO Master amd Line Item Details.
|
#Step 9 Updating Pending Quantity IN PO Master amd Line Item Details.
|
||||||
if ($TotalPendingQty == 0.00) {
|
if ($TotalPendingQty == 0.00) {
|
||||||
$Newstatus = array('Status' => $IGRStatus);
|
$Newstatus = array('Status' => $IGRStatus);
|
||||||
$this->inwardgateregister_model->POLineItemsupdatestatus($PONO, $Newstatus);
|
$this->inwardgateregister_model->POLineItemsupdatestatus($PONO, $Newstatus);
|
||||||
@ -544,7 +535,7 @@ class Inwardgateregister extends BaseController
|
|||||||
$finalstatement = "Successfully Created IGR Number: $IGRNO \n";
|
$finalstatement = "Successfully Created IGR Number: $IGRNO \n";
|
||||||
if ($fileupdated_count > 0) {
|
if ($fileupdated_count > 0) {
|
||||||
$finalstatement .= "Number of files updated: $fileupdated_count \n";
|
$finalstatement .= "Number of files updated: $fileupdated_count \n";
|
||||||
$finalstatement .= "Files: \n " . implode('\n ', $fileupdated_name);
|
$finalstatement .= "Files: \n" . implode(PHP_EOL, $fileupdated_name);
|
||||||
} else {
|
} else {
|
||||||
$finalstatement .= "No files to update";
|
$finalstatement .= "No files to update";
|
||||||
}
|
}
|
||||||
@ -559,7 +550,7 @@ class Inwardgateregister extends BaseController
|
|||||||
echo "<script>
|
echo "<script>
|
||||||
alert('$finalstatement');
|
alert('$finalstatement');
|
||||||
window.location.href = 'ViewIGR';
|
window.location.href = 'ViewIGR';
|
||||||
</script>";
|
</script>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,7 +570,7 @@ function viewIGRDetails()
|
|||||||
{
|
{
|
||||||
$IGRNO = $this->request->getPost('id');
|
$IGRNO = $this->request->getPost('id');
|
||||||
$igrfile = $this->inwardgateregister_model->viewIGRFile($IGRNO);
|
$igrfile = $this->inwardgateregister_model->viewIGRFile($IGRNO);
|
||||||
$billfile = $this->inwardgateregister_model->ViewIGRfile1($IGRNO);
|
$billfile = []; // $this->inwardgateregister_model->ViewIGRfile1($IGRNO);
|
||||||
$data = array_merge($igrfile, $billfile);
|
$data = array_merge($igrfile, $billfile);
|
||||||
echo json_encode($data);
|
echo json_encode($data);
|
||||||
}
|
}
|
||||||
@ -609,9 +600,31 @@ function viewIGRDetails()
|
|||||||
$IGRStatus = (int)$this->request->getPost('status') == 1 ? IGR_CREATED : IGR_DRAFT;
|
$IGRStatus = (int)$this->request->getPost('status') == 1 ? IGR_CREATED : IGR_DRAFT;
|
||||||
|
|
||||||
$tableData = $this->request->getPost('tableData');
|
$tableData = $this->request->getPost('tableData');
|
||||||
|
if (is_string($tableData)) {
|
||||||
|
$tableData = json_decode($tableData, true);
|
||||||
|
}
|
||||||
$updateby = $this->session->get('userId');
|
$updateby = $this->session->get('userId');
|
||||||
|
|
||||||
|
$path = ROOTPATH.'public/uploads/Igrfiles/';
|
||||||
|
if(!is_dir($path)) { mkdir($path, 0777, true); }
|
||||||
|
|
||||||
$igrarr = array('DeliveryChellanDate' => $DeliveryChellanDate, 'MaterialRcvdDate' => $MaterialRcvdDt,'VehicleNo'=>$VehicleNo,'DriverMobileNumber'=>$DriverMobileNumber,'DriverName'=>$DriverName, 'IGRStatus' => $IGRStatus,'UpdateBY' => $updateby);
|
$igrarr = array('DeliveryChellanDate' => $DeliveryChellanDate, 'MaterialRcvdDate' => $MaterialRcvdDt,'VehicleNo'=>$VehicleNo,'DriverMobileNumber'=>$DriverMobileNumber,'DriverName'=>$DriverName, 'IGRStatus' => $IGRStatus,'UpdateBY' => $updateby);
|
||||||
|
|
||||||
|
$MasterFile = $this->request->getfile('MasterFile');
|
||||||
|
$requestMasterFileName = $MasterFile->getName();
|
||||||
|
|
||||||
|
if (!empty($requestMasterFileName)) {
|
||||||
|
if ($MasterFile && $MasterFile->isValid() && !$MasterFile->hasMoved()) {
|
||||||
|
if (!empty($this->inwardgateregister_model->isFileExistsInIGRmaster($requestMasterFileName))) {
|
||||||
|
log_message('error', 'File already exists in the database'.$requestMasterFileName);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$MasterFile->move($path, $requestMasterFileName);
|
||||||
|
$igrarr['MasterFile'] = $requestMasterFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log_message('error', 'UpdateIGR igrarr: ' . json_encode($igrarr));
|
log_message('error', 'UpdateIGR igrarr: ' . json_encode($igrarr));
|
||||||
$updateigrmaster = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo);
|
$updateigrmaster = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo);
|
||||||
if(!empty($tableData )){
|
if(!empty($tableData )){
|
||||||
@ -694,6 +707,21 @@ function viewIGRDetails()
|
|||||||
'IGRItemNo' => $igrItemNo,
|
'IGRItemNo' => $igrItemNo,
|
||||||
'UpdateBY' => $updateby
|
'UpdateBY' => $updateby
|
||||||
);
|
);
|
||||||
|
// $WeightFile = $this->request->getfile('WeightFile');
|
||||||
|
// $requestWeightFileName = $WeightFile->getName();
|
||||||
|
|
||||||
|
// if (!empty($requestWeightFileName)) {
|
||||||
|
// if ($WeightFile && $WeightFile->isValid() && !$WeightFile->hasMoved()) {
|
||||||
|
// if (!empty($this->inwardgateregister_model->isFileExistsInIGRdetails($requestWeightFileName))) {
|
||||||
|
// log_message('error', 'File already exists in the database'.$requestWeightFileName);
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// $WeightFile->move($path, $requestWeightFileName);
|
||||||
|
// $igrline['WeightFile'] = $requestWeightFileName;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
$updateigrlineitem = $this->inwardgateregister_model->updateIGRLineItem($igrline, $igrItemNo);
|
$updateigrlineitem = $this->inwardgateregister_model->updateIGRLineItem($igrline, $igrItemNo);
|
||||||
log_message('error', "lineitem updated successfully: " . $updateigrlineitem);
|
log_message('error', "lineitem updated successfully: " . $updateigrlineitem);
|
||||||
log_message('error', 'UpdateIGR updateigrlineitem: ' . json_encode($igrline));
|
log_message('error', 'UpdateIGR updateigrlineitem: ' . json_encode($igrline));
|
||||||
@ -1132,6 +1160,11 @@ function updateIGRWeight(){
|
|||||||
$IGRNO = $this->request->getPost('IGR');
|
$IGRNO = $this->request->getPost('IGR');
|
||||||
$IGRItemNo = $this->request->getPost('IGRlineitem');
|
$IGRItemNo = $this->request->getPost('IGRlineitem');
|
||||||
$updateby = $this->session->get('userId');
|
$updateby = $this->session->get('userId');
|
||||||
|
$WeightFile = $this->request->getfile('WeightFile');
|
||||||
|
$requestWeightFileName = $WeightFile->getName();
|
||||||
|
$path = ROOTPATH.'public/uploads/Igrfiles/';
|
||||||
|
if(!is_dir($path)) { mkdir($path, 0777, true); }
|
||||||
|
|
||||||
if($GrossWeight){
|
if($GrossWeight){
|
||||||
$gross = $this->inwardgateregister_model->get_igr_history('GrossWeight',$IGRNO, $IGRItemNo);
|
$gross = $this->inwardgateregister_model->get_igr_history('GrossWeight',$IGRNO, $IGRItemNo);
|
||||||
if(!empty($gross)){
|
if(!empty($gross)){
|
||||||
@ -1234,6 +1267,17 @@ function updateIGRWeight(){
|
|||||||
$IGRItemNo = $this->request->getPost('IGRlineitem');
|
$IGRItemNo = $this->request->getPost('IGRlineitem');
|
||||||
$igr_lineitem = array('GrossWeight' => $GrossWeight,'GrossWeightDate' => $GrossWeightDate,'TareWeightDate' => $TareWeightDate,'TareWeight' => $TareWeight,'NetWeight' => $NetWeight,'UpdateBY' => $updateby);
|
$igr_lineitem = array('GrossWeight' => $GrossWeight,'GrossWeightDate' => $GrossWeightDate,'TareWeightDate' => $TareWeightDate,'TareWeight' => $TareWeight,'NetWeight' => $NetWeight,'UpdateBY' => $updateby);
|
||||||
|
|
||||||
|
if (!empty($requestWeightFileName)) {
|
||||||
|
if ($WeightFile && $WeightFile->isValid() && !$WeightFile->hasMoved()) {
|
||||||
|
if (!empty($this->inwardgateregister_model->isFileExistsInIGRdetails($requestWeightFileName))) {
|
||||||
|
log_message('error', 'File already exists in the database'.$requestWeightFileName);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$WeightFile->move($path, $requestWeightFileName);
|
||||||
|
$igr_lineitem['WeightFile'] = $requestWeightFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$update = $this->inwardgateregister_model->updateIGRLineItem($igr_lineitem, $IGRItemNo);
|
$update = $this->inwardgateregister_model->updateIGRLineItem($igr_lineitem, $IGRItemNo);
|
||||||
|
|
||||||
if ($update) {
|
if ($update) {
|
||||||
|
|||||||
@ -904,4 +904,16 @@ class Inwardgateregister_model extends Model
|
|||||||
// Pass the result to the view or return it as JSON
|
// Pass the result to the view or return it as JSON
|
||||||
// return $this->response->setJSON($result);
|
// return $this->response->setJSON($result);
|
||||||
}
|
}
|
||||||
|
public function isFileExistsInIGRmaster($filename)
|
||||||
|
{
|
||||||
|
$result = $this->db->table('t_igr_master')->where('MasterFile', $filename);
|
||||||
|
$query = $result->get();
|
||||||
|
return $query->getResult();
|
||||||
|
}
|
||||||
|
public function isFileExistsInIGRdetails($filename)
|
||||||
|
{
|
||||||
|
$result = $this->db->table('t_igr_details')->where('WeightFile', $filename);
|
||||||
|
$query = $result->get();
|
||||||
|
return $query->getResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -248,6 +248,12 @@
|
|||||||
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<!-- <a class="btn btn-primary" id="update" value="Update">Update</a> -->
|
<!-- <a class="btn btn-primary" id="update" value="Update">Update</a> -->
|
||||||
|
<div class="col-md-4 col-md-offset-8">
|
||||||
|
<input type="file" name="MasterFile" id="MasterFile" onchange="Copyfilenames(this.name); ">
|
||||||
|
<label id="MasterFileLabel" style="display:none;">
|
||||||
|
<a><span></span><small></small></a>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="buttonContainer">
|
<div class="buttonContainer">
|
||||||
<a class="btn btn-primary" id="draftIGR" value="draftIGR">Draft IGR</a>
|
<a class="btn btn-primary" id="draftIGR" value="draftIGR">Draft IGR</a>
|
||||||
@ -322,6 +328,13 @@
|
|||||||
echo form_input($data);
|
echo form_input($data);
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-5">
|
||||||
|
<input type="file" name="WeightFile" id="WeightFile" onchange="Copyfilenames(this.name); ">
|
||||||
|
|
||||||
|
<label id="WeightFileLabel" style="display:none;">
|
||||||
|
<a><span></span><small></small></a>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
@ -459,6 +472,9 @@
|
|||||||
var VehicleNoInput = modal.find('#Vehicle_No');
|
var VehicleNoInput = modal.find('#Vehicle_No');
|
||||||
var DriverInput = modal.find('#Driver_Name');
|
var DriverInput = modal.find('#Driver_Name');
|
||||||
var DriverMobileNumberInput = modal.find('#DriverMobileNumber');
|
var DriverMobileNumberInput = modal.find('#DriverMobileNumber');
|
||||||
|
var MasterFileInput = modal.find('#MasterFile');
|
||||||
|
modal.find('#MasterFileLabel').hide();
|
||||||
|
|
||||||
var depCode = "<?php echo $DEPCode; ?>";
|
var depCode = "<?php echo $DEPCode; ?>";
|
||||||
|
|
||||||
// depCode != "DEP27"
|
// depCode != "DEP27"
|
||||||
@ -491,6 +507,7 @@
|
|||||||
|
|
||||||
$("#tbleIGRAppend").empty();
|
$("#tbleIGRAppend").empty();
|
||||||
$('#content').loader('show');
|
$('#content').loader('show');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data: { id: igr },
|
data: { id: igr },
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@ -498,18 +515,45 @@
|
|||||||
success: function(data) {
|
success: function(data) {
|
||||||
// success:function(data) {
|
// success:function(data) {
|
||||||
$('#content').loader('hide');
|
$('#content').loader('hide');
|
||||||
|
var parsedData = JSON.parse(data);
|
||||||
|
if (parsedData.length === 0) {
|
||||||
|
console.log("No data available");
|
||||||
|
// Reset all relevant fields and table
|
||||||
|
$('#IgrshowTitle').text('');
|
||||||
|
$("#IGRNO1").val('');
|
||||||
|
$("#txtIGRLineItem").val('');
|
||||||
|
$('#printLink').attr('href', '#');
|
||||||
|
$('.help-block').text('');
|
||||||
|
$("#Vehicle_No").val('');
|
||||||
|
$("#Driver_Name").val('');
|
||||||
|
$("#DriverMobileNumber").val('');
|
||||||
|
$("#IGRStatus").val('');
|
||||||
|
$("#PONo").val('');
|
||||||
|
$("#Supplier").val('');
|
||||||
|
$("#Add1").val('');
|
||||||
|
$("#Invoice_No").val('');
|
||||||
|
$("#Invoice_Date").val('');
|
||||||
|
$("#MaterialRcvdDate").val('');
|
||||||
|
$("#ser").val('');
|
||||||
|
$("#tbleIGRAppend").empty(); // Clear the table
|
||||||
|
// Hide the MasterFileLabel if no data
|
||||||
|
modal.find('#MasterFileLabel').hide();
|
||||||
|
|
||||||
|
return; // Exit the function early
|
||||||
|
}
|
||||||
|
|
||||||
var trIGRHTML = '';
|
var trIGRHTML = '';
|
||||||
$.each(JSON.parse(data), function(i, item) {
|
$.each(parsedData, function(i, item) {
|
||||||
if (igr == item.IGRNO) {
|
if (igr == item.IGRNO) {
|
||||||
console.log(item);
|
console.log(item);
|
||||||
$('#IgrshowTitle').text(" ( "+item.IGRNO+" ) ");
|
$('#IgrshowTitle').text(" ( " + item.IGRNO + " ) ");
|
||||||
$("#IGRNO1").val(item.IGRNO);
|
$("#IGRNO1").val(item.IGRNO);
|
||||||
$("#IGRItemNo").val(item.IGRItemNo);
|
$("#txtIGRLineItem").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);
|
||||||
var isOpenOrder = parseInt(item.IsOpenOrder, 2);
|
var isOpenOrder = parseInt(item.IsOpenOrder, 2);
|
||||||
var formatted_IsOpenOrder = (isOpenOrder === 0 || isNaN(isOpenOrder)) ? "" : "Open";
|
var formatted_IsOpenOrder = (isOpenOrder === 0 || isNaN(isOpenOrder)) ? "" : "Open";
|
||||||
$('.help-block').text(formatted_IsOpenOrder);
|
$('.help-block').text(formatted_IsOpenOrder);
|
||||||
|
|
||||||
$("#Vehicle_No").val(item.VehicleNo);
|
$("#Vehicle_No").val(item.VehicleNo);
|
||||||
@ -520,32 +564,31 @@
|
|||||||
$("#Supplier").val(item.SupplierName);
|
$("#Supplier").val(item.SupplierName);
|
||||||
$("#Add1").val(item.Address);
|
$("#Add1").val(item.Address);
|
||||||
$("#Invoice_No").val(item.DeliveryChellanOrInvoiceNo);
|
$("#Invoice_No").val(item.DeliveryChellanOrInvoiceNo);
|
||||||
// alert(item.DeliveryChellanDate);
|
console.log(typeof item.MasterFile);
|
||||||
|
modal.find('#MasterFileLabel').hide();
|
||||||
|
if (typeof item.MasterFile == 'string') {
|
||||||
|
if (item.MasterFile !== null && item.MasterFile !== undefined && item.MasterFile.trim() !== "") {
|
||||||
|
modal.find('#MasterFileLabel a').attr('href', '<?php echo base_url() ?>' + 'public/uploads/Igrfiles/' + item.MasterFile);
|
||||||
|
modal.find('#MasterFileLabel a').attr('title', 'previously uploaded IGR Master File');
|
||||||
|
modal.find('#MasterFileLabel a span').text('previously uploaded - ');
|
||||||
|
modal.find('#MasterFileLabel a small').text(item.MasterFile);
|
||||||
|
modal.find('#MasterFileLabel').show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
modal.find('#MasterFileLabel').hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format dates
|
||||||
var dcd = new Date(item.DeliveryChellanDate);
|
var dcd = new Date(item.DeliveryChellanDate);
|
||||||
//alert(dcd.getDate()+ '.' + (dcd.getMonth() + 1)+ '.' + dcd.getFullYear());
|
|
||||||
// var dcd2 = (dcd.getDate() + '/' + (dcd.getMonth() + 1) + '/' + dcd.getFullYear());
|
|
||||||
var dcd2 = (String(dcd.getDate()).padStart(2, '0') + '-' + (String(dcd.getMonth() + 1).padStart(2, '0')) + '-' + dcd.getFullYear());
|
var dcd2 = (String(dcd.getDate()).padStart(2, '0') + '-' + (String(dcd.getMonth() + 1).padStart(2, '0')) + '-' + dcd.getFullYear());
|
||||||
$("#Invoice_Date").val(dcd2);
|
$("#Invoice_Date").val(dcd2);
|
||||||
if (item.MaterialRcvdDate === null) {
|
var Mat_rcv_date = (item.MaterialRcvdDate === null) ? ' ' : formatDate(new Date(item.MaterialRcvdDate));
|
||||||
var Mat_rcv_date = ' ';
|
|
||||||
} else {
|
|
||||||
var MR_dt = new Date(item.MaterialRcvdDate);
|
|
||||||
var Mat_rcv_date = (String(MR_dt.getDate()).padStart(2, '0') + '-' + (String(MR_dt.getMonth() + 1).padStart(2, '0')) + '-' + MR_dt.getFullYear());
|
|
||||||
}
|
|
||||||
$("#MaterialRcvdDate").val(Mat_rcv_date);
|
$("#MaterialRcvdDate").val(Mat_rcv_date);
|
||||||
if (item.GrossWeightDate === null) {
|
var gross_rcv_date = (item.GrossWeightDate === null) ? ' ' : formatDate(new Date(item.GrossWeightDate));
|
||||||
var gross_rcv_date = ' ';
|
|
||||||
} else {
|
|
||||||
var G_dt = new Date(item.GrossWeightDate);
|
|
||||||
var gross_rcv_date = formatDateTime(G_dt);
|
|
||||||
}
|
|
||||||
$("#ser").val(item.ServiceDescription);
|
$("#ser").val(item.ServiceDescription);
|
||||||
|
|
||||||
|
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
if (igrstatus === "ST074") {
|
if (igrstatus === "ST074") {
|
||||||
// alert("here");
|
|
||||||
// document.getElementById('pendingQuantityHeader').style.display = 'table-cell';
|
|
||||||
$("#pendingQuantityHeader").css("display", "table-cell");
|
$("#pendingQuantityHeader").css("display", "table-cell");
|
||||||
|
|
||||||
trIGRHTML += '<tr>' +
|
trIGRHTML += '<tr>' +
|
||||||
@ -558,12 +601,8 @@
|
|||||||
'<td name="PendingQuantity' + i + '" id="PendingQuantity' + i + '">' + parseInt(item.Quantity - item.QuantityAsPerInvoice) + '</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 + ')" style="width: 75px;"> </td>' +
|
'<td><input type="text" id="Remark' + i + '" name="Remark' + i + '" class="form" onchange="SetRemarks(' + i + ')" style="width: 75px;"> </td>' +
|
||||||
'<td><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="'+i+'" data-material="'+item.MaterialName+'" data-igrstatus = "'+igrstatus+'"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
|
'<td><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="'+i+'" data-material="'+item.MaterialName+'" data-igrstatus = "'+igrstatus+'"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'<input type="hidden" id="IGRNO' + i + '" name="IGRNO' + i + '" value="' + item.IGRNO + '">' +
|
'<input type="hidden" id="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="text" 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="txtQuantityAsPerInvoice' + i + '" name="txtQuantityAsPerInvoice' + i + '" value="' + item.QuantityAsPerInvoice + '">' +
|
||||||
'<input type="hidden" id="txtOrderedQuantity' + i + '" name="txtOrderedQuantity' + i + '" value="' + item.Quantity + '">' +
|
'<input type="hidden" id="txtOrderedQuantity' + i + '" name="txtOrderedQuantity' + i + '" value="' + item.Quantity + '">' +
|
||||||
'<input type="hidden" id="txtGrossWeight' + i + '" name="txtGrossWeight' + i + '" value="' + item.GrossWeight + '">' +
|
'<input type="hidden" id="txtGrossWeight' + i + '" name="txtGrossWeight' + i + '" value="' + item.GrossWeight + '">' +
|
||||||
@ -571,14 +610,15 @@
|
|||||||
'<input type="hidden" id="txtTareWeight' + i + '" name="txtTareWeight' + i + '" value="' + item.TareWeight + '">' +
|
'<input type="hidden" id="txtTareWeight' + i + '" name="txtTareWeight' + i + '" value="' + item.TareWeight + '">' +
|
||||||
'<input type="hidden" id="txtTareWeightDate' + i + '" name="txtTareWeightDate' + i + '" value="' + item.TareWeightDate + '">' +
|
'<input type="hidden" id="txtTareWeightDate' + i + '" name="txtTareWeightDate' + i + '" value="' + item.TareWeightDate + '">' +
|
||||||
'<input type="hidden" id="txtNetWeight' + i + '" name="txtNetWeight' + i + '"value="' + item.NetWeight + '">' +
|
'<input type="hidden" id="txtNetWeight' + i + '" name="txtNetWeight' + i + '"value="' + item.NetWeight + '">' +
|
||||||
'<input type="hidden" id="txtRemarks' + i + '" name="txtRemarks' + i + '"value="' + item.Remarks + '">' + // Example with no initial value
|
'<input type="hidden" id="txtRemarks' + i + '" name="txtRemarks' + i + '"value="' + item.Remarks + '">' +
|
||||||
'<input type="hidden" id="txtIGRLineItem' + i + '" name="txtIGRLineItem' + i + '"value="' + item.IGRItemNo + '">' +
|
'<input type="hidden" id="txtIGRLineItem' + i + '" name="txtIGRLineItem' + i + '"value="' + item.IGRItemNo + '">' +
|
||||||
|
'<input type="file" id="txtWeightFile' + i + '" name="txtWeightFile' + i + '"value="' + item.WeightFile + '" style="display:none;">' +
|
||||||
|
'<input type="hidden" id="txtWeightFileName' + i + '" name="txtWeightFileName' + i + '"value="' + item.WeightFile + '">' +
|
||||||
'</tr>';
|
'</tr>';
|
||||||
//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');
|
||||||
}
|
}
|
||||||
// console.log("Ifpart ... ");
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$("#pendingQuantityHeader").css("display", "none");
|
$("#pendingQuantityHeader").css("display", "none");
|
||||||
@ -592,7 +632,6 @@
|
|||||||
'<td>' + item.Remarks + '</td>' +
|
'<td>' + item.Remarks + '</td>' +
|
||||||
'<td><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="'+i+'" data-material="'+item.MaterialName+'" data-igrstatus = "'+igrstatus+'"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
|
'<td><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="'+i+'" data-material="'+item.MaterialName+'" data-igrstatus = "'+igrstatus+'"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
|
||||||
'<input type="hidden" id="IGRNO' + i + '" name="IGRNO' + i + '" value="' + item.IGRNO + '">' +
|
'<input type="hidden" id="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="MaterialCode' + i + '" name="MaterialCode' + i + '" value="' + item.MaterialCode + '">' +
|
||||||
'<input type="hidden" id="txtQuantityAsPerInvoice' + i + '" name="txtQuantityAsPerInvoice' + i + '" value="' + item.QuantityAsPerInvoice + '">' +
|
'<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="txtOrderedQuantity' + i + '" name="txtOrderedQuantity' + i + '" value="' + item.Quantity + '">' +
|
||||||
@ -603,14 +642,13 @@
|
|||||||
'<input type="hidden" id="txtNetWeight' + i + '" name="txtNetWeight' + i + '"value="' + item.NetWeight + '">' +
|
'<input type="hidden" id="txtNetWeight' + i + '" name="txtNetWeight' + i + '"value="' + item.NetWeight + '">' +
|
||||||
'<input type="hidden" id="txtRemarks' + i + '" name="txtRemarks' + i + '"value="' + item.Remarks + '">' +
|
'<input type="hidden" id="txtRemarks' + i + '" name="txtRemarks' + i + '"value="' + item.Remarks + '">' +
|
||||||
'<input type="hidden" id="txtIGRLineItem' + i + '" name="txtIGRLineItem' + i + '"value="' + item.IGRItemNo + '">' +
|
'<input type="hidden" id="txtIGRLineItem' + i + '" name="txtIGRLineItem' + i + '"value="' + item.IGRItemNo + '">' +
|
||||||
|
'<input type="file" id="txtWeightFile' + i + '" name="txtWeightFile' + i + '"value="' + item.WeightFile + '">' +
|
||||||
|
'<input type="hidden" id="txtWeightFileName' + i + '" name="txtWeightFileName' + i + '"value="' + item.WeightFile + '">' +
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//alert(item.QuantityAsPerInvoice);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#tbleIGRAppend").empty();
|
$("#tbleIGRAppend").empty();
|
||||||
$("#tbleIGRAppend").append(trIGRHTML);
|
$("#tbleIGRAppend").append(trIGRHTML);
|
||||||
}
|
}
|
||||||
@ -638,11 +676,6 @@
|
|||||||
$('#draftIGR').click(function(){
|
$('#draftIGR').click(function(){
|
||||||
$('#content').loader('show');
|
$('#content').loader('show');
|
||||||
var igrno = $("#IGRNO1").val();
|
var igrno = $("#IGRNO1").val();
|
||||||
var materialrcv_date = $("#MaterialRcvdDate").val();
|
|
||||||
var inv_date = $("#Invoice_Date").val();
|
|
||||||
var vehicle_no = $('#Vehicle_No').val();
|
|
||||||
var driver = $('#Driver_Name').val();
|
|
||||||
var driver_mobile = $('#DriverMobileNumber').val();
|
|
||||||
var status = 0;
|
var status = 0;
|
||||||
var tableData = [];
|
var tableData = [];
|
||||||
$('#tbleIGRAppend tr').each(function(index) {
|
$('#tbleIGRAppend tr').each(function(index) {
|
||||||
@ -657,15 +690,27 @@
|
|||||||
TareWeight: row.find('#txtTareWeight' + index).val(),
|
TareWeight: row.find('#txtTareWeight' + index).val(),
|
||||||
TareWeightDate: row.find('#txtTareWeightDate' + index).val(),
|
TareWeightDate: row.find('#txtTareWeightDate' + index).val(),
|
||||||
NetWeight: row.find('#txtNetWeight' + index).val(),
|
NetWeight: row.find('#txtNetWeight' + index).val(),
|
||||||
IGRItemNo: row.find('#txtIGRLineItem' + index).val()
|
IGRItemNo: row.find('#txtIGRLineItem' + index).val(),
|
||||||
|
WeightFile: row.find('#txtWeightFile' + index).val()
|
||||||
};
|
};
|
||||||
tableData.push(rowData);
|
tableData.push(rowData);
|
||||||
});
|
});
|
||||||
console.log(tableData);
|
var formData = new FormData();
|
||||||
|
formData.append('igr', igrno);
|
||||||
|
formData.append('mrc', $("#MaterialRcvdDate").val());
|
||||||
|
formData.append('invdate', $("#Invoice_Date").val());
|
||||||
|
formData.append('vehicle_no', $('#Vehicle_No').val());
|
||||||
|
formData.append('driver', $('#Driver_Name').val());
|
||||||
|
formData.append('driver_mobile', $('#DriverMobileNumber').val());
|
||||||
|
formData.append('status', status);
|
||||||
|
formData.append('tableData', JSON.stringify(tableData));
|
||||||
|
formData.append('MasterFile', $('#MasterFile')[0].files[0]);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data:{igr:igrno,mrc:materialrcv_date,invdate:inv_date,vehicle_no:vehicle_no,driver:driver,driver_mobile:driver_mobile,status:status,tableData: tableData},
|
data: formData,
|
||||||
type:"POST",
|
type: "POST",
|
||||||
url:"<?php echo base_url() ?>UpdateIGR",
|
url: "<?php echo base_url() ?>UpdateIGR",
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
success:function(data) {
|
success:function(data) {
|
||||||
$('#content').loader('hide');
|
$('#content').loader('hide');
|
||||||
alert(data);
|
alert(data);
|
||||||
@ -676,11 +721,6 @@ console.log(tableData);
|
|||||||
$('#generateIGR').click(function(){
|
$('#generateIGR').click(function(){
|
||||||
$('#content').loader('show');
|
$('#content').loader('show');
|
||||||
var igrno = $("#IGRNO1").val();
|
var igrno = $("#IGRNO1").val();
|
||||||
var materialrcv_date = $("#MaterialRcvdDate").val();
|
|
||||||
var inv_date = $("#Invoice_Date").val();
|
|
||||||
var vehicle_no = $('#Vehicle_No').val();
|
|
||||||
var driver = $('#Driver_Name').val();
|
|
||||||
var driver_mobile = $('#DriverMobileNumber').val();
|
|
||||||
var status = 1;
|
var status = 1;
|
||||||
var tableData = [];
|
var tableData = [];
|
||||||
$('#tbleIGRAppend tr').each(function(index) {
|
$('#tbleIGRAppend tr').each(function(index) {
|
||||||
@ -695,15 +735,29 @@ console.log(tableData);
|
|||||||
TareWeight: row.find('#txtTareWeight' + index).val(),
|
TareWeight: row.find('#txtTareWeight' + index).val(),
|
||||||
TareWeightDate: row.find('#txtTareWeightDate' + index).val(),
|
TareWeightDate: row.find('#txtTareWeightDate' + index).val(),
|
||||||
NetWeight: row.find('#txtNetWeight' + index).val(),
|
NetWeight: row.find('#txtNetWeight' + index).val(),
|
||||||
IGRItemNo: row.find('#txtIGRLineItem' + index).val()
|
IGRItemNo: row.find('#txtIGRLineItem' + index).val(),
|
||||||
|
WeightFile: row.find('#txtWeightFile' + index).val()
|
||||||
};
|
};
|
||||||
tableData.push(rowData);
|
tableData.push(rowData);
|
||||||
});
|
});
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append('igr', igrno);
|
||||||
|
formData.append('mrc', $("#MaterialRcvdDate").val());
|
||||||
|
formData.append('invdate', $("#Invoice_Date").val());
|
||||||
|
formData.append('vehicle_no', $('#Vehicle_No').val());
|
||||||
|
formData.append('driver', $('#Driver_Name').val());
|
||||||
|
formData.append('driver_mobile', $('#DriverMobileNumber').val());
|
||||||
|
formData.append('status', status);
|
||||||
|
formData.append('tableData', JSON.stringify(tableData));
|
||||||
|
formData.append('MasterFile', $('#MasterFile')[0].files[0]);
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data:{igr:igrno,mrc:materialrcv_date,invdate:inv_date,vehicle_no:vehicle_no,driver:driver,driver_mobile:driver_mobile,status:status,tableData: tableData},
|
data: formData,
|
||||||
type:"POST",
|
type:"POST",
|
||||||
url:"<?php echo base_url() ?>UpdateIGR",
|
url: "<?php echo base_url() ?>UpdateIGR",
|
||||||
success:function(data) {
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
success:function(data) {
|
||||||
$('#content').loader('hide');
|
$('#content').loader('hide');
|
||||||
alert(data);
|
alert(data);
|
||||||
location.reload();
|
location.reload();
|
||||||
@ -997,9 +1051,10 @@ function deleteBill(Billno,i){
|
|||||||
$("#WeightCalculator").on("shown.bs.modal", function(e) {
|
$("#WeightCalculator").on("shown.bs.modal", function(e) {
|
||||||
var inx = $(e.relatedTarget).data('index');
|
var inx = $(e.relatedTarget).data('index');
|
||||||
var material = $(e.relatedTarget).data('material');
|
var material = $(e.relatedTarget).data('material');
|
||||||
|
var modal = $(this);
|
||||||
|
|
||||||
document.getElementById('WeightTitle').textContent = " ( "+material+" )";
|
|
||||||
|
|
||||||
|
$('#WeightTitle').text(" ( " + material + " )");
|
||||||
|
|
||||||
// Clear the modal inputs
|
// Clear the modal inputs
|
||||||
$("#GrossWeight").val('');
|
$("#GrossWeight").val('');
|
||||||
@ -1007,6 +1062,8 @@ function deleteBill(Billno,i){
|
|||||||
$("#TareWeight").val('');
|
$("#TareWeight").val('');
|
||||||
$("#TareWeightDate").val('');
|
$("#TareWeightDate").val('');
|
||||||
$("#NetWeight").val('');
|
$("#NetWeight").val('');
|
||||||
|
$("#WeightFile").val('');
|
||||||
|
|
||||||
|
|
||||||
// Retrieve values from hidden inputs
|
// Retrieve values from hidden inputs
|
||||||
var v1 = $("#txtGrossWeight" + inx).val();
|
var v1 = $("#txtGrossWeight" + inx).val();
|
||||||
@ -1014,14 +1071,18 @@ function deleteBill(Billno,i){
|
|||||||
var v3 = $("#txtTareWeight" + inx).val();
|
var v3 = $("#txtTareWeight" + inx).val();
|
||||||
var v4 = $("#txtTareWeightDate" + inx).val();
|
var v4 = $("#txtTareWeightDate" + inx).val();
|
||||||
var v5 = $("#txtNetWeight" + inx).val();
|
var v5 = $("#txtNetWeight" + inx).val();
|
||||||
|
var fileInput = $("#txtWeightFile" + inx)[0];
|
||||||
|
var fileName = $("#txtWeightFileName" + inx).val();
|
||||||
// Debugging alerts
|
modal.find('#WeightFileLabel').hide();
|
||||||
// console.log("v1:", v1);
|
console.log(typeof fileName);
|
||||||
// console.log("v2:", v2);
|
if (fileName !== 'null' && fileName !== undefined && fileName.trim() !== "") {
|
||||||
// console.log("v3:", v3);
|
modal.find('#WeightFileLabel a').attr('title', 'previously uploaded IGR Weight File');
|
||||||
// console.log("v4:", v4);
|
modal.find('#WeightFileLabel a').attr('href', '<?php echo base_url() ?>'+'public/uploads/Igrfiles/'+fileName);
|
||||||
// console.log("v5:", v5);
|
modal.find('#WeightFileLabel a span').text('previously uploaded - ');
|
||||||
|
modal.find('#WeightFileLabel a small').text(fileName);
|
||||||
|
modal.find('#WeightFileLabel').show();
|
||||||
|
}
|
||||||
|
console.log(fileInput);
|
||||||
console.log("Selected values for index:", typeof inx,inx);
|
console.log("Selected values for index:", typeof inx,inx);
|
||||||
|
|
||||||
// Set modal inputs with the retrieved values
|
// Set modal inputs with the retrieved values
|
||||||
@ -1031,6 +1092,22 @@ function deleteBill(Billno,i){
|
|||||||
$("#TareWeightDate").val(v4);
|
$("#TareWeightDate").val(v4);
|
||||||
$("#NetWeight").val(v5);
|
$("#NetWeight").val(v5);
|
||||||
$("#CurrentInx").val(inx);
|
$("#CurrentInx").val(inx);
|
||||||
|
|
||||||
|
fileName
|
||||||
|
if (fileInput && fileInput.files.length > 0) {
|
||||||
|
var targetInput = $("#WeightFile")[0];
|
||||||
|
var file = fileInput.files[0];
|
||||||
|
|
||||||
|
// Create a new DataTransfer object
|
||||||
|
var dataTransfer = new DataTransfer();
|
||||||
|
dataTransfer.items.add(file);
|
||||||
|
|
||||||
|
// Set the file to the target input
|
||||||
|
targetInput.files = dataTransfer.files;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log("No file selected or file input not found.");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -1040,31 +1117,57 @@ function deleteBill(Billno,i){
|
|||||||
var v3 = $("#TareWeight").val();
|
var v3 = $("#TareWeight").val();
|
||||||
var v4 = $("#TareWeightDate").val();
|
var v4 = $("#TareWeightDate").val();
|
||||||
var v5 = $("#NetWeight").val();
|
var v5 = $("#NetWeight").val();
|
||||||
var v6 = $("#CurrentInx").val();
|
var inx = $("#CurrentInx").val();
|
||||||
var IGRNO1 = $("#IGRNO1").val();
|
var IGRNO1 = $("#IGRNO1").val();
|
||||||
|
var fileInput = $("#WeightFile")[0]; // Get the file input element
|
||||||
|
|
||||||
// Debugging alerts
|
if (inx !== undefined && inx !== '') {
|
||||||
// console.log("v1:", v1);
|
console.log("Saving values for index:", inx);
|
||||||
// console.log("v2:", v2);
|
|
||||||
// console.log("v3:", v3);
|
|
||||||
// console.log("v4:", v4);
|
|
||||||
// console.log("v5:", v5);
|
|
||||||
if (v6 !== undefined && v6 !== '') {
|
|
||||||
console.log("Saving values for index:", v6);
|
|
||||||
|
|
||||||
// Set the values back to the hidden inputs
|
// Set the values back to the hidden inputs
|
||||||
$("#txtGrossWeight" + v6).val(v1);
|
$("#txtGrossWeight" + inx).val(v1);
|
||||||
$("#txtGrossWeightDate" + v6).val(v2);
|
$("#txtGrossWeightDate" + inx).val(v2);
|
||||||
$("#txtTareWeight" + v6).val(v3);
|
$("#txtTareWeight" + inx).val(v3);
|
||||||
$("#txtTareWeightDate" + v6).val(v4);
|
$("#txtTareWeightDate" + inx).val(v4);
|
||||||
$("#txtNetWeight" + v6).val(v5);
|
$("#txtNetWeight" + inx).val(v5);
|
||||||
var txtIGRLineItem = $("#txtIGRLineItem" + v6).val();
|
var txtIGRLineItem = $("#txtIGRLineItem" + inx).val();
|
||||||
|
|
||||||
|
// Prepare FormData
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append('GrossWeight', v1);
|
||||||
|
formData.append('GrossWeightDate', v2);
|
||||||
|
formData.append('TareWeight', v3);
|
||||||
|
formData.append('TareWeightDate', v4);
|
||||||
|
formData.append('NetWeight', v5);
|
||||||
|
formData.append('IGR', IGRNO1);
|
||||||
|
formData.append('IGRlineitem', txtIGRLineItem);
|
||||||
|
if (fileInput && fileInput.files.length > 0) {
|
||||||
|
var file = fileInput.files[0];
|
||||||
|
formData.append('WeightFile', file);
|
||||||
|
} else {
|
||||||
|
console.log("No file selected or file input not found.");
|
||||||
|
}
|
||||||
|
// if (fileInput && fileInput.files.length > 0) {
|
||||||
|
// var targetInput = $("#txtWeightFile" + inx)[0];
|
||||||
|
// var file = fileInput.files[0];
|
||||||
|
|
||||||
|
// // Create a new DataTransfer object
|
||||||
|
// var dataTransfer = new DataTransfer();
|
||||||
|
// dataTransfer.items.add(file);
|
||||||
|
|
||||||
|
// // Set the file to the target input
|
||||||
|
// targetInput.files = dataTransfer.files;
|
||||||
|
// formData.append('WeightFile', file);
|
||||||
|
|
||||||
|
// } else {
|
||||||
|
// console.log("No file selected or file input not found.");
|
||||||
|
// }
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data:{GrossWeight:v1,GrossWeightDate:v2,TareWeight:v3,TareWeightDate:v4,NetWeight:v5,IGR:IGRNO1,IGRlineitem:txtIGRLineItem},
|
url: "<?php echo base_url() ?>updateIGRWeight",
|
||||||
//dataType:"json",
|
type: "POST",
|
||||||
type:"POST",
|
data: formData,
|
||||||
url: "<?php echo base_url() ?>updateIGRWeight",
|
contentType: false, // Don't set content type header
|
||||||
|
processData: false,
|
||||||
success:function(data) {
|
success:function(data) {
|
||||||
if(data)
|
if(data)
|
||||||
{
|
{
|
||||||
@ -1079,11 +1182,12 @@ function deleteBill(Billno,i){
|
|||||||
$("#TareWeight").val('');
|
$("#TareWeight").val('');
|
||||||
$("#TareWeightDate").val('');
|
$("#TareWeightDate").val('');
|
||||||
$("#NetWeight").val('');
|
$("#NetWeight").val('');
|
||||||
|
$("#WeightFile").val('');
|
||||||
|
|
||||||
// Close the modal
|
// Close the modal
|
||||||
$("#WeightCalculator").modal('hide');
|
$("#WeightCalculator").modal('hide');
|
||||||
} else {
|
} else {
|
||||||
console.log("Saving values for index: "+v6+" undefined");
|
console.log("Saving values for index: "+inx+" undefined");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1260,7 +1364,14 @@ function deleteBill(Billno,i){
|
|||||||
'</tr>';
|
'</tr>';
|
||||||
$('#tblefile').append(newRow);
|
$('#tblefile').append(newRow);
|
||||||
}
|
}
|
||||||
|
function Copyfilenames(id) {
|
||||||
|
var size = $('input[name=' + id + ']')[0].files[0].size;
|
||||||
|
if (size > 2100000) {
|
||||||
|
alert('Sorry Your File is Large To 2MB');
|
||||||
|
} else {
|
||||||
|
var name = $('input[name=' + id + ']')[0].files[0].name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<!-- Latest DataTables JS -->
|
<!-- Latest DataTables JS -->
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user