From af50cca1bcfb2041cb0a7c5481e983d9bdcf9ade Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 30 Jul 2024 09:42:23 +0000 Subject: [PATCH] FIX_Normal Renenuepo File --- app/Controllers/Purchaseorder.php | 40 ++++++++++++++++++++++++-- app/Models/Purchaseorder_model.php | 7 ++++- app/Views/editRevenuepurchaseorder.php | 21 ++++++++++++-- app/Views/purchaseorder.php | 25 +++++++++------- 4 files changed, 77 insertions(+), 16 deletions(-) diff --git a/app/Controllers/Purchaseorder.php b/app/Controllers/Purchaseorder.php index 778cf207..d93724fb 100644 --- a/app/Controllers/Purchaseorder.php +++ b/app/Controllers/Purchaseorder.php @@ -1096,14 +1096,34 @@ $mpdf->use_kwt = true; $Local_Interstate = $this->request->getPost('Range'); $Qualitycheck = 1; $IsOpenOrder = ($this->request->getPost('IsOpenOrder') !== null && !empty($this->request->getPost('IsOpenOrder')) && $this->request->getPost('IsOpenOrder') === '1') ? $this->request->getPost('IsOpenOrder') : null; + + + $file = $this->request->getFile('POFile'); + $requestfilename = $file->getName(); + if (!empty($requestfilename)) { + + if ($file->isValid() && !$file->hasMoved()) { + $path = ROOTPATH.'public/uploads/POfiles/'; + if(!is_dir($path)) { mkdir($path, 0777, true); } + if (!empty($this->purchaseorder_model->isFileExists($requestfilename))) { + log_message('error', 'File already exists in the database'.$requestfilename); + $requestfilename = ""; + } + else{ + $file->move($path, $requestfilename); + } + }else{ + $requestfilename = ""; + } + + } // Generate PO Number $lastPONO = $this->purchaseorder_model->lastPONO(); $newPONO = generate_po_number($lastPONO); log_message('debug', 'newPONO returned: ' . $newPONO); - // PO Master - $POList = array('PONO'=>$newPONO,'SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrderValueSummary, 'PODate' => $PODate, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'Status' => $POStatus, 'PORange' => $Local_Interstate, 'ServiceDescription' => $SpcialInstruction, 'CreatedBy' => $CreateBy, 'DeliveryAddress' => $DeliveryAddr, 'DeliveryDate' => $Deliverydt, 'CreatedDate' => $createddt, 'PaymentTerms' => $PaymentTerms, 'POType' => $POType, 'CapitalRange' => $Local_Interstate, 'PaymentOtherDescription' => $OtherPayment, 'Supplier_Reference' => $supplierreference, 'Mode_Of_Shipment' => $Modeofshipment, 'Supplier_Offer_No' => $supplieroffno, 'Other_Reference' => $otherreference, 'Fincap' => $fincap, 'InsuranceStatus' => $insurancestatus, 'POSubType' => $revenuetype, 'InsuranceNumber' => $InsuranceNumber, 'IsQualityChkReqired' => $Qualitycheck, 'BudgetType' => $BudgetType,'IsOpenOrder'=>$IsOpenOrder); + $POList = array('PONO'=>$newPONO,'SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrderValueSummary, 'PODate' => $PODate, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'Status' => $POStatus, 'PORange' => $Local_Interstate, 'ServiceDescription' => $SpcialInstruction, 'CreatedBy' => $CreateBy, 'DeliveryAddress' => $DeliveryAddr, 'DeliveryDate' => $Deliverydt, 'CreatedDate' => $createddt, 'PaymentTerms' => $PaymentTerms, 'POType' => $POType, 'CapitalRange' => $Local_Interstate, 'PaymentOtherDescription' => $OtherPayment, 'Supplier_Reference' => $supplierreference, 'Mode_Of_Shipment' => $Modeofshipment, 'Supplier_Offer_No' => $supplieroffno, 'Other_Reference' => $otherreference, 'Fincap' => $fincap, 'InsuranceStatus' => $insurancestatus, 'POSubType' => $revenuetype, 'InsuranceNumber' => $InsuranceNumber, 'IsQualityChkReqired' => $Qualitycheck, 'BudgetType' => $BudgetType,'IsOpenOrder'=>$IsOpenOrder,'POFile'=>$requestfilename); $POMaster = $this->purchaseorder_model->addPOMaster($POList, $POType, $revenuetype); $PONO = ''; if (count($POMaster) > 0) { @@ -1260,6 +1280,22 @@ $mpdf->use_kwt = true; $POList['ReleasedOn'] = get_current_date_time(); $POList['ReleasedBy'] = $this->session->get('userId'); } + $file = $this->request->getFile('POFile'); + $requestfilename = $file->getName(); + if (!empty($requestfilename)) { + if ($file && $file->isValid() && !$file->hasMoved()) { + $path = ROOTPATH.'public/uploads/POfiles/'; + if(!is_dir($path)) { mkdir($path, 0777, true); } + if (!empty($this->purchaseorder_model->isFileExists($requestfilename))) { + log_message('error', 'File already exists in the database'.$requestfilename); + } + else{ + $file->move($path, $requestfilename); + $POList['POFile'] = $requestfilename; + } + } + } + $POMaster = $this->purchaseorder_model->updatePOMaster($PONO, $POList); diff --git a/app/Models/Purchaseorder_model.php b/app/Models/Purchaseorder_model.php index f5a6fde4..72b9f3ca 100644 --- a/app/Models/Purchaseorder_model.php +++ b/app/Models/Purchaseorder_model.php @@ -140,7 +140,12 @@ Where IGRM.PONO = ? '; return $query->getResult(); } ///////////////////end this function used to pono reset financeyear configuration - + public function isFileExists($filename) + { + $result = $this->db->table('t_purchaseorder_master')->where('POFile', $filename); + $query = $result->get(); + return $query->getResult(); + } diff --git a/app/Views/editRevenuepurchaseorder.php b/app/Views/editRevenuepurchaseorder.php index 23474c45..3912d363 100644 --- a/app/Views/editRevenuepurchaseorder.php +++ b/app/Views/editRevenuepurchaseorder.php @@ -59,6 +59,8 @@ $ServiceDescription = ''; $CapitalRange = ''; $otherPayment = ''; $BudgetType = ''; +$PrePOFile = ''; + if (!empty($POMaster)) { //print_r($POMaster); //print_r($POItem); @@ -100,7 +102,7 @@ if (!empty($POMaster)) { $insurenceno = $Req->InsuranceNumber; $BudgetType = $Req->BudgetType; $IGRNO = $Req->IGRNO; - + $PrePOFile = $Req->POFile; // echo $otherPayment; } } @@ -3935,6 +3937,13 @@ if (!empty($getlogpodtl)) {

+
+ + + + +
+
@@ -4796,11 +4805,14 @@ if (!empty($getlogpodtl)) { $('#insurance').focus(); return false; } else { + var formData = new FormData($('.CreatePO')[0]); $('#content').loader('show'); $.ajax({ - data: $('.CreatePO').serialize(), type: "POST", url: "purchaseorder/EditRevenuePurchaseOrder", + data: formData, + processData: false, + contentType: false, success: function(data) { if (data) { $('#content').loader('hide'); @@ -4817,7 +4829,10 @@ if (!empty($getlogpodtl)) { alert("Error"); } - } + },error: function(jqXHR, textStatus, errorThrown) { + console.error("AJAX Error: " + textStatus + ": " + errorThrown); + alert("Error: " + textStatus); + } }); } diff --git a/app/Views/purchaseorder.php b/app/Views/purchaseorder.php index 75b4f3aa..4571bc30 100644 --- a/app/Views/purchaseorder.php +++ b/app/Views/purchaseorder.php @@ -1821,10 +1821,9 @@ if (!empty($INRSYMBOL)) {
'form-label-left CreatePO ', 'name' => 'CreatePO', 'id' => 'CreatePO'); + $attributes = array('class' => 'form-label-left CreatePO ', 'name' => 'CreatePO', 'id' => 'CreatePO','enctype' => 'multipart/form-data'); echo form_open(base_url() . '/purchaseorder/addPO/', $attributes); ?> -
@@ -2109,7 +2108,10 @@ if (!empty($INRSYMBOL)) {
- +
+
+
+
- -
- -
@@ -2297,7 +2295,7 @@ if (!empty($INRSYMBOL)) {
-
+
@@ -3206,6 +3204,7 @@ if (!empty($INRSYMBOL)) {

+
@@ -3917,12 +3916,15 @@ if (!empty($INRSYMBOL)) { } else { + var formData = new FormData($('.CreatePO')[0]); $('#content').loader('show'); $.ajax({ - data: $('.CreatePO').serialize(), type: "POST", url: "purchaseorder/addNewPurchaseOrder", + data: formData, + processData: false, + contentType: false, success: function(data) { if (data) { $('#content').loader('hide'); @@ -3937,7 +3939,10 @@ if (!empty($INRSYMBOL)) { alert("Error"); } - } + },error: function(jqXHR, textStatus, errorThrown) { + console.error("AJAX Error: " + textStatus + ": " + errorThrown); + alert("Error: " + textStatus); + } }); }