dolibarr 20.0.2
workstationresource.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
32{
34 public $table_element = 'workstation_workstation_resource';
35
37 public $element = 'workstationresource';
38
42 public $fields = array(
43 'fk_workstation' => array('type' => 'integer', 'label' => 'Workstation', 'enabled' => 1, 'position' => 10, 'visible' => 1),
44 'fk_resource' => array('type' => 'integer', 'label' => 'UserGroup', 'enabled' => 1, 'position' => 20, 'visible' => 1),
45 );
46
50 public $fk_workstation;
51
55 public $fk_resource;
56
57
63 public function __construct($db)
64 {
65 global $langs;
66
67 $this->db = $db;
68
69 // Unset fields that are disabled
70 foreach ($this->fields as $key => $val) {
71 if (isset($val['enabled']) && empty($val['enabled'])) {
72 unset($this->fields[$key]);
73 }
74 }
75
76 // Translate some data of arrayofkeyval
77 if (is_object($langs)) {
78 foreach ($this->fields as $key => $val) {
79 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
80 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
81 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
82 }
83 }
84 }
85 }
86 }
87
94 public static function getAllResourcesOfWorkstation($fk_workstation)
95 {
96 global $db;
97 $obj = new self($db);
98 return parent::getAllItemsLinkedByObjectID($fk_workstation, 'fk_resource', 'fk_workstation', $obj->table_element);
99 }
100
107 public static function deleteAllResourcesOfWorkstation($fk_workstation)
108 {
109 global $db;
110 $obj = new self($db);
111 return parent::deleteAllItemsLinkedByObjectID($fk_workstation, 'fk_workstation', $obj->table_element);
112 }
113}
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Class to link resource with Workstations.
static getAllResourcesOfWorkstation($fk_workstation)
Function used to get an array with all resources linked to a workstation.
__construct($db)
WorkstationResource constructor.
static deleteAllResourcesOfWorkstation($fk_workstation)
Function used to remove all resources linked to a workstation.