1 | <?php |
||
2 | |||
3 | /* Copyright (C) 2023 Laurent Destailleur <[email protected]> |
||
4 | * Copyright (C) 2024 Rafael San José <[email protected]> |
||
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 | |||
20 | use Dolibarr\Code\Commande\Classes\Commande; |
||
21 | use Dolibarr\Code\Core\Classes\ExtraFields; |
||
22 | use Dolibarr\Code\Core\Classes\Form; |
||
23 | use Dolibarr\Code\Projet\Classes\Project; |
||
24 | use Dolibarr\Lib\ViewMain; |
||
25 | |||
26 | /** |
||
27 | * \file htdocs/commande/agenda.php |
||
28 | * \ingroup order |
||
29 | * \brief Tab of events on Sale Orders |
||
30 | */ |
||
31 | |||
32 | require constant('DOL_DOCUMENT_ROOT') . '/main.inc.php'; |
||
33 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/company.lib.php'; |
||
34 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/order.lib.php'; |
||
35 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/functions2.lib.php'; |
||
36 | |||
37 | // Load translation files required by the page |
||
38 | $langs->loadLangs(array("order", "other")); |
||
39 | |||
40 | // Get parameters |
||
41 | $id = GETPOSTINT('id'); |
||
42 | $ref = GETPOST('ref', 'alpha'); |
||
43 | $action = GETPOST('action', 'aZ09'); |
||
44 | $cancel = GETPOST('cancel', 'aZ09'); |
||
45 | $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)) . basename(__FILE__, '.php')); // To manage different context of search |
||
46 | $backtopage = GETPOST('backtopage', 'alpha'); |
||
47 | |||
48 | if (GETPOST('actioncode', 'array')) { |
||
49 | $actioncode = GETPOST('actioncode', 'array', 3); |
||
50 | if (!count($actioncode)) { |
||
51 | $actioncode = '0'; |
||
52 | } |
||
53 | } else { |
||
54 | $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); |
||
55 | } |
||
56 | $search_rowid = GETPOST('search_rowid'); |
||
57 | $search_agenda_label = GETPOST('search_agenda_label'); |
||
58 | |||
59 | $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; |
||
60 | $sortfield = GETPOST('sortfield', 'aZ09comma'); |
||
61 | $sortorder = GETPOST('sortorder', 'aZ09comma'); |
||
62 | $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); |
||
63 | if (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; |
||
69 | if (!$sortfield) { |
||
70 | $sortfield = 'a.datep,a.id'; |
||
71 | } |
||
72 | if (!$sortorder) { |
||
73 | $sortorder = 'DESC,DESC'; |
||
74 | } |
||
75 | |||
76 | // Initialize technical objects |
||
77 | $object = new Commande($db); |
||
78 | $extrafields = new ExtraFields($db); |
||
79 | $diroutputmassaction = $conf->commande->multidir_output[$conf->entity] . '/temp/massgeneration/' . $user->id; |
||
80 | $hookmanager->initHooks(array('orderagenda', 'globalcard')); // Note that conf->hooks_modules contains array |
||
81 | // Fetch optionals attributes and labels |
||
82 | $extrafields->fetch_name_optionals_label($object->table_element); |
||
83 | |||
84 | // Load object |
||
85 | include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals |
||
86 | if ($id > 0 || !empty($ref)) { |
||
87 | $upload_dir = $conf->commande->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity] . "/" . $object->id; |
||
88 | } |
||
89 | |||
90 | $permissiontoread = $user->hasRight("commande", "lire"); |
||
91 | $permissiontoadd = $user->hasRight("commande", "creer"); |
||
92 | |||
93 | // Security check |
||
94 | if (!empty($user->socid)) { |
||
95 | $socid = $user->socid; |
||
96 | } |
||
97 | $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); |
||
98 | restrictedArea($user, 'commande', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); |
||
99 | |||
100 | |||
101 | /* |
||
102 | * Actions |
||
103 | */ |
||
104 | |||
105 | $parameters = array('id' => $id); |
||
106 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||
107 | if ($reshook < 0) { |
||
108 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||
109 | } |
||
110 | |||
111 | if (empty($reshook)) { |
||
112 | // Cancel |
||
113 | if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { |
||
114 | header("Location: " . $backtopage); |
||
115 | exit; |
||
116 | } |
||
117 | |||
118 | // Purge search criteria |
||
119 | 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 |
||
120 | $actioncode = ''; |
||
121 | $search_agenda_label = ''; |
||
122 | } |
||
123 | } |
||
124 | |||
125 | /* |
||
126 | * View |
||
127 | */ |
||
128 | |||
129 | $form = new Form($db); |
||
130 | |||
131 | if ($object->id > 0) { |
||
132 | $title = $langs->trans("Agenda"); |
||
133 | $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; |
||
134 | ViewMain::llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-order page-card_agenda'); |
||
135 | |||
136 | if (isModEnabled('notification')) { |
||
137 | $langs->load("mails"); |
||
138 | } |
||
139 | $head = commande_prepare_head($object); |
||
140 | |||
141 | |||
142 | print dol_get_fiche_head($head, 'agenda', $langs->trans("Order"), -1, $object->picto); |
||
143 | |||
144 | // Object card |
||
145 | // ------------------------------------------------------------ |
||
146 | $linkback = '<a href="' . constant('BASE_URL') . '/commande/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
||
147 | |||
148 | $morehtmlref = '<div class="refidno">'; |
||
149 | // Ref customer |
||
150 | $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
||
151 | $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
||
152 | // Thirdparty |
||
153 | $morehtmlref .= '<br>' . $object->thirdparty->getNomUrl(1); |
||
0 ignored issues
–
show
|
|||
154 | // Project |
||
155 | if (isModEnabled('project')) { |
||
156 | $langs->load("projects"); |
||
157 | $morehtmlref .= '<br>'; |
||
158 | if (0) { |
||
159 | $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); |
||
160 | if ($action != 'classify') { |
||
161 | $morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token=' . newToken() . '&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> '; |
||
162 | } |
||
163 | $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); |
||
164 | } else { |
||
165 | if (!empty($object->fk_project)) { |
||
166 | $proj = new Project($db); |
||
167 | $proj->fetch($object->fk_project); |
||
168 | $morehtmlref .= $proj->getNomUrl(1); |
||
169 | if ($proj->title) { |
||
170 | $morehtmlref .= '<span class="opacitymedium"> - ' . dol_escape_htmltag($proj->title) . '</span>'; |
||
171 | } |
||
172 | } |
||
173 | } |
||
174 | } |
||
175 | $morehtmlref .= '</div>'; |
||
176 | |||
177 | |||
178 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
||
179 | |||
180 | print '<div class="fichecenter">'; |
||
181 | print '<div class="underbanner clearboth"></div>'; |
||
182 | |||
183 | $object->info($object->id); |
||
184 | dol_print_object_info($object, 1); |
||
185 | |||
186 | print '</div>'; |
||
187 | |||
188 | print dol_get_fiche_end(); |
||
189 | |||
190 | |||
191 | // Actions buttons |
||
192 | |||
193 | $objthirdparty = $object; |
||
194 | $objcon = new stdClass(); |
||
195 | |||
196 | $out = '&origin=' . urlencode((string)($object->element . (property_exists($object, 'module') ? '@' . $object->module : ''))) . '&originid=' . urlencode((string)($object->id)); |
||
197 | $urlbacktopage = $_SERVER['PHP_SELF'] . '?id=' . $object->id; |
||
198 | $out .= '&backtopage=' . urlencode($urlbacktopage); |
||
199 | $permok = $user->hasRight('agenda', 'myactions', 'create'); |
||
200 | if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { |
||
201 | //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'; |
||
202 | if (get_only_class($objthirdparty) == 'Societe') { |
||
203 | $out .= '&socid=' . urlencode((string)($objthirdparty->id)); |
||
204 | } |
||
205 | $out .= (!empty($objcon->id) ? '&contactid=' . urlencode($objcon->id) : ''); |
||
206 | //$out.=$langs->trans("AddAnAction").' '; |
||
207 | //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); |
||
208 | //$out.="</a>"; |
||
209 | } |
||
210 | |||
211 | $morehtmlright = ''; |
||
212 | |||
213 | //$messagingUrl = DOL_URL_ROOT.'/societe/messaging.php?socid='.$object->id; |
||
214 | //$morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); |
||
215 | //$messagingUrl = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; |
||
216 | //$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2); |
||
217 | |||
218 | if (isModEnabled('agenda')) { |
||
219 | if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { |
||
220 | $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', constant('BASE_URL') . '/comm/action/card.php?action=create' . $out); |
||
221 | } else { |
||
222 | $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', constant('BASE_URL') . '/comm/action/card.php?action=create' . $out, '', 0); |
||
223 | } |
||
224 | } |
||
225 | |||
226 | |||
227 | if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { |
||
228 | print '<br>'; |
||
229 | |||
230 | $param = '&id=' . $object->id . (!empty($socid) ? '&socid=' . $socid : ''); |
||
231 | if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
||
232 | $param .= '&contextpage=' . urlencode($contextpage); |
||
233 | } |
||
234 | if ($limit > 0 && $limit != $conf->liste_limit) { |
||
235 | $param .= '&limit=' . ((int)$limit); |
||
236 | } |
||
237 | |||
238 | // Try to know count of actioncomm from cache |
||
239 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/memory.lib.php'; |
||
240 | $cachekey = 'count_events_commande_' . $object->id; |
||
241 | $nbEvent = dol_getcache($cachekey); |
||
242 | |||
243 | print_barre_liste($langs->trans("ActionsOnOrder") . (is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">(' . $nbEvent . ')</span>' : ''), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); |
||
244 | //print_barre_liste($langs->trans("ActionsOnOrder"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); |
||
245 | |||
246 | // List of all actions |
||
247 | $filters = array(); |
||
248 | $filters['search_agenda_label'] = $search_agenda_label; |
||
249 | $filters['search_rowid'] = $search_rowid; |
||
250 | |||
251 | // TODO Replace this with same code than into list.php |
||
252 | show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, property_exists($object, 'module') ? $object->module : ''); |
||
253 | } |
||
254 | } |
||
255 | |||
256 | // End of page |
||
257 | ViewMain::llxFooter(); |
||
258 | $db->close(); |
||
259 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.