<?php

/**
 * Implements hook_install() using the name of the country as the base of
 * the function name.
 */
function colombia_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' => 170,
      'country_name' => 'Colombia',
      'country_iso_code_2' => 'CO',
      'country_iso_code_3' => 'COL',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(170, 'AMA', 'Amazonas'),
    array(170, 'ANT', 'Antioquia'),
    array(170, 'ARA', 'Arauca'),
    array(170, 'ATL', 'Atlantico'),
    array(170, 'BOL', 'Bolivar'),
    array(170, 'CAL', 'Caldas'),
    array(170, 'CAQ', 'Caqueta'),
    array(170, 'CAS', 'Casanare'),
    array(170, 'CAU', 'Cauca'),
    array(170, 'CES', 'Cesar'),
    array(170, 'CHO', 'Choco'),
    array(170, 'COR', 'Cordoba'),
    array(170, 'CUN', 'Cundinamarca'),
    array(170, 'DC', 'Distrito Capital de Bogota'),
    array(170, 'GUA', 'Guainia'),
    array(170, 'GUV', 'Guaviare'),
    array(170, 'HUI', 'Huila'),
    array(170, 'LAG', 'La Guajira'),
    array(170, 'MAG', 'Magdalena'),
    array(170, 'MET', 'Meta'),
    array(170, 'NAR', 'Narino'),
    array(170, 'NSA', 'Norte de Santander'),
    array(170, 'PUT', 'Putumayo'),
    array(170, 'QUI', 'Quindio'),
    array(170, 'RIS', 'Risaralda'),
    array(170, 'SAP', 'San Andres, Providencia y Santa Catalina'),
    array(170, 'SAN', 'Santander'),
    array(170, 'SUC', 'Sucre'),
    array(170, 'TOL', 'Tolima'),
    array(170, 'VAC', 'Valle del Cauca'),
    array(170, 'VAU', 'Vaupes'),
    array(170, 'VID', 'Vichada'),
  );

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