PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/tine20/Sales/Model/Supplier.php

https://github.com/corneliusweiss/Tine-2.0-Open-Source-Groupware-and-CRM
PHP | 262 lines | 206 code | 9 blank | 47 comment | 0 complexity | 8d727c11fabe99969b9170bb8138a53e MD5 | raw file
  1. <?php
  2. /**
  3. * Tine 2.0
  4. * @package Sales
  5. * @subpackage Model
  6. * @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
  7. * @author Alexander Stintzing <a.stintzing@metaways.de>
  8. * @copyright Copyright (c) 2013 Metaways Infosystems GmbH (http://www.metaways.de)
  9. */
  10. /**
  11. * class to hold Supplier data
  12. *
  13. * @package Sales
  14. * @subpackage Model
  15. */
  16. class Sales_Model_Supplier extends Tinebase_Record_Abstract
  17. {
  18. /**
  19. * holds the configuration object (must be declared in the concrete class)
  20. *
  21. * @var Tinebase_ModelConfiguration
  22. */
  23. protected static $_configurationObject = NULL;
  24. /**
  25. * Holds the model configuration (must be assigned in the concrete class)
  26. *
  27. * @var array
  28. */
  29. protected static $_modelConfiguration = array(
  30. 'recordName' => 'Supplier',
  31. 'recordsName' => 'Suppliers', // ngettext('Supplier', 'Suppliers', n)
  32. 'hasRelations' => TRUE,
  33. 'hasCustomFields' => TRUE,
  34. 'hasNotes' => TRUE,
  35. 'hasTags' => TRUE,
  36. 'modlogActive' => TRUE,
  37. 'hasAttachments' => TRUE,
  38. 'createModule' => TRUE,
  39. 'containerProperty' => NULL,
  40. 'resolveVFGlobally' => TRUE,
  41. 'titleProperty' => 'fulltext',
  42. 'appName' => 'Sales',
  43. 'modelName' => 'Supplier',
  44. 'fieldGroups' => array(
  45. 'core' => 'Core Data', // _('Core Data')
  46. 'accounting' => 'Accounting', // _('Accounting')
  47. 'misc' => 'Miscellaneous', // _('Miscellaneous')
  48. ),
  49. 'defaultSortInfo' => ['field' => 'number', 'direction' => 'DESC'],
  50. 'fields' => array(
  51. 'number' => array(
  52. 'label' => 'Supplier Number', //_('Supplier Number')
  53. 'group' => 'core',
  54. 'queryFilter' => TRUE,
  55. 'type' => 'integer'
  56. ),
  57. 'name' => array(
  58. 'label' => 'Name', // _('Name')
  59. 'type' => 'text',
  60. 'duplicateCheckGroup' => 'name',
  61. 'group' => 'core',
  62. 'queryFilter' => TRUE,
  63. ),
  64. 'url' => array(
  65. 'label' => 'Web', // _('Web')
  66. 'type' => 'text',
  67. 'group' => 'misc',
  68. 'shy' => TRUE
  69. ),
  70. 'description' => array(
  71. 'label' => 'Description', // _('Description')
  72. 'group' => 'core',
  73. 'type' => 'fulltext',
  74. 'queryFilter' => TRUE,
  75. 'shy' => TRUE
  76. ),
  77. 'cpextern_id' => array(
  78. 'label' => 'Contact Person (external)', // _('Contact Person (external)')
  79. 'validators' => array(Zend_Filter_Input::ALLOW_EMPTY => TRUE),
  80. 'type' => 'record',
  81. 'group' => 'core',
  82. 'config' => array(
  83. 'appName' => 'Addressbook',
  84. 'modelName' => 'Contact',
  85. 'idProperty' => 'id',
  86. )
  87. ),
  88. 'cpintern_id' => array(
  89. 'label' => 'Contact Person (internal)', // _('Contact Person (internal)')
  90. 'validators' => array(Zend_Filter_Input::ALLOW_EMPTY => TRUE),
  91. 'type' => 'record',
  92. 'group' => 'core',
  93. 'config' => array(
  94. 'appName' => 'Addressbook',
  95. 'modelName' => 'Contact',
  96. 'idProperty' => 'id',
  97. )
  98. ),
  99. 'vatid' => array (
  100. 'label' => 'VAT No.', // _('VAT No.')
  101. 'type' => 'text',
  102. 'group' => 'accounting',
  103. 'shy' => TRUE
  104. ),
  105. 'credit_term' => array (
  106. 'label' => 'Credit Term (days)', // _('Credit Term (days)')
  107. 'type' => 'integer',
  108. 'group' => 'accounting',
  109. 'default' => 10,
  110. 'shy' => TRUE
  111. ),
  112. 'currency' => array (
  113. 'label' => 'Currency', // _('Currency')
  114. 'type' => 'text',
  115. 'group' => 'accounting'
  116. ),
  117. 'currency_trans_rate' => array (
  118. 'label' => 'Currency Translation Rate', // _('Currency Translation Rate')
  119. 'type' => 'float',
  120. 'group' => 'accounting',
  121. 'default' => 1,
  122. 'shy' => TRUE
  123. ),
  124. 'iban' => array (
  125. 'label' => 'IBAN',
  126. 'group' => 'accounting',
  127. 'shy' => TRUE
  128. ),
  129. 'bic' => array (
  130. 'label' => 'BIC',
  131. 'group' => 'accounting',
  132. 'shy' => TRUE
  133. ),
  134. #'discount' => array(
  135. # 'label' => 'Discount (%)', // _('Discount (%)')
  136. # 'type' => 'float',
  137. # 'specialType' => 'percent',
  138. # 'default' => 0,
  139. # //'inputFilters' => array('Zend_Filter_Empty' => 0),
  140. # //'shy' => TRUE,
  141. #),
  142. // the postal address
  143. 'postal_id' => array(
  144. 'type' => 'virtual',
  145. 'config' => array(
  146. 'duplicateOmit' => TRUE,
  147. 'label' => NULL,
  148. )
  149. ),
  150. 'adr_prefix1' => array(
  151. 'config' => array(
  152. 'duplicateOmit' => TRUE,
  153. 'label' => 'Prefix', //_('Prefix')
  154. 'shy' => TRUE
  155. ),
  156. 'type' => 'virtual',
  157. ),
  158. 'adr_prefix2' => array(
  159. 'config' => array(
  160. 'duplicateOmit' => TRUE,
  161. 'label' => 'Additional Prefix', //_('Additional Prefix')
  162. 'shy' => TRUE
  163. ),
  164. 'type' => 'virtual',
  165. ),
  166. 'adr_street' => array(
  167. 'config' => array(
  168. 'duplicateOmit' => TRUE,
  169. 'label' => 'Street', //_('Street')
  170. 'shy' => TRUE
  171. ),
  172. 'type' => 'virtual',
  173. ),
  174. 'adr_postalcode' => array(
  175. 'type' => 'virtual',
  176. 'config' => array(
  177. 'duplicateOmit' => TRUE,
  178. 'label' => 'Postalcode', //_('Postalcode')
  179. 'shy' => TRUE
  180. ),
  181. ),
  182. 'adr_locality' => array(
  183. 'type' => 'virtual',
  184. 'config' => array(
  185. 'duplicateOmit' => TRUE,
  186. 'label' => 'Locality', //_('Locality')
  187. 'shy' => TRUE
  188. ),
  189. ),
  190. 'adr_region' => array(
  191. 'type' => 'virtual',
  192. 'config' => array(
  193. 'duplicateOmit' => TRUE,
  194. 'label' => 'Region', //_('Region')
  195. 'shy' => TRUE
  196. ),
  197. ),
  198. 'adr_countryname' => array(
  199. 'type' => 'virtual',
  200. 'config' => array(
  201. 'duplicateOmit' => TRUE,
  202. 'label' => 'Country', //_('Country')
  203. 'shy' => TRUE,
  204. 'default' => 'DE'
  205. ),
  206. ),
  207. 'adr_pobox' => array(
  208. 'type' => 'virtual',
  209. 'config' => array(
  210. 'duplicateOmit' => TRUE,
  211. 'label' => 'Postbox', //_('Postbox')
  212. 'shy' => TRUE
  213. ),
  214. ),
  215. 'fulltext' => array(
  216. 'type' => 'virtual',
  217. 'config' => array(
  218. 'type' => 'string',
  219. 'sortable' => false
  220. )
  221. ),
  222. )
  223. );
  224. /**
  225. * sets the record related properties from user generated input.
  226. *
  227. * Input-filtering and validation by Zend_Filter_Input can enabled and disabled
  228. *
  229. * @param array $_data the new data to set
  230. * @throws Tinebase_Exception_Record_Validation when content contains invalid or missing data
  231. *
  232. * @todo remove custom fields handling (use Tinebase_Record_RecordSet for them)
  233. */
  234. public function setFromArray(array $_data)
  235. {
  236. parent::setFromArray($_data);
  237. $this->fulltext = $this->number . ' - ' . $this->name;
  238. }
  239. /**
  240. * @see Tinebase_Record_Abstract
  241. */
  242. protected static $_relatableConfig = array(
  243. array(
  244. 'relatedApp' => 'Addressbook',
  245. 'relatedModel' => 'Contact',
  246. 'config' => array(
  247. array('type' => 'SUPPLIER', 'degree' => 'sibling', 'text' => 'Supplier', 'max' => '0:0'), // _('Supplier')
  248. ),
  249. 'defaultType' => 'SUPPLIER'
  250. )
  251. );
  252. }