Source for file gTaxTable.php

Documentation is available at gTaxTable.php

  1. <?php
  2.  
  3. /**
  4. * ========================================================
  5. * phpGCheckout, Open Source PHP G Checkout Library
  6. * http://www.phpgcheckout.com
  7. * ========================================================
  8. *
  9. * Copyright (c) 2006 Expert Database Solutions, LLC
  10. *
  11. * Permission is hereby granted, free of charge, to any person obtaining a
  12. * copy of this software and associated documentation files (the "Software"),
  13. * to deal in the Software without restriction, including without limitation the
  14. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15. * copies of the Software, and to permit persons to whom the Software is
  16. * furnished to do so, subject to the following conditions:
  17. *
  18. * The above copyright notice and this permission notice shall be included in all
  19. * copies or substantial portions of the Software.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  22. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  23. * PARTICULAR PURPOSE AND NONINFRINGEMENT.
  24. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  25. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
  26. * OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. *
  28. */
  29.  
  30. /**
  31. * Google Checkout Tax Table Primitive
  32. *
  33. *
  34. * This class is the abstraction of a Google Checkout Tax Table object.
  35. *
  36. * @author Ron Howard
  37. * @copyright Expert Database Solutions, LLC 2006
  38. *
  39. */
  40. class gTaxTable {
  41. var $_arr_tax_rules;
  42. var $_type;
  43. var $_name;
  44. var $_standalone;
  45. /**
  46. * Default Constructor
  47. *
  48. * @param unknown_type $rate
  49. * @param unknown_type $country_area
  50. * @param unknown_type $arr_states
  51. * @param unknown_type $arr_zips
  52. * @param unknown_type $type
  53. * @return gTaxTable
  54. */
  55. function gTaxTable($name, $arr_tax_rules, $type = 'alternate', $standalone = 'false') {
  56. $this->_arr_tax_rules = $arr_tax_rules;
  57. $this->_name = $name;
  58. $this->_standalone = $standalone;
  59. $this->_type = $type;
  60. }
  61. /**
  62. * Returns the XML representation of the Tax Table.
  63. *
  64. * @return XML Representation of Tax Table.
  65. * @access public.
  66. *
  67. */
  68. function getXML() {
  69. $str_xml = " <$this->_type-tax-table ";
  70. if($this->_type == 'alternate')
  71. $str_xml .= " standalone=\"$this->_standalone\" name=\"$this->_name\" ";
  72.  
  73. $str_xml .= ">";
  74. if(!empty($this->_arr_tax_rules)){
  75. /**
  76. * Omit if default type
  77. */
  78. if($this->_type != 'default')
  79. $str_xml .= "<$this->_type-tax-rules>";
  80. else
  81. $str_xml .= "<tax-rules>";
  82. /**
  83. * For each tax rule
  84. */
  85. foreach ($this->_arr_tax_rules as $tax_rule){
  86. $tax_rule->_type = $this->_type; //Tax Rule must be the same type as the table
  87. $str_xml .= $tax_rule->getXML(); //Add tax rule xml to the string.
  88. /**
  89. * If the table is default tax table we can only have one default
  90. * tax rule. Break after first.
  91. */
  92. if($this->_type == 'default')
  93. break;
  94. }
  95. /**
  96. * Omit if default type
  97. */
  98. if($this->_type != 'default')
  99. $str_xml .= "</$this->_type-tax-rules>";
  100. else
  101. $str_xml .= "</tax-rules>";
  102. }
  103. $str_xml .= "</$this->_type-tax-table>";
  104. return $str_xml;
  105. }
  106. }
  107. ?>

Documentation generated on Mon, 04 Dec 2006 11:09:41 -0500 by phpDocumentor 1.3.0RC3