<?php

/**
* First implement hook_install() using the name of the country as the base of
* the function name.
*/
function mexico_install() {
  // Make the entry in the country table.
  // VALUES = Country ID, Country Name, 2-digit Code, 3-digit Code, File Version
  db_query("INSERT INTO {uc_countries} (country_id, country_name, country_iso_code_2, country_iso_code_3, version) VALUES ('484', 'Mexico', 'MX', 'MEX', 1)");

  // Make the entries in the zones table.
  $zones = array(
    array(484, 'AGS', 'Aguascalientes'),
    array(484, 'BC', 'Baja California'),
    array(484, 'BCS', 'Baja California Sur'),
    array(484, 'CAM', 'Campeche'),
    array(484, 'CHIS', 'Chiapas'),
    array(484, 'CHI', 'Chihuahua'),
    array(484, 'COAH', 'Coahuila'),
    array(484, 'COL', 'Colima'),
    array(484, 'DF', 'Distrito Federal'),
    array(484, 'DGO', 'Durango'),
    array(484, 'GTO', 'Guanajuato'),
    array(484, 'GRO', 'Guerrero'),
    array(484, 'HGO', 'Hidalgo'),
    array(484, 'JAL', 'Jalisco'),
    array(484, 'ME', 'México'),
    array(484, 'MICH', 'Michoacán'),
    array(484, 'MOR', 'Morelos'),
    array(484, 'NAY', 'Nayarit'),
    array(484, 'NL', 'Nuevo León'),
    array(484, 'OAX', 'Oaxaca'),
    array(484, 'PUE', 'Puebla'),
    array(484, 'QUE', 'Querétaro'),
    array(484, 'QR', 'Quintana Roo'),
    array(484, 'SLP', 'San Luis Potosi'),
    array(484, 'SIN', 'Sinaloa'),
    array(484, 'SON', 'Sonora'),
    array(484, 'TAB', 'Tabasco'),
    array(484, 'TAM', 'Tamaulipas'),
    array(484, 'TLA', 'Tlaxcala'),
    array(484, 'VER', 'Veracruz'),
    array(484, 'YUC', 'Yucatán'),
    array(484, 'ZAC', 'Zacatecas'),
  );

  foreach ($zones as $zone) {
    db_query("INSERT INTO {uc_zones} (zone_country_id, zone_code, zone_name) VALUES (%d, '%s', '%s')", $zone);
  }

  // Use uc_set_address_format() with the country ID as the first argument and
  // an address format string as the second.  Documentation on address formats
  // is available at:
  // http://www.ubercart.org/ubercart_users_guide/country_settings#address_format_docs
  uc_set_address_format(484,
    "!company\n!first_name !last_name\n!street1\n!street2"
   ."\n!postal_code !city\n!country_name_if");
}
