dolibarr 23.0.4
api_holidays.class.php
1<?php
2/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
3 * Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2020-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
6 * Copyright (C) 2025 William Mead <william@m34d.com>
7 * Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23use Luracast\Restler\RestException;
24
25require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
26require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
27
28
37class Holidays extends DolibarrApi
38{
42 public static $FIELDS = array(
43 'fk_user',
44 'date_debut',
45 'date_fin',
46 );
47
54 public static $FIELDS_FORBIDDEN_FOR_API = array(
55 'status',
56 'statut',
57 'fk_validator',
58 'date_valid',
59 'fk_user_valid',
60 'date_approval',
61 'fk_user_approve',
62 'date_refuse',
63 'fk_user_refuse',
64 'detail_refuse',
65 );
66
70 public $holiday;
71
72
76 public function __construct()
77 {
78 global $db;
79
80 $this->db = $db;
81 $this->holiday = new Holiday($this->db);
82 }
83
96 public function get($id)
97 {
98 if (!DolibarrApiAccess::$user->hasRight('holiday', 'read')) {
99 throw new RestException(403);
100 }
101
102 $result = $this->holiday->fetch($id);
103 if (!$result) {
104 throw new RestException(404, 'Leave not found');
105 }
106
107 if (!DolibarrApi::_checkAccessToResource('holiday', $this->holiday)) {
108 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
109 }
110
111 $this->holiday->fetchObjectLinked();
112 return $this->_cleanObjectDatas($this->holiday);
113 }
114
134 public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = '', $sqlfilters = '', $properties = '', $pagination_data = false)
135 {
136 // TODO Check on permission holiday->read only if all ID are inside the childids of user
137
138 if (!DolibarrApiAccess::$user->hasRight('holiday', 'readall')) {
139 throw new RestException(403);
140 }
141
142 $obj_ret = array();
143
144 // case of external user, $societe param is ignored and replaced by user's socid
145 //$socid = DolibarrApiAccess::$user->socid ?: $societe;
146
147 $sql = "SELECT t.rowid";
148 $sql .= " FROM ".MAIN_DB_PREFIX."holiday AS t LEFT JOIN ".MAIN_DB_PREFIX."holiday_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
149 $sql .= ' WHERE t.entity IN ('.getEntity('holiday').')';
150 if ($user_ids) {
151 $sql .= " AND t.fk_user IN (".$this->db->sanitize($user_ids).")";
152 }
153
154 // Add sql filters
155 if ($sqlfilters) {
156 $errormessage = '';
157 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
158 if ($errormessage) {
159 throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
160 }
161 }
162
163 //this query will return total orders with the filters given
164 $sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
165
166 $sql .= $this->db->order($sortfield, $sortorder);
167 if ($limit) {
168 if ($page < 0) {
169 $page = 0;
170 }
171 $offset = $limit * $page;
172
173 $sql .= $this->db->plimit($limit + 1, $offset);
174 }
175
176 $result = $this->db->query($sql);
177
178 if ($result) {
179 $num = $this->db->num_rows($result);
180 $min = min($num, ($limit <= 0 ? $num : $limit));
181 $i = 0;
182 while ($i < $min) {
183 $obj = $this->db->fetch_object($result);
184 $holiday_static = new Holiday($this->db);
185 if ($holiday_static->fetch($obj->rowid)) {
186 $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($holiday_static), $properties);
187 }
188 $i++;
189 }
190 } else {
191 throw new RestException(503, 'Error when retrieve Leave list : '.$this->db->lasterror());
192 }
193
194 //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
195 if ($pagination_data) {
196 $totalsResult = $this->db->query($sqlTotals);
197 $total = $this->db->fetch_object($totalsResult)->total;
198
199 $tmp = $obj_ret;
200 $obj_ret = [];
201
202 $obj_ret['data'] = $tmp;
203 $obj_ret['pagination'] = [
204 'total' => (int) $total,
205 'page' => $page, //count starts from 0
206 'page_count' => ceil((int) $total / $limit),
207 'limit' => $limit
208 ];
209 }
210
211 return $obj_ret;
212 }
213
226 public function post($request_data = null)
227 {
228 if (!DolibarrApiAccess::$user->hasRight('holiday', 'write')) {
229 throw new RestException(403, "Insufficiant rights");
230 }
231
232 // Check mandatory fields
233 $result = $this->_validate($request_data);
234
235 // Check that the leave is for the user himself or for a user of his hierarchy (same rule as holiday/card.php)
236 if (!DolibarrApiAccess::$user->hasRight('holiday', 'writeall') && !in_array((int) $request_data['fk_user'], DolibarrApiAccess::$user->getAllChildIds(1))) {
237 throw new RestException(403, 'UserNotInHierachy');
238 }
239
240 foreach ($request_data as $field => $value) {
241 if ($field === 'caller') {
242 // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
243 $this->holiday->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
244 continue;
245 }
246 if (in_array($field, self::$FIELDS_FORBIDDEN_FOR_API) && $field !== 'fk_validator') {
247 throw new RestException(400, "Field '".$field."' is not allowed in create endpoint. Use dedicated routes (validate, approve, refuse, cancel, reopen) to change the workflow status.");
248 }
249
250 $this->holiday->$field = $this->_checkValForAPI($field, $value, $this->holiday);
251 }
252 /*if (isset($request_data["lines"])) {
253 $lines = array();
254 foreach ($request_data["lines"] as $line) {
255 array_push($lines, (object) $line);
256 }
257 $this->holiday->lines = $lines;
258 }*/
259 if ($this->holiday->create(DolibarrApiAccess::$user) < 0) {
260 throw new RestException(500, "Error creating holiday", array_merge(array($this->holiday->error), $this->holiday->errors));
261 }
262
263 return $this->holiday->id;
264 }
265
266
284 public function put($id, $request_data = null)
285 {
286 if (!DolibarrApiAccess::$user->hasRight('holiday', 'write')) {
287 throw new RestException(403);
288 }
289
290 $result = $this->holiday->fetch($id);
291 if (!$result) {
292 throw new RestException(404, 'Leave not found');
293 }
294
295 // Only a draft of the user himself or of his hierarchy can be modified (same rule as holiday/card.php)
296 if (!DolibarrApiAccess::$user->hasRight('holiday', 'writeall') && !in_array((int) $this->holiday->fk_user, DolibarrApiAccess::$user->getAllChildIds(1))) {
297 throw new RestException(403, 'UserNotInHierachy');
298 }
299 if ($this->holiday->status != Holiday::STATUS_DRAFT) {
300 throw new RestException(400, 'Only a draft leave can be modified');
301 }
302
303 if (!DolibarrApi::_checkAccessToResource('holiday', $this->holiday)) {
304 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
305 }
306
307 if (!is_array($request_data)) {
308 $request_data = array();
309 }
310
311 foreach ($request_data as $field => $value) {
312 if ($field == 'id') {
313 continue;
314 }
315 if ($field === 'caller') {
316 // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
317 $this->holiday->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
318 continue;
319 }
320 if (in_array($field, self::$FIELDS_FORBIDDEN_FOR_API)) {
321 throw new RestException(400, "Field '".$field."' is not allowed in update endpoint. Use dedicated routes (validate, approve, refuse, cancel, reopen) to change the workflow status.");
322 }
323
324 if ($field == 'array_options' && is_array($value)) {
325 foreach ($value as $index => $val) {
326 $this->holiday->array_options[$index] = $this->_checkValForAPI($field, $val, $this->holiday);
327 }
328 continue;
329 }
330
331 $this->holiday->$field = $this->_checkValForAPI($field, $value, $this->holiday);
332 }
333
334 if ($this->holiday->update(DolibarrApiAccess::$user) > 0) {
335 return $this->get($id);
336 } else {
337 throw new RestException(500, $this->holiday->error);
338 }
339 }
340
353 public function delete($id)
354 {
355 if (!DolibarrApiAccess::$user->hasRight('holiday', 'delete')) {
356 throw new RestException(403);
357 }
358
359 $result = $this->holiday->fetch($id);
360 if (!$result) {
361 throw new RestException(404, 'Leave not found');
362 }
363
364 if (!DolibarrApi::_checkAccessToResource('holiday', $this->holiday)) {
365 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
366 }
367
368 // Same rule as holiday/card.php
369 if (!in_array($this->holiday->status, array(Holiday::STATUS_DRAFT, Holiday::STATUS_CANCELED, Holiday::STATUS_REFUSED))) {
370 throw new RestException(400, 'Only a draft, canceled or refused leave can be deleted');
371 }
372
373 if (!$this->holiday->delete(DolibarrApiAccess::$user)) {
374 throw new RestException(500, 'Error when deleting Leave : '.$this->holiday->error);
375 }
376
377 return array(
378 'success' => array(
379 'code' => 200,
380 'message' => 'Leave deleted'
381 )
382 );
383 }
384
404 public function validate($id, $notrigger = 0)
405 {
406 if (!DolibarrApiAccess::$user->hasRight('holiday', 'write')) {
407 throw new RestException(403, "Insufficiant rights");
408 }
409 $result = $this->holiday->fetch($id);
410 if (!$result) {
411 throw new RestException(404, 'Leave not found');
412 }
413
414 if (!DolibarrApi::_checkAccessToResource('holiday', $this->holiday)) {
415 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
416 }
417
418 // Only a draft can be validated, by its owner or his hierarchy (same rule as holiday/card.php)
419 if (!DolibarrApiAccess::$user->hasRight('holiday', 'writeall') && !in_array((int) $this->holiday->fk_user, DolibarrApiAccess::$user->getAllChildIds(1))) {
420 throw new RestException(403, 'UserNotInHierachy');
421 }
422 if ($this->holiday->status != Holiday::STATUS_DRAFT) {
423 throw new RestException(400, 'Only a draft leave can be validated');
424 }
425
426 $this->holiday->status = Holiday::STATUS_VALIDATED;
427 $result = $this->holiday->validate(DolibarrApiAccess::$user, $notrigger);
428 if ($result == 0) {
429 throw new RestException(304, 'Error nothing done. May be object is already validated');
430 }
431 if ($result < 0) {
432 throw new RestException(500, 'Error when validating leave: '.$this->holiday->error);
433 }
434
435 return $this->_cleanObjectDatas($this->holiday);
436 }
437
438
458 public function approve($id, $notrigger = 0)
459 {
460 if (!DolibarrApiAccess::$user->hasRight('holiday', 'approve')) {
461 throw new RestException(403, "Insufficiant rights");
462 }
463 $result = $this->holiday->fetch($id);
464 if (!$result) {
465 throw new RestException(404, 'Leave not found');
466 }
467
468 if (!DolibarrApi::_checkAccessToResource('holiday', $this->holiday)) {
469 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
470 }
471
472 // Only a leave waiting for approval can be approved, by its approver (same rule as holiday/card.php)
473 if ($this->holiday->status != Holiday::STATUS_VALIDATED) {
474 throw new RestException(400, 'Only a validated leave can be approved');
475 }
476 if (DolibarrApiAccess::$user->id != $this->holiday->fk_validator && !DolibarrApiAccess::$user->hasRight('holiday', 'writeall')) {
477 throw new RestException(403, 'Only the approver of the leave can approve it');
478 }
479
480 $this->holiday->date_approval = dol_now();
481 $this->holiday->fk_user_approve = DolibarrApiAccess::$user->id;
482 $this->holiday->status = Holiday::STATUS_APPROVED;
483 $this->db->begin();
484 $result = $this->holiday->approve(DolibarrApiAccess::$user, $notrigger);
485 // Decrease the balance of the user (same code as holiday/card.php)
486 if ($result > 0 && !getDolGlobalInt('HOLIDAY_DECREASE_AT_END_OF_MONTH')) {
487 global $langs;
488 $langs->load('holiday');
489
490 $tmpUser = new User($this->db);
491 $tmpUser->fetch($this->holiday->fk_user);
492
493 // Calculate number of days consumed
494 $nbopenedday = num_open_day($this->holiday->date_debut_gmt, $this->holiday->date_fin_gmt, 0, 1, $this->holiday->halfday, $tmpUser->country_id);
495 $soldeActuel = $this->holiday->getCpforUser($this->holiday->fk_user, $this->holiday->fk_type);
496 $newSolde = ($soldeActuel - $nbopenedday);
497 $label = $this->holiday->ref.' - '.$langs->transnoentitiesnoconv("HolidayConsumption");
498
499 // The modification is added to the LOG, then the balance is updated
500 if ($this->holiday->addLogCP(DolibarrApiAccess::$user->id, $this->holiday->fk_user, $label, $newSolde, $this->holiday->fk_type) < 0
501 || $this->holiday->updateSoldeCP($this->holiday->fk_user, $newSolde, $this->holiday->fk_type) < 0) {
502 $result = -1;
503 }
504 }
505 if ($result > 0) {
506 $this->db->commit();
507 } else {
508 $this->db->rollback();
509 }
510 if ($result == 0) {
511 throw new RestException(304, 'Error nothing done. May be object is already approved');
512 }
513 if ($result < 0) {
514 throw new RestException(500, 'Error when approving expense report: '.$this->holiday->error);
515 }
516
517 return $this->_cleanObjectDatas($this->holiday);
518 }
519
539 public function cancel($id, $notrigger = 0)
540 {
541 if (!DolibarrApiAccess::$user->hasRight('holiday', 'write')) {
542 throw new RestException(403, "Insufficient rights");
543 }
544
545 $result = $this->holiday->fetch($id);
546 if (!$result) {
547 throw new RestException(404, 'Leave not found');
548 }
549
550 if (!DolibarrApi::_checkAccessToResource('holiday', $this->holiday)) {
551 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
552 }
553
554 // Only a leave waiting for approval or approved can be canceled (same rule as holiday/card.php)
555 if ($this->holiday->status != Holiday::STATUS_VALIDATED && $this->holiday->status != Holiday::STATUS_APPROVED) {
556 throw new RestException(400, 'Only a validated or approved leave can be canceled');
557 }
558 if (DolibarrApiAccess::$user->id != $this->holiday->fk_validator && !DolibarrApiAccess::$user->hasRight('holiday', 'writeall') && !DolibarrApiAccess::$user->hasRight('holiday', 'approve')
559 && !in_array((int) $this->holiday->fk_user, DolibarrApiAccess::$user->getAllChildIds(1))) {
560 throw new RestException(403, 'UserNotInHierachy');
561 }
562
563 $oldstatus = $this->holiday->status;
564 $this->holiday->date_cancel = dol_now();
565 $this->holiday->fk_user_cancel = DolibarrApiAccess::$user->id;
566 $this->holiday->status = Holiday::STATUS_CANCELED;
567 $this->db->begin();
568 $result = $this->holiday->update(DolibarrApiAccess::$user, $notrigger);
569 // The leave was approved, so the balance was decreased: increase it back (same code as holiday/card.php)
570 if ($result > 0 && $oldstatus == Holiday::STATUS_APPROVED) {
571 global $langs;
572 $langs->load('holiday');
573
574 if (!$notrigger && $this->holiday->call_trigger('HOLIDAY_CANCEL', DolibarrApiAccess::$user) < 0) {
575 $result = -1;
576 }
577
578 $startDate = $this->holiday->date_debut_gmt;
579 $endDate = $this->holiday->date_fin_gmt;
580 $alreadydebited = true;
581
582 if (getDolGlobalInt('HOLIDAY_DECREASE_AT_END_OF_MONTH')) {
583 $lastUpdate = strtotime($this->holiday->getConfCP('lastUpdate', dol_print_date(dol_now(), '%Y%m%d%H%M%S')));
584 $date = strtotime('-1 month', $lastUpdate);
585 $endOfMonthBeforeLastUpdate = dol_mktime(0, 0, 0, (int) date('m', $date), (int) date('t', $date), (int) date('Y', $date), 1);
586 if ($this->holiday->date_debut_gmt < $endOfMonthBeforeLastUpdate && $this->holiday->date_fin_gmt > $endOfMonthBeforeLastUpdate) {
587 $endDate = $endOfMonthBeforeLastUpdate;
588 } elseif ($this->holiday->date_debut_gmt > $endOfMonthBeforeLastUpdate) {
589 $alreadydebited = false; // The leave starts after the last monthly update, nothing was debited yet
590 }
591 }
592
593 $tmpUser = new User($this->db);
594 $tmpUser->fetch($this->holiday->fk_user);
595
596 // Calculate number of days consumed
597 $nbopenedday = $alreadydebited ? num_open_day($startDate, $endDate, 0, 1, $this->holiday->halfday, $tmpUser->country_id) : 0;
598 $soldeActuel = $this->holiday->getCpforUser($this->holiday->fk_user, $this->holiday->fk_type);
599 $newSolde = ($soldeActuel + $nbopenedday);
600 $label = $this->holiday->ref.' - '.$langs->transnoentitiesnoconv("HolidayCreditAfterCancellation");
601
602 // The modification is added to the LOG, then the balance is updated
603 if ($this->holiday->addLogCP(DolibarrApiAccess::$user->id, $this->holiday->fk_user, $label, $newSolde, $this->holiday->fk_type) < 0
604 || $this->holiday->updateSoldeCP($this->holiday->fk_user, $newSolde, $this->holiday->fk_type) < 0) {
605 $result = -1;
606 }
607 }
608 if ($result > 0) {
609 $this->db->commit();
610 } else {
611 $this->db->rollback();
612 }
613 if ($result == 0) {
614 throw new RestException(304, 'Error nothing done. May be object is already canceled');
615 }
616 if ($result < 0) {
617 throw new RestException(500, 'Error when canceling holiday: '.$this->holiday->error);
618 }
619
620 return $this->_cleanObjectDatas($this->holiday);
621 }
622
643 public function refuse($id, $detail_refuse, $notrigger = 0)
644 {
645 if (!DolibarrApiAccess::$user->hasRight('holiday', 'approve')) {
646 throw new RestException(403, "Insufficient rights");
647 }
648
649 $result = $this->holiday->fetch($id);
650 if (!$result) {
651 throw new RestException(404, 'Leave not found');
652 }
653
654 if (!DolibarrApi::_checkAccessToResource('holiday', $this->holiday)) {
655 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
656 }
657
658 // Only a leave waiting for approval can be refused, by its approver (same rule as holiday/card.php)
659 if ($this->holiday->status != Holiday::STATUS_VALIDATED) {
660 throw new RestException(400, 'Only a validated leave can be refused');
661 }
662 if (DolibarrApiAccess::$user->id != $this->holiday->fk_validator && !DolibarrApiAccess::$user->hasRight('holiday', 'writeall')) {
663 throw new RestException(403, 'Only the approver of the leave can refuse it');
664 }
665
666 $this->holiday->date_refuse = dol_now();
667 $this->holiday->fk_user_refuse = DolibarrApiAccess::$user->id;
668 $this->holiday->status = Holiday::STATUS_REFUSED;
669 $this->holiday->detail_refuse = $detail_refuse;
670 $result = $this->holiday->update(DolibarrApiAccess::$user, $notrigger);
671 if ($result == 0) {
672 throw new RestException(304, 'Error nothing done. May be object is already refused');
673 }
674 if ($result < 0) {
675 throw new RestException(500, 'Error when refusing holiday: '.$this->holiday->error);
676 }
677
678 return $this->_cleanObjectDatas($this->holiday);
679 }
680
703 public function reopen($id, $notrigger = 0)
704 {
705 if (!DolibarrApiAccess::$user->hasRight('holiday', 'write')) {
706 throw new RestException(403, "Insufficient rights");
707 }
708
709 $result = $this->holiday->fetch($id);
710 if (!$result) {
711 throw new RestException(404, 'Leave not found');
712 }
713
714 if (!DolibarrApi::_checkAccessToResource('holiday', $this->holiday)) {
715 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
716 }
717
718 // Check if the holiday is actually canceled
719 if ($this->holiday->statut != Holiday::STATUS_CANCELED) {
720 throw new RestException(400, 'Holiday is not canceled. Only canceled holidays can be reopened.');
721 }
722 $this->holiday->status = Holiday::STATUS_VALIDATED;
723 $result = $this->holiday->validate(DolibarrApiAccess::$user, $notrigger);
724 if ($result < 0) {
725 throw new RestException(500, 'Error when canceling holiday: '.$this->holiday->error);
726 }
727
728 return $this->_cleanObjectDatas($this->holiday);
729 }
730
731 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
741 protected function _cleanObjectDatas($object)
742 {
743 // phpcs:enable
744 $object = parent::_cleanObjectDatas($object);
748 unset($object->statut);
749 unset($object->user);
750 unset($object->thirdparty);
751
752 unset($object->cond_reglement);
753 unset($object->shipping_method_id);
754
755 unset($object->barcode_type);
756 unset($object->barcode_type_code);
757 unset($object->barcode_type_label);
758 unset($object->barcode_type_coder);
759
760 unset($object->mode_reglement_id);
761 unset($object->cond_reglement_id);
762
763 unset($object->name);
764 unset($object->lastname);
765 unset($object->firstname);
766 unset($object->civility_id);
767 unset($object->cond_reglement_id);
768 unset($object->contact);
769 unset($object->contact_id);
770
771 unset($object->state);
772 unset($object->state_id);
773 unset($object->state_code);
774 unset($object->country);
775 unset($object->country_id);
776 unset($object->country_code);
777
778 unset($object->logs);
779 unset($object->events);
780 unset($object->holiday);
781 unset($object->canvas);
782 unset($object->lines);
783
784 unset($object->totalpaid);
785 unset($object->totalpaid_multicurrency);
786
787 unset($object->note); // We already use note_public and note_pricate
788
789 return $object;
790 }
791
799 private function _validate($data)
800 {
801 if ($data === null) {
802 $data = array();
803 }
804 $expensereport = array();
805 foreach (self::$FIELDS as $field) {
806 if (!isset($data[$field])) {
807 throw new RestException(400, "$field field missing");
808 }
809 $expensereport[$field] = $data[$field];
810 }
811 return $expensereport;
812 }
813}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class for API REST v1.
Definition api.class.php:33
_filterObjectProperties($object, $properties)
Filter properties that will be returned on object.
static _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
Check access by user to a given resource.
_checkValForAPI($field, $value, $object)
Check and convert a string depending on its type/name.
Definition api.class.php:98
_cleanObjectDatas($object)
Clean sensitive object data @phpstan-template T.
Class of the module paid holiday.
const STATUS_VALIDATED
Validated status.
const STATUS_DRAFT
Draft status.
const STATUS_REFUSED
Refused.
const STATUS_CANCELED
Canceled.
const STATUS_APPROVED
Approved.
_validate($data)
Validate fields before create or update object.
index($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $user_ids='', $sqlfilters='', $properties='', $pagination_data=false)
List leaves.
put($id, $request_data=null)
Update expense report general fields.
validate($id, $notrigger=0)
Validate a holiday.
refuse($id, $detail_refuse, $notrigger=0)
Refuse a holiday.
__construct()
Constructor.
cancel($id, $notrigger=0)
Cancel a holiday.
reopen($id, $notrigger=0)
Reopen a canceled holiday.
approve($id, $notrigger=0)
Approve a leave.
post($request_data=null)
Create a leave.
Class to manage Dolibarr users.
num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $countryCodeOrId='')
Function to return number of working days (and text of units) between two dates (working days)
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
sanitizeVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
if(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
Definition receipt.php:469