load->model('purchaseorder_model'); $this->load->library('session'); $this->load->library('form_validation'); $this->isLoggedIn(); } /** * Index Page for this controller(default function of the class) */ public function index() { $this->load->library('pagination'); $forwhat='amendment'; $data['POData'] = $this->purchaseorder_model->purchaseorderListing($forwhat); $this->global['pageTitle'] = 'Siddharth : Amendment Purchase Order'; $this->loadviews('AmendPOlist',$this->global,$data,NULL); } /** * For editing purpose and it has oldest all released po. */ function EditAmendPurchaseOrder() { $PONO = $_GET['PONO']; $ReqType = $_GET['ReqType']; $Req = $this->purchaseorder_model->getRequistionNoFromPO($PONO); $data['ReqList'] = $Req ; $result = array(); $ReqArray = array(); $Status = ''; foreach ($Req as $SID): $ReqArray[] = $SID->ReqNo ; $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); endforeach; $data['MaterialList'] = $result; $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); $data['Payment']=$this->purchaseorder_model->getPaymentTermsDetails(); $data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR'); /* Cost code from Requisition - Client Review Fix Start here */ $ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray); $data['RequistionDetails'] = $ReqDetails; foreach ($data['RequistionDetails'] as $ReqDet) { $Status=$ReqDet->Status; } $data['POSTATUS']=$this->purchaseorder_model->GetPOStatus($Status); foreach ($data['POSTATUS'] as $POST) { $Status=$POST->StatusName; } $CostCode = ''; $this->load->model('costcenter_model'); $FYStart = ''; $FYEnd = ''; $FiscalYear = $this->costcenter_model->getFiscalYear(); if(!empty($FiscalYear)) { foreach ($FiscalYear as $Fy) { $FYStart =$Fy->StartYear; $FYEnd =$Fy->EndYear; } } $FYdt = $FYStart." - ".$FYEnd ; foreach ($ReqDetails as $Rs): $CostCode = $Rs->CostCenterCode; endforeach; $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$FYdt,$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'); $data['PoTypeOptions'] = $this->purchaseorder_model->getConfigValue('C026'); if($ReqType == SERVICE) { $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetails($PONO); $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); $this->global['pageTitle'] = 'Siddharth : Edit Service Purchase order form'; $this->loadViews("editServiceAmendPO", $this->global, $data, NULL); } else if($ReqType == REVENUE) { $data['POSTATUS']=$this->purchaseorder_model->GetPOStatus($PONO); $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetails($PONO); $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); $this->global['pageTitle'] = 'Siddharth : Edit Revenue Purchase order form'; $this->loadViews("editRevenueAmendPO", $this->global, $data, NULL); } else if($ReqType == IMPORT) { $AvlBudget = $this->purchaseorder_model->GetAvailableImportBudgetAmount($CostCode,$FYdt,$ReqType); if(count($AvlBudget)>0) { $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; } $data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetails($PONO); $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); $data['PoTypeOptions'] = $this->purchaseorder_model->getConfigValue('C026'); foreach($data['POMaster'] as $CUR) { $Currency=$CUR->CurrencyType; } $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); $data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR'); $unicode =''; foreach ($data['CurrencyDetail'] as $Detail) { $unicode=$Detail->FontCode2000; } foreach ($data['CurrencyDetail'] as $Detail) { $currencycode=$Detail->Currency_Code; } $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']; $CapitalAvlBudget = $this->purchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode,$FYdt,$ReqType); if(count($CapitalAvlBudget)>0) { $data['AvlCapitalBudAmt'] = $CapitalAvlBudget[0]['BudgetAmount'] - $CapitalAvlBudget[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); } } /** * To Store release Revenue Po values after edit */ function EditRevenuePurchaseOrder() { $NewPO=''; $MAD=''; $PONO =$this->input->post('txtPONO'); $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'); $predeliverydate=$this->input->post('beforeDeliverydt'); $preschedule=$this->input->post('beforeScheduleby'); $DeliverySchedule1 = $this->input->post('Scheduleby'); $DeliveryOption = $this->input->post('DateRange'); if($DeliveryOption==1){ $Deliverydt=null; $DeliverySchedule = $this->input->post('Scheduleby'); } else{ $Deliverydt = $this->getDateformat($dt); $DeliverySchedule = ''; } $Modeofshipment=$this->input->post('addmodeofshipment'); $supplierreference=$this->input->post('amendsupplierreference'); $supplieroffno=$this->input->post('amendsupplierofferno'); $otherreference=$this->input->post('amendotherreference'); $fincap=$this->input->post('amendfincap'); $revenuetype=$this->input->post('PoTypeOptions'); $insurancestatus=$this->input->post('insurancestatus'); if($insurancestatus == 1){ $insuranceno=$this->input->post('insuranceno'); }else{ $insuranceno=""; } $POType = $this->input->post('POType'); $PoRange = $this->input->post('Range'); $PaymentTermsText=$this->input->post('beforePaymentTermsText'); $PaymentTerms=$this->input->post('PaymentTerms'); $Otherpayment=$this->input->post('Otherpayment'); $Otherpaymentamend=$this->input->post('Otherpayment'); $prePaymentTerms=$this->input->post('beforePaymentTerms'); $preTotalOdervalue=$this->input->post('preTotalOdervalue'); $MAD.="Current TotalOrder Value:  :" . $preTotalOdervalue ."
"; $testdate=date("Y-m-d"); if($PaymentTerms!=$prePaymentTerms) { if($prePaymentTerms != 'PT08'){ $Otherpaymentamend='';} $MAD.="Current PaymentTerms :  ". $PaymentTermsText . $Otherpaymentamend ."
"; } if(($dt != $predeliverydate)|| ($DeliverySchedule1 != $preschedule)) { $MAD.='Current Delivery Option :    ' . $predeliverydate . $preschedule . '
' ; } $SpecialInstruction = $this->input->post('txtSpcialInstruction'); $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); $POStatus = $this->input->post('txtStatus'); $updatedBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); $dtt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updateddt = $dtt->format('Y-m-d H:i:s'); $qtycheck = $this->purchaseorder_model->getqtycheck($PONO); $qtycheckresult=''; foreach($qtycheck as $qty) { $qtycheckresult= $qty->IsQualityChkReqired; } if(empty($Deliverydt)) { $Deliverydt=null; } if($PaymentTerms != 'PT08'){ $Otherpayment=''; } $POMaster = array('ParentPO'=>$PONO,'SupplierID'=>$SupplierID,'POType'=>$POType,'PORange'=>$PoRange,'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>PO_RELEASED,'PaymentTerms'=>$PaymentTerms,'PaymentOtherDescription'=>$Otherpayment,'Mode_Of_Shipment'=>$Modeofshipment,'Supplier_Reference'=>$supplierreference,'Supplier_Offer_No'=>$supplieroffno,'Other_Reference'=>$otherreference,'Fincap'=>$fincap,'InsuranceStatus'=>$insurancestatus,'InsuranceNumber'=>$insuranceno,'POSubType'=>$revenuetype,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpecialInstruction,'CreatedBy'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt,'ReleasedBy'=>$updatedBy,'ReleasedOn'=>$updateddt,'AmendedDetails'=>$MAD,'IsQualityChkReqired'=>$qtycheckresult); $LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster,$updatedBy,$PONO); if(count($LastPO)>0) { $NewPO = $LastPO[0]['PONO']; } $PODetail=array('Status'=>PO_AMENDED);//TO SET PARENT PO AS AMENDMENT STATUS $APO=$this->purchaseorder_model->updateAmendPOMaster($PONO,$PODetail); $LineItemStatus = REQITEM_NEW; $igrvalue = $this->purchaseorder_model->selectigrmaster($PONO); $po = ''; $igrno =''; // if(count($igrvalue) >0) // { // $igrno = $igrvalue[0]->IGRNO; // $po =$igrvalue[0]->PONO; // } foreach ($igrvalue as $value) { $igrno = $value->IGRNO; $po =$value->PONO; // print_r($igrno); if($PONO == $po) { $NewPOno = array('PONO' =>$NewPO); // print_r($NewPOno); $this->purchaseorder_model->updateigrmaster($igrno,$NewPOno); $this->purchaseorder_model->updateigrfile($igrno,$NewPOno); } } for ($i = 1; $i <= $RowCount; $i++) { $CAD=''; $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); $preqty=$this->input->post('beforeqty'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); $preitemrate=$this->input->post('beforeitemRate'.$i); $per=$this->input->post('per'.$i); $servicematerialdescription=$this->input->post('service_description'.$i); $DiscountType = $this->input->post('DisType'.$i); $beforeDiscountType = $this->input->post('beforeDisType'.$i); $DiscountValue = $this->input->post('DisVal'.$i); $preDiscountValue = $this->input->post('beforeDisVal'.$i); $AfterDiscount = $this->input->post('AfterDisVal'.$i); $beforeAfterDiscount = $this->input->post('beforeAfterDisVal'.$i); $PackagingOption = $this->input->post('PackOption'.$i); $PackagingType = $this->input->post('PackType'.$i); $beforePackagingType = $this->input->post('beforePackType'.$i); $PackagingValue = $this->input->post('PackVal'.$i); $prePackagingValue = $this->input->post('beforePackVal'.$i); $AfterPackagingValue = $this->input->post('AfterPackVal'.$i); $beforeAfterPackagingValue = $this->input->post('beforeAfterPackVal'.$i); $VatValue = $this->input->post('VatVal'.$i);//SGST $preVatValue = $this->input->post('beforeVatVal'.$i); $AfterVatValue = $this->input->post('AfterVatVal'.$i); $beforeAfterVatValue = $this->input->post('beforeAfterVatVal'.$i); $GSTValue = $this->input->post('GSTVal'.$i);//CGST $preGSTValue = $this->input->post('beforeGSTVal'.$i); $AfterGSTValue = $this->input->post('AfterGSTVal'.$i); $beforeAfterGSTValue = $this->input->post('beforeAfterGSTVal'.$i); $OtherTaxValue = $this->input->post('OtherTaxVal'.$i);//IGST $preOtherTaxValue = $this->input->post('beforeOtherTaxVal'.$i); $AfterOtherTaxValue = $this->input->post('AfterOtherTaxVal'.$i); $beforeAfterOtherTaxValue = $this->input->post('beforeAfterOtherTaxVal'.$i); $FreightType = $this->input->post('FreightType'.$i); $beforeFreightType = $this->input->post('beforeFreightType'.$i); $FreightValue = $this->input->post('FreightVal'.$i); $preFreightValue = $this->input->post('beforeFreightVal'.$i); $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); $beforeAfterFreightValue = $this->input->post('beforeAfterFreightVal'.$i); $NoofTrips = $this->input->post('Nooftrips'.$i); $beforeNoofTrips = $this->input->post('beforeNooftrips'.$i); $InsuranceValue = $this->input->post('Insval'.$i); $preInsuranceValue = $this->input->post('beforeInsval'.$i); $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); $POLineItemNo = $this->input->post('LineItemNo'.$i); $CostCenter = $this->input->post('costCode'.$i); $ServiceFrequency=$this->input->post('Frequency'.$i); $LineItemNo = ''; $RecQtyvalue=0.00; $rowspanvalue=0; if(($Quantity-$preqty)!=0) { $rowspanvalue++; $CAD.="Current Quantity : ".$preqty ."Revised Qty : ".$Quantity.""; } if(($itemRate-$preitemrate)!=0) { $rowspanvalue++; $CAD.="Current Rate : " . $preitemrate."Revised Item Rate : ".$itemRate.""; } if($DiscountType != $beforeDiscountType){ $rowspanvalue++; $CAD.="Current DiscountType : " . $beforeDiscountType."Revised DiscountType : ".$DiscountType.""; } if(($DiscountValue-$preDiscountValue)!=0) { $rowspanvalue++; $CAD.="Current Discount : ". $preDiscountValue ."Revised Discount : ".$DiscountValue.""; } if(($AfterDiscount-$beforeAfterDiscount)!=0) { $rowspanvalue++; $CAD.="Current Discount Value : ". $beforeAfterDiscount ."Revised Discount Value : ".$AfterDiscount.""; } if($PackagingType != $beforePackagingType){ $rowspanvalue++; $CAD.="Current Packaging Type : ". $beforePackagingType ."Revised Packaging Type : ".$PackagingType.""; } if(($PackagingValue-$prePackagingValue)!=0) { $rowspanvalue++; $CAD.="Current Package Value : ". $prePackagingValue."Revised Package Value : ".$PackagingValue.""; } if(($AfterPackagingValue-$beforeAfterPackagingValue)!=0) { $rowspanvalue++; $CAD.="Current Package Value : ". $beforeAfterPackagingValue."Revised Package Value : ".$AfterPackagingValue.""; } if(($VatValue-$preVatValue)!=0)//SGST { $rowspanvalue++; $CAD.="Current SGST : ". $preVatValue."Revised SGST : ".$VatValue.""; } if(($AfterVatValue-$beforeAfterVatValue)!=0)//SGST { $rowspanvalue++; $CAD.="Current SGST value : ". $beforeAfterVatValue."Revised SGST Value : ".$AfterVatValue.""; } if(($GSTValue-$preGSTValue)!=0)//CGST { $rowspanvalue++; $CAD.="Current CGST : ". $preGSTValue."Revised CGST : ".$GSTValue.""; } if(($AfterGSTValue-$beforeAfterGSTValue)!=0)//CGST { $rowspanvalue++; $CAD.="Current CGST Value : ". $beforeAfterGSTValue."Revised CGST Value : ".$AfterGSTValue.""; } if(($OtherTaxValue-$preOtherTaxValue)!=0)//IGST { $rowspanvalue++; $CAD.="Current IGST : ". $preOtherTaxValue."Revised IGST : ".$OtherTaxValue.""; } if(($AfterOtherTaxValue-$beforeAfterOtherTaxValue)!=0)//IGST { $rowspanvalue++; $CAD.="Current IGST : ". $beforeAfterOtherTaxValue."Revised IGST : ".$AfterOtherTaxValue.""; } if($FreightType != $beforeFreightType){ $rowspanvalue++; $CAD.="Current Freight Type : ". $beforeFreightType."Revised Freight Type : ".$FreightType.""; } if(($FreightType=="PER TRIP") || ($beforeFreightType=="PER TRIP")){ if($NoofTrips != $beforeNoofTrips) { $rowspanvalue++; $CAD.="Current No of Trips : ". $beforeNoofTrips."Revised No of Trips : ".$NoofTrips.""; } } if(($FreightValue-$preFreightValue)!=0) { $rowspanvalue++; $CAD.="Current Freight : ". $preFreightValue."Revised Freight : ".$FreightValue.""; } if(($AfterFreightValue-$beforeAfterFreightValue)!=0) { $rowspanvalue++; $CAD.="Current Freight Value : ". $beforeAfterFreightValue."Revised Freight Value : ".$AfterFreightValue.""; } if(($InsuranceValue-$preInsuranceValue)!=0) { $rowspanvalue++; $CAD.="Current Insurance Value : ". $preInsuranceValue."Revised Insurance Value : ".$InsuranceValue.""; } if($rowspanvalue>0) { $rowspanvalue++; $CAD2=''; $CAD2=$CAD; $CAD=''; $CAD="".$MaterialCode.""; $CAD.=$CAD2; } $ReceivedQty = $this->purchaseorder_model->GetLineItemReceivedQty($PONO,$MaterialCode); if(count($ReceivedQty)>0) { $RecQtyvalue = $ReceivedQty[0]['ReceivedQuantity']; } $POLineItemList = array('PONO'=>$NewPO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'ReceivedQuantity'=>$RecQtyvalue,'Quantity'=>$Quantity,'Per'=>$per,'ServiceMaterialDescription'=>$servicematerialdescription,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency,'AmendedDetails'=>$CAD); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); if(count($POLineItem)>0) { $LineItemNo = $POLineItem[0]['LineItemNo']; } $RevenueTaxList = array('LineItemNo'=>$LineItemNo, 'DiscountType'=>$DiscountType,'DiscountValue'=>$DiscountValue,'AfterDiscount'=>$AfterDiscount,'PackagingType'=>$PackagingType,'PackagingValue'=>$PackagingValue,'PackagingCalulatedOn'=>$PackagingOption,'AfterPackagingValue'=>$AfterPackagingValue,'FreightType'=>$FreightType,'NoOfTrip'=>$NoofTrips,'FreightValue'=>$FreightValue,'AfterFreightValue'=>$AfterFreightValue,'SGST'=>$VatValue,'AfterSGST'=>$AfterVatValue,'CGST'=>$GSTValue,'AfterCGST'=>$AfterGSTValue,'IGST'=>$OtherTaxValue,'AfterIGST'=>$AfterOtherTaxValue,'Insurance'=>$InsuranceValue,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt); $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); } $qty = $this->purchaseorder_model->getpolineqty($NewPO); $ordqty =''; $recqty =''; // $POno=''; // sum(Quantity)as Qty,sum(ReceivedQuantity)as rec // foreach ($qty as $qtyvalue) // { $ordqty = $qty[0]->Qty; $recqty = $qty[0]->rec; // $POno = $qtyvalue->PONO; if($ordqty == $recqty) { $Newstatus = array('Status'=>IGR_CREATED); $this->purchaseorder_model-> POLineItemsupdatestatus($NewPO,$Newstatus); $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstatus); } echo 'Purchase Order Amended Successfully! PO Number Is: '.$PONO .'- New PO Number is'.$NewPO; } /** * To Store release Service Po values after edit */ function UpdateAmendServicePurchaseOrder() { $PONO =$this->input->post('txtPONO'); $MAD=''; $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 =null; $DeliverySchedule = $this->input->post('Scheduleby'); } else{ $Deliverydt = $this->getDateformat($dt); $DeliverySchedule = ''; } $ddate=$this->input->post('Deliverydt'); $beforeddate=$this->input->post('beforeDeliverydt'); $testdate=date("Y-m-d"); $dschedule=$this->input->post('Scheduleby'); $beforedschedule=$this->input->post('beforeScheduleby'); $preTotalordervalue=$this->input->post('preTotalordervalue'); $MAD.="Current TotalOrder Value:  " . $preTotalordervalue . "
"; if(($ddate != $beforeddate)||($dschedule != $beforedschedule)) { $MAD.="Current DeliveryOption :  " . $beforeddate . $beforedschedule."
"; } $PaymentTermsText=$this->input->post('beforePaymentTermsText'); $PaymentTerms=$this->input->post('PaymentTerms'); $Otherpayment=$this->input->post('Otherpayment'); $Otherpaymentamend=$this->input->post('Otherpayment'); $beforePaymentTerms=$this->input->post('beforePaymentTerms'); if($PaymentTerms != $beforePaymentTerms) { if($beforePaymentTerms != 'PT08'){ $Otherpaymentamend='';} $MAD.="Current PaymentTerms :  ". $PaymentTermsText . $Otherpaymentamend."
"; } $POType = $this->input->post('POType'); $ModeOfShipment=$this->input->post('addmodeofshipment'); $SupplierReference=$this->input->post('amendsupplierreference'); $SuppliersOfferNo=$this->input->post('amendsupplierofferno'); $OtherReferences=$this->input->post('amendotherreference'); $Fincap=$this->input->post('amendfincap'); $InsuranceOptions=$this->input->post('insuranceStatus'); $InsuranceNo=$this->input->post('insuranceNo'); $ServiceTypeOptions=$this->input->post('PoTypeOptions'); $DescriptionOfPo = $this->input->post('amenddescofpo'); $scopeofwork = $this->input->post('ScopeofWork'); $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); $POStatus = $this->input->post('txtStatus'); $updatedBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updateddt = $dt->format('Y-m-d H:i:s'); $WorkStatus=$this->input->post('workstatus'); $qtycheck = $this->purchaseorder_model->getqtycheck($PONO); $qtycheckresult=''; foreach($qtycheck as $qty) { $qtycheckresult= $qty->IsQualityChkReqired; } // PO Master if(empty($Deliverydt)) { $Deliverydt=null; } if($PaymentTerms != 'PT08'){ $Otherpayment=''; } $POMaster = array('ParentPO'=>$PONO,'POType'=>$POType,'SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>PO_RELEASED,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$scopeofwork,'CreatedBy'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$updateddt,'PaymentTerms'=>$PaymentTerms,'PaymentOtherDescription'=>$Otherpayment,'ServiceWorkStatus'=>$WorkStatus,'ReleasedBy'=>$updatedBy,'ReleasedOn'=>$updateddt,'AmendedDetails'=>$MAD,'Supplier_Reference'=>$SupplierReference,'Mode_Of_Shipment'=>$ModeOfShipment,'Supplier_Offer_No'=>$SuppliersOfferNo,'Other_Reference'=>$OtherReferences,'Fincap'=>$Fincap,'Description_Of_Service'=>$DescriptionOfPo,'InsuranceStatus'=>$InsuranceOptions,'InsuranceNumber'=>$InsuranceNo,'POSubType'=>$ServiceTypeOptions,'IsQualityChkReqired'=>$qtycheckresult); $LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster,$updatedBy,$PONO); $NewPO = ''; if(count($LastPO)>0) { $NewPO = $LastPO[0]['PONO']; } $PODetail=array('Status'=>PO_AMENDED);//TO SET PARENT PO AS AMENDMENT STATUS $APO=$this->purchaseorder_model->updateAmendPOMaster($PONO,$PODetail); $LineItemStatus = REQITEM_NEW; $igrvalue = $this->purchaseorder_model->selectigrmaster($PONO); $po = ''; $igrno =''; // if(count($igrvalue) >0) // { // $igrno = $igrvalue[0]->IGRNO; // $po =$igrvalue[0]->PONO; // } foreach ($igrvalue as $value) { $igrno = $value->IGRNO; $po =$value->PONO; // print_r($igrno); if($PONO == $po) { $NewPOno = array('PONO' =>$NewPO); // print_r($NewPOno); $this->purchaseorder_model->updateigrmaster($igrno,$NewPOno); $this->purchaseorder_model->updateigrfile($igrno,$NewPOno); } } for ($i = 1; $i <= $RowCount; $i++) { $CAD=''; $MaterialCode = $this->input->post('materialCode'.$i); $MaterialName=$this->input->post('materialName'.$i); $Quantity = $this->input->post('quantity'.$i); $beforeQuantity = $this->input->post('beforequantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); $beforeitemRate = $this->input->post('beforeitemRate'.$i); $Per = $this->input->post('per'.$i); $AfterSGST = $this->input->post('AfterSgst'.$i); $beforeSGSTvalue = $this->input->post('beforeSgstvalue'.$i); $AfterCGST = $this->input->post('AfterCgst'.$i); $beforeCGSTvalue = $this->input->post('beforeCgstvalue'.$i); $AfterIGST = $this->input->post('AfterIgst'.$i); $beforeIGSTvalue = $this->input->post('beforeIgstvalue'.$i); $SGST = $this->input->post('Sgst'.$i); $beforeSGST = $this->input->post('beforeSgst'.$i); $CGST = $this->input->post('Cgst'.$i); $beforeCGST = $this->input->post('beforeCgst'.$i); $IGST = $this->input->post('Igst'.$i); $beforeIGST = $this->input->post('beforeIgst'.$i); $otherallowance = $this->input->post('otherallowance'.$i); $beforeotherallowance = $this->input->post('beforeotherallowance'.$i); $servicematerialdescription = $this->input->post('servicematerialdescription'.$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); $LineItemNo = ''; $RecQtyvalue=0.00; $rowspanvalue=0; $ReceivedQty = $this->purchaseorder_model->GetLineItemReceivedQty($PONO,$MaterialCode); if(count($ReceivedQty)>0) { $RecQtyvalue = $ReceivedQty[0]['ReceivedQuantity']; } if($Quantity != $beforeQuantity) { $rowspanvalue++; $CAD.="Current Qty : " . $beforeQuantity ."Revised Qty : " . $Quantity . ""; } if($itemRate != $beforeitemRate) { $rowspanvalue++; $CAD.="Current Rate : " . $beforeitemRate ."Revised Rate : " . $itemRate . ""; } if(($SGST != $beforeSGST) && ($AfterSGST != $beforeSGSTvalue)) { $rowspanvalue+=2; $CAD.="Current SGST% : " . $beforeSGST ."Revised SGST% : " . $SGST . "Current SGST value : " . $beforeSGSTvalue ."Revised SGST value: " . $AfterSGST . ""; } if(($CGST != $beforeCGST) && ($AfterCGST != $beforeCGSTvalue)) { $rowspanvalue+=2; $CAD.="Current CGST% : " . $beforeCGST ."Revised CGST% : " . $CGST . "Current CGST value : " . $beforeCGSTvalue ."Revised CGST value: " . $AfterCGST . ""; } if(($IGST != $beforeIGST) && ($AfterIGST != $beforeIGSTvalue)) { $rowspanvalue+=2; $CAD.="Current IGST% : " . $beforeIGST ."Revised IGST% : " . $IGST . "Current IGST value : " . $beforeIGSTvalue ."Revised IGST value: " . $AfterIGST . ""; } if($otherallowance != $beforeotherallowance) { $rowspanvalue++; $CAD.="Current OtherAllowances : " . $beforeotherallowance ."Revised OtherAllowances : " . $otherallowance . ""; } if($rowspanvalue>0) { $rowspanvalue++; $CAD2=''; $CAD2=$CAD; $CAD=''; $CAD="".$MaterialCode."-".$MaterialName.""; $CAD.=$CAD2; } $POLineItemList = array('PONO'=>$NewPO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'ServiceMaterialDescription'=>$servicematerialdescription,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency,'ReceivedQuantity'=>$RecQtyvalue,'AmendedDetails'=>$CAD,'Per'=>$Per); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); if(count($POLineItem)>0) { $LineItemNo = $POLineItem[0]['LineItemNo']; } $ServiceTaxList = array('LineItemNo'=>$LineItemNo,'CGST'=>$CGST,'After_CGST'=>$AfterCGST,'SGST'=>$SGST,'After_SGST'=>$AfterSGST,'IGST'=>$IGST,'After_IGST'=>$AfterIGST,'otherallowance'=>$otherallowance, 'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt); $ServiceList =$this->purchaseorder_model->addServiceTax($ServiceTaxList); // if($Quantity == $RecQtyvalue ) // { // $Newstatus = array('Status'=>IGR_CREATED); // $this->purchaseorder_model-> POLineItemsupdatestatus($NewPO,$Newstatus); // $Newstat = array('Status'=>IGR_CREATED); // $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstat); // } // else if($Quantity != $RecQtyvalue ) // { // $Newstatus = array('Status'=>POLINEITEM_IGRPARTIAL_CREATED); // $this->purchaseorder_model->POLineItemsupdatestatus($NewPO,$Newstatus); // $Newstat = array('Status'=>PO_RELEASED); // $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstat); // } } $qty = $this->purchaseorder_model->getpolineqty($NewPO); $ordqty =''; $recqty =''; // $POno=''; // sum(Quantity)as Qty,sum(ReceivedQuantity)as rec // foreach ($qty as $qtyvalue) // { $ordqty = $qty[0]->Qty; $recqty = $qty[0]->rec; // $POno = $qtyvalue->PONO; if($ordqty == $recqty) { $Newstatus = array('Status'=>IGR_CREATED); $this->purchaseorder_model-> POLineItemsupdatestatus($NewPO,$Newstatus); $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstatus); } echo 'PO Number is'.$PONO . ' is Amended Successfully! - New Amended PO Number is '.$NewPO; } /** * To Store Capital Po values after edit */ function EditAmendCapitalPurchaseOrder() { $PONO =$this->input->post('txtPONO'); $MAD=''; $DeliverySchedule = ''; $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); $DeliveryAddr = $this->input->post('DeliveryAddr'); $dt = $this->input->post('Deliverydate'); $POType = $this->input->post('POType'); $PoRange = $this->input->post('capitalType'); $DeliveryOption = $this->input->post('DateRange'); $Deliverydt = ''; if(($DeliveryOption==1)||($DeliveryOption==2)){ $Deliverydt = null; if($DeliveryOption==1){ $DeliverySchedule = $this->input->post('Scheduleby');} } else{ $Deliverydt = $this->getDateformat($dt); $DeliverySchedule = ''; } $predispatch=$this->input->post('beforeDisins'); $curdispatch=$this->input->post('Dispatch'); $PaymentMethod = $this->input->post('PaymentMethod'); $prePaymentmethod=$this->input->post('beforePaymentmethod'); $prePaymentmethodtext=$this->input->post('beforePaymentTermsText'); $DeliverySchedule1 = $this->input->post('Scheduleby'); $preDeliverySchedule = $this->input->post('beforeSchedule'); $PlaceOforigin = $this->input->post('PlaceOforigin'); $preDate = $this->input->post('beforeDate'); $Date = $this->input->post('Deliverydate'); $Otherpayment=$this->input->post('Otherpayment'); $Otherpaymentamend=$this->input->post('Otherpayment'); $PreServiceTotalorder = $this->input->post('preServiceTotalorderValue');//For Domestic Pre Total Value $Totalserviceorder = $this->input->post('Totalservicesummary');//For Domestic Revised Total value $TotalCapitalorder= $this->input->post('CapitalToatlOrder');//For International total CapitalOrder $preTotalCapitalorder= $this->input->post('preinterTotalorderValue');//For International pre total CapitalOrder $ModeOfShipment=$this->input->post('addmodeofshipment'); $SupplierReference=$this->input->post('amendsupplierreference'); $SuppliersOfferNo=$this->input->post('amendsupplierofferno'); $OtherReferences=$this->input->post('amendotherreference'); $Fincap=$this->input->post('amendfincap'); $InsuranceOptions=$this->input->post('insuranceStatus'); $InsuranceNo=$this->input->post('insuranceNo'); $ServiceTypeOptions=$this->input->post('PoTypeOptions'); if($PoRange==1){ $MAD.="Current TotalOrder Value:  " . $PreServiceTotalorder . "
"; }else if($PoRange==0){ $MAD.="Current TotalOrder Value:  " . $preTotalCapitalorder . "
"; } if($PaymentMethod != $prePaymentmethod) { if($prePaymentmethod != 'PT08'){ $Otherpaymentamend='';} $MAD.="Current Paymemnt Terms :  " .$prePaymentmethodtext."
"; } if($predispatch != $curdispatch) { $MAD.="Current Delivery Option :  " .$predispatch.$preDeliverySchedule.$preDate."
"; } if($DeliverySchedule1!= $preDeliverySchedule) { $MAD.="Current DeliveyOption :  " .$preDeliverySchedule.$preDate.$predispatch."
"; } if($preDate != $Date) { $MAD.="Current DeliveyOption :  " .$preDate.$preDeliverySchedule."
"; } $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'); $ExchangeRateOn = $this->getDateformat($ExchangeRateOn); $ExchangeRate=$this->input->post('ExchangeRt'); } $SpcialInstruction = $this->input->post('txtSpcialInstruction'); if($PoRange==1){ $FinalTotalOrder = $Totalserviceorder; }else if($PoRange==0) { $FinalTotalOrder=$TotalCapitalorder; } $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'); $qtycheck = $this->purchaseorder_model->getqtycheck($PONO); $qtycheckresult=''; foreach($qtycheck as $qty) { $qtycheckresult= $qty->IsQualityChkReqired; } if(empty($Deliverydt)){ $Deliverydt=null; } if($PaymentMethod != 'PT08'){ $Otherpayment=''; } $updatedBy = $this->session->userdata ( 'userId' ); $POMaster = array('ParentPO'=>$PONO,'SupplierID'=>$SupplierID, 'TotalOrderValue'=>$FinalTotalOrder,'POType'=>$POType,'PODate'=>$PODate,'Status'=>PO_RELEASED,'CapitalRange'=>$PoRange,'ExchangeRate'=>$ExchangeRate,'ExchangeRateCalculatedon'=>$ExchangeRateOn,'PaymentTerms'=>$PaymentMethod,'PaymentOtherDescription'=>$Otherpayment,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'ReleasedBy'=>$updatedBy,'ReleasedOn'=>$updateddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'CurrencyType'=>$currencytypeID,'AmendedDetails'=>$MAD,'Import_DispatchDetails'=>$curdispatch,'Import_PlaceofOrgin'=>$PlaceOforigin,'Supplier_Reference'=>$SupplierReference,'Mode_Of_Shipment'=>$ModeOfShipment,'Supplier_Offer_No'=>$SuppliersOfferNo,'Other_Reference'=>$OtherReferences,'Fincap'=>$Fincap,'InsuranceStatus'=>$InsuranceOptions,'InsuranceNumber'=>$InsuranceNo,'POSubType'=>$ServiceTypeOptions,'IsQualityChkReqired'=>$qtycheckresult); $LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster,$CreateBy,$PONO); foreach($LastPO as $PO): $NewPO=$PO['PONO']; endforeach; $PODetail=array('Status'=>PO_AMENDED);//TO SET PARENT PO AS AMENDMENT STATUS $APO=$this->purchaseorder_model->updateAmendPOMaster($PONO,$PODetail); $LineItemStatus = REQITEM_NEW; $igrvalue = $this->purchaseorder_model->selectigrmaster($PONO); $po = ''; $igrno =''; // if(count($igrvalue) >0) // { // $igrno = $igrvalue[0]->IGRNO; // $po =$igrvalue[0]->PONO; // } foreach ($igrvalue as $value) { $igrno = $value->IGRNO; $po =$value->PONO; // print_r($igrno); if($PONO == $po) { $NewPOno = array('PONO' =>$NewPO); // print_r($NewPOno); $this->purchaseorder_model->updateigrmaster($igrno,$NewPOno); $this->purchaseorder_model->updateigrfile($igrno,$NewPOno); } } for ($i = 1; $i <= $RowCount; $i++) { $CAD=''; $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); $preQuantity = $this->input->post('beforequantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); $preitemRate = $this->input->post('itemRate'.$i); $itemRate = $this->input->post('rateInUs'.$i); $Per = $this->input->post('per'.$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); $CustomDuty = $this->input->post('beforeCustomDuty'.$i); $AfterCustomDuty = $this->input->post('CustomDuty'.$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); $Grossdutypayable = $this->input->post('GrossDutyPayable'.$i); $purchaseratePerKG = $this->input->post('purchaseRate'.$i); $CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpenses'.$i); $QuantityKG = $this->input->post('PurQuantity'.$i); $Totalvalueitem=$this->input->post('PerKgExpense'.$i); $Assable=$this->input->post('AssessableValue'.$i); $beforeAssable=$this->input->post('beforeAssessableValue'.$i); $Subtotal=$this->input->post('SubTotal'.$i); $beforeSubtotal=$this->input->post('beforeSubTotal'.$i); $Igst=$this->input->post('IGSTInt'.$i); $beforeIgst=$this->input->post('beforeIGSTInt'.$i); $AfterIgst=$this->input->post('AfterIGSTInt'.$i); $ClearingCharge = $this->input->post('ClearingCharge'.$i); $NetValue = $this->input->post('NetValue'.$i); $DutyImpact=$this->input->post('DutyImpact'.$i); $CostCenter = $this->input->post('CPCostCode'.$i); $SGST = $this->input->post('SGST'.$i); $preSGST = $this->input->post('beforeSGST'.$i); $CGST = $this->input->post('CGST'.$i); $preCGST = $this->input->post('beforeCGST'.$i); $IGST = $this->input->post('IGST'.$i); $preIGST = $this->input->post('beforeIGST'.$i); $SGSTvalue=$this->input->post('afterSGST'.$i); $preSGSTvalue=$this->input->post('beforeSGSTvalue'.$i); $CGSTvalue=$this->input->post('afterCGST'.$i); $preCGSTvalue=$this->input->post('beforeCGSTvalue'.$i); $IGSTvalue=$this->input->post('afterIGST'.$i); $preIGSTvalue=$this->input->post('beforeIGSTvalue'.$i); $otherallowance=$this->input->post('otherallowance'.$i); $preotherallowance=$this->input->post('beforeotherallowance'.$i); $DiscountType = $this->input->post('DisType'.$i); $DiscountValue = $this->input->post('DisVal'.$i); $AfterDiscount = $this->input->post('AfterDisVal'.$i); $preDiscountType = $this->input->post('beforeDisType'.$i); $preDiscountValue = $this->input->post('beforeDisVal'.$i); $preAfterDiscount = $this->input->post('beforeAfterDisVal'.$i); $TotalServiceOrderValue = $this->input->post('totalservicevalue'.$i); $CapitalItemDescrition = $this->input->post('CapitalItemDescrition'.$i); $FreightType = $this->input->post('FreightType'.$i); $FreightValue = $this->input->post('FreightVal'.$i); $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); $NOOfTrip = $this->input->post('NoOfTrip'.$i); $POLineItemNo = $this->input->post('LineItemNo'.$i); $FreightTypeloc=$this->input->post('Ftype'.$i); $FreightNoofTriploc=$this->input->post('NoTrip'.$i); $Freightrateloc=$this->input->post('Fvalue'.$i); $FreightAmountloc=$this->input->post('Afvalue'.$i); $beforeFreightTypeloc=$this->input->post('beforeFtype'.$i); $beforeFreightNoofTriploc=$this->input->post('beforeNoTrip'.$i); $beforeFreightrateloc=$this->input->post('beforeFvalue'.$i); $beforeFreightAmountloc=$this->input->post('beforeAfvalue'.$i); $rowspanvalue=0; if($Quantity != $preQuantity) { $rowspanvalue++; $CAD.="Current Qty : " . $preQuantity ."Revised Qty : " . $Quantity . ""; } if($itemRate != $preitemRate) { $rowspanvalue++; $CAD.="Current Rate : " . $preitemRate ."Revised Rate : " . $itemRate . ""; } if($PoRange==1){ if(($DiscountValue!=$preDiscountValue) && ($AfterDiscount!=$preAfterDiscount)){ $rowspanvalue+=2; $CAD.="Current Discount : " . $preDiscountValue ."Revised Discount : " . $DiscountValue . "Current Discount value : " . $preAfterDiscount ."Revised Discount value: " . $AfterDiscount . ""; } if(($SGST != $preSGST) && ($SGSTvalue != $preSGSTvalue)) { $rowspanvalue+=2; $CAD.="Current SGST% : " . $preSGST ."Revised SGST% : " . $SGST . "Current SGST value : " . $preSGSTvalue ."Revised SGST value: " . $SGSTvalue . ""; } if(($CGST != $preCGST) && ($CGSTvalue != $preCGSTvalue)) { $rowspanvalue+=2; $CAD.="Current CGST% : " . $preCGST ."Revised CGST% : " . $CGST . "Current CGST value : " . $preCGSTvalue ."Revised CGST value: " . $CGSTvalue . ""; } if(($IGST != $preIGST) && ($IGSTvalue != $preIGSTvalue)) { $rowspanvalue+=2; $CAD.="Current IGST% : " . $preIGST ."Revised IGST% : " . $IGST . "Current IGST value : " . $preIGSTvalue ."Revised IGST value: " . $IGSTvalue . ""; } if($otherallowance != $preotherallowance) { $rowspanvalue++; $CAD.="Current OtherAllowances : " . $preotherallowance ."Revised OtherAllowances : " . $otherallowance . ""; } if($FreightTypeloc != $beforeFreightTypeloc) { $rowspanvalue++; $CAD.="Current Freight Type : " . $beforeFreightTypeloc ."Revised Qty : " . $FreightTypeloc . ""; } if($FreightNoofTriploc != $beforeFreightNoofTriploc) { $rowspanvalue++; $CAD.="Current Freight Nooftrips : " . $beforeFreightNoofTriploc ."Revised Freight Nooftrips: " . $FreightNoofTriploc . ""; } if($Freightrateloc != $beforeFreightrateloc) { $rowspanvalue++; $CAD.="Current Freight Rate : " . $beforeFreightrateloc ."Revised Freight Rate: " . $Freightrateloc . ""; } if($FreightAmountloc != $beforeFreightAmountloc) { $rowspanvalue++; $CAD.="Current Freight Amount : " .$beforeFreightAmountloc ."Revised Freight Amount: " . $FreightAmountloc . ""; } if(($Assable-$beforeAssable)!=0) { $rowspanvalue++; $CAD=$CAD."Current Assessable : ".$beforeAssable ."Revised CustomDuty:".$Assable.""; } if(($Subtotal-$beforeSubtotal)!=0) { $rowspanvalue++; $CAD=$CAD."Current Subtotal : ".$beforeSubtotal ."Revised Subtotal:".$Subtotal.""; } if(($Igst-$beforeIgst)!=0) { $rowspanvalue++; $CAD=$CAD."Current IGST Percentage : ".$beforeIgst ."Revised IGST Percentage:".$Igst.""; } } if($rowspanvalue>0) { $rowspanvalue++; $CAD2=''; $CAD2=$CAD; $CAD=''; $CAD="".$MaterialCode.""; $CAD.=$CAD2; } $POLineItemList = array('PONO'=>$NewPO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'AmendedDetails'=>$CAD,'Per'=>$Per,'ServiceMaterialDescription'=>$CapitalItemDescrition); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); $LineItemNo = ''; foreach($POLineItem as $line): $LineItemNo = $line['LineItemNo']; endforeach; if(trim($POType) == CAPITAL ) { if($capitalType=='1'){ $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'CGST'=>$CGST,'After_CGST'=>$CGSTvalue,'SGST'=>$SGST,'After_SGST'=>$SGSTvalue,'IGST'=>$IGST,'After_IGST'=>$IGSTvalue, 'otherallowance'=>$otherallowance,'TotalValue'=>$TotalServiceOrderValue,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'discount'=>$DiscountType,'discountval'=>$DiscountValue,'Afterdiscountval'=>$AfterDiscount,'FreightType'=>$FreightTypeloc,'NoOfTrip'=>$FreightNoofTriploc,'FreightValue'=>$Freightrateloc,'AfterFreightValue'=>$FreightAmountloc); $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); } else 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'=>$Assable,'SubTotal'=>$Subtotal,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'DutyImpact'=>$DutyImpact,'NetValue'=>$NetValue,'ClearingCharge'=>$ClearingCharge); $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); } } } $qty = $this->purchaseorder_model->getpolineqty($NewPO); $ordqty =''; $recqty =''; // $POno=''; // sum(Quantity)as Qty,sum(ReceivedQuantity)as rec // foreach ($qty as $qtyvalue) // { $ordqty = $qty[0]->Qty; $recqty = $qty[0]->rec; // $POno = $qtyvalue->PONO; if($ordqty == $recqty) { $Newstatus = array('Status'=>IGR_CREATED); $this->purchaseorder_model-> POLineItemsupdatestatus($NewPO,$Newstatus); $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstatus); } echo 'Purchase Order'.$PONO.'Amended Successfully! New PO Number Is: '.$NewPO ; } /** * To Store release import Po values after edit */ function EditAmendImportPO() { $MAD=''; $PONO =$this->input->post('txtPONO'); $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'); $updatedBy = $this->session->userdata ( 'userId' ); $Exchangerate=$this->input->post('ExchangeRate'); $Edt=$this->input->post('Exchangerateon'); $ExchangeRateCalculatedon=$this->getDateformat($Edt); $CurrencyType=$this->input->post('currencytype'); $DeliveryOption = $this->input->post('DateRange'); $DeliverySchedule=''; $Dispatch=''; if($DeliveryOption==1) { $Dispatch=''; $DeliverySchedule = $this->input->post('Scheduleby'); } else { $Dispatch = $this->input->post('Dispatch'); $DeliverySchedule = ''; } $SpcialInstruction = $this->input->post('txtSpcialInstruction'); $TotalOrder = $this->input->post('txttot'); $AmendTotal=$this->input->post('txttotamend'); $MAD.="Current Total Order Value:  :" . $AmendTotal ."
"; $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'); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updateddt = $dt->format('Y-m-d H:i:s'); $PaymentTerms=$this->input->post('PaymentTerms'); $beforePaymentTerms=$this->input->post('beforePaymentterms'); $Shipmentmode=$this->input->post('addmodeofshipment'); $SupplierRef=$this->input->post('amendsupplierreference'); $SupplierOffer=$this->input->post('amendsupplierofferno'); $otherRef=$this->input->post('amendotherreference'); $finCap=$this->input->post('amendfincap'); $OtherPayment=$this->input->post('Otherpayment'); $Insurance=$this->input->post('Insurance'); $qtycheck = $this->purchaseorder_model->getqtycheck($PONO); $qtycheckresult=''; foreach($qtycheck as $qty) { $qtycheckresult= $qty->IsQualityChkReqired; } if($Insurance=='YES') { $Insurancenumber=$this->input->post('insurancenumber'); $insurestatus='1'; } else { $Insurancenumber=''; $insurestatus='0'; } $importoption=$this->input->post('Importoption'); if($PaymentTerms!=$beforePaymentTerms) { $MAD.="Current Payment Terms  " . $beforePaymentTerms."
"; } $Palaceoforigin=$this->input->post('PlaceOforigin'); $beforePalaceoforigin=$this->input->post('beforePlaceOforigin'); if($Palaceoforigin!=$beforePalaceoforigin) { $MAD.=$MAD."Current Place of Origin:  " . $beforePalaceoforigin."
"; } $POMaster = array('ParentPO'=>$PONO,'SupplierID'=>$SupplierID, 'POType'=>$POType,'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,'ReleasedBy'=>$updatedBy,'ReleasedOn'=>$updateddt,'Import_PlaceofOrgin'=>$Palaceoforigin,'Mode_Of_Shipment'=>$Shipmentmode,'Supplier_Reference'=>$SupplierRef,'Supplier_Offer_No'=>$SupplierOffer,'Other_Reference'=>$otherRef,'Fincap'=>$finCap,'AmendedDetails'=>$MAD,'PaymentOtherDescription'=>$OtherPayment,'InsuranceStatus'=>$insurestatus,'InsuranceNumber'=>$Insurancenumber,'POSubType'=>$importoption,'IsQualityChkReqired'=>$qtycheckresult); $LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster,$CreateBy,$PONO); $NewPO = ''; if(count($LastPO)>0) { $NewPO = $LastPO[0]['PONO']; } $PODetail=array('Status'=>PO_AMENDED);//TO SET PARENT PO AS AMENDMENT STATUS $APO=$this->purchaseorder_model->updateAmendPOMaster($PONO,$PODetail); $LineItemStatus = REQITEM_NEW; $igrvalue = $this->purchaseorder_model->selectigrmaster($PONO); $po = ''; $igrno =''; // if(count($igrvalue) >0) // { // $igrno = $igrvalue[0]->IGRNO; // $po =$igrvalue[0]->PONO; // } foreach ($igrvalue as $value) { $igrno = $value->IGRNO; $po =$value->PONO; // print_r($igrno); if($PONO == $po) { $NewPOno = array('PONO' =>$NewPO); // print_r($NewPOno); $this->purchaseorder_model->updateigrmaster($igrno,$NewPOno); $this->purchaseorder_model->updateigrfile($igrno,$NewPOno); } } for ($i = 1; $i <= $RowCount; $i++) { $CAD=''; $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); $beforeQuantity=$this->input->post('beforequantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); $beforeitemRate=$this->input->post('beforeitemRate'.$i); $BasicPriceinmton = $this->input->post('BasicPriceInMTon'.$i); $Productprice = $this->input->post('ProductPrice'.$i); $LandingCharge = $this->input->post('LandingCharge'.$i); $beforeLandingCharge = $this->input->post('beforeLandingCharge'.$i); $AfterLandingCharge = $this->input->post('AfterLandingCharge'.$i); $CustomDuty = $this->input->post('CustomDuty'.$i); $beforeCustomDuty=$this->input->post('beforeCustomDuty'.$i); $AfterCustomDuty = $this->input->post('AfterCustomDuty'.$i); $CustomEd= $this->input->post('CustomEdCess1'.$i); $beforeCustomEd=$this->input->post('beforeCustomEdCess'.$i); $AfterCustomEd= $this->input->post('AfterCustomEdCess1'.$i); $CustomSH = $this->input->post('CustomSHCess'.$i); $beforeCustomSH=$this->input->post('beforeCustomSHCess'.$i); $AfterCustomSH = $this->input->post('AfterCustomSHCess'.$i); $Grossdutypayable = $this->input->post('Grossdutypayable1'.$i); $beforeGrossdutypayable = $this->input->post('beforeGrossdutypayable'.$i); $Assable=$this->input->post('AssessableValue'.$i); $beforeAssable=$this->input->post('beforeAssessableValue'.$i); $Subtotal=$this->input->post('SubTotal'.$i); $beforeSubtotal=$this->input->post('beforeSubTotal'.$i); $Igst=$this->input->post('IGST'.$i); $beforeIgst=$this->input->post('beforeIGST'.$i); $AfterIgst=$this->input->post('AfterIGST'.$i); $CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpensesPerKG'.$i); $beforeCustomDutyExpensesPerKG = $this->input->post('beforeCustomDutyExpensesPerKG'.$i); $FreightType=$this->input->post('FreightType'.$i); $NoOfTrip=$this->input->post('NoOfTrip'.$i); $Freightrate=$this->input->post('FreightValue'.$i); $Freightamount=$this->input->post('AfterFreightValue'.$i); $per=$this->input->post('Per'.$i); $beforeFreightType=$this->input->post('beforeFreightType'.$i); $beforeNoOfTrip=$this->input->post('beforeNoOfTrip'.$i); $beforeFreightrate=$this->input->post('beforeFreightValue'.$i); $beforeFreightamount=$this->input->post('beforeAfterFreightValue'.$i); $beforeper=$this->input->post('beforePer'.$i); $QuantityKG = $this->input->post('QuantityKG'.$i); $ClearingCharge = $this->input->post('ClearingCharge'.$i); $NetValue = $this->input->post('NetValue'.$i); $DutyImpact=$this->input->post('DutyImpact'.$i); $specialinstruction=$this->input->post('Addinstruction'.$i); $CostCenter = $this->input->post('costCode'.$i); $Totalvalueitem=$this->input->post('txtTotalorderValue'); $RecQtyvalue=0; $rowspanvalue=0; $LineItemNo = ''; if(($itemRate-$beforeitemRate)!=0) { $rowspanvalue++; $CAD=$CAD."Current Rate : ".$beforeitemRate ."Revised Rate:".$itemRate.""; } if(($Quantity-$beforeQuantity)!=0) { $rowspanvalue++; $CAD=$CAD."Current Quantity : ".$beforeQuantity ."Revised Quantity:".$Quantity.""; } if(($LandingCharge-$beforeLandingCharge)!=0) { $rowspanvalue++; $CAD=$CAD."Current Landing percentage : ".$beforeLandingCharge ."Revised Landing Percentage:".$LandingCharge.""; } if(($CustomDuty-$beforeCustomDuty)!=0) { $rowspanvalue++; $CAD=$CAD."Current CustomDuty : ".$beforeCustomDuty ."Revised CustomDuty:".$CustomDuty.""; } if($CustomEd-$beforeCustomEd) { $rowspanvalue++; $CAD=$CAD."Current CustomEd : ".$beforeCustomEd ."Revised CustomEd:".$CustomEd.""; } if($CustomSH-$beforeCustomSH) { $rowspanvalue++; $CAD=$CAD."Current CustomSH : ".$beforeCustomSH ."Revised CustomSH:".$CustomSH.""; } if($FreightType!=$beforeFreightType) { $rowspanvalue++; $CAD=$CAD."Current Freight Type: ".$beforeFreightType ."Revised Freight Type:".$FreightType.""; } if($NoOfTrip-$beforeNoOfTrip) { $rowspanvalue++; $CAD=$CAD."Current No of Trip: ".$beforeNoOfTrip ."Revised Additional Excise duty:".$NoOfTrip.""; } if($Freightrate-$beforeFreightrate) { $rowspanvalue++; $CAD=$CAD."Current Freightrate: ".$beforeFreightrate ."Revised Freightrate:".$Freightrate.""; } if($Freightamount-$beforeFreightamount) { $rowspanvalue++; $CAD=$CAD."Current Freight Amount: ".$beforeFreightamount ."Revised Freight Amount:".$Freightamount.""; } if($per!=$beforeper) { $rowspanvalue++; $CAD=$CAD."Current Per Value: ".$beforeper ."Revised Per Value:".$per.""; } if(($Assable-$beforeAssable)!=0) { $rowspanvalue++; $CAD=$CAD."Current Assessable : ".$beforeAssable ."Revised CustomDuty:".$Assable.""; } if(($Subtotal-$beforeSubtotal)!=0) { $rowspanvalue++; $CAD=$CAD."Current Subtotal : ".$beforeSubtotal ."Revised Subtotal:".$Subtotal.""; } if(($Igst-$beforeIgst)!=0) { $rowspanvalue++; $CAD=$CAD."Current IGST Percentage : ".$beforeIgst ."Revised IGST Percentage:".$Igst.""; } if(($Grossdutypayable-$beforeGrossdutypayable)!=0) { $rowspanvalue++; $CAD=$CAD."Current Gross Duty Payable : ".$beforeGrossdutypayable ."Revised Gross Duty Payable:".$Grossdutypayable.""; } if($rowspanvalue>0) { $rowspanvalue++; $CAD2=''; $CAD2=$CAD; $CAD=''; $CAD="".$MaterialCode.""; $CAD.=$CAD2; } $POLineItemList = array('PONO'=>$NewPO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'AmendedDetails'=>$CAD,'Per'=>$per,'ServiceMaterialDescription'=>$specialinstruction); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); if(count($POLineItem)>0) { $LineItemNo = $POLineItem[0]['LineItemNo']; } $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'=>$Assable,'SubTotal'=>$Subtotal,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'DutyImpact'=>$DutyImpact,'NetValue'=>$NetValue,'ClearingCharge'=>$ClearingCharge); $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); } $qty = $this->purchaseorder_model->getpolineqty($NewPO); $ordqty =''; $recqty =''; // $POno=''; // sum(Quantity)as Qty,sum(ReceivedQuantity)as rec // foreach ($qty as $qtyvalue) // { $ordqty = $qty[0]->Qty; $recqty = $qty[0]->rec; // $POno = $qtyvalue->PONO; if($ordqty == $recqty) { $Newstatus = array('Status'=>IGR_CREATED); $this->purchaseorder_model-> POLineItemsupdatestatus($NewPO,$Newstatus); $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstatus); } echo 'Purchase Order is'.$PONO.'Amended Successfully! New PO Number is: '.$NewPO ; } /** * To convert the dateformat (date with time) and store to DB */ function getDateformat($Val) { $date = new DateTime($Val,new DateTimeZone('Asia/Kolkata')); $retDate = $date->format('Y-m-d H:i:s'); return $retDate; } }