1887 lines
76 KiB
PHP
Executable File
1887 lines
76 KiB
PHP
Executable File
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.php';
|
|
|
|
/**
|
|
* Class : Amendment Purchase Order controller
|
|
* User Class to control all user related operations.
|
|
* @author : Velmurugan
|
|
* @version : 1.1
|
|
* @since : 10 Jul 2017
|
|
*/
|
|
class amendmentpurchaseorder extends BaseController
|
|
{
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
//$this->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');
|
|
|
|
$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->getPaymentTermsDetails();
|
|
$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;
|
|
// $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');
|
|
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['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->GetAvailableImportBudgetAmount($CostCode,$FYdt,$ReqType);
|
|
|
|
//print_r($AvlBudget);
|
|
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);
|
|
$data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR');
|
|
//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'];
|
|
|
|
$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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
function EditRevenuePurchaseOrder()
|
|
{
|
|
|
|
$NewPO='';
|
|
$MAD='';
|
|
|
|
$PONO =$this->input->post('txtPONO');
|
|
// echo "Revenue Amendment";
|
|
// 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');
|
|
$predeliverydate=$this->input->post('beforeDeliverydt');
|
|
$preschedule=$this->input->post('beforeScheduleby');
|
|
//$Deliverydt = $this->getDateformat($dt);
|
|
$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 = '';
|
|
}
|
|
|
|
|
|
|
|
|
|
$POType = $this->input->post('POType');
|
|
$PoRange = $this->input->post('txtPoRange');
|
|
$PaymentTermsText=$this->input->post('beforePaymentTermsText');
|
|
$PaymentTerms=$this->input->post('PaymentTerms');
|
|
$Otherpayment=$this->input->post('Otherpayment');
|
|
$Otherpaymentamend=$this->input->post('Otherpayment');
|
|
//echo $Otherpayment;
|
|
$prePaymentTerms=$this->input->post('beforePaymentTerms');
|
|
$preTotalOdervalue=$this->input->post('preTotalOdervalue');
|
|
$MAD.="Amended Total Order Value: :" . $preTotalOdervalue ."<br>";
|
|
$testdate=date("Y-m-d");
|
|
if($PaymentTerms!=$prePaymentTerms)
|
|
{
|
|
if($prePaymentTerms != 'PT08'){ $Otherpaymentamend='';}
|
|
$MAD.="Amended PaymentTerms : ". $PaymentTermsText . $Otherpaymentamend ."<br>";
|
|
}
|
|
|
|
if(($dt != $predeliverydate)|| ($DeliverySchedule1 != $preschedule))
|
|
{
|
|
|
|
|
|
$MAD.='Amended Delivery Option : ' . $predeliverydate . $preschedule . '<br>' ;
|
|
}
|
|
|
|
$SpecialInstruction = $this->input->post('txtSpcialInstruction');//$_POST['txtSpcialInstruction'];//$this->input->post('txtSpcialInstruction');//t->post('txtSpcialInstruction'));
|
|
|
|
//echo $MAD;
|
|
|
|
$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');
|
|
if(empty($Deliverydt))
|
|
{
|
|
$Deliverydt=null;
|
|
}
|
|
|
|
if($PaymentTerms != 'PT08'){
|
|
$Otherpayment='';
|
|
|
|
}
|
|
|
|
$POMaster = array('ParentPO'=>$PONO,'SupplierID'=>$SupplierID,'POType'=>$POType,'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>PO_RELEASED,'PaymentTerms'=>$PaymentTerms,'PaymentOtherDescription'=>$Otherpayment,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpecialInstruction,'CreatedBy'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt,'AmendedDetails'=>$MAD);
|
|
//print_r($POMaster);
|
|
|
|
|
|
|
|
$LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster,$updatedBy,$PONO);
|
|
if(count($LastPO)>0)
|
|
{
|
|
$NewPO = $LastPO[0]['PONO'];
|
|
}
|
|
|
|
//echo "NEW PO IS " . $NewPO;
|
|
//echo "";
|
|
//change old po status as Amendment
|
|
$PODetail=array('Status'=>PO_AMENDED);//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";
|
|
$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);
|
|
|
|
$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;
|
|
$rowspanvalue=0;
|
|
|
|
if(($Quantity-$preqty)!=0)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Quantity : ".$preqty ."</td><td>Current Qty : ".$Quantity."</td></tr>";
|
|
}
|
|
if(($itemRate-$preitemrate)!=0)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Rate : " . $preitemrate."</td><td>Current Item Rate : ".$itemRate."</td></tr>";
|
|
}
|
|
if($DiscountType != $beforeDiscountType){
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended DiscountType : " . $beforeDiscountType."</td><td>Current DiscountType : ".$DiscountType."</td></tr>";
|
|
}
|
|
if(($DiscountValue-$preDiscountValue)!=0)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Discount : ". $preDiscountValue ."</td><td>Current Discount : ".$DiscountValue."</td></tr>";
|
|
}
|
|
if(($AfterDiscount-$beforeAfterDiscount)!=0)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Discount Value : ". $beforeAfterDiscount ."</td><td>Current Discount Value : ".$AfterDiscount."</td></tr>";
|
|
}
|
|
if($PackagingType != $beforePackagingType){
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Packaging Type : ". $beforePackagingType ."</td><td>Current Packaging Type : ".$PackagingType."</td></tr>";
|
|
}
|
|
if(($PackagingValue-$prePackagingValue)!=0)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Package Value : ". $prePackagingValue."</td><td>Current Package Value : ".$PackagingValue."</td></tr>";
|
|
}
|
|
if(($AfterPackagingValue-$beforeAfterPackagingValue)!=0)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Package Value : ". $beforeAfterPackagingValue."</td><td>Current Package Value : ".$AfterPackagingValue."</td></tr>";
|
|
}
|
|
if(($VatValue-$preVatValue)!=0)//SGST
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended SGST : ". $preVatValue."</td><td>Current SGST : ".$VatValue."</td></tr>";
|
|
}
|
|
if(($AfterVatValue-$beforeAfterVatValue)!=0)//SGST
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended SGST value : ". $beforeAfterVatValue."</td><td>Current SGST Value : ".$AfterVatValue."</td></tr>";
|
|
}
|
|
if(($GSTValue-$preGSTValue)!=0)//CGST
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended CGST : ". $preGSTValue."</td><td>Current CGST : ".$GSTValue."</td></tr>";
|
|
}
|
|
if(($AfterGSTValue-$beforeAfterGSTValue)!=0)//CGST
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended CGST Value : ". $beforeAfterGSTValue."</td><td>Current CGST Value : ".$AfterGSTValue."</td></tr>";
|
|
}
|
|
if(($OtherTaxValue-$preOtherTaxValue)!=0)//IGST
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended IGST : ". $preOtherTaxValue."</td><td>Current IGST : ".$OtherTaxValue."</td></tr>";
|
|
}
|
|
if(($AfterOtherTaxValue-$beforeAfterOtherTaxValue)!=0)//IGST
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended IGST : ". $beforeAfterOtherTaxValue."</td><td>Current IGST : ".$AfterOtherTaxValue."</td></tr>";
|
|
}
|
|
if($FreightType != $beforeFreightType){
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Freight Type : ". $beforeFreightType."</td><td>Current Freight Type : ".$FreightType."</td></tr>";
|
|
}
|
|
if(($FreightType=="PER TRIP") || ($beforeFreightType=="PER TRIP")){
|
|
if($NoofTrips != $beforeNoofTrips)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended No of Trips : ". $beforeNoofTrips."</td><td>Current No of Trips : ".$NoofTrips."</td></tr>";
|
|
}
|
|
}
|
|
|
|
if(($FreightValue-$preFreightValue)!=0)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Freight : ". $preFreightValue."</td><td>Current Freight : ".$FreightValue."</td></tr>";
|
|
}
|
|
|
|
if(($AfterFreightValue-$beforeAfterFreightValue)!=0)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Freight Value : ". $beforeAfterFreightValue."</td><td>Current Freight Value : ".$AfterFreightValue."</td></tr>";
|
|
}
|
|
|
|
if(($InsuranceValue-$preInsuranceValue)!=0)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Insurance Value : ". $preInsuranceValue."</td><td>Current Insurance Value : ".$InsuranceValue."</td></tr>";
|
|
}
|
|
if($rowspanvalue>0)
|
|
{
|
|
$rowspanvalue++;
|
|
|
|
$CAD2='';
|
|
$CAD2=$CAD;
|
|
$CAD='';
|
|
$CAD="<tr><td rowspan=". $rowspanvalue .">".$MaterialCode."</td></tr>";
|
|
$CAD.=$CAD2;
|
|
}
|
|
// echo $CAD;
|
|
// die();
|
|
$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,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency,'AmendedDetails'=>$CAD);
|
|
//print_r($POLineItemList);
|
|
|
|
$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);
|
|
// print_r($RevenueTaxList);
|
|
$RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList);
|
|
|
|
}
|
|
|
|
echo 'Purchase Order Amended Successfully! PO Number Is: '.$PONO .'- New PO Number is'.$NewPO;
|
|
}
|
|
|
|
|
|
|
|
|
|
function UpdateAmendServicePurchaseOrder()
|
|
{
|
|
$PONO =$this->input->post('txtPONO');
|
|
|
|
$MAD='';
|
|
$POdt =$this->input->post('PODate');
|
|
$PODate = $this->getDateformat($POdt);
|
|
//echo $PODate;
|
|
$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);
|
|
// echo "IF" . $Deliverydt;
|
|
$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.="Amended Total OrderValue: " . $preTotalordervalue . "<br>";
|
|
if(($ddate != $beforeddate)||($dschedule != $beforedschedule))
|
|
{
|
|
$MAD.="Amended DeliveryOption : " . $beforeddate . $beforedschedule."<br>";
|
|
}
|
|
|
|
// if($dschedule != $beforedschedule)
|
|
// {
|
|
// $MAD.="Amended DeliveryOption : " . $beforedschedule . $beforeddate."<br>";
|
|
// }
|
|
|
|
$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.="Amended PaymentTerms : ". $PaymentTermsText . $Otherpaymentamend."<br>";
|
|
}
|
|
//echo "MAD IS" . $MAD . "<br>";
|
|
|
|
$POType = $this->input->post('POType');
|
|
|
|
$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');
|
|
//echo 'RowCount is' . $RowCount;
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$updateddt = $dt->format('Y-m-d H:i:s');
|
|
$WorkStatus=$this->input->post('workstatus');
|
|
// 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);
|
|
|
|
//print_r($POMaster);
|
|
|
|
$LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster,$updatedBy,$PONO);
|
|
//print_r($LastPO);
|
|
$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;
|
|
|
|
|
|
for ($i = 1; $i <= $RowCount; $i++)
|
|
{
|
|
|
|
//echo "Inside Loop";
|
|
$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);
|
|
|
|
$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;
|
|
$rowspanvalue=0;
|
|
$ReceivedQty = $this->purchaseorder_model->GetLineItemReceivedQty($PONO,$MaterialCode);
|
|
if(count($ReceivedQty)>0)
|
|
{
|
|
$RecQtyvalue = $ReceivedQty[0]['ReceivedQuantity'];
|
|
}
|
|
|
|
if($Quantity != $beforeQuantity)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Qty : " . $beforeQuantity ."</td><td>Current Qty : " . $Quantity . "</td></tr>";
|
|
}
|
|
if($itemRate != $beforeitemRate)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Rate : " . $beforeitemRate ."</td><td>Current Rate : " . $itemRate . "</td></tr>";
|
|
}
|
|
|
|
if(($SGST != $beforeSGST) && ($AfterSGST != $beforeSGSTvalue))
|
|
{
|
|
$rowspanvalue+=2;
|
|
$CAD.="<tr><td>Amended SGST% : " . $beforeSGST ."</td><td>Current SGST% : " . $SGST . "</td></tr><tr><td>Amended SGST value : " . $beforeSGSTvalue ."</td><td>Current SGST value: " . $AfterSGST . "</td></tr>";
|
|
}
|
|
if(($CGST != $beforeCGST) && ($AfterCGST != $beforeCGSTvalue))
|
|
{
|
|
$rowspanvalue+=2;
|
|
$CAD.="<tr><td>Amended CGST% : " . $beforeCGST ."</td><td>Current CGST% : " . $CGST . "</td></tr><tr><td>Amended CGST value : " . $beforeCGSTvalue ."</td><td>Current CGST value: " . $AfterCGST . "</td></tr>";
|
|
}
|
|
if(($IGST != $beforeIGST) && ($AfterIGST != $beforeIGSTvalue))
|
|
{
|
|
$rowspanvalue+=2;
|
|
$CAD.="<tr><td>Amended IGST% : " . $beforeIGST ."</td><td>Current IGST% : " . $IGST . "</td></tr><tr><td>Amended IGST value : " . $beforeIGSTvalue ."</td><td>Current IGST value: " . $AfterIGST . "</td></tr>";
|
|
}
|
|
if($otherallowance != $beforeotherallowance)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended OtherAllowances : " . $beforeotherallowance ."</td><td>Current OtherAllowances : " . $otherallowance . "</td></tr>";
|
|
}
|
|
if($rowspanvalue>0)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD2='';
|
|
$CAD2=$CAD;
|
|
$CAD='';
|
|
$CAD="<tr><td rowspan=". $rowspanvalue .">".$MaterialCode."-".$MaterialName."</td></tr>";
|
|
$CAD.=$CAD2;
|
|
}
|
|
|
|
//echo "<br>CAD IS" . $CAD . "<br>";
|
|
|
|
$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);
|
|
//print_r($POLineItemList);
|
|
|
|
$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);
|
|
//print_r($ServiceTaxList);
|
|
$ServiceList =$this->purchaseorder_model->addServiceTax($ServiceTaxList);
|
|
|
|
}
|
|
echo 'PO Number is'.$PONO . ' is Amended Successfully! - New Amended PO Number is '.$NewPO;
|
|
}
|
|
|
|
|
|
function EditAmendCapitalPurchaseOrder()
|
|
{
|
|
|
|
//echo "WELCOME-";
|
|
|
|
$PONO =$this->input->post('txtPONO');
|
|
//echo $PONO."--";
|
|
$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');
|
|
//echo $dt . "-";
|
|
//die();
|
|
$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 Current Total value
|
|
//echo "Tjb" . $Totalserviceorder."--" . $PreServiceTotalorder;die();
|
|
$TotalCapitalorder= $this->input->post('CapitalToatlOrder');//For International total CapitalOrder
|
|
$preTotalCapitalorder= $this->input->post('preinterTotalorderValue');//For International pre total CapitalOrder
|
|
//echo $TotalCapitalorder . "-" . $preTotalCapitalorder;
|
|
if($PoRange==1){
|
|
$MAD.="Amended TotalOrder Vale: " . $PreServiceTotalorder . "<br>";
|
|
}else if($PoRange==0){
|
|
$MAD.="Amended TotalOrder Vale: " . $preTotalCapitalorder . "<br>";
|
|
}
|
|
|
|
if($PaymentMethod != $prePaymentmethod)
|
|
{
|
|
if($prePaymentmethod != 'PT08'){ $Otherpaymentamend='';}
|
|
$MAD.="Amended Paymemnt Terms : " .$prePaymentmethodtext."<br>";
|
|
}
|
|
if($predispatch != $curdispatch)
|
|
{
|
|
$MAD.="Amended Delivery Option : " .$predispatch.$preDeliverySchedule.$preDate."<br>";
|
|
}
|
|
if($DeliverySchedule1!= $preDeliverySchedule)
|
|
{
|
|
$MAD.="Amended DeliveyOption : " .$preDeliverySchedule.$preDate.$predispatch."<br>";
|
|
}
|
|
if($preDate != $Date)
|
|
{
|
|
$MAD.="Amended DeliveyOption : " .$preDate.$preDeliverySchedule."<br>";
|
|
}
|
|
//echo "<br><br>" . $MAD;
|
|
//die();
|
|
|
|
$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');
|
|
}
|
|
|
|
|
|
$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');
|
|
//echo $RowCount;
|
|
|
|
$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 "FINAL-".$Deliverydt;
|
|
if(empty($Deliverydt)){
|
|
$Deliverydt=null;
|
|
//echo "*INSIDE IF" .$Deliverydt;
|
|
}
|
|
// echo "*" .$Deliverydt;
|
|
if($PaymentMethod != 'PT08'){
|
|
$Otherpayment='';
|
|
}
|
|
$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,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'CurrencyType'=>$currencytypeID,'AmendedDetails'=>$MAD,'Import_DispatchDetails'=>$curdispatch,'Import_PlaceofOrgin'=>$PlaceOforigin);
|
|
// print_r($POMaster);
|
|
|
|
$LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster,$CreateBy,$PONO);
|
|
|
|
foreach($LastPO as $PO):
|
|
$NewPO=$PO['PONO'];
|
|
endforeach;
|
|
|
|
// echo "NEW PO IS " . $NewPO."</br>";
|
|
|
|
|
|
$PODetail=array('Status'=>PO_AMENDED);//TO SET PARENT PO AS AMENDMENT STATUS
|
|
//print_r($PODetail);
|
|
$APO=$this->purchaseorder_model->updateAmendPOMaster($PONO,$PODetail);
|
|
// echo $APO."Affected</br>";
|
|
|
|
$LineItemStatus = REQITEM_NEW;
|
|
|
|
|
|
|
|
//echo "Before Loopp";
|
|
|
|
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);
|
|
|
|
$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);
|
|
|
|
$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);
|
|
$TotalServiceOrderValue = $this->input->post('totalservicevalue'.$i);
|
|
$POLineItemNo = $this->input->post('LineItemNo'.$i);
|
|
$rowspanvalue=0;
|
|
|
|
if($Quantity != $preQuantity)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Qty : " . $preQuantity ."</td><td>Current Qty : " . $Quantity . "</td></tr>";
|
|
}
|
|
if($itemRate != $preitemRate)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended Rate : " . $preitemRate ."</td><td>Current Rate : " . $itemRate . "</td></tr>";
|
|
}
|
|
|
|
if($PoRange==1){
|
|
if(($SGST != $preSGST) && ($SGSTvalue != $preSGSTvalue))
|
|
{
|
|
$rowspanvalue+=2;
|
|
$CAD.="<tr><td>Amended SGST% : " . $preSGST ."</td><td>Current SGST% : " . $SGST . "</td></tr><tr><td>Amended SGST value : " . $preSGSTvalue ."</td><td>Current SGST value: " . $SGSTvalue . "</td></tr>";
|
|
}
|
|
if(($CGST != $preCGST) && ($CGSTvalue != $preCGSTvalue))
|
|
{
|
|
$rowspanvalue+=2;
|
|
$CAD.="<tr><td>Amended CGST% : " . $preCGST ."</td><td>Current CGST% : " . $CGST . "</td></tr><tr><td>Amended CGST value : " . $preCGSTvalue ."</td><td>Current CGST value: " . $CGSTvalue . "</td></tr>";
|
|
}
|
|
if(($IGST != $preIGST) && ($IGSTvalue != $preIGSTvalue))
|
|
{
|
|
$rowspanvalue+=2;
|
|
$CAD.="<tr><td>Amended IGST% : " . $preIGST ."</td><td>Current IGST% : " . $IGST . "</td></tr><tr><td>Amended IGST value : " . $preIGSTvalue ."</td><td>Current IGST value: " . $IGSTvalue . "</td></tr>";
|
|
}
|
|
if($otherallowance != $preotherallowance)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD.="<tr><td>Amended OtherAllowances : " . $preotherallowance ."</td><td>Current OtherAllowances : " . $otherallowance . "</td></tr>";
|
|
}
|
|
}
|
|
if($rowspanvalue>0)
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD2='';
|
|
$CAD2=$CAD;
|
|
$CAD='';
|
|
$CAD="<tr><td rowspan=". $rowspanvalue .">".$MaterialCode."</td></tr>";
|
|
$CAD.=$CAD2;
|
|
}
|
|
|
|
//echo $CAD;
|
|
|
|
$POLineItemList = array('PONO'=>$NewPO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'AmendedDetails'=>$CAD);
|
|
// print_r($POLineItemList);
|
|
|
|
$POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
|
|
|
|
$LineItemNo = '';
|
|
|
|
foreach($POLineItem as $line):
|
|
$LineItemNo = $line['LineItemNo'];
|
|
endforeach;
|
|
//echo $LineItemNo;
|
|
|
|
if(trim($POType) == CAPITAL )
|
|
{
|
|
$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);
|
|
// print_r($ServiceTaxList);
|
|
$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);
|
|
print_r($ImportTaxList);
|
|
//die();
|
|
|
|
|
|
$ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
echo 'Purchase Order'.$PONO.'Amended Successfully! New PO Number Is: '.$NewPO ;
|
|
}
|
|
function EditAmendImportPO()
|
|
{
|
|
$MAD='';
|
|
$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');
|
|
$updatedBy = $this->session->userdata ( 'userId' );
|
|
|
|
|
|
$Exchangerate=$this->input->post('ExchangeRate');
|
|
$ExchangeRateCalculatedon=$this->input->post('Exchangerateon');
|
|
$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 = '';
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// if($DeliveryOption==1){
|
|
// $Deliverydt = '';
|
|
// $DeliverySchedule = $this->input->post('Scheduleby');
|
|
// }
|
|
// else{
|
|
// $Deliverydt = $this->getDateformat($dt);
|
|
// $DeliverySchedule = '';
|
|
// }
|
|
|
|
|
|
$SpcialInstruction = $this->input->post('txtSpcialInstruction');
|
|
// $TotalOrder = $this->input->post('txtTotalorderValue');
|
|
$TotalOrder = $this->input->post('txtToatlOrder');
|
|
//$beforeTotalOrder=$this->input->post()
|
|
//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');
|
|
|
|
$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');
|
|
|
|
//echo $beforePaymentTerms;
|
|
//die();
|
|
if($PaymentTerms!=$beforePaymentTerms)
|
|
{
|
|
//$MAD=$MAD."Amended Payment Terms:". $beforePaymentTerms ."</br>";
|
|
$MAD.="Amended Payment Terms " . $beforePaymentTerms."<br>";
|
|
}
|
|
//$Payableat=$this->input->post('PayableAT');
|
|
$Palaceoforigin=$this->input->post('PlaceOforigin');
|
|
|
|
$beforePalaceoforigin=$this->input->post('beforePlaceOforigin');
|
|
|
|
if($Palaceoforigin!=$beforePalaceoforigin)
|
|
{
|
|
//$MAD=$MAD."Amended Place of Origin:". $beforePalaceoforigin ."</br>";
|
|
$MAD.=$MAD."Amended Place of Origin: " . $beforePalaceoforigin."<br>";
|
|
}
|
|
//echo $MAD;
|
|
//die();
|
|
|
|
|
|
|
|
//echo $RowCount;
|
|
// PO Master
|
|
// PO Master
|
|
$POMaster = array('ParentPO'=>$PONO,'SupplierID'=>$SupplierID, 'POType'=>$POType,'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'Import_DispatchDetails'=>$Dispatch,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'ReleasedBy'=>$updatedBy,'ReleasedOn'=>$updateddt,'Import_PlaceofOrgin'=>$Palaceoforigin,'AmendedDetails'=>$MAD);
|
|
//print_r($POMaster);
|
|
//die();
|
|
|
|
// $POList = array('SupplierID'=>$Supp,lierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'Import_DispatchDetails'=>$Dispatch,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'Import_PlaceofOrgin'=>$Palaceoforigin);
|
|
|
|
|
|
//print_r($POMaster);
|
|
|
|
$LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster,$CreateBy,$PONO);
|
|
$NewPO = '';
|
|
if(count($LastPO)>0)
|
|
{
|
|
$NewPO = $LastPO[0]['PONO'];
|
|
}
|
|
|
|
//echo $NewPO;
|
|
|
|
$PODetail=array('Status'=>PO_AMENDED);//TO SET PARENT PO AS AMENDMENT STATUS
|
|
// print_r($PODetail);
|
|
$APO=$this->purchaseorder_model->updateAmendPOMaster($PONO,$PODetail);
|
|
// echo "Affected Rows:";
|
|
// print_r($APO);
|
|
|
|
$LineItemStatus = REQITEM_NEW;
|
|
|
|
|
|
|
|
//echo "Before Loop";
|
|
for ($i = 1; $i <= $RowCount; $i++)
|
|
{
|
|
// echo "Inside Loop";
|
|
// die();
|
|
$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);
|
|
|
|
//$Exchangerate = $this->input->post('Exchangerate'.$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);
|
|
|
|
// echo $LandingCharge;
|
|
// echo $beforeLandingCharge;
|
|
// die();
|
|
|
|
$AfterLandingCharge = $this->input->post('AfterLandingCharge'.$i);
|
|
$HighSeas = $this->input->post('HighSeasSalesCharge'.$i);
|
|
$beforeHighSeas=$this->input->post('beforeHighSeasSalesCharge'.$i);
|
|
|
|
$AfterHighSeas = $this->input->post('AfterHighSeasSalesCharge'.$i);
|
|
|
|
$CustomDuty = $this->input->post('CustomDuty'.$i);
|
|
|
|
$beforeCustomDuty=$this->input->post('beforeCustomDuty'.$i);
|
|
|
|
$AfterCustomDuty = $this->input->post('AfterCustomDuty'.$i);
|
|
|
|
$ExciseDuty = $this->input->post('ExciseDuty'.$i);
|
|
$beforeExciseDuty=$this->input->post('beforeExciseDuty'.$i);
|
|
|
|
$AfterExciseDuty = $this->input->post('AfterExciseDuty'.$i);
|
|
|
|
$ExciseDutyEd = $this->input->post('ExciseDutyEdCess'.$i);
|
|
$beforeExciseDutyEd=$this->input->post('beforeExciseDutyEdCess'.$i);
|
|
|
|
$AfterExciseDutyEd = $this->input->post('AfterExciseDutyEdCess'.$i);
|
|
|
|
$ExciseDutySH = $this->input->post('ExciseDutySHCess'.$i);
|
|
$beforeExciseDutySH=$this->input->post('beforeExciseDutySHCess'.$i);
|
|
|
|
$AfterExciseDutySH = $this->input->post('AfterExciseDutySHCess'.$i);
|
|
|
|
$CustomEd= $this->input->post('CustomEdCess'.$i);
|
|
$beforeCustomEd=$this->input->post('beforeCustomEdCess'.$i);
|
|
|
|
$AfterCustomEd= $this->input->post('AfterCustomEdCess'.$i);
|
|
|
|
$CustomSH = $this->input->post('CustomSHCess'.$i);
|
|
$beforeCustomSH=$this->input->post('beforeCustomSHCess'.$i);
|
|
|
|
$AfterCustomSH = $this->input->post('AfterCustomSHCess'.$i);
|
|
|
|
$AddAdtional = $this->input->post('AddlExciseDuty'.$i);
|
|
$beforeAddAdtional=$this->input->post('beforeAddlExciseDuty'.$i);
|
|
|
|
|
|
$AfterAddAdtional = $this->input->post('AfterAddlExciseDuty'.$i);
|
|
|
|
$Grossdutypayable = $this->input->post('Grossdutypayable'.$i);
|
|
$beforeGrossdutypayable = $this->input->post('beforeGrossdutypayable'.$i);
|
|
|
|
$AvailableModvat = $this->input->post('AvailableModvat'.$i);
|
|
$beforeAvailableModvat = $this->input->post('beforeAvailableModvat'.$i);
|
|
|
|
$Grossexpensesduetocustomduty = $this->input->post('Grossexpensesduetocustomduty'.$i);
|
|
$beforeGrossexpensesduetocustomduty = $this->input->post('Grossexpensesduetocustomduty'.$i);
|
|
|
|
$purchaseratePerKG = $this->input->post('purchaseratePerKG'.$i);
|
|
$beforepurchaseratePerKG = $this->input->post('beforepurchaseratePerKG'.$i);
|
|
|
|
$CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpensesPerKG'.$i);
|
|
$beforeCustomDutyExpensesPerKG = $this->input->post('beforeCustomDutyExpensesPerKG'.$i);
|
|
|
|
$RMCIncludingCustomersPerKG = $this->input->post('RMCIncludingCustomersPerKG'.$i);
|
|
$beforeRMCIncludingCustomersPerKG = $this->input->post('RMCIncludingCustomersPerKG'.$i);
|
|
// if($RMCIncludingCustomersPerKG-$beforeRMCIncludingCustomersPerKG )
|
|
// {
|
|
// $CAD="Amended RMC Including Customs".$beforeRMCIncludingCustomersPerKG ."</br>";
|
|
// }
|
|
|
|
$QuantityKG = $this->input->post('QuantityKG'.$i);
|
|
|
|
|
|
|
|
//$POLineItemNo = $this->input->post('LineItemNo'.$i);
|
|
$CostCenter = $this->input->post('costCode'.$i);
|
|
|
|
$Totalvalueitem=$this->input->post('txtTotalorderValue');
|
|
$RecQtyvalue=0;
|
|
$rowspanvalue=0;
|
|
$LineItemNo = '';
|
|
|
|
if(($Quantity-$beforeQuantity)!=0)
|
|
{
|
|
$rowspanvalue++;
|
|
//$CAD="Amended Quantity :".$beforeQuantity ."</br>";
|
|
$CAD=$CAD."<tr><td>Amended Quantity : ".$beforeQuantity ."</td><td>Current Qty:".$Quantity."</td></tr>";
|
|
}
|
|
|
|
|
|
if(($LandingCharge-$beforeLandingCharge)!=0)
|
|
{
|
|
//$CAD=$CAD."Amended Landing :".$beforeLandingCharge ."</br>";
|
|
$rowspanvalue++;
|
|
$CAD=$CAD."<tr><td>Amended Landing percentage : ".$beforeLandingCharge ."</td><td>Current Landing Percentage:".$LandingCharge."</td></tr>";
|
|
}
|
|
|
|
if(($HighSeas-$beforeHighSeas)!=0)
|
|
{
|
|
$rowspanvalue++;
|
|
//$CAD=$CAD."Amended Highsesas :".$beforeHighSeas ."</br>";
|
|
$CAD=$CAD."<tr><td>Amended Highsesas : ".$beforeHighSeas ."</td><td>Current Highsesas:".$HighSeas."</td></tr>";
|
|
}
|
|
|
|
|
|
if(($CustomDuty-$beforeCustomDuty)!=0)
|
|
{
|
|
//$CAD=$CAD."Amended CustomDuty :".$beforeCustomDuty ."</br>";
|
|
$rowspanvalue++;
|
|
$CAD=$CAD."<tr><td>Amended CustomDuty : ".$beforeCustomDuty ."</td><td>Current CustomDuty:".$CustomDuty."</td></tr>";
|
|
}
|
|
|
|
|
|
|
|
if(($ExciseDuty-$beforeExciseDuty)!=0)
|
|
{
|
|
$rowspanvalue++;
|
|
//$CAD=$CAD."Amended ExciseDuty :".$beforeExciseDuty ."</br>";
|
|
$CAD=$CAD."<tr><td>Amended ExciseDuty : ".$beforeExciseDuty ."</td><td>Current ExciseDuty:".$ExciseDuty."</td></tr>";
|
|
|
|
}
|
|
|
|
if($ExciseDutyEd-$beforeExciseDutyEd)
|
|
{
|
|
$rowspanvalue++;
|
|
//$CAD=$CAD."Amended ExciseDutyEd :".$beforeExciseDutyEd ."</br>";
|
|
$CAD=$CAD."<tr><td>Amended ExciseDutyEd : ".$beforeExciseDutyEd ."</td><td>Current ExciseDutyEd:".$ExciseDutyEd."</td></tr>";
|
|
|
|
}
|
|
|
|
|
|
if($ExciseDutySH-$beforeExciseDutySH)
|
|
{
|
|
$rowspanvalue++;
|
|
//$CAD=$CAD."Amended ExciseDutySH :".$beforeExciseDutySH ."</br>";
|
|
$CAD=$CAD."<tr><td>Amended ExciseDutySH : ".$beforeExciseDutySH ."</td><td>Current ExciseDutySH:".$ExciseDutySH."</td></tr>";
|
|
|
|
}
|
|
|
|
if($CustomEd-$beforeCustomEd)
|
|
{
|
|
$rowspanvalue++;
|
|
//$CAD=$CAD."Amended CustomEd :".$beforeCustomEd ."</br>";
|
|
$CAD=$CAD."<tr><td>Amended CustomEd : ".$beforeCustomEd ."</td><td>Current CustomEd:".$CustomEd."</td></tr>";
|
|
|
|
}
|
|
|
|
|
|
if($CustomSH-$beforeCustomSH)
|
|
{
|
|
$rowspanvalue++;
|
|
//$CAD=$CAD."Amended CustomSH :".$beforeCustomSH ."</br>";
|
|
$CAD=$CAD."<tr><td>Amended CustomSH : ".$beforeCustomSH ."</td><td>Current CustomSH:".$CustomSH."</td></tr>";
|
|
|
|
}
|
|
|
|
|
|
if($AddAdtional-$beforeAddAdtional)
|
|
{
|
|
//$CAD=$CAD."Amended Additional Excise duty :".$beforeAddAdtional ."</br>";
|
|
$rowspanvalue++;
|
|
$CAD=$CAD."<tr><td>Amended Additional Excise duty: ".$beforeAddAdtional ."</td><td>Current Additional Excise duty:".$AddAdtional."</td></tr>";
|
|
}
|
|
|
|
|
|
if($rowspanvalue>0)
|
|
{
|
|
$rowspanvalue++;
|
|
|
|
$CAD2='';
|
|
$CAD2=$CAD;
|
|
$CAD='';
|
|
$CAD="<tr><td rowspan=". $rowspanvalue .">".$MaterialCode."</td></tr>";
|
|
$CAD.=$CAD2;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$POLineItemList = array('PONO'=>$NewPO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'AmendedDetails'=>$CAD);
|
|
//print_r($POLineItemList);
|
|
|
|
$POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
|
|
|
|
if(count($POLineItem)>0)
|
|
{
|
|
$LineItemNo = $POLineItem[0]['LineItemNo'];
|
|
}
|
|
// foreach($POLineItem as $line):
|
|
// $LineItemNo = $line['LineItemNo'];
|
|
// endforeach;
|
|
|
|
|
|
$ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem);
|
|
// print_r($ImportTaxList);
|
|
//die();
|
|
$ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList);
|
|
|
|
|
|
}
|
|
|
|
echo 'Purchase Order is'.$PONO.'Amended Successfully! New PO Number is: '.$NewPO ; }
|
|
|
|
function CreateAmendPOPrint()
|
|
{
|
|
$PONO = $_GET['PONO'];
|
|
$ReqType = $_GET['ReqType'];
|
|
|
|
if($ReqType == SERVICE)
|
|
{
|
|
$this ->servicepoprint($PONO);
|
|
|
|
}
|
|
else if($ReqType == REVENUE)
|
|
{
|
|
$this ->revenuepoprint($PONO);
|
|
|
|
}
|
|
|
|
else if($ReqType == IMPORT)
|
|
{
|
|
$this ->importpoprint($PONO);
|
|
|
|
}
|
|
else if($ReqType == CAPITAL)
|
|
{
|
|
$this ->CapitalPoPrint($PONO);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public function importpoprint($PONO)
|
|
{
|
|
|
|
//$this->load->view('includes/pdfheader');
|
|
|
|
// Load the pdf page with multiviews
|
|
$Requester='';
|
|
$Depcode='';
|
|
$Currencycode='';
|
|
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
|
|
$data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetailsForPDF($PONO);
|
|
//print_r($data['POItem']);
|
|
//die();
|
|
$data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO);
|
|
//print_r( $data['releasedetails']);
|
|
foreach ($data['POItem'] as $Reqdby)
|
|
{
|
|
$Requester=$Reqdby->Requestedby;
|
|
|
|
}
|
|
|
|
foreach ($data['POItem'] as $CURTYPE)
|
|
{
|
|
$Currencycode=$CURTYPE->CurrencyType;
|
|
}
|
|
|
|
$data['Requestername']=$this->purchaseorder_model->GerRequesterName($Requester);
|
|
|
|
foreach ($data['Requestername'] as $ReqDep)
|
|
{
|
|
$Depcode=$ReqDep->Departmentcode;
|
|
}
|
|
|
|
$data['DEPCODE']=$this->purchaseorder_model->GerRequesterDep($Depcode);
|
|
//print_r($data['Requestername']);
|
|
$data['Currencytype']=$this->purchaseorder_model->GerCurrencyCodeName($Currencycode);
|
|
$ProductPrice='';
|
|
$TotalOrderValue = '';
|
|
foreach ($data['POItem'] as $PO )
|
|
{
|
|
$TotalOrderValue=$PO->TotalOrderValue;
|
|
}
|
|
|
|
//$totalAmt=sprintf("%.2f", $ProductPrice);
|
|
//$data['TotalAmountInWords']= $this->convertNumber($totalAmt);
|
|
//print_r($data['TotalAmountInWords']);
|
|
|
|
//$this->load->View("importpopdf", $data);
|
|
|
|
|
|
$CurrencyType='';
|
|
if(!empty($data['POItem'])){
|
|
$CurrencyType=$data['POItem'][0]->CurrencyType;
|
|
}
|
|
//echo $CurrencyType;
|
|
|
|
if($CurrencyType=='')
|
|
{
|
|
$data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR');
|
|
}
|
|
else
|
|
{
|
|
$data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName($CurrencyType);
|
|
}
|
|
|
|
// $TotalOrderValue=$data['POItem'][0]->$TotalOrderValue;
|
|
//print_r($data['POItem'][0]);
|
|
|
|
$totalAmt=sprintf("%.2f", $TotalOrderValue);
|
|
|
|
$data['TotalAmountInWords']= $this->convertNumber($totalAmt);
|
|
|
|
|
|
|
|
|
|
$SymbolCurrency = '';
|
|
$SymbolCurrencyName ='';
|
|
$PaiseVal = '';
|
|
if(!empty($data['CurrencySymbol']) >0)
|
|
{
|
|
$SymbolCurrency=$data['CurrencySymbol'][0]->FontCode2000;
|
|
$SymbolCurrencyName=$data['CurrencySymbol'][0]->Currency;
|
|
$PaiseVal=$data['CurrencySymbol'][0]->PaiseVal;
|
|
}
|
|
$TotalOrderValue=$data['POItem'][0]->TotalOrderValue;
|
|
|
|
$totalAmt=sprintf("%.2f", $TotalOrderValue);
|
|
|
|
$data['TotalAmountInWords']= $this->convertNumberSymbol($totalAmt,$SymbolCurrency,$SymbolCurrencyName,$PaiseVal);
|
|
|
|
|
|
$this->load->View("Amendedimportpopdf", $data);
|
|
|
|
|
|
// Add header to pdf
|
|
//s $this->load->view('includes/pdffooter');
|
|
|
|
// Get output html
|
|
$php = $this->output->get_output();
|
|
|
|
// Load library
|
|
$this->load->library('dompdf_gen');
|
|
|
|
// Convert to PDF
|
|
//$this->dompdf->set_paper(array(0, 0, 841.89, 1190.55), 'landscape');
|
|
$this->dompdf->load_html($php);
|
|
$this->dompdf->render();
|
|
$data['Attachment'] = FALSE;
|
|
$this->dompdf->stream("ImportPOReport.pdf",$data,$php);
|
|
|
|
}
|
|
|
|
|
|
public function revenuepoprint($PONO)
|
|
{
|
|
// Load all views as normal
|
|
|
|
|
|
|
|
|
|
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
|
|
$data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetailsForAmendPDF($PONO);
|
|
//print_r($data['POItem']);
|
|
|
|
//die();
|
|
$data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO);
|
|
$data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR');
|
|
|
|
$Currencycode='';
|
|
|
|
$TotalOrderValue=$data['POItem'][0]->TotalOrderValue;
|
|
|
|
$totalAmt=sprintf("%.2f", $TotalOrderValue);
|
|
|
|
// die();
|
|
|
|
$data['TotalAmountInWords']= $this->convertNumber($totalAmt);
|
|
|
|
$data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO);
|
|
|
|
// Add header to pdf
|
|
//$this->load->view('includes/pdfheader');
|
|
|
|
// Load the pdf page with multiviews
|
|
$this->load->View("Amendrevenuepopdf", $data);
|
|
|
|
// Add header to pdf
|
|
//$this->load->view('includes/pdffooter');
|
|
|
|
// Get output html
|
|
$php = $this->output->get_output();
|
|
|
|
// // Load library
|
|
$this->load->library('dompdf_gen');
|
|
|
|
// // Convert to PDF
|
|
$this->dompdf->load_html($php);
|
|
|
|
$this->dompdf->render();
|
|
|
|
$data['Attachment'] = FALSE;
|
|
|
|
$this->dompdf->stream("Amendrevenuepopdf.pdf",$data,$php);
|
|
|
|
}
|
|
public function servicepoprint($PONO)
|
|
{
|
|
|
|
// $this->load->view('includes/pdfheader');
|
|
|
|
// Load the pdf page with multiviews
|
|
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
|
|
$data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderAmendDetailsforPdfprint($PONO);
|
|
|
|
|
|
$data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO);
|
|
|
|
$data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR');
|
|
|
|
//print_r( $data['CurrencySymbol']);
|
|
|
|
$TotalOrderValue=0;
|
|
$Currencycode='';
|
|
foreach ($data['POItem'] as $POValue)
|
|
{
|
|
|
|
$TotalOrderValue=$TotalOrderValue + $POValue->TotalValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$totalAmt=sprintf("%.2f", $TotalOrderValue);
|
|
|
|
$data['TotalAmountInWords']= $this->convertNumber($totalAmt);
|
|
|
|
$data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO);
|
|
|
|
$this->load->View("Amendervicepopdf", $data);
|
|
|
|
// Add header to pdf
|
|
//$this->load->view('includes/pdffooter');
|
|
|
|
// Get output html
|
|
$php = $this->output->get_output();
|
|
|
|
// Load library
|
|
$this->load->library('dompdf_gen');
|
|
|
|
// Convert to PDF
|
|
$this->dompdf->load_html($php);
|
|
$this->dompdf->render();
|
|
$data['Attachment'] = FALSE;
|
|
$this->dompdf->stream("Amendservicepopdf.pdf",$data,$php);
|
|
|
|
}
|
|
|
|
public function CapitalPoPrint($PONO)
|
|
{
|
|
|
|
|
|
|
|
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
|
|
//print_r($data['CompanyDetails']);
|
|
$data['POItem'] = $this->purchaseorder_model->GetCapitalAmendPurchaseOrderDetailsForprintPDF($PONO);
|
|
//print_r($data['POItem']);
|
|
$data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO);
|
|
//print_r($data['releasedetails']);
|
|
|
|
$CurrencyType='';
|
|
if(!empty($data['POItem'])){
|
|
$CurrencyType=$data['POItem'][0]->CurrencyType;
|
|
// echo $CurrencyType;
|
|
}
|
|
|
|
|
|
if($CurrencyType=='' OR $CurrencyType=='0'){
|
|
$data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR');
|
|
// echo "<br><br>";
|
|
//print_r($data['CurrencySymbol']);
|
|
$TotalOrderValue=$data['POItem'][0]->TotalOrderValue;
|
|
//echo $TotalOrderValue;
|
|
$totalAmt=sprintf("%.2f", $TotalOrderValue);
|
|
//echo $totalAmt;
|
|
$data['TotalAmountInWords']= $this->convertNumber($totalAmt);
|
|
//print_r($data['TotalAmountInWords']);
|
|
}
|
|
|
|
|
|
else{
|
|
$data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName($CurrencyType);
|
|
//echo "<br><br>";
|
|
// print_r($data['CurrencySymbol']);
|
|
$SymbolCurrency=$data['CurrencySymbol'][0]->FontCode2000;
|
|
$SymbolCurrencyName=$data['CurrencySymbol'][0]->Currency;
|
|
$PaiseVal=$data['CurrencySymbol'][0]->PaiseVal;
|
|
|
|
$TotalOrderValue=$data['POItem'][0]->TotalOrderValue;
|
|
// echo $TotalOrderValue;
|
|
$totalAmt=sprintf("%.2f", $TotalOrderValue);
|
|
//echo "<br>" . $totalAmt;
|
|
|
|
$data['TotalAmountInWords']= $this->convertNumberSymbol($totalAmt,$SymbolCurrency,$SymbolCurrencyName,$PaiseVal);
|
|
//print_r($data['TotalAmountInWords']);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO);
|
|
|
|
|
|
|
|
$this->load->View("amendcapitalpopdf", $data);
|
|
|
|
|
|
|
|
|
|
$php = $this->output->get_output();
|
|
|
|
// Load library
|
|
$this->load->library('dompdf_gen');
|
|
|
|
// Convert to PDF
|
|
$this->dompdf->load_html($php);
|
|
$this->dompdf->render();
|
|
$data['Attachment'] = FALSE;
|
|
$this->dompdf->stream("capitalamenpo.pdf",$data,$php);
|
|
|
|
}
|
|
|
|
public function convertNumber($amt){
|
|
$ShowPaise='0';
|
|
$totalAmt=explode(".",$amt);
|
|
|
|
$number = $totalAmt[0];
|
|
$no = $number;
|
|
|
|
if(!empty($totalAmt[1]) && $totalAmt[1]!=0){
|
|
$point = $totalAmt[1];
|
|
$ShowPaise='1';
|
|
}
|
|
else{
|
|
$point=0;
|
|
$ShowPaise='0';
|
|
}
|
|
|
|
|
|
$hundred = null;
|
|
$digits_1 = strlen($no);
|
|
|
|
$i = 0;
|
|
$str = array();
|
|
$words = array('0' => '', '1' => 'one', '2' => 'two',
|
|
'3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six',
|
|
'7' => 'seven', '8' => 'eight', '9' => 'nine',
|
|
'10' => 'ten', '11' => 'eleven', '12' => 'twelve',
|
|
'13' => 'thirteen', '14' => 'fourteen',
|
|
'15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen',
|
|
'18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty',
|
|
'30' => 'thirty', '40' => 'forty', '50' => 'fifty',
|
|
'60' => 'sixty', '70' => 'seventy',
|
|
'80' => 'eighty', '90' => 'ninety');
|
|
$digits = array('', 'hundred', 'thousand', 'lakh', 'crore');
|
|
while ($i < $digits_1) {
|
|
$divider = ($i == 2) ? 10 : 100;
|
|
$number = floor($no % $divider);
|
|
$no = floor($no / $divider);
|
|
$i += ($divider == 10) ? 1 : 2;
|
|
if ($number) {
|
|
$plural = (($counter = count($str)) && $number > 9) ? 's' : null;
|
|
$hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
|
|
$str [] = ($number < 21) ? $words[$number] .
|
|
" " . $digits[$counter] . $plural . " " . $hundred
|
|
:
|
|
$words[floor($number / 10) * 10]
|
|
. " " . $words[$number % 10] . " "
|
|
. $digits[$counter] . $plural . " " . $hundred;
|
|
} else $str[] = null;
|
|
}
|
|
$str = array_reverse($str);
|
|
$result = implode('', $str);
|
|
|
|
$points = ($point) ?
|
|
" " . $words[$point / 10] . " " .
|
|
$words[$point = $point % 10] : '';
|
|
|
|
if($ShowPaise=='0'){
|
|
|
|
$amountInWords = "Rupee " . $result." Only";
|
|
}
|
|
else{
|
|
|
|
$amountInWords = "Rupee " . $result ." Paise ". $points." Only";
|
|
}
|
|
|
|
|
|
return $amountInWords;
|
|
}
|
|
|
|
public function convertNumberSymbol($amt,$symbol,$name,$paise){
|
|
$ShowPaise='0';
|
|
$totalAmt=explode(".",$amt);
|
|
|
|
$number = $totalAmt[0];
|
|
$no = $number;
|
|
if(!empty($totalAmt[1]) && $totalAmt[1]!=0){
|
|
$point = $totalAmt[1];
|
|
$ShowPaise='1';
|
|
}
|
|
else{
|
|
$point=0;
|
|
$ShowPaise='0';
|
|
}
|
|
|
|
$hundred = null;
|
|
$digits_1 = strlen($no);
|
|
|
|
$i = 0;
|
|
$str = array();
|
|
$words = array('0' => '', '1' => 'one', '2' => 'two',
|
|
'3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six',
|
|
'7' => 'seven', '8' => 'eight', '9' => 'nine',
|
|
'10' => 'ten', '11' => 'eleven', '12' => 'twelve',
|
|
'13' => 'thirteen', '14' => 'fourteen',
|
|
'15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen',
|
|
'18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty',
|
|
'30' => 'thirty', '40' => 'forty', '50' => 'fifty',
|
|
'60' => 'sixty', '70' => 'seventy',
|
|
'80' => 'eighty', '90' => 'ninety');
|
|
$digits = array('', 'hundred', 'thousand', 'lakh', 'crore');
|
|
while ($i < $digits_1) {
|
|
$divider = ($i == 2) ? 10 : 100;
|
|
$number = floor($no % $divider);
|
|
$no = floor($no / $divider);
|
|
$i += ($divider == 10) ? 1 : 2;
|
|
if ($number) {
|
|
$plural = (($counter = count($str)) && $number > 9) ? 's' : null;
|
|
$hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
|
|
$str [] = ($number < 21) ? $words[$number] .
|
|
" " . $digits[$counter] . $plural . " " . $hundred
|
|
:
|
|
$words[floor($number / 10) * 10]
|
|
. " " . $words[$number % 10] . " "
|
|
. $digits[$counter] . $plural . " " . $hundred;
|
|
} else $str[] = null;
|
|
}
|
|
$str = array_reverse($str);
|
|
$result = implode('', $str);
|
|
|
|
$points = ($point) ?
|
|
" " . $words[$point / 10] . " " .
|
|
$words[$point = $point % 10] : '';
|
|
|
|
if($ShowPaise=='0'){
|
|
$amountInWords = $name." " . $result." Only";
|
|
}
|
|
else{
|
|
$amountInWords = $name." " . $result.$paise ." ". $points." Only";
|
|
}
|
|
|
|
|
|
return $amountInWords;
|
|
}
|
|
|
|
function getDateformat($Val)
|
|
{
|
|
$date = new DateTime($Val,new DateTimeZone('Asia/Kolkata'));
|
|
$retDate = $date->format('Y-m-d H:i:s');
|
|
return $retDate;
|
|
}
|
|
|
|
} |