From d81bd8ecfb661c0d36b3d43ee2b4cac4212bc30d Mon Sep 17 00:00:00 2001 From: sriramv Date: Wed, 21 Jun 2017 11:14:54 +0530 Subject: [PATCH] IGR Screen Created by sriramv --- application/config/constants.php | 6 + application/config/routes.php | 5 + .../controllers/inwardgateregister.php | 167 ++++- .../models/inwardgateregister_model.php | 131 ++++ application/views/includes/header.php | 18 +- application/views/inwardgateregister.php | 642 +++++++++++------- application/views/viewinwardgateregister.php | 245 +++++++ 7 files changed, 948 insertions(+), 266 deletions(-) create mode 100644 application/models/inwardgateregister_model.php create mode 100644 application/views/viewinwardgateregister.php diff --git a/application/config/constants.php b/application/config/constants.php index 810566da..4205b1eb 100755 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -68,6 +68,12 @@ define('REQITEM_PARTIALLY_PO_CREATED', 'ST023'); define('REQITEM_Emergency_PO_CREATED', 'ST024'); +/*IGR Status */ +define('IGR_CREATED', 'ST027'); +define('IGR_CLOSED', 'ST028'); +define('IGR_CANCELLED', 'ST029'); +/*IGR Status*/ + define('REQUISTSTATUS', '0'); define('REQUISTITEMSTATUS', '1'); diff --git a/application/config/routes.php b/application/config/routes.php index 5112a6c2..0669b6b3 100755 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -168,5 +168,10 @@ $route['purchaseorderListing'] = "purchaseorder/PurchaseOrderList"; $route['EditPO'] = "purchaseorder/EditPurchaseOrder"; $route['EmergencyPO'] = "emergencypurchaseorder/CreateEmergencyPO"; + +//<-------------IGR page-----------------> +$route['Addigr'] = "inwardgateregister/addinwardgateregister"; +$route['Viewigr'] = "inwardgateregister/viewinwardgateregister"; + /* End of file routes.php */ /* Location: ./application/config/routes.php */ diff --git a/application/controllers/inwardgateregister.php b/application/controllers/inwardgateregister.php index 1662ea35..839cce28 100755 --- a/application/controllers/inwardgateregister.php +++ b/application/controllers/inwardgateregister.php @@ -16,9 +16,12 @@ class inwardgateregister extends BaseController */ public function __construct() { - parent::__construct(); + parent::__construct(); + $this->load->model('inwardgateregister_model'); + $this->load->library('session'); - $this->load->library('form_validation'); + $this->load->library('form_validation'); + $this->isLoggedIn(); } /** @@ -28,16 +31,162 @@ class inwardgateregister extends BaseController { $this->global['pageTitle'] = 'Siddharth : Inward Gate Register'; - $this->loadViews("inwardgateregister", $this->global, NULL , NULL); + $this->loadViews("viewinwardgateregister", $this->global,NULL , NULL); } -function materialinspectionreport() - { - $this->global['pageTitle'] = 'Siddharth : Material Inspetion Report'; - - $this->loadViews("materialinspectionreport", $this->global, NULL , NULL); - } + function viewinwardgateregister($IGRNO='',$IGR='') + { + $this->load->model('inwardgateregister_model'); + $this->global['pageTitle'] = 'Siddharth : Inward Gate Register'; + $data['IGR']= $this->inwardgateregister_model->igrListing($IGRNO,$IGR); + + $this->loadViews("viewinwardgateregister",$this->global,$data,NULL); + } + function addinwardgateregister($pono='',$IGRNO='',$IGR='') + { + + $this->load->model('inwardgateregister_model'); + $this->global['pageTitle'] = 'Siddharth : Add Inward Gate Register'; + //$data['IGR']=$this->inwardgateregister_model->igrListing($IGRNO,$IGR); + + $data['PO_NO'] = $this->inwardgateregister_model->getpurchaseorder($pono); + + + //print_r($data); + + + + $this->loadViews("inwardgateregister", $this->global, $data, NULL); + } + + function getDateformat($Val) + { + $date = new DateTime($Val,new DateTimeZone('Asia/Kolkata')); + // print_r($date); + $retDate = $date->format('Y-m-d H:i:s'); + return $retDate; + } + + function IGRITEM($PO='') + { + + + $PO = $this->input->post('id'); + $data = $this->inwardgateregister_model->viewpurchaseorder($PO); + //$result = $this->inwardgateregister_model->viewpurchaseorder($PO); + /*$HTML=""; + for ($i = 0; $i < count($data); $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; + + }*/ + echo json_encode($data); + //$this->load->view('sample',$data,NULL); + + } + function addNewigr() + { + + + + $PONO = $this->input->post('PONO'); + //$igr = $this->input->post('igr'); + + + + $DeliveryChellanOrInvoiceNo = $this->input->post('InvoiceNo'); + + $DeliveryChellan = $this->input->post('InvoiceDate'); + $DeliveryChellanDate = $this->getDateformat($DeliveryChellan); + + + $VehicleNo = $this->input->post('VehicleNo'); + $CourierNo = $this->input->post('CourierNo'); + + + $CreatedBy = $this->session->userdata('userId'); + //$Remarks = $this->input->post('Remarks'); + $RowCount = $this->input->post('txtRowCount'); + //echo $RowCount; + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddt = $dt->format('Y-m-d H:i:s'); + $IGRStatus = IGR_CREATED; + + + //echo $RowCount; + + $igr = array(); + + $igr = array('PONO'=>$PONO,'VehicleNo'=>$VehicleNo,'DeliveryChellanOrInvoiceNo'=>$DeliveryChellanOrInvoiceNo,'DeliveryChellanDate'=>$DeliveryChellanDate,'CourierNo'=>$CourierNo,'IGRStatus'=>$IGRStatus,'CreatedBy'=>$CreatedBy,'CreatedDate' =>$createddt); + //print_r($igr); + + $igrM = $this->inwardgateregister_model->addigrM($igr); + + + $IGRNO = ''; + if(count($igrM)>0) + { + $IGRNO = $igrM[0]['IGRNO']; + } + //echo $IGRNO; + $IGRItemStatus = REQITEM_NEW; + //echo ("success"); + + //print_r($RowCount); + for ($i = 1; $i <= $RowCount; $i++) + { + //echo i; + + //echo $IGRNO ; + $MaterialCode = $this->input->post('MaterialCode'.$i); + + + $QuantityAsPerInvoice = $this->input->post('ReceivedQuantity'.$i); + $Remarks = $this->input->post('Remarks'.$i); + //$Remarks = $this->input->post('Remarks'); + + $CreatedBy = $this->session->userdata('userId'); + + + + $igrDetails = array('IGRNO'=>$IGRNO,'MaterialCode'=>$MaterialCode,'QuantityAsPerInvoice'=>$QuantityAsPerInvoice,'Remarks'=>$Remarks,'IGRItemStatus'=>$IGRItemStatus,'CreatedBy'=>$CreatedBy,'CreatedDate'=>$createddt); + //print_r($igrDetails); + $igrD = $this->inwardgateregister_model->addigrD($igrDetails); + + } + + + + + } + + function ViewIGR($IGRNO='') + { + + $IGRNO= $this->input->post('id'); + //print_r($IGRNO); + $data = $this->inwardgateregister_model->viewigr($IGRNO); + //print_r( $data); + + echo json_encode($data); + + } function pageNotFound() { $this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found'; diff --git a/application/models/inwardgateregister_model.php b/application/models/inwardgateregister_model.php new file mode 100644 index 00000000..465292bc --- /dev/null +++ b/application/models/inwardgateregister_model.php @@ -0,0 +1,131 @@ +db->select('igr.*,igrd.*,POM.DeliveryDate,sup.SupplierName,MM.MaterialName'); + $this->db->from('T_IGR_Master igr'); + $this->db->join('T_IGR_Details igrd','igrd.IGRNO = igr.IGRNO','left'); + $this->db->join('T_PurchaseOrder_Master POM ', 'igr.PONO = POM.PONO','left'); + $this->db->join('T_SupplierDetailsN sup', 'POM.SupplierID = sup.SupplierID','left'); + $this->db->join('T_PurchaseOrder_LineItem POL', 'POL.PONO = igr.PONO','left'); + $this->db->join('T_MaterialMaster MM', 'MM.MaterialCode = igrd.MaterialCode','left'); + $this->db->group_by('igr.IGRNO',$IGRNO); + + + + $query = $this->db->get(); + //print_r( $this->db->last_query()); + $result = $query->result(); + return $result; + } + + function getpurchaseorder($pono='') + { + $this->db->select('POM.PONO,POM.ServiceDescription,POM.DeliveryDate,sup.SupplierName,sup.Address'); + $this->db->from('T_PurchaseOrder_Master POM'); + $this->db->join('T_SupplierDetailsN sup', 'POM.SupplierID = sup.SupplierID','left'); + //$this->db->join('T_PurchaseOrder_LineItem POL', 'POL.PONO = POM.PONO','left'); + //$this->db->join('T_MaterialMaster MM', 'MM.MaterialCode = POL.MaterialCode','left'); + //$this->db->where('PONO',$pono="PO0002" ); + $query = $this->db->get(); + + $result = $query->result(); + //print_r($result); + //$this->db->last_query(); + return $result; + } + + + function viewpurchaseorder($PO) + { + + $this->db->select('POM.PONO,POL.MaterialCode,POL.Quantity,POL.PONO,MM.MaterialName,MM.UOM'); + $this->db->from('T_PurchaseOrder_Master POM'); + //$this->db->join('T_SupplierDetailsN sup', 'POM.SupplierID = sup.SupplierID','left'); + $this->db->join('T_PurchaseOrder_LineItem POL', 'POL.PONO = POM.PONO','left'); + $this->db->join('T_MaterialMaster MM', 'MM.MaterialCode = POL.MaterialCode','left'); + $this->db->where('POM.PONO',$PO ); + + //$this->db->where('PONO', $PO); + $query = $this->db->get(); + + $result = $query->result(); + + $this->db->last_query(); + return $result; + } + function addigrM($igrM) + { + + $this->db->trans_start(); + $this->db->insert('T_IGR_Master', $igrM); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + // print_r($this->db->last_query()); + print_r($insert_id); + if($insert_id>0) + { + $subQuery = 'select max(IGRNO) as IGRNO from T_IGR_Master'; + + $query = $this->db->query($subQuery); + + return $query->result_array(); + } + } + + function addigrD($igrD) + { + $this->db->trans_start(); + $this->db->insert('T_IGR_Details', $igrD); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + // print_r($this->db->last_query()); + if($insert_id>0) + { + $subQuery = 'select max(IGRItemNo) as IGRItemNo from T_IGR_Details'; + + $query = $this->db->query($subQuery); + + return $query->result_array(); + } + } + function viewigr($IGRNO) + { + + $this->db->select('igr.*,igrd.*,MM.MaterialName,MM.UOM,sup.Address,sup.SupplierName,POM.ServiceDescription,POL.Quantity'); + $this->db->from('T_IGR_Master igr'); + $this->db->join('T_IGR_Details igrd','igrd.IGRNO = igr.IGRNO','left'); + $this->db->join('T_PurchaseOrder_Master POM','igr.PONO = POM.PONO','left'); + $this->db->join('T_PurchaseOrder_LineItem POL','POL.PONO = POM.PONO','left'); + + $this->db->join('T_SupplierDetailsN sup', 'sup.SupplierID = POM.SupplierID','left'); + + $this->db->join('T_MaterialMaster MM', 'MM.MaterialCode = igrd.MaterialCode','left'); + $this->db->order_by('igr.IGRNO'); + $this->db->where('igr.IGRNO',$IGRNO); + + + + $query = $this->db->get(); + //print_r( $this->db->last_query()); + $result = $query->result(); + return $result; + } +} \ No newline at end of file diff --git a/application/views/includes/header.php b/application/views/includes/header.php index 055bc803..5f0f8998 100755 --- a/application/views/includes/header.php +++ b/application/views/includes/header.php @@ -433,15 +433,27 @@ Inspection diff --git a/application/views/inwardgateregister.php b/application/views/inwardgateregister.php index aa564008..f440537e 100755 --- a/application/views/inwardgateregister.php +++ b/application/views/inwardgateregister.php @@ -2,19 +2,17 @@ $(document).ready(function(){ - $("#PurchaseOrderNo").select2(); - $("#PurchaseOrderNoview").select2(); + $("#PONO").select2(); + //$("#PurchaseOrderNoview").select2(); $("#InvoiceDate").datepicker({ //minDate : d, maxDate : 'now', dateFormat: 'mm/dd/yy',changeMonth: true, changeYear: true,yearRange: '-100:+0' }); }); - // For table - (function(l,q){var e=function(b,c){b.extend(!0,c.defaults,{dom:"<'row'<'col-sm-9'l><'col-sm-3'f>><'row'<'col-sm-12'tr>><'row'<'col-sm-8'i><'col-sm-4'p>>",renderer:"bootstrap"});b.extend(c.ext.classes,{sWrapper:"dataTables_wrapper form-inline dt-bootstrap",sFilterInput:"form-control input-sm",sLengthSelect:"form-control input-sm"});c.ext.renderer.pageButton.bootstrap=function(g,e,r,s,i,m){var t=new c.Api(g),u=g.oClasses,j=g.oLanguage.oPaginate,d,f,n=0,p=function(c,e){var k,h,o,a,l=function(a){a.preventDefault(); -b(a.currentTarget).hasClass("disabled")||t.page(a.data.action).draw(!1)};k=0;for(h=e.length;k",{"class":u.sPageButton+" "+ -f,id:0===r&&"string"===typeof a?g.sTableId+"_"+a:null}).append(b("",{href:"#","aria-controls":g.sTableId,"data-dt-idx":n,tabindex:g.iTabIndex}).html(d)).appendTo(c),g.oApi._fnBindAction(o,{action:a},l),n++)}},h;try{h=b(q.activeElement).data("dt-idx")}catch(l){}p(b(e).empty().html('