<?php
// $Id: philippines_608_2.cif,v 1.3.4.2 2009/07/21 14:51:20 islandusurper 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.
  $zones = array(
    array(608,'ABR','Abra'),
    array(608,'ANO','Agusan del Norte'),
    array(608,'ASU','Agusan del Sur'),
    array(608,'AKL','Aklan'),
    array(608,'ALB','Albay'),
    array(608,'ANT','Antique'),
    array(608,'APY','Apayao'),
    array(608,'AUR','Aurora'),
    array(608,'BAS','Basilan'),
    array(608,'BTA','Bataan'),
    array(608,'BTE','Batanes'),
    array(608,'BTG','Batangas'),
    array(608,'BEN','Benguet'),
    array(608,'BLR','Biliran'),
    array(608,'BOL','Bohol'),
    array(608,'BUK','Bukidnon'),
    array(608,'BUL','Bulacan'),
    array(608,'CAG','Cagayan'),
    array(608,'CNO','Camarines Norte'),
    array(608,'CSU','Camarines Sur'),
    array(608,'CAM','Camiguin'),
    array(608,'CAP','Capiz'),
    array(608,'CAT','Catanduanes'),
    array(608,'CAV','Cavite'),
    array(608,'CEB','Cebu'),
    array(608,'CMP','Compostela Valley'),
    array(608,'DNO','Davao del Norte'),
    array(608,'DSU','Davao del Sur'),
    array(608,'DOR','Davao Oriental'),
    array(608,'DGI','Dinagat Islands'),
    array(608,'ESA','Eastern Samar'),
    array(608,'GUI','Guimaras'),
    array(608,'IFU','Ifugao'),
    array(608,'INO','Ilocos Norte'),
    array(608,'ISU','Ilocos Sur'),
    array(608,'ILO','Iloilo'),
    array(608,'ISA','Isabela'),
    array(608,'KAL','Kalinga'),
    array(608,'LAG','Laguna'),
    array(608,'LNO','Lanao del Norte'),
    array(608,'LSU','Lanao del Sur'),
    array(608,'UNI','La Union'),
    array(608,'LEY','Leyte'),
    array(608,'MAG','Maguindanao'),
    array(608,'MRN','Marinduque'),
    array(608,'MSB','Masbate'),
    array(608,'MLA','Metro Manila'),
    array(608,'MIC','Mindoro Occidental'),
    array(608,'MIR','Mindoro Oriental'),
    array(608,'MSC','Misamis Occidental'),
    array(608,'MOR','Misamis Oriental'),
    array(608,'MOP','Mountain Province'),
    array(608,'NOC','Negros Occidental'),
    array(608,'NOR','Negros Oriental'),
    array(608,'NCT','North Cotabato'),
    array(608,'NSM','Northern Samar'),
    array(608,'NEC','Nueva Ecija'),
    array(608,'NVZ','Nueva Vizcaya'),
    array(608,'PLW','Palawan'),
    array(608,'PMP','Pampanga'),
    array(608,'PNG','Pangasinan'),
    array(608,'QZN','Quezon'),
    array(608,'QRN','Quirino'),
    array(608,'RIZ','Rizal'),
    array(608,'ROM','Romblon'),
    array(608,'SMR','Samar'),
    array(608,'SRG','Sarangani'),
    array(608,'SHK','Shariff Kabunsuan'),
    array(608,'SQJ','Siquijor'),
    array(608,'SRS','Sorsogon'),
    array(608,'SCO','South Cotabato'),
    array(608,'SLE','Southern Leyte'),
    array(608,'SKU','Sultan Kudarat'),
    array(608,'SLU','Sulu'),
    array(608,'SNO','Surigao del Norte'),
    array(608,'SSU','Surigao del Sur'),
    array(608,'TAR','Tarlac'),
    array(608,'TAW','Tawi-Tawi'),
    array(608,'ZBL','Zambales'),
    array(608,'ZNO','Zamboanga del Norte'),
    array(608,'ZSU','Zamboanga del Sur'),
    array(608,'ZSI','Zamboanga Sibugay'),
  );

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

  // 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;
  }
}

/**
 * If necessary, implement hook_uninstall().  This requires no argument.  The
 * store module automatically removes rows from the country and zones tables
 * related to the country, and it unsets the address format.  This function is
 * only necessary for other things you may have included in your country's
 * installation process.
*/
function example_country_uninstall() {
}
