<?php

/**
 * Implements hook_install() using the name of the country as the base of
 * the function name.
 */
function mauritius_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' => 480,
      'country_name' => 'Mauritius',
      'country_iso_code_2' => 'MU',
      'country_iso_code_3' => 'MUS',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(480, 'AG', 'Agalega Islands'),
    array(480, 'BR', 'Beau Bassin-Rose'),
    array(480, 'BL', 'Black River'),
    array(480, 'CC', 'Cargados Carajos'),
    array(480, 'CU', 'Curepipe'),
    array(480, 'FL', 'Flacq'),
    array(480, 'GP', 'Grand Port'),
    array(480, 'MO', 'Moka'),
    array(480, 'PA', 'Pamplemousses'),
    array(480, 'PW', 'Plaines Wilhems'),
    array(480, 'PL', 'Port Louis'),
    array(480, 'PU', 'Port Louis'),
    array(480, 'QB', 'Quatre Bornes'),
    array(480, 'RR', 'Riviere du Rempart'),
    array(480, 'RO', 'Rodrigues Island'),
    array(480, 'CC', 'Saint Brandon Islands'),
    array(480, 'SA', 'Savanne'),
    array(480, 'VP', 'Vacoas-Phoenix'),
  );

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