db->table('t_asset_details asd') ->select('asd.*,dep.DepartmentName,sup.SupplierName') ->join('t_departmentdetails dep', ' dep.DEPCode = asd.DEPCode', 'left') ->join('t_supplierdetailsn sup', 'sup.SupplierID = asd.SupplierCode', 'left') ->orderBy('asd.CreatedDt', 'desc'); $query = $builder->get(); $result = $query->getResult(); return $result; } function getDepartment($Department = '') { $builder = $this->db->table('t_departmentdetails') ->select('DEPCode,DepartmentName') ->where('IsActive', 1); if ($Department != '') { $builder->where('DEPCode !=', $Department); } $query = $builder->get(); return $query->getResult(); } function getSupplierName($SupplierID = '') { $builder = $this->db->table('t_supplierdetailsn') ->select('SupplierID, SupplierName') ->where('IsActive', 1); if ($SupplierID != '') { $builder->where('SupplierID !=', $SupplierID); } $query = $builder->get(); return $query->getResult(); } function getpodetails($PO) { $builder = $this->db->table('t_purchaseorder_master POM') ->distinct() ->select('POM.PONO,POM.SupplierID,POL.MaterialCode,DeliveryDate,PODate,sup.SupplierName,POL.LineItemNo') ->join('t_purchaseorder_lineitem POL', 'POL.PONO = POM.PONO') ->join('t_supplierdetailsn sup', 'sup.SupplierID = POM.SupplierID') ->where('POM.status', MRIR_APPROVED); if (!empty($PO)) { $builder->where('POM.PONO', $PO); } $query = $builder->get(); return $query->getResult(); } function getPO($PO = '') { $builder = $this->db->table('t_purchaseorder_master POM') ->distinct() ->select(' POM.PONO'); //,DeliveryDate,PODate,sup.SupplierName,POM.SupplierID'); //->join ('t_purchaseorder_lineitem POL ',' POL.PONO = POM.PONO'); //->join ('t_supplierdetailsn sup ',' sup.SupplierID = POM.SupplierID'); $builder->where('POM.status', MRIR_APPROVED); if (!empty($PO)) { $builder->where('POM.PONO', $PO); } $query = $builder->get(); return $query->getResult(); } function getlineitemre($line) { $builder = $this->db->table('t_purchaseorder_lineitem POL') ->select('POL.LineItemNo,POL.MaterialCode,MM.MaterialName,MM.UOM,POL.Quantity,POM.POType,re.TotalValue, req.ReqNo,emp.firstname,emp.Departmentcode,dep.DepartmentName,sup.SupplierName, date(POM.DeliveryDate) as DeliveryDate,POM.PODate,POM.SupplierID') ->join('t_requestion_master req', 'req.ReqNo = POL.ReqNo', 'left') ->join('t_purchaseorder_master POM', 'POM.PONO=POL.PONO', 'left') ->join('t_materialmaster MM', 'MM.MaterialCode = POL.MaterialCode', 'left') ->join('t_employee_details emp', 'emp.EmpID = req.Requestedby', 'left') ->join('t_departmentdetails dep', 'dep.DEPCode = emp.Departmentcode', 'left') ->join('t_revenue_tax re', 're.LineItemNo = POL.LineItemNo', 'left') ->join('t_supplierdetailsn sup', 'sup.SupplierID = POM.SupplierID', 'left') ->where('POL.LineItemNo', $line); $query = $builder->get(); $result = $query->getResult(); return $result; } function getlineitemser($line) { $builder = $this->db->table('t_purchaseorder_lineitem POL') ->select('POL.LineItemNo,POL.MaterialCode,MM.MaterialName,MM.UOM,POM.POType,POL.Quantity,ser.TotalValue,req.ReqNo,emp.firstname,dep.DepartmentName,emp.Departmentcode,sup.SupplierName,date(POM.DeliveryDate) as DeliveryDate,POM.PODate,POM.SupplierID') ->join('t_requestion_master req', 'req.ReqNo = POL.ReqNo', 'left') ->join('t_purchaseorder_master POM', 'POM.PONO=POL.PONO', 'left') ->join('t_materialmaster MM', 'MM.MaterialCode = POL.MaterialCode', 'left') ->join('t_employee_details emp', 'emp.EmpID = req.Requestedby', 'left') ->join('t_departmentdetails dep', 'dep.DEPCode = emp.Departmentcode', 'left') ->join('t_service_tax ser', 'ser.LineItemNo = POL.LineItemNo', 'left') ->join('t_supplierdetailsn sup', 'sup.SupplierID = POM.SupplierID', 'left') ->where('POL.LineItemNo', $line); $query = $builder->get(); $result = $query->getResult(); return $result; } function getlineitemimport($line) { $builder = $this->db->table('t_purchaseorder_lineitem POL') ->select('POL.LineItemNo,POL.MaterialCode,MM.MaterialName,MM.UOM,POM.POType,POL.Quantity,ser.TotalValue,req.ReqNo,emp.firstname,dep.DepartmentName,emp.Departmentcode,sup.SupplierName,date(POM.DeliveryDate) as DeliveryDate,POM.PODate,POM.SupplierID') ->join('t_requestion_master req', 'req.ReqNo = POL.ReqNo', 'left') ->join('t_purchaseorder_master POM', 'POM.PONO=POL.PONO', 'left') ->join('t_materialmaster MM', 'MM.MaterialCode = POL.MaterialCode', 'left') ->join('t_employee_details emp', 'emp.EmpID = req.Requestedby', 'left') ->join('t_departmentdetails dep', 'dep.DEPCode = emp.Departmentcode', 'left') ->join('t_import_tax ser', 'ser.LineItemNo = POL.LineItemNo', 'left') ->join('t_supplierdetailsn sup', 'sup.SupplierID = POM.SupplierID', 'left') ->where('POL.LineItemNo', $line); $query = $builder->get(); $result = $query->getResult(); return $result; } function getlineitemcap($line) { $builder = $this->db->table('t_purchaseorder_lineitem POL') ->select('POL.LineItemNo,POL.MaterialCode,MM.MaterialName,MM.UOM,POM.POType,POL.Quantity,sum(ser.TotalValue+imp.TotalValue) as TotalValue,req.ReqNo,emp.firstname,dep.DepartmentName,emp.Departmentcode,sup.SupplierName,date(POM.DeliveryDate) as DeliveryDate,POM.PODate,POM.SupplierID') ->join('t_requestion_master req', 'req.ReqNo = POL.ReqNo', 'left') ->join('t_purchaseorder_master POM', 'POM.PONO=POL.PONO', 'left') ->join('t_materialmaster MM', 'MM.MaterialCode = POL.MaterialCode', 'left') ->join('t_employee_details emp', 'emp.EmpID = req.Requestedby', 'left') ->join('t_departmentdetails dep', 'dep.DEPCode = emp.Departmentcode', 'left') ->join('t_import_tax imp', 'imp.LineItemNo = POL.LineItemNo', 'left') ->join('t_service_tax ser', 'ser.LineItemNo = POL.LineItemNo', 'left') ->join('t_supplierdetailsn sup', 'sup.SupplierID = POM.SupplierID', 'left') ->where('POL.LineItemNo', $line); $query = $builder->get(); $result = $query->getResult(); return $result; } function gettyp($type) { $builder = $this->db->table('t_purchaseorder_lineitem POL') ->select('POM.POType,POL.LineItemNo') ->join('t_purchaseorder_master POM', 'POM.PONO=POL.PONO') ->where('POL.LineItemNo', $type); $query = $builder->get(); $result = $query->getResult(); return $result; } /** * This function is used to get the Config value from configuration table * @return array $result : This is result of the query */ function getConfigValue($ConfigID, $ConfigValue = '') { $builder = $this->db->table('t_configdetails') ->select('ConfigValue') ->where('Config_id ', $ConfigID); if ($ConfigValue != '') { $builder->where('ConfigValue != ', $ConfigValue); } $query = $builder->get(); return $query->getResult(); } /** * This function used to get user information by id * @param number $userId : This is user id * @return array $result : This is user information */ function addNewasset($asset) { $this->db->transBegin(); $this->db->table('t_asset_details')->insert($asset); $affectedRows = $this->db->affectedRows(); if ($this->db->transStatus() === false) { $this->db->transRollback(); return false; } else { $this->db->transCommit(); return $affectedRows; } } /** * This function used to get Asset details by Asset Code * @param number $Asset_Code : This is AssetCode * @return array $result : This is Asset information */ function getAssetDetails($Asset_Code) { $builder = $this->db->table('t_asset_details Asset') //echo $Asset_Code; ->select('Asset.*,POM.DeliveryDate,Dep.DepartmentName as DepartmentName,MM.MaterialName,MM.UOM,Supp.SupplierName as SupplierName') ->join('t_departmentdetails Dep', 'Asset.DEPCode = Dep.DEPCode', 'left') ->join('t_supplierdetailsn Supp', 'Asset.SupplierCode = Supp.SupplierID', 'left') ->join('t_materialmaster MM ', 'MM.MaterialCode = Asset.MaterialCode', 'left') ->join('t_purchaseorder_master POM', 'POM.PONO = Asset.PONO', 'left') ->where('Asset.AssetCode', $Asset_Code); $query = $builder->get(); return $query->getResult(); } function editasset($asset, $Asset_Code) { $this->db->table('t_asset_details') ->where('AssetCode', $Asset_Code) ->update($asset); $count = $this->db->affectedRows(); return $count; } function deleteAsset($assetCode, $assetInfo) { $this->db->table('t_asset_details') ->where('AssetCode', $assetCode) ->update($assetInfo); $count = $this->db->affectedRows(); return $count; } function reActivateAsset($assetCode, $assetInfo) { $this->db->table('t_asset_details') ->where('AssetCode', $assetCode) ->update($assetInfo); $count = $this->db->affectedRows(); return $count; } function checkAssetName($assetName) { $builder = $this->db->table('t_asset_details') ->select('t_asset_details.*') ->where('AssetName', $assetName); $query = $builder->get(); return $query->getResultArray(); } function viewasset($asset, $Asset_Code) { $this->db->table('t_asset_details') ->where('AssetCode', $Asset_Code) ->update($asset); $count = $this->db->affectedRows(); return $count; } function export_excel() { $builder = $this->db->table('t_asset_details as det') ->select('det.AssetCode,det.AssetName,det.Description,dep.DepartmentName as DEPCode,det.Location,det.PONO,det.POLineItem,MM.MaterialName,det.Quantity,det.UserName,sup.SupplierName,det.DateOfPurchase,det.DateOfCommison,det.AssetValue,det.AssetStatus,det.IsActive,det.Remarks,emp.firstname,emp1.firstname as Updated_By') ->join('tbl_users as tbl', ' det.createdby = tbl.userid', 'left') ->join('t_departmentdetails as dep', 'dep.DEPCode=det.DEPCode', 'left') ->join('t_employee_details as emp', 'emp.empid=tbl.empid', 'left') ->join('t_supplierdetailsn as sup', 'sup.SupplierID=det.SupplierCode', 'left') ->join('t_materialmaster MM ', 'MM.MaterialCode = det.MaterialCode', 'left') ->join('tbl_users as tbl1', ' det.UpdatedBy = tbl1.userid', 'left') ->join('t_employee_details as emp1', 'emp1.empid=tbl1.empid', 'left'); $query = $builder->get(); return $query->getResult(); } }