<?php

/**
 * Implements hook_install() using the name of the country as the base of
 * the function name.
 */
function georgia_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' => 268,
      'country_name' => 'Georgia',
      'country_iso_code_2' => 'GE',
      'country_iso_code_3' => 'GEO',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(268, 'AB', 'Abkhazia'),
    array(268, 'AJ', 'Ajaria'),
    array(268, 'GU', 'Guria'),
    array(268, 'IM', "Imeret'i"),
    array(268, 'KA', "Kakhet'i"),
    array(268, 'KK', "K'vemo K'art'li"),
    array(268, 'MM', "Mts'khet'a-Mt'ianet'i"),
    array(268, 'RL', "Racha-Lech'khumi-K'vemo"),
    array(268, 'SZ', "Samegrelo-Zemo Svanet'i"),
    array(268, 'SJ', "Samts'khe-Javakhet'i"),
    array(268, 'SK', "Shida K'art'li"),
    array(268, 'TB', "T'bilisi"),
  );

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