dolibarr 23.0.3
job_agenda.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
4 * Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
5 * Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
6 * Copyright (C) 2021 Grégory BLEMAND <gregory.blemand@atm-consulting.fr>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
31// Load Dolibarr environment
32require '../main.inc.php';
33
34require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
35require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
36require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
37require_once DOL_DOCUMENT_ROOT . '/hrm/class/job.class.php';
38require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_job.lib.php';
39
48// Load translation files required by the page
49$langs->loadLangs(array('hrm', 'other'));
50
51// Get parameters
52$id = GETPOSTINT('id');
53$ref = GETPOST('ref', 'alpha');
54$action = GETPOST('action', 'aZ09');
55$cancel = GETPOST('cancel');
56$backtopage = GETPOST('backtopage', 'alpha');
57
58if (GETPOST('actioncode', 'array')) {
59 $actioncode = GETPOST('actioncode', 'array', 3);
60 if (!count($actioncode)) {
61 $actioncode = '0';
62 }
63} else {
64 $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
65}
66$search_rowid = GETPOST('search_rowid');
67$search_agenda_label = GETPOST('search_agenda_label');
68
69$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
70$sortfield = GETPOST('sortfield', 'aZ09comma');
71$sortorder = GETPOST('sortorder', 'aZ09comma');
72$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
73if (empty($page) || $page == -1) {
74 $page = 0;
75} // If $page is not defined, or '' or -1
76$offset = $limit * $page;
77$pageprev = $page - 1;
78$pagenext = $page + 1;
79if (!$sortfield) {
80 $sortfield = 'a.datep,a.id';
81}
82if (!$sortorder) {
83 $sortorder = 'DESC,DESC';
84}
85
86// Initialize a technical objects
87$object = new Job($db);
88$extrafields = new ExtraFields($db);
89$diroutputmassaction = $conf->hrm->dir_output.'/temp/massgeneration/'.$user->id;
90$hookmanager->initHooks(array('jobagenda', 'globalcard')); // Note that conf->hooks_modules contains array
91// Fetch optionals attributes and labels
92$extrafields->fetch_name_optionals_label($object->table_element);
93
94// Load object
95include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. Include fetch and fetch_thirdparty but not fetch_optionals
96if ($id > 0 || !empty($ref)) {
97 $upload_dir = $conf->hrm->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id;
98}
99
100// Permissions
101$permissiontoread = $user->hasRight('hrm', 'all', 'read');
102$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php
103
104// Security check (enable the most restrictive one)
105//if ($user->socid > 0) accessforbidden();
106//if ($user->socid > 0) $socid = $user->socid;
107//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
108//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
109if (empty($conf->hrm->enabled)) {
111}
112if (!$permissiontoread) {
114}
115
116
117/*
118 * Actions
119 */
120
121$parameters = array('id' => $id);
122$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
123if ($reshook < 0) {
124 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
125}
126
127if (empty($reshook)) {
128 // Cancel
129 if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
130 header("Location: ".$backtopage);
131 exit;
132 }
133
134 // Purge search criteria
135 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
136 $actioncode = '';
137 $search_agenda_label = '';
138 }
139}
140
141
142
143/*
144 * View
145 */
146
147$form = new Form($db);
148
149if ($object->id > 0) {
150 $title = $langs->trans("Agenda");
151 $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung';
152 llxHeader('', $title, $help_url);
153
154 if (isModEnabled('notification')) {
155 $langs->load("mails");
156 }
157 $head = jobPrepareHead($object);
158
159
160 print dol_get_fiche_head($head, 'agenda', $langs->trans("Agenda"), -1, $object->picto);
161
162 // Object card
163 // ------------------------------------------------------------
164 $linkback = '<a href="'.dol_buildpath('/hrm/job_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
165
166 $morehtmlref = '<div class="refid">';
167 $morehtmlref .= $object->label;
168 $morehtmlref .= '</div>';
169
170
171 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref);
172
173 print '<div class="fichecenter">';
174 print '<div class="underbanner clearboth"></div>';
175
176 $object->info($object->id);
177 dol_print_object_info($object, 1);
178
179 print '</div>';
180
181 print dol_get_fiche_end();
182
183
184
185 // Actions buttons
186
187 $objthirdparty = $object;
188 $objcon = new stdClass();
189
190 $out = '&origin='.urlencode((string) ($object->element.'@'.$object->module)).'&originid='.urlencode((string) ($object->id));
191 $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id;
192 $out .= '&backtopage='.urlencode($urlbacktopage);
193 $permok = $user->hasRight('agenda', 'myactions', 'create');
194 if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
195 //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
196 if (get_class($objthirdparty) == 'Societe') {
197 $out .= '&socid='.urlencode((string) ($objthirdparty->id));
198 }
199 $out .= (!empty($objcon->id) ? '&contactid='.urlencode($objcon->id) : '');
200 //$out.=$langs->trans("AddAnAction").' ';
201 //$out.=img_picto($langs->trans("AddAnAction"),'filenew');
202 //$out.="</a>";
203 }
204
205
206 $newcardbutton = '';
207 if (isModEnabled('agenda')) {
208 if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
209 $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
210 }
211 }
212
213 if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
214 $param = '&id='.$object->id.'&socid='.(!empty($socid) ? '&socid='.$socid : '');
215 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
216 $param .= '&contextpage='.urlencode($contextpage);
217 }
218 if ($limit > 0 && $limit != $conf->liste_limit) {
219 $param .= '&limit='.((int) $limit);
220 }
221
222
223 print load_fiche_titre($langs->trans("ActionsOnJob"), $newcardbutton, '');
224
225 // List of all actions
226 $filters = array();
227 $filters['search_agenda_label'] = $search_agenda_label;
228 $filters['search_rowid'] = $search_rowid;
229
230 // TODO Replace this with same code than into list.php
231 show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
232 }
233}
234
235// End of page
236llxFooter();
237$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class for Job.
Definition job.class.php:38
show_actions_done($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC', $module='')
Show html area with actions (done or not, ignore the name of function).
dol_print_object_info($object, $usetable=0)
Show information on an object TODO Move this into html.formother.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
jobPrepareHead($object)
Prepare array of tabs for Job.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.