<?php

function nigeria_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' => 566,
      'country_name' => 'Nigeria',
      'country_iso_code_2' => 'NG',
      'country_iso_code_3' => 'NGA',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(566, 'AB', 'Abia'),
    array(566, 'AD', 'Adamawa'),
    array(566, 'AK', 'Akwa Ibom'),
    array(566, 'AN', 'Anambra'),
    array(566, 'BA', 'Bauchi'),
    array(566, 'BY', 'Bayelsa'),
    array(566, 'BN', 'Benue'),
    array(566, 'BO', 'Borno'),
    array(566, 'CR', 'Cross River'),
    array(566, 'DT', 'Delta'),
    array(566, 'EB', 'Ebonyi'),
    array(566, 'ED', 'Edo'),
    array(566, 'EK', 'Ekiti'),
    array(566, 'EN', 'Enugu'),
    array(566, 'FC', 'FCT - Abuja'),
    array(566, 'GB', 'Gombe'),
    array(566, 'IM', 'Imo'),
    array(566, 'JG', 'Jigawa'),
    array(566, 'KD', 'Kaduna'),
    array(566, 'KN', 'Kano'),
    array(566, 'KT', 'Katsina'),
    array(566, 'KB', 'Kebbi'),
    array(566, 'KG', 'Kogi'),
    array(566, 'KW', 'Kwara'),
    array(566, 'LA', 'Lagos'),
    array(566, 'NS', 'Nassarawa'),
    array(566, 'NG', 'Niger'),
    array(566, 'OG', 'Ogun'),
    array(566, 'ON', 'Ondo'),
    array(566, 'OS', 'Osun'),
    array(566, 'OY', 'Oyo'),
    array(566, 'PL', 'Plateau'),
    array(566, 'RV', 'Rivers'),
    array(566, 'SO', 'Sokoto'),
    array(566, 'TB', 'Taraba'),
    array(566, 'YB', 'Yobe'),
    array(566, 'ZM', 'Zamfara'),
  );

  $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(
    566,
    "!company\r\n".
    "!first_name !last_name\r\n".
    "!street1\r\n".
    "!street2\r\n".
    "!city - !postal_code\r\n".
    "!zone_code\r\n".
    "!country_name_if"
  );
}
