4131 lines
154 KiB
PHP
4131 lines
154 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
|
|
use CodeIgniter\Validation\Exceptions\ValidationException;
|
|
|
|
use App\Models\Costcenter_model;
|
|
use App\Models\Inwardgateregister_model;
|
|
use App\Models\Purchaseorder_model;
|
|
use App\Models\Requistion_model;
|
|
use Mpdf\Mpdf;
|
|
|
|
|
|
|
|
/**
|
|
* Module : PO-Purchaseorder
|
|
* Purchaseorder Class to control all user related operations.
|
|
* @author : Venba InfoTech
|
|
* @version : 1.1
|
|
* @since : 09/06 Feb 2017
|
|
* @example : Revised at 15th april 2024
|
|
*/
|
|
class Purchaseorder extends BaseController
|
|
{
|
|
protected $purchaseorder_model;
|
|
protected $inwardgateregister_model;
|
|
protected $requistion_model;
|
|
protected $costcenter_model;
|
|
protected $session;
|
|
|
|
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->purchaseorder_model = new Purchaseorder_model();
|
|
$this->inwardgateregister_model = new Inwardgateregister_model();
|
|
$this->requistion_model = new Requistion_model();
|
|
$this->costcenter_model = new Costcenter_model();
|
|
$this->session = session();
|
|
helper('form'); //$this->load->library('form_validation');
|
|
|
|
$this->isLoggedIn();
|
|
}
|
|
|
|
//end this function used to pono reset financeyear configuration
|
|
|
|
/**
|
|
* This function used to load the first screen of the user
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->global['pageTitle'] = 'AddPO';
|
|
|
|
$this->loadViews("addPO", $this->global, NULL, NULL);
|
|
}
|
|
function viewfullpurchaseorder()
|
|
{
|
|
$this->global['pageTitle'] = 'View Purchase Order';
|
|
|
|
$this->loadViews("viewfullpurchaseorder", $this->global, Null);
|
|
}
|
|
function advancerequest()
|
|
{
|
|
$this->global['pageTitle'] = 'Advance Request';
|
|
|
|
$data['PONO'] = $this->purchaseorder_model->getadvancePONO('ST026');
|
|
//print_r($data['PONO']);
|
|
|
|
|
|
|
|
$this->loadViews("advancerequest", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
function requisition($listErrors = null)
|
|
{
|
|
|
|
$data['DeptList'] = $this->purchaseorder_model->getDepartmentListForAllReq();
|
|
|
|
$data['stList'] = $this->purchaseorder_model->getStatusListforAllReq();
|
|
/* Cost code from Requisition - Client Review Fix
|
|
Start here */
|
|
// $data['ReqList'] = $this->purchaseorder_model->getRequistionListbySearch();
|
|
|
|
$data['ReqList'] = $this->purchaseorder_model->getAllRequistionListToCreatePO();
|
|
/* End Here */
|
|
|
|
$this->session->setFlashdata('message', $listErrors);
|
|
$this->global['pageTitle'] = 'Create PO from Requisition List';
|
|
|
|
|
|
|
|
$this->loadViews("createPOfromRequistion", $this->global, $data, Null);
|
|
}
|
|
|
|
|
|
/**
|
|
* This function is used to load the purchaseorder list
|
|
*/
|
|
function PurchaseOrderList()
|
|
{
|
|
|
|
// $this->load->library('pagination');
|
|
|
|
// $count = $this->purchaseorder_model->purchaseorderListingCount('');
|
|
|
|
//$returns = $this->paginationCompress ( "purchaseorderListing/", $count, 10 );
|
|
|
|
$this->purchaseorder_model->UpdateRequistionStatus();
|
|
|
|
$data['POData'] = $this->purchaseorder_model->purchaseorderListing();
|
|
|
|
$this->global['pageTitle'] = 'Purchase Orders';
|
|
|
|
|
|
|
|
|
|
$this->loadViews("POlist", $this->global, $data, NULL);
|
|
}
|
|
function validate_req($str = null)
|
|
{
|
|
if (empty($str)) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* This function used to show the Purchase Order Screen
|
|
*/
|
|
public function CreatePurchaseOrder()
|
|
{
|
|
$validation = \Config\Services::validation();
|
|
$validation->setRule('txtReqNo', 'Requisition Number', ['Req_validate[txtReqNo]'], ['Req_validate' => 'Please Select Requisition Number to Create PO.']);
|
|
|
|
// !$validation->withRequest($this->request)->run()
|
|
if (!$validation->run($this->request->getPost())) {
|
|
// echo $validation->getError('txtReqNo');
|
|
// print_r($validation->listErrors());// print_r($validation->getErrors());
|
|
// exit;
|
|
$this->requisition($validation->listErrors());
|
|
} else {
|
|
// echo "@242 else proceed"."<br>";
|
|
$this->global['pageTitle'] = 'Purchase order';
|
|
$data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006');
|
|
$data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018');
|
|
$data['Suplist'] = $this->purchaseorder_model->getSupplierName();
|
|
$data['Payment'] = $this->purchaseorder_model->getPaymentTermsDetails();
|
|
$data['WorkStatus'] = $this->purchaseorder_model->getStatus(7);
|
|
$txtReqNo = $this->request->getPost('txtReqNo');
|
|
if (is_array($txtReqNo)) {
|
|
$txtReqNo = json_encode($txtReqNo);
|
|
}
|
|
$SelectedReq = json_decode($txtReqNo);
|
|
// echo '<pre>'.print_r($SelectedReq,true).'</pre>'."<br>";
|
|
$Req = $SelectedReq->Req;
|
|
$data['ReqList'] = $Req;
|
|
$ReqArray = array();
|
|
$ReqType = $this->request->getPost('txtReqType');
|
|
$result = array();
|
|
|
|
foreach ($Req as $SID) :
|
|
$ReqArray[] = $SID->ReqNo;
|
|
$result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo);
|
|
if ($ReqType == '') {
|
|
$ReqType = $SID->ReqType;
|
|
}
|
|
|
|
endforeach;
|
|
|
|
|
|
$data['MaterialList'] = $result;
|
|
// echo '<pre>'.print_r($data['MaterialList'],true).'</pre>'."<br>";die;
|
|
/* Cost code from Requisition - Client Review Fix
|
|
Start here */
|
|
$ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray);
|
|
|
|
$data['RequistionDetails'] = $ReqDetails;
|
|
$CostCode = '';
|
|
|
|
|
|
$FYStart = '';
|
|
$FYEnd = '';
|
|
$FiscalYear = $this->costcenter_model->getFiscalYear();
|
|
if (!empty($FiscalYear)) {
|
|
foreach ($FiscalYear as $Fy) {
|
|
$FYStart = $Fy->StartYear;
|
|
$FYEnd = $Fy->EndYear;
|
|
//$FYEnd=$FYStart+1;
|
|
}
|
|
}
|
|
|
|
$FYdt = $FYStart . " - " . $FYEnd;
|
|
|
|
//echo $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['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
|
|
//print_r($data['CompanyDetails']);
|
|
// $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate();
|
|
$data['MaxPODate'] = $this->purchaseorder_model->getLastReleasedPODate();
|
|
$data['Currency'] = $this->purchaseorder_model->GetCurrencytype();
|
|
$data['INRSYMBOL'] = $this->purchaseorder_model->GetINRCurrencytype('INR');
|
|
//print_r($data['INRSYMBOL']);
|
|
|
|
$AvlimportBudget = $this->purchaseorder_model->GetAvailableImportBudgetAmount($CostCode, $FYdt, $ReqType);
|
|
|
|
//print_r($AvlimportBudget);
|
|
|
|
// $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType);
|
|
|
|
|
|
//print_r($AvlimportBudget);
|
|
|
|
|
|
if (count($AvlimportBudget) > 0) {
|
|
$data['AvlimportBudAmt'] = $AvlimportBudget[0]['BudgetAmount'] - $AvlimportBudget[0]['Totalvalue'];
|
|
}
|
|
|
|
|
|
$data['PoTypeOptions'] = $this->purchaseorder_model->getConfigValue('C026');
|
|
|
|
//print_r($data['PoTypeOptions']);
|
|
|
|
|
|
// $data[$Rate->ExchangeRate]=$Rate->ExchangeRate;
|
|
//$data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency);
|
|
|
|
$ViewName = '';
|
|
if ($ReqType == REVENUE) {
|
|
$ViewName = 'purchaseorder';
|
|
} else if ($ReqType == SERVICE) {
|
|
|
|
|
|
$ViewName = 'servicePurchaseorder';
|
|
} else if ($ReqType == IMPORT) {
|
|
|
|
$data['staticspecialinstruction'] = $this->purchaseorder_model->getConfigValue('C027');
|
|
|
|
$ViewName = 'importpo';
|
|
} else if ($ReqType == CAPITAL) {
|
|
$data['staticspecialinstruction'] = $this->purchaseorder_model->getConfigValue('C027');
|
|
$CapitalAvlBudget = $this->purchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode, $FYdt, $ReqType);
|
|
|
|
|
|
if (count($CapitalAvlBudget) > 0) {
|
|
|
|
|
|
$data['AvlCapitalBudAmt'] = $CapitalAvlBudget[0]['BudgetAmount'] - $CapitalAvlBudget[0]['Totalvalue'];
|
|
}
|
|
$ViewName = 'capitalpurchaseorder';
|
|
}
|
|
// echo '@376 final step '.$ViewName;
|
|
// echo '<pre>'.print_r($data,true).'</pre>'."<br>";die();
|
|
$this->loadViews($ViewName, $this->global, $data, NULL);
|
|
}
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
public function check_select_value($value)
|
|
{
|
|
if (empty($value)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function CreatePOPrint_old()
|
|
{
|
|
$PONO = $this->request->getVar('PONO');
|
|
|
|
|
|
$ReqType = $this->request->getVar('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 CreatePOPrint()
|
|
{
|
|
|
|
|
|
$PONO = $this->request->getVar('PONO');
|
|
$ReqType = $this->request->getVar('ReqType');
|
|
|
|
$PoStatus = '';
|
|
$data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO);
|
|
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformationforPDF();
|
|
$data['GetPoFormat'] = $this->purchaseorder_model->GetPoFormat($PONO);
|
|
if ($ReqType == SERVICE) {
|
|
$data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetailsForpdf($PONO);
|
|
$data['serviceTaxList'] = $this->purchaseorder_model->GetServiceTaxDetails($PONO);
|
|
} else if ($ReqType == REVENUE) {
|
|
$data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetailsForPDF($PONO);
|
|
$data['reveuetax'] = $this->purchaseorder_model->getRevenueTaxinforforpdf($PONO);
|
|
} else if ($ReqType == IMPORT) {
|
|
$data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetailsForPDF($PONO);
|
|
} else if ($ReqType == CAPITAL) {
|
|
$data['POItem'] = $this->purchaseorder_model->GetCapitalPurchaseOrderDetailsForPDF($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;
|
|
$AdvanceAmount = 0.00;
|
|
foreach ($data['POItem'] as $POI) {
|
|
$AdvanceAmount = $POI->AdvanceAmount;
|
|
$PoStatus = $POI->Status;
|
|
}
|
|
|
|
$TotaltoPay = 0.00;
|
|
$TotaltoPay = $TotalOrderValue - $AdvanceAmount;
|
|
$totalAmt = sprintf("%.2f", $TotalOrderValue);
|
|
|
|
|
|
|
|
$data['TotalAmountInWords'] = $this->convertNumber($totalAmt);
|
|
$data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO);
|
|
|
|
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8',
|
|
'format' => 'A4',
|
|
'default_font' => 'sans-serif',
|
|
'margin_header' => 0,
|
|
'margin_top' => -30,
|
|
'margin_right' => 14,
|
|
'margin_left' => 5,
|
|
'margin_footer' => -30,
|
|
'orientation' => 'P']);
|
|
// Set PDF properties
|
|
$mpdf->SetTitle('Invoice');
|
|
$mpdf->SetAuthor($data['CompanyDetails'][0]->CompanyName);
|
|
$mpdf->SetCreator('Venba');
|
|
|
|
|
|
// Generate the PDF content (HTML)
|
|
// if ($PoStatus == PO_RELEASED || $PoStatus == PO_SERVICE_COMPLETED || $PoStatus == MRIR_APPROVED || $PoStatus == MRIR_REJECTED || $PoStatus == IGR_CREATED || $PoStatus == '' || $PoStatus == SPECIAL_PO) {
|
|
// $mpdf->SetWatermarkText('');
|
|
// } else {
|
|
// $mpdf->SetWatermarkText('DRAFT');
|
|
// }
|
|
|
|
|
|
// Set auto margins
|
|
$mpdf->setAutoTopMargin = 'stretch';
|
|
$mpdf->setAutoBottomMargin = 'stretch';
|
|
$mpdf->use_kwt = true;
|
|
// Set HTML header
|
|
// $HtmlHeading = view('includes/pdfheader', $data);
|
|
// $mpdf->SetHTMLHeader($HtmlHeading);
|
|
|
|
// Set HTML body
|
|
// $html = view('pdf_view', $data);
|
|
// $mpdf->WriteHTML($html); // Use WriteHTML() method to add body content
|
|
$html = view('po_pdf', $data);
|
|
//echo $html;die;
|
|
$mpdf->WriteHTML($html); // Use WriteHTML() method to add body content
|
|
|
|
// Set HTML footer
|
|
// $HTMLFooter = view('includes/pdffooter', $data);
|
|
// $mpdf->setFooter('' . "Page {PAGENO} of {nb}");
|
|
|
|
// Output PDF
|
|
$mpdf->Output('POReport' . $PONO . '.pdf', 'D');
|
|
}
|
|
public function poprint2($PONO,$ReqType)
|
|
{
|
|
|
|
// Load all views as normal
|
|
|
|
|
|
//$PONO = $this->request->getVar('PO');
|
|
$Requester = '';
|
|
$Depcode = '';
|
|
$Currencycode = '';
|
|
$PoStatus = '';
|
|
$PaiseVal = '';
|
|
$SymbolCurrency = '';
|
|
$SymbolCurrencyName = '';
|
|
$TotalOrderValue = 0.00;
|
|
$AdvanceAmount = 0.00;
|
|
$ProductPrice = '';
|
|
$TotaltoPay = 0.00;
|
|
|
|
|
|
$data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO);
|
|
|
|
$data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO);
|
|
|
|
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformationforPDF();
|
|
|
|
$data['GetPoFormat'] = $this->purchaseorder_model->GetPoFormat($PONO);
|
|
|
|
$data['DEPCODE'] = $this->purchaseorder_model->GerRequesterDep($Depcode);
|
|
|
|
|
|
$data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO);
|
|
$data['CurrencySymbol'] = $this->purchaseorder_model->GerCurrencyCodeName($Currencycode);
|
|
$data['Requestername'] = $this->purchaseorder_model->GerRequesterName($Requester);
|
|
|
|
|
|
|
|
|
|
// print_r($data['POItem']);die;
|
|
$CapitalRange = 1;
|
|
|
|
|
|
if (!empty($data['CurrencySymbol']) > 0) {
|
|
$SymbolCurrency = $data['CurrencySymbol'][0]->FontCode2000;
|
|
$SymbolCurrencyName = $data['CurrencySymbol'][0]->Currency;
|
|
$PaiseVal = $data['CurrencySymbol'][0]->PaiseVal;
|
|
}
|
|
|
|
if (!empty($data['POItem'])) {
|
|
foreach ($data['POItem'] as $POI) {
|
|
$Currencycode = $POI->CurrencyType;
|
|
$CapitalRange = $POI->CapitalRange;
|
|
$AdvanceAmount = $POI->AdvanceAmount;
|
|
$TotalOrderValue = $POI->TotalOrderValue;
|
|
$PoStatus = $POI->Status;
|
|
$Requester = isset($POI->Requestedby) ? $POI->Requestedby : "";
|
|
|
|
|
|
}
|
|
}
|
|
|
|
if ($CapitalRange != '') {
|
|
$data['TaxListDetails'] = $this->purchaseorder_model->GetCapitalTaxListDetails($PONO, $CapitalRange);
|
|
}
|
|
|
|
foreach ($data['Requestername'] as $ReqDep) {
|
|
$Depcode = $ReqDep->Departmentcode;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8',
|
|
'format' => 'A4',
|
|
'default_font' => 'sans-serif',
|
|
'margin_header' => 0,
|
|
'margin_top' => -30,
|
|
'margin_right' => 14,
|
|
'margin_left' => 5,
|
|
'margin_footer' => -30,
|
|
'orientation' => 'P']);
|
|
// Set PDF properties
|
|
$mpdf->SetTitle('Invoice');
|
|
$mpdf->SetAuthor($data['CompanyDetails'][0]->CompanyName);
|
|
$mpdf->SetCreator('Venba');
|
|
|
|
|
|
// Generate the PDF content (HTML)
|
|
// if ($PoStatus == PO_RELEASED || $PoStatus == PO_SERVICE_COMPLETED || $PoStatus == MRIR_APPROVED || $PoStatus == MRIR_REJECTED || $PoStatus == IGR_CREATED || $PoStatus == '' || $PoStatus == SPECIAL_PO) {
|
|
// $mpdf->SetWatermarkText('');
|
|
// } else {
|
|
// $mpdf->SetWatermarkText('DRAFT');
|
|
// }
|
|
|
|
|
|
// Set auto margins
|
|
$mpdf->setAutoTopMargin = 'stretch';
|
|
$mpdf->setAutoBottomMargin = 'stretch';
|
|
|
|
// Set HTML header
|
|
// $HtmlHeading = view('includes/pdfheader', $data);
|
|
// $mpdf->SetHTMLHeader($HtmlHeading);
|
|
|
|
// Set HTML body
|
|
// $html = view('pdf_view', $data);
|
|
// $mpdf->WriteHTML($html); // Use WriteHTML() method to add body content
|
|
$html = view('po_pdf', $data);
|
|
// echo $html; die;
|
|
$mpdf->WriteHTML($html); // Use WriteHTML() method to add body content
|
|
|
|
// Set HTML footer
|
|
// $HTMLFooter = view('includes/pdffooter', $data);
|
|
// $mpdf->setFooter('' . "Page {PAGENO} of {nb}");
|
|
|
|
// Output PDF
|
|
$mpdf->Output($ReqType.'_' . $PONO . '.pdf', 'D');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function CreaterevenuePOPrint()
|
|
{
|
|
view("revenuepopdf");
|
|
}
|
|
function CreateservicePOPrint()
|
|
{
|
|
view("servicepopdf");
|
|
}
|
|
function CreateimportPOPrint()
|
|
{
|
|
view("importpopdf");
|
|
}
|
|
function CreatecapitalPOPrint()
|
|
{
|
|
view("capitalpopdf");
|
|
}
|
|
//To View/Update Purchase Order
|
|
|
|
function EditPurchaseOrder()
|
|
{
|
|
|
|
$PONO = $this->request->getVar('PONO');
|
|
$ReqType = $this->request->getVar('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['PoTypeOptions'] = $this->purchaseorder_model->getConfigValue('C026');
|
|
$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);
|
|
//print_r($data['POMaster']);
|
|
//die();
|
|
//$data['POSTATUS']=$this->purchaseorder_model->GetServicePurchaseOrder($PONO);
|
|
//print_r($data['POMaster']);
|
|
foreach ($data['POMaster'] as $Exc) {
|
|
$exRate = $Exc->ExchangeRate;
|
|
}
|
|
foreach ($data['POMaster'] as $TER) {
|
|
$PAYTERM = $TER->PaymentTerms;
|
|
}
|
|
|
|
|
|
$data['getdata'] = $this->purchaseorder_model->getfunctionr($PONO);
|
|
$data['billfile'] = $this->purchaseorder_model->getbillfiesr($PONO);
|
|
|
|
$data['MaxPODate'] = $this->purchaseorder_model->getLastReleasedPODate();
|
|
$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['getdata'] = $this->purchaseorder_model->getfunction($PONO);
|
|
//$data['billfile'] = $this->purchaseorder_model->getbillfiesr($pono);
|
|
|
|
//s print_r($data['getdata']);
|
|
$data['getlogpodtl'] = $this->purchaseorder_model->getlogpodtl($PONO);
|
|
|
|
|
|
$data['PaymentTerms'] = $this->purchaseorder_model->GetPaymentTerms($PONO);
|
|
//$data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019');
|
|
|
|
$data['WorkStatus'] = $this->purchaseorder_model->getStatus(7);
|
|
//print_r($data);die;
|
|
$this->global['pageTitle'] = 'Edit Service Purchase order form';
|
|
$this->loadViews("EditservicePurchaseorder", $this->global, $data, NULL);
|
|
} else if ($ReqType == REVENUE) {
|
|
|
|
$data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetails($PONO);
|
|
$data['PaymentTerms'] = $this->purchaseorder_model->GetPaymentTerms($PONO);
|
|
|
|
$data['getlogpodtl'] = $this->purchaseorder_model->getlogpodtl($PONO);
|
|
|
|
$data['WorkStatus'] = $this->purchaseorder_model->getStatus(7);
|
|
$this->global['pageTitle'] = 'Edit Revenue Purchase order form';
|
|
$this->loadViews("editRevenuepurchaseorder", $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'];
|
|
}
|
|
//print_r($data['AvlBudAmt']);
|
|
$data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetails($PONO);
|
|
// print_r($data['POItem']);
|
|
$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['getlogpodtl'] = $this->purchaseorder_model->getlogpodtl($PONO);
|
|
|
|
//print_r($data['PaymentTerms']);
|
|
$unicode = '';
|
|
foreach ($data['CurrencyDetail'] as $Detail) {
|
|
$unicode = $Detail->FontCode2000;
|
|
}
|
|
foreach ($data['CurrencyDetail'] as $Detail) {
|
|
$currencycode = $Detail->Currency_Code;
|
|
}
|
|
//print_r($unicode);
|
|
$data['unicode'] = $unicode;
|
|
$data['currencycode'] = $currencycode;
|
|
$this->global['pageTitle'] = 'Edit Import Purchase order form';
|
|
$this->loadViews("editimportpo", $this->global, $data, NULL);
|
|
} else if ($ReqType == CAPITAL) {
|
|
$CapitalRange = $this->request->getVar('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);
|
|
|
|
$data['getlogpodtl'] = $this->purchaseorder_model->getlogpodtl($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'] = $this->purchaseorder_model->GetCurrencyDetail('INR');
|
|
$data['ExchangeRate'] = $exRate;
|
|
$data['Currency'] = $this->purchaseorder_model->GetCurrencytype();
|
|
}
|
|
|
|
|
|
$this->global['pageTitle'] = 'Edit Capital Purchase order form';
|
|
$this->loadViews("editCapitalPo", $this->global, $data, NULL);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function PurchaseOrderFinanceView()
|
|
{
|
|
$PONO = $this->request->getVar('PONO');
|
|
$POType = $this->request->getVar('POType');
|
|
|
|
$ReqType = $this->request->getVar('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');
|
|
/* Cost code from Requisition - Client Review Fix
|
|
Start here */
|
|
$data['PoTypeOptions'] = $this->purchaseorder_model->getConfigValue('C026');
|
|
$ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray);
|
|
|
|
$data['RequistionDetails'] = $ReqDetails;
|
|
foreach ($data['RequistionDetails'] as $ReqDet) {
|
|
|
|
$Status = $ReqDet->Status;
|
|
}
|
|
|
|
$data['POSTATUS'] = $this->purchaseorder_model->GetPOStatus($Status);
|
|
|
|
foreach ($data['POSTATUS'] as $POST) {
|
|
$Status = $POST->StatusName;
|
|
}
|
|
|
|
$CostCode = '';
|
|
$this->costcenter_model = new 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['POSTATUS']=$this->purchaseorder_model->GetServicePurchaseOrder($PONO);
|
|
//print_r($data['POMaster']);
|
|
foreach ($data['POMaster'] as $Exc) {
|
|
$exRate = $Exc->ExchangeRate;
|
|
}
|
|
foreach ($data['POMaster'] as $TER) {
|
|
$PAYTERM = $TER->PaymentTerms;
|
|
}
|
|
|
|
|
|
$data['MaxPODate'] = $this->purchaseorder_model->getLastReleasedPODate();
|
|
$data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006');
|
|
$data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018');
|
|
|
|
|
|
if ($POType == IMPORT) {
|
|
$AvlBudget = $this->purchaseorder_model->GetAvailableImportBudgetAmount($CostCode, $FYdt, 'IMPORT');
|
|
|
|
|
|
//print_r($AvlBudget);
|
|
|
|
|
|
if (count($AvlBudget) > 0) {
|
|
$data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue'];
|
|
}
|
|
//print_r($data['AvlBudAmt']);
|
|
$data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetails($PONO);
|
|
// print_r($data['POItem']);
|
|
$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['PoTypeOptions'] = $this->purchaseorder_model->getConfigValue('C026');
|
|
//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'] = 'Edit Import Purchase order form';
|
|
$this->loadViews("editimportpo", $this->global, $data, NULL);
|
|
} else if ($POType == CAPITAL) {
|
|
$CapitalRange = $this->request->getVar('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'] = $this->purchaseorder_model->GetCurrencyDetail('INR');
|
|
$data['ExchangeRate'] = $exRate;
|
|
$data['Currency'] = $this->purchaseorder_model->GetCurrencytype();
|
|
}
|
|
|
|
|
|
$this->global['pageTitle'] = 'Edit Capital Purchase order form';
|
|
$this->loadViews("editCapitalPo", $this->global, $data, NULL);
|
|
}
|
|
}
|
|
|
|
// To get the Material value based on the MaterialCode
|
|
function getDetailsforReq()
|
|
{
|
|
|
|
|
|
$SearchFilter = $this->request->getPost('id');
|
|
// $reqDate= $this->request->getPost('ReqDate');
|
|
$DeptCode = $SearchFilter[0];
|
|
$MatType = $SearchFilter[1];
|
|
$ReqNo = $SearchFilter[2];
|
|
// $ReqDetai = $this->purchaseorder_model->getRequistDetails( $EmpID );
|
|
|
|
$CostList = $this->requistion_model->GetCostCenterByDept($DeptCode);
|
|
|
|
$HTML = "<option value='-1'>Select Cost center</option>";
|
|
$BudAmount = "";
|
|
if (count($CostList) > 0) {
|
|
for ($j = 0; $j < count($CostList); $j++) {
|
|
$Code = $CostList[$j]['CostCenterCode'];
|
|
$Name = $CostList[$j]['CostCenterName'];
|
|
$HTML .= "<option value='" . $Code . "'>" . $Code . "-" . $Name . "</option>";
|
|
}
|
|
}
|
|
$MaterialDetails = $this->purchaseorder_model->getRawMaterialListForPO($MatType, $ReqNo);
|
|
|
|
$HTML1 = "<option value='-1'>Select Material Type</option>";
|
|
|
|
if (count($MaterialDetails) > 0) {
|
|
for ($j = 0; $j < count($MaterialDetails); $j++) {
|
|
$Code = $MaterialDetails[$j]['MaterialCode'];
|
|
$Name = $MaterialDetails[$j]['MaterialName'];
|
|
$HTML1 .= "<option value='" . $Code . "'>" . $Code . "-" . $Name . "</option>";
|
|
}
|
|
}
|
|
// print_r($HTML1);
|
|
|
|
die(json_encode(array('MatDetail' => $HTML1, 'Cost' => $HTML)));
|
|
}
|
|
/* This method to get the status based on the Department selection in th
|
|
*/
|
|
function getStatusByDepartment()
|
|
{
|
|
$DepId = $this->request->getPost('id');
|
|
|
|
$data = $this->purchaseorder_model->getStatusByDepartment($DepId);
|
|
|
|
$HTML = "<option value='0'>Select Requistion Status</option>";
|
|
if (count($data) > 0) {
|
|
for ($j = 0; $j < count($data); $j++) {
|
|
$Code = $data[$j]['StatusCode'];
|
|
$Name = $data[$j]['StatusName'];
|
|
$HTML .= "<option value='" . $Code . "'>" . $Code . "-" . $Name . "</option>";
|
|
}
|
|
}
|
|
//echo $HTML;
|
|
die(json_encode(array('depStaus' => $HTML)));
|
|
}
|
|
|
|
// To get the available Budget Amount
|
|
function AvilBudgetAmount()
|
|
{
|
|
$SearchFilter = $this->request->getPost('id');
|
|
// $reqDate= $this->request->getPost('ReqDate');
|
|
$CostCode = $SearchFilter[0];
|
|
$ReqType = $SearchFilter[1];
|
|
print_r($SearchFilter);
|
|
$CostCode = $this->request->getPost('id');
|
|
|
|
$Year = get_current_date("Y");
|
|
$this->purchaseorder_model = new purchaseorder_model();
|
|
$result = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode, $Year, $ReqType);
|
|
//print_r($result);
|
|
$AvilBudAmt = '';
|
|
if (count($result) > 0) {
|
|
$AvilBudAmt = $result[0]['BudgetAmount'] - $result[0]['Totalvalue'];
|
|
}
|
|
|
|
print_r($AvilBudAmt);
|
|
}
|
|
|
|
/* Method to get the Requistion list based on the search filter*/
|
|
|
|
function SearchListofRequistion()
|
|
{
|
|
$SearchFilter = $this->request->getPost('id');
|
|
|
|
$DEPCode = $SearchFilter[0];
|
|
$Status = $SearchFilter[1];
|
|
$rng = $SearchFilter[2];;
|
|
|
|
$FromDate = '';
|
|
$ToDate = '';
|
|
|
|
$Dt = explode("-", $rng);
|
|
|
|
if (count($Dt) > 1) {
|
|
$FDate = $Dt[0];
|
|
$TDate = $Dt[1];
|
|
$FromDate = get_date_time_format($FDate);
|
|
$ToDate = get_date_time_format($TDate);
|
|
}
|
|
|
|
$result = $this->purchaseorder_model->getRequistionListbySearch($DEPCode, $Status, $FromDate, $ToDate);
|
|
|
|
|
|
$HTML = "";
|
|
for ($i = 0; $i < count($result); $i++) {
|
|
$SNo = $i + 1;
|
|
$ReqNo = $result[$i]['ReqNo'];
|
|
$ReqType = $result[$i]['ReqType'];
|
|
$Reqedby = $result[$i]['FirstName'];
|
|
$ReqDate = $result[$i]['ReqDate'];
|
|
$Status = $result[$i]['StatusName'];
|
|
$Department = $result[$i]['DepartmentName'];
|
|
$Designation = $result[$i]['Designation'];
|
|
|
|
$HTML .= "<tr id='" . $i . "'>
|
|
<td align='left'><input type='checkbox' name='chk'" . $i . " id='chk'" . $i . "/></td>
|
|
<td align='left'><a data-toggle='modal' data-target='#myModal'><u>" . $ReqNo . "</u></a></td>
|
|
|
|
<td align='left'>" . $ReqType . "</td>
|
|
|
|
<td align='left'>" . $Reqedby . "</td>
|
|
<td align='left'>" . $ReqDate . "</td>
|
|
<td align='left'>" . $Status . "</td>
|
|
<td align='left'>" . $Department . "</td>
|
|
<td align='left'>" . $Designation . "</td>
|
|
</tr>";
|
|
}
|
|
die(json_encode(array('ReqList' => $HTML)));
|
|
}
|
|
|
|
|
|
/* To View the request details*/
|
|
function ListPORequistion()
|
|
{
|
|
$ReqNo = $this->request->getPost('id');
|
|
$result = $this->requistion_model->getRequistItemList($ReqNo);
|
|
$ReqList = $this->requistion_model->getRequistDetails($ReqNo);
|
|
$DepNo = $ReqList[0]['DEPCode'];
|
|
$CostList = $this->requistion_model->GetCostCenterByDept($DepNo);
|
|
$HTML = "";
|
|
for ($i = 0; $i < count($result); $i++) {
|
|
$SNo = $i + 1;
|
|
$MaterialCode = $result[$i]['MaterialCode'];
|
|
$MaterialName = $result[$i]['MaterialName'];
|
|
$UOM = $result[$i]['UOM'];
|
|
$Quantity = $result[$i]['Quantity'];
|
|
$HTML .= "<tr id='" . $i . "'>
|
|
<td align='left'>" . $SNo . "</td>
|
|
<td align='left'>" . $MaterialCode . "</td>
|
|
|
|
<td align='left'>" . $MaterialName . "</td>
|
|
|
|
<td align='left'>" . $UOM . "</td>
|
|
<td align='left'>" . $Quantity . "</td>
|
|
</tr>";
|
|
|
|
//$index = $index + 1;
|
|
|
|
}
|
|
|
|
$CostCenter = "<option value='-1'>Select Cost center</option>";
|
|
if (count($CostList) > 0) {
|
|
for ($j = 0; $j < count($CostList); $j++) {
|
|
$Code = $CostList[$j]['CostCenterCode'];
|
|
$Name = $CostList[$j]['CostCenterName'];
|
|
$CostCenter .= "<option value='" . $Code . "'>" . $Code . "-" . $Name . "</option>";
|
|
}
|
|
}
|
|
|
|
die(json_encode(array('Items' => $HTML, 'Requist' => $ReqList, 'Cost' => $CostCenter)));
|
|
}
|
|
|
|
//This used to Create Revenue Purchase Order
|
|
|
|
function addNewPurchaseOrder()
|
|
{
|
|
// print_r($this->request->getPost());
|
|
// echo "@1100 i have pomaster = ".'<pre>'.print_r($this->request->getPost(),true).'</pre>'."<br>";
|
|
$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('Deliverydt');
|
|
$POType = $this->request->getPost('POType');
|
|
$DeliveryOption = $this->request->getPost('DateRange');
|
|
if ($DeliveryOption == 1) {
|
|
$Deliverydt = '';
|
|
$DeliverySchedule = $this->request->getPost('Scheduleby');
|
|
} else {
|
|
$Deliverydt = get_date_time_format($dt);
|
|
$DeliverySchedule = '';
|
|
}
|
|
$POType = $this->request->getPost('POType');
|
|
$BudgetType = $this->request->getPost('Budget');
|
|
//$PoRange = $this->request->getPost('txtPoRange');
|
|
$Modeofshipment = $this->request->getPost('addmodeofshipment');
|
|
$supplierreference = $this->request->getPost('addsupplierreference');
|
|
$supplieroffno = $this->request->getPost('addsupplierofferno');
|
|
$otherreference = $this->request->getPost('addotherreference');
|
|
$fincap = $this->request->getPost('addfincap');
|
|
$revenuetype = $this->request->getPost('PoTypeOptions');
|
|
$insurancestatus = $this->request->getPost('insurance');
|
|
if ($insurancestatus == 1) {
|
|
$InsuranceNumber = $this->request->getPost('InsuranceNumber');
|
|
} else {
|
|
$InsuranceNumber = $this->request->getPost('InsuranceNumber');
|
|
}
|
|
$SpcialInstruction = $this->request->getPost('SpcialInstruction');
|
|
$TotalOrderValueSummary = $this->request->getPost('txtTotalOrderValueSummary');
|
|
$POStatus = $this->request->getPost('txtStatus');
|
|
$CreateBy = $this->session->get('userId');
|
|
$RowCount = $this->request->getPost('txtRowCount');
|
|
$DeletedRow = $this->request->getPost('txtDeletedRow');
|
|
$comma_separated = ($DeletedRow !== null && is_string($DeletedRow))
|
|
? explode(':', $DeletedRow)
|
|
: [];
|
|
// echo "DeletedRow = ".$DeletedRow;
|
|
|
|
|
|
|
|
$createddt = get_current_date_time();
|
|
|
|
$PaymentTerms = $this->request->getPost('PaymentTerms');
|
|
$OtherPayment = $this->request->getPost('Otherpayment');
|
|
$Local_Interstate = $this->request->getPost('Range');
|
|
|
|
$Qualitycheck = 1;
|
|
|
|
$IsOpenOrder = ($this->request->getPost('IsOpenOrder') !== null && !empty($this->request->getPost('IsOpenOrder')) && $this->request->getPost('IsOpenOrder') === '1') ? $this->request->getPost('IsOpenOrder') : null;
|
|
|
|
$lastPONO = $this->purchaseorder_model->lastPONO();
|
|
$newPONO = generate_po_number($lastPONO);
|
|
|
|
// PO Master
|
|
$POList = array('PONO'=>$newPONO,'SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrderValueSummary, 'PODate' => $PODate, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'Status' => $POStatus, 'PORange' => $Local_Interstate, 'ServiceDescription' => $SpcialInstruction, 'CreatedBy' => $CreateBy, 'DeliveryAddress' => $DeliveryAddr, 'DeliveryDate' => $Deliverydt, 'CreatedDate' => $createddt, 'PaymentTerms' => $PaymentTerms, 'POType' => $POType, 'CapitalRange' => $Local_Interstate, 'PaymentOtherDescription' => $OtherPayment, 'Supplier_Reference' => $supplierreference, 'Mode_Of_Shipment' => $Modeofshipment, 'Supplier_Offer_No' => $supplieroffno, 'Other_Reference' => $otherreference, 'Fincap' => $fincap, 'InsuranceStatus' => $insurancestatus, 'POSubType' => $revenuetype, 'InsuranceNumber' => $InsuranceNumber, 'IsQualityChkReqired' => $Qualitycheck, 'BudgetType' => $BudgetType,'IsOpenOrder'=>$IsOpenOrder);
|
|
$POMaster = $this->purchaseorder_model->addPOMaster($POList, $POType, $revenuetype);
|
|
// echo "@1100 i have pomaster = ".'<pre>'.print_r($POMaster,true).'</pre>'."<br>";die();
|
|
$PONO = $POMaster ? $newPONO : "";
|
|
// $PONO = '';
|
|
// if (count($POMaster) > 0) {
|
|
// $PONO = $POMaster[0]['PONO'];
|
|
// }
|
|
// $PONO = "SIA/2021-2022/10044";
|
|
// PO Line Items
|
|
$LineItemStatus = REQITEM_NEW;
|
|
|
|
for ($i = 1; $i <= $RowCount; $i++) {
|
|
|
|
$MaterialCode = $this->request->getPost('materialCode' . $i);
|
|
$Quantity = $this->request->getPost('quantity' . $i);
|
|
$Reqnumber = $this->request->getPost('Reqnumber' . $i);
|
|
$itemRate = $this->request->getPost('itemRate' . $i);
|
|
$per = $this->request->getPost('per' . $i);
|
|
|
|
$DiscountType = $this->request->getPost('DisType' . $i);
|
|
$DiscountValue = $this->request->getPost('DisVal' . $i);
|
|
$AfterDiscount = $this->request->getPost('AfterDisVal' . $i);
|
|
$PackagingOption = $this->request->getPost('PackOption' . $i);
|
|
$PackagingType = $this->request->getPost('PackType' . $i);
|
|
$PackagingValue = $this->request->getPost('PackVal' . $i);
|
|
$AfterPackagingValue = $this->request->getPost('AfterPackVal' . $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);
|
|
$InsuranceValue = $this->request->getPost('Insval' . $i);
|
|
$TotalOrderValue = $this->request->getPost('TotalOrderValue' . $i);
|
|
$revenuedescription = $this->request->getPost('Service_Description' . $i);
|
|
$CostCenter = $this->request->getPost('costCode' . $i);
|
|
$Cgst = $this->request->getPost('RevenueCgst' . $i);
|
|
$Sgst = $this->request->getPost('RevenueSgst' . $i);
|
|
$Igst = $this->request->getPost('RevenueIgst' . $i);
|
|
$AfterCgst = $this->request->getPost('RevenueAfterCgst' . $i);
|
|
$AfterSgst = $this->request->getPost('RevenueAfterSgst' . $i);
|
|
$AfterIgst = $this->request->getPost('RevenueAfterIgst' . $i);
|
|
|
|
$SkipInsert = "False";
|
|
if (count($comma_separated) > 0) {
|
|
for ($j = 1; $j < count($comma_separated); $j++) {
|
|
$deletedRow = $comma_separated[$j];
|
|
|
|
if ($deletedRow == $i) {
|
|
$SkipInsert = "True";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if ($SkipInsert == "False") {
|
|
$POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Per' => $per, 'ServiceMaterialDescription' => $revenuedescription, 'Status' => $LineItemStatus, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CostCenterCode' => $CostCenter);
|
|
$POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
|
|
// echo "@1162 i have polineitem arr ".'<pre>'.print_r($POLineItem,true).'</pre>'."<br>";
|
|
// [PONO] => SIA/2021-2022/10044
|
|
// [ReqNo] => REQ7704
|
|
// [LineItemNo] => POItem9999
|
|
// $LineItemNo = "POItem10360";
|
|
$LineItemNo = '';
|
|
if (count($POLineItem) > 0) {
|
|
$LineItemNo = $POLineItem[0]['LineItemNo'];
|
|
}
|
|
// echo $LineItemNo; die;
|
|
// echo "POType ".$POType."<br>";
|
|
/*---------*/
|
|
// $logpo =array('PONO'=>$PONO,'Date'=>$PODate,'POType'=>$POType,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'SupplierID'=>$SupplierID,'LineItemNos'=>$LineItemNo);
|
|
|
|
// $addlog= $this->purchaseorder_model->newlogpo($logpo);
|
|
/*---------*/
|
|
if (trim((string)$POType) == REVENUE) {
|
|
// echo 'Success';
|
|
$RevenueTaxList = array('LineItemNo' => $LineItemNo, 'DiscountType' => $DiscountType, 'DiscountValue' => $DiscountValue, 'AfterDiscount' => $AfterDiscount, 'PackagingType' => $PackagingType, 'PackagingValue' => $PackagingValue, 'PackagingCalulatedOn' => $PackagingOption, 'AfterPackagingValue' => $AfterPackagingValue, 'FreightType' => $FreightType, 'FreightValue' => $FreightValue, 'AfterFreightValue' => $AfterFreightValue, 'Insurance' => $InsuranceValue, 'TotalValue' => $TotalOrderValue, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CGST' => $Cgst, 'AfterCGST' => $AfterCgst, 'SGST' => $Sgst, 'AfterSGST' => $AfterSgst, 'IGST' => $Igst, 'AfterIGST' => $AfterIgst, 'NoOfTrip' => $NOOfTrip);
|
|
// echo "@1176 i have arr for tax ".'<pre>'.print_r($RevenueTaxList,true).'</pre>'."<br>";
|
|
$RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList);
|
|
// echo "@1183 i have after insertion ".'<pre>'.print_r($RevenueList,true).'</pre>'."<br>";
|
|
//echo 'Revenue tax Success';
|
|
}
|
|
}
|
|
}
|
|
echo 'Purchase Order Created Successfully! PO Number Is: ' . $PONO;
|
|
}
|
|
//This used to Edit the Revenue Purchase Order
|
|
function EditRevenuePurchaseOrder()
|
|
{
|
|
$PONO = $this->request->getPost('txtPONO');
|
|
$POdt = $this->request->getPost('PODate');
|
|
$PODate = get_date_time_format($POdt);
|
|
$SupplierID = $this->request->getPost('drpSupplier');
|
|
$newsup = (string)$this->request->getPost('newsup');
|
|
// $newSupId = split("[ - ]+", $newsup);
|
|
$newSupId = preg_split('[-]', $newsup);
|
|
|
|
|
|
$DeliveryAddr = $this->request->getPost('txtDeliveryAddress');
|
|
$dt = $this->request->getPost('Deliverydt');
|
|
//$Deliverydt = get_date_time_format($dt);
|
|
$DeliveryOption = $this->request->getPost('DateRange');
|
|
if ($DeliveryOption == 1) {
|
|
$Deliverydt = '';
|
|
$DeliverySchedule = $this->request->getPost('Scheduleby');
|
|
} else {
|
|
$Deliverydt = get_date_time_format($dt);
|
|
$DeliverySchedule = '';
|
|
}
|
|
|
|
$b4supplier = $this->request->getPost('b4supplier');
|
|
$b4date = $this->request->getPost('b4podate');
|
|
$b4podate = get_date_time_format($b4date);
|
|
|
|
$Modeofshipment = $this->request->getPost('editmodeofshipment');
|
|
$supplierreference = $this->request->getPost('editsupplierreference');
|
|
$supplieroffno = $this->request->getPost('editsupplierofferno');
|
|
$otherreference = $this->request->getPost('editotherreference');
|
|
$fincap = $this->request->getPost('editfincap');
|
|
$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('txtPoRange');
|
|
|
|
$BudgetType = $this->request->getPost('Budget');
|
|
|
|
$SpcialInstruction = $this->request->getPost('SpcialInstruction');
|
|
$TotalOrderValueSummary = $this->request->getPost('txtTotalOrderValueSummary');
|
|
$POStatus = $this->request->getPost('txtStatus');
|
|
|
|
$updatedBy = $this->session->get('userId');
|
|
|
|
//echo($updatedBy);
|
|
$RowCount = $this->request->getPost('txtRowCount');
|
|
$DeletedRow = $this->request->getPost('txtDeletedRow');
|
|
$comma_separated = ($DeletedRow !== null && is_string($DeletedRow))
|
|
? explode(':', $DeletedRow)
|
|
: [];
|
|
//echo $RowCount . "-" . $DeletedRow;
|
|
//die();
|
|
|
|
$updateddt = get_current_date_time();
|
|
|
|
$PaymentTerms = $this->request->getPost('PaymentTerms');
|
|
$OtherPayment = $this->request->getPost('Otherpayment');
|
|
$Local_Interstate = $this->request->getPost('Range');
|
|
|
|
$Qualitycheck = 1;
|
|
// PO Master
|
|
// PO Master
|
|
$POList = array('SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrderValueSummary, 'PODate' => $PODate, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'Status' => $POStatus, 'PORange' => $Local_Interstate, 'ServiceDescription' => $SpcialInstruction, 'UpdateBY' => $updatedBy, 'DeliveryAddress' => $DeliveryAddr, 'DeliveryDate' => $Deliverydt, 'UpdatedOn' => $updateddt, 'PaymentTerms' => $PaymentTerms, 'POType' => $POType, 'CapitalRange' => $Local_Interstate, 'PaymentOtherDescription' => $OtherPayment, 'Supplier_Reference' => $supplierreference, 'Mode_Of_Shipment' => $Modeofshipment, 'Supplier_Offer_No' => $supplieroffno, 'Other_Reference' => $otherreference, 'Fincap' => $fincap, 'InsuranceStatus' => $insurancestatus, 'POSubType' => $revenuetype, 'InsuranceNumber' => $InsuranceNumber, 'IsQualityChkReqired' => $Qualitycheck, 'BudgetType' => $BudgetType);
|
|
if ($POStatus == 'ST026') {
|
|
$POList['ApprovedOn'] = get_current_date_time();
|
|
$POList['ApprovedBy'] = $this->session->get('userId');
|
|
$POList['ReleasedOn'] = get_current_date_time();
|
|
$POList['ReleasedBy'] = $this->session->get('userId');
|
|
}
|
|
$POMaster = $this->purchaseorder_model->updatePOMaster($PONO, $POList);
|
|
|
|
|
|
$LineItemStatus = REQITEM_NEW;
|
|
if ($PODate != $b4podate) {
|
|
$logpo = array('PONO' => $PONO, 'LineItemNos' => '-', 'UpdateBy' => $updatedBy, 'UpdatedOn' => $updateddt, 'oldValue' => $b4podate, 'newValue' => $PODate, 'entity' => 'PO DateChanged');
|
|
|
|
|
|
$this->purchaseorder_model->insertlogpo($logpo);
|
|
}
|
|
|
|
if (!empty($newSupId[0])) {
|
|
if ($newSupId[0] != $b4supplier) {
|
|
//echo $b4supplier.'-'.$newSupId[0];die;
|
|
$logpo = array('PONO' => $PONO, 'LineItemNos' => '-', 'UpdateBy' => $updatedBy, 'UpdatedOn' => $updateddt, 'oldValue' => $b4supplier, 'newValue' => $newsup, 'entity' => 'Supplier Changed');
|
|
|
|
|
|
$this->purchaseorder_model->insertlogpo($logpo);
|
|
}
|
|
}
|
|
|
|
//echo "OUT";
|
|
for ($i = 1; $i <= $RowCount; $i++) {
|
|
//echo "IN";
|
|
$MaterialCode = $this->request->getPost('materialCode' . $i);
|
|
$Quantity = $this->request->getPost('quantity' . $i);
|
|
$Reqnumber = $this->request->getPost('Reqnumber' . $i);
|
|
|
|
$b4qty = $this->request->getPost('b4qty' . $i);
|
|
$b4rate = $this->request->getPost('b4rate' . $i);
|
|
|
|
$itemRate = $this->request->getPost('itemRate' . $i);
|
|
$per = $this->request->getPost('per' . $i);
|
|
$DiscountType = $this->request->getPost('DisType' . $i);
|
|
$DiscountValue = $this->request->getPost('DisVal' . $i);
|
|
$AfterDiscount = $this->request->getPost('AfterDisVal' . $i);
|
|
$PackagingOption = $this->request->getPost('PackOption' . $i);
|
|
$PackagingType = $this->request->getPost('PackType' . $i);
|
|
$PackagingValue = $this->request->getPost('PackVal' . $i);
|
|
$AfterPackagingValue = $this->request->getPost('AfterPackVal' . $i);
|
|
$Cgst = $this->request->getPost('RevenueCgst' . $i);
|
|
$Sgst = $this->request->getPost('RevenueSgst' . $i);
|
|
$Igst = $this->request->getPost('RevenueIgst' . $i);
|
|
$AfterCgst = $this->request->getPost('RevenueAfterCgst' . $i);
|
|
$AfterSgst = $this->request->getPost('RevenueAfterSgst' . $i);
|
|
$AfterIgst = $this->request->getPost('RevenueAfterIgst' . $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);
|
|
$revenuedescription = $this->request->getPost('service_description' . $i);
|
|
$InsuranceValue = $this->request->getPost('Insval' . $i);
|
|
$TotalOrderValue = $this->request->getPost('TotalOrderValue' . $i);
|
|
$POLineItemNo = $this->request->getPost('LineItemNo' . $i);
|
|
$CostCenter = $this->request->getPost('costCode' . $i);
|
|
$LineItemNo = '';
|
|
|
|
/*---------start---------------------*/
|
|
if ($Quantity != $b4qty) {
|
|
$logpo = array('PONO' => $PONO, 'LineItemNos' => $POLineItemNo, 'UpdateBy' => $updatedBy, 'UpdatedOn' => $updateddt, 'oldValue' => $b4qty, 'newValue' => $Quantity, 'entity' => 'Quantity Changed');
|
|
|
|
|
|
$this->purchaseorder_model->insertlogpo($logpo);
|
|
}
|
|
|
|
|
|
if ($itemRate != $b4rate) {
|
|
$logpo = array('PONO' => $PONO, 'LineItemNos' => $POLineItemNo, 'UpdateBy' => $updatedBy, 'UpdatedOn' => $updateddt, 'oldValue' => $b4rate, 'newValue' => $itemRate, 'entity' => 'Rate Changed');
|
|
|
|
|
|
$this->purchaseorder_model->insertlogpo($logpo);
|
|
}
|
|
|
|
|
|
|
|
$SkipInsert = "False";
|
|
if (count($comma_separated) > 0) {
|
|
for ($j = 1; $j < count($comma_separated); $j++) {
|
|
$deletedRow = $comma_separated[$j];
|
|
|
|
if ($deletedRow == $i) {
|
|
$SkipInsert = "True";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$ReqDetails = array('Quantity' => $Quantity, 'UpdatedBy' => $updatedBy, 'UpdatedOn' => $updateddt);
|
|
|
|
|
|
$this->purchaseorder_model->updateReqDetails($Reqnumber, $MaterialCode, $ReqDetails);
|
|
$recqty = 0;
|
|
|
|
if ($POStatus == SPECIAL_PO) {
|
|
|
|
$recqty = $Quantity;
|
|
|
|
$IGRD = $this->purchaseorder_model->IGRDetailsupdate($PONO);
|
|
$j = $i - 1;
|
|
|
|
|
|
// print_r($IGRD); die;
|
|
$IGRDs = array('QuantityAsPerInvoice' => $Quantity, 'UpdateBY' => $updatedBy, 'UpdatedOn' => $updateddt);
|
|
|
|
|
|
$this->purchaseorder_model->updateIGR($IGRD[$j]['IGRItemNo'], $IGRDs);
|
|
|
|
|
|
$MaterialstockHistoryupdate = array('SupplierID' => $SupplierID, 'Quantity' => $Quantity, 'ItemValue' => $itemRate, 'UpdateBY' => $updatedBy, 'UpdatedOn' => $updateddt);
|
|
|
|
|
|
$itemNo = $IGRD[$j]['IGRItemNo'];
|
|
|
|
|
|
$this->purchaseorder_model->updateMatStock(
|
|
$itemNo,
|
|
$MaterialstockHistoryupdate
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$rawget_pre_qty = $this->inwardgateregister_model->get_CurrentQty($MaterialCode);
|
|
$av_qty = 0;
|
|
if (!empty($rawget_pre_qty)) {
|
|
foreach ($rawget_pre_qty as $gt) {
|
|
$av_qty = $gt->Current_stock;
|
|
}
|
|
}
|
|
|
|
// echo $av_qty;
|
|
// die();
|
|
$qty_dif = $Quantity - $b4qty;
|
|
|
|
$currentav_qty = $av_qty - $qty_dif;
|
|
|
|
|
|
//echo $currentav_qty;
|
|
//die();
|
|
|
|
$current_qty = array('Current_stock' => $currentav_qty);
|
|
|
|
|
|
//echo $current_qty;
|
|
|
|
$this->inwardgateregister_model->addmaterialmaster($current_qty, $rawmaterial);
|
|
}
|
|
|
|
if ($SkipInsert == "False") {
|
|
|
|
if (strlen((string)$POLineItemNo) == 0) {
|
|
// $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Per'=>$per,'ServiceMaterialDescription'=>$revenuedescription,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter);
|
|
// //print_r($POLineItemList);
|
|
// $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
|
|
// if(count($POLineItem)>0)
|
|
// {
|
|
// $LineItemNo = $POLineItem[0]['LineItemNo'];
|
|
// }
|
|
|
|
} else {
|
|
|
|
$LineItemNo = $POLineItemNo;
|
|
|
|
$POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'ReceivedQuantity' => $recqty, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'UpdateBY' => $updatedBy, 'UpdatedOn' => $updateddt, 'CostCenterCode' => $CostCenter);
|
|
|
|
|
|
//print_r($POLineItemList);
|
|
$POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO, $POLineItemNo, $POLineItemList);
|
|
}
|
|
$isExists = $this->purchaseorder_model->LineItemExistsinRevenueTax($LineItemNo);
|
|
if (count($isExists) == 0) {
|
|
// $RevenueTaxList = array('LineItemNo'=>$LineItemNo, 'DiscountType'=>$DiscountType,'DiscountValue'=>$DiscountValue,'AfterDiscount'=>$AfterDiscount,'PackagingType'=>$PackagingType,'PackagingValue'=>$PackagingValue,'PackagingCalulatedOn'=>$PackagingOption,'AfterPackagingValue'=>$AfterPackagingValue,'FreightType'=>$FreightType, 'FreightValue'=>$FreightValue,'AfterFreightValue'=>$AfterFreightValue,'Insurance'=>$InsuranceValue,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CGST'=>$Cgst,'AfterCGST'=>$AfterCgst,'SGST'=>$Sgst,'AfterSGST'=>$AfterSgst,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'NoOfTrip'=>$NOOfTrip);
|
|
// //print_r($RevenueTaxList);
|
|
// $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList);
|
|
|
|
} else {
|
|
|
|
$RevenueTaxList = array('DiscountType' => $DiscountType, 'DiscountValue' => $DiscountValue, 'AfterDiscount' => $AfterDiscount, 'PackagingType' => $PackagingType, 'PackagingValue' => $PackagingValue, 'PackagingCalulatedOn' => $PackagingOption, 'AfterPackagingValue' => $AfterPackagingValue, 'FreightType' => $FreightType, 'FreightValue' => $FreightValue, 'AfterFreightValue' => $AfterFreightValue, 'Insurance' => $InsuranceValue, 'TotalValue' => $TotalOrderValue, 'UpdateBY' => $updatedBy, 'UpdatedOn' => $updateddt, 'CGST' => $Cgst, 'AfterCGST' => $AfterCgst, 'SGST' => $Sgst, 'AfterSGST' => $AfterSgst, 'IGST' => $Igst, 'AfterIGST' => $AfterIgst, 'CreatedBy' => $updatedBy, 'NoOfTrip' => $NOOfTrip);
|
|
//print_r($RevenueTaxList);
|
|
$this->purchaseorder_model->updateRevenueTax($LineItemNo, $RevenueTaxList);
|
|
}
|
|
}
|
|
}
|
|
|
|
echo 'Purchase Order Updated Successfully! PO Number Is: ' . $PONO;
|
|
}
|
|
|
|
|
|
public function revenuepoprint($PONO)
|
|
{
|
|
|
|
// Load all views as normal
|
|
|
|
|
|
//$PONO = $this->request->getVar('PO');
|
|
$PoStatus = '';
|
|
$data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO);
|
|
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformationforPDF();
|
|
$data['GetPoFormat'] = $this->purchaseorder_model->GetPoFormat($PONO);
|
|
$data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetailsForPDF($PONO);
|
|
$data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO);
|
|
$data['CurrencySymbol'] = $this->purchaseorder_model->GerCurrencyCodeName('INR');
|
|
$data['reveuetax'] = $this->purchaseorder_model->getRevenueTaxinforforpdf($PONO);
|
|
$data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO);
|
|
$Currencycode = '';
|
|
|
|
$TotalOrderValue = $data['POItem'][0]->TotalOrderValue;
|
|
$AdvanceAmount = 0.00;
|
|
foreach ($data['POItem'] as $POI) {
|
|
$AdvanceAmount = $POI->AdvanceAmount;
|
|
$PoStatus = $POI->Status;
|
|
}
|
|
|
|
$TotaltoPay = 0.00;
|
|
$TotaltoPay = $TotalOrderValue - $AdvanceAmount;
|
|
$totalAmt = sprintf("%.2f", $TotalOrderValue);
|
|
|
|
|
|
|
|
$data['TotalAmountInWords'] = $this->convertNumber($totalAmt);
|
|
$data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO);
|
|
|
|
|
|
$mpdf = new Mpdf([
|
|
'mode' => 'utf-8',
|
|
'format' => 'A4', // Page format: A4 with portrait orientation
|
|
// 'format' => [148, 210], // Set custom width and height in millimeters
|
|
'default_font_size' => 6,
|
|
'default_font' => 'sans-serif',
|
|
'margin_left' => 10,
|
|
'margin_right' => 10,
|
|
'margin_top' => 10,
|
|
'margin_bottom' => 10,
|
|
'margin_header' => 82,
|
|
'margin_footer' => 38,
|
|
'orientation' => 'P',
|
|
]);
|
|
|
|
|
|
$mpdf->autoLangToFont = true;
|
|
$mpdf->autoScriptToLang = true;
|
|
// Set PDF properties
|
|
$mpdf->SetTitle('Invoice');
|
|
$mpdf->SetAuthor($data['CompanyDetails'][0]->CompanyName);
|
|
$mpdf->SetCreator('');
|
|
|
|
$htmlFooter = '<div>
|
|
<img src="https://cdn.pixabay.com/photo/2012/04/26/14/17/blue-42596_960_720.png"style=margin-top:70px;/>
|
|
</div>';
|
|
$mpdf->setHTMLFooter($htmlFooter);
|
|
|
|
// Generate the PDF content (HTML)
|
|
if ($PoStatus == PO_RELEASED || $PoStatus == PO_SERVICE_COMPLETED || $PoStatus == MRIR_APPROVED || $PoStatus == MRIR_REJECTED || $PoStatus == IGR_CREATED || $PoStatus == '' || $PoStatus == SPECIAL_PO) {
|
|
$mpdf->SetWatermarkText('');
|
|
} else {
|
|
$mpdf->SetWatermarkText('DRAFT');
|
|
}
|
|
|
|
$WatermarkImage = base_url()."public/assets/images/mpdf.png";
|
|
$mpdf->SetWatermarkImage($WatermarkImage, 8, 10);
|
|
|
|
$mpdf->showWatermarkImage = true;
|
|
$mpdf->watermark_font = 'DejaVuSansCondensed';
|
|
$mpdf->showWatermarkText = true;
|
|
|
|
// Set auto margins
|
|
$mpdf->setAutoTopMargin = 'stretch';
|
|
$mpdf->setAutoBottomMargin = 'stretch';
|
|
|
|
// Set HTML header
|
|
$HtmlHeading = view('includes/pdfheader', $data);
|
|
$mpdf->SetHTMLHeader($HtmlHeading);
|
|
|
|
// Set HTML body
|
|
// $html = view('pdf_view', $data);
|
|
// $mpdf->WriteHTML($html); // Use WriteHTML() method to add body content
|
|
$html = view('capitalpopdf', $data);
|
|
$mpdf->WriteHTML($html); // Use WriteHTML() method to add body content
|
|
|
|
// Set HTML footer
|
|
$HTMLFooter = view('includes/pdffooter', $data);
|
|
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
|
|
|
|
// Output PDF
|
|
$mpdf->Output('CapitalPOReport' . $PONO . '.pdf', 'D');
|
|
}
|
|
|
|
|
|
|
|
public function servicepoprint($PONO)
|
|
{
|
|
|
|
// view('includes/pdfheader');
|
|
|
|
// Load the pdf page with multiviews
|
|
$PoStatus = '';
|
|
$data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO);
|
|
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformationforPDF();
|
|
$data['GetPoFormat'] = $this->purchaseorder_model->GetPoFormat($PONO);
|
|
$data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetailsForpdf($PONO);
|
|
$data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO);
|
|
|
|
$data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO);
|
|
$data['serviceTaxList'] = $this->purchaseorder_model->GetServiceTaxDetails($PONO);
|
|
|
|
$data['CurrencySymbol'] = $this->purchaseorder_model->GerCurrencyCodeName('INR');
|
|
|
|
//print_r( $data['CurrencySymbol']);
|
|
|
|
$TotalOrderValue = 0;
|
|
$Currencycode = '';
|
|
foreach ($data['POItem'] as $POValue) {
|
|
|
|
$TotalOrderValue = $TotalOrderValue + $POValue->TotalValue;
|
|
}
|
|
$Advance = 0.00;
|
|
foreach ($data['POItem'] as $PO) {
|
|
$Advance = $PO->AdvanceAmount;
|
|
$PoStatus = $PO->Status;
|
|
}
|
|
$TotaltoPay = 0.00;
|
|
$TotaltoPay = $TotalOrderValue - $Advance;
|
|
|
|
|
|
|
|
$totalAmt = sprintf("%.2f", $TotalOrderValue);
|
|
|
|
$data['TotalAmountInWords'] = $this->convertNumber($totalAmt);
|
|
|
|
$data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO);
|
|
|
|
$mpdf = new Mpdf([
|
|
'mode' => 'utf-8',
|
|
'format' => 'A4-P', // Page format: A4 with portrait orientation
|
|
// 'format' => [148, 210], // Set custom width and height in millimeters
|
|
'default_font_size' => 6,
|
|
'default_font' => 'sans-serif',
|
|
'margin_left' => 10,
|
|
'margin_right' => 10,
|
|
'margin_top' => 10,
|
|
'margin_bottom' => 10,
|
|
'margin_header' => 82,
|
|
'margin_footer' => 38,
|
|
'orientation' => 'P',
|
|
]);
|
|
|
|
// Set watermark
|
|
if ($PoStatus == PO_RELEASED || $PoStatus == PO_SERVICE_COMPLETED || $PoStatus == MRIR_APPROVED || $PoStatus == MRIR_REJECTED || $PoStatus == IGR_CREATED || $PoStatus == '' || $PoStatus == SPECIAL_PO) {
|
|
$mpdf->SetWatermarkText('');
|
|
} else {
|
|
$mpdf->SetWatermarkText('DRAFT');
|
|
}
|
|
$mpdf->SetWatermarkImage('.public/assets/images/mpdf.png', 8, 10);
|
|
$mpdf->showWatermarkImage = true;
|
|
$mpdf->watermark_font = 'DejaVuSansCondensed';
|
|
$mpdf->showWatermarkText = true;
|
|
|
|
// Set HTML header
|
|
$HtmlHeading = view('includes/pdfheader', $data);
|
|
$mpdf->SetHTMLHeader($HtmlHeading);
|
|
|
|
// Set HTML footer
|
|
$HTMLFooter = view('includes/pdffooter', $data);
|
|
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
|
|
|
|
// Set auto margins
|
|
$mpdf->setAutoTopMargin = 'stretch';
|
|
$mpdf->setAutoBottomMargin = 'stretch';
|
|
|
|
// Generate PDF content
|
|
$html = view('servicepopdf', $data);
|
|
|
|
|
|
// Write HTML content to PDF
|
|
$mpdf->WriteHTML($html);
|
|
$mpdf->SetDisplayMode('fullpage');
|
|
// Output PDF
|
|
$mpdf->Output('ServicePOReport' . $PONO . '.pdf', 'D');
|
|
}
|
|
|
|
public function importpoprint($PONO)
|
|
{
|
|
// echo $PONO;
|
|
// die();
|
|
//view('includes/pdfheader');
|
|
|
|
// Load the pdf page with multiviews
|
|
$Requester = '';
|
|
$Depcode = '';
|
|
$Currencycode = '';
|
|
$PoStatus = '';
|
|
$PaiseVal = '';
|
|
$data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO);
|
|
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformationforPDF();
|
|
$data['GetPoFormat'] = $this->purchaseorder_model->GetPoFormat($PONO);
|
|
$data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetailsForPDF($PONO);
|
|
$data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO);
|
|
$data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO);
|
|
$data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO);
|
|
//print_r( $data['RequistionDetails']);
|
|
foreach ($data['POItem'] as $Reqdby) {
|
|
$Requester = $Reqdby->Requestedby;
|
|
$PoStatus = $Reqdby->Status;
|
|
}
|
|
|
|
|
|
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 = 0.0;
|
|
foreach ($data['POItem'] as $PO) {
|
|
$TotalOrderValue = $PO->TotalOrderValue;
|
|
}
|
|
$AdvanceAmount = 0.0;
|
|
foreach ($data['POItem'] as $POI) {
|
|
$AdvanceAmount = $POI->AdvanceAmount;
|
|
}
|
|
|
|
$TotaltoPay = 0.00;
|
|
$TotaltoPay = $TotalOrderValue - $AdvanceAmount;
|
|
|
|
//$totalAmt=sprintf("%.2f", $ProductPrice);
|
|
//$data['TotalAmountInWords']= $this->convertNumber($totalAmt);
|
|
//print_r($data['TotalAmountInWords']);
|
|
|
|
//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", $TotaltoPay);
|
|
|
|
$data['TotalAmountInWords'] = $this->convertNumberSymbol($totalAmt, $SymbolCurrency, $SymbolCurrencyName, $PaiseVal);
|
|
|
|
$mpdf = new Mpdf([
|
|
'mode' => 'utf-8',
|
|
'format' => 'A4-P', // Page format: A4 with portrait orientation
|
|
// 'format' => [148, 210], // Set custom width and height in millimeters
|
|
'default_font_size' => 6,
|
|
'default_font' => 'sans-serif',
|
|
'margin_left' => 10,
|
|
'margin_right' => 10,
|
|
'margin_top' => 10,
|
|
'margin_bottom' => 10,
|
|
'margin_header' => 82,
|
|
'margin_footer' => 38,
|
|
'orientation' => 'P',
|
|
]);
|
|
|
|
// Set watermark
|
|
if ($PoStatus == PO_RELEASED || $PoStatus == PO_SERVICE_COMPLETED || $PoStatus == MRIR_APPROVED || $PoStatus == MRIR_REJECTED || $PoStatus == IGR_CREATED || $PoStatus == '' || $PoStatus == SPECIAL_PO) {
|
|
$mpdf->SetWatermarkText('');
|
|
} else {
|
|
$mpdf->SetWatermarkText('DRAFT');
|
|
}
|
|
$mpdf->SetWatermarkImage('.public/assets/images/mpdf.png', 8, 10);
|
|
$mpdf->showWatermarkImage = true;
|
|
$mpdf->watermark_font = 'DejaVuSansCondensed';
|
|
$mpdf->showWatermarkText = true;
|
|
|
|
// Set HTML header
|
|
$HtmlHeading = view('includes/pdfheader', $data);
|
|
$mpdf->SetHTMLHeader($HtmlHeading);
|
|
|
|
// Set HTML footer
|
|
$HTMLFooter = view('includes/pdffooter', $data);
|
|
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
|
|
|
|
// Set auto margins
|
|
$mpdf->setAutoTopMargin = 'stretch';
|
|
$mpdf->setAutoBottomMargin = 'stretch';
|
|
|
|
// Generate PDF content
|
|
$html = view('importpopdf', $data);
|
|
|
|
|
|
// Write HTML content to PDF
|
|
$mpdf->WriteHTML($html);
|
|
$mpdf->SetDisplayMode('fullpage');
|
|
// Output PDF
|
|
$mpdf->Output('ImportPOReport' . $PONO . '.pdf', 'I');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* This function used to load the Delete the Requistion Items
|
|
*/
|
|
function DeletePODetails()
|
|
{
|
|
|
|
|
|
$ReqList = $this->request->getPost('id');
|
|
$LineItemNo = '';
|
|
$ReqNo = '';
|
|
$MaterialCode = '';
|
|
$POType = '';
|
|
if (count($ReqList) > 0) {
|
|
$LineItemNo = $ReqList[0];
|
|
$ReqNo = $ReqList[1];
|
|
$MaterialCode = $ReqList[2];
|
|
$POType = $ReqList[3];
|
|
}
|
|
|
|
if ($POType == REVENUE) {
|
|
$this->purchaseorder_model->DeletePORevenueTax($LineItemNo);
|
|
} else if ($POType == SERVICE) {
|
|
$this->purchaseorder_model->DeletePOServiceTax($LineItemNo);
|
|
} else if ($POType == IMPORT) {
|
|
$this->purchaseorder_model->DeletePOImportTax($LineItemNo);
|
|
} else if ($POType == CAPITAL) {
|
|
$this->purchaseorder_model->DeletePOImportTax($LineItemNo);
|
|
$this->purchaseorder_model->DeletePOServiceTax($LineItemNo);
|
|
}
|
|
$this->purchaseorder_model->DeletePOLineItem($LineItemNo, $ReqNo, $MaterialCode);
|
|
echo "Successfully Deleted the Line item" . $LineItemNo;
|
|
}
|
|
|
|
|
|
|
|
function addNewImportPurchaseOrder()
|
|
{ //echo ("ggh");
|
|
|
|
|
|
|
|
$POdt = $this->request->getPost('PODate');
|
|
$PODate = get_date_time_format($POdt);
|
|
$SupplierID = $this->request->getPost('drpSupplier');
|
|
$DeliveryAddr = $this->request->getPost('DeliveryAddr');
|
|
|
|
$POType = $this->request->getPost('POType');
|
|
$PoRange = $this->request->getPost('txtPoRange');
|
|
|
|
$DeliveryOption = $this->request->getPost('DateRange');
|
|
|
|
//echo $DeliveryOption;
|
|
//die();
|
|
$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('txtToatlOrder');
|
|
$POStatus = $this->request->getVar('textStatus');
|
|
|
|
$BudgetType = $this->request->getPost('Budget');
|
|
|
|
$CreateBy = $this->session->get('userId');
|
|
$RowCount = $this->request->getVar('txtRowCount');
|
|
|
|
$DeletedRow = $this->request->getVar('txtDeletedRow');
|
|
$comma_separated = ($DeletedRow !== null && is_string($DeletedRow))
|
|
? explode(':', $DeletedRow)
|
|
: [];
|
|
|
|
$createddt = get_current_date_time();
|
|
$Exchangerate = $this->request->getPost('ExchangeRate');
|
|
$Edt = $this->request->getPost('Exchangerateon');
|
|
$ExchangeRateCalculatedon = get_date_time_format($Edt);
|
|
|
|
$CurrencyType = $this->request->getPost('currencytype');
|
|
|
|
$PaymentTerms = $this->request->getPost('PaymentTerms');
|
|
$OtherPayment = $this->request->getPost('Otherpayment');
|
|
$Palaceoforigin = $this->request->getPost('PlaceOforigin');
|
|
// $Payableat=$this->request->getPost('PayableAT');
|
|
|
|
$Shipmentmode = $this->request->getPost('addmodeofshipment');
|
|
$SupplierRef = $this->request->getPost('addsupplierreference');
|
|
$SupplierOffer = $this->request->getPost('addsupplierofferno');
|
|
$otherRef = $this->request->getPost('addotherreference');
|
|
$finCap = $this->request->getPost('addfincap');
|
|
|
|
$importoption = $this->request->getPost('Importoption');
|
|
// echo $importoption;
|
|
// die();
|
|
$Insurance = $this->request->getPost('Insurance');
|
|
|
|
if ($Insurance == 1) {
|
|
|
|
$InsuranceNumber = $this->request->getPost('InsuranceNumber');
|
|
} else {
|
|
$InsuranceNumber = '';
|
|
}
|
|
|
|
// $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'CreatedDate'=>$createddt,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType);
|
|
|
|
$Qualitycheck = 1;
|
|
$IsOpenOrder = ($this->request->getPost('IsOpenOrder') !== null && !empty($this->request->getPost('IsOpenOrder')) && $this->request->getPost('IsOpenOrder') === '1') ? $this->request->getPost('IsOpenOrder') : null;
|
|
|
|
$lastPONO = $this->purchaseorder_model->lastPONO();
|
|
$newPONO = generate_po_number($lastPONO);
|
|
|
|
$POList = array('PONO'=>$newPONO,'SupplierID' => $SupplierID, '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, 'PaymentOtherDescription' => $OtherPayment, 'Mode_Of_Shipment' => $Shipmentmode, 'Supplier_Reference' => $SupplierRef, 'Supplier_Offer_No' => $SupplierOffer, 'Other_Reference' => $otherRef, 'Fincap' => $finCap, 'InsuranceStatus' => $Insurance, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $importoption, 'IsQualityChkReqired' => $Qualitycheck, 'BudgetType' => $BudgetType,'IsOpenOrder'=>$IsOpenOrder);
|
|
|
|
//print_r($POList);
|
|
//die();
|
|
$POMaster = $this->purchaseorder_model->addPOMaster($POList, $POType, $importoption);
|
|
$PONO = $POMaster ? $newPONO : "";
|
|
// $PONO = '';
|
|
// if (count($POMaster) > 0) {
|
|
// $PONO = $POMaster[0]['PONO'];
|
|
// }
|
|
//echo $PONO;
|
|
//echo $POType;
|
|
// PO Line Items
|
|
$LineItemStatus = REQITEM_NEW;
|
|
//echo ' test:'.REVENUE;
|
|
//echo $RowCount;
|
|
for ($i = 1; $i <= $RowCount; $i++) {
|
|
//echo "AS";
|
|
$MaterialCode = $this->request->getPost('materialCode' . $i);
|
|
$Quantity = $this->request->getPost('quantity' . $i);
|
|
//echo $Quantity;
|
|
$Reqnumber = $this->request->getPost('Reqnumber' . $i);
|
|
$itemRate = $this->request->getPost('itemRate' . $i);
|
|
|
|
//$Exchangerate = $this->request->getPost('Exchangerate'.$i);
|
|
$BasicPriceinmton = $this->request->getPost('BasicPriceinUS' . $i);
|
|
$Productprice = $this->request->getPost('BasicAmt' . $i);
|
|
$LandingCharge = $this->request->getPost('LandingChargee' . $i);
|
|
$AfterLandingCharge = $this->request->getPost('AfterLandingChargee' . $i);
|
|
$CustomDuty = $this->request->getPost('Customduty' . $i);
|
|
$AfterCustomDuty = $this->request->getPost('AfterCustomduty' . $i);
|
|
$CustomEd = $this->request->getPost('CustomEDcess' . $i);
|
|
$AfterCustomEd = $this->request->getPost('AfterCustomEDcess' . $i);
|
|
$CustomSH = $this->request->getPost('CustomSHcess' . $i);
|
|
$AfterCustomSH = $this->request->getPost('AfterCustomSHcess' . $i);
|
|
$Grossdutypayable = $this->request->getPost('Grossdutypayable' . $i);
|
|
$CustomDutyExpensesPerKG = $this->request->getPost('CustomDutyExpenses' . $i);
|
|
|
|
$QuantityKG = $this->request->getPost('PurQuantity' . $i);
|
|
|
|
//$currencytypeID = $this->request->getPost('currencytype');
|
|
$Totalvalueitem = $this->request->getPost('TotalExp' . $i);
|
|
|
|
//echo $BasicPriceinmton;
|
|
$CostCenter = $this->request->getPost('costCode' . $i);
|
|
|
|
$AssessableValue = $this->request->getPost('AfterAssessable' . $i);
|
|
$Subtotal = $this->request->getPost('Subtotal' . $i);
|
|
$Igst = $this->request->getPost('Igst' . $i);
|
|
$AfterIgst = $this->request->getPost('AfterIgst' . $i);
|
|
$Dutyimpact = $this->request->getPost('Dutyimpact' . $i);
|
|
$Clearingcharge = $this->request->getPost('ClearingCharges' . $i);
|
|
$Nettvalue = $this->request->getPost('Nett' . $i);
|
|
|
|
|
|
|
|
$FreightType = $this->request->getPost('FreightType' . $i);
|
|
$nooftrip = $this->request->getPost('NoofTrip' . $i);
|
|
$Freightrate = $this->request->getPost('FreightRate' . $i);
|
|
$Freightamount = $this->request->getPost('AfterFreightRate' . $i);
|
|
|
|
//echo $Freightamount;
|
|
|
|
$specialinstruction = $this->request->getPost('Addinstruction' . $i);
|
|
|
|
//echo $specialinstruction;
|
|
|
|
$per = $this->request->getPost('Per' . $i);
|
|
|
|
|
|
|
|
|
|
$SkipInsert = "False";
|
|
if (count($comma_separated) > 0) {
|
|
for ($j = 1; $j < count($comma_separated); $j++) {
|
|
$deletedRow = $comma_separated[$j];
|
|
|
|
if ($deletedRow == $i) {
|
|
$SkipInsert = "True";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if ($SkipInsert == "False") {
|
|
$POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CostCenterCode' => $CostCenter, 'Per' => $per, 'ServiceMaterialDescription' => $specialinstruction);
|
|
|
|
//print_r($POLineItemList);
|
|
//die();
|
|
|
|
|
|
$POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
|
|
|
|
$LineItemNo = '';
|
|
if (count($POLineItem) > 0) {
|
|
$LineItemNo = $POLineItem[0]['LineItemNo'];
|
|
}
|
|
//echo $LineItemNo;
|
|
|
|
/* --------------------------------------------*/
|
|
|
|
// $logpo =array('PONO'=>$PONO,'Date'=>$PODate,'POType'=>$POType,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=> $itemRate,'SupplierID'=>$SupplierID,'LineItemNos'=>$LineItemNo);
|
|
// $this->purchaseorder_model->newlogpo($logpo);
|
|
/* --------------------------------------------*/
|
|
|
|
if (trim((string)$POType) == IMPORT) {
|
|
// echo 'Success';
|
|
$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' => $AssessableValue, 'SubTotal' => $Subtotal, 'IGST' => $Igst, 'AfterIGST' => $AfterIgst, 'DutyImpact' => $Dutyimpact, 'ClearingCharge' => $Clearingcharge, 'NetValue' => $Nettvalue);
|
|
//print_r($ImportTaxList);
|
|
//die();$Nettvalue
|
|
|
|
|
|
|
|
$ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
echo 'Purchase Order Created Successfully! PO Number Is: ' . $PONO;
|
|
}
|
|
|
|
|
|
function EditImportPurchaseOrder()
|
|
{
|
|
|
|
//echo "dfds";
|
|
//die();
|
|
$PONO = $this->request->getPost('txtPONO');
|
|
$POdt = '';
|
|
$createddt = '';
|
|
|
|
$PODate = get_date_time_format($POdt);
|
|
$SupplierID = $this->request->getPost('drpSupplier');
|
|
|
|
|
|
$newsup = (string)$this->request->getPost('newsup');
|
|
// $newSupId = split("[ - ]+", $newsup);
|
|
$newSupId = preg_split('[-]', $newsup);
|
|
|
|
/*-----------------------------------*/
|
|
$b4supplier = $this->request->getPost('b4supplier');
|
|
$b4date = $this->request->getPost('b4podate');
|
|
$b4podate = get_date_time_format($b4date);
|
|
/*-----------------------------------*/
|
|
$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');
|
|
//$DeliveryOption = $this->request->getPost('DateRange');
|
|
|
|
$Exchangerate = $this->request->getPost('ExchangeRate');
|
|
$Edt = $this->request->getPost('Exchangerateon');
|
|
$ExchangeRateCalculatedon = get_date_time_format($Edt);
|
|
|
|
// $ExchangeRateCalculatedon=$this->request->getPost('Exchangerateon');
|
|
$CurrencyType = $this->request->getPost('currencytype');
|
|
|
|
$DeliveryOption = $this->request->getPost('DateRange');
|
|
|
|
//echo $DeliveryOption;
|
|
//die();
|
|
$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('txtToatlOrder');
|
|
$TotalOrder = $this->request->getPost('txttot');
|
|
// echo $TotalOrder;
|
|
//die();
|
|
$POStatus = $this->request->getPost('txtStatus');
|
|
|
|
$BudgetType = $this->request->getPost('Budget');
|
|
|
|
$CreateBy = $this->session->get('userId');
|
|
$RowCount = $this->request->getPost('txtRowCount');
|
|
$DeletedRow = $this->request->getPost('txtDeletedRow');
|
|
$comma_separated = ($DeletedRow !== null && is_string($DeletedRow))
|
|
? explode(':', $DeletedRow)
|
|
: [];
|
|
|
|
|
|
$updateddt = get_current_date_time();
|
|
|
|
$PaymentTerms = $this->request->getPost('PaymentTerms');
|
|
$OtherPayment = $this->request->getPost('Otherpayment');
|
|
$Palaceoforigin = $this->request->getPost('PlaceOforigin');
|
|
// $Payableat=$this->request->getPost('PayableAT');
|
|
|
|
|
|
$Shipmentmode = $this->request->getPost('editmodeofshipment');
|
|
$SupplierRef = $this->request->getPost('editsupplierreference');
|
|
$SupplierOffer = $this->request->getPost('editsupplierofferno');
|
|
$otherRef = $this->request->getPost('editotherreference');
|
|
$finCap = $this->request->getPost('editfincap');
|
|
|
|
|
|
|
|
$importoption = $this->request->getPost('Importoption');
|
|
// echo $importoption;
|
|
// die();
|
|
$Insurance = $this->request->getPost('Insurance');
|
|
|
|
//echo $Insurance;
|
|
|
|
if ($Insurance == 'YES') {
|
|
|
|
$InsuranceNumber = $this->request->getPost('InsuranceNumber');
|
|
$insurestatus = '1';
|
|
} else {
|
|
$InsuranceNumber = '';
|
|
$insurestatus = '0';
|
|
}
|
|
// PO Master
|
|
// PO Master
|
|
// $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$updateddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms);
|
|
$Qualitycheck = 1;
|
|
|
|
|
|
$POList = array('SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrder, 'PODate' => $PODate, 'Status' => $POStatus, 'ServiceDescription' => $SpcialInstruction, 'CreatedBy' => $CreateBy, 'DeliveryAddress' => $DeliveryAddr, 'Import_DispatchDetails' => $Dispatch, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'ExchangeRate' => $Exchangerate, 'ExchangeRateCalculatedon' => $ExchangeRateCalculatedon, 'CurrencyType' => $CurrencyType, 'PaymentTerms' => $PaymentTerms, 'POType' => $POType, 'Import_PlaceofOrgin' => $Palaceoforigin, 'PaymentOtherDescription' => $OtherPayment, 'Mode_Of_Shipment' => $Shipmentmode, 'Supplier_Reference' => $SupplierRef, 'Supplier_Offer_No' => $SupplierOffer, 'Other_Reference' => $otherRef, 'Fincap' => $finCap, 'InsuranceStatus' => $insurestatus, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $importoption, 'IsQualityChkReqired' => $Qualitycheck, 'BudgetType' => $BudgetType);
|
|
if ($POStatus == 'ST026') {
|
|
$POList['ApprovedOn'] = get_current_date_time();
|
|
$POList['ApprovedBy'] = $this->session->get('userId');
|
|
$POList['ReleasedOn'] = get_current_date_time();
|
|
$POList['ReleasedBy'] = $this->session->get('userId');
|
|
}
|
|
//echo $PONO;
|
|
//echo $TotalOrder;
|
|
//print_r($POList);
|
|
//die();
|
|
|
|
$POMaster = $this->purchaseorder_model->updatePOMaster($PONO, $POList);
|
|
//echo "sdasds";
|
|
$LineItemStatus = REQITEM_NEW;
|
|
|
|
|
|
//echo $LineItemStatus;
|
|
|
|
|
|
|
|
|
|
|
|
if ($PODate == $b4podate) {
|
|
$logpo = array('PONO' => $PONO, 'LineItemNos' => '-', 'UpdateBy' => $CreateBy, 'UpdatedOn' => $updateddt, 'oldValue' => $b4podate, 'newValue' => $PODate, 'entity' => 'PO DateChanged');
|
|
|
|
|
|
$this->purchaseorder_model->insertlogpo($logpo);
|
|
}
|
|
|
|
if (!empty($newSupId[0])) {
|
|
if ($newSupId[0] != $b4supplier) {
|
|
$logpo = array('PONO' => $PONO, 'LineItemNos' => '-', 'UpdateBy' => $CreateBy, 'UpdatedOn' => $updateddt, 'oldValue' => $b4supplier, 'newValue' => $newsup, 'entity' => 'Supplier Changed');
|
|
|
|
|
|
$this->purchaseorder_model->insertlogpo($logpo);
|
|
}
|
|
}
|
|
|
|
|
|
//echo $RowCount;
|
|
for ($i = 1; $i <= $RowCount; $i++) {
|
|
|
|
$MaterialCode = $this->request->getPost('materialCode' . $i);
|
|
|
|
$Quantity = $this->request->getPost('quantity' . $i);
|
|
//echo $Quantity;
|
|
$Reqnumber = $this->request->getPost('Reqnumber' . $i);
|
|
$itemRate = $this->request->getPost('itemRate' . $i);
|
|
/*-----------------------------------*/
|
|
$b4qty = $this->request->getPost('b4qty' . $i);
|
|
$b4rate = $this->request->getPost('b4rate' . $i);
|
|
/*-----------------------------------*/
|
|
//die();
|
|
|
|
//$Exchangerate = $this->request->getPost('Exchangerate'.$i);
|
|
$BasicPriceinmton = $this->request->getPost('BasicPriceInMTon' . $i);
|
|
$Productprice = $this->request->getPost('TotalValue' . $i);
|
|
//echo $ProductPrice;
|
|
//die();
|
|
$LandingCharge = $this->request->getPost('LandingCharge' . $i);
|
|
$AfterLandingCharge = $this->request->getPost('AfterLandingCharge' . $i);
|
|
$HighSeas = $this->request->getPost('HighSeasSalesCharge' . $i);
|
|
$AfterHighSeas = $this->request->getPost('AfterHighSeasSalesCharge' . $i);
|
|
|
|
$CustomDuty = $this->request->getPost('CustomDuty' . $i);
|
|
$AfterCustomDuty = $this->request->getPost('AfterCustomDuty' . $i);
|
|
|
|
$ExciseDuty = $this->request->getPost('ExciseDuty' . $i);
|
|
$AfterExciseDuty = $this->request->getPost('AfterExciseDuty' . $i);
|
|
$ExciseDutyEd = $this->request->getPost('ExciseDutyEdCess' . $i);
|
|
$AfterExciseDutyEd = $this->request->getPost('AfterExciseDutyEdCess' . $i);
|
|
|
|
$ExciseDutySH = $this->request->getPost('ExciseDutySHCess' . $i);
|
|
$AfterExciseDutySH = $this->request->getPost('AfterExciseDutySHCess' . $i);
|
|
|
|
$CustomEd = $this->request->getPost('CustomEdCess' . $i);
|
|
$AfterCustomEd = $this->request->getPost('AfterCustomEdCess1' . $i);
|
|
|
|
$CustomSH = $this->request->getPost('CustomSHCess' . $i);
|
|
$AfterCustomSH = $this->request->getPost('AfterCustomSHCess' . $i);
|
|
|
|
$AddAdtional = $this->request->getPost('AddlExciseDuty' . $i);
|
|
$AfterAddAdtional = $this->request->getPost('AfterAddlExciseDuty' . $i);
|
|
|
|
$Grossdutypayable = $this->request->getPost('Grossdutypayable' . $i);
|
|
//echo $Grossdutypayable;
|
|
//die();
|
|
|
|
$AvailableModvat = $this->request->getPost('AvailableModvat' . $i);
|
|
|
|
$Grossexpensesduetocustomduty = $this->request->getPost('Grossexpensesduetocustomduty' . $i);
|
|
|
|
|
|
$purchaseratePerKG = $this->request->getPost('purchaseratePerKG' . $i);
|
|
|
|
$CustomDutyExpensesPerKG = $this->request->getPost('CustomDutyExpensesPerKG' . $i);
|
|
|
|
$RMCIncludingCustomersPerKG = $this->request->getPost('RMCIncludingCustomersPerKG' . $i);
|
|
|
|
$QuantityKG = $this->request->getPost('QuantityKG' . $i);
|
|
|
|
$POLineItemNo = $this->request->getPost('LineItemNo' . $i);
|
|
|
|
$CostCenter = $this->request->getPost('costCode' . $i);
|
|
|
|
//$ExciseDutySH = $this->request->getPost('ExcisedutySH'.$i);
|
|
$Totalvalueitem = $this->request->getPost('TotalValue' . $i);
|
|
|
|
|
|
|
|
$FreightType = $this->request->getPost('FreightType' . $i);
|
|
$Nosoftrip = $this->request->getPost('NoOfTrip' . $i);
|
|
$FreightRate = $this->request->getPost('FreightValue' . $i);
|
|
$FreightAmount = $this->request->getPost('AfterFreightValue' . $i);
|
|
|
|
|
|
|
|
|
|
|
|
$AssessableValue = $this->request->getPost('AssessableValue' . $i);
|
|
//echo $AssessableValue;
|
|
$Subtotal = $this->request->getPost('SubTotal' . $i);
|
|
$Igst = $this->request->getPost('IGST' . $i);
|
|
$AfterIgst = $this->request->getPost('AfterIGST' . $i);
|
|
$Dutyimpact = $this->request->getPost('DutyImpact' . $i);
|
|
$Clearingcharge = $this->request->getPost('ClearingCharge' . $i);
|
|
$Nettvalue = $this->request->getPost('NetValue' . $i);
|
|
|
|
//echo $FreightAmount;
|
|
|
|
|
|
$specialinstruction = $this->request->getPost('Addinstruction' . $i);
|
|
|
|
$per = $this->request->getPost('Per' . $i);
|
|
// echo $per;
|
|
//die();
|
|
$LineItemNo = '';
|
|
|
|
/*---------start---------------------*/
|
|
|
|
// if(($PODate != $b4podate )||( $SupplierID != $b4supplier) || ($itemRate !=$b4rate) ||
|
|
// ($Quantity != $b4qty ))
|
|
// {
|
|
// $logpo =array('UpdateBy'=>$CreateBy,'UpdatedOn'=>$updateddt);
|
|
|
|
|
|
// $this->purchaseorder_model->updatelogpo($MaterialCode,$POLineItemNo,$logpo);
|
|
// }
|
|
|
|
|
|
|
|
if ($Quantity != $b4qty) {
|
|
$logpo = array('PONO' => $PONO, 'LineItemNos' => $POLineItemNo, 'UpdateBy' => $CreateBy, 'UpdatedOn' => $updateddt, 'oldValue' => $b4qty, 'newValue' => $Quantity, 'entity' => 'Quantity Changed');
|
|
|
|
|
|
$this->purchaseorder_model->insertlogpo($logpo);
|
|
}
|
|
|
|
|
|
if ($itemRate != $b4rate) {
|
|
$logpo = array('PONO' => $PONO, 'LineItemNos' => $POLineItemNo, 'UpdateBy' => $CreateBy, 'UpdatedOn' => $updateddt, 'oldValue' => $b4rate, 'newValue' => $itemRate, 'entity' => 'Rate Changed');
|
|
|
|
|
|
$this->purchaseorder_model->insertlogpo($logpo);
|
|
}
|
|
|
|
/*----------end--------------------*/
|
|
//echo "sdsfsd";
|
|
//die();
|
|
|
|
$currencytypeID = $this->request->getPost('currencytype');
|
|
$SkipInsert = "False";
|
|
if (count($comma_separated) > 0) {
|
|
for ($j = 1; $j < count($comma_separated); $j++) {
|
|
$deletedRow = $comma_separated[$j];
|
|
|
|
if ($deletedRow == $i) {
|
|
$SkipInsert = "True";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/*------------------------------*/
|
|
$ReqDetails = array('Quantity' => $Quantity, 'UpdatedBy' => $CreateBy, 'UpdatedOn' => $updateddt);
|
|
//print_r($ReqDetails);
|
|
|
|
$this->purchaseorder_model->updateReqDetails($Reqnumber, $MaterialCode, $ReqDetails);
|
|
|
|
|
|
/*------------------------------*/
|
|
if ($SkipInsert == "False") {
|
|
if (strlen((string)$POLineItemNo) == 0) {
|
|
$POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CostCenterCode' => $CostCenter, 'Per' => $per, 'ServiceMaterialDescription' => $specialinstruction);
|
|
$POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
|
|
if (count($POLineItem) > 0) {
|
|
$LineItemNo = $POLineItem[0]['LineItemNo'];
|
|
}
|
|
} else {
|
|
|
|
|
|
|
|
$LineItemNo = $POLineItemNo;
|
|
//echo $LineItemNo;
|
|
//die();
|
|
|
|
$POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'UpdatedOn' => $updateddt, 'CostCenterCode' => $CostCenter, 'Per' => $per, 'ServiceMaterialDescription' => $specialinstruction);
|
|
$POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO, $POLineItemNo, $POLineItemList);
|
|
}
|
|
$isExists = $this->purchaseorder_model->LineItemExistsinImportTax($LineItemNo);
|
|
//echo $isExists;
|
|
|
|
//die();
|
|
if (count($isExists) == 0) {
|
|
// print_r(count($isExists));
|
|
//echo $isExists;
|
|
//die();
|
|
$ImportTaxList = array('LineItemNo' => $LineItemNo, 'BasicPriceInMTon' => $BasicPriceinmton, 'ProductPrice' => $Productprice, 'LandingCharge' => $LandingCharge, 'AfterLandingCharge' => $AfterLandingCharge, 'CustomDuty' => $CustomDuty, 'AfterCustomDuty' => $AfterCustomDuty, 'CustomEdCess' => $CustomEd, 'CustomSHCess' => $CustomSH, 'CreatedBy' => $CreateBy, 'UpdatedOn' => $updateddt, 'Grossdutypayable' => $Grossdutypayable, 'CustomDutyExpensesPerKG' => $CustomDutyExpensesPerKG, 'QuantityKG' => $QuantityKG, 'AfterCustomSHCess' => $AfterCustomSH, 'AfterCustomEdCess' => $AfterCustomEd, 'TotalValue' => $Totalvalueitem, 'FreightType' => $FreightType, 'NoOfTrip' => $Nosoftrip, 'FreightValue' => $FreightRate, 'AfterFreightValue' => $FreightAmount, 'AssessableValue' => $AssessableValue, 'SubTotal' => $Subtotal, 'IGST' => $Igst, 'AfterIGST' => $AfterIgst, 'DutyImpact' => $Dutyimpact, 'ClearingCharge' => $Clearingcharge, 'NetValue' => $Nettvalue);
|
|
|
|
|
|
|
|
//print_r($ImportTaxList);
|
|
//die();
|
|
$ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList);
|
|
} else {
|
|
//echo "xxcx";
|
|
//die();
|
|
$ImportTaxList = array('LineItemNo' => $LineItemNo, 'BasicPriceInMTon' => $BasicPriceinmton, 'ProductPrice' => $Productprice, 'LandingCharge' => $LandingCharge, 'AfterLandingCharge' => $AfterLandingCharge, 'CustomDuty' => $CustomDuty, 'AfterCustomDuty' => $AfterCustomDuty, 'CustomEdCess' => $CustomEd, 'CustomSHCess' => $CustomSH, 'CreatedBy' => $CreateBy, 'UpdatedOn' => $updateddt, 'Grossdutypayable' => $Grossdutypayable, 'CustomDutyExpensesPerKG' => $CustomDutyExpensesPerKG, 'QuantityKG' => $QuantityKG, 'AfterCustomSHCess' => $AfterCustomSH, 'AfterCustomEdCess' => $AfterCustomEd, 'TotalValue' => $Totalvalueitem, 'FreightType' => $FreightType, 'NoOfTrip' => $Nosoftrip, 'FreightValue' => $FreightRate, 'AfterFreightValue' => $FreightAmount, 'AssessableValue' => $AssessableValue, 'SubTotal' => $Subtotal, 'IGST' => $Igst, 'AfterIGST' => $AfterIgst, 'DutyImpact' => $Dutyimpact, 'ClearingCharge' => $Clearingcharge, 'NetValue' => $Nettvalue);
|
|
//echo "cxvc ";
|
|
//die();
|
|
//print_r($ImportTaxList);
|
|
//die();
|
|
$this->purchaseorder_model->updateImportTax($LineItemNo, $ImportTaxList);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
echo 'Purchase Order Updated Successfully! PO Number Is: ' . $PONO;
|
|
}
|
|
|
|
|
|
|
|
|
|
/* All Function following This command for FINANCE TEAM PO APPROVAL SCREEN*/
|
|
function poapproval()
|
|
{
|
|
$q = "APPROVAL";
|
|
$this->global['pageTitle'] = 'Purchase Order Approval';
|
|
// $data['Status']= $this->purchaseorder_model->getStatus();
|
|
$userID = $this->session->get('userId');
|
|
//print_r($data['Status']);echo "CON";
|
|
$data['AppList'] = $this->purchaseorder_model->getPOList($q);
|
|
|
|
$this->loadViews("poapproval_view", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
function ApprovePO()
|
|
{
|
|
$StatusCode = Trim($_POST['SCode']);
|
|
|
|
$PONO = Trim($_POST['PONO']);
|
|
$Remarks = Trim($_POST['NewRemarks']);
|
|
|
|
$ApprovedBy = $this->session->get('userId');
|
|
|
|
$ApprovedDate = get_current_date_time();
|
|
|
|
if ($StatusCode == 'ST025') {
|
|
|
|
$store = array('Status' => $StatusCode, 'ApprovedOn' => $ApprovedDate, 'Approvedby' => $ApprovedBy, 'Remarks' => $Remarks);
|
|
$this->purchaseorder_model->UpdatePO($store, $PONO);
|
|
echo "Successfully Approve the Purchase Order No: " . $PONO;
|
|
} else {
|
|
$store = array('Status' => $StatusCode, 'OnHoldOn' => $ApprovedDate, 'OnHoldBy' => $ApprovedBy, 'Remarks' => $Remarks);
|
|
$this->purchaseorder_model->UpdatePO($store, $PONO);
|
|
echo "The Purchase Order No: " . $PONO . "is On Hold";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FOLLOWING CODES FOR PO RELEASE SCREEN FUNCTIONALITIES*/
|
|
|
|
|
|
function porelease()
|
|
{
|
|
|
|
$q = "RELEASE";
|
|
$this->global['pageTitle'] = 'Purchase Order Release';
|
|
// $data['Status']= $this->purchaseorder_model->getStatus();
|
|
$userID = $this->session->get('userId');
|
|
//print_r($data['Status']);echo "CON";
|
|
$data['AppList'] = $this->purchaseorder_model->getPOList($q);
|
|
|
|
$this->loadViews("porelease_view", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
function ReleasePO()
|
|
{
|
|
$StatusCode = Trim($_POST['SCode']);
|
|
|
|
$PONO = Trim($_POST['PONO']);
|
|
$Remarks = Trim($_POST['NewRemarks']);
|
|
|
|
$ReleasedBy = $this->session->get('userId');
|
|
|
|
$ReleasedDate = get_current_date_time();
|
|
|
|
if ($StatusCode == 'ST026') {
|
|
|
|
$store = array('Status' => $StatusCode, 'ReleasedOn' => $ReleasedDate, 'ReleasedBy' => $ReleasedBy, 'Remarks' => $Remarks);
|
|
$this->purchaseorder_model->UpdatePO($store, $PONO);
|
|
// echo "Successfully Released the Purchase Order No: " . $PONO;
|
|
echo "Successfully Approved the Purchase Order No: " . $PONO;
|
|
} else {
|
|
$store = array('Status' => $StatusCode, 'OnHoldOn' => $ReleasedDate, 'OnHoldBy' => $ReleasedBy, 'Remarks' => $Remarks);
|
|
$this->purchaseorder_model->UpdatePO($store, $PONO);
|
|
echo "The Purchase Order No: " . $PONO . "is On Hold";
|
|
}
|
|
}
|
|
/* Add capital Po*/
|
|
function addNewCapitalPurchaseOrder()
|
|
{
|
|
|
|
|
|
$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('txtPoRange');
|
|
|
|
/* $DeliveryOption = $this->request->getPost('DateRange');
|
|
if($DeliveryOption==1){
|
|
$Deliverydt = '';
|
|
$DeliverySchedule = $this->request->getPost('Scheduleby');
|
|
}
|
|
else{
|
|
$Deliverydt = get_date_time_format($dt);
|
|
$DeliverySchedule = '';
|
|
} */
|
|
|
|
$DeliveryOption = $this->request->getPost('DateRange');
|
|
|
|
|
|
$DeliverySchedule = '';
|
|
$Dispatch = '';
|
|
$Deliverydt = '';
|
|
if ($DeliveryOption == 1) {
|
|
$Dispatch = '';
|
|
$Deliverydt = '';
|
|
$DeliverySchedule = $this->request->getPost('Scheduleby');
|
|
} else if ($DeliveryOption == 2) {
|
|
$Deliverydt = '';
|
|
$DeliverySchedule = '';
|
|
$Dispatch = $this->request->getPost('Dispatch');
|
|
} else {
|
|
$Dispatch = '';
|
|
$DeliverySchedule = '';
|
|
$Deliverydt = get_date_time_format($dt);
|
|
}
|
|
$capitalType = $this->request->getPost('capitalType');
|
|
if ($capitalType == 'Domestic') {
|
|
$CapitalRange = '1';
|
|
$ExchangeRateOn = '';
|
|
$ExchangeRate = '';
|
|
$Palaceoforigin = '';
|
|
} else {
|
|
|
|
$CapitalRange = '0';
|
|
$ExchangeRateBeforeFormat = $this->request->getPost('Exchangerateon');
|
|
$ExchangeRateOn = get_date_time_format($ExchangeRateBeforeFormat);
|
|
$ExchangeRate = $this->request->getPost('ExchangeRt');
|
|
$Palaceoforigin = $this->request->getPost('PlaceOforigin');
|
|
}
|
|
$ModeOfShipment = $this->request->getPost('addmodeofshipment');
|
|
$SupplierReference = $this->request->getPost('addsupplierreference');
|
|
$SuppliersOfferNo = $this->request->getPost('addsupplierofferno');
|
|
$OtherReferences = $this->request->getPost('addotherreference');
|
|
$Fincap = $this->request->getPost('addfincap');
|
|
$InsuranceOptions = $this->request->getPost('insuranceStatus');
|
|
$InsuranceNumber = $this->request->getPost('InsuranceNumber');
|
|
$ServiceTypeOptions = $this->request->getPost('PoTypeOptions');
|
|
|
|
$PaymentMethod = $this->request->getPost('PaymentMethod');
|
|
$OtherPayment = $this->request->getPost('Otherpayment');
|
|
|
|
$BudgetType = $this->request->getPost('Budget');
|
|
|
|
|
|
|
|
|
|
$SpcialInstruction = $this->request->getPost('txtSpcialInstruction');
|
|
$TotalOrder = $this->request->getPost('CapitalToatlOrder');
|
|
$POStatus = $this->request->getPost('txtStatus');
|
|
|
|
|
|
$CreateBy = $this->session->get('userId');
|
|
$RowCount = $this->request->getPost('txtRowCount');
|
|
$DeletedRow = $this->request->getPost('txtDeletedRow');
|
|
$comma_separated = ($DeletedRow !== null && is_string($DeletedRow))
|
|
? explode(':', $DeletedRow)
|
|
: [];
|
|
|
|
$createddt = get_current_date_time();
|
|
$currencytypeID = $this->request->getPost('currencytype');
|
|
|
|
$Qualitycheck = 1;
|
|
|
|
$IsOpenOrder = ($this->request->getPost('IsOpenOrder') !== null && !empty($this->request->getPost('IsOpenOrder')) && $this->request->getPost('IsOpenOrder') === '1') ? $this->request->getPost('IsOpenOrder') : null;
|
|
|
|
$lastPONO = $this->purchaseorder_model->lastPONO();
|
|
$newPONO = generate_po_number($lastPONO);
|
|
|
|
$POList = array('PONO'=>$newPONO,'SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrder, 'PODate' => $PODate, 'Status' => $POStatus, 'PORange' => $PoRange, 'ExchangeRateCalculatedon' => $ExchangeRateOn, 'ExchangeRate' => $ExchangeRate, 'PaymentTerms' => $PaymentMethod, 'ServiceDescription' => $SpcialInstruction, 'CreatedBy' => $CreateBy, 'DeliveryAddress' => $DeliveryAddr, 'CreatedDate' => $createddt, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'CapitalRange' => $CapitalRange, 'POType' => $POType, 'CurrencyType' => $currencytypeID, 'DeliverySchedule' => $DeliverySchedule, 'Import_PlaceofOrgin' => $Palaceoforigin, 'Import_DispatchDetails' => $Dispatch, 'DeliveryDate' => $Deliverydt, 'PaymentOtherDescription' => $OtherPayment, 'Supplier_Reference' => $SupplierReference, 'Mode_Of_Shipment' => $ModeOfShipment, 'Supplier_Offer_No' => $SuppliersOfferNo, 'Other_Reference' => $OtherReferences, 'Fincap' => $Fincap, 'InsuranceStatus' => $InsuranceOptions, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $ServiceTypeOptions, 'IsQualityChkReqired' => $Qualitycheck, 'BudgetType' => $BudgetType,'IsOpenOrder'=>$IsOpenOrder);
|
|
|
|
// $POList = array('SupplierID'=>$SupplierID, '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);
|
|
|
|
|
|
$POMaster = $this->purchaseorder_model->addPOMaster($POList, $POType, $ServiceTypeOptions);
|
|
$PONO = $POMaster ? $newPONO : "";
|
|
// $PONO = '';
|
|
// if (count($POMaster) > 0) {
|
|
// $PONO = $POMaster[0]['PONO'];
|
|
// }
|
|
|
|
$LineItemStatus = REQITEM_NEW;
|
|
|
|
for ($i = 1; $i <= $RowCount; $i++) {
|
|
|
|
$MaterialCode = $this->request->getPost('materialCode' . $i);
|
|
$Quantity = $this->request->getPost('quantity' . $i);
|
|
$Reqnumber = $this->request->getPost('Reqnumber' . $i);
|
|
$itemRate = $this->request->getPost('itemRate' . $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);
|
|
|
|
|
|
|
|
$QuantityKG = $this->request->getPost('PurQuantity' . $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);
|
|
|
|
$Totalvalueitem = $this->request->getPost('PerKgExpense' . $i);
|
|
|
|
//echo $BasicPriceinmton;
|
|
$CostCenter = $this->request->getPost('CPCostCode' . $i);
|
|
|
|
$TotalOrderValue = $this->request->getPost('basicvalInINR' . $i);
|
|
$Cgst = $this->request->getPost('Cgst' . $i);
|
|
$Sgst = $this->request->getPost('Sgst' . $i);
|
|
$Igst = $this->request->getPost('Igst' . $i);
|
|
$AfterCgst = $this->request->getPost('AfterCgst' . $i);
|
|
$AfterSgst = $this->request->getPost('AfterSgst' . $i);
|
|
$AfterIgst = $this->request->getPost('AfterIgst' . $i);
|
|
$DiscountType = $this->request->getPost('DisType' . $i);
|
|
$DiscountValue = $this->request->getPost('DisVal' . $i);
|
|
$AfterDiscount = $this->request->getPost('AfterDisVal' . $i);
|
|
$OtherAmt = $this->request->getPost('OtherAmt' . $i);
|
|
|
|
$FreightTypeloc = $this->request->getPost('FreightTypeloc' . $i);
|
|
$FreightNoofTriploc = $this->request->getPost('NoofTriploc' . $i);
|
|
$Freightrateloc = $this->request->getPost('FreightRateloc' . $i);
|
|
$FreightAmountloc = $this->request->getPost('AfterFreightRateloc' . $i);
|
|
|
|
$AssessableValue = $this->request->getPost('AfterAssessable' . $i);
|
|
$SubTotal = $this->request->getPost('Subtotal' . $i);
|
|
$IGST = $this->request->getPost('IgstInt' . $i);
|
|
$AfterIGST = $this->request->getPost('AfterIgstInt' . $i);
|
|
$DutyImpact = $this->request->getPost('Dutyimpact' . $i);
|
|
$NetValue = $this->request->getPost('Nett' . $i);
|
|
$ClearingCharge = $this->request->getPost('ClearingCharges' . $i);
|
|
|
|
$CustomDutyExpensesPerKG = $this->request->getPost('CustomDutyExpenses' . $i);
|
|
|
|
|
|
|
|
|
|
$TaxtotalOrderValue = $itemRate * $Quantity + $OtherAmt + $AfterCgst + $AfterSgst + $AfterIgst - $AfterDiscount;
|
|
|
|
$CapitalItemDescription = $this->request->getPost('CapitalItemDescrition' . $i);
|
|
$Per = $this->request->getPost('per' . $i);
|
|
$SkipInsert = "False";
|
|
if (count($comma_separated) > 0) {
|
|
for ($j = 1; $j < count($comma_separated); $j++) {
|
|
$deletedRow = $comma_separated[$j];
|
|
|
|
if ($deletedRow == $i) {
|
|
$SkipInsert = "True";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if ($SkipInsert == "False") {
|
|
$POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CostCenterCode' => $CostCenter, 'ServiceMaterialDescription' => $CapitalItemDescription, 'Per' => $Per);
|
|
|
|
$POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
|
|
|
|
$LineItemNo = '';
|
|
if (count($POLineItem) > 0) {
|
|
$LineItemNo = $POLineItem[0]['LineItemNo'];
|
|
}
|
|
|
|
/* --------------------------------------------*/
|
|
|
|
// $logpo =array('PONO'=>$PONO,'Date'=>$PODate,'POType'=>$POType,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=> $itemRate,'SupplierID'=>$SupplierID,'LineItemNos'=>$LineItemNo);
|
|
// $this->purchaseorder_model->newlogpo($logpo);
|
|
/* --------------------------------------------*/
|
|
if (trim((string)$POType) == CAPITAL) {
|
|
if ($CapitalRange == '1') {
|
|
$ServiceTaxList = array('LineItemNo' => $LineItemNo, 'CGST' => $Cgst, 'After_CGST' => $AfterCgst, 'SGST' => $Sgst, 'After_SGST' => $AfterSgst, 'IGST' => $Igst, 'After_IGST' => $AfterIgst, 'otherallowance' => $OtherAmt, 'TotalValue' => $TaxtotalOrderValue, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'discount' => $DiscountType, 'discountval' => $DiscountValue, 'Afterdiscountval' => $AfterDiscount, 'FreightType' => $FreightTypeloc, 'NoOfTrip' => $FreightNoofTriploc, 'FreightValue' => $Freightrateloc, 'AfterFreightValue' => $FreightAmountloc);
|
|
|
|
|
|
|
|
|
|
|
|
$ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList);
|
|
}
|
|
if ($CapitalRange == '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, 'QuantityKG' => $QuantityKG, 'AfterCustomSHCess' => $AfterCustomSH, 'AfterCustomEdCess' => $AfterCustomEd, 'TotalValue' => $Totalvalueitem, 'FreightType' => $FreightType, 'NoOfTrip' => $NOOfTrip, 'FreightValue' => $FreightValue, 'AfterFreightValue' => $AfterFreightValue, 'AssessableValue' => $AssessableValue, 'SubTotal' => $SubTotal, 'IGST' => $IGST, 'AfterIGST' => $AfterIGST, 'DutyImpact' => $DutyImpact, 'NetValue' => $NetValue, 'ClearingCharge' => $ClearingCharge, 'CustomDutyExpensesPerKG' => $CustomDutyExpensesPerKG);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
echo 'Purchase Order Created Successfully! PO Number Is: ' . $PONO;
|
|
}
|
|
|
|
|
|
|
|
/*Edit Capital po*/
|
|
function EditCapitalPurchaseOrder()
|
|
{
|
|
|
|
|
|
$PONO = $this->request->getPost('txtPONO');
|
|
$POdt = $this->request->getPost('PODate');
|
|
$PODate = get_date_time_format($POdt);
|
|
$SupplierID = $this->request->getPost('drpSupplier');
|
|
|
|
|
|
$newsup = (string)$this->request->getPost('newsup');
|
|
// $newSupId = split("[ - ]+", $newsup);
|
|
$newSupId = preg_split('[-]', $newsup);
|
|
|
|
|
|
|
|
$DeliveryAddr = $this->request->getPost('DeliveryAddr');
|
|
$dt = $this->request->getPost('Deliverydate');
|
|
|
|
$POType = $this->request->getPost('POType');
|
|
$PoRange = $this->request->getPost('txtPoRange');
|
|
|
|
/* $DeliveryOption = $this->request->getPost('DateRange');
|
|
if($DeliveryOption==1){
|
|
$Deliverydt = '';
|
|
$DeliverySchedule = $this->request->getPost('Scheduleby');
|
|
}
|
|
else{
|
|
//$Deliverydt = get_date_time_format($dt);
|
|
$Deliverydt = '';
|
|
$DeliverySchedule = '';
|
|
} */
|
|
/*-----------------------------------*/
|
|
$b4supplier = $this->request->getPost('b4supplier');
|
|
$b4date = $this->request->getPost('b4podate');
|
|
$b4podate = get_date_time_format($b4date);
|
|
/*-----------------------------------*/
|
|
|
|
$DeliveryOption = $this->request->getPost('DateRange');
|
|
|
|
$DeliverySchedule = '';
|
|
$Dispatch = '';
|
|
$Deliverydt = '';
|
|
if ($DeliveryOption == 1) {
|
|
$Dispatch = '';
|
|
$Deliverydt = '';
|
|
$DeliverySchedule = $this->request->getPost('Scheduleby');
|
|
} else if ($DeliveryOption == 2) {
|
|
$Deliverydt = '';
|
|
$DeliverySchedule = '';
|
|
$Dispatch = $this->request->getPost('Dispatch');
|
|
} else {
|
|
$Dispatch = '';
|
|
$DeliverySchedule = '';
|
|
$Deliverydt = get_date_time_format($dt);
|
|
}
|
|
|
|
|
|
|
|
$capitalType = $this->request->getPost('capitalType');
|
|
$currencytypeID = $this->request->getPost('currencytype');
|
|
if ($capitalType == '1') {
|
|
$CapitalRange = '1';
|
|
$ExchangeRateOn = '';
|
|
$ExchangeRate = '';
|
|
} else {
|
|
|
|
$CapitalRange = '0';
|
|
$ExchangeRateBeforeFormat = $this->request->getPost('Exchangerateon');
|
|
$ExchangeRateOn = get_date_time_format($ExchangeRateBeforeFormat);
|
|
$ExchangeRate = $this->request->getPost('ExchangeRt');
|
|
}
|
|
$PaymentMethod = $this->request->getPost('PaymentMethod');
|
|
$OtherPayment = $this->request->getPost('Otherpayment');
|
|
|
|
|
|
|
|
$SpcialInstruction = $this->request->getPost('txtSpcialInstruction');
|
|
$TotalOrder = $this->request->getPost('CapitalToatlOrder');
|
|
$POStatus = $this->request->getPost('txtStatus');
|
|
$Palaceoforigin = $this->request->getPost('PlaceOforigin');
|
|
$ModeOfShipment = $this->request->getPost('editmodeofshipment');
|
|
$SupplierReference = $this->request->getPost('editsupplierreference');
|
|
$SuppliersOfferNo = $this->request->getPost('editsupplierofferno');
|
|
$OtherReferences = $this->request->getPost('editotherreference');
|
|
$Fincap = $this->request->getPost('editfincap');
|
|
$InsuranceOptions = $this->request->getPost('insuranceStatus');
|
|
$InsuranceNumber = $this->request->getPost('InsuranceNumber');
|
|
$ServiceTypeOptions = $this->request->getPost('PoTypeOptions');
|
|
|
|
$BudgetType = $this->request->getPost('Budget');
|
|
|
|
$CreateBy = $this->session->get('userId');
|
|
$RowCount = $this->request->getPost('txtRowCount');
|
|
|
|
$DeletedRow = $this->request->getPost('txtDeletedRow');
|
|
$comma_separated = ($DeletedRow !== null && is_string($DeletedRow))
|
|
? explode(':', $DeletedRow)
|
|
: [];
|
|
|
|
|
|
$createddt = get_current_date_time();
|
|
$updateddt = get_current_date_time();
|
|
$Qualitycheck = 1;
|
|
|
|
|
|
$POList = array('SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrder, 'PODate' => $PODate, 'Status' => $POStatus, 'PORange' => $PoRange, 'ExchangeRate' => $ExchangeRate, 'ExchangeRateCalculatedon' => $ExchangeRateOn, 'PaymentTerms' => $PaymentMethod, 'ServiceDescription' => $SpcialInstruction, 'CreatedBy' => $CreateBy, 'DeliveryAddress' => $DeliveryAddr, 'CreatedDate' => $createddt, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'CurrencyType' => $currencytypeID, 'DeliverySchedule' => $DeliverySchedule, 'Import_PlaceofOrgin' => $Palaceoforigin, 'Import_DispatchDetails' => $Dispatch, 'DeliveryDate' => $Deliverydt, 'PaymentOtherDescription' => $OtherPayment, 'Supplier_Reference' => $SupplierReference, 'Mode_Of_Shipment' => $ModeOfShipment, 'Supplier_Offer_No' => $SuppliersOfferNo, 'Other_Reference' => $OtherReferences, 'Fincap' => $Fincap, 'InsuranceStatus' => $InsuranceOptions, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $ServiceTypeOptions, 'IsQualityChkReqired' => $Qualitycheck, 'BudgetType' => $BudgetType);
|
|
if ($POStatus == 'ST026') {
|
|
$POList['ApprovedOn'] = get_current_date_time();
|
|
$POList['ApprovedBy'] = $this->session->get('userId');
|
|
$POList['ReleasedOn'] = get_current_date_time();
|
|
$POList['ReleasedBy'] = $this->session->get('userId');
|
|
}
|
|
|
|
$POMaster = $this->purchaseorder_model->updatePOMaster($PONO, $POList);
|
|
|
|
$LineItemStatus = REQITEM_NEW;
|
|
|
|
|
|
if ($PODate != $b4podate) {
|
|
$logpo = array('PONO' => $PONO, 'LineItemNos' => '-', 'UpdateBy' => $CreateBy, 'UpdatedOn' => $updateddt, 'oldValue' => $b4podate, 'newValue' => $PODate, 'entity' => 'PO DateChanged');
|
|
|
|
|
|
$this->purchaseorder_model->insertlogpo($logpo);
|
|
}
|
|
|
|
if (!empty($newSupId[0])) {
|
|
if ($newSupId[0] != $b4supplier) {
|
|
|
|
$logpo = array('PONO' => $PONO, 'LineItemNos' => '-', 'UpdateBy' => $CreateBy, 'UpdatedOn' => $updateddt, 'oldValue' => $b4supplier, 'newValue' => $newsup, 'entity' => 'Supplier Changed');
|
|
|
|
|
|
$this->purchaseorder_model->insertlogpo($logpo);
|
|
}
|
|
}
|
|
|
|
for ($i = 1; $i <= $RowCount; $i++) {
|
|
|
|
$MaterialCode = $this->request->getPost('materialCode' . $i);
|
|
$Quantity = $this->request->getPost('quantity' . $i);
|
|
$Reqnumber = $this->request->getPost('Reqnumber' . $i);
|
|
$itemRate = $this->request->getPost('itemRate' . $i);
|
|
/*-----------------------------------*/
|
|
$b4qty = $this->request->getPost('b4qty' . $i);
|
|
$b4rate = $this->request->getPost('b4rate' . $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);
|
|
|
|
|
|
$CustomDutyExpensesPerKG = $this->request->getPost('CustomDutyExpenses' . $i);
|
|
|
|
$QuantityKG = $this->request->getPost('PurQuantity' . $i);
|
|
|
|
|
|
|
|
$AssessableValue = $this->request->getPost('AssessableValue' . $i);
|
|
$SubTotal = $this->request->getPost('SubTotal' . $i);
|
|
$IGST = $this->request->getPost('IGSTInt' . $i);
|
|
$AfterIGST = $this->request->getPost('AfterIGSTInt' . $i);
|
|
$DutyImpact = $this->request->getPost('DutyImpact' . $i);
|
|
$NetValue = $this->request->getPost('NetValue' . $i);
|
|
$ClearingCharge = $this->request->getPost('ClearingCharge' . $i);
|
|
|
|
|
|
$Totalvalueitem = $this->request->getPost('PerKgExpense' . $i);
|
|
|
|
//echo $BasicPriceinmton;
|
|
$CostCenter = $this->request->getPost('CPCostCode' . $i);
|
|
|
|
$TotalOrderValue = $this->request->getPost('basicvalInINR' . $i);
|
|
|
|
|
|
$POLineItemNo = $this->request->getPost('LineItemNo' . $i);
|
|
$Cgst = $this->request->getPost('Cgst' . $i);
|
|
$Sgst = $this->request->getPost('Sgst' . $i);
|
|
$Igst = $this->request->getPost('Igst' . $i);
|
|
$AfterCgst = $this->request->getPost('AfterCgst' . $i);
|
|
$AfterSgst = $this->request->getPost('AfterSgst' . $i);
|
|
$AfterIgst = $this->request->getPost('AfterIgst' . $i);
|
|
|
|
$OtherAmt = $this->request->getPost('OtherAmt' . $i);
|
|
$DiscountType = $this->request->getPost('DisType' . $i);
|
|
$DiscountValue = $this->request->getPost('DisVal' . $i);
|
|
$AfterDiscount = $this->request->getPost('AfterDisVal' . $i);
|
|
$TaxtotalOrderValue = $itemRate * $Quantity + $OtherAmt + $AfterCgst + $AfterSgst + $AfterIgst - $AfterDiscount;
|
|
|
|
|
|
$OtherAmt = $this->request->getPost('OtherAmt' . $i);
|
|
$CapitalItemDescription = $this->request->getPost('CapitalItemDescrition' . $i);
|
|
$Per = $this->request->getPost('per' . $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);
|
|
|
|
|
|
|
|
|
|
$FreightTypeloc = $this->request->getPost('Ftype' . $i);
|
|
$FreightNoofTriploc = $this->request->getPost('NoTrip' . $i);
|
|
$Freightrateloc = $this->request->getPost('Fvalue' . $i);
|
|
$FreightAmountloc = $this->request->getPost('Afvalue' . $i);
|
|
|
|
// echo $FreightTypeloc;
|
|
// echo 'n';
|
|
// echo $FreightNoofTriploc;
|
|
// echo 'n';
|
|
// echo $Freightrateloc;
|
|
// echo 'n';
|
|
// echo $FreightAmountloc;
|
|
|
|
// die();
|
|
|
|
/*---------start---------------------*/
|
|
|
|
// if(($PODate != $b4podate )||( $SupplierID != $b4supplier) || ($itemRate !=$b4rate) ||
|
|
// ($Quantity != $b4qty ))
|
|
// {
|
|
// $logpo =array('UpdateBy'=>$CreateBy,'UpdatedOn'=>$updateddt);
|
|
|
|
|
|
// $this->purchaseorder_model->updatelogpo($MaterialCode,$POLineItemNo,$logpo);
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($Quantity != $b4qty) {
|
|
$logpo = array('PONO' => $PONO, 'LineItemNos' => $POLineItemNo, 'UpdateBy' => $CreateBy, 'UpdatedOn' => $updateddt, 'oldValue' => $b4qty, 'newValue' => $Quantity, 'entity' => 'Quantity Changed');
|
|
|
|
|
|
$this->purchaseorder_model->insertlogpo($logpo);
|
|
}
|
|
|
|
|
|
if ($itemRate != $b4rate) {
|
|
$logpo = array('PONO' => $PONO, 'LineItemNos' => $POLineItemNo, 'UpdateBy' => $CreateBy, 'UpdatedOn' => $updateddt, 'oldValue' => $b4rate, 'newValue' => $itemRate, 'entity' => 'Rate Changed');
|
|
|
|
|
|
$this->purchaseorder_model->insertlogpo($logpo);
|
|
}
|
|
|
|
/*----------end--------------------*/
|
|
|
|
|
|
$SkipInsert = "False";
|
|
if (count($comma_separated) > 0) {
|
|
for ($j = 1; $j < count($comma_separated); $j++) {
|
|
$deletedRow = $comma_separated[$j];
|
|
|
|
if ($deletedRow == $i) {
|
|
$SkipInsert = "True";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/*------------------------------*/
|
|
$ReqDetails = array('Quantity' => $Quantity, 'UpdatedBy' => $CreateBy, 'UpdatedOn' => $updateddt);
|
|
//print_r($ReqDetails);
|
|
|
|
$this->purchaseorder_model->updateReqDetails($Reqnumber, $MaterialCode, $ReqDetails);
|
|
|
|
|
|
|
|
/*------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($SkipInsert == "False") {
|
|
if (strlen((string)$POLineItemNo) == 0) {
|
|
$POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CostCenterCode' => $CostCenter, 'ServiceMaterialDescription' => $CapitalItemDescription, 'Per' => $Per);
|
|
|
|
$POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
|
|
|
|
$LineItemNo = '';
|
|
if (count($POLineItem) > 0) {
|
|
$LineItemNo = $POLineItem[0]['LineItemNo'];
|
|
}
|
|
|
|
|
|
if (trim((string)$POType) == CAPITAL) {
|
|
if ($capitalType == '1') {
|
|
$ServiceTaxList = array('LineItemNo' => $LineItemNo, 'FreightType' => $FreightTypeloc, 'NoOfTrip' => $FreightNoofTriploc, 'FreightValue' => $Freightrateloc, 'AfterFreightValue' => $FreightAmountloc, 'CGST' => $Cgst, 'After_CGST' => $AfterCgst, 'SGST' => $Sgst, 'After_SGST' => $AfterSgst, 'IGST' => $Igst, 'After_IGST' => $AfterIgst, 'otherallowance' => $OtherAmt, 'TotalValue' => $TaxtotalOrderValue, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'discount' => $DiscountType, 'discountval' => $DiscountValue, 'Afterdiscountval' => $AfterDiscount);
|
|
|
|
$ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList);
|
|
}
|
|
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' => $AssessableValue, 'SubTotal' => $SubTotal, 'IGST' => $IGST,
|
|
'AfterIGST' => $AfterIGST, 'DutyImpact' => $DutyImpact, 'NetValue' => $NetValue, 'ClearingCharge' => $ClearingCharge
|
|
);
|
|
|
|
$ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList);
|
|
}
|
|
}
|
|
} else {
|
|
$LineItemNo = $POLineItemNo;
|
|
|
|
|
|
|
|
$POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CostCenterCode' => $CostCenter, 'ServiceMaterialDescription' => $CapitalItemDescription, 'Per' => $Per);
|
|
$POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO, $LineItemNo, $POLineItemList);
|
|
if ($capitalType == '1') {
|
|
$ServiceTaxList = array('CGST' => $Cgst, 'After_CGST' => $AfterCgst, 'SGST' => $Sgst, 'After_SGST' => $AfterSgst, 'IGST' => $Igst, 'After_IGST' => $AfterIgst, 'otherallowance' => $OtherAmt, 'TotalValue' => $TaxtotalOrderValue, 'UpdateBY' => $CreateBy, 'UpdatedOn' => $createddt, 'discount' => $DiscountType, 'discountval' => $DiscountValue, 'Afterdiscountval' => $AfterDiscount, 'FreightType' => $FreightTypeloc, 'NoOfTrip' => $FreightNoofTriploc, 'FreightValue' => $Freightrateloc, 'AfterFreightValue' => $FreightAmountloc);
|
|
|
|
$ServiceTax = $this->purchaseorder_model->updateServiceTax($LineItemNo, $ServiceTaxList);
|
|
}
|
|
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' => $AssessableValue, 'SubTotal' => $SubTotal, 'IGST' => $IGST,
|
|
'AfterIGST' => $AfterIGST, 'DutyImpact' => $DutyImpact, 'NetValue' => $NetValue, 'ClearingCharge' => $ClearingCharge
|
|
);
|
|
|
|
|
|
$ImportList = $this->purchaseorder_model->updateImportTax($LineItemNo, $ImportTaxList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
echo 'Purchase Order Updated Successfully! PO Number Is: ' . $PONO;
|
|
}
|
|
|
|
|
|
/* capital po print/pdf*/
|
|
|
|
public function CapitalPoPrint($PONO)
|
|
{
|
|
|
|
$PoStatus = '';
|
|
$data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO);
|
|
// Load the pdf page with multiviews
|
|
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformationforPDF();
|
|
$data['GetPoFormat'] = $this->purchaseorder_model->GetPoFormat($PONO);
|
|
$data['POItem'] = $this->purchaseorder_model->GetCapitalPurchaseOrderDetailsForPDF($PONO);
|
|
$data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO);
|
|
$data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO);
|
|
|
|
$CurrencyType = '';
|
|
$CapitalRange = 1;
|
|
if (!empty($data['POItem'])) {
|
|
$CurrencyType = $data['POItem'][0]->CurrencyType;
|
|
$CapitalRange = $data['POItem'][0]->CapitalRange;
|
|
$PoStatus = $data['POItem'][0]->Status;
|
|
}
|
|
|
|
|
|
if ($CurrencyType == '' or $CurrencyType == '0') {
|
|
$data['CurrencySymbol'] = $this->purchaseorder_model->GerCurrencyCodeName('INR');
|
|
|
|
$TotalOrderValue = $data['POItem'][0]->TotalOrderValue;
|
|
|
|
// $totalAmt=sprintf("%.2f", $TotalOrderValue);
|
|
|
|
// $data['TotalAmountInWords']= $this->convertNumber($totalAmt);
|
|
// }
|
|
|
|
$AdvanceAmount = 0.0;
|
|
|
|
foreach ($data['POItem'] as $POI) {
|
|
$AdvanceAmount = $POI->AdvanceAmount;
|
|
}
|
|
|
|
$TotaltoPay = $TotalOrderValue - $AdvanceAmount;
|
|
$totalAmt = sprintf("%.2f", $TotalOrderValue);
|
|
$data['TotalAmountInWords'] = $this->convertNumber($totalAmt);
|
|
} else {
|
|
$data['CurrencySymbol'] = $this->purchaseorder_model->GerCurrencyCodeName($CurrencyType);
|
|
$SymbolCurrency = $data['CurrencySymbol'][0]->FontCode2000;
|
|
$SymbolCurrencyName = $data['CurrencySymbol'][0]->Currency;
|
|
$PaiseVal = $data['CurrencySymbol'][0]->PaiseVal;
|
|
|
|
$TotalOrderValue = $data['POItem'][0]->TotalOrderValue;
|
|
foreach ($data['POItem'] as $POI) {
|
|
$AdvanceAmount = $POI->AdvanceAmount;
|
|
}
|
|
$TotaltoPay = $TotalOrderValue - $AdvanceAmount;
|
|
$totalAmt = sprintf("%.2f", $TotaltoPay);
|
|
|
|
$data['TotalAmountInWords'] = $this->convertNumberSymbol($totalAmt, $SymbolCurrency, $SymbolCurrencyName, $PaiseVal);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO);
|
|
if ($CapitalRange != '') {
|
|
$data['TaxListDetails'] = $this->purchaseorder_model->GetCapitalTaxListDetails($PONO, $CapitalRange);
|
|
}
|
|
|
|
|
|
|
|
// view("capitalpopdf", $data);
|
|
|
|
// Add header to pdf
|
|
//view('includes/pdffooter');
|
|
|
|
// Get output html
|
|
// $php = $this->output->get_output();
|
|
|
|
// Load library
|
|
// $this->load->library('dompdf_gen');
|
|
// $paper_orientation = 'portrait';
|
|
// $customPaper = array(0,0,750,950);
|
|
// $this->dompdf->set_paper($customPaper,$paper_orientation);
|
|
|
|
// Convert to PDF
|
|
// $this->dompdf->load_html($php);
|
|
// $this->dompdf->render();
|
|
// $data['Attachment'] = FALSE;
|
|
// $this->dompdf->stream("CapitalPOReport".$PONO.".pdf",$data,$php);
|
|
|
|
|
|
|
|
$mpdf = new Mpdf([
|
|
'mode' => 'utf-8',
|
|
'format' => 'A4-P', // Page format: A4 with portrait orientation
|
|
// 'format' => [148, 210], // Set custom width and height in millimeters
|
|
'default_font_size' => 6,
|
|
'default_font' => 'sans-serif',
|
|
'margin_left' => 10,
|
|
'margin_right' => 10,
|
|
'margin_top' => 10,
|
|
'margin_bottom' => 10,
|
|
'margin_header' => 82,
|
|
'margin_footer' => 38,
|
|
'orientation' => 'P',
|
|
]);
|
|
|
|
// Set watermark
|
|
if ($PoStatus == PO_RELEASED || $PoStatus == PO_SERVICE_COMPLETED || $PoStatus == MRIR_APPROVED || $PoStatus == MRIR_REJECTED || $PoStatus == IGR_CREATED || $PoStatus == '' || $PoStatus == SPECIAL_PO) {
|
|
$mpdf->SetWatermarkText('');
|
|
} else {
|
|
$mpdf->SetWatermarkText('DRAFT');
|
|
}
|
|
$mpdf->SetWatermarkImage('.public/assets/images/mpdf.png', 8, 10);
|
|
$mpdf->showWatermarkImage = true;
|
|
$mpdf->watermark_font = 'DejaVuSansCondensed';
|
|
$mpdf->showWatermarkText = true;
|
|
|
|
// Set HTML header
|
|
$HtmlHeading = view('includes/pdfheader', $data);
|
|
$mpdf->SetHTMLHeader($HtmlHeading);
|
|
|
|
// Set HTML footer
|
|
$HTMLFooter = view('includes/pdffooter', $data);
|
|
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
|
|
|
|
// Set auto margins
|
|
$mpdf->setAutoTopMargin = 'stretch';
|
|
$mpdf->setAutoBottomMargin = 'stretch';
|
|
|
|
// Generate PDF content
|
|
$html = view('capitalpopdf', $data);
|
|
|
|
|
|
// Write HTML content to PDF
|
|
$mpdf->WriteHTML($html);
|
|
$mpdf->SetDisplayMode('fullpage');
|
|
// Output PDF
|
|
$mpdf->Output('CapitalPOReport' . $PONO . '.pdf', 'I');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*This function is used to convert amount(digit) into words*/
|
|
|
|
public function convertNumber($amt)
|
|
{
|
|
//echo $amt;die();
|
|
$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' => 'fourty', '50' => 'fifty',
|
|
'60' => 'sixty', '70' => 'seventy',
|
|
'80' => 'eighty', '90' => 'ninety', '06' => 'Zero Six', '01' => 'Zero One', '02' => 'Zero Two', '03' => 'Zero Three', '04' => 'Zero Four', '05' => 'Zero Five', '07' => 'Zero Seven', '08' => 'Zero Eight', '09' => 'Zero Nine'
|
|
);
|
|
$words1 = array(
|
|
'2' => 'twenty',
|
|
'3' => 'thirty', '4' => 'fourty',
|
|
'5' => 'fifty', '6' => 'sixty', '7' => 'seventy',
|
|
'8' => 'eighty', '9' => 'ninety'
|
|
);
|
|
$words12 = array(
|
|
'11' => 'eleven',
|
|
'12' => 'twelve', '13' => 'thirteen', '14' => 'fourteen',
|
|
'15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen',
|
|
'18' => 'eighteen', '19' => 'nineteen', '20' => 'twenty',
|
|
);
|
|
$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 > 1) ? 's' : null;
|
|
//print_r($plural);
|
|
$hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
|
|
//print_r($hundred);
|
|
$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);
|
|
if ($point >= 1 && $point <= 10) {
|
|
$points = ($point) ?
|
|
" " . $words[$point] : " ";
|
|
} else if ($point >= 11 && $point <= 20) {
|
|
$points = ($point) ?
|
|
" " . $words12[$point] : " ";
|
|
} else {
|
|
$points = ($point) ?
|
|
" " . $words1[$point / 10] . " " .
|
|
$words[$point = $point % 10] : '';
|
|
}
|
|
|
|
if ($ShowPaise == '0') {
|
|
|
|
$amountInWords = "Rupees " . $result . " Only";
|
|
} else {
|
|
|
|
$amountInWords = "Rupees " . $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' => 'fourty', '50' => 'fifty',
|
|
'60' => 'sixty', '70' => 'seventy',
|
|
'80' => 'eighty', '90' => 'ninety'
|
|
);
|
|
$words1 = array(
|
|
'2' => 'twenty',
|
|
'3' => 'thirty', '4' => 'fourty',
|
|
'5' => 'fifty', '6' => 'sixty', '7' => 'seventy',
|
|
'8' => 'eighty', '9' => 'ninety'
|
|
);
|
|
$words12 = array(
|
|
'11' => 'eleven',
|
|
'12' => 'twelve', '13' => 'thirteen', '14' => 'fourteen',
|
|
'15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen',
|
|
'18' => 'eighteen', '19' => 'nineteen', '20' => 'twenty',
|
|
);
|
|
$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 > 1) ? 's' : null;
|
|
//print_r($plural);
|
|
$hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
|
|
//print_r($hundred);
|
|
$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);
|
|
if ($point >= 1 && $point <= 10) {
|
|
$points = ($point) ?
|
|
" " . $words[$point] : " ";
|
|
} else if ($point >= 11 && $point <= 20) {
|
|
$points = ($point) ?
|
|
" " . $words12[$point] : " ";
|
|
} else {
|
|
$points = ($point) ?
|
|
" " . $words1[$point / 10] . " " .
|
|
$words[$point = $point % 10] : '';
|
|
}
|
|
|
|
if ($ShowPaise == '0') {
|
|
$amountInWords = $name . " " . $result . " Only";
|
|
} else {
|
|
$amountInWords = $name . " " . $result . $paise . " " . $points . " Only";
|
|
}
|
|
|
|
|
|
return $amountInWords;
|
|
}
|
|
|
|
|
|
|
|
function addadvancerequest()
|
|
{
|
|
|
|
$PONO = $this->request->getPost('PONO');
|
|
$AdvancePercentage = $this->request->getPost('AdvanceIn');
|
|
$AdvanceAmount = $this->request->getPost('AdvanceAmount');
|
|
$Remarks = $this->request->getPost('Remarks');
|
|
|
|
$createddt = get_current_date_time();
|
|
$CreateBy = $this->session->get('userId');
|
|
|
|
$isExists = $this->purchaseorder_model->PONOExists($PONO);
|
|
|
|
if (count($isExists) == 0) {
|
|
|
|
$advance = array('PONO' => $PONO, 'AdvancePercentage' => $AdvancePercentage, 'AdvanceAmount' => $AdvanceAmount, 'Remarks' => $Remarks, 'CreatedBy' => $CreateBy, 'CreatedDt' => $createddt);
|
|
$this->purchaseorder_model->addadvanceRequest($advance);
|
|
} else {
|
|
$advance = array('AdvancePercentage' => $AdvancePercentage, 'AdvanceAmount' => $AdvanceAmount, 'Remarks' => $Remarks);
|
|
$this->purchaseorder_model->updateadvanceRequest($advance, $PONO);
|
|
}
|
|
|
|
|
|
if ($advance > 0) {
|
|
// $this->session->set_flashdata('success', 'New Asset created successfully');
|
|
echo "<script>alert('Advance Request Created successfully!');</script>";
|
|
redirect('purchaseorder/advancerequest', 'refresh');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function SaveEnquiry()
|
|
{
|
|
|
|
$client_id = $this->request->getPost('client_id');
|
|
$date = $this->request->getPost('date');
|
|
$contact_person = $this->request->getPost('contact_person');
|
|
$requirement = $this->request->getPost('requirement');
|
|
$feasible = $this->request->getPost('feasible');
|
|
$orderno = $this->request->getPost('orderno');
|
|
$reqqty = $this->request->getPost('reqqty');
|
|
$supqty = $this->request->getPost('supqty');
|
|
$remarks = $this->request->getPost('remarks');
|
|
|
|
$save = array('client_id' => $client_id, 'Created_Date' => $date, 'Contact_Person' => $contact_person, 'Requirement' => $requirement, 'Feasible' => $feasible, 'OrderNo' => $orderno, 'Requested_Qty' => $reqqty, 'Supplied_Qty' => $supqty, 'Remarks' => $remarks);
|
|
|
|
$save_result = $this->purchaseorder_model->SaveEnquiry($save);
|
|
|
|
if ($save_result > 0) {
|
|
//echo "<script>alert('Saved successfully!');</script>";
|
|
echo "Saved Successfully";
|
|
//redirect('purchaseorder/addenquiry','refresh');
|
|
|
|
}
|
|
}
|
|
|
|
|
|
function UpdateEnquiry()
|
|
{
|
|
|
|
$client_id = $this->request->getPost('client_id');
|
|
$date = $this->request->getPost('date');
|
|
$contact_person = $this->request->getPost('contact_person');
|
|
$requirement = $this->request->getPost('requirement');
|
|
$feasible = $this->request->getPost('feasible');
|
|
$orderno = $this->request->getPost('orderno');
|
|
$reqqty = $this->request->getPost('reqqty');
|
|
$supqty = $this->request->getPost('supqty');
|
|
$remarks = $this->request->getPost('remarks');
|
|
$Id = $this->request->getPost('id');
|
|
|
|
$save = array('client_id' => $client_id, 'Created_Date' => $date, 'Contact_Person' => $contact_person, 'Requirement' => $requirement, 'Feasible' => $feasible, 'OrderNo' => $orderno, 'Requested_Qty' => $reqqty, 'Supplied_Qty' => $supqty, 'Remarks' => $remarks);
|
|
|
|
//print_r($save);
|
|
|
|
$save_result = $this->purchaseorder_model->UpdateEnquiry($save, $Id);
|
|
|
|
if (($save_result == 0) || ($save_result == 1)) {
|
|
echo "Saved Successfully";
|
|
//echo "<script>alert('Saved successfully!');</script>";
|
|
// redirect('purchaseorder/addenquiry','refresh');
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public function enquiry()
|
|
{
|
|
|
|
$data['Customer'] = $this->purchaseorder_model->GetClients();
|
|
//$dt = date('yyyy-mm-dd');
|
|
|
|
$createddt = get_current_date_time();
|
|
|
|
$data['enquirycount'] = $this->purchaseorder_model->GetEnquiryCount($createddt);
|
|
$this->global['pageTitle'] = 'Enquiry Form';
|
|
|
|
$this->loadViews("addenquiry", $this->global, $data, NULL);
|
|
}
|
|
|
|
public function Editenquiry()
|
|
{
|
|
$Id = $this->request->getVar('Id');
|
|
//echo $Id;
|
|
$data['EnquiryDetails'] = $this->purchaseorder_model->GetEnquiry($Id);
|
|
$data['Customer'] = $this->purchaseorder_model->GetClients();
|
|
//print_r($data['EnquiryDetails']);
|
|
|
|
$this->global['pageTitle'] = 'Enquiry Form';
|
|
|
|
$this->loadViews("editenquiry", $this->global, $data, NULL);
|
|
}
|
|
|
|
public function enquirylist()
|
|
{
|
|
|
|
$data['Customer_Order'] = $this->purchaseorder_model->GetEnquiryDetails();
|
|
|
|
$this->global['pageTitle'] = 'Enquiry List';
|
|
|
|
$this->loadViews("enquirylist", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
|
|
|
|
public function Nonconfirmative()
|
|
{
|
|
|
|
$CId = $this->request->getVar('CId');
|
|
|
|
$data['CId'] = $CId;
|
|
$data['Suplist'] = $this->purchaseorder_model->GetEnquiryDetails();
|
|
|
|
$this->global['pageTitle'] = 'Action Report';
|
|
|
|
// $this->loadViews("action_report", $this->global, $data , NULL);
|
|
|
|
$this->loadViews("action_report", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
public function EditNonconfirmative()
|
|
{
|
|
|
|
$Id = $this->request->getVar('Id');
|
|
|
|
$data['Suplist'] = $this->purchaseorder_model->GetEnquiryDetails();
|
|
$data['masterdetails'] = $this->purchaseorder_model->GetncrmasterDetails($Id);
|
|
$data['DispositionDetails'] = $this->purchaseorder_model->GetDispositionDetails($Id);
|
|
$data['RootcauseDetails'] = $this->purchaseorder_model->GetRootcauseDetails($Id);
|
|
$data['CounteractionDetails'] = $this->purchaseorder_model->GetCouteractionDetails($Id);
|
|
|
|
//print_r($data['DispositionDetails']);
|
|
|
|
$this->global['pageTitle'] = 'Edit Action Report';
|
|
|
|
$this->loadViews("editaction_report", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
public function Nonconfirmativelist()
|
|
{
|
|
|
|
$data['ncrarray'] = $this->purchaseorder_model->GetNcrlist();
|
|
//print_r($data['Customer_Order']);
|
|
$this->global['pageTitle'] = 'NCR List';
|
|
|
|
$this->loadViews("ncrlist", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
public function AddComplaint()
|
|
{
|
|
|
|
$data['Customer'] = $this->purchaseorder_model->GetClients();
|
|
//$dt = date('yyyy-mm-dd');
|
|
|
|
//$createddt = get_current_date_time();
|
|
|
|
//$data['enquirycount']=$this->purchaseorder_model->GetEnquiryCount($createddt);
|
|
|
|
$this->global['pageTitle'] = 'Add Complaint';
|
|
|
|
$this->loadViews("addcomplaint", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
public function EditComplaint()
|
|
{
|
|
|
|
$CId = $this->request->getVar('CId');
|
|
$data['Customer'] = $this->purchaseorder_model->GetClients();
|
|
$data['savedata'] = $this->purchaseorder_model->Get_SavedComplaint($CId);
|
|
$this->global['pageTitle'] = 'Edit Complaint';
|
|
|
|
$this->loadViews("editcomplaint", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
|
|
public function Savencrlist()
|
|
{
|
|
|
|
//$client_id=$this->request->getPost('client_id');
|
|
$Id = '';
|
|
$cname = $this->request->getPost('cname');
|
|
$date = $this->request->getPost('date');
|
|
$servicedetails = $this->request->getPost('servicedetails');
|
|
$detailsofcoplaint = $this->request->getPost('detailsofcoplaint');
|
|
$modeofcommunication = $this->request->getPost('modeofcommunication');
|
|
$actiontaken = $this->request->getPost('actiontaken');
|
|
$actioncardno = $this->request->getPost('actioncardno');
|
|
$remark = $this->request->getPost('remark');
|
|
|
|
|
|
$save = array('client_id' => $cname, 'Created_Date' => $date, 'Details' => $servicedetails, 'Reason' => $detailsofcoplaint, 'mode_of_communication' => $modeofcommunication, 'action_taken' => $actiontaken, 'Remarks' => $remark, 'card_ref_no' => $actioncardno);
|
|
|
|
|
|
if ($Id == "") {
|
|
echo "Unable to Update! Try again";
|
|
} else {
|
|
$save_result = $this->purchaseorder_model->UpdateEnquiry($save, $Id);
|
|
if (($save_result == 0) || ($save_result == 1)) {
|
|
echo "Saved Successfully";
|
|
//echo "<script>alert('Saved successfully!');</script>";
|
|
// redirect('purchaseorder/addenquiry','refresh');
|
|
|
|
} else {
|
|
echo "Updation Failed! Try again";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function Action_Report()
|
|
{
|
|
$txtactionrow = $this->request->getPost('txtactionrow');
|
|
$txtrootrow = $this->request->getPost('txtrootrow');
|
|
$txtcounterrow = $this->request->getPost('txtcounterrow');
|
|
|
|
$Department = $this->request->getPost('Department');
|
|
$Date = $this->request->getPost('newdate');
|
|
$Auditor = $this->request->getPost('AUDITOR');
|
|
$Auditee = $this->request->getPost('AUDITEE');
|
|
$Iqaref = $this->request->getPost('IQAREF');
|
|
$ncdetails = $this->request->getPost('ObjectiveEvidence');
|
|
$ReviewDetails = $this->request->getPost('ReviewDetails');
|
|
$ncrstatus = $this->request->getPost('ncrstatus');
|
|
$Comments = $this->request->getPost('Comments');
|
|
|
|
$CId = $this->request->getPost('CId');
|
|
|
|
$master = array('Department' => $Department, 'Created_Date' => $Date, 'Auditor' => $Auditor, 'Auditee' => $Auditee, 'Iqra' => $Iqaref, 'NC_Details' => $ncdetails, 'Review_Details' => $ReviewDetails, 'Ncr_status' => $ncrstatus, 'Comments' => $Comments);
|
|
|
|
|
|
//print_r($master);
|
|
|
|
$save_result = $this->purchaseorder_model->SaveActionMaster($master);
|
|
|
|
$lastId = '';
|
|
|
|
if (count($save_result) > 0) {
|
|
$lastId = $save_result[0]['Id'];
|
|
}
|
|
|
|
$up = array('Ncr_Id' => $lastId);
|
|
$updatecomplaint = $this->purchaseorder_model->updatecomplaintId($up, $CId);
|
|
|
|
|
|
for ($i = 1; $i <= $txtactionrow; $i++) {
|
|
$action = $this->request->getPost('action' . $i);
|
|
$resp = $this->request->getPost('resp' . $i);
|
|
$target = $this->request->getPost('target' . $i);
|
|
|
|
$actionsave = array('Id' => $lastId, 'Action' => $action, 'Resp' => $resp, 'Target' => $target);
|
|
|
|
$actionsave = $this->purchaseorder_model->SaveActionDisposition($actionsave);
|
|
}
|
|
|
|
|
|
for ($i = 1; $i <= $txtrootrow; $i++) {
|
|
$rootcause = $this->request->getPost('RootCause' . $i);
|
|
|
|
$rootsave = array('Id' => $lastId, 'Root_cause' => $rootcause);
|
|
|
|
$saveroot = $this->purchaseorder_model->SaveRootCause($rootsave);
|
|
}
|
|
|
|
|
|
for ($i = 1; $i <= $txtcounterrow; $i++) {
|
|
$action = $this->request->getPost('counteraction' . $i);
|
|
$resp = $this->request->getPost('counterresp' . $i);
|
|
$target = $this->request->getPost('countertarget' . $i);
|
|
|
|
$savecounter = array('Id' => $lastId, 'Action' => $action, 'Resp' => $resp, 'Target' => $target);
|
|
|
|
$countersave = $this->purchaseorder_model->Savecounteraction($savecounter);
|
|
}
|
|
|
|
|
|
|
|
echo "Saved Successfully";
|
|
}
|
|
|
|
|
|
|
|
public function UpdateAction_Report()
|
|
{
|
|
|
|
$txtactionrow = $this->request->getPost('txtactionrow');
|
|
$txtrootrow = $this->request->getPost('txtrootrow');
|
|
$txtcounterrow = $this->request->getPost('txtcounterrow');
|
|
|
|
$Id = $this->request->getPost('ObjectiveEvidence1');
|
|
$Department = $this->request->getPost('Department');
|
|
$Date = $this->request->getPost('newdate');
|
|
|
|
//die();
|
|
$Auditor = $this->request->getPost('AUDITOR');
|
|
$Auditee = $this->request->getPost('AUDITEE');
|
|
$Iqaref = $this->request->getPost('IQAREF');
|
|
$ncdetails = $this->request->getPost('ObjectiveEvidence');
|
|
$ReviewDetails = $this->request->getPost('ReviewDetails');
|
|
$ncrstatus = $this->request->getPost('ncrstatus');
|
|
$Comments = $this->request->getPost('Comments');
|
|
|
|
|
|
$master = array('Department' => $Department, 'Created_Date' => $Date, 'Auditor' => $Auditor, 'Auditee' => $Auditee, 'Iqra' => $Iqaref, 'NC_Details' => $ncdetails, 'Review_Details' => $ReviewDetails, 'Ncr_status' => $ncrstatus, 'Comments' => $Comments);
|
|
|
|
|
|
$save_result = $this->purchaseorder_model->UpdateActionMaster($master, $Id);
|
|
|
|
//print_r($save_result);
|
|
|
|
|
|
$lastId = '';
|
|
|
|
if (count($save_result) > 0) {
|
|
$lastId = $save_result[0]['Id'];
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for ($i = 1; $i <= $txtactionrow; $i++) {
|
|
$action = $this->request->getPost('action' . $i);
|
|
$resp = $this->request->getPost('resp' . $i);
|
|
$target = $this->request->getPost('target' . $i);
|
|
$LineDisposition = $this->request->getPost('ActionId' . $i);
|
|
|
|
if ($action == '' && $resp == '' & $target == '') {
|
|
} else {
|
|
|
|
$actionsave = array('Id' => $Id, 'Action' => $action, 'Resp' => $resp, 'Target' => $target);
|
|
$checklineid = $this->purchaseorder_model->GetActionid($LineDisposition);
|
|
|
|
//print_r($actionsave);
|
|
|
|
if (count($checklineid) == 0) {
|
|
|
|
$actionsave = $this->purchaseorder_model->SaveActionDisposition($actionsave);
|
|
} else {
|
|
$actionsave = $this->purchaseorder_model->UpdateActionDisposition($actionsave, $LineDisposition);
|
|
}
|
|
}
|
|
|
|
// $actionsave = $this->purchaseorder_model->UpdateActionDisposition($actionsave,$LineDisposition);
|
|
}
|
|
|
|
|
|
for ($i = 1; $i <= $txtrootrow; $i++) {
|
|
$rootcause = $this->request->getPost('RootCause' . $i);
|
|
$Lineroot = $this->request->getPost('RootCauseId' . $i);
|
|
|
|
if ($rootcause == '') {
|
|
} else {
|
|
|
|
$rootsave = array('Id' => $Id, 'Root_cause' => $rootcause);
|
|
|
|
$checkrootid = $this->purchaseorder_model->Getrootid($Lineroot);
|
|
if (count($checkrootid) == 0) {
|
|
$saveroot = $this->purchaseorder_model->SaveRootCause($rootsave);
|
|
} else {
|
|
$saveroot = $this->purchaseorder_model->UpdateRootCause($rootsave, $Lineroot);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
for ($i = 1; $i <= $txtcounterrow; $i++) {
|
|
$action = $this->request->getPost('counteraction' . $i);
|
|
$resp = $this->request->getPost('counterresp' . $i);
|
|
$target = $this->request->getPost('countertarget' . $i);
|
|
$LineCounter = $this->request->getPost('CounterId' . $i);
|
|
|
|
if ($action == '' && $resp == '' & $target == '') {
|
|
} else {
|
|
|
|
$savecounter = array('Id' => $Id, 'Action' => $action, 'Resp' => $resp, 'Target' => $target);
|
|
|
|
$checkcounterid = $this->purchaseorder_model->Getcounterid($LineCounter);
|
|
|
|
if (count($checkcounterid) == 0) {
|
|
$countersave = $this->purchaseorder_model->Savecounteraction($savecounter);
|
|
} else {
|
|
$countersave = $this->purchaseorder_model->Updatecounteraction($savecounter, $LineCounter);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
echo "Saved Successfully";
|
|
}
|
|
|
|
|
|
public function SaveComplaint()
|
|
{
|
|
|
|
$client_id = $this->request->getPost('client_id');
|
|
$date = $this->request->getPost('date');
|
|
$Service_Details = $this->request->getPost('Service_Details');
|
|
$Reasons = $this->request->getPost('Reasons');
|
|
$mode = $this->request->getPost('mode');
|
|
$Action = $this->request->getPost('Action');
|
|
$Remark = $this->request->getPost('Remark');
|
|
|
|
$save_complaint = array('client_id' => $client_id, 'Created_Date' => $date, 'Service_Details' => $Service_Details, 'Reason' => $Reasons, 'mode_of_communication' => $mode, 'Action_taken' => $Action, 'Remark' => $Remark);
|
|
|
|
$savecomplaint = $this->purchaseorder_model->Savecomplaint($save_complaint);
|
|
|
|
if ($savecomplaint > 0) {
|
|
|
|
echo "Saved Successfully";
|
|
} else {
|
|
echo "Error Occured! Please Try Again";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function UpdateComplaint()
|
|
{
|
|
|
|
$client_id = $this->request->getPost('client_id');
|
|
$date = $this->request->getPost('date');
|
|
$Service_Details = $this->request->getPost('Service_Details');
|
|
$Reasons = $this->request->getPost('Reasons');
|
|
$mode = $this->request->getPost('mode');
|
|
$Action = $this->request->getPost('Action');
|
|
$Remark = $this->request->getPost('Remark');
|
|
$CId = $this->request->getPost('CId');
|
|
|
|
$save_complaint = array('client_id' => $client_id, 'Created_Date' => $date, 'Service_Details' => $Service_Details, 'Reason' => $Reasons, 'mode_of_communication' => $mode, 'Action_taken' => $Action, 'Remark' => $Remark);
|
|
|
|
$savecomplaint = $this->purchaseorder_model->Updatecomplaint($save_complaint, $CId);
|
|
|
|
if ($savecomplaint > 0) {
|
|
|
|
echo "Saved Successfully";
|
|
} else {
|
|
echo "Error Occured! Please Try Again";
|
|
}
|
|
}
|
|
|
|
|
|
public function DeleteAction_Report()
|
|
{
|
|
$DelId = $this->request->getPost('delactionId');
|
|
$delete = $this->purchaseorder_model->DeleteAction($DelId);
|
|
|
|
//echo $delete;
|
|
if ($delete > 0) {
|
|
echo "Successfully Deleted";
|
|
}
|
|
}
|
|
|
|
|
|
public function DeleteRoot_Cause()
|
|
{
|
|
$DelId = $this->request->getPost('delactionId');
|
|
$delete = $this->purchaseorder_model->DeleteRoot($DelId);
|
|
|
|
//echo $delete;
|
|
if ($delete > 0) {
|
|
echo "Successfully Deleted";
|
|
}
|
|
}
|
|
|
|
|
|
public function DeleteCounter_Row()
|
|
{
|
|
$DelId = $this->request->getPost('delactionId');
|
|
$delete = $this->purchaseorder_model->DeleteCounter($DelId);
|
|
|
|
//echo $delete;
|
|
if ($delete > 0) {
|
|
echo "Successfully Deleted";
|
|
}
|
|
}
|
|
/*--------------------------------------------------------------------------------------*/
|
|
function addloadfile()
|
|
{
|
|
|
|
$pono = $this->request->getPost('PONO');
|
|
|
|
$igr = $this->request->getPost('igr');
|
|
|
|
$new_file_name = $_FILES['file']['name'];
|
|
$new_file_name = str_replace(" ", "", $new_file_name);
|
|
|
|
$files = $this->purchaseorder_model->getfies($pono);
|
|
|
|
|
|
$fcount = 0;
|
|
|
|
foreach ($files as $value) {
|
|
|
|
$lastfile = $value->FilePath;
|
|
|
|
|
|
if ($lastfile == $new_file_name) {
|
|
$fcount++;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($fcount == 0) {
|
|
|
|
if (!empty($new_file_name)) {
|
|
$Picture = $this->adfile();
|
|
$filelist = array('PONO' => $pono, 'IGRNO' => $igr, 'FilePath' => $Picture);
|
|
$uploadfiles = $this->purchaseorder_model->insertfile($filelist);
|
|
}
|
|
}
|
|
|
|
if ($uploadfiles > 0) {
|
|
echo "file updated successfully!";
|
|
} else {
|
|
echo "No File Choose or File name already Exist";
|
|
}
|
|
}
|
|
|
|
|
|
public function adfile()
|
|
{
|
|
$picture = '';
|
|
$file = $this->request->getFile('file');
|
|
|
|
if ($file && $file->isValid()) {
|
|
$uploadPath = base_url() . 'public/uploads/BillFiles/';
|
|
$file->move($uploadPath);
|
|
|
|
$picture = $file->getName();
|
|
} else {
|
|
$picture = '';
|
|
}
|
|
|
|
return $picture;
|
|
}
|
|
|
|
|
|
|
|
function splpodata()
|
|
{
|
|
|
|
$invno = $this->request->getPost('param1');
|
|
$invdate = $this->request->getPost('param2');
|
|
$VehicleNo = $this->request->getPost('param3');
|
|
$CourierNo = $this->request->getPost('param4');
|
|
$MaterialRcvdDate = $this->request->getPost('param5');
|
|
$PONO = $this->request->getPost('param6');
|
|
$IGRNO = $this->request->getPost('param7');
|
|
$invdate = format_date($invdate);
|
|
|
|
$MaterialRcvdDate = format_date($MaterialRcvdDate);
|
|
|
|
$CreatedBy = $this->session->get('userId');
|
|
|
|
|
|
|
|
$createddt = get_current_date_time();
|
|
|
|
|
|
|
|
|
|
// $billdetails = $this->purchaseorder_model->getigrno($bill);
|
|
|
|
// //print_r($billdetails);
|
|
|
|
|
|
// $PONO = $billdetails[0]['PONO'];
|
|
|
|
|
|
// $IGRNo = $billdetails[0]['IGRNO'];
|
|
|
|
|
|
|
|
|
|
$igrMaster = array('VehicleNo' => $VehicleNo, 'DeliveryChellanOrInvoiceNo' => $invno, 'DeliveryChellanDate' => $invdate, 'MaterialRcvdDate' => $MaterialRcvdDate, 'CourierNo' => $CourierNo, 'UpdateBY' => $CreatedBy, 'UpdatedOn' => $createddt);
|
|
|
|
|
|
|
|
$igrM = $this->purchaseorder_model->updateigrM($PONO, $IGRNO, $igrMaster);
|
|
|
|
if ($igrM > 0) {
|
|
echo "updated successfully!";
|
|
} else {
|
|
echo " not updated successfully!";
|
|
}
|
|
}
|
|
|
|
function uploadfile()
|
|
{
|
|
|
|
//alert();
|
|
$bill = $this->request->getPost('param1');
|
|
|
|
$oldfile = $this->request->getPost('param2');
|
|
|
|
$newfile = $this->request->getPost('file');
|
|
// $new_file_name =$_FILES['file']['name'];
|
|
$newfile = str_replace(" ", "", $newfile);
|
|
|
|
|
|
|
|
if (!empty($_FILES['file']['name'])) {
|
|
|
|
$Picture = $this->add();
|
|
} else {
|
|
$Picture = $oldfile;
|
|
}
|
|
//echo $Picture;die;
|
|
$uploadfile = $this->purchaseorder_model->updatefile($bill, $Picture, $oldfile);
|
|
|
|
|
|
// if($uploadfile > 0){
|
|
echo "updated successfully!";
|
|
// }
|
|
// else{
|
|
// echo "updated successfully!";
|
|
// }
|
|
}
|
|
|
|
// function add()
|
|
// {
|
|
// $picture = '';
|
|
// if (!empty($_FILES['file']['name'])) {
|
|
// $config['upload_path'] = 'public/uploads/BillFiles/';
|
|
// $config['allowed_types'] = '*';
|
|
// //$config['file_name'] = $_FILES['file']['name'];
|
|
// $config['file_name'] = str_replace(" ", "", $_FILES['file']['name']);
|
|
|
|
|
|
// //print_r($config) ;die;
|
|
// //Load upload library and initialize configuration
|
|
// $this->load->library('upload', $config);
|
|
// $this->upload->initialize($config);
|
|
// if ($this->upload->do_upload('file')) {
|
|
// $uploadData = $this->upload->data();
|
|
// $picture = $uploadData['file_name'];
|
|
// } else {
|
|
// $error = array('error' => $this->upload->display_errors());
|
|
// $picture = '';
|
|
// }
|
|
// } else {
|
|
// $picture = '';
|
|
// }
|
|
|
|
// return $picture;
|
|
// }
|
|
public function add()
|
|
{
|
|
$picture = '';
|
|
|
|
// Check if file is uploaded
|
|
if ($file = $this->request->getFile('file')) {
|
|
// Define upload directory and allowed file types
|
|
$uploadPath = base_url() . 'public/uploads/BillFiles/'; // You can change this path as needed
|
|
$allowedTypes = '*'; // You can change this to specific file types like 'jpg|png|gif'
|
|
|
|
// Set the file name without spaces
|
|
$fileName = str_replace(" ", "", $file->getName());
|
|
|
|
// Perform the upload
|
|
if ($file->isValid() && $file->move($uploadPath, $fileName)) {
|
|
$picture = $fileName;
|
|
} else {
|
|
$error = $file->getErrorString();
|
|
// Handle errors as needed
|
|
}
|
|
}
|
|
|
|
return $picture;
|
|
}
|
|
|
|
public function VerifyWithSupplierForPendingPO()
|
|
{
|
|
$supplierid = $this->request->getPost('supplierid');
|
|
$materialcode = $this->request->getPost('materialcode');
|
|
$result = $this->purchaseorder_model->VerifyWithSupplierForPendingPO($supplierid, $materialcode);
|
|
|
|
$response = "";
|
|
if (!empty($result)) {
|
|
if ($result[0]['PO_count'] > 0) {
|
|
$PONO = explode(',', $result[0]['PONO']);
|
|
$response = "There are pending purchase orders with the same supplier. PONO(s):\n" . implode("\n", $PONO);
|
|
}
|
|
// else {
|
|
// $response = "No pending purchase orders found with the same supplier.";
|
|
// }
|
|
}
|
|
|
|
echo $response;
|
|
// return $this->response->setJSON($result);
|
|
}
|
|
|
|
/*--------------------------------------------------------------------------------------*/
|
|
}
|