dolibarr 23.0.3
actioncommreminder.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Put here all includes required by your class file
27require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
28
29
34{
38 public $element = 'actioncomm_reminder';
39
43 public $table_element = 'actioncomm_reminder';
44
48 public $picto = 'generic';
49
50 const STATUS_TODO = 0;
51 const STATUS_DONE = 1;
52 const STATUS_ERROR = -1;
53
55 const TYPE_USER = 0;
57 const TYPE_CUSTOMER = 1;
59 const TYPE_CONTACT = 2;
60
61
79 // BEGIN MODULEBUILDER PROPERTIES
83 public $fields = array(
84 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'visible' => -1, 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'index' => 1, 'comment' => "Id",),
85 'entity' => array('type' => 'integer', 'label' => 'Entity', 'visible' => 0, 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'index' => 1,),
86 'dateremind' => array('type' => 'datetime', 'label' => 'DateRemind', 'visible' => 1, 'enabled' => 1, 'position' => 60, 'notnull' => 1, 'index' => 1,),
87 'typeremind' => array('type' => 'varchar(32)', 'label' => 'TypeRemind', 'visible' => -1, 'enabled' => 1, 'position' => 55, 'notnull' => 1, 'comment' => "email, browser, sms",),
88 'fk_user' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'User', 'visible' => -1, 'enabled' => 1, 'position' => 65, 'notnull' => 1, 'index' => 1,),
89 'offsetvalue' => array('type' => 'integer', 'label' => 'OffsetValue', 'visible' => 1, 'enabled' => 1, 'position' => 56, 'notnull' => 1,),
90 'offsetunit' => array('type' => 'varchar(1)', 'label' => 'OffsetUnit', 'visible' => 1, 'enabled' => 1, 'position' => 57, 'notnull' => 1, 'comment' => "y, m, d, w, h, i",),
91 'status' => array('type' => 'integer', 'label' => 'Status', 'visible' => 1, 'enabled' => 1, 'position' => 58, 'notnull' => 1, 'default' => '0', 'index' => 0, 'arrayofkeyval' => array('0' => 'ToDo', '1' => 'Done')),
92 'lasterror' => array('type' => 'varchar(128)', 'label' => 'LastError', 'visible' => -1, 'enabled' => 1, 'position' => 59, 'index' => 0),
93 'fk_actioncomm' => array('type' => 'integer', 'label' => 'Project', 'visible' => 1, 'enabled' => 1, 'position' => 70, 'notnull' => 1, 'index' => 1,),
94 'fk_email_template' => array('type' => 'integer', 'label' => 'EmailTemplate', 'visible' => 1, 'enabled' => 1, 'position' => 80, 'notnull' => 0),
95 );
96
100 public $rowid;
101
105 public $dateremind;
106
110 public $typeremind;
111
115 public $fk_user;
116
120 public $offsetvalue;
121
125 public $offsetunit;
126
130 public $status;
131
135 public $lasterror;
136
140 public $fk_actioncomm;
141
145 public $fk_email_template;
146 // END MODULEBUILDER PROPERTIES
147
148
154 public function __construct(DoliDB $db)
155 {
156 $this->db = $db;
157
158 $this->ismultientitymanaged = 0;
159
160 if (!getDolGlobalString('MAIN_SHOW_TECHNICAL_ID')) {
161 $this->fields['rowid']['visible'] = 0;
162 }
163 if (!isModEnabled('multicompany')) {
164 $this->fields['entity']['enabled'] = 0;
165 }
166 }
167
175 public function create(User $user, $notrigger = 0)
176 {
177 return $this->createCommon($user, $notrigger);
178 }
179
180
188 public function fetch($id, $ref = null)
189 {
190 $result = $this->fetchCommon($id, $ref);
191 return $result;
192 }
193
201 public function update(User $user, $notrigger = 0)
202 {
203 return $this->updateCommon($user, $notrigger);
204 }
205
213 public function delete(User $user, $notrigger = 0)
214 {
215 return $this->deleteCommon($user, $notrigger);
216 }
217
224 public function getLibStatut($mode = 0)
225 {
226 return $this->LibStatut($this->status, $mode);
227 }
228
229 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
237 public static function LibStatut($status, $mode = 0)
238 {
239 // phpcs:enable
240 global $langs;
241
242 $labelStatus = $langs->transnoentitiesnoconv('ToDo');
243 if ($status == 1) {
244 $labelStatus = $langs->transnoentitiesnoconv('Done');
245 } elseif ($status == -1) {
246 $labelStatus = $langs->transnoentitiesnoconv('Error');
247 }
248
249 $labelStatusShort = $langs->transnoentitiesnoconv('ToDo');
250 if ($status == 1) {
251 $labelStatus = $langs->transnoentitiesnoconv('Done');
252 } elseif ($status == -1) {
253 $labelStatus = $langs->transnoentitiesnoconv('Error');
254 }
255
256 $statusType = 'status5';
257 if ($status == 1) {
258 $statusType = 'status4';
259 } elseif ($status == -1) {
260 $statusType = 'status8';
261 }
262
263 return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
264 }
265
272 public function initAsSpecimen()
273 {
274 return $this->initAsSpecimenCommon();
275 }
276}
Class for ActionCommReminder.
fetch($id, $ref=null)
Load object in memory from the database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
static LibStatut($status, $mode=0)
Return the status.
create(User $user, $notrigger=0)
Create object into database.
update(User $user, $notrigger=0)
Update object into database.
__construct(DoliDB $db)
Constructor.
getLibStatut($mode=0)
Return label of the status of a reminder.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
createCommon(User $user, $notrigger=0)
Create object in the database.
updateCommon(User $user, $notrigger=0)
Update object into database.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:171
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.