From 5d90214dfef3dc04ae1a85c249bf62abf8619c82 Mon Sep 17 00:00:00 2001 From: gandhimathi Bharathirajan Date: Wed, 12 Jul 2017 15:19:26 +0530 Subject: [PATCH] Amendment issue --- .../controllers/amendmentpurchaseorder.php | 321 ++++-------------- application/controllers/purchaseorder.php | 93 ++--- 2 files changed, 124 insertions(+), 290 deletions(-) diff --git a/application/controllers/amendmentpurchaseorder.php b/application/controllers/amendmentpurchaseorder.php index 2022aa29..5ebda2b2 100755 --- a/application/controllers/amendmentpurchaseorder.php +++ b/application/controllers/amendmentpurchaseorder.php @@ -5,9 +5,9 @@ require APPPATH . '/libraries/BaseController.php'; /** * Class : Amendment Purchase Order controller * User Class to control all user related operations. - * @author : Saravana kumar + * @author : Velmurugan * @version : 1.1 - * @since : 19 June 2016 + * @since : 10 Jul 2017 */ class amendmentpurchaseorder extends BaseController { @@ -32,14 +32,8 @@ class amendmentpurchaseorder extends BaseController { - $this->load->library('pagination'); - - // $count = $this->purchaseorder_model->purchaseorderListingCount(''); - - //$returns = $this->paginationCompress ( "purchaseorderListing/", $count, 10 ); - - //$this->purchaseorder_model->UpdateRequistionStatus(); CONFORM IT - + $this->load->library('pagination'); + $forwhat='amendment'; $data['POData'] = $this->purchaseorder_model->purchaseorderListing($forwhat); $this->global['pageTitle'] = 'Siddharth : Amendment Purchase Order'; @@ -71,7 +65,7 @@ class amendmentpurchaseorder extends BaseController $data['RequistionDetails'] = $ReqDetails; $CostCode = ''; $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); - + $currencycode = ''; $Year = $dt->format('Y'); foreach ($ReqDetails as $Rs): @@ -425,37 +419,27 @@ class amendmentpurchaseorder extends BaseController function UpdateAmendServicePurchaseOrder() { $PONO =$this->input->post('txtPONO'); - $NewPO='0'; - //echo $PONO; + + $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); $DeliveryAddr = $this->input->post('txtDeliveryAddress'); $dt = $this->input->post('Deliverydt'); - $DeliveryOption = $this->input->post('DateRange'); - if($DeliveryOption==1){ - $Deliverydt = ''; - $DeliverySchedule = $this->input->post('Scheduleby'); - } - else{ - $Deliverydt = $this->getDateformat($dt); - $DeliverySchedule = ''; - } - - - $PaymentDate=$this->input->post('Payment'); - if($PaymentDate==1) - { - $PaymentDays='After'; - } - else - { - $PaymentDays='Before'; - } + $DeliveryOption = $this->input->post('DateRange'); + if($DeliveryOption==1){ + $Deliverydt = ''; + $DeliverySchedule = $this->input->post('Scheduleby'); + } + else{ + $Deliverydt = $this->getDateformat($dt); + $DeliverySchedule = ''; + } + $PaymentTerms=$this->input->post('PaymentTerms'); - $Payableat=$this->input->post('PayableAT'); + $POType = $this->input->post('POType'); @@ -465,35 +449,31 @@ function UpdateAmendServicePurchaseOrder() $updatedBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); - //echo "ROw Count is" . $RowCount; - //die(); - // $DeletedRow = $this->input->post('txtDeletedRow'); - //$comma_separated = explode(':', $DeletedRow); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updateddt = $dt->format('Y-m-d H:i:s'); $WorkStatus=$this->input->post('workstatus'); // PO Master - $POMaster = array('ParentPO'=>$PONO,'POType'=>$POType,'SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$updateddt,'PaymentTerms'=>$PaymentTerms,'PayableAT'=>$Payableat,'PaymentDays'=>$PaymentDays,'ServiceWorkStatus'=>$WorkStatus ); + $POMaster = array('ParentPO'=>$PONO,'POType'=>$POType,'SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$updateddt,'PaymentTerms'=>$PaymentTerms,'ServiceWorkStatus'=>$WorkStatus,'ReleasedBy'=>$updatedBy,'ReleasedOn'=>$updateddt); + //print_r($POMaster); - $LastPO = $this->purchaseorder_model->addPOMaster($POMaster); + $LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster,$updatedBy,$PONO); //print_r($LastPO); - foreach($LastPO as $PO): - $NewPO=$PO['PONO']; - endforeach; - //echo "NEW PO IS " . $NewPO; - //echo ""; + $NewPO = ''; + if(count($LastPO)>0) + { + $NewPO = $LastPO[0]['PONO']; + } + + + $PODetail=array('Status'=>PO_AMENDED);//TO SET PARENT PO AS AMENDMENT STATUS - $PODetail=array('Status'=>"ST030");//TO SET PARENT PO AS AMENDMENT STATUS - //print_r($PODetail); $APO=$this->purchaseorder_model->updateAmendPOMaster($PONO,$PODetail); - //echo $APO."Affected"; - + $LineItemStatus = REQITEM_NEW; - //echo "Before For Loop" ; - //echo $RowCount; + for ($i = 1; $i <= $RowCount; $i++) { @@ -513,84 +493,28 @@ function UpdateAmendServicePurchaseOrder() $POLineItemNo = $this->input->post('LineItemNo'.$i); $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); $ServiceFrequency=$this->input->post('Frequency'.$i); - // echo $MaterialCode; - //$POLineItem = array(); + $LineItemNo = ''; - //echo "LineItem is". $LineItemNo; - // $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") - // { - // if(strlen($POLineItemNo) == 0) - // { + $POLineItemList = array('PONO'=>$NewPO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency); - //print_r($POLineItemList); + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); - // if(count($POLineItem)>0) - // { - foreach($POLineItem as $line): - $LineItemNo = $line['LineItemNo']; - endforeach; - //echo " Last Lineitem no is" . $LineItemNo; + + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + - //} - - // //} - // else - // { - // $LineItemNo = $POLineItemNo; - // $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter); - // $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$POLineItemNo,$POLineItemList); - - // } - - - - // if(trim($POType) == SERVICE ) - // { - // $isExists = $this->purchaseorder_model->LineItemExists($LineItemNo); - - // if(count($isExists) == 0) - // { $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt); - //echo "Service to be stored"; - - //print_r($ServiceTaxList); + $ServiceList =$this->purchaseorder_model->addServiceTax($ServiceTaxList); - //echo "final"; - //print_r($ServiceList); - - - // } - // else - // { - // $ServiceTaxList1 = array('ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt); - - // $this->purchaseorder_model->updateServiceTax($LineItemNo,$ServiceTaxList1); - - // } - - //} - - //} + } - echo 'PO Number'.$PONO . ' Amended Successfully! - New PO Number is'.$NewPO; + echo 'PO Number is'.$PONO . ' is Amended Successfully! - New Amended PO Number is '.$NewPO; } @@ -647,11 +571,7 @@ function UpdateAmendServicePurchaseOrder() $CreateBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); - //echo $RowCount; - //die(); - //$DeletedRow = $this->input->post('txtDeletedRow'); - //$comma_separated = explode(':', $DeletedRow); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); @@ -660,7 +580,7 @@ function UpdateAmendServicePurchaseOrder() $POMaster = array('ParentPO'=>$PONO,'SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'POType'=>$POType,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ExchangeRate'=>$ExchangeRate,'ExchangeRateCalculatedon'=>$ExchangeRateOn,'PaymentTerms'=>$PaymentMethod,'PaymentDays'=>$PaymentDate,'PayableAt'=>$PayableAT,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'CurrencyType'=>$currencytypeID); //print_r($POMaster); - $LastPO = $this->purchaseorder_model->addPOMaster($POMaster); + $LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster,$CreateBy,$PONO); foreach($LastPO as $PO): $NewPO=$PO['PONO']; endforeach; @@ -680,7 +600,7 @@ function UpdateAmendServicePurchaseOrder() for ($i = 1; $i <= $RowCount; $i++) { - //echo "Inside Loopp"; + $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); @@ -737,25 +657,8 @@ function UpdateAmendServicePurchaseOrder() $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); $POLineItemNo = $this->input->post('LineItemNo'.$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") - // { - // if(strlen($POLineItemNo) == 0) - // { + + $POLineItemList = array('PONO'=>$NewPO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); // print_r($POLineItemList); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); @@ -783,31 +686,11 @@ function UpdateAmendServicePurchaseOrder() $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); - //echo "Import"; - - //print_r($ImportList); + } - // } - // else - // { - // $LineItemNo = $POLineItemNo; - - - - // $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); - // $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$LineItemNo,$POLineItemList); - - // $ServiceTaxList = array('ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt); - - // $ServiceTax = $this->purchaseorder_model->updateServiceTax($LineItemNo,$ServiceTaxList); - // $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem); - // $ImportList= $this->purchaseorder_model->updateImportTax($LineItemNo,$ImportTaxList); - - // } - // } } @@ -845,15 +728,7 @@ function UpdateAmendServicePurchaseOrder() $Deliverydt = $this->getDateformat($dt); $DeliverySchedule = ''; } - $PaymentDate=$this->input->post('Payment'); - if($PaymentDate==1) - { - $PaymentDays='After'; - } - else - { - $PaymentDays='Before'; - } + $SpcialInstruction = $this->input->post('txtSpcialInstruction'); $TotalOrder = $this->input->post('txtTotalorderValue'); @@ -865,33 +740,29 @@ function UpdateAmendServicePurchaseOrder() $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); $updateddt = $dt->format('Y-m-d H:i:s'); - //echo "Row Count is:"; - //echo $RowCount; - - //$DeletedRow = $this->input->post('txtDeletedRow'); - - //$comma_separated = explode(':', $DeletedRow); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updateddt = $dt->format('Y-m-d H:i:s'); $PaymentTerms=$this->input->post('PaymentTerms'); $Payableat=$this->input->post('PayableAT'); + echo $RowCount; // PO Master // PO Master - $POMaster = array('ParentPO'=>$PONO,'SupplierID'=>$SupplierID, 'POType'=>$POType,'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'PayableAT'=>$Payableat,'PaymentDays'=>$PaymentDays); - //echo $PONO; - //echo $TotalOrder; - //print_r($POMaster); + $POMaster = array('ParentPO'=>$PONO,'SupplierID'=>$SupplierID, 'POType'=>$POType,'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'ReleasedBy'=>$updatedBy,'ReleasedOn'=>$updateddt); + //print_r($POMaster); - $LastPO = $this->purchaseorder_model->addPOMaster($POMaster); - foreach($LastPO as $PO): - $NewPO=$PO['PONO']; - endforeach; - // echo "NEW PO IS " . $NewPO."
"; - //echo ""; + $LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster,$CreateBy,$PONO); + $NewPO = ''; + if(count($LastPO)>0) + { + $NewPO = $LastPO[0]['PONO']; + } - $PODetail=array('Status'=>"ST030");//TO SET PARENT PO AS AMENDMENT STATUS + //echo $NewPO; + + $PODetail=array('Status'=>PO_AMENDED);//TO SET PARENT PO AS AMENDMENT STATUS // print_r($PODetail); $APO=$this->purchaseorder_model->updateAmendPOMaster($PONO,$PODetail); // echo "Affected Rows:"; @@ -955,72 +826,30 @@ function UpdateAmendServicePurchaseOrder() $Totalvalueitem=$this->input->post('txtTotalorderValue'); $LineItemNo = ''; - //$currencytypeID = $this->input->post('currencytype'); - // $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") - // { - // if(strlen($POLineItemNo) == 0) - // { + $POLineItemList = array('PONO'=>$NewPO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); //print_r($POLineItemList); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); - // // if(count($POLineItem)>0) - // // { - foreach($POLineItem as $line): - $LineItemNo = $line['LineItemNo']; - endforeach; - // //} - // echo "New Line Item is:".$LineItemNo; - - // } - // else - // { - // $LineItemNo = $POLineItemNo; - - // $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter); - // $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$POLineItemNo,$POLineItemList); - - // } - // $isExists = $this->purchaseorder_model->LineItemExistsinImportTax($LineItemNo); - // if(count($isExists) == 0) - // { + + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + // foreach($POLineItem as $line): + // $LineItemNo = $line['LineItemNo']; + // endforeach; + $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem); - //print_r($ImportTaxList); + // print_r($ImportTaxList); //die(); $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); - //echo "DONE ALL"; - //} - // else - // { - // $ImportTaxList = array('LineItemNo'=>$LineItemNo, 'ExchangeRate'=>$Exchangerate,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'CurrencyType'=>$currencytypeID,'TotalValue'=>$Totalvalueitem); - - // //print_r($ImportTaxList); - // //die(); - // $this->purchaseorder_model->updateImportTax($LineItemNo,$ImportTaxList); - - // } - // } + } - echo 'Purchase Order'.$PONO.'Amended Successfully! New PO Number Is: '.$NewPO ; - } + echo 'Purchase Order is'.$PONO.'Amended Successfully! New PO Number is: '.$NewPO ; } function getDateformat($Val) diff --git a/application/controllers/purchaseorder.php b/application/controllers/purchaseorder.php index 3ac113c8..33115d35 100755 --- a/application/controllers/purchaseorder.php +++ b/application/controllers/purchaseorder.php @@ -370,6 +370,7 @@ class purchaseorder extends BaseController $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); //print_r($data['PaymentTerms']); $unicode =''; + $currencycode = ''; foreach ($data['CurrencyDetail'] as $Detail) { $unicode=$Detail->FontCode2000; @@ -379,7 +380,6 @@ class purchaseorder extends BaseController $currencycode=$Detail->Currency_Code; } //print_r($unicode); - $currencycode=''; $data['unicode']=$unicode; $data['currencycode']=$currencycode; $this->global['pageTitle'] = 'Siddharth : Edit Import Purchase order form'; @@ -689,7 +689,7 @@ $DeliveryOption = $this->input->post('DateRange'); $PONO = ''; if(count($POMaster)>0) { - $PONO = $POMaster[0]['PONO']; + $PONO = $POMaster[0]['PONO']; } // PO Line Items @@ -1030,19 +1030,18 @@ $DeliveryOption = $this->input->post('DateRange'); } - public function importpoprint($PONO) { //$this->load->view('includes/pdfheader'); // Load the pdf page with multiviews - $Requester=''; - $Depcode=''; - $Currencycode=''; + $Requester=''; + $Depcode=''; + $Currencycode=''; $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); $data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetailsForPDF($PONO); - + // print_r( $data['POItem']); foreach ($data['POItem'] as $Reqdby) { $Requester=$Reqdby->Requestedby; @@ -1065,6 +1064,7 @@ public function importpoprint($PONO) //print_r($data['Requestername']); $data['Currencytype']=$this->purchaseorder_model->GerCurrencyCodeName($Currencycode); $ProductPrice=''; + $TotalOrderValue = ''; foreach ($data['POItem'] as $PO ) { $TotalOrderValue=$PO->TotalOrderValue; @@ -1081,46 +1081,51 @@ public function importpoprint($PONO) if(!empty($data['POItem'])){ $CurrencyType=$data['POItem'][0]->CurrencyType; } - else{ - } + //echo $CurrencyType; - if($CurrencyType==''){ + if($CurrencyType=='') + { $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR'); - - - $TotalOrderValue=$data['POItem'][0]->$TotalOrderValue; + } + else + { + $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName($CurrencyType); + } + + // $TotalOrderValue=$data['POItem'][0]->$TotalOrderValue; //print_r($data['POItem'][0]); $totalAmt=sprintf("%.2f", $TotalOrderValue); - $data['TotalAmountInWords']= $this->convertNumber($totalAmt); - - } + $data['TotalAmountInWords']= $this->convertNumber($totalAmt); - else{ - $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName($CurrencyType); - //print_r($data['CurrencySymbol']); - $SymbolCurrency=$data['CurrencySymbol'][0]->FontCode2000; - $SymbolCurrencyName=$data['CurrencySymbol'][0]->Currency; - $PaiseVal=$data['CurrencySymbol'][0]->PaiseVal; + - $TotalOrderValue=$data['POItem'][0]->TotalOrderValue; + $SymbolCurrency = ''; + $SymbolCurrencyName =''; + $PaiseVal = ''; + if(!empty($data['CurrencySymbol']) >0) + { + $SymbolCurrency=$data['CurrencySymbol'][0]->FontCode2000; + $SymbolCurrencyName=$data['CurrencySymbol'][0]->Currency; + $PaiseVal=$data['CurrencySymbol'][0]->PaiseVal; + } + $TotalOrderValue=$data['POItem'][0]->TotalOrderValue; $totalAmt=sprintf("%.2f", $TotalOrderValue); $data['TotalAmountInWords']= $this->convertNumberSymbol($totalAmt,$SymbolCurrency,$SymbolCurrencyName,$PaiseVal); - } + - - $this->load->View("importpopdf", $data); + $this->load->View("importpopdf", $data); // Add header to pdf - //$this->load->view('includes/pdffooter'); + $this->load->view('includes/pdffooter'); // Get output html - $php = $this->output->get_output(); + $php = $this->output->get_output(); // Load library $this->load->library('dompdf_gen'); @@ -1130,7 +1135,7 @@ public function importpoprint($PONO) $this->dompdf->load_html($php); $this->dompdf->render(); $data['Attachment'] = FALSE; - //$this->dompdf->stream("ImportPOReport.pdf",$data,$php); + $this->dompdf->stream("ImportPOReport.pdf",$data,$php); } @@ -1182,7 +1187,7 @@ public function importpoprint($PONO) function addNewImportPurchaseOrder() {//echo ("ggh"); - //die(); + $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); @@ -1202,15 +1207,15 @@ function addNewImportPurchaseOrder() $DeliverySchedule = ''; } - // $PaymentDate=$this->input->post('Payment'); - // if($PaymentDate==1) - // { - // $PaymentDays='After'; - // } - // else - // { - // $PaymentDays='Before'; - // } + $PaymentDate=$this->input->post('Payment'); + if($PaymentDate==1) + { + $PaymentDays='After'; + } + else + { + $PaymentDays='Before'; + } //echo $PaymentDays; //die(); @@ -1233,12 +1238,13 @@ function addNewImportPurchaseOrder() $Exchangerate=$this->input->post('ExchangeRate'); $ExchangeRateCalculatedon=$this->input->post('Exchangerateon'); $CurrencyType=$this->input->post('currencytype'); + $PaymentTerms=$this->input->post('PaymentTerms'); - //$Payableat=$this->input->post('PayableAT'); + $Payableat=$this->input->post('PayableAT'); - $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType); + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'PayableAT'=>$Payableat,'PaymentDays'=>$PaymentDays,'POType'=>$POType); //print_r($POList); //die(); @@ -1414,7 +1420,7 @@ $createddt=''; $Payableat=$this->input->post('PayableAT'); // PO Master // PO Master - $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$updateddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms); + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$updateddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'PayableAT'=>$Payableat,'PaymentDays'=>$PaymentDays); //echo $PONO; //echo $TotalOrder; //print_r($POList); @@ -2066,8 +2072,7 @@ $createddt=''; if(!empty($data['POItem'])){ $CurrencyType=$data['POItem'][0]->CurrencyType; } - else{ - } + if($CurrencyType=='' OR $CurrencyType=='0'){ $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR');