<?php

function cape_verde_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' => 132,
      'country_name' => 'Cape Verde',
      'country_iso_code_2' => 'CV',
      'country_iso_code_3' => 'CPV',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(132, 'BV', 'Boa Vista'),
    array(132, 'BR', 'Brava'),
    array(132, 'MA', 'Maio'),
    array(132, 'MO', 'Mosteiros'),
    array(132, 'PA', 'Paul'),
    array(132, 'PN', 'Porto Novo'),
    array(132, 'PR', 'Praia'),
    array(132, 'SN', 'Ribeira Brava'),
    array(132, 'RG', 'Ribeira Grande'),
    array(132, 'PR', 'Ribeira Grande de Santiago'),
    array(132, 'SL', 'Sal'),
    array(132, 'CA', 'Santa Catarina'),
    array(132, 'SF', 'Santa Catarina do Fogo'),
    array(132, 'CR', 'Santa Cruz'),
    array(132, 'SD', 'Sao Domingos'),
    array(132, 'SF', 'Sao Filipe'),
    array(132, 'CR', 'Sao Lourenço dos Orgaos'),
    array(132, 'CS', 'Sao Miguel'),
    array(132, 'CA', 'Sao Salvador do Mundo'),
    array(132, 'SV', 'Sao Vicente'),
    array(132, 'TA', 'Tarrafal'),
    array(132, 'TS', 'Tarrafal de Sao Nicolau'),
  );

  $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(
    132,
    "!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"
  );
}
