dolibarr  19.0.0-dev
actioncommreminder.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 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 
24 // Put here all includes required by your class file
25 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
26 
27 
32 {
36  public $element = 'actioncomm_reminder';
37 
41  public $table_element = 'actioncomm_reminder';
42 
46  public $ismultientitymanaged = 0;
47 
51  public $picto = 'generic';
52 
53  const STATUS_TODO = 0;
54  const STATUS_DONE = 1;
55  const STATUS_ERROR = -1;
56 
57 
75  // BEGIN MODULEBUILDER PROPERTIES
79  public $fields = array(
80  'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
81  'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,),
82  'dateremind' => array('type'=>'datetime', 'label'=>'DateRemind', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>1, 'index'=>1,),
83  'typeremind' => array('type'=>'varchar(32)', 'label'=>'TypeRemind', 'visible'=>-1, 'enabled'=>1, 'position'=>55, 'notnull'=>1, 'comment'=>"email, browser, sms",),
84  'fk_user' => array('type'=>'integer', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>65, 'notnull'=>1, 'index'=>1,),
85  'offsetvalue' => array('type'=>'integer', 'label'=>'OffsetValue', 'visible'=>1, 'enabled'=>1, 'position'=>56, 'notnull'=>1,),
86  'offsetunit' => array('type'=>'varchar(1)', 'label'=>'OffsetUnit', 'visible'=>1, 'enabled'=>1, 'position'=>57, 'notnull'=>1, 'comment'=>"y, m, d, w, h, i",),
87  'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>58, 'notnull'=>1, 'default'=>0, 'index'=>0, 'arrayofkeyval'=>array('0'=>'ToDo', '1'=>'Done')),
88  'lasterror' => array('type'=>'varchar(128)', 'label'=>'LastError', 'visible'=>-1, 'enabled'=>1, 'position'=>59, 'index'=>0),
89  'fk_actioncomm' => array('type'=>'integer', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>70, 'notnull'=>1, 'index'=>1,),
90  'fk_email_template' => array('type'=>'integer', 'label'=>'EmailTemplate', 'visible'=>1, 'enabled'=>1, 'position'=>80, 'notnull'=>0),
91  );
92 
96  public $rowid;
97 
101  public $entity;
102 
103  public $dateremind;
104 
108  public $typeremind;
109 
113  public $fk_user;
114 
118  public $offsetvalue;
119 
123  public $offsetunit;
124 
128  public $status;
129 
133  public $lasterror;
134 
138  public $fk_actioncomm;
139 
143  public $fk_email_template;
144  // END MODULEBUILDER PROPERTIES
145 
151  public function __construct(DoliDB $db)
152  {
153  global $conf;
154 
155  $this->db = $db;
156 
157  if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
158  $this->fields['rowid']['visible'] = 0;
159  }
160  if (!isModEnabled('multicompany')) {
161  $this->fields['entity']['enabled'] = 0;
162  }
163  }
164 
172  public function create(User $user, $notrigger = false)
173  {
174  return $this->createCommon($user, $notrigger);
175  }
176 
177 
185  public function fetch($id, $ref = null)
186  {
187  $result = $this->fetchCommon($id, $ref);
188  return $result;
189  }
190 
198  public function update(User $user, $notrigger = false)
199  {
200  return $this->updateCommon($user, $notrigger);
201  }
202 
210  public function delete(User $user, $notrigger = false)
211  {
212  return $this->deleteCommon($user, $notrigger);
213  }
214 
221  public function getLibStatut($mode = 0)
222  {
223  return $this->LibStatut($this->status, $mode);
224  }
225 
226  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
234  public static function LibStatut($status, $mode = 0)
235  {
236  // phpcs:enable
237  global $langs;
238 
239  $labelStatus = $langs->transnoentitiesnoconv('ToDo');
240  if ($status == 1) {
241  $labelStatus = $langs->transnoentitiesnoconv('Done');
242  } elseif ($status == -1) {
243  $labelStatus = $langs->transnoentitiesnoconv('Error');
244  }
245 
246  $labelStatusShort = $langs->transnoentitiesnoconv('ToDo');
247  if ($status == 1) {
248  $labelStatus = $langs->transnoentitiesnoconv('Done');
249  } elseif ($status == -1) {
250  $labelStatus = $langs->transnoentitiesnoconv('Error');
251  }
252 
253  $statusType = 'status5';
254  if ($status == 1) {
255  $statusType = 'status4';
256  } elseif ($status == -1) {
257  $statusType = 'status8';
258  }
259 
260  return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
261  }
262 
269  public function initAsSpecimen()
270  {
271  $this->initAsSpecimenCommon();
272  }
273 }
CommonObject\deleteCommon
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
Definition: commonobject.class.php:9605
CommonObject\fetchCommon
fetchCommon($id, $ref=null, $morewhere='')
Load object in memory from the database.
Definition: commonobject.class.php:9395
DoliDB
Class to manage Dolibarr database access.
Definition: DoliDB.class.php:30
ActionCommReminder\fetch
fetch($id, $ref=null)
Load object in memory from the database.
Definition: actioncommreminder.class.php:185
ActionCommReminder\create
create(User $user, $notrigger=false)
Create object into database.
Definition: actioncommreminder.class.php:172
CommonObject\initAsSpecimenCommon
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
Definition: commonobject.class.php:9933
CommonObject
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Definition: commonobject.class.php:45
CommonObject\createCommon
createCommon(User $user, $notrigger=false)
Create object into database.
Definition: commonobject.class.php:9228
ActionCommReminder\__construct
__construct(DoliDB $db)
Constructor.
Definition: actioncommreminder.class.php:151
ActionCommReminder
Class for ActionCommReminder.
Definition: actioncommreminder.class.php:31
ActionCommReminder\initAsSpecimen
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
Definition: actioncommreminder.class.php:269
CommonObject\updateCommon
updateCommon(User $user, $notrigger=false)
Update object into database.
Definition: commonobject.class.php:9501
ActionCommReminder\update
update(User $user, $notrigger=false)
Update object into database.
Definition: actioncommreminder.class.php:198
ActionCommReminder\LibStatut
static LibStatut($status, $mode=0)
Return the status.
Definition: actioncommreminder.class.php:234
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:207
User
Class to manage Dolibarr users.
Definition: user.class.php:47
dolGetStatus
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
Definition: functions.lib.php:10967
ActionCommReminder\getLibStatut
getLibStatut($mode=0)
Return label of the status of a reminder.
Definition: actioncommreminder.class.php:221