costa_rica_188_2.cif 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Implements hook_install() using the name of the country as the base of
  4. * the function name.
  5. */
  6. function costa_rica_install() {
  7. // Make the entry in the country table.
  8. // VALUES = Country ID, Country Name, 2-digit Code, 3-digit Code, File Version
  9. db_insert('uc_countries')
  10. ->fields(array(
  11. 'country_id' => 188,
  12. 'country_name' => 'Costa Rica',
  13. 'country_iso_code_2' => 'CR',
  14. 'country_iso_code_3' => 'CRI',
  15. 'version' => 2,
  16. ))
  17. ->execute();
  18. // Make the entries in the zones table.
  19. $zones = array(
  20. array(188, 'AL', 'Alajuela'),
  21. array(188, 'CA', 'Cartago'),
  22. array(188, 'GU', 'Guanacaste'),
  23. array(188, 'HE', 'Heredia'),
  24. array(188, 'LI', 'Limón'),
  25. array(188, 'PU', 'Puntarenas'),
  26. array(188, 'SJ', 'San José'),
  27. );
  28. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  29. foreach ($zones as $zone) {
  30. $query->values($zone);
  31. }
  32. $query->execute();
  33. // Set address format
  34. uc_set_address_format(
  35. 188,
  36. "!company\r\n".
  37. "!first_name !last_name\r\n".
  38. "!street1\r\n".
  39. "!street2\r\n".
  40. "!city !zone_code !postal_code\r\n".
  41. "!country_name_if"
  42. );
  43. }
  44. function costa_rica_update($version) {
  45. switch ($version) {
  46. case 2:
  47. // Correct ISO-3166-1 country name
  48. db_update('uc_countries')
  49. ->fields(array('country_iso_code_3' => 'CRI'))
  50. ->condition('country_id', 188)
  51. ->execute();
  52. break;
  53. }
  54. }