<?php

/**
 * Implements hook_install() using the name of the country as the base of
 * the function name.
 */
function uganda_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' => 800,
      'country_name' => 'Uganda',
      'country_iso_code_2' => 'UG',
      'country_iso_code_3' => 'UGA',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(800, 'UG-317', 'Abim'),
    array(800, 'UG-301', 'Adjumani'),
    array(800, 'UG-314', 'Amolatar'),
    array(800, 'UG-216', 'Amuria'),
    array(800, 'UG-319', 'Amuru'),
    array(800, 'UG-302', 'Apac'),
    array(800, 'UG-303', 'Arua'),
    array(800, 'UG-217', 'Budaka'),
    array(800, 'UG-223', 'Bududa'),
    array(800, 'UG-201', 'Bugiri'),
    array(800, 'UG-224', 'Bukedea'),
    array(800, 'UG-218', 'Bukwa'),
    array(800, 'UG-419', 'Buliisa'),
    array(800, 'UG-401', 'Bundibugyo'),
    array(800, 'UG-402', 'Bushenyi'),
    array(800, 'UG-202', 'Busia'),
    array(800, 'UG-219', 'Butaleja'),
    array(800, 'UG-318', 'Dokolo'),
    array(800, 'UG-304', 'Gulu'),
    array(800, 'UG-403', 'Hoima'),
    array(800, 'UG-416', 'Ibanda'),
    array(800, 'UG-203', 'Iganga'),
    array(800, 'UG-417', 'Isingiro'),
    array(800, 'UG-204', 'Jinja'),
    array(800, 'UG-315', 'Kaabong'),
    array(800, 'UG-404', 'Kabale'),
    array(800, 'UG-405', 'Kabarole'),
    array(800, 'UG-213', 'Kaberamaido'),
    array(800, 'UG-101', 'Kalangala'),
    array(800, 'UG-220', 'Kaliro'),
    array(800, 'UG-102', 'Kampala'),
    array(800, 'UG-205', 'Kamuli'),
    array(800, 'UG-413', 'Kamwenge'),
    array(800, 'UG-414', 'Kanungu'),
    array(800, 'UG-206', 'Kapchorwa'),
    array(800, 'UG-406', 'Kasese'),
    array(800, 'UG-207', 'Katakwi'),
    array(800, 'UG-112', 'Kayunga'),
    array(800, 'UG-407', 'Kibaale'),
    array(800, 'UG-103', 'Kiboga'),
    array(800, 'UG-418', 'Kiruhura'),
    array(800, 'UG-408', 'Kisoro'),
    array(800, 'UG-305', 'Kitgum'),
    array(800, 'UG-316', 'Koboko'),
    array(800, 'UG-306', 'Kotido'),
    array(800, 'UG-208', 'Kumi'),
    array(800, 'UG-415', 'Kyenjojo'),
    array(800, 'UG-307', 'Lira'),
    array(800, 'UG-104', 'Luwero'),
    array(800, 'UG-116', 'Lyantonde'),
    array(800, 'UG-221', 'Manafwa'),
    array(800, 'UG-320', 'Maracha'),
    array(800, 'UG-105', 'Masaka'),
    array(800, 'UG-409', 'Masindi'),
    array(800, 'UG-214', 'Mayuge'),
    array(800, 'UG-209', 'Mbale'),
    array(800, 'UG-410', 'Mbarara'),
    array(800, 'UG-114', 'Mityana'),
    array(800, 'UG-308', 'Moroto'),
    array(800, 'UG-309', 'Moyo'),
    array(800, 'UG-106', 'Mpigi'),
    array(800, 'UG-107', 'Mubende'),
    array(800, 'UG-108', 'Mukono'),
    array(800, 'UG-311', 'Nakapiripirit'),
    array(800, 'UG-115', 'Nakaseke'),
    array(800, 'UG-109', 'Nakasongola'),
    array(800, 'UG-222', 'Namutumba'),
    array(800, 'UG-310', 'Nebbi'),
    array(800, 'UG-411', 'Ntungamo'),
    array(800, 'UG-321', 'Oyam'),
    array(800, 'UG-312', 'Pader'),
    array(800, 'UG-210', 'Pallisa'),
    array(800, 'UG-110', 'Rakai'),
    array(800, 'UG-412', 'Rukungiri'),
    array(800, 'UG-111', 'Sembabule'),
    array(800, 'UG-215', 'Sironko'),
    array(800, 'UG-211', 'Soroti'),
    array(800, 'UG-212', 'Tororo'),
    array(800, 'UG-113', 'Wakiso'),
    array(800, 'UG-313', 'Yumbe'),
  );

  $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(
    800,
    "!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"
  );
}
