load->model('amendment_model'); $this->load->model('purchaseorder_model'); $this->load->library('session'); $this->load->library('form_validation'); // $this->load->library('pagination'); $this->isLoggedIn(); } /** * This function used to load the first screen of the user */ public function index() { $this->load->library('pagination'); // $count = $this->purchaseorder_model->purchaseorderListingCount(''); //$returns = $this->paginationCompress ( "purchaseorderListing/", $count, 10 ); //$this->purchaseorder_model->UpdateRequistionStatus(); CONFORM IT $forwhat='amendment'; $data['POData'] = $this->purchaseorder_model->purchaseorderListing($forwhat); $this->global['pageTitle'] = 'Siddharth : Amendment Purchase Order'; $this->loadviews('AmendPOlist',$this->global,$data,NULL); } function EditAmendPurchaseOrder() { $PONO = $_GET['PONO']; $ReqType = $_GET['ReqType']; $Req = $this->purchaseorder_model->getRequistionNoFromPO($PONO); $data['ReqList'] = $Req ; $result = array(); $ReqArray = array(); foreach ($Req as $SID): $ReqArray[] = $SID->ReqNo ; $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); endforeach; $data['MaterialList'] = $result;//$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray); $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); $data['Payment']=$this->purchaseorder_model->getConfigValue('C009'); $data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR'); //print_r($data['Payment']); /* Cost code from Requisition - Client Review Fix Start here */ $ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray); $data['RequistionDetails'] = $ReqDetails; $CostCode = ''; $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $Year = $dt->format('Y'); foreach ($ReqDetails as $Rs): $CostCode = $Rs->CostCenterCode; endforeach; $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType); if(count($AvlBudget)>0) { $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; } /* End Here */ $data['POMaster'] = $this->purchaseorder_model->GetServicePurchaseOrder($PONO); $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); if($ReqType == SERVICE) { $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetails($PONO); $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); $data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); $this->global['pageTitle'] = 'Siddharth : Edit Service Purchase order form'; $this->loadViews("editServiceAmendPO", $this->global, $data, NULL); } else if($ReqType == REVENUE) { //$data['Payment']=$this->purchaseorder_model->getSupplierPayment(); $data['POSTATUS']=$this->purchaseorder_model->GetPOStatus($PONO); $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetails($PONO); $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); //echo "FROM CON"; //print_r($data['Payment']); $this->global['pageTitle'] = 'Siddharth : Edit Revenue Purchase order form'; $this->loadViews("editRevenueAmendPO", $this->global, $data, NULL); } else if($ReqType == IMPORT) { $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType); if(count($AvlBudget)>0) { $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; } // print_r($data); $data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetails($PONO); $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); foreach($data['POMaster'] as $CUR) { //print_r($CUR->CurrencyType); $Currency=$CUR->CurrencyType; } // $data[$Rate->ExchangeRate]=$Rate->ExchangeRate; $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); //print_r($data['PaymentTerms']); $unicode =''; foreach ($data['CurrencyDetail'] as $Detail) { $unicode=$Detail->FontCode2000; } foreach ($data['CurrencyDetail'] as $Detail) { $currencycode=$Detail->Currency_Code; } //print_r($unicode); $data['unicode']=$unicode; $data['currencycode']=$currencycode; $this->global['pageTitle'] = 'Siddharth : Edit Import Purchase order form'; $this->loadViews("editImportAmendPO", $this->global, $data, NULL); } else if($ReqType == CAPITAL) { $CapitalRange = $_GET['CapitalRange']; $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType); if(count($AvlBudget)>0) { $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; } if($CapitalRange=='0'){ $data['POItem'] = $this->purchaseorder_model->getCapitalPurchaseOrderDetails($PONO); } else if($CapitalRange=='1'){ $data['POItem'] = $this->purchaseorder_model->getDomesticCapitalPurchaseOrderDetails($PONO); } $data['requestedBy'] = $this->purchaseorder_model->GetRequesedByDetails($PONO); $CapitalRange=''; foreach($data['POItem'] as $Rate) { $exRate=$Rate->ExchangeRate; $CapitalRange=$Rate->CapitalRange; } foreach($data['POItem'] as $CUR) { $Currency=$CUR->CurrencyType; } if($CapitalRange=='0'){ $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); $data['ExchangeRate']=$exRate; $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); } else if($CapitalRange=='1'){ $data['CurrencyDetail']=''; $data['ExchangeRate']=$exRate; $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); } $this->global['pageTitle'] = 'Siddharth : Edit Capital Purchase order form'; $this->loadViews("editCapitalAmendPO", $this->global, $data, NULL); } } function EditRevenuePurchaseOrder() { $NewPO='0'; $PONO =$this->input->post('txtPONO'); //echo "OLD PO IS" . $PONO; $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); $POType = $this->input->post('POType'); $DeliveryAddr = $this->input->post('txtDeliveryAddress'); $dt = $this->input->post('Deliverydt'); //$Deliverydt = $this->getDateformat($dt); $DeliveryOption = $this->input->post('DateRange'); if($DeliveryOption==1){ $Deliverydt = ''; $DeliverySchedule = $this->input->post('Scheduleby'); } else{ $Deliverydt = $this->getDateformat($dt); $DeliverySchedule = ''; } $POType = $this->input->post('POType'); $PoRange = $this->input->post('txtPoRange'); $PaymentTerms=$this->input->post('PaymentTerms'); $PayableAT=$this->input->post('PayableAT'); $PaymentDate=$this->input->post('Payment'); if($PaymentDate==1) { $PaymentDays='After'; } else { $PaymentDays='Before'; } // echo $PaymentTerms; // echo $PayableAT; // echo $PaymentDays; // echo "FINAL"; $SpcialInstruction = $this->input->post('SpcialInstruction'); $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); $POStatus = $this->input->post('txtStatus'); $updatedBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); //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'); // PO Master // PO Master $POMaster = array('ParentPO'=>$PONO,'SupplierID'=>$SupplierID,'POType'=>$POType,'PaymentTerms'=> $PaymentTerms,'PayableAT'=>$PayableAT,'PaymentDays'=>$PaymentDays,'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>'ST015','DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt ); //print_r($POMaster); //$POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); $LastPO = $this->purchaseorder_model->addPOMaster($POMaster); foreach($LastPO as $PO): $NewPO=$PO['PONO']; endforeach; //echo "NEW PO IS " . $NewPO; //echo ""; //change old po status as Amendment $PODetail=array('Status'=>"ST030");//TO SET PARENT PO AS AMENDMENT STATUS //print_r($PODetail); $APO=$this->purchaseorder_model->updateAmendPOMaster($PONO,$PODetail); echo $APO."Affected"; //die(); //print_r($LastPO); $LineItemStatus = REQITEM_NEW; //echo 'before for loop'; //echo $RowCount; for ($i = 1; $i <= $RowCount; $i++) { //echo "inside loop"; $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); $DiscountType = $this->input->post('DisType'.$i); $DiscountValue = $this->input->post('DisVal'.$i); $AfterDiscount = $this->input->post('AfterDisVal'.$i); $PackagingOption = $this->input->post('PackOption'.$i); $PackagingType = $this->input->post('PackType'.$i); $PackagingValue = $this->input->post('PackVal'.$i); $AfterPackagingValue = $this->input->post('AfterPackVal'.$i); $ExciseOption = $this->input->post('ExciseOption'.$i); $ExciseValue = $this->input->post('ExciseVal'.$i); $AfterExciseValue = $this->input->post('AfterExciseVal'.$i); $VatOption = $this->input->post('VatOption'.$i); $VatValue = $this->input->post('VatVal'.$i); $AfterVatValue = $this->input->post('AfterVatVal'.$i); $CSTOption = $this->input->post('CSTOption'.$i); $CSTValue = $this->input->post('CSTVal'.$i); $AfterCSTValue = $this->input->post('AfterCSTVal'.$i); $GSTValue = $this->input->post('GSTVal'.$i); $AfterGSTValue = $this->input->post('AfterGSTVal'.$i); $OtherTaxValue = $this->input->post('OtherTaxVal'.$i); $AfterOtherTaxValue = $this->input->post('AfterOtherTaxVal'.$i); $FreightType = $this->input->post('FreightType'.$i); $FreightValue = $this->input->post('FreightVal'.$i); $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); $InsuranceValue = $this->input->post('Insval'.$i); $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); $POLineItemNo = $this->input->post('LineItemNo'.$i); $CostCenter = $this->input->post('costCode'.$i); $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); //print_r($POLineItemList); //die(); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); //print_r($POLineItem); // if(count($POLineItem)>0) // { foreach($POLineItem as $line): $LineItemNo = $line['LineItemNo']; endforeach; //echo "Lineitem no is" . $LineItemNo; //print_r($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->LineItemExistsinRevenueTax($LineItemNo); // if(count($isExists) == 0) // { $RevenueTaxList = array('LineItemNo'=>$LineItemNo, 'DiscountType'=>$DiscountType,'DiscountValue'=>$DiscountValue,'AfterDiscount'=>$AfterDiscount,'PackagingType'=>$PackagingType,'PackagingValue'=>$PackagingValue,'PackagingCalulatedOn'=>$PackagingOption,'AfterPackagingValue'=>$AfterPackagingValue,'FreightType'=>$FreightType, 'FreightValue'=>$FreightValue,'AfterFreightValue'=>$AfterFreightValue,'ExciseDuty'=>$ExciseValue,'ExciseDutyCalulatedOn'=>$ExciseOption,'AfterExciseDuty'=>$AfterExciseValue,'Vat'=>$VatValue,'AfterVAT'=>$AfterVatValue,'VatCalulatedOn'=>$VatOption, 'CST'=>$CSTValue,'AfterCST'=>$AfterCSTValue,'CSTCalulatedOn'=>$CSTOption,'GST'=>$GSTValue,'AfterGST'=>$AfterGSTValue,'OtherTaxes'=>$OtherTaxValue,'AfterOtherTaxes'=>$AfterOtherTaxValue,'Insurance'=>$InsuranceValue,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt); $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); //echo "DONE ALL"; // } // else // { // $RevenueTaxList = array('DiscountType'=>$DiscountType,'DiscountValue'=>$DiscountValue,'AfterDiscount'=>$AfterDiscount,'PackagingType'=>$PackagingType,'PackagingValue'=>$PackagingValue,'PackagingCalulatedOn'=>$PackagingOption,'AfterPackagingValue'=>$AfterPackagingValue,'FreightType'=>$FreightType, 'FreightValue'=>$FreightValue,'AfterFreightValue'=>$AfterFreightValue,'ExciseDuty'=>$ExciseValue,'ExciseDutyCalulatedOn'=>$ExciseOption,'AfterExciseDuty'=>$AfterExciseValue,'Vat'=>$VatValue,'AfterVAT'=>$AfterVatValue,'VatCalulatedOn'=>$VatOption, 'CST'=>$CSTValue,'AfterCST'=>$AfterCSTValue,'CSTCalulatedOn'=>$CSTOption,'GST'=>$GSTValue,'AfterGST'=>$AfterGSTValue,'OtherTaxes'=>$OtherTaxValue,'AfterOtherTaxes'=>$AfterOtherTaxValue,'Insurance'=>$InsuranceValue,'TotalValue'=>$TotalOrderValue, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt); // $this->purchaseorder_model->updateRevenueTax($LineItemNo,$RevenueTaxList); // } } echo 'Purchase Order Amended Successfully! PO Number Is: '.$PONO .'- New PO Number is'.$NewPO; } 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'; } $PaymentTerms=$this->input->post('PaymentTerms'); $Payableat=$this->input->post('PayableAT'); $POType = $this->input->post('POType'); $SpcialInstruction = $this->input->post('SpcialInstruction'); $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); $POStatus = $this->input->post('txtStatus'); $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 ); //print_r($POMaster); $LastPO = $this->purchaseorder_model->addPOMaster($POMaster); //print_r($LastPO); foreach($LastPO as $PO): $NewPO=$PO['PONO']; endforeach; //echo "NEW PO IS " . $NewPO; //echo ""; $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++) { //echo "Inside Loop"; $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); $ServiceTax = $this->input->post('ServiceTax'.$i); $EduCess = $this->input->post('EduCess'.$i); $SecHighTax = $this->input->post('SecHighTax'.$i); $KrishiTax = $this->input->post('KrishiTax'.$i); $SwachhTax = $this->input->post('SwachhTax'.$i); $CostCenter = $this->input->post('costCode'.$i); $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; //} // //} // 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; } function EditAmendCapitalPurchaseOrder() { //echo "WELCOME-"; $PONO =$this->input->post('txtPONO'); //echo $PONO."--"; $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); $DeliveryAddr = $this->input->post('DeliveryAddr'); $dt = $this->input->post('Deliverydt'); $POType = $this->input->post('POType'); $PoRange = $this->input->post('txtPoRange'); $DeliveryOption = $this->input->post('DateRange'); if($DeliveryOption==1){ $Deliverydt = ''; $DeliverySchedule = $this->input->post('Scheduleby'); } else{ $Deliverydt = $this->getDateformat($dt); $DeliverySchedule = ''; } $capitalType = $this->input->post('capitalType'); $currencytypeID = $this->input->post('currencytype'); if($capitalType=='1'){ $CapitalRange = '1'; $ExchangeRateOn = ''; $ExchangeRate=''; } else{ $CapitalRange = '0'; $ExchangeRateOn = $this->input->post('ExchangeRateOn'); $ExchangeRate=$this->input->post('ExchangeRt'); } $PaymentMethod = $this->input->post('PaymentMethod'); $PayableAT = $this->input->post('PayableAT'); $PaymentDate=$this->input->post('PaymentDate'); $SpcialInstruction = $this->input->post('txtSpcialInstruction'); $TotalOrder = $this->input->post('CapitalToatlOrder'); $POStatus = $this->input->post('txtStatus'); $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'); $updateddt = $dt->format('Y-m-d H:i:s'); $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); foreach($LastPO as $PO): $NewPO=$PO['PONO']; endforeach; //echo "NEW PO IS " . $NewPO."
"; //echo ""; $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 Loopp"; 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); $itemRate = $this->input->post('itemRate'.$i); $Exchangerate = $this->input->post('echangeRate'.$i); $BasicPriceinmton = $this->input->post('rateInUs'.$i); $Productprice = $this->input->post('basicvalInINR'.$i); $LandingCharge = $this->input->post('beforeLanding'.$i); $AfterLandingCharge = $this->input->post('landingCharge'.$i); $HighSeas = $this->input->post('beforeHighSeasSalesCharge'.$i); $AfterHighSeas = $this->input->post('HighSeasSalesCharge'.$i); $CustomDuty = $this->input->post('beforeCustomDuty'.$i); $AfterCustomDuty = $this->input->post('CustomDuty'.$i); $ExciseDuty = $this->input->post('beforeExciseDuty'.$i); $AfterExciseDuty = $this->input->post('ExciseDuty'.$i); $ExciseDutyEd = $this->input->post('beforeExciseDutyEDCess'.$i); $AfterExciseDutyEd = $this->input->post('ExciseDutyEDCess'.$i); $ExciseDutySH = $this->input->post('beforeExciseDutySHCess'.$i); $AfterExciseDutySH = $this->input->post('ExciseDutySHCess'.$i); $CustomEd= $this->input->post('beforeCustomEDCess'.$i); $AfterCustomEd= $this->input->post('CustomEDCess'.$i); $CustomSH = $this->input->post('beforeCustomSHCess'.$i); $AfterCustomSH = $this->input->post('CustomSHCess'.$i); $AddAdtional = $this->input->post('beforeAdditionalExciseDuty'.$i); $AfterAddAdtional = $this->input->post('AdditionalExciseDuty'.$i); $Grossdutypayable = $this->input->post('GrossDutyPayable'.$i); $AvailableModvat = $this->input->post('AvailableModvat'.$i); $Grossexpensesduetocustomduty = $this->input->post('GrossExpensesDuetoCustom'.$i); $purchaseratePerKG = $this->input->post('purchaseRate'.$i); $CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpenses'.$i); $RMCIncludingCustomersPerKG = $this->input->post('RMCIncludingCustomers'.$i); $QuantityKG = $this->input->post('PurQuantity'.$i); $Totalvalueitem=$this->input->post('PerKgExpense'.$i); //echo $BasicPriceinmton; $CostCenter = $this->input->post('CPCostCode'.$i); $ServiceTax = $this->input->post('AfterServiceTax'.$i); $EduCess = $this->input->post('AfterEduCess'.$i); $SecHighTax = $this->input->post('AfterSecHighTax'.$i); $KrishiTax = $this->input->post('AfterKrishiTax'.$i); $SwachhTax = $this->input->post('AfterSwachhTax'.$i); $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); $LineItemNo = ''; // if(count($POLineItem)>0) // { foreach($POLineItem as $line): $LineItemNo = $line['LineItemNo']; endforeach; //echo $LineItemNo; //} //echo $LineItemNo; if(trim($POType) == CAPITAL ) { $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt); $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); //echo "Service"; //print_r($ServiceTax); $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); //die(); $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); // } // } } echo 'Purchase Order'.$PONO.'Amended Successfully! New PO Number Is: '.$NewPO ; } function EditAmendImportPO() { $PONO =$this->input->post('txtPONO'); //echo $PONO; $POdt = ''; $createddt=''; $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); $DeliveryAddr = $this->input->post('DeliveryAddr'); $dt = $this->input->post('Deliverydt'); $Deliverydt = $this->getDateformat($dt); $POType = $this->input->post('POType'); $PoRange = $this->input->post('txtPoRange'); $DeliveryOption = $this->input->post('DateRange'); $Exchangerate=$this->input->post('ExchangeRate'); $ExchangeRateCalculatedon=$this->input->post('Exchangerateon'); $CurrencyType=$this->input->post('currencytype'); 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'; } $SpcialInstruction = $this->input->post('txtSpcialInstruction'); $TotalOrder = $this->input->post('txtTotalorderValue'); //echo "Total Order:".$TotalOrder; $POStatus = $this->input->post('txtStatus'); $CreateBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); $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'); // 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); $LastPO = $this->purchaseorder_model->addPOMaster($POMaster); foreach($LastPO as $PO): $NewPO=$PO['PONO']; endforeach; // echo "NEW PO IS " . $NewPO."
"; //echo ""; $PODetail=array('Status'=>"ST030");//TO SET PARENT PO AS AMENDMENT STATUS // print_r($PODetail); $APO=$this->purchaseorder_model->updateAmendPOMaster($PONO,$PODetail); // echo "Affected Rows:"; // print_r($APO); $LineItemStatus = REQITEM_NEW; //echo "Before Loop"; for ($i = 1; $i <= $RowCount; $i++) { //echo "Inside Loop"; $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); //$Exchangerate = $this->input->post('Exchangerate'.$i); $BasicPriceinmton = $this->input->post('BasicPriceInMTon'.$i); $Productprice = $this->input->post('ProductPrice'.$i); $LandingCharge = $this->input->post('LandingCharge'.$i); $AfterLandingCharge = $this->input->post('AfterLandingCharge'.$i); $HighSeas = $this->input->post('HighSeasSalesCharge'.$i); $AfterHighSeas = $this->input->post('AfterHighSeasSalesCharge'.$i); $CustomDuty = $this->input->post('CustomDuty'.$i); $AfterCustomDuty = $this->input->post('AfterCustomDuty'.$i); $ExciseDuty = $this->input->post('ExciseDuty'.$i); $AfterExciseDuty = $this->input->post('AfterExciseDuty'.$i); $ExciseDutyEd = $this->input->post('ExciseDutyEdCess'.$i); $AfterExciseDutyEd = $this->input->post('AfterExciseDutyEdCess'.$i); $ExciseDutySH = $this->input->post('ExciseDutySHCess'.$i); $AfterExciseDutySH = $this->input->post('AfterExciseDutySHCess'.$i); $CustomEd= $this->input->post('CustomEdCess'.$i); $AfterCustomEd= $this->input->post('AfterCustomEdCess'.$i); $CustomSH = $this->input->post('CustomSHCess'.$i); $AfterCustomSH = $this->input->post('AfterCustomSHCess'.$i); $AddAdtional = $this->input->post('AddlExciseDuty'.$i); $AfterAddAdtional = $this->input->post('AfterAddlExciseDuty'.$i); $Grossdutypayable = $this->input->post('Grossdutypayable'.$i); $AvailableModvat = $this->input->post('AvailableModvat'.$i); $Grossexpensesduetocustomduty = $this->input->post('Grossexpensesduetocustomduty'.$i); $purchaseratePerKG = $this->input->post('purchaseratePerKG'.$i); $CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpensesPerKG'.$i); $RMCIncludingCustomersPerKG = $this->input->post('RMCIncludingCustomersPerKG'.$i); $QuantityKG = $this->input->post('QuantityKG'.$i); //$POLineItemNo = $this->input->post('LineItemNo'.$i); $CostCenter = $this->input->post('costCode'.$i); $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) // { $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); //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 ; } function getDateformat($Val) { $date = new DateTime($Val,new DateTimeZone('Asia/Kolkata')); $retDate = $date->format('Y-m-d H:i:s'); return $retDate; } }