load->model('purchaseorder_model'); $this->load->library('session'); $this->load->library('form_validation'); $this->load->model('requistion_model'); $this->isLoggedIn(); } // start this function used to pono reset financeyear configuration function poresetview() { $this->global['pageTitle'] = 'Siddharth : PurchaseOrderNumber/FinanceYear-Configuration '; $data['ponoreset']=$this->purchaseorder_model->ponoresetfinyear(); $this->loadViews("poresetview", $this->global,$data,Null); } function addnew() { $pono1 = $this->input->post('pono'); //echo $pono; $potype1= $this->input->post('potype'); //echo $potype; $posubtype1 = $this->input->post('posubtype'); //echo $posubtype; //die; $ponoreset = array('pono'=>$pono1, 'potype'=>$potype1, 'posubtype'=>$posubtype1); $result = $this->purchaseorder_model->ponoreset($ponoreset); if( $result >= 0){ echo ""; redirect('purchaseorder/poresetview','refresh'); } } function edited(){ $sno=$this->input->post('sno'); //echo $sno; $pono = $this->input->post('pono'); //echo $pono; $potype= $this->input->post('potype'); // echo $potype; $posubtype = $this->input->post('posubtype'); //echo $posubtype; //die(); $ponoreset = array('pono'=>$pono, 'potype'=>$potype, 'posubtype'=>$posubtype); //print_r($ponoreset); die(); $result = $this->purchaseorder_model->updateponoreset($ponoreset,$sno,$potype,$posubtype); if( $result >= 0) { echo "Updated Successfully Saved"; redirect('purchaseorder/poresetview','refresh'); } } //end this function used to pono reset financeyear configuration /** * This function used to load the first screen of the user */ public function index() { $this->global['pageTitle'] = 'Siddharth : AddPO'; $this->loadViews("addPO", $this->global, NULL , NULL); } function viewfullpurchaseorder() { $this->global['pageTitle'] = 'Siddharth : View Purchase Order'; $this->loadViews("viewfullpurchaseorder", $this->global,Null); } function advancerequest() { $this->global['pageTitle'] = 'Siddharth : Advance Request'; $data['PONO']=$this->purchaseorder_model->getadvancePONO('ST026'); //print_r($data['PONO']); $this->loadViews("advancerequest", $this->global, $data, NULL); } function requisition() { $data['DeptList'] = $this->purchaseorder_model->getDepartmentListForAllReq(); $data['stList'] = $this->purchaseorder_model->getStatusListforAllReq(); /* Cost code from Requisition - Client Review Fix Start here */ // $data['ReqList'] = $this->purchaseorder_model->getRequistionListbySearch(); $data['ReqList'] = $this->purchaseorder_model->getAllRequistionListToCreatePO(); /* End Here */ $this->global['pageTitle'] = 'Siddharth : Create PO from Requisition List'; $this->loadViews("createPOfromRequistion", $this->global, $data,Null); } /** * This function is used to load the purchaseorder list */ function PurchaseOrderList() { $this->load->library('pagination'); // $count = $this->purchaseorder_model->purchaseorderListingCount(''); //$returns = $this->paginationCompress ( "purchaseorderListing/", $count, 10 ); $this->purchaseorder_model->UpdateRequistionStatus(); $data['POData'] = $this->purchaseorder_model->purchaseorderListing(); $this->global['pageTitle'] = 'Siddharth : Purchase Orders'; $this->loadViews("POlist", $this->global, $data, NULL); } function Req_validate($selectValue) { //echo 'select_validate method called'; // 'none' is the first option and the text says something like "-Choose one-" if(strlen($selectValue) == 0) { $this->form_validation->set_message('Req_validate', 'Please Select Requisition Number to Create PO.'); return false; } else // user picked something { return true; } } /** * This function used to show the Purchase Order Screen */ function CreatePurchaseOrder() { // if( $DEPCode == PURCHASE) // { $this->form_validation->set_rules('txtReqNo', 'txtReqNo', 'callback_Req_validate'); if($this->form_validation->run() == FALSE) { $this->requisition(); } else { $this->global['pageTitle'] = 'Siddharth : Purchase order' ; $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); $data['Payment']=$this->purchaseorder_model->getPaymentTermsDetails(); // print_r($data['Payment']); $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); $SelectedReq = json_decode($this->input->post('txtReqNo')); $Req = $SelectedReq->Req; $data['ReqList'] = $Req ; $ReqArray = array(); $ReqType = $this->input->post('txtReqType'); $result = array(); foreach ($Req as $SID): $ReqArray[] = $SID->ReqNo ; $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); if($ReqType == '') { $ReqType = $SID->ReqType; } endforeach; $data['MaterialList'] = $result; //print_r($data['MaterialList']); /* Cost code from Requisition - Client Review Fix Start here */ $ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray); $data['RequistionDetails'] = $ReqDetails; $CostCode = ''; $this->load->model('costcenter_model'); $FYStart = ''; $FYEnd = ''; $FiscalYear = $this->costcenter_model->getFiscalYear(); if(!empty($FiscalYear)) { foreach ($FiscalYear as $Fy) { $FYStart =$Fy->StartYear; $FYEnd =$Fy->EndYear; //$FYEnd=$FYStart+1; } } $FYdt = $FYStart." - ".$FYEnd ; //echo $FYEnd; foreach ($ReqDetails as $Rs): $CostCode = $Rs->CostCenterCode; endforeach; $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$FYdt,$ReqType); if(count($AvlBudget)>0) { $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; } /* End Here */ $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); //print_r($data['CompanyDetails']); // $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); $data['MaxPODate'] = $this->purchaseorder_model->getLastReleasedPODate(); $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); $data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR'); //print_r($data['INRSYMBOL']); $AvlimportBudget = $this->purchaseorder_model->GetAvailableImportBudgetAmount($CostCode,$FYdt,$ReqType); //print_r($AvlimportBudget); // $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType); //print_r($AvlimportBudget); if(count($AvlimportBudget)>0) { $data['AvlimportBudAmt'] = $AvlimportBudget[0]['BudgetAmount'] - $AvlimportBudget[0]['Totalvalue']; } $data['PoTypeOptions'] = $this->purchaseorder_model->getConfigValue('C026'); //print_r($data['PoTypeOptions']); // $data[$Rate->ExchangeRate]=$Rate->ExchangeRate; //$data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); $ViewName = ''; if($ReqType == REVENUE) { $ViewName = 'purchaseorder'; } else if($ReqType == SERVICE) { $ViewName = 'servicePurchaseorder'; } else if($ReqType == IMPORT) { $data['staticspecialinstruction']=$this->purchaseorder_model->getConfigValue('C027'); $ViewName = 'importpo'; } else if($ReqType == CAPITAL) { $data['staticspecialinstruction']=$this->purchaseorder_model->getConfigValue('C027'); $CapitalAvlBudget = $this->purchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode,$FYdt,$ReqType); if(count($CapitalAvlBudget)>0) { $data['AvlCapitalBudAmt'] = $CapitalAvlBudget[0]['BudgetAmount'] - $CapitalAvlBudget[0]['Totalvalue']; } $ViewName = 'capitalpurchaseorder'; } $this->loadViews($ViewName, $this->global,$data, NULL); } // } } function CreatePOPrint() { $PONO = $_GET['PONO']; $ReqType = $_GET['ReqType']; if($ReqType == SERVICE) { $this ->servicepoprint($PONO); } else if($ReqType == REVENUE) { $this ->revenuepoprint($PONO); } else if($ReqType == IMPORT) { $this ->importpoprint($PONO); } else if($ReqType == CAPITAL) { $this ->CapitalPoPrint($PONO); } } function CreaterevenuePOPrint() { $this->load->View("revenuepopdf", NULL); } function CreateservicePOPrint() { $this->load->View("servicepopdf", NULL); } function CreateimportPOPrint() { $this->load->View("importpopdf", NULL); } function CreatecapitalPOPrint() { $this->load->View("capitalpopdf", NULL); } //To View/Update Purchase Order function EditPurchaseOrder() { $PONO = $_GET['PONO']; $ReqType = $_GET['ReqType']; $Req = $this->purchaseorder_model->getRequistionNoFromPO($PONO); $data['ReqList'] = $Req ; $result = array(); $ReqArray = array(); foreach ($Req as $SID): $ReqArray[] = $SID->ReqNo ; $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); endforeach; $data['MaterialList'] = $result;//$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray); $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); $data['Payment']=$this->purchaseorder_model->getPaymentTermsDetails(); $data['PoTypeOptions'] = $this->purchaseorder_model->getConfigValue('C026'); $data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR'); /* Cost code from Requisition - Client Review Fix Start here */ $ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray); $data['RequistionDetails'] = $ReqDetails; foreach ($data['RequistionDetails'] as $ReqDet) { $Status=$ReqDet->Status; } $data['POSTATUS']=$this->purchaseorder_model->GetPOStatus($Status); foreach ($data['POSTATUS'] as $POST) { $Status=$POST->StatusName; } $CostCode = ''; $this->load->model('costcenter_model'); $FYStart = ''; $FYEnd = ''; $FiscalYear = $this->costcenter_model->getFiscalYear(); if(!empty($FiscalYear)) { foreach ($FiscalYear as $Fy) { $FYStart =$Fy->StartYear; $FYEnd =$Fy->EndYear; } } $FYdt = $FYStart." - ".$FYEnd ; foreach ($ReqDetails as $Rs): $CostCode = $Rs->CostCenterCode; endforeach; $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$FYdt,$ReqType); if(count($AvlBudget)>0) { $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; } /* End Here */ $data['POMaster'] = $this->purchaseorder_model->GetServicePurchaseOrder($PONO); //$data['POSTATUS']=$this->purchaseorder_model->GetServicePurchaseOrder($PONO); //print_r($data['POMaster']); foreach ($data['POMaster'] as $Exc) { $exRate=$Exc->ExchangeRate; } foreach ($data['POMaster'] as $TER) { $PAYTERM=$TER->PaymentTerms; } $data['getdata'] = $this->purchaseorder_model->getfunction($PONO); $data['MaxPODate'] = $this->purchaseorder_model->getLastReleasedPODate(); $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); if($ReqType == SERVICE) { $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetails($PONO); $data['getdata'] = $this->purchaseorder_model->getfunction($PONO); //s print_r($data['getdata']); $data['getlogpodtl']=$this->purchaseorder_model->getlogpodtl($PONO); $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); //$data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); //print_r($data);die; $this->global['pageTitle'] = 'Siddharth : Edit Service Purchase order form'; $this->loadViews("EditservicePurchaseorder", $this->global, $data, NULL); } else if($ReqType == REVENUE) { $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetails($PONO); $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); $data['getlogpodtl']=$this->purchaseorder_model->getlogpodtl($PONO); $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); $this->global['pageTitle'] = 'Siddharth : Edit Revenue Purchase order form'; $this->loadViews("editRevenuepurchaseorder", $this->global, $data, NULL); } else if($ReqType == IMPORT) { $AvlBudget = $this->purchaseorder_model->GetAvailableImportBudgetAmount($CostCode,$FYdt,$ReqType); if(count($AvlBudget)>0) { $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; } //print_r($data['AvlBudAmt']); $data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetails($PONO); // print_r($data['POItem']); $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); foreach($data['POMaster'] as $CUR) { //print_r($CUR->CurrencyType); $Currency=$CUR->CurrencyType; } // $data[$Rate->ExchangeRate]=$Rate->ExchangeRate; $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); $data['getlogpodtl']=$this->purchaseorder_model->getlogpodtl($PONO); //print_r($data['PaymentTerms']); $unicode =''; foreach ($data['CurrencyDetail'] as $Detail) { $unicode=$Detail->FontCode2000; } foreach ($data['CurrencyDetail'] as $Detail) { $currencycode=$Detail->Currency_Code; } //print_r($unicode); $data['unicode']=$unicode; $data['currencycode']=$currencycode; $this->global['pageTitle'] = 'Siddharth : Edit Import Purchase order form'; $this->loadViews("editimportpo", $this->global, $data, NULL); } else if($ReqType == CAPITAL) { $CapitalRange = $_GET['CapitalRange']; $CapitalAvlBudget = $this->purchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode,$FYdt,$ReqType); if(count($CapitalAvlBudget)>0) { $data['AvlCapitalBudAmt'] = $CapitalAvlBudget[0]['BudgetAmount'] - $CapitalAvlBudget[0]['Totalvalue']; } if($CapitalRange=='0'){ $data['POItem'] = $this->purchaseorder_model->getCapitalPurchaseOrderDetails($PONO); } else if($CapitalRange=='1'){ $data['POItem'] = $this->purchaseorder_model->getDomesticCapitalPurchaseOrderDetails($PONO); } $data['requestedBy'] = $this->purchaseorder_model->GetRequesedByDetails($PONO); $data['getlogpodtl']=$this->purchaseorder_model->getlogpodtl($PONO); //$CapitalRange=''; foreach($data['POItem'] as $Rate) { $exRate=$Rate->ExchangeRate; $CapitalRange=$Rate->CapitalRange; } foreach($data['POItem'] as $CUR) { $Currency=$CUR->CurrencyType; } if($CapitalRange=='0'){ $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); $data['ExchangeRate']=$exRate; $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); } else if($CapitalRange=='1'){ $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail('INR'); $data['ExchangeRate']=$exRate; $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); } $this->global['pageTitle'] = 'Siddharth : Edit Capital Purchase order form'; $this->loadViews("editCapitalPo", $this->global, $data, NULL); } } function PurchaseOrderFinanceView() { $PONO = $_GET['PONO']; $POType = $_GET['POType']; $ReqType= $_GET['ReqType']; $Req = $this->purchaseorder_model->getRequistionNoFromPO($PONO); $data['ReqList'] = $Req ; $result = array(); $ReqArray = array(); foreach ($Req as $SID): $ReqArray[] = $SID->ReqNo ; $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); endforeach; $data['MaterialList'] = $result;//$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray); $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); $data['Payment']=$this->purchaseorder_model->getPaymentTermsDetails(); $data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR'); /* Cost code from Requisition - Client Review Fix Start here */ $data['PoTypeOptions'] = $this->purchaseorder_model->getConfigValue('C026'); $ReqDetails = $this->purchaseorder_model->getRequistDetails($ReqArray); $data['RequistionDetails'] = $ReqDetails; foreach ($data['RequistionDetails'] as $ReqDet) { $Status=$ReqDet->Status; } $data['POSTATUS']=$this->purchaseorder_model->GetPOStatus($Status); foreach ($data['POSTATUS'] as $POST) { $Status=$POST->StatusName; } $CostCode = ''; $this->load->model('costcenter_model'); $FYStart = ''; $FYEnd = ''; $FiscalYear = $this->costcenter_model->getFiscalYear(); if(!empty($FiscalYear)) { foreach ($FiscalYear as $Fy) { $FYStart =$Fy->StartYear; $FYEnd =$Fy->EndYear; } } $FYdt = $FYStart." - ".$FYEnd ; foreach ($ReqDetails as $Rs): $CostCode = $Rs->CostCenterCode; endforeach; $AvlBudget = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$FYdt,$ReqType); if(count($AvlBudget)>0) { $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; } /* End Here */ $data['POMaster'] = $this->purchaseorder_model->GetServicePurchaseOrder($PONO); //$data['POSTATUS']=$this->purchaseorder_model->GetServicePurchaseOrder($PONO); //print_r($data['POMaster']); foreach ($data['POMaster'] as $Exc) { $exRate=$Exc->ExchangeRate; } foreach ($data['POMaster'] as $TER) { $PAYTERM=$TER->PaymentTerms; } $data['MaxPODate'] = $this->purchaseorder_model->getLastReleasedPODate(); $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); if($POType == IMPORT) { $AvlBudget = $this->purchaseorder_model->GetAvailableImportBudgetAmount($CostCode,$FYdt,'IMPORT'); //print_r($AvlBudget); if(count($AvlBudget)>0) { $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; } //print_r($data['AvlBudAmt']); $data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetails($PONO); // print_r($data['POItem']); $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); foreach($data['POMaster'] as $CUR) { //print_r($CUR->CurrencyType); $Currency=$CUR->CurrencyType; } // $data[$Rate->ExchangeRate]=$Rate->ExchangeRate; $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); $data['PoTypeOptions'] = $this->purchaseorder_model->getConfigValue('C026'); //print_r($data['PaymentTerms']); $unicode =''; foreach ($data['CurrencyDetail'] as $Detail) { $unicode=$Detail->FontCode2000; } foreach ($data['CurrencyDetail'] as $Detail) { $currencycode=$Detail->Currency_Code; } //print_r($unicode); $data['unicode']=$unicode; $data['currencycode']=$currencycode; $this->global['pageTitle'] = 'Siddharth : Edit Import Purchase order form'; $this->loadViews("editimportpo", $this->global, $data, NULL); } else if($POType == CAPITAL) { $CapitalRange = $_GET['CapitalRange']; $CapitalAvlBudget = $this->purchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode,$FYdt,$ReqType); if(count($CapitalAvlBudget)>0) { $data['AvlCapitalBudAmt'] = $CapitalAvlBudget[0]['BudgetAmount'] - $CapitalAvlBudget[0]['Totalvalue']; } if($CapitalRange=='0'){ $data['POItem'] = $this->purchaseorder_model->getCapitalPurchaseOrderDetails($PONO); } else if($CapitalRange=='1'){ $data['POItem'] = $this->purchaseorder_model->getDomesticCapitalPurchaseOrderDetails($PONO); } $data['requestedBy'] = $this->purchaseorder_model->GetRequesedByDetails($PONO); //$CapitalRange=''; foreach($data['POItem'] as $Rate) { $exRate=$Rate->ExchangeRate; $CapitalRange=$Rate->CapitalRange; } foreach($data['POItem'] as $CUR) { $Currency=$CUR->CurrencyType; } if($CapitalRange=='0'){ $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); $data['ExchangeRate']=$exRate; $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); } else if($CapitalRange=='1'){ $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail('INR'); $data['ExchangeRate']=$exRate; $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); } $this->global['pageTitle'] = 'Siddharth : Edit Capital Purchase order form'; $this->loadViews("editCapitalPo", $this->global, $data, NULL); } } // To get the Material value based on the MaterialCode function getDetailsforReq() { $SearchFilter= $this->input->post('id'); // $reqDate= $this->input->post('ReqDate'); $DeptCode = $SearchFilter[0]; $MatType = $SearchFilter[1]; $ReqNo = $SearchFilter[2]; // $ReqDetai = $this->purchaseorder_model->getRequistDetails( $EmpID ); $CostList = $this->requistion_model->GetCostCenterByDept( $DeptCode); $HTML = ""; $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']; } print_r($AvilBudAmt); } function getDateformat($Val) { $date = new DateTime($Val,new DateTimeZone('Asia/Kolkata')); $retDate = $date->format('Y-m-d H:i:s'); return $retDate; } /* Method to get the Requistion list based on the search filter*/ function SearchListofRequistion() { $SearchFilter= $this->input->post('id'); $DEPCode = $SearchFilter[0]; $Status = $SearchFilter[1]; $rng = $SearchFilter[2];; $FromDate =''; $ToDate = ''; $Dt = explode("-",$rng); if(count( $Dt)>1) { $FDate = $Dt[0]; $TDate = $Dt[1]; $FromDate = $this->getDateformat($FDate); $ToDate = $this->getDateformat($TDate); } $result = $this->purchaseorder_model->getRequistionListbySearch($DEPCode,$Status,$FromDate,$ToDate); $HTML=""; for ($i = 0; $i < count($result); $i++) { $SNo = $i + 1; $ReqNo = $result[$i]['ReqNo']; $ReqType = $result[$i]['ReqType']; $Reqedby = $result[$i]['FirstName']; $ReqDate = $result[$i]['ReqDate']; $Status = $result[$i]['StatusName']; $Department = $result[$i]['DepartmentName']; $Designation = $result[$i]['Designation']; $HTML.=" ". $ReqNo." ".$ReqType." ".$Reqedby." ".$ReqDate." ".$Status." ".$Department." ".$Designation." "; } 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." ".$MaterialName." ".$UOM." ".$Quantity." "; //$index = $index + 1; } $CostCenter = ""; if(count($CostList) > 0) { for ($j = 0; $j < count($CostList); $j++) { $Code = $CostList[$j]['CostCenterCode']; $Name = $CostList[$j]['CostCenterName']; $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'); $POType = $this->input->post('POType'); $DeliveryOption = $this->input->post('DateRange'); if($DeliveryOption==1){ $Deliverydt = ''; $DeliverySchedule = $this->input->post('Scheduleby'); } else{ $Deliverydt = $this->getDateformat($dt); $DeliverySchedule = ''; } $POType = $this->input->post('POType'); $BudgetType = $this->input->post('Budget'); //$PoRange = $this->input->post('txtPoRange'); $Modeofshipment=$this->input->post('addmodeofshipment'); $supplierreference=$this->input->post('addsupplierreference'); $supplieroffno=$this->input->post('addsupplierofferno'); $otherreference=$this->input->post('addotherreference'); $fincap=$this->input->post('addfincap'); $revenuetype=$this->input->post('PoTypeOptions'); $insurancestatus=$this->input->post('insurance'); if($insurancestatus == 1){ $insuranceno=$this->input->post('insuranceno'); }else{ $insuranceno=$this->input->post('insuranceno'); } $SpcialInstruction = $this->input->post('SpcialInstruction'); $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); $POStatus = $this->input->post('txtStatus'); $CreateBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); $DeletedRow = $this->input->post('txtDeletedRow'); $comma_separated = explode(':', $DeletedRow); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); $PaymentTerms=$this->input->post('PaymentTerms'); $OtherPayment=$this->input->post('Otherpayment'); $Local_Interstate=$this->input->post('Range'); $Qualitycheck=1; // PO Master $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'Status'=>$POStatus,'PORange'=>$Local_Interstate,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'CapitalRange'=>$Local_Interstate,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$supplierreference,'Mode_Of_Shipment'=>$Modeofshipment,'Supplier_Offer_No'=>$supplieroffno,'Other_Reference'=>$otherreference,'Fincap'=>$fincap,'InsuranceStatus'=>$insurancestatus,'POSubType'=>$revenuetype,'InsuranceNumber'=>$insuranceno,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); // print_r($POList); // die(); $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$revenuetype); $PONO = ''; if(count($POMaster)>0) { $PONO = $POMaster[0]['PONO']; } // PO Line Items $LineItemStatus = REQITEM_NEW; for ($i = 1; $i <= $RowCount; $i++) { $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); $per=$this->input->post('per'.$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); $FreightType = $this->input->post('FreightType'.$i); $FreightValue = $this->input->post('FreightVal'.$i); $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); $NOOfTrip = $this->input->post('NoOfTrip'.$i); $InsuranceValue = $this->input->post('Insval'.$i); $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); $revenuedescription = $this->input->post('Service_Description'.$i); $CostCenter = $this->input->post('costCode'.$i); $Cgst = $this->input->post('RevenueCgst'.$i); $Sgst = $this->input->post('RevenueSgst'.$i); $Igst = $this->input->post('RevenueIgst'.$i); $AfterCgst = $this->input->post('RevenueAfterCgst'.$i); $AfterSgst = $this->input->post('RevenueAfterSgst'.$i); $AfterIgst = $this->input->post('RevenueAfterIgst'.$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,'Per'=>$per,'ServiceMaterialDescription'=>$revenuedescription,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); //print_r($POLineItemList); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); $LineItemNo = ''; if(count($POLineItem)>0) { $LineItemNo = $POLineItem[0]['LineItemNo']; } //echo $LineItemNo; /*---------*/ // $logpo =array('PONO'=>$PONO,'Date'=>$PODate,'POType'=>$POType,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'SupplierID'=>$SupplierID,'LineItemNos'=>$LineItemNo); // $addlog= $this->purchaseorder_model->newlogpo($logpo); /*---------*/ if(trim($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,'Insurance'=>$InsuranceValue,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CGST'=>$Cgst,'AfterCGST'=>$AfterCgst,'SGST'=>$Sgst,'AfterSGST'=>$AfterSgst,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'NoOfTrip'=>$NOOfTrip); //print_r($RevenueTaxList); $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() { //echo "EDIT REBEIE"; //die(); $PONO =$this->input->post('txtPONO'); $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); $newsup=$this->input->post('newsup'); $newSupId = split("[ - ]+", $newsup); $DeliveryAddr = $this->input->post('txtDeliveryAddress'); $dt = $this->input->post('Deliverydt'); //$Deliverydt = $this->getDateformat($dt); $DeliveryOption = $this->input->post('DateRange'); if($DeliveryOption==1){ $Deliverydt = ''; $DeliverySchedule = $this->input->post('Scheduleby'); } else{ $Deliverydt = $this->getDateformat($dt); $DeliverySchedule = ''; } /*-----------------------------------*/ $b4supplier=$this->input->post('b4supplier'); $b4date=$this->input->post('b4podate'); $b4podate = $this->getDateformat($b4date); /*-----------------------------------*/ $Modeofshipment=$this->input->post('editmodeofshipment'); $supplierreference=$this->input->post('editsupplierreference'); $supplieroffno=$this->input->post('editsupplierofferno'); $otherreference=$this->input->post('editotherreference'); $fincap=$this->input->post('editfincap'); $revenuetype=$this->input->post('PoTypeOptions'); $insurancestatus=$this->input->post('insurancestatus'); if($insurancestatus == 1){ $insuranceno=$this->input->post('insuranceno'); }else{ $insuranceno=""; } $POType = $this->input->post('POType'); $PoRange = $this->input->post('txtPoRange'); $BudgetType = $this->input->post('Budget'); $SpcialInstruction = $this->input->post('SpcialInstruction'); $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); $POStatus = $this->input->post('txtStatus'); $updatedBy = $this->session->userdata('userId'); //echo($updatedBy); $RowCount = $this->input->post('txtRowCount'); $DeletedRow = $this->input->post('txtDeletedRow'); //echo $RowCount . "-" . $DeletedRow; //die(); $comma_separated = explode(':', $DeletedRow); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updateddt = $dt->format('Y-m-d H:i:s'); $PaymentTerms=$this->input->post('PaymentTerms'); $OtherPayment=$this->input->post('Otherpayment'); $Local_Interstate=$this->input->post('Range'); $Qualitycheck=1; // PO Master // PO Master $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'Status'=>$POStatus,'PORange'=>$Local_Interstate,'ServiceDescription'=>$SpcialInstruction,'UpdateBY'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'CapitalRange'=>$Local_Interstate,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$supplierreference,'Mode_Of_Shipment'=>$Modeofshipment,'Supplier_Offer_No'=>$supplieroffno,'Other_Reference'=>$otherreference,'Fincap'=>$fincap,'InsuranceStatus'=>$insurancestatus,'POSubType'=>$revenuetype,'InsuranceNumber'=>$insuranceno,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); //print_r($POList); //die(); $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); $LineItemStatus = REQITEM_NEW; if($PODate != $b4podate ) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>'-','UpdateBy'=>$updatedBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4podate,'newValue'=>$PODate,'entity'=>'PO DateChanged'); $this->purchaseorder_model->insertlogpo($logpo); } if(!empty($newSupId[0] )) { if($newSupId[0] != $b4supplier) { //echo $b4supplier.'-'.$newSupId[0];die; $logpo =array('PONO'=>$PONO,'LineItemNos'=>'-','UpdateBy'=>$updatedBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4supplier,'newValue'=>$newsup,'entity'=>'Supplier Changed'); $this->purchaseorder_model->insertlogpo($logpo); } } //echo "OUT"; for ($i = 1; $i <= $RowCount; $i++) { //echo "IN"; $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); /*-----------------------------------*/ $b4qty=$this->input->post('b4qty'.$i); $b4rate=$this->input->post('b4rate'.$i); /*-----------------------------------*/ $itemRate = $this->input->post('itemRate'.$i); $per=$this->input->post('per'.$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); $Cgst = $this->input->post('RevenueCgst'.$i); $Sgst = $this->input->post('RevenueSgst'.$i); $Igst = $this->input->post('RevenueIgst'.$i); $AfterCgst = $this->input->post('RevenueAfterCgst'.$i); $AfterSgst = $this->input->post('RevenueAfterSgst'.$i); $AfterIgst = $this->input->post('RevenueAfterIgst'.$i); $FreightType = $this->input->post('FreightType'.$i); $FreightValue = $this->input->post('FreightVal'.$i); $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); $NOOfTrip = $this->input->post('NoOfTrip'.$i); $revenuedescription = $this->input->post('service_description'.$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 = ''; /*---------start---------------------*/ if($Quantity != $b4qty) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>$POLineItemNo,'UpdateBy'=>$updatedBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4qty,'newValue'=>$Quantity,'entity'=>'Quantity Changed'); $this->purchaseorder_model->insertlogpo($logpo); } if($itemRate != $b4rate) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>$POLineItemNo,'UpdateBy'=>$updatedBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4rate,'newValue'=>$itemRate,'entity'=>'Rate Changed'); $this->purchaseorder_model->insertlogpo($logpo); } // if($PODate != $b4podate ) // { // $logpo =array('UpdateBy'=>$updatedBy,'UpdatedOn'=>$updateddt); // $this->purchaseorder_model->updatelogpo($MaterialCode,$POLineItemNo,$logpo); // } // if($PODate != $b4podate ) // { // $logpo =array('UpdateBy'=>$updatedBy,'UpdatedOn'=>$updateddt); // $this->purchaseorder_model->updatelogpo($MaterialCode,$POLineItemNo,$logpo); // } // if($PODate != $b4podate ) // { // $logpo =array('UpdateBy'=>$updatedBy,'UpdatedOn'=>$updateddt); // $this->purchaseorder_model->updatelogpo($MaterialCode,$POLineItemNo,$logpo); // } /*----------end--------------------*/ $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; } } } /*-------------start-----------------*/ //if($MaterialCode!= ''){ $ReqDetails = array('Quantity'=>$Quantity,'UpdatedBy'=>$updatedBy,'UpdatedOn'=>$updateddt); //print_r($ReqDetails); $this->purchaseorder_model->updateReqDetails($Reqnumber,$MaterialCode,$ReqDetails); // } $recqty=0; if($POStatus == SPECIAL_PO) { $recqty= $Quantity; $IGRD= $this->purchaseorder_model->IGRDetailsupdate($PONO); $j = $i-1; // print_r($IGRD); die; $IGRDs = array('QuantityAsPerInvoice'=>$Quantity,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt); $this->purchaseorder_model->updateIGR($IGRD[$j]['IGRItemNo'],$IGRDs); } //print_r($data['IGRDetails']); /*-----------end-------------------*/ if($SkipInsert == "False") { if(strlen($POLineItemNo) == 0) { $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Per'=>$per,'ServiceMaterialDescription'=>$revenuedescription,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter); //print_r($POLineItemList); $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,'ReceivedQuantity'=>$recqty,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter); //print_r($POLineItemList); $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,'Insurance'=>$InsuranceValue,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CGST'=>$Cgst,'AfterCGST'=>$AfterCgst,'SGST'=>$Sgst,'AfterSGST'=>$AfterSgst,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'NoOfTrip'=>$NOOfTrip); //print_r($RevenueTaxList); $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,'Insurance'=>$InsuranceValue,'TotalValue'=>$TotalOrderValue, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'CGST'=>$Cgst,'AfterCGST'=>$AfterCgst,'SGST'=>$Sgst,'AfterSGST'=>$AfterSgst,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'CreatedBy'=>$updatedBy,'NoOfTrip'=>$NOOfTrip); //print_r($RevenueTaxList); $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']; $PoStatus=''; $data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO); $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformationforPDF(); $data['GetPoFormat'] = $this->purchaseorder_model->GetPoFormat($PONO); $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetailsForPDF($PONO); $data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO); $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR'); $data['reveuetax']=$this->purchaseorder_model->getRevenueTaxinforforpdf($PONO); $data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO); $Currencycode=''; $TotalOrderValue=$data['POItem'][0]->TotalOrderValue; $AdvanceAmount=0.00; foreach ($data['POItem'] as $POI) { $AdvanceAmount=$POI->AdvanceAmount; $PoStatus=$POI->Status; } $TotaltoPay=0.00; $TotaltoPay=$TotalOrderValue-$AdvanceAmount; $totalAmt=sprintf("%.2f", $TotalOrderValue); $data['TotalAmountInWords']= $this->convertNumber($totalAmt); $data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($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'); // $paper_orientation = 'portrait'; // $customPaper = array(0,0,750,950); // $this->dompdf->set_paper($customPaper,$paper_orientation); // // Convert to PDF // $this->dompdf->load_html($php); // $this->dompdf->render(); // $data['Attachment'] = FALSE; // $this->dompdf->stream("RevenuePOReport".$PONO.".pdf",$data,$php); $mpdf=new mPDF('utf-8','A4-P',7, 10,10, 10, 82, 38, 4, 6); //$mpdf=new mPDF('utf-8', array(190,236)); $HtmlHeading = $this->load->view('includes/pdfheader',$data, true); $HTMLFooter = $this->load->view('includes/pdffooter',$data, true); $mpdf->SetWatermarkImage('./assets/images/mpdf.png', 8, 10 ); $mpdf->showWatermarkImage = true; $mpdf->SetDisplayMode('fullpage'); if($PoStatus == PO_RELEASED || $PoStatus == PO_SERVICE_COMPLETED || $PoStatus == MRIR_APPROVED || $PoStatus == MRIR_REJECTED || $PoStatus == IGR_CREATED || $PoStatus==''||$PoStatus==SPECIAL_PO){ $mpdf->SetWatermarkText(''); } else{ $mpdf->SetWatermarkText('DRAFT'); } $mpdf->watermark_font = 'DejaVuSansCondensed'; $mpdf->showWatermarkText = true; //$mpdf->Image('files/images/frontcover.jpg', 0, 0, 210, 297, 'jpg', '', true, false); $mpdf->SetHTMLHeader($HtmlHeading); $html = $this->load->view('revenuepopdf',$data,true); //$mpdf=new mPDF('utf-8', array(500,500)); $mpdf->SetDisplayMode('fullpage'); $mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}"); //$mpdf->setFooter("Page {PAGENO} of {nb}"); $mpdf->list_indent_first_level = 1; $mpdf->setAutoTopMargin = 'stretch'; $mpdf->setAutoBottomMargin = 'stretch'; //$stylesheet = file_get_contents('assets/css/mpdfstyletables.css'); //$mpdf->WriteHTML($stylesheet, 1); $mpdf->WriteHTML($html); //$mpdf->writeHTMLHeaders(); $mpdf->Output('RevenuePOReport'.$PONO.'.pdf','I'); } public function servicepoprint($PONO) { // $this->load->view('includes/pdfheader'); // Load the pdf page with multiviews $PoStatus=''; $data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO); $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformationforPDF(); $data['GetPoFormat'] = $this->purchaseorder_model->GetPoFormat($PONO); $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetailsForpdf($PONO); $data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO); $data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO); $data['serviceTaxList'] = $this->purchaseorder_model->GetServiceTaxDetails($PONO); $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR'); //print_r( $data['CurrencySymbol']); $TotalOrderValue=0; $Currencycode=''; foreach ($data['POItem'] as $POValue) { $TotalOrderValue=$TotalOrderValue + $POValue->TotalValue; } $Advance=0.00; foreach ($data['POItem'] as $PO) { $Advance=$PO->AdvanceAmount; $PoStatus=$PO->Status; } $TotaltoPay=0.00; $TotaltoPay=$TotalOrderValue-$Advance; $totalAmt=sprintf("%.2f", $TotalOrderValue); $data['TotalAmountInWords']= $this->convertNumber($totalAmt); $data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($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'); // $paper_orientation = 'portrait'; // $customPaper = array(0,0,750,950); // $this->dompdf->set_paper($customPaper,$paper_orientation); // // Convert to PDF // $this->dompdf->load_html($php); // $this->dompdf->render(); // $data['Attachment'] = FALSE; // $this->dompdf->stream("ServicePOReport".$PONO.".pdf",$data,$php); $mpdf=new mPDF('utf-8','A4-P',7, 10,10, 10, 82, 38, 4, 6); //$mpdf=new mPDF('utf-8', array(190,236)); $HtmlHeading = $this->load->view('includes/pdfheader',$data, true); $HTMLFooter = $this->load->view('includes/pdffooter',$data, true); $mpdf->SetWatermarkImage('./assets/images/mpdf.png', 8, 10 ); $mpdf->showWatermarkImage = true; $mpdf->SetDisplayMode('fullpage'); if($PoStatus == PO_RELEASED || $PoStatus == PO_SERVICE_COMPLETED || $PoStatus == MRIR_APPROVED || $PoStatus == MRIR_REJECTED || $PoStatus == IGR_CREATED || $PoStatus==''||$PoStatus==SPECIAL_PO){ $mpdf->SetWatermarkText(''); } else{ $mpdf->SetWatermarkText('DRAFT'); } $mpdf->watermark_font = 'DejaVuSansCondensed'; $mpdf->showWatermarkText = true; //$mpdf->Image('files/images/frontcover.jpg', 0, 0, 210, 297, 'jpg', '', true, false); $mpdf->SetHTMLHeader($HtmlHeading); $html = $this->load->view('servicepopdf',$data,true); //$mpdf=new mPDF('utf-8', array(500,500)); $mpdf->SetDisplayMode('fullpage'); $mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}"); //$mpdf->setFooter("Page {PAGENO} of {nb}"); $mpdf->list_indent_first_level = 1; $mpdf->setAutoTopMargin = 'stretch'; $mpdf->setAutoBottomMargin = 'stretch'; //$stylesheet = file_get_contents('assets/css/mpdfstyletables.css'); //$mpdf->WriteHTML($stylesheet, 1); $mpdf->WriteHTML($html); //$mpdf->writeHTMLHeaders(); $mpdf->Output('ServicePOReport'.$PONO.'.pdf','I'); } public function importpoprint($PONO) { // echo $PONO; // die(); //$this->load->view('includes/pdfheader'); // Load the pdf page with multiviews $Requester=''; $Depcode=''; $Currencycode=''; $PoStatus=''; $data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO); $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformationforPDF(); $data['GetPoFormat'] = $this->purchaseorder_model->GetPoFormat($PONO); $data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetailsForPDF($PONO); $data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO); $data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO); $data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO); //print_r( $data['RequistionDetails']); foreach ($data['POItem'] as $Reqdby) { $Requester=$Reqdby->Requestedby; $PoStatus=$Reqdby->Status; } foreach ($data['POItem'] as $CURTYPE) { $Currencycode=$CURTYPE->CurrencyType; } $data['Requestername']=$this->purchaseorder_model->GerRequesterName($Requester); foreach ($data['Requestername'] as $ReqDep) { $Depcode=$ReqDep->Departmentcode; } $data['DEPCODE']=$this->purchaseorder_model->GerRequesterDep($Depcode); //print_r($data['Requestername']); $data['Currencytype']=$this->purchaseorder_model->GerCurrencyCodeName($Currencycode); $ProductPrice=''; $TotalOrderValue = 0.0; foreach ($data['POItem'] as $PO ) { $TotalOrderValue=$PO->TotalOrderValue; } $AdvanceAmount=0.0; foreach ($data['POItem'] as $POI) { $AdvanceAmount=$POI->AdvanceAmount; } $TotaltoPay=0.00; $TotaltoPay=$TotalOrderValue-$AdvanceAmount; //$totalAmt=sprintf("%.2f", $ProductPrice); //$data['TotalAmountInWords']= $this->convertNumber($totalAmt); //print_r($data['TotalAmountInWords']); //$this->load->View("importpopdf", $data); $CurrencyType=''; if(!empty($data['POItem'])){ $CurrencyType=$data['POItem'][0]->CurrencyType; } //echo $CurrencyType; if($CurrencyType=='') { $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR'); } else { $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName($CurrencyType); } // $TotalOrderValue=$data['POItem'][0]->$TotalOrderValue; //print_r($data['POItem'][0]); $totalAmt=sprintf("%.2f", $TotalOrderValue); $data['TotalAmountInWords']= $this->convertNumber($totalAmt); $SymbolCurrency = ''; $SymbolCurrencyName =''; $PaiseVal = ''; if(!empty($data['CurrencySymbol']) >0) { $SymbolCurrency=$data['CurrencySymbol'][0]->FontCode2000; $SymbolCurrencyName=$data['CurrencySymbol'][0]->Currency; $PaiseVal=$data['CurrencySymbol'][0]->PaiseVal; } $TotalOrderValue=$data['POItem'][0]->TotalOrderValue; $totalAmt=sprintf("%.2f", $TotaltoPay); // $data['TotalAmountInWords']= $this->convertNumberSymbol($totalAmt,$SymbolCurrency,$SymbolCurrencyName,$PaiseVal); // $this->load->View("importpopdf", $data); // $this->load->View("mririmportpopdf", $data); // Add header to pdf //s $this->load->view('includes/pdffooter'); // Get output html // $php = $this->output->get_output(); // Load library // $this->load->library('dompdf_gen'); // $paper_orientation = 'portrait'; // $customPaper = array(0,0,750,950); // $this->dompdf->set_paper($customPaper,$paper_orientation); // Convert to PDF //$this->dompdf->set_paper(array(0, 0, 841.89, 1190.55), 'landscape'); // $this->dompdf->load_html($php); // $this->dompdf->render(); //$data['Attachment'] = FALSE; // $this->dompdf->stream("ImportPOReport".$PONO.".pdf",$data,$php); /// $mpdf=new mPDF('utf-8','A4-P',7, 10,10, 10, 82, 38, 4, 6); //$mpdf=new mPDF('utf-8', array(190,236)); $HtmlHeading = $this->load->view('includes/pdfheader',$data, true); $HTMLFooter = $this->load->view('includes/pdffooter',$data, true); $mpdf->SetWatermarkImage('./assets/images/mpdf.png', 8, 10 ); $mpdf->showWatermarkImage = true; $mpdf->SetDisplayMode('fullpage'); if($PoStatus == PO_RELEASED || $PoStatus == PO_SERVICE_COMPLETED || $PoStatus == MRIR_APPROVED || $PoStatus == MRIR_REJECTED || $PoStatus == IGR_CREATED || $PoStatus==''||$PoStatus==SPECIAL_PO){ $mpdf->SetWatermarkText(''); } else{ $mpdf->SetWatermarkText('DRAFT'); } $mpdf->watermark_font = 'DejaVuSansCondensed'; $mpdf->showWatermarkText = true; //$mpdf->Image('files/images/frontcover.jpg', 0, 0, 210, 297, 'jpg', '', true, false); $mpdf->SetHTMLHeader($HtmlHeading); $html = $this->load->view('importpopdf',$data,true); //$mpdf=new mPDF('utf-8', array(500,500)); $mpdf->SetDisplayMode('fullpage'); $mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}"); //$mpdf->setFooter("Page {PAGENO} of {nb}"); $mpdf->list_indent_first_level = 1; $mpdf->setAutoTopMargin = 'stretch'; $mpdf->setAutoBottomMargin = 'stretch'; //$stylesheet = file_get_contents('assets/css/mpdfstyletables.css'); //$mpdf->WriteHTML($stylesheet, 1); $mpdf->WriteHTML($html); //$mpdf->writeHTMLHeaders(); $mpdf->Output('ImportPOReport'.$PONO.'.pdf','I'); } /** * 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]; } If($POType == REVENUE) { $this->purchaseorder_model->DeletePORevenueTax($LineItemNo); } else If($POType == SERVICE) { $this->purchaseorder_model->DeletePOServiceTax($LineItemNo); } else If($POType == IMPORT) { $this->purchaseorder_model->DeletePOImportTax($LineItemNo); } else If($POType == CAPITAL) { $this->purchaseorder_model->DeletePOImportTax($LineItemNo); $this->purchaseorder_model->DeletePOServiceTax($LineItemNo); } $this->purchaseorder_model->DeletePOLineItem($LineItemNo , $ReqNo,$MaterialCode); echo "Successfully Deleted the Line item".$LineItemNo; } function addNewImportPurchaseOrder() {//echo ("ggh"); $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); $DeliveryAddr = $this->input->post('DeliveryAddr'); $POType = $this->input->post('POType'); $PoRange = $this->input->post('txtPoRange'); $DeliveryOption = $this->input->post('DateRange'); //echo $DeliveryOption; //die(); $DeliverySchedule=''; $Dispatch=''; if($DeliveryOption==1) { $Dispatch=''; $DeliverySchedule = $this->input->post('Scheduleby'); } else { $Dispatch = $this->input->post('Dispatch'); $DeliverySchedule = ''; } $SpcialInstruction = $this->input->post('txtSpcialInstruction'); $TotalOrder = $this->input->post('txtToatlOrder'); $POStatus = $this->input->post('textStatus'); $BudgetType = $this->input->post('Budget'); $CreateBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); $DeletedRow = $this->input->post('txtDeletedRow'); $comma_separated = explode(':', $DeletedRow); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); $Exchangerate=$this->input->post('ExchangeRate'); $Edt=$this->input->post('Exchangerateon'); $ExchangeRateCalculatedon=$this->getDateformat($Edt); $CurrencyType=$this->input->post('currencytype'); $PaymentTerms=$this->input->post('PaymentTerms'); $OtherPayment=$this->input->post('Otherpayment'); $Palaceoforigin=$this->input->post('PlaceOforigin'); // $Payableat=$this->input->post('PayableAT'); $Shipmentmode=$this->input->post('addmodeofshipment'); $SupplierRef=$this->input->post('addsupplierreference'); $SupplierOffer=$this->input->post('addsupplierofferno'); $otherRef=$this->input->post('addotherreference'); $finCap=$this->input->post('addfincap'); $importoption=$this->input->post('Importoption'); // echo $importoption; // die(); $Insurance=$this->input->post('Insurance'); if($Insurance==1) { $Insurancenumber=$this->input->post('insurancenumber'); } else { $Insurancenumber=''; } // $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'CreatedDate'=>$createddt,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType); $Qualitycheck=1; $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'Import_DispatchDetails'=>$Dispatch,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'Import_PlaceofOrgin'=>$Palaceoforigin,'PaymentOtherDescription'=>$OtherPayment,'Mode_Of_Shipment'=>$Shipmentmode,'Supplier_Reference'=>$SupplierRef,'Supplier_Offer_No'=>$SupplierOffer,'Other_Reference'=>$otherRef,'Fincap'=>$finCap,'InsuranceStatus'=>$Insurance,'InsuranceNumber'=>$Insurancenumber,'POSubType'=>$importoption,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); //print_r($POList); //die(); $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$importoption); $PONO = ''; if(count($POMaster)>0) { $PONO = $POMaster[0]['PONO']; } //echo $PONO; //echo $POType; // PO Line Items $LineItemStatus = REQITEM_NEW; //echo ' test:'.REVENUE; //echo $RowCount; for ($i = 1; $i <= $RowCount; $i++) { //echo "AS"; $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); //echo $Quantity; $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); //$Exchangerate = $this->input->post('Exchangerate'.$i); $BasicPriceinmton = $this->input->post('BasicPriceinUS'.$i); $Productprice = $this->input->post('BasicAmt'.$i); $LandingCharge = $this->input->post('LandingChargee'.$i); $AfterLandingCharge = $this->input->post('AfterLandingChargee'.$i); $CustomDuty = $this->input->post('Customduty'.$i); $AfterCustomDuty = $this->input->post('AfterCustomduty'.$i); $CustomEd= $this->input->post('CustomEDcess'.$i); $AfterCustomEd= $this->input->post('AfterCustomEDcess'.$i); $CustomSH = $this->input->post('CustomSHcess'.$i); $AfterCustomSH = $this->input->post('AfterCustomSHcess'.$i); $Grossdutypayable = $this->input->post('Grossdutypayable'.$i); $CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpenses'.$i); $QuantityKG = $this->input->post('PurQuantity'.$i); //$currencytypeID = $this->input->post('currencytype'); $Totalvalueitem=$this->input->post('TotalExp'.$i); //echo $BasicPriceinmton; $CostCenter = $this->input->post('costCode'.$i); $AssessableValue=$this->input->post('AfterAssessable'.$i); $Subtotal=$this->input->post('Subtotal'.$i); $Igst=$this->input->post('Igst'.$i); $AfterIgst=$this->input->post('AfterIgst'.$i); $Dutyimpact=$this->input->post('Dutyimpact'.$i); $Clearingcharge=$this->input->post('ClearingCharges'.$i); $Nettvalue=$this->input->post('Nett'.$i); $FreightType=$this->input->post('FreightType'.$i); $nooftrip=$this->input->post('NoofTrip'.$i); $Freightrate=$this->input->post('FreightRate'.$i); $Freightamount=$this->input->post('AfterFreightRate'.$i); //echo $Freightamount; $specialinstruction=$this->input->post('Addinstruction'.$i); //echo $specialinstruction; $per=$this->input->post('Per'.$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,'Per'=>$per,'ServiceMaterialDescription'=>$specialinstruction); //print_r($POLineItemList); //die(); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); $LineItemNo = ''; if(count($POLineItem)>0) { $LineItemNo = $POLineItem[0]['LineItemNo']; } //echo $LineItemNo; /* --------------------------------------------*/ // $logpo =array('PONO'=>$PONO,'Date'=>$PODate,'POType'=>$POType,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=> $itemRate,'SupplierID'=>$SupplierID,'LineItemNos'=>$LineItemNo); // $this->purchaseorder_model->newlogpo($logpo); /* --------------------------------------------*/ if(trim($POType) == IMPORT ) { // echo 'Success'; $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'Grossdutypayable'=>$Grossdutypayable,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem,'FreightType'=>$FreightType,'NoOfTrip'=>$nooftrip,'FreightValue'=>$Freightrate,'AfterFreightValue'=>$Freightamount,'AssessableValue'=>$AssessableValue,'SubTotal'=>$Subtotal,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'DutyImpact'=>$Dutyimpact,'ClearingCharge'=>$Clearingcharge,'NetValue'=>$Nettvalue); //print_r($ImportTaxList); //die();$Nettvalue $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); } } } echo 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; } function EditImportPurchaseOrder() { //echo "dfds"; //die(); $PONO =$this->input->post('txtPONO'); $POdt = ''; $createddt=''; $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); $newsup=$this->input->post('newsup'); $newSupId = split("[ - ]+", $newsup); /*-----------------------------------*/ $b4supplier=$this->input->post('b4supplier'); $b4date=$this->input->post('b4podate'); $b4podate = $this->getDateformat($b4date); /*-----------------------------------*/ $DeliveryAddr = $this->input->post('DeliveryAddr'); $dt = $this->input->post('Deliverydt'); $Deliverydt = $this->getDateformat($dt); $POType = $this->input->post('POType'); //$PoRange = $this->input->post('txtPoRange'); //$DeliveryOption = $this->input->post('DateRange'); $Exchangerate=$this->input->post('ExchangeRate'); $Edt=$this->input->post('Exchangerateon'); $ExchangeRateCalculatedon=$this->getDateformat($Edt); // $ExchangeRateCalculatedon=$this->input->post('Exchangerateon'); $CurrencyType=$this->input->post('currencytype'); $DeliveryOption = $this->input->post('DateRange'); //echo $DeliveryOption; //die(); $DeliverySchedule=''; $Dispatch=''; if($DeliveryOption==1) { $Dispatch=''; $DeliverySchedule = $this->input->post('Scheduleby'); } else { $Dispatch = $this->input->post('Dispatch'); $DeliverySchedule = ''; } $SpcialInstruction = $this->input->post('txtSpcialInstruction'); //$TotalOrder = $this->input->post('txtToatlOrder'); $TotalOrder = $this->input->post('txttot'); // echo $TotalOrder; //die(); $POStatus = $this->input->post('txtStatus'); $BudgetType = $this->input->post('Budget'); $CreateBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); $DeletedRow = $this->input->post('txtDeletedRow'); $comma_separated = explode(':', $DeletedRow); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updateddt = $dt->format('Y-m-d H:i:s'); $PaymentTerms=$this->input->post('PaymentTerms'); $OtherPayment=$this->input->post('Otherpayment'); $Palaceoforigin=$this->input->post('PlaceOforigin'); // $Payableat=$this->input->post('PayableAT'); $Shipmentmode=$this->input->post('editmodeofshipment'); $SupplierRef=$this->input->post('editsupplierreference'); $SupplierOffer=$this->input->post('editsupplierofferno'); $otherRef=$this->input->post('editotherreference'); $finCap=$this->input->post('editfincap'); $importoption=$this->input->post('Importoption'); // echo $importoption; // die(); $Insurance=$this->input->post('Insurance'); //echo $Insurance; if($Insurance=='YES') { $Insurancenumber=$this->input->post('insurancenumber'); $insurestatus='1'; } else { $Insurancenumber=''; $insurestatus='0'; } // PO Master // PO Master // $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$updateddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms); $Qualitycheck=1; $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'Import_DispatchDetails'=>$Dispatch,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'Import_PlaceofOrgin'=>$Palaceoforigin,'PaymentOtherDescription'=>$OtherPayment,'Mode_Of_Shipment'=>$Shipmentmode,'Supplier_Reference'=>$SupplierRef,'Supplier_Offer_No'=>$SupplierOffer,'Other_Reference'=>$otherRef,'Fincap'=>$finCap,'InsuranceStatus'=>$insurestatus,'InsuranceNumber'=>$Insurancenumber,'POSubType'=>$importoption,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); //echo $PONO; //echo $TotalOrder; //print_r($POList); //die(); $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); //echo "sdasds"; $LineItemStatus = REQITEM_NEW; //echo $LineItemStatus; if($PODate == $b4podate ) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>'-','UpdateBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4podate,'newValue'=>$PODate,'entity'=>'PO DateChanged'); $this->purchaseorder_model->insertlogpo($logpo); } if(!empty($newSupId[0] )) { if($newSupId[0] != $b4supplier) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>'-','UpdateBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4supplier,'newValue'=>$newsup,'entity'=>'Supplier Changed'); $this->purchaseorder_model->insertlogpo($logpo); } } //echo $RowCount; for ($i = 1; $i <= $RowCount; $i++) { $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); //echo $Quantity; $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); /*-----------------------------------*/ $b4qty=$this->input->post('b4qty'.$i); $b4rate=$this->input->post('b4rate'.$i); /*-----------------------------------*/ //die(); //$Exchangerate = $this->input->post('Exchangerate'.$i); $BasicPriceinmton = $this->input->post('BasicPriceInMTon'.$i); $Productprice = $this->input->post('TotalValue'.$i); //echo $ProductPrice; //die(); $LandingCharge = $this->input->post('LandingCharge'.$i); $AfterLandingCharge = $this->input->post('AfterLandingCharge'.$i); $HighSeas = $this->input->post('HighSeasSalesCharge'.$i); $AfterHighSeas = $this->input->post('AfterHighSeasSalesCharge'.$i); $CustomDuty = $this->input->post('CustomDuty'.$i); $AfterCustomDuty = $this->input->post('AfterCustomDuty'.$i); $ExciseDuty = $this->input->post('ExciseDuty'.$i); $AfterExciseDuty = $this->input->post('AfterExciseDuty'.$i); $ExciseDutyEd = $this->input->post('ExciseDutyEdCess'.$i); $AfterExciseDutyEd = $this->input->post('AfterExciseDutyEdCess'.$i); $ExciseDutySH = $this->input->post('ExciseDutySHCess'.$i); $AfterExciseDutySH = $this->input->post('AfterExciseDutySHCess'.$i); $CustomEd= $this->input->post('CustomEdCess'.$i); $AfterCustomEd= $this->input->post('AfterCustomEdCess1'.$i); $CustomSH = $this->input->post('CustomSHCess'.$i); $AfterCustomSH = $this->input->post('AfterCustomSHCess'.$i); $AddAdtional = $this->input->post('AddlExciseDuty'.$i); $AfterAddAdtional = $this->input->post('AfterAddlExciseDuty'.$i); $Grossdutypayable = $this->input->post('Grossdutypayable'.$i); //echo $Grossdutypayable; //die(); $AvailableModvat = $this->input->post('AvailableModvat'.$i); $Grossexpensesduetocustomduty = $this->input->post('Grossexpensesduetocustomduty'.$i); $purchaseratePerKG = $this->input->post('purchaseratePerKG'.$i); $CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpensesPerKG'.$i); $RMCIncludingCustomersPerKG = $this->input->post('RMCIncludingCustomersPerKG'.$i); $QuantityKG = $this->input->post('QuantityKG'.$i); $POLineItemNo = $this->input->post('LineItemNo'.$i); $CostCenter = $this->input->post('costCode'.$i); //$ExciseDutySH = $this->input->post('ExcisedutySH'.$i); $Totalvalueitem=$this->input->post('TotalValue'.$i); $FreightType=$this->input->post('FreightType'.$i); $Nosoftrip=$this->input->post('NoOfTrip'.$i); $FreightRate=$this->input->post('FreightValue'.$i); $FreightAmount=$this->input->post('AfterFreightValue'.$i); $AssessableValue=$this->input->post('AssessableValue'.$i); //echo $AssessableValue; $Subtotal=$this->input->post('SubTotal'.$i); $Igst=$this->input->post('IGST'.$i); $AfterIgst=$this->input->post('AfterIGST'.$i); $Dutyimpact=$this->input->post('DutyImpact'.$i); $Clearingcharge=$this->input->post('ClearingCharge'.$i); $Nettvalue=$this->input->post('NetValue'.$i); //echo $FreightAmount; $specialinstruction=$this->input->post('Addinstruction'.$i); $per=$this->input->post('Per'.$i); // echo $per; //die(); $LineItemNo = ''; /*---------start---------------------*/ // if(($PODate != $b4podate )||( $SupplierID != $b4supplier) || ($itemRate !=$b4rate) || // ($Quantity != $b4qty )) // { // $logpo =array('UpdateBy'=>$CreateBy,'UpdatedOn'=>$updateddt); // $this->purchaseorder_model->updatelogpo($MaterialCode,$POLineItemNo,$logpo); // } if($Quantity != $b4qty) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>$POLineItemNo,'UpdateBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4qty,'newValue'=>$Quantity,'entity'=>'Quantity Changed'); $this->purchaseorder_model->insertlogpo($logpo); } if($itemRate != $b4rate) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>$POLineItemNo,'UpdateBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4rate,'newValue'=>$itemRate,'entity'=>'Rate Changed'); $this->purchaseorder_model->insertlogpo($logpo); } /*----------end--------------------*/ //echo "sdsfsd"; //die(); $currencytypeID = $this->input->post('currencytype'); $SkipInsert = "False"; if( count($comma_separated) > 0) { for($j = 1; $j < count($comma_separated); $j++) { $deletedRow = $comma_separated[$j] ; if($deletedRow == $i ) { $SkipInsert = "True"; break; } } } /*------------------------------*/ $ReqDetails = array('Quantity'=>$Quantity,'UpdatedBy'=>$CreateBy,'UpdatedOn'=>$updateddt); //print_r($ReqDetails); $this->purchaseorder_model->updateReqDetails($Reqnumber,$MaterialCode,$ReqDetails); /*------------------------------*/ if($SkipInsert == "False") { if(strlen($POLineItemNo) == 0) { $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'Per'=>$per,'ServiceMaterialDescription'=>$specialinstruction); $POLineItem=$this->purchaseorder_model->addPOLineItem($POLineItemList); if(count($POLineItem)>0) { $LineItemNo = $POLineItem[0]['LineItemNo']; } } else { $LineItemNo = $POLineItemNo; //echo $LineItemNo; //die(); $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter,'Per'=>$per,'ServiceMaterialDescription'=>$specialinstruction); $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$POLineItemNo,$POLineItemList); } $isExists = $this->purchaseorder_model->LineItemExistsinImportTax($LineItemNo); //echo $isExists; //die(); if(count($isExists) == 0) { // print_r(count($isExists)); //echo $isExists; //die(); $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'CreatedBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'Grossdutypayable'=>$Grossdutypayable,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem,'FreightType'=>$FreightType,'NoOfTrip'=>$Nosoftrip,'FreightValue'=>$FreightRate,'AfterFreightValue'=>$FreightAmount,'AssessableValue'=>$AssessableValue,'SubTotal'=>$Subtotal,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'DutyImpact'=>$Dutyimpact,'ClearingCharge'=>$Clearingcharge,'NetValue'=>$Nettvalue); //print_r($ImportTaxList); //die(); $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); } else { //echo "xxcx"; //die(); $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'CreatedBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'Grossdutypayable'=>$Grossdutypayable,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem,'FreightType'=>$FreightType,'NoOfTrip'=>$Nosoftrip,'FreightValue'=>$FreightRate,'AfterFreightValue'=>$FreightAmount,'AssessableValue'=>$AssessableValue,'SubTotal'=>$Subtotal,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'DutyImpact'=>$Dutyimpact,'ClearingCharge'=>$Clearingcharge,'NetValue'=>$Nettvalue); //echo "cxvc "; //die(); //print_r($ImportTaxList); //die(); $this->purchaseorder_model->updateImportTax($LineItemNo,$ImportTaxList); } } } echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ; } /* All Function following This command for FINANCE TEAM PO APPROVAL SCREEN*/ function poapproval(){ $q="APPROVAL"; $this->global['pageTitle'] = 'Siddharth : Purchase Order Approval'; // $data['Status']= $this->purchaseorder_model->getStatus(); $userID = $this->session->userdata ( 'userId' ); //print_r($data['Status']);echo "CON"; $data['AppList'] = $this->purchaseorder_model->getPOList($q); $this->loadViews("poapproval_view", $this->global,$data, NULL); } function getDateformat2($Val) { $date = new DateTime($Val); $retDate = $date->format('Y-m-d H:i:s'); return $retDate; } function ApprovePO() { $StatusCode= Trim($_POST['SCode']); $PONO= Trim($_POST['PONO']); $Remarks= Trim($_POST['NewRemarks']); $ApprovedBy = $this->session->userdata ( 'userId' ); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $ApprovedDate = $dt->format('Y-m-d H:i:s'); if($StatusCode == 'ST025') { $store = array('Status'=>$StatusCode,'ApprovedOn'=>$ApprovedDate,'Approvedby'=>$ApprovedBy,'Remarks'=>$Remarks); $this->purchaseorder_model->UpdatePO($store,$PONO); echo "Successfully Approve the Purchase Order No: ".$PONO; } else{ $store = array('Status'=>$StatusCode,'OnHoldOn'=>$ApprovedDate,'OnHoldBy'=>$ApprovedBy,'Remarks'=>$Remarks); $this->purchaseorder_model->UpdatePO($store,$PONO); echo "The Purchase Order No: ".$PONO ."is On Hold"; } } /* FOLLOWING CODES FOR PO RELEASE SCREEN FUNCTIONALITIES*/ function porelease(){ $q="RELEASE"; $this->global['pageTitle'] = 'Siddharth : Purchase Order Release'; // $data['Status']= $this->purchaseorder_model->getStatus(); $userID = $this->session->userdata ( 'userId' ); //print_r($data['Status']);echo "CON"; $data['AppList'] = $this->purchaseorder_model->getPOList($q); $this->loadViews("porelease_view", $this->global,$data, NULL); } function ReleasePO() { $StatusCode= Trim($_POST['SCode']); $PONO= Trim($_POST['PONO']); $Remarks= Trim($_POST['NewRemarks']); $ReleasedBy = $this->session->userdata ( 'userId' ); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $ReleasedDate = $dt->format('Y-m-d H:i:s'); if($StatusCode == 'ST026') { $store = array('Status'=>$StatusCode,'ReleasedOn'=>$ReleasedDate,'ReleasedBy'=>$ReleasedBy,'Remarks'=>$Remarks); $this->purchaseorder_model->UpdatePO($store,$PONO); echo "Successfully Released the Purchase Order No: ".$PONO; } else{ $store = array('Status'=>$StatusCode,'OnHoldOn'=>$ReleasedDate,'OnHoldBy'=>$ReleasedBy,'Remarks'=>$Remarks); $this->purchaseorder_model->UpdatePO($store,$PONO); echo "The Purchase Order No: ".$PONO ."is On Hold"; } } /* Add capital Po*/ function addNewCapitalPurchaseOrder() { $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); $DeliveryAddr = $this->input->post('DeliveryAddr'); $dt = $this->input->post('Deliverydate'); $POType = $this->input->post('POType'); $PoRange = $this->input->post('txtPoRange'); /* $DeliveryOption = $this->input->post('DateRange'); if($DeliveryOption==1){ $Deliverydt = ''; $DeliverySchedule = $this->input->post('Scheduleby'); } else{ $Deliverydt = $this->getDateformat($dt); $DeliverySchedule = ''; } */ $DeliveryOption = $this->input->post('DateRange'); $DeliverySchedule=''; $Dispatch=''; $Deliverydt=''; if($DeliveryOption==1) { $Dispatch=''; $Deliverydt=''; $DeliverySchedule = $this->input->post('Scheduleby'); } else if($DeliveryOption==2) { $Deliverydt=''; $DeliverySchedule = ''; $Dispatch = $this->input->post('Dispatch'); } else { $Dispatch = ''; $DeliverySchedule = ''; $Deliverydt = $this->getDateformat($dt); } $capitalType = $this->input->post('capitalType'); if($capitalType=='Domestic'){ $CapitalRange = '1'; $ExchangeRateOn = ''; $ExchangeRate=''; $Palaceoforigin=''; } else{ $CapitalRange = '0'; $ExchangeRateBeforeFormat = $this->input->post('Exchangerateon'); $ExchangeRateOn =$this->getDateformat($ExchangeRateBeforeFormat); $ExchangeRate=$this->input->post('ExchangeRt'); $Palaceoforigin=$this->input->post('PlaceOforigin'); } $ModeOfShipment=$this->input->post('addmodeofshipment'); $SupplierReference=$this->input->post('addsupplierreference'); $SuppliersOfferNo=$this->input->post('addsupplierofferno'); $OtherReferences=$this->input->post('addotherreference'); $Fincap=$this->input->post('addfincap'); $InsuranceOptions=$this->input->post('insuranceStatus'); $InsuranceNo=$this->input->post('insuranceNo'); $ServiceTypeOptions=$this->input->post('PoTypeOptions'); $PaymentMethod = $this->input->post('PaymentMethod'); $OtherPayment=$this->input->post('Otherpayment'); $BudgetType = $this->input->post('Budget'); $SpcialInstruction = $this->input->post('txtSpcialInstruction'); $TotalOrder = $this->input->post('CapitalToatlOrder'); $POStatus = $this->input->post('txtStatus'); $CreateBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); $DeletedRow = $this->input->post('txtDeletedRow'); $comma_separated = explode(':', $DeletedRow); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); $currencytypeID = $this->input->post('currencytype'); $Qualitycheck=1; $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ExchangeRateCalculatedon'=>$ExchangeRateOn,'ExchangeRate'=>$ExchangeRate,'PaymentTerms'=>$PaymentMethod,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'CapitalRange'=>$CapitalRange,'POType'=>$POType,'CurrencyType'=>$currencytypeID,'DeliverySchedule'=>$DeliverySchedule,'Import_PlaceofOrgin'=>$Palaceoforigin,'Import_DispatchDetails'=>$Dispatch,'DeliveryDate'=>$Deliverydt,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$SupplierReference,'Mode_Of_Shipment'=>$ModeOfShipment,'Supplier_Offer_No'=>$SuppliersOfferNo,'Other_Reference'=>$OtherReferences,'Fincap'=>$Fincap,'InsuranceStatus'=>$InsuranceOptions,'InsuranceNumber'=>$InsuranceNo,'POSubType'=>$ServiceTypeOptions,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); // $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'Import_DispatchDetails'=>$Dispatch,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'Import_PlaceofOrgin'=>$Palaceoforigin); $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$ServiceTypeOptions); $PONO = ''; if(count($POMaster)>0) { $PONO = $POMaster[0]['PONO']; } $LineItemStatus = REQITEM_NEW; for ($i = 1; $i <= $RowCount; $i++) { $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); $BasicPriceinmton = $this->input->post('rateInUs'.$i); $Productprice = $this->input->post('basicvalInINR'.$i); $LandingCharge = $this->input->post('beforeLanding'.$i); $AfterLandingCharge = $this->input->post('landingCharge'.$i); $CustomDuty = $this->input->post('beforeCustomDuty'.$i); $AfterCustomDuty = $this->input->post('CustomDuty'.$i); $CustomEd= $this->input->post('beforeCustomEDCess'.$i); $AfterCustomEd= $this->input->post('CustomEDCess'.$i); $CustomSH = $this->input->post('beforeCustomSHCess'.$i); $AfterCustomSH = $this->input->post('CustomSHCess'.$i); $Grossdutypayable = $this->input->post('GrossDutyPayable'.$i); $QuantityKG = $this->input->post('PurQuantity'.$i); $FreightType = $this->input->post('FreightType'.$i); $FreightValue = $this->input->post('FreightVal'.$i); $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); $NOOfTrip = $this->input->post('NoOfTrip'.$i); $Totalvalueitem=$this->input->post('PerKgExpense'.$i); //echo $BasicPriceinmton; $CostCenter = $this->input->post('CPCostCode'.$i); $TotalOrderValue = $this->input->post('basicvalInINR'.$i); $Cgst = $this->input->post('Cgst'.$i); $Sgst = $this->input->post('Sgst'.$i); $Igst = $this->input->post('Igst'.$i); $AfterCgst = $this->input->post('AfterCgst'.$i); $AfterSgst = $this->input->post('AfterSgst'.$i); $AfterIgst = $this->input->post('AfterIgst'.$i); $DiscountType = $this->input->post('DisType'.$i); $DiscountValue = $this->input->post('DisVal'.$i); $AfterDiscount = $this->input->post('AfterDisVal'.$i); $OtherAmt = $this->input->post('OtherAmt'.$i); $FreightTypeloc=$this->input->post('FreightTypeloc'.$i); $FreightNoofTriploc=$this->input->post('NoofTriploc'.$i); $Freightrateloc=$this->input->post('FreightRateloc'.$i); $FreightAmountloc=$this->input->post('AfterFreightRateloc'.$i); $AssessableValue=$this->input->post('AfterAssessable'.$i); $SubTotal=$this->input->post('Subtotal'.$i); $IGST=$this->input->post('IgstInt'.$i); $AfterIGST=$this->input->post('AfterIgstInt'.$i); $DutyImpact=$this->input->post('Dutyimpact'.$i); $NetValue=$this->input->post('Nett'.$i); $ClearingCharge=$this->input->post('ClearingCharges'.$i); $CustomDutyExpensesPerKG =$this->input->post('CustomDutyExpenses'.$i); $TaxtotalOrderValue = $itemRate*$Quantity+$OtherAmt+$AfterCgst+$AfterSgst+$AfterIgst-$AfterDiscount; $CapitalItemDescription = $this->input->post('CapitalItemDescrition'.$i); $Per = $this->input->post('per'.$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,'ServiceMaterialDescription'=>$CapitalItemDescription,'Per'=>$Per); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); $LineItemNo = ''; if(count($POLineItem)>0) { $LineItemNo = $POLineItem[0]['LineItemNo']; } /* --------------------------------------------*/ // $logpo =array('PONO'=>$PONO,'Date'=>$PODate,'POType'=>$POType,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=> $itemRate,'SupplierID'=>$SupplierID,'LineItemNos'=>$LineItemNo); // $this->purchaseorder_model->newlogpo($logpo); /* --------------------------------------------*/ if(trim($POType) == CAPITAL ) { if($CapitalRange=='1') { $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'CGST'=>$Cgst,'After_CGST'=>$AfterCgst,'SGST'=>$Sgst,'After_SGST'=>$AfterSgst,'IGST'=>$Igst,'After_IGST'=>$AfterIgst,'otherallowance'=>$OtherAmt,'TotalValue'=>$TaxtotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'discount'=>$DiscountType,'discountval'=>$DiscountValue,'Afterdiscountval'=>$AfterDiscount,'FreightType'=>$FreightTypeloc,'NoOfTrip'=>$FreightNoofTriploc,'FreightValue'=>$Freightrateloc,'AfterFreightValue'=>$FreightAmountloc); $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); } if($CapitalRange=='0') { $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'Grossdutypayable'=>$Grossdutypayable,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem,'FreightType'=>$FreightType,'NoOfTrip'=>$NOOfTrip,'FreightValue'=>$FreightValue,'AfterFreightValue'=>$AfterFreightValue,'AssessableValue'=>$AssessableValue,'SubTotal'=>$SubTotal,'IGST'=>$IGST,'AfterIGST'=>$AfterIGST,'DutyImpact'=>$DutyImpact,'NetValue'=>$NetValue,'ClearingCharge'=>$ClearingCharge,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG); $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); } } } } echo 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; } /*Edit Capital po*/ function EditCapitalPurchaseOrder() { $PONO =$this->input->post('txtPONO'); $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); $newsup=$this->input->post('newsup'); $newSupId = split("[ - ]+", $newsup); $DeliveryAddr = $this->input->post('DeliveryAddr'); $dt = $this->input->post('Deliverydate'); $POType = $this->input->post('POType'); $PoRange = $this->input->post('txtPoRange'); /* $DeliveryOption = $this->input->post('DateRange'); if($DeliveryOption==1){ $Deliverydt = ''; $DeliverySchedule = $this->input->post('Scheduleby'); } else{ //$Deliverydt = $this->getDateformat($dt); $Deliverydt = ''; $DeliverySchedule = ''; } */ /*-----------------------------------*/ $b4supplier=$this->input->post('b4supplier'); $b4date=$this->input->post('b4podate'); $b4podate = $this->getDateformat($b4date); /*-----------------------------------*/ $DeliveryOption = $this->input->post('DateRange'); $DeliverySchedule=''; $Dispatch=''; $Deliverydt=''; if($DeliveryOption==1) { $Dispatch=''; $Deliverydt=''; $DeliverySchedule = $this->input->post('Scheduleby'); } else if($DeliveryOption==2) { $Deliverydt=''; $DeliverySchedule = ''; $Dispatch = $this->input->post('Dispatch'); } else { $Dispatch = ''; $DeliverySchedule = ''; $Deliverydt = $this->getDateformat($dt); } $capitalType = $this->input->post('capitalType'); $currencytypeID = $this->input->post('currencytype'); if($capitalType=='1'){ $CapitalRange = '1'; $ExchangeRateOn = ''; $ExchangeRate=''; } else{ $CapitalRange = '0'; $ExchangeRateBeforeFormat = $this->input->post('Exchangerateon'); $ExchangeRateOn =$this->getDateformat($ExchangeRateBeforeFormat); $ExchangeRate=$this->input->post('ExchangeRt'); } $PaymentMethod = $this->input->post('PaymentMethod'); $OtherPayment=$this->input->post('Otherpayment'); $SpcialInstruction = $this->input->post('txtSpcialInstruction'); $TotalOrder = $this->input->post('CapitalToatlOrder'); $POStatus = $this->input->post('txtStatus'); $Palaceoforigin=$this->input->post('PlaceOforigin'); $ModeOfShipment=$this->input->post('editmodeofshipment'); $SupplierReference=$this->input->post('editsupplierreference'); $SuppliersOfferNo=$this->input->post('editsupplierofferno'); $OtherReferences=$this->input->post('editotherreference'); $Fincap=$this->input->post('editfincap'); $InsuranceOptions=$this->input->post('insuranceStatus'); $InsuranceNo=$this->input->post('insuranceNo'); $ServiceTypeOptions=$this->input->post('PoTypeOptions'); $BudgetType = $this->input->post('Budget'); $CreateBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); $DeletedRow = $this->input->post('txtDeletedRow'); $comma_separated = explode(':', $DeletedRow); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); $updateddt = $dt->format('Y-m-d H:i:s'); $Qualitycheck=1; $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ExchangeRate'=>$ExchangeRate,'ExchangeRateCalculatedon'=>$ExchangeRateOn,'PaymentTerms'=>$PaymentMethod,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'CurrencyType'=>$currencytypeID,'DeliverySchedule'=>$DeliverySchedule,'Import_PlaceofOrgin'=>$Palaceoforigin,'Import_DispatchDetails'=>$Dispatch,'DeliveryDate'=>$Deliverydt,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$SupplierReference,'Mode_Of_Shipment'=>$ModeOfShipment,'Supplier_Offer_No'=>$SuppliersOfferNo,'Other_Reference'=>$OtherReferences,'Fincap'=>$Fincap,'InsuranceStatus'=>$InsuranceOptions,'InsuranceNumber'=>$InsuranceNo,'POSubType'=>$ServiceTypeOptions,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); $LineItemStatus = REQITEM_NEW; if($PODate != $b4podate ) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>'-','UpdateBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4podate,'newValue'=>$PODate,'entity'=>'PO DateChanged'); $this->purchaseorder_model->insertlogpo($logpo); } if(!empty($newSupId[0] )) { if($newSupId[0] != $b4supplier) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>'-','UpdateBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4supplier,'newValue'=>$newsup,'entity'=>'Supplier Changed'); $this->purchaseorder_model->insertlogpo($logpo); } } 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); /*-----------------------------------*/ $b4qty=$this->input->post('b4qty'.$i); $b4rate=$this->input->post('b4rate'.$i); /*-----------------------------------*/ $Exchangerate = $this->input->post('echangeRate'.$i); $BasicPriceinmton = $this->input->post('rateInUs'.$i); $Productprice = $this->input->post('basicvalInINR'.$i); $LandingCharge = $this->input->post('beforeLanding'.$i); $AfterLandingCharge = $this->input->post('landingCharge'.$i); $CustomDuty = $this->input->post('beforeCustomDuty'.$i); $AfterCustomDuty = $this->input->post('CustomDuty'.$i); $CustomEd= $this->input->post('beforeCustomEDCess'.$i); $AfterCustomEd= $this->input->post('CustomEDCess'.$i); $CustomSH = $this->input->post('beforeCustomSHCess'.$i); $AfterCustomSH = $this->input->post('CustomSHCess'.$i); $Grossdutypayable = $this->input->post('GrossDutyPayable'.$i); $CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpenses'.$i); $QuantityKG = $this->input->post('PurQuantity'.$i); $AssessableValue = $this->input->post('AssessableValue'.$i); $SubTotal = $this->input->post('SubTotal'.$i); $IGST = $this->input->post('IGSTInt'.$i); $AfterIGST = $this->input->post('AfterIGSTInt'.$i); $DutyImpact = $this->input->post('DutyImpact'.$i); $NetValue = $this->input->post('NetValue'.$i); $ClearingCharge = $this->input->post('ClearingCharge'.$i); $Totalvalueitem=$this->input->post('PerKgExpense'.$i); //echo $BasicPriceinmton; $CostCenter = $this->input->post('CPCostCode'.$i); $TotalOrderValue = $this->input->post('basicvalInINR'.$i); $POLineItemNo = $this->input->post('LineItemNo'.$i); $Cgst = $this->input->post('Cgst'.$i); $Sgst = $this->input->post('Sgst'.$i); $Igst = $this->input->post('Igst'.$i); $AfterCgst = $this->input->post('AfterCgst'.$i); $AfterSgst = $this->input->post('AfterSgst'.$i); $AfterIgst = $this->input->post('AfterIgst'.$i); $OtherAmt = $this->input->post('OtherAmt'.$i); $DiscountType = $this->input->post('DisType'.$i); $DiscountValue = $this->input->post('DisVal'.$i); $AfterDiscount = $this->input->post('AfterDisVal'.$i); $TaxtotalOrderValue = $itemRate*$Quantity+$OtherAmt+$AfterCgst+$AfterSgst+$AfterIgst-$AfterDiscount; $OtherAmt = $this->input->post('OtherAmt'.$i); $CapitalItemDescription = $this->input->post('CapitalItemDescrition'.$i); $Per = $this->input->post('per'.$i); $FreightType = $this->input->post('FreightType'.$i); $FreightValue = $this->input->post('FreightVal'.$i); $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); $NOOfTrip = $this->input->post('NoOfTrip'.$i); $FreightTypeloc=$this->input->post('Ftype'.$i); $FreightNoofTriploc=$this->input->post('NoTrip'.$i); $Freightrateloc=$this->input->post('Fvalue'.$i); $FreightAmountloc=$this->input->post('Afvalue'.$i); // echo $FreightTypeloc; // echo 'n'; // echo $FreightNoofTriploc; // echo 'n'; // echo $Freightrateloc; // echo 'n'; // echo $FreightAmountloc; // die(); /*---------start---------------------*/ // if(($PODate != $b4podate )||( $SupplierID != $b4supplier) || ($itemRate !=$b4rate) || // ($Quantity != $b4qty )) // { // $logpo =array('UpdateBy'=>$CreateBy,'UpdatedOn'=>$updateddt); // $this->purchaseorder_model->updatelogpo($MaterialCode,$POLineItemNo,$logpo); // } if($Quantity != $b4qty) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>$POLineItemNo,'UpdateBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4qty,'newValue'=>$Quantity,'entity'=>'Quantity Changed'); $this->purchaseorder_model->insertlogpo($logpo); } if($itemRate != $b4rate) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>$POLineItemNo,'UpdateBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4rate,'newValue'=>$itemRate,'entity'=>'Rate Changed'); $this->purchaseorder_model->insertlogpo($logpo); } /*----------end--------------------*/ $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; } } } /*------------------------------*/ $ReqDetails = array('Quantity'=>$Quantity,'UpdatedBy'=>$CreateBy,'UpdatedOn'=>$updateddt); //print_r($ReqDetails); $this->purchaseorder_model->updateReqDetails($Reqnumber,$MaterialCode,$ReqDetails); /*------------------------------*/ if($SkipInsert == "False") { if(strlen($POLineItemNo) == 0) { $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'ServiceMaterialDescription'=>$CapitalItemDescription,'Per'=>$Per); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); $LineItemNo = ''; if(count($POLineItem)>0) { $LineItemNo = $POLineItem[0]['LineItemNo']; } if(trim($POType) == CAPITAL ) { if($capitalType=='1') { $ServiceTaxList = array('LineItemNo'=>$LineItemNo,'FreightType'=>$FreightTypeloc,'NoOfTrip'=>$FreightNoofTriploc,'FreightValue'=>$Freightrateloc,'AfterFreightValue'=>$FreightAmountloc ,'CGST'=>$Cgst,'After_CGST'=>$AfterCgst,'SGST'=>$Sgst,'After_SGST'=>$AfterSgst,'IGST'=>$Igst,'After_IGST'=>$AfterIgst,'otherallowance'=>$OtherAmt,'TotalValue'=>$TaxtotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'discount'=>$DiscountType,'discountval'=>$DiscountValue,'Afterdiscountval'=>$AfterDiscount); $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); } if($capitalType=='0') { $ImportTaxList = array('LineItemNo'=>$LineItemNo, 'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'Grossdutypayable'=>$Grossdutypayable,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem,'FreightType'=>$FreightType,'NoOfTrip'=>$NOOfTrip,'FreightValue'=>$FreightValue,'AfterFreightValue'=>$AfterFreightValue,'AssessableValue'=>$AssessableValue,'SubTotal'=>$SubTotal,'IGST'=>$IGST, 'AfterIGST'=>$AfterIGST,'DutyImpact'=>$DutyImpact,'NetValue'=>$NetValue,'ClearingCharge'=>$ClearingCharge); $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); } } } else { $LineItemNo = $POLineItemNo; $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'ServiceMaterialDescription'=>$CapitalItemDescription,'Per'=>$Per); $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$LineItemNo,$POLineItemList); if($capitalType=='1') { $ServiceTaxList = array('CGST'=>$Cgst,'After_CGST'=>$AfterCgst,'SGST'=>$Sgst,'After_SGST'=>$AfterSgst,'IGST'=>$Igst,'After_IGST'=>$AfterIgst,'otherallowance'=>$OtherAmt,'TotalValue'=>$TaxtotalOrderValue, 'UpdateBY'=>$CreateBy,'UpdatedOn'=>$createddt,'discount'=>$DiscountType,'discountval'=>$DiscountValue,'Afterdiscountval'=>$AfterDiscount,'FreightType'=>$FreightTypeloc,'NoOfTrip'=>$FreightNoofTriploc,'FreightValue'=>$Freightrateloc,'AfterFreightValue'=>$FreightAmountloc); $ServiceTax = $this->purchaseorder_model->updateServiceTax($LineItemNo,$ServiceTaxList); } if($capitalType=='0') { $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'Grossdutypayable'=>$Grossdutypayable,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem,'FreightType'=>$FreightType,'NoOfTrip'=>$NOOfTrip,'FreightValue'=>$FreightValue,'AfterFreightValue'=>$AfterFreightValue,'AssessableValue'=>$AssessableValue,'SubTotal'=>$SubTotal,'IGST'=>$IGST, 'AfterIGST'=>$AfterIGST,'DutyImpact'=>$DutyImpact,'NetValue'=>$NetValue,'ClearingCharge'=>$ClearingCharge); $ImportList= $this->purchaseorder_model->updateImportTax($LineItemNo,$ImportTaxList); } } } } echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ; } /* capital po print/pdf*/ public function CapitalPoPrint($PONO) { $PoStatus=''; $data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO); // Load the pdf page with multiviews $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformationforPDF(); $data['GetPoFormat'] = $this->purchaseorder_model->GetPoFormat($PONO); $data['POItem'] = $this->purchaseorder_model->GetCapitalPurchaseOrderDetailsForPDF($PONO); $data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO); $data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO); $CurrencyType=''; $CapitalRange=1; if(!empty($data['POItem'])){ $CurrencyType=$data['POItem'][0]->CurrencyType; $CapitalRange=$data['POItem'][0]->CapitalRange; $PoStatus=$data['POItem'][0]->Status; } if($CurrencyType=='' OR $CurrencyType=='0'){ $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR'); $TotalOrderValue=$data['POItem'][0]->TotalOrderValue; // $totalAmt=sprintf("%.2f", $TotalOrderValue); // $data['TotalAmountInWords']= $this->convertNumber($totalAmt); // } $AdvanceAmount=0.0; foreach ($data['POItem'] as $POI) { $AdvanceAmount=$POI->AdvanceAmount; } $TotaltoPay=$TotalOrderValue-$AdvanceAmount; $totalAmt=sprintf("%.2f", $TotalOrderValue); $data['TotalAmountInWords']= $this->convertNumber($totalAmt); } else{ $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName($CurrencyType); $SymbolCurrency=$data['CurrencySymbol'][0]->FontCode2000; $SymbolCurrencyName=$data['CurrencySymbol'][0]->Currency; $PaiseVal=$data['CurrencySymbol'][0]->PaiseVal; $TotalOrderValue=$data['POItem'][0]->TotalOrderValue; foreach ($data['POItem'] as $POI) { $AdvanceAmount=$POI->AdvanceAmount; } $TotaltoPay=$TotalOrderValue-$AdvanceAmount; $totalAmt=sprintf("%.2f", $TotaltoPay); $data['TotalAmountInWords']= $this->convertNumberSymbol($totalAmt,$SymbolCurrency,$SymbolCurrencyName,$PaiseVal); } $data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO); if($CapitalRange!=''){ $data['TaxListDetails'] = $this->purchaseorder_model->GetCapitalTaxListDetails($PONO,$CapitalRange); } // $this->load->View("capitalpopdf", $data); // Add header to pdf //$this->load->view('includes/pdffooter'); // Get output html // $php = $this->output->get_output(); // Load library // $this->load->library('dompdf_gen'); // $paper_orientation = 'portrait'; // $customPaper = array(0,0,750,950); // $this->dompdf->set_paper($customPaper,$paper_orientation); // Convert to PDF // $this->dompdf->load_html($php); // $this->dompdf->render(); // $data['Attachment'] = FALSE; // $this->dompdf->stream("CapitalPOReport".$PONO.".pdf",$data,$php); $mpdf=new mPDF('utf-8','A4-P',7, 10,10, 10, 82, 38, 4, 6); //$mpdf=new mPDF('utf-8', array(190,236)); $HtmlHeading = $this->load->view('includes/pdfheader',$data, true); $HTMLFooter = $this->load->view('includes/pdffooter',$data, true); $mpdf->SetWatermarkImage('./assets/images/mpdf.png', 8, 10 ); $mpdf->showWatermarkImage = true; $mpdf->SetDisplayMode('fullpage'); if($PoStatus == PO_RELEASED || $PoStatus == PO_SERVICE_COMPLETED || $PoStatus == MRIR_APPROVED || $PoStatus == MRIR_REJECTED || $PoStatus == IGR_CREATED || $PoStatus==''||$PoStatus==SPECIAL_PO){ $mpdf->SetWatermarkText(''); } else{ $mpdf->SetWatermarkText('DRAFT'); } $mpdf->watermark_font = 'DejaVuSansCondensed'; $mpdf->showWatermarkText = true; //$mpdf->Image('files/images/frontcover.jpg', 0, 0, 210, 297, 'jpg', '', true, false); $mpdf->SetHTMLHeader($HtmlHeading); $html = $this->load->view('capitalpopdf',$data,true); //$mpdf=new mPDF('utf-8', array(500,500)); $mpdf->SetDisplayMode('fullpage'); $mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}"); //$mpdf->setFooter("Page {PAGENO} of {nb}"); $mpdf->list_indent_first_level = 1; $mpdf->setAutoTopMargin = 'stretch'; $mpdf->setAutoBottomMargin = 'stretch'; //$stylesheet = file_get_contents('assets/css/mpdfstyletables.css'); //$mpdf->WriteHTML($stylesheet, 1); $mpdf->WriteHTML($html); //$mpdf->writeHTMLHeaders(); $mpdf->Output('CapitalPOReport'.$PONO.'.pdf','I'); } /*This function is used to convert amount(digit) into words*/ public function convertNumber($amt){ //echo $amt;die(); $ShowPaise='0'; $totalAmt=explode(".",$amt); $number = $totalAmt[0]; $no = $number; if(!empty($totalAmt[1]) && $totalAmt[1]!=0){ $point = $totalAmt[1]; $ShowPaise='1'; } else{ $point=0; $ShowPaise='0'; } $hundred = null; $digits_1 = strlen($no); $i = 0; $str = array(); $words = array('0' => '', '1' => 'one', '2' => 'two', '3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six', '7' => 'seven', '8' => 'eight', '9' => 'nine', '10' => 'ten', '11' => 'eleven', '12' => 'twelve', '13' => 'thirteen', '14' => 'fourteen', '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen', '18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty', '30' => 'thirty', '40' => 'fourty', '50' => 'fifty', '60' => 'sixty', '70' => 'seventy', '80' => 'eighty', '90' => 'ninety','06'=>'Zero Six','01'=>'Zero One','02'=>'Zero Two' ,'03'=>'Zero Three','04'=>'Zero Four','05'=>'Zero Five','07'=>'Zero Seven','08'=>'Zero Eight','09'=>'Zero Nine'); $words1 = array('2' => 'twenty', '3' => 'thirty', '4' => 'fourty', '5' => 'fifty', '6' => 'sixty', '7' => 'seventy', '8' => 'eighty', '9' =>'ninety'); $words12 = array('11' => 'eleven', '12' => 'twelve', '13' => 'thirteen', '14' => 'fourteen', '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen', '18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty',); $digits = array('', 'hundred', 'thousand', 'lakh', 'crore'); while ($i < $digits_1) { $divider = ($i == 2) ? 10 : 100; $number = floor($no % $divider); $no = floor($no / $divider); $i += ($divider == 10) ? 1 : 2; if ($number) { $plural = (($counter = count($str)) && $number > 1) ? 's' : null; //print_r($plural); $hundred = ($counter == 1 && $str[0]) ? ' and ' : null; //print_r($hundred); $str [] = ($number < 21) ? $words[$number] . " " . $digits[$counter] . $plural . " " . $hundred : $words[floor($number / 10) * 10] . " " . $words[$number % 10] . " " . $digits[$counter] . $plural . " " . $hundred; } else $str[] = null; } $str = array_reverse($str); $result = implode('', $str); if($point>=1 && $point<=10) { $points = ($point) ? " " . $words[$point] : " "; } else if($point>=11 && $point<=20) { $points = ($point) ? " " . $words12[$point] : " "; } else { $points = ($point) ? " " . $words1[$point / 10] . " " . $words[$point = $point % 10] : ''; } if($ShowPaise=='0'){ $amountInWords = "Rupees " . $result." Only"; } else{ $amountInWords = "Rupees " . $result ." Paise ". $points." Only"; } return $amountInWords; } public function convertNumberSymbol($amt,$symbol,$name,$paise){ $ShowPaise='0'; $totalAmt=explode(".",$amt); $number = $totalAmt[0]; $no = $number; if(!empty($totalAmt[1]) && $totalAmt[1]!=0){ $point = $totalAmt[1]; $ShowPaise='1'; } else{ $point=0; $ShowPaise='0'; } $hundred = null; $digits_1 = strlen($no); $i = 0; $str = array(); $words = array('0' => '', '1' => 'one', '2' => 'two', '3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six', '7' => 'seven', '8' => 'eight', '9' => 'nine', '10' => 'ten', '11' => 'eleven', '12' => 'twelve', '13' => 'thirteen', '14' => 'fourteen', '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen', '18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty', '30' => 'thirty', '40' => 'fourty', '50' => 'fifty', '60' => 'sixty', '70' => 'seventy', '80' => 'eighty', '90' => 'ninety'); $words1 = array('2' => 'twenty', '3' => 'thirty', '4' => 'fourty', '5' => 'fifty', '6' => 'sixty', '7' => 'seventy', '8' => 'eighty', '9' =>'ninety'); $words12 = array('11' => 'eleven', '12' => 'twelve', '13' => 'thirteen', '14' => 'fourteen', '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen', '18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty',); $digits = array('', 'hundred', 'thousand', 'lakh', 'crore'); while ($i < $digits_1) { $divider = ($i == 2) ? 10 : 100; $number = floor($no % $divider); $no = floor($no / $divider); $i += ($divider == 10) ? 1 : 2; if ($number) { $plural = (($counter = count($str)) && $number > 1) ? 's' : null; //print_r($plural); $hundred = ($counter == 1 && $str[0]) ? ' and ' : null; //print_r($hundred); $str [] = ($number < 21) ? $words[$number] . " " . $digits[$counter] . $plural . " " . $hundred : $words[floor($number / 10) * 10] . " " . $words[$number % 10] . " " . $digits[$counter] . $plural . " " . $hundred; } else $str[] = null; } $str = array_reverse($str); $result = implode('', $str); if($point>=1 && $point<=10) { $points = ($point) ? " " . $words[$point] : " "; } else if($point>=11 && $point<=20) { $points = ($point) ? " " . $words12[$point] : " "; } else { $points = ($point) ? " " . $words1[$point / 10] . " " . $words[$point = $point % 10] : ''; } if($ShowPaise=='0'){ $amountInWords = $name." " . $result." Only"; } else{ $amountInWords = $name." " . $result.$paise ." ". $points." Only"; } return $amountInWords; } function addadvancerequest() { $PONO =$this->input->post('PONO'); $AdvancePercentage=$this->input->post('AdvanceIn'); $AdvanceAmount=$this->input->post('AdvanceAmount'); $Remarks=$this->input->post('Remarks'); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); $CreateBy = $this->session->userdata ( 'userId' ); $isExists = $this->purchaseorder_model->PONOExists($PONO); if(count($isExists)==0) { $advance=array('PONO'=>$PONO,'AdvancePercentage'=>$AdvancePercentage,'AdvanceAmount'=>$AdvanceAmount,'Remarks'=>$Remarks,'CreatedBy'=>$CreateBy ,'CreatedDt'=>$createddt); $this->purchaseorder_model->addadvanceRequest($advance); } else { $advance=array('AdvancePercentage'=>$AdvancePercentage,'AdvanceAmount'=>$AdvanceAmount,'Remarks'=>$Remarks); $this->purchaseorder_model->updateadvanceRequest($advance,$PONO); } if($advance > 0) { // $this->session->set_flashdata('success', 'New Asset created successfully'); echo ""; redirect('purchaseorder/advancerequest','refresh'); } } function SaveEnquiry() { $client_id=$this->input->post('client_id'); $date= $this->input->post('date'); $contact_person = $this->input->post('contact_person'); $requirement= $this->input->post('requirement'); $feasible = $this->input->post('feasible'); $orderno = $this->input->post('orderno'); $reqqty =$this->input->post('reqqty'); $supqty = $this->input->post('supqty'); $remarks= $this->input->post('remarks'); $save=array('client_id'=>$client_id,'Created_Date'=>$date,'Contact_Person'=>$contact_person,'Requirement'=>$requirement,'Feasible'=>$feasible,'OrderNo'=>$orderno,'Requested_Qty'=>$reqqty,'Supplied_Qty'=>$supqty,'Remarks'=>$remarks); $save_result = $this->purchaseorder_model->SaveEnquiry($save); if($save_result>0) { //echo ""; echo "Saved Successfully"; //redirect('purchaseorder/addenquiry','refresh'); } } function UpdateEnquiry() { $client_id=$this->input->post('client_id'); $date= $this->input->post('date'); $contact_person = $this->input->post('contact_person'); $requirement= $this->input->post('requirement'); $feasible = $this->input->post('feasible'); $orderno = $this->input->post('orderno'); $reqqty =$this->input->post('reqqty'); $supqty = $this->input->post('supqty'); $remarks= $this->input->post('remarks'); $Id = $this->input->post('id'); $save=array('client_id'=>$client_id,'Created_Date'=>$date,'Contact_Person'=>$contact_person,'Requirement'=>$requirement,'Feasible'=>$feasible,'OrderNo'=>$orderno,'Requested_Qty'=>$reqqty,'Supplied_Qty'=>$supqty,'Remarks'=>$remarks); //print_r($save); $save_result = $this->purchaseorder_model->UpdateEnquiry($save,$Id); if(($save_result ==0)||($save_result == 1)) { echo "Saved Successfully"; //echo ""; // redirect('purchaseorder/addenquiry','refresh'); } } public function enquiry() { $data['Customer'] = $this->purchaseorder_model->GetClients(); //$dt = date('yyyy-mm-dd'); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d'); $data['enquirycount']=$this->purchaseorder_model->GetEnquiryCount($createddt); $this->global['pageTitle'] = 'Siddharth : Enquiry Form'; $this->loadViews("addenquiry", $this->global, $data , NULL); } public function Editenquiry() { $Id = $_GET['Id']; //echo $Id; $data['EnquiryDetails'] = $this->purchaseorder_model->GetEnquiry($Id); $data['Customer'] = $this->purchaseorder_model->GetClients(); //print_r($data['EnquiryDetails']); $this->global['pageTitle'] = 'Siddharth : Enquiry Form'; $this->loadViews("editenquiry", $this->global, $data , NULL); } public function enquirylist() { $data['Customer_Order'] = $this->purchaseorder_model->GetEnquiryDetails(); $this->global['pageTitle'] = 'Siddharth : Enquiry List'; $this->loadViews("enquirylist", $this->global, $data , NULL); } public function Nonconfirmative() { $CId = $_GET['CId']; $data['CId']=$CId; $data['Suplist'] = $this->purchaseorder_model->GetEnquiryDetails(); $this->global['pageTitle'] = 'Siddharth : Action Report'; // $this->loadViews("action_report", $this->global, $data , NULL); $this->loadViews("action_report", $this->global, $data , NULL); } public function EditNonconfirmative() { $Id = $_GET['Id']; $data['Suplist'] = $this->purchaseorder_model->GetEnquiryDetails(); $data['masterdetails'] =$this->purchaseorder_model->GetncrmasterDetails($Id); $data['DispositionDetails'] =$this->purchaseorder_model->GetDispositionDetails($Id); $data['RootcauseDetails'] =$this->purchaseorder_model->GetRootcauseDetails($Id); $data['CounteractionDetails'] =$this->purchaseorder_model->GetCouteractionDetails($Id); //print_r($data['DispositionDetails']); $this->global['pageTitle'] = 'Siddharth : Edit Action Report'; $this->loadViews("editaction_report", $this->global, $data , NULL); } public function Nonconfirmativelist() { $data['ncrarray'] = $this->purchaseorder_model->GetNcrlist(); //print_r($data['Customer_Order']); $this->global['pageTitle'] = 'Siddharth : NCR List'; $this->loadViews("ncrlist", $this->global, $data , NULL); } public function AddComplaint() { $data['Customer'] = $this->purchaseorder_model->GetClients(); //$dt = date('yyyy-mm-dd'); //$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); //$createddt = $dt->format('Y-m-d'); //$data['enquirycount']=$this->purchaseorder_model->GetEnquiryCount($createddt); $this->global['pageTitle'] = 'Siddharth : Add Complaint'; $this->loadViews("addcomplaint", $this->global, $data , NULL); } public function EditComplaint() { $CId = $_GET['CId']; $data['Customer'] = $this->purchaseorder_model->GetClients(); $data['savedata'] = $this->purchaseorder_model->Get_SavedComplaint($CId); $this->global['pageTitle'] = 'Siddharth : Edit Complaint'; $this->loadViews("editcomplaint", $this->global, $data , NULL); } public function Savencrlist() { //$client_id=$this->input->post('client_id'); $cname= $this->input->post('cname'); $date= $this->input->post('date'); $servicedetails = $this->input->post('servicedetails'); $detailsofcoplaint= $this->input->post('detailsofcoplaint'); $modeofcommunication = $this->input->post('modeofcommunication'); $actiontaken = $this->input->post('actiontaken'); $actioncardno =$this->input->post('actioncardno'); $remark = $this->input->post('remark'); $save=array('client_id'=>$cname,'Created_Date'=>$date,'Details'=>$servicedetails,'Reason'=>$detailsofcoplaint,'mode_of_communication'=>$modeofcommunication,'action_taken'=>$actiontaken,'Remarks'=>$remark,'card_ref_no'=>$actioncardno); $save_result = $this->purchaseorder_model->UpdateEnquiry($save,$Id); if(($save_result ==0)||($save_result == 1)) { echo "Saved Successfully"; //echo ""; // redirect('purchaseorder/addenquiry','refresh'); } } public function Action_Report() { $txtactionrow = $this->input->post('txtactionrow'); $txtrootrow = $this->input->post('txtrootrow'); $txtcounterrow = $this->input->post('txtcounterrow'); $Department = $this->input->post('Department'); $Date = $this->input->post('newdate'); $Auditor = $this->input->post('AUDITOR'); $Auditee= $this->input->post('AUDITEE'); $Iqaref = $this->input->post('IQAREF'); $ncdetails = $this->input->post('ObjectiveEvidence'); $ReviewDetails = $this->input->post('ReviewDetails'); $ncrstatus = $this->input->post('ncrstatus'); $Comments = $this->input->post('Comments'); $CId= $this->input->post('CId'); $master=array('Department'=>$Department,'Created_Date'=>$Date,'Auditor'=>$Auditor,'Auditee'=>$Auditee,'Iqra'=>$Iqaref,'NC_Details'=>$ncdetails,'Review_Details'=>$ReviewDetails,'Ncr_status'=>$ncrstatus,'Comments'=>$Comments); //print_r($master); $save_result = $this->purchaseorder_model->SaveActionMaster($master); $lastId=''; if(count($save_result)>0) { $lastId = $save_result[0]['Id']; } $up=array('Ncr_Id'=>$lastId); $updatecomplaint= $this->purchaseorder_model->updatecomplaintId($up,$CId); for($i=1;$i<=$txtactionrow ;$i++) { $action = $this->input->post('action'.$i); $resp = $this->input->post('resp'.$i); $target = $this->input->post('target'.$i); $actionsave =array('Id'=>$lastId,'Action'=>$action ,'Resp'=>$resp,'Target'=>$target); $actionsave = $this->purchaseorder_model->SaveActionDisposition($actionsave); } for($i=1;$i<=$txtrootrow;$i++) { $rootcause = $this->input->post('RootCause'.$i); $rootsave =array('Id'=>$lastId,'Root_cause'=>$rootcause); $saveroot = $this->purchaseorder_model->SaveRootCause($rootsave); } for($i=1;$i<=$txtcounterrow ;$i++) { $action = $this->input->post('counteraction'.$i); $resp = $this->input->post('counterresp'.$i); $target = $this->input->post('countertarget'.$i); $savecounter =array('Id'=>$lastId,'Action'=>$action ,'Resp'=>$resp,'Target'=>$target); $countersave = $this->purchaseorder_model->Savecounteraction($savecounter); } echo "Saved Successfully"; } public function UpdateAction_Report() { $txtactionrow = $this->input->post('txtactionrow'); $txtrootrow = $this->input->post('txtrootrow'); $txtcounterrow = $this->input->post('txtcounterrow'); $Id= $this->input->post('ObjectiveEvidence1'); $Department = $this->input->post('Department'); $Date = $this->input->post('newdate'); //die(); $Auditor = $this->input->post('AUDITOR'); $Auditee= $this->input->post('AUDITEE'); $Iqaref = $this->input->post('IQAREF'); $ncdetails = $this->input->post('ObjectiveEvidence'); $ReviewDetails = $this->input->post('ReviewDetails'); $ncrstatus = $this->input->post('ncrstatus'); $Comments = $this->input->post('Comments'); $master=array('Department'=>$Department,'Created_Date'=>$Date,'Auditor'=>$Auditor,'Auditee'=>$Auditee,'Iqra'=>$Iqaref,'NC_Details'=>$ncdetails,'Review_Details'=>$ReviewDetails,'Ncr_status'=>$ncrstatus,'Comments'=>$Comments); $save_result = $this->purchaseorder_model->UpdateActionMaster($master,$Id); //print_r($save_result); $lastId=''; if(count($save_result)>0) { $lastId = $save_result[0]['Id']; } for($i=1;$i<=$txtactionrow ;$i++) { $action = $this->input->post('action'.$i); $resp = $this->input->post('resp'.$i); $target = $this->input->post('target'.$i); $LineDisposition = $this->input->post('ActionId'.$i); if($action == '' && $resp == '' & $target == '') { } else { $actionsave =array('Id'=>$Id,'Action'=>$action ,'Resp'=>$resp,'Target'=>$target); $checklineid=$this->purchaseorder_model->GetActionid($LineDisposition); //print_r($actionsave); if(count($checklineid)==0) { $actionsave = $this->purchaseorder_model->SaveActionDisposition($actionsave); } else { $actionsave = $this->purchaseorder_model->UpdateActionDisposition($actionsave,$LineDisposition); } } // $actionsave = $this->purchaseorder_model->UpdateActionDisposition($actionsave,$LineDisposition); } for($i=1;$i<=$txtrootrow;$i++) { $rootcause = $this->input->post('RootCause'.$i); $Lineroot = $this->input->post('RootCauseId'.$i); if($rootcause == '') { } else { $rootsave =array('Id'=>$Id,'Root_cause'=>$rootcause); $checkrootid=$this->purchaseorder_model->Getrootid($Lineroot); if(count($checkrootid)==0) { $saveroot = $this->purchaseorder_model->SaveRootCause($rootsave); } else { $saveroot = $this->purchaseorder_model->UpdateRootCause($rootsave,$Lineroot); } } } for($i=1;$i<=$txtcounterrow ;$i++) { $action = $this->input->post('counteraction'.$i); $resp = $this->input->post('counterresp'.$i); $target = $this->input->post('countertarget'.$i); $LineCounter = $this->input->post('CounterId'.$i); if($action == '' && $resp == '' & $target == '') { } else { $savecounter =array('Id'=>$Id,'Action'=>$action ,'Resp'=>$resp,'Target'=>$target); $checkcounterid=$this->purchaseorder_model->Getcounterid($LineCounter); if(count($checkcounterid)==0) { $countersave = $this->purchaseorder_model->Savecounteraction($savecounter); } else { $countersave = $this->purchaseorder_model->Updatecounteraction($savecounter,$LineCounter); } } } echo "Saved Successfully"; } public function SaveComplaint() { $client_id = $this->input->post('client_id'); $date = $this->input->post('date'); $Service_Details= $this->input->post('Service_Details'); $Reasons= $this->input->post('Reasons'); $mode= $this->input->post('mode'); $Action= $this->input->post('Action'); $Remark= $this->input->post('Remark'); $save_complaint = array('client_id' =>$client_id,'Created_Date'=>$date,'Service_Details'=>$Service_Details,'Reason'=>$Reasons,'mode_of_communication'=>$mode,'Action_taken'=>$Action,'Remark'=>$Remark ); $savecomplaint = $this->purchaseorder_model->Savecomplaint($save_complaint); if($savecomplaint>0) { echo "Saved Successfully"; } else { echo "Error Occured! Please Try Again"; } } public function UpdateComplaint() { $client_id = $this->input->post('client_id'); $date = $this->input->post('date'); $Service_Details= $this->input->post('Service_Details'); $Reasons= $this->input->post('Reasons'); $mode= $this->input->post('mode'); $Action= $this->input->post('Action'); $Remark= $this->input->post('Remark'); $CId =$this->input->post('CId'); $save_complaint = array('client_id' =>$client_id,'Created_Date'=>$date,'Service_Details'=>$Service_Details,'Reason'=>$Reasons,'mode_of_communication'=>$mode,'Action_taken'=>$Action,'Remark'=>$Remark ); $savecomplaint = $this->purchaseorder_model->Updatecomplaint($save_complaint,$CId); if($savecomplaint>0) { echo "Saved Successfully"; } else { echo "Error Occured! Please Try Again"; } } public function DeleteAction_Report() { $DelId= $this->input->post('delactionId'); $delete=$this->purchaseorder_model->DeleteAction($DelId); //echo $delete; if($delete>0) { echo "Successfully Deleted"; } } public function DeleteRoot_Cause() { $DelId= $this->input->post('delactionId'); $delete=$this->purchaseorder_model->DeleteRoot($DelId); //echo $delete; if($delete>0) { echo "Successfully Deleted"; } } public function DeleteCounter_Row() { $DelId= $this->input->post('delactionId'); $delete=$this->purchaseorder_model->DeleteCounter($DelId); //echo $delete; if($delete>0) { echo "Successfully Deleted"; } } /*--------------------------------------------------------------------------------------*/ function uploadfile() { $bill= $this->input->post('param1'); $oldfile= $this->input->post('param2'); if(!empty($_FILES['file']['name'])) { $Picture = $this->add(); } $uploadfile = $this->purchaseorder_model->updatefile($bill,$Picture,$oldfile); if($uploadfile > 0){ echo "file updated successfully!"; } else{ echo "file not updated!"; } } function add() { $picture = ''; if(!empty($_FILES['file']['name'])) { $config['upload_path'] = 'uploads/BillFiles/'; $config['allowed_types'] = 'docx|pdf|doc|png|jpg'; $config['file_name'] = $_FILES['file']['name']; //print_r($config) ; //Load upload library and initialize configuration $this->load->library('upload',$config); $this->upload->initialize($config); if($this->upload->do_upload('file')) { $uploadData = $this->upload->data(); $picture = $uploadData['file_name']; } else { $error = array('error' => $this->upload->display_errors()); $picture = ''; } } else { $picture = ''; } return $picture ; } /*--------------------------------------------------------------------------------------*/ } ?>