tanzania_834_2.cif 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Implements hook_install() using the name of the country as the base of
  4. * the function name.
  5. */
  6. function tanzania_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' => 834,
  12. 'country_name' => 'Tanzania, United Republic of',
  13. 'country_iso_code_2' => 'TZ',
  14. 'country_iso_code_3' => 'TZA',
  15. 'version' => 2,
  16. ))
  17. ->execute();
  18. // Make the entries in the zones table.
  19. $zones = array(
  20. array(834, '01', 'Arusha'),
  21. array(834, '19', 'Coast'),
  22. array(834, '02', 'Dar es Salaam'),
  23. array(834, '03', 'Dodoma'),
  24. array(834, '04', 'Iringa'),
  25. array(834, '05', 'Kagera'),
  26. array(834, '06', 'Kaskazini Pemba'),
  27. array(834, '07', 'Kaskazini Unguja'),
  28. array(834, '08', 'Kigoma'),
  29. array(834, '09', 'Kilimanjaro'),
  30. array(834, '10', 'Kusini Pemba'),
  31. array(834, '11', 'Kusini Unguja'),
  32. array(834, '12', 'Lindi'),
  33. array(834, '26', 'Manyara'),
  34. array(834, '13', 'Mara'),
  35. array(834, '14', 'Mbeya'),
  36. array(834, '15', 'Mjini Mgharibi'),
  37. array(834, '16', 'Morogoro'),
  38. array(834, '17', 'Mtwara'),
  39. array(834, '18', 'Mwanza'),
  40. array(834, '06', 'Pemba North'),
  41. array(834, '10', 'Pemba South'),
  42. array(834, '19', 'Pwani'),
  43. array(834, '20', 'Rukwa'),
  44. array(834, '21', 'Ruvuma'),
  45. array(834, '22', 'Shinyanga'),
  46. array(834, '23', 'Singida'),
  47. array(834, '24', 'Tabora'),
  48. array(834, '25', 'Tanga'),
  49. array(834, '07', 'Zanzibar North'),
  50. array(834, '11', 'Zanzibar South'),
  51. array(834, '15', 'Zanzibar West'),
  52. );
  53. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  54. foreach ($zones as $zone) {
  55. $query->values($zone);
  56. }
  57. $query->execute();
  58. // Set address format
  59. uc_set_address_format(
  60. 834,
  61. "!company\r\n" .
  62. "!first_name !last_name\r\n" .
  63. "!street1\r\n" .
  64. "!street2\r\n" .
  65. "!city !zone_code !postal_code\r\n" .
  66. "!country_name_if"
  67. );
  68. }
  69. /**
  70. * Implements hook_update() with $version being the only argument.
  71. * Add a new case for each version update, and be sure to always include the
  72. * latest changes in the install function.
  73. */
  74. function tanzania_update($version) {
  75. switch ($version) {
  76. case 2:
  77. // Correct ISO-3166-1 country name
  78. db_update('uc_countries')
  79. ->fields(array('country_name' => 'Tanzania, United Republic of'))
  80. ->condition('country_id', 834)
  81. ->execute();
  82. break;
  83. }
  84. }