<?php

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} (country_id, country_name, country_iso_code_2, country_iso_code_3, version) 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");
}
