<?php

function oman_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' => 512,
      'country_name' => 'Oman',
      'country_iso_code_2' => 'OM',
      'country_iso_code_3' => 'OMN',
      'version' => 1,
    ))
    ->execute();

  $zones = array(
    array(512, 'BA', 'Al Batinah'),
    array(512, 'DA', 'Ad Dakhiliyah'),
    array(512, 'JA', 'Al Janubiyah'),
    array(512, 'MA', 'Masqat'),
    array(512, 'MU', 'Musandam'),
    array(512, 'SH', 'Ash Sharqiyah'),
    array(512, 'WU', 'Al Wusta'),
    array(512, 'ZA', 'Az Zahirah'),
  );

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