dolibarr 19.0.3
agenda.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
6 * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
7 * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2015 Marcos GarcĂ­a <marcosgdf@gmail.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
30// Load Dolibarr environment
31require '../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
33require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
37
38// Load translation files required by the page
39$langs->load("companies");
40
41if (GETPOST('actioncode', 'array')) {
42 $actioncode = GETPOST('actioncode', 'array', 3);
43 if (!count($actioncode)) {
44 $actioncode = '0';
45 }
46} else {
47 $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
48}
49$search_rowid = GETPOST('search_rowid');
50$search_agenda_label = GETPOST('search_agenda_label');
51
52// Security check
53$id = GETPOST('id', 'int');
54$ref = GETPOST('ref', 'alpha');
55if ($user->socid) {
56 $id = $user->socid;
57}
58
59$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
60$sortfield = GETPOST('sortfield', 'aZ09comma');
61$sortorder = GETPOST('sortorder', 'aZ09comma');
62$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
63if (empty($page) || $page == -1) {
64 $page = 0;
65} // If $page is not defined, or '' or -1
66$offset = $limit * $page;
67$pageprev = $page - 1;
68$pagenext = $page + 1;
69if (!$sortfield) {
70 $sortfield = 'a.datep,a.id';
71}
72if (!$sortorder) {
73 $sortorder = 'DESC,DESC';
74}
75
76// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
77$hookmanager->initHooks(array('productagenda'));
78
79$object = new Product($db);
80if ($id > 0 || !empty($ref)) {
81 $object->fetch($id, $ref);
82}
83
84if ($object->id > 0) {
85 if ($object->type == $object::TYPE_PRODUCT) {
86 restrictedArea($user, 'produit', $object->id, 'product&product', '', '');
87 }
88 if ($object->type == $object::TYPE_SERVICE) {
89 restrictedArea($user, 'service', $object->id, 'product&product', '', '');
90 }
91} else {
92 restrictedArea($user, 'produit|service', 0, 'product&product', '', '');
93}
94
95
96/*
97 * Actions
98 */
99
100$parameters = array('id'=>$id);
101$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
102if ($reshook < 0) {
103 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
104}
105
106if (empty($reshook)) {
107 // Cancel
108 if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
109 header("Location: ".$backtopage);
110 exit;
111 }
112
113 // Purge search criteria
114 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
115 $actioncode = '';
116 $search_agenda_label = '';
117 }
118}
119
120
121
122/*
123 * View
124 */
125
126$contactstatic = new Contact($db);
127
128$form = new Form($db);
129
130if ($id > 0 || $ref) {
131 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
132 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
133
134 $langs->load("companies");
135
136
137 $object = new Product($db);
138 $result = $object->fetch($id, $ref);
139
140 $title = $langs->trans("Agenda");
141
142 $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|DE:Modul_Terminplanung';
143
144 if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/productnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
145 $title = $object->name." - ".$title;
146 }
147 llxHeader('', $title, $help_url);
148
149 if (isModEnabled('notification')) {
150 $langs->load("mails");
151 }
152 $type = $langs->trans('Product');
153 if ($object->isService()) {
154 $type = $langs->trans('Service');
155 }
156
157 $head = product_prepare_head($object);
158
159 $titre = $langs->trans("CardProduct".$object->type);
160 $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
161 print dol_get_fiche_head($head, 'agenda', $titre, -1, $picto);
162
163 $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
164 $object->next_prev_filter = "fk_product_type = ".((int) $object->type);
165
166 $shownav = 1;
167 if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
168 $shownav = 0;
169 }
170
171 dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
172
173 print '<div class="fichecenter">';
174
175 print '<div class="underbanner clearboth"></div>';
176
177 $object->info($object->id);
178 dol_print_object_info($object, 1);
179
180 print '</div>';
181
182 print dol_get_fiche_end();
183
184
185
186 // Actions buttons
187
188 $objproduct = $object;
189 $objcon = new stdClass();
190
191 $out = '';
192 $morehtmlcenter = '';
193 if (isModEnabled('agenda')) {
194 $permok = $user->hasRight('agenda', 'myactions', 'create');
195 if ((!empty($objproduct->id) || !empty($objcon->id)) && $permok) {
196 if (get_class($objproduct) == 'Product') {
197 $out .= '&amp;prodid='.$objproduct->id.'&origin=product&originid='.$id;
198 }
199 $out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;backtopage='.$_SERVER["PHP_SELF"].'?id='.$object->id;
200 }
201
202 $linktocreatetimeBtnStatus = $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create');
203 $morehtmlcenter = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', $linktocreatetimeBtnStatus);
204 }
205
206 if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
207 print '<br>';
208
209 $param = '&id='.$id;
210 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
211 $param .= '&contextpage='.$contextpage;
212 }
213 if ($limit > 0 && $limit != $conf->liste_limit) {
214 $param .= '&limit='.$limit;
215 }
216
217 print_barre_liste($langs->trans("ActionsOnProduct"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1);
218
219 // List of all actions
220 $filters = array();
221 $filters['search_agenda_label'] = $search_agenda_label;
222 $filters['search_rowid'] = $search_rowid;
223
224 // TODO Replace this with same code than into list.php
225 show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
226 }
227}
228
229// End of page
230llxFooter();
231$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage generation of HTML components Only common components must be here.
Class to manage products or services.
const TYPE_SERVICE
Service.
show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $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 informations on an object TODO Move this into html.formother.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
product_prepare_head($object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Contact()
Old copy.
Definition index.php:572