bosnia_herzegovina_70_2.cif 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Implements hook_install() using the name of the country as the base of
  4. * the function name.
  5. */
  6. function bosnia_herzegovina_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' => 70,
  12. 'country_name' => 'Bosnia and Herzegovina',
  13. 'country_iso_code_2' => 'BA',
  14. 'country_iso_code_3' => 'BIH',
  15. 'version' => 2,
  16. ))
  17. ->execute();
  18. // Make the entries in the zones table.
  19. $zones = array(
  20. array(70, 'BIH', 'Federacija Bosna i Hercegovina'),
  21. array(70, 'SRP', 'Republika Srpska'),
  22. array(70, '05', 'Bosansko-Podrinjski Kanton'),
  23. array(70, '10', 'Hercegovacko-Bosanski Kanton'),
  24. array(70, '07', 'Hercegovacko-Neretvanski Kanton'),
  25. array(70, '09', 'Kanton Sarajevo'),
  26. array(70, '02', 'Posavski Kanton'),
  27. array(70, '06', 'Srednjobosanski Kanton'),
  28. array(70, '03', 'Tuzlanski Kanton'),
  29. array(70, '01', 'Unsko-Sanski Kanton'),
  30. array(70, '08', 'Zapadno-Hercegovacki Kanton'),
  31. array(70, '04', 'Zenicko-Dobojski Kanton'),
  32. );
  33. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  34. foreach ($zones as $zone) {
  35. $query->values($zone);
  36. }
  37. $query->execute();
  38. // Set address format
  39. uc_set_address_format(
  40. 70,
  41. "!company\r\n" .
  42. "!first_name !last_name\r\n" .
  43. "!street1\r\n" .
  44. "!street2\r\n" .
  45. "!city !zone_code !postal_code\r\n" .
  46. "!country_name_if"
  47. );
  48. }
  49. /**
  50. * Implements hook_update() with $version being the only argument.
  51. * Add a new case for each version update, and be sure to always include the
  52. * latest changes in the install function.
  53. */
  54. function bosnia_herzegovina_update($version) {
  55. switch ($version) {
  56. case 2:
  57. // Correct ISO-3166-1 country name
  58. db_update('uc_countries')
  59. ->fields(array('country_name' => 'Bosnia and Herzegovina'))
  60. ->condition('country_id', 70)
  61. ->execute();
  62. break;
  63. }
  64. }