<?php
// $Id: chile_152_1.cif,v 1.8 2010-04-14 14:20:56 islandusurper Exp $

function chile_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' => 152,
      'country_name' => 'Chile',
      'country_iso_code_2' => 'CL',
      'country_iso_code_3' => 'CHL',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(152, 'TA', 'Tarapaca'),
    array(152, 'AN', 'Antofagasta'),
    array(152, 'AT', 'Atacama'),
    array(152, 'CO', 'Coquimbo'),
    array(152, 'VA', 'Valparaiso'),
    array(152, 'OH', 'Ohiggins'),
    array(152, 'MA', 'Maule'),
    array(152, 'BI', 'Biobio'),
    array(152, 'AR', 'Araucania'),
    array(152, 'LA', 'Lagos'),
    array(152, 'AI', 'Aisen'),
    array(152, 'MA', 'Magallanes'),
    array(152, 'RM', 'Metropolitana'),
    array(152, 'Ri', 'Rios'),
    array(152, 'AR', 'Arica'),
  );

  $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(
    152,
    "!company\r\n".
    "!first_name !last_name\r\n".
    "!street1\r\n".
    "!street2\r\n".
    "!city, !postal_code\r\n".
    "!zone_name, !country_name"
  );
}
