bbone/application/modules/Asset/models/Asset_model.php
2022-12-26 14:03:09 +05:30

56 lines
2.1 KiB
PHP

<?php
class Asset_model extends MY_Model {
public function get_assets($business_id)
{
$this->db->select('A.* , categories.name as category_name , third_parties.name as manufacturer_name ,tp.name as supplier_name , locations.location as location_name');
$this->db->from('asset A');
$this->db->join('categories', 'categories.id = A.category', 'left');
$this->db->join('third_parties', 'third_parties.id = A.manufacturer', 'left');
$this->db->join('third_parties as tp', 'tp.id = A.supplier', 'left');
$this->db->join('locations', 'locations.id = A.location', 'left');
$this->db->where('A.business_id', $business_id);
$this->db->order_by('A.id','ASC');
$this->db->where('A.is_active', 1);
$query = $this->db->get();
$query = $query->result();
return $query;
}
public function get_asset_by_md5_id($id,$business_id)
{
$this->db->select('A.* , categories.name as category_name , third_parties.name as manufacturer_name ,tp.name as supplier_name , locations.location as location_name');
$this->db->from('asset A');
$this->db->join('categories', 'categories.id = A.category', 'left');
$this->db->join('third_parties', 'third_parties.id = A.manufacturer', 'left');
$this->db->join('third_parties as tp', 'tp.id = A.supplier', 'left');
$this->db->join('locations', 'locations.id = A.location', 'left');
$this->db->where('A.business_id', $business_id);
$this->db->where('md5(A.id)', $id);
$query = $this->db->get();
$query = $query->row();
return $query;
}
public function delete_asset_by_md5_id($id,$business_id)
{
$this->db->where('md5(id)', $id);
$this->db->where('business_id', $business_id);
$this->db->set('is_active',0);
$this->db->update('asset');
return;
}
public function get_by_asset_id($id,$table,$business_id)
{
$this->db->select();
$this->db->from($table);
$this->db->where('business_id', $business_id);
$this->db->where('md5(asset_id)', $id);
$query = $this->db->get();
$query = $query->result();
return $query;
}
}