<?php

function argentina_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' => 32,
      'country_name' => 'Argentina',
      'country_iso_code_2' => 'AR',
      'country_iso_code_3' => 'ARG',
      'version' => 1,
    ))
    ->execute();

  // VALUES = %d for ID, Parent Country ID, Zone Abbreviation, Zone Name
  $zones = array(
    array(32, 'A', 'Salta'),
    array(32, 'B', 'Buenos Aires Province'),
    array(32, 'C', 'Capital Federal'),
    array(32, 'D', 'San Luis'),
    array(32, 'E', 'Entre Ríos'),
    array(32, 'F', 'La Rioja'),
    array(32, 'G', 'Santiago del Estero'),
    array(32, 'H', 'Chaco'),
    array(32, 'J', 'San Juan'),
    array(32, 'K', 'Catamarca'),
    array(32, 'L', 'La Pampa'),
    array(32, 'M', 'Mendoza'),
    array(32, 'N', 'Misiones'),
    array(32, 'P', 'Formosa'),
    array(32, 'Q', 'Neuquén'),
    array(32, 'R', 'Río Negro'),
    array(32, 'S', 'Santa Fe'),
    array(32, 'T', 'Tucumán'),
    array(32, 'U', 'Chubut'),
    array(32, 'V', 'Tierra del Fuego'),
    array(32, 'W', 'Corrientes'),
    array(32, 'X', 'Córdoba'),
    array(32, 'Y', 'Jujuy'),
    array(32, 'Z', 'Santa Cruz'),
  );

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