dolibarr 23.0.4
viewcat.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
3 * Copyright (C) 2006-2024 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7 * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
8 * Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
9 * Copyright (C) 2022-2023 Solution Libre SAS <contact@solution-libre.fr>
10 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
11 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
12 * Copyright (C) 2024-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
13 * Copyright (C) 2023-2024 Charlene Benke <charlene@patas-monkey.com>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 */
28
35// Load Dolibarr environment
36require '../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
47require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
48
49// Load translation files required by the page
50$langs->loadLangs(array("categories", "compta"));
51
52$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
53$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
54$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
55$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
56$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
57$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
58$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'categorylist'; // To manage different context of search
59$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
60$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
61
62$id = GETPOSTINT('id');
63$label = GETPOST('label', 'alpha');
64$removeelem = GETPOSTINT('removeelem');
65$elemid = GETPOSTINT('elemid');
66
67if (GETPOST('addintocategory')) {
68 $action = 'addintocategory';
69}
70
71
72// Load variable for pagination
73$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
74$sortfield = GETPOST('sortfield', 'aZ09comma');
75$sortorder = GETPOST('sortorder', 'aZ09comma');
76$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
77if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
78 $page = 0;
79} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
80$offset = $limit * $page;
81$pageprev = $page - 1;
82$pagenext = $page + 1;
83
84if ($id == "" && $label == "") {
85 dol_print_error(null, 'Missing parameter id');
86 exit();
87}
88
89// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array
90$hookmanager->initHooks(array('categorycard', 'globalcard'));
91
92$object = new Categorie($db);
93$result = $object->fetch($id, $label);
94if ($result <= 0) {
95 dol_print_error($db, $object->error);
96 exit;
97}
98
99// Security check
100$result = restrictedArea($user, 'categorie', $object->id, '&category');
101
102$type = $object->type;
103if (is_numeric($type)) {
104 $type = array_search($type, $object->MAP_ID); // For backward compatibility
105}
106
107$extrafields = new ExtraFields($db);
108$extrafields->fetch_name_optionals_label($object->table_element);
109
110/*
111 * Actions
112 */
113
114if ($confirm == 'no') {
115 if ($backtopage) {
116 header("Location: ".$backtopage);
117 exit;
118 }
119}
120$parameters = array('type' => $type, 'id' => $id, 'label' => $label);
121$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
122// Remove element from category
123if ($id > 0 && $removeelem > 0 && $action == 'unlink') { // Test on permission not required here. Done later according to type of object.
124 $tmpobject = null;
125 $elementtype = '';
126 if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
127 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
128 $tmpobject = new Product($db);
129 $result = $tmpobject->fetch($removeelem);
130 $elementtype = 'product';
131 } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) {
132 $tmpobject = new Societe($db);
133 $result = $tmpobject->fetch($removeelem);
134 $elementtype = 'supplier';
135 } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) {
136 $tmpobject = new Societe($db);
137 $result = $tmpobject->fetch($removeelem);
138 $elementtype = 'customer';
139 } elseif ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) {
140 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
141 $tmpobject = new Adherent($db);
142 $result = $tmpobject->fetch($removeelem);
143 $elementtype = 'member';
144 } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) {
145 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
146 $tmpobject = new Contact($db);
147 $result = $tmpobject->fetch($removeelem);
148 $elementtype = 'contact';
149 } elseif ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) {
150 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
151 $tmpobject = new Account($db);
152 $result = $tmpobject->fetch($removeelem);
153 $elementtype = 'account';
154 } elseif ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) {
155 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
156 $tmpobject = new Project($db);
157 $result = $tmpobject->fetch($removeelem);
158 $elementtype = 'project';
159 } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) {
160 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
161 $tmpobject = new User($db);
162 $result = $tmpobject->fetch($removeelem);
163 $elementtype = 'user';
164 } elseif ($type == Categorie::TYPE_WAREHOUSE && $user->hasRight('stock', 'creer')) {
165 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
166 $tmpobject = new Entrepot($db);
167 $result = $tmpobject->fetch($removeelem);
168 $elementtype = 'warehouse';
169 } elseif ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) {
170 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
171 $tmpobject = new Ticket($db);
172 $result = $tmpobject->fetch($removeelem);
173 $elementtype = 'ticket';
174 } elseif ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) {
175 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
176 $tmpobject = new Fichinter($db);
177 $result = $tmpobject->fetch($removeelem);
178 $elementtype = 'fichinter';
179 } elseif ($type == Categorie::TYPE_ORDER && $user->hasRight('commande', 'creer')) {
180 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
181 $tmpobject = new Commande($db);
182 $result = $tmpobject->fetch($removeelem);
183 $elementtype = 'order';
184 } elseif ($type == Categorie::TYPE_INVOICE && $user->hasRight('facture', 'creer')) {
185 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
186 $tmpobject = new Facture($db);
187 $result = $tmpobject->fetch($removeelem);
188 $elementtype = 'invoice';
189 } elseif ($type == Categorie::TYPE_SUPPLIER_ORDER && $user->hasRight('fournisseur', 'commande', 'creer')) {
190 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
191 $tmpobject = new CommandeFournisseur($db);
192 $result = $tmpobject->fetch($removeelem);
193 $elementtype = 'supplier_order';
194 } elseif ($type == Categorie::TYPE_SUPPLIER_INVOICE && $user->hasRight('fournisseur', 'facture', 'creer')) {
195 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
196 $tmpobject = new FactureFournisseur($db);
197 $result = $tmpobject->fetch($removeelem);
198 $elementtype = 'supplier_invoice';
199 } else {
200 dol_print_error(null, "Not supported value of type = ".$type);
201 $result = -100;
202 }
203
204 if ($tmpobject !== null) {
205 // also enter here when item was not found to report error
206 $result = $object->del_type($tmpobject, $elementtype);
207 if ($result < 0) {
208 dol_print_error(null, $object->error);
209 }
210 }
211}
212
213if ($user->hasRight('categorie', 'supprimer') && $action == 'confirm_delete' && $confirm == 'yes') {
214 if ($object->delete($user) >= 0) {
215 if ($backtopage) {
216 header("Location: ".$backtopage);
217 exit;
218 } else {
219 header("Location: ".dolBuildUrl(DOL_URL_ROOT.'/categories/categorie_list.php', ['type' => $type]));
220 exit;
221 }
222 } else {
223 setEventMessages($object->error, $object->errors, 'errors');
224 }
225}
226
227if ($elemid && $action == 'addintocategory') { // Test on permission not required here. Done just after depending on object type
228 $newobject = null;
229 $elementtype = '';
230 if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
231 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
232 $newobject = new Product($db);
233 $elementtype = 'product';
234 } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) {
235 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
236 $newobject = new Societe($db);
237 $elementtype = 'customer';
238 } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) {
239 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
240 $newobject = new Societe($db);
241 $elementtype = 'supplier';
242 } elseif ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) {
243 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
244 $newobject = new Ticket($db);
245 $elementtype = 'ticket';
246 } elseif ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) {
247 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
248 $newobject = new Fichinter($db);
249 $elementtype = 'fichinter';
250 } elseif ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) {
251 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
252 $newobject = new Project($db);
253 $elementtype = 'project';
254 } elseif ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) {
255 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
256 $newobject = new Adherent($db);
257 $elementtype = 'member';
258 } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) {
259 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
260 $newobject = new Contact($db);
261 $elementtype = 'contact';
262 } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) {
263 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
264 $newobject = new User($db);
265 $elementtype = 'user';
266 } elseif ($type == Categorie::TYPE_WAREHOUSE && $user->hasRight('stock', 'creer')) {
267 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
268 $newobject = new Entrepot($db);
269 $elementtype = 'warehouse';
270 } elseif ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) {
271 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
272 $newobject = new Account($db);
273 $elementtype = 'bank_account';
274 } elseif ($type == Categorie::TYPE_ORDER && $user->hasRight('commande', 'creer')) {
275 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
276 $newobject = new Commande($db);
277 $elementtype = 'order';
278 } elseif ($type == Categorie::TYPE_INVOICE && $user->hasRight('facture', 'creer')) {
279 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
280 $newobject = new Facture($db);
281 $elementtype = 'invoice';
282 } elseif ($type == Categorie::TYPE_SUPPLIER_ORDER && $user->hasRight('fournisseur', 'commande', 'creer')) {
283 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
284 $newobject = new CommandeFournisseur($db);
285 $elementtype = 'supplier_order';
286 } elseif ($type == Categorie::TYPE_SUPPLIER_INVOICE && $user->hasRight('fournisseur', 'facture', 'creer')) {
287 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
288 $newobject = new FactureFournisseur($db);
289 $elementtype = 'supplier_invoice';
290 } else {
291 // No permission to modify the objects of this type: refuse instead of reporting a success
292 $result = -1;
293 $object->error = $langs->trans("NotEnoughPermissions");
294 }
295 if ($newobject !== null) {
296 $result = $newobject->fetch($elemid);
297 }
298
299 if ($result >= 0 && $newobject !== null) {
300 // Add into category
301 $result = $object->add_type($newobject, $elementtype);
302 }
303 if ($result >= 0) {
304 setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs');
305 } else {
306 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
307 setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
308 } else {
309 setEventMessages($object->error, $object->errors, 'errors');
310 }
311 }
312}
313
314
315/*
316 * View
317 */
318
319$form = new Form($db);
320$formother = new FormOther($db);
321
322$arrayofjs = array(
323 '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
324 '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'
325);
326$arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
327
328$help_url = '';
329
330llxHeader("", $langs->trans("Categories"), $help_url, '', 0, 0, $arrayofjs, $arrayofcss);
331
332$title = $langs->trans("Categories");
333$title .= ' ('.$langs->trans(empty(Categorie::$MAP_TYPE_TITLE_AREA[$type]) ? ucfirst($type) : Categorie::$MAP_TYPE_TITLE_AREA[$type]).')';
334
335$head = categories_prepare_head($object, $type);
336print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category');
337
338$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/categorie_list.php?leftmenu=cat&type='.urlencode($type));
339$linkback = '<a href="'.dol_sanitizeUrl($backtolist).'">'.$langs->trans("BackToList").'</a>';
340$object->next_prev_filter = 'type:=:'.((int) $object->type);
341$object->ref = $object->label;
342$morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/categorie_list.php?leftmenu=cat&type='.urlencode($type).'">'.$langs->trans("Root").'</a>';
343$morehtmlref .= ' > ';
344$ways = $object->print_all_ways("auto", '', 1, 0, 1);
345foreach ($ways as $way) {
346 $morehtmlref .= $way."<br>\n";
347}
348$morehtmlref .= '</div>';
349
350dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.urlencode($type), 0, '', '', 1);
351
352
353// Confirmation of deletion
354if ($action == 'delete') {
355 if ($backtopage) {
356 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.urlencode($type).'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2);
357 } else {
358 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.urlencode($type), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
359 }
360}
361
362print '<br>';
363
364print '<div class="fichecenter">';
365print '<div class="underbanner clearboth"></div>';
366print '<table class="border centpercent tableforfield">';
367
368// Description
369print '<tr><td class="titlefield notopnoleft tdtop">';
370print $langs->trans("Description").'</td><td>';
371print dol_htmlentitiesbr($object->description);
372print '</td></tr>';
373
374// Color
375print '<tr><td class="notopnoleft">';
376print $langs->trans("Color").'</td><td>';
377print $formother->showColor($object->color);
378print '</td></tr>';
379
380// Position
381print '<tr><td class="titlefield notopnoleft">';
382print $langs->trans("Position").'</td><td>';
383print $object->position ? $object->position : '';
384print '</td></tr>';
385
386// Other attributes
387include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
388
389print '</table>';
390print '</div>';
391
392print dol_get_fiche_end();
393
394
395/*
396 * Boutons actions
397 */
398
399print "<div class='tabsAction'>\n";
400$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
401if ($reshook < 0) {
402 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
403}
404if (empty($reshook)) {
405 if ($user->hasRight('categorie', 'creer')) {
406 $socid = ($object->socid ? $object->socid : "");
407 print '<a class="butAction" href="'.dolBuildUrl(DOL_URL_ROOT.'/categories/edit.php', ['id' => $object->id, 'socid' => $socid, 'type' => $type]).'">'.$langs->trans("Modify").'</a>';
408 }
409
410 if ($user->hasRight('categorie', 'supprimer')) {
411 print '<a class="butActionDelete" href="'.dolBuildUrl($_SERVER["PHP_SELF"], ['action' => 'delete', 'id' => $object->id, 'type' => $type, 'backtolist' => $backtolist], true).'">'.$langs->trans("Delete").'</a>';
412 }
413}
414
415print "</div>";
416
417$newcardbutton = '';
418if ($user->hasRight('categorie', 'creer')) {
419 $link = dolBuildUrl(DOL_URL_ROOT.'/categories/card.php', ['action'=> 'create', 'type' => $type, 'catorigin' => $object->id, 'backtopage' => dolBuildUrl($_SERVER["PHP_SELF"], ['type' => $type, 'id' => $id])]);
420
421 $newcardbutton = '<div class="right">';
422 $newcardbutton .= dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', $link);
423 $newcardbutton .= '</div>';
424}
425
426
427/*
428 * Sub-category tree view of this category
429 */
430
431print '<div class="fichecenter">';
432
433print load_fiche_titre($langs->trans("SubCats"), $newcardbutton, 'object_category');
434
435$cats = $object->get_filles();
436
437print '<table class="liste nohover noborder centpercent borderbottom">';
438
439print '<tr class="liste_titre">';
440print '<td>'.$langs->trans("SubCats").'</td>';
441print '<td></td>';
442print '<td class="right">';
443
444if (is_array($cats) && count($cats) > 1 && !empty($conf->use_javascript_ajax)) {
445 print '<div id="iddivjstreecontrol">';
446 print '<a class="notasortlink" href="#">'.img_picto('', 'folder').' '.$langs->trans("UndoExpandAll").'</a>';
447 print " | ";
448 print '<a class="notasortlink" href="#">'.img_picto('', 'folder-open').' '.$langs->trans("ExpandAll").'</a>';
449 print '</div>';
450}
451
452print '</td>';
453print '</tr>';
454
455if (is_numeric($cats) && $cats < 0) {
456 dol_print_error($db, $object->error, $object->errors);
457} elseif (count($cats) < 1) {
458 print '<tr class="oddeven nobottom nohover">';
459 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("NoSubCat").'</span></td>';
460 print '</tr>';
461} else {
462 $categstatic = new Categorie($db);
463
464 $fulltree = $categstatic->get_full_arbo($type, $object->id, 1);
465
466 // Load possible missing includes
467 if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) {
468 if ($type == Categorie::TYPE_MEMBER) {
469 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
470 }
471 if ($type == Categorie::TYPE_ACCOUNT) {
472 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
473 }
474 if ($type == Categorie::TYPE_PROJECT) {
475 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
476 }
477 if ($type == Categorie::TYPE_USER) {
478 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
479 }
480 }
481
482 // Define data (format for treeview)
483 $data = array();
484 $data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => 'racine', 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => '');
485 foreach ($fulltree as $key => $val) {
486 $categstatic->id = $val['id'];
487 $categstatic->ref = $val['label'];
488 $categstatic->color = $val['color'];
489 $categstatic->type = $type;
490 //$desc = dol_htmlcleanlastbr($val['description']);
491
492 $counter = '';
493 if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) {
494 // we need only a count of the elements, so it is enough to consume only the id's from the database
495 $elements = $categstatic->getObjectsInCateg($type, 1);
496
497 $counter = "<td class='left' width='40px;'>".(is_array($elements) ? count($elements) : '0')."</td>";
498 }
499
500 if ($categstatic->color) {
501 $stylecolor = ' style="background: #'.sprintf("%06s", $categstatic->color).';"';
502 } else {
503 $stylecolor = ' style="background: #bbb;"';
504 }
505 $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.((int) $id).'&type='.urlencode($type)), 0);
506
507 $entry = '<table class="nobordernopadding centpercent">';
508 $entry .= '<tr>';
509
510 $entry .= '<td>';
511 $entry .= '<span class="noborderoncategories" '.$stylecolor.'>'.$li.'</span>';
512 $entry .= '</td>';
513
514 $entry .= $counter;
515
516 $entry .= '<td class="right" width="20px;">';
517 $entry .= '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.urlencode($type).'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.urlencode($type)).'">'.img_view().'</a>';
518 $entry .= '</td>';
519 $entry .= '<td class="right" width="20px;">';
520 $entry .= '<a class="editfielda" href="'.DOL_URL_ROOT.'/categories/edit.php?id='.$val['id'].'&type='.urlencode($type).'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.urlencode($type)).'">'.img_edit().'</a>';
521 $entry .= '</td>';
522 $entry .= '<td class="right" width="20px;">';
523 $entry .= '<a class="deletefilelink" href="'.DOL_URL_ROOT.'/categories/viewcat.php?action=delete&token='.newToken().'&id='.$val['id'].'&type='.urlencode($type).'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.urlencode($type)).'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.urlencode($type)).'">'.img_delete().'</a>';
524 $entry .= '</td>';
525
526 $entry .= '</tr>';
527 $entry .= '</table>';
528
529 $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
530 }
531
532 $nbofentries = (count($data) - 1);
533 if ($nbofentries > 0) {
534 require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
535 print '<tr class="pair">';
536 print '<td colspan="3">';
537
538 // $data[0] is the current shown category, to don'T show the current category use $data[1] instead
539 tree_recur($data, $data[1], 0);
540
541 print '</td>';
542 print '</tr>';
543 } else {
544 print '<tr class="pair">';
545 print '<td colspan="3">';
546 print '<table class="nobordernopadding">';
547
548 print '<tr class="nobordernopadding">';
549 print '<td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
550 print '<td class="valignmiddle"><span class="opacitymedium">'.$langs->trans("NoCategoryYet").'</span></td>';
551 print '<td>&nbsp;</td>';
552 print '</tr>';
553
554 print '</table>';
555 print '</td>';
556 print '</tr>';
557 }
558}
559
560print "</table>";
561print "</div>";
562
563// List of mass actions available
564$arrayofmassactions = array(
565 //'validate'=>$langs->trans("Validate"),
566 //'generate_doc'=>$langs->trans("ReGeneratePDF"),
567 //'builddoc'=>$langs->trans("PDFMerge"),
568 //'presend'=>$langs->trans("SendByMail"),
569);
570$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
571
572$typeid = $type; // warning, typeid can be a string
573
574
575// List of products or services (type is type of category)
576if ($type == Categorie::TYPE_PRODUCT) {
577 if ($user->hasRight("product", "read") || $user->hasRight("service", "read")) {
578 $permission = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'));
579 $showclassifyform = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'));
580
581 $prods = $object->getObjectsInCateg($type, 0, $limit, $offset, 'ref');
582 if ($prods < 0) {
583 dol_print_error($db, $object->error, $object->errors);
584 } else {
586 '@phan-var-force Product[] $prods';
587 // Form to add record into the category
588 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
589 print '<input type="hidden" name="token" value="'.newToken().'">';
590 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
591 print '<input type="hidden" name="type" value="'.$typeid.'">';
592 print '<input type="hidden" name="id" value="'.$object->id.'">';
593 print '<input type="hidden" name="page_y" value="">';
594 print '<input type="hidden" name="action" value="list">';
595
596 print '<br>';
597 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
598 $num = count($prods);
599 $nbtotalofrecords = '';
600 $newcardbutton = dolGetButtonTitle($langs->trans("AddProduct"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&categories[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->hasRight('societe', 'creer'));
601
602 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
603 print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit);
604
605 if ($showclassifyform) {
606 print '<table class="noborder centpercent">';
607 print '<tr class="liste_titre"><td>';
608 print $langs->trans("AddProductServiceIntoCategory").' &nbsp;';
609 $form->select_produits(0, 'elemid', '', 0, 0, -1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null);
610 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
611 print '</tr>';
612 print '</table>';
613 }
614
615 print '<table class="noborder centpercent">'."\n";
616 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
617
618 if (count($prods) > 0) {
619 $i = 0;
620 foreach ($prods as $prod) {
621 $i++;
622 if ($i > $limit) {
623 break;
624 }
625
626 print '<tr class="oddeven">'."\n";
627 print '<td class="nowrap tdtop">';
628 print $prod->getNomUrl(1);
629 print "</td>\n";
630 print '<td class="tdtop">'.dolPrintHTML($prod->label)."</td>\n";
631 // Link to delete from category
632 print '<td class="right">';
633 if ($permission) {
634 print '<a class="reposition" href= "'.$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".((int) $object->id)."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $prod->id).($limit ? '&limit='.$limit : '').'">';
635 //print $langs->trans("DeleteFromCat");
636 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
637 print "</a>";
638 }
639 print '</td>';
640 print "</tr>\n";
641 }
642 } else {
643 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
644 }
645 print "</table>\n";
646
647 print "</form>\n";
648 }
649 } else {
650 print_barre_liste($langs->trans("ProductsAndServices"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'products');
651 accessforbidden("NotEnoughPermissions", 0, 0);
652 }
653}
654
655// List of customers
656if ($type == Categorie::TYPE_CUSTOMER) {
657 if ($user->hasRight("societe", "read")) {
658 $permission = $user->hasRight('societe', 'creer');
659 $showclassifyform = $user->hasRight('societe', 'creer');
660
661 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset, 'nom');
662 if ($socs < 0) {
663 dol_print_error($db, $object->error, $object->errors);
664 } else {
666 '@phan-var-force Societe[] $socs';
667 // Form to add record into a category
668 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
669 print '<input type="hidden" name="token" value="'.newToken().'">';
670 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
671 print '<input type="hidden" name="type" value="'.$typeid.'">';
672 print '<input type="hidden" name="id" value="'.$object->id.'">';
673 print '<input type="hidden" name="action" value="list">';
674 print '<input type="hidden" name="page_y" value="">';
675
676 print '<br>';
677 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
678 $num = count($socs);
679 $nbtotalofrecords = '';
680 $newcardbutton = dolGetButtonTitle($langs->trans("AddThirdParty"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&customer=3&custcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->hasRight('societe', 'creer'));
681
682 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
683 print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
684
685 if ($showclassifyform) {
686 print '<table class="noborder centpercent">';
687 print '<tr class="liste_titre"><td>';
688 print $langs->trans("AddCustomerIntoCategory").' &nbsp;';
689 $filter = '(s.client:IN:1,2,3)';
690 print $form->select_company('', 'elemid', $filter);
691 print '<input type="submit" class="reposition button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
692 print '</tr>';
693 print '</table>';
694 }
695
696 print '<table class="noborder centpercent">'."\n";
697 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name").'</td></tr>'."\n";
698
699 if (count($socs) > 0) {
700 $i = 0;
701 foreach ($socs as $key => $soc) {
702 $i++;
703 if ($i > $limit) {
704 break;
705 }
706
707 print "\t".'<tr class="oddeven">'."\n";
708 print '<td class="nowrap tdtop tdoverflowmax250">';
709 print $soc->getNomUrl(1);
710 print "</td>\n";
711 // Link to delete from category
712 print '<td class="right">';
713 if ($permission) {
714 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $soc->id).($limit ? '&limit='.$limit : '')."'>";
715 //print $langs->trans("DeleteFromCat");
716 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
717 print "</a>";
718 }
719 print '</td>';
720 print "</tr>\n";
721 }
722 } else {
723 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
724 }
725 print "</table>\n";
726
727 print "</form>\n";
728 }
729 } else {
730 print_barre_liste($langs->trans("Customers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
731 accessforbidden("NotEnoughPermissions", 0, 0);
732 }
733}
734
735// List of suppliers
736if ($type == Categorie::TYPE_SUPPLIER) {
737 if ($user->hasRight("fournisseur", "read")) {
738 $permission = $user->hasRight('societe', 'creer');
739 $showclassifyform = $user->hasRight('societe', 'creer');
740
741 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset, 'nom');
742
743 if ($socs < 0) {
744 dol_print_error($db, $object->error, $object->errors);
745 } else {
747 '@phan-var-force Fournisseur[] $socs';
748 // Form to add record into a category
749 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
750 print '<input type="hidden" name="token" value="'.newToken().'">';
751 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
752 print '<input type="hidden" name="type" value="'.$typeid.'">';
753 print '<input type="hidden" name="id" value="'.$object->id.'">';
754 print '<input type="hidden" name="page_y" value="">';
755 print '<input type="hidden" name="action" value="list">';
756
757 print '<br>';
758 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
759 $num = count($socs);
760 $nbtotalofrecords = '';
761 $newcardbutton = dolGetButtonTitle($langs->trans("AddSupplier"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&fournisseur=1&suppcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->hasRight('societe', 'creer'));
762
763 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
764 print_barre_liste($langs->trans("Suppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
765
766 if ($showclassifyform) {
767 print '<table class="noborder centpercent">';
768 print '<tr class="liste_titre"><td>';
769 print $langs->trans("AddSupplierIntoCategory").' &nbsp;';
770 $filter = '(s.fournisseur:=:1)';
771 print $form->select_company('', 'elemid', $filter);
772 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
773 print '</tr>';
774 print '</table>';
775 }
776
777 print '<table class="noborder centpercent">'."\n";
778 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name")."</td></tr>\n";
779
780 if (count($socs) > 0) {
781 $i = 0;
782 foreach ($socs as $soc) {
783 $i++;
784 if ($i > $limit) {
785 break;
786 }
787
788 print "\t".'<tr class="oddeven">'."\n";
789 print '<td class="nowrap tdtop">';
790 print $soc->getNomUrl(1);
791 print "</td>\n";
792 // Link to delete from category
793 print '<td class="right">';
794 if ($permission) {
795 print '<a class="reposition" href="'.$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $soc->id).($limit ? '&limit='.$limit : '').'">';
796 //print $langs->trans("DeleteFromCat");
797 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
798 print "</a>";
799 }
800 print '</td>';
801
802 print "</tr>\n";
803 }
804 } else {
805 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
806 }
807 print "</table>\n";
808
809 print "</form>\n";
810 }
811 } else {
812 print_barre_liste($langs->trans("Suppliers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
813 accessforbidden("NotEnoughPermissions", 0, 0);
814 }
815}
816
817// List of members
818if ($type == Categorie::TYPE_MEMBER) {
819 if ($user->hasRight("adherent", "read")) {
820 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
821
822 $permission = $user->hasRight('adherent', 'creer');
823 $showclassifyform = $user->hasRight('adherent', 'creer');
824
825 $members = $object->getObjectsInCateg($type, 0, $limit, $offset, 'lastname');
826 if ($members < 0) {
827 dol_print_error($db, $object->error, $object->errors);
828 } else {
830 '@phan-var-force Adherent[] $members';
831 // Form to add record into a category
832 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
833 print '<input type="hidden" name="token" value="'.newToken().'">';
834 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
835 print '<input type="hidden" name="type" value="'.$typeid.'">';
836 print '<input type="hidden" name="id" value="'.$object->id.'">';
837 print '<input type="hidden" name="page_y" value="">';
838 print '<input type="hidden" name="action" value="list">';
839
840 print '<br>';
841 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
842 $num = count($members);
843 $nbtotalofrecords = '';
844 $newcardbutton = dolGetButtonTitle($langs->trans("AddMember"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create&memcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->hasRight('adherent', 'creer'));
845
846 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
847 print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit);
848
849 if ($showclassifyform) {
850 print '<table class="noborder centpercent">';
851 print '<tr class="liste_titre"><td>';
852 print $langs->trans("AssignCategoryTo").' &nbsp;';
853 print $form->selectMembers('', 'elemid');
854 print '<input type="submit" class="button buttongen" value="'.$langs->trans("Save").'"></td>';
855 print '</tr>';
856 print '</table>';
857 }
858
859 print '<table class="noborder centpercent">'."\n";
860 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Name").'</td></tr>'."\n";
861
862 if (count($members) > 0) {
863 $i = 0;
864 foreach ($members as $key => $member) {
865 $i++;
866 if ($i > $limit) {
867 break;
868 }
869
870 print "\t".'<tr class="oddeven">'."\n";
871 print '<td class="nowrap tdtop">';
872 $member->ref = $member->login;
873 print $member->getNomUrl(1, 0);
874 print "</td>\n";
875 print '<td class="tdtop">'.$member->lastname."</td>\n";
876 print '<td class="tdtop">'.$member->firstname."</td>\n";
877 // Link to delete from category
878 print '<td class="right">';
879 if ($permission) {
880 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $member->id).($limit ? '&limit='.$limit : '')."'>";
881 //print $langs->trans("DeleteFromCat");
882 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
883 print "</a>";
884 }
885 print '</td>';
886 print "</tr>\n";
887 }
888 } else {
889 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
890 }
891 print "</table>\n";
892
893 print "</form>\n";
894 }
895 } else {
896 print_barre_liste($langs->trans("Member"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'members');
897 accessforbidden("NotEnoughPermissions", 0, 0);
898 }
899}
900
901// List of contacts
902if ($type == Categorie::TYPE_CONTACT) {
903 if ($user->hasRight("societe", "read")) {
904 $permission = $user->hasRight('societe', 'creer');
905 $showclassifyform = $user->hasRight('societe', 'creer');
906
907 $contacts = $object->getObjectsInCateg($type, 0, $limit, $offset, 'lastname');
908 if (is_numeric($contacts) && $contacts < 0) {
909 dol_print_error($db, $object->error, $object->errors);
910 } else {
912 '@phan-var-force Contact[] $contacts';
913 // Form to add record into a category
914 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
915 print '<input type="hidden" name="token" value="'.newToken().'">';
916 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
917 print '<input type="hidden" name="type" value="'.$typeid.'">';
918 print '<input type="hidden" name="id" value="'.$object->id.'">';
919 print '<input type="hidden" name="page_y" value="">';
920 print '<input type="hidden" name="action" value="list">';
921
922 print '<br>';
923 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
924 $num = count($contacts);
925 $nbtotalofrecords = '';
926 $newcardbutton = dolGetButtonTitle($langs->trans("AddContact"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create&contcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->hasRight('societe', 'creer'));
927
928 $objsoc = new Societe($db);
929
930 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
931 print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contact', 0, $newcardbutton, '', $limit);
932
933 if ($showclassifyform) {
934 print '<table class="noborder centpercent">';
935 print '<tr class="liste_titre"><td>';
936 print $langs->trans("AssignCategoryTo").' &nbsp;';
937 print $form->select_contact(0, '', 'elemid', '', '', '', 0, 'maxwidth300 widthcentpercentminusx');
938 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
939 print '</tr>';
940 print '</table>';
941 }
942
943 print '<table class="noborder centpercent">'."\n";
944 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Ref").'</td></tr>'."\n";
945
946 if (is_array($contacts) && count($contacts) > 0) {
947 $i = 0;
948 foreach ($contacts as $key => $contact) {
949 $i++;
950 if ($i > $limit) {
951 break;
952 }
953
954 print "\t".'<tr class="oddeven">'."\n";
955 print '<td class="nowrap tdtop">';
956 print $contact->getNomUrl(1, 'category');
957 if ($contact->socid > 0) {
958 $objsoc->fetch($contact->socid);
959 print ' - ';
960 print $objsoc->getNomUrl(1, 'contact');
961 }
962 print "</td>\n";
963 // Link to delete from category
964 print '<td class="right">';
965 if ($permission) {
966 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $contact->id).($limit ? '&limit='.$limit : '')."'>";
967 //print $langs->trans("DeleteFromCat");
968 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
969 print "</a>";
970 }
971 print '</td>';
972 print "</tr>\n";
973 }
974 } else {
975 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
976 }
977 print "</table>\n";
978
979 print "</form>\n";
980 }
981 } else {
982 print_barre_liste($langs->trans("Contact"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'contact');
983 accessforbidden("NotEnoughPermissions", 0, 0);
984 }
985}
986
987// List of bank accounts
988if ($type == Categorie::TYPE_ACCOUNT) {
989 if ($user->hasRight("banque", "read")) {
990 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
991
992 $permission = $user->hasRight('banque', 'creer');
993 $showclassifyform = $user->hasRight('banque', 'creer');
994
995 $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset);
996 if ($accounts < 0) {
997 dol_print_error($db, $object->error, $object->errors);
998 } else {
1000 '@phan-var-force Account[] $accounts';
1001 // Form to add record into a category
1002 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1003 print '<input type="hidden" name="token" value="'.newToken().'">';
1004 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1005 print '<input type="hidden" name="type" value="'.$typeid.'">';
1006 print '<input type="hidden" name="id" value="'.$object->id.'">';
1007 print '<input type="hidden" name="page_y" value="">';
1008 print '<input type="hidden" name="action" value="list">';
1009
1010 print '<br>';
1011 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1012 $num = count($accounts);
1013 $nbtotalofrecords = '';
1014 $newcardbutton = '';
1015
1016 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1017 print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit);
1018
1019 if ($showclassifyform) {
1020 print '<table class="noborder centpercent">';
1021 print '<tr class="liste_titre"><td>';
1022 print $langs->trans("AddObjectIntoCategory").' &nbsp;';
1023 print $form->select_comptes('', 'elemid', 0, '', 0, '', 0, '', 1);
1024 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1025 print '</tr>';
1026 print '</table>';
1027 }
1028
1029 print '<table class="noborder centpercent">'."\n";
1030 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1031
1032 if (count($accounts) > 0) {
1033 $i = 0;
1034 foreach ($accounts as $key => $account) {
1035 $i++;
1036 if ($i > $limit) {
1037 break;
1038 }
1039
1040 print "\t".'<tr class="oddeven">'."\n";
1041 print '<td class="nowrap tdtop">';
1042 print $account->getNomUrl(1, '0');
1043 print "</td>\n";
1044 print '<td class="tdtop">'.$account->bank."</td>\n";
1045 print '<td class="tdtop">'.$account->number."</td>\n";
1046 // Link to delete from category
1047 print '<td class="right">';
1048 if ($permission) {
1049 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $account->id).($limit ? '&limit='.$limit : '')."'>";
1050 //print $langs->trans("DeleteFromCat");
1051 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1052 print "</a>";
1053 }
1054 print '</td>';
1055 print "</tr>\n";
1056 }
1057 } else {
1058 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1059 }
1060 print "</table>\n";
1061
1062 print "</form>\n";
1063 }
1064 } else {
1065 print_barre_liste($langs->trans("Banque"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'bank');
1066 accessforbidden("NotEnoughPermissions", 0, 0);
1067 }
1068}
1069
1070// List of Project
1071if ($type == Categorie::TYPE_PROJECT) {
1072 if ($user->hasRight("project", "read")) {
1073 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
1074
1075 $permission = $user->hasRight('projet', 'creer');
1076 $showclassifyform = $user->hasRight('projet', 'creer');
1077
1078 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1079 if ($objects < 0) {
1080 dol_print_error($db, $object->error, $object->errors);
1081 } else {
1083 '@phan-var-force Project[] $objects';
1084 // Form to add record into a category
1085 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1086 print '<input type="hidden" name="token" value="'.newToken().'">';
1087 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1088 print '<input type="hidden" name="type" value="'.$typeid.'">';
1089 print '<input type="hidden" name="id" value="'.$object->id.'">';
1090 print '<input type="hidden" name="page_y" value="">';
1091 print '<input type="hidden" name="action" value="list">';
1092
1093 print '<br>';
1094 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1095 $num = count($objects);
1096 $nbtotalofrecords = '';
1097 $newcardbutton = '';
1098
1099 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1100 print_barre_liste($langs->trans("Project"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit);
1101
1102 if ($showclassifyform) {
1103 print '<table class="noborder centpercent">';
1104 print '<tr class="liste_titre"><td>';
1105 print $langs->trans("AddObjectIntoCategory").' &nbsp;';
1106 $form->selectProjects('', 'elemid');
1107 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1108 print '</tr>';
1109 print '</table>';
1110 }
1111
1112 print '<table class="noborder centpercent">'."\n";
1113 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1114
1115 if (count($objects) > 0) {
1116 $i = 0;
1117 foreach ($objects as $key => $project) {
1118 $i++;
1119 if ($i > $limit) {
1120 break;
1121 }
1122
1123 print "\t".'<tr class="oddeven">'."\n";
1124 print '<td class="nowrap tdtop">';
1125 print $project->getNomUrl(1);
1126 print "</td>\n";
1127 print '<td class="tdtop">'.$project->title."</td>\n";
1128 // Link to delete from category
1129 print '<td class="right">';
1130 if ($permission) {
1131 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $project->id).($limit ? '&limit='.$limit : '')."'>";
1132 //print $langs->trans("DeleteFromCat");
1133 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1134 print "</a>";
1135 }
1136 print '</td>';
1137 print "</tr>\n";
1138 }
1139 } else {
1140 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1141 }
1142 print "</table>\n";
1143
1144 print "</form>\n";
1145 }
1146 } else {
1147 print_barre_liste($langs->trans("Project"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'project');
1148 accessforbidden("NotEnoughPermissions", 0, 0);
1149 }
1150}
1151
1152// List of users
1153if ($type == Categorie::TYPE_USER) {
1154 if ($user->hasRight("user", "user", "read")) {
1155 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
1156 $showclassifyform = $user->hasRight("user", "user", "creer");
1157
1158 $users = $object->getObjectsInCateg($type, 0, 0, 0, 'lastname');
1159 if ($users < 0) {
1160 dol_print_error($db, $object->error, $object->errors);
1161 } else {
1163 '@phan-var-force User[] $users';
1164
1165 // Form to add record into a category
1166 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1167 print '<input type="hidden" name="token" value="'.newToken().'">';
1168 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1169 print '<input type="hidden" name="type" value="'.$typeid.'">';
1170 print '<input type="hidden" name="id" value="'.$object->id.'">';
1171 print '<input type="hidden" name="page_y" value="">';
1172 print '<input type="hidden" name="action" value="list">';
1173
1174 print '<br>';
1175
1176 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1177 $num = count($users);
1178 $nbtotalofrecords = '';
1179 $newcardbutton = '';
1180
1181 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1182 print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, '', '', $limit);
1183
1184 if ($showclassifyform) {
1185 print '<table class="noborder centpercent">';
1186 print '<tr class="liste_titre"><td>';
1187 $force_entity = getEntity($object->element); // So we will get same filter than the getObjectsInCateg()
1188 print img_picto('', $type, 'class="pictofixedwidth"');
1189 print $form->select_dolusers('', 'elemid', 1, null, 0, '', '', $force_entity);
1190 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1191 print '</tr>';
1192 print '</table>';
1193 }
1194
1195 print '<table class="noborder centpercent">'."\n";
1196 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Users").' <span class="badge">'.$num.'</span></td></tr>'."\n";
1197
1198 if (count($users) > 0) {
1199 // Use "$userentry" here, because "$user" is the current user
1200 foreach ($users as $key => $userentry) {
1201 print "\t".'<tr class="oddeven">'."\n";
1202 print '<td class="nowrap tdtop">';
1203 print $userentry->getNomUrl(-1);
1204 print "</td>\n";
1205 print '<td class="tdtop">'.$userentry->job."</td>\n";
1206
1207 // Link to delete from category
1208 print '<td class="right">';
1209 if ($user->hasRight('user', 'user', 'creer')) {
1210 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $userentry->id).($limit ? '&limit='.$limit : '')."'>";
1211 //print $langs->trans("DeleteFromCat");
1212 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1213 print "</a>";
1214 }
1215 print '</td>';
1216 print "</tr>\n";
1217 }
1218 } else {
1219 print '<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1220 }
1221 print "</table>\n";
1222
1223 print "</form>\n";
1224 }
1225 } else {
1226 print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'user');
1227 accessforbidden("NotEnoughPermissions", 0, 0);
1228 }
1229}
1230
1231// List of warehouses
1232if ($type == Categorie::TYPE_WAREHOUSE) {
1233 if ($user->hasRight("stock", "read")) {
1234 $permission = $user->hasRight('stock', 'creer');
1235 $showclassifyform = $user->hasRight('stock', 'creer');
1236
1237 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
1238
1239 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1240 if ($objects < 0) {
1241 dol_print_error($db, $object->error, $object->errors);
1242 } else {
1244 '@phan-var-force Entrepot[] $objects';
1245 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1246 print '<input type="hidden" name="token" value="'.newToken().'">';
1247 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1248 print '<input type="hidden" name="type" value="'.$typeid.'">';
1249 print '<input type="hidden" name="id" value="'.$object->id.'">';
1250 print '<input type="hidden" name="page_y" value="">';
1251 print '<input type="hidden" name="action" value="list">';
1252
1253 print '<br>';
1254 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1255 $num = count($objects);
1256 $nbtotalofrecords = '';
1257 $newcardbutton = '';
1258
1259 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1260 print_barre_liste($langs->trans("Warehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit);
1261
1262 if ($showclassifyform) {
1263 print '<table class="noborder centpercent">';
1264 print '<tr class="liste_titre"><td>';
1265 print $langs->trans("AddWarehouseIntoCategory").' &nbsp;';
1266 print $form->selectForForms('Entrepot:product/stock/class/entrepot.class.php', 'elemid', 0, 1, '', '', 'maxwidth500');
1267 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1268 print '</tr>';
1269 print '</table>';
1270 }
1271
1272 print '<table class="noborder centpercent">'."\n";
1273 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1274
1275 if (count($objects) > 0) {
1276 $i = 0;
1277 foreach ($objects as $key => $warehouse) {
1278 $i++;
1279 if ($i > $limit) {
1280 break;
1281 }
1282
1283 print "\t".'<tr class="oddeven">'."\n";
1284 print '<td class="nowrap tdtop">';
1285 print $warehouse->getNomUrl(1);
1286 print "</td>\n";
1287 print '<td class="tdtop">'.$warehouse->ref."</td>\n";
1288 print '<td class="tdtop">'.$warehouse->lieu."</td>\n";
1289 // Link to delete from category
1290 print '<td class="right">';
1291 if ($permission) {
1292 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $warehouse->id).($limit ? '&limit='.$limit : '')."'>";
1293 //print $langs->trans("DeleteFromCat");
1294 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1295 print "</a>";
1296 }
1297 print '</td>';
1298 print "</tr>\n";
1299 }
1300 } else {
1301 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1302 }
1303 print "</table>\n";
1304
1305 print "</form>\n";
1306 }
1307 } else {
1308 print_barre_liste($langs->trans("Warehouse"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'stock');
1309 accessforbidden("NotEnoughPermissions", 0, 0);
1310 }
1311}
1312
1313// List of tickets
1314if ($type == Categorie::TYPE_TICKET) {
1315 if ($user->hasRight("ticket", "read")) {
1316 $permission = $user->hasRight('categorie', 'creer');
1317 $showclassifyform = $user->hasRight('categorie', 'creer');
1318
1319 $tickets = $object->getObjectsInCateg($type, 0, $limit, $offset);
1320 if ($tickets < 0) {
1321 dol_print_error($db, $object->error, $object->errors);
1322 } else {
1324 '@phan-var-force Ticket[] $tickets';
1325 // Form to add record into a category
1326 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1327 print '<input type="hidden" name="token" value="'.newToken().'">';
1328 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1329 print '<input type="hidden" name="type" value="'.$typeid.'">';
1330 print '<input type="hidden" name="id" value="'.$object->id.'">';
1331 print '<input type="hidden" name="page_y" value="">';
1332 print '<input type="hidden" name="action" value="list">';
1333
1334 print '<br>';
1335 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1336 $num = count($tickets);
1337 $nbtotalofrecords = '';
1338 $newcardbutton = '';
1339
1340 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1341 print_barre_liste($langs->trans("Ticket"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'ticket', 0, $newcardbutton, '', $limit);
1342
1343 if ($showclassifyform) {
1344 print '<table class="noborder centpercent">';
1345 print '<tr class="liste_titre"><td>';
1346 print $langs->trans("AddTicketIntoCategory").' &nbsp;';
1347 $form->selectTickets('', 'elemid');
1348 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1349 print '</tr>';
1350 print '</table>';
1351 }
1352
1353 print '<table class="noborder centpercent">'."\n";
1354 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
1355
1356 if (count($tickets) > 0) {
1357 $i = 0;
1358 foreach ($tickets as $ticket) {
1359 $i++;
1360 if ($i > $limit) {
1361 break;
1362 }
1363
1364 print "\t".'<tr class="oddeven">'."\n";
1365 print '<td class="nowrap tdtop">';
1366 print $ticket->getNomUrl(1);
1367 print "</td>\n";
1368 print '<td class="tdtop">'.$ticket->track_id."</td>\n";
1369 // Link to delete from category
1370 print '<td class="right">';
1371 if ($permission) {
1372 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $ticket->id).($limit ? '&limit='.$limit : '')."'>";
1373 //print $langs->trans("DeleteFromCat");
1374 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1375 print "</a>";
1376 }
1377 print '</td>';
1378 print "</tr>\n";
1379 }
1380 } else {
1381 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1382 }
1383 print "</table>\n";
1384
1385 print "</form>\n";
1386 }
1387 } else {
1388 print_barre_liste($langs->trans("Ticket"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'ticket');
1389 accessforbidden("NotEnoughPermissions", 0, 0);
1390 }
1391}
1392
1393// List of Interventions
1394if ($type == Categorie::TYPE_FICHINTER) {
1395 if ($user->hasRight("fichinter", "lire")) {
1396 $permission = $user->hasRight('categorie', 'creer');
1397 $showclassifyform = $user->hasRight('categorie', 'creer');
1398
1399 $fichinters = $object->getObjectsInCateg($type, 0, $limit, $offset);
1400 if ($fichinters < 0) {
1401 dol_print_error($db, $object->error, $object->errors);
1402 } else {
1404 '@phan-var-force Fichinter[] $fichinters';
1405
1406 // Form to add record into a category
1407 if ($showclassifyform) {
1408 print '<br>';
1409 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1410 print '<input type="hidden" name="token" value="'.newToken().'">';
1411 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1412 print '<input type="hidden" name="type" value="'.$typeid.'">';
1413 print '<input type="hidden" name="id" value="'.$object->id.'">';
1414 print '<input type="hidden" name="action" value="addintocategory">';
1415 print '<table class="noborder centpercent">';
1416 print '<tr class="liste_titre"><td>';
1417 print $langs->trans("AddFichinterIntoCategory").' &nbsp;';
1418 print $form->selectForForms('Fichinter:fichinter/class/fichinter.class.php', 'elemid', 0, 1, '', '', 'maxwidth500');
1419 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1420 print '</tr>';
1421 print '</table>';
1422 print '</form>';
1423 }
1424
1425 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1426 print '<input type="hidden" name="token" value="'.newToken().'">';
1427 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1428 print '<input type="hidden" name="type" value="'.$typeid.'">';
1429 print '<input type="hidden" name="id" value="'.$object->id.'">';
1430 print '<input type="hidden" name="action" value="list">';
1431
1432 print '<br>';
1433 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1434 $num = count($fichinters);
1435 $nbtotalofrecords = '';
1436 $newcardbutton = '';
1437
1438 $langs->load('interventions');
1439 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1440 print_barre_liste($langs->trans("Intervention"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_intervention', 0, $newcardbutton, '', $limit);
1441 print '<table class="noborder centpercent">'."\n";
1442 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
1443
1444 if (count($fichinters) > 0) {
1445 $i = 0;
1446 foreach ($fichinters as $fichinter) {
1447 $i++;
1448 if ($i > $limit) {
1449 break;
1450 }
1451
1452 print "\t".'<tr class="oddeven">'."\n";
1453 print '<td class="nowrap tdtop">';
1454 print $fichinter->getNomUrl(1);
1455 print "</td>\n";
1456 print '<td class="tdtop">'.$fichinter->description."</td>\n";
1457 // Link to delete from category
1458 print '<td class="right">';
1459 if ($permission) {
1460 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".((int) $object->id)."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $fichinter->id).($limit ? '&limit='.$limit : '')."'>";
1461 print $langs->trans("DeleteFromCat");
1462 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1463 print "</a>";
1464 }
1465 print '</td>';
1466 print "</tr>\n";
1467 }
1468 } else {
1469 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1470 }
1471 print "</table>\n";
1472 print "</form>\n";
1473 }
1474 } else {
1475 print_barre_liste($langs->trans("Intervention"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'fichinter');
1476 accessforbidden("NotEnoughPermissions", 0, 0);
1477 }
1478}
1479
1480// List of Orders
1481// The objects of the category are listed only to a user allowed to read them
1482if ($type == Categorie::TYPE_ORDER && !$user->hasRight('commande', 'lire')) {
1483 accessforbidden("NotEnoughPermissions", 0, 0);
1484}
1485if ($type == Categorie::TYPE_ORDER) {
1486 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
1487
1488 $permission = $user->hasRight('commande', 'creer');
1489
1490 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1491 if ($objects < 0) {
1492 dol_print_error($db, $object->error, $object->errors);
1493 } else {
1495 '@phan-var-force Commande[] $objects';
1496 // Form to add record into a category
1497 $showclassifyform = $user->hasRight('order', 'write');
1498 if ($showclassifyform) {
1499 print '<br>';
1500 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1501 print '<input type="hidden" name="token" value="'.newToken().'">';
1502 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1503 print '<input type="hidden" name="type" value="'.$typeid.'">';
1504 print '<input type="hidden" name="id" value="'.$object->id.'">';
1505 print '<input type="hidden" name="action" value="addintocategory">';
1506 print '<table class="noborder centpercent">';
1507 print '<tr class="liste_titre"><td>';
1508 print $langs->trans("AddOrderIntoCategory").' &nbsp;';
1509 print $form->selectForForms('Commande:commande/class/commande.class.php', 'elemid', 0, 1, '', '', 'maxwidth500');
1510 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1511 print '</tr>';
1512 print '</table>';
1513 print '</form>';
1514 }
1515
1516 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1517 print '<input type="hidden" name="token" value="'.newToken().'">';
1518 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1519 print '<input type="hidden" name="type" value="'.$typeid.'">';
1520 print '<input type="hidden" name="id" value="'.$object->id.'">';
1521 print '<input type="hidden" name="action" value="list">';
1522
1523 print '<br>';
1524 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1525 $num = count($objects);
1526 $nbtotalofrecords = '';
1527 $newcardbutton = '';
1528
1529 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1530 print_barre_liste($langs->trans("Orders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit);
1531
1532 print "<table class='noborder centpercent'>\n";
1533 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1534
1535 if (count($objects) > 0) {
1536 $i = 0;
1537 foreach ($objects as $key => $order) {
1538 $i++;
1539 if ($i > $limit) {
1540 break;
1541 }
1542
1543 print "\t".'<tr class="oddeven">'."\n";
1544 print '<td class="nowrap tdtop">';
1545 print $order->getNomUrl(1);
1546 print "</td>\n";
1547 print '<td class="tdtop">'.$order->ref."</td>\n";
1548 // Link to delete from category
1549 print '<td class="right">';
1550 if ($permission) {
1551 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$order->id."'>";
1552 print $langs->trans("DeleteFromCat");
1553 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1554 print "</a>";
1555 }
1556 print "</tr>\n";
1557 }
1558 } else {
1559 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1560 }
1561 print "</table>\n";
1562
1563 print "</form>\n";
1564 }
1565}
1566
1567// List of Invoices
1568if ($type == Categorie::TYPE_INVOICE && !$user->hasRight('facture', 'lire')) {
1569 accessforbidden("NotEnoughPermissions", 0, 0);
1570}
1571if ($type == Categorie::TYPE_INVOICE) {
1572 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1573
1574 $permission = $user->hasRight('facture', 'creer');
1575
1576 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1577 if ($objects < 0) {
1578 dol_print_error($db, $object->error, $object->errors);
1579 } else {
1580 // Form to add record into a category
1581 $showclassifyform = $user->hasRight('facture', 'write');
1582 if ($showclassifyform) {
1583 print '<br>';
1584 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1585 print '<input type="hidden" name="token" value="'.newToken().'">';
1586 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1587 print '<input type="hidden" name="type" value="'.$typeid.'">';
1588 print '<input type="hidden" name="id" value="'.$object->id.'">';
1589 print '<input type="hidden" name="action" value="addintocategory">';
1590 print '<table class="noborder centpercent">';
1591 print '<tr class="liste_titre"><td>';
1592 print $langs->trans("AddInvoiceIntoCategory").' &nbsp;';
1593 print $form->selectForForms('Facture:compta/facture/class/facture.class.php', 'elemid', 0, 1, '', '', 'maxwidth500');
1594 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1595 print '</tr>';
1596 print '</table>';
1597 print '</form>';
1598 }
1599
1600 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1601 print '<input type="hidden" name="token" value="'.newToken().'">';
1602 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1603 print '<input type="hidden" name="type" value="'.$typeid.'">';
1604 print '<input type="hidden" name="id" value="'.$object->id.'">';
1605 print '<input type="hidden" name="action" value="list">';
1606
1607 print '<br>';
1608 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1609 $num = count($objects);
1610 $nbtotalofrecords = '';
1611 $newcardbutton = '';
1612
1613 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1614 print_barre_liste($langs->trans("BillsCustomers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit);
1615
1616 print "<table class='noborder centpercent'>\n";
1617 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1618
1619 if (count($objects) > 0) {
1620 $i = 0;
1621 foreach ($objects as $key => $invoice) {
1622 $i++;
1623 if ($i > $limit) {
1624 break;
1625 }
1626
1627 print "\t".'<tr class="oddeven">'."\n";
1628 print '<td class="nowrap tdtop">';
1629 print $invoice->getNomUrl(1);
1630 print "</td>\n";
1631 print '<td class="tdtop">'.$invoice->ref."</td>\n";
1632 // Link to delete from category
1633 print '<td class="right">';
1634 if ($permission) {
1635 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$invoice->id."'>";
1636 print $langs->trans("DeleteFromCat");
1637 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1638 print "</a>";
1639 }
1640 print "</tr>\n";
1641 }
1642 } else {
1643 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1644 }
1645 print "</table>\n";
1646
1647 print "</form>\n";
1648 }
1649}
1650
1651// List of Supplier Orders
1652if ($type == Categorie::TYPE_SUPPLIER_ORDER && !((isModEnabled('fournisseur') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'commande', 'lire')) || (isModEnabled('supplier_order') && $user->hasRight('supplier_order', 'lire')))) {
1653 accessforbidden("NotEnoughPermissions", 0, 0);
1654}
1655if ($type == Categorie::TYPE_SUPPLIER_ORDER) {
1656 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
1657
1658 $permission = $user->hasRight('fournisseur', 'commande', 'creer');
1659
1660 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1661 if ($objects < 0) {
1662 dol_print_error($db, $object->error, $object->errors);
1663 } else {
1664 // Form to add record into a category
1665 $showclassifyform = $user->hasRight('fournisseur', 'commande', 'creer');
1666 ;
1667 if ($showclassifyform) {
1668 print '<br>';
1669 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1670 print '<input type="hidden" name="token" value="'.newToken().'">';
1671 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1672 print '<input type="hidden" name="type" value="'.$typeid.'">';
1673 print '<input type="hidden" name="id" value="'.$object->id.'">';
1674 print '<input type="hidden" name="action" value="addintocategory">';
1675 print '<table class="noborder centpercent">';
1676 print '<tr class="liste_titre"><td>';
1677 print $langs->trans("AddSupplierOrderIntoCategory").' &nbsp;';
1678 print $form->selectForForms('CommandeFournisseur:fourn/class/fournisseur.commande.class.php', 'elemid', 0, 1, '', '', 'maxwidth500');
1679 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1680 print '</tr>';
1681 print '</table>';
1682 print '</form>';
1683 }
1684
1685 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1686 print '<input type="hidden" name="token" value="'.newToken().'">';
1687 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1688 print '<input type="hidden" name="type" value="'.$typeid.'">';
1689 print '<input type="hidden" name="id" value="'.$object->id.'">';
1690 print '<input type="hidden" name="action" value="list">';
1691
1692 print '<br>';
1693 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1694 $num = count($objects);
1695 $nbtotalofrecords = '';
1696 $newcardbutton = '';
1697
1698 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1699 print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit);
1700
1701 print "<table class='noborder centpercent'>\n";
1702 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1703
1704 if (count($objects) > 0) {
1705 $i = 0;
1706 foreach ($objects as $key => $supplier_order) {
1707 $i++;
1708 if ($i > $limit) {
1709 break;
1710 }
1711
1712 print "\t".'<tr class="oddeven">'."\n";
1713 print '<td class="nowrap tdtop">';
1714 print $supplier_order->getNomUrl(1);
1715 print "</td>\n";
1716 print '<td class="tdtop">'.$supplier_order->ref."</td>\n";
1717 // Link to delete from category
1718 print '<td class="right">';
1719 if ($permission) {
1720 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$supplier_order->id."'>";
1721 print $langs->trans("DeleteFromCat");
1722 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1723 print "</a>";
1724 }
1725 print "</tr>\n";
1726 }
1727 } else {
1728 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1729 }
1730 print "</table>\n";
1731
1732 print "</form>\n";
1733 }
1734}
1735
1736// List of Supplier Invoices
1737if ($type == Categorie::TYPE_SUPPLIER_INVOICE && !((isModEnabled('fournisseur') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled('supplier_invoice') && $user->hasRight('supplier_invoice', 'lire')))) {
1738 accessforbidden("NotEnoughPermissions", 0, 0);
1739}
1740if ($type == Categorie::TYPE_SUPPLIER_INVOICE) {
1741 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1742
1743 $permission = $user->hasRight('fournisseur', 'facture', 'creer');
1744
1745 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1746 if ($objects < 0) {
1747 dol_print_error($db, $object->error, $object->errors);
1748 } else {
1749 // Form to add record into a category
1750 $showclassifyform = $user->hasRight('fournisseur', 'facture', 'creer');;
1751 if ($showclassifyform) {
1752 print '<br>';
1753 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1754 print '<input type="hidden" name="token" value="'.newToken().'">';
1755 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1756 print '<input type="hidden" name="type" value="'.$typeid.'">';
1757 print '<input type="hidden" name="id" value="'.$object->id.'">';
1758 print '<input type="hidden" name="action" value="addintocategory">';
1759 print '<table class="noborder centpercent">';
1760 print '<tr class="liste_titre"><td>';
1761 print $langs->trans("AddSupplierInvoiceIntoCategory").' &nbsp;';
1762 print $form->selectForForms('FactureFournisseur:fourn/class/fournisseur.facture.class.php', 'elemid', 0, 1, '', '', 'maxwidth500');
1763 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1764 print '</tr>';
1765 print '</table>';
1766 print '</form>';
1767 }
1768
1769 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1770 print '<input type="hidden" name="token" value="'.newToken().'">';
1771 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1772 print '<input type="hidden" name="type" value="'.$typeid.'">';
1773 print '<input type="hidden" name="id" value="'.$object->id.'">';
1774 print '<input type="hidden" name="action" value="list">';
1775
1776 print '<br>';
1777 $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = '';
1778
1779 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1780 print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit);
1781
1782 print "<table class='noborder centpercent'>\n";
1783 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1784
1785 if (count($objects) > 0) {
1786 $i = 0;
1787 foreach ($objects as $key => $supplier_invoice) {
1788 $i++;
1789 if ($i > $limit) {
1790 break;
1791 }
1792
1793 print "\t".'<tr class="oddeven">'."\n";
1794 print '<td class="nowrap tdtop">';
1795 print $supplier_invoice->getNomUrl(1);
1796 print "</td>\n";
1797 print '<td class="tdtop">'.$supplier_invoice->ref."</td>\n";
1798 // Link to delete from category
1799 print '<td class="right">';
1800 if ($permission) {
1801 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$supplier_invoice->id."'>";
1802 print $langs->trans("DeleteFromCat");
1803 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1804 print "</a>";
1805 }
1806 print "</tr>\n";
1807 }
1808 } else {
1809 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1810 }
1811 print "</table>\n";
1812
1813 print "</form>\n";
1814 }
1815}
1816
1817// Note that $action and $object may have been modified by some hooks
1818$parameters = array('type' => $type, 'id' => $id, 'label' => $label);
1819$reshook = $hookmanager->executeHooks('addMoreCategoriesList', $parameters, $object, $action);
1820
1821// End of page
1822llxFooter();
1823$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
categories_prepare_head(Categorie $object, $type)
Prepare array with list of tabs.
Class to manage bank accounts.
Class to manage members of a foundation.
Class to manage categories.
Class to manage predefined suppliers products.
Class to manage customers orders.
Class to manage contact/addresses.
Class to manage warehouses.
Class to manage standard extra fields.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation de composants html autre Only common components are here.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
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.
img_view($titlealt='default', $float=0, $other='class="valignmiddle"')
Show logo view card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to generate the form for creating a new ticket.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetalreadyloaded=0, $showfk=0, $moreparam='')
Recursive function to output a tree.