684 lines
24 KiB
PHP
684 lines
24 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
|
|
use CodeIgniter\Validation\Exceptions\ValidationException;
|
|
|
|
use App\Models\Costcenter_model;
|
|
use App\Models\Purchaseorder_model;
|
|
use App\Models\Requistion_model;
|
|
|
|
|
|
/**
|
|
* Module : Purchaseorder
|
|
* Servicepurchaseorder Class to control all Servicepurchaseorder related operations.
|
|
* @author : Venba
|
|
* @version : 1.1
|
|
* @since : 15 Feb 2016
|
|
* @example : Revised at 15th april 2024
|
|
*/
|
|
class Servicepurchaseorder extends BaseController
|
|
{
|
|
protected $session;
|
|
protected $purchaseorder_model;
|
|
protected $requistion_model;
|
|
protected $costcenter_model;
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->purchaseorder_model = new Purchaseorder_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();
|
|
}
|
|
|
|
function viewServicePOReportForBilling()
|
|
{
|
|
|
|
$this->global['pageTitle'] = 'Service Purchase Order for Billing';
|
|
|
|
$data["Billing"] = $this->purchaseorder_model->GetServicePOListforBilling();
|
|
|
|
//print_r($data["Billing"]);
|
|
|
|
$this->loadViews("serviceporeport", $this->global, $data, null);
|
|
}
|
|
|
|
function UpdateServicePOStatus()
|
|
{
|
|
$this->global['pageTitle'] = 'Update Service PO Status';
|
|
$data['PO'] = $this->purchaseorder_model->GetServicePOListforStatusUpdate();
|
|
$data['WorkStatus'] = $this->purchaseorder_model->getStatus(7);
|
|
|
|
$this->loadViews("statusofservicepurchaseorder", $this->global, $data, Null);
|
|
}
|
|
|
|
|
|
function getPODetails()
|
|
{
|
|
$PONO = $this->request->getPost('id');
|
|
$PO = $PONO;
|
|
$result = $this->purchaseorder_model->GetPODetailforBillingServicePO($PO);
|
|
$HTML = "";
|
|
for ($i = 0; $i < count($result); $i++) {
|
|
$SNo = $i + 1;
|
|
$ReqNo = $result[$i]['ReqNo'];
|
|
$Reqedby = $result[$i]['FirstName'];
|
|
$ReqDate = $result[$i]['ReqDate'];
|
|
$SupplierID = $result[$i]['SupplierName'];
|
|
$Workstatus = $result[$i]['WorkStatus'];
|
|
$MaterialCode = $result[$i]['MaterialCode'];
|
|
$Description = $result[$i]['ServiceMaterialDescription'];
|
|
$UOM = $result[$i]['UOM'];
|
|
$Quantity = $result[$i]['Quantity'];
|
|
$Rate = $result[$i]['Rate'];
|
|
$ReqDate = format_date($result[$i]['ReqDate'], 0,'d-m-Y');
|
|
|
|
|
|
$HTML .= "<tr id='" . $SNo . "'>
|
|
|
|
<td align='left'>" . $ReqNo . "</td>
|
|
<td align='left'>" . $Reqedby . "</td>
|
|
<td align='left'>" . $ReqDate . "</td>
|
|
<td align='left'>" . $SupplierID . "</td>
|
|
<td align='left'>" . $MaterialCode . "</td>
|
|
<td align='left' >" . $Description . "</td>
|
|
<td align='left'>" . $UOM . "</td>
|
|
<td align='left'>" . $Quantity . "</td>
|
|
<td align='left'>" . $Rate . "</td>
|
|
|
|
<td align='left'>" . $Workstatus . "</td>
|
|
</tr>";
|
|
}
|
|
|
|
echo $HTML;
|
|
}
|
|
|
|
function UpdateServiceStatus()
|
|
{
|
|
|
|
$PONO = $this->request->getPost('PONO');
|
|
$WorkStatus = $this->request->getPost('WorkStatus');
|
|
|
|
|
|
$Remarks = $this->request->getPost('Remarks');
|
|
|
|
$updatedBy = $this->session->get('userId');
|
|
|
|
$updateddt = get_current_date_time();
|
|
if ($WorkStatus == SERVICE_COMPLETED) {
|
|
$POStatus = PO_SERVICE_COMPLETED;
|
|
$POList = array('UpdateBY' => $updatedBy, 'UpdatedOn' => $updateddt, 'ServiceWorkStatusRemarks' => $Remarks, 'ServiceWorkStatus' => $WorkStatus, 'Status' => $POStatus);
|
|
|
|
|
|
|
|
|
|
$PO = $PONO;
|
|
$result = $this->purchaseorder_model->GetPODetailforBillingServicePO($PO);
|
|
|
|
|
|
for ($i = 0; $i < count($result); $i++) {
|
|
|
|
$MaterialCode = $result[$i]['MaterialCode'];
|
|
|
|
$ReqList = $this->purchaseorder_model->updateReqDetail($PONO, $POStatus, $MaterialCode);
|
|
}
|
|
|
|
|
|
|
|
// $ReqList = $this->purchaseorder_model->updateReqDetail($PONO,$POStatus);
|
|
$this->purchaseorder_model->UpdateReceivedQtyforServicePO($PONO, $updateddt, $updatedBy);
|
|
} else {
|
|
$POList = array('UpdateBY' => $updatedBy, 'UpdatedOn' => $updateddt, 'ServiceWorkStatusRemarks' => $Remarks, 'ServiceWorkStatus' => $WorkStatus);
|
|
}
|
|
|
|
|
|
$POMaster = $this->purchaseorder_model->updatePOMaster($PONO, $POList);
|
|
|
|
$this->UpdateServicePOStatus();
|
|
echo "<script>alert('Successfully Updated the workStatus of the PO " . $PONO . "')</script>";
|
|
}
|
|
// To get the available Budget Amount
|
|
function AvilBudgetAmount()
|
|
{
|
|
|
|
$CostCode = $this->request->getPost('id');
|
|
$ReqType = $this->request->getPost('type');
|
|
$FYStart = '';
|
|
$FYEnd = '';
|
|
$FiscalYear = $this->costcenter_model->getFiscalYear();
|
|
if (!empty($FiscalYear)) {
|
|
foreach ($FiscalYear as $Fy) {
|
|
$FYStart = $Fy->StartYear;
|
|
$FYEnd = $Fy->EndYear;
|
|
}
|
|
}
|
|
|
|
$FYdt = $FYStart . " - " . $FYEnd;
|
|
|
|
$result = array();
|
|
|
|
if ($ReqType == CAPITAL) {
|
|
$result = $this->purchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode, $FYdt, $ReqType);
|
|
} else if ($ReqType == IMPORT) {
|
|
$result = $this->purchaseorder_model->GetAvailableImportBudgetAmount($CostCode, $FYdt, $ReqType);
|
|
} else {
|
|
$result = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode, $FYdt, $ReqType);
|
|
}
|
|
|
|
$AvilBudAmt = '0';
|
|
if (count($result) > 0) {
|
|
$AvilBudAmt = $result[0]['BudgetAmount'] - $result[0]['Totalvalue'];
|
|
}
|
|
|
|
return $this->response->setJSON($AvilBudAmt);
|
|
}
|
|
|
|
|
|
//This used to Create Service Purchase Order
|
|
function addNewServicePurchaseOrder()
|
|
{
|
|
|
|
$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');
|
|
//$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 = '';
|
|
}
|
|
$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');
|
|
$DescriptionOfPo = $this->request->getPost('descofpo');
|
|
$PaymentTerms = $this->request->getPost('PaymentTerms');
|
|
$OtherPayment = $this->request->getPost('Otherpayment');
|
|
|
|
$POType = $this->request->getPost('POType');
|
|
|
|
$BudgetType = $this->request->getPost('Budget');
|
|
|
|
$SpcialInstruction = $this->request->getPost('ScopeOfWork');
|
|
$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 = explode(':', (string)$DeletedRow);
|
|
|
|
|
|
$createddt = get_current_date_time();
|
|
|
|
$WorkStatus = $this->request->getPost('workstatus');
|
|
$lastPONO = $this->purchaseorder_model->lastPONO();
|
|
$newPONO = generate_po_number($lastPONO);
|
|
$IsOpenOrder = ($this->request->getPost('IsOpenOrder') !== null && !empty($this->request->getPost('IsOpenOrder')) && $this->request->getPost('IsOpenOrder') === '1') ? $this->request->getPost('IsOpenOrder') : null;
|
|
$file = $this->request->getFile('POFile');
|
|
$requestfilename = $file->getName();
|
|
if (!empty($requestfilename)) {
|
|
|
|
if ($file->isValid() && !$file->hasMoved()) {
|
|
$path = ROOTPATH.'public/uploads/POfiles/';
|
|
if(!is_dir($path)) { mkdir($path, 0777, true); }
|
|
if (!empty($this->purchaseorder_model->isFileExists($requestfilename))) {
|
|
log_message('error', 'File already exists in the database'.$requestfilename);
|
|
$requestfilename = "";
|
|
}
|
|
else{
|
|
$file->move($path, $requestfilename);
|
|
}
|
|
}else{
|
|
$requestfilename = "";
|
|
}
|
|
|
|
}
|
|
|
|
// PO Master
|
|
$POList = array('PONO'=>$newPONO,'SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrderValueSummary, 'PODate' => $PODate, 'Status' => $POStatus, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'ServiceDescription' => $SpcialInstruction, 'CreatedBy' => $CreateBy, 'DeliveryAddress' => $DeliveryAddr, 'DeliveryDate' => $Deliverydt, 'CreatedDate' => $createddt, 'PaymentTerms' => $PaymentTerms, 'ServiceWorkStatus' => $WorkStatus, 'POType' => $POType, 'PaymentOtherDescription' => $OtherPayment, 'Supplier_Reference' => $SupplierReference, 'Mode_Of_Shipment' => $ModeOfShipment, 'Supplier_Offer_No' => $SuppliersOfferNo, 'Other_Reference' => $OtherReferences, 'Fincap' => $Fincap, 'Description_Of_Service' => $DescriptionOfPo, 'InsuranceStatus' => $InsuranceOptions, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $ServiceTypeOptions, 'BudgetType' => $BudgetType,'IsOpenOrder'=>$IsOpenOrder);
|
|
$POList['POFile'] = $requestfilename;
|
|
$POMaster = $this->purchaseorder_model->addPOMaster($POList, $POType, $ServiceTypeOptions);
|
|
$PONO = $POMaster ? $newPONO : "";
|
|
// $PONO = '';
|
|
// if (count($POMaster) > 0) {
|
|
// $PONO = $POMaster[0]['PONO'];
|
|
// }
|
|
|
|
// PO Line Items
|
|
$LineItemStatus = REQITEM_NEW;
|
|
|
|
for ($i = 1; $i <= $RowCount; $i++) {
|
|
$Per = $this->request->getPost('per' . $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);
|
|
$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);
|
|
$CostCenter = $this->request->getPost('costCode' . $i);
|
|
$ServiceFrequency = $this->request->getPost('Frequency' . $i);
|
|
$ItemDescription = $this->request->getPost('ItemDescription' . $i);
|
|
$OtherAmt = $this->request->getPost('OtherAmt' . $i);
|
|
$TotalOrderValue = $this->request->getPost('TotalOrderValue' . $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") {
|
|
$this->requistion_model = new requistion_model();
|
|
|
|
$RetItemNo = $this->requistion_model->getItemNumber($Reqnumber, $MaterialCode);
|
|
|
|
$ItemNo = '';
|
|
if (count($RetItemNo) > 0) {
|
|
$ItemNo = $RetItemNo[0]['ItemNo'];
|
|
}
|
|
|
|
|
|
|
|
|
|
$POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CostCenterCode' => $CostCenter, 'ServiceFrequency' => $ServiceFrequency, 'ServiceMaterialDescription' => $ItemDescription, 'Per' => $Per, 'ItemNo' => $ItemNo);
|
|
|
|
$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);
|
|
|
|
// $addlog= $this->purchaseorder_model->newlogpo($logpo);
|
|
/*---------*/
|
|
|
|
if (trim((string)$POType) == SERVICE) {
|
|
// echo 'Success';
|
|
$ServiceTaxList = array('LineItemNo' => $LineItemNo, 'CGST' => $Cgst, 'After_CGST' => $AfterCgst, 'SGST' => $Sgst, 'After_SGST' => $AfterSgst, 'IGST' => $Igst, 'After_IGST' => $AfterIgst, 'TotalValue' => $TotalOrderValue, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'otherallowance' => $OtherAmt);
|
|
|
|
$ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList);
|
|
}
|
|
}
|
|
}
|
|
echo 'Service Purchase Order Created Successfully!The PO NO Is: ' . $PONO;
|
|
}
|
|
//update service po
|
|
function UpdateServicePurchaseOrder()
|
|
{
|
|
$PONO = $this->request->getPost('txtPONO');
|
|
$newsup = $this->request->getPost('newsup');
|
|
// $newSupId = split("[ - ]+", $newsup);
|
|
$newSupId = preg_split('[-]', (string)$newsup);
|
|
|
|
$POdt = $this->request->getPost('PODate');
|
|
$PODate = get_date_time_format($POdt);
|
|
/*-----------------------------------*/
|
|
$b4supplier = $this->request->getPost('b4supplier');
|
|
$b4date = $this->request->getPost('b4podate');
|
|
$b4podate = get_date_time_format($b4date);
|
|
/*-----------------------------------*/
|
|
$SupplierID = $this->request->getPost('drpSupplier');
|
|
$DeliveryAddr = $this->request->getPost('txtDeliveryAddress');
|
|
$dt = $this->request->getPost('Deliverydt');
|
|
$DeliveryOption = $this->request->getPost('DateRange');
|
|
if ($DeliveryOption == 1) {
|
|
$Deliverydt = '';
|
|
$DeliverySchedule = $this->request->getPost('Scheduleby');
|
|
} else {
|
|
$Deliverydt = get_date_time_format($dt);
|
|
$DeliverySchedule = '';
|
|
}
|
|
|
|
$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');
|
|
$DescriptionOfPo = $this->request->getPost('editdescofpo');
|
|
|
|
|
|
$PaymentTerms = $this->request->getPost('PaymentTerms');
|
|
$OtherPayment = $this->request->getPost('Otherpayment');
|
|
|
|
$POType = $this->request->getPost('POType');
|
|
|
|
$BudgetType = $this->request->getPost('Budget');
|
|
|
|
$SpcialInstruction = $this->request->getPost('ScopeofWork');
|
|
$TotalOrderValueSummary = $this->request->getPost('txtTotalOrderValueSummary');
|
|
$POStatus = $this->request->getPost('txtStatus');
|
|
|
|
$updatedBy = $this->session->get('userId');
|
|
$RowCount = $this->request->getPost('txtRowCount');
|
|
$DeletedRow = $this->request->getPost('txtDeletedRow');
|
|
|
|
$comma_separated = explode(':', (string)$DeletedRow);
|
|
|
|
$updateddt = get_current_date_time();
|
|
$WorkStatus = $this->request->getPost('workstatus');
|
|
|
|
$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('SupplierID' => $SupplierID, 'TotalOrderValue' => $TotalOrderValueSummary, 'PODate' => $PODate, 'Status' => $POStatus, 'DeliverySchedule' => $DeliverySchedule, 'DeliveryOption' => $DeliveryOption, 'ServiceDescription' => $SpcialInstruction, 'UpdateBY' => $updatedBy, 'DeliveryAddress' => $DeliveryAddr, 'DeliveryDate' => $Deliverydt, 'UpdatedOn' => $updateddt, 'PaymentTerms' => $PaymentTerms, 'ServiceWorkStatus' => $WorkStatus, 'PaymentOtherDescription' => $OtherPayment, 'Supplier_Reference' => $SupplierReference, 'Mode_Of_Shipment' => $ModeOfShipment, 'Supplier_Offer_No' => $SuppliersOfferNo, 'Other_Reference' => $OtherReferences, 'Fincap' => $Fincap, 'Description_Of_Service' => $DescriptionOfPo, 'InsuranceStatus' => $InsuranceOptions, 'InsuranceNumber' => $InsuranceNumber, 'POSubType' => $ServiceTypeOptions, 'BudgetType' => $BudgetType,'IsOpenOrder'=>$IsOpenOrder);
|
|
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');
|
|
}
|
|
$file = $this->request->getFile('POFile');
|
|
$requestfilename = $file->getName();
|
|
if (!empty($requestfilename)) {
|
|
if ($file && $file->isValid() && !$file->hasMoved()) {
|
|
$path = ROOTPATH.'public/uploads/POfiles/';
|
|
if(!is_dir($path)) { mkdir($path, 0777, true); }
|
|
if (!empty($this->purchaseorder_model->isFileExists($requestfilename))) {
|
|
log_message('error', 'File already exists in the database'.$requestfilename);
|
|
}
|
|
else{
|
|
$file->move($path, $requestfilename);
|
|
$POList['POFile'] = $requestfilename;
|
|
}
|
|
}
|
|
}
|
|
|
|
$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) {
|
|
//$newsupname = $newSupId[0].'-'.$newSupId[1];
|
|
//echo $newsup;die;
|
|
$logpo = array('PONO' => $PONO, 'LineItemNos' => '-', 'UpdateBy' => $updatedBy, '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);
|
|
/*-----------------------------------*/
|
|
$b4qty = $this->request->getPost('b4qty' . $i);
|
|
$b4rate = $this->request->getPost('b4rate' . $i);
|
|
/*-----------------------------------*/
|
|
$Reqnumber = $this->request->getPost('Reqnumber' . $i);
|
|
$itemRate = $this->request->getPost('itemRate' . $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);
|
|
$CostCenter = $this->request->getPost('costCode' . $i);
|
|
$ServiceFrequency = $this->request->getPost('Frequency' . $i);
|
|
$POLineItemNo = $this->request->getPost('LineItemNo' . $i);
|
|
$TotalOrderValue = $this->request->getPost('TotalOrderValue' . $i);
|
|
$ItemDescription = $this->request->getPost('ItemDescription' . $i);
|
|
$OtherAmt = $this->request->getPost('OtherAmt' . $i);
|
|
$Per = $this->request->getPost('per' . $i);
|
|
|
|
|
|
|
|
/*------------------------------*/
|
|
//if($MaterialCode!= ''){
|
|
$ReqDetails = array('Quantity' => $Quantity, 'UpdatedBy' => $updatedBy, 'UpdatedOn' => $updateddt);
|
|
//print_r($ReqDetails);
|
|
|
|
$this->purchaseorder_model->updateReqDetails($Reqnumber, $MaterialCode, $ReqDetails);
|
|
// }
|
|
|
|
|
|
/*------------------------------*/
|
|
|
|
|
|
|
|
/*---------start---------------------*/
|
|
|
|
// if(($PODate != $b4podate )||($SupplierID != $b4supplier) || ($itemRate!=$b4rate) ||
|
|
// ($Quantity != $b4qty ))
|
|
// {
|
|
// $logpo =array('UpdateBy'=>$updatedBy,'UpdatedOn'=>$updateddt);
|
|
|
|
|
|
// $this->purchaseorder_model->updatelogpo($MaterialCode,$POLineItemNo,$logpo);
|
|
// }
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
|
|
/*----------end--------------------*/
|
|
|
|
$POLineItem = array();
|
|
$LineItemNo = '';
|
|
|
|
|
|
|
|
$SkipInsert = "False";
|
|
if (count($comma_separated) > 0) {
|
|
for ($j = 1; $j < count($comma_separated); $j++) {
|
|
$deletedRow = $comma_separated[$j];
|
|
|
|
if ($deletedRow == $i) {
|
|
$SkipInsert = "True";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if ($SkipInsert == "False") {
|
|
if (strlen((string)$POLineItemNo) == 0) {
|
|
$this->requistion_model = new requistion_model();
|
|
|
|
$RetItemNo = $this->requistion_model->getItemNumber($Reqnumber, $MaterialCode);
|
|
|
|
$ItemNo = '';
|
|
if (count($RetItemNo) > 0) {
|
|
$ItemNo = $RetItemNo[0]['ItemNo'];
|
|
}
|
|
$POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'CreatedBy' => $updatedBy, 'CreatedDate' => $updateddt, 'CostCenterCode' => $CostCenter, 'ServiceFrequency' => $ServiceFrequency, 'ServiceMaterialDescription' => $ItemDescription, 'Per' => $Per, 'ItemNo' => $ItemNo);
|
|
|
|
$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, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'UpdateBY' => $updatedBy, 'UpdatedOn' => $updateddt, 'CostCenterCode' => $CostCenter, 'ServiceMaterialDescription' => $ItemDescription, 'Per' => $Per);
|
|
$POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO, $POLineItemNo, $POLineItemList);
|
|
}
|
|
|
|
|
|
|
|
if (trim((string)$POType) == SERVICE) {
|
|
$isExists = $this->purchaseorder_model->LineItemExists($LineItemNo);
|
|
|
|
if (count($isExists) == 0) {
|
|
$ServiceTaxList = array('LineItemNo' => $LineItemNo, 'CGST' => $Cgst, 'After_CGST' => $AfterCgst, 'SGST' => $Sgst, 'After_SGST' => $AfterSgst, 'IGST' => $Igst, 'After_IGST' => $AfterIgst, 'TotalValue' => $TotalOrderValue, 'CreatedBy' => $updatedBy, 'CreatedDate' => $updateddt, 'otherallowance' => $OtherAmt);
|
|
|
|
$this->purchaseorder_model->addServiceTax($ServiceTaxList);
|
|
} else {
|
|
$ServiceTaxList1 = array('CGST' => $Cgst, 'After_CGST' => $AfterCgst, 'SGST' => $Sgst, 'After_SGST' => $AfterSgst, 'IGST' => $Igst, 'After_IGST' => $AfterIgst, 'TotalValue' => $TotalOrderValue, 'UpdateBY' => $updatedBy, 'UpdatedOn' => $updateddt, 'otherallowance' => $OtherAmt);
|
|
|
|
$this->purchaseorder_model->updateServiceTax($LineItemNo, $ServiceTaxList1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
echo 'Purchase Order Updated Successfully! PO Number Is: ' . $PONO;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------*/
|
|
function uploadfile()
|
|
{
|
|
$bill = $this->request->getPost('param1');
|
|
$oldfile = $this->request->getPost('param2');
|
|
// $new_file_name =$_FILES['file']['name'];
|
|
|
|
|
|
$new_file_name = $_FILES['file']['name'];
|
|
$new_file_name = str_replace(" ", "", $new_file_name);
|
|
|
|
if (!empty($new_file_name)) {
|
|
|
|
$file = $this->request->getFile('file');
|
|
if ($file && $file->isValid()) {
|
|
$uploadPath = base_url() . 'public/uploads/BillFiles/';
|
|
$file->move($uploadPath);
|
|
$Picture = $file->getName();
|
|
} else {
|
|
$Picture = '';
|
|
}
|
|
}
|
|
|
|
$uploadfile = $this->purchaseorder_model->updatefile($bill, $Picture, $oldfile);
|
|
|
|
if ($uploadfile > 0) {
|
|
echo "file updated successfully!";
|
|
} else {
|
|
echo "file not updated!";
|
|
}
|
|
}
|
|
|
|
/*-----------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
function addfileuplod()
|
|
{
|
|
|
|
$pono = $this->request->getPost('PONO');
|
|
|
|
|
|
|
|
$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++;
|
|
}
|
|
}
|
|
|
|
$upfile = '';
|
|
|
|
if ($fcount == 0) {
|
|
|
|
if (!empty($new_file_name)) {
|
|
$Picture = $this->adfile();
|
|
$filelist = array('PONO' => $pono, 'FilePath' => $Picture);
|
|
$upfile = $this->purchaseorder_model->insertfile($filelist);
|
|
}
|
|
}
|
|
|
|
if ($upfile > 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;
|
|
}
|
|
}
|