<?php

/**
* Implements hook_install() using the name of the country as the base of
* the function name.
*/
function papua_new_guinea_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' => 598,
      'country_name' => 'Papua New Guinea',
      'country_iso_code_2' => 'PG',
      'country_iso_code_3' => 'PNG',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(598, 'CPM', 'Central'),
    array(598, 'CPK', 'Chimbu'),
    array(598, 'EHG', 'Eastern Highlands'),
    array(598, 'EBR', 'East New Britain'),
    array(598, 'ESW', 'East Sepik'),
    array(598, 'EPW', 'Enga'),
    array(598, 'GPK', 'Gulf'),
    array(598, 'MPM', 'Madang'),
    array(598, 'MRL', 'Manus'),
    array(598, 'MBA', 'Milne Bay'),
    array(598, 'MPL', 'Morobe'),
    array(598, 'NCD', 'National Capital District (Port Moresby)'),
    array(598, 'NIK', 'New Ireland'),
    array(598, 'NPP', 'Northern'),
    array(598, 'NSA', 'North Solomons'),
    array(598, 'SAN', 'Sandaun [West Sepik]'),
    array(598, 'SHM', 'Southern Highlands'),
    array(598, 'WPD', 'Western'),
    array(598, 'WHM', 'Western Highlands'),
    array(598, 'WBK', 'West New Britain'),
  );

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