recruitmentcandidature.class.php 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  1. <?php
  2. /* Copyright (C) 2020 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 class/recruitmentcandidature.class.php
  19. * \ingroup recruitment
  20. * \brief This file is a CRUD class file for RecruitmentCandidature (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 RecruitmentCandidature
  28. */
  29. class RecruitmentCandidature extends CommonObject
  30. {
  31. /**
  32. * @var string ID of module.
  33. */
  34. public $module = 'recruitment';
  35. /**
  36. * @var string ID to identify managed object.
  37. */
  38. public $element = 'recruitmentcandidature';
  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 = 'recruitment_recruitmentcandidature';
  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 recruitmentcandidature. Must be the part after the 'object_' into object_recruitmentcandidature.png
  54. */
  55. public $picto = 'recruitmentcandidature';
  56. /**
  57. * @var int Do not exploit fields email_xxx into triggers.
  58. */
  59. public $email_fields_no_propagate_in_actioncomm;
  60. const STATUS_DRAFT = 0;
  61. const STATUS_VALIDATED = 1;
  62. //const STATUS_INTERVIEW_SCHEDULED = 2;
  63. const STATUS_CONTRACT_PROPOSED = 3;
  64. const STATUS_CONTRACT_SIGNED = 5;
  65. const STATUS_CONTRACT_REFUSED = 6;
  66. const STATUS_REFUSED = 8;
  67. const STATUS_CANCELED = 9;
  68. /**
  69. * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
  70. * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
  71. * 'label' the translation key.
  72. * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)
  73. * 'position' is the sort order of field.
  74. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
  75. * '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)
  76. * 'noteditable' says if field is not editable (1 or 0)
  77. * '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.
  78. * 'index' if we want an index in database.
  79. * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
  80. * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
  81. * '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).
  82. * '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'
  83. * 'help' is a string visible as a tooltip on field
  84. * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
  85. * '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.
  86. * 'arrayofkeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
  87. * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
  88. * 'comment' is not used. You can store here any text of your choice. It is not used by application.
  89. *
  90. * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
  91. */
  92. // BEGIN MODULEBUILDER PROPERTIES
  93. /**
  94. * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
  95. */
  96. public $fields = array(
  97. 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'comment'=>"Id"),
  98. 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1),
  99. 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of candidature", 'csslist'=>'nowraponall'),
  100. 'fk_recruitmentjobposition' => array('type'=>'integer:RecruitmentJobPosition:recruitment/class/recruitmentjobposition.class.php', 'label'=>'Job', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>1, 'index'=>1, 'picto'=>'recruitmentjobposition', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'minwidth100 nowraponall'),
  101. 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
  102. 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
  103. 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid', 'csslist'=>'tdoverflowmax100'),
  104. 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2, 'csslist'=>'tdoverflowmax100'),
  105. 'lastname' => array('type'=>'varchar(128)', 'label'=>'Lastname', 'enabled'=>'1', 'position'=>20, 'notnull'=>0, 'visible'=>1, 'csslist'=>'tdoverflowmax150'),
  106. 'firstname' => array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>'1', 'position'=>21, 'notnull'=>0, 'visible'=>1, 'csslist'=>'tdoverflowmax150'),
  107. 'email' => array('type'=>'email', 'label'=>'EMail', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'picto'=>'email', 'csslist'=>'tdoverflowmax150'),
  108. 'phone' => array('type'=>'phone', 'label'=>'Phone', 'enabled'=>'1', 'position'=>31, 'notnull'=>0, 'visible'=>1, 'picto'=>'phone', 'csslist'=>'tdoverflowmax150'),
  109. 'date_birth' => array('type'=>'date', 'label'=>'DateOfBirth', 'enabled'=>'1', 'position'=>70, 'visible'=>-1,),
  110. 'email_msgid' => array('type'=>'varchar(255)', 'label'=>'EmailMsgID', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'help'=>'EmailMsgIDDesc'),
  111. 'email_date' => array('type'=>'datetime', 'label'=>'EmailDate', 'visible'=>-2, 'enabled'=>1, 'position'=>541),
  112. //'fk_recruitment_origin' => array('type'=>'integer:CRecruitmentOrigin:recruitment/class/crecruitmentorigin.class.php', 'label'=>'Origin', 'enabled'=>'1', 'position'=>45, 'visible'=>1, 'index'=>1),
  113. 'remuneration_requested' => array('type'=>'integer', 'label'=>'RequestedRemuneration', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,),
  114. 'remuneration_proposed' => array('type'=>'integer', 'label'=>'ProposedRemuneration', 'enabled'=>'1', 'position'=>81, 'notnull'=>0, 'visible'=>-1,),
  115. 'description' => array('type'=>'html', 'label'=>'Description', 'enabled'=>'1', 'position'=>300, 'notnull'=>0, 'visible'=>3, 'cssview'=>'wordbreak'),
  116. 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-4, 'csslist'=>'nowraponall'),
  117. 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2, 'csslist'=>'nowraponall'),
  118. 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
  119. 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
  120. 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'default'=>0, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Received', '3'=>'ContractProposed', '5'=>'ContractSigned', '8'=>'Refused', '9'=>'Canceled')),
  121. );
  122. public $rowid;
  123. public $entity;
  124. public $ref;
  125. public $fk_recruitmentjobposition;
  126. public $description;
  127. public $note_public;
  128. public $note_private;
  129. public $date_creation;
  130. public $tms;
  131. public $fk_user_creat;
  132. public $fk_user_modif;
  133. public $lastname;
  134. public $firstname;
  135. public $email;
  136. public $phone;
  137. public $date_birth;
  138. public $email_msgid;
  139. public $email_date;
  140. public $remuneration_requested;
  141. public $remuneration_proposed;
  142. public $fk_recruitment_origin;
  143. public $import_key;
  144. public $model_pdf;
  145. public $status;
  146. // END MODULEBUILDER PROPERTIES
  147. /**
  148. * Constructor
  149. *
  150. * @param DoliDb $db Database handler
  151. */
  152. public function __construct(DoliDB $db)
  153. {
  154. global $conf, $langs;
  155. $this->db = $db;
  156. if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
  157. $this->fields['rowid']['visible'] = 0;
  158. }
  159. if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
  160. $this->fields['entity']['enabled'] = 0;
  161. }
  162. // Example to show how to set values of fields definition dynamically
  163. /*if ($user->rights->recruitment->recruitmentcandidature->read) {
  164. $this->fields['myfield']['visible'] = 1;
  165. $this->fields['myfield']['noteditable'] = 0;
  166. }*/
  167. // Unset fields that are disabled
  168. foreach ($this->fields as $key => $val) {
  169. if (isset($val['enabled']) && empty($val['enabled'])) {
  170. unset($this->fields[$key]);
  171. }
  172. }
  173. // Translate some data of arrayofkeyval
  174. if (is_object($langs)) {
  175. foreach ($this->fields as $key => $val) {
  176. if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
  177. foreach ($val['arrayofkeyval'] as $key2 => $val2) {
  178. $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
  179. }
  180. }
  181. }
  182. }
  183. }
  184. /**
  185. * Create object into database
  186. *
  187. * @param User $user User that creates
  188. * @param bool $notrigger false=launch triggers after, true=disable triggers
  189. * @return int <0 if KO, Id of created object if OK
  190. */
  191. public function create(User $user, $notrigger = false)
  192. {
  193. return $this->createCommon($user, $notrigger);
  194. }
  195. /**
  196. * Clone an object into another one
  197. *
  198. * @param User $user User that creates
  199. * @param int $fromid Id of object to clone
  200. * @return mixed New object created, <0 if KO
  201. */
  202. public function createFromClone(User $user, $fromid)
  203. {
  204. global $langs, $extrafields;
  205. $error = 0;
  206. dol_syslog(__METHOD__, LOG_DEBUG);
  207. $object = new self($this->db);
  208. $this->db->begin();
  209. // Load source object
  210. $result = $object->fetchCommon($fromid);
  211. if ($result > 0 && !empty($object->table_element_line)) {
  212. $object->fetchLines();
  213. }
  214. // get lines so they will be clone
  215. //foreach($this->lines as $line)
  216. // $line->fetch_optionals();
  217. // Reset some properties
  218. unset($object->id);
  219. unset($object->fk_user_creat);
  220. unset($object->import_key);
  221. // Clear fields
  222. if (property_exists($object, 'ref')) {
  223. $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
  224. }
  225. if (property_exists($object, 'label')) {
  226. $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
  227. }
  228. if (property_exists($object, 'status')) {
  229. $object->status = self::STATUS_DRAFT;
  230. }
  231. if (property_exists($object, 'date_creation')) {
  232. $object->date_creation = dol_now();
  233. }
  234. if (property_exists($object, 'date_modification')) {
  235. $object->date_modification = null;
  236. }
  237. // ...
  238. // Clear extrafields that are unique
  239. if (is_array($object->array_options) && count($object->array_options) > 0) {
  240. $extrafields->fetch_name_optionals_label($this->table_element);
  241. foreach ($object->array_options as $key => $option) {
  242. $shortkey = preg_replace('/options_/', '', $key);
  243. if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
  244. //var_dump($key);
  245. //var_dump($clonedObj->array_options[$key]); exit;
  246. unset($object->array_options[$key]);
  247. }
  248. }
  249. }
  250. // Create clone
  251. $object->context['createfromclone'] = 'createfromclone';
  252. $result = $object->createCommon($user);
  253. if ($result < 0) {
  254. $error++;
  255. $this->error = $object->error;
  256. $this->errors = $object->errors;
  257. }
  258. if (!$error) {
  259. // copy internal contacts
  260. if ($this->copy_linked_contact($object, 'internal') < 0) {
  261. $error++;
  262. }
  263. }
  264. if (!$error) {
  265. // copy external contacts if same company
  266. if (property_exists($this, 'socid') && $this->socid == $object->socid) {
  267. if ($this->copy_linked_contact($object, 'external') < 0) {
  268. $error++;
  269. }
  270. }
  271. }
  272. unset($object->context['createfromclone']);
  273. // End
  274. if (!$error) {
  275. $this->db->commit();
  276. return $object;
  277. } else {
  278. $this->db->rollback();
  279. return -1;
  280. }
  281. }
  282. /**
  283. * Load object in memory from the database
  284. *
  285. * @param int $id Id object
  286. * @param string $ref Ref
  287. * @param string $email_msgid Email msgid
  288. * @return int <0 if KO, 0 if not found, >0 if OK
  289. */
  290. public function fetch($id, $ref = null, $email_msgid = '')
  291. {
  292. $morewhere = '';
  293. if ($email_msgid) {
  294. $morewhere = " AND email_msgid = '".$this->db->escape($email_msgid)."'";
  295. }
  296. $result = $this->fetchCommon($id, $ref, $morewhere);
  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();
  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. return $this->deleteCommon($user, $notrigger);
  403. //return $this->deleteCommon($user, $notrigger, 1);
  404. }
  405. /**
  406. * Delete a line of object in database
  407. *
  408. * @param User $user User that delete
  409. * @param int $idline Id of line to delete
  410. * @param bool $notrigger false=launch triggers after, true=disable triggers
  411. * @return int >0 if OK, <0 if KO
  412. */
  413. public function deleteLine(User $user, $idline, $notrigger = false)
  414. {
  415. if ($this->status < 0) {
  416. $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
  417. return -2;
  418. }
  419. return $this->deleteLineCommon($user, $idline, $notrigger);
  420. }
  421. /**
  422. * Validate object
  423. *
  424. * @param User $user User making status change
  425. * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
  426. * @return int <=0 if OK, 0=Nothing done, >0 if KO
  427. */
  428. public function validate($user, $notrigger = 0)
  429. {
  430. global $conf, $langs;
  431. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  432. $error = 0;
  433. // Protection
  434. if ($this->status == self::STATUS_VALIDATED) {
  435. dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
  436. return 0;
  437. }
  438. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->recruitment->recruitmentcandidature->write))
  439. || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->recruitment->recruitmentcandidature->recruitmentcandidature_advance->validate))))
  440. {
  441. $this->error='NotEnoughPermissions';
  442. dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
  443. return -1;
  444. }*/
  445. $now = dol_now();
  446. $this->db->begin();
  447. // Define new ref
  448. if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
  449. $num = $this->getNextNumRef();
  450. } else {
  451. $num = $this->ref;
  452. }
  453. $this->newref = $num;
  454. if (!empty($num)) {
  455. // Validate
  456. $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
  457. $sql .= " SET ref = '".$this->db->escape($num)."',";
  458. $sql .= " status = ".self::STATUS_VALIDATED;
  459. if (!empty($this->fields['date_validation'])) {
  460. $sql .= ", date_validation = '".$this->db->idate($now)."',";
  461. }
  462. if (!empty($this->fields['fk_user_valid'])) {
  463. $sql .= ", fk_user_valid = ".$user->id;
  464. }
  465. $sql .= " WHERE rowid = ".((int) $this->id);
  466. dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
  467. $resql = $this->db->query($sql);
  468. if (!$resql) {
  469. dol_print_error($this->db);
  470. $this->error = $this->db->lasterror();
  471. $error++;
  472. }
  473. if (!$error && !$notrigger) {
  474. // Call trigger
  475. $result = $this->call_trigger('RECRUITMENTCANDIDATURE_VALIDATE', $user);
  476. if ($result < 0) {
  477. $error++;
  478. }
  479. // End call triggers
  480. }
  481. }
  482. if (!$error) {
  483. $this->oldref = $this->ref;
  484. // Rename directory if dir was a temporary ref
  485. if (preg_match('/^[\(]?PROV/i', $this->ref)) {
  486. // Now we rename also files into index
  487. $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'recruitmentcandidature/".$this->db->escape($this->newref)."'";
  488. $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'recruitmentcandidature/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
  489. $resql = $this->db->query($sql);
  490. if (!$resql) {
  491. $error++; $this->error = $this->db->lasterror();
  492. }
  493. // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
  494. $oldref = dol_sanitizeFileName($this->ref);
  495. $newref = dol_sanitizeFileName($num);
  496. $dirsource = $conf->recruitment->dir_output.'/recruitmentcandidature/'.$oldref;
  497. $dirdest = $conf->recruitment->dir_output.'/recruitmentcandidature/'.$newref;
  498. if (!$error && file_exists($dirsource)) {
  499. dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
  500. if (@rename($dirsource, $dirdest)) {
  501. dol_syslog("Rename ok");
  502. // Rename docs starting with $oldref with $newref
  503. $listoffiles = dol_dir_list($conf->recruitment->dir_output.'/recruitmentcandidature/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
  504. foreach ($listoffiles as $fileentry) {
  505. $dirsource = $fileentry['name'];
  506. $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
  507. $dirsource = $fileentry['path'].'/'.$dirsource;
  508. $dirdest = $fileentry['path'].'/'.$dirdest;
  509. @rename($dirsource, $dirdest);
  510. }
  511. }
  512. }
  513. }
  514. }
  515. // Set new ref and current status
  516. if (!$error) {
  517. $this->ref = $num;
  518. $this->status = self::STATUS_VALIDATED;
  519. }
  520. if (!$error) {
  521. $this->db->commit();
  522. return 1;
  523. } else {
  524. $this->db->rollback();
  525. return -1;
  526. }
  527. }
  528. /**
  529. * Set draft status
  530. *
  531. * @param User $user Object user that modify
  532. * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
  533. * @return int <0 if KO, >0 if OK
  534. */
  535. public function setDraft($user, $notrigger = 0)
  536. {
  537. // Protection
  538. if ($this->status <= self::STATUS_DRAFT) {
  539. return 0;
  540. }
  541. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->recruitment->write))
  542. || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->recruitment->recruitment_advance->validate))))
  543. {
  544. $this->error='Permission denied';
  545. return -1;
  546. }*/
  547. return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'RECRUITMENTCANDIDATURE_UNVALIDATE');
  548. }
  549. /**
  550. * Set cancel status
  551. *
  552. * @param User $user Object user that modify
  553. * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
  554. * @return int <0 if KO, 0=Nothing done, >0 if OK
  555. */
  556. public function cancel($user, $notrigger = 0)
  557. {
  558. // Protection
  559. if ($this->status != self::STATUS_VALIDATED) {
  560. return 0;
  561. }
  562. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->recruitment->write))
  563. || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->recruitment->recruitment_advance->validate))))
  564. {
  565. $this->error='Permission denied';
  566. return -1;
  567. }*/
  568. return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'RECRUITMENTCANDIDATURE_CLOSE');
  569. }
  570. /**
  571. * Set back to validated status
  572. *
  573. * @param User $user Object user that modify
  574. * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
  575. * @return int <0 if KO, 0=Nothing done, >0 if OK
  576. */
  577. public function reopen($user, $notrigger = 0)
  578. {
  579. // Protection
  580. if ($this->status != self::STATUS_REFUSED && $this->status != self::STATUS_CANCELED && $this->status != self::STATUS_CONTRACT_REFUSED) {
  581. return 0;
  582. }
  583. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->recruitment->write))
  584. || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->recruitment->recruitment_advance->validate))))
  585. {
  586. $this->error='Permission denied';
  587. return -1;
  588. }*/
  589. return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'RECRUITMENTCANDIDATURE_REOPEN');
  590. }
  591. /**
  592. * Return a link to the object card (with optionaly the picto)
  593. *
  594. * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
  595. * @param string $option On what the link point to ('nolink', ...)
  596. * @param int $notooltip 1=Disable tooltip
  597. * @param string $morecss Add more css on link
  598. * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
  599. * @return string String with URL
  600. */
  601. public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
  602. {
  603. global $conf, $langs, $hookmanager;
  604. if (!empty($conf->dol_no_mouse_hover)) {
  605. $notooltip = 1; // Force disable tooltips
  606. }
  607. $result = '';
  608. $label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("RecruitmentCandidature").'</u>';
  609. if (isset($this->status)) {
  610. $label .= ' '.$this->getLibStatut(5);
  611. }
  612. $label .= '<br>';
  613. $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
  614. $label .= '<br><b>'.$langs->trans('Email').':</b> '.$this->email;
  615. $label .= '<br><b>'.$langs->trans('Name').':</b> '.$this->getFullName($langs);
  616. $url = dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?id='.$this->id;
  617. if ($option != 'nolink') {
  618. // Add param to save lastsearch_values or not
  619. $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
  620. if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
  621. $add_save_lastsearch_values = 1;
  622. }
  623. if ($add_save_lastsearch_values) {
  624. $url .= '&save_lastsearch_values=1';
  625. }
  626. }
  627. $linkclose = '';
  628. if (empty($notooltip)) {
  629. if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
  630. $label = $langs->trans("ShowRecruitmentCandidature");
  631. $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
  632. }
  633. $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
  634. $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
  635. } else {
  636. $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
  637. }
  638. $linkstart = '<a href="'.$url.'"';
  639. $linkstart .= $linkclose.'>';
  640. $linkend = '</a>';
  641. $result .= $linkstart;
  642. if (empty($this->showphoto_on_popup)) {
  643. if ($withpicto) {
  644. $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);
  645. }
  646. } else {
  647. if ($withpicto) {
  648. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  649. list($class, $module) = explode('@', $this->picto);
  650. $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
  651. $filearray = dol_dir_list($upload_dir, "files");
  652. $filename = $filearray[0]['name'];
  653. if (!empty($filename)) {
  654. $pospoint = strpos($filearray[0]['name'], '.');
  655. $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
  656. if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
  657. $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>';
  658. } else {
  659. $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>';
  660. }
  661. $result .= '</div>';
  662. } else {
  663. $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);
  664. }
  665. }
  666. }
  667. if ($withpicto != 2) {
  668. $result .= $this->ref;
  669. }
  670. $result .= $linkend;
  671. //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
  672. global $action, $hookmanager;
  673. $hookmanager->initHooks(array('recruitmentcandidaturedao'));
  674. $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
  675. $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
  676. if ($reshook > 0) {
  677. $result = $hookmanager->resPrint;
  678. } else {
  679. $result .= $hookmanager->resPrint;
  680. }
  681. return $result;
  682. }
  683. /**
  684. * Return label of the status
  685. *
  686. * @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
  687. * @return string Label of status
  688. */
  689. public function getLibStatut($mode = 0)
  690. {
  691. return $this->LibStatut($this->status, $mode);
  692. }
  693. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  694. /**
  695. * Return the status
  696. *
  697. * @param int $status Id status
  698. * @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
  699. * @return string Label of status
  700. */
  701. public function LibStatut($status, $mode = 0)
  702. {
  703. // phpcs:enable
  704. if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
  705. global $langs;
  706. //$langs->load("recruitment@recruitment");
  707. $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
  708. $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Received').' ('.$langs->transnoentitiesnoconv("InterviewToDo").')';
  709. $this->labelStatus[self::STATUS_CONTRACT_PROPOSED] = $langs->transnoentitiesnoconv('ContractProposed');
  710. $this->labelStatus[self::STATUS_CONTRACT_SIGNED] = $langs->transnoentitiesnoconv('ContractSigned');
  711. $this->labelStatus[self::STATUS_CONTRACT_REFUSED] = $langs->transnoentitiesnoconv('ContractRefused');
  712. $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
  713. $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled');
  714. $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
  715. $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Received');
  716. $this->labelStatusShort[self::STATUS_CONTRACT_PROPOSED] = $langs->transnoentitiesnoconv('ContractProposed');
  717. $this->labelStatusShort[self::STATUS_CONTRACT_SIGNED] = $langs->transnoentitiesnoconv('ContractSigned');
  718. $this->labelStatusShort[self::STATUS_CONTRACT_REFUSED] = $langs->transnoentitiesnoconv('ContractRefused');
  719. $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
  720. $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled');
  721. }
  722. $statusType = 'status'.$status;
  723. //if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
  724. if ($status == self::STATUS_CANCELED) {
  725. $statusType = 'status9';
  726. }
  727. if ($status == self::STATUS_CONTRACT_PROPOSED) {
  728. $statusType = 'status4';
  729. }
  730. if ($status == self::STATUS_CONTRACT_SIGNED) {
  731. $statusType = 'status6';
  732. }
  733. if ($status == self::STATUS_REFUSED) {
  734. $statusType = 'status10';
  735. }
  736. return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
  737. }
  738. /**
  739. * Load the info information in the object
  740. *
  741. * @param int $id Id of object
  742. * @return void
  743. */
  744. public function info($id)
  745. {
  746. $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
  747. $sql .= ' fk_user_creat, fk_user_modif';
  748. $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
  749. $sql .= ' WHERE t.rowid = '.((int) $id);
  750. $result = $this->db->query($sql);
  751. if ($result) {
  752. if ($this->db->num_rows($result)) {
  753. $obj = $this->db->fetch_object($result);
  754. $this->id = $obj->rowid;
  755. $this->user_creation_id = $obj->fk_user_creat;
  756. $this->user_modification_id = $obj->fk_user_modif;
  757. $this->date_creation = $this->db->jdate($obj->datec);
  758. $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
  759. }
  760. $this->db->free($result);
  761. } else {
  762. dol_print_error($this->db);
  763. }
  764. }
  765. /**
  766. * Initialise object with example values
  767. * Id must be 0 if object instance is a specimen
  768. *
  769. * @return void
  770. */
  771. public function initAsSpecimen()
  772. {
  773. $this->initAsSpecimenCommon();
  774. }
  775. /**
  776. * Create an array of lines
  777. *
  778. * @return array|int array of lines if OK, <0 if KO
  779. */
  780. public function getLinesArray()
  781. {
  782. $this->lines = array();
  783. $objectline = new RecruitmentCandidatureLine($this->db);
  784. $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_recruitmentcandidature = '.((int) $this->id)));
  785. if (is_numeric($result)) {
  786. $this->error = $this->error;
  787. $this->errors = $this->errors;
  788. return $result;
  789. } else {
  790. $this->lines = $result;
  791. return $this->lines;
  792. }
  793. }
  794. /**
  795. * Returns the reference to the following non used object depending on the active numbering module.
  796. *
  797. * @return string Object free reference
  798. */
  799. public function getNextNumRef()
  800. {
  801. global $langs, $conf;
  802. $langs->load("recruitment@recruitment");
  803. if (empty($conf->global->RECRUITMENT_RECRUITMENTCANDIDATURE_ADDON)) {
  804. $conf->global->RECRUITMENT_RECRUITMENTCANDIDATURE_ADDON = 'mod_recruitmentcandidature_standard';
  805. }
  806. if (!empty($conf->global->RECRUITMENT_RECRUITMENTCANDIDATURE_ADDON)) {
  807. $mybool = false;
  808. $file = $conf->global->RECRUITMENT_RECRUITMENTCANDIDATURE_ADDON.".php";
  809. $classname = $conf->global->RECRUITMENT_RECRUITMENTCANDIDATURE_ADDON;
  810. // Include file with class
  811. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  812. foreach ($dirmodels as $reldir) {
  813. $dir = dol_buildpath($reldir."core/modules/recruitment/");
  814. // Load file with numbering class (if found)
  815. $mybool |= @include_once $dir.$file;
  816. }
  817. if ($mybool === false) {
  818. dol_print_error('', "Failed to include file ".$file);
  819. return '';
  820. }
  821. if (class_exists($classname)) {
  822. $obj = new $classname();
  823. $numref = $obj->getNextValue($this);
  824. if ($numref != '' && $numref != '-1') {
  825. return $numref;
  826. } else {
  827. $this->error = $obj->error;
  828. //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
  829. return "";
  830. }
  831. } else {
  832. print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
  833. return "";
  834. }
  835. } else {
  836. print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
  837. return "";
  838. }
  839. }
  840. /**
  841. * Create a document onto disk according to template module.
  842. *
  843. * @param string $modele Force template to use ('' to not force)
  844. * @param Translate $outputlangs objet lang a utiliser pour traduction
  845. * @param int $hidedetails Hide details of lines
  846. * @param int $hidedesc Hide description
  847. * @param int $hideref Hide ref
  848. * @param null|array $moreparams Array to provide more information
  849. * @return int 0 if KO, 1 if OK
  850. */
  851. public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
  852. {
  853. global $conf, $langs;
  854. $result = 0;
  855. $includedocgeneration = 0;
  856. $langs->load("recruitment@recruitment");
  857. if (!dol_strlen($modele)) {
  858. if (!empty($conf->global->RECRUITMENTCANDIDATURE_ADDON_PDF)) {
  859. $modele = $conf->global->RECRUITMENTCANDIDATURE_ADDON_PDF;
  860. } else {
  861. $modele = ''; // No default value. For job application, we allow to disable all PDF generation
  862. }
  863. }
  864. $modelpath = "core/modules/recruitment/doc/";
  865. if ($includedocgeneration && !empty($modele)) {
  866. $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
  867. }
  868. return $result;
  869. }
  870. /**
  871. * Action executed by scheduler
  872. * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters'
  873. * Use public function doScheduledJob($param1, $param2, ...) to get parameters
  874. *
  875. * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
  876. */
  877. public function doScheduledJob()
  878. {
  879. global $conf, $langs;
  880. //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
  881. $error = 0;
  882. $this->output = '';
  883. $this->error = '';
  884. dol_syslog(__METHOD__, LOG_DEBUG);
  885. $now = dol_now();
  886. $this->db->begin();
  887. // ...
  888. $this->db->commit();
  889. return $error;
  890. }
  891. }
  892. require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
  893. /**
  894. * Class RecruitmentCandidatureLine. You can also remove this and generate a CRUD class for lines objects.
  895. */
  896. class RecruitmentCandidatureLine extends CommonObjectLine
  897. {
  898. // To complete with content of an object RecruitmentCandidatureLine
  899. // We should have a field rowid, fk_recruitmentcandidature and position
  900. /**
  901. * Constructor
  902. *
  903. * @param DoliDb $db Database handler
  904. */
  905. public function __construct(DoliDB $db)
  906. {
  907. $this->db = $db;
  908. }
  909. }