<?php
require_once (PATH_TABLES . "activity/JobCentreListEquipmentTable.php") ;
require_once (PATH_MODELS . "base/MasterBase.php") ;
require_once (PATH_MODELS . "activity/BrandClass.php");
require_once (PATH_MODELS . "activity/ModelClass.php");
require_once (PATH_MODELS . "activity/ProductClass.php");
class JobCentreListEquipmentClass extends MasterBase {
	function __construct($db) {
		$this->db 		= $db ;
		$this->tbl 		= JobCentreListEquipmentTable::C_TABLE ;
		$this->fldid 	= JobCentreListEquipmentTable::C_ID ;
        $this->fldid2   = JobCentreListEquipmentTable::C_EQUIPMENT_ID ;
	}

	function __destruct() {
	}

    function getJobCentreListEquipment($id){
        $sql = "SELECT * FROM " ;
        $sql .= JobCentreListEquipmentTable::C_TABLE . " WHERE " . JobCentreListEquipmentTable::C_ID . " = " . $id;
        
        $rows = $this->db->getTable($sql);
       
        if(!is_null($rows) && count($rows) > 0){
            return $rows;
        }
        
        return null;
    }

    function getEquipmentName($id){

        if($id==0)return "";

        $productCls = new ProductClass($this->db) ;
        $brandCls   = new BrandClass($this->db) ;
        $modelCls   = new ModelClass($this->db) ;

        $sql = "SELECT * FROM " ;
        $sql .= JobCentreListEquipmentTable::C_TABLE . " WHERE " . JobCentreListEquipmentTable::C_EQUIPMENT_ID . " = " . $id;
        
        $row = $this->db->getTable($sql);
        
        $name = "";
        if(!is_null($row) && count($row) > 0){
            $name .= $productCls->getRecord($row[0][JobCentreListEquipmentTable::C_PRODUCT])[ProductTable::C_DESC].'-';
            $name .= $brandCls->getRecord($row[0][JobCentreListEquipmentTable::C_BRAND_ID])[BrandTable::C_DESC].'-';
            $name .= $modelCls->getRecord($row[0][JobCentreListEquipmentTable::C_MODEL_ID])[ModelTable::C_DESC].'-';
            $name .= $row[0][JobCentreListEquipmentTable::C_SERIAL_NUMBER];
            return $name;
        }
        
        return $name;
    }

}
?>