<?php

function indonesia_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' => 360,
      'country_name' => 'Indonesia',
      'country_iso_code_2' => 'ID',
      'country_iso_code_3' => 'IDN',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(360, 'NAD', 'Nanggroe Aceh Darussalam'),
    array(360, 'Sumut', 'Sumatera Utara'),
    array(360, 'Sumbar', 'Sumatera Barat'),
    array(360, 'Riau', 'Riau'),
    array(360, 'Jambi', 'Jambi'),
    array(360, 'Sumsel', 'Sumatera Selatan'),
    array(360, 'Bengkulu', 'Bengkulu'),
    array(360, 'Lampung', 'Lampung'),
    array(360, 'Babel', 'Kepulauan Bangka Belitung'),
    array(360, 'Kepri', 'Kepulauan Riau'),
    array(360, 'DKI', 'DKI Jakarta'),
    array(360, 'Jabar', 'Jawa Barat'),
    array(360, 'Jateng', 'Jawa Tengah'),
    array(360, 'DIY', 'Daista Yogyakarta'),
    array(360, 'Jatim', 'Jawa Timur'),
    array(360, 'Banten', 'Banten'),
    array(360, 'Bali', 'Bali'),
    array(360, 'NTB', 'Nusa Tenggara Barat'),
    array(360, 'NTT', 'Nusa Tenggara Timur'),
    array(360, 'Kalbar', 'Kalimantan Barat'),
    array(360, 'Kalteng', 'Kalimantan Tengah'),
    array(360, 'Kalsel', 'Kalimantan Selatan'),
    array(360, 'Kaltim', 'Kalimantan Timur'),
    array(360, 'Sulut', 'Sulawesi Utara'),
    array(360, 'Sulteng', 'Sulawesi Tengah'),
    array(360, 'Sulsel', 'Sulawesi Selatan'),
    array(360, 'Sultra', 'Sulawesi Tenggara'),
    array(360, 'Gorontalo', 'Gorontalo'),
    array(360, 'Sulbar', 'Sulawesi Barat'),
    array(360, 'Maluku', 'Maluku'),
    array(360, 'Malut', 'Maluku Utara'),
    array(360, 'Papua', 'Papua'),
    array(360, 'Irjabar', 'Irian Jaya Barat'),
  );

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