diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 30f04bf9..124541b9 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -16,6 +16,7 @@ $routes->add('loginMe', 'Login::loginMe'); $routes->get('logout', 'User::logout'); $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'loadChangePass', 'User::loadChangePass'); $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'changePassword', 'User::changePassword'); +$routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'userChangePassword', 'User::userChangePassword'); $routes->match(['GET', 'POST', 'PUT', 'DELETE'],'pageNotFound', 'User::pageNotFound'); $routes->match(['GET', 'POST', 'PUT', 'DELETE'],'checkEmailExists', 'User::checkEmailExists'); $routes->match(['GET', 'POST', 'PUT', 'DELETE'],'forgotPassword', 'Login::forgotPassword'); diff --git a/app/Controllers/Configurationctrl.php b/app/Controllers/Configurationctrl.php index a67b2275..51a7b3eb 100644 --- a/app/Controllers/Configurationctrl.php +++ b/app/Controllers/Configurationctrl.php @@ -61,6 +61,8 @@ class Configurationctrl extends BaseController function saveconfig() { + // echo "
";
+		// dd($this->request->getPost());
 		$ConfigName = $this->request->getPost('configurationname');
 		$Rowcount =  $this->request->getPost('txtRowCount');
 		$Comments = $this->request->getPost('Comments');
@@ -90,14 +92,15 @@ class Configurationctrl extends BaseController
 		$data['child'] = $this->configmodel->GetConfigCenterDetails($ConfigID);
 		
 		$this->global['pageTitle'] = 'Edit Config';
-		
+		// echo "
";
+		// print_r($data);die;
 		$this->loadViews("editconfig", $this->global, $data, NULL);
 	
 	}
 
 	function updateconfig()
 	{
-		
+		// dd($this->request->getPost());
 		$ConfigId = $this->request->getPost('ConfigId');
 		$ConfigName = $this->request->getPost('ConfigName');
 		$Comments = $this->request->getPost('Remarks');
diff --git a/app/Controllers/Expense.php b/app/Controllers/Expense.php
index 64c0d7ab..ce09ab38 100644
--- a/app/Controllers/Expense.php
+++ b/app/Controllers/Expense.php
@@ -46,11 +46,12 @@ class Expense extends BaseController
             'transporter_file' => $fileName,
             'supplier_id' => $this->request->getPost('supplierid'),
             'remarks' => $this->request->getPost('remarks'),
+            'item_description' => $this->request->getPost('item_description'),
             'cost' => $this->request->getPost('cost'),
-            'gst' => $this->request->getPost('gst'),
-            'total' => (int)$this->request->getPost('gst') + (int)$this->request->getPost('cost'),
-            'status' => $status,
-            'payment_method' => $paymentMethod
+            'cgst' => $this->request->getPost('cgst'),
+            'sgst' => $this->request->getPost('sgst'),
+            'igst' => $this->request->getPost('igst'),
+            'total' => $this->request->getPost('total'),
         ];
 
         $insert_id = $this->expense_model->insertExpense($data);
@@ -92,16 +93,16 @@ class Expense extends BaseController
         $data = [
             'supplier_id' => $this->request->getPost('supplierid'),
             'remarks' => $this->request->getPost('remarks'),
+            'item_description' => $this->request->getPost('item_description'),
             'cost' => $this->request->getPost('cost'),
-            'gst' => $this->request->getPost('gst'),
-            'total' => (int)$this->request->getPost('gst') + (int)$this->request->getPost('cost'),
-            'status' => $status,
-            'payment_method' => $paymentMethod
+            'cgst' => $this->request->getPost('cgst'),
+            'sgst' => $this->request->getPost('sgst'),
+            'igst' => $this->request->getPost('igst'),
+            'total' => $this->request->getPost('total'),
         ];
         if(!empty($fileName)){
             $data['transporter_file'] = $fileName;
         }
-            $data['payment_method'] = $this->request->getPost('payment_method');
        
 
         if ($id) {
diff --git a/app/Controllers/Purchaseorder.php b/app/Controllers/Purchaseorder.php
index d25e7e54..83c8101b 100644
--- a/app/Controllers/Purchaseorder.php
+++ b/app/Controllers/Purchaseorder.php
@@ -291,7 +291,7 @@ class Purchaseorder extends BaseController
   {
     $PONO =  $this->request->getVar('PONO');
 
-  
+
     $ReqType =  $this->request->getVar('ReqType');
 
     if ($ReqType == SERVICE) {
@@ -325,7 +325,7 @@ class Purchaseorder extends BaseController
       $data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetailsForPDF($PONO);
     } else if ($ReqType == CAPITAL) {
       $data['POItem'] = $this->purchaseorder_model->GetCapitalPurchaseOrderDetailsForPDF($PONO);
-    }    
+    }
     // print_r($data['POItem']);die;
     $data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO);
     $data['CurrencySymbol'] = $this->purchaseorder_model->GerCurrencyCodeName('INR');
@@ -345,37 +345,39 @@ class Purchaseorder extends BaseController
 
     $data['TotalAmountInWords'] = $this->convertNumber($totalAmt);
     $data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO);
-// echo '
';
-// print_r($data);
-// echo '
'; -// die; - $mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', - 'format' => 'A4', - 'default_font' => 'sans-serif', - 'margin_header' => 0, - 'margin_top' => -30, - 'margin_right' => 14, - 'margin_left' => 5, - 'margin_footer' => -30, - 'orientation' => 'P']); + // echo '
';
+    // print_r($data);
+    // echo '
'; + // die; + $mpdf = new \Mpdf\Mpdf([ + 'mode' => 'utf-8', + 'format' => 'A4', + 'default_font' => 'sans-serif', + 'margin_header' => 0, + 'margin_top' => -30, + 'margin_right' => 14, + 'margin_left' => 5, + 'margin_footer' => -30, + 'orientation' => 'P' + ]); // Set PDF properties $mpdf->SetTitle('Invoice'); $mpdf->SetAuthor($data['CompanyDetails'][0]->CompanyName); $mpdf->SetCreator('Venba'); - + // Generate the PDF content (HTML) // if ($PoStatus == PO_RELEASED || $PoStatus == PO_SERVICE_COMPLETED || $PoStatus == MRIR_APPROVED || $PoStatus == MRIR_REJECTED || $PoStatus == IGR_CREATED || $PoStatus == '' || $PoStatus == SPECIAL_PO) { // $mpdf->SetWatermarkText(''); // } else { // $mpdf->SetWatermarkText('DRAFT'); // } - - + + // Set auto margins $mpdf->setAutoTopMargin = 'stretch'; $mpdf->setAutoBottomMargin = 'stretch'; -$mpdf->use_kwt = true; + $mpdf->use_kwt = true; // Set HTML header // $HtmlHeading = view('includes/pdfheader', $data); // $mpdf->SetHTMLHeader($HtmlHeading); @@ -394,7 +396,7 @@ $mpdf->use_kwt = true; // Output PDF $mpdf->Output('POReport' . $PONO . '.pdf', 'D'); } - public function poprint2($PONO,$ReqType) + public function poprint2($PONO, $ReqType) { // Load all views as normal @@ -405,21 +407,21 @@ $mpdf->use_kwt = true; $Depcode = ''; $Currencycode = ''; $PoStatus = ''; - $PaiseVal = ''; + $PaiseVal = ''; $SymbolCurrency = ''; $SymbolCurrencyName = ''; $TotalOrderValue = 0.00; - $AdvanceAmount = 0.00; + $AdvanceAmount = 0.00; $ProductPrice = ''; $TotaltoPay = 0.00; $data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO); - + $data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO); $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformationforPDF(); - + $data['GetPoFormat'] = $this->purchaseorder_model->GetPoFormat($PONO); $data['DEPCODE'] = $this->purchaseorder_model->GerRequesterDep($Depcode); @@ -429,19 +431,19 @@ $mpdf->use_kwt = true; $data['CurrencySymbol'] = $this->purchaseorder_model->GerCurrencyCodeName($Currencycode); $data['Requestername'] = $this->purchaseorder_model->GerRequesterName($Requester); - - -// print_r($data['POItem']);die; + + + // print_r($data['POItem']);die; $CapitalRange = 1; - - + + if (!empty($data['CurrencySymbol']) > 0) { $SymbolCurrency = $data['CurrencySymbol'][0]->FontCode2000; $SymbolCurrencyName = $data['CurrencySymbol'][0]->Currency; $PaiseVal = $data['CurrencySymbol'][0]->PaiseVal; } - + if (!empty($data['POItem'])) { foreach ($data['POItem'] as $POI) { $Currencycode = $POI->CurrencyType; @@ -450,8 +452,6 @@ $mpdf->use_kwt = true; $TotalOrderValue = $POI->TotalOrderValue; $PoStatus = $POI->Status; $Requester = isset($POI->Requestedby) ? $POI->Requestedby : ""; - - } } @@ -463,34 +463,36 @@ $mpdf->use_kwt = true; $Depcode = $ReqDep->Departmentcode; } - - $mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', - 'format' => 'A4', - 'default_font' => 'sans-serif', - 'margin_header' => 0, - 'margin_top' => -30, - 'margin_right' => 14, - 'margin_left' => 5, - 'margin_footer' => -30, - 'orientation' => 'P']); + + $mpdf = new \Mpdf\Mpdf([ + 'mode' => 'utf-8', + 'format' => 'A4', + 'default_font' => 'sans-serif', + 'margin_header' => 0, + 'margin_top' => -30, + 'margin_right' => 14, + 'margin_left' => 5, + 'margin_footer' => -30, + 'orientation' => 'P' + ]); // Set PDF properties $mpdf->SetTitle('Invoice'); $mpdf->SetAuthor($data['CompanyDetails'][0]->CompanyName); $mpdf->SetCreator('Venba'); - + // Generate the PDF content (HTML) // if ($PoStatus == PO_RELEASED || $PoStatus == PO_SERVICE_COMPLETED || $PoStatus == MRIR_APPROVED || $PoStatus == MRIR_REJECTED || $PoStatus == IGR_CREATED || $PoStatus == '' || $PoStatus == SPECIAL_PO) { // $mpdf->SetWatermarkText(''); // } else { // $mpdf->SetWatermarkText('DRAFT'); // } - - + + // Set auto margins $mpdf->setAutoTopMargin = 'stretch'; $mpdf->setAutoBottomMargin = 'stretch'; @@ -511,7 +513,7 @@ $mpdf->use_kwt = true; // $mpdf->setFooter('' . "Page {PAGENO} of {nb}"); // Output PDF - $mpdf->Output($ReqType.'_' . $PONO . '.pdf', 'D'); + $mpdf->Output($ReqType . '_' . $PONO . '.pdf', 'D'); } @@ -538,12 +540,12 @@ $mpdf->use_kwt = true; function EditPurchaseOrder() { - + $PONO = $this->request->getVar('PONO'); $ReqType = $this->request->getVar('ReqType'); $Req = $this->purchaseorder_model->getRequistionNoFromPO($PONO); - + $data['ReqList'] = $Req; $result = array(); @@ -620,14 +622,14 @@ $mpdf->use_kwt = true; if ($ReqType == SERVICE) { $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetails($PONO); -// print_r($data['POItem']);die; + // print_r($data['POItem']);die; $data['getdata'] = $this->purchaseorder_model->getfunction($PONO); //$data['billfile'] = $this->purchaseorder_model->getbillfiesr($pono); //s print_r($data['getdata']); $data['getlogpodtl'] = $this->purchaseorder_model->getlogpodtl($PONO); - + $data['PaymentTerms'] = $this->purchaseorder_model->GetPaymentTerms($PONO); //$data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); @@ -1062,151 +1064,151 @@ $mpdf->use_kwt = true; //This used to Create Revenue Purchase Order function addNewPurchaseOrder() { - try { - // Extract POST data - $POdt = $this->request->getPost('PODate'); - $PODate = get_date_time_format($POdt); - $SupplierID = $this->request->getPost('drpSupplier'); - $DeliveryAddr = $this->request->getPost('DeliveryAddr'); - $dt = $this->request->getPost('Deliverydt'); - $POType = $this->request->getPost('POType'); - $DeliveryOption = $this->request->getPost('DateRange'); - if ($DeliveryOption == 1) { - $Deliverydt = ''; - $DeliverySchedule = $this->request->getPost('Scheduleby'); - } else { - $Deliverydt = get_date_time_format($dt); - $DeliverySchedule = ''; - } - $BudgetType = $this->request->getPost('Budget'); - $Modeofshipment = $this->request->getPost('addmodeofshipment'); - $supplierreference = $this->request->getPost('addsupplierreference'); - $supplieroffno = $this->request->getPost('addsupplierofferno'); - $otherreference = $this->request->getPost('addotherreference'); - $fincap = "";//$this->request->getPost('addfincap'); - $revenuetype = $this->request->getPost('PoTypeOptions'); - $insurancestatus = $this->request->getPost('insurance'); - $InsuranceNumber = ($insurancestatus == 1) ? $this->request->getPost('InsuranceNumber') : ''; - $SpcialInstruction = $this->request->getPost('SpcialInstruction'); - $TotalOrderValueSummary = $this->request->getPost('txtTotalOrderValueSummary'); - $POStatus = $this->request->getPost('txtStatus'); - $CreateBy = $this->session->get('userId'); - $RowCount = $this->request->getPost('txtRowCount'); - $DeletedRow = $this->request->getPost('txtDeletedRow'); - $comma_separated = ($DeletedRow !== null && is_string($DeletedRow)) ? explode(':', $DeletedRow) : []; - $createddt = get_current_date_time(); - $PaymentTerms = $this->request->getPost('PaymentTerms'); - $OtherPayment = $this->request->getPost('Otherpayment'); - $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 = NULL; - if (!empty($file)) { - if ($file->isValid() && !$file->hasMoved()) { - $requestfilename = $file->getName(); - $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,'POFile'=>$requestfilename); - $POMaster = $this->purchaseorder_model->addPOMaster($POList, $POType, $revenuetype); - $PONO = ''; - if (count($POMaster) > 0) { - $PONO = $POMaster[0]['PONO']; - } else { - throw new \Exception('Error occurred while creating PO Master'); - } - log_message('error', 'CTRL PONO : ' . $PONO); - - // PO Line Items - $LineItemStatus = REQITEM_NEW; - - for ($i = 1; $i <= $RowCount; $i++) { - $MaterialCode = $this->request->getPost('materialCode' . $i); - $Quantity = $this->request->getPost('quantity' . $i); - $Reqnumber = $this->request->getPost('Reqnumber' . $i); - $itemRate = $this->request->getPost('itemRate' . $i); - $per = $this->request->getPost('per' . $i); - - $DiscountType = $this->request->getPost('DisType' . $i); - $DiscountValue = $this->request->getPost('DisVal' . $i); - $AfterDiscount = $this->request->getPost('AfterDisVal' . $i); - $PackagingOption = $this->request->getPost('PackOption' . $i); - $PackagingType = $this->request->getPost('PackType' . $i); - $PackagingValue = $this->request->getPost('PackVal' . $i); - $AfterPackagingValue = $this->request->getPost('AfterPackVal' . $i); - - $FreightType = $this->request->getPost('FreightType' . $i); - $FreightValue = $this->request->getPost('FreightVal' . $i); - $AfterFreightValue = $this->request->getPost('AfterFreightVal' . $i); - $NOOfTrip = $this->request->getPost('NoOfTrip' . $i); - $InsuranceValue = $this->request->getPost('Insval' . $i); - $TotalOrderValue = $this->request->getPost('TotalOrderValue' . $i); - $revenuedescription = $this->request->getPost('Service_Description' . $i); - $CostCenter = $this->request->getPost('costCode' . $i); - $Cgst = $this->request->getPost('RevenueCgst' . $i); - $Sgst = $this->request->getPost('RevenueSgst' . $i); - $Igst = $this->request->getPost('RevenueIgst' . $i); - $AfterCgst = $this->request->getPost('RevenueAfterCgst' . $i); - $AfterSgst = $this->request->getPost('RevenueAfterSgst' . $i); - $AfterIgst = $this->request->getPost('RevenueAfterIgst' . $i); - - $SkipInsert = "False"; - if (count($comma_separated) > 0) { - for ($j = 1; $j < count($comma_separated); $j++) { - $deletedRow = $comma_separated[$j]; - if ($deletedRow == $i) { - $SkipInsert = "True"; - break; - } - } - } - if ($SkipInsert == "False") { - - $POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Per' => $per, 'ServiceMaterialDescription' => $revenuedescription, 'Status' => $LineItemStatus, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CostCenterCode' => $CostCenter); - $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); - $LineItemNo = ''; - if (count($POLineItem) > 0) { - $LineItemNo = $POLineItem[0]['LineItemNo']; - } else { - throw new \Exception('Error occurred while creating PO Line Item'); - } - - if (trim((string)$POType) == REVENUE) { - $RevenueTaxList = array('LineItemNo' => $LineItemNo, 'DiscountType' => $DiscountType, 'DiscountValue' => $DiscountValue, 'AfterDiscount' => $AfterDiscount, 'PackagingType' => $PackagingType, 'PackagingValue' => $PackagingValue, 'PackagingCalulatedOn' => $PackagingOption, 'AfterPackagingValue' => $AfterPackagingValue, 'FreightType' => $FreightType, 'FreightValue' => $FreightValue, 'AfterFreightValue' => $AfterFreightValue, 'Insurance' => $InsuranceValue, 'TotalValue' => $TotalOrderValue, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CGST' => $Cgst, 'AfterCGST' => $AfterCgst, 'SGST' => $Sgst, 'AfterSGST' => $AfterSgst, 'IGST' => $Igst, 'AfterIGST' => $AfterIgst, 'NoOfTrip' => $NOOfTrip); - $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); - if (!$RevenueList) { - throw new \Exception('Error occurred while creating Revenue Tax'); - } - } - } - } - echo 'Purchase Order Created Successfully! PO Number Is: ' . $PONO; - } catch (\Exception $e) { - log_message('error', 'Exception occurred: ' . $e->getMessage()); - echo 'An error occurred while creating the purchase order. Please try again.'; + try { + // Extract POST data + $POdt = $this->request->getPost('PODate'); + $PODate = get_date_time_format($POdt); + $SupplierID = $this->request->getPost('drpSupplier'); + $DeliveryAddr = $this->request->getPost('DeliveryAddr'); + $dt = $this->request->getPost('Deliverydt'); + $POType = $this->request->getPost('POType'); + $DeliveryOption = $this->request->getPost('DateRange'); + if ($DeliveryOption == 1) { + $Deliverydt = ''; + $DeliverySchedule = $this->request->getPost('Scheduleby'); + } else { + $Deliverydt = get_date_time_format($dt); + $DeliverySchedule = ''; } + $BudgetType = $this->request->getPost('Budget'); + $Modeofshipment = $this->request->getPost('addmodeofshipment'); + $supplierreference = $this->request->getPost('addsupplierreference'); + $supplieroffno = $this->request->getPost('addsupplierofferno'); + $otherreference = $this->request->getPost('addotherreference'); + $fincap = ""; //$this->request->getPost('addfincap'); + $revenuetype = $this->request->getPost('PoTypeOptions'); + $insurancestatus = $this->request->getPost('insurance'); + $InsuranceNumber = ($insurancestatus == 1) ? $this->request->getPost('InsuranceNumber') : ''; + $SpcialInstruction = $this->request->getPost('SpcialInstruction'); + $TotalOrderValueSummary = $this->request->getPost('txtTotalOrderValueSummary'); + $POStatus = $this->request->getPost('txtStatus'); + $CreateBy = $this->session->get('userId'); + $RowCount = $this->request->getPost('txtRowCount'); + $DeletedRow = $this->request->getPost('txtDeletedRow'); + $comma_separated = ($DeletedRow !== null && is_string($DeletedRow)) ? explode(':', $DeletedRow) : []; + $createddt = get_current_date_time(); + $PaymentTerms = $this->request->getPost('PaymentTerms'); + $OtherPayment = $this->request->getPost('Otherpayment'); + $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 = NULL; + if (!empty($file)) { + if ($file->isValid() && !$file->hasMoved()) { + $requestfilename = $file->getName(); + $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, 'POFile' => $requestfilename); + $POMaster = $this->purchaseorder_model->addPOMaster($POList, $POType, $revenuetype); + $PONO = ''; + if (count($POMaster) > 0) { + $PONO = $POMaster[0]['PONO']; + } else { + throw new \Exception('Error occurred while creating PO Master'); + } + log_message('error', 'CTRL PONO : ' . $PONO); + + // PO Line Items + $LineItemStatus = REQITEM_NEW; + + for ($i = 1; $i <= $RowCount; $i++) { + $MaterialCode = $this->request->getPost('materialCode' . $i); + $Quantity = $this->request->getPost('quantity' . $i); + $Reqnumber = $this->request->getPost('Reqnumber' . $i); + $itemRate = $this->request->getPost('itemRate' . $i); + $per = $this->request->getPost('per' . $i); + + $DiscountType = $this->request->getPost('DisType' . $i); + $DiscountValue = $this->request->getPost('DisVal' . $i); + $AfterDiscount = $this->request->getPost('AfterDisVal' . $i); + $PackagingOption = $this->request->getPost('PackOption' . $i); + $PackagingType = $this->request->getPost('PackType' . $i); + $PackagingValue = $this->request->getPost('PackVal' . $i); + $AfterPackagingValue = $this->request->getPost('AfterPackVal' . $i); + + $FreightType = $this->request->getPost('FreightType' . $i); + $FreightValue = $this->request->getPost('FreightVal' . $i); + $AfterFreightValue = $this->request->getPost('AfterFreightVal' . $i); + $NOOfTrip = $this->request->getPost('NoOfTrip' . $i); + $InsuranceValue = $this->request->getPost('Insval' . $i); + $TotalOrderValue = $this->request->getPost('TotalOrderValue' . $i); + $revenuedescription = $this->request->getPost('Service_Description' . $i); + $CostCenter = $this->request->getPost('costCode' . $i); + $Cgst = $this->request->getPost('RevenueCgst' . $i); + $Sgst = $this->request->getPost('RevenueSgst' . $i); + $Igst = $this->request->getPost('RevenueIgst' . $i); + $AfterCgst = $this->request->getPost('RevenueAfterCgst' . $i); + $AfterSgst = $this->request->getPost('RevenueAfterSgst' . $i); + $AfterIgst = $this->request->getPost('RevenueAfterIgst' . $i); + + $SkipInsert = "False"; + if (count($comma_separated) > 0) { + for ($j = 1; $j < count($comma_separated); $j++) { + $deletedRow = $comma_separated[$j]; + if ($deletedRow == $i) { + $SkipInsert = "True"; + break; + } + } + } + if ($SkipInsert == "False") { + + $POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Per' => $per, 'ServiceMaterialDescription' => $revenuedescription, 'Status' => $LineItemStatus, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CostCenterCode' => $CostCenter); + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + $LineItemNo = ''; + if (count($POLineItem) > 0) { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } else { + throw new \Exception('Error occurred while creating PO Line Item'); + } + + if (trim((string)$POType) == REVENUE) { + $RevenueTaxList = array('LineItemNo' => $LineItemNo, 'DiscountType' => $DiscountType, 'DiscountValue' => $DiscountValue, 'AfterDiscount' => $AfterDiscount, 'PackagingType' => $PackagingType, 'PackagingValue' => $PackagingValue, 'PackagingCalulatedOn' => $PackagingOption, 'AfterPackagingValue' => $AfterPackagingValue, 'FreightType' => $FreightType, 'FreightValue' => $FreightValue, 'AfterFreightValue' => $AfterFreightValue, 'Insurance' => $InsuranceValue, 'TotalValue' => $TotalOrderValue, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CGST' => $Cgst, 'AfterCGST' => $AfterCgst, 'SGST' => $Sgst, 'AfterSGST' => $AfterSgst, 'IGST' => $Igst, 'AfterIGST' => $AfterIgst, 'NoOfTrip' => $NOOfTrip); + $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); + if (!$RevenueList) { + throw new \Exception('Error occurred while creating Revenue Tax'); + } + } + } + } + echo 'Purchase Order Created Successfully! PO Number Is: ' . $PONO; + } catch (\Exception $e) { + log_message('error', 'Exception occurred: ' . $e->getMessage()); + echo 'An error occurred while creating the purchase order. Please try again.'; + } } - + //This used to Edit the Revenue Purchase Order function EditRevenuePurchaseOrder() { @@ -1239,7 +1241,7 @@ $mpdf->use_kwt = true; $supplierreference = $this->request->getPost('editsupplierreference'); $supplieroffno = $this->request->getPost('editsupplierofferno'); $otherreference = $this->request->getPost('editotherreference'); - $fincap = "";// $this->request->getPost('editfincap'); + $fincap = ""; // $this->request->getPost('editfincap'); $revenuetype = $this->request->getPost('PoTypeOptions'); $insurancestatus = $this->request->getPost('insurancestatus'); if ($insurancestatus == 1) { @@ -1284,24 +1286,25 @@ $mpdf->use_kwt = true; $POList['ReleasedOn'] = get_current_date_time(); $POList['ReleasedBy'] = $this->session->get('userId'); } - $file = $this->request->getFile('POFile'); - $requestfilename = NULL; - if (!empty($file)) { - if ($file && $file->isValid() && !$file->hasMoved()) { - $requestfilename = $file->getName(); + $file = $this->request->getFile('POFile'); + $requestfilename = NULL; + if (!empty($file)) { + if ($file && $file->isValid() && !$file->hasMoved()) { + $requestfilename = $file->getName(); + + $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; + } + } + } - $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); @@ -1438,7 +1441,6 @@ $mpdf->use_kwt = true; if ($SkipInsert == "False") { if (strlen((string)$POLineItemNo) == 0) { - } else { $LineItemNo = $POLineItemNo; @@ -1449,7 +1451,6 @@ $mpdf->use_kwt = true; } $isExists = $this->purchaseorder_model->LineItemExistsinRevenueTax($LineItemNo); if (count($isExists) == 0) { - } else { $RevenueTaxList = array('DiscountType' => $DiscountType, 'DiscountValue' => $DiscountValue, 'AfterDiscount' => $AfterDiscount, 'PackagingType' => $PackagingType, 'PackagingValue' => $PackagingValue, 'PackagingCalulatedOn' => $PackagingOption, 'AfterPackagingValue' => $AfterPackagingValue, 'FreightType' => $FreightType, 'FreightValue' => $FreightValue, 'AfterFreightValue' => $AfterFreightValue, 'Insurance' => $InsuranceValue, 'TotalValue' => $TotalOrderValue, 'UpdateBY' => $updatedBy, 'UpdatedOn' => $updateddt, 'CGST' => $Cgst, 'AfterCGST' => $AfterCgst, 'SGST' => $Sgst, 'AfterSGST' => $AfterSgst, 'IGST' => $Igst, 'AfterIGST' => $AfterIgst, 'CreatedBy' => $updatedBy, 'NoOfTrip' => $NOOfTrip); @@ -1460,8 +1461,8 @@ $mpdf->use_kwt = true; echo 'Purchase Order Updated Successfully! PO Number Is: ' . $PONO; } - - + + public function revenuepoprint($PONO) { @@ -1531,10 +1532,10 @@ $mpdf->use_kwt = true; } else { $mpdf->SetWatermarkText('DRAFT'); } - - $WatermarkImage = base_url()."public/assets/images/mpdf.png"; + + $WatermarkImage = base_url() . "public/assets/images/mpdf.png"; $mpdf->SetWatermarkImage($WatermarkImage, 8, 10); - + $mpdf->showWatermarkImage = true; $mpdf->watermark_font = 'DejaVuSansCondensed'; $mpdf->showWatermarkText = true; @@ -1653,7 +1654,7 @@ $mpdf->use_kwt = true; // Output PDF $mpdf->Output('ServicePOReport' . $PONO . '.pdf', 'D'); } - + public function importpoprint($PONO) { // echo $PONO; @@ -1841,185 +1842,184 @@ $mpdf->use_kwt = true; function addNewImportPurchaseOrder() { - try { - $POdt = $this->request->getPost('PODate'); - $PODate = get_date_time_format($POdt); - $SupplierID = $this->request->getPost('drpSupplier'); - $DeliveryAddr = $this->request->getPost('DeliveryAddr'); - - $POType = $this->request->getPost('POType'); - $PoRange = $this->request->getPost('txtPoRange'); - - $DeliveryOption = $this->request->getPost('DateRange'); - - $DeliverySchedule = ''; - $Dispatch = ''; - if ($DeliveryOption == 1) { - $Dispatch = ''; - $DeliverySchedule = $this->request->getPost('Scheduleby'); - } else { - $Dispatch = $this->request->getPost('Dispatch'); - $DeliverySchedule = ''; - } - - $SpcialInstruction = $this->request->getPost('txtSpcialInstruction'); - $TotalOrder = $this->request->getPost('txtToatlOrder'); - $POStatus = $this->request->getVar('textStatus'); - - $BudgetType = $this->request->getPost('Budget'); - - $CreateBy = $this->session->get('userId'); - $RowCount = $this->request->getVar('txtRowCount'); - - $DeletedRow = $this->request->getVar('txtDeletedRow'); - $comma_separated = ($DeletedRow !== null && is_string($DeletedRow)) - ? explode(':', $DeletedRow) - : []; - - $createddt = get_current_date_time(); - $Exchangerate = $this->request->getPost('ExchangeRate'); - $Edt = $this->request->getPost('Exchangerateon'); - $ExchangeRateCalculatedon = get_date_time_format($Edt); - - $CurrencyType = $this->request->getPost('currencytype'); - - $PaymentTerms = $this->request->getPost('PaymentTerms'); - $OtherPayment = $this->request->getPost('Otherpayment'); - $Palaceoforigin = $this->request->getPost('PlaceOforigin'); - - $Shipmentmode = $this->request->getPost('addmodeofshipment'); - $SupplierRef = $this->request->getPost('addsupplierreference'); - $SupplierOffer = $this->request->getPost('addsupplierofferno'); - $otherRef = $this->request->getPost('addotherreference'); - $finCap = "";//$this->request->getPost('addfincap'); - - $importoption = $this->request->getPost('Importoption'); - $Insurance = $this->request->getPost('Insurance'); - - if ($Insurance == 1) { - $InsuranceNumber = $this->request->getPost('InsuranceNumber'); - } else { - $InsuranceNumber = ''; - } - - $Qualitycheck = 1; - $IsOpenOrder = ($this->request->getPost('IsOpenOrder') !== null && !empty($this->request->getPost('IsOpenOrder')) && $this->request->getPost('IsOpenOrder') === '1') ? $this->request->getPost('IsOpenOrder') : null; - - $lastPONO = $this->purchaseorder_model->lastPONO(); - $newPONO = generate_po_number($lastPONO); - $file = $this->request->getFile('POFile'); - $requestfilename = NULL; - if (!empty($file)) { - - if ($file->isValid() && !$file->hasMoved()) { - $requestfilename = $file->getName(); - $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 = ""; - } - - } + try { + $POdt = $this->request->getPost('PODate'); + $PODate = get_date_time_format($POdt); + $SupplierID = $this->request->getPost('drpSupplier'); + $DeliveryAddr = $this->request->getPost('DeliveryAddr'); - $POList = array('PONO' => $newPONO,'SupplierID' => $SupplierID,'TotalOrderValue' => $TotalOrder,'PODate' => $PODate,'Status' => $POStatus,'PORange' => $PoRange,'ServiceDescription' => $SpcialInstruction,'CreatedBy' => $CreateBy,'DeliveryAddress' => $DeliveryAddr,'Import_DispatchDetails' => $Dispatch,'CreatedDate' => $createddt,'DeliverySchedule' => $DeliverySchedule,'DeliveryOption' => $DeliveryOption,'ExchangeRate' => $Exchangerate,'ExchangeRateCalculatedon' => $ExchangeRateCalculatedon,'CurrencyType' => $CurrencyType,'PaymentTerms' => $PaymentTerms,'POType' => $POType,'Import_PlaceofOrgin' => $Palaceoforigin,'PaymentOtherDescription' => $OtherPayment,'Mode_Of_Shipment' => $Shipmentmode,'Supplier_Reference' => $SupplierRef,'Supplier_Offer_No' => $SupplierOffer,'Other_Reference' => $otherRef,'Fincap' => $finCap,'InsuranceStatus' => $Insurance,'InsuranceNumber' => $InsuranceNumber,'POSubType' => $importoption,'IsQualityChkReqired' => $Qualitycheck,'BudgetType' => $BudgetType,'IsOpenOrder' => $IsOpenOrder); - $POList['POFile'] = $requestfilename; - $POMaster = $this->purchaseorder_model->addPOMaster($POList, $POType, $importoption); - $PONO = ''; - if (count($POMaster) > 0) { - $PONO = $POMaster[0]['PONO']; - } else { - throw new \Exception('Error occurred while creating PO Master'); - } - - $LineItemStatus = REQITEM_NEW; - - for ($i = 1; $i <= $RowCount; $i++) { - $MaterialCode = $this->request->getPost('materialCode' . $i); - $Quantity = $this->request->getPost('quantity' . $i); - $Reqnumber = $this->request->getPost('Reqnumber' . $i); - $itemRate = $this->request->getPost('itemRate' . $i); - - $BasicPriceinmton = $this->request->getPost('BasicPriceinUS' . $i); - $Productprice = $this->request->getPost('BasicAmt' . $i); - $LandingCharge = $this->request->getPost('LandingChargee' . $i); - $AfterLandingCharge = $this->request->getPost('AfterLandingChargee' . $i); - $CustomDuty = $this->request->getPost('Customduty' . $i); - $AfterCustomDuty = $this->request->getPost('AfterCustomduty' . $i); - $CustomEd = $this->request->getPost('CustomEDcess' . $i); - $AfterCustomEd = $this->request->getPost('AfterCustomEDcess' . $i); - $CustomSH = $this->request->getPost('CustomSHcess' . $i); - $AfterCustomSH = $this->request->getPost('AfterCustomSHcess' . $i); - $Grossdutypayable = $this->request->getPost('Grossdutypayable' . $i); - $CustomDutyExpensesPerKG = $this->request->getPost('CustomDutyExpenses' . $i); - - $QuantityKG = $this->request->getPost('PurQuantity' . $i); - $Totalvalueitem = $this->request->getPost('TotalExp' . $i); - $CostCenter = $this->request->getPost('costCode' . $i); - $AssessableValue = $this->request->getPost('AfterAssessable' . $i); - $Subtotal = $this->request->getPost('Subtotal' . $i); - $Igst = $this->request->getPost('Igst' . $i); - $AfterIgst = $this->request->getPost('AfterIgst' . $i); - $Dutyimpact = $this->request->getPost('Dutyimpact' . $i); - $Clearingcharge = $this->request->getPost('ClearingCharges' . $i); - $Nettvalue = $this->request->getPost('Nett' . $i); - - $FreightType = $this->request->getPost('FreightType' . $i); - $nooftrip = $this->request->getPost('NoofTrip' . $i); - $Freightrate = $this->request->getPost('FreightRate' . $i); - $Freightamount = $this->request->getPost('AfterFreightRate' . $i); - - $specialinstruction = $this->request->getPost('Addinstruction' . $i); - $per = $this->request->getPost('Per' . $i); - - $SkipInsert = "False"; - if (count($comma_separated) > 0) { - for ($j = 1; $j < count($comma_separated); $j++) { - $deletedRow = $comma_separated[$j]; - - if ($deletedRow == $i) { - $SkipInsert = "True"; - break; - } - } - } - - if ($SkipInsert == "False") { - $POLineItemList = array('PONO' => $PONO,'ReqNo' => $Reqnumber,'MaterialCode' => $MaterialCode,'Quantity' => $Quantity,'Rate' => $itemRate,'Status' => $LineItemStatus,'CreatedBy' => $CreateBy,'CreatedDate' => $createddt,'CostCenterCode' => $CostCenter,'Per' => $per,'ServiceMaterialDescription' => $specialinstruction); - - $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); - - $LineItemNo = ''; - if (count($POLineItem) > 0) { - $LineItemNo = $POLineItem[0]['LineItemNo']; - } else { - throw new \Exception('Error occurred while creating PO Line Item'); - } - - if (trim((string)$POType) == IMPORT) { - $ImportTaxList = array('LineItemNo' => $LineItemNo,'BasicPriceInMTon' => $BasicPriceinmton,'ProductPrice' => $Productprice,'LandingCharge' => $LandingCharge,'AfterLandingCharge' => $AfterLandingCharge,'CustomDuty' => $CustomDuty,'AfterCustomDuty' => $AfterCustomDuty,'CustomEdCess' => $CustomEd,'CustomSHCess' => $CustomSH,'CreatedBy' => $CreateBy,'CreatedDate' => $createddt,'Grossdutypayable' => $Grossdutypayable,'CustomDutyExpensesPerKG' => $CustomDutyExpensesPerKG,'QuantityKG' => $QuantityKG,'AfterCustomSHCess' => $AfterCustomSH,'AfterCustomEdCess' => $AfterCustomEd,'TotalValue' => $Totalvalueitem,'FreightType' => $FreightType,'NoOfTrip' => $nooftrip,'FreightValue' => $Freightrate,'AfterFreightValue' => $Freightamount,'AssessableValue' => $AssessableValue,'SubTotal' => $Subtotal,'IGST' => $Igst,'AfterIGST' => $AfterIgst,'DutyImpact' => $Dutyimpact,'ClearingCharge' => $Clearingcharge,'NetValue' => $Nettvalue); - $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); - if (!$ImportList) { - throw new \Exception('Error occurred while creating Import Tax'); - } - } - } - } - - echo 'Purchase Order Created Successfully! PO Number Is: ' . $PONO; - } catch (\Exception $e) { - log_message('error', 'Exception occurred: ' . $e->getMessage()); - echo 'An error occurred while creating the purchase order. Please try again.'; + $POType = $this->request->getPost('POType'); + $PoRange = $this->request->getPost('txtPoRange'); + $DeliveryOption = $this->request->getPost('DateRange'); + + $DeliverySchedule = ''; + $Dispatch = ''; + if ($DeliveryOption == 1) { + $Dispatch = ''; + $DeliverySchedule = $this->request->getPost('Scheduleby'); + } else { + $Dispatch = $this->request->getPost('Dispatch'); + $DeliverySchedule = ''; } + + $SpcialInstruction = $this->request->getPost('txtSpcialInstruction'); + $TotalOrder = $this->request->getPost('txtToatlOrder'); + $POStatus = $this->request->getVar('textStatus'); + + $BudgetType = $this->request->getPost('Budget'); + + $CreateBy = $this->session->get('userId'); + $RowCount = $this->request->getVar('txtRowCount'); + + $DeletedRow = $this->request->getVar('txtDeletedRow'); + $comma_separated = ($DeletedRow !== null && is_string($DeletedRow)) + ? explode(':', $DeletedRow) + : []; + + $createddt = get_current_date_time(); + $Exchangerate = $this->request->getPost('ExchangeRate'); + $Edt = $this->request->getPost('Exchangerateon'); + $ExchangeRateCalculatedon = get_date_time_format($Edt); + + $CurrencyType = $this->request->getPost('currencytype'); + + $PaymentTerms = $this->request->getPost('PaymentTerms'); + $OtherPayment = $this->request->getPost('Otherpayment'); + $Palaceoforigin = $this->request->getPost('PlaceOforigin'); + + $Shipmentmode = $this->request->getPost('addmodeofshipment'); + $SupplierRef = $this->request->getPost('addsupplierreference'); + $SupplierOffer = $this->request->getPost('addsupplierofferno'); + $otherRef = $this->request->getPost('addotherreference'); + $finCap = ""; //$this->request->getPost('addfincap'); + + $importoption = $this->request->getPost('Importoption'); + $Insurance = $this->request->getPost('Insurance'); + + if ($Insurance == 1) { + $InsuranceNumber = $this->request->getPost('InsuranceNumber'); + } else { + $InsuranceNumber = ''; + } + + $Qualitycheck = 1; + $IsOpenOrder = ($this->request->getPost('IsOpenOrder') !== null && !empty($this->request->getPost('IsOpenOrder')) && $this->request->getPost('IsOpenOrder') === '1') ? $this->request->getPost('IsOpenOrder') : null; + + $lastPONO = $this->purchaseorder_model->lastPONO(); + $newPONO = generate_po_number($lastPONO); + $file = $this->request->getFile('POFile'); + $requestfilename = NULL; + if (!empty($file)) { + + if ($file->isValid() && !$file->hasMoved()) { + $requestfilename = $file->getName(); + $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 = ""; + } + } + + $POList = array('PONO' => $newPONO, 'SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrder, 'PODate' => $PODate, 'Status' => $POStatus, 'PORange' => $PoRange, 'ServiceDescription' => $SpcialInstruction, 'CreatedBy' => $CreateBy, 'DeliveryAddress' => $DeliveryAddr, 'Import_DispatchDetails' => $Dispatch, 'CreatedDate' => $createddt, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'ExchangeRate' => $Exchangerate, 'ExchangeRateCalculatedon' => $ExchangeRateCalculatedon, 'CurrencyType' => $CurrencyType, 'PaymentTerms' => $PaymentTerms, 'POType' => $POType, 'Import_PlaceofOrgin' => $Palaceoforigin, 'PaymentOtherDescription' => $OtherPayment, 'Mode_Of_Shipment' => $Shipmentmode, 'Supplier_Reference' => $SupplierRef, 'Supplier_Offer_No' => $SupplierOffer, 'Other_Reference' => $otherRef, 'Fincap' => $finCap, 'InsuranceStatus' => $Insurance, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $importoption, 'IsQualityChkReqired' => $Qualitycheck, 'BudgetType' => $BudgetType, 'IsOpenOrder' => $IsOpenOrder); + $POList['POFile'] = $requestfilename; + $POMaster = $this->purchaseorder_model->addPOMaster($POList, $POType, $importoption); + $PONO = ''; + if (count($POMaster) > 0) { + $PONO = $POMaster[0]['PONO']; + } else { + throw new \Exception('Error occurred while creating PO Master'); + } + + $LineItemStatus = REQITEM_NEW; + + for ($i = 1; $i <= $RowCount; $i++) { + $MaterialCode = $this->request->getPost('materialCode' . $i); + $Quantity = $this->request->getPost('quantity' . $i); + $Reqnumber = $this->request->getPost('Reqnumber' . $i); + $itemRate = $this->request->getPost('itemRate' . $i); + + $BasicPriceinmton = $this->request->getPost('BasicPriceinUS' . $i); + $Productprice = $this->request->getPost('BasicAmt' . $i); + $LandingCharge = $this->request->getPost('LandingChargee' . $i); + $AfterLandingCharge = $this->request->getPost('AfterLandingChargee' . $i); + $CustomDuty = $this->request->getPost('Customduty' . $i); + $AfterCustomDuty = $this->request->getPost('AfterCustomduty' . $i); + $CustomEd = $this->request->getPost('CustomEDcess' . $i); + $AfterCustomEd = $this->request->getPost('AfterCustomEDcess' . $i); + $CustomSH = $this->request->getPost('CustomSHcess' . $i); + $AfterCustomSH = $this->request->getPost('AfterCustomSHcess' . $i); + $Grossdutypayable = $this->request->getPost('Grossdutypayable' . $i); + $CustomDutyExpensesPerKG = $this->request->getPost('CustomDutyExpenses' . $i); + + $QuantityKG = $this->request->getPost('PurQuantity' . $i); + $Totalvalueitem = $this->request->getPost('TotalExp' . $i); + $CostCenter = $this->request->getPost('costCode' . $i); + $AssessableValue = $this->request->getPost('AfterAssessable' . $i); + $Subtotal = $this->request->getPost('Subtotal' . $i); + $Igst = $this->request->getPost('Igst' . $i); + $AfterIgst = $this->request->getPost('AfterIgst' . $i); + $Dutyimpact = $this->request->getPost('Dutyimpact' . $i); + $Clearingcharge = $this->request->getPost('ClearingCharges' . $i); + $Nettvalue = $this->request->getPost('Nett' . $i); + + $FreightType = $this->request->getPost('FreightType' . $i); + $nooftrip = $this->request->getPost('NoofTrip' . $i); + $Freightrate = $this->request->getPost('FreightRate' . $i); + $Freightamount = $this->request->getPost('AfterFreightRate' . $i); + + $specialinstruction = $this->request->getPost('Addinstruction' . $i); + $per = $this->request->getPost('Per' . $i); + + $SkipInsert = "False"; + if (count($comma_separated) > 0) { + for ($j = 1; $j < count($comma_separated); $j++) { + $deletedRow = $comma_separated[$j]; + + if ($deletedRow == $i) { + $SkipInsert = "True"; + break; + } + } + } + + if ($SkipInsert == "False") { + $POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CostCenterCode' => $CostCenter, 'Per' => $per, 'ServiceMaterialDescription' => $specialinstruction); + + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + + $LineItemNo = ''; + if (count($POLineItem) > 0) { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } else { + throw new \Exception('Error occurred while creating PO Line Item'); + } + + if (trim((string)$POType) == IMPORT) { + $ImportTaxList = array('LineItemNo' => $LineItemNo, 'BasicPriceInMTon' => $BasicPriceinmton, 'ProductPrice' => $Productprice, 'LandingCharge' => $LandingCharge, 'AfterLandingCharge' => $AfterLandingCharge, 'CustomDuty' => $CustomDuty, 'AfterCustomDuty' => $AfterCustomDuty, 'CustomEdCess' => $CustomEd, 'CustomSHCess' => $CustomSH, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'Grossdutypayable' => $Grossdutypayable, 'CustomDutyExpensesPerKG' => $CustomDutyExpensesPerKG, 'QuantityKG' => $QuantityKG, 'AfterCustomSHCess' => $AfterCustomSH, 'AfterCustomEdCess' => $AfterCustomEd, 'TotalValue' => $Totalvalueitem, 'FreightType' => $FreightType, 'NoOfTrip' => $nooftrip, 'FreightValue' => $Freightrate, 'AfterFreightValue' => $Freightamount, 'AssessableValue' => $AssessableValue, 'SubTotal' => $Subtotal, 'IGST' => $Igst, 'AfterIGST' => $AfterIgst, 'DutyImpact' => $Dutyimpact, 'ClearingCharge' => $Clearingcharge, 'NetValue' => $Nettvalue); + $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); + if (!$ImportList) { + throw new \Exception('Error occurred while creating Import Tax'); + } + } + } + } + + echo 'Purchase Order Created Successfully! PO Number Is: ' . $PONO; + } catch (\Exception $e) { + log_message('error', 'Exception occurred: ' . $e->getMessage()); + echo 'An error occurred while creating the purchase order. Please try again.'; + } } - + function EditImportPurchaseOrder() @@ -2102,7 +2102,7 @@ $mpdf->use_kwt = true; $SupplierRef = $this->request->getPost('editsupplierreference'); $SupplierOffer = $this->request->getPost('editsupplierofferno'); $otherRef = $this->request->getPost('editotherreference'); - $finCap = "";//$this->request->getPost('editfincap'); + $finCap = ""; //$this->request->getPost('editfincap'); @@ -2135,23 +2135,24 @@ $mpdf->use_kwt = true; $POList['ReleasedBy'] = $this->session->get('userId'); } $file = $this->request->getFile('POFile'); - $requestfilename = NULL; + $requestfilename = NULL; + + if (!empty($file)) { + if ($file && $file->isValid() && !$file->hasMoved()) { + $requestfilename = $file->getName(); + $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; + } + } + } - if (!empty($file)) { - if ($file && $file->isValid() && !$file->hasMoved()) { - $requestfilename = $file->getName(); - $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; - } - } - } - //echo $PONO; //echo $TotalOrder; //print_r($POList); @@ -2443,8 +2444,8 @@ $mpdf->use_kwt = true; $userID = $this->session->get('userId'); //print_r($data['Status']);echo "CON"; $appList = $this->purchaseorder_model->getPOList($q); - $filteredAppList = array_filter($appList, function($item) { - return $item->Status !== PO_DRAFT; + $filteredAppList = array_filter($appList, function ($item) { + return $item->Status !== PO_DRAFT; }); $data['AppList'] = $filteredAppList; $this->loadViews("porelease_view", $this->global, $data, NULL); @@ -2478,17 +2479,17 @@ $mpdf->use_kwt = true; function addNewCapitalPurchaseOrder() { -try{ - $POdt = $this->request->getPost('PODate'); - $PODate = get_date_time_format($POdt); - $SupplierID = $this->request->getPost('drpSupplier'); - $DeliveryAddr = $this->request->getPost('DeliveryAddr'); - $dt = $this->request->getPost('Deliverydate'); + try { + $POdt = $this->request->getPost('PODate'); + $PODate = get_date_time_format($POdt); + $SupplierID = $this->request->getPost('drpSupplier'); + $DeliveryAddr = $this->request->getPost('DeliveryAddr'); + $dt = $this->request->getPost('Deliverydate'); - $POType = $this->request->getPost('POType'); - $PoRange = $this->request->getPost('txtPoRange'); + $POType = $this->request->getPost('POType'); + $PoRange = $this->request->getPost('txtPoRange'); - /* $DeliveryOption = $this->request->getPost('DateRange'); + /* $DeliveryOption = $this->request->getPost('DateRange'); if($DeliveryOption==1){ $Deliverydt = ''; $DeliverySchedule = $this->request->getPost('Scheduleby'); @@ -2498,249 +2499,248 @@ try{ $DeliverySchedule = ''; } */ - $DeliveryOption = $this->request->getPost('DateRange'); + $DeliveryOption = $this->request->getPost('DateRange'); - $DeliverySchedule = ''; - $Dispatch = ''; - $Deliverydt = ''; - if ($DeliveryOption == 1) { + $DeliverySchedule = ''; $Dispatch = ''; $Deliverydt = ''; - $DeliverySchedule = $this->request->getPost('Scheduleby'); - } else if ($DeliveryOption == 2) { - $Deliverydt = ''; - $DeliverySchedule = ''; - $Dispatch = $this->request->getPost('Dispatch'); - } else { - $Dispatch = ''; - $DeliverySchedule = ''; - $Deliverydt = get_date_time_format($dt); - } - $capitalType = $this->request->getPost('capitalType'); - if ($capitalType == 'Domestic') { - $CapitalRange = '1'; - $ExchangeRateOn = ''; - $ExchangeRate = ''; - $Palaceoforigin = ''; - } else { + if ($DeliveryOption == 1) { + $Dispatch = ''; + $Deliverydt = ''; + $DeliverySchedule = $this->request->getPost('Scheduleby'); + } else if ($DeliveryOption == 2) { + $Deliverydt = ''; + $DeliverySchedule = ''; + $Dispatch = $this->request->getPost('Dispatch'); + } else { + $Dispatch = ''; + $DeliverySchedule = ''; + $Deliverydt = get_date_time_format($dt); + } + $capitalType = $this->request->getPost('capitalType'); + if ($capitalType == 'Domestic') { + $CapitalRange = '1'; + $ExchangeRateOn = ''; + $ExchangeRate = ''; + $Palaceoforigin = ''; + } else { - $CapitalRange = '0'; - $ExchangeRateBeforeFormat = $this->request->getPost('Exchangerateon'); - $ExchangeRateOn = get_date_time_format($ExchangeRateBeforeFormat); - $ExchangeRate = $this->request->getPost('ExchangeRt'); - $Palaceoforigin = $this->request->getPost('PlaceOforigin'); - } - $ModeOfShipment = $this->request->getPost('addmodeofshipment'); - $SupplierReference = $this->request->getPost('addsupplierreference'); - $SuppliersOfferNo = $this->request->getPost('addsupplierofferno'); - $OtherReferences = $this->request->getPost('addotherreference'); - $Fincap = "";//$this->request->getPost('addfincap'); - $InsuranceOptions = $this->request->getPost('insuranceStatus'); - $InsuranceNumber = $this->request->getPost('InsuranceNumber'); - $ServiceTypeOptions = $this->request->getPost('PoTypeOptions'); + $CapitalRange = '0'; + $ExchangeRateBeforeFormat = $this->request->getPost('Exchangerateon'); + $ExchangeRateOn = get_date_time_format($ExchangeRateBeforeFormat); + $ExchangeRate = $this->request->getPost('ExchangeRt'); + $Palaceoforigin = $this->request->getPost('PlaceOforigin'); + } + $ModeOfShipment = $this->request->getPost('addmodeofshipment'); + $SupplierReference = $this->request->getPost('addsupplierreference'); + $SuppliersOfferNo = $this->request->getPost('addsupplierofferno'); + $OtherReferences = $this->request->getPost('addotherreference'); + $Fincap = ""; //$this->request->getPost('addfincap'); + $InsuranceOptions = $this->request->getPost('insuranceStatus'); + $InsuranceNumber = $this->request->getPost('InsuranceNumber'); + $ServiceTypeOptions = $this->request->getPost('PoTypeOptions'); - $PaymentMethod = $this->request->getPost('PaymentMethod'); - $OtherPayment = $this->request->getPost('Otherpayment'); + $PaymentMethod = $this->request->getPost('PaymentMethod'); + $OtherPayment = $this->request->getPost('Otherpayment'); - $BudgetType = $this->request->getPost('Budget'); + $BudgetType = $this->request->getPost('Budget'); - $SpcialInstruction = $this->request->getPost('txtSpcialInstruction'); - $TotalOrder = $this->request->getPost('CapitalToatlOrder'); - $POStatus = $this->request->getPost('txtStatus'); + $SpcialInstruction = $this->request->getPost('txtSpcialInstruction'); + $TotalOrder = $this->request->getPost('CapitalToatlOrder'); + $POStatus = $this->request->getPost('txtStatus'); - $CreateBy = $this->session->get('userId'); - $RowCount = $this->request->getPost('txtRowCount'); - $DeletedRow = $this->request->getPost('txtDeletedRow'); - $comma_separated = ($DeletedRow !== null && is_string($DeletedRow)) - ? explode(':', $DeletedRow) - : []; + $CreateBy = $this->session->get('userId'); + $RowCount = $this->request->getPost('txtRowCount'); + $DeletedRow = $this->request->getPost('txtDeletedRow'); + $comma_separated = ($DeletedRow !== null && is_string($DeletedRow)) + ? explode(':', $DeletedRow) + : []; - $createddt = get_current_date_time(); - $currencytypeID = $this->request->getPost('currencytype'); + $createddt = get_current_date_time(); + $currencytypeID = $this->request->getPost('currencytype'); - $Qualitycheck = 1; + $Qualitycheck = 1; - $IsOpenOrder = ($this->request->getPost('IsOpenOrder') !== null && !empty($this->request->getPost('IsOpenOrder')) && $this->request->getPost('IsOpenOrder') === '1') ? $this->request->getPost('IsOpenOrder') : null; + $IsOpenOrder = ($this->request->getPost('IsOpenOrder') !== null && !empty($this->request->getPost('IsOpenOrder')) && $this->request->getPost('IsOpenOrder') === '1') ? $this->request->getPost('IsOpenOrder') : null; + + $lastPONO = $this->purchaseorder_model->lastPONO(); + $newPONO = generate_po_number($lastPONO); + $file = $this->request->getFile('POFile'); + $requestfilename = NULL; + if (!empty($file)) { - $lastPONO = $this->purchaseorder_model->lastPONO(); - $newPONO = generate_po_number($lastPONO); - $file = $this->request->getFile('POFile'); - $requestfilename = NULL; - if (!empty($file)) { - if ($file->isValid() && !$file->hasMoved()) { - $requestfilename = $file->getName(); - $path = ROOTPATH.'public/uploads/POfiles/'; - if(!is_dir($path)) { mkdir($path, 0777, true); } + $requestfilename = $file->getName(); + $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); + log_message('error', 'File already exists in the database' . $requestfilename); $requestfilename = ""; + } else { + $file->move($path, $requestfilename); } - else{ - $file->move($path, $requestfilename); - } - }else{ + } else { $requestfilename = ""; } - } - $POList = array('PONO'=>$newPONO,'SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrder, 'PODate' => $PODate, 'Status' => $POStatus, 'PORange' => $PoRange, 'ExchangeRateCalculatedon' => $ExchangeRateOn, 'ExchangeRate' => $ExchangeRate, 'PaymentTerms' => $PaymentMethod, 'ServiceDescription' => $SpcialInstruction, 'CreatedBy' => $CreateBy, 'DeliveryAddress' => $DeliveryAddr, 'CreatedDate' => $createddt, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'CapitalRange' => $CapitalRange, 'POType' => $POType, 'CurrencyType' => $currencytypeID, 'DeliverySchedule' => $DeliverySchedule, 'Import_PlaceofOrgin' => $Palaceoforigin, 'Import_DispatchDetails' => $Dispatch, 'DeliveryDate' => $Deliverydt, 'PaymentOtherDescription' => $OtherPayment, 'Supplier_Reference' => $SupplierReference, 'Mode_Of_Shipment' => $ModeOfShipment, 'Supplier_Offer_No' => $SuppliersOfferNo, 'Other_Reference' => $OtherReferences, 'Fincap' => $Fincap, 'InsuranceStatus' => $InsuranceOptions, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $ServiceTypeOptions, 'IsQualityChkReqired' => $Qualitycheck, 'BudgetType' => $BudgetType,'IsOpenOrder'=>$IsOpenOrder); - $POList['POFile'] = $requestfilename; - // $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'Import_DispatchDetails'=>$Dispatch,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'Import_PlaceofOrgin'=>$Palaceoforigin); + $POList = array('PONO' => $newPONO, 'SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrder, 'PODate' => $PODate, 'Status' => $POStatus, 'PORange' => $PoRange, 'ExchangeRateCalculatedon' => $ExchangeRateOn, 'ExchangeRate' => $ExchangeRate, 'PaymentTerms' => $PaymentMethod, 'ServiceDescription' => $SpcialInstruction, 'CreatedBy' => $CreateBy, 'DeliveryAddress' => $DeliveryAddr, 'CreatedDate' => $createddt, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'CapitalRange' => $CapitalRange, 'POType' => $POType, 'CurrencyType' => $currencytypeID, 'DeliverySchedule' => $DeliverySchedule, 'Import_PlaceofOrgin' => $Palaceoforigin, 'Import_DispatchDetails' => $Dispatch, 'DeliveryDate' => $Deliverydt, 'PaymentOtherDescription' => $OtherPayment, 'Supplier_Reference' => $SupplierReference, 'Mode_Of_Shipment' => $ModeOfShipment, 'Supplier_Offer_No' => $SuppliersOfferNo, 'Other_Reference' => $OtherReferences, 'Fincap' => $Fincap, 'InsuranceStatus' => $InsuranceOptions, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $ServiceTypeOptions, 'IsQualityChkReqired' => $Qualitycheck, 'BudgetType' => $BudgetType, 'IsOpenOrder' => $IsOpenOrder); + $POList['POFile'] = $requestfilename; + // $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'Import_DispatchDetails'=>$Dispatch,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'Import_PlaceofOrgin'=>$Palaceoforigin); - $POMaster = $this->purchaseorder_model->addPOMaster($POList, $POType, $ServiceTypeOptions); - $PONO = ''; - if (count($POMaster) > 0) { + $POMaster = $this->purchaseorder_model->addPOMaster($POList, $POType, $ServiceTypeOptions); + $PONO = ''; + if (count($POMaster) > 0) { $PONO = $POMaster[0]['PONO']; - } else { - throw new \Exception('Error occurred while creating PO Master'); - } - - $LineItemStatus = REQITEM_NEW; - - for ($i = 1; $i <= $RowCount; $i++) { - - $MaterialCode = $this->request->getPost('materialCode' . $i); - $Quantity = $this->request->getPost('quantity' . $i); - $Reqnumber = $this->request->getPost('Reqnumber' . $i); - $itemRate = $this->request->getPost('itemRate' . $i); - - - $BasicPriceinmton = $this->request->getPost('rateInUs' . $i); - $Productprice = $this->request->getPost('basicvalInINR' . $i); - $LandingCharge = $this->request->getPost('beforeLanding' . $i); - $AfterLandingCharge = $this->request->getPost('landingCharge' . $i); - - - $CustomDuty = $this->request->getPost('beforeCustomDuty' . $i); - $AfterCustomDuty = $this->request->getPost('CustomDuty' . $i); - - - $CustomEd = $this->request->getPost('beforeCustomEDCess' . $i); - $AfterCustomEd = $this->request->getPost('CustomEDCess' . $i); - - $CustomSH = $this->request->getPost('beforeCustomSHCess' . $i); - $AfterCustomSH = $this->request->getPost('CustomSHCess' . $i); - - - $Grossdutypayable = $this->request->getPost('GrossDutyPayable' . $i); - - - - $QuantityKG = $this->request->getPost('PurQuantity' . $i); - $FreightType = $this->request->getPost('FreightType' . $i); - $FreightValue = $this->request->getPost('FreightVal' . $i); - $AfterFreightValue = $this->request->getPost('AfterFreightVal' . $i); - $NOOfTrip = $this->request->getPost('NoOfTrip' . $i); - - $Totalvalueitem = $this->request->getPost('PerKgExpense' . $i); - - //echo $BasicPriceinmton; - $CostCenter = $this->request->getPost('CPCostCode' . $i); - - $TotalOrderValue = $this->request->getPost('basicvalInINR' . $i); - $Cgst = $this->request->getPost('Cgst' . $i); - $Sgst = $this->request->getPost('Sgst' . $i); - $Igst = $this->request->getPost('Igst' . $i); - $AfterCgst = $this->request->getPost('AfterCgst' . $i); - $AfterSgst = $this->request->getPost('AfterSgst' . $i); - $AfterIgst = $this->request->getPost('AfterIgst' . $i); - $DiscountType = $this->request->getPost('DisType' . $i); - $DiscountValue = $this->request->getPost('DisVal' . $i); - $AfterDiscount = $this->request->getPost('AfterDisVal' . $i); - $OtherAmt = $this->request->getPost('OtherAmt' . $i); - - $FreightTypeloc = $this->request->getPost('FreightTypeloc' . $i); - $FreightNoofTriploc = $this->request->getPost('NoofTriploc' . $i); - $Freightrateloc = $this->request->getPost('FreightRateloc' . $i); - $FreightAmountloc = $this->request->getPost('AfterFreightRateloc' . $i); - - $AssessableValue = $this->request->getPost('AfterAssessable' . $i); - $SubTotal = $this->request->getPost('Subtotal' . $i); - $IGST = $this->request->getPost('IgstInt' . $i); - $AfterIGST = $this->request->getPost('AfterIgstInt' . $i); - $DutyImpact = $this->request->getPost('Dutyimpact' . $i); - $NetValue = $this->request->getPost('Nett' . $i); - $ClearingCharge = $this->request->getPost('ClearingCharges' . $i); - - $CustomDutyExpensesPerKG = $this->request->getPost('CustomDutyExpenses' . $i); - - $TaxtotalOrderValue = (float)$itemRate * (float)$Quantity + (float)$OtherAmt + (float)$AfterCgst + (float)$AfterSgst + (float)$AfterIgst - (float)$AfterDiscount; - - $CapitalItemDescription = $this->request->getPost('CapitalItemDescrition' . $i); - $Per = $this->request->getPost('per' . $i); - $SkipInsert = "False"; - if (count($comma_separated) > 0) { - for ($j = 1; $j < count($comma_separated); $j++) { - $deletedRow = $comma_separated[$j]; - - if ($deletedRow == $i) { - $SkipInsert = "True"; - break; - } - } - } - if ($SkipInsert == "False") { - $POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CostCenterCode' => $CostCenter, 'ServiceMaterialDescription' => $CapitalItemDescription, 'Per' => $Per); - - $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); - - $LineItemNo = ''; - if (count($POLineItem) > 0) { - $LineItemNo = $POLineItem[0]['LineItemNo']; } else { - throw new \Exception('Error occurred while creating PO Line Item'); + throw new \Exception('Error occurred while creating PO Master'); } - /* --------------------------------------------*/ + $LineItemStatus = REQITEM_NEW; - // $logpo =array('PONO'=>$PONO,'Date'=>$PODate,'POType'=>$POType,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=> $itemRate,'SupplierID'=>$SupplierID,'LineItemNos'=>$LineItemNo); - // $this->purchaseorder_model->newlogpo($logpo); - /* --------------------------------------------*/ - if (trim((string)$POType) == CAPITAL) { - if ($CapitalRange == '1') { - $ServiceTaxList = array('LineItemNo' => $LineItemNo, 'CGST' => $Cgst, 'After_CGST' => $AfterCgst, 'SGST' => $Sgst, 'After_SGST' => $AfterSgst, 'IGST' => $Igst, 'After_IGST' => $AfterIgst, 'otherallowance' => $OtherAmt, 'TotalValue' => $TaxtotalOrderValue, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'discount' => $DiscountType, 'discountval' => $DiscountValue, 'Afterdiscountval' => $AfterDiscount, 'FreightType' => $FreightTypeloc, 'NoOfTrip' => $FreightNoofTriploc, 'FreightValue' => $Freightrateloc, 'AfterFreightValue' => $FreightAmountloc); + for ($i = 1; $i <= $RowCount; $i++) { + + $MaterialCode = $this->request->getPost('materialCode' . $i); + $Quantity = $this->request->getPost('quantity' . $i); + $Reqnumber = $this->request->getPost('Reqnumber' . $i); + $itemRate = $this->request->getPost('itemRate' . $i); + + + $BasicPriceinmton = $this->request->getPost('rateInUs' . $i); + $Productprice = $this->request->getPost('basicvalInINR' . $i); + $LandingCharge = $this->request->getPost('beforeLanding' . $i); + $AfterLandingCharge = $this->request->getPost('landingCharge' . $i); + + + $CustomDuty = $this->request->getPost('beforeCustomDuty' . $i); + $AfterCustomDuty = $this->request->getPost('CustomDuty' . $i); + + + $CustomEd = $this->request->getPost('beforeCustomEDCess' . $i); + $AfterCustomEd = $this->request->getPost('CustomEDCess' . $i); + + $CustomSH = $this->request->getPost('beforeCustomSHCess' . $i); + $AfterCustomSH = $this->request->getPost('CustomSHCess' . $i); + + + $Grossdutypayable = $this->request->getPost('GrossDutyPayable' . $i); + $QuantityKG = $this->request->getPost('PurQuantity' . $i); + $FreightType = $this->request->getPost('FreightType' . $i); + $FreightValue = $this->request->getPost('FreightVal' . $i); + $AfterFreightValue = $this->request->getPost('AfterFreightVal' . $i); + $NOOfTrip = $this->request->getPost('NoOfTrip' . $i); + $Totalvalueitem = $this->request->getPost('PerKgExpense' . $i); - $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); - if (!$ServiceTax) { - throw new \Exception('Error occurred while creating Capital national Tax'); + //echo $BasicPriceinmton; + $CostCenter = $this->request->getPost('CPCostCode' . $i); + + $TotalOrderValue = $this->request->getPost('basicvalInINR' . $i); + $Cgst = $this->request->getPost('Cgst' . $i); + $Sgst = $this->request->getPost('Sgst' . $i); + $Igst = $this->request->getPost('Igst' . $i); + $AfterCgst = $this->request->getPost('AfterCgst' . $i); + $AfterSgst = $this->request->getPost('AfterSgst' . $i); + $AfterIgst = $this->request->getPost('AfterIgst' . $i); + $DiscountType = $this->request->getPost('DisType' . $i); + $DiscountValue = $this->request->getPost('DisVal' . $i); + $AfterDiscount = $this->request->getPost('AfterDisVal' . $i); + $OtherAmt = $this->request->getPost('OtherAmt' . $i); + + $FreightTypeloc = $this->request->getPost('FreightTypeloc' . $i); + $FreightNoofTriploc = $this->request->getPost('NoofTriploc' . $i); + $Freightrateloc = $this->request->getPost('FreightRateloc' . $i); + $FreightAmountloc = $this->request->getPost('AfterFreightRateloc' . $i); + + $AssessableValue = $this->request->getPost('AfterAssessable' . $i); + $SubTotal = $this->request->getPost('Subtotal' . $i); + $IGST = $this->request->getPost('IgstInt' . $i); + $AfterIGST = $this->request->getPost('AfterIgstInt' . $i); + $DutyImpact = $this->request->getPost('Dutyimpact' . $i); + $NetValue = $this->request->getPost('Nett' . $i); + $ClearingCharge = $this->request->getPost('ClearingCharges' . $i); + + $CustomDutyExpensesPerKG = $this->request->getPost('CustomDutyExpenses' . $i); + + $TaxtotalOrderValue = (float)$itemRate * (float)$Quantity + (float)$OtherAmt + (float)$AfterCgst + (float)$AfterSgst + (float)$AfterIgst - (float)$AfterDiscount; + + $CapitalItemDescription = $this->request->getPost('CapitalItemDescrition' . $i); + $Per = $this->request->getPost('per' . $i); + $SkipInsert = "False"; + if (count($comma_separated) > 0) { + for ($j = 1; $j < count($comma_separated); $j++) { + $deletedRow = $comma_separated[$j]; + + if ($deletedRow == $i) { + $SkipInsert = "True"; + break; } } - if ($CapitalRange == '0') { + } + if ($SkipInsert == "False") { + $POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CostCenterCode' => $CostCenter, 'ServiceMaterialDescription' => $CapitalItemDescription, 'Per' => $Per); - $ImportTaxList = array('LineItemNo' => $LineItemNo, 'BasicPriceInMTon' => $BasicPriceinmton, 'ProductPrice' => $Productprice, 'LandingCharge' => $LandingCharge, 'AfterLandingCharge' => $AfterLandingCharge, 'CustomDuty' => $CustomDuty, 'AfterCustomDuty' => $AfterCustomDuty, 'CustomEdCess' => $CustomEd, 'CustomSHCess' => $CustomSH, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'Grossdutypayable' => $Grossdutypayable, 'QuantityKG' => $QuantityKG, 'AfterCustomSHCess' => $AfterCustomSH, 'AfterCustomEdCess' => $AfterCustomEd, 'TotalValue' => $Totalvalueitem, 'FreightType' => $FreightType, 'NoOfTrip' => $NOOfTrip, 'FreightValue' => $FreightValue, 'AfterFreightValue' => $AfterFreightValue, 'AssessableValue' => $AssessableValue, 'SubTotal' => $SubTotal, 'IGST' => $IGST, 'AfterIGST' => $AfterIGST, 'DutyImpact' => $DutyImpact, 'NetValue' => $NetValue, 'ClearingCharge' => $ClearingCharge, 'CustomDutyExpensesPerKG' => $CustomDutyExpensesPerKG); + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + + $LineItemNo = ''; + if (count($POLineItem) > 0) { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } else { + throw new \Exception('Error occurred while creating PO Line Item'); + } + + /* --------------------------------------------*/ + + // $logpo =array('PONO'=>$PONO,'Date'=>$PODate,'POType'=>$POType,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=> $itemRate,'SupplierID'=>$SupplierID,'LineItemNos'=>$LineItemNo); + // $this->purchaseorder_model->newlogpo($logpo); + /* --------------------------------------------*/ + if (trim((string)$POType) == CAPITAL) { + if ($CapitalRange == '1') { + $ServiceTaxList = array('LineItemNo' => $LineItemNo, 'CGST' => $Cgst, 'After_CGST' => $AfterCgst, 'SGST' => $Sgst, 'After_SGST' => $AfterSgst, 'IGST' => $Igst, 'After_IGST' => $AfterIgst, 'otherallowance' => $OtherAmt, 'TotalValue' => $TaxtotalOrderValue, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'discount' => $DiscountType, 'discountval' => $DiscountValue, 'Afterdiscountval' => $AfterDiscount, 'FreightType' => $FreightTypeloc, 'NoOfTrip' => $FreightNoofTriploc, 'FreightValue' => $Freightrateloc, 'AfterFreightValue' => $FreightAmountloc); + + + + + + $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); + if (!$ServiceTax) { + throw new \Exception('Error occurred while creating Capital national Tax'); + } + } + if ($CapitalRange == '0') { + + $ImportTaxList = array('LineItemNo' => $LineItemNo, 'BasicPriceInMTon' => $BasicPriceinmton, 'ProductPrice' => $Productprice, 'LandingCharge' => $LandingCharge, 'AfterLandingCharge' => $AfterLandingCharge, 'CustomDuty' => $CustomDuty, 'AfterCustomDuty' => $AfterCustomDuty, 'CustomEdCess' => $CustomEd, 'CustomSHCess' => $CustomSH, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'Grossdutypayable' => $Grossdutypayable, 'QuantityKG' => $QuantityKG, 'AfterCustomSHCess' => $AfterCustomSH, 'AfterCustomEdCess' => $AfterCustomEd, 'TotalValue' => $Totalvalueitem, 'FreightType' => $FreightType, 'NoOfTrip' => $NOOfTrip, 'FreightValue' => $FreightValue, 'AfterFreightValue' => $AfterFreightValue, 'AssessableValue' => $AssessableValue, 'SubTotal' => $SubTotal, 'IGST' => $IGST, 'AfterIGST' => $AfterIGST, 'DutyImpact' => $DutyImpact, 'NetValue' => $NetValue, 'ClearingCharge' => $ClearingCharge, 'CustomDutyExpensesPerKG' => $CustomDutyExpensesPerKG); - $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); - if (!$ImportList) { - throw new \Exception('Error occurred while creating Capital international Tax'); + $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); + if (!$ImportList) { + throw new \Exception('Error occurred while creating Capital international Tax'); + } } } } } - } - echo 'Purchase Order Created Successfully! PO Number Is: ' . $PONO; + echo 'Purchase Order Created Successfully! PO Number Is: ' . $PONO; } catch (\Exception $e) { - log_message('error', 'Exception occurred: ' . $e->getMessage()); - echo 'An error occurred while creating the purchase order. Please try again.'; + log_message('error', 'Exception occurred: ' . $e->getMessage()); + echo 'An error occurred while creating the purchase order. Please try again.'; } - } /*Edit Capital po*/ @@ -2829,7 +2829,7 @@ try{ $SupplierReference = $this->request->getPost('editsupplierreference'); $SuppliersOfferNo = $this->request->getPost('editsupplierofferno'); $OtherReferences = $this->request->getPost('editotherreference'); - $Fincap = "";//$this->request->getPost('editfincap'); + $Fincap = ""; //$this->request->getPost('editfincap'); $InsuranceOptions = $this->request->getPost('insuranceStatus'); $InsuranceNumber = $this->request->getPost('InsuranceNumber'); $ServiceTypeOptions = $this->request->getPost('PoTypeOptions'); @@ -2858,20 +2858,21 @@ try{ $POList['ReleasedBy'] = $this->session->get('userId'); } $file = $this->request->getFile('POFile'); - $requestfilename = NULL; + $requestfilename = NULL; if (!empty($file)) { - if ($file && $file->isValid() && !$file->hasMoved()) { - $requestfilename = $file->getName(); - $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; - } - } + if ($file && $file->isValid() && !$file->hasMoved()) { + $requestfilename = $file->getName(); + $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); @@ -3073,8 +3074,34 @@ try{ } if ($capitalType == '0') { $ImportTaxList = array( - 'LineItemNo' => $LineItemNo, 'BasicPriceInMTon' => $BasicPriceinmton, 'ProductPrice' => $Productprice, 'LandingCharge' => $LandingCharge, 'AfterLandingCharge' => $AfterLandingCharge, 'CustomDuty' => $CustomDuty, 'AfterCustomDuty' => $AfterCustomDuty, 'CustomEdCess' => $CustomEd, 'CustomSHCess' => $CustomSH, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'Grossdutypayable' => $Grossdutypayable, 'CustomDutyExpensesPerKG' => $CustomDutyExpensesPerKG, 'QuantityKG' => $QuantityKG, 'AfterCustomSHCess' => $AfterCustomSH, 'AfterCustomEdCess' => $AfterCustomEd, 'TotalValue' => $Totalvalueitem, 'FreightType' => $FreightType, 'NoOfTrip' => $NOOfTrip, 'FreightValue' => $FreightValue, 'AfterFreightValue' => $AfterFreightValue, 'AssessableValue' => $AssessableValue, 'SubTotal' => $SubTotal, 'IGST' => $IGST, - 'AfterIGST' => $AfterIGST, 'DutyImpact' => $DutyImpact, 'NetValue' => $NetValue, 'ClearingCharge' => $ClearingCharge + 'LineItemNo' => $LineItemNo, + 'BasicPriceInMTon' => $BasicPriceinmton, + 'ProductPrice' => $Productprice, + 'LandingCharge' => $LandingCharge, + 'AfterLandingCharge' => $AfterLandingCharge, + 'CustomDuty' => $CustomDuty, + 'AfterCustomDuty' => $AfterCustomDuty, + 'CustomEdCess' => $CustomEd, + 'CustomSHCess' => $CustomSH, + 'CreatedBy' => $CreateBy, + 'CreatedDate' => $createddt, + 'Grossdutypayable' => $Grossdutypayable, + 'CustomDutyExpensesPerKG' => $CustomDutyExpensesPerKG, + 'QuantityKG' => $QuantityKG, + 'AfterCustomSHCess' => $AfterCustomSH, + 'AfterCustomEdCess' => $AfterCustomEd, + 'TotalValue' => $Totalvalueitem, + 'FreightType' => $FreightType, + 'NoOfTrip' => $NOOfTrip, + 'FreightValue' => $FreightValue, + 'AfterFreightValue' => $AfterFreightValue, + 'AssessableValue' => $AssessableValue, + 'SubTotal' => $SubTotal, + 'IGST' => $IGST, + 'AfterIGST' => $AfterIGST, + 'DutyImpact' => $DutyImpact, + 'NetValue' => $NetValue, + 'ClearingCharge' => $ClearingCharge ); $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); @@ -3094,8 +3121,34 @@ try{ } if ($capitalType == '0') { $ImportTaxList = array( - 'LineItemNo' => $LineItemNo, 'BasicPriceInMTon' => $BasicPriceinmton, 'ProductPrice' => $Productprice, 'LandingCharge' => $LandingCharge, 'AfterLandingCharge' => $AfterLandingCharge, 'CustomDuty' => $CustomDuty, 'AfterCustomDuty' => $AfterCustomDuty, 'CustomEdCess' => $CustomEd, 'CustomSHCess' => $CustomSH, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'Grossdutypayable' => $Grossdutypayable, 'CustomDutyExpensesPerKG' => $CustomDutyExpensesPerKG, 'QuantityKG' => $QuantityKG, 'AfterCustomSHCess' => $AfterCustomSH, 'AfterCustomEdCess' => $AfterCustomEd, 'TotalValue' => $Totalvalueitem, 'FreightType' => $FreightType, 'NoOfTrip' => $NOOfTrip, 'FreightValue' => $FreightValue, 'AfterFreightValue' => $AfterFreightValue, 'AssessableValue' => $AssessableValue, 'SubTotal' => $SubTotal, 'IGST' => $IGST, - 'AfterIGST' => $AfterIGST, 'DutyImpact' => $DutyImpact, 'NetValue' => $NetValue, 'ClearingCharge' => $ClearingCharge + 'LineItemNo' => $LineItemNo, + 'BasicPriceInMTon' => $BasicPriceinmton, + 'ProductPrice' => $Productprice, + 'LandingCharge' => $LandingCharge, + 'AfterLandingCharge' => $AfterLandingCharge, + 'CustomDuty' => $CustomDuty, + 'AfterCustomDuty' => $AfterCustomDuty, + 'CustomEdCess' => $CustomEd, + 'CustomSHCess' => $CustomSH, + 'CreatedBy' => $CreateBy, + 'CreatedDate' => $createddt, + 'Grossdutypayable' => $Grossdutypayable, + 'CustomDutyExpensesPerKG' => $CustomDutyExpensesPerKG, + 'QuantityKG' => $QuantityKG, + 'AfterCustomSHCess' => $AfterCustomSH, + 'AfterCustomEdCess' => $AfterCustomEd, + 'TotalValue' => $Totalvalueitem, + 'FreightType' => $FreightType, + 'NoOfTrip' => $NOOfTrip, + 'FreightValue' => $FreightValue, + 'AfterFreightValue' => $AfterFreightValue, + 'AssessableValue' => $AssessableValue, + 'SubTotal' => $SubTotal, + 'IGST' => $IGST, + 'AfterIGST' => $AfterIGST, + 'DutyImpact' => $DutyImpact, + 'NetValue' => $NetValue, + 'ClearingCharge' => $ClearingCharge ); @@ -3285,28 +3338,65 @@ try{ $i = 0; $str = array(); $words = array( - '0' => '', '1' => 'one', '2' => 'two', - '3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six', - '7' => 'seven', '8' => 'eight', '9' => 'nine', - '10' => 'ten', '11' => 'eleven', '12' => 'twelve', - '13' => 'thirteen', '14' => 'fourteen', - '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen', - '18' => 'eighteen', '19' => 'nineteen', '20' => 'twenty', - '30' => 'thirty', '40' => 'fourty', '50' => 'fifty', - '60' => 'sixty', '70' => 'seventy', - '80' => 'eighty', '90' => 'ninety', '06' => 'Zero Six', '01' => 'Zero One', '02' => 'Zero Two', '03' => 'Zero Three', '04' => 'Zero Four', '05' => 'Zero Five', '07' => 'Zero Seven', '08' => 'Zero Eight', '09' => 'Zero Nine' + '0' => '', + '1' => 'one', + '2' => 'two', + '3' => 'three', + '4' => 'four', + '5' => 'five', + '6' => 'six', + '7' => 'seven', + '8' => 'eight', + '9' => 'nine', + '10' => 'ten', + '11' => 'eleven', + '12' => 'twelve', + '13' => 'thirteen', + '14' => 'fourteen', + '15' => 'fifteen', + '16' => 'sixteen', + '17' => 'seventeen', + '18' => 'eighteen', + '19' => 'nineteen', + '20' => 'twenty', + '30' => 'thirty', + '40' => 'fourty', + '50' => 'fifty', + '60' => 'sixty', + '70' => 'seventy', + '80' => 'eighty', + '90' => 'ninety', + '06' => 'Zero Six', + '01' => 'Zero One', + '02' => 'Zero Two', + '03' => 'Zero Three', + '04' => 'Zero Four', + '05' => 'Zero Five', + '07' => 'Zero Seven', + '08' => 'Zero Eight', + '09' => 'Zero Nine' ); $words1 = array( '2' => 'twenty', - '3' => 'thirty', '4' => 'fourty', - '5' => 'fifty', '6' => 'sixty', '7' => 'seventy', - '8' => 'eighty', '9' => 'ninety' + '3' => 'thirty', + '4' => 'fourty', + '5' => 'fifty', + '6' => 'sixty', + '7' => 'seventy', + '8' => 'eighty', + '9' => 'ninety' ); $words12 = array( '11' => 'eleven', - '12' => 'twelve', '13' => 'thirteen', '14' => 'fourteen', - '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen', - '18' => 'eighteen', '19' => 'nineteen', '20' => 'twenty', + '12' => 'twelve', + '13' => 'thirteen', + '14' => 'fourteen', + '15' => 'fifteen', + '16' => 'sixteen', + '17' => 'seventeen', + '18' => 'eighteen', + '19' => 'nineteen', + '20' => 'twenty', ); $digits = array('', 'hundred', 'thousand', 'lakh', 'crore'); while ($i < $digits_1) { @@ -3373,28 +3463,56 @@ try{ $i = 0; $str = array(); $words = array( - '0' => '', '1' => 'one', '2' => 'two', - '3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six', - '7' => 'seven', '8' => 'eight', '9' => 'nine', - '10' => 'ten', '11' => 'eleven', '12' => 'twelve', - '13' => 'thirteen', '14' => 'fourteen', - '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen', - '18' => 'eighteen', '19' => 'nineteen', '20' => 'twenty', - '30' => 'thirty', '40' => 'fourty', '50' => 'fifty', - '60' => 'sixty', '70' => 'seventy', - '80' => 'eighty', '90' => 'ninety' + '0' => '', + '1' => 'one', + '2' => 'two', + '3' => 'three', + '4' => 'four', + '5' => 'five', + '6' => 'six', + '7' => 'seven', + '8' => 'eight', + '9' => 'nine', + '10' => 'ten', + '11' => 'eleven', + '12' => 'twelve', + '13' => 'thirteen', + '14' => 'fourteen', + '15' => 'fifteen', + '16' => 'sixteen', + '17' => 'seventeen', + '18' => 'eighteen', + '19' => 'nineteen', + '20' => 'twenty', + '30' => 'thirty', + '40' => 'fourty', + '50' => 'fifty', + '60' => 'sixty', + '70' => 'seventy', + '80' => 'eighty', + '90' => 'ninety' ); $words1 = array( '2' => 'twenty', - '3' => 'thirty', '4' => 'fourty', - '5' => 'fifty', '6' => 'sixty', '7' => 'seventy', - '8' => 'eighty', '9' => 'ninety' + '3' => 'thirty', + '4' => 'fourty', + '5' => 'fifty', + '6' => 'sixty', + '7' => 'seventy', + '8' => 'eighty', + '9' => 'ninety' ); $words12 = array( '11' => 'eleven', - '12' => 'twelve', '13' => 'thirteen', '14' => 'fourteen', - '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen', - '18' => 'eighteen', '19' => 'nineteen', '20' => 'twenty', + '12' => 'twelve', + '13' => 'thirteen', + '14' => 'fourteen', + '15' => 'fifteen', + '16' => 'sixteen', + '17' => 'seventeen', + '18' => 'eighteen', + '19' => 'nineteen', + '20' => 'twenty', ); $digits = array('', 'hundred', 'thousand', 'lakh', 'crore'); while ($i < $digits_1) { @@ -3991,7 +4109,7 @@ try{ } } - + public function adfile() { $picture = ''; diff --git a/app/Controllers/User.php b/app/Controllers/User.php index b0640664..c1c74bd3 100644 --- a/app/Controllers/User.php +++ b/app/Controllers/User.php @@ -901,7 +901,7 @@ class User extends BaseController $data['userRecords'] = $this->user_model->userListing(); $this->global['pageTitle'] = 'User Listing'; - + // dd($data); $this->loadViews("userListing", $this->global, $data, NULL); //} } @@ -1095,10 +1095,10 @@ class User extends BaseController $data['EmpRole'] = $this->user_model->GetRoleNameByUserID($Uid); $data['AccessDept'] = $this->costcenter_model->getaccessDept($Empid); - // $data['userInfo'] = $this->user_model->getUserInfo($userId); + // $data['userInfo'] = $this->user_model->getUserInfo($Uid); + $data['userId'] = $Uid; $this->global['pageTitle'] = 'Edit User'; - $this->loadViews("editOld", $this->global, $data, NULL); //} } @@ -1126,7 +1126,7 @@ class User extends BaseController // } else { $EmpID = $this->request->getPost('EmpList'); $role = $this->request->getPost('role'); - $password = $this->request->getPost('password'); + // $password = $this->request->getPost('password'); $updatedDate = get_current_date_time(); @@ -1134,7 +1134,8 @@ class User extends BaseController $userInfo = array(); - $userInfo = array('password' => getHashedPassword($password), 'roleId' => $role, 'EmpId' => $EmpID, 'updatedDtm' => $updatedDate); + // $userInfo = array('password' => getHashedPassword($password), 'roleId' => $role, 'EmpId' => $EmpID, 'updatedDtm' => $updatedDate); + $userInfo = array('roleId' => $role, 'EmpId' => $EmpID, 'updatedDtm' => $updatedDate); $result = $this->user_model->editUser($userInfo, $EmpID); @@ -1168,6 +1169,34 @@ class User extends BaseController echo 'Succssfully change the user status to InAcive'; } + + function userChangePassword() + { + helper('form'); + $userId = $this->request->getPost('userId'); + $newPassword = $this->request->getPost('password'); + $cNewPassword = $this->request->getPost('cpassword'); + + if ($newPassword == $cNewPassword) { + $usersData = array( + 'password' => getHashedPassword($newPassword), + 'updatedBy' => $userId, + 'updatedDtm' => date('Y-m-d H:i:sa') + ); + $result = $this->user_model->changePassword($userId, $usersData); + if ($result > 0) { + $this->session->setFlashdata('success', 'Password updation successful'); + } else { + $this->session->setFlashdata('error', 'Password updation failed'); + } + + return redirect()->route('userListing'); + } else { + $this->session->setFlashdata('error', 'New Password and Confirm Password Not Same'); + return redirect()->route('userListing'); + } + } + /** * This function is used to load the change password screen */ @@ -1191,10 +1220,11 @@ class User extends BaseController // $this->validator->setRules(['cNewPassword', 'Confirm new password'=> 'required|matches[newPassword]|max_length[20]']); // if ($this->validator->run() == FALSE) { - $oldPassword = $this->request->getPost('oldPassword'); - $newPassword = $this->request->getPost('newPassword'); - $cNewPassword = $this->request->getPost('newPassword'); - if($newPassword === $cNewPassword && $oldPassword != $newPassword) { + $oldPassword = $this->request->getPost('oldPassword'); + $newPassword = $this->request->getPost('newPassword'); + $cNewPassword = $this->request->getPost('cNewPassword'); + + if ($newPassword == $cNewPassword) { $resultPas = $this->user_model->matchOldPassword($this->vendorId, $oldPassword); if (empty($resultPas)) { $this->session->setFlashdata('nomatch', 'Your old password not correct'); @@ -1205,7 +1235,6 @@ class User extends BaseController 'updatedBy' => $this->vendorId, 'updatedDtm' => date('Y-m-d H:i:sa') ); - $this->session->setFlashdata('error', 'Password updation failed'); $result = $this->user_model->changePassword($this->vendorId, $usersData); if ($result > 0) { $this->session->setFlashdata('success', 'Password updation successful'); @@ -1215,6 +1244,9 @@ class User extends BaseController return redirect()->route('loadChangePass'); } + } else { + $this->session->setFlashdata('error', 'New Password and Confirm Password Not Same'); + return redirect()->route('loadChangePass'); } } diff --git a/app/Models/Expense_model.php b/app/Models/Expense_model.php index 24c0a807..f3090317 100644 --- a/app/Models/Expense_model.php +++ b/app/Models/Expense_model.php @@ -9,7 +9,7 @@ class Expense_model extends Model protected $primaryKey = 'id'; // Primary key protected $allowedFields = [ - 'transporter_file', 'supplier_id', 'remarks', 'cost', 'gst', 'total', 'status', 'payment_method' + 'transporter_file', 'supplier_id', 'remarks', 'item_description', 'cost', 'cgst', 'sgst', 'igst', 'total', ]; // Retrieve all active expenses diff --git a/app/Views/EditservicePurchaseorder.php b/app/Views/EditservicePurchaseorder.php index 116e905e..d319407e 100644 --- a/app/Views/EditservicePurchaseorder.php +++ b/app/Views/EditservicePurchaseorder.php @@ -868,7 +868,7 @@ if (!empty($getlogpodtl)) {
'date','name' => 'Deliverydt', 'value' => set_value('Deliverydt', $Deliverydt), 'id' => 'Deliverydt', 'class' => 'form-control num', 'required' => 'true', 'onkeypress' => 'return false;'); + $data = array('name' => 'Deliverydt', 'value' => set_value('Deliverydt', $Deliverydt), 'id' => 'Deliverydt', 'class' => 'form-control num', 'required' => 'true', 'onkeypress' => 'return false;'); echo form_input($data); ?>
diff --git a/app/Views/addEmployeenew.php b/app/Views/addEmployeenew.php index 50414640..0aba698f 100644 --- a/app/Views/addEmployeenew.php +++ b/app/Views/addEmployeenew.php @@ -377,20 +377,20 @@
+
+
+
+

Add Employee

+
+
+
+ Back +
+
-
-
-
-

Add Employee

-
-
-
- Back -
-
-
+
Full Name*
-
Father / Husband NameFather / Husband Name*
-
Contact NumberContact Number*
- -
Gender +
+
Gender*
-
Date Of BirthDate Of Birth*
-
-
-
Age +
Age
-
Personal Email ID +
+
+
Personal Email ID* + class="form-control" required>
-
Official Email ID +
Official Email ID
-
+
Blood group*
- -
+
+
+
Marital Status*
-
-
Current Address*
-
+
Current address same as permanent address
+
+
Permanent Address* @@ -564,16 +566,15 @@ name="permanentaddress" pattern=".{0,500}" maxlength="500" class="form-control">
-
-
-
+ +
Emergency Contact Name
-
+
Emergency Contact Number
-
+
@@ -679,8 +680,7 @@ onchange=" return getValidReferNumber();" maxlength="10" onkeypress="return isNumberKey(event)" class="form-control">
-
-
+
Work Location*
@@ -118,8 +121,7 @@ getFlashdata('success'); ?>
-
- t +
@@ -128,9 +130,9 @@
- +
@@ -156,8 +158,8 @@
@@ -194,7 +196,7 @@
@@ -213,162 +215,172 @@ -     +     \ No newline at end of file diff --git a/app/Views/companyview.php b/app/Views/companyview.php index 1a887da5..a0e71b17 100644 --- a/app/Views/companyview.php +++ b/app/Views/companyview.php @@ -1,6 +1,6 @@ CompID; - $CompanyName = $uf->CompanyName; - $Address = $uf->Address; - $ContactNumber = $uf->ContactNumber; - $AlternateContactNumber = $uf->AlternateContactNumber; - $EmailAddress= $uf->EmailAddress; - $Exiseregistration= $uf->Exiseregistration; - $TIN = $uf->TIN; - $PAN= $uf->PAN; - $GSTNO = $uf->GSTNO; - $GSTRange = $uf->GSTRange; - $CollectrateAddress = $uf->CollectrateAddress; - $UANumber = $uf->UANumber; - $PaymentTerms = $uf->PaymentTerms ; +if (!empty($userRecords)) { + foreach ($userRecords as $uf) { + $CompID = $uf->CompID; + $CompanyName = $uf->CompanyName; + $Address = $uf->Address; + $ContactNumber = $uf->ContactNumber; + $AlternateContactNumber = $uf->AlternateContactNumber; + $EmailAddress = $uf->EmailAddress; + $Exiseregistration = $uf->Exiseregistration; + $TIN = $uf->TIN; + $PAN = $uf->PAN; + $GSTNO = $uf->GSTNO; + $GSTRange = $uf->GSTRange; + $CollectrateAddress = $uf->CollectrateAddress; + $UANumber = $uf->UANumber; + $PaymentTerms = $uf->PaymentTerms; $PaymentId = $uf->paymentID; $MSME = $uf->MSME; - //$PaymentDays = $uf->PaymentDays ; - //$PayableAT = $uf->PayableAT ; - $Createdby = $uf->Createdby; - //$CreatedDate = $uf->CreatedDate; - $UpdatedBy = $uf->UpdatedBy; - $Updatedon = $uf->Updatedon; - $ProfilePic = $uf->ProfilePic; - $companywebsite = $uf->companyWebsite; - //$companywebsite = $uf->companywebsite; - //$ceoname = $uf->ceoname; - //$mdname = $uf->mdname; + //$PaymentDays = $uf->PaymentDays ; + //$PayableAT = $uf->PayableAT ; + $Createdby = $uf->Createdby; + //$CreatedDate = $uf->CreatedDate; + $UpdatedBy = $uf->UpdatedBy; + $Updatedon = $uf->Updatedon; + $ProfilePic = $uf->ProfilePic; + $companywebsite = $uf->companyWebsite; + //$companywebsite = $uf->companywebsite; + //$ceoname = $uf->ceoname; + //$mdname = $uf->mdname; //$companystartedon = $uf->companystartedon; //$partnerdetails = $uf->partnerdetails; $firstname = $uf->firstname; - //$financialstart= $uf->FiscalYearStartOn; + //$financialstart= $uf->FiscalYearStartOn; //$financialend= $uf->FiscalYearEndsOn; //$files = $uf->files; //$financialyear = $uf->financialyear; - - $FStartDt = $uf->FiscalYearStartOn; - if($FStartDt != '' && $FStartDt != '0000-00-00 00:00:00' ) - { - $FSdate = new DateTime($FStartDt); - $financialstart = $FSdate->format('d-m-Y'); - } - else - { - $financialstart = ""; - } - - $FEndDt = $uf->FiscalYearEndsOn; - if($FEndDt != '' && $FEndDt != '0000-00-00 00:00:00' ) - { - $FEdate = new DateTime($FEndDt); - $financialend = $FEdate ->format('d-m-Y'); - } - else - { - $financialend = ""; - } - - } - - } -if(!empty($filenames)) -{ - foreach ($filenames as $uf) - { - $filedescription1=$uf->filedescription; - $filename=$uf->filename; - $createdDate=$uf->createdDate; - } -} + $FStartDt = $uf->FiscalYearStartOn; + if ($FStartDt != '' && $FStartDt != '0000-00-00 00:00:00') { + $FSdate = new DateTime($FStartDt); + $financialstart = $FSdate->format('d-m-Y'); + } else { + $financialstart = ""; + } + + $FEndDt = $uf->FiscalYearEndsOn; + if ($FEndDt != '' && $FEndDt != '0000-00-00 00:00:00') { + $FEdate = new DateTime($FEndDt); + $financialend = $FEdate->format('d-m-Y'); + } else { + $financialend = ""; + } + } +} + +if (!empty($filenames)) { + foreach ($filenames as $uf) { + $filedescription1 = $uf->filedescription; + $filename = $uf->filename; + $createdDate = $uf->createdDate; + } +} // if(!empty($bankdetails)) // { @@ -127,808 +115,751 @@ if(!empty($filenames)) // } ?> - - + + + } + + } + + + function ValidateAlternateContact() { + // alert('phone'); + + var AlternateContactNumber = $('#AlternateContactNumber').val(); + + var telephone = /^[0-9]{3,5}\s[0-9]{6,8}$/.test(AlternateContactNumber); + var mobilephone = /^[0-9]{10}$/.test(AlternateContactNumber); + + // alert('chennai telephone:'+telephone);//alert('other telephone:'+regex); + // alert('mobilephone:'+mobilephone);//alert('input value:'+contactNumber); + + if (AlternateContactNumber != '') { + + if (telephone) { + // alert(' telephone number chennai district successfully inserted'+AlternateContactNumber); + return true; + } else if (mobilephone) { + // alert('mobile number successfully inserted'+AlternateContactNumber); + return true; + } else { + alert('Please Enter valid Contact Number ex: 044 12345678 , 0444 1234567,04444 123456 and 9876543210'); //alert('need to change:'+contactNumber); + return false; + } + } else { + + alert('Please enter correct format of contact number'); + //alert('invalid'+AlternateContactNumber); + return false; + } + } + + + + function ValidateUA() { + + var reguano = /^([a-zA-Z]){5}([0-9]){10}?$/; + var UA = $('#UANumber').val(); + + if (UA != '') { + if (reguano.test(UA) == false) { + alert('Please Enter Valid UA Number'); + return (false); + } else { + return true; + } + } + + } + - - + } + + .form-group { + padding-bottom: 4%; + } + + .pad { + padding-bottom: 1%; + } + + .badge { + color: red; + background-color: #fff; + } +
-
- -
- - getFlashdata('error'); - if ($error) { - ?> -
- - getFlashdata('error'); ?> -
- - getFlashdata('success'); - if ($success) { - ?> -
- - getFlashdata('success'); ?> -
- -
-
-
-

Business Settings

+
+ +
+ + getFlashdata('error'); + if ($error) { + ?> +
+ + getFlashdata('error'); ?> +
+ + getFlashdata('success'); + if ($success) { + ?> +
+ + getFlashdata('success'); ?> +
+ +
+
+
+

Business Settings

+
+
+
+ Back +
+
+ +
+
+
+
+
+
+ +
+ + Business Information +
+
+
+ your image
+ + + + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + + Address Details +
+
+
+ + +
+
+
+ + + Tax Related Data + +
+
+
+ + + +
+
+ + +
+ + + ID Proof + +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + + Bank Details +
+ +
+
+ Bank Name + +
+
+ IFSC + +
+
+ Bank Account Number + +
+
+ Bank Address + +
+
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + +
BankNameIFSCBankAccountNumberBankAddressIsActive
Bank_name ?>IFSC ?>Bank_AccNo ?>Address ?> + Is_Active == 1) { + echo 'Yes'; + } else { + echo 'No'; + } + ?> + +
+
-
- Back -
-
- -
-
-
-
-
-
- -
- - Business Information -
-
-
- your image
- - - - -
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
-
- - -
-
- - -
-
-
-
- - - Address Details -
-
-
- - -
-
-
+ Upload File +
+
+
+ File Description + +
+
+ + - - Tax Related Data - -
-
-
- - -
-
+
+
+
+
+ +
+
+
+
+ + - - - - - ID Proof - -
-
-
- -
-
- -
-
- -
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - - Bank Details -
- -
-
- Bank Name - -
-
- IFSC -
-
- Bank Account Number -
-
- Bank Address -
-
-
- - -
-
-
- - - - - - - - - - - - - - - - - - - - - -
BankNameIFSCBankAccountNumberBankAddressIsActive
Bank_name ?>IFSC ?>Bank_AccNo ?>Address ?> - Is_Active == 1 ) - { - echo 'Yes'; - } - else - { - echo 'No'; - } - ?> - -
-
-
-
- - Upload File -
-
-
- File Description - -
-
- - - -
-
-
-
- -
-
-
-
- - - - - - - - + + + + + - - - - - - - - - + + + + + + + + + -
filedescriptionfilenameuploadedbyuploadedonActionsfiledescriptionfilenameuploadedbyuploadedonActions
filedescription ?>filename ?>createdDate ?> - -     - -
filedescription ?>filename ?>createdDate ?> + +     + +
-
-
-
-
- - - -
-
- -
-
- -
-
-
+ +
+
+
+
+ + + +
+
+
- -
-
+
+ +
+
+
+
+ +
+
- \ No newline at end of file diff --git a/app/Views/editOld.php b/app/Views/editOld.php index b2b8d5d8..d7915a30 100644 --- a/app/Views/editOld.php +++ b/app/Views/editOld.php @@ -1,5 +1,3 @@ - - roleId; - $RoleName = $Er->role; - } +$RoleName = ''; +if (!empty($EmpRole)) { + foreach ($EmpRole as $Er) { + $Role = $Er->roleId; + $RoleName = $Er->role; + } } -if(!empty($EmpList)) -{ - foreach ($EmpList as $Emp) - { +if (!empty($EmpList)) { + foreach ($EmpList as $Emp) { $EmpId = $Emp->EmpID; $FirstName = $Emp->FirstName; $LastName = $Emp->LastName; $ContactNo = $Emp->ContactNumber; $EmailId = $Emp->EmailId; - - $Designation = $Emp->Designation; - + $Designation = $Emp->Designation; } } @@ -38,20 +30,19 @@ if(!empty($EmpList))
-
-
-

Edit User Details

+

Edit User Details

- Back + Back
- + +
@@ -77,7 +68,6 @@ if(!empty($EmpList))
-
@@ -86,18 +76,23 @@ if(!empty($EmpList))
-
-
-
- - -
- - + +
-
@@ -105,6 +100,8 @@ if(!empty($EmpList))
+ + getFlashdata('listErrors'); if ($listErrors) { @@ -114,6 +111,7 @@ if(!empty($EmpList)) getFlashdata('listErrors'); ?>
+ getFlashdata('error'); if ($error) { @@ -123,6 +121,7 @@ if(!empty($EmpList)) getFlashdata('error'); ?>
+ getFlashdata('success'); if ($success) { @@ -134,152 +133,160 @@ if(!empty($EmpList))
-
-
+
+
+ + +
+
+
+
+
+ +
+
+ + +
+
+ + +
+
+
+ + +
+
+
+
+
+
- -
-
+
+ + > + }); +> \ No newline at end of file diff --git a/app/Views/editRevenuepurchaseorder.php b/app/Views/editRevenuepurchaseorder.php index a746a8bd..a9e75c39 100644 --- a/app/Views/editRevenuepurchaseorder.php +++ b/app/Views/editRevenuepurchaseorder.php @@ -1958,7 +1958,7 @@ if (!empty($getlogpodtl)) {
'date','name' => 'Deliverydt', 'value' => set_value('Deliverydt', $Deliverydt), 'id' => 'Deliverydt', 'class' => 'form-control num', 'required' => 'true', 'onkeypress' => 'return false;'); + $data = array('name' => 'Deliverydt', 'value' => set_value('Deliverydt', $Deliverydt), 'id' => 'Deliverydt', 'class' => 'form-control num', 'required' => 'true', 'onkeypress' => 'return false;'); echo form_input($data); ?> @@ -1986,7 +1986,7 @@ if (!empty($getlogpodtl)) {
'date','name' => 'PODate', 'value' => set_value('PODate', $PODate), 'id' => 'PODate', 'class' => 'form-control num', 'required' => 'true', 'onkeypress' => 'return false;'); + $data = array('name' => 'PODate', 'value' => set_value('PODate', $PODate), 'id' => 'PODate', 'class' => 'form-control num', 'required' => 'true', 'onkeypress' => 'return false;'); echo form_input($data); ?>
diff --git a/app/Views/editconfig.php b/app/Views/editconfig.php index 544396c2..eac454ff 100644 --- a/app/Views/editconfig.php +++ b/app/Views/editconfig.php @@ -1,8 +1,8 @@ Config_ID; - $ConfigName = $con->ConfigName; - $Comments = $con->Comments; - } + foreach ($master as $con) { + $ConfigId = $con->Config_ID; + $ConfigName = $con->ConfigName; + $Comments = $con->Comments; + } } ?> @@ -31,7 +31,7 @@ if (!empty($master)) {
- Back + Back
@@ -132,10 +132,10 @@ if (!empty($master)) {
-
- Cancel - -
+
+ Cancel + +
@@ -148,9 +148,9 @@ if (!empty($master)) { @@ -184,9 +184,9 @@ if (!empty($master)) { @@ -250,168 +250,176 @@ if (!empty($master)) { - - \ No newline at end of file diff --git a/app/Views/expense_list.php b/app/Views/expense_list.php index c521e501..27269df7 100644 --- a/app/Views/expense_list.php +++ b/app/Views/expense_list.php @@ -9,6 +9,11 @@ padding-bottom: 0%; } + .expandable-td { + cursor: pointer; + } + + .Date-filter-form { display: flex; align-items: center; @@ -86,15 +91,16 @@ - + - - - - - - - + + + + + + + + @@ -118,12 +124,23 @@ ?> - + + + + - + + + - -
Created DateCreated Date Supplier NameCostGSTTotalPayment MethodStatusActionSupplier NameItem DescriptionCostCGSTSGSTIGSTTotalAction
+
+ +
+
+
+ +
+
- - -
  • - - -
    - - - -
    + +
    + + Change Password - -
  • - -
    + + + + + + + + + Logout + + + + + + + + + + + + +
    - + + -
    -
    -
    + + + + + + + + + +
    + + + + + + + \ No newline at end of file diff --git a/app/Views/publicholidays.php b/app/Views/publicholidays.php index 29ecb08a..24a10dcc 100644 --- a/app/Views/publicholidays.php +++ b/app/Views/publicholidays.php @@ -93,7 +93,7 @@

     

    -
    +