api_recruitment.class.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <?php
  2. /* Copyright (C) 2022 Thibault FOUCART <support@ptibogxiv.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. use Luracast\Restler\RestException;
  18. dol_include_once('/recruitment/class/recruitmentjobposition.class.php');
  19. dol_include_once('/recruitment/class/recruitmentcandidature.class.php');
  20. /**
  21. * \file recruitment/class/api_recruitment.class.php
  22. * \ingroup recruitment
  23. * \brief File for API management of recruitment.
  24. */
  25. /**
  26. * API class for recruitment
  27. *
  28. * @access protected
  29. * @class DolibarrApiAccess {@requires user,external}
  30. */
  31. class Recruitment extends DolibarrApi
  32. {
  33. /**
  34. * @var RecruitmentJobPosition $jobposition {@type RecruitmentJobPosition}
  35. */
  36. public $jobposition;
  37. /**
  38. * @var RecruitmentCandidature $candidature {@type RecruitmentCandidature}
  39. */
  40. public $candidature;
  41. /**
  42. * Constructor
  43. *
  44. * @url GET /
  45. *
  46. */
  47. public function __construct()
  48. {
  49. global $db;
  50. $this->db = $db;
  51. $this->jobposition = new RecruitmentJobPosition($this->db);
  52. $this->candidature = new RecruitmentCandidature($this->db);
  53. }
  54. /**
  55. * Get properties of a jobposition object
  56. *
  57. * Return an array with jobposition informations
  58. *
  59. * @param int $id ID of jobposition
  60. * @return array|mixed data without useless information
  61. *
  62. * @url GET jobposition/{id}
  63. *
  64. * @throws RestException 401 Not allowed
  65. * @throws RestException 404 Not found
  66. */
  67. public function getJobPosition($id)
  68. {
  69. if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->read) {
  70. throw new RestException(401);
  71. }
  72. $result = $this->jobposition->fetch($id);
  73. if (!$result) {
  74. throw new RestException(404, 'JobPosition not found');
  75. }
  76. if (!DolibarrApi::_checkAccessToResource('recruitment', $this->jobposition->id, 'recruitment_recruitmentjobposition')) {
  77. throw new RestException(401, 'Access to instance id='.$this->jobposition->id.' of object not allowed for login '.DolibarrApiAccess::$user->login);
  78. }
  79. return $this->_cleanObjectDatas($this->jobposition);
  80. }
  81. /**
  82. * Get properties of a candidature object
  83. *
  84. * Return an array with candidature informations
  85. *
  86. * @param int $id ID of candidature
  87. * @return array|mixed data without useless information
  88. *
  89. * @url GET candidature/{id}
  90. *
  91. * @throws RestException 401 Not allowed
  92. * @throws RestException 404 Not found
  93. */
  94. public function getCandidature($id)
  95. {
  96. if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->read) {
  97. throw new RestException(401);
  98. }
  99. $result = $this->candidature->fetch($id);
  100. if (!$result) {
  101. throw new RestException(404, 'Candidature not found');
  102. }
  103. if (!DolibarrApi::_checkAccessToResource('recruitment', $this->candidature->id, 'recruitment_recruitmentcandidature')) {
  104. throw new RestException(401, 'Access to instance id='.$this->candidature->id.' of object not allowed for login '.DolibarrApiAccess::$user->login);
  105. }
  106. return $this->_cleanObjectDatas($this->candidature);
  107. }
  108. /**
  109. * List jobpositions
  110. *
  111. * Get a list of jobpositions
  112. *
  113. * @param string $sortfield Sort field
  114. * @param string $sortorder Sort order
  115. * @param int $limit Limit for list
  116. * @param int $page Page number
  117. * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
  118. * @return array Array of order objects
  119. *
  120. * @throws RestException
  121. *
  122. * @url GET /jobposition/
  123. */
  124. public function indexJobPosition($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
  125. {
  126. global $db, $conf;
  127. $obj_ret = array();
  128. $tmpobject = new RecruitmentJobPosition($this->db);
  129. if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->read) {
  130. throw new RestException(401);
  131. }
  132. $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : '';
  133. $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object
  134. // If the internal user must only see his customers, force searching by him
  135. $search_sale = 0;
  136. if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) {
  137. $search_sale = DolibarrApiAccess::$user->id;
  138. }
  139. $sql = "SELECT t.rowid";
  140. if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
  141. $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
  142. }
  143. $sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t";
  144. if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
  145. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
  146. }
  147. $sql .= " WHERE 1 = 1";
  148. // Example of use $mode
  149. //if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
  150. //if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
  151. if ($tmpobject->ismultientitymanaged) {
  152. $sql .= ' AND t.entity IN ('.getEntity($tmpobject->element).')';
  153. }
  154. if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
  155. $sql .= " AND t.fk_soc = sc.fk_soc";
  156. }
  157. if ($restrictonsocid && $socid) {
  158. $sql .= " AND t.fk_soc = ".((int) $socid);
  159. }
  160. if ($restrictonsocid && $search_sale > 0) {
  161. $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
  162. }
  163. // Insert sale filter
  164. if ($restrictonsocid && $search_sale > 0) {
  165. $sql .= " AND sc.fk_user = ".((int) $search_sale);
  166. }
  167. if ($sqlfilters) {
  168. $errormessage = '';
  169. $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
  170. if ($errormessage) {
  171. throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
  172. }
  173. }
  174. $sql .= $this->db->order($sortfield, $sortorder);
  175. if ($limit) {
  176. if ($page < 0) {
  177. $page = 0;
  178. }
  179. $offset = $limit * $page;
  180. $sql .= $this->db->plimit($limit + 1, $offset);
  181. }
  182. $result = $this->db->query($sql);
  183. $i = 0;
  184. if ($result) {
  185. $num = $this->db->num_rows($result);
  186. while ($i < $num) {
  187. $obj = $this->db->fetch_object($result);
  188. $tmp_object = new RecruitmentJobPosition($this->db);
  189. if ($tmp_object->fetch($obj->rowid)) {
  190. $obj_ret[] = $this->_cleanObjectDatas($tmp_object);
  191. }
  192. $i++;
  193. }
  194. } else {
  195. throw new RestException(503, 'Error when retrieving jobposition list: '.$this->db->lasterror());
  196. }
  197. if (!count($obj_ret)) {
  198. throw new RestException(404, 'No jobposition found');
  199. }
  200. return $obj_ret;
  201. }
  202. /**
  203. * List candatures
  204. *
  205. * Get a list of candidatures
  206. *
  207. * @param string $sortfield Sort field
  208. * @param string $sortorder Sort order
  209. * @param int $limit Limit for list
  210. * @param int $page Page number
  211. * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
  212. * @return array Array of order objects
  213. *
  214. * @throws RestException
  215. *
  216. * @url GET /candidature/
  217. */
  218. public function indexCandidature($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
  219. {
  220. global $db, $conf;
  221. $obj_ret = array();
  222. $tmpobject = new RecruitmentCandidature($this->db);
  223. if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->read) {
  224. throw new RestException(401);
  225. }
  226. $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : '';
  227. $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object
  228. // If the internal user must only see his customers, force searching by him
  229. $search_sale = 0;
  230. if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) {
  231. $search_sale = DolibarrApiAccess::$user->id;
  232. }
  233. $sql = "SELECT t.rowid";
  234. if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
  235. $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
  236. }
  237. $sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t";
  238. if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
  239. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
  240. }
  241. $sql .= " WHERE 1 = 1";
  242. // Example of use $mode
  243. //if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
  244. //if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
  245. if ($tmpobject->ismultientitymanaged) {
  246. $sql .= ' AND t.entity IN ('.getEntity($tmpobject->element).')';
  247. }
  248. if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
  249. $sql .= " AND t.fk_soc = sc.fk_soc";
  250. }
  251. if ($restrictonsocid && $socid) {
  252. $sql .= " AND t.fk_soc = ".((int) $socid);
  253. }
  254. if ($restrictonsocid && $search_sale > 0) {
  255. $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
  256. }
  257. // Insert sale filter
  258. if ($restrictonsocid && $search_sale > 0) {
  259. $sql .= " AND sc.fk_user = ".((int) $search_sale);
  260. }
  261. if ($sqlfilters) {
  262. $errormessage = '';
  263. $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
  264. if ($errormessage) {
  265. throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
  266. }
  267. }
  268. $sql .= $this->db->order($sortfield, $sortorder);
  269. if ($limit) {
  270. if ($page < 0) {
  271. $page = 0;
  272. }
  273. $offset = $limit * $page;
  274. $sql .= $this->db->plimit($limit + 1, $offset);
  275. }
  276. $result = $this->db->query($sql);
  277. $i = 0;
  278. if ($result) {
  279. $num = $this->db->num_rows($result);
  280. while ($i < $num) {
  281. $obj = $this->db->fetch_object($result);
  282. $tmp_object = new RecruitmentCandidature($this->db);
  283. if ($tmp_object->fetch($obj->rowid)) {
  284. $obj_ret[] = $this->_cleanObjectDatas($tmp_object);
  285. }
  286. $i++;
  287. }
  288. } else {
  289. throw new RestException(503, 'Error when retrieving candidature list: '.$this->db->lasterror());
  290. }
  291. if (!count($obj_ret)) {
  292. throw new RestException(404, 'No candidature found');
  293. }
  294. return $obj_ret;
  295. }
  296. /**
  297. * Create jobposition object
  298. *
  299. * @param array $request_data Request datas
  300. * @return int ID of jobposition
  301. *
  302. * @throws RestException
  303. *
  304. * @url POST jobposition/
  305. */
  306. public function postJobPosition($request_data = null)
  307. {
  308. if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) {
  309. throw new RestException(401);
  310. }
  311. // Check mandatory fields
  312. $result = $this->_validate($request_data);
  313. foreach ($request_data as $field => $value) {
  314. $this->jobposition->$field = $this->_checkValForAPI($field, $value, $this->jobposition);
  315. }
  316. // Clean data
  317. // $this->jobposition->abc = sanitizeVal($this->jobposition->abc, 'alphanohtml');
  318. if ($this->jobposition->create(DolibarrApiAccess::$user)<0) {
  319. throw new RestException(500, "Error creating jobposition", array_merge(array($this->jobposition->error), $this->jobposition->errors));
  320. }
  321. return $this->jobposition->id;
  322. }
  323. /**
  324. * Create candidature object
  325. *
  326. * @param array $request_data Request datas
  327. * @return int ID of candidature
  328. *
  329. * @throws RestException
  330. *
  331. * @url POST candidature/
  332. */
  333. public function postCandidature($request_data = null)
  334. {
  335. if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) {
  336. throw new RestException(401);
  337. }
  338. // Check mandatory fields
  339. $result = $this->_validate($request_data);
  340. foreach ($request_data as $field => $value) {
  341. $this->jobposition->$field = $this->_checkValForAPI($field, $value, $this->jobposition);
  342. }
  343. // Clean data
  344. // $this->jobposition->abc = sanitizeVal($this->jobposition->abc, 'alphanohtml');
  345. if ($this->candidature->create(DolibarrApiAccess::$user)<0) {
  346. throw new RestException(500, "Error creating candidature", array_merge(array($this->candidature->error), $this->candidature->errors));
  347. }
  348. return $this->candidature->id;
  349. }
  350. /**
  351. * Update jobposition
  352. *
  353. * @param int $id Id of jobposition to update
  354. * @param array $request_data Datas
  355. * @return int
  356. *
  357. * @throws RestException
  358. *
  359. * @url PUT jobposition/{id}
  360. */
  361. public function putJobPosition($id, $request_data = null)
  362. {
  363. if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) {
  364. throw new RestException(401);
  365. }
  366. $result = $this->jobposition->fetch($id);
  367. if (!$result) {
  368. throw new RestException(404, 'jobposition not found');
  369. }
  370. if (!DolibarrApi::_checkAccessToResource('recruitment', $this->jobposition->id, 'recruitment_recruitmentjobposition')) {
  371. throw new RestException(401, 'Access to instance id='.$this->jobposition->id.' of object not allowed for login '.DolibarrApiAccess::$user->login);
  372. }
  373. foreach ($request_data as $field => $value) {
  374. if ($field == 'id') {
  375. continue;
  376. }
  377. $this->jobposition->$field = $this->_checkValForAPI($field, $value, $this->jobposition);
  378. }
  379. // Clean data
  380. // $this->jobposition->abc = sanitizeVal($this->jobposition->abc, 'alphanohtml');
  381. if ($this->jobposition->update(DolibarrApiAccess::$user, false) > 0) {
  382. return $this->getJobPosition($id);
  383. } else {
  384. throw new RestException(500, $this->jobposition->error);
  385. }
  386. }
  387. /**
  388. * Update candidature
  389. *
  390. * @param int $id Id of candidature to update
  391. * @param array $request_data Datas
  392. * @return int
  393. *
  394. * @throws RestException
  395. *
  396. * @url PUT candidature/{id}
  397. */
  398. public function putCandidature($id, $request_data = null)
  399. {
  400. if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) {
  401. throw new RestException(401);
  402. }
  403. $result = $this->candidature->fetch($id);
  404. if (!$result) {
  405. throw new RestException(404, 'candidature not found');
  406. }
  407. if (!DolibarrApi::_checkAccessToResource('recruitment', $this->candidature->id, 'recruitment_recruitmentcandidature')) {
  408. throw new RestException(401, 'Access to instance id='.$this->candidature->id.' of object not allowed for login '.DolibarrApiAccess::$user->login);
  409. }
  410. foreach ($request_data as $field => $value) {
  411. if ($field == 'id') {
  412. continue;
  413. }
  414. $this->candidature->$field = $this->_checkValForAPI($field, $value, $this->candidature);
  415. }
  416. // Clean data
  417. // $this->jobposition->abc = sanitizeVal($this->jobposition->abc, 'alphanohtml');
  418. if ($this->candidature->update(DolibarrApiAccess::$user, false) > 0) {
  419. return $this->getCandidature($id);
  420. } else {
  421. throw new RestException(500, $this->candidature->error);
  422. }
  423. }
  424. /**
  425. * Delete jobposition
  426. *
  427. * @param int $id jobposition ID
  428. * @return array
  429. *
  430. * @throws RestException
  431. *
  432. * @url DELETE jobposition/{id}
  433. */
  434. public function deleteJobPosition($id)
  435. {
  436. if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->delete) {
  437. throw new RestException(401);
  438. }
  439. $result = $this->jobposition->fetch($id);
  440. if (!$result) {
  441. throw new RestException(404, 'jobposition not found');
  442. }
  443. if (!DolibarrApi::_checkAccessToResource('recruitment', $this->jobposition->id, 'recruitment_recruitmentjobposition')) {
  444. throw new RestException(401, 'Access to instance id='.$this->jobposition->id.' of object not allowed for login '.DolibarrApiAccess::$user->login);
  445. }
  446. if (!$this->jobposition->delete(DolibarrApiAccess::$user)) {
  447. throw new RestException(500, 'Error when deleting jobposition : '.$this->jobposition->error);
  448. }
  449. return array(
  450. 'success' => array(
  451. 'code' => 200,
  452. 'message' => 'jobposition deleted'
  453. )
  454. );
  455. }
  456. /**
  457. * Delete candidature
  458. *
  459. * @param int $id candidature ID
  460. * @return array
  461. *
  462. * @throws RestException
  463. *
  464. * @url DELETE candidature/{id}
  465. */
  466. public function deleteCandidature($id)
  467. {
  468. if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->delete) {
  469. throw new RestException(401);
  470. }
  471. $result = $this->candidature->fetch($id);
  472. if (!$result) {
  473. throw new RestException(404, 'candidature not found');
  474. }
  475. if (!DolibarrApi::_checkAccessToResource('recruitment', $this->candidature->id, 'recruitment_recruitmentcandidature')) {
  476. throw new RestException(401, 'Access to instance id='.$this->candidature->id.' of object not allowed for login '.DolibarrApiAccess::$user->login);
  477. }
  478. if (!$this->candidature->delete(DolibarrApiAccess::$user)) {
  479. throw new RestException(500, 'Error when deleting candidature : '.$this->candidature->error);
  480. }
  481. return array(
  482. 'success' => array(
  483. 'code' => 200,
  484. 'message' => 'candidature deleted'
  485. )
  486. );
  487. }
  488. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
  489. /**
  490. * Clean sensible object datas
  491. *
  492. * @param Object $object Object to clean
  493. * @return Object Object with cleaned properties
  494. */
  495. protected function _cleanObjectDatas($object)
  496. {
  497. // phpcs:enable
  498. $object = parent::_cleanObjectDatas($object);
  499. unset($object->rowid);
  500. unset($object->canvas);
  501. /*unset($object->name);
  502. unset($object->lastname);
  503. unset($object->firstname);
  504. unset($object->civility_id);
  505. unset($object->statut);
  506. unset($object->state);
  507. unset($object->state_id);
  508. unset($object->state_code);
  509. unset($object->region);
  510. unset($object->region_code);
  511. unset($object->country);
  512. unset($object->country_id);
  513. unset($object->country_code);
  514. unset($object->barcode_type);
  515. unset($object->barcode_type_code);
  516. unset($object->barcode_type_label);
  517. unset($object->barcode_type_coder);
  518. unset($object->total_ht);
  519. unset($object->total_tva);
  520. unset($object->total_localtax1);
  521. unset($object->total_localtax2);
  522. unset($object->total_ttc);
  523. unset($object->fk_account);
  524. unset($object->comments);
  525. unset($object->note);
  526. unset($object->mode_reglement_id);
  527. unset($object->cond_reglement_id);
  528. unset($object->cond_reglement);
  529. unset($object->shipping_method_id);
  530. unset($object->fk_incoterms);
  531. unset($object->label_incoterms);
  532. unset($object->location_incoterms);
  533. */
  534. // If object has lines, remove $db property
  535. if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) {
  536. $nboflines = count($object->lines);
  537. for ($i = 0; $i < $nboflines; $i++) {
  538. $this->_cleanObjectDatas($object->lines[$i]);
  539. unset($object->lines[$i]->lines);
  540. unset($object->lines[$i]->note);
  541. }
  542. }
  543. return $object;
  544. }
  545. /**
  546. * Validate fields before create or update object
  547. *
  548. * @param array $data Array of data to validate
  549. * @return array
  550. *
  551. * @throws RestException
  552. */
  553. private function _validate($data)
  554. {
  555. $jobposition = array();
  556. foreach ($this->jobposition->fields as $field => $propfield) {
  557. if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) {
  558. continue; // Not a mandatory field
  559. }
  560. if (!isset($data[$field])) {
  561. throw new RestException(400, "$field field missing");
  562. }
  563. $jobposition[$field] = $data[$field];
  564. }
  565. return $jobposition;
  566. }
  567. }