knowledgerecord.class.php 38 KB

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