<?php

function madagascar_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' => 450,
      'country_name' => 'Madagascar',
      'country_iso_code_2' => 'MG',
      'country_iso_code_3' => 'MDG',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(450, 'MG-T', 'Antananarivo'),
    array(450, 'MG-D', 'Antsiranana'),
    array(450, 'MG-F', 'Fianarantsoa'),
    array(450, 'MG-M', 'Mahajanga'),
    array(450, 'MG-A', 'Toamasina'),
    array(450, 'MG-U', 'Toliara'),
  );

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