<?php
// $Id: spain_724_1.cif,v 1.3.4.4 2010/04/14 05:18:19 tr Exp $

/**
* First implement hook_install() using the name of the country as the base of
* the function name.
*/
function spain_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 ('724', 'Spain', 'ES', 'ESP', 1)");

  // Make the entries in the zones table.
  $zones = array(
    array(724, 'CA', 'A Coruña'),
    array(724, 'AL', 'Álava'),
    array(724, 'AB', 'Albacete'),
    array(724, 'AC', 'Alicante'),
    array(724, 'AM', 'Almería'),
    array(724, 'AS', 'Asturias'),
    array(724, 'AV', 'Ávila'),
    array(724, 'BJ', 'Badajoz'),
    array(724, 'IB', 'Baleares'),
    array(724, 'BA', 'Barcelona'),
    array(724, 'BU', 'Burgos'),
    array(724, 'CC', 'Cáceres'),
    array(724, 'CZ', 'Cádiz'),
    array(724, 'CT', 'Cantabria'),
    array(724, 'CL', 'Castellón'),
    array(724, 'CE', 'Ceuta'),
    array(724, 'CR', 'Ciudad Real'),
    array(724, 'CD', 'Córdoba'),
    array(724, 'CU', 'Cuenca'),
    array(724, 'GI', 'Girona'),
    array(724, 'GD', 'Granada'),
    array(724, 'GJ', 'Guadalajara'),
    array(724, 'GP', 'Guipúzcoa'),
    array(724, 'HL', 'Huelva'),
    array(724, 'HS', 'Huesca'),
    array(724, 'JN', 'Jaén'),
    array(724, 'RJ', 'La Rioja'),
    array(724, 'PM', 'Las Palmas'),
    array(724, 'LE', 'León'),
    array(724, 'LL', 'Lleida'),
    array(724, 'LG', 'Lugo'),
    array(724, 'MD', 'Madrid'),
    array(724, 'MA', 'Málaga'),
    array(724, 'ML', 'Melilla'),
    array(724, 'MU', 'Murcia'),
    array(724, 'NV', 'Navarra'),
    array(724, 'OU', 'Ourense'),
    array(724, 'PL', 'Palencia'),
    array(724, 'PO', 'Pontevedra'),
    array(724, 'SL', 'Salamanca'),
    array(724, 'SC', 'Santa Cruz de Tenerife'),
    array(724, 'SG', 'Segovia'),
    array(724, 'SV', 'Sevilla'),
    array(724, 'SO', 'Soria'),
    array(724, 'TA', 'Tarragona'),
    array(724, 'TE', 'Teruel'),
    array(724, 'TO', 'Toledo'),
    array(724, 'VC', 'Valencia'),
    array(724, 'VD', 'Valladolid'),
    array(724, 'VZ', 'Vizcaya'),
    array(724, 'ZM', 'Zamora'),
    array(724, 'ZR', 'Zaragoza'),
  );

  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(724,
    "!company\n!first_name !last_name\n!street1\n!street2"
   ."\n!postal_code !city\n!country_name_if");
}
