<?php

function chad_install() {
  // Make the entry in the country table.
  // VALUES = Country ID, Country Name, 2-digit Code, 3-digit Code, File Version
  db_query("INSERT INTO {uc_countries} (country_id, country_name, country_iso_code_2, country_iso_code_3, version) VALUES (148,'Chad','TD','TCD',1)");

  // Make the entries in the zones table.
  $zones = array(
    array(148, 'KA', 'Barh el Ghazel'),
    array(148, 'BA', 'Batha'),
    array(148, 'BET', 'Borkou'),
    array(148, 'CB', 'Chari-Baguirmi'),
    array(148, 'BET', 'Ennedi'),
    array(148, 'GR', 'Guera'),
    array(148, 'HL', 'Hadjer-Lamis'),
    array(148, 'KA', 'Kanem'),
    array(148, 'LC', 'Lac'),
    array(148, 'LO', 'Logone Occidental'),
    array(148, 'LR', 'Logone Oriental'),
    array(148, 'MA', 'Mandoul'),
    array(148, 'ME', 'Mayo-Kebbi Est'),
    array(148, 'MO', 'Mayo-Kebbi Ouest'),
    array(148, 'MC', 'Moyen-Chari'),
    array(148, 'OD', 'Ouaddai'),
    array(148, 'SA', 'Salamat'),
    array(148, 'OD', 'Sila'),
    array(148, 'TA', 'Tandjile'),
    array(148, 'BET', 'Tibesti'),
    array(148, 'ND', "Ville de N'Djamena"),
    array(148, 'WF', 'Wadi Fira'),
  );

  foreach ($zones as $zone) {
    db_query("INSERT INTO {uc_zones} (zone_country_id, zone_code, zone_name) VALUES (%d, '%s', '%s')", $zone);
  }

  // Set address format
  uc_set_address_format(
    148,
    "!company\r\n".
    "!first_name !last_name\r\n".
    "!street1\r\n".
    "!street2\r\n".
    "!city, !zone_name  !postal_code\r\n".
    "!country_name_if"
  );
}
