<?php
final class DModelLocalisationZone extends Model {
  public function getZone($zone_id) {
    $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE zone_id = '" . (int)$zone_id . "' AND status = '1'");

    return $query->row;
  }

  public function getZoneIdByUf($uf) {
		$this->load->type('tipocomum');
		$query = $this->db->query("SELECT zone_id FROM " . DB_PREFIX . "zone WHERE country_id = '" . Type_PaisId::Tp_Brasil . "' and code = '".$uf."' ");		
		return $query->row['zone_id'];
	}

	public function getZoneId($country_code, $zone_code){
    $this->load->type('tipocomum');
    $query = $this->db->query(
      "SELECT 
          z.zone_id 
       FROM oc_zone z 
       inner join oc_country c on(c.country_id = z.country_id)
       WHERE c.iso_code_2 = '$country_code' and z.code = '$zone_code' ");

    return  ($query->num_rows > 0) ? $query->row['zone_id'] : false;
  }
	
	
}
