<?php
// $Id: malta_470_1.cif,v 1.5 2010-04-14 14:20:56 islandusurper Exp $ 1.0.0

/**
 * Implements hook_install() using the name of the country as the base of
 * the function name.
 */
function malta_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' => 470,
      'country_name' => 'Malta',
      'country_iso_code_2' => 'MT',
      'country_iso_code_3' => 'MLT',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(470, '01', 'Attard'),
    array(470, '02', 'Balzan'),
    array(470, '03', 'Birqu'),
    array(470, '04', 'Birkirkara'),
    array(470, '05', 'Birzebbuqa'),
    array(470, '06', 'Bormla'),
    array(470, '07', 'Dinqli'),
    array(470, '08', 'Fgura'),
    array(470, '09', 'Floriana'),
    array(470, '10', 'Fontana'),
    array(470, '13', 'Ghajnsielem'),
    array(470, '14', 'Gharb'),
    array(470, '15', 'Gharqhur'),
    array(470, '16', 'Ghasri'),
    array(470, '17', 'Ghaxaq'),
    array(470, '11', 'Gudja'),
    array(470, '12', 'Gzira'),
    array(470, '18', 'Hamrun'),
    array(470, '19', 'Iklin'),
    array(470, '20', 'Isla'),
    array(470, '21', 'Kalkara'),
    array(470, '22', 'Kercem'),
    array(470, '23', 'Kirkop'),
    array(470, '24', 'Lija'),
    array(470, '25', 'Luga'),
    array(470, '26', 'Marsa'),
    array(470, '27', 'Marsaskala'),
    array(470, '28', 'Marsaxlokk'),
    array(470, '29', 'Mdina'),
    array(470, '30', 'Mellieha'),
    array(470, '31', 'Mgarr'),
    array(470, '32', 'Mosta'),
    array(470, '33', 'Mgabba'),
    array(470, '34', 'Msida'),
    array(470, '35', 'Mtarfa'),
    array(470, '36', 'Munxar'),
    array(470, '37', 'Nadur'),
    array(470, '38', 'Naxxar'),
    array(470, '39', 'Paola'),
    array(470, '40', 'Pembroke'),
    array(470, '41', 'Pieta'),
    array(470, '42', 'Qala'),
    array(470, '43', 'Qormi'),
    array(470, '44', 'Qrendi'),
    array(470, '45', 'Rabat Ghawdex'),
    array(470, '45', 'Rabat Gozo'),
    array(470, '46', 'Rabat Malta'),
    array(470, '47', 'Safi'),
    array(470, '49', 'Saint John'),
    array(470, '48', "Saint Julian's"),
    array(470, '50', 'Saint Lawrence'),
    array(470, '53', "Saint Lucia's"),
    array(470, '51', "Saint Paul's Bay"),
    array(470, '48', 'San Giljan'),
    array(470, '49', 'San Gwann'),
    array(470, '50', 'San Lawrenz'),
    array(470, '51', 'San Pawl il-Bahar'),
    array(470, '52', 'Sannat'),
    array(470, '53', 'Santa Lucija'),
    array(470, '54', 'Santa Venera'),
    array(470, '55', 'Siggiewi'),
    array(470, '56', 'Sliema'),
    array(470, '57', 'Swiegi'),
    array(470, '58', "Ta'Xbiex"),
    array(470, '59', 'Tarxien'),
    array(470, '60', 'Valletta'),
    array(470, '61', 'Xaghra'),
    array(470, '62', 'Xewkija'),
    array(470, '63', 'Xghajra'),
    array(470, '64', 'Zabbar'),
    array(470, '65', 'Zebbug Ghawdex'),
    array(470, '65', 'Zebbug Gozo'),
    array(470, '66', 'Zebbug Malta'),
    array(470, '67', 'Zejtun'),
    array(470, '68', 'Zurrieg'),
  );

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