From 107c90a49d49c2c4413b2274b4778acf16a9ddbf Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 13 Aug 2024 05:03:04 +0000 Subject: [PATCH 1/3] FIX_IGR files Changes --- app/Config/Routes.php | 6 +- app/Controllers/Emergencypurchaseorder.php | 4 +- app/Controllers/Inwardgateregister.php | 208 +++- app/Models/Inwardgateregister_model.php | 67 +- app/Models/Requistion_model.php | 5 +- app/Views/alterpurchaseorder.php | 303 ++--- app/Views/capitalpurchaseorder.php | 2 +- app/Views/editCapitalAmendPO.php | 2 +- app/Views/editRevenueAmendPO.php | 2 +- app/Views/inwardgateregister.php | 121 +- app/Views/requisitionlisting.php | 13 +- app/Views/viewinwardgateregister.php | 186 +++- public/uploads/POfiles/SECLIENT.jpg | Bin 0 -> 11487 bytes public/uploads/POfiles/SupplierBills.png | Bin 0 -> 2512 bytes public/uploads/POfiles/WorkPlace2.jpeg | Bin 0 -> 6399 bytes public/uploads/POfiles/WorkPlace2_1.jpeg | Bin 0 -> 6399 bytes public/uploads/POfiles/WorkPlace2_2.jpeg | Bin 0 -> 6399 bytes public/uploads/POfiles/WorkPlace3.jpeg | Bin 0 -> 8933 bytes public/uploads/POfiles/ria_test.sql | 1171 ++++++++++++++++++++ 19 files changed, 1846 insertions(+), 244 deletions(-) create mode 100644 public/uploads/POfiles/SECLIENT.jpg create mode 100644 public/uploads/POfiles/SupplierBills.png create mode 100644 public/uploads/POfiles/WorkPlace2.jpeg create mode 100644 public/uploads/POfiles/WorkPlace2_1.jpeg create mode 100644 public/uploads/POfiles/WorkPlace2_2.jpeg create mode 100644 public/uploads/POfiles/WorkPlace3.jpeg create mode 100644 public/uploads/POfiles/ria_test.sql diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 51dc80fe..1c314c49 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -246,7 +246,6 @@ $routes->get('AddIGR', 'Inwardgateregister::addIGR'); // ADD IGR page - working $routes->get('ViewIGR', 'Inwardgateregister::viewIGR'); // View IGR PAGE - Working $routes->post('ViewIGRDetails', 'Inwardgateregister::viewIGRDetails'); $routes->post('GetIGRLineItemDetails', 'Inwardgateregister::getIGRLineItemDetails'); -$routes->post('deleteBillFile', 'Inwardgateregister::deleteBillFile'); $routes->post('SaveIGR', 'Inwardgateregister::SaveIGR');// Save IGR PAGE - Working $routes->post('UpdateIGR', 'Inwardgateregister::UpdateIGR'); $routes->post('updateIGRWeight', 'Inwardgateregister::updateIGRWeight'); @@ -254,7 +253,10 @@ $routes->post('UpdateIGRLineItem', 'Inwardgateregister::updateIGRLineItem'); $routes->post('ViewIGRHistory', 'Inwardgateregister::ViewIGRHistory'); $routes->post('getCostCenterData', 'Inwardgateregister::getCostCenterData'); $routes->post('ViewIGRfile', 'Inwardgateregister::ViewIGRfile'); -$routes->post('inwardgateregister/addloadfile', 'Inwardgateregister::addloadfile'); +$routes->post('getAdditionalIGRFile', 'Inwardgateregister::getAdditionalIGRFile'); +$routes->post('deleteAdditionalIGRFile', 'Inwardgateregister::deleteAdditionalIGRFile'); +$routes->get('download-files/(:segment)', 'Inwardgateregister::downloadFilesAsZip/$1'); + $routes->post('inwardgateregister/edituploadfile', 'Inwardgateregister::edituploadfile'); // Application OGR Page diff --git a/app/Controllers/Emergencypurchaseorder.php b/app/Controllers/Emergencypurchaseorder.php index 671ee3ed..df4d8f5c 100644 --- a/app/Controllers/Emergencypurchaseorder.php +++ b/app/Controllers/Emergencypurchaseorder.php @@ -1325,7 +1325,9 @@ class Emergencypurchaseorder extends BaseController $SupplierID = $this->request->getPost('drpSupplier'); $newsup = (string)$this->request->getPost('newsup'); - $newSupId = split("[ - ]+", $newsup); + // echo $newsup;die; + // $newSupId = split("[ - ]+", $newsup); + $newSupId = preg_split('/[ - ]+/', $newsup); /*-----------------------------------*/ $b4supplier = $this->request->getPost('b4supplier'); $b4date = $this->request->getPost('b4podate'); diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index 2e75b53e..d2c5ce2a 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -8,6 +8,8 @@ use CodeIgniter\Validation\Exceptions\ValidationException; use App\Models\Inwardgateregister_model; +use ZipArchive; + /** * Module : IGR (security) * Inwardgateregister Class to control all igr related operations. @@ -71,6 +73,9 @@ class Inwardgateregister extends BaseController $data['PO_NO'] = array_filter($result, function($item) { return !($item->status === 'ST027'); }); + $data['emp_data'] = []; + // $data['emp_data'] = $this->inwardgateregister_model->getAdditionalIGRFile(); + // print_r($data['PO_NO']);die; $this->loadViews("inwardgateregister", $this->global, $data, NULL); } @@ -201,7 +206,7 @@ class Inwardgateregister extends BaseController $PO = $this->request->getPost('id'); $CreatedBy = $this->session->get('userId'); - $this->inwardgateregister_model->UpdatePOMaster($PO, $CreatedBy); + $this->inwardgateregister_model->UpdatePOMaster($PO, $CreatedBy,IGR_CREATED); $data = $this->inwardgateregister_model->viewpurchaseorder($PO); echo json_encode($data); @@ -209,7 +214,7 @@ class Inwardgateregister extends BaseController - function addloadfile() + function getAdditionalIGRFile() { $lastinsertbillid = 0; @@ -221,7 +226,7 @@ class Inwardgateregister extends BaseController $file = $this->request->getFile('file'); $requestfilename = $file->getName(); - $files = $this->inwardgateregister_model->getfies($igr); + $files = $this->inwardgateregister_model->getAdditionalIGRFile($igr); $fcount = 0; foreach ($files as $value) { @@ -247,7 +252,7 @@ class Inwardgateregister extends BaseController $myfiles = array('PONO' => $pono, 'IGRNO' => $igr, 'FilePath' => $Picture); - $lastinsertbillid = $this->inwardgateregister_model->fileupload($myfiles); + $lastinsertbillid = $this->inwardgateregister_model->uploadAdditionalFile($myfiles); } } @@ -258,18 +263,17 @@ class Inwardgateregister extends BaseController } } - function deleteBillFile(){ + function deleteAdditionalIGRFile(){ - $deleteBillFile = ''; - - $Billno = $this->request->getPost('Billno'); - $deleteBillFile = $this->inwardgateregister_model->deleteBillFile($Billno); - - if ($deleteBillFile) { - echo "file deleted successfully!"; - } else { - echo "file details not exist to delete"; - } + $deleteAdditionalFile = false; + $fileid = $this->request->getPost('id'); + $deleteAdditionalFile = $this->inwardgateregister_model->deleteAdditionalFile($fileid); + return $deleteAdditionalFile; + // if ($deleteAdditionalFile) { + // echo "file deleted successfully!"; + // } else { + // echo "file details not exist to delete"; + // } } @@ -307,8 +311,10 @@ class Inwardgateregister extends BaseController function SaveIGR() { + //print_r($this->request->getPost());die; #Step 1 IGR Details $PONO = $this->request->getPost('PONO'); + $IsThisOpenOrderPO = $this->request->getPost('hiddenIsOpenOrder'); $DeliveryChellanOrInvoiceNo = $this->request->getPost('InvoiceNo'); $DeliveryChellan = (string)$this->request->getPost('InvoiceDate'); $DeliveryChellanDate = get_date_time_format($DeliveryChellan); @@ -321,8 +327,8 @@ class Inwardgateregister extends BaseController $RowCount = $this->request->getPost('txtRowCount'); $createddt = get_current_date_time(); //$IGRStatus = IGR_CREATED;//old - $IGRStatus = (int)$this->request->getPost('hideIGRStatus') == 1 ? IGR_CREATED : IGR_DRAFT; - + $PreIGRStatus = (int)$this->request->getPost('hideIGRStatus') == 1 ? IGR_CREATED : IGR_DRAFT; + $IGRStatus = ((int)$IsThisOpenOrderPO == 1) ? IGR_DRAFT : $PreIGRStatus; $igr = array(); // For IGR Master $paymentstatus = NO_PAIDIGR; @@ -353,10 +359,38 @@ class Inwardgateregister extends BaseController #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['MasterFile'] = $requestMasterFileName; + // print_r( $igr );die; #Step 4 Calling DB to Save IGR Master $IGRNO = $this->inwardgateregister_model->addigrM($igr); + // Get the uploaded files + // $IGRNO = "IGRNO02750"; // $IGRNO = "IGRNO02734"; if($IGRNO){ + $files = $this->request->getFiles(); + $fileNames = $this->request->getPost('file_name'); // Get user-entered file names + if(isset($files['emp_file'])) + { + foreach ($files['emp_file'] as $index => $file) { + if ($file->isValid() && !$file->hasMoved()) { + // Move the file to the desired directory + $newName = $file->getRandomName(); + $file->move($path, $newName); + // Store the file information in the database + $additionalFiles = array( + 'Remarks' => $fileNames[$index], + 'FilePath' => $newName, + 'IGRNO' => $IGRNO, + 'PONO' => $PONO + ); + $lastInsertFileId = $this->inwardgateregister_model->uploadAdditionalFile($additionalFiles); + if ($lastInsertFileId) { + $fileupdated_count++; + $fileupdated_name[] = $fileNames[$index]; + } + } + } + } + #Step 5 Save Master Detail On History Table 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); @@ -427,7 +461,6 @@ class Inwardgateregister extends BaseController $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; log_message('error', "TareWeightDate" . $TareWeightDate); - if (strlen($QuantityAsPerInvoice) > 0 && $QuantityAsPerInvoice != '0') { $Remarks = $this->request->getPost('txtRemarks' . $i); $ItemStatus = ''; @@ -514,18 +547,56 @@ class Inwardgateregister extends BaseController $POLineItem = array('ReceivedQuantity' => $totalReceivedqty, 'Status' => $ItemStatus, 'UpdateBY' => $CreatedBy, 'UpdatedOn' => $createddt); $this->inwardgateregister_model->UpdatePOLineItem($POLineItem, $PONO, $MaterialCode); } + else if ((int)$IsThisOpenOrderPO == 1) { + $ItemStatus = POLINEITEM_IGRPARTIAL_CREATED; + + # Is this open order po means i have to save IGR DETAILS + $Remarks = $this->request->getPost('txtRemarks' . $i); + $ItemStatus = POLINEITEM_IGRPARTIAL_CREATED; + $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['WeightFile'] = $requestWeightFileName; + $igrD = $this->inwardgateregister_model->addigrD($igrDetails); + $igrD =''; + $igrlineno = !empty($igrD) ? $igrD : ''; + log_message('error', 'SaveIGR igrDetails result : ' . json_encode($igrDetails)." IgrLineNo : ".$igrlineno); + $itemvalue = ''; + $SupplierId = ''; + $polineitemvalue = $this->inwardgateregister_model->getitemvalue($PONO, $MaterialCode); + foreach ($polineitemvalue as $it) { + $itemvalue = $it->Rate; + $SupplierId = $it->SupplierID; + } + # Is this open order po means i have to save add material history + $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); + + # Is this open order po means i have to save the get received qty in PO lineitem table + $get_pre_qty = $this->inwardgateregister_model->get_CurrentQty($MaterialCode); + $Recqty = $this->inwardgateregister_model->getPOLineItemReceivedQty($PONO, $MaterialCode); + $ReceivedQuantity = 0.00; + if (count($Recqty) > 0) { + foreach ($Recqty as $key) { + $ReceivedQuantity = $key->ReceivedQuantity; + } + } + $totalReceivedqty = $ReceivedQuantity + $QuantityAsPerInvoice; + $POLineItem = array('ReceivedQuantity' => $totalReceivedqty, 'Status' => $ItemStatus, 'UpdateBY' => $CreatedBy, 'UpdatedOn' => $createddt); + $this->inwardgateregister_model->UpdatePOLineItem($POLineItem, $PONO, $MaterialCode); + } } - $this->inwardgateregister_model->UpdatePOMaster($PONO, $CreatedBy); + $this->inwardgateregister_model->UpdatePOMaster($PONO, $CreatedBy,$IGRStatus); #Step 9 Updating Pending Quantity IN PO Master amd Line Item Details. + if ((int)$IsThisOpenOrderPO != 1) { if ($TotalPendingQty == 0.00) { $Newstatus = array('Status' => $IGRStatus); $this->inwardgateregister_model->POLineItemsupdatestatus($PONO, $Newstatus); $this->inwardgateregister_model->pomasterupdatestatus($PONO, $Newstatus); } else { /*echo 'error' ;*/ - } + }} #finally $finalstatement = "Successfully Created IGR Number: $IGRNO \n"; if ($fileupdated_count > 0) { @@ -555,7 +626,9 @@ function viewIGRDetails() $IGRNO = $this->request->getPost('id'); - $data = $this->inwardgateregister_model->viewigr($IGRNO); + $data['details'] = $this->inwardgateregister_model->viewigr($IGRNO); + $data['files'] = $this->inwardgateregister_model->viewIGRFile($IGRNO); + // echo $IGRNO; // print_r($data);die; @@ -588,6 +661,7 @@ function viewIGRDetails() { $IGRNo = $this->request->getPost('igr'); + $PONo = $this->request->getPost('po'); $DeliveryChellan = $this->request->getPost('invdate'); $DeliveryChellanDate = !$DeliveryChellan || $DeliveryChellan === null ? NULL : get_date_time_format($DeliveryChellan); @@ -627,7 +701,37 @@ function viewIGRDetails() } } } - + $fileupdated_count = 0; + $fileupdated_name = []; + + $fileNames = $this->request->getPost('file_name'); + $files = $this->request->getFiles(); + + if(isset($files['emp_file'])) + { + foreach ($files['emp_file'] as $index => $file) { + + if ($file->isValid() && !$file->hasMoved()) { + + // Move the file to the desired directory + $newName = $file->getRandomName(); + $file->move($path, $newName); + // Store the file information in the database + $additionalFiles = array( + 'Remarks' => $fileNames[$index], + 'FilePath' => $newName, + 'IGRNO' => $IGRNo, + 'PONO' => $PONo + ); + $lastInsertFileId = $this->inwardgateregister_model->uploadAdditionalFile($additionalFiles); + if ($lastInsertFileId) { + $fileupdated_count++; + $fileupdated_name[] = $fileNames[$index]; + } + } + } + } + log_message('error', 'UpdateIGR igrarr: ' . json_encode($igrarr)); $updateigrmaster = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo); if(!empty($tableData )){ @@ -877,12 +981,21 @@ function viewIGRDetails() } } if ($updateigrmaster > 0) { - echo "Updated Succefully!"; + $finalstatement = "Successfully Updated IGR Number: $IGRNo \n"; } else if($updateigrlineitem >0){ - echo "Updated Succefully!"; + $finalstatement = "Successfully Updated IGR Number: $IGRNo \n"; }else{ - echo "Not Updated!"; + $finalstatement = "IGR Number: $IGRNo \n"; } + + if ($fileupdated_count > 0) { + $finalstatement .= "Number of files updated: $fileupdated_count \n"; + $finalstatement .= "Files: \n" . implode(PHP_EOL, $fileupdated_name); + } else { + $finalstatement .= "No files to update"; + } + + echo $finalstatement; } function updateIGRLineItem() { @@ -1156,6 +1269,7 @@ function viewIGRDetails() } } + function updateIGRWeight(){ $GrossWeight = $this->request->getPost('GrossWeight'); $GrossWeightDate = $this->request->getPost('GrossWeightDate'); @@ -1166,8 +1280,8 @@ function updateIGRWeight(){ $IGRItemNo = $this->request->getPost('IGRlineitem'); $updateby = $this->session->get('userId'); $WeightFile = $this->request->getfile('WeightFile'); - $GrossWtDt = !empty($GrossWeightDate) ? get_date_time_format($GrossWeightDate) : null; - $TareWtDt = !empty($TareWeightDate) ? get_date_time_format($TareWeightDate) : null; + $GrossWtDt = (!empty($GrossWeightDate) && (string)$GrossWeightDate != 'null' ) ? get_date_time_format($GrossWeightDate) : null; + $TareWtDt =(!empty($TareWeightDate) && (string)$TareWeightDate != 'null') ? get_date_time_format($TareWeightDate) : null; $path = ROOTPATH.'public/uploads/Igrfiles/'; @@ -1521,4 +1635,44 @@ function updateIGRWeight(){ } } } + public function downloadFilesAsZip($igrno) + { + + // Get all file details for the given IGR number + $fileDetails = $this->inwardgateregister_model->getAllIgrFileDetails($igrno); + if (empty($fileDetails)) { + // Display an alert message + echo ''; + return; + } + + // Define the root path for files + $rootPath = ROOTPATH . 'public/uploads/Igrfiles/'; + + // Create a new ZIP archive + $zip = new ZipArchive(); + + // Define the name of the ZIP file + $zipFileName = $igrno . '.zip'; + $zipFilePath = ROOTPATH . 'public/uploads/Igrfiles/' . $zipFileName; + + if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) { + // Add each file to the ZIP archive + foreach ($fileDetails as $file) { + $filePath = $rootPath . $file->file; + if (file_exists($filePath)) { + $zip->addFile($filePath, $file->filename); + } + } + + // Close the ZIP archive + $zip->close(); + + // Return the ZIP file as a download + return $this->response->download($zipFilePath, null)->setFileName($zipFileName); + } else { + // Handle the error + echo 'Failed to create ZIP file'; + } + } } diff --git a/app/Models/Inwardgateregister_model.php b/app/Models/Inwardgateregister_model.php index 400cc159..1fdc17ce 100755 --- a/app/Models/Inwardgateregister_model.php +++ b/app/Models/Inwardgateregister_model.php @@ -40,21 +40,14 @@ class Inwardgateregister_model extends Model $afftectedRows = $this->db->affectedRows(); return $afftectedRows; } - - - function getfies($igr) - { - + function getAdditionalIGRFile($igr){ $builder = $this->db->table('t_inwardgateregister_fileupload')->select('*') - - ->where('IGRNO', $igr); - + ->where('IGRNO', $igr); $query = $builder->get(); - return $query->getResult(); } - function fileupload($myfiles) + function uploadAdditionalFile($myfiles) { $builder = $this->db->table('t_inwardgateregister_fileupload'); $builder->insert($myfiles); @@ -62,13 +55,14 @@ class Inwardgateregister_model extends Model return $aff > 0 ? $this->db->insertID() : 0; } - function deleteBillFile($billno) + function deleteAdditionalFile($fileid) { - $deleteBillFile = array('Isactive' => 0); + $arr = array('Isactive' => 0); $this->db->table('t_inwardgateregister_fileupload') - ->where('BillNo', $billno) - ->update($deleteBillFile); - return TRUE; + ->where('BillNo', $fileid) + ->update($arr); + $aff = $this->db->affectedRows(); + return $aff > 0 ? true : false; } @@ -266,9 +260,7 @@ class Inwardgateregister_model extends Model $builder = $this->db->table('t_igr_details'); $builder->insert($igrD); $aff_row = $this->db->affectedRows(); - log_message('error', 'addigrD Query: ' . $this->db->getLastQuery()->getQuery()); - - + log_message('error', 'addigrD Query: ' . $this->db->getLastQuery()->getQuery()); $this->db->transComplete(); $result = $this->db->table('t_igr_details') @@ -277,7 +269,7 @@ class Inwardgateregister_model extends Model ->get() ->getRow(); - $res = ($aff_row && $result !== null) ? $result->IGRItemNo : 0; + $res = ($aff_row > 0) ? $result->IGRItemNo : 0; return $res; } @@ -414,7 +406,7 @@ class Inwardgateregister_model extends Model } } - function UpdatePOMaster($PONO, $updatedBy) + function UpdatePOMaster($PONO, $updatedBy,$IGRStatus) { $builder = $this->db->table('t_purchaseorder_lineitem')->select('*') @@ -425,7 +417,7 @@ class Inwardgateregister_model extends Model if ($query->getNumRows() == 0) { - $POStatus = array('status' => IGR_CREATED, 'UpdateBY' => $updatedBy); + $POStatus = array('status' => $IGRStatus, 'UpdateBY' => $updatedBy); $this->db->table('t_purchaseorder_master') ->where('PONO', $PONO) ->update($POStatus); @@ -933,5 +925,38 @@ class Inwardgateregister_model extends Model } + public function getAllIgrFileDetails($igrno) + { + + // Query 1: Get FilePath and Remarks from t_inwardgateregister_fileupload + $builder1 = $this->db->table('t_inwardgateregister_fileupload IFU'); + $query1 = $builder1->select('IFU.FilePath as file, IFU.Remarks as filename') + ->where('IFU.IGRNO', $igrno) + ->where('IFU.Isactive', 1) + ->get(); + $result1 = $query1->getResult(); + + // Query 2: Get MasterFile from t_igr_master + $builder2 = $this->db->table('t_igr_master IM'); + $query2 = $builder2->select('IM.MasterFile as file, IM.MasterFile as filename') + ->where('IM.IGRNO', $igrno) + ->where('IM.MasterFile IS NOT NULL') + ->get(); + $result2 = $query2->getResult(); + + // Query 3: Get WeightFile from t_igr_details + $builder3 = $this->db->table('t_igr_details ID'); + $query3 = $builder3->select('ID.WeightFile as file, ID.WeightFile as filename') + ->where('ID.IGRNO', $igrno) + ->where('ID.WeightFile IS NOT NULL') + ->get(); + $result3 = $query3->getResult(); + + // Merging results into a single array + $results = array_merge($result1, $result2, $result3); + + return $results; + } + } \ No newline at end of file diff --git a/app/Models/Requistion_model.php b/app/Models/Requistion_model.php index dce025d3..d8891486 100644 --- a/app/Models/Requistion_model.php +++ b/app/Models/Requistion_model.php @@ -124,8 +124,9 @@ class Requistion_model extends Model { $builder = $this->db->table('t_costcenter_master Mast ') ->select('Mast.CostCenterCode,Mast.CostCenterName') - ->join('t_costcenter_departments COST', 'COST.CostCenterCode = Mast.CostCenterCode') - ->where('COST.DEPCode ',$DeptId ); + ->where('Mast.IsActive ',1 ); + // ->join('t_costcenter_departments COST', 'COST.CostCenterCode = Mast.CostCenterCode','left') + // ->where('COST.DEPCode ',$DeptId ); $query = $builder->get(); return $query->getResultArray(); diff --git a/app/Views/alterpurchaseorder.php b/app/Views/alterpurchaseorder.php index a5cdd7ca..5ecf7ae4 100644 --- a/app/Views/alterpurchaseorder.php +++ b/app/Views/alterpurchaseorder.php @@ -3224,7 +3224,7 @@ if (!empty($INRSYMBOL)) {
-
+
- -
+
-
+
-
@@ -3333,6 +3331,7 @@ if (!empty($INRSYMBOL)) {
+
@@ -3372,29 +3371,9 @@ if (!empty($INRSYMBOL)) { ?>
- - -
- -
- 'RevenueEditCgst', 'value' => set_value('RevenueEditCgst', 0), 'id' => 'RevenueEditCgst', 'class' => 'form-control num', 'onkeypress' => 'return isNumberKey(event);', 'onchange' => 'Editchange();'); - echo form_input($data); - ?> -
-
-
- -
- 'RevenueEditAfterCgst', 'value' => set_value('RevenueEditAfterCgst', 0), 'id' => 'RevenueEditAfterCgst', 'class' => 'form-control num', 'readonly' => 'true'); - echo form_input($data); - ?> -
-
-
+
@@ -3434,49 +3413,10 @@ if (!empty($INRSYMBOL)) { ?>
-
-
- -
- 'RevenueEditSgst', 'value' => set_value('RevenueEditSgst', 0), 'id' => 'RevenueEditSgst', 'class' => 'form-control num', 'onkeypress' => 'return isNumberKey(event);', 'onchange' => 'Editchange();'); - echo form_input($data); - ?> -
-
-
- -
- 'RevenueEditAfterSgst', 'value' => set_value('RevenueEditAfterSgst', 0), 'id' => 'RevenueEditAfterSgst', 'class' => 'form-control num', 'readonly' => 'true'); - echo form_input($data); - ?> -
-
-
-
-
- -
- 'RevenueEditIgst', 'value' => set_value('RevenueEditIgst', 0), 'id' => 'RevenueEditIgst', 'class' => 'form-control num', 'onkeypress' => 'return isNumberKey(event);', 'onchange' => 'Editchange()'); - echo form_input($data); - ?> -
-
-
- -
- 'RevenueEditAfterIgst', 'value' => set_value('RevenueEditAfterIgst', 0), 'id' => 'RevenueEditAfterIgst', 'class' => 'form-control num', 'readonly' => 'true'); - echo form_input($data); - ?> -
-
-
-
+
+
+ + + +
+
+
+
+
+ +
+ 'RevenueEditCgst', 'value' => set_value('RevenueEditCgst', 0), 'id' => 'RevenueEditCgst', 'class' => 'form-control num', 'onkeypress' => 'return isNumberKey(event);', 'onchange' => 'Editchange();'); + echo form_input($data); + ?> +
+
+
+ +
+ 'RevenueEditAfterCgst', 'value' => set_value('RevenueEditAfterCgst', 0), 'id' => 'RevenueEditAfterCgst', 'class' => 'form-control num', 'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+ +
+
+
+
+ +
+ 'RevenueEditSgst', 'value' => set_value('RevenueEditSgst', 0), 'id' => 'RevenueEditSgst', 'class' => 'form-control num', 'onkeypress' => 'return isNumberKey(event);', 'onchange' => 'Editchange();'); + echo form_input($data); + ?> +
+
+
+ +
+ 'RevenueEditAfterSgst', 'value' => set_value('RevenueEditAfterSgst', 0), 'id' => 'RevenueEditAfterSgst', 'class' => 'form-control num', 'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+
+
+
+
+ +
+ 'RevenueEditIgst', 'value' => set_value('RevenueEditIgst', 0), 'id' => 'RevenueEditIgst', 'class' => 'form-control num', 'onkeypress' => 'return isNumberKey(event);', 'onchange' => 'Editchange()'); + echo form_input($data); + ?> +
+
+
+ +
+ 'RevenueEditAfterIgst', 'value' => set_value('RevenueEditAfterIgst', 0), 'id' => 'RevenueEditAfterIgst', 'class' => 'form-control num', 'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+
+
+
@@ -3535,11 +3549,11 @@ if (!empty($INRSYMBOL)) { ?>
- -
+
- +
+
@@ -3663,9 +3677,10 @@ if (!empty($INRSYMBOL)) {
-
+
+
@@ -3705,29 +3720,9 @@ if (!empty($INRSYMBOL)) { ?>
- -
- -
- 'RevenueCgst', 'value' => set_value('RevenueCgst', 0), 'id' => 'RevenueCgst', 'class' => 'form-control num', 'onkeypress' => 'return isNumberKey(event);', 'onchange' => 'change();RevenueChangeSgst();'); - echo form_input($data); - ?> -
-
-
- -
- 'RevenueAfterCgst', 'value' => set_value('RevenueAfterCgst', 0), 'id' => 'RevenueAfterCgst', 'class' => 'form-control num', 'readonly' => 'true'); - echo form_input($data); - ?> -
-
-
-
+
@@ -3767,50 +3762,10 @@ if (!empty($INRSYMBOL)) { ?>
-
-
- -
- 'RevenueSgst', 'value' => set_value('RevenueSgst', 0), 'id' => 'RevenueSgst', 'class' => 'form-control num', 'onkeypress' => 'return isNumberKey(event);', 'onchange' => 'change()'); - echo form_input($data); - ?> -
-
-
- -
- 'RevenueAfterSgst', 'value' => set_value('RevenueAfterSgst', 0), 'id' => 'RevenueAfterSgst', 'class' => 'form-control num', 'readonly' => 'true'); - echo form_input($data); - ?> -
-
-
-
-
-
+
+
-
@@ -3859,6 +3813,79 @@ if (!empty($INRSYMBOL)) { ?>
+
+ +
+
+
+ +
+ 'RevenueCgst', 'value' => set_value('RevenueCgst', 0), 'id' => 'RevenueCgst', 'class' => 'form-control num', 'onkeypress' => 'return isNumberKey(event);', 'onchange' => 'change();RevenueChangeSgst();'); + echo form_input($data); + ?> +
+
+
+ +
+ 'RevenueAfterCgst', 'value' => set_value('RevenueAfterCgst', 0), 'id' => 'RevenueAfterCgst', 'class' => 'form-control num', 'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+
+
+
+
+ +
+ 'RevenueSgst', 'value' => set_value('RevenueSgst', 0), 'id' => 'RevenueSgst', 'class' => 'form-control num', 'onkeypress' => 'return isNumberKey(event);', 'onchange' => 'change()'); + echo form_input($data); + ?> +
+
+
+ +
+ 'RevenueAfterSgst', 'value' => set_value('RevenueAfterSgst', 0), 'id' => 'RevenueAfterSgst', 'class' => 'form-control num', 'readonly' => 'true'); + echo form_input($data); + ?> +
+
+
+
+
+ +
+ +
+
+
@@ -3868,13 +3895,11 @@ if (!empty($INRSYMBOL)) { ?>
- - -
- +
+
diff --git a/app/Views/capitalpurchaseorder.php b/app/Views/capitalpurchaseorder.php index de528ad2..8483b2cc 100644 --- a/app/Views/capitalpurchaseorder.php +++ b/app/Views/capitalpurchaseorder.php @@ -2477,7 +2477,7 @@ <%=TotalValue%> -     +     diff --git a/app/Views/editCapitalAmendPO.php b/app/Views/editCapitalAmendPO.php index dd0b5526..5fa92d34 100644 --- a/app/Views/editCapitalAmendPO.php +++ b/app/Views/editCapitalAmendPO.php @@ -2243,7 +2243,7 @@ <%=TotalValue%> -     +     diff --git a/app/Views/editRevenueAmendPO.php b/app/Views/editRevenueAmendPO.php index 093c00d3..2c9be165 100644 --- a/app/Views/editRevenueAmendPO.php +++ b/app/Views/editRevenueAmendPO.php @@ -2081,7 +2081,7 @@ if (!empty($INRSYMBOL)) { <%=TotalValue%> -     +     diff --git a/app/Views/inwardgateregister.php b/app/Views/inwardgateregister.php index ddd9d371..f9d9a4bb 100755 --- a/app/Views/inwardgateregister.php +++ b/app/Views/inwardgateregister.php @@ -127,21 +127,21 @@
'InvoiceNo', 'value' => set_value('InvoiceNo'), 'id' => 'InvoiceNo', 'class' => 'form-control', 'required=>"true"'); // ,'onkeypress'=>'return isNumberKey(event);' ); + $data = array('name' => 'InvoiceNo', 'value' => set_value('InvoiceNo'), 'id' => 'InvoiceNo', 'class' => 'form-control', 'required=>"true"', 'autocomplete'=>'off'); // ,'onkeypress'=>'return isNumberKey(event);' ); echo form_input($data); ?>
'InvoiceDate', 'value' => set_value('InvoiceDate'), 'id' => 'InvoiceDate', 'class' => 'form-control num', 'required' => 'true'); + $data = array('name' => 'InvoiceDate', 'value' => set_value('InvoiceDate'), 'id' => 'InvoiceDate', 'class' => 'form-control num', 'required' => 'true', 'autocomplete'=>'off'); echo form_input($data); ?>
'MaterialRcvdDate', 'value' => set_value('MaterialRcvdDate'), 'id' => 'MaterialRcvdDate', 'class' => 'form-control num', 'required' => 'true'); + $data = array('name' => 'MaterialRcvdDate', 'value' => set_value('MaterialRcvdDate'), 'id' => 'MaterialRcvdDate', 'class' => 'form-control num', 'required' => 'true', 'autocomplete'=>'off'); echo form_input($data); ?>
@@ -150,7 +150,7 @@
'VehicleNo', 'value' => set_value('VehicleNo'), 'id' => 'VehicleNo', 'class' => 'form-control', 'maxlength' => '20'); + $data = array('name' => 'VehicleNo', 'value' => set_value('VehicleNo'), 'id' => 'VehicleNo', 'class' => 'form-control', 'maxlength' => '20', 'autocomplete'=>'off'); echo form_input($data); ?> @@ -158,14 +158,14 @@
'DriverName', 'value' => set_value('DriverName'), 'id' => 'DriverName', 'class' => 'form-control', 'maxlength' => '50'); + $data = array('name' => 'DriverName', 'value' => set_value('DriverName'), 'id' => 'DriverName', 'class' => 'form-control', 'maxlength' => '50', 'autocomplete'=>'off'); echo form_input($data); ?>
'DriverMobileNumber', 'value' => set_value('DriverMobileNumber'), 'id' => 'DriverMobileNumber', 'class' => 'form-control', 'maxlength' => '50'); + $data = array('name' => 'DriverMobileNumber', 'value' => set_value('DriverMobileNumber'), 'id' => 'DriverMobileNumber', 'class' => 'form-control', 'maxlength' => '50', 'autocomplete'=>'off'); echo form_input($data); ?>
@@ -206,7 +206,43 @@

- +
+
+
+ +
+ + $value) { ?> + +
+
+ File Name + +
+
+ + + +
+
+ +
+
+ + + +
+

+
+
@@ -267,7 +303,7 @@
'GrossWeight', 'value' => set_value('GrossWeight'), 'id' => 'GrossWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'WeightDiffer(this);', 'placeholder' => 'Gross Weight Value (A)'); + $data = array('name' => 'GrossWeight', 'value' => set_value('GrossWeight'), 'id' => 'GrossWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'WeightDiffer(this);', 'placeholder' => 'Gross Weight Value (A)', 'autocomplete'=>"off"); echo form_input($data); ?>
@@ -283,7 +319,7 @@
'TareWeight', 'value' => set_value('TareWeight'), 'id' => 'TareWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'validateTareWeight(this);', 'placeholder' => 'Enter your username', 'placeholder' => 'Tare Weight Value (B)'); + $data = array('name' => 'TareWeight', 'value' => set_value('TareWeight'), 'id' => 'TareWeight', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'maxlength' => '50', 'onchange' => 'validateTareWeight(this);', 'autocomplete' => 'off', 'placeholder' => 'Tare Weight Value (B)', 'autocomplete'=>"off"); echo form_input($data); ?>
@@ -325,15 +361,8 @@
- - - - -
- -
@@ -348,7 +377,8 @@ @@ -818,4 +857,42 @@ console.log("Saving values for index: " + inx + " undefined"); } } + + \ No newline at end of file diff --git a/app/Views/requisitionlisting.php b/app/Views/requisitionlisting.php index 848e3948..b27c03f0 100644 --- a/app/Views/requisitionlisting.php +++ b/app/Views/requisitionlisting.php @@ -111,6 +111,7 @@ span.highlight { Partially PoCreatedLineItem NewLine Item Status + Requested By Action @@ -133,14 +134,12 @@ span.highlight { ReqNo ?> ReqType ?> TotalNoofLineItems ?> - PolineItems ?> - PartilallyLineItems ?> - newLineItem ?> - - + PolineItems ?> + PartilallyLineItems ?> + newLineItem ?> StatusName ?> - -     + Requestedby ?> +     format('d-m-Y'); ?> VehicleNo ?> IGRStatus == 'ST074' ? 'Draft' : 'Completed'; ?> - FilePath)) { ?> - + + + + +   + FilePath)) { ?> + file)) { ?> - + - +   @@ -147,6 +152,8 @@ ?>
+ +
@@ -423,8 +441,6 @@
+ + + + + + + + + + + + + + + + @@ -129,21 +156,28 @@ span.highlight { - - - - - - + + + + + + + - - - - - - StatusName ?> + + + + + From 40a2cbc4d257ff06a1dd54bb17b027eee771c771 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 13 Aug 2024 09:26:02 +0000 Subject: [PATCH 3/3] FIX_issues : ps --- app/Controllers/Inwardgateregister.php | 80 ++++++++++++++++---------- app/Views/viewinwardgateregister.php | 52 ++++++++--------- 2 files changed, 77 insertions(+), 55 deletions(-) diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index d2c5ce2a..a82917df 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -1635,44 +1635,66 @@ function updateIGRWeight(){ } } } + public function downloadFilesAsZip($igrno) - { - - // Get all file details for the given IGR number - $fileDetails = $this->inwardgateregister_model->getAllIgrFileDetails($igrno); - if (empty($fileDetails)) { +{ + // Get all file details for the given IGR number + $fileDetails = $this->inwardgateregister_model->getAllIgrFileDetails($igrno); + if (empty($fileDetails)) { // Display an alert message echo ''; + redirect('ViewIGR', 'refresh'); return; - } + } - // Define the root path for files - $rootPath = ROOTPATH . 'public/uploads/Igrfiles/'; + // Define the root path for files + $rootPath = ROOTPATH . 'public/uploads/Igrfiles/'; - // Create a new ZIP archive - $zip = new ZipArchive(); + // Create a new ZIP archive + $zip = new ZipArchive(); - // Define the name of the ZIP file - $zipFileName = $igrno . '.zip'; - $zipFilePath = ROOTPATH . 'public/uploads/Igrfiles/' . $zipFileName; + // Define the name of the ZIP file + $zipFileName = $igrno . '.zip'; + $zipFilePath = $rootPath . $zipFileName; - if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) { - // Add each file to the ZIP archive - foreach ($fileDetails as $file) { - $filePath = $rootPath . $file->file; - if (file_exists($filePath)) { - $zip->addFile($filePath, $file->filename); - } - } + if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) { + $filesAdded = false; - // Close the ZIP archive - $zip->close(); + // Add each file to the ZIP archive + foreach ($fileDetails as $file) { + $filePath = $rootPath . $file->file; + if (file_exists($filePath)) { + if (!$zip->addFile($filePath, $file->filename)) { + // Handle error when adding file to ZIP + echo ''; + $zip->close(); + redirect('ViewIGR', 'refresh'); + return; + } + $filesAdded = true; + } + } - // Return the ZIP file as a download - return $this->response->download($zipFilePath, null)->setFileName($zipFileName); - } else { - // Handle the error - echo 'Failed to create ZIP file'; - } + // Close the ZIP archive + $zip->close(); + + if ($filesAdded) { + // Return the ZIP file as a download + return $this->response->download($zipFilePath, null)->setFileName($zipFileName); + } else { + // Delete the empty ZIP file + if (file_exists($zipFilePath)) { + unlink($zipFilePath); + } + echo ''; + redirect('ViewIGR', 'refresh'); + return; + } + } else { + echo ''; + redirect('ViewIGR', 'refresh'); + return; } } + +} diff --git a/app/Views/viewinwardgateregister.php b/app/Views/viewinwardgateregister.php index 93a686ba..3a9ae581 100644 --- a/app/Views/viewinwardgateregister.php +++ b/app/Views/viewinwardgateregister.php @@ -205,15 +205,15 @@
Requisted DateRequisition NoRequisition TypeTot No.OfLineItem Po CreatedLineItemPartially PoCreatedLineItemNewLine ItemStatusAction
CreatedDate ); $PODate = $Pdt->format('d-m-Y'); echo $PODate ?> - ReqNo ?>ReqType ?>TotalNoofLineItems ?>PolineItems ?>PartilallyLineItems ?> newLineItem ?>ReqNo ?>ReqType ?>TotalNoofLineItems ?>PolineItems ?>PartilallyLineItems ?> newLineItem ?>StatusName ?>    
    + +
- - - - - - - - - + + + + + + + + + @@ -610,15 +610,15 @@ console.log(parsedData); $("#pendingQuantityHeader").css("display", "table-cell"); trIGRHTML += '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + '' + '' + '' + @@ -641,14 +641,14 @@ console.log(parsedData); } else { $("#pendingQuantityHeader").css("display", "none"); trIGRHTML += '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + '' + '' + '' +
SNoItem CodeItem DescriptionUOMOrdred QtyReceived QtyRemarksSNoItem CodeItem DescriptionUOMOrdered QtyReceived QtyRemarks
' + i + '' + item.MaterialCode + '' + item.MaterialName + '' + item.UOM + '' + parseInt(item.Quantity) + '' + parseInt(item.Quantity - item.QuantityAsPerInvoice) + ' ' + i + '' + item.MaterialCode + '' + item.MaterialName + '' + item.UOM + '' + parseInt(item.Quantity) + '' + parseInt(item.Quantity - item.QuantityAsPerInvoice) + '
' + i + '' + item.MaterialCode + '' + item.MaterialName + '' + item.UOM + '' + item.Quantity + '' + item.QuantityAsPerInvoice + '' + item.Remarks + ' ' + i + '' + item.MaterialCode + '' + item.MaterialName + '' + item.UOM + '' + item.Quantity + '' + item.QuantityAsPerInvoice + '' + item.Remarks + '