<?php

/**
 * Implements hook_install() using the name of the country as the base of
 * the function name.
 */
function nepal_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' => 524,
      'country_name' => 'Nepal',
      'country_iso_code_2' => 'NP',
      'country_iso_code_3' => 'NPL',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(524, '2', 'Madhya Pashchimanchal'),
    array(524, '1', 'Madhyamanchal'),
    array(524, '3', 'Pashchimanchal'),
    array(524, '4', 'Purwanchal'),
    array(524, '5', 'Sudur Pashchimanchal'),
    array(524, 'BA', 'Bagmati'),
    array(524, 'JA', 'Janakpur'),
    array(524, 'NA', 'Narayani'),
    array(524, 'BH', 'Bheri'),
    array(524, 'KA', 'Karnali'),
    array(524, 'RA', 'Rapti'),
    array(524, 'DH', 'Dhawalagiri'),
    array(524, 'GA', 'Gandaki'),
    array(524, 'LU', 'Lumbini'),
    array(524, 'KO', 'Koshi'),
    array(524, 'KO', 'Kosi'),
    array(524, 'ME', 'Mechi'),
    array(524, 'SA', 'Sagarmatha'),
    array(524, 'MA', 'Mahakali'),
    array(524, 'SE', 'Seti'),
  );

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