siddharth_application/application/controllers/purchaseorder.php
venbatechnologies@gmail.com 4bd7eb643c edit status display
2017-07-05 11:10:30 +05:30

2334 lines
84 KiB
PHP
Executable File

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
/**
* Class : purchaseorder (PurchaseorderController)
* User Class to control all user related operations.
* @author : Venba InfoTech
* @version : 1.1
* @since : 09/06 Feb 2017
*/
class purchaseorder extends BaseController
{
/**
* This is default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->load->model('purchaseorder_model');
$this->load->library('session');
$this->load->library('form_validation');
$this->load->model('requistion_model');
$this->isLoggedIn();
}
/**
* This function used to load the first screen of the user
*/
public function index()
{
$this->global['pageTitle'] = 'Siddharth : AddPO';
$this->loadViews("addPO", $this->global, NULL , NULL);
}
function viewfullpurchaseorder()
{
$this->global['pageTitle'] = 'Siddharth : View Purchase Order';
$this->loadViews("viewfullpurchaseorder", $this->global,Null);
}
function requisition()
{
$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->global['pageTitle'] = 'Siddharth : 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'] = 'Siddharth : Purchase Orders';
$this->loadViews("POlist", $this->global, $data, NULL);
}
function Req_validate($selectValue)
{
//echo 'select_validate method called';
// 'none' is the first option and the text says something like "-Choose one-"
if(strlen($selectValue) == 0)
{
$this->form_validation->set_message('Req_validate', 'Please Select Requisition Number to Create PO.');
return false;
}
else // user picked something
{
return true;
}
}
/**
* This function used to show the Purchase Order Screen
*/
function CreatePurchaseOrder()
{
$this->form_validation->set_rules('txtReqNo', 'txtReqNo', 'callback_Req_validate');
if($this->form_validation->run() == FALSE)
{
$this->requisition();
}
else
{
$this->global['pageTitle'] = 'Siddharth : 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->getSupplierPayment('C009');
$data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019');
foreach ($data['WorkStatus'] as $WST)
{
$WStatus=$WST->ConfigValue;
//print_r($WStatus);
}
//print_r($data['WorkStatus']);
// foreach ($data['Suplist'] as $SUP)
// {
// $Detail=$SUP->PaymentTerms;
// }
//print_r($data['Payment']);
//print_r($data['Suplist']);
$SelectedReq = json_decode($this->input->post('txtReqNo'));
$Req = $SelectedReq->Req;
$data['ReqList'] = $Req ;
$ReqArray = array();
$ReqType = $this->input->post('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;
//print_r($data['MaterialList']);
/* Cost code from Requisition - Client Review Fix
Start here */
$ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray);
$data['RequistionDetails'] = $ReqDetails;
$CostCode = '';
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$Year = $dt->format('Y');
foreach ($ReqDetails as $Rs):
$CostCode = $Rs->CostCenterCode;
endforeach;
$AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType);
if(count($AvlBudget)>0)
{
$data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue'];
}
/* End Here */
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
// $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']);
// $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)
{
$ViewName = 'importpo';
}
else if($ReqType == CAPITAL)
{
$ViewName = 'capitalpurchaseorder';
}
$this->loadViews($ViewName, $this->global,$data, NULL);
}
}
function CreatePOPrint()
{
$PONO = $_GET['PONO'];
$ReqType = $_GET['ReqType'];
if($ReqType == SERVICE)
{
$this ->servicepoprint($PONO);
}
else if($ReqType == REVENUE)
{
$this ->revenuepoprint($PONO);
}
else if($ReqType == IMPORT)
{
$this ->importpoprint($PONO);
}
else if($ReqType == CAPITAL)
{
$this ->CapitalPoPrint($PONO);
}
}
function CreaterevenuePOPrint()
{
$this->load->View("revenuepopdf", NULL);
}
function CreateservicePOPrint()
{
$this->load->View("servicepopdf", NULL);
}
function CreateimportPOPrint()
{
$this->load->View("importpopdf", NULL);
}
function CreatecapitalPOPrint()
{
$this->load->View("capitalpopdf", NULL);
}
//To View/Update Purchase Order
function EditPurchaseOrder()
{
$PONO = $_GET['PONO'];
$ReqType = $_GET['ReqType'];
$Req = $this->purchaseorder_model->getRequistionNoFromPO($PONO);
$data['ReqList'] = $Req ;
$result = array();
$ReqArray = array();
foreach ($Req as $SID):
$ReqArray[] = $SID->ReqNo ;
$result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo);
endforeach;
$data['MaterialList'] = $result;//$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray);
$data['Suplist'] = $this->purchaseorder_model->getSupplierName();
$data['Payment']=$this->purchaseorder_model->getSupplierPayment();
$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;
}
//print_r($Status);
$data['POSTATUS']=$this->purchaseorder_model->GetPOStatus($Status);
//print_r($data['POSTATUS']);
foreach ($data['POSTATUS'] as $POST)
{
$Status=$POST->StatusName;
}
//print_r($Status);
$CostCode = '';
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$Year = $dt->format('Y');
foreach ($ReqDetails as $Rs):
$CostCode = $Rs->CostCenterCode;
endforeach;
$AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$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;
}
// foreach ($data['POMaster'] as $STATUSCODE)
// {
// $STATUSNAME=$STATUSCODE->PaymentTerms;
// }
//print_r($PAYTERM);
//print_r($exRate);
//$data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate();
$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['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO);
//$data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019');
$data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019');
$this->global['pageTitle'] = 'Siddharth : 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['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019');
$this->global['pageTitle'] = 'Siddharth : Edit Revenue Purchase order form';
$this->loadViews("editRevenuepurchaseorder", $this->global, $data, NULL);
}
else if($ReqType == IMPORT)
{
$AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType);
if(count($AvlBudget)>0)
{
$data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue'];
}
// print_r($data);
$data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetails($PONO);
$data['Currency']=$this->purchaseorder_model->GetCurrencytype();
foreach($data['POMaster'] as $CUR)
{
//print_r($CUR->CurrencyType);
$Currency=$CUR->CurrencyType;
}
// $data[$Rate->ExchangeRate]=$Rate->ExchangeRate;
$data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency);
$data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO);
//print_r($data['PaymentTerms']);
$unicode ='';
foreach ($data['CurrencyDetail'] as $Detail)
{
$unicode=$Detail->FontCode2000;
}
//print_r($unicode);
$data['unicode']=$unicode;
$this->global['pageTitle'] = 'Siddharth : Edit Import Purchase order form';
$this->loadViews("editimportpo", $this->global, $data, NULL);
}
else if($ReqType == CAPITAL)
{
$AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType);
if(count($AvlBudget)>0)
{
$data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue'];
}
$data['POItem'] = $this->purchaseorder_model->getCapitalPurchaseOrderDetails($PONO);
$data['requestedBy'] = $this->purchaseorder_model->GetRequesedByDetails($PONO);
//print_r($data['POItem']);
foreach($data['POItem'] as $Rate)
{
$exRate=$Rate->ExchangeRate;
}
foreach($data['POItem'] as $CUR)
{
$Currency=$CUR->CurrencyType;
}
$data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency);
$data['ExchangeRate']=$exRate;
$data['Currency']=$this->purchaseorder_model->GetCurrencytype();
$this->global['pageTitle'] = 'Siddharth : 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->input->post('id');
// $reqDate= $this->input->post('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->input->post('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->input->post('id');
// $reqDate= $this->input->post('ReqDate');
$CostCode = $SearchFilter[0];
$ReqType = $SearchFilter[1];
print_r($SearchFilter);
$CostCode= $this->input->post('id');
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$Year = $dt->format('Y');
$this->load->model('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);
}
function getDateformat($Val)
{
$date = new DateTime($Val,new DateTimeZone('Asia/Kolkata'));
$retDate = $date->format('Y-m-d H:i:s');
return $retDate;
}
/* Method to get the Requistion list based on the search filter*/
function SearchListofRequistion()
{
$SearchFilter= $this->input->post('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 = $this->getDateformat($FDate);
$ToDate = $this->getDateformat($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->input->post('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()
{
$POdt =$this->input->post('PODate');
$PODate = $this->getDateformat($POdt);
$SupplierID = $this->input->post('drpSupplier');
$DeliveryAddr = $this->input->post('DeliveryAddr');
$dt = $this->input->post('Deliverydt');
$POType = $this->input->post('POType');
$DeliveryOption = $this->input->post('DateRange');
if($DeliveryOption==1){
$Deliverydt = '';
$DeliverySchedule = $this->input->post('Scheduleby');
}
else{
$Deliverydt = $this->getDateformat($dt);
$DeliverySchedule = '';
}
$PaymentDate=$this->input->post('Payment');
if($PaymentDate==1)
{
$PaymentDays='After';
}
else
{
$PaymentDays='Before';
}
$POType = $this->input->post('POType');
$PoRange = $this->input->post('txtPoRange');
$SpcialInstruction = $this->input->post('txtSpcialInstruction');
$TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary');
$POStatus = $this->input->post('txtStatus');
$CreateBy = $this->session->userdata ( 'userId' );
$RowCount = $this->input->post('txtRowCount');
$DeletedRow = $this->input->post('txtDeletedRow');
$comma_separated = explode(':', $DeletedRow);
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$createddt = $dt->format('Y-m-d H:i:s');
$PaymentTerms=$this->input->post('PaymentTerms');
$Payableat=$this->input->post('PayableAT');
// PO Master
$POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'PayableAT'=>$Payableat,'PaymentDays'=>$PaymentDays,'POType'=>$POType);
$POMaster = $this->purchaseorder_model->addPOMaster($POList);
$PONO = '';
if(count($POMaster)>0)
{
$PONO = $POMaster[0]['PONO'];
}
// PO Line Items
$LineItemStatus = REQITEM_NEW;
for ($i = 1; $i <= $RowCount; $i++)
{
$MaterialCode = $this->input->post('materialCode'.$i);
$Quantity = $this->input->post('quantity'.$i);
$Reqnumber = $this->input->post('Reqnumber'.$i);
$itemRate = $this->input->post('itemRate'.$i);
$DiscountType = $this->input->post('DisType'.$i);
$DiscountValue = $this->input->post('DisVal'.$i);
$AfterDiscount = $this->input->post('AfterDisVal'.$i);
$PackagingOption = $this->input->post('PackOption'.$i);
$PackagingType = $this->input->post('PackType'.$i);
$PackagingValue = $this->input->post('PackVal'.$i);
$AfterPackagingValue = $this->input->post('AfterPackVal'.$i);
$ExciseOption = $this->input->post('ExciseOption'.$i);
$ExciseValue = $this->input->post('ExciseVal'.$i);
$AfterExciseValue = $this->input->post('AfterExciseVal'.$i);
$VatOption = $this->input->post('VatOption'.$i);
$VatValue = $this->input->post('VatVal'.$i);
$AfterVatValue = $this->input->post('AfterVatVal'.$i);
$CSTOption = $this->input->post('CSTOption'.$i);
$CSTValue = $this->input->post('CSTVal'.$i);
$AfterCSTValue = $this->input->post('AfterCSTVal'.$i);
$GSTValue = $this->input->post('GSTVal'.$i);
$AfterGSTValue = $this->input->post('AfterGSTVal'.$i);
$OtherTaxValue = $this->input->post('OtherTaxVal'.$i);
$AfterOtherTaxValue = $this->input->post('AfterOtherTaxVal'.$i);
$FreightType = $this->input->post('FreightType'.$i);
$FreightValue = $this->input->post('FreightVal'.$i);
$AfterFreightValue = $this->input->post('AfterFreightVal'.$i);
$InsuranceValue = $this->input->post('Insval'.$i);
$TotalOrderValue = $this->input->post('TotalOrderValue'.$i);
$CostCenter = $this->input->post('costCode'.$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);
$POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
$LineItemNo = '';
if(count($POLineItem)>0)
{
$LineItemNo = $POLineItem[0]['LineItemNo'];
}
//echo $LineItemNo;
if(trim($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,'ExciseDuty'=>$ExciseValue,'ExciseDutyCalulatedOn'=>$ExciseOption,'AfterExciseDuty'=>$AfterExciseValue,'Vat'=>$VatValue,'AfterVAT'=>$AfterVatValue,'VatCalulatedOn'=>$VatOption, 'CST'=>$CSTValue,'AfterCST'=>$AfterCSTValue,'CSTCalulatedOn'=>$CSTOption,'GST'=>$GSTValue,'AfterGST'=>$AfterGSTValue,'OtherTaxes'=>$OtherTaxValue,'AfterOtherTaxes'=>$AfterOtherTaxValue,'Insurance'=>$InsuranceValue,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt);
$RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList);
//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->input->post('txtPONO');
$POdt =$this->input->post('PODate');
$PODate = $this->getDateformat($POdt);
$SupplierID = $this->input->post('drpSupplier');
$DeliveryAddr = $this->input->post('txtDeliveryAddress');
$dt = $this->input->post('Deliverydt');
//$Deliverydt = $this->getDateformat($dt);
$DeliveryOption = $this->input->post('DateRange');
if($DeliveryOption==1){
$Deliverydt = '';
$DeliverySchedule = $this->input->post('Scheduleby');
}
else{
$Deliverydt = $this->getDateformat($dt);
$DeliverySchedule = '';
}
$PaymentDate=$this->input->post('Payment');
if($PaymentDate==1)
{
$PaymentDays='After';
}
else
{
$PaymentDays='Before';
}
$POType = $this->input->post('POType');
$PoRange = $this->input->post('txtPoRange');
$SpcialInstruction = $this->input->post('SpcialInstruction');
$TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary');
$POStatus = $this->input->post('txtStatus');
$updatedBy = $this->session->userdata ( 'userId' );
$RowCount = $this->input->post('txtRowCount');
$DeletedRow = $this->input->post('txtDeletedRow');
$comma_separated = explode(':', $DeletedRow);
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$updateddt = $dt->format('Y-m-d H:i:s');
$PaymentTerms=$this->input->post('PaymentTerms');
$Payableat=$this->input->post('PayableAT');
// PO Master
// 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,'PayableAT'=>$Payableat,'PaymentDays'=>$PaymentDays);
$POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList);
$LineItemStatus = REQITEM_NEW;
//echo $RowCount;
for ($i = 1; $i <= $RowCount; $i++)
{
$MaterialCode = $this->input->post('materialCode'.$i);
$Quantity = $this->input->post('quantity'.$i);
$Reqnumber = $this->input->post('Reqnumber'.$i);
$itemRate = $this->input->post('itemRate'.$i);
$DiscountType = $this->input->post('DisType'.$i);
$DiscountValue = $this->input->post('DisVal'.$i);
$AfterDiscount = $this->input->post('AfterDisVal'.$i);
$PackagingOption = $this->input->post('PackOption'.$i);
$PackagingType = $this->input->post('PackType'.$i);
$PackagingValue = $this->input->post('PackVal'.$i);
$AfterPackagingValue = $this->input->post('AfterPackVal'.$i);
$ExciseOption = $this->input->post('ExciseOption'.$i);
$ExciseValue = $this->input->post('ExciseVal'.$i);
$AfterExciseValue = $this->input->post('AfterExciseVal'.$i);
$VatOption = $this->input->post('VatOption'.$i);
$VatValue = $this->input->post('VatVal'.$i);
$AfterVatValue = $this->input->post('AfterVatVal'.$i);
$CSTOption = $this->input->post('CSTOption'.$i);
$CSTValue = $this->input->post('CSTVal'.$i);
$AfterCSTValue = $this->input->post('AfterCSTVal'.$i);
$GSTValue = $this->input->post('GSTVal'.$i);
$AfterGSTValue = $this->input->post('AfterGSTVal'.$i);
$OtherTaxValue = $this->input->post('OtherTaxVal'.$i);
$AfterOtherTaxValue = $this->input->post('AfterOtherTaxVal'.$i);
$FreightType = $this->input->post('FreightType'.$i);
$FreightValue = $this->input->post('FreightVal'.$i);
$AfterFreightValue = $this->input->post('AfterFreightVal'.$i);
$InsuranceValue = $this->input->post('Insval'.$i);
$TotalOrderValue = $this->input->post('TotalOrderValue'.$i);
$POLineItemNo = $this->input->post('LineItemNo'.$i);
$CostCenter = $this->input->post('costCode'.$i);
$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($POLineItemNo) == 0)
{
$POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter);
$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);
$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,'ExciseDuty'=>$ExciseValue,'ExciseDutyCalulatedOn'=>$ExciseOption,'AfterExciseDuty'=>$AfterExciseValue,'Vat'=>$VatValue,'AfterVAT'=>$AfterVatValue,'VatCalulatedOn'=>$VatOption, 'CST'=>$CSTValue,'AfterCST'=>$AfterCSTValue,'CSTCalulatedOn'=>$CSTOption,'GST'=>$GSTValue,'AfterGST'=>$AfterGSTValue,'OtherTaxes'=>$OtherTaxValue,'AfterOtherTaxes'=>$AfterOtherTaxValue,'Insurance'=>$InsuranceValue,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt);
$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,'ExciseDuty'=>$ExciseValue,'ExciseDutyCalulatedOn'=>$ExciseOption,'AfterExciseDuty'=>$AfterExciseValue,'Vat'=>$VatValue,'AfterVAT'=>$AfterVatValue,'VatCalulatedOn'=>$VatOption, 'CST'=>$CSTValue,'AfterCST'=>$AfterCSTValue,'CSTCalulatedOn'=>$CSTOption,'GST'=>$GSTValue,'AfterGST'=>$AfterGSTValue,'OtherTaxes'=>$OtherTaxValue,'AfterOtherTaxes'=>$AfterOtherTaxValue,'Insurance'=>$InsuranceValue,'TotalValue'=>$TotalOrderValue, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt);
$this->purchaseorder_model->updateRevenueTax($LineItemNo,$RevenueTaxList);
}
}
}
echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ;
}
function pageNotFound()
{
$this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found';
$this->loadViews("404", $this->global, NULL, NULL);
}
public function revenuepoprint($PONO)
{
// Load all views as normal
//$PONO = $_GET['PO'];
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
$data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetailsForPDF($PONO);
// Add header to pdf
//$this->load->view('includes/pdfheader');
// Load the pdf page with multiviews
$this->load->View("revenuepopdf", $data);
// Add header to pdf
//$this->load->view('includes/pdffooter');
// Get output html
$php = $this->output->get_output();
// Load library
$this->load->library('dompdf_gen');
// Convert to PDF
$this->dompdf->load_html($php);
$this->dompdf->render();
$data['Attachment'] = FALSE;
$this->dompdf->stream("RevenuePOReport.pdf",$data,$php);
}
public function servicepoprint($PONO)
{
// $this->load->view('includes/pdfheader');
// Load the pdf page with multiviews
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
$data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetailsForPrint($PONO);
$data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO);
$this->load->View("servicepopdf", $data);
// Add header to pdf
//$this->load->view('includes/pdffooter');
// Get output html
$php = $this->output->get_output();
// Load library
$this->load->library('dompdf_gen');
// Convert to PDF
$this->dompdf->load_html($php);
$this->dompdf->render();
$data['Attachment'] = FALSE;
$this->dompdf->stream("ServicePOReport.pdf",$data,$php);
}
public function importpoprint($PONO)
{
// $this->load->view('includes/pdfheader');
// Load the pdf page with multiviews
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
$data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetailsForPDF($PONO);
$this->load->View("importpopdf", $data);
// Add header to pdf
//$this->load->view('includes/pdffooter');
// Get output html
$php = $this->output->get_output();
// Load library
$this->load->library('dompdf_gen');
// Convert to PDF
$this->dompdf->set_paper(array(0, 0, 841.89, 1190.55), 'landscape');
$this->dompdf->load_html($php);
$this->dompdf->render();
$data['Attachment'] = FALSE;
$this->dompdf->stream("ImportPOReport.pdf",$data,$php);
}
/**
* This function used to load the Delete the Requistion Items
*/
function DeletePODetails()
{
$ReqList= $this->input->post('id');
$LineItemNo = '';
$ReqNo ='';
$MaterialCode = '';
$POType = '';
if(count($ReqList) > 0)
{
$LineItemNo = $ReqList[0];
$ReqNo = $ReqList[1];
$MaterialCode = $ReqList[2];
$POType = $ReqList[3];
}
// print_r($ReqList);
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->input->post('PODate');
$PODate = $this->getDateformat($POdt);
$SupplierID = $this->input->post('drpSupplier');
$DeliveryAddr = $this->input->post('DeliveryAddr');
$dt = $this->input->post('Deliverydt');
$Deliverydt = $this->getDateformat($dt);
$POType = $this->input->post('POType');
$PoRange = $this->input->post('txtPoRange');
$DeliveryOption = $this->input->post('DateRange');
if($DeliveryOption==1){
$Deliverydt = '';
$DeliverySchedule = $this->input->post('Scheduleby');
}
else{
$Deliverydt = $this->getDateformat($dt);
$DeliverySchedule = '';
}
$PaymentDate=$this->input->post('Payment');
if($PaymentDate==1)
{
$PaymentDays='After';
}
else
{
$PaymentDays='Before';
}
//echo $PaymentDays;
//die();
$SpcialInstruction = $this->input->post('txtSpcialInstruction');
$TotalOrder = $this->input->post('txtToatlOrder');
$POStatus = $this->input->post('textStatus');
//echo "$POStatus";
//die();
$CreateBy = $this->session->userdata ( 'userId' );
$RowCount = $this->input->post('txtRowCount');
$DeletedRow = $this->input->post('txtDeletedRow');
$comma_separated = explode(':', $DeletedRow);
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$createddt = $dt->format('Y-m-d H:i:s');
$Exchangerate=$this->input->post('ExchangeRate');
$ExchangeRateCalculatedon=$this->input->post('Exchangerateon');
$CurrencyType=$this->input->post('currencytype');
$PaymentTerms=$this->input->post('PaymentTerms');
$Payableat=$this->input->post('PayableAT');
$POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'PayableAT'=>$Payableat,'PaymentDays'=>$PaymentDays,'POType'=>$POType);
//print_r($POList);PaymentDays
//die();
$POMaster = $this->purchaseorder_model->addPOMaster($POList);
$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->input->post('materialCode'.$i);
$Quantity = $this->input->post('quantity'.$i);
$Reqnumber = $this->input->post('Reqnumber'.$i);
$itemRate = $this->input->post('itemRate'.$i);
//$Exchangerate = $this->input->post('Exchangerate'.$i);
$BasicPriceinmton = $this->input->post('BasicPriceinUS'.$i);
$Productprice = $this->input->post('BasicAmt'.$i);
$LandingCharge = $this->input->post('LandingChargee'.$i);
$AfterLandingCharge = $this->input->post('AfterLandingChargee'.$i);
$HighSeas = $this->input->post('Highseass'.$i);
$AfterHighSeas = $this->input->post('AfterHighseass'.$i);
$CustomDuty = $this->input->post('Customduty'.$i);
$AfterCustomDuty = $this->input->post('AfterCustomduty'.$i);
$ExciseDuty = $this->input->post('ExcisedutyTax'.$i);
$AfterExciseDuty = $this->input->post('AfterExcisedutyTax'.$i);
$ExciseDutyEd = $this->input->post('ExcisedutyED'.$i);
$AfterExciseDutyEd = $this->input->post('AfterExcisedutyED'.$i);
$ExciseDutySH = $this->input->post('ExcisedutySH'.$i);
$AfterExciseDutySH = $this->input->post('AfterExcisedutySH'.$i);
$CustomEd= $this->input->post('CustomEDcess'.$i);
$AfterCustomEd= $this->input->post('AfterCustomEDcess'.$i);
$CustomSH = $this->input->post('CustomSHcess'.$i);
$AfterCustomSH = $this->input->post('AfterCustomSHcess'.$i);
$AddAdtional = $this->input->post('AdditionalExciseduty'.$i);
$AfterAddAdtional = $this->input->post('AfterAdditionalExciseduty'.$i);
$Grossdutypayable = $this->input->post('Grossdutypayable'.$i);
$AvailableModvat = $this->input->post('AvilableModvat'.$i);
$Grossexpensesduetocustomduty = $this->input->post('Grossexpenses'.$i);
$purchaseratePerKG = $this->input->post('purchaserate'.$i);
$CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpenses'.$i);
$RMCIncludingCustomersPerKG = $this->input->post('RMCIncludingCustomers'.$i);
$QuantityKG = $this->input->post('PurQuantity'.$i);
//$currencytypeID = $this->input->post('currencytype');
$Totalvalueitem=$this->input->post('TotalExp'.$i);
//echo $BasicPriceinmton;
$CostCenter = $this->input->post('costCode'.$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);
$POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
$LineItemNo = '';
if(count($POLineItem)>0)
{
$LineItemNo = $POLineItem[0]['LineItemNo'];
}
//echo $LineItemNo;
if(trim($POType) == IMPORT )
{
// echo 'Success';
$ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem);
//print_r($ImportTaxList);
//die();
$ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList);
}
}
}
echo 'Purchase Order Created Successfully! PO Number Is: '.$PONO ;
}
function EditImportPurchaseOrder()
{
$PONO =$this->input->post('txtPONO');
$POdt = '';
$createddt='';
$PODate = $this->getDateformat($POdt);
$SupplierID = $this->input->post('drpSupplier');
$DeliveryAddr = $this->input->post('DeliveryAddr');
$dt = $this->input->post('Deliverydt');
$Deliverydt = $this->getDateformat($dt);
$POType = $this->input->post('POType');
$PoRange = $this->input->post('txtPoRange');
$DeliveryOption = $this->input->post('DateRange');
$Exchangerate=$this->input->post('ExchangeRate');
$ExchangeRateCalculatedon=$this->input->post('Exchangerateon');
$CurrencyType=$this->input->post('currencytype');
if($DeliveryOption==1){
$Deliverydt = '';
$DeliverySchedule = $this->input->post('Scheduleby');
}
else{
$Deliverydt = $this->getDateformat($dt);
$DeliverySchedule = '';
}
$PaymentDate=$this->input->post('Payment');
if($PaymentDate==1)
{
$PaymentDays='After';
}
else
{
$PaymentDays='Before';
}
$SpcialInstruction = $this->input->post('txtSpcialInstruction');
$TotalOrder = $this->input->post('txtToatlOrder');
$POStatus = $this->input->post('txtStatus');
$CreateBy = $this->session->userdata ( 'userId' );
$RowCount = $this->input->post('txtRowCount');
$DeletedRow = $this->input->post('txtDeletedRow');
$comma_separated = explode(':', $DeletedRow);
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$updateddt = $dt->format('Y-m-d H:i:s');
$PaymentTerms=$this->input->post('PaymentTerms');
$Payableat=$this->input->post('PayableAT');
// PO Master
// PO Master
$POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'PayableAT'=>$Payableat,'PaymentDays'=>$PaymentDays);
//echo $PONO;
//echo $TotalOrder;
//print_r($POList);
//die();
$POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList);
$LineItemStatus = REQITEM_NEW;
//echo $RowCount;
for ($i = 1; $i <= $RowCount; $i++)
{
$MaterialCode = $this->input->post('materialCode'.$i);
$Quantity = $this->input->post('quantity'.$i);
$Reqnumber = $this->input->post('Reqnumber'.$i);
$itemRate = $this->input->post('itemRate'.$i);
//$Exchangerate = $this->input->post('Exchangerate'.$i);
$BasicPriceinmton = $this->input->post('BasicPriceinUS'.$i);
$Productprice = $this->input->post('BasicAmt'.$i);
$LandingCharge = $this->input->post('LandingChargee'.$i);
$AfterLandingCharge = $this->input->post('AfterLandingChargee'.$i);
$HighSeas = $this->input->post('Highseass'.$i);
$AfterHighSeas = $this->input->post('AfterHighseass'.$i);
$CustomDuty = $this->input->post('Customduty'.$i);
$AfterCustomDuty = $this->input->post('AfterCustomduty'.$i);
$ExciseDuty = $this->input->post('ExcisedutyTax'.$i);
$AfterExciseDuty = $this->input->post('AfterExcisedutyTax'.$i);
$ExciseDutyEd = $this->input->post('ExcisedutyED'.$i);
$AfterExciseDutyEd = $this->input->post('AfterExcisedutyED'.$i);
$ExciseDutySH = $this->input->post('ExcisedutySH'.$i);
$AfterExciseDutySH = $this->input->post('AfterExcisedutySH'.$i);
$CustomEd= $this->input->post('CustomEDcess'.$i);
$AfterCustomEd= $this->input->post('AfterCustomEDcess'.$i);
$CustomSH = $this->input->post('CustomSHcess'.$i);
$AfterCustomSH = $this->input->post('AfterCustomSHcess'.$i);
$AddAdtional = $this->input->post('AdditionalExciseduty'.$i);
$AfterAddAdtional = $this->input->post('AfterAdditionalExciseduty'.$i);
$Grossdutypayable = $this->input->post('Grossdutypayable'.$i);
$AvailableModvat = $this->input->post('AvilableModvat'.$i);
$Grossexpensesduetocustomduty = $this->input->post('Grossexpenses'.$i);
$purchaseratePerKG = $this->input->post('purchaserate'.$i);
$CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpenses'.$i);
$RMCIncludingCustomersPerKG = $this->input->post('RMCIncludingCustomers'.$i);
$QuantityKG = $this->input->post('PurQuantity'.$i);
$POLineItemNo = $this->input->post('LineItemNo'.$i);
$CostCenter = $this->input->post('costCode'.$i);
$ExciseDutySH = $this->input->post('ExcisedutySH'.$i);
$Totalvalueitem=$this->input->post('TotalExp'.$i);
$LineItemNo = '';
//$currencytypeID = $this->input->post('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;
}
}
}
if($SkipInsert == "False")
{
if(strlen($POLineItemNo) == 0)
{
$POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter);
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);
$POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$POLineItemNo,$POLineItemList);
}
$isExists = $this->purchaseorder_model->LineItemExistsinImportTax($LineItemNo);
if(count($isExists) == 0)
{
$ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem);
//print_r($ImportTaxList);
//die();
$ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList);
}
else
{
$ImportTaxList = array('LineItemNo'=>$LineItemNo, 'ExchangeRate'=>$Exchangerate,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'CurrencyType'=>$currencytypeID,'TotalValue'=>$Totalvalueitem);
//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="A";
$this->global['pageTitle'] = 'Siddharth : Purchase Order Approval';
// $data['Status']= $this->purchaseorder_model->getStatus();
$userID = $this->session->userdata ( 'userId' );
//print_r($data['Status']);echo "CON";
$data['AppList'] = $this->purchaseorder_model->getPOList($q);
$this->loadViews("poapproval_view", $this->global,$data, NULL);
}
function getDateformat2($Val)
{
$date = new DateTime($Val);
$retDate = $date->format('Y-m-d H:i:s');
return $retDate;
}
function ApprovePO()
{
$StatusCode= Trim($_POST['SCode']);
$PONO= Trim($_POST['PONO']);
$Remarks= Trim($_POST['NewRemarks']);
$ApprovedBy = $this->session->userdata ( 'userId' );
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$ApprovedDate = $dt->format('Y-m-d H:i:s');
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="R";
$this->global['pageTitle'] = 'Siddharth : Purchase Order Release';
// $data['Status']= $this->purchaseorder_model->getStatus();
$userID = $this->session->userdata ( '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->userdata ( 'userId' );
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$ReleasedDate = $dt->format('Y-m-d H:i:s');
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;
}
else{
$store = array('Status'=>$StatusCode,'OnHoldOn'=>$ReleasedOn,'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->input->post('PODate');
$PODate = $this->getDateformat($POdt);
$SupplierID = $this->input->post('drpSupplier');
$DeliveryAddr = $this->input->post('DeliveryAddr');
$dt = $this->input->post('Deliverydt');
$POType = $this->input->post('POType');
$PoRange = $this->input->post('txtPoRange');
$DeliveryOption = $this->input->post('DateRange');
if($DeliveryOption==1){
$Deliverydt = '';
$DeliverySchedule = $this->input->post('Scheduleby');
}
else{
$Deliverydt = $this->getDateformat($dt);
$DeliverySchedule = '';
}
$ExchangeRateOn = $this->input->post('ExchangeRateOn');
$PaymentMethod = $this->input->post('PaymentMethod');
$PayableAT = $this->input->post('PayableAT');
$PaymentDate=$this->input->post('PaymentDate');
$SpcialInstruction = $this->input->post('txtSpcialInstruction');
$TotalOrder = $this->input->post('CapitalToatlOrder');
$POStatus = $this->input->post('txtStatus');
$CreateBy = $this->session->userdata ( 'userId' );
$RowCount = $this->input->post('txtRowCount');
$DeletedRow = $this->input->post('txtDeletedRow');
$comma_separated = explode(':', $DeletedRow);
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$createddt = $dt->format('Y-m-d H:i:s');
$POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ExchangeRate'=>$ExchangeRateOn,'PaymentTerms'=>$PaymentMethod,'PaymentDays'=>$PaymentDate,'PayableAt'=>$PayableAT,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'POType'=>$POType);
$POMaster = $this->purchaseorder_model->addPOMaster($POList);
$PONO = '';
if(count($POMaster)>0)
{
$PONO = $POMaster[0]['PONO'];
}
$LineItemStatus = REQITEM_NEW;
for ($i = 1; $i <= $RowCount; $i++)
{
$MaterialCode = $this->input->post('materialCode'.$i);
$Quantity = $this->input->post('quantity'.$i);
$Reqnumber = $this->input->post('Reqnumber'.$i);
$itemRate = $this->input->post('itemRate'.$i);
$Exchangerate = $this->input->post('echangeRate'.$i);
$BasicPriceinmton = $this->input->post('rateInUs'.$i);
$Productprice = $this->input->post('basicval'.$i);
$LandingCharge = $this->input->post('beforeLanding'.$i);
$AfterLandingCharge = $this->input->post('landingCharge'.$i);
$HighSeas = $this->input->post('beforeHighSeasSalesCharge'.$i);
$AfterHighSeas = $this->input->post('HighSeasSalesCharge'.$i);
$CustomDuty = $this->input->post('beforeCustomDuty'.$i);
$AfterCustomDuty = $this->input->post('CustomDuty'.$i);
$ExciseDuty = $this->input->post('beforeExciseDuty'.$i);
$AfterExciseDuty = $this->input->post('ExciseDuty'.$i);
$ExciseDutyEd = $this->input->post('beforeExciseDutyEDCess'.$i);
$AfterExciseDutyEd = $this->input->post('ExciseDutyEDCess'.$i);
$ExciseDutySH = $this->input->post('beforeExciseDutySHCess'.$i);
$AfterExciseDutySH = $this->input->post('ExciseDutySHCess'.$i);
$CustomEd= $this->input->post('beforeCustomEDCess'.$i);
$AfterCustomEd= $this->input->post('CustomEDCess'.$i);
$CustomSH = $this->input->post('beforeCustomSHCess'.$i);
$AfterCustomSH = $this->input->post('CustomSHCess'.$i);
$AddAdtional = $this->input->post('beforeAdditionalExciseDuty'.$i);
$AfterAddAdtional = $this->input->post('AdditionalExciseDuty'.$i);
$Grossdutypayable = $this->input->post('GrossDutyPayable'.$i);
$AvailableModvat = $this->input->post('AvailableModvat'.$i);
$Grossexpensesduetocustomduty = $this->input->post('GrossExpensesDuetoCustom'.$i);
$purchaseratePerKG = $this->input->post('purchaseRate'.$i);
$CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpenses'.$i);
$RMCIncludingCustomersPerKG = $this->input->post('RMCIncludingCustomers'.$i);
$QuantityKG = $this->input->post('PurQuantity'.$i);
$currencytypeID = $this->input->post('currencytype');
$Totalvalueitem=$this->input->post('PerKgExpense'.$i);
//echo $BasicPriceinmton;
$CostCenter = $this->input->post('CPCostCode'.$i);
$ServiceTax = $this->input->post('AfterServiceTax'.$i);
$EduCess = $this->input->post('AfterEduCess'.$i);
$SecHighTax = $this->input->post('AfterSecHighTax'.$i);
$KrishiTax = $this->input->post('AfterKrishiTax'.$i);
$SwachhTax = $this->input->post('AfterSwachhTax'.$i);
$TotalOrderValue = $this->input->post('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")
{
$POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter);
$POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
$LineItemNo = '';
if(count($POLineItem)>0)
{
$LineItemNo = $POLineItem[0]['LineItemNo'];
}
//echo $LineItemNo;
if(trim($POType) == CAPITAL )
{
$ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt);
$ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList);
$ImportTaxList = array('LineItemNo'=>$LineItemNo, 'ExchangeRate'=>$Exchangerate,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'CurrencyType'=>$currencytypeID,'TotalValue'=>$Totalvalueitem);
//print_r($ImportTaxList);
//die();
$ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList);
}
}
}
echo 'Purchase Order Created Successfully! PO Number Is: '.$PONO ;
}
/*Edit Capital po*/
function EditCapitalPurchaseOrder()
{
$PONO =$this->input->post('txtPONO');
$POdt =$this->input->post('PODate');
$PODate = $this->getDateformat($POdt);
$SupplierID = $this->input->post('drpSupplier');
$DeliveryAddr = $this->input->post('DeliveryAddr');
$dt = $this->input->post('Deliverydt');
$POType = $this->input->post('POType');
$PoRange = $this->input->post('txtPoRange');
$DeliveryOption = $this->input->post('DateRange');
if($DeliveryOption==1){
$Deliverydt = '';
$DeliverySchedule = $this->input->post('Scheduleby');
}
else{
$Deliverydt = $this->getDateformat($dt);
$DeliverySchedule = '';
}
$ExchangeRateOn = $this->input->post('ExchangeRateOn');
$PaymentMethod = $this->input->post('PaymentMethod');
$PayableAT = $this->input->post('PayableAT');
$PaymentDate=$this->input->post('PaymentDate');
$SpcialInstruction = $this->input->post('txtSpcialInstruction');
$TotalOrder = $this->input->post('CapitalToatlOrder');
$POStatus = $this->input->post('txtStatus');
$CreateBy = $this->session->userdata ( 'userId' );
$RowCount = $this->input->post('txtRowCount');
$DeletedRow = $this->input->post('txtDeletedRow');
$comma_separated = explode(':', $DeletedRow);
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$createddt = $dt->format('Y-m-d H:i:s');
$updateddt = $dt->format('Y-m-d H:i:s');
$POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ExchangeRate'=>$ExchangeRateOn,'PaymentTerms'=>$PaymentMethod,'PaymentDays'=>$PaymentDate,'PayableAt'=>$PayableAT,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption);
$POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList);
$LineItemStatus = REQITEM_NEW;
for ($i = 1; $i <= $RowCount; $i++)
{
$MaterialCode = $this->input->post('materialCode'.$i);
$Quantity = $this->input->post('quantity'.$i);
$Reqnumber = $this->input->post('Reqnumber'.$i);
$itemRate = $this->input->post('itemRate'.$i);
$Exchangerate = $this->input->post('echangeRate'.$i);
$BasicPriceinmton = $this->input->post('rateInUs'.$i);
$Productprice = $this->input->post('basicval'.$i);
$LandingCharge = $this->input->post('beforeLanding'.$i);
$AfterLandingCharge = $this->input->post('landingCharge'.$i);
$HighSeas = $this->input->post('beforeHighSeasSalesCharge'.$i);
$AfterHighSeas = $this->input->post('HighSeasSalesCharge'.$i);
$CustomDuty = $this->input->post('beforeCustomDuty'.$i);
$AfterCustomDuty = $this->input->post('CustomDuty'.$i);
$ExciseDuty = $this->input->post('beforeExciseDuty'.$i);
$AfterExciseDuty = $this->input->post('ExciseDuty'.$i);
$ExciseDutyEd = $this->input->post('beforeExciseDutyEDCess'.$i);
$AfterExciseDutyEd = $this->input->post('ExciseDutyEDCess'.$i);
$ExciseDutySH = $this->input->post('beforeExciseDutySHCess'.$i);
$AfterExciseDutySH = $this->input->post('ExciseDutySHCess'.$i);
$CustomEd= $this->input->post('beforeCustomEDCess'.$i);
$AfterCustomEd= $this->input->post('CustomEDCess'.$i);
$CustomSH = $this->input->post('beforeCustomSHCess'.$i);
$AfterCustomSH = $this->input->post('CustomSHCess'.$i);
$AddAdtional = $this->input->post('beforeAdditionalExciseDuty'.$i);
$AfterAddAdtional = $this->input->post('AdditionalExciseDuty'.$i);
$Grossdutypayable = $this->input->post('GrossDutyPayable'.$i);
$AvailableModvat = $this->input->post('AvailableModvat'.$i);
$Grossexpensesduetocustomduty = $this->input->post('GrossExpensesDuetoCustom'.$i);
$purchaseratePerKG = $this->input->post('purchaseRate'.$i);
$CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpenses'.$i);
$RMCIncludingCustomersPerKG = $this->input->post('RMCIncludingCustomers'.$i);
$QuantityKG = $this->input->post('PurQuantity'.$i);
$currencytypeID = $this->input->post('currencytype');
$Totalvalueitem=$this->input->post('PerKgExpense'.$i);
//echo $BasicPriceinmton;
$CostCenter = $this->input->post('CPCostCode'.$i);
$ServiceTax = $this->input->post('AfterServiceTax'.$i);
$EduCess = $this->input->post('AfterEduCess'.$i);
$SecHighTax = $this->input->post('AfterSecHighTax'.$i);
$KrishiTax = $this->input->post('AfterKrishiTax'.$i);
$SwachhTax = $this->input->post('AfterSwachhTax'.$i);
$TotalOrderValue = $this->input->post('TotalOrderValue'.$i);
$POLineItemNo = $this->input->post('LineItemNo'.$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")
{
if(strlen($POLineItemNo) == 0)
{
$POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter);
$POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
$LineItemNo = '';
if(count($POLineItem)>0)
{
$LineItemNo = $POLineItem[0]['LineItemNo'];
}
//echo $LineItemNo;
if(trim($POType) == CAPITAL )
{
$ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt);
$ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList);
$ImportTaxList = array('LineItemNo'=>$LineItemNo, 'ExchangeRate'=>$Exchangerate,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'CurrencyType'=>$currencytypeID,'TotalValue'=>$Totalvalueitem);
//print_r($ImportTaxList);
//die();
$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);
$POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$LineItemNo,$POLineItemList);
$ServiceTaxList = array('ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt);
$ServiceTax = $this->purchaseorder_model->updateServiceTax($LineItemNo,$ServiceTaxList);
$ImportTaxList = array('LineItemNo'=>$LineItemNo, 'ExchangeRate'=>$Exchangerate,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'AfterHighSeasSalesCharge'=>$AfterHighSeas,'HighSeasSalesCharge'=>$HighSeas,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'ExciseDuty'=>$ExciseDuty,'AfterExciseDuty'=>$AfterExciseDuty,'ExciseDutyEdCess'=>$ExciseDutyEd,'AfterExciseDutyEdCess'=>$AfterExciseDutyEd,'ExciseDutySHCess'=>$ExciseDutySH,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'AddlExciseDuty'=>$AddAdtional,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'AfterExciseDutySHCess'=>$AfterExciseDutySH,'AfterAddlExciseDuty'=>$AfterAddAdtional,'Grossdutypayable'=>$Grossdutypayable,'AvailableModvat'=>$AvailableModvat,'Grossexpensesduetocustomduty'=>$Grossexpensesduetocustomduty,'purchaseratePerKG'=>$purchaseratePerKG,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'RMCIncludingCustomersPerKG'=>$RMCIncludingCustomersPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'CurrencyType'=>$currencytypeID,'TotalValue'=>$Totalvalueitem);
$ImportList= $this->purchaseorder_model->updateImportTax($LineItemNo,$ImportTaxList);
}
}
}
echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ;
}
/* capital po print/pdf*/
public function CapitalPoPrint($PONO)
{
// Load the pdf page with multiviews
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
$data['POItem'] = $this->purchaseorder_model->GetCapitalPurchaseOrderDetailsForPDF($PONO);
$totalAmt = $data['POItem'][0]->TotalOrderValue." "."Only";
$data['requestedBy'] = $this->purchaseorder_model->GetRequesedByDetails($PONO);
$data['TotalAmountInWords']=$this->convertNumber($totalAmt);
$this->load->View("capitalpopdf", $data);
// Add header to pdf
//$this->load->view('includes/pdffooter');
// Get output html
$php = $this->output->get_output();
// Load library
$this->load->library('dompdf_gen');
// Convert to PDF
$this->dompdf->load_html($php);
$this->dompdf->render();
$data['Attachment'] = FALSE;
$this->dompdf->stream("CapitalPOReport.pdf",$data,$php);
}
/*This function is used to convert amount(digit) into words*/
public function convertNumber($number)
{
list($integer, $fraction) = explode(".", (string) $number);
$output = "Rupee"." ";
if ($integer{0} == "-")
{
$output = "negative ";
$integer = ltrim($integer, "-");
}
else if ($integer{0} == "+")
{
$output = "positive ";
$integer = ltrim($integer, "+");
}
if ($integer{0} == "0")
{
$output .= "zero";
}
else
{
$integer = str_pad($integer, 36, "0", STR_PAD_LEFT);
$group = rtrim(chunk_split($integer, 3, " "), " ");
$groups = explode(" ", $group);
$groups2 = array();
foreach ($groups as $g)
{
$groups2[] = $this->convertThreeDigit($g{0}, $g{1}, $g{2});
}
for ($z = 0; $z < count($groups2); $z++)
{
if ($groups2[$z] != "")
{
$output .= $groups2[$z] . $this->convertGroup(11 - $z) . (
$z < 11
&& !array_search('', array_slice($groups2, $z + 1, -1))
&& $groups2[11] != ''
&& $groups[11]{0} == '0'
? " "
: ", "
);
}
}
$output = rtrim($output, ", ");
}
if ($fraction > 0)
{
$output .= " paise";
for ($i = 0; $i < strlen($fraction); $i++)
{
$output .= " " . $this->convertDigit($fraction{$i});
}
}
return $output;
}
public function convertGroup($index)
{
switch ($index)
{
case 11:
return " decillion";
case 10:
return " nonillion";
case 9:
return " octillion";
case 8:
return " septillion";
case 7:
return " sextillion";
case 6:
return " quintrillion";
case 5:
return " quadrillion";
case 4:
return " trillion";
case 3:
return " billion";
case 2:
return " million";
case 1:
return " thousand";
case 0:
return "";
}
}
public function convertThreeDigit($digit1, $digit2, $digit3)
{
$buffer = "";
if ($digit1 == "0" && $digit2 == "0" && $digit3 == "0")
{
return "";
}
if ($digit1 != "0")
{
$buffer .= $this->convertDigit($digit1) . " hundred";
if ($digit2 != "0" || $digit3 != "0")
{
$buffer .= " and ";
}
}
if ($digit2 != "0")
{
$buffer .= $this->convertTwoDigit($digit2, $digit3);
}
else if ($digit3 != "0")
{
$buffer .= $this->convertDigit($digit3);
}
return $buffer;
}
public function convertTwoDigit($digit1, $digit2)
{
if ($digit2 == "0")
{
switch ($digit1)
{
case "1":
return "ten";
case "2":
return "twenty";
case "3":
return "thirty";
case "4":
return "forty";
case "5":
return "fifty";
case "6":
return "sixty";
case "7":
return "seventy";
case "8":
return "eighty";
case "9":
return "ninety";
}
} else if ($digit1 == "1")
{
switch ($digit2)
{
case "1":
return "eleven";
case "2":
return "twelve";
case "3":
return "thirteen";
case "4":
return "fourteen";
case "5":
return "fifteen";
case "6":
return "sixteen";
case "7":
return "seventeen";
case "8":
return "eighteen";
case "9":
return "nineteen";
}
} else
{
$temp = $this->convertDigit($digit2);
switch ($digit1)
{
case "2":
return "twenty-$temp";
case "3":
return "thirty-$temp";
case "4":
return "forty-$temp";
case "5":
return "fifty-$temp";
case "6":
return "sixty-$temp";
case "7":
return "seventy-$temp";
case "8":
return "eighty-$temp";
case "9":
return "ninety-$temp";
}
}
}
public function convertDigit($digit)
{
switch ($digit)
{
case "0":
return "zero";
case "1":
return "one";
case "2":
return "two";
case "3":
return "three";
case "4":
return "four";
case "5":
return "five";
case "6":
return "six";
case "7":
return "seven";
case "8":
return "eight";
case "9":
return "nine";
}
}
}
?>