1665 lines
72 KiB
PHP
Executable File
1665 lines
72 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
use App\Models\Purchaseorder_model;
|
|
use App\Models\Costcenter_model;
|
|
use CodeIgniter\Validation\Exceptions\ValidationException;
|
|
|
|
/**
|
|
* Module : PO-Purchase Order
|
|
* Amendmentpurchaseorder Class to control all amendmented po's related operations.
|
|
* @author : Venba Info Tech - Velmurugan
|
|
* @version : 1.1
|
|
* @since : 18 November 2017
|
|
* @example : Revised at 15th april 2024
|
|
*/
|
|
class Amendmentpurchaseorder extends BaseController
|
|
{
|
|
protected $purchaseorder_model;
|
|
protected $costcenter_model;
|
|
protected $session;
|
|
|
|
/**
|
|
* default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->purchaseorder_model = new Purchaseorder_model();
|
|
$this->costcenter_model = new Costcenter_model();
|
|
$this->session = session();
|
|
// $this->session = \CodeIgniter\Config\Factories::libraries('session');
|
|
helper(['form']);
|
|
$this->isLoggedIn();
|
|
}
|
|
|
|
/**
|
|
* Index Page for this controller(default function of the class)
|
|
*/
|
|
public function index()
|
|
{
|
|
|
|
|
|
if ($this->request->getMethod() === 'GET')
|
|
{
|
|
$currentYear = date('Y');
|
|
$currentMonth = date('m');
|
|
$startOfMonth = "$currentYear-$currentMonth-01";
|
|
$endOfMonth = date('Y-m-t');
|
|
$fromDate = $startOfMonth;
|
|
$toDate = $endOfMonth;
|
|
} elseif ($this->request->getMethod() === 'POST') {
|
|
$fromDate = $this->request->getPost('fromDate');
|
|
$toDate = $this->request->getPost('toDate');
|
|
$fromDate = date('Y-m-d', strtotime($fromDate));
|
|
$toDate = date('Y-m-d', strtotime($toDate));
|
|
}
|
|
|
|
// $this->load->library('pagination');
|
|
$forwhat = 'amendment';
|
|
|
|
$data['POData'] = $this->purchaseorder_model->purchaseorderListing($forwhat,$fromDate,$toDate);
|
|
$data['fromDate'] = date('d-m-Y', strtotime($fromDate));
|
|
$data['toDate'] = date('d-m-Y', strtotime($toDate));
|
|
|
|
$this->global['pageTitle'] = '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 = '';
|
|
|
|
|
|
$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'] = '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);
|
|
// echo "<pre>";
|
|
// print_r($data['POItem']);die;
|
|
$data['PaymentTerms'] = $this->purchaseorder_model->GetPaymentTerms($PONO);
|
|
$this->global['pageTitle'] = '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'] = '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'] = '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->request->getPost('txtPONO');
|
|
$POdt = $this->request->getPost('PODate');
|
|
$PODate = get_date_time_format($POdt);
|
|
$SupplierID = $this->request->getPost('drpSupplier');
|
|
$POType = $this->request->getPost('POType');
|
|
$DeliveryAddr = $this->request->getPost('txtDeliveryAddress');
|
|
$dt = $this->request->getPost('Deliverydt');
|
|
$predeliverydate = $this->request->getPost('beforeDeliverydt');
|
|
$preschedule = $this->request->getPost('beforeScheduleby');
|
|
$DeliverySchedule1 = $this->request->getPost('Scheduleby');
|
|
$DeliveryOption = $this->request->getPost('DateRange');
|
|
|
|
if ($DeliveryOption == 1) {
|
|
$Deliverydt = null;
|
|
$DeliverySchedule = $this->request->getPost('Scheduleby');
|
|
} else {
|
|
$Deliverydt = get_date_time_format($dt);
|
|
$DeliverySchedule = '';
|
|
}
|
|
$Modeofshipment = $this->request->getPost('addmodeofshipment');
|
|
$supplierreference = $this->request->getPost('amendsupplierreference');
|
|
$supplieroffno = $this->request->getPost('amendsupplierofferno');
|
|
$otherreference = $this->request->getPost('amendotherreference');
|
|
$fincap = ""; //$this->request->getPost('amendfincap');
|
|
$revenuetype = $this->request->getPost('PoTypeOptions');
|
|
$insurancestatus = $this->request->getPost('insurancestatus');
|
|
if ($insurancestatus == 1) {
|
|
$InsuranceNumber = $this->request->getPost('InsuranceNumber');
|
|
} else {
|
|
$InsuranceNumber = "";
|
|
}
|
|
|
|
$POType = $this->request->getPost('POType');
|
|
$PoRange = $this->request->getPost('Range');
|
|
$PaymentTermsText = $this->request->getPost('beforePaymentTermsText');
|
|
$PaymentTerms = $this->request->getPost('PaymentTerms');
|
|
$Otherpayment = $this->request->getPost('Otherpayment');
|
|
$Otherpaymentamend = $this->request->getPost('Otherpayment');
|
|
$prePaymentTerms = $this->request->getPost('beforePaymentTerms');
|
|
$preTotalOdervalue = $this->request->getPost('preTotalOdervalue');
|
|
$MAD .= "Current TotalOrder Value: :" . $preTotalOdervalue . "<br>";
|
|
$testdate = get_current_date();
|
|
if ($PaymentTerms != $prePaymentTerms) {
|
|
if ($prePaymentTerms != 'PT08') {
|
|
$Otherpaymentamend = '';
|
|
}
|
|
$MAD .= "Current PaymentTerms : " . $PaymentTermsText . $Otherpaymentamend . "<br>";
|
|
}
|
|
|
|
if (($dt != $predeliverydate) || ($DeliverySchedule1 != $preschedule)) {
|
|
$MAD .= 'Current Delivery Option : ' . $predeliverydate . $preschedule . '<br>';
|
|
}
|
|
|
|
$SpecialInstruction = $this->request->getPost('txtSpcialInstruction');
|
|
$TotalOrderValueSummary = $this->request->getPost('txtTotalOrderValueSummary');
|
|
$POStatus = $this->request->getPost('txtStatus');
|
|
$updatedBy = $this->session->get('userId');
|
|
$RowCount = $this->request->getPost('txtRowCount');
|
|
$updateddt = get_current_date_time();
|
|
|
|
$qtycheck = $this->purchaseorder_model->getqtycheck($PONO);
|
|
$qtycheckresult = '';
|
|
foreach ($qtycheck as $qty) {
|
|
$qtycheckresult = $qty->IsQualityChkReqired;
|
|
}
|
|
|
|
if (empty($Deliverydt)) {
|
|
$Deliverydt = null;
|
|
}
|
|
|
|
if ($PaymentTerms != 'PT08') {
|
|
$Otherpayment = '';
|
|
}
|
|
$AmendmentNewPoNo = generate_amendment_po_number($PONO);
|
|
|
|
$POMaster = array('PONO' => $AmendmentNewPoNo, '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' => $InsuranceNumber, 'POSubType' => $revenuetype, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'ServiceDescription' => $SpecialInstruction, 'CreatedBy' => $updatedBy, 'DeliveryAddress' => $DeliveryAddr, 'DeliveryDate' => $Deliverydt, 'UpdatedOn' => $updateddt, 'ReleasedBy' => $updatedBy, 'ReleasedOn' => $updateddt, 'AmendedDetails' => $MAD, 'IsQualityChkReqired' => $qtycheckresult);
|
|
$file = $this->request->getFile('POFile');
|
|
$requestfilename = $file->getName();
|
|
$PrePOFile = $this->request->getPost('PrePOFile');
|
|
if (!empty($requestfilename)) {
|
|
if ($file && $file->isValid() && !$file->hasMoved()) {
|
|
$path = ROOTPATH . 'public/uploads/POfiles/';
|
|
if (!is_dir($path)) {
|
|
mkdir($path, 0777, true);
|
|
}
|
|
if (!empty($this->purchaseorder_model->isFileExists($requestfilename))) {
|
|
log_message('error', 'File already exists in the database' . $requestfilename);
|
|
$POMaster['POFile'] = $PrePOFile ? $PrePOFile : null;
|
|
} else {
|
|
$file->move($path, $requestfilename);
|
|
$POMaster['POFile'] = $requestfilename;
|
|
}
|
|
} else {
|
|
$POMaster['POFile'] = $PrePOFile ? $PrePOFile : null;
|
|
}
|
|
} else {
|
|
$POMaster['POFile'] = $PrePOFile ? $PrePOFile : null;
|
|
}
|
|
// print_r($POMaster);die;
|
|
|
|
$LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster, $updatedBy, $PONO);
|
|
|
|
if(!empty($LastPO)){
|
|
if (count($LastPO) > 0) {
|
|
$NewPO = $LastPO[0]['PONO'];
|
|
}
|
|
}else{
|
|
$NewPO = "";
|
|
}
|
|
|
|
$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->request->getPost('materialCode' . $i);
|
|
$Quantity = $this->request->getPost('quantity' . $i);
|
|
$preqty = $this->request->getPost('beforeqty' . $i);
|
|
$Reqnumber = $this->request->getPost('Reqnumber' . $i);
|
|
$itemRate = $this->request->getPost('itemRate' . $i);
|
|
$preitemrate = $this->request->getPost('beforeitemRate' . $i);
|
|
$per = $this->request->getPost('per' . $i);
|
|
$servicematerialdescription = $this->request->getPost('service_description' . $i);
|
|
|
|
$DiscountType = $this->request->getPost('DisType' . $i);
|
|
$beforeDiscountType = $this->request->getPost('beforeDisType' . $i);
|
|
$DiscountValue = $this->request->getPost('DisVal' . $i);
|
|
$preDiscountValue = $this->request->getPost('beforeDisVal' . $i);
|
|
$AfterDiscount = $this->request->getPost('AfterDisVal' . $i);
|
|
$beforeAfterDiscount = $this->request->getPost('beforeAfterDisVal' . $i);
|
|
|
|
$PackagingOption = $this->request->getPost('PackOption' . $i);
|
|
$PackagingType = $this->request->getPost('PackType' . $i);
|
|
$beforePackagingType = $this->request->getPost('beforePackType' . $i);
|
|
$PackagingValue = $this->request->getPost('PackVal' . $i);
|
|
$prePackagingValue = $this->request->getPost('beforePackVal' . $i);
|
|
$AfterPackagingValue = $this->request->getPost('AfterPackVal' . $i);
|
|
$beforeAfterPackagingValue = $this->request->getPost('beforeAfterPackVal' . $i);
|
|
|
|
|
|
$VatValue = $this->request->getPost('VatVal' . $i); //SGST
|
|
$preVatValue = $this->request->getPost('beforeVatVal' . $i);
|
|
$AfterVatValue = $this->request->getPost('AfterVatVal' . $i);
|
|
$beforeAfterVatValue = $this->request->getPost('beforeAfterVatVal' . $i);
|
|
|
|
$GSTValue = $this->request->getPost('GSTVal' . $i); //CGST
|
|
$preGSTValue = $this->request->getPost('beforeGSTVal' . $i);
|
|
$AfterGSTValue = $this->request->getPost('AfterGSTVal' . $i);
|
|
$beforeAfterGSTValue = $this->request->getPost('beforeAfterGSTVal' . $i);
|
|
|
|
$OtherTaxValue = $this->request->getPost('OtherTaxVal' . $i); //IGST
|
|
$preOtherTaxValue = $this->request->getPost('beforeOtherTaxVal' . $i);
|
|
$AfterOtherTaxValue = $this->request->getPost('AfterOtherTaxVal' . $i);
|
|
$beforeAfterOtherTaxValue = $this->request->getPost('beforeAfterOtherTaxVal' . $i);
|
|
|
|
$FreightType = $this->request->getPost('FreightType' . $i);
|
|
$beforeFreightType = $this->request->getPost('beforeFreightType' . $i);
|
|
$FreightValue = $this->request->getPost('FreightVal' . $i);
|
|
$preFreightValue = $this->request->getPost('beforeFreightVal' . $i);
|
|
$AfterFreightValue = $this->request->getPost('AfterFreightVal' . $i);
|
|
$beforeAfterFreightValue = $this->request->getPost('beforeAfterFreightVal' . $i);
|
|
|
|
$NoofTrips = $this->request->getPost('Nooftrips' . $i);
|
|
$beforeNoofTrips = $this->request->getPost('beforeNooftrips' . $i);
|
|
|
|
$InsuranceValue = $this->request->getPost('Insval' . $i);
|
|
$preInsuranceValue = $this->request->getPost('beforeInsval' . $i);
|
|
$TotalOrderValue = $this->request->getPost('TotalOrderValue' . $i);
|
|
$POLineItemNo = $this->request->getPost('LineItemNo' . $i);
|
|
$CostCenter = $this->request->getPost('costCode' . $i);
|
|
$ServiceFrequency = $this->request->getPost('Frequency' . $i);
|
|
$LineItemNo = '';
|
|
$RecQtyvalue = 0.00;
|
|
$rowspanvalue = 0;
|
|
|
|
if (($Quantity - $preqty) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Quantity : " . $preqty . "</td><td>Revised Qty : " . $Quantity . "</td></tr>";
|
|
}
|
|
if (($itemRate - $preitemrate) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Rate : " . $preitemrate . "</td><td>Revised Item Rate : " . $itemRate . "</td></tr>";
|
|
}
|
|
if ($DiscountType != $beforeDiscountType) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current DiscountType : " . $beforeDiscountType . "</td><td>Revised DiscountType : " . $DiscountType . "</td></tr>";
|
|
}
|
|
if (($DiscountValue - $preDiscountValue) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Discount : " . $preDiscountValue . "</td><td>Revised Discount : " . $DiscountValue . "</td></tr>";
|
|
}
|
|
if (($AfterDiscount - $beforeAfterDiscount) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Discount Value : " . $beforeAfterDiscount . "</td><td>Revised Discount Value : " . $AfterDiscount . "</td></tr>";
|
|
}
|
|
if ($PackagingType != $beforePackagingType) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Packaging Type : " . $beforePackagingType . "</td><td>Revised Packaging Type : " . $PackagingType . "</td></tr>";
|
|
}
|
|
if (($PackagingValue - $prePackagingValue) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Package Value : " . $prePackagingValue . "</td><td>Revised Package Value : " . $PackagingValue . "</td></tr>";
|
|
}
|
|
if (($AfterPackagingValue - $beforeAfterPackagingValue) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Package Value : " . $beforeAfterPackagingValue . "</td><td>Revised Package Value : " . $AfterPackagingValue . "</td></tr>";
|
|
}
|
|
if (($VatValue - $preVatValue) != 0) //SGST
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current SGST : " . $preVatValue . "</td><td>Revised SGST : " . $VatValue . "</td></tr>";
|
|
}
|
|
if (($AfterVatValue - $beforeAfterVatValue) != 0) //SGST
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current SGST value : " . $beforeAfterVatValue . "</td><td>Revised SGST Value : " . $AfterVatValue . "</td></tr>";
|
|
}
|
|
if (($GSTValue - $preGSTValue) != 0) //CGST
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current CGST : " . $preGSTValue . "</td><td>Revised CGST : " . $GSTValue . "</td></tr>";
|
|
}
|
|
if (($AfterGSTValue - $beforeAfterGSTValue) != 0) //CGST
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current CGST Value : " . $beforeAfterGSTValue . "</td><td>Revised CGST Value : " . $AfterGSTValue . "</td></tr>";
|
|
}
|
|
if (($OtherTaxValue - $preOtherTaxValue) != 0) //IGST
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current IGST : " . $preOtherTaxValue . "</td><td>Revised IGST : " . $OtherTaxValue . "</td></tr>";
|
|
}
|
|
if (($AfterOtherTaxValue - $beforeAfterOtherTaxValue) != 0) //IGST
|
|
{
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current IGST : " . $beforeAfterOtherTaxValue . "</td><td>Revised IGST : " . $AfterOtherTaxValue . "</td></tr>";
|
|
}
|
|
if ($FreightType != $beforeFreightType) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Freight Type : " . $beforeFreightType . "</td><td>Revised Freight Type : " . $FreightType . "</td></tr>";
|
|
}
|
|
if (($FreightType == "PER TRIP") || ($beforeFreightType == "PER TRIP")) {
|
|
if ($NoofTrips != $beforeNoofTrips) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current No of Trips : " . $beforeNoofTrips . "</td><td>Revised No of Trips : " . $NoofTrips . "</td></tr>";
|
|
}
|
|
}
|
|
|
|
if (((int)$FreightValue - $preFreightValue) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Freight : " . $preFreightValue . "</td><td>Revised Freight : " . $FreightValue . "</td></tr>";
|
|
}
|
|
if (($AfterFreightValue - $beforeAfterFreightValue) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Freight Value : " . $beforeAfterFreightValue . "</td><td>Revised Freight Value : " . $AfterFreightValue . "</td></tr>";
|
|
}
|
|
|
|
if (($InsuranceValue - $preInsuranceValue) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Insurance Value : " . $preInsuranceValue . "</td><td>Revised Insurance Value : " . $InsuranceValue . "</td></tr>";
|
|
}
|
|
if ($rowspanvalue > 0) {
|
|
$rowspanvalue++;
|
|
$CAD2 = '';
|
|
$CAD2 = $CAD;
|
|
$CAD = '';
|
|
$CAD = "<tr><td rowspan=" . $rowspanvalue . ">" . $MaterialCode . "</td></tr>";
|
|
$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->request->getPost('txtPONO');
|
|
|
|
$MAD = '';
|
|
$POdt = $this->request->getPost('PODate');
|
|
$PODate = get_date_time_format($POdt);
|
|
|
|
$SupplierID = $this->request->getPost('drpSupplier');
|
|
$DeliveryAddr = $this->request->getPost('txtDeliveryAddress');
|
|
$dt = $this->request->getPost('Deliverydt');
|
|
$DeliveryOption = $this->request->getPost('DateRange');
|
|
|
|
if ($DeliveryOption == 1) {
|
|
$Deliverydt = null;
|
|
$DeliverySchedule = $this->request->getPost('Scheduleby');
|
|
} else {
|
|
$Deliverydt = get_date_time_format($dt);
|
|
$DeliverySchedule = '';
|
|
}
|
|
|
|
$ddate = $this->request->getPost('Deliverydt');
|
|
$beforeddate = $this->request->getPost('beforeDeliverydt');
|
|
$testdate = get_current_date();
|
|
$dschedule = $this->request->getPost('Scheduleby');
|
|
$beforedschedule = $this->request->getPost('beforeScheduleby');
|
|
$preTotalordervalue = $this->request->getPost('preTotalordervalue');
|
|
$MAD .= "Current TotalOrder Value: " . $preTotalordervalue . "<br>";
|
|
|
|
if (($ddate != $beforeddate) || ($dschedule != $beforedschedule)) {
|
|
$MAD .= "Current DeliveryOption : " . $beforeddate . $beforedschedule . "<br>";
|
|
}
|
|
|
|
$PaymentTermsText = $this->request->getPost('beforePaymentTermsText');
|
|
$PaymentTerms = $this->request->getPost('PaymentTerms');
|
|
$Otherpayment = $this->request->getPost('Otherpayment');
|
|
$Otherpaymentamend = $this->request->getPost('Otherpayment');
|
|
$beforePaymentTerms = $this->request->getPost('beforePaymentTerms');
|
|
|
|
if ($PaymentTerms != $beforePaymentTerms) {
|
|
if ($beforePaymentTerms != 'PT08') {
|
|
$Otherpaymentamend = '';
|
|
}
|
|
$MAD .= "Current PaymentTerms : " . $PaymentTermsText . $Otherpaymentamend . "<br>";
|
|
}
|
|
|
|
$POType = $this->request->getPost('POType');
|
|
$ModeOfShipment = $this->request->getPost('addmodeofshipment');
|
|
$SupplierReference = $this->request->getPost('amendsupplierreference');
|
|
$SuppliersOfferNo = $this->request->getPost('amendsupplierofferno');
|
|
$OtherReferences = $this->request->getPost('amendotherreference');
|
|
$Fincap = ""; //$this->request->getPost('amendfincap');
|
|
$InsuranceOptions = $this->request->getPost('insuranceStatus');
|
|
$InsuranceNumber = $this->request->getPost('InsuranceNumber');
|
|
$ServiceTypeOptions = $this->request->getPost('PoTypeOptions');
|
|
$DescriptionOfPo = $this->request->getPost('amenddescofpo');
|
|
$scopeofwork = $this->request->getPost('ScopeofWork');
|
|
$TotalOrderValueSummary = $this->request->getPost('txtTotalOrderValueSummary');
|
|
$POStatus = $this->request->getPost('txtStatus');
|
|
|
|
$updatedBy = $this->session->get('userId');
|
|
$RowCount = $this->request->getPost('txtRowCount');
|
|
|
|
|
|
$updateddt = get_current_date_time();
|
|
$WorkStatus = $this->request->getPost('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 = '';
|
|
}
|
|
$AmendmentNewPoNo = generate_amendment_po_number($PONO);
|
|
|
|
$POMaster = array('PONO' => $AmendmentNewPoNo, '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' => strip_tags((string)$DescriptionOfPo), 'InsuranceStatus' => $InsuranceOptions, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $ServiceTypeOptions, 'IsQualityChkReqired' => $qtycheckresult);
|
|
$file = $this->request->getFile('POFile');
|
|
$PrePOFile = $this->request->getPost('PrePOFile');
|
|
$requestfilename = $file ? $file->getName() : null;
|
|
if (!empty($requestfilename)) {
|
|
if ($file && $file->isValid() && !$file->hasMoved()) {
|
|
$path = ROOTPATH . 'public/uploads/POfiles/';
|
|
if (!is_dir($path)) {
|
|
mkdir($path, 0777, true);
|
|
}
|
|
if (!empty($this->purchaseorder_model->isFileExists($requestfilename))) {
|
|
log_message('error', 'File already exists in the database' . $requestfilename);
|
|
$POMaster['POFile'] = $PrePOFile ? $PrePOFile : null;
|
|
} else {
|
|
$file->move($path, $requestfilename);
|
|
$POMaster['POFile'] = $requestfilename;
|
|
}
|
|
} else {
|
|
$POMaster['POFile'] = $PrePOFile ? $PrePOFile : null;
|
|
}
|
|
} else {
|
|
$POMaster['POFile'] = $PrePOFile ? $PrePOFile : null;
|
|
}
|
|
$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->request->getPost('materialCode' . $i);
|
|
$MaterialName = $this->request->getPost('materialName' . $i);
|
|
$Quantity = $this->request->getPost('quantity' . $i);
|
|
$beforeQuantity = $this->request->getPost('beforequantity' . $i);
|
|
$Reqnumber = $this->request->getPost('Reqnumber' . $i);
|
|
$itemRate = $this->request->getPost('itemRate' . $i);
|
|
$beforeitemRate = $this->request->getPost('beforeitemRate' . $i);
|
|
$Per = $this->request->getPost('per' . $i);
|
|
$AfterSGST = $this->request->getPost('AfterSgst' . $i);
|
|
$beforeSGSTvalue = $this->request->getPost('beforeSgstvalue' . $i);
|
|
$AfterCGST = $this->request->getPost('AfterCgst' . $i);
|
|
$beforeCGSTvalue = $this->request->getPost('beforeCgstvalue' . $i);
|
|
$AfterIGST = $this->request->getPost('AfterIgst' . $i);
|
|
$beforeIGSTvalue = $this->request->getPost('beforeIgstvalue' . $i);
|
|
$SGST = $this->request->getPost('Sgst' . $i);
|
|
$beforeSGST = $this->request->getPost('beforeSgst' . $i);
|
|
$CGST = $this->request->getPost('Cgst' . $i);
|
|
$beforeCGST = $this->request->getPost('beforeCgst' . $i);
|
|
$IGST = $this->request->getPost('Igst' . $i);
|
|
$beforeIGST = $this->request->getPost('beforeIgst' . $i);
|
|
$otherallowance = $this->request->getPost('otherallowance' . $i);
|
|
$beforeotherallowance = $this->request->getPost('beforeotherallowance' . $i);
|
|
$servicematerialdescription = $this->request->getPost('servicematerialdescription' . $i);
|
|
$CostCenter = $this->request->getPost('costCode' . $i);
|
|
$POLineItemNo = $this->request->getPost('LineItemNo' . $i);
|
|
$TotalOrderValue = $this->request->getPost('TotalOrderValue' . $i);
|
|
$ServiceFrequency = $this->request->getPost('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 .= "<tr><td>Current Qty : " . $beforeQuantity . "</td><td>Revised Qty : " . $Quantity . "</td></tr>";
|
|
}
|
|
if ($itemRate != $beforeitemRate) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Rate : " . $beforeitemRate . "</td><td>Revised Rate : " . $itemRate . "</td></tr>";
|
|
}
|
|
|
|
if (($SGST != $beforeSGST) && ($AfterSGST != $beforeSGSTvalue)) {
|
|
$rowspanvalue += 2;
|
|
$CAD .= "<tr><td>Current SGST% : " . $beforeSGST . "</td><td>Revised SGST% : " . $SGST . "</td></tr><tr><td>Current SGST value : " . $beforeSGSTvalue . "</td><td>Revised SGST value: " . $AfterSGST . "</td></tr>";
|
|
}
|
|
if (($CGST != $beforeCGST) && ($AfterCGST != $beforeCGSTvalue)) {
|
|
$rowspanvalue += 2;
|
|
$CAD .= "<tr><td>Current CGST% : " . $beforeCGST . "</td><td>Revised CGST% : " . $CGST . "</td></tr><tr><td>Current CGST value : " . $beforeCGSTvalue . "</td><td>Revised CGST value: " . $AfterCGST . "</td></tr>";
|
|
}
|
|
if (($IGST != $beforeIGST) && ($AfterIGST != $beforeIGSTvalue)) {
|
|
$rowspanvalue += 2;
|
|
$CAD .= "<tr><td>Current IGST% : " . $beforeIGST . "</td><td>Revised IGST% : " . $IGST . "</td></tr><tr><td>Current IGST value : " . $beforeIGSTvalue . "</td><td>Revised IGST value: " . $AfterIGST . "</td></tr>";
|
|
}
|
|
if ($otherallowance != $beforeotherallowance) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current OtherAllowances : " . $beforeotherallowance . "</td><td>Revised OtherAllowances : " . $otherallowance . "</td></tr>";
|
|
}
|
|
if ($rowspanvalue > 0) {
|
|
$rowspanvalue++;
|
|
$CAD2 = '';
|
|
$CAD2 = $CAD;
|
|
$CAD = '';
|
|
$CAD = "<tr><td rowspan=" . $rowspanvalue . ">" . $MaterialCode . "-" . $MaterialName . "</td></tr>";
|
|
$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->request->getPost('txtPONO');
|
|
$MAD = '';
|
|
$DeliverySchedule = '';
|
|
$POdt = $this->request->getPost('PODate');
|
|
$PODate = get_date_time_format($POdt);
|
|
$SupplierID = $this->request->getPost('drpSupplier');
|
|
$DeliveryAddr = $this->request->getPost('DeliveryAddr');
|
|
$dt = $this->request->getPost('Deliverydate');
|
|
$POType = $this->request->getPost('POType');
|
|
$PoRange = $this->request->getPost('capitalType');
|
|
$DeliveryOption = $this->request->getPost('DateRange');
|
|
$Deliverydt = '';
|
|
if (($DeliveryOption == 1) || ($DeliveryOption == 2)) {
|
|
$Deliverydt = null;
|
|
|
|
if ($DeliveryOption == 1) {
|
|
$DeliverySchedule = $this->request->getPost('Scheduleby');
|
|
}
|
|
} else {
|
|
$Deliverydt = get_date_time_format($dt);
|
|
$DeliverySchedule = '';
|
|
}
|
|
|
|
$predispatch = $this->request->getPost('beforeDisins');
|
|
$curdispatch = $this->request->getPost('Dispatch');
|
|
$PaymentMethod = $this->request->getPost('PaymentMethod');
|
|
$prePaymentmethod = $this->request->getPost('beforePaymentmethod');
|
|
$prePaymentmethodtext = $this->request->getPost('beforePaymentTermsText');
|
|
|
|
$DeliverySchedule1 = $this->request->getPost('Scheduleby');
|
|
$preDeliverySchedule = $this->request->getPost('beforeSchedule');
|
|
$PlaceOforigin = $this->request->getPost('PlaceOforigin');
|
|
|
|
$preDate = $this->request->getPost('beforeDate');
|
|
$Date = $this->request->getPost('Deliverydate');
|
|
$Otherpayment = $this->request->getPost('Otherpayment');
|
|
$Otherpaymentamend = $this->request->getPost('Otherpayment');
|
|
$PreServiceTotalorder = $this->request->getPost('preServiceTotalorderValue'); //For Domestic Pre Total Value
|
|
$Totalserviceorder = $this->request->getPost('Totalservicesummary'); //For Domestic Revised Total value
|
|
$TotalCapitalorder = $this->request->getPost('CapitalToatlOrder'); //For International total CapitalOrder
|
|
$preTotalCapitalorder = $this->request->getPost('preinterTotalorderValue'); //For International pre total CapitalOrder
|
|
|
|
$ModeOfShipment = $this->request->getPost('addmodeofshipment');
|
|
$SupplierReference = $this->request->getPost('amendsupplierreference');
|
|
$SuppliersOfferNo = $this->request->getPost('amendsupplierofferno');
|
|
$OtherReferences = $this->request->getPost('amendotherreference');
|
|
$Fincap = ""; //$this->request->getPost('amendfincap');
|
|
$InsuranceOptions = $this->request->getPost('insuranceStatus');
|
|
$InsuranceNumber = $this->request->getPost('InsuranceNumber');
|
|
$ServiceTypeOptions = $this->request->getPost('PoTypeOptions');
|
|
|
|
if ($PoRange == 1) {
|
|
$MAD .= "Current TotalOrder Value: " . $PreServiceTotalorder . "<br>";
|
|
} else if ($PoRange == 0) {
|
|
$MAD .= "Current TotalOrder Value: " . $preTotalCapitalorder . "<br>";
|
|
}
|
|
|
|
if ($PaymentMethod != $prePaymentmethod) {
|
|
if ($prePaymentmethod != 'PT08') {
|
|
$Otherpaymentamend = '';
|
|
}
|
|
$MAD .= "Current Paymemnt Terms : " . $prePaymentmethodtext . "<br>";
|
|
}
|
|
if ($predispatch != $curdispatch) {
|
|
$MAD .= "Current Delivery Option : " . $predispatch . $preDeliverySchedule . $preDate . "<br>";
|
|
}
|
|
if ($DeliverySchedule1 != $preDeliverySchedule) {
|
|
$MAD .= "Current DeliveyOption : " . $preDeliverySchedule . $preDate . $predispatch . "<br>";
|
|
}
|
|
if ($preDate != $Date) {
|
|
$MAD .= "Current DeliveyOption : " . $preDate . $preDeliverySchedule . "<br>";
|
|
}
|
|
|
|
$capitalType = $this->request->getPost('capitalType');
|
|
$currencytypeID = $this->request->getPost('currencytype');
|
|
if ($capitalType == '1') {
|
|
$CapitalRange = '1';
|
|
$ExchangeRateOn = '';
|
|
$ExchangeRate = '';
|
|
} else {
|
|
$CapitalRange = '0';
|
|
$ExchangeRateOn = $this->request->getPost('ExchangeRateOn');
|
|
$ExchangeRateOn = get_date_time_format($ExchangeRateOn);
|
|
$ExchangeRate = $this->request->getPost('ExchangeRt');
|
|
}
|
|
|
|
$SpcialInstruction = $this->request->getPost('txtSpcialInstruction');
|
|
|
|
if ($PoRange == 1) {
|
|
$FinalTotalOrder = $Totalserviceorder;
|
|
} else if ($PoRange == 0) {
|
|
$FinalTotalOrder = $TotalCapitalorder;
|
|
}
|
|
|
|
$POStatus = $this->request->getPost('txtStatus');
|
|
$CreateBy = $this->session->get('userId');
|
|
$RowCount = $this->request->getPost('txtRowCount');
|
|
|
|
$createddt = get_current_date_time();
|
|
$updateddt = get_current_date_time();
|
|
|
|
$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->get('userId');
|
|
$AmendmentNewPoNo = generate_amendment_po_number($PONO);
|
|
$POMaster = array('PONO' => $AmendmentNewPoNo, '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' => $InsuranceNumber, 'POSubType' => $ServiceTypeOptions, 'IsQualityChkReqired' => $qtycheckresult);
|
|
$file = $this->request->getFile('POFile');
|
|
$requestfilename = $file ? $file->getName() : null;
|
|
$PrePOFile = $this->request->getPost('PrePOFile');
|
|
if (!empty($requestfilename)) {
|
|
if ($file && $file->isValid() && !$file->hasMoved()) {
|
|
$path = ROOTPATH . 'public/uploads/POfiles/';
|
|
if (!is_dir($path)) {
|
|
mkdir($path, 0777, true);
|
|
}
|
|
if (!empty($this->purchaseorder_model->isFileExists($requestfilename))) {
|
|
log_message('error', 'File already exists in the database' . $requestfilename);
|
|
$POMaster['POFile'] = $PrePOFile ? $PrePOFile : null;
|
|
} else {
|
|
$file->move($path, $requestfilename);
|
|
$POMaster['POFile'] = $requestfilename;
|
|
}
|
|
} else {
|
|
$POMaster['POFile'] = $PrePOFile ? $PrePOFile : null;
|
|
}
|
|
} else {
|
|
$POMaster['POFile'] = $PrePOFile ? $PrePOFile : null;
|
|
}
|
|
|
|
$LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster, $CreateBy, $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->request->getPost('materialCode' . $i);
|
|
$Quantity = $this->request->getPost('quantity' . $i);
|
|
$preQuantity = $this->request->getPost('beforequantity' . $i);
|
|
$Reqnumber = $this->request->getPost('Reqnumber' . $i);
|
|
$preitemRate = $this->request->getPost('itemRate' . $i);
|
|
$itemRate = $this->request->getPost('rateInUs' . $i);
|
|
$Per = $this->request->getPost('per' . $i);
|
|
$Exchangerate = $this->request->getPost('echangeRate' . $i);
|
|
$BasicPriceinmton = $this->request->getPost('rateInUs' . $i);
|
|
$Productprice = $this->request->getPost('basicvalInINR' . $i);
|
|
$LandingCharge = $this->request->getPost('beforeLanding' . $i);
|
|
$AfterLandingCharge = $this->request->getPost('landingCharge' . $i);
|
|
|
|
|
|
$CustomDuty = $this->request->getPost('beforeCustomDuty' . $i);
|
|
$AfterCustomDuty = $this->request->getPost('CustomDuty' . $i);
|
|
|
|
|
|
$CustomEd = $this->request->getPost('beforeCustomEDCess' . $i);
|
|
$AfterCustomEd = $this->request->getPost('CustomEDCess' . $i);
|
|
|
|
$CustomSH = $this->request->getPost('beforeCustomSHCess' . $i);
|
|
$AfterCustomSH = $this->request->getPost('CustomSHCess' . $i);
|
|
|
|
|
|
|
|
$Grossdutypayable = $this->request->getPost('GrossDutyPayable' . $i);
|
|
|
|
$purchaseratePerKG = $this->request->getPost('purchaseRate' . $i);
|
|
$CustomDutyExpensesPerKG = $this->request->getPost('CustomDutyExpenses' . $i);
|
|
|
|
$QuantityKG = $this->request->getPost('PurQuantity' . $i);
|
|
|
|
|
|
$Totalvalueitem = $this->request->getPost('PerKgExpense' . $i);
|
|
|
|
|
|
|
|
|
|
$Assable = $this->request->getPost('AssessableValue' . $i);
|
|
$beforeAssable = $this->request->getPost('beforeAssessableValue' . $i);
|
|
|
|
|
|
|
|
$Subtotal = $this->request->getPost('SubTotal' . $i);
|
|
$beforeSubtotal = $this->request->getPost('beforeSubTotal' . $i);
|
|
|
|
|
|
|
|
$Igst = $this->request->getPost('IGSTInt' . $i);
|
|
$beforeIgst = $this->request->getPost('beforeIGSTInt' . $i);
|
|
$AfterIgst = $this->request->getPost('AfterIGSTInt' . $i);
|
|
|
|
|
|
$ClearingCharge = $this->request->getPost('ClearingCharge' . $i);
|
|
|
|
$NetValue = $this->request->getPost('NetValue' . $i);
|
|
|
|
$DutyImpact = $this->request->getPost('DutyImpact' . $i);
|
|
|
|
$CostCenter = $this->request->getPost('CPCostCode' . $i);
|
|
|
|
$SGST = $this->request->getPost('SGST' . $i);
|
|
$preSGST = $this->request->getPost('beforeSGST' . $i);
|
|
$CGST = $this->request->getPost('CGST' . $i);
|
|
$preCGST = $this->request->getPost('beforeCGST' . $i);
|
|
$IGST = $this->request->getPost('IGST' . $i);
|
|
$preIGST = $this->request->getPost('beforeIGST' . $i);
|
|
|
|
$SGSTvalue = $this->request->getPost('afterSGST' . $i);
|
|
$preSGSTvalue = $this->request->getPost('beforeSGSTvalue' . $i);
|
|
$CGSTvalue = $this->request->getPost('afterCGST' . $i);
|
|
$preCGSTvalue = $this->request->getPost('beforeCGSTvalue' . $i);
|
|
$IGSTvalue = $this->request->getPost('afterIGST' . $i);
|
|
$preIGSTvalue = $this->request->getPost('beforeIGSTvalue' . $i);
|
|
$otherallowance = $this->request->getPost('otherallowance' . $i);
|
|
$preotherallowance = $this->request->getPost('beforeotherallowance' . $i);
|
|
$DiscountType = $this->request->getPost('DisType' . $i);
|
|
$DiscountValue = $this->request->getPost('DisVal' . $i);
|
|
$AfterDiscount = $this->request->getPost('AfterDisVal' . $i);
|
|
$preDiscountType = $this->request->getPost('beforeDisType' . $i);
|
|
$preDiscountValue = $this->request->getPost('beforeDisVal' . $i);
|
|
$preAfterDiscount = $this->request->getPost('beforeAfterDisVal' . $i);
|
|
$TotalServiceOrderValue = $this->request->getPost('totalservicevalue' . $i);
|
|
$CapitalItemDescrition = $this->request->getPost('CapitalItemDescrition' . $i);
|
|
$FreightType = $this->request->getPost('FreightType' . $i);
|
|
$FreightValue = $this->request->getPost('FreightVal' . $i);
|
|
$AfterFreightValue = $this->request->getPost('AfterFreightVal' . $i);
|
|
$NOOfTrip = $this->request->getPost('NoOfTrip' . $i);
|
|
$POLineItemNo = $this->request->getPost('LineItemNo' . $i);
|
|
|
|
$FreightTypeloc = $this->request->getPost('Ftype' . $i);
|
|
$FreightNoofTriploc = $this->request->getPost('NoTrip' . $i);
|
|
$Freightrateloc = $this->request->getPost('Fvalue' . $i);
|
|
$FreightAmountloc = $this->request->getPost('Afvalue' . $i);
|
|
|
|
$beforeFreightTypeloc = $this->request->getPost('beforeFtype' . $i);
|
|
$beforeFreightNoofTriploc = $this->request->getPost('beforeNoTrip' . $i);
|
|
$beforeFreightrateloc = $this->request->getPost('beforeFvalue' . $i);
|
|
$beforeFreightAmountloc = $this->request->getPost('beforeAfvalue' . $i);
|
|
|
|
$rowspanvalue = 0;
|
|
|
|
if ($Quantity != $preQuantity) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Qty : " . $preQuantity . "</td><td>Revised Qty : " . $Quantity . "</td></tr>";
|
|
}
|
|
if ($itemRate != $preitemRate) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Rate : " . $preitemRate . "</td><td>Revised Rate : " . $itemRate . "</td></tr>";
|
|
}
|
|
|
|
if ($PoRange == 1) {
|
|
if (($DiscountValue != $preDiscountValue) && ($AfterDiscount != $preAfterDiscount)) {
|
|
$rowspanvalue += 2;
|
|
$CAD .= "<tr><td>Current Discount : " . $preDiscountValue . "</td><td>Revised Discount : " . $DiscountValue . "</td></tr><tr><td>Current Discount value : " . $preAfterDiscount . "</td><td>Revised Discount value: " . $AfterDiscount . "</td></tr>";
|
|
}
|
|
if (($SGST != $preSGST) && ($SGSTvalue != $preSGSTvalue)) {
|
|
$rowspanvalue += 2;
|
|
$CAD .= "<tr><td>Current SGST% : " . $preSGST . "</td><td>Revised SGST% : " . $SGST . "</td></tr><tr><td>Current SGST value : " . $preSGSTvalue . "</td><td>Revised SGST value: " . $SGSTvalue . "</td></tr>";
|
|
}
|
|
if (($CGST != $preCGST) && ($CGSTvalue != $preCGSTvalue)) {
|
|
$rowspanvalue += 2;
|
|
$CAD .= "<tr><td>Current CGST% : " . $preCGST . "</td><td>Revised CGST% : " . $CGST . "</td></tr><tr><td>Current CGST value : " . $preCGSTvalue . "</td><td>Revised CGST value: " . $CGSTvalue . "</td></tr>";
|
|
}
|
|
if (($IGST != $preIGST) && ($IGSTvalue != $preIGSTvalue)) {
|
|
$rowspanvalue += 2;
|
|
$CAD .= "<tr><td>Current IGST% : " . $preIGST . "</td><td>Revised IGST% : " . $IGST . "</td></tr><tr><td>Current IGST value : " . $preIGSTvalue . "</td><td>Revised IGST value: " . $IGSTvalue . "</td></tr>";
|
|
}
|
|
if ($otherallowance != $preotherallowance) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current OtherAllowances : " . $preotherallowance . "</td><td>Revised OtherAllowances : " . $otherallowance . "</td></tr>";
|
|
}
|
|
if ($FreightTypeloc != $beforeFreightTypeloc) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Freight Type : " . $beforeFreightTypeloc . "</td><td>Revised Qty : " . $FreightTypeloc . "</td></tr>";
|
|
}
|
|
if ($FreightNoofTriploc != $beforeFreightNoofTriploc) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Freight Nooftrips : " . $beforeFreightNoofTriploc . "</td><td>Revised Freight Nooftrips: " . $FreightNoofTriploc . "</td></tr>";
|
|
}
|
|
if ($Freightrateloc != $beforeFreightrateloc) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Freight Rate : " . $beforeFreightrateloc . "</td><td>Revised Freight Rate: " . $Freightrateloc . "</td></tr>";
|
|
}
|
|
|
|
|
|
if ($FreightAmountloc != $beforeFreightAmountloc) {
|
|
$rowspanvalue++;
|
|
$CAD .= "<tr><td>Current Freight Amount : " . $beforeFreightAmountloc . "</td><td>Revised Freight Amount: " . $FreightAmountloc . "</td></tr>";
|
|
}
|
|
|
|
|
|
if (($Assable - $beforeAssable) != 0) {
|
|
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current Assessable : " . $beforeAssable . "</td><td>Revised CustomDuty:" . $Assable . "</td></tr>";
|
|
}
|
|
|
|
if (($Subtotal - $beforeSubtotal) != 0) {
|
|
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current Subtotal : " . $beforeSubtotal . "</td><td>Revised Subtotal:" . $Subtotal . "</td></tr>";
|
|
}
|
|
|
|
if (($Igst - $beforeIgst) != 0) {
|
|
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current IGST Percentage : " . $beforeIgst . "</td><td>Revised IGST Percentage:" . $Igst . "</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, 'Per' => $Per, 'ServiceMaterialDescription' => $CapitalItemDescrition);
|
|
$POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
|
|
$LineItemNo = '';
|
|
|
|
foreach ($POLineItem as $line) :
|
|
$LineItemNo = $line['LineItemNo'];
|
|
endforeach;
|
|
|
|
|
|
|
|
if (!is_null($POType) && is_string($POType) && 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->request->getPost('txtPONO');
|
|
|
|
$POdt = '';
|
|
$createddt = '';
|
|
|
|
$PODate = get_date_time_format($POdt);
|
|
$SupplierID = $this->request->getPost('drpSupplier');
|
|
$DeliveryAddr = $this->request->getPost('DeliveryAddr');
|
|
$dt = $this->request->getPost('Deliverydt');
|
|
$Deliverydt = get_date_time_format($dt);
|
|
$POType = $this->request->getPost('POType');
|
|
$PoRange = $this->request->getPost('txtPoRange');
|
|
|
|
$updatedBy = $this->session->get('userId');
|
|
|
|
$Exchangerate = $this->request->getPost('ExchangeRate');
|
|
$Edt = $this->request->getPost('Exchangerateon');
|
|
$ExchangeRateCalculatedon = get_date_time_format($Edt);
|
|
|
|
$CurrencyType = $this->request->getPost('currencytype');
|
|
$DeliveryOption = $this->request->getPost('DateRange');
|
|
|
|
|
|
$DeliverySchedule = '';
|
|
$Dispatch = '';
|
|
if ($DeliveryOption == 1) {
|
|
$Dispatch = '';
|
|
$DeliverySchedule = $this->request->getPost('Scheduleby');
|
|
} else {
|
|
$Dispatch = $this->request->getPost('Dispatch');
|
|
$DeliverySchedule = '';
|
|
}
|
|
|
|
$SpcialInstruction = $this->request->getPost('txtSpcialInstruction');
|
|
|
|
$TotalOrder = $this->request->getPost('txttot');
|
|
$AmendTotal = $this->request->getPost('txttotamend');
|
|
$MAD .= "Current Total Order Value: :" . $AmendTotal . "<br>";
|
|
$POStatus = $this->request->getPost('txtStatus');
|
|
|
|
$CreateBy = $this->session->get('userId');
|
|
$RowCount = $this->request->getPost('txtRowCount');
|
|
|
|
$createddt = get_current_date_time();
|
|
$updateddt = get_current_date_time();
|
|
|
|
|
|
|
|
$PaymentTerms = $this->request->getPost('PaymentTerms');
|
|
$beforePaymentTerms = $this->request->getPost('beforePaymentterms');
|
|
|
|
$Shipmentmode = $this->request->getPost('addmodeofshipment');
|
|
$SupplierRef = $this->request->getPost('amendsupplierreference');
|
|
$SupplierOffer = $this->request->getPost('amendsupplierofferno');
|
|
$otherRef = $this->request->getPost('amendotherreference');
|
|
$finCap = ""; //$this->request->getPost('amendfincap');
|
|
|
|
$OtherPayment = $this->request->getPost('Otherpayment');
|
|
|
|
$Insurance = $this->request->getPost('Insurance');
|
|
|
|
|
|
$qtycheck = $this->purchaseorder_model->getqtycheck($PONO);
|
|
$qtycheckresult = '';
|
|
foreach ($qtycheck as $qty) {
|
|
$qtycheckresult = $qty->IsQualityChkReqired;
|
|
}
|
|
|
|
if ($Insurance == 'YES') {
|
|
|
|
$InsuranceNumber = $this->request->getPost('InsuranceNumber');
|
|
$insurestatus = '1';
|
|
} else {
|
|
$InsuranceNumber = '';
|
|
$insurestatus = '0';
|
|
}
|
|
$importoption = $this->request->getPost('Importoption');
|
|
|
|
if ($PaymentTerms != $beforePaymentTerms) {
|
|
|
|
$MAD .= "Current Payment Terms " . $beforePaymentTerms . "<br>";
|
|
}
|
|
|
|
$Palaceoforigin = $this->request->getPost('PlaceOforigin');
|
|
$beforePalaceoforigin = $this->request->getPost('beforePlaceOforigin');
|
|
|
|
if ($Palaceoforigin != $beforePalaceoforigin) {
|
|
|
|
$MAD .= $MAD . "Current Place of Origin: " . $beforePalaceoforigin . "<br>";
|
|
}
|
|
$AmendmentNewPoNo = generate_amendment_po_number($PONO);
|
|
$POMaster = array('PONO' => $AmendmentNewPoNo, '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);
|
|
$file = $this->request->getFile('POFile');
|
|
$requestfilename = $file->getName();
|
|
$PrePOFile = $this->request->getPost('PrePOFile');
|
|
if (!empty($requestfilename)) {
|
|
if ($file && $file->isValid() && !$file->hasMoved()) {
|
|
$path = ROOTPATH . 'public/uploads/POfiles/';
|
|
if (!is_dir($path)) {
|
|
mkdir($path, 0777, true);
|
|
}
|
|
if (!empty($this->purchaseorder_model->isFileExists($requestfilename))) {
|
|
log_message('error', 'File already exists in the database' . $requestfilename);
|
|
$POMaster['POFile'] = $PrePOFile ? $PrePOFile : null;
|
|
} else {
|
|
$file->move($path, $requestfilename);
|
|
$POMaster['POFile'] = $requestfilename;
|
|
}
|
|
} else {
|
|
$POMaster['POFile'] = $PrePOFile ? $PrePOFile : null;
|
|
}
|
|
} else {
|
|
$POMaster['POFile'] = $PrePOFile ? $PrePOFile : null;
|
|
}
|
|
$LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster, $CreateBy, $PONO);
|
|
$NewPO = '';
|
|
// if (count($LastPO) > 0) {
|
|
// $NewPO = $LastPO[0]['PONO'];
|
|
// }
|
|
// print_r($LastPO);die;
|
|
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->request->getPost('materialCode' . $i);
|
|
$Quantity = $this->request->getPost('quantity' . $i);
|
|
$beforeQuantity = $this->request->getPost('beforequantity' . $i);
|
|
|
|
|
|
$Reqnumber = $this->request->getPost('Reqnumber' . $i);
|
|
$itemRate = $this->request->getPost('itemRate' . $i);
|
|
$beforeitemRate = $this->request->getPost('beforeitemRate' . $i);
|
|
|
|
$BasicPriceinmton = $this->request->getPost('BasicPriceInMTon' . $i);
|
|
$Productprice = $this->request->getPost('ProductPrice' . $i);
|
|
$LandingCharge = $this->request->getPost('LandingCharge' . $i);
|
|
$beforeLandingCharge = $this->request->getPost('beforeLandingCharge' . $i);
|
|
|
|
$AfterLandingCharge = $this->request->getPost('AfterLandingCharge' . $i);
|
|
|
|
$CustomDuty = $this->request->getPost('CustomDuty' . $i);
|
|
|
|
$beforeCustomDuty = $this->request->getPost('beforeCustomDuty' . $i);
|
|
|
|
$AfterCustomDuty = $this->request->getPost('AfterCustomDuty' . $i);
|
|
|
|
$CustomEd = $this->request->getPost('CustomEdCess1' . $i);
|
|
$beforeCustomEd = $this->request->getPost('beforeCustomEdCess' . $i);
|
|
|
|
$AfterCustomEd = $this->request->getPost('AfterCustomEdCess1' . $i);
|
|
|
|
$CustomSH = $this->request->getPost('CustomSHCess' . $i);
|
|
$beforeCustomSH = $this->request->getPost('beforeCustomSHCess' . $i);
|
|
|
|
$AfterCustomSH = $this->request->getPost('AfterCustomSHCess' . $i);
|
|
|
|
$Grossdutypayable = $this->request->getPost('Grossdutypayable1' . $i);
|
|
$beforeGrossdutypayable = $this->request->getPost('beforeGrossdutypayable' . $i);
|
|
|
|
$Assable = $this->request->getPost('AssessableValue' . $i);
|
|
$beforeAssable = $this->request->getPost('beforeAssessableValue' . $i);
|
|
|
|
$Subtotal = $this->request->getPost('SubTotal' . $i);
|
|
$beforeSubtotal = $this->request->getPost('beforeSubTotal' . $i);
|
|
|
|
$Igst = $this->request->getPost('IGST' . $i);
|
|
$beforeIgst = $this->request->getPost('beforeIGST' . $i);
|
|
$AfterIgst = $this->request->getPost('AfterIGST' . $i);
|
|
|
|
$CustomDutyExpensesPerKG = $this->request->getPost('CustomDutyExpensesPerKG' . $i);
|
|
$beforeCustomDutyExpensesPerKG = $this->request->getPost('beforeCustomDutyExpensesPerKG' . $i);
|
|
|
|
$FreightType = $this->request->getPost('FreightType' . $i);
|
|
$NoOfTrip = $this->request->getPost('NoOfTrip' . $i);
|
|
$Freightrate = $this->request->getPost('FreightValue' . $i);
|
|
$Freightamount = $this->request->getPost('AfterFreightValue' . $i);
|
|
|
|
$per = $this->request->getPost('Per' . $i);
|
|
|
|
$beforeFreightType = $this->request->getPost('beforeFreightType' . $i);
|
|
$beforeNoOfTrip = $this->request->getPost('beforeNoOfTrip' . $i);
|
|
$beforeFreightrate = $this->request->getPost('beforeFreightValue' . $i);
|
|
$beforeFreightamount = $this->request->getPost('beforeAfterFreightValue' . $i);
|
|
$beforeper = $this->request->getPost('beforePer' . $i);
|
|
|
|
$QuantityKG = $this->request->getPost('QuantityKG' . $i);
|
|
$ClearingCharge = $this->request->getPost('ClearingCharge' . $i);
|
|
$NetValue = $this->request->getPost('NetValue' . $i);
|
|
$DutyImpact = $this->request->getPost('DutyImpact' . $i);
|
|
|
|
$specialinstruction = $this->request->getPost('Addinstruction' . $i);
|
|
$CostCenter = $this->request->getPost('costCode' . $i);
|
|
|
|
$Totalvalueitem = $this->request->getPost('txtTotalorderValue');
|
|
$RecQtyvalue = 0;
|
|
$rowspanvalue = 0;
|
|
$LineItemNo = '';
|
|
|
|
if (($itemRate - $beforeitemRate) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current Rate : " . $beforeitemRate . "</td><td>Revised Rate:" . $itemRate . "</td></tr>";
|
|
}
|
|
|
|
|
|
if (($Quantity - $beforeQuantity) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current Quantity : " . $beforeQuantity . "</td><td>Revised Quantity:" . $Quantity . "</td></tr>";
|
|
}
|
|
|
|
|
|
if (($LandingCharge - $beforeLandingCharge) != 0) {
|
|
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current Landing percentage : " . $beforeLandingCharge . "</td><td>Revised Landing Percentage:" . $LandingCharge . "</td></tr>";
|
|
}
|
|
|
|
if (($CustomDuty - $beforeCustomDuty) != 0) {
|
|
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current CustomDuty : " . $beforeCustomDuty . "</td><td>Revised CustomDuty:" . $CustomDuty . "</td></tr>";
|
|
}
|
|
|
|
|
|
if ($CustomEd - $beforeCustomEd) {
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current CustomEd : " . $beforeCustomEd . "</td><td>Revised CustomEd:" . $CustomEd . "</td></tr>";
|
|
}
|
|
|
|
|
|
if ($CustomSH - $beforeCustomSH) {
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current CustomSH : " . $beforeCustomSH . "</td><td>Revised CustomSH:" . $CustomSH . "</td></tr>";
|
|
}
|
|
|
|
if ($FreightType != $beforeFreightType) {
|
|
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current Freight Type: " . $beforeFreightType . "</td><td>Revised Freight Type:" . $FreightType . "</td></tr>";
|
|
}
|
|
|
|
if ((float)$NoOfTrip - (float)$beforeNoOfTrip) {
|
|
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current No of Trip: " . $beforeNoOfTrip . "</td><td>Revised Additional Excise duty:" . $NoOfTrip . "</td></tr>";
|
|
}
|
|
|
|
if ($Freightrate - $beforeFreightrate) {
|
|
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current Freightrate: " . $beforeFreightrate . "</td><td>Revised Freightrate:" . $Freightrate . "</td></tr>";
|
|
}
|
|
|
|
if ($Freightamount - $beforeFreightamount) {
|
|
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current Freight Amount: " . $beforeFreightamount . "</td><td>Revised Freight Amount:" . $Freightamount . "</td></tr>";
|
|
}
|
|
|
|
|
|
if ($per != $beforeper) {
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current Per Value: " . $beforeper . "</td><td>Revised Per Value:" . $per . "</td></tr>";
|
|
}
|
|
|
|
if (($Assable - $beforeAssable) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current Assessable : " . $beforeAssable . "</td><td>Revised CustomDuty:" . $Assable . "</td></tr>";
|
|
}
|
|
|
|
if (($Subtotal - $beforeSubtotal) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current Subtotal : " . $beforeSubtotal . "</td><td>Revised Subtotal:" . $Subtotal . "</td></tr>";
|
|
}
|
|
|
|
if (($Igst - $beforeIgst) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current IGST Percentage : " . $beforeIgst . "</td><td>Revised IGST Percentage:" . $Igst . "</td></tr>";
|
|
}
|
|
|
|
if (($Grossdutypayable - $beforeGrossdutypayable) != 0) {
|
|
$rowspanvalue++;
|
|
$CAD = $CAD . "<tr><td>Current Gross Duty Payable : " . $beforeGrossdutypayable . "</td><td>Revised Gross Duty Payable:" . $Grossdutypayable . "</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, '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;
|
|
}
|
|
}
|