<?php

function namibia_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' => 516,
      'country_name' => 'Namibia',
      'country_iso_code_2' => 'NA',
      'country_iso_code_3' => 'NAM',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(516, 'NA-CA', 'Caprivi'),
    array(516, 'NA-ER', 'Erongo'),
    array(516, 'NA-HA', 'Hardap'),
    array(516, 'NA-KA', 'Karas'),
    array(516, 'NA-KH', 'Khomas'),
    array(516, 'NA-KU', 'Kunene'),
    array(516, 'NA-OW', 'Ohangwena'),
    array(516, 'NA-OK', 'Okavango'),
    array(516, 'NA-OH', 'Omaheke'),
    array(516, 'NA-OS', 'Omusati'),
    array(516, 'NA-ON', 'Oshana'),
    array(516, 'NA-OT', 'Oshikoto'),
    array(516, 'NA-OD', 'Otjozondjupa'),
  );

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