<?php /* ############################################
############################################
USED IN controller/brands.php |
Developed By Abhishek Singhal | 7838222290 |
###########################################
############################################# */ ?>
<?php
class Settings_model extends CI_Model {

	function __construct(){
		parent::__construct();
	}
	
	
	/*##############################################################*/
	/*---------------------TO GET SINGLE RECORDS -------------------------*/
	public function getSettingsData(){
		$this->db->select('*');
		$this->db->from('settings');
		$this->db->where('id', 1 );
		$query = $this->db->get();
		if ( $query->num_rows() > 0 )
		{
			$row = $query->row_array();
			return $row;
		}
		return 0;
	}
	
	public function updateData($data){
		
		$values=array();
		$values['value']=$data;
		
		$this->db->where('id', 1);
		$this->db->update('settings', $values);	

	}
	
	/*##############################################################*/
	/*---------------------TAX CLASS SETTINGS -------------------------*/
	
	public function getAllTaxClassData($view=NULL){
		$this->db->select('*');
		$query = $this->db->get('setting_tax_class');
		return $query->result();
	}
	
	public function getSingleTaxClassData($id){
		$this->db->select('*');
		$this->db->from('setting_tax_class');
		$this->db->where('tax_class_id', $id );
		$query = $this->db->get();
		if ( $query->num_rows() > 0 )
		{
			$row = $query->row_array();
			return $row;
		}
		return 0;
	}
	
	
	public function saveTaxClassData($data,$id){
		
		if($id>0)
		{
			$this->db->where('tax_class_id', $id);
			$this->db->update('setting_tax_class', $data);	
		}else{
			$this->db->insert('setting_tax_class', $data);	
		}

	}
	
	public function deleteTaxClassData($id){
		
		$this->db->where('tax_class_id', $_GET['id'] );
		$this->db->delete('setting_tax_class');
	}
	
	/*##############################################################*/
	/*---------------------TAX CLASS SETTINGS END -------------------------*/
	
	
	
	/*##############################################################*/
	/*---------------------PRODUCT QTY SETTINGS -------------------------*/
	
	public function getAllProductQtyClassData($view=NULL){
		$this->db->select('*');
		$query = $this->db->get('`setting_product_qty`');
		return $query->result();
	}
	
	public function getSingleProductQtyClassData($id){
		$this->db->select('*');
		$this->db->from('setting_product_qty');
		$this->db->where('`product_qty_class_id`', $id );
		$query = $this->db->get();
		if ( $query->num_rows() > 0 )
		{
			$row = $query->row_array();
			return $row;
		}
		return 0;
	}
	
	public function saveProductQtyClassData($data,$id){
		
		if($id>0)
		{
			$this->db->where('product_qty_class_id', $id);
			$this->db->update('`setting_product_qty`', $data);	
		}else{
			$this->db->insert('`setting_product_qty`', $data);	
		}
	}
	
	public function deleteProductQtyClassData($id){
		
		$this->db->where('product_qty_class_id', $_GET['id'] );
		$this->db->delete('`setting_product_qty`');
	}
	
	/*##############################################################*/
	/*---------------------PRODUCT QTY SETTINGS END -------------------------*/
	
	public function getAllUserlist(){
		$this->db->select('*');
		$query = $this->db->get('adminuser');
		return $query->result();
	}
	
	public function getUserSingleData($id){
		$this->db->select('*');
		$this->db->from('adminuser');
		$this->db->where('id', $id );
		$query = $this->db->get();
		if ( $query->num_rows() > 0 )
		{
			$row = $query->row_array();
			return $row;
		}
		return 0;
	}
	
	public function saveUserData($data,$id){
		
		if($id>0)
		{
			$this->db->where('id', $id);
			$this->db->update('adminuser', $data);	
		}else{
			$this->db->insert('adminuser', $data);	
		}

	}
	
	public function deleteUserData($id){
		
		$this->db->where('id', $_GET['id'] );
		$this->db->delete('adminuser');
	}
}
?>