db->select('IGRNO'); $this->db->from('T_IGR_Master'); $this->db->order_by('IGRNO', 'asc'); $res=$this->db->get(); return $res->result(); } /** * This function is used to get the user listing count * @param string $searchText : This is optional search text * @param number $page : This is pagination offset * @param number $segment : This is pagination limit * @return array $result : This is result */ function ViewigrListing() { $this->db->select('igr.*,PO.DeliveryDate,sup.SupplierName'); $this->db->from('T_IGR_Master igr'); $this->db->join('T_PurchaseOrder_Master PO','igr.PONO = PO.PONO'); $this->db->join('T_SupplierDetailsN` sup','PO.SupplierID = sup.SupplierID'); $this->db->where('igr.IGRStatus !=',MRIR_CREATED); $query = $this->db->get(); $result = $query->result(); return $result; } /* This function is used to get the igr value (button link)*/ function get_IGR($IgrNo) { $this->db->distinct(); $this->db->select('IGRM.DeliveryChellanDate,IGRM.CreatedDate,IGRM.IGRNO,IGRM.VehicleNo,IGRM.DeliveryChellanOrInvoiceNo,IGRM.CourierNo,IGRM.PONO,IGRD.MaterialCode,IGRD.QuantityAsPerInvoice,POMR.ServiceDescription,POMR.PODate,POMR.DeliveryDate,POMR.CreatedBy,SUPP.SupplierName,SUPP.Address,MM.UOM,MM.MaterialName,POLT.Quantity,POLT.ReceivedQuantity,ED.FirstName'); //$this->db->select("DATE_FORMAT(IGRM.DeliveryChellanDate, '%d %m %Y') as DCdate"); $this->db->from('T_IGR_Master IGRM'); $this->db->join('T_PurchaseOrder_Master POMR ','IGRM.PONO=POMR.PONO'); $this->db->join('T_IGR_Details IGRD','IGRM.IGRNO=IGRD.IGRNO'); $this->db->join('T_SupplierDetailsN SUPP','POMR.SupplierID=SUPP.SupplierID'); $this->db->join('T_MaterialMaster MM',' MM.MaterialCode=IGRD.MaterialCode'); $this->db->join('T_PurchaseOrder_LineItem POLT','IGRM.PONO=POLT.PONO and IGRD.MaterialCode = POLT.MaterialCode'); $this->db->join ('tbl_users user','user.userid=POMR.CreatedBy','left'); $this->db->join ('T_Employee_Details ED','ED.EmpID = user.EmpID','left'); $this->db->where('IGRM.IGRNO',$IgrNo); $query = $this->db->get(); $result = $query->result(); //print_r($this->db->last_query()); return $result; } function ViewDistributionList() { $subQuery = 'select distinct MR.PONO,REQ.ReqNo,ReqLine.MaterialCode,MM.MaterialName,MM.UOM, EMP.FirstName,DD.DEPCode,DD.DepartmentName,ReqLine.Quantity as RequestedQty,POL.Quantity as OrderedQuantity ,sum(MD.ActualQuantityReceived) as ActualReceivedqty,sum(MD.QuantityAccepted) as AcceptedQty,REQ.ReqDate from T_PurchaseOrder_LineItem POL left join T_Requestion_Details ReqLine on ReqLine.ReqNo = POL.ReqNo left join T_Requestion_Master REQ on REQ.ReqNo = ReqLine.ReqNo join T_MRIR_Master MR on MR.PONO = POL.PONO join T_MRIR_Details MD on MD.MRIRNO = MR.MRIRNO left join T_MaterialMaster MM on MM.MaterialCode = ReqLine.MaterialCode left join T_Employee_Details EMP on EMP.EmpID = REQ.Requestedby left join T_DepartmentDetails DD on DD.DEPCode = EMP.Departmentcode group by MR.PONO'; $query = $this->db->query($subQuery ); return $query->result(); } /* This function is used to list the MRIR value*/ function view_mrir() { $this->db->distinct(); $this->db->select('TMM.MRIRNO,TMM.PONO,TMM.IGRNO,IGRM.DeliveryChellanOrInvoiceNo,IGRM.DeliveryChellanDate,IGRM.VehicleNo,IGRM.CourierNo,TMD.StoreInchargeID,TMD.QualityInchargeID,TMD.PlantInchargeID,TMD.UpdateBY,POM.PODate,POM.POType,POM.ReleasedBy,ED.FirstName as UpdatedbyName,ED1.FirstName as ReleasedbyName'); $this->db->from ('T_MRIR_Master TMM'); $this->db->join ('T_MRIR_Details TMD','TMM.MRIRNO=TMD.MRIRNO'); $this->db->join ('T_IGR_Master IGRM','TMM.IGRNO=IGRM.IGRNO'); $this->db->join ('T_IGR_Details IGRD','IGRM.IGRNO=IGRD.IGRNO'); $this->db->join ('T_PurchaseOrder_Master POM','TMM.PONO=POM.PONO'); $this->db->join ('tbl_users user','user.userid=TMD.UpdateBY','left'); $this->db->join ('T_Employee_Details ED','ED.EmpID = user.EmpID','left'); $this->db->join ('tbl_users user1','user1.userid = POM.ReleasedBy','left'); $this->db->join ('T_Employee_Details ED1','ED1.EmpID = user1.EmpID','left'); $this->db->order_by ('TMM.MRIRNO','asc'); $query = $this->db->get(); return $query->result(); } /* This function is used to list the MRIR value*/ function view_mrir_Billing() { $this->db->distinct(); $this->db->select('TMM.MRIRNO,TMM.PONO,TMM.IGRNO,IGRM.DeliveryChellanOrInvoiceNo,IGRM.DeliveryChellanDate,IGRM.VehicleNo,IGRM.CourierNo,TMD.StoreInchargeID,TMD.QualityInchargeID,TMD.PlantInchargeID,TMD.UpdateBY,POM.PODate,POM.POType,POM.ReleasedBy,ED.FirstName as UpdatedbyName,ED1.FirstName as ReleasedbyName,MM.MaterialCode,MM.MaterialName,MM.UOM,POL.Quantity,IGRD.QuantityAsPerInvoice,TMD.ActualQuantityReceived,TMD.QuantityAccepted,TMD.QuantityRejected,ST.StatusName,TMD.Remarks'); $this->db->from ('T_MRIR_Master TMM'); $this->db->join ('T_MRIR_Details TMD','TMM.MRIRNO=TMD.MRIRNO'); $this->db->join ('T_IGR_Master IGRM','TMM.IGRNO=IGRM.IGRNO'); $this->db->join ('T_IGR_Details IGRD','IGRM.IGRNO=IGRD.IGRNO'); $this->db->join ('T_PurchaseOrder_Master POM','POM.PONO=IGRM.PONO'); $this->db->join ('T_PurchaseOrder_LineItem POL','POL.PONO=POM.PONO'); $this->db->join ('tbl_users user','user.userid=TMD.UpdateBY'); $this->db->join ('T_Employee_Details ED','ED.EmpID = user.EmpID'); $this->db->join ('tbl_users user1','user1.userid = POM.ReleasedBy'); $this->db->join ('T_Employee_Details ED1','ED1.EmpID = user1.EmpID'); $this->db->join ('T_MaterialMaster MM','MM.MaterialCode = IGRD.MaterialCode and POL.MaterialCode = MM.MaterialCode'); $this->db->join ('T_Status ST','ST.StatusCode = TMD.MRIRStatus'); $this->db->where('TMM.MRIRStatus',MRIR_APPROVED); $this->db->order_by('TMM.MRIRNO','asc'); $query = $this->db->get(); // print_r($this->db->last_query()); return $query->result(); } /* This function is used to get the MRIR value for edit*/ function edit_mrir($MrirNo) { $this->db->distinct(); $this->db->select('TMM.MRIRNO,TMM.PONO,TMM.IGRNO,TMM.Createdon,TMD.ActualQuantityReceived,IGRM.DeliveryChellanOrInvoiceNo,IGRM.DeliveryChellanDate,IGRM.VehicleNo,IGRM.CourierNo,IGRM.CreatedDate,IGRD.QuantityAsPerInvoice,SUPP.SupplierName,SUPP.Address,POMR.PODate,POMR.DeliveryDate,POMR.ServiceDescription,TMD.MaterialCode,MM.MaterialName,MM.UOM,POLT.Quantity,POLT.ReceivedQuantity,ED.FirstName as PORasiedbyName,ED1.FirstName as MRIRRasiedbyName, ED2.FirstName as IGRRasiedbyName,TMM.MRIRStatus'); $this->db->from ('T_MRIR_Master TMM'); $this->db->join ('T_MRIR_Details TMD','TMM.MRIRNO = TMD.MRIRNO','left');//to get IGRNO,PONO,MRIRNO,mrirdate, $this->db->join ('T_IGR_Master IGRM', 'IGRM.IGRNO = TMM.IGRNO','left');//to get actualquantity,deliverydate,Invoicedate,vechileno,courierno,igrdate, $this->db->join ('T_PurchaseOrder_Master POMR ','IGRM.PONO = POMR.PONO','left');//to get podate,deliverydate,servicedescription $this->db->join ('T_PurchaseOrder_LineItem POLT','IGRM.PONO=POLT.PONO','left');//to get receivedquantity,quantity $this->db->join ('T_IGR_Details IGRD','IGRD.IGRNO = IGRM.IGRNO','left');//to get invoicequantity $this->db->join ('T_MaterialMaster MM','IGRD.MaterialCode = MM.MaterialCode','left'); $this->db->join ('T_SupplierDetailsN SUPP','POMR.SupplierID = SUPP.SupplierID','left');//to get suppliername,supplieraddress $this->db->join ('tbl_users user','user.userid = POMR.CreatedBy','left');//to get poraisedby $this->db->join ('T_Employee_Details ED','ED.EmpID = user.EmpID','left'); $this->db->join ('tbl_users user1','user1.userid=TMM.CreatedBy','left');//to get mrirraisedby $this->db->join ('T_Employee_Details ED1','ED1.EmpID = user1.EmpID','left'); $this->db->join ('tbl_users user2','user2.userid=IGRM.CreatedBy','left');//to get igrraisedby $this->db->join ('T_Employee_Details ED2','ED2.EmpID = user2.EmpID','left'); $this->db->where('TMM.MRIRNO',$MrirNo); $this->db->group_by('TMM.MRIRNO,TMD.MaterialCode'); $query = $this->db->get(); $result = $query->result(); // print_r( $this->db->last_query()); return $result; } /* This function is used to store the MRIR value in master table*/ function master_mrir($mrirmastervalues) { $this->db->insert('T_MRIR_Master', $mrirmastervalues); $insert_id = $this->db->affected_rows(); if($insert_id>0) { $subQuery = 'select max(MRIRNO) as MRIRNo from T_MRIR_Master'; $query = $this->db->query($subQuery); return $query->result();//_array(); } } /* This function is used to store the MRIR value in detail table*/ function detail_mrir($mrirdetailvalues) { $this->db->insert('T_MRIR_Details',$mrirdetailvalues); $insert_id = $this->db->affected_rows(); return $insert_id; } /* This function is used to update the value in MRIR master table*/ function update_mrirmaster($updatemastervalues,$mrir_no) { $this->db->where('MRIRNO', $mrir_no); $this->db->update('T_MRIR_Master', $updatemastervalues); $affectedRows = $this->db->affected_rows(); return $affectedRows; } /* This function is used to update the value in MRIR detail table*/ function update_mrirdetail($updatedetailvalues,$mrir_no) { $this->db->where('MRIRNO',$mrir_no); $this->db->update('T_MRIR_Details',$updatedetailvalues); $affectedRows = $this->db->affected_rows(); return $affectedRows; } /* This function is used to get the value for modal in view MRIR page */ function get_MRIRs($mrir) { $this->db->select('TMM.MRIRNO,TMM.PONO,TMM.IGRNO,TMD.*,IGRM.DeliveryChellanOrInvoiceNo,IGRM.DeliveryChellanDate,IGRM.VehicleNo,IGRD.*,SUPP.SupplierName,SUPP.Address,POMR.DeliveryDate,POMR.ServiceDescription,MM.MaterialCode,MM.UOM,MM.MaterialName,POLT.Quantity,POLT.ReceivedQuantity'); $this->db->from ('T_MRIR_Master TMM'); $this->db->join ('T_MRIR_Details TMD','TMM.MRIRNO = TMD.MRIRNO','left'); $this->db->join ('T_MaterialMaster MM','TMD.MaterialCode = MM.MaterialCode','left'); $this->db->join ('T_IGR_Master IGRM', 'IGRM.IGRNO=TMM.IGRNO','left'); $this->db->join ('T_PurchaseOrder_Master POMR ','IGRM.PONO=POMR.PONO','left'); $this->db->join ('T_PurchaseOrder_LineItem POLT','IGRM.PONO=POLT.PONO','left'); $this->db->join ('T_IGR_Details IGRD','IGRD.IGRNO= IGRM.IGRNO','left'); $this->db->join ('T_SupplierDetailsN SUPP','POMR.SupplierID=SUPP.SupplierID','left'); $this->db->where('TMD.MRIRNO',$mrir); //$this->db->order_by('TMD.MRIRNO','asc'); // $this->db->from ('T_MRIR_Master TMM'); $query = $this->db->get(); //print_r($this->db->last_query()); $result=$query->result(); //print_r($result); return $result; function get_IGRdatas() { $this->db->select('IGRM.*,IGRD.*,SUPP.SupplierName,SUPP.Address,TMM.PONO,TMD.*,MM.MaterialCode,MM.UOM,MM.MaterialName,POLT.Quantity,POLT.ReceivedQuantity'); $this->db->from ('T_IGR_Master IGRM'); $this->db->join ('T_PurchaseOrder_Master POMR ','IGRM.PONO=POMR.PONO','left'); $this->db->join ('T_MRIR_Master TMM' ,'TMM.IGRNO=IGRM.IGRNO'); $this->db->join ('T_MRIR_Details TMD','TMD.MRIRNO=TMM.MRIRNO'); //$this->db->join ('T_MRIRNO'); $this->db->join ('T_IGR_Details IGRD','IGRD.IGRNO= IGRM.IGRNO','left'); $this->db->join ('T_PurchaseOrder_LineItem POLT','IGRM.PONO=POLT.PONO','left'); $this->db->join ('T_SupplierDetailsN SUPP','POMR.SupplierID=SUPP.SupplierID','left'); $this->db->join ('T_MaterialMaster MM',' MM.MaterialCode=TMD.MaterialCode','left'); //$this->db->where('IGRM.IGRNO '); $query = $this->db->get(); $result = $query->result(); //print_r($result); return $result; } } function UpdateIGRStatus($IGRDetails,$IGRNO) { $this->db->where('IGRNO', $IGRNO); $this->db->update('T_IGR_Master', $IGRDetails); return TRUE; } function getItemQuantityFromStock($MaterialCode) { $subQuery = 'select Quantity from T_Store_Stockdetails where MaterialCode=?'; $query = $this->db->query($subQuery,array($MaterialCode)); return $query->result_array(); } function UpdateStock($StockDetails,$MaterialCode) { $this->db->where('MaterialCode', $MaterialCode); $this->db->update('T_Store_Stockdetails', $StockDetails); return TRUE; } function getMRIRBillingList() { } } ?>