<?php

/**
 * Implements 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_insert('uc_countries')
    ->fields(array(
      'country_id' => 12,
      'country_name' => 'Algeria',
      'country_iso_code_2' => 'DZ',
      'country_iso_code_3' => 'DZA',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  // 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'),
  );

  $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  foreach ($zones as $zone) {
    $query->values($zone);
  }
  $query->execute();

  // Set address format
  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"
  );
}
