<?php

/**
 * First implement hook_install() using the name of the country as the base of
 * the function name.
 */
function algeria_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 ('12', 'Algeria', 'DZ', 'DZA', 1)");

  // Make the entries in the zones table.  Use %d for the zone_id and the
  // VALUES = Parent Country ID, Zone Abbreviation, Zone Name
  $zones = array(
    array(12, 'ADRAR', 'Adrar'),
    array(12, 'AIN TEMOUCHENT', 'Ain Temouchent'),
    array(12, 'ALGIERS', 'Algiers'),
    array(12, 'ANNABA', 'Annaba'),
    array(12, 'LAGHOUAT', 'Laghouat'),
    array(12, 'BATNA', 'Batna'),
    array(12, 'BEJAIA', 'Bejaia'),
    array(12, 'BISKRA', 'Biskra'),
    array(12, 'BECHAR', 'Bechar'),
    array(12, 'BLIDA', 'Blida'),
    array(12, 'BOUIRA', 'Bouira'),
    array(12, 'CHLEF', 'Chlef'),
    array(12, 'CONSTANTINE', 'Constantine'),
    array(12, 'DJELFA', 'Djelfa'),
    array(12, 'TAMANGHASSET', 'Tamanghasset'),
    array(12, 'TEBESSA', 'Tebessa'),
    array(12, 'TLEMCEN', 'Tlemcen'),
    array(12, 'TIZI OUZOU', 'Tizi Ouzou'),
    array(12, 'JIJEL', 'Jijel'),
    array(12, 'SETIF', 'Setif'),
    array(12, 'SAIDA', 'Saida'),
    array(12, 'SKIKDA', 'Skikda'),
    array(12, 'SIDI BEL ABBES', 'Sidi Bel Abbes'),
    array(12, 'GUELMA', 'Guelma'),
    array(12, 'MEDEA', 'Medea'),
    array(12, 'MOSTAGANEM', 'Mostaganem'),
    array(12, 'MSILA', 'MSila'),
    array(12, 'ORAN', 'Oran'),
    array(12, 'OUARGLA', 'Ouargla'),
    array(12, 'OUM EL-BOUAGHI', 'Oum el-Bouaghi'),
    array(12, 'EL BAYADH', 'El Bayadh'),
    array(12, 'ILLIZI', 'Illizi'),
    array(12, 'BORDJ BOU ARRERIDJ', 'Bordj Bou Arreridj'),
    array(12, 'BOUMERDES', 'Boumerdes'),
    array(12, 'EL TARF', 'El Tarf'),
    array(12, 'TINDDOUF', 'Tindouf'),
    array(12, 'TISSEMSILT', 'Tissemsilt'),
    array(12, 'EL OUED', 'El Oued'),
    array(12, 'KHENCHELA', 'Khenchela'),
    array(12, 'SOUK AHRAS', 'Souk Ahras'),
    array(12, 'MILA', 'Mila'),
    array(12, 'AIN DEFLA', 'Ain Defla'),
    array(12, 'NAAMA', 'Naama'),
    array(12, 'GHARDAIA', 'Ghardaia'),
    array(12, 'RELIZANE', 'Relizane'),
  );

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

  // Use uc_set_address_format() with the country ID as the first argument and
  // an address format string as the second.  Documentation on address formats
  // is available at:
  // http://www.ubercart.org/ubercart_users_guide/country_settings#address_format_docs
  uc_set_address_format(12,
    "!company\r\n!first_name !last_name\r\n!street1\r\n!street2"
   ."\r\n!city\r\n!postal_code !zone_code\r\n!country_name_if");
}
