<?php

/**
 * Implements hook_install() using the name of the country as the base of
 * the function name.
 */
function sudan_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' => 736,
      'country_name' => 'Sudan',
      'country_iso_code_2' => 'SD',
      'country_iso_code_3' => 'SDN',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(736, 'SD-23', "Ā'ٰālī an Nīl"),
    array(736, 'SD-26', 'Al Baḩr al Aḩmar'),
    array(736, 'SD-18', 'Al Buḩayrāt'),
    array(736, 'SD-07', 'Al Jazīrah'),
    array(736, 'SD-03', 'Al Kharţūm'),
    array(736, 'SD-06', 'Al Qaḑārif'),
    array(736, 'SD-22', 'Al Waḩdah'),
    array(736, 'SD-04', 'An Nīl'),
    array(736, 'SD-08', 'An Nīl al Abyaḑ'),
    array(736, 'SD-24', 'An Nīl al Azraq'),
    array(736, 'SD-01', 'Ash Shamālīyah'),
    array(736, 'SD-17', 'Baḩr al Jabal'),
    array(736, 'SD-16', "Gharb al Istiwā'īyah"),
    array(736, 'SD-14', 'Gharb Baḩr al Ghazāl'),
    array(736, 'SD-12', 'Gharb Dārfūr'),
    array(736, 'SD-11', 'Janūb Dārfūr'),
    array(736, 'SD-13', 'Janūb Kurdufān'),
    array(736, 'SD-20', 'Jūnqalī'),
    array(736, 'SD-05', 'Kassalā'),
    array(736, 'SD-15', 'Shamāl Baḩr al Ghazāl'),
    array(736, 'SD-02', 'Shamāl Dārfūr'),
    array(736, 'SD-09', 'Shamāl Kurdufān'),
    array(736, 'SD-19', "Sharq al Istiwā'īyah"),
    array(736, 'SD-25', 'Sinnār'),
    array(736, 'SD-21', 'Wārāb'),
  );

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