rollerrenthistory.class.php 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118
  1. <?php
  2. /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2024 László Szollősi
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file class/rollerrenthistory.class.php
  20. * \ingroup rollerstorage
  21. * \brief This file is a CRUD class file for RollerRentHistory (Create/Read/Update/Delete)
  22. */
  23. // Put here all includes required by your class file
  24. require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
  25. //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
  26. //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
  27. /**
  28. * Class for RollerRentHistory
  29. */
  30. class RollerRentHistory extends CommonObject
  31. {
  32. /**
  33. * @var string ID of module.
  34. */
  35. public $module = 'rollerstorage';
  36. /**
  37. * @var string ID to identify managed object.
  38. */
  39. public $element = 'rollerrenthistory';
  40. /**
  41. * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
  42. */
  43. public $table_element = 'rollerstorage_rollerrenthistory';
  44. /**
  45. * @var int Does this object support multicompany module ?
  46. * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
  47. */
  48. public $ismultientitymanaged = 0;
  49. /**
  50. * @var int Does object support extrafields ? 0=No, 1=Yes
  51. */
  52. public $isextrafieldmanaged = 1;
  53. /**
  54. * @var string String with name of icon for rollerrenthistory. Must be a 'fa-xxx' fontawesome code (or 'fa-xxx_fa_color_size') or 'rollerrenthistory@rollerstorage' if picto is file 'img/object_rollerrenthistory.png'.
  55. */
  56. public $picto = 'fa-file';
  57. const STATUS_DRAFT = 0;
  58. const STATUS_VALIDATED = 1;
  59. const STATUS_CANCELED = 9;
  60. /**
  61. * 'type' field format:
  62. * 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',
  63. * 'select' (list of values are in 'options'),
  64. * 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]',
  65. * 'chkbxlst:...',
  66. * 'varchar(x)',
  67. * 'text', 'text:none', 'html',
  68. * 'double(24,8)', 'real', 'price',
  69. * 'date', 'datetime', 'timestamp', 'duration',
  70. * 'boolean', 'checkbox', 'radio', 'array',
  71. * 'mail', 'phone', 'url', 'password', 'ip'
  72. * Note: Filter must be a Dolibarr filter syntax string. Example: "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.status:!=:0) or (t.nature:is:NULL)"
  73. * 'label' the translation key.
  74. * 'picto' is code of a picto to show before value in forms
  75. * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled("multicurrency")' ...)
  76. * 'position' is the sort order of field.
  77. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
  78. * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
  79. * 'noteditable' says if field is not editable (1 or 0)
  80. * 'alwayseditable' says if field can be modified also when status is not draft ('1' or '0')
  81. * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
  82. * 'index' if we want an index in database.
  83. * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
  84. * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
  85. * 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage)
  86. * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
  87. * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
  88. * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
  89. * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
  90. * 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar'
  91. * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
  92. * 'comment' is not used. You can store here any text of your choice. It is not used by application.
  93. * 'validate' is 1 if need to validate with $this->validateField()
  94. * 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value)
  95. *
  96. * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
  97. */
  98. // BEGIN MODULEBUILDER PROPERTIES
  99. /**
  100. * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
  101. */
  102. public $fields=array(
  103. 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
  104. 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0, 'default'=>'1', 'index'=>1,),
  105. 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1', 'comment'=>"Reference of object"),
  106. 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
  107. 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
  108. 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'picto'=>'user', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid', 'csslist'=>'tdoverflowmax150',),
  109. 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2, 'csslist'=>'tdoverflowmax150',),
  110. 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Piszkozat', '1'=>'Hiteles&iacute;tve', '9'=>'Megszak&iacute;tva'), 'validate'=>'1',),
  111. 'event_id' => array('type'=>'integer', 'label'=>'Event', 'enabled'=>'1', 'position'=>512, 'notnull'=>0, 'visible'=>1, 'noteditable'=>'1',),
  112. 'inventory_id' => array('type'=>'integer', 'label'=>'Scooter', 'enabled'=>'1', 'position'=>513, 'notnull'=>1, 'visible'=>1, 'noteditable'=>'1',),
  113. 'facture_id' => array('type'=>'integer', 'label'=>'Facture', 'enabled'=>'1', 'position'=>514, 'notnull'=>0, 'visible'=>1, 'noteditable'=>'1',),
  114. 'ticket_id' => array('type'=>'integer', 'label'=>'Ticket', 'enabled'=>'1', 'position'=>515, 'notnull'=>0, 'visible'=>1, 'noteditable'=>'1',),
  115. 'product_id' => array('type'=>'integer', 'label'=>'Product', 'enabled'=>'1', 'position'=>516, 'notnull'=>0, 'visible'=>1, 'noteditable'=>'1',),
  116. 'invoice_number' => array('type'=>'varchar(255)', 'label'=>'InvoiceNumber', 'enabled'=>'1', 'position'=>517, 'notnull'=>1, 'visible'=>1, 'noteditable'=>'1',),
  117. );
  118. public $rowid;
  119. public $entity;
  120. public $ref;
  121. public $date_creation;
  122. public $tms;
  123. public $fk_user_creat;
  124. public $fk_user_modif;
  125. public $status;
  126. public $event_id;
  127. public $inventory_id;
  128. public $facture_id;
  129. public $ticket_id;
  130. public $product_id;
  131. public $invoice_number;
  132. // END MODULEBUILDER PROPERTIES
  133. // If this object has a subtable with lines
  134. // /**
  135. // * @var string Name of subtable line
  136. // */
  137. // public $table_element_line = 'rollerstorage_rollerrenthistoryline';
  138. // /**
  139. // * @var string Field with ID of parent key if this object has a parent
  140. // */
  141. // public $fk_element = 'fk_rollerrenthistory';
  142. // /**
  143. // * @var string Name of subtable class that manage subtable lines
  144. // */
  145. // public $class_element_line = 'RollerRentHistoryline';
  146. // /**
  147. // * @var array List of child tables. To test if we can delete object.
  148. // */
  149. // protected $childtables = array();
  150. // /**
  151. // * @var array List of child tables. To know object to delete on cascade.
  152. // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
  153. // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
  154. // */
  155. // protected $childtablesoncascade = array('rollerstorage_rollerrenthistorydet');
  156. // /**
  157. // * @var RollerRentHistoryLine[] Array of subtable lines
  158. // */
  159. // public $lines = array();
  160. /**
  161. * Constructor
  162. *
  163. * @param DoliDb $db Database handler
  164. */
  165. public function __construct(DoliDB $db)
  166. {
  167. global $conf, $langs;
  168. $this->db = $db;
  169. if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
  170. $this->fields['rowid']['visible'] = 0;
  171. }
  172. if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
  173. $this->fields['entity']['enabled'] = 0;
  174. }
  175. // Example to show how to set values of fields definition dynamically
  176. /*if ($user->rights->rollerstorage->rollerrenthistory->read) {
  177. $this->fields['myfield']['visible'] = 1;
  178. $this->fields['myfield']['noteditable'] = 0;
  179. }*/
  180. // Unset fields that are disabled
  181. foreach ($this->fields as $key => $val) {
  182. if (isset($val['enabled']) && empty($val['enabled'])) {
  183. unset($this->fields[$key]);
  184. }
  185. }
  186. // Translate some data of arrayofkeyval
  187. if (is_object($langs)) {
  188. foreach ($this->fields as $key => $val) {
  189. if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
  190. foreach ($val['arrayofkeyval'] as $key2 => $val2) {
  191. $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
  192. }
  193. }
  194. }
  195. }
  196. }
  197. /**
  198. * Create object into database
  199. *
  200. * @param User $user User that creates
  201. * @param bool $notrigger false=launch triggers after, true=disable triggers
  202. * @return int <0 if KO, Id of created object if OK
  203. */
  204. public function create(User $user, $notrigger = false)
  205. {
  206. $resultcreate = $this->createCommon($user, $notrigger);
  207. //$resultvalidate = $this->validate($user, $notrigger);
  208. return $resultcreate;
  209. }
  210. /**
  211. * Clone an object into another one
  212. *
  213. * @param User $user User that creates
  214. * @param int $fromid Id of object to clone
  215. * @return mixed New object created, <0 if KO
  216. */
  217. public function createFromClone(User $user, $fromid)
  218. {
  219. global $langs, $extrafields;
  220. $error = 0;
  221. dol_syslog(__METHOD__, LOG_DEBUG);
  222. $object = new self($this->db);
  223. $this->db->begin();
  224. // Load source object
  225. $result = $object->fetchCommon($fromid);
  226. if ($result > 0 && !empty($object->table_element_line)) {
  227. $object->fetchLines();
  228. }
  229. // get lines so they will be clone
  230. //foreach($this->lines as $line)
  231. // $line->fetch_optionals();
  232. // Reset some properties
  233. unset($object->id);
  234. unset($object->fk_user_creat);
  235. unset($object->import_key);
  236. // Clear fields
  237. if (property_exists($object, 'ref')) {
  238. $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
  239. }
  240. if (property_exists($object, 'label')) {
  241. $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
  242. }
  243. if (property_exists($object, 'status')) {
  244. $object->status = self::STATUS_DRAFT;
  245. }
  246. if (property_exists($object, 'date_creation')) {
  247. $object->date_creation = dol_now();
  248. }
  249. if (property_exists($object, 'date_modification')) {
  250. $object->date_modification = null;
  251. }
  252. // ...
  253. // Clear extrafields that are unique
  254. if (is_array($object->array_options) && count($object->array_options) > 0) {
  255. $extrafields->fetch_name_optionals_label($this->table_element);
  256. foreach ($object->array_options as $key => $option) {
  257. $shortkey = preg_replace('/options_/', '', $key);
  258. if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
  259. //var_dump($key);
  260. //var_dump($clonedObj->array_options[$key]); exit;
  261. unset($object->array_options[$key]);
  262. }
  263. }
  264. }
  265. // Create clone
  266. $object->context['createfromclone'] = 'createfromclone';
  267. $result = $object->createCommon($user);
  268. if ($result < 0) {
  269. $error++;
  270. $this->error = $object->error;
  271. $this->errors = $object->errors;
  272. }
  273. if (!$error) {
  274. // copy internal contacts
  275. if ($this->copy_linked_contact($object, 'internal') < 0) {
  276. $error++;
  277. }
  278. }
  279. if (!$error) {
  280. // copy external contacts if same company
  281. if (!empty($object->socid) && property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
  282. if ($this->copy_linked_contact($object, 'external') < 0) {
  283. $error++;
  284. }
  285. }
  286. }
  287. unset($object->context['createfromclone']);
  288. // End
  289. if (!$error) {
  290. $this->db->commit();
  291. return $object;
  292. } else {
  293. $this->db->rollback();
  294. return -1;
  295. }
  296. }
  297. /**
  298. * Load object in memory from the database
  299. *
  300. * @param int $id Id object
  301. * @param string $ref Ref
  302. * @return int <0 if KO, 0 if not found, >0 if OK
  303. */
  304. public function fetch($id, $ref = null)
  305. {
  306. $result = $this->fetchCommon($id, $ref);
  307. if ($result > 0 && !empty($this->table_element_line)) {
  308. $this->fetchLines();
  309. }
  310. return $result;
  311. }
  312. /**
  313. * Load object lines in memory from the database
  314. *
  315. * @return int <0 if KO, 0 if not found, >0 if OK
  316. */
  317. public function fetchLines()
  318. {
  319. $this->lines = array();
  320. $result = $this->fetchLinesCommon();
  321. return $result;
  322. }
  323. /**
  324. * Load list of objects in memory from the database.
  325. *
  326. * @param string $sortorder Sort Order
  327. * @param string $sortfield Sort field
  328. * @param int $limit limit
  329. * @param int $offset Offset
  330. * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...)
  331. * @param string $filtermode Filter mode (AND or OR)
  332. * @return array|int int <0 if KO, array of pages if OK
  333. */
  334. public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
  335. {
  336. global $conf;
  337. dol_syslog(__METHOD__, LOG_DEBUG);
  338. $records = array();
  339. $sql = "SELECT ";
  340. $sql .= $this->getFieldList('t');
  341. $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
  342. if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
  343. $sql .= " WHERE t.entity IN (".getEntity($this->element).")";
  344. } else {
  345. $sql .= " WHERE 1 = 1";
  346. }
  347. // Manage filter
  348. $sqlwhere = array();
  349. if (count($filter) > 0) {
  350. foreach ($filter as $key => $value) {
  351. if ($key == 't.rowid') {
  352. $sqlwhere[] = $key." = ".((int) $value);
  353. } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
  354. $sqlwhere[] = $key." = '".$this->db->idate($value)."'";
  355. } elseif ($key == 'customsql') {
  356. $sqlwhere[] = $value;
  357. } elseif (strpos($value, '%') === false) {
  358. $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
  359. } else {
  360. $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
  361. }
  362. }
  363. }
  364. if (count($sqlwhere) > 0) {
  365. $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")";
  366. }
  367. if (!empty($sortfield)) {
  368. $sql .= $this->db->order($sortfield, $sortorder);
  369. }
  370. if (!empty($limit)) {
  371. $sql .= $this->db->plimit($limit, $offset);
  372. }
  373. $resql = $this->db->query($sql);
  374. if ($resql) {
  375. $num = $this->db->num_rows($resql);
  376. $i = 0;
  377. while ($i < ($limit ? min($limit, $num) : $num)) {
  378. $obj = $this->db->fetch_object($resql);
  379. $record = new self($this->db);
  380. $record->setVarsFromFetchObj($obj);
  381. $records[$record->id] = $record;
  382. $i++;
  383. }
  384. $this->db->free($resql);
  385. return $records;
  386. } else {
  387. $this->errors[] = 'Error '.$this->db->lasterror();
  388. dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
  389. return -1;
  390. }
  391. }
  392. /**
  393. * Update object into database
  394. *
  395. * @param User $user User that modifies
  396. * @param bool $notrigger false=launch triggers after, true=disable triggers
  397. * @return int <0 if KO, >0 if OK
  398. */
  399. public function update(User $user, $notrigger = false)
  400. {
  401. return $this->updateCommon($user, $notrigger);
  402. }
  403. /**
  404. * Delete object in database
  405. *
  406. * @param User $user User that deletes
  407. * @param bool $notrigger false=launch triggers, true=disable triggers
  408. * @return int <0 if KO, >0 if OK
  409. */
  410. public function delete(User $user, $notrigger = false)
  411. {
  412. return $this->deleteCommon($user, $notrigger);
  413. //return $this->deleteCommon($user, $notrigger, 1);
  414. }
  415. /**
  416. * Delete a line of object in database
  417. *
  418. * @param User $user User that delete
  419. * @param int $idline Id of line to delete
  420. * @param bool $notrigger false=launch triggers after, true=disable triggers
  421. * @return int >0 if OK, <0 if KO
  422. */
  423. public function deleteLine(User $user, $idline, $notrigger = false)
  424. {
  425. if ($this->status < 0) {
  426. $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
  427. return -2;
  428. }
  429. return $this->deleteLineCommon($user, $idline, $notrigger);
  430. }
  431. /**
  432. * Validate object
  433. *
  434. * @param User $user User making status change
  435. * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
  436. * @return int <=0 if OK, 0=Nothing done, >0 if KO
  437. */
  438. public function validate($user, $notrigger = 0)
  439. {
  440. global $conf, $langs;
  441. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  442. $error = 0;
  443. // Protection
  444. if ($this->status == self::STATUS_VALIDATED) {
  445. dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
  446. return 0;
  447. }
  448. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->rollerstorage->rollerrenthistory->write))
  449. || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->rollerstorage->rollerrenthistory->rollerrenthistory_advance->validate))))
  450. {
  451. $this->error='NotEnoughPermissions';
  452. dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
  453. return -1;
  454. }*/
  455. $now = dol_now();
  456. $this->db->begin();
  457. // Define new ref
  458. if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
  459. $num = $this->getNextNumRef();
  460. } else {
  461. $num = $this->ref;
  462. }
  463. $this->newref = $num;
  464. if (!empty($num)) {
  465. // Validate
  466. $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
  467. $sql .= " SET ref = '".$this->db->escape($num)."',";
  468. $sql .= " status = ".self::STATUS_VALIDATED;
  469. if (!empty($this->fields['date_validation'])) {
  470. $sql .= ", date_validation = '".$this->db->idate($now)."'";
  471. }
  472. if (!empty($this->fields['fk_user_valid'])) {
  473. $sql .= ", fk_user_valid = ".((int) $user->id);
  474. }
  475. $sql .= " WHERE rowid = ".((int) $this->id);
  476. dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
  477. $resql = $this->db->query($sql);
  478. if (!$resql) {
  479. dol_print_error($this->db);
  480. $this->error = $this->db->lasterror();
  481. $error++;
  482. }
  483. if (!$error && !$notrigger) {
  484. // Call trigger
  485. $result = $this->call_trigger('ROLLERRENTHISTORY_VALIDATE', $user);
  486. if ($result < 0) {
  487. $error++;
  488. }
  489. // End call triggers
  490. }
  491. }
  492. if (!$error) {
  493. $this->oldref = $this->ref;
  494. // Rename directory if dir was a temporary ref
  495. if (preg_match('/^[\(]?PROV/i', $this->ref)) {
  496. // Now we rename also files into index
  497. $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'rollerrenthistory/".$this->db->escape($this->newref)."'";
  498. $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'rollerrenthistory/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
  499. $resql = $this->db->query($sql);
  500. if (!$resql) {
  501. $error++; $this->error = $this->db->lasterror();
  502. }
  503. // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
  504. $oldref = dol_sanitizeFileName($this->ref);
  505. $newref = dol_sanitizeFileName($num);
  506. $dirsource = $conf->rollerstorage->dir_output.'/rollerrenthistory/'.$oldref;
  507. $dirdest = $conf->rollerstorage->dir_output.'/rollerrenthistory/'.$newref;
  508. if (!$error && file_exists($dirsource)) {
  509. dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
  510. if (@rename($dirsource, $dirdest)) {
  511. dol_syslog("Rename ok");
  512. // Rename docs starting with $oldref with $newref
  513. $listoffiles = dol_dir_list($conf->rollerstorage->dir_output.'/rollerrenthistory/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
  514. foreach ($listoffiles as $fileentry) {
  515. $dirsource = $fileentry['name'];
  516. $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
  517. $dirsource = $fileentry['path'].'/'.$dirsource;
  518. $dirdest = $fileentry['path'].'/'.$dirdest;
  519. @rename($dirsource, $dirdest);
  520. }
  521. }
  522. }
  523. }
  524. }
  525. // Set new ref and current status
  526. if (!$error) {
  527. $this->ref = $num;
  528. $this->status = self::STATUS_VALIDATED;
  529. }
  530. if (!$error) {
  531. $this->db->commit();
  532. return 1;
  533. } else {
  534. $this->db->rollback();
  535. return -1;
  536. }
  537. }
  538. /**
  539. * Set draft status
  540. *
  541. * @param User $user Object user that modify
  542. * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
  543. * @return int <0 if KO, >0 if OK
  544. */
  545. public function setDraft($user, $notrigger = 0)
  546. {
  547. // Protection
  548. if ($this->status <= self::STATUS_DRAFT) {
  549. return 0;
  550. }
  551. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->rollerstorage->write))
  552. || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->rollerstorage->rollerstorage_advance->validate))))
  553. {
  554. $this->error='Permission denied';
  555. return -1;
  556. }*/
  557. return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'ROLLERRENTHISTORY_UNVALIDATE');
  558. }
  559. /**
  560. * Set cancel status
  561. *
  562. * @param User $user Object user that modify
  563. * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
  564. * @return int <0 if KO, 0=Nothing done, >0 if OK
  565. */
  566. public function cancel($user, $notrigger = 0)
  567. {
  568. // Protection
  569. if ($this->status != self::STATUS_VALIDATED) {
  570. return 0;
  571. }
  572. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->rollerstorage->write))
  573. || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->rollerstorage->rollerstorage_advance->validate))))
  574. {
  575. $this->error='Permission denied';
  576. return -1;
  577. }*/
  578. return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'ROLLERRENTHISTORY_CANCEL');
  579. }
  580. /**
  581. * Set back to validated status
  582. *
  583. * @param User $user Object user that modify
  584. * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
  585. * @return int <0 if KO, 0=Nothing done, >0 if OK
  586. */
  587. public function reopen($user, $notrigger = 0)
  588. {
  589. // Protection
  590. if ($this->status == self::STATUS_VALIDATED) {
  591. return 0;
  592. }
  593. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->rollerstorage->write))
  594. || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->rollerstorage->rollerstorage_advance->validate))))
  595. {
  596. $this->error='Permission denied';
  597. return -1;
  598. }*/
  599. return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'ROLLERRENTHISTORY_REOPEN');
  600. }
  601. /**
  602. * Return a link to the object card (with optionaly the picto)
  603. *
  604. * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
  605. * @param string $option On what the link point to ('nolink', ...)
  606. * @param int $notooltip 1=Disable tooltip
  607. * @param string $morecss Add more css on link
  608. * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
  609. * @return string String with URL
  610. */
  611. public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
  612. {
  613. global $conf, $langs, $hookmanager;
  614. if (!empty($conf->dol_no_mouse_hover)) {
  615. $notooltip = 1; // Force disable tooltips
  616. }
  617. $result = '';
  618. $label = img_picto('', $this->picto).' <u>'.$langs->trans("RollerRentHistory").'</u>';
  619. if (isset($this->status)) {
  620. $label .= ' '.$this->getLibStatut(5);
  621. }
  622. $label .= '<br>';
  623. $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
  624. $url = dol_buildpath('/rollerstorage/rollerrenthistory_card.php', 1).'?id='.$this->id;
  625. if ($option != 'nolink') {
  626. // Add param to save lastsearch_values or not
  627. $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
  628. if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
  629. $add_save_lastsearch_values = 1;
  630. }
  631. if ($url && $add_save_lastsearch_values) {
  632. $url .= '&save_lastsearch_values=1';
  633. }
  634. }
  635. $linkclose = '';
  636. if (empty($notooltip)) {
  637. if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
  638. $label = $langs->trans("ShowRollerRentHistory");
  639. $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
  640. }
  641. $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
  642. $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
  643. } else {
  644. $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
  645. }
  646. if ($option == 'nolink' || empty($url)) {
  647. $linkstart = '<span';
  648. } else {
  649. $linkstart = '<a href="'.$url.'"';
  650. }
  651. $linkstart .= $linkclose.'>';
  652. if ($option == 'nolink' || empty($url)) {
  653. $linkend = '</span>';
  654. } else {
  655. $linkend = '</a>';
  656. }
  657. $result .= $linkstart;
  658. if (empty($this->showphoto_on_popup)) {
  659. if ($withpicto) {
  660. $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
  661. }
  662. } else {
  663. if ($withpicto) {
  664. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  665. list($class, $module) = explode('@', $this->picto);
  666. $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
  667. $filearray = dol_dir_list($upload_dir, "files");
  668. $filename = $filearray[0]['name'];
  669. if (!empty($filename)) {
  670. $pospoint = strpos($filearray[0]['name'], '.');
  671. $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
  672. if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
  673. $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.'" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div></div>';
  674. } else {
  675. $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div>';
  676. }
  677. $result .= '</div>';
  678. } else {
  679. $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
  680. }
  681. }
  682. }
  683. if ($withpicto != 2) {
  684. $result .= $this->ref;
  685. }
  686. $result .= $linkend;
  687. //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
  688. global $action, $hookmanager;
  689. $hookmanager->initHooks(array($this->element.'dao'));
  690. $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
  691. $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
  692. if ($reshook > 0) {
  693. $result = $hookmanager->resPrint;
  694. } else {
  695. $result .= $hookmanager->resPrint;
  696. }
  697. return $result;
  698. }
  699. /**
  700. * Return a thumb for kanban views
  701. *
  702. * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
  703. * @return string HTML Code for Kanban thumb.
  704. */
  705. /*
  706. public function getKanbanView($option = '')
  707. {
  708. $return = '<div class="box-flex-item box-flex-grow-zero">';
  709. $return .= '<div class="info-box info-box-sm">';
  710. $return .= '<span class="info-box-icon bg-infobox-action">';
  711. $return .= img_picto('', $this->picto);
  712. $return .= '</span>';
  713. $return .= '<div class="info-box-content">';
  714. $return .= '<span class="info-box-ref">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
  715. if (property_exists($this, 'label')) {
  716. $return .= '<br><span class="info-box-label opacitymedium">'.$this->label.'</span>';
  717. }
  718. if (method_exists($this, 'getLibStatut')) {
  719. $return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(5).'</div>';
  720. }
  721. $return .= '</div>';
  722. $return .= '</div>';
  723. $return .= '</div>';
  724. return $return;
  725. }
  726. */
  727. /**
  728. * Return the label of the status
  729. *
  730. * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
  731. * @return string Label of status
  732. */
  733. public function getLabelStatus($mode = 0)
  734. {
  735. return $this->LibStatut($this->status, $mode);
  736. }
  737. /**
  738. * Return the label of the status
  739. *
  740. * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
  741. * @return string Label of status
  742. */
  743. public function getLibStatut($mode = 0)
  744. {
  745. return $this->LibStatut($this->status, $mode);
  746. }
  747. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  748. /**
  749. * Return the status
  750. *
  751. * @param int $status Id status
  752. * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
  753. * @return string Label of status
  754. */
  755. public function LibStatut($status, $mode = 0)
  756. {
  757. // phpcs:enable
  758. if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
  759. global $langs;
  760. //$langs->load("rollerstorage@rollerstorage");
  761. $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
  762. $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
  763. $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
  764. $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
  765. $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
  766. $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
  767. }
  768. $statusType = 'status'.$status;
  769. //if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
  770. if ($status == self::STATUS_CANCELED) {
  771. $statusType = 'status6';
  772. }
  773. return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
  774. }
  775. /**
  776. * Load the info information in the object
  777. *
  778. * @param int $id Id of object
  779. * @return void
  780. */
  781. public function info($id)
  782. {
  783. $sql = "SELECT rowid,";
  784. $sql .= " date_creation as datec, tms as datem,";
  785. $sql .= " fk_user_creat, fk_user_modif";
  786. $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
  787. $sql .= " WHERE t.rowid = ".((int) $id);
  788. $result = $this->db->query($sql);
  789. if ($result) {
  790. if ($this->db->num_rows($result)) {
  791. $obj = $this->db->fetch_object($result);
  792. $this->id = $obj->rowid;
  793. $this->user_creation_id = $obj->fk_user_creat;
  794. $this->user_modification_id = $obj->fk_user_modif;
  795. if (!empty($obj->fk_user_valid)) {
  796. $this->user_validation_id = $obj->fk_user_valid;
  797. }
  798. $this->date_creation = $this->db->jdate($obj->datec);
  799. $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
  800. if (!empty($obj->datev)) {
  801. $this->date_validation = empty($obj->datev) ? '' : $this->db->jdate($obj->datev);
  802. }
  803. }
  804. $this->db->free($result);
  805. } else {
  806. dol_print_error($this->db);
  807. }
  808. }
  809. /**
  810. * Initialise object with example values
  811. * Id must be 0 if object instance is a specimen
  812. *
  813. * @return void
  814. */
  815. public function initAsSpecimen()
  816. {
  817. // Set here init that are not commonf fields
  818. // $this->property1 = ...
  819. // $this->property2 = ...
  820. $this->initAsSpecimenCommon();
  821. }
  822. /**
  823. * Create an array of lines
  824. *
  825. * @return array|int array of lines if OK, <0 if KO
  826. */
  827. public function getLinesArray()
  828. {
  829. $this->lines = array();
  830. $objectline = new RollerRentHistoryLine($this->db);
  831. $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_rollerrenthistory = '.((int) $this->id)));
  832. if (is_numeric($result)) {
  833. $this->error = $objectline->error;
  834. $this->errors = $objectline->errors;
  835. return $result;
  836. } else {
  837. $this->lines = $result;
  838. return $this->lines;
  839. }
  840. }
  841. /**
  842. * Returns the reference to the following non used object depending on the active numbering module.
  843. *
  844. * @return string Object free reference
  845. */
  846. public function getNextNumRef()
  847. {
  848. global $langs, $conf;
  849. $langs->load("rollerstorage@rollerstorage");
  850. if (empty($conf->global->ROLLERSTORAGE_ROLLERRENTHISTORY_ADDON)) {
  851. $conf->global->ROLLERSTORAGE_ROLLERRENTHISTORY_ADDON = 'mod_rollerrenthistory_standard';
  852. }
  853. if (!empty($conf->global->ROLLERSTORAGE_ROLLERRENTHISTORY_ADDON)) {
  854. $mybool = false;
  855. $file = $conf->global->ROLLERSTORAGE_ROLLERRENTHISTORY_ADDON.".php";
  856. $classname = $conf->global->ROLLERSTORAGE_ROLLERRENTHISTORY_ADDON;
  857. // Include file with class
  858. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  859. foreach ($dirmodels as $reldir) {
  860. $dir = dol_buildpath($reldir."core/modules/rollerstorage/");
  861. // Load file with numbering class (if found)
  862. $mybool |= @include_once $dir.$file;
  863. }
  864. if ($mybool === false) {
  865. dol_print_error('', "Failed to include file ".$file);
  866. return '';
  867. }
  868. if (class_exists($classname)) {
  869. $obj = new $classname();
  870. $numref = $obj->getNextValue($this);
  871. if ($numref != '' && $numref != '-1') {
  872. return $numref;
  873. } else {
  874. $this->error = $obj->error;
  875. //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
  876. return "";
  877. }
  878. } else {
  879. print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
  880. return "";
  881. }
  882. } else {
  883. print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
  884. return "";
  885. }
  886. }
  887. /**
  888. * Create a document onto disk according to template module.
  889. *
  890. * @param string $modele Force template to use ('' to not force)
  891. * @param Translate $outputlangs objet lang a utiliser pour traduction
  892. * @param int $hidedetails Hide details of lines
  893. * @param int $hidedesc Hide description
  894. * @param int $hideref Hide ref
  895. * @param null|array $moreparams Array to provide more information
  896. * @return int 0 if KO, 1 if OK
  897. */
  898. public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
  899. {
  900. global $conf, $langs;
  901. $result = 0;
  902. $includedocgeneration = 0;
  903. $langs->load("rollerstorage@rollerstorage");
  904. if (!dol_strlen($modele)) {
  905. $modele = 'standard_rollerrenthistory';
  906. if (!empty($this->model_pdf)) {
  907. $modele = $this->model_pdf;
  908. } elseif (!empty($conf->global->ROLLERRENTHISTORY_ADDON_PDF)) {
  909. $modele = $conf->global->ROLLERRENTHISTORY_ADDON_PDF;
  910. }
  911. }
  912. $modelpath = "core/modules/rollerstorage/doc/";
  913. if ($includedocgeneration && !empty($modele)) {
  914. $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
  915. }
  916. return $result;
  917. }
  918. /**
  919. * Action executed by scheduler
  920. * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters'
  921. * Use public function doScheduledJob($param1, $param2, ...) to get parameters
  922. *
  923. * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
  924. */
  925. public function doScheduledJob()
  926. {
  927. global $conf, $langs;
  928. //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
  929. $error = 0;
  930. $this->output = '';
  931. $this->error = '';
  932. dol_syslog(__METHOD__, LOG_DEBUG);
  933. $now = dol_now();
  934. $this->db->begin();
  935. // ...
  936. $this->db->commit();
  937. return $error;
  938. }
  939. }
  940. require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
  941. /**
  942. * Class RollerRentHistoryLine. You can also remove this and generate a CRUD class for lines objects.
  943. */
  944. class RollerRentHistoryLine extends CommonObjectLine
  945. {
  946. // To complete with content of an object RollerRentHistoryLine
  947. // We should have a field rowid, fk_rollerrenthistory and position
  948. /**
  949. * @var int Does object support extrafields ? 0=No, 1=Yes
  950. */
  951. public $isextrafieldmanaged = 0;
  952. /**
  953. * Constructor
  954. *
  955. * @param DoliDb $db Database handler
  956. */
  957. public function __construct(DoliDB $db)
  958. {
  959. $this->db = $db;
  960. }
  961. }