AMEND REVENUE AND SERVICE

This commit is contained in:
velz2020 2017-07-04 19:25:02 +05:30
parent c9571be6d3
commit 875cde5325
4 changed files with 1339 additions and 884 deletions

View File

@ -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."</br>";
// 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 "<script>alert($rowsaffected+'--Rows Affected')</script>";
$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.</br>";
//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);
}
}

View File

@ -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();

View File

@ -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;
}
?>
<style>
@ -149,6 +172,25 @@ $(function() {
minDate : 'now',
dateFormat: 'mm/dd/yy',changeMonth: true, changeYear: true,yearRange: '0:+10'
});
$("#Requeston").datepicker({
//minDate : d,
maxDate : 'now',
dateFormat: 'mm/dd/yy',changeMonth: true, changeYear: true,yearRange: '-100:+0'
});
var paymentday=<?php echo json_encode($PaymentDays,JSON_PRETTY_PRINT)?>;
if (paymentday=="After")
{
//alert();
document.getElementById("After").checked = true;
}
else
{
document.getElementById("Before").checked = true;
}
$('#drpSupplier').change(function() {
@ -1844,6 +1886,49 @@ body {
</div>
</div>
<div class="col-md-12">
<legend>Payment Details</legend>
<!-- Text input-->
<div class="col-md-3">
<span for="payablefrom">Payable Terms</span>
<select class="form-control required" id="PaymentTerms" name="PaymentTerms">
<option value="" ><?php echo $Terms;?></option>
<?php
if(!empty($payment))
{
foreach ($payment as $rl)
{
?>
<option value="<?php echo $rl->PaymentTerms ?>"><?php echo $rl->PaymentTerms ?></option>
<?php
}
}
?>
</select>
</div>
<div class="col-md-3">
<span>Payable AT</span>
<?php
$data = array('name' => 'PayableAT','value' => set_value('PayableAT',$PayableAT),'id'=>'PayableAT', 'class' => 'form-control' ,'required' => 'true');
echo form_input($data);
?>
</div>
<div class="col-md-6">
Payment Date <br/>
<tr>
<td>
<?php echo form_label('Before', 'Before') ."&nbsp;&nbsp;". form_radio(array("name"=>"Payment", "id"=>"Before", "value"=>"0", 'checked'=>set_radio('Payment', '0', TRUE))); ?>&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>
<?php echo form_label('After', 'After') ."&nbsp;&nbsp;". form_radio(array("name"=>"Payment", "id"=>"After", "value"=>"1", 'checked'=>set_radio('Payment', '1', FALSE))); ?>
</td>
</tr>
</div>
</div>
</div>
</div>
<!-- Modal for Packing Calculation -->
@ -3010,16 +3095,39 @@ body {
<input type="hidden" name="txtDeletedRow" id="txtDeletedRow" />
<input type="hidden" name="txtPONO" id="txtPONO" value="<?php echo $PONO; ?>"/>
<a class="btn btn-primary Save" ID="Save" onclick="Save(0)" >&nbsp;&nbsp;<span class="bold">Save</span></a>
<!-- <a class="btn btn-primary Save" ID="Save" onclick="Save(0)" >&nbsp;&nbsp;<span class="bold">Save</span></a> -->
<a class="btn btn-primary Save" ID="Submit" onclick="Save(1)" >&nbsp;&nbsp;<span class="bold">Submit</span></a>
<input type="reset" class="btn btn-primary" value="Reset">
<input type="reset" class="btn btn-primary" value = "OK">
<!-- <input type="reset" class="btn btn-primary" value = "OK"> -->
</div><br/>
</div>
<div class="col-md-12">
<div class="col-md-4">
<span>Request On</span>
<?php
$data = array('name' => 'Requeston','value' => set_value('Requeston',$Reqon),'id'=>'Requeston', 'class' => 'form-control num' ,'required' => 'true', 'onkeypress'=>'return false;');
echo form_input($data);
?>
</div>
<div class="col-md-4">
<span>Request By</span>
<?php
$data = array('name' => 'RequestBy','value' => set_value('RequestBy',$Requestedby),'id'=>'RequestBy', 'class' => 'form-control' ,'required' => 'true');
echo form_input($data);
?>
</div>
<div class="col-md-4">
<span>Status</span>
<?php
$options = array("0"=>$POStatus);
echo form_dropdown('Status', $options,set_value('Status'),'id="Status"' ,'required="true"' ,'class="form-control select2')
?>
</div><br/>
</div>
</div>
</div>
</div>
@ -3783,6 +3891,19 @@ function populateValueMainFormForDeleteItem(rowid)
$('#txtTotalVat').val(parseFloat(totVATAmt).toFixed(2) );
$('#txtTotCST').val(parseFloat(totCSTAmt).toFixed(2) );
$('#txtTotalGST').val(parseFloat(totGSTAmt).toFixed(2) );
var Detail = <?php echo json_encode($Payment, JSON_PRETTY_PRINT) ?>;
//console.log(Detail);
$.each(Detail, function (index, value)
{
$("#PaymentTerms").append( $('<option></option>').val(value.PaymentTerms).html(value.PaymentTerms) );
} );
$('#txtTotalOtherTaxes').val(parseFloat(totOtherTaxAmt).toFixed(2) );
$('#txtTotalFreight').val(parseFloat(totFreightAmt).toFixed(2) );
$('#txtTotalInsurance').val(parseFloat(totInsuranceAmt).toFixed(2) );
@ -3888,4 +4009,14 @@ $('#Scheduleby').change(function(){
});
});
var Detail = <?php echo json_encode($Payment, JSON_PRETTY_PRINT) ?>;
//console.log(Detail);
$.each(Detail, function (index, value)
{
$("#PaymentTerms").append( $('<option></option>').val(value.PaymentTerms).html(value.PaymentTerms) );
} );
</script>

File diff suppressed because it is too large Load Diff