diff --git a/application/config/constants.php b/application/config/constants.php
index 138da66f..4e5e197e 100755
--- a/application/config/constants.php
+++ b/application/config/constants.php
@@ -65,6 +65,7 @@ define('REQITEM_DELIVERED', 'ST011');
define('REQ_DELETED', 'ST013');
define('REQITEM_POCREATED', 'ST022');
define('REQITEM_PARTIALLY_PO_CREATED', 'ST023');
+define('REQITEM_Emergency_PO_CREATED', 'ST024');
define('REQUISTSTATUS', '0');
@@ -169,4 +170,4 @@ define('RMC_CAL', 'txtpurchaserate+txtc
/* End of file constants.php */
-/* Location: ./application/config/constants.php */
\ No newline at end of file
+/* Location: ./application/config/constants.php */
diff --git a/application/controllers/emergencypurchaseorder.php b/application/controllers/emergencypurchaseorder.php
index 1153eca3..d5996bb2 100755
--- a/application/controllers/emergencypurchaseorder.php
+++ b/application/controllers/emergencypurchaseorder.php
@@ -18,295 +18,499 @@ class emergencypurchaseorder extends BaseController
{
parent::__construct();
$this->load->model('purchaseorder_model');
-
- $this->load->library('session');
- $this->load->library('form_validation');
- $this->load->model('requistion_model');
- $this->isLoggedIn();
- }
-
-
-
-
-
- function CreateEmergencyPO()
- {
-
- $this->global['pageTitle'] = 'Siddharth : Create Emergency Purchase Order';
-
- $data['RequestType'] = $this->requistion_model->getConfigValue('C004');
-
- $data['Suplist'] = $this->purchaseorder_model->getSupplierName();
-
- $data['DeptList'] = $this->purchaseorder_model->getDepartmentListForAllReq();
-
- $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
-
- $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate();
-
- $this->loadViews("alterpurchaseorder", $this->global, $data,Null);
-
- }
-
- /**
+ $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 requisition()
+ {
+ $data['DeptList'] = $this->purchaseorder_model->getDepartmentListForAllReq();
+
+ $data['stList'] = $this->purchaseorder_model->getStatusListforAllReq();
+
+ $data['ReqList'] = $this->purchaseorder_model->getRequistionListbySearch();
+ $this->global['pageTitle'] = 'Siddharth : Create PO from Requisition List';
+
+ $this->loadViews("createPOfromRequistion", $this->global, $data,Null);
+ }
+
+ function CreateEmergencyPO()
+ {
+ $this->global['pageTitle'] = 'Siddharth : Create Emergency Purchase Order';
+ $data['RequestType'] = $this->requistion_model->getConfigValue('C004');
+ $data['Suplist'] = $this->purchaseorder_model->getSupplierName();
+ $data['DeptList'] = $this->purchaseorder_model->getDepartmentListForAllReq();
+ $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
+ $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate();
+ $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006');
+ $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018');
+
+ $this->loadViews("alterpurchaseorder", $this->global, $data, Null);
+
+ }
+ /**
+ * this function used for get all material code using request type
+ */
+ function getMaterialCode(){
+ $reqType = $this->input->post('input');
+ $materialList = $this->requistion_model->GetMaterialCode($reqType);
+ echo json_encode($materialList);
+
+ }
+
+ /*This function is used for get cost center list using department code*/
+ function getCostCenterName(){
+ $CostList='';
+ $DeptCode = $this->input->post('id');
+ $CostList = $this->requistion_model->GetCostCenterByDept($DeptCode);
+ // print_r($CostList);
+ echo json_encode($CostList);
+
+ }
+
+ //This used to Create Service Purchase Order
+ function addNewServicePurchaseOrder()
+ {
+ $POdt =$this->input->post('PODate');
+ $PODate = $this->getDateformat($POdt);
+ $SupplierID = $this->input->post('drpSupplier');
+ $DeliveryAddr = $this->input->post('DeliveryAddr');
+ $dt = $this->input->post('Deliverydt');
+ $CostCenterName = $this->input->post('CostCenterName');
+ $Deliverydt = $this->getDateformat($dt);
+ $POType = $this->input->post('POType');
+
+ $SpcialInstruction = $this->input->post('TextSpcialInstruction');
+ $TotalOrderValueSummary = $this->input->post('TextTotalOrderValueSummaryService');
+
+ $POStatus = $this->input->post('TextStatus');
+ $CreateBy = $this->session->userdata ('userId');
+ $RequestedBy = $this->session->userdata ('EmpID');
+ $ReqStatus = REQITEM_Emergency_PO_CREATED;
+
+ $RowCount = $this->input->post('TextRowCount');
+
+ $DeletedRow = $this->input->post('TextDeletedRowCount');
+
+ $comma_separated = explode(':', $DeletedRow);
+
+ $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
+
+ $createddt = $dt->format('Y-m-d H:i:s');
+ //create T_Requestion_Master
+ $Request = array('ReqType'=>$POType, 'Requestedby'=>$RequestedBy,'CostCenterCode'=>$CostCenterName,'Status'=>$ReqStatus,'Comments'=>$SpcialInstruction,'ReqDate'=>$createddt,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy);
+
+ $Req = $this->requistion_model->addRequistion($Request);
+
+ $RegNo='';
+ if(count($Req)>0)
+ {
+ $RegNo = $Req[0]['ReqNo'];
+ }
+
+
+ // PO Master
+ $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt );
+
+ $POMaster = $this->purchaseorder_model->addPOMaster($POList);
+ $PONO = '';
+ if(count($POMaster)>0)
+ {
+ $PONO = $POMaster[0]['PONO'];
+ }
+
+ $RegDetailsStatus=REQITEM_POCREATED;
+
+ // PO Line Items
+ $LineItemStatus = REQITEM_POCREATED;
+
+ 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);
+ $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);
+
+ $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")
+ {
+
+ //add requistion details
+ $ReqDetails = array('ReqNo'=>$RegNo, 'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Status'=>$RegDetailsStatus,'UpdatedBy'=>$CreateBy,'UpdatedOn'=>$createddt);
+
+
+ $ReqDetQuery = $this->requistion_model->addRequistionDetails($ReqDetails);
+
+
+
+ $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$RegNo,'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'];
+ }
+
+
+ if(trim($POType) == SERVICE )
+ {
+ // echo 'Success';
+
+ $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);
+
+ }
+ }
+ else {
+
+ }
+
+ }
+
+ if($POStatus == REQ_DRAFT)
+ {
+ echo 'Emergency Service Purchase Order Saved Successfully!The PO NO Is: '.$PONO;
+
+ }
+ else
+ {
+ echo 'Emergency Service Purchase Order Created Successfully!The PO NO Is: '.$PONO;
+
+ }
+
+
+ }
+
+
+ /**
+ * 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, 5 );
+
+ //$this->purchaseorder_model->UpdateRequistItemStatus();
+ $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->load->library('form_validation');
-
- $this->form_validation->set_rules('txtReqNo', 'txtReqNo', 'callback_Req_validate');
-
- if($this->form_validation->run() == FALSE)
- {
- $this->requisition();
- //echo 'Validate method called';
- }
- else
- {
-
+
+ function CreatePurchaseOrder()
+ {
+
+
+ $this->load->library('form_validation');
+
+ $this->form_validation->set_rules('txtReqNo', 'txtReqNo', 'callback_Req_validate');
+
+ if($this->form_validation->run() == FALSE)
+ {
+ $this->requisition();
+ //echo 'Validate method called';
+ }
+ else
+ {
+
$this->global['pageTitle'] = 'Siddharth : Purchase order form';
- $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006');
- $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018');
- $data['Suplist'] = $this->purchaseorder_model->getSupplierName();
- $SelectedReq = json_decode($this->input->post('txtReqNo'));
-
- $Req = $SelectedReq->Req;
- $data['ReqList'] = $Req ;
- $ReqArray = array();
- $ReqType = '';
- $result = array();
-
- foreach ($Req as $SID):
- $ReqArray[] = $SID->ReqNo ;
- $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo);
- $ReqType = $SID->ReqType;
- // echo $SID->ReqNo;
-
- endforeach;
- //print_r ($result);
- $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
- $Year = $dt->format('Y');
- $data['CostList'] = $this->purchaseorder_model->getCostCenterbyRequist('',$Year,$ReqType);
- $data['MaterialList'] = $result; //$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray);
- //print_r ($data['MaterialList']);
- $data['RequistionDetails'] = $this->purchaseorder_model->getRequistDetails($ReqArray);
- $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
- $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate();
-
- $ViewName = '';
- if($ReqType == REVENUE)
- {
- $ViewName = 'Purchaseorder';
- }
- else if($ReqType == SERVICE)
- {
- $ViewName = 'servicePurchaseorder';
- }
- $this->loadViews($ViewName, $this->global,$data, NULL);
- }
+ $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006');
+ $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018');
+ $data['Suplist'] = $this->purchaseorder_model->getSupplierName();
+ $SelectedReq = json_decode($this->input->post('txtReqNo'));
+ $Req = $SelectedReq->Req;
+ $data['ReqList'] = $Req ;
+ $ReqArray = array();
+ $ReqType = '';
+ $result = array();
+
+ foreach ($Req as $SID):
+ $ReqArray[] = $SID->ReqNo ;
+ $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo);
+ $ReqType = $SID->ReqType;
+ //echo $SID->ReqNo;
+
+ endforeach;
+ //print_r ($result);
+ $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
+ $Year = $dt->format('Y');
+ $data['CostList'] = $this->purchaseorder_model->getCostCenterbyRequist('',$Year,$ReqType);
+ $data['MaterialList'] = $result; //$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray);
+ //print_r ($data['MaterialList']);
+ $data['RequistionDetails'] = $this->purchaseorder_model->getRequistDetails($ReqArray);
+ $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
+ $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate();
+
+ $ViewName = '';
+ if($ReqType == REVENUE)
+ {
+ $ViewName = 'Purchaseorder';
+ }
+ else if($ReqType == SERVICE)
+ {
+ $ViewName = 'servicePurchaseorder';
+ }
+ $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);
-
- }
- }
- //To View/Update Purchase Order
- function EditPurchaseOrder()
- {
- $PONO = $_GET['PONO'];
- $ReqType = $_GET['ReqType'];
- $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
- $Year = $dt->format('Y');
- $data['CostList'] = $this->purchaseorder_model->getCostCenterbyRequist('',$Year,$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['RequistionDetails'] = $this->purchaseorder_model->getRequistDetails($ReqArray);
- $data['POMaster'] = $this->purchaseorder_model->GetServicePurchaseOrder($PONO);
- $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate();
- $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006');
- $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018');
- if($ReqType == SERVICE)
- {
-
- $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetails($PONO);
- $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);
- $this->global['pageTitle'] = 'Siddharth : Edit Revenue Purchase order form';
- $this->loadViews("editRevenuepurchaseorder", $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 = "";
- $BudAmount = "";
- if(count($CostList) > 0)
- {
- for ($j = 0; $j < count($CostList); $j++)
- {
- $Code = $CostList[$j]['CostCenterCode'];
- $Name = $CostList[$j]['CostCenterName'];
- $HTML .="";
- }
- }
- $MaterialDetails = $this->purchaseorder_model->getRawMaterialListForPO($MatType,$ReqNo);
-
- $HTML1 = "";
-
- if(count($MaterialDetails) > 0)
- {
- for ($j = 0; $j < count($MaterialDetails); $j++)
- {
- $Code = $MaterialDetails[$j]['MaterialCode'];
- $Name = $MaterialDetails[$j]['MaterialName'];
- $HTML1 .="";
-
- }
-
- }
- // 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 = "";
- if(count($data) > 0)
- {
- for ($j = 0; $j < count($data); $j++)
- {
- $Code = $data[$j]['StatusCode'];
- $Name = $data[$j]['StatusName'];
- $HTML .="";
- }
- }
- //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'];
- }
-
- // echo 'Test';
- print_r($AvilBudAmt);
- //die(json_encode(array('Cost' => $AvilBudAmt)));
- }
-
-
- function getDateformat($Val)
- {
- $date = new DateTime($Val,new DateTimeZone('Asia/Kolkata'));
- // print_r($date);
- $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');
- // $reqDate= $this->input->post('ReqDate');
- $DEPCode = $SearchFilter[0];
- $Status = $SearchFilter[1];
- $rng = $SearchFilter[2];;
- // $ToDate = $SearchFilter[3];
- $FromDate ='';
- $ToDate = '';
- // echo $rng;
- $Dt = explode("-",$rng);
- // print_r( $Dt);
- if(count( $Dt)>1)
- {
- $FDate = $Dt[0];
- $TDate = $Dt[1];
- $FromDate = $this->getDateformat($FDate);
- $ToDate = $this->getDateformat($TDate);
- }
- //echo $FromDate;
- // print_r($Dt);
- $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.="
+
+ function CreatePOPrint()
+ {
+ $PONO = $_GET['PONO'];
+ $ReqType = $_GET['ReqType'];
+
+ if($ReqType == SERVICE)
+ {
+ $this ->servicepoprint($PONO);
+
+ }
+ else if($ReqType == REVENUE)
+ {
+ $this ->revenuepoprint($PONO);
+
+ }
+ }
+ //To View/Update Purchase Order
+ function EditPurchaseOrder()
+ {
+ $PONO = $_GET['PONO'];
+ $ReqType = $_GET['ReqType'];
+ $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
+ $Year = $dt->format('Y');
+ $data['CostList'] = $this->purchaseorder_model->getCostCenterbyRequist('',$Year,$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['RequistionDetails'] = $this->purchaseorder_model->getRequistDetails($ReqArray);
+ $data['POMaster'] = $this->purchaseorder_model->GetServicePurchaseOrder($PONO);
+ $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate();
+ $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006');
+ $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018');
+ if($ReqType == SERVICE)
+ {
+
+ $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetails($PONO);
+ $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);
+ $this->global['pageTitle'] = 'Siddharth : Edit Revenue Purchase order form';
+ $this->loadViews("editRevenuepurchaseorder", $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 = "";
+ $BudAmount = "";
+ if(count($CostList) > 0)
+ {
+ for ($j = 0; $j < count($CostList); $j++)
+ {
+ $Code = $CostList[$j]['CostCenterCode'];
+ $Name = $CostList[$j]['CostCenterName'];
+ $HTML .="";
+ }
+ }
+ $MaterialDetails = $this->purchaseorder_model->getRawMaterialListForPO($MatType,$ReqNo);
+
+ $HTML1 = "";
+
+ if(count($MaterialDetails) > 0)
+ {
+ for ($j = 0; $j < count($MaterialDetails); $j++)
+ {
+ $Code = $MaterialDetails[$j]['MaterialCode'];
+ $Name = $MaterialDetails[$j]['MaterialName'];
+ $HTML1 .="";
+
+ }
+
+ }
+ // 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 = "";
+ if(count($data) > 0)
+ {
+ for ($j = 0; $j < count($data); $j++)
+ {
+ $Code = $data[$j]['StatusCode'];
+ $Name = $data[$j]['StatusName'];
+ $HTML .="";
+ }
+ }
+ //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'];
+ }
+
+ // echo 'Test';
+ print_r($AvilBudAmt);
+ //die(json_encode(array('Cost' => $AvilBudAmt)));
+ }
+
+
+ function getDateformat($Val)
+ {
+ $date = new DateTime($Val,new DateTimeZone('Asia/Kolkata'));
+ // print_r($date);
+ $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');
+ // $reqDate= $this->input->post('ReqDate');
+ $DEPCode = $SearchFilter[0];
+ $Status = $SearchFilter[1];
+ $rng = $SearchFilter[2];;
+ // $ToDate = $SearchFilter[3];
+ $FromDate ='';
+ $ToDate = '';
+ // echo $rng;
+ $Dt = explode("-",$rng);
+ // print_r( $Dt);
+ if(count( $Dt)>1)
+ {
+ $FDate = $Dt[0];
+ $TDate = $Dt[1];
+ $FromDate = $this->getDateformat($FDate);
+ $ToDate = $this->getDateformat($TDate);
+ }
+ //echo $FromDate;
+ // print_r($Dt);
+ $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.="
|
". $ReqNo." |
@@ -317,30 +521,30 @@ class emergencypurchaseorder extends BaseController
".$Status." |
".$Department." |
".$Designation." |
-
";
- }
- //print_r( $HTML);
- 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.="
+
";
+ }
+ //print_r( $HTML);
+ 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.="
| ".$SNo." |
". $MaterialCode." |
@@ -350,371 +554,371 @@ class emergencypurchaseorder extends BaseController
".$Quantity." |
";
- //$index = $index + 1;
-
- }
+ //$index = $index + 1;
- $CostCenter = "";
- if(count($CostList) > 0)
- {
- for ($j = 0; $j < count($CostList); $j++)
- {
- $Code = $CostList[$j]['CostCenterCode'];
- $Name = $CostList[$j]['CostCenterName'];
- $CostCenter .="";
- }
- }
- //echo $HTML;
- //echo $CostCenter;
- 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');
- $Deliverydt = $this->getDateformat($dt);
- $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');
- // PO Master
- $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt );
-
- $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++)
- {
-
- $MaterialCode = $this->input->post('materialCode'.$i);
- $Quantity = $this->input->post('quantity'.$i);
- $Reqnumber = $this->input->post('Reqnumber'.$i);
- $itemRate = $this->input->post('itemRate'.$i);
+ $CostCenter = "";
+ if(count($CostList) > 0)
+ {
+ for ($j = 0; $j < count($CostList); $j++)
+ {
+ $Code = $CostList[$j]['CostCenterCode'];
+ $Name = $CostList[$j]['CostCenterName'];
+ $CostCenter .="";
+ }
+ }
+ //echo $HTML;
+ //echo $CostCenter;
+ die(json_encode(array('Items' =>$HTML,'Requist'=>$ReqList,'Cost'=>$CostCenter)));
+ }
- $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);
- $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');
+ //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');
+ $Deliverydt = $this->getDateformat($dt);
+ $POType = $this->input->post('POType');
+ $PoRange = $this->input->post('txtPoRange');
- $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');
- // PO Master
- // PO Master
- $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'UpdateBY'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt );
-
- $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);
+ $SpcialInstruction = $this->input->post('txtSpcialInstruction');
+ $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary');
+ $POStatus = $this->input->post('txtStatus');
- $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 ;
- }
+ $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');
+ // PO Master
+ $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt );
+
+ $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++)
+ {
+
+ $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);
+ $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');
+ // PO Master
+ // PO Master
+ $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'UpdateBY'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt );
+
+ $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);
-
- $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 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);
+
+ $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);
+
+ }
+ /**
* 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);
- }
- $this->purchaseorder_model->DeletePOLineItem($LineItemNo , $ReqNo,$MaterialCode);
- echo "Successfully Deleted the Line item".$LineItemNo;
-
- }
+ {
+
+ $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);
+ }
+ $this->purchaseorder_model->DeletePOLineItem($LineItemNo , $ReqNo,$MaterialCode);
+ echo "Successfully Deleted the Line item".$LineItemNo;
+
+ }
}
-?>
\ No newline at end of file
+?>
diff --git a/application/controllers/login.php b/application/controllers/login.php
index 3f4e9766..60352858 100755
--- a/application/controllers/login.php
+++ b/application/controllers/login.php
@@ -78,7 +78,8 @@ class Login extends CI_Controller
'DEPCode'=>$res->DEPCode,
'HeadDept'=>$res->HeadDept,
'DepartmentName'=>$res->DepartmentName,
- 'isLoggedIn' => TRUE
+ 'isLoggedIn' => TRUE,
+ 'EmpID' => $res->EmpID
);
$this->session->set_userdata($sessionArray);
@@ -253,3 +254,4 @@ class Login extends CI_Controller
}
?>
+
diff --git a/application/libraries/BaseController.php b/application/libraries/BaseController.php
index fa1575cf..b0e812cf 100755
--- a/application/libraries/BaseController.php
+++ b/application/libraries/BaseController.php
@@ -16,6 +16,7 @@ class BaseController extends CI_Controller {
protected $HeadDept = '';
protected $DepartmentName = '';
protected $roleText = '';
+ protected $EmpID = '';
protected $global = array ();
/**
@@ -48,10 +49,13 @@ class BaseController extends CI_Controller {
$this->DEPCode = $this->session->userdata ( 'DEPCode' );
$this->HeadDept = $this->session->userdata ( 'HeadDept' );
$this->DepartmentName = $this->session->userdata ( 'DepartmentName' );
+ $this->EmpID = $this->session->userdata ( 'EmpID' );
+
$this->global ['name'] = $this->name;
$this->global ['role'] = $this->role;
$this->global ['role_text'] = $this->roleText;
$this->global ['DEPCode'] = $this->DEPCode;
+ $this->global ['EmpID'] = $this->EmpID;
}
}
@@ -155,4 +159,4 @@ class BaseController extends CI_Controller {
"segment" => $segment
);
}
-}
\ No newline at end of file
+}
diff --git a/application/models/login_model.php b/application/models/login_model.php
index b7afc93f..d6ccf023 100755
--- a/application/models/login_model.php
+++ b/application/models/login_model.php
@@ -10,7 +10,7 @@ class Login_model extends CI_Model
*/
function loginMe($email, $password)
{
- $this->db->select('BaseTbl.userId, BaseTbl.password, Emp.FirstName,Emp.Designation, BaseTbl.roleId, Roles.role,DEPT.DEPCode,DEPT.DepartmentName,DEPT.HeadDept');
+ $this->db->select('BaseTbl.userId, BaseTbl.password, Emp.EmpID,Emp.FirstName,Emp.Designation, BaseTbl.roleId, Roles.role,DEPT.DEPCode,DEPT.DepartmentName,DEPT.HeadDept');
$this->db->from('tbl_users as BaseTbl');
$this->db->join('tbl_roles as Roles','Roles.roleId = BaseTbl.roleId');
$this->db->join('T_Employee_Details as Emp','BaseTbl.EmpID = Emp.EmpID');
@@ -34,4 +34,4 @@ class Login_model extends CI_Model
}
}
-?>
\ No newline at end of file
+?>
diff --git a/application/views/alterpurchaseorder.php b/application/views/alterpurchaseorder.php
index 0766d864..2796b368 100755
--- a/application/views/alterpurchaseorder.php
+++ b/application/views/alterpurchaseorder.php
@@ -44,10 +44,30 @@ if(!empty($CompanyDetails))
}
.form-control
{
- text-align:right;
+ text-align:left;
}
+
\ No newline at end of file
+
+ $.ajax({
+ data:{id:id},
+ type:"POST",
+ url:"emergencypurchaseorder/getCostCenterName",
+ success:function(data) {
+ if(data)
+ {
+ CostArray=data;
+ $('#CostCenterName').empty();
+ $("#CostCenterName").append( $('').val("0").html("Select Cost Center") );
+
+ $.each(JSON.parse(data), function (index, value) {
+
+ $("#CostCenterName").append( $('').val(value.CostCenterCode).html(value.CostCenterCode + "-" + value.CostCenterName) );
+
+
+ });
+ $('#content').loader('hide');
+
+
+ }
+ else
+ {
+ alert("Error");
+ }
+
+ }
+
+ });
+
+
+
+
+ }
+ else
+ {
+ alert('Please select the Department');
+ return false;
+ }
+
+ });
+ /**
+ * update available budget calculation using regNo and cost center
+ */
+ $('#CostCenterName').change(function() {
+
+ var id = $('#CostCenterName').val();
+ $("#AvlBudAmt").val('');
+ var ReqType =$('#purpose').val();
+ if(id != '0')
+ {
+ $('#content').loader('show');
+ $.ajax({
+ data:{id:id},
+ type:"POST",
+ url:"servicepurchaseorder/AvilBudgetAmount?ReqType="+ReqType,
+ success:function(data) {
+ if(data)
+ {
+ $('#content').loader('hide');
+ $("#AvalBuget").val(data);
+ if(parseFloat($("#AvalBuget").val()) <= 0)
+ {
+ $('#AlertImg').removeAttr("style");
+ isExceed = 1;
+ }
+ else
+ {
+ $('#AlertImg').attr("style","display:none;");
+ isExceed =0;
+ }
+ }
+ else
+ {
+ $('#content').loader('hide');
+ alert("Error");
+ }
+
+ }
+ });
+ }
+ else
+ {
+ alert('Please select the MaterialCode');
+ return false;
+ }
+
+ });
+ /**
+ * getting item name and uom using global variable materialData each change
+ */
+ $('#ServiceMaterialCode').change(function(){
+ var selectedMaterialCode='';
+ selectedMaterialCode=$("#ServiceMaterialCode").val();
+ $.each(JSON.parse(materialData), function (index, value) {
+ if(selectedMaterialCode==value.MaterialCode){
+ $("#ServiceDescription").val(value.MaterialName);
+ $("#ServiceUOM").val(value.UOM);
+
+ }
+
+ });
+
+ });
+ /**
+ * getting item name and uom using global variable materialData each change in revenue
+ */
+ $('#MaterialCode').change(function(){
+ var selectedRevenueMaterialCode='';
+ selectedRevenueMaterialCode=$("#MaterialCode").val();
+ $.each(JSON.parse(materialData), function (index, value) {
+ if(selectedRevenueMaterialCode==value.MaterialCode){
+ $("#ItemName").val(value.MaterialName);
+ $("#UOM").val(value.UOM);
+
+ }
+
+ });
+
+ });
+
+ /**
+ * get material list when selecting the request type
+ */
+ var materialData;
+
+ $('#purpose').change(function(){
+ var input='';
+ input=$("#purpose").val();
+if(input == -1){
+ $("#POType").val('');
+
+}
+ else {
+ $("#POType").val(input);
+ // $('#content').loader('show');
+ $.ajax({
+ data:{input:input},
+ type:"POST",
+ url:"emergencypurchaseorder/getMaterialCode?input="+input,
+ success:function(data) {
+
+ if(data)
+ {
+ materialData=data;
+ if (input=='SERVICE') {
+
+ $('#ServiceMaterialCode').empty();
+ $("#ServiceMaterialCode").append( $('').val("0").html("Select Iten Code") );
+
+ $.each(JSON.parse(data), function (index, value) {
+ $("#ServiceMaterialCode").append( $('').val(value.MaterialCode).html(value.MaterialCode + "-" + value.MaterialName) );
+
+
+ });
+ }
+ else if (input=='REVENUE') {
+ $('#MaterialCode').empty();
+ $("#MaterialCode").append( $('').val("0").html("Select Iten Code") );
+
+ $.each(JSON.parse(data), function (index, value) {
+ $("#MaterialCode").append( $('').val(value.MaterialCode).html(value.MaterialCode + "-" + value.MaterialName) );
+
+
+ });
+ }
+ else {
+
+ }
+
+ $('#content').loader('hide');
+
+ }
+
+ }
+ });
+
+ }
+
+ });
+ /**
+ * calculating taxes using quanty and rate
+ */
+ function Ratechange(){
+ if($('#ServiceMaterialCode').val() == "0")
+ {
+ alert('Please Select Item Code ');
+ $('#ServiceMaterialCode').focus();
+ return false;
+ }
+
+
+
+ if($('#ServiceQuantity').val() != '' && $('#ServiceRate').val() != '')
+ {
+ var txtQuantity = parseFloat( $('#ServiceQuantity').val());
+ var txtUnitPrice = parseFloat($('#ServiceRate').val());
+ var Tot = txtQuantity * txtUnitPrice
+ $('#ServiceBasAmt').val(Tot);
+
+ //Service Tax calculation
+ $('#AfterServiceTax').val(calculateServiceTax($('#ServiceBasAmt').val())); // calculateServiceTax();
+
+ //Edu. cess @2% on service Tax
+ $('#AfterEduCess').val( calculateEduess($('#AfterServiceTax').val()));
+
+ //Sec. & Higher Edu. cess @1 % on service Tax
+
+ $('#AfterSecHighTax').val(calculateHigherEdu($('#AfterServiceTax').val()));
+ //Krishi Kalyan tax
+ $('#AfterKrishiTax').val(calculateKrishiKalyantax($('#ServiceBasAmt').val()));
+
+ //Swachh Bharat tax
+
+ $('#AfterSwachhTax').val(calculateSwachhBharattax($('#ServiceBasAmt').val()));
+ calculateTotalOrdervalue();
+
+ var res = ExceedBudget($('#TotalOrderValue').val(), $('#AvalBuget').val());
+ if(!res)
+ {
+ $('#ServiceRate').focus();
+ return false;
+ }
+ }
+
+ }
+ function calculateServiceTax(varBasicValue)
+ {
+
+ var basicValue = parseFloat(varBasicValue);
+
+ var ServiceTaxValue = 0.0;
+
+ ServiceTaxValue = ;
+
+ var TAXval = parseFloat(ServiceTaxValue).toFixed(2);
+
+ return TAXval;// $('#AfterServiceTax').val(TAXval);
+
+ }
+ function calculateEduess(varAfterServiceTax)
+ {
+ var ServiceTaxAmount = parseFloat(varAfterServiceTax);
+
+ var ServiceTaxValue = 0.0;
+
+ ServiceTaxValue = ;
+
+ var TAXval = parseFloat(ServiceTaxValue).toFixed(2);
+
+ return TAXval;// $('#AfterEduCess').val(TAXval);
+ }
+ function calculateHigherEdu(varAfterServiceTax)
+ {
+ var ServiceTaxAmount = parseFloat(varAfterServiceTax);
+
+ var ServiceTaxValue = 0.0;
+
+ ServiceTaxValue = ;
+
+ var TAXval = parseFloat(ServiceTaxValue).toFixed(2);
+
+ return TAXval;//$('#AfterSecHighTax').val(TAXval);
+ }
+ function calculateKrishiKalyantax(varBasicValue)
+ {
+ var basicValue = parseFloat(varBasicValue);
+
+ var ServiceTaxValue = 0.0;
+
+ ServiceTaxValue = ;
+
+ var TAXval = parseFloat(ServiceTaxValue).toFixed(2);
+ return TAXval;//$('#AfterKrishiTax').val(TAXval);
+ }
+ function calculateSwachhBharattax(varBasicValue)
+ {
+ var basicValue = parseFloat(varBasicValue);
+
+ var ServiceTaxValue = 0.0;
+
+ ServiceTaxValue = ;
+
+ var TAXval = parseFloat(ServiceTaxValue).toFixed(2);
+
+ return TAXval; //$('#AfterSwachhTax').val(TAXval);
+ }
+
+ function calculateTotalOrdervalue()
+ {
+ var basicValue = parseFloat($('#ServiceBasAmt').val());
+ var ServiceTaxAmount = parseFloat($('#AfterServiceTax').val());
+ var EduCessTaxAmount = parseFloat($('#AfterEduCess').val());
+ var SecHighTaxAmount = parseFloat($('#AfterSecHighTax').val());
+ var KrishiTaxAmount = parseFloat($('#AfterKrishiTax').val());
+ var SwachhTaxAmount = parseFloat($('#AfterSwachhTax').val());
+
+ var TotAmt = basicValue + ServiceTaxAmount+ EduCessTaxAmount + SecHighTaxAmount+ KrishiTaxAmount + SwachhTaxAmount;
+
+ $('#TotalOrderValue').val( parseFloat(TotAmt).toFixed(2));
+
+ }
+ function ExceedBudget(ValuetoCheck,budgetAmount)
+ {
+ var ReqAmount = parseFloat(ValuetoCheck);
+ var BudAmount = parseFloat(budgetAmount);
+
+ if(ReqAmount > BudAmount )
+ {
+ alert('Your exceeding the Avaiable Budget :'+ budgetAmount +'.Please adjust the Product to proceed further.');
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ /**
+ * This function is used when clicking add service button that time store the info for submit
+ */
+
+ $('.AddService').click(function(){
+ if(validateServiceTax())
+ {
+ // alert('inside Addservice');
+ var temp = index;
+ var Reqnumber = $('#purpose').val();
+ var departmentName = $('#DepartmentName').val();
+ var AvilBudget = $('#AvalBuget').val();
+ var costCode = $('#CostCenterName').val();
+ var materialCode =$('#ServiceMaterialCode').val();
+ var materialName = $("#ServiceDescription").val();
+ var uom = $("#ServiceUOM").val();
+ var quantity = $("#ServiceQuantity").val();
+ var itemRate = $("#ServiceRate").val();
+
+
+ var AfterServiceTax = $("#AfterServiceTax").val();
+
+
+ var AfterEduCess = $("#AfterEduCess").val();
+
+
+ var AfterSecHighTax = $("#AfterSecHighTax").val();
+
+
+ var AfterKrishiTax = $("#AfterKrishiTax").val();
+
+
+ var AfterSwachhTax = $("#AfterSwachhTax").val();
+
+ var TotalOrderValue = $("#TotalOrderValue ").val();
+
+
+ var basicval = $("#ServiceBasAmt").val();
+
+
+ var TotalTaxValue = calculateTaxValue();
+
+ $('#ServiceMaterialCode option[value='+materialCode+']').remove();
+
+ SelectedMaterialCode[CollIndex] = materialCode;
+ CollIndex = CollIndex + 1;
+
+ populateValueMainFormForServiceTax();
+
+
+ index = parseInt(index)+1;
+
+ var template = jQuery("#ServiceList").html();
+
+
+ $('#ServiceAppend').append(_.template(template,{index:temp,ReqNo:Reqnumber,MaterialName:materialName,Quantity:quantity,UOM:uom,Rate:itemRate,BasicAmount:basicval,Taxvalue:TotalTaxValue,TotalValue:TotalOrderValue}));
+
+ clearServiceModalFields();
+
+ var theForm = $(".CreatealterPO");
+
+ addHidden(theForm,"Reqnumber"+temp,Reqnumber );
+ addHidden(theForm,"departmentName"+temp,departmentName );
+ addHidden(theForm,"AvilBudget"+temp,AvilBudget );
+ addHidden(theForm,"costCode"+temp,costCode );
+ addHidden(theForm,"materialCode"+temp,materialCode );
+ addHidden(theForm,"materialName"+temp,materialName );
+ addHidden(theForm,"uom"+temp,uom);
+ addHidden(theForm,"quantity"+temp,quantity);
+ addHidden(theForm,"itemRate"+temp,itemRate);
+ addHidden(theForm,"ServiceTax"+temp,AfterServiceTax);
+ addHidden(theForm,"EduCess"+temp,AfterEduCess);
+ addHidden(theForm,"SecHighTax"+temp,AfterSecHighTax);
+ addHidden(theForm,"KrishiTax"+temp,AfterKrishiTax);
+ addHidden(theForm,"SwachhTax"+temp,AfterSwachhTax);
+ addHidden(theForm,"TotalOrderValue"+temp,TotalOrderValue);
+
+ $('#txtRowCount').val(temp);
+
+ }
+
+ });
+ /**
+ * validate fields when clicking add service button
+ */
+ function validateServiceTax()
+ {
+
+ if($('#ServiceMaterialCode').val() == "0")
+ {
+ alert('Please select the Material Code');
+ $('#ServiceMaterialCode').focus();
+ return false;
+ }
+ else if($('#ServiceQuantity').val() == '')
+ {
+ alert('Please Enter the Quantity value');
+ $('#ServiceQuantity').focus();
+ return false;
+ }
+ else if($('#ServiceRate').val() == '')
+ {
+ alert('Please Enter the Rate of the Item');
+ $('#ServiceRate').focus();
+ return false;
+ }
+
+ else if(ExceedBudget($('#TotalOrderValue').val(),$('#AvalBuget').val()) == false)
+ {
+ $('#ServiceRate').focus();
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+
+ }
+ function populateValueMainFormForServiceTax()
+ {
+ var AfterServiceTax = $('#AfterServiceTax').val() == '' ? '0.00' : $('#AfterServiceTax').val();
+ var AfterEduCess = $('#AfterEduCess').val() == '' ? '0.00' : $('#AfterEduCess').val();
+ var AfterSecHighTax = $('#AfterSecHighTax').val() == '' ? '0.00' : $('#AfterSecHighTax').val();
+ var AfterKrishiTax = $('#AfterKrishiTax').val() == '' ? '0.00' : $('#AfterKrishiTax').val();
+ var AfterSwachhTax = $('#AfterSwachhTax').val() == '' ? '0.00' : $('#AfterSwachhTax').val();
+ var TotalVal = $('#TotalOrderValue ').val() == '' ? '0.00' : $('#TotalOrderValue').val();
+ var BasicVal = $('#ServiceBasAmt').val() == '' ? '0.00' : $('#ServiceBasAmt').val();
+
+ var TotalOrderValueSummary = $('#txtTotalOrderValueSummaryService').val() == '' ? '0.00' : $('#txtTotalOrderValueSummaryService').val();
+
+ var totBasicAmt = $('#txtTotBasicAmount').val() == '' ? '0.00' : $('#txtTotBasicAmount').val();
+ var TotalServiceTax = $('#txtTotalServiceTax').val() == '' ? '0.00' : $('#txtTotalServiceTax').val();
+ var TotHigherEdu = $('#txtTotHigherEdu').val() == '' ? '0.00' : $('#txtTotHigherEdu').val();
+ var TotalEducess = $('#txtTotalEducess').val() == '' ? '0.00' : $('#txtTotalEducess').val();
+ var TotalKrishiKalyan = $('#txtTotalKrishiKalyan').val() == '' ? '0.00' : $('#txtTotalKrishiKalyan').val();
+ var TotSwachhBharat = $('#txtTotSwachhBharat').val() == '' ? '0.00' : $('#txtTotSwachhBharat').val();
+ $('#txtTotBasicAmount').val((parseFloat(totBasicAmt) + parseFloat(BasicVal)).toFixed(2) );
+ $('#txtTotalServiceTax').val((parseFloat(TotalServiceTax) + parseFloat(AfterServiceTax)).toFixed(2) );
+ $('#txtTotHigherEdu').val((parseFloat(TotHigherEdu) + parseFloat(AfterSecHighTax)).toFixed(2) );
+ $('#txtTotalEducess').val((parseFloat(TotalEducess) + parseFloat(AfterEduCess)).toFixed(2) );
+ $('#txtTotalKrishiKalyan').val((parseFloat(TotalKrishiKalyan) + parseFloat(AfterKrishiTax)).toFixed(2) );
+ $('#txtTotSwachhBharat').val((parseFloat(TotSwachhBharat) + parseFloat(AfterSwachhTax)).toFixed(2) );
+ $('#txtTotalOrderValueSummaryService').val((parseFloat(TotalOrderValueSummary) + parseFloat(TotalVal)).toFixed(2) );
+
+ }
+ function calculateTaxValue()
+ {
+ var ServiceTaxAmount = parseFloat($('#AfterServiceTax').val());
+ var EduCessTaxAmount = parseFloat($('#AfterEduCess').val());
+ var SecHighTaxAmount = parseFloat($('#AfterSecHighTax').val());
+ var KrishiTaxAmount = parseFloat($('#AfterKrishiTax').val());
+ var SwachhTaxAmount = parseFloat($('#AfterSwachhTax').val());
+
+ var TottaxAmt = ServiceTaxAmount+ EduCessTaxAmount + SecHighTaxAmount+ KrishiTaxAmount + SwachhTaxAmount;
+ return parseFloat(TottaxAmt.toFixed(2));
+ }
+
+ $(function () {
+ $('#serviceTax').DataTable({
+ "paging": true,
+ "lengthChange": true,
+ "searching": false,
+ //"ordering": true,
+ // "info": true,
+ "autoWidth": true
+
+ });
+ });
+ /**
+ * clear the seleted fields after clicking add service
+ */
+ function clearServiceModalFields()
+ {
+ // To reset the Modal controls
+
+ $('#ServiceMaterialCode').val("0") ;
+ $("#ServiceDescription").val('');
+ $('#ServiceUOM').val('');
+ $('#ServiceQuantity').val('');
+ $("#ServiceRate").val('');
+
+ $("#ServiceBasAmt").val('');
+ $("#AfterServiceTax").val('');
+ $("#AfterEduCess").val('');
+ $("#AfterSecHighTax").val('');
+ $("#AfterKrishiTax").val('');
+ $("#AfterSwachhTax").val('');
+ $("#TotalOrderValue ").val('');
+
+ }
+ /**
+ * This function is used to edit the service seleted po
+ */
+ var EditGetMaterialData;
+
+ $("#EDITSERVICE").on("shown.bs.modal", function(e) {
+
+ EditGetMaterialData='';
+
+ userid = $(e.relatedTarget).data('userid');
+ var tr= document.getElementById(userid);
+ var cellval = tr.cells;
+ var id= $('#Reqnumber'+userid).val();
+ $('#EditReqNo').val($('#Reqnumber'+userid).val());
+ $('#EditdeptName').val($('#departmentName'+userid).val());
+
+
+ $('#EditAvlBudAmt').val($('#AvilBudget'+userid).val());
+
+ $('#EditItemName').val($('#materialName'+userid).val());
+ $('#EditUOM').val($('#uom'+userid).val());
+ $('#EditQuantity').val($('#quantity'+userid).val());
+ $('#EditRate').val($('#itemRate'+userid).val());
+ $('#txtEditBasicValue').val(cellval[6].innerHTML);
+ $('#EditAfterServiceTax').val($('#ServiceTax'+userid).val());
+ $('#EditAfterEduCess').val($('#EduCess'+userid).val());
+ $('#EditAfterSecHighTax').val($('#SecHighTax'+userid).val());
+ $('#EditAfterKrishiTax').val($('#KrishiTax'+userid).val());
+ $('#EditAfterSwachhTax').val($('#SwachhTax'+userid).val());
+ $('#EditTotalOrderValue').val(cellval[8].innerHTML);
+
+
+
+
+
+ $.each(JSON.parse(CostArray), function (index, value) {
+ if ($('#costCode'+userid).val()==value.CostCenterCode) {
+ $('#EditCostCenter').val($('#costCode'+userid).val() + '-'+ value.CostCenterName);
+
+ }
+
+
+ $("#EditMaterialCode").empty();
+
+ $("#EditMaterialCode").append( $('').val($('#materialCode'+userid).val()).html($('#materialCode'+userid).val() + "-" + $('#materialName'+userid).val()) );
+ $.each(JSON.parse(materialData), function (index, value) {
+
+
+ if($('#materialCode'+userid).val() != value.MaterialCode)
+ {
+
+ $("#EditMaterialCode").append( $('').val(value.MaterialCode).html(value.MaterialCode + "-" + value.MaterialName) );
+
+ }
+
+
+
+ });
+
+
+
+
+ });
+
+ /*get Material list while editing
+
+ var EditPoType=$('#Reqnumber'+userid).val();
+
+ $.ajax({
+ data:{input:EditPoType},
+ type:"POST",
+ url:"emergencypurchaseorder/getMaterialCode?input="+EditPoType,
+ success:function(data) {
+$('#content').loader('hide');
+ if(data)
+ {
+ EditGetMaterialData=data;
+
+ $("#EditMaterialCode").empty();
+
+ $("#EditMaterialCode").append( $('').val($('#materialCode'+userid).val()).html($('#materialCode'+userid).val() + "-" + $('#materialName'+userid).val()) );
+ $.each(JSON.parse(data), function (index, value) {
+
+
+ if($('#materialCode'+userid).val() != value.MaterialCode)
+ {
+
+ $("#EditMaterialCode").append( $('').val(value.MaterialCode).html(value.MaterialCode + "-" + value.MaterialName) );
+
+ }
+
+
+
+ });
+
+
+ }
+
+ }
+ });*/
+
+
+
+
+
+
+
+ });
+
+ /**
+ * edit emenergency service po validations
+ */
+
+ function EditRatechange(){
+
+
+ if($('#EditQuantity').val() != '' && $('#EditRate').val() != '')
+ {
+ var txtQuantity = parseFloat( $('#EditQuantity').val());
+ var txtUnitPrice = parseFloat($('#EditRate').val());
+ var Tot = txtQuantity * txtUnitPrice
+ $('#txtEditBasicValue').val(Tot);
+ ExceedBudget(Tot, $('#EditAvlBudAmt').val());
+
+ //Service Tax calculation
+ $('#EditAfterServiceTax').val(calculateServiceTax($('#txtEditBasicValue').val())); // calculateServiceTax();
+
+ //Edu. cess @2% on service Tax
+ $('#EditAfterEduCess').val( calculateEduess($('#EditAfterServiceTax').val()));
+
+ //Sec. & Higher Edu. cess @1 % on service Tax
+
+ $('#EditAfterSecHighTax').val(calculateHigherEdu($('#EditAfterServiceTax').val()));
+ //Krishi Kalyan tax
+
+ $('#EditAfterKrishiTax').val(calculateKrishiKalyantax($('#txtEditBasicValue').val()));
+ //Swachh Bharat tax
+
+ $('#EditAfterSwachhTax').val(calculateSwachhBharattax($('#txtEditBasicValue').val()));
+
+ calculateTotalEditOrdervalue();
+ }
+
+ }
+ /**
+ * calculate total edit order value
+ */
+ function calculateTotalEditOrdervalue()
+ {
+ var basicValue = parseFloat($('#txtEditBasicValue').val());
+ var ServiceTaxAmount = parseFloat($('#EditAfterServiceTax').val());
+ var EduCessTaxAmount = parseFloat($('#EditAfterEduCess').val());
+ var SecHighTaxAmount = parseFloat($('#EditAfterSecHighTax').val());
+ var KrishiTaxAmount = parseFloat($('#EditAfterKrishiTax').val());
+ var SwachhTaxAmount = parseFloat($('#EditAfterSwachhTax').val());
+
+ var TotAmt = basicValue + ServiceTaxAmount+ EduCessTaxAmount + SecHighTaxAmount+ KrishiTaxAmount + SwachhTaxAmount;
+
+ $('#EditTotalOrderValue').val( parseFloat(TotAmt).toFixed(2));
+
+ }
+ /**
+ * This function is used for update service
+ */
+ $('.EditService').click(function(){
+
+ if( validateEditServiceTax())
+ {
+
+ var CostCode = $("#EditCostCenter").val();
+ var AvilBudget = $('#EditAvlBudAmt').val();
+ var editMaterialCode = $("#EditMaterialCode").val();
+
+ var editDescription = $("#EditItemName").val();
+ var editUOM = $('#EditUOM').val();
+ var editQuantity = $('#EditQuantity').val();
+
+ var itemRate = $("#EditRate").val();
+
+
+ var AfterServiceTax = $("#EditAfterServiceTax").val();
+
+
+ var AfterEduCess = $("#EditAfterEduCess").val();
+
+
+ var AfterSecHighTax = $("#EditAfterSecHighTax").val();
+
+
+ var AfterKrishiTax = $("#EditAfterKrishiTax").val();
+
+
+ var AfterSwachhTax = $("#EditAfterSwachhTax").val();
+
+ var TotalOrderValue = $("#EditTotalOrderValue ").val();
+
+
+ var basicval = $("#txtEditBasicValue").val();
+
+ var TotalTaxValue = calculateEditTaxValue();
+
+
+
+ var tr= document.getElementById(userid);
+ var cellval = tr.cells;
+
+ cellval[2].innerHTML = editDescription;
+ cellval[3].innerHTML = editQuantity;
+ cellval[4].innerHTML =editUOM;
+ cellval[5].innerHTML =itemRate;
+ cellval[6].innerHTML =basicval;
+ cellval[7].innerHTML =TotalTaxValue;
+ cellval[8].innerHTML =TotalOrderValue;
+
+
+ $('#materialCode'+userid).val(editMaterialCode);
+ $('#materialName'+userid).val(editDescription);
+ $('#uom'+userid).val(editUOM);
+ $('#quantity'+userid).val(editQuantity);
+ $('#itemRate'+userid).val(itemRate);
+ $('#ServiceTax'+userid).val(AfterServiceTax);
+ $('#EduCess'+userid).val(AfterEduCess);
+ $('#SecHighTax'+userid).val(AfterSecHighTax);
+ $('#KrishiTax'+userid).val(AfterKrishiTax);
+ $('#SwachhTax'+userid).val(AfterSwachhTax);
+ $('#TotalOrderValue'+userid).val(TotalOrderValue);
+
+ populateValueMainFormForEditServiceTax();
+
+ }
+
+ });
+ /**
+ * This function is used for validate while update
+ */
+ function validateEditServiceTax()
+ {
+
+ if($('#EditQuantity').val() == '')
+ {
+ alert('Please Enter the Quantity value');
+ $('#EditQuantity').focus();
+ return false;
+ }
+ else if($('#EditRate').val() == '')
+ {
+ alert('Please Enter the Rate of the Item');
+ $('#EditRate').focus();
+ return false;
+ }
+
+ else if(ExceedBudget($('#EditTotalOrderValue').val(),$('#EditAvlBudAmt').val()) == false)
+ {
+ $('#EditRate').focus();
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+
+ }
+ function calculateEditTaxValue()
+ {
+ var ServiceTaxAmount = parseFloat($('#EditAfterServiceTax').val());
+ var EduCessTaxAmount = parseFloat($('#EditAfterEduCess').val());
+ var SecHighTaxAmount = parseFloat($('#EditAfterSecHighTax').val());
+ var KrishiTaxAmount = parseFloat($('#EditAfterKrishiTax').val());
+ var SwachhTaxAmount = parseFloat($('#EditAfterSwachhTax').val());
+
+ var TottaxAmt = ServiceTaxAmount+ EduCessTaxAmount + SecHighTaxAmount+ KrishiTaxAmount + SwachhTaxAmount;
+ return parseFloat(TottaxAmt.toFixed(2));
+ }
+ function populateValueMainFormForEditServiceTax()
+ {
+
+ var rows = document.getElementById('serviceTax').rows.length;
+ var TotServiceTax = 0;
+ var TotEduCess = 0;
+ var TotSecHighTax = 0;
+ var TotKrishiTax = 0;
+ var TotSwachhTax = 0;
+ var TotSummary = 0;
+ var TotBasicAmout = 0;
+ for (i = 1; i < rows-1; i++) {
+
+ var AfterServiceTax = $('#ServiceTax'+i).val() == '' ? '0.00' : $('#ServiceTax'+i).val();
+ var AfterEduCess = $('#EduCess'+i).val() == '' ? '0.00' : $('#EduCess'+i).val();
+ var AfterSecHighTax = $('#SecHighTax'+i).val() == '' ? '0.00' : $('#SecHighTax'+i).val();
+ var AfterKrishiTax =$('#KrishiTax'+i).val() == '' ? '0.00' : $('#KrishiTax'+i).val();
+ var AfterSwachhTax = $('#SwachhTax'+i).val() == '' ? '0.00' : $('#SwachhTax'+i).val();
+ var TotalVal =$('#TotalOrderValue'+i).val() == '' ? '0.00' : $('#TotalOrderValue'+i).val();
+ var Quantity = $('#quantity'+i).val() == '' ? '0.00' : $('#quantity'+i).val();
+ var ItemRate = $('#itemRate'+i).val() == '' ? '0.00' : $('#itemRate'+i).val();
+ var BasicVal = parseFloat(Quantity) * parseFloat(ItemRate);
+
+ TotServiceTax = parseFloat(TotServiceTax) + parseFloat(AfterServiceTax);
+ TotEduCess = parseFloat(TotEduCess) + parseFloat(AfterEduCess);
+ TotSecHighTax = parseFloat(TotSecHighTax) + parseFloat(AfterSecHighTax);
+ TotKrishiTax = parseFloat(TotKrishiTax) + parseFloat(AfterKrishiTax);
+ TotSwachhTax = parseFloat(TotSwachhTax) + parseFloat(AfterSwachhTax);
+ TotSummary = parseFloat(TotSummary) + parseFloat(TotalVal);
+ TotBasicAmout = parseFloat(TotBasicAmout) + parseFloat(BasicVal);
+
+ }
+
+
+ $('#txtTotBasicAmount').val(parseFloat(TotBasicAmout).toFixed(2) );
+ $('#txtTotalServiceTax').val(parseFloat(TotServiceTax).toFixed(2) );
+ $('#txtTotHigherEdu').val(parseFloat(TotSecHighTax).toFixed(2) );
+ $('#txtTotalEducess').val(parseFloat(TotEduCess).toFixed(2) );
+ $('#txtTotalKrishiKalyan').val(parseFloat(TotKrishiTax).toFixed(2) );
+ $('#txtTotSwachhBharat').val(parseFloat(TotSwachhTax).toFixed(2) );
+ $('#txtTotalOrderValueSummaryService').val(parseFloat(TotSummary).toFixed(2) );
+
+
+ }
+ /**
+ * This function is used for delete list of tem from selected list
+ */
+ function DeleteRow(rowid)
+ {
+ var DelRows = $('#txtDeletedRow').val();
+
+ var answer = confirm(" Do you want to delete the Item from the List?")
+ if (answer)
+ {
+ var td = document.getElementById(rowid);
+ td.parentNode.removeChild(td);
+
+ var removeItem = $('#materialCode'+rowid).val();
+
+
+
+ SelectedMaterialCode.splice( SelectedMaterialCode.indexOf('removeItem'), 1 );
+
+ if(DelRows != '')
+ {
+ DelRows = DelRows + ":" + rowid;
+ populateValueMainFormForDeleteServiceTax(rowid);
+ }
+ else
+ {
+ DelRows= "0" + ":" + rowid;
+ populateValueMainFormForDeleteServiceTax(rowid);
+
+ }
+ $('#txtDeletedRow').val(DelRows);
+ }
+
+ }
+ /**
+ * This function is used to submit and save the emergency service Po list
+ */
+ function Save(status)
+ {
+ if(status == '0')
+ {
+ stat = '';
+ }
+ else
+ {
+ stat = '';
+ }
+
+
+ var splinstr = $('#txtSpcialInstruction').val();
+ var deladd = $('#DeliveryAddr').val();
+ $('#SpcialInstruction').val(splinstr);
+ $('#txtDeliveryAddress').val(deladd);
+ $('#txtStatus').val(stat);
+ var TextRowCount = $('#txtRowCount').val();
+ var TextDeletedRowCount = $('#txtDeletedRow').val();
+ var TextTotalOrderValueSummaryService = $('#txtTotalOrderValueSummaryService').val();
+ var TextSpcialInstruction = $('#txtSpcialInstruction').val();
+ var TextStatus = stat;
+
+ if(validate())
+ {
+ if(document.getElementById('serviceTax').rows.length < 3)
+ {
+ alert('Please Select Line item to Create PO');
+ $('#Deliverydt').focus();
+ return false;
+ }
+ else
+ {
+ $('#content').loader('show');
+ $.ajax({
+ data:$('.CreatealterPO').serialize()+"&TextRowCount="+TextRowCount+"&TextDeletedRowCount="+TextDeletedRowCount+"&TextTotalOrderValueSummaryService="+TextTotalOrderValueSummaryService+"&TextSpcialInstruction="+TextSpcialInstruction+"&TextStatus="+TextStatus,
+ type:"POST",
+ url:"emergencypurchaseorder/addNewServicePurchaseOrder",
+ success:function(data) {
+ if(data)
+ {
+ $('#content').loader('hide');
+ alert(data);
+ $('#txtRowCount').val('');
+ $('#txtDeletedRow').val('');
+ $('#SpcialInstruction').val('');
+ $('#txtDeliveryAddress').val('');
+ window.location = "purchaseorderListing";
+
+ }
+ else
+ {
+ $('#content').loader('hide');
+ alert("Error");
+ }
+
+ }
+
+ });
+ }
+
+ }
+ }
+ /**
+ * This function is used to calculate the total amounts after delete the row
+ */
+ function populateValueMainFormForDeleteServiceTax(deletedRow)
+ {
+ var rows = document.getElementById('serviceTax').rows.length+1;
+ var TotServiceTax = 0;
+ var TotEduCess = 0;
+ var TotSecHighTax = 0;
+ var TotKrishiTax = 0;
+ var TotSwachhTax = 0;
+ var TotSummary = 0;
+ var TotBasicAmout = 0;
+ for (var i = 1; i < rows; i++) {
+ if(deletedRow==i){
+ $('#ServiceTax'+i).val('');
+ $('#EduCess'+i).val('');
+ $('#SecHighTax'+i).val('');
+ $('#KrishiTax'+i).val('');
+ $('#SwachhTax'+i).val('');
+ $('#ServiceTax'+i).val('');
+ $('#TotalOrderValue'+i).val('');
+ $('#quantity'+i).val('');
+ $('#itemRate'+i).val('');
+
+ var AfterServiceTax = $('#ServiceTax'+i).val() == '' ? '0.00' : $('#ServiceTax'+i).val();
+ var AfterEduCess = $('#EduCess'+i).val() == '' ? '0.00' : $('#EduCess'+i).val();
+ var AfterSecHighTax = $('#SecHighTax'+i).val() == '' ? '0.00' : $('#SecHighTax'+i).val();
+ var AfterKrishiTax =$('#KrishiTax'+i).val() == '' ? '0.00' : $('#KrishiTax'+i).val();
+ var AfterSwachhTax = $('#SwachhTax'+i).val() == '' ? '0.00' : $('#SwachhTax'+i).val();
+ var TotalVal =$('#TotalOrderValue'+i).val() == '' ? '0.00' : $('#TotalOrderValue'+i).val();
+
+ var Quantity = $('#quantity'+i).val() == '' ? '0.00' : $('#quantity'+i).val();
+ var ItemRate = $('#itemRate'+i).val() == '' ? '0.00' : $('#itemRate'+i).val();
+ var BasicVal = parseFloat(Quantity) * parseFloat(ItemRate);
+
+ TotServiceTax = parseFloat(TotServiceTax) + parseFloat(AfterServiceTax);
+ TotEduCess = parseFloat(TotEduCess) + parseFloat(AfterEduCess);
+ TotSecHighTax = parseFloat(TotSecHighTax) + parseFloat(AfterSecHighTax);
+ TotKrishiTax = parseFloat(TotKrishiTax) + parseFloat(AfterKrishiTax);
+ TotSwachhTax = parseFloat(TotSwachhTax) + parseFloat(AfterSwachhTax);
+ TotSummary = parseFloat(TotSummary) + parseFloat(TotalVal);
+ TotBasicAmout = parseFloat(TotBasicAmout) + parseFloat(BasicVal);
+ }
+ else if(deletedRow!=i){
+ var AfterServiceTax = $('#ServiceTax'+i).val() == '' ? '0.00' : $('#ServiceTax'+i).val();
+ var AfterEduCess = $('#EduCess'+i).val() == '' ? '0.00' : $('#EduCess'+i).val();
+ var AfterSecHighTax = $('#SecHighTax'+i).val() == '' ? '0.00' : $('#SecHighTax'+i).val();
+ var AfterKrishiTax =$('#KrishiTax'+i).val() == '' ? '0.00' : $('#KrishiTax'+i).val();
+ var AfterSwachhTax = $('#SwachhTax'+i).val() == '' ? '0.00' : $('#SwachhTax'+i).val();
+ var TotalVal =$('#TotalOrderValue'+i).val() == '' ? '0.00' : $('#TotalOrderValue'+i).val();
+
+ var Quantity = $('#quantity'+i).val() == '' ? '0.00' : $('#quantity'+i).val();
+ var ItemRate = $('#itemRate'+i).val() == '' ? '0.00' : $('#itemRate'+i).val();
+ var BasicVal = parseFloat(Quantity) * parseFloat(ItemRate);
+ if(AfterServiceTax!=undefined){
+ TotServiceTax = parseFloat(TotServiceTax) + parseFloat(AfterServiceTax);
+ TotEduCess = parseFloat(TotEduCess) + parseFloat(AfterEduCess);
+ TotSecHighTax = parseFloat(TotSecHighTax) + parseFloat(AfterSecHighTax);
+ TotKrishiTax = parseFloat(TotKrishiTax) + parseFloat(AfterKrishiTax);
+ TotSwachhTax = parseFloat(TotSwachhTax) + parseFloat(AfterSwachhTax);
+ TotSummary = parseFloat(TotSummary) + parseFloat(TotalVal);
+ TotBasicAmout = parseFloat(TotBasicAmout) + parseFloat(BasicVal);
+ }
+
+ }
+ else{
+
+ }
+
+
+ }
+
+
+ $('#txtTotBasicAmount').val(parseFloat(TotBasicAmout).toFixed(2) );
+ $('#txtTotalServiceTax').val(parseFloat(TotServiceTax).toFixed(2) );
+ $('#txtTotHigherEdu').val(parseFloat(TotSecHighTax).toFixed(2) );
+ $('#txtTotalEducess').val(parseFloat(TotEduCess).toFixed(2) );
+ $('#txtTotalKrishiKalyan').val(parseFloat(TotKrishiTax).toFixed(2) );
+ $('#txtTotSwachhBharat').val(parseFloat(TotSwachhTax).toFixed(2) );
+ $('#txtTotalOrderValueSummaryService').val(parseFloat(TotSummary).toFixed(2) );
+
+
+ }
+ /**
+ * update available budget calculation using regNo and cost center while editing
+ */
+ $('#EditCostCenter').change(function() {
+
+ var getCostId = $('#EditCostCenter').val();
+ $("#EditAvlBudAmt").val('');
+ var EditReqType =$('#EditReqNo').val();
+ if(getCostId != '0')
+ {
+
+ $('#content').loader('show');
+ $.ajax({
+ data:{id:getCostId},
+ type:"POST",
+ url:"servicepurchaseorder/AvilBudgetAmount?ReqType="+EditReqType,
+ success:function(data) {
+ if(data)
+ {
+ $('#content').loader('hide');
+ $("#EditAvlBudAmt").val(data);
+ if(parseFloat($("#EditAvlBudAmt").val()) <= 0)
+ {
+ $('#AlertImg').removeAttr("style");
+ isExceed = 1;
+ }
+ else
+ {
+ $('#AlertImg').attr("style","display:none;");
+ isExceed =0;
+ }
+ }
+ else
+ {
+ $('#content').loader('hide');
+ alert("Error");
+ }
+
+ }
+ });
+ }
+ else
+ {
+ alert('Please select the MaterialCode');
+ return false;
+ }
+
+ });
+ /**
+ * getting item name and uom using global variable materialData each change ehile editing
+ */
+ $('#EditMaterialCode').change(function(){
+
+ var editselectedMaterialCode='';
+ editselectedMaterialCode=$("#EditMaterialCode").val();
+
+ $.each(JSON.parse(materialData), function (index, value) {
+ if(editselectedMaterialCode==value.MaterialCode){
+ $("#EditMaterialCode").val(value.MaterialCode);
+ $("#EditItemName").val(value.MaterialName);
+ $("#EditItemUOM").val(value.UOM);
+
+ }
+
+ });
+
+ });
+ $("#EDITREVENUE").on("shown.bs.modal", function(e) {
+
+
+
+ userid = $(e.relatedTarget).data('userid');
+
+ var CheckLocalInter = $('#CheckLocalInter'+userid).val();
+ if(CheckLocalInter == "0")
+ {
+ // style="display:none;"
+ // $('#Vat').removeAttr("style");
+ // $('#TotVat').removeAttr("style");
+ // $('#CST').attr("style","display:none;");
+ // $('#TotCST').attr("style","display:none;");
+ $('#EditVat').show();
+ $('#EditCST').hide();
+
+ }
+ else
+ {
+ // $('#CST').removeAttr("style");
+ // $('#TotCST').removeAttr("style");
+ // $('#Vat').attr("style","display:none;");
+ // $('#TotVat').attr("style","display:none;");
+ $('#EditVat').hide();
+ $('#EditCST').show();
+
+ }
+
+ $('#isEdit').val(1);
+ //alert(userid);
+ var tr= document.getElementById(userid);
+
+ var cellval = tr.cells;
+
+ var id= $('#Reqnumber'+userid).val();
+
+ $('#EditRevenueReqNo').val($('#Reqnumber'+userid).val());
+ $('#EditRevenuedeptName').val($('#departmentName'+userid).val());
+ //$("#EditRevenueCostCenter").val($('#costCode'+userid).val());
+ $('#EditRevenueAvlBudAmt').val($('#AvilBudget'+userid).val());
+
+ $('#EditRevenueItemName').val($('#materialName'+userid).val());
+ $('#EditRevenueUOM').val($('#uom'+userid).val());
+ $('#EditRevenueQuantity').val($('#quantity'+userid).val());
+ $('#EditRevenueRate').val($('#itemRate'+userid).val());
+ $('#txtEditRevenueBasicValue').val(cellval[6].innerHTML);
+ RequistQuantity = $('#quantity'+userid).val();
+ $('#txtEditDiscount').val($('#DisVal'+userid).val());
+ $('#txtEditAfterDiscount').val($('#AfterDisVal'+userid).val());
+ $('#txtEditVat').val($('#VatVal'+userid).val());
+ $('#txtEditAfterVat').val($('#AfterVatVal'+userid).val());
+ $('#txtEditCST').val($('#CSTVal'+userid).val());
+ $('#txtEditAfterCST').val($('#AfterCSTVal'+userid).val());
+
+ $('#txtEditPackaging').val($('#PackVal'+userid).val());
+ $('#txtEditAfterPackaging').val($('#AfterPackVal'+userid).val());
+ $('#txtEditGST').val($('#GSTVal'+userid).val());
+ $('#txtEditAfterGST').val($('#AfterGSTVal'+userid).val());
+ $('#txtEditExciseDuty').val($('#ExciseVal'+userid).val());
+ $('#txtEditAfterExciseDuty').val($('#AfterExciseVal'+userid).val());
+ $('#txtEditOtherTax').val($('#OtherTaxVal'+userid).val());
+ $('#txtEditAfterOtherTax').val($('#AfterOtherTaxVal'+userid).val());
+ $('#txtEditFreight').val($('#FreightVal'+userid).val());
+ $('#txtEditAfterFreight').val($('#AfterFreightVal'+userid).val());
+ $('#txtEditInsurance').val($('#Insval'+userid).val());
+
+ $('#txtEditRevenueTotalOrderValue').val($('#TotalOrderValue'+userid).val());
+
+
+ $.each(JSON.parse(CostArray), function (index, value) {
+ if ($('#costCode'+userid).val()==value.CostCenterCode) {
+ $('#EditRevenueCostCenter').val($('#costCode'+userid).val() + '-'+ value.CostCenterName);
+
+ }
+
+
+ $("#EditRevenueMaterialCode").empty();
+
+ $("#EditRevenueMaterialCode").append( $('').val($('#materialCode'+userid).val()).html($('#materialCode'+userid).val() + "-" + $('#materialName'+userid).val()) );
+ $.each(JSON.parse(materialData), function (index, value) {
+
+
+ if($('#materialCode'+userid).val() != value.MaterialCode)
+ {
+
+ $("#EditRevenueMaterialCode").append( $('').val(value.MaterialCode).html(value.MaterialCode + "-" + value.MaterialName) );
+
+ }
+
+
+
+ });
+
+
+
+
+ });
+ $("#EditDiscountType").val($('#DisType'+userid).val());
+ $("#drpEditFreight").val($('#FreightType'+userid).val());
+ $("#EditPackagingType").val($('#PackType'+userid).val())
+
+
+
+
+});
+ $('#EditRevenueMaterialCode').change(function(){
+
+ var editselectedMaterialCode='';
+ editselectedMaterialCode=$("#EditRevenueMaterialCode").val();
+
+ $.each(JSON.parse(materialData), function (index, value) {
+ if(editselectedMaterialCode==value.MaterialCode){
+ $("#EditRevenueMaterialCode").val(value.MaterialCode);
+ $("#EditRevenueItemName").val(value.MaterialName);
+ $("#EditRevenueUOM").val(value.UOM);
+
+ }
+
+ });
+
+ });
+$('.EditRevenue').click(function(){
+
+
+ if(validateEditRevenueTax() && validateEditExceedLimit())
+ {
+ //alert('inside Add');
+ var CostCode = $("#EditRevenueCostCenter").val();
+ var AvilBudget = $('#EditRevenueAvlBudAmt').val();
+ var editMaterialCode = $("#EditRevenueMaterialCode").val();
+ var editDescription = $("#EditRevenueItemName").val();
+ var editUOM = $('#EditRevenueUOM').val();
+ var editQuantity = $('#EditRevenueQuantity').val();
+
+ var itemRate = $("#EditRevenueRate").val();
+
+
+ var DisType = $("#EditDiscountType").val();
+ var DisVal = $("#txtEditDiscount").val();
+ var AfterDisVal = $("#txtEditAfterDiscount").val();
+
+ var PackOption = PackagingCalculation ;
+ var PackType = $("#EditPackagingType").val();
+ var PackVal = $("#txtEditPackaging").val();
+ var AfterPackVal = $("#txtEditAfterPackaging").val();
+
+ var ExciseOption = ExciseCalculation ;
+ var ExciseVal = $("#txtEditExciseDuty").val();
+ var AfterExciseVal = $("#txtEditAfterExciseDuty").val();
+
+ var VatOption = VatCalculation ;
+ var VatVal = $("#txtEditVat").val();
+ var AfterVatVal = $("#txtEditAfterVat").val();
+
+ var CSTOption = CSTCalculation ;
+ var CSTVal = $("#txtCST").val();
+ var AfterCSTVal = $("#txtEditAfterCST").val();
+
+ var GSTVal = $("#txtEditCST").val();
+ var AfterGSTVal = $("#txtEditAfterCST").val();
+
+ var OtherTaxVal = $("#txtEditOtherTax").val();
+ var AfterOtherTaxVal = $("#txtEditAfterOtherTax").val();
+
+ var FreightType = $("#drpEditFreight").val();
+ var FreightVal = $("#txtEditFreight").val();
+ var AfterFreightVal = $("#txtEditAfterFreight").val();
+
+ var basicval = $("#txtEditBasicValue").val();
+ var Insval = $("#txtEditInsurance").val();
+ var TotalOrderValue = $("#txtEditRevenueTotalOrderValue").val();
+
+ var TotalTaxValue = calculateEditTaxValue();
+
+
+ var tr= document.getElementById(userid);
+ var cellval = tr.cells;
+
+ cellval[2].innerHTML = editDescription;
+ cellval[3].innerHTML = editQuantity;
+ cellval[4].innerHTML =editUOM;
+ cellval[5].innerHTML =itemRate;
+ cellval[6].innerHTML =basicval;
+ cellval[7].innerHTML =TotalTaxValue;
+ cellval[8].innerHTML =TotalOrderValue;
+
+
+ $('#materialCode'+userid).val(editMaterialCode);
+ $('#materialName'+userid).val(editDescription);
+ $('#uom'+userid).val(editUOM);
+ $('#quantity'+userid).val(editQuantity);
+ $('#itemRate'+userid).val(itemRate);
+ $('#DisType'+userid).val(DisType);
+ $('#DisVal'+userid).val(DisVal);
+ $('#AfterDisVal'+userid).val(AfterDisVal);
+ $('#PackOption'+userid).val(PackOption);
+ $('#PackType'+userid).val(PackType);
+ $('#PackVal'+userid).val(PackVal);
+ $('#AfterPackVal'+userid).val(AfterPackVal);
+ $('#ExciseOption'+userid).val(ExciseOption);
+ $('#ExciseVal'+userid).val(ExciseVal);
+ $('#AfterExciseVal'+userid).val(AfterExciseVal);
+ $('#VatOption'+userid).val(VatOption);
+ $('#VatVal'+userid).val(VatVal);
+ $('#AfterVatVal'+userid).val(AfterVatVal);
+ $('#CSTOption'+userid).val(CSTOption);
+ $('#CSTVal'+userid).val(CSTVal);
+ $('#AfterCSTVal'+userid).val(AfterCSTVal);
+ $('#GSTVal'+userid).val(GSTVal);
+ $('#AfterGSTVal'+userid).val(AfterGSTVal);
+ $('#OtherTaxVal'+userid).val(OtherTaxVal);
+ $('#AfterOtherTaxVal'+userid).val(AfterOtherTaxVal);
+ $('#FreightType'+userid).val(FreightType);
+ $('#FreightVal'+userid).val(FreightVal);
+ $('#AfterFreightVal'+userid).val(AfterFreightVal);
+ $('#basicval'+userid).val(basicval);
+ $('#Insval'+userid).val(Insval);
+ $('#TotalOrderValue'+userid).val(TotalOrderValue);
+ populateValueMainFormForEditRevenueTax();
+ }
+
+ });
+ function validateEditRevenueTax()
+ {
+ if($('#EditRevenueCostCenter').val() == "0")
+ {
+ alert('Please select the Cost center');
+ $('#EditRevenueCostCenter').focus();
+ return false;
+ }
+ else if($('#EditRevenueMaterialCode').val() == "0")
+ {
+ alert('Please select the Material Code');
+ $('#EditRevenueMaterialCode').focus();
+ return false;
+ }
+ else if($('#EditRevenueQuantity').val() == '')
+ {
+ alert('Please Enter the Quantity value');
+ $('#EditRevenueQuantity').focus();
+ return false;
+ }
+ else if($('#EditRevenueRate').val() == '')
+ {
+ alert('Please Enter the Rate of the Item');
+ $('#EditRevenueRate').focus();
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ function validateEditExceedLimit()
+ {
+ var avalbudAmt = parseFloat($('#EditAvlBudAmt').val());
+ var basicAmountRate = parseFloat($('#txtEditBasicValue').val());
+ var totalAmount = parseFloat($('#txtEditTotalOrderValue').val());
+
+ if(basicAmountRate > avalbudAmt || totalAmount > avalbudAmt)
+ {
+ alert('Basic amount is exceeding the Budget Limit.Please adjust the product value.');
+ $('#EditRate').focus();
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+
+ }
+ function populateValueMainFormForEditRevenueTax()
+{
+
+ var rows = document.getElementById('serviceTax').rows.length;
+ //alert(rows);
+ var totBasicAmt = 0;
+ var totDiscountAmt = 0;
+ var totPackagingAmt = 0;
+ var totExciseAmt = 0;
+ var totVATAmt = 0;
+ var totCSTAmt = 0;
+ var totGSTAmt = 0;
+ var totOtherTaxAmt = 0;
+ var totFreightAmt = 0;
+ var totInsuranceAmt = 0;
+ var totOrderSummaryAmt = 0;
+ var i = 0;
+ do {
+ i += 1;
+
+
+ var tr= document.getElementById(i);
+ //alert(tr);
+ if(tr != null)
+ {
+ cells = tr.getElementsByTagName('td');
+
+
+ var rowid = cells[0].innerHTML;
+ // alert(rowid);
+ var Packaging = $('#AfterPackVal'+rowid).val() == '' ? '0.00' : $('#AfterPackVal'+rowid).val();
+ var ExciseDuty = $('#AfterExciseVal'+rowid).val() == '' ? '0.00' : $('#AfterExciseVal'+rowid).val();
+ var Vat = $('#AfterVatVal'+rowid).val() == '' ? '0.00' : $('#AfterVatVal'+rowid).val();
+ var CST =$('#AfterCSTVal'+rowid).val() == '' ? '0.00' : $('#AfterCSTVal'+rowid).val();
+ var GST = $('#AfterGSTVal'+rowid).val() == '' ? '0.00' : $('#AfterGSTVal'+rowid).val();
+ var OtherTax = $('#AfterOtherTaxVal'+rowid).val() == '' ? '0.00' : $('#AfterOtherTaxVal'+rowid).val();
+ var Freight = $('#AfterFreightVal'+rowid).val() == '' ? '0.00' : $('#AfterFreightVal'+rowid).val();
+ var Insurance = $('#Insval'+rowid).val() == '' ? '0.00' : $('#Insval'+rowid).val();
+ var Discount =$('#AfterDisVal'+rowid).val() == '' ? '0.00' : $('#AfterDisVal'+rowid).val();
+ var BasicVal = $('#basicval'+rowid).val() == '' ? '0.00' : $('#basicval'+rowid).val();
+ var TotalVal =$('#TotalOrderValue'+rowid).val() == '' ? '0.00' : $('#TotalOrderValue'+rowid).val();
+ //alert(TotalVal);
+
+
+ totBasicAmt = parseFloat(totBasicAmt ) + parseFloat(BasicVal);
+ totDiscountAmt = parseFloat(totDiscountAmt ) + parseFloat(Discount);
+ totPackagingAmt = parseFloat(totPackagingAmt) + parseFloat(Packaging);
+ totExciseAmt = parseFloat(totExciseAmt) + parseFloat(ExciseDuty);
+ totVATAmt = parseFloat(totVATAmt ) + parseFloat(Vat);
+ totCSTAmt = parseFloat(totCSTAmt ) + parseFloat(CST);
+ totGSTAmt = parseFloat(totGSTAmt ) + parseFloat(GST);
+ totOtherTaxAmt = parseFloat(totOtherTaxAmt ) + parseFloat(OtherTax);
+ totFreightAmt = parseFloat(totFreightAmt ) + parseFloat(Freight);
+ totInsuranceAmt = parseFloat(totInsuranceAmt ) + parseFloat(Insurance);
+ totOrderSummaryAmt = parseFloat(totOrderSummaryAmt ) + parseFloat(TotalVal);
+ }
+
+ } while (i < rows);
+
+
+ $('#txtTotBasicAmount').val(parseFloat(totBasicAmt).toFixed(2) );
+ $('#txtTotalDiscount').val(parseFloat(totDiscountAmt).toFixed(2) );
+ $('#txtTotalPackaing').val(parseFloat(totPackagingAmt).toFixed(2) );
+ $('#txtTotExciseDuty').val(parseFloat(totExciseAmt).toFixed(2) );
+ $('#txtTotalVat').val(parseFloat(totVATAmt).toFixed(2) );
+ $('#txtTotCST').val(parseFloat(totCSTAmt).toFixed(2) );
+ $('#txtTotalGST').val(parseFloat(totGSTAmt).toFixed(2) );
+ $('#txtTotalOtherTaxes').val(parseFloat(totOtherTaxAmt).toFixed(2) );
+ $('#txtTotalFreight').val(parseFloat(totFreightAmt).toFixed(2) );
+ $('#txtTotalInsurance').val(parseFloat(totInsuranceAmt).toFixed(2) );
+ $('#txtTotalOrderValueSummary').val(parseFloat(totOrderSummaryAmt).toFixed(2) );
+
+}
+
+
+
+