<?php

/**
 * Implements hook_install() using the name of the country as the base of
 * the function name.
 */
function macedonia_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' => 807,
      'country_name' => 'Macedonia',
      'country_iso_code_2' => 'MK',
      'country_iso_code_3' => 'MKD',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(807, '01', 'Aerodrom'),
    array(807, '02', 'Aracinovo'),
    array(807, '03', 'Berovo'),
    array(807, '04', 'Bitola'),
    array(807, '05', 'Bogdanci'),
    array(807, '06', 'Bogovinje'),
    array(807, '07', 'Bosilovo'),
    array(807, '08', 'Brvenica'),
    array(807, '09', 'Butel'),
    array(807, '79', 'Cair'),
    array(807, '80', 'Caska'),
    array(807, '77', 'Centar'),
    array(807, '78', 'Centar Zupa'),
    array(807, '81', 'Cesinovo-Oblesevo'),
    array(807, '82', 'Cucer Sandevo'),
    array(807, '21', 'Debar'),
    array(807, '22', 'Debarca'),
    array(807, '23', 'Delcevo'),
    array(807, '24', 'Demir Kapija'),
    array(807, '26', 'Dojran'),
    array(807, '27', 'Dolneni'),
    array(807, '28', 'Drugovo'),
    array(807, '17', 'Gazi Baba'),
    array(807, '18', 'Gevgelija'),
    array(807, '29', 'Gjorce Petrov'),
    array(807, '19', 'Gostivar'),
    array(807, '20', 'Gradsko'),
    array(807, '34', 'Ilinden'),
    array(807, '35', 'Jequnovce'),
    array(807, '37', 'Karbinci'),
    array(807, '38', 'Karpos'),
    array(807, '36', 'Kavadarci'),
    array(807, '40', 'Kicevo'),
    array(807, '39', 'Kisela Voda'),
    array(807, '42', 'Kocani'),
    array(807, '41', 'Konce'),
    array(807, '43', 'Kratovo'),
    array(807, '44', 'Kriva Palanka'),
    array(807, '45', 'Krivoqastani'),
    array(807, '46', 'Krusevo'),
    array(807, '47', 'Kumanovo'),
    array(807, '48', 'Lipkovo'),
    array(807, '49', 'Lozovo'),
    array(807, '51', 'Makedonska Kamenica'),
    array(807, '52', 'Makedonski Brod'),
    array(807, '50', 'Mavrovo-i-Rostusa'),
    array(807, '53', 'Moqila'),
    array(807, '54', 'Negotino'),
    array(807, '55', 'Novaci'),
    array(807, '56', 'Novo Selo'),
    array(807, '58', 'Ohrid'),
    array(807, '57', 'Oslomej'),
    array(807, '60', 'Pehcevo'),
    array(807, '59', 'Petrovec'),
    array(807, '61', 'Plasnica'),
    array(807, '62', 'Prilep'),
    array(807, '63', 'Probistip'),
    array(807, '64', 'Radovis'),
    array(807, '65', 'Rankovce'),
    array(807, '66', 'Resen'),
    array(807, '67', 'Rosoman'),
    array(807, '68', 'Saraj'),
    array(807, '70', 'Sopiste'),
    array(807, '71', 'Staro Nagoricane'),
    array(807, '83', 'Stip'),
    array(807, '72', 'Struga'),
    array(807, '73', 'Strumica'),
    array(807, '74', 'Studenicani'),
    array(807, '84', 'Suto Orizari'),
    array(807, '69', 'Sveti Nikole'),
    array(807, '75', 'Tearce'),
    array(807, '76', 'Tetovo'),
    array(807, '10', 'Valandovo'),
    array(807, '11', 'Vasilevo'),
    array(807, '13', 'Veles'),
    array(807, '12', 'Vevcani'),
    array(807, '14', 'Vinica'),
    array(807, '15', 'Vranestica'),
    array(807, '16', 'Vrapciste'),
    array(807, '31', 'Zajas'),
    array(807, '32', 'Zelenikovo'),
    array(807, '30', 'Zelino'),
    array(807, '33', 'Zrnovci'),
  );

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