<?php
// $Id: philippines_608_2.cif,v 1.3.2.1 2010-11-02 06:42:17 tr Exp $

/*
  Comments / Notes:

  [Fri Mar 30 17:51:34 PHT 2007 @452 /Internet Time/ sarah]

  Country ID numbers based on ISO 3166-1 (http://en.wikipedia.org/wiki/ISO_3166-1_numeric)
  2-letter country code based on ISO 2-Alpha (http://www.unc.edu/~rowlett/units/codes/country.htm)
  3-letter country code based on ISO 3-Alpha (http://www.unc.edu/~rowlett/units/codes/country.htm)

  - the province list and zone codes are based on ISO 3166-2:PH (from: http://en.wikipedia.org/wiki/ISO_3166-2:PH)
  - the list was last updated in 2002. since then, there have been 2 provinces added.

  - im adding the new provinces -- dinagat island & shariff kabunsuan. since they dont have geocodes yet,
  im improvising the codes, until the ISO list has been updated.
  - also, i added metro manila to the list of provinces.because the people who do live in metro manila
  aren't classified under any of the provinces on the list. improvised the code also.
  - total zones = 82

  - version numbers are incremented by 1 with every update of this file

  [Fri Apr 13 14:02:42 PHT 2007 @293 /Internet Time/ sarah]
  - updated entries in the zones table, to use %d, instead of NULL for the zoneID
  - updated function comments, copied from http://www.ubercart.org/ubercart_developers_guide/country_import_file_structure
*/

function philippines_install() {

  // Make the entry in the country table.
  // VALUES = Country ID, Country Name, 2-digit Code, 3-digit Code, File Version
  db_query("INSERT INTO {uc_countries} VALUES ('608', 'Philippines', 'PH', 'PHL', 2)");

  // Make the entries in the zones table.  Use %d for the zone_id and the
  // function uc_get_zone_ids($num) as the second argument for db_query() where
  // $num is the number of zones in the INSERT query.
  // VALUES = %d for ID, Parent Country ID, Zone Abbreviation, Zone Name
  db_query("INSERT INTO {uc_zones} VALUES "
           . "(%d,608,'ABR','Abra'),"
           . "(%d,608,'ANO','Agusan del Norte'),"
           . "(%d,608,'ASU','Agusan del Sur'),"
           . "(%d,608,'AKL','Aklan'),"
           . "(%d,608,'ALB','Albay'),"
           . "(%d,608,'ANT','Antique'),"
           . "(%d,608,'APY','Apayao'),"
           . "(%d,608,'AUR','Aurora'),"
           . "(%d,608,'BAS','Basilan'),"
           . "(%d,608,'BTA','Bataan'),"
           . "(%d,608,'BTE','Batanes'),"
           . "(%d,608,'BTG','Batangas'),"
           . "(%d,608,'BEN','Benguet'),"
           . "(%d,608,'BLR','Biliran'),"
           . "(%d,608,'BOL','Bohol'),"
           . "(%d,608,'BUK','Bukidnon'),"
           . "(%d,608,'BUL','Bulacan'),"
           . "(%d,608,'CAG','Cagayan'),"
           . "(%d,608,'CNO','Camarines Norte'),"
           . "(%d,608,'CSU','Camarines Sur'),"
           . "(%d,608,'CAM','Camiguin'),"
           . "(%d,608,'CAP','Capiz'),"
           . "(%d,608,'CAT','Catanduanes'),"
           . "(%d,608,'CAV','Cavite'),"
           . "(%d,608,'CEB','Cebu'),"
           . "(%d,608,'CMP','Compostela Valley'),"
           . "(%d,608,'DNO','Davao del Norte'),"
           . "(%d,608,'DSU','Davao del Sur'),"
           . "(%d,608,'DOR','Davao Oriental'),"
           . "(%d,608,'DGI','Dinagat Islands'),"
           . "(%d,608,'ESA','Eastern Samar'),"
           . "(%d,608,'GUI','Guimaras'),"
           . "(%d,608,'IFU','Ifugao'),"
           . "(%d,608,'INO','Ilocos Norte'),"
           . "(%d,608,'ISU','Ilocos Sur'),"
           . "(%d,608,'ILO','Iloilo'),"
           . "(%d,608,'ISA','Isabela'),"
           . "(%d,608,'KAL','Kalinga'),"
           . "(%d,608,'LAG','Laguna'),"
           . "(%d,608,'LNO','Lanao del Norte'),"
           . "(%d,608,'LSU','Lanao del Sur'),"
           . "(%d,608,'UNI','La Union'),"
           . "(%d,608,'LEY','Leyte'),"
           . "(%d,608,'MAG','Maguindanao'),"
           . "(%d,608,'MRN','Marinduque'),"
           . "(%d,608,'MSB','Masbate'),"
           . "(%d,608,'MLA','Metro Manila'),"
           . "(%d,608,'MIC','Mindoro Occidental'),"
           . "(%d,608,'MIR','Mindoro Oriental'),"
           . "(%d,608,'MSC','Misamis Occidental'),"
           . "(%d,608,'MOR','Misamis Oriental'),"
           . "(%d,608,'MOP','Mountain Province'),"
           . "(%d,608,'NOC','Negros Occidental'),"
           . "(%d,608,'NOR','Negros Oriental'),"
           . "(%d,608,'NCT','North Cotabato'),"
           . "(%d,608,'NSM','Northern Samar'),"
           . "(%d,608,'NEC','Nueva Ecija'),"
           . "(%d,608,'NVZ','Nueva Vizcaya'),"
           . "(%d,608,'PLW','Palawan'),"
           . "(%d,608,'PMP','Pampanga'),"
           . "(%d,608,'PNG','Pangasinan'),"
           . "(%d,608,'QZN','Quezon'),"
           . "(%d,608,'QRN','Quirino'),"
           . "(%d,608,'RIZ','Rizal'),"
           . "(%d,608,'ROM','Romblon'),"
           . "(%d,608,'SMR','Samar'),"
           . "(%d,608,'SRG','Sarangani'),"
           . "(%d,608,'SHK','Shariff Kabunsuan'),"
           . "(%d,608,'SQJ','Siquijor'),"
           . "(%d,608,'SRS','Sorsogon'),"
           . "(%d,608,'SCO','South Cotabato'),"
           . "(%d,608,'SLE','Southern Leyte'),"
           . "(%d,608,'SKU','Sultan Kudarat'),"
           . "(%d,608,'SLU','Sulu'),"
           . "(%d,608,'SNO','Surigao del Norte'),"
           . "(%d,608,'SSU','Surigao del Sur'),"
           . "(%d,608,'TAR','Tarlac'),"
           . "(%d,608,'TAW','Tawi-Tawi'),"
           . "(%d,608,'ZBL','Zambales'),"
           . "(%d,608,'ZNO','Zamboanga del Norte'),"
           . "(%d,608,'ZSU','Zamboanga del Sur'),"
           . "(%d,608,'ZSI','Zamboanga Sibugay')",
           uc_get_zone_ids(82));

  // Use uc_set_address_format() with the country ID as the first argument and
  // an address format string as the second.  Documentation on address formats
  // is available at:
  // http://www.ubercart.org/ubercart_users_guide/country_settings#address_format_docs
  uc_set_address_format(608, "!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");
}

/**
 * If necessary, implement hook_update() with $version being the only argument.
 * Add a new case for each version update, and be sure to always include the
 * latest changes in the install function.
*/
function example_country_update($version) {
  // Use a switch control block for easy file maintenance.
  switch ($version) {
    case 2:
      // Obviously this would be replaced with actual update code.
      drupal_set_message('Performing update 2.');
      break;
  }
}
