<?php

function malawi_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' => 454,
      'country_name' => 'Malawi',
      'country_iso_code_2' => 'MW',
      'country_iso_code_3' => 'MWI',
      'version' => 1,
    ))
    ->execute();

  // Make the entries in the zones table.
  $zones = array(
    array(454, 'MW-BA', 'Balaka'),
    array(454, 'MW-BL', 'Blantyre'),
    array(454, 'MW-CK', 'Chikwawa'),
    array(454, 'MW-CR', 'Chiradzulu'),
    array(454, 'MW-CT', 'Chitipa'),
    array(454, 'MW-DE', 'Dedza'),
    array(454, 'MW-DO', 'Dowa'),
    array(454, 'MW-KR', 'Karonga'),
    array(454, 'MW-KS', 'Kasungu'),
    array(454, 'MW-LK', 'Likoma'),
    array(454, 'MW-LI', 'Lilongwe'),
    array(454, 'MW-MH', 'Machinga'),
    array(454, 'MW-MG', 'Mangochi'),
    array(454, 'MW-MC', 'Mchinji'),
    array(454, 'MW-MU', 'Mulanje'),
    array(454, 'MW-MW', 'Mwanza'),
    array(454, 'MW-MZ', 'Mzimba'),
    array(454, 'MW-NE', 'Neno'),
    array(454, 'MW-NB', 'Nkhata Bay'),
    array(454, 'MW-NK', 'Nkhotakota'),
    array(454, 'MW-NS', 'Nsanje'),
    array(454, 'MW-NU', 'Ntcheu'),
    array(454, 'MW-NI', 'Ntchisi'),
    array(454, 'MW-PH', 'Phalombe'),
    array(454, 'MW-RU', 'Rumphi'),
    array(454, 'MW-SA', 'Salima'),
    array(454, 'MW-TH', 'Thyolo'),
    array(454, 'MW-ZO', 'Zomba'),
  );

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