From 9a80993826c50d72535c82b16fff3d7f33923e09 Mon Sep 17 00:00:00 2001 From: gandhimathi Bharathirajan Date: Thu, 13 Apr 2017 00:21:40 +0530 Subject: [PATCH] Material Master --- .../models/rawmaterialdetails_model.php | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/application/models/rawmaterialdetails_model.php b/application/models/rawmaterialdetails_model.php index b5e8343e..0d584e23 100644 --- a/application/models/rawmaterialdetails_model.php +++ b/application/models/rawmaterialdetails_model.php @@ -9,15 +9,13 @@ class rawmaterialdetails_model extends CI_Model */ function rawmaterialListingCount($searchText = '') { - $this->db->select('BaseT.MaterialCode, BaseT.MaterialName, BaseT.MaterialType, BaseT.UOM, BaseT.CreatedDate'); - $this->db->from('T_MaterialMaster as BaseT'); - //$this->db->join('tbl_users as users', 'users.userId = BaseT.userId','left'); - //$this->db->join('T_SupplierDetailsN as ID', 'ID.SupplierID = BaseT.SupplierID','left'); + $this->db->select('*'); + $this->db->from('T_MaterialMaster'); + if(!empty($searchText)) { - $likeCriteria = "(BaseT.MaterialCode LIKE '%".$searchText."%' - OR BaseT.MaterialName LIKE '%".$searchText."%' - OR BaseT.MaterialType LIKE '%".$searchText."%' - OR BaseT.SupplierID LIKE '%".$searchText."%')"; + $likeCriteria = "(MaterialCode LIKE '%".$searchText."%' + OR MaterialName LIKE '%".$searchText."%' + OR MaterialType LIKE '%".$searchText."%' OR UOM LIKE '%".$searchText."%')"; $this->db->where($likeCriteria); } //$this->db->where('BaseT.isDeleted', 0); @@ -35,19 +33,17 @@ class rawmaterialdetails_model extends CI_Model */ function rawmaterialListing($searchText = '', $page, $segment) { - $this->db->select('BaseT.MaterialCode, BaseT.MaterialName, BaseT.MaterialType, BaseT.UOM ,BaseT.CreatedDate'); - $this->db->from('T_MaterialMaster as BaseT'); + $this->db->select('*'); + $this->db->from('T_MaterialMaster'); - //$this->db->join('T_SupplierDetailsN as ID', 'ID.SupplierID = BaseT.SupplierID','left'); if(!empty($searchText)) { - $likeCriteria = "(BaseT.MaterialCode LIKE '%".$searchText."%' - OR BaseT.MaterialName LIKE '%".$searchText."%' - OR BaseT.MaterialType LIKE '%".$searchText."%' - OR BaseT.SupplierID LIKE '%".$searchText."%')"; + $likeCriteria = "(MaterialCode LIKE '%".$searchText."%' + OR MaterialName LIKE '%".$searchText."%' + OR MaterialType LIKE '%".$searchText."%' OR UOM LIKE '%".$searchText."%')"; + $this->db->where($likeCriteria); } - //$this->db->where('BaseT.isDeleted', 0); - //$this->db->where('BaseT.userId !=', 1); + $this->db->limit($page, $segment); $query = $this->db->get(); @@ -57,24 +53,32 @@ class rawmaterialdetails_model extends CI_Model - function getUOM() + function getUOM($UOM = '') { $ConfigID = 'C001'; - $this->db->select('ConfigValue'); - $this->db->from('T_ConfigDetails'); - $this->db->where('Config_id ',$ConfigID ); + $this->db->select('ConfigValue'); + $this->db->from('T_ConfigDetails'); + $this->db->where('Config_id ',$ConfigID ); + if($UOM != '') + { + $this->db->where('ConfigValue !=',$UOM ); + } $query = $this->db->get(); return $query->result(); } - function getmaterial() + function getmaterialType($MaterialType = '') { $Config_ID = 'C003'; $this->db->select('Config_ID,ConfigValue'); $this->db->from('T_ConfigDetails'); $this->db->where('Config_id',$Config_ID ); + if($MaterialType != '') + { + $this->db->where('ConfigValue !=',$MaterialType ); + } $query = $this->db->get(); return $query->result(); @@ -87,14 +91,10 @@ class rawmaterialdetails_model extends CI_Model function addNewRawMaterial($RawMaterial) { - $this->db->trans_start(); + $this->db->insert('T_MaterialMaster', $RawMaterial); - - $MaterialCode = $this->db->insert_id(); - - $this->db->trans_complete(); - - return $MaterialCode; + + return TRUE; } /** @@ -102,15 +102,14 @@ function addNewRawMaterial($RawMaterial) * @param number $userId : This is user id * @return array $result : This is user information */ - function getuserInfo($MaterialCode) + function getMaterialDetails($MaterialCode) { - $this->db->select('MaterialCode, MaterialName,MaterialType,UOM,CreatedBy,UpdatedBy,CreatedDate'); + $this->db->select('*'); $this->db->from('T_MaterialMaster'); - //$this->db->where('isDeleted', 0); - //$this->db->where('roleId !=', 1); + $this->db->where('MaterialCode', $MaterialCode); $query = $this->db->get(); - + //sprint_r($this->db->last_query()); return $query->result(); } function editRawmaterial($RawMaterial, $MaterialCode)