<?php

function france_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' => 250,
      'country_name' => 'France',
      'country_iso_code_2' => 'FR',
      'country_iso_code_3' => 'FRA',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(250, 'FR-01', 'Ain'),
    array(250, 'FR-02', 'Aisne'),
    array(250, 'FR-03', 'Allier'),
    array(250, 'FR-04', 'Alpes-de-Haute-Provence'),
    array(250, 'FR-05', 'Hautes-Alpes'),
    array(250, 'FR-06', 'Alpes-Maritimes'),
    array(250, 'FR-07', 'Ardèche'),
    array(250, 'FR-08', 'Ardennes'),
    array(250, 'FR-09', 'Ariège'),
    array(250, 'FR-10', 'Aube'),
    array(250, 'FR-11', 'Aude'),
    array(250, 'FR-12', 'Aveyron'),
    array(250, 'FR-13', 'Bouches-du-Rhône'),
    array(250, 'FR-14', 'Calvados'),
    array(250, 'FR-15', 'Cantal'),
    array(250, 'FR-16', 'Charente'),
    array(250, 'FR-17', 'Charente-Maritime'),
    array(250, 'FR-18', 'Cher'),
    array(250, 'FR-19', 'Corrèze'),
    array(250, 'FR-21', "Côte-d'Or"),
    array(250, 'FR-22', "Côtes-d'Armor"),
    array(250, 'FR-23', 'Creuse'),
    array(250, 'FR-24', 'Dordogne'),
    array(250, 'FR-25', 'Doubs'),
    array(250, 'FR-26', 'Drôme'),
    array(250, 'FR-27', 'Eure'),
    array(250, 'FR-28', 'Eure-et-Loir'),
    array(250, 'FR-29', 'Finistère'),
    array(250, 'FR-2A', 'Corse-du-Sud'),
    array(250, 'FR-2B', 'Haute-Corse'),
    array(250, 'FR-30', 'Gard'),
    array(250, 'FR-31', 'Haute-Garonne'),
    array(250, 'FR-32', 'Gers'),
    array(250, 'FR-33', 'Gironde'),
    array(250, 'FR-34', 'Hérault'),
    array(250, 'FR-35', 'Ille-et-Vilaine'),
    array(250, 'FR-36', 'Indre'),
    array(250, 'FR-37', 'Indre-et-Loire'),
    array(250, 'FR-38', 'Isère'),
    array(250, 'FR-39', 'Jura'),
    array(250, 'FR-40', 'Landes'),
    array(250, 'FR-41', 'Loir-et-Cher'),
    array(250, 'FR-42', 'Loire'),
    array(250, 'FR-43', 'Haute-Loire'),
    array(250, 'FR-44', 'Loire-Atlantique'),
    array(250, 'FR-45', 'Loiret'),
    array(250, 'FR-46', 'Lot'),
    array(250, 'FR-47', 'Lot-et-Garonne'),
    array(250, 'FR-48', 'Lozère'),
    array(250, 'FR-49', 'Maine-et-Loire'),
    array(250, 'FR-50', 'Manche'),
    array(250, 'FR-51', 'Marne'),
    array(250, 'FR-52', 'Haute-Marne'),
    array(250, 'FR-53', 'Mayenne'),
    array(250, 'FR-54', 'Meurthe-et-Moselle'),
    array(250, 'FR-55', 'Meuse'),
    array(250, 'FR-56', 'Morbihan'),
    array(250, 'FR-57', 'Moselle'),
    array(250, 'FR-58', 'Nièvre'),
    array(250, 'FR-59', 'Nord'),
    array(250, 'FR-60', 'Oise'),
    array(250, 'FR-61', 'Orne'),
    array(250, 'FR-62', 'Pas-de-Calais'),
    array(250, 'FR-63', 'Puy-de-Dôme'),
    array(250, 'FR-64', 'Pyrénées-Atlantiques'),
    array(250, 'FR-65', 'Hautes-Pyrénées'),
    array(250, 'FR-66', 'Pyrénées-Orientales'),
    array(250, 'FR-67', 'Bas-Rhin'),
    array(250, 'FR-68', 'Haut-Rhin'),
    array(250, 'FR-69', 'Rhône'),
    array(250, 'FR-70', 'Haute-Saône'),
    array(250, 'FR-71', 'Saône-et-Loire'),
    array(250, 'FR-72', 'Sarthe'),
    array(250, 'FR-73', 'Savoie'),
    array(250, 'FR-74', 'Haute-Savoie'),
    array(250, 'FR-75', 'Paris'),
    array(250, 'FR-76', 'Seine-Maritime'),
    array(250, 'FR-77', 'Seine-et-Marne'),
    array(250, 'FR-78', 'Yvelines'),
    array(250, 'FR-79', 'Deux-Sèvres'),
    array(250, 'FR-80', 'Somme'),
    array(250, 'FR-81', 'Tarn'),
    array(250, 'FR-82', 'Tarn-et-Garonne'),
    array(250, 'FR-83', 'Var'),
    array(250, 'FR-84', 'Vaucluse'),
    array(250, 'FR-85', 'Vendée'),
    array(250, 'FR-86', 'Vienne'),
    array(250, 'FR-87', 'Haute-Vienne'),
    array(250, 'FR-88', 'Vosges'),
    array(250, 'FR-89', 'Yonne'),
    array(250, 'FR-90', 'Territoire de Belfort'),
    array(250, 'FR-91', 'Essonne'),
    array(250, 'FR-92', 'Hauts-de-Seine'),
    array(250, 'FR-93', 'Seine-Saint-Denis'),
    array(250, 'FR-94', 'Val-de-Marne'),
    array(250, 'FR-95', "Val-d'Oise"),
    array(250, 'FR-NC', 'New Caledonia'),
    array(250, 'FR-PF', 'French Polynesia'),
    array(250, 'FR-PM', 'Saint-Pierre and Miquelon'),
    array(250, 'FR-TF', 'French Southern Territories'),
    array(250, 'FR-YT', 'Mayotte'),
    array(250, 'FR-WF', 'Wallis and Futuna'),
  );

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