<?php
// $Id: belgium_56_3.cif,v 1.1.2.5 2010-04-14 05:18:19 tr Exp $

function belgium_install() {
  db_query("INSERT INTO {uc_countries} (country_id, country_name, country_iso_code_2, country_iso_code_3, version) VALUES (56, 'Belgium', 'BE', 'BEL', 3)");

  // Make the entries in the zones table.
  $zones = array(
    array(56, 'VWV', 'West-Vlaanderen'),
    array(56, 'VOV', 'Oost-Vlaanderen'),
    array(56, 'VAN', 'Antwerpen'),
    array(56, 'VLI', 'Limburg'),
    array(56, 'VBR', 'Vlaams-Brabant'),
    array(56, 'BRU', 'Brussel/Bruxelles'),
    array(56, 'WBW', 'Brabant-Wallon'),
    array(56, 'WLG', 'Liège'),
    array(56, 'WHT', 'Hainaut'),
    array(56, 'WNA', 'Namur'),
    array(56, 'WLX', 'Luxembourg'),
  );

  foreach ($zones as $zone) {
    db_query("INSERT INTO {uc_zones} (zone_country_id, zone_code, zone_name) VALUES (%d, '%s', '%s')", $zone);
  }

  uc_set_address_format(56, "!company\n!first_name !last_name\n!street1\n!street2\n!postal_code !city\n!country_name_if");
}

function belgium_update($version) {
  switch ($version) {
    case '2':
      // Update existing zone codes and names.
      db_query("UPDATE {uc_zones} SET zone_code = 'VWV' WHERE zone_code = 'WV' AND zone_country_id = 56");
      db_query("UPDATE {uc_zones} SET zone_code = 'VOV' WHERE zone_code = 'OV' AND zone_country_id = 56");
      db_query("UPDATE {uc_zones} SET zone_code = 'VAN' WHERE zone_code = 'AN' AND zone_country_id = 56");
      db_query("UPDATE {uc_zones} SET zone_code = 'VLI' WHERE zone_code = 'LG' AND zone_country_id = 56");
      db_query("UPDATE {uc_zones} SET zone_code = 'VBR' WHERE zone_code = 'VB' AND zone_country_id = 56");
      db_query("UPDATE {uc_zones} SET zone_name = 'Brabant-Wallon', zone_code = 'WBR' WHERE zone_code = 'BW' AND zone_country_id = 56");
      db_query("UPDATE {uc_zones} SET zone_name = 'Liège', zone_code = 'WLG' WHERE zone_code = 'LB' AND zone_country_id = 56");
      db_query("UPDATE {uc_zones} SET zone_name = 'Hainaut', zone_code = 'WHT' WHERE zone_code = 'HT' AND zone_country_id = 56");
      db_query("UPDATE {uc_zones} SET zone_name = 'Namur', zone_code = 'WNA' WHERE zone_code = 'NM' AND zone_country_id = 56");
      db_query("UPDATE {uc_zones} SET zone_name = 'Luxembourg', zone_code = 'WLX' WHERE zone_code = 'LU' AND zone_country_id = 56");

      // Insert Brussels.
      db_query("INSERT INTO {uc_zones} (zone_country_id, zone_code, zone_name) VALUES (056, 'BRU', 'Brussel/Bruxelles')");

      break;
  }
}
