PageRenderTime 84ms CodeModel.GetById 34ms RepoModel.GetById 2ms app.codeStats 0ms

/drupal/sites/all/modules/civicrm/CRM/Price/DAO/LineItem.php

https://github.com/michaelmcandrew/lbc
PHP | 311 lines | 148 code | 0 blank | 163 comment | 10 complexity | 133cfd9b064fc8eca5672194f568f4b0 MD5 | raw file
  1. <?php
  2. /*
  3. +--------------------------------------------------------------------+
  4. | CiviCRM version 4.1 |
  5. +--------------------------------------------------------------------+
  6. | Copyright CiviCRM LLC (c) 2004-2011 |
  7. +--------------------------------------------------------------------+
  8. | This file is a part of CiviCRM. |
  9. | |
  10. | CiviCRM is free software; you can copy, modify, and distribute it |
  11. | under the terms of the GNU Affero General Public License |
  12. | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
  13. | |
  14. | CiviCRM is distributed in the hope that it will be useful, but |
  15. | WITHOUT ANY WARRANTY; without even the implied warranty of |
  16. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
  17. | See the GNU Affero General Public License for more details. |
  18. | |
  19. | You should have received a copy of the GNU Affero General Public |
  20. | License and the CiviCRM Licensing Exception along |
  21. | with this program; if not, contact CiviCRM LLC |
  22. | at info[AT]civicrm[DOT]org. If you have questions about the |
  23. | GNU Affero General Public License or the licensing of CiviCRM, |
  24. | see the CiviCRM license FAQ at http://civicrm.org/licensing |
  25. +--------------------------------------------------------------------+
  26. */
  27. /**
  28. *
  29. * @package CRM
  30. * @copyright CiviCRM LLC (c) 2004-2011
  31. * $Id$
  32. *
  33. */
  34. require_once 'CRM/Core/DAO.php';
  35. require_once 'CRM/Utils/Type.php';
  36. class CRM_Price_DAO_LineItem extends CRM_Core_DAO
  37. {
  38. /**
  39. * static instance to hold the table name
  40. *
  41. * @var string
  42. * @static
  43. */
  44. static $_tableName = 'civicrm_line_item';
  45. /**
  46. * static instance to hold the field values
  47. *
  48. * @var array
  49. * @static
  50. */
  51. static $_fields = null;
  52. /**
  53. * static instance to hold the FK relationships
  54. *
  55. * @var string
  56. * @static
  57. */
  58. static $_links = null;
  59. /**
  60. * static instance to hold the values that can
  61. * be imported
  62. *
  63. * @var array
  64. * @static
  65. */
  66. static $_import = null;
  67. /**
  68. * static instance to hold the values that can
  69. * be exported
  70. *
  71. * @var array
  72. * @static
  73. */
  74. static $_export = null;
  75. /**
  76. * static value to see if we should log any modifications to
  77. * this table in the civicrm_log table
  78. *
  79. * @var boolean
  80. * @static
  81. */
  82. static $_log = true;
  83. /**
  84. * Line Item
  85. *
  86. * @var int unsigned
  87. */
  88. public $id;
  89. /**
  90. * table which has the transaction
  91. *
  92. * @var string
  93. */
  94. public $entity_table;
  95. /**
  96. * entry in table
  97. *
  98. * @var int unsigned
  99. */
  100. public $entity_id;
  101. /**
  102. * FK to price_field
  103. *
  104. * @var int unsigned
  105. */
  106. public $price_field_id;
  107. /**
  108. * descriptive label for item - from custom_option.label
  109. *
  110. * @var string
  111. */
  112. public $label;
  113. /**
  114. * How many items ordered
  115. *
  116. * @var int unsigned
  117. */
  118. public $qty;
  119. /**
  120. * price of each item
  121. *
  122. * @var float
  123. */
  124. public $unit_price;
  125. /**
  126. * qty * unit_price
  127. *
  128. * @var float
  129. */
  130. public $line_total;
  131. /**
  132. * Participant count for field
  133. *
  134. * @var int unsigned
  135. */
  136. public $participant_count;
  137. /**
  138. * Implicit FK to civicrm_option_value
  139. *
  140. * @var int unsigned
  141. */
  142. public $price_field_value_id;
  143. /**
  144. * class constructor
  145. *
  146. * @access public
  147. * @return civicrm_line_item
  148. */
  149. function __construct()
  150. {
  151. parent::__construct();
  152. }
  153. /**
  154. * return foreign links
  155. *
  156. * @access public
  157. * @return array
  158. */
  159. function &links()
  160. {
  161. if (!(self::$_links)) {
  162. self::$_links = array(
  163. 'price_field_id' => 'civicrm_price_field:id',
  164. 'price_field_value_id' => 'civicrm_price_field_value:id',
  165. );
  166. }
  167. return self::$_links;
  168. }
  169. /**
  170. * returns all the column names of this table
  171. *
  172. * @access public
  173. * @return array
  174. */
  175. function &fields()
  176. {
  177. if (!(self::$_fields)) {
  178. self::$_fields = array(
  179. 'id' => array(
  180. 'name' => 'id',
  181. 'type' => CRM_Utils_Type::T_INT,
  182. 'required' => true,
  183. ) ,
  184. 'entity_table' => array(
  185. 'name' => 'entity_table',
  186. 'type' => CRM_Utils_Type::T_STRING,
  187. 'title' => ts('Entity Table') ,
  188. 'required' => true,
  189. 'maxlength' => 64,
  190. 'size' => CRM_Utils_Type::BIG,
  191. ) ,
  192. 'entity_id' => array(
  193. 'name' => 'entity_id',
  194. 'type' => CRM_Utils_Type::T_INT,
  195. 'required' => true,
  196. ) ,
  197. 'price_field_id' => array(
  198. 'name' => 'price_field_id',
  199. 'type' => CRM_Utils_Type::T_INT,
  200. 'required' => true,
  201. 'FKClassName' => 'CRM_Price_DAO_Field',
  202. ) ,
  203. 'label' => array(
  204. 'name' => 'label',
  205. 'type' => CRM_Utils_Type::T_STRING,
  206. 'title' => ts('Label') ,
  207. 'required' => true,
  208. 'maxlength' => 255,
  209. 'size' => CRM_Utils_Type::HUGE,
  210. ) ,
  211. 'qty' => array(
  212. 'name' => 'qty',
  213. 'type' => CRM_Utils_Type::T_INT,
  214. 'title' => ts('Qty') ,
  215. 'required' => true,
  216. ) ,
  217. 'unit_price' => array(
  218. 'name' => 'unit_price',
  219. 'type' => CRM_Utils_Type::T_MONEY,
  220. 'title' => ts('Unit Price') ,
  221. 'required' => true,
  222. ) ,
  223. 'line_total' => array(
  224. 'name' => 'line_total',
  225. 'type' => CRM_Utils_Type::T_MONEY,
  226. 'title' => ts('Line Total') ,
  227. 'required' => true,
  228. ) ,
  229. 'participant_count' => array(
  230. 'name' => 'participant_count',
  231. 'type' => CRM_Utils_Type::T_INT,
  232. 'title' => ts('Participant Count') ,
  233. 'default' => 'UL',
  234. ) ,
  235. 'price_field_value_id' => array(
  236. 'name' => 'price_field_value_id',
  237. 'type' => CRM_Utils_Type::T_INT,
  238. 'default' => 'UL',
  239. 'FKClassName' => 'CRM_Price_DAO_FieldValue',
  240. ) ,
  241. );
  242. }
  243. return self::$_fields;
  244. }
  245. /**
  246. * returns the names of this table
  247. *
  248. * @access public
  249. * @return string
  250. */
  251. function getTableName()
  252. {
  253. return self::$_tableName;
  254. }
  255. /**
  256. * returns if this table needs to be logged
  257. *
  258. * @access public
  259. * @return boolean
  260. */
  261. function getLog()
  262. {
  263. return self::$_log;
  264. }
  265. /**
  266. * returns the list of fields that can be imported
  267. *
  268. * @access public
  269. * return array
  270. */
  271. function &import($prefix = false)
  272. {
  273. if (!(self::$_import)) {
  274. self::$_import = array();
  275. $fields = self::fields();
  276. foreach($fields as $name => $field) {
  277. if (CRM_Utils_Array::value('import', $field)) {
  278. if ($prefix) {
  279. self::$_import['line_item'] = & $fields[$name];
  280. } else {
  281. self::$_import[$name] = & $fields[$name];
  282. }
  283. }
  284. }
  285. }
  286. return self::$_import;
  287. }
  288. /**
  289. * returns the list of fields that can be exported
  290. *
  291. * @access public
  292. * return array
  293. */
  294. function &export($prefix = false)
  295. {
  296. if (!(self::$_export)) {
  297. self::$_export = array();
  298. $fields = self::fields();
  299. foreach($fields as $name => $field) {
  300. if (CRM_Utils_Array::value('export', $field)) {
  301. if ($prefix) {
  302. self::$_export['line_item'] = & $fields[$name];
  303. } else {
  304. self::$_export[$name] = & $fields[$name];
  305. }
  306. }
  307. }
  308. }
  309. return self::$_export;
  310. }
  311. }