knowledgerecord.class.php 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  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); var_dump($clonedObj->array_options[$key]); exit;
  250. unset($object->array_options[$key]);
  251. }
  252. }
  253. }
  254. // Create clone
  255. $object->context['createfromclone'] = 'createfromclone';
  256. $result = $object->createCommon($user);
  257. if ($result < 0) {
  258. $error++;
  259. $this->error = $object->error;
  260. $this->errors = $object->errors;
  261. }
  262. if (!$error) {
  263. // copy internal contacts
  264. if ($this->copy_linked_contact($object, 'internal') < 0) {
  265. $error++;
  266. }
  267. }
  268. if (!$error) {
  269. // copy external contacts if same company
  270. if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
  271. if ($this->copy_linked_contact($object, 'external') < 0) {
  272. $error++;
  273. }
  274. }
  275. }
  276. unset($object->context['createfromclone']);
  277. // End
  278. if (!$error) {
  279. $this->db->commit();
  280. return $object;
  281. } else {
  282. $this->db->rollback();
  283. return -1;
  284. }
  285. }
  286. /**
  287. * Load object in memory from the database
  288. *
  289. * @param int $id Id object
  290. * @param string $ref Ref
  291. * @return int <0 if KO, 0 if not found, >0 if OK
  292. */
  293. public function fetch($id, $ref = null)
  294. {
  295. $result = $this->fetchCommon($id, $ref);
  296. if ($result > 0 && !empty($this->table_element_line)) {
  297. $this->fetchLines();
  298. }
  299. return $result;
  300. }
  301. /**
  302. * Load object lines in memory from the database
  303. *
  304. * @return int <0 if KO, 0 if not found, >0 if OK
  305. */
  306. public function fetchLines()
  307. {
  308. $this->lines = array();
  309. $result = $this->fetchLinesCommon();
  310. return $result;
  311. }
  312. /**
  313. * Load list of objects in memory from the database.
  314. *
  315. * @param string $sortorder Sort Order
  316. * @param string $sortfield Sort field
  317. * @param int $limit limit
  318. * @param int $offset Offset
  319. * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...)
  320. * @param string $filtermode Filter mode (AND or OR)
  321. * @return array|int int <0 if KO, array of pages if OK
  322. */
  323. public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
  324. {
  325. global $conf;
  326. dol_syslog(__METHOD__, LOG_DEBUG);
  327. $records = array();
  328. $sql = 'SELECT ';
  329. $sql .= $this->getFieldList('t');
  330. $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
  331. if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
  332. $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
  333. } else {
  334. $sql .= ' WHERE 1 = 1';
  335. }
  336. // Manage filter
  337. $sqlwhere = array();
  338. if (count($filter) > 0) {
  339. foreach ($filter as $key => $value) {
  340. if ($key == 't.rowid') {
  341. $sqlwhere[] = $key." = ".((int) $value);
  342. } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
  343. $sqlwhere[] = $key." = '".$this->db->idate($value)."'";
  344. } elseif ($key == 'customsql') {
  345. $sqlwhere[] = $value;
  346. } elseif (strpos($value, '%') === false) {
  347. $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')';
  348. } else {
  349. $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
  350. }
  351. }
  352. }
  353. if (count($sqlwhere) > 0) {
  354. $sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
  355. }
  356. if (!empty($sortfield)) {
  357. $sql .= $this->db->order($sortfield, $sortorder);
  358. }
  359. if (!empty($limit)) {
  360. $sql .= $this->db->plimit($limit, $offset);
  361. }
  362. $resql = $this->db->query($sql);
  363. if ($resql) {
  364. $num = $this->db->num_rows($resql);
  365. $i = 0;
  366. while ($i < ($limit ? min($limit, $num) : $num)) {
  367. $obj = $this->db->fetch_object($resql);
  368. $record = new self($this->db);
  369. $record->setVarsFromFetchObj($obj);
  370. $records[$record->id] = $record;
  371. $i++;
  372. }
  373. $this->db->free($resql);
  374. return $records;
  375. } else {
  376. $this->errors[] = 'Error '.$this->db->lasterror();
  377. dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
  378. return -1;
  379. }
  380. }
  381. /**
  382. * Update object into database
  383. *
  384. * @param User $user User that modifies
  385. * @param bool $notrigger false=launch triggers after, true=disable triggers
  386. * @return int <0 if KO, >0 if OK
  387. */
  388. public function update(User $user, $notrigger = false)
  389. {
  390. return $this->updateCommon($user, $notrigger);
  391. }
  392. /**
  393. * Delete object in database
  394. *
  395. * @param User $user User that deletes
  396. * @param bool $notrigger false=launch triggers after, true=disable triggers
  397. * @return int <0 if KO, >0 if OK
  398. */
  399. public function delete(User $user, $notrigger = false)
  400. {
  401. $error = 0;
  402. $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement WHERE fk_knowledgemanagement = ".((int) $this->id);
  403. dol_syslog(get_class($this)."::delete", LOG_DEBUG);
  404. $resql = $this->db->query($sql);
  405. if (!$resql) {
  406. $error++;
  407. $this->error .= $this->db->lasterror();
  408. $errorflag = -1;
  409. }
  410. return $this->deleteCommon($user, $notrigger);
  411. //return $this->deleteCommon($user, $notrigger, 1);
  412. }
  413. /**
  414. * Delete a line of object in database
  415. *
  416. * @param User $user User that delete
  417. * @param int $idline Id of line to delete
  418. * @param bool $notrigger false=launch triggers after, true=disable triggers
  419. * @return int >0 if OK, <0 if KO
  420. */
  421. public function deleteLine(User $user, $idline, $notrigger = false)
  422. {
  423. if ($this->status < 0) {
  424. $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
  425. return -2;
  426. }
  427. return $this->deleteLineCommon($user, $idline, $notrigger);
  428. }
  429. /**
  430. * Validate object
  431. *
  432. * @param User $user User making status change
  433. * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
  434. * @return int <=0 if OK, 0=Nothing done, >0 if KO
  435. */
  436. public function validate($user, $notrigger = 0)
  437. {
  438. global $conf, $langs;
  439. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  440. $error = 0;
  441. // Protection
  442. if ($this->status == self::STATUS_VALIDATED) {
  443. dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
  444. return 0;
  445. }
  446. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->knowledgemanagement->knowledgerecord->write))
  447. || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->knowledgemanagement->knowledgerecord->knowledgerecord_advance->validate))))
  448. {
  449. $this->error='NotEnoughPermissions';
  450. dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
  451. return -1;
  452. }*/
  453. $now = dol_now();
  454. $this->db->begin();
  455. // Define new ref
  456. if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
  457. $num = $this->getNextNumRef();
  458. } else {
  459. $num = $this->ref;
  460. }
  461. $this->newref = $num;
  462. if (!empty($num)) {
  463. // Validate
  464. $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
  465. $sql .= " SET ref = '".$this->db->escape($num)."',";
  466. $sql .= " status = ".self::STATUS_VALIDATED;
  467. if (!empty($this->fields['date_validation'])) {
  468. $sql .= ", date_validation = '".$this->db->idate($now)."'";
  469. }
  470. if (!empty($this->fields['fk_user_valid'])) {
  471. $sql .= ", fk_user_valid = ".((int) $user->id);
  472. }
  473. $sql .= " WHERE rowid = ".((int) $this->id);
  474. dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
  475. $resql = $this->db->query($sql);
  476. if (!$resql) {
  477. dol_print_error($this->db);
  478. $this->error = $this->db->lasterror();
  479. $error++;
  480. }
  481. if (!$error && !$notrigger) {
  482. // Call trigger
  483. $result = $this->call_trigger('KNOWLEDGERECORD_VALIDATE', $user);
  484. if ($result < 0) {
  485. $error++;
  486. }
  487. // End call triggers
  488. }
  489. }
  490. if (!$error) {
  491. $this->oldref = $this->ref;
  492. // Rename directory if dir was a temporary ref
  493. if (preg_match('/^[\(]?PROV/i', $this->ref)) {
  494. // Now we rename also files into index
  495. $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)."'";
  496. $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'knowledgerecord/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
  497. $resql = $this->db->query($sql);
  498. if (!$resql) {
  499. $error++; $this->error = $this->db->lasterror();
  500. }
  501. // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
  502. $oldref = dol_sanitizeFileName($this->ref);
  503. $newref = dol_sanitizeFileName($num);
  504. $dirsource = $conf->knowledgemanagement->dir_output.'/knowledgerecord/'.$oldref;
  505. $dirdest = $conf->knowledgemanagement->dir_output.'/knowledgerecord/'.$newref;
  506. if (!$error && file_exists($dirsource)) {
  507. dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
  508. if (@rename($dirsource, $dirdest)) {
  509. dol_syslog("Rename ok");
  510. // Rename docs starting with $oldref with $newref
  511. $listoffiles = dol_dir_list($conf->knowledgemanagement->dir_output.'/knowledgerecord/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
  512. foreach ($listoffiles as $fileentry) {
  513. $dirsource = $fileentry['name'];
  514. $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
  515. $dirsource = $fileentry['path'].'/'.$dirsource;
  516. $dirdest = $fileentry['path'].'/'.$dirdest;
  517. @rename($dirsource, $dirdest);
  518. }
  519. }
  520. }
  521. }
  522. }
  523. // Set new ref and current status
  524. if (!$error) {
  525. $this->ref = $num;
  526. $this->status = self::STATUS_VALIDATED;
  527. }
  528. if (!$error) {
  529. $this->db->commit();
  530. return 1;
  531. } else {
  532. $this->db->rollback();
  533. return -1;
  534. }
  535. }
  536. /**
  537. * Set draft status
  538. *
  539. * @param User $user Object user that modify
  540. * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
  541. * @return int <0 if KO, >0 if OK
  542. */
  543. public function setDraft($user, $notrigger = 0)
  544. {
  545. // Protection
  546. if ($this->status <= self::STATUS_DRAFT) {
  547. return 0;
  548. }
  549. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->knowledgemanagement->write))
  550. || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->knowledgemanagement->knowledgemanagement_advance->validate))))
  551. {
  552. $this->error='Permission denied';
  553. return -1;
  554. }*/
  555. return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'KNOWLEDGERECORD_UNVALIDATE');
  556. }
  557. /**
  558. * Set cancel status
  559. *
  560. * @param User $user Object user that modify
  561. * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
  562. * @return int <0 if KO, 0=Nothing done, >0 if OK
  563. */
  564. public function cancel($user, $notrigger = 0)
  565. {
  566. // Protection
  567. if ($this->status != self::STATUS_VALIDATED) {
  568. return 0;
  569. }
  570. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->knowledgemanagement->write))
  571. || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->knowledgemanagement->knowledgemanagement_advance->validate))))
  572. {
  573. $this->error='Permission denied';
  574. return -1;
  575. }*/
  576. return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'KNOWLEDGERECORD_CANCEL');
  577. }
  578. /**
  579. * Set back to validated status
  580. *
  581. * @param User $user Object user that modify
  582. * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
  583. * @return int <0 if KO, 0=Nothing done, >0 if OK
  584. */
  585. public function reopen($user, $notrigger = 0)
  586. {
  587. // Protection
  588. if ($this->status != self::STATUS_CANCELED) {
  589. return 0;
  590. }
  591. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->knowledgemanagement->write))
  592. || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->knowledgemanagement->knowledgemanagement_advance->validate))))
  593. {
  594. $this->error='Permission denied';
  595. return -1;
  596. }*/
  597. return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'KNOWLEDGERECORD_REOPEN');
  598. }
  599. /**
  600. * Return a link to the object card (with optionaly the picto)
  601. *
  602. * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
  603. * @param string $option On what the link point to ('nolink', ...)
  604. * @param int $notooltip 1=Disable tooltip
  605. * @param string $morecss Add more css on link
  606. * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
  607. * @return string String with URL
  608. */
  609. public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
  610. {
  611. global $conf, $langs, $hookmanager;
  612. if (!empty($conf->dol_no_mouse_hover)) {
  613. $notooltip = 1; // Force disable tooltips
  614. }
  615. $result = '';
  616. $label = img_picto('', $this->picto).' <u>'.$langs->trans("KnowledgeRecord").'</u>';
  617. if (isset($this->status)) {
  618. $label .= ' '.$this->getLibStatut(5);
  619. }
  620. $label .= '<br>';
  621. $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
  622. $url = dol_buildpath('/knowledgemanagement/knowledgerecord_card.php', 1).'?id='.$this->id;
  623. if ($option != 'nolink') {
  624. // Add param to save lastsearch_values or not
  625. $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
  626. if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
  627. $add_save_lastsearch_values = 1;
  628. }
  629. if ($add_save_lastsearch_values) {
  630. $url .= '&save_lastsearch_values=1';
  631. }
  632. }
  633. $linkclose = '';
  634. if (empty($notooltip)) {
  635. if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
  636. $label = $langs->trans("ShowKnowledgeRecord");
  637. $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
  638. }
  639. $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
  640. $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
  641. } else {
  642. $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
  643. }
  644. if ($option == 'nolink') {
  645. $linkstart = '<span';
  646. } else {
  647. $linkstart = '<a href="'.$url.'"';
  648. }
  649. $linkstart .= $linkclose.'>';
  650. if ($option == 'nolink') {
  651. $linkend = '</span>';
  652. } else {
  653. $linkend = '</a>';
  654. }
  655. $result .= $linkstart;
  656. if (empty($this->showphoto_on_popup)) {
  657. if ($withpicto) {
  658. $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);
  659. }
  660. } else {
  661. if ($withpicto) {
  662. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  663. list($class, $module) = explode('@', $this->picto);
  664. $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
  665. $filearray = dol_dir_list($upload_dir, "files");
  666. $filename = $filearray[0]['name'];
  667. if (!empty($filename)) {
  668. $pospoint = strpos($filearray[0]['name'], '.');
  669. $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
  670. if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
  671. $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>';
  672. } else {
  673. $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>';
  674. }
  675. $result .= '</div>';
  676. } else {
  677. $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);
  678. }
  679. }
  680. }
  681. if ($withpicto != 2) {
  682. $result .= $this->ref;
  683. }
  684. $result .= $linkend;
  685. //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
  686. global $action, $hookmanager;
  687. $hookmanager->initHooks(array('knowledgerecorddao'));
  688. $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
  689. $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
  690. if ($reshook > 0) {
  691. $result = $hookmanager->resPrint;
  692. } else {
  693. $result .= $hookmanager->resPrint;
  694. }
  695. return $result;
  696. }
  697. /**
  698. * Return the label of the status
  699. *
  700. * @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
  701. * @return string Label of status
  702. */
  703. public function getLibStatut($mode = 0)
  704. {
  705. return $this->LibStatut($this->status, $mode);
  706. }
  707. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  708. /**
  709. * Return the status
  710. *
  711. * @param int $status Id status
  712. * @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
  713. * @return string Label of status
  714. */
  715. public function LibStatut($status, $mode = 0)
  716. {
  717. // phpcs:enable
  718. if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
  719. global $langs;
  720. //$langs->load("knowledgemanagement");
  721. $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
  722. $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
  723. $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Obsolete');
  724. $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
  725. $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
  726. $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Obsolete');
  727. }
  728. $statusType = 'status'.$status;
  729. if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
  730. if ($status == self::STATUS_CANCELED) {
  731. $statusType = 'status6';
  732. }
  733. return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
  734. }
  735. /**
  736. * Load the info information in the object
  737. *
  738. * @param int $id Id of object
  739. * @return void
  740. */
  741. public function info($id)
  742. {
  743. $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
  744. $sql .= ' fk_user_creat, fk_user_modif';
  745. $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
  746. $sql .= ' WHERE t.rowid = '.((int) $id);
  747. $result = $this->db->query($sql);
  748. if ($result) {
  749. if ($this->db->num_rows($result)) {
  750. $obj = $this->db->fetch_object($result);
  751. $this->id = $obj->rowid;
  752. if ($obj->fk_user_author) {
  753. $cuser = new User($this->db);
  754. $cuser->fetch($obj->fk_user_author);
  755. $this->user_creation = $cuser;
  756. }
  757. if ($obj->fk_user_valid) {
  758. $vuser = new User($this->db);
  759. $vuser->fetch($obj->fk_user_valid);
  760. $this->user_validation = $vuser;
  761. }
  762. if ($obj->fk_user_cloture) {
  763. $cluser = new User($this->db);
  764. $cluser->fetch($obj->fk_user_cloture);
  765. $this->user_cloture = $cluser;
  766. }
  767. $this->date_creation = $this->db->jdate($obj->datec);
  768. $this->date_modification = $this->db->jdate($obj->datem);
  769. $this->date_validation = $this->db->jdate($obj->datev);
  770. }
  771. $this->db->free($result);
  772. } else {
  773. dol_print_error($this->db);
  774. }
  775. }
  776. /**
  777. * Initialise object with example values
  778. * Id must be 0 if object instance is a specimen
  779. *
  780. * @return void
  781. */
  782. public function initAsSpecimen()
  783. {
  784. $this->question = "ABCD";
  785. $this->initAsSpecimenCommon();
  786. }
  787. /**
  788. * Create an array of lines
  789. *
  790. * @return array|int array of lines if OK, <0 if KO
  791. */
  792. public function getLinesArray()
  793. {
  794. $this->lines = array();
  795. $objectline = new KnowledgeRecordLine($this->db);
  796. $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_knowledgerecord = '.((int) $this->id)));
  797. if (is_numeric($result)) {
  798. $this->error = $this->error;
  799. $this->errors = $this->errors;
  800. return $result;
  801. } else {
  802. $this->lines = $result;
  803. return $this->lines;
  804. }
  805. }
  806. /**
  807. * Returns the reference to the following non used object depending on the active numbering module.
  808. *
  809. * @return string Object free reference
  810. */
  811. public function getNextNumRef()
  812. {
  813. global $langs, $conf;
  814. $langs->load("knowledgemanagement");
  815. if (empty($conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON)) {
  816. $conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON = 'mod_knowledgerecord_standard';
  817. }
  818. if (!empty($conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON)) {
  819. $mybool = false;
  820. $file = $conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON.".php";
  821. $classname = $conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON;
  822. // Include file with class
  823. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  824. foreach ($dirmodels as $reldir) {
  825. $dir = dol_buildpath($reldir."core/modules/knowledgemanagement/");
  826. // Load file with numbering class (if found)
  827. $mybool |= @include_once $dir.$file;
  828. }
  829. if ($mybool === false) {
  830. dol_print_error('', "Failed to include file ".$file);
  831. return '';
  832. }
  833. if (class_exists($classname)) {
  834. $obj = new $classname();
  835. $numref = $obj->getNextValue($this);
  836. if ($numref != '' && $numref != '-1') {
  837. return $numref;
  838. } else {
  839. $this->error = $obj->error;
  840. //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
  841. return "";
  842. }
  843. } else {
  844. print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
  845. return "";
  846. }
  847. } else {
  848. print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
  849. return "";
  850. }
  851. }
  852. /**
  853. * Create a document onto disk according to template module.
  854. *
  855. * @param string $modele Force template to use ('' to not force)
  856. * @param Translate $outputlangs objet lang a utiliser pour traduction
  857. * @param int $hidedetails Hide details of lines
  858. * @param int $hidedesc Hide description
  859. * @param int $hideref Hide ref
  860. * @param null|array $moreparams Array to provide more information
  861. * @return int 0 if KO, 1 if OK
  862. */
  863. public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
  864. {
  865. global $conf, $langs;
  866. $result = 0;
  867. $includedocgeneration = 0;
  868. $langs->load("knowledgemanagement");
  869. if (!dol_strlen($modele)) {
  870. $modele = 'standard_knowledgerecord';
  871. if (!empty($this->model_pdf)) {
  872. $modele = $this->model_pdf;
  873. } elseif (!empty($conf->global->KNOWLEDGERECORD_ADDON_PDF)) {
  874. $modele = $conf->global->KNOWLEDGERECORD_ADDON_PDF;
  875. }
  876. }
  877. $modelpath = "core/modules/knowledgemanagement/doc/";
  878. if ($includedocgeneration && !empty($modele)) {
  879. $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
  880. }
  881. return $result;
  882. }
  883. /**
  884. * Action executed by scheduler
  885. * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters'
  886. * Use public function doScheduledJob($param1, $param2, ...) to get parameters
  887. *
  888. * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
  889. */
  890. public function doScheduledJob()
  891. {
  892. global $conf, $langs;
  893. //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
  894. $error = 0;
  895. $this->output = '';
  896. $this->error = '';
  897. dol_syslog(__METHOD__, LOG_DEBUG);
  898. $now = dol_now();
  899. $this->db->begin();
  900. // ...
  901. $this->db->commit();
  902. return $error;
  903. }
  904. /**
  905. * Sets object to supplied categories.
  906. *
  907. * Deletes object from existing categories not supplied.
  908. * Adds it to non existing supplied categories.
  909. * Existing categories are left untouch.
  910. *
  911. * @param int[]|int $categories Category or categories IDs
  912. * @return void
  913. */
  914. public function setCategories($categories)
  915. {
  916. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  917. return parent::setCategoriesCommon($categories, Categorie::TYPE_KNOWLEDGEMANAGEMENT);
  918. }
  919. }
  920. require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
  921. /**
  922. * Class KnowledgeRecordLine. You can also remove this and generate a CRUD class for lines objects.
  923. */
  924. class KnowledgeRecordLine extends CommonObjectLine
  925. {
  926. // To complete with content of an object KnowledgeRecordLine
  927. // We should have a field rowid, fk_knowledgerecord and position
  928. /**
  929. * @var int Does object support extrafields ? 0=No, 1=Yes
  930. */
  931. public $isextrafieldmanaged = 0;
  932. /**
  933. * Constructor
  934. *
  935. * @param DoliDb $db Database handler
  936. */
  937. public function __construct(DoliDB $db)
  938. {
  939. $this->db = $db;
  940. }
  941. }