diff --git a/application/controllers/amendmentpurchaseorder.php b/application/controllers/amendmentpurchaseorder.php
index 5173e84c..3f2a5ee6 100755
--- a/application/controllers/amendmentpurchaseorder.php
+++ b/application/controllers/amendmentpurchaseorder.php
@@ -62,6 +62,8 @@ class amendmentpurchaseorder extends BaseController
endforeach;
$data['MaterialList'] = $result;//$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray);
$data['Suplist'] = $this->purchaseorder_model->getSupplierName();
+ $data['Payment']=$this->purchaseorder_model->getSupplierPayment();
+ //print_r($data['Payment']);
/* Cost code from Requisition - Client Review Fix
Start here */
$ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray);
@@ -92,13 +94,19 @@ class amendmentpurchaseorder extends BaseController
{
$data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetails($PONO);
+ $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO);
+ $data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019');
$this->global['pageTitle'] = 'Siddharth : Edit Service Purchase order form';
$this->loadViews("editServiceAmendPO", $this->global, $data, NULL);
}
else if($ReqType == REVENUE)
{
-
+ //$data['Payment']=$this->purchaseorder_model->getSupplierPayment();
+ $data['POSTATUS']=$this->purchaseorder_model->GetPOStatus($PONO);
$data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetails($PONO);
+ $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO);
+ echo "FROM CON";
+ //print_r($data['Payment']);
$this->global['pageTitle'] = 'Siddharth : Edit Revenue Purchase order form';
$this->loadViews("editRevenueAmendPO", $this->global, $data, NULL);
}
@@ -157,7 +165,7 @@ class amendmentpurchaseorder extends BaseController
{
$NewPO='0';
$PONO =$this->input->post('txtPONO');
- echo "OLD PO IS" . $PONO;
+ // echo "OLD PO IS" . $PONO;
$POdt =$this->input->post('PODate');
$PODate = $this->getDateformat($POdt);
@@ -176,6 +184,22 @@ class amendmentpurchaseorder extends BaseController
}
$POType = $this->input->post('POType');
$PoRange = $this->input->post('txtPoRange');
+ $PaymentTerms=$this->input->post('PaymentTerms');
+ $PayableAT=$this->input->post('PayableAT');
+ $PaymentDate=$this->input->post('Payment');
+
+ if($PaymentDate==1)
+ {
+ $PaymentDays='After';
+ }
+ else
+ {
+ $PaymentDays='Before';
+ }
+ // echo $PaymentTerms;
+ // echo $PayableAT;
+ // echo $PaymentDays;
+ // echo "FINAL";
$SpcialInstruction = $this->input->post('SpcialInstruction');
$TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary');
@@ -193,15 +217,15 @@ class amendmentpurchaseorder extends BaseController
$updateddt = $dt->format('Y-m-d H:i:s');
// PO Master
// PO Master
- $POMaster = array('ParentPO'=>$PONO,'SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>'ST015','DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt );
+ $POMaster = array('ParentPO'=>$PONO,'SupplierID'=>$SupplierID,'PaymentTerms'=> $PaymentTerms,'PayableAT'=>$PayableAT,'PaymentDays'=>$PaymentDays,'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>'ST015','DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt );
//$POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList);
$LastPO = $this->purchaseorder_model->addPOMaster($POMaster);
foreach($LastPO as $PO):
- $NewPO=$PO->PONO;
+ $NewPO=$PO['PONO'];
endforeach;
- echo "NEW PO IS " . $NewPO;
- echo "";
+ //echo "NEW PO IS " . $NewPO;
+ //echo "";
//change old po status as Amendment
$PODetail=array('Status'=>"ST030");//TO SET PARENT PO AS AMENDMENT STATUS
print_r($PODetail);
@@ -215,7 +239,7 @@ class amendmentpurchaseorder extends BaseController
- echo 'before for loop';
+ //echo 'before for loop';
echo $RowCount;
for ($i = 1; $i <= $RowCount; $i++)
@@ -277,13 +301,15 @@ class amendmentpurchaseorder extends BaseController
// {
$POLineItemList = array('PONO'=>$NewPO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter);
print_r($POLineItemList);
+ //die();
+
$POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
// if(count($POLineItem)>0)
// {
foreach($POLineItem as $line):
$LineItemNo = $line->LineItemNo;
endforeach;
- echo "Lineitem no is" . $LineItemNo;
+ //echo "Lineitem no is" . $LineItemNo;
//print_r($LineItemNo);
// }
@@ -303,6 +329,7 @@ class amendmentpurchaseorder extends BaseController
$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);
+ echo "DONE ALL";
// }
// else
@@ -315,7 +342,180 @@ class amendmentpurchaseorder extends BaseController
}
echo 'Purchase Order Amended Successfully! PO Number Is: '.$PONO .'- New PO Number is'.$NewPO;
- }
+ }
+
+
+
+function UpdateAmendServicePurchaseOrder()
+ {
+ $PONO =$this->input->post('txtPONO');
+ $NewPO='0';
+ //echo $PONO;
+ $POdt =$this->input->post('PODate');
+ $PODate = $this->getDateformat($POdt);
+
+ $SupplierID = $this->input->post('drpSupplier');
+ $DeliveryAddr = $this->input->post('txtDeliveryAddress');
+ $dt = $this->input->post('Deliverydt');
+ $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';
+ }
+
+ $PaymentTerms=$this->input->post('PaymentTerms');
+ $Payableat=$this->input->post('PayableAT');
+
+ $POType = $this->input->post('POType');
+
+ $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');
+ // echo "ROw Count is" . $RowCount;
+
+ // $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');
+ $WorkStatus=$this->input->post('workstatus');
+
+
+ // PO Master
+ $POMaster = array('ParentPO'=>$PONO,'POType'=>$POType,'SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$updateddt,'PaymentTerms'=>$PaymentTerms,'PayableAT'=>$Payableat,'PaymentDays'=>$PaymentDays,'ServiceWorkStatus'=>$WorkStatus );
+ //print_r($POMaster);
+ $LastPO = $this->purchaseorder_model->addPOMaster($POMaster);
+ //print_r($LastPO);
+ foreach($LastPO as $PO):
+ $NewPO=$PO['PONO'];
+ endforeach;
+ //echo "NEW PO IS " . $NewPO;
+ //echo "";
+
+ $PODetail=array('Status'=>"ST030");//TO SET PARENT PO AS AMENDMENT STATUS
+ //print_r($PODetail);
+ $APO=$this->purchaseorder_model->updateAmendPOMaster($PONO,$PODetail);
+ //echo $APO."Affected";
+
+ $LineItemStatus = REQITEM_NEW;
+ //echo "Before For Loop" ;
+ //echo $RowCount;
+
+ for ($i = 1; $i <= $RowCount; $i++)
+ {
+
+ //echo "Inside Loop";
+
+ $MaterialCode = $this->input->post('materialCode'.$i);
+ $Quantity = $this->input->post('quantity'.$i);
+ $Reqnumber = $this->input->post('Reqnumber'.$i);
+ $itemRate = $this->input->post('itemRate'.$i);
+ $ServiceTax = $this->input->post('ServiceTax'.$i);
+ $EduCess = $this->input->post('EduCess'.$i);
+ $SecHighTax = $this->input->post('SecHighTax'.$i);
+ $KrishiTax = $this->input->post('KrishiTax'.$i);
+ $SwachhTax = $this->input->post('SwachhTax'.$i);
+ $CostCenter = $this->input->post('costCode'.$i);
+ $POLineItemNo = $this->input->post('LineItemNo'.$i);
+ $TotalOrderValue = $this->input->post('TotalOrderValue'.$i);
+ $ServiceFrequency=$this->input->post('Frequency'.$i);
+ // echo $MaterialCode;
+ //$POLineItem = array();
+ $LineItemNo = '';
+ //echo "LineItem is". $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'=>$NewPO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency);
+ //print_r($POLineItemList);
+
+ $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList);
+ // if(count($POLineItem)>0)
+ // {
+ foreach($POLineItem as $line):
+ $LineItemNo = $line->LineItemNo;
+ endforeach;
+ // echo " Last Lineitem no is" . $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);
+
+ // }
+
+
+
+ // if(trim($POType) == SERVICE )
+ // {
+ // $isExists = $this->purchaseorder_model->LineItemExists($LineItemNo);
+
+ // if(count($isExists) == 0)
+ // {
+ $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt);
+ //echo "Service to be stored";
+
+ //print_r($ServiceTaxList);
+ $ServiceList =$this->purchaseorder_model->addServiceTax($ServiceTaxList);
+ //echo "final";
+ //print_r($ServiceList);
+
+
+ // }
+ // else
+ // {
+ // $ServiceTaxList1 = array('ServiceTax'=>$ServiceTax,'EducessTax'=>$EduCess,'SecHigherEducessTax'=>$SecHighTax,'KrishiKalyantax'=>$KrishiTax,'SwachhBharattax'=>$SwachhTax,'TotalValue'=>$TotalOrderValue, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt);
+
+ // $this->purchaseorder_model->updateServiceTax($LineItemNo,$ServiceTaxList1);
+
+ // }
+
+ //}
+
+ //}
+ }
+ echo 'PO Number'.$PONO . ' Amended Successfully! - New PO Number is'.$NewPO;
+ }
@@ -327,71 +527,5 @@ class amendmentpurchaseorder extends BaseController
$retDate = $date->format('Y-m-d H:i:s');
return $retDate;
}
- /* ---------------------------------OLD AMENDPO FUNCTION-----------------------------------------------*/
- function getpodetails()
- {
- $PONO=$this->input->post('pono');
- //$PONO='PO0001';
- $result = $this->amendment_model->getPODetails($PONO);
- // print_r($result);
- $obj=json_encode($result);
- echo $obj;
- //print_r($obj);
- //die();
-
-
- }
-
- function updatepo(){
- $someArray = $_GET['jsondata'];
- //$PONO = $_GET['pono'];
- $PONO = $this->input->get('PONO');
- $rowsaffected=0;
- $porow=0;
-
- //echo $PONO."";
- // print_r($someArray);
- $d=json_decode($someArray);
- ////print_r( $d);
- foreach($d as $d1){
- $MaterialCode=$d1->ItemCode;
- $Quantity=$d1->Ordered_Quantity;
- $ReceivedQuantity=$d1->Additional_Quantity_Received;
- $Remarks=$d1->Remarks;
- $Status='ST031';
- $POstatus='ST030';
- $store=array('Quantity'=>$Quantity,'AmendmentQuantity'=>$ReceivedQuantity,'AmendmentRemarks'=>$Remarks,'Status'=>$Status);
- //print_r($store);
- $result=$this->amendment_model->updatePODetails($PONO,$MaterialCode,$store,$POstatus);
- $rowsaffected++;
-
-
-
- }
- echo "";
- $data['PODetails']=$this->amendment_model->getPONO();
- $this->global['pageTitle'] = 'Siddharth : Amendment Purchase Order';
-
- $this->loadviews('amendmentpo',$this->global, NULL);
-
-
-
- }
- function amendmentpolisting()
- {
- $this->global['pageTitle'] = 'Siddharth : Amendment Purchase Order';
-
- $data['POlisiting']=$this->amendment_model->getPOlist();
- //echo "From CON.";
- //print_r($data);
- $this->loadviews('amendmentpolisting',$this->global,$data);
- }
-
- function pageNotFound()
- {
- $this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found';
-
- $this->loadViews("404", $this->global, NULL, NULL);
- }
}
\ No newline at end of file
diff --git a/application/models/purchaseorder_model.php b/application/models/purchaseorder_model.php
index d9357036..4566c06b 100755
--- a/application/models/purchaseorder_model.php
+++ b/application/models/purchaseorder_model.php
@@ -30,7 +30,7 @@ class purchaseorder_model extends CI_Model
* @return array $result : This is result
*/
-function purchaseorderListing()
+function purchaseorderListing($forwhat='')
{
$this->db->distinct();
$this->db->select('POMast.PONO,supp.SupplierName,TotalOrderValue,PODate,Stat.StatusName,Stat.StatusCode,POMast.POType as ReqType,DeliveryDate,DeliverySchedule,DeliveryOption');
@@ -39,7 +39,10 @@ function purchaseorderListing()
$this->db->join('T_Status Stat', 'Stat.StatusCode = POMast.Status');
$this->db->join('T_PurchaseOrder_LineItem LineItem', 'POMast.PONO = LineItem.PONO');
$this->db->join('T_Requestion_Master Req', 'Req.ReqNo = LineItem.ReqNo');
-
+ if($forwhat=='amendment')
+ {
+ $this->db->where('POMast.Status',PO_RELEASED);
+ }
$query = $this->db->get();
//print_r( $this->db->last_query());
$result = $query->result();
diff --git a/application/views/editRevenueAmendPO.php b/application/views/editRevenueAmendPO.php
index f40880e8..e7efc175 100755
--- a/application/views/editRevenueAmendPO.php
+++ b/application/views/editRevenueAmendPO.php
@@ -27,6 +27,10 @@ if(!empty($AvlBudAmt))
$AvlAmount = $AvlBudAmt;
+}
+foreach ($PaymentTerms as $TER)
+{
+ $Terms=$TER->PaymentTerms;
}
$SupId = '';
@@ -71,8 +75,27 @@ if(!empty($POMaster))
$POStatus = $Req->StatusCode;
$PONO = $Req->PONO;
$ServiceDescription = $Req->ServiceDescription;
+ $PayableAT=$Req->PayableAT;
+ $PaymentDays=$Req->PaymentDays;
}
}
+if(!empty($RequistionDetails))
+{
+
+ foreach ($RequistionDetails as $ReqDet)
+ {
+ $Reqon=$ReqDet->ReqDate;
+ $Requestedby=$ReqDet->Requestedby;
+ //$Status=$ReqDet->Status;
+ }
+}
+
+
+foreach ($POSTATUS as $PST )
+{
+ $POStatus=$PST->StatusName;
+}
+
?>