<?php
// $Id: serbia_688_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 serbia_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' => 688,
      'country_name' => 'Serbia',
      'country_iso_code_2' => 'RS',
      'country_iso_code_3' => 'SRB',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(688, '00', 'Beograd'),
    array(688, '14', 'Bor'),
    array(688, '11', 'Barnicevo'),
    array(688, '23', 'Jablanica'),
    array(688, '09', 'Kolubara'),
    array(688, 'KM', 'Kosovo-Metohija'),
    array(688, '08', 'Macva'),
    array(688, '17', 'Moravica'),
    array(688, '20', 'Nisava'),
    array(688, '24', 'Pcinja'),
    array(688, '22', 'Pirot'),
    array(688, '10', 'Podunavlje'),
    array(688, '13', 'Pomoravlje'),
    array(688, '19', 'Rasina'),
    array(688, '18', 'Raska'),
    array(688, '12', 'Sumadija'),
    array(688, '21', 'Toplica'),
    array(688, 'VO', 'Vojvodina'),
    array(688, '15', 'Zajecar'),
    array(688, '16', 'Zlatibor'),
    array(688, '25', 'Kosovo'),
    array(688, '29', 'Kosovo-Pomoravlje'),
    array(688, '28', 'Kosovska Mitrovica'),
    array(688, '26', 'Pec'),
    array(688, '27', 'Prizren'),
    array(688, '06', 'Juzna Backa'),
    array(688, '04', 'Juzni Banat'),
    array(688, '01', 'Severna Backa'),
    array(688, '03', 'Severni Banat'),
    array(688, '02', 'Srednji Banat'),
    array(688, '07', 'Srem'),
    array(688, '05', 'Zapadna Backa'),
  );

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