dolibarr 23.0.3
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_TICKET && $user->hasRight('ticket', 'write')) {
165 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
166 $tmpobject = new Ticket($db);
167 $result = $tmpobject->fetch($removeelem);
168 $elementtype = 'ticket';
169 } elseif ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) {
170 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
171 $tmpobject = new Fichinter($db);
172 $result = $tmpobject->fetch($removeelem);
173 $elementtype = 'fichinter';
174 } elseif ($type == Categorie::TYPE_ORDER && $user->hasRight('commande', 'creer')) {
175 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
176 $tmpobject = new Commande($db);
177 $result = $tmpobject->fetch($removeelem);
178 $elementtype = 'order';
179 } elseif ($type == Categorie::TYPE_INVOICE && $user->hasRight('facture', 'creer')) {
180 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
181 $tmpobject = new Facture($db);
182 $result = $tmpobject->fetch($removeelem);
183 $elementtype = 'invoice';
184 } elseif ($type == Categorie::TYPE_SUPPLIER_ORDER && $user->hasRight('fournisseur', 'commande', 'creer')) {
185 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
186 $tmpobject = new CommandeFournisseur($db);
187 $result = $tmpobject->fetch($removeelem);
188 $elementtype = 'supplier_order';
189 } else {
190 dol_print_error(null, "Not supported value of type = ".$type);
191 $result = -100;
192 }
193
194 if ($tmpobject !== null) {
195 // also enter here when item was not found to report error
196 $result = $object->del_type($tmpobject, $elementtype);
197 if ($result < 0) {
198 dol_print_error(null, $object->error);
199 }
200 }
201}
202
203if ($user->hasRight('categorie', 'supprimer') && $action == 'confirm_delete' && $confirm == 'yes') {
204 if ($object->delete($user) >= 0) {
205 if ($backtopage) {
206 header("Location: ".$backtopage);
207 exit;
208 } else {
209 header("Location: ".dolBuildUrl(DOL_URL_ROOT.'/categories/categorie_list.php', ['type' => $type]));
210 exit;
211 }
212 } else {
213 setEventMessages($object->error, $object->errors, 'errors');
214 }
215}
216
217if ($elemid && $action == 'addintocategory') { // Test on permission not required here. Done just after depending on object type
218 $newobject = null;
219 $elementtype = '';
220 if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
221 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
222 $newobject = new Product($db);
223 $elementtype = 'product';
224 } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) {
225 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
226 $newobject = new Societe($db);
227 $elementtype = 'customer';
228 } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) {
229 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
230 $newobject = new Societe($db);
231 $elementtype = 'supplier';
232 } elseif ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) {
233 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
234 $newobject = new Ticket($db);
235 $elementtype = 'ticket';
236 } elseif ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) {
237 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
238 $newobject = new Fichinter($db);
239 $elementtype = 'fichinter';
240 } elseif ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) {
241 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
242 $newobject = new Project($db);
243 $elementtype = 'project';
244 } elseif ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) {
245 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
246 $newobject = new Adherent($db);
247 $elementtype = 'member';
248 } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) {
249 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
250 $newobject = new Contact($db);
251 $elementtype = 'contact';
252 } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) {
253 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
254 $newobject = new User($db);
255 $elementtype = 'user';
256 } elseif ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) {
257 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
258 $newobject = new Account($db);
259 $elementtype = 'bank_account';
260 } elseif ($type == Categorie::TYPE_ORDER && $user->hasRight('commande', 'creer')) {
261 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
262 $newobject = new Commande($db);
263 $elementtype = 'order';
264 } elseif ($type == Categorie::TYPE_INVOICE && $user->hasRight('facture', 'creer')) {
265 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
266 $newobject = new Facture($db);
267 $elementtype = 'invoice';
268 } elseif ($type == Categorie::TYPE_SUPPLIER_ORDER && $user->hasRight('fournisseur', 'commande', 'creer')) {
269 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
270 $newobject = new CommandeFournisseur($db);
271 $elementtype = 'supplier_order';
272 } elseif ($type == Categorie::TYPE_SUPPLIER_INVOICE && $user->hasRight('fournisseur', 'facture', 'creer')) {
273 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
274 $newobject = new FactureFournisseur($db);
275 $elementtype = 'supplier_invoice';
276 } else {
277 dol_print_error(null, "Not supported value of type = ".$type);
278 }
279 if ($newobject !== null) {
280 $result = $newobject->fetch($elemid);
281 }
282
283 if ($result >= 0 && $newobject !== null) {
284 // Add into category
285 $result = $object->add_type($newobject, $elementtype);
286 }
287 if ($result >= 0) {
288 setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs');
289 } else {
290 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
291 setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
292 } else {
293 setEventMessages($object->error, $object->errors, 'errors');
294 }
295 }
296}
297
298
299/*
300 * View
301 */
302
303$form = new Form($db);
304$formother = new FormOther($db);
305
306$arrayofjs = array(
307 '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
308 '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'
309);
310$arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
311
312$help_url = '';
313
314llxHeader("", $langs->trans("Categories"), $help_url, '', 0, 0, $arrayofjs, $arrayofcss);
315
316$title = $langs->trans("Categories");
317$title .= ' ('.$langs->trans(empty(Categorie::$MAP_TYPE_TITLE_AREA[$type]) ? ucfirst($type) : Categorie::$MAP_TYPE_TITLE_AREA[$type]).')';
318
319$head = categories_prepare_head($object, $type);
320print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category');
321
322$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/categorie_list.php?leftmenu=cat&type='.urlencode($type));
323$linkback = '<a href="'.dol_sanitizeUrl($backtolist).'">'.$langs->trans("BackToList").'</a>';
324$object->next_prev_filter = 'type:=:'.((int) $object->type);
325$object->ref = $object->label;
326$morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/categorie_list.php?leftmenu=cat&type='.urlencode($type).'">'.$langs->trans("Root").'</a>';
327$morehtmlref .= ' > ';
328$ways = $object->print_all_ways("auto", '', 1, 0, 1);
329foreach ($ways as $way) {
330 $morehtmlref .= $way."<br>\n";
331}
332$morehtmlref .= '</div>';
333
334dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.urlencode($type), 0, '', '', 1);
335
336
337// Confirmation of deletion
338if ($action == 'delete') {
339 if ($backtopage) {
340 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.urlencode($type).'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2);
341 } else {
342 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.urlencode($type), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
343 }
344}
345
346print '<br>';
347
348print '<div class="fichecenter">';
349print '<div class="underbanner clearboth"></div>';
350print '<table class="border centpercent tableforfield">';
351
352// Description
353print '<tr><td class="titlefield notopnoleft tdtop">';
354print $langs->trans("Description").'</td><td>';
355print dol_htmlentitiesbr($object->description);
356print '</td></tr>';
357
358// Color
359print '<tr><td class="notopnoleft">';
360print $langs->trans("Color").'</td><td>';
361print $formother->showColor($object->color);
362print '</td></tr>';
363
364// Position
365print '<tr><td class="titlefield notopnoleft">';
366print $langs->trans("Position").'</td><td>';
367print $object->position ? $object->position : '';
368print '</td></tr>';
369
370// Other attributes
371include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
372
373print '</table>';
374print '</div>';
375
376print dol_get_fiche_end();
377
378
379/*
380 * Boutons actions
381 */
382
383print "<div class='tabsAction'>\n";
384$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
385if ($reshook < 0) {
386 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
387}
388if (empty($reshook)) {
389 if ($user->hasRight('categorie', 'creer')) {
390 $socid = ($object->socid ? $object->socid : "");
391 print '<a class="butAction" href="'.dolBuildUrl(DOL_URL_ROOT.'/categories/edit.php', ['id' => $object->id, 'socid' => $socid, 'type' => $type]).'">'.$langs->trans("Modify").'</a>';
392 }
393
394 if ($user->hasRight('categorie', 'supprimer')) {
395 print '<a class="butActionDelete" href="'.dolBuildUrl($_SERVER["PHP_SELF"], ['action' => 'delete', 'id' => $object->id, 'type' => $type, 'backtolist' => $backtolist], true).'">'.$langs->trans("Delete").'</a>';
396 }
397}
398
399print "</div>";
400
401$newcardbutton = '';
402if ($user->hasRight('categorie', 'creer')) {
403 $link = dolBuildUrl(DOL_URL_ROOT.'/categories/card.php', ['action'=> 'create', 'type' => $type, 'catorigin' => $object->id, 'backtopage' => dolBuildUrl($_SERVER["PHP_SELF"], ['type' => $type, 'id' => $id])]);
404
405 $newcardbutton = '<div class="right">';
406 $newcardbutton .= dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', $link);
407 $newcardbutton .= '</div>';
408}
409
410
411/*
412 * Sub-category tree view of this category
413 */
414
415print '<div class="fichecenter">';
416
417print load_fiche_titre($langs->trans("SubCats"), $newcardbutton, 'object_category');
418
419$cats = $object->get_filles();
420
421print '<table class="liste nohover noborder centpercent borderbottom">';
422
423print '<tr class="liste_titre">';
424print '<td>'.$langs->trans("SubCats").'</td>';
425print '<td></td>';
426print '<td class="right">';
427
428if (is_array($cats) && count($cats) > 1 && !empty($conf->use_javascript_ajax)) {
429 print '<div id="iddivjstreecontrol">';
430 print '<a class="notasortlink" href="#">'.img_picto('', 'folder').' '.$langs->trans("UndoExpandAll").'</a>';
431 print " | ";
432 print '<a class="notasortlink" href="#">'.img_picto('', 'folder-open').' '.$langs->trans("ExpandAll").'</a>';
433 print '</div>';
434}
435
436print '</td>';
437print '</tr>';
438
439if (is_numeric($cats) && $cats < 0) {
440 dol_print_error($db, $object->error, $object->errors);
441} elseif (count($cats) < 1) {
442 print '<tr class="oddeven nobottom nohover">';
443 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("NoSubCat").'</span></td>';
444 print '</tr>';
445} else {
446 $categstatic = new Categorie($db);
447
448 $fulltree = $categstatic->get_full_arbo($type, $object->id, 1);
449
450 // Load possible missing includes
451 if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) {
452 if ($type == Categorie::TYPE_MEMBER) {
453 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
454 }
455 if ($type == Categorie::TYPE_ACCOUNT) {
456 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
457 }
458 if ($type == Categorie::TYPE_PROJECT) {
459 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
460 }
461 if ($type == Categorie::TYPE_USER) {
462 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
463 }
464 }
465
466 // Define data (format for treeview)
467 $data = array();
468 $data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => 'racine', 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => '');
469 foreach ($fulltree as $key => $val) {
470 $categstatic->id = $val['id'];
471 $categstatic->ref = $val['label'];
472 $categstatic->color = $val['color'];
473 $categstatic->type = $type;
474 //$desc = dol_htmlcleanlastbr($val['description']);
475
476 $counter = '';
477 if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) {
478 // we need only a count of the elements, so it is enough to consume only the id's from the database
479 $elements = $categstatic->getObjectsInCateg($type, 1);
480
481 $counter = "<td class='left' width='40px;'>".(is_array($elements) ? count($elements) : '0')."</td>";
482 }
483
484 if ($categstatic->color) {
485 $stylecolor = ' style="background: #'.sprintf("%06s", $categstatic->color).';"';
486 } else {
487 $stylecolor = ' style="background: #bbb;"';
488 }
489 $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.((int) $id).'&type='.urlencode($type)), 0);
490
491 $entry = '<table class="nobordernopadding centpercent">';
492 $entry .= '<tr>';
493
494 $entry .= '<td>';
495 $entry .= '<span class="noborderoncategories" '.$stylecolor.'>'.$li.'</span>';
496 $entry .= '</td>';
497
498 $entry .= $counter;
499
500 $entry .= '<td class="right" width="20px;">';
501 $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>';
502 $entry .= '</td>';
503 $entry .= '<td class="right" width="20px;">';
504 $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>';
505 $entry .= '</td>';
506 $entry .= '<td class="right" width="20px;">';
507 $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>';
508 $entry .= '</td>';
509
510 $entry .= '</tr>';
511 $entry .= '</table>';
512
513 $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
514 }
515
516 $nbofentries = (count($data) - 1);
517 if ($nbofentries > 0) {
518 require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
519 print '<tr class="pair">';
520 print '<td colspan="3">';
521
522 // $data[0] is the current shown category, to don'T show the current category use $data[1] instead
523 tree_recur($data, $data[1], 0);
524
525 print '</td>';
526 print '</tr>';
527 } else {
528 print '<tr class="pair">';
529 print '<td colspan="3">';
530 print '<table class="nobordernopadding">';
531
532 print '<tr class="nobordernopadding">';
533 print '<td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
534 print '<td class="valignmiddle"><span class="opacitymedium">'.$langs->trans("NoCategoryYet").'</span></td>';
535 print '<td>&nbsp;</td>';
536 print '</tr>';
537
538 print '</table>';
539 print '</td>';
540 print '</tr>';
541 }
542}
543
544print "</table>";
545print "</div>";
546
547// List of mass actions available
548$arrayofmassactions = array(
549 //'validate'=>$langs->trans("Validate"),
550 //'generate_doc'=>$langs->trans("ReGeneratePDF"),
551 //'builddoc'=>$langs->trans("PDFMerge"),
552 //'presend'=>$langs->trans("SendByMail"),
553);
554$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
555
556$typeid = $type; // warning, typeid can be a string
557
558
559// List of products or services (type is type of category)
560if ($type == Categorie::TYPE_PRODUCT) {
561 if ($user->hasRight("product", "read") || $user->hasRight("service", "read")) {
562 $permission = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'));
563 $showclassifyform = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'));
564
565 $prods = $object->getObjectsInCateg($type, 0, $limit, $offset, 'ref');
566 if ($prods < 0) {
567 dol_print_error($db, $object->error, $object->errors);
568 } else {
570 '@phan-var-force Product[] $prods';
571 // Form to add record into the category
572 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
573 print '<input type="hidden" name="token" value="'.newToken().'">';
574 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
575 print '<input type="hidden" name="type" value="'.$typeid.'">';
576 print '<input type="hidden" name="id" value="'.$object->id.'">';
577 print '<input type="hidden" name="page_y" value="">';
578 print '<input type="hidden" name="action" value="list">';
579
580 print '<br>';
581 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
582 $num = count($prods);
583 $nbtotalofrecords = '';
584 $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'));
585
586 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
587 print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit);
588
589 if ($showclassifyform) {
590 print '<table class="noborder centpercent">';
591 print '<tr class="liste_titre"><td>';
592 print $langs->trans("AddProductServiceIntoCategory").' &nbsp;';
593 $form->select_produits(0, 'elemid', '', 0, 0, -1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null);
594 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
595 print '</tr>';
596 print '</table>';
597 }
598
599 print '<table class="noborder centpercent">'."\n";
600 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
601
602 if (count($prods) > 0) {
603 $i = 0;
604 foreach ($prods as $prod) {
605 $i++;
606 if ($i > $limit) {
607 break;
608 }
609
610 print '<tr class="oddeven">'."\n";
611 print '<td class="nowrap tdtop">';
612 print $prod->getNomUrl(1);
613 print "</td>\n";
614 print '<td class="tdtop">'.dolPrintHTML($prod->label)."</td>\n";
615 // Link to delete from category
616 print '<td class="right">';
617 if ($permission) {
618 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 : '').'">';
619 //print $langs->trans("DeleteFromCat");
620 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
621 print "</a>";
622 }
623 print '</td>';
624 print "</tr>\n";
625 }
626 } else {
627 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
628 }
629 print "</table>\n";
630
631 print "</form>\n";
632 }
633 } else {
634 print_barre_liste($langs->trans("ProductsAndServices"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'products');
635 accessforbidden("NotEnoughPermissions", 0, 0);
636 }
637}
638
639// List of customers
640if ($type == Categorie::TYPE_CUSTOMER) {
641 if ($user->hasRight("societe", "read")) {
642 $permission = $user->hasRight('societe', 'creer');
643 $showclassifyform = $user->hasRight('societe', 'creer');
644
645 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset, 'nom');
646 if ($socs < 0) {
647 dol_print_error($db, $object->error, $object->errors);
648 } else {
650 '@phan-var-force Societe[] $socs';
651 // Form to add record into a category
652 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
653 print '<input type="hidden" name="token" value="'.newToken().'">';
654 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
655 print '<input type="hidden" name="type" value="'.$typeid.'">';
656 print '<input type="hidden" name="id" value="'.$object->id.'">';
657 print '<input type="hidden" name="action" value="list">';
658 print '<input type="hidden" name="page_y" value="">';
659
660 print '<br>';
661 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
662 $num = count($socs);
663 $nbtotalofrecords = '';
664 $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'));
665
666 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
667 print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
668
669 if ($showclassifyform) {
670 print '<table class="noborder centpercent">';
671 print '<tr class="liste_titre"><td>';
672 print $langs->trans("AddCustomerIntoCategory").' &nbsp;';
673 $filter = '(s.client:IN:1,2,3)';
674 print $form->select_company('', 'elemid', $filter);
675 print '<input type="submit" class="reposition button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
676 print '</tr>';
677 print '</table>';
678 }
679
680 print '<table class="noborder centpercent">'."\n";
681 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name").'</td></tr>'."\n";
682
683 if (count($socs) > 0) {
684 $i = 0;
685 foreach ($socs as $key => $soc) {
686 $i++;
687 if ($i > $limit) {
688 break;
689 }
690
691 print "\t".'<tr class="oddeven">'."\n";
692 print '<td class="nowrap tdtop tdoverflowmax250">';
693 print $soc->getNomUrl(1);
694 print "</td>\n";
695 // Link to delete from category
696 print '<td class="right">';
697 if ($permission) {
698 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 : '')."'>";
699 //print $langs->trans("DeleteFromCat");
700 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
701 print "</a>";
702 }
703 print '</td>';
704 print "</tr>\n";
705 }
706 } else {
707 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
708 }
709 print "</table>\n";
710
711 print "</form>\n";
712 }
713 } else {
714 print_barre_liste($langs->trans("Customers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
715 accessforbidden("NotEnoughPermissions", 0, 0);
716 }
717}
718
719// List of suppliers
720if ($type == Categorie::TYPE_SUPPLIER) {
721 if ($user->hasRight("fournisseur", "read")) {
722 $permission = $user->hasRight('societe', 'creer');
723 $showclassifyform = $user->hasRight('societe', 'creer');
724
725 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset, 'nom');
726
727 if ($socs < 0) {
728 dol_print_error($db, $object->error, $object->errors);
729 } else {
731 '@phan-var-force Fournisseur[] $socs';
732 // Form to add record into a category
733 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
734 print '<input type="hidden" name="token" value="'.newToken().'">';
735 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
736 print '<input type="hidden" name="type" value="'.$typeid.'">';
737 print '<input type="hidden" name="id" value="'.$object->id.'">';
738 print '<input type="hidden" name="page_y" value="">';
739 print '<input type="hidden" name="action" value="list">';
740
741 print '<br>';
742 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
743 $num = count($socs);
744 $nbtotalofrecords = '';
745 $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'));
746
747 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
748 print_barre_liste($langs->trans("Suppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
749
750 if ($showclassifyform) {
751 print '<table class="noborder centpercent">';
752 print '<tr class="liste_titre"><td>';
753 print $langs->trans("AddSupplierIntoCategory").' &nbsp;';
754 $filter = '(s.fournisseur:=:1)';
755 print $form->select_company('', 'elemid', $filter);
756 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
757 print '</tr>';
758 print '</table>';
759 }
760
761 print '<table class="noborder centpercent">'."\n";
762 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name")."</td></tr>\n";
763
764 if (count($socs) > 0) {
765 $i = 0;
766 foreach ($socs as $soc) {
767 $i++;
768 if ($i > $limit) {
769 break;
770 }
771
772 print "\t".'<tr class="oddeven">'."\n";
773 print '<td class="nowrap tdtop">';
774 print $soc->getNomUrl(1);
775 print "</td>\n";
776 // Link to delete from category
777 print '<td class="right">';
778 if ($permission) {
779 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 : '').'">';
780 //print $langs->trans("DeleteFromCat");
781 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
782 print "</a>";
783 }
784 print '</td>';
785
786 print "</tr>\n";
787 }
788 } else {
789 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
790 }
791 print "</table>\n";
792
793 print "</form>\n";
794 }
795 } else {
796 print_barre_liste($langs->trans("Suppliers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
797 accessforbidden("NotEnoughPermissions", 0, 0);
798 }
799}
800
801// List of members
802if ($type == Categorie::TYPE_MEMBER) {
803 if ($user->hasRight("adherent", "read")) {
804 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
805
806 $permission = $user->hasRight('adherent', 'creer');
807 $showclassifyform = $user->hasRight('adherent', 'creer');
808
809 $members = $object->getObjectsInCateg($type, 0, $limit, $offset, 'lastname');
810 if ($members < 0) {
811 dol_print_error($db, $object->error, $object->errors);
812 } else {
814 '@phan-var-force Adherent[] $members';
815 // Form to add record into a category
816 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
817 print '<input type="hidden" name="token" value="'.newToken().'">';
818 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
819 print '<input type="hidden" name="type" value="'.$typeid.'">';
820 print '<input type="hidden" name="id" value="'.$object->id.'">';
821 print '<input type="hidden" name="page_y" value="">';
822 print '<input type="hidden" name="action" value="list">';
823
824 print '<br>';
825 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
826 $num = count($members);
827 $nbtotalofrecords = '';
828 $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'));
829
830 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
831 print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit);
832
833 if ($showclassifyform) {
834 print '<table class="noborder centpercent">';
835 print '<tr class="liste_titre"><td>';
836 print $langs->trans("AssignCategoryTo").' &nbsp;';
837 print $form->selectMembers('', 'elemid');
838 print '<input type="submit" class="button buttongen" value="'.$langs->trans("Save").'"></td>';
839 print '</tr>';
840 print '</table>';
841 }
842
843 print '<table class="noborder centpercent">'."\n";
844 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Name").'</td></tr>'."\n";
845
846 if (count($members) > 0) {
847 $i = 0;
848 foreach ($members as $key => $member) {
849 $i++;
850 if ($i > $limit) {
851 break;
852 }
853
854 print "\t".'<tr class="oddeven">'."\n";
855 print '<td class="nowrap tdtop">';
856 $member->ref = $member->login;
857 print $member->getNomUrl(1, 0);
858 print "</td>\n";
859 print '<td class="tdtop">'.$member->lastname."</td>\n";
860 print '<td class="tdtop">'.$member->firstname."</td>\n";
861 // Link to delete from category
862 print '<td class="right">';
863 if ($permission) {
864 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 : '')."'>";
865 //print $langs->trans("DeleteFromCat");
866 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
867 print "</a>";
868 }
869 print '</td>';
870 print "</tr>\n";
871 }
872 } else {
873 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
874 }
875 print "</table>\n";
876
877 print "</form>\n";
878 }
879 } else {
880 print_barre_liste($langs->trans("Member"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'members');
881 accessforbidden("NotEnoughPermissions", 0, 0);
882 }
883}
884
885// List of contacts
886if ($type == Categorie::TYPE_CONTACT) {
887 if ($user->hasRight("societe", "read")) {
888 $permission = $user->hasRight('societe', 'creer');
889 $showclassifyform = $user->hasRight('societe', 'creer');
890
891 $contacts = $object->getObjectsInCateg($type, 0, $limit, $offset, 'lastname');
892 if (is_numeric($contacts) && $contacts < 0) {
893 dol_print_error($db, $object->error, $object->errors);
894 } else {
896 '@phan-var-force Contact[] $contacts';
897 // Form to add record into a category
898 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
899 print '<input type="hidden" name="token" value="'.newToken().'">';
900 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
901 print '<input type="hidden" name="type" value="'.$typeid.'">';
902 print '<input type="hidden" name="id" value="'.$object->id.'">';
903 print '<input type="hidden" name="page_y" value="">';
904 print '<input type="hidden" name="action" value="list">';
905
906 print '<br>';
907 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
908 $num = count($contacts);
909 $nbtotalofrecords = '';
910 $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'));
911
912 $objsoc = new Societe($db);
913
914 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
915 print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contact', 0, $newcardbutton, '', $limit);
916
917 if ($showclassifyform) {
918 print '<table class="noborder centpercent">';
919 print '<tr class="liste_titre"><td>';
920 print $langs->trans("AssignCategoryTo").' &nbsp;';
921 print $form->select_contact(0, '', 'elemid', '', '', '', 0, 'maxwidth300 widthcentpercentminusx');
922 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
923 print '</tr>';
924 print '</table>';
925 }
926
927 print '<table class="noborder centpercent">'."\n";
928 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Ref").'</td></tr>'."\n";
929
930 if (is_array($contacts) && count($contacts) > 0) {
931 $i = 0;
932 foreach ($contacts as $key => $contact) {
933 $i++;
934 if ($i > $limit) {
935 break;
936 }
937
938 print "\t".'<tr class="oddeven">'."\n";
939 print '<td class="nowrap tdtop">';
940 print $contact->getNomUrl(1, 'category');
941 if ($contact->socid > 0) {
942 $objsoc->fetch($contact->socid);
943 print ' - ';
944 print $objsoc->getNomUrl(1, 'contact');
945 }
946 print "</td>\n";
947 // Link to delete from category
948 print '<td class="right">';
949 if ($permission) {
950 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 : '')."'>";
951 //print $langs->trans("DeleteFromCat");
952 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
953 print "</a>";
954 }
955 print '</td>';
956 print "</tr>\n";
957 }
958 } else {
959 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
960 }
961 print "</table>\n";
962
963 print "</form>\n";
964 }
965 } else {
966 print_barre_liste($langs->trans("Contact"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'contact');
967 accessforbidden("NotEnoughPermissions", 0, 0);
968 }
969}
970
971// List of bank accounts
972if ($type == Categorie::TYPE_ACCOUNT) {
973 if ($user->hasRight("banque", "read")) {
974 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
975
976 $permission = $user->hasRight('banque', 'creer');
977 $showclassifyform = $user->hasRight('banque', 'creer');
978
979 $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset);
980 if ($accounts < 0) {
981 dol_print_error($db, $object->error, $object->errors);
982 } else {
984 '@phan-var-force Account[] $accounts';
985 // Form to add record into a category
986 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
987 print '<input type="hidden" name="token" value="'.newToken().'">';
988 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
989 print '<input type="hidden" name="type" value="'.$typeid.'">';
990 print '<input type="hidden" name="id" value="'.$object->id.'">';
991 print '<input type="hidden" name="page_y" value="">';
992 print '<input type="hidden" name="action" value="list">';
993
994 print '<br>';
995 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
996 $num = count($accounts);
997 $nbtotalofrecords = '';
998 $newcardbutton = '';
999
1000 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1001 print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit);
1002
1003 if ($showclassifyform) {
1004 print '<table class="noborder centpercent">';
1005 print '<tr class="liste_titre"><td>';
1006 print $langs->trans("AddObjectIntoCategory").' &nbsp;';
1007 print $form->select_comptes('', 'elemid', 0, '', 0, '', 0, '', 1);
1008 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1009 print '</tr>';
1010 print '</table>';
1011 }
1012
1013 print '<table class="noborder centpercent">'."\n";
1014 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1015
1016 if (count($accounts) > 0) {
1017 $i = 0;
1018 foreach ($accounts as $key => $account) {
1019 $i++;
1020 if ($i > $limit) {
1021 break;
1022 }
1023
1024 print "\t".'<tr class="oddeven">'."\n";
1025 print '<td class="nowrap tdtop">';
1026 print $account->getNomUrl(1, '0');
1027 print "</td>\n";
1028 print '<td class="tdtop">'.$account->bank."</td>\n";
1029 print '<td class="tdtop">'.$account->number."</td>\n";
1030 // Link to delete from category
1031 print '<td class="right">';
1032 if ($permission) {
1033 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 : '')."'>";
1034 //print $langs->trans("DeleteFromCat");
1035 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1036 print "</a>";
1037 }
1038 print '</td>';
1039 print "</tr>\n";
1040 }
1041 } else {
1042 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1043 }
1044 print "</table>\n";
1045
1046 print "</form>\n";
1047 }
1048 } else {
1049 print_barre_liste($langs->trans("Banque"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'bank');
1050 accessforbidden("NotEnoughPermissions", 0, 0);
1051 }
1052}
1053
1054// List of Project
1055if ($type == Categorie::TYPE_PROJECT) {
1056 if ($user->hasRight("project", "read")) {
1057 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
1058
1059 $permission = $user->hasRight('projet', 'creer');
1060 $showclassifyform = $user->hasRight('projet', 'creer');
1061
1062 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1063 if ($objects < 0) {
1064 dol_print_error($db, $object->error, $object->errors);
1065 } else {
1067 '@phan-var-force Project[] $objects';
1068 // Form to add record into a category
1069 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1070 print '<input type="hidden" name="token" value="'.newToken().'">';
1071 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1072 print '<input type="hidden" name="type" value="'.$typeid.'">';
1073 print '<input type="hidden" name="id" value="'.$object->id.'">';
1074 print '<input type="hidden" name="page_y" value="">';
1075 print '<input type="hidden" name="action" value="list">';
1076
1077 print '<br>';
1078 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1079 $num = count($objects);
1080 $nbtotalofrecords = '';
1081 $newcardbutton = '';
1082
1083 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1084 print_barre_liste($langs->trans("Project"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit);
1085
1086 if ($showclassifyform) {
1087 print '<table class="noborder centpercent">';
1088 print '<tr class="liste_titre"><td>';
1089 print $langs->trans("AddObjectIntoCategory").' &nbsp;';
1090 $form->selectProjects('', 'elemid');
1091 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1092 print '</tr>';
1093 print '</table>';
1094 }
1095
1096 print '<table class="noborder centpercent">'."\n";
1097 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1098
1099 if (count($objects) > 0) {
1100 $i = 0;
1101 foreach ($objects as $key => $project) {
1102 $i++;
1103 if ($i > $limit) {
1104 break;
1105 }
1106
1107 print "\t".'<tr class="oddeven">'."\n";
1108 print '<td class="nowrap tdtop">';
1109 print $project->getNomUrl(1);
1110 print "</td>\n";
1111 print '<td class="tdtop">'.$project->title."</td>\n";
1112 // Link to delete from category
1113 print '<td class="right">';
1114 if ($permission) {
1115 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 : '')."'>";
1116 //print $langs->trans("DeleteFromCat");
1117 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1118 print "</a>";
1119 }
1120 print '</td>';
1121 print "</tr>\n";
1122 }
1123 } else {
1124 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1125 }
1126 print "</table>\n";
1127
1128 print "</form>\n";
1129 }
1130 } else {
1131 print_barre_liste($langs->trans("Project"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'project');
1132 accessforbidden("NotEnoughPermissions", 0, 0);
1133 }
1134}
1135
1136// List of users
1137if ($type == Categorie::TYPE_USER) {
1138 if ($user->hasRight("user", "user", "read")) {
1139 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
1140 $showclassifyform = $user->hasRight("user", "user", "creer");
1141
1142 $users = $object->getObjectsInCateg($type, 0, 0, 0, 'lastname');
1143 if ($users < 0) {
1144 dol_print_error($db, $object->error, $object->errors);
1145 } else {
1147 '@phan-var-force User[] $users';
1148
1149 // Form to add record into a category
1150 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1151 print '<input type="hidden" name="token" value="'.newToken().'">';
1152 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1153 print '<input type="hidden" name="type" value="'.$typeid.'">';
1154 print '<input type="hidden" name="id" value="'.$object->id.'">';
1155 print '<input type="hidden" name="page_y" value="">';
1156 print '<input type="hidden" name="action" value="list">';
1157
1158 print '<br>';
1159
1160 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1161 $num = count($users);
1162 $nbtotalofrecords = '';
1163 $newcardbutton = '';
1164
1165 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1166 print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, '', '', $limit);
1167
1168 if ($showclassifyform) {
1169 print '<table class="noborder centpercent">';
1170 print '<tr class="liste_titre"><td>';
1171 $force_entity = getEntity($object->element); // So we will get same filter than the getObjectsInCateg()
1172 print img_picto('', $type, 'class="pictofixedwidth"');
1173 print $form->select_dolusers('', 'elemid', 1, null, 0, '', '', $force_entity);
1174 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1175 print '</tr>';
1176 print '</table>';
1177 }
1178
1179 print '<table class="noborder centpercent">'."\n";
1180 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Users").' <span class="badge">'.$num.'</span></td></tr>'."\n";
1181
1182 if (count($users) > 0) {
1183 // Use "$userentry" here, because "$user" is the current user
1184 foreach ($users as $key => $userentry) {
1185 print "\t".'<tr class="oddeven">'."\n";
1186 print '<td class="nowrap tdtop">';
1187 print $userentry->getNomUrl(-1);
1188 print "</td>\n";
1189 print '<td class="tdtop">'.$userentry->job."</td>\n";
1190
1191 // Link to delete from category
1192 print '<td class="right">';
1193 if ($user->hasRight('user', 'user', 'creer')) {
1194 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 : '')."'>";
1195 //print $langs->trans("DeleteFromCat");
1196 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1197 print "</a>";
1198 }
1199 print '</td>';
1200 print "</tr>\n";
1201 }
1202 } else {
1203 print '<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1204 }
1205 print "</table>\n";
1206
1207 print "</form>\n";
1208 }
1209 } else {
1210 print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'user');
1211 accessforbidden("NotEnoughPermissions", 0, 0);
1212 }
1213}
1214
1215// List of warehouses
1216if ($type == Categorie::TYPE_WAREHOUSE) {
1217 if ($user->hasRight("stock", "read")) {
1218 $permission = $user->hasRight('stock', 'creer');
1219 $showclassifyform = $user->hasRight('stock', 'creer');
1220
1221 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
1222
1223 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1224 if ($objects < 0) {
1225 dol_print_error($db, $object->error, $object->errors);
1226 } else {
1228 '@phan-var-force Entrepot[] $objects';
1229 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1230 print '<input type="hidden" name="token" value="'.newToken().'">';
1231 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1232 print '<input type="hidden" name="type" value="'.$typeid.'">';
1233 print '<input type="hidden" name="id" value="'.$object->id.'">';
1234 print '<input type="hidden" name="page_y" value="">';
1235 print '<input type="hidden" name="action" value="list">';
1236
1237 print '<br>';
1238 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1239 $num = count($objects);
1240 $nbtotalofrecords = '';
1241 $newcardbutton = '';
1242
1243 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1244 print_barre_liste($langs->trans("Warehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit);
1245
1246 if ($showclassifyform) {
1247 print '<table class="noborder centpercent">';
1248 print '<tr class="liste_titre"><td>';
1249 print $langs->trans("AddTicketIntoCategory").' &nbsp;';
1250 print $form->selectForForms('Entrepot:product/stock/class/entrepot.class.php', 'elemid', 0, 1, '', '', 'maxwidth500');
1251 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1252 print '</tr>';
1253 print '</table>';
1254 }
1255
1256 print '<table class="noborder centpercent">'."\n";
1257 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1258
1259 if (count($objects) > 0) {
1260 $i = 0;
1261 foreach ($objects as $key => $warehouse) {
1262 $i++;
1263 if ($i > $limit) {
1264 break;
1265 }
1266
1267 print "\t".'<tr class="oddeven">'."\n";
1268 print '<td class="nowrap tdtop">';
1269 print $warehouse->getNomUrl(1);
1270 print "</td>\n";
1271 print '<td class="tdtop">'.$warehouse->ref."</td>\n";
1272 print '<td class="tdtop">'.$warehouse->lieu."</td>\n";
1273 // Link to delete from category
1274 print '<td class="right">';
1275 if ($permission) {
1276 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 : '')."'>";
1277 //print $langs->trans("DeleteFromCat");
1278 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1279 print "</a>";
1280 }
1281 print '</td>';
1282 print "</tr>\n";
1283 }
1284 } else {
1285 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1286 }
1287 print "</table>\n";
1288
1289 print "</form>\n";
1290 }
1291 } else {
1292 print_barre_liste($langs->trans("Warehouse"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'stock');
1293 accessforbidden("NotEnoughPermissions", 0, 0);
1294 }
1295}
1296
1297// List of tickets
1298if ($type == Categorie::TYPE_TICKET) {
1299 if ($user->hasRight("ticket", "read")) {
1300 $permission = $user->hasRight('categorie', 'creer');
1301 $showclassifyform = $user->hasRight('categorie', 'creer');
1302
1303 $tickets = $object->getObjectsInCateg($type, 0, $limit, $offset);
1304 if ($tickets < 0) {
1305 dol_print_error($db, $object->error, $object->errors);
1306 } else {
1308 '@phan-var-force Ticket[] $tickets';
1309 // Form to add record into a category
1310 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1311 print '<input type="hidden" name="token" value="'.newToken().'">';
1312 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1313 print '<input type="hidden" name="type" value="'.$typeid.'">';
1314 print '<input type="hidden" name="id" value="'.$object->id.'">';
1315 print '<input type="hidden" name="page_y" value="">';
1316 print '<input type="hidden" name="action" value="list">';
1317
1318 print '<br>';
1319 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1320 $num = count($tickets);
1321 $nbtotalofrecords = '';
1322 $newcardbutton = '';
1323
1324 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1325 print_barre_liste($langs->trans("Ticket"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'ticket', 0, $newcardbutton, '', $limit);
1326
1327 if ($showclassifyform) {
1328 print '<table class="noborder centpercent">';
1329 print '<tr class="liste_titre"><td>';
1330 print $langs->trans("AddTicketIntoCategory").' &nbsp;';
1331 $form->selectTickets('', 'elemid');
1332 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1333 print '</tr>';
1334 print '</table>';
1335 }
1336
1337 print '<table class="noborder centpercent">'."\n";
1338 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
1339
1340 if (count($tickets) > 0) {
1341 $i = 0;
1342 foreach ($tickets as $ticket) {
1343 $i++;
1344 if ($i > $limit) {
1345 break;
1346 }
1347
1348 print "\t".'<tr class="oddeven">'."\n";
1349 print '<td class="nowrap tdtop">';
1350 print $ticket->getNomUrl(1);
1351 print "</td>\n";
1352 print '<td class="tdtop">'.$ticket->track_id."</td>\n";
1353 // Link to delete from category
1354 print '<td class="right">';
1355 if ($permission) {
1356 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 : '')."'>";
1357 //print $langs->trans("DeleteFromCat");
1358 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1359 print "</a>";
1360 }
1361 print '</td>';
1362 print "</tr>\n";
1363 }
1364 } else {
1365 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1366 }
1367 print "</table>\n";
1368
1369 print "</form>\n";
1370 }
1371 } else {
1372 print_barre_liste($langs->trans("Ticket"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'ticket');
1373 accessforbidden("NotEnoughPermissions", 0, 0);
1374 }
1375}
1376
1377// List of Interventions
1378if ($type == Categorie::TYPE_FICHINTER) {
1379 if ($user->hasRight("fichinter", "lire")) {
1380 $permission = $user->hasRight('categorie', 'creer');
1381 $showclassifyform = $user->hasRight('categorie', 'creer');
1382
1383 $fichinters = $object->getObjectsInCateg($type, 0, $limit, $offset);
1384 if ($fichinters < 0) {
1385 dol_print_error($db, $object->error, $object->errors);
1386 } else {
1388 '@phan-var-force Fichinter[] $fichinters';
1389
1390 // Form to add record into a category
1391 if ($showclassifyform) {
1392 print '<br>';
1393 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1394 print '<input type="hidden" name="token" value="'.newToken().'">';
1395 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1396 print '<input type="hidden" name="type" value="'.$typeid.'">';
1397 print '<input type="hidden" name="id" value="'.$object->id.'">';
1398 print '<input type="hidden" name="action" value="addintocategory">';
1399 print '<table class="noborder centpercent">';
1400 print '<tr class="liste_titre"><td>';
1401 print $langs->trans("AddFichinterIntoCategory").' &nbsp;';
1402 print $form->selectForForms('Fichinter:fichinter/class/fichinter.class.php', 'elemid', 0, 1, '', '', 'maxwidth500');
1403 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1404 print '</tr>';
1405 print '</table>';
1406 print '</form>';
1407 }
1408
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="list">';
1415
1416 print '<br>';
1417 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1418 $num = count($fichinters);
1419 $nbtotalofrecords = '';
1420 $newcardbutton = '';
1421
1422 $langs->load('interventions');
1423 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1424 print_barre_liste($langs->trans("Intervention"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_intervention', 0, $newcardbutton, '', $limit);
1425 print '<table class="noborder centpercent">'."\n";
1426 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
1427
1428 if (count($fichinters) > 0) {
1429 $i = 0;
1430 foreach ($fichinters as $fichinter) {
1431 $i++;
1432 if ($i > $limit) {
1433 break;
1434 }
1435
1436 print "\t".'<tr class="oddeven">'."\n";
1437 print '<td class="nowrap tdtop">';
1438 print $fichinter->getNomUrl(1);
1439 print "</td>\n";
1440 print '<td class="tdtop">'.$fichinter->description."</td>\n";
1441 // Link to delete from category
1442 print '<td class="right">';
1443 if ($permission) {
1444 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 : '')."'>";
1445 print $langs->trans("DeleteFromCat");
1446 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1447 print "</a>";
1448 }
1449 print '</td>';
1450 print "</tr>\n";
1451 }
1452 } else {
1453 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1454 }
1455 print "</table>\n";
1456 print "</form>\n";
1457 }
1458 } else {
1459 print_barre_liste($langs->trans("Intervention"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'fichinter');
1460 accessforbidden("NotEnoughPermissions", 0, 0);
1461 }
1462}
1463
1464// List of Orders
1465if ($type == Categorie::TYPE_ORDER) {
1466 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
1467
1468 $permission = $user->hasRight('commande', 'creer');
1469
1470 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1471 if ($objects < 0) {
1472 dol_print_error($db, $object->error, $object->errors);
1473 } else {
1475 '@phan-var-force Commande[] $objects';
1476 // Form to add record into a category
1477 $showclassifyform = $user->hasRight('order', 'write');
1478 if ($showclassifyform) {
1479 print '<br>';
1480 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1481 print '<input type="hidden" name="token" value="'.newToken().'">';
1482 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1483 print '<input type="hidden" name="type" value="'.$typeid.'">';
1484 print '<input type="hidden" name="id" value="'.$object->id.'">';
1485 print '<input type="hidden" name="action" value="addintocategory">';
1486 print '<table class="noborder centpercent">';
1487 print '<tr class="liste_titre"><td>';
1488 print $langs->trans("AddOrderIntoCategory").' &nbsp;';
1489 print $form->selectForForms('Commande:commande/class/commande.class.php', 'elemid', 0, 1, '', '', 'maxwidth500');
1490 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1491 print '</tr>';
1492 print '</table>';
1493 print '</form>';
1494 }
1495
1496 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1497 print '<input type="hidden" name="token" value="'.newToken().'">';
1498 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1499 print '<input type="hidden" name="type" value="'.$typeid.'">';
1500 print '<input type="hidden" name="id" value="'.$object->id.'">';
1501 print '<input type="hidden" name="action" value="list">';
1502
1503 print '<br>';
1504 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1505 $num = count($objects);
1506 $nbtotalofrecords = '';
1507 $newcardbutton = '';
1508
1509 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1510 print_barre_liste($langs->trans("Orders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit);
1511
1512 print "<table class='noborder centpercent'>\n";
1513 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1514
1515 if (count($objects) > 0) {
1516 $i = 0;
1517 foreach ($objects as $key => $order) {
1518 $i++;
1519 if ($i > $limit) {
1520 break;
1521 }
1522
1523 print "\t".'<tr class="oddeven">'."\n";
1524 print '<td class="nowrap tdtop">';
1525 print $order->getNomUrl(1);
1526 print "</td>\n";
1527 print '<td class="tdtop">'.$order->ref."</td>\n";
1528 // Link to delete from category
1529 print '<td class="right">';
1530 if ($permission) {
1531 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$order->id."'>";
1532 print $langs->trans("DeleteFromCat");
1533 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1534 print "</a>";
1535 }
1536 print "</tr>\n";
1537 }
1538 } else {
1539 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1540 }
1541 print "</table>\n";
1542
1543 print "</form>\n";
1544 }
1545}
1546
1547// List of Invoices
1548if ($type == Categorie::TYPE_INVOICE) {
1549 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1550
1551 $permission = $user->hasRight('facture', 'creer');
1552
1553 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1554 if ($objects < 0) {
1555 dol_print_error($db, $object->error, $object->errors);
1556 } else {
1557 // Form to add record into a category
1558 $showclassifyform = $user->hasRight('facture', 'write');
1559 if ($showclassifyform) {
1560 print '<br>';
1561 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1562 print '<input type="hidden" name="token" value="'.newToken().'">';
1563 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1564 print '<input type="hidden" name="type" value="'.$typeid.'">';
1565 print '<input type="hidden" name="id" value="'.$object->id.'">';
1566 print '<input type="hidden" name="action" value="addintocategory">';
1567 print '<table class="noborder centpercent">';
1568 print '<tr class="liste_titre"><td>';
1569 print $langs->trans("AddInvoiceIntoCategory").' &nbsp;';
1570 print $form->selectForForms('Facture:compta/facture/class/facture.class.php', 'elemid', 0, 1, '', '', 'maxwidth500');
1571 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1572 print '</tr>';
1573 print '</table>';
1574 print '</form>';
1575 }
1576
1577 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1578 print '<input type="hidden" name="token" value="'.newToken().'">';
1579 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1580 print '<input type="hidden" name="type" value="'.$typeid.'">';
1581 print '<input type="hidden" name="id" value="'.$object->id.'">';
1582 print '<input type="hidden" name="action" value="list">';
1583
1584 print '<br>';
1585 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1586 $num = count($objects);
1587 $nbtotalofrecords = '';
1588 $newcardbutton = '';
1589
1590 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1591 print_barre_liste($langs->trans("BillsCustomers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit);
1592
1593 print "<table class='noborder centpercent'>\n";
1594 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1595
1596 if (count($objects) > 0) {
1597 $i = 0;
1598 foreach ($objects as $key => $invoice) {
1599 $i++;
1600 if ($i > $limit) {
1601 break;
1602 }
1603
1604 print "\t".'<tr class="oddeven">'."\n";
1605 print '<td class="nowrap tdtop">';
1606 print $invoice->getNomUrl(1);
1607 print "</td>\n";
1608 print '<td class="tdtop">'.$invoice->ref."</td>\n";
1609 // Link to delete from category
1610 print '<td class="right">';
1611 if ($permission) {
1612 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$invoice->id."'>";
1613 print $langs->trans("DeleteFromCat");
1614 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1615 print "</a>";
1616 }
1617 print "</tr>\n";
1618 }
1619 } else {
1620 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1621 }
1622 print "</table>\n";
1623
1624 print "</form>\n";
1625 }
1626}
1627
1628// List of Supplier Orders
1629if ($type == Categorie::TYPE_SUPPLIER_ORDER) {
1630 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
1631
1632 $permission = $user->hasRight('fournisseur', 'commande', 'creer');
1633
1634 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1635 if ($objects < 0) {
1636 dol_print_error($db, $object->error, $object->errors);
1637 } else {
1638 // Form to add record into a category
1639 $showclassifyform = $user->hasRight('fournisseur', 'commande', 'creer');
1640 ;
1641 if ($showclassifyform) {
1642 print '<br>';
1643 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1644 print '<input type="hidden" name="token" value="'.newToken().'">';
1645 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1646 print '<input type="hidden" name="type" value="'.$typeid.'">';
1647 print '<input type="hidden" name="id" value="'.$object->id.'">';
1648 print '<input type="hidden" name="action" value="addintocategory">';
1649 print '<table class="noborder centpercent">';
1650 print '<tr class="liste_titre"><td>';
1651 print $langs->trans("AddSupplierOrderIntoCategory").' &nbsp;';
1652 print $form->selectForForms('CommandeFournisseur:fourn/class/fournisseur.commande.class.php', 'elemid', 0, 1, '', '', 'maxwidth500');
1653 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1654 print '</tr>';
1655 print '</table>';
1656 print '</form>';
1657 }
1658
1659 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1660 print '<input type="hidden" name="token" value="'.newToken().'">';
1661 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1662 print '<input type="hidden" name="type" value="'.$typeid.'">';
1663 print '<input type="hidden" name="id" value="'.$object->id.'">';
1664 print '<input type="hidden" name="action" value="list">';
1665
1666 print '<br>';
1667 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1668 $num = count($objects);
1669 $nbtotalofrecords = '';
1670 $newcardbutton = '';
1671
1672 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1673 print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit);
1674
1675 print "<table class='noborder centpercent'>\n";
1676 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1677
1678 if (count($objects) > 0) {
1679 $i = 0;
1680 foreach ($objects as $key => $supplier_order) {
1681 $i++;
1682 if ($i > $limit) {
1683 break;
1684 }
1685
1686 print "\t".'<tr class="oddeven">'."\n";
1687 print '<td class="nowrap tdtop">';
1688 print $supplier_order->getNomUrl(1);
1689 print "</td>\n";
1690 print '<td class="tdtop">'.$supplier_order->ref."</td>\n";
1691 // Link to delete from category
1692 print '<td class="right">';
1693 if ($permission) {
1694 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$supplier_order->id."'>";
1695 print $langs->trans("DeleteFromCat");
1696 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1697 print "</a>";
1698 }
1699 print "</tr>\n";
1700 }
1701 } else {
1702 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1703 }
1704 print "</table>\n";
1705
1706 print "</form>\n";
1707 }
1708}
1709
1710// List of Supplier Invoices
1711if ($type == Categorie::TYPE_SUPPLIER_INVOICE) {
1712 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1713
1714 $permission = $user->hasRight('fournisseur', 'facture', 'creer');
1715
1716 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1717 if ($objects < 0) {
1718 dol_print_error($db, $object->error, $object->errors);
1719 } else {
1720 // Form to add record into a category
1721 $showclassifyform = $user->hasRight('fournisseur', 'facture', 'creer');;
1722 if ($showclassifyform) {
1723 print '<br>';
1724 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1725 print '<input type="hidden" name="token" value="'.newToken().'">';
1726 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1727 print '<input type="hidden" name="type" value="'.$typeid.'">';
1728 print '<input type="hidden" name="id" value="'.$object->id.'">';
1729 print '<input type="hidden" name="action" value="addintocategory">';
1730 print '<table class="noborder centpercent">';
1731 print '<tr class="liste_titre"><td>';
1732 print $langs->trans("AddSupplierInvoiceIntoCategory").' &nbsp;';
1733 print $form->selectForForms('FactureFournisseur:fourn/class/fournisseur.facture.class.php', 'elemid', 0, 1, '', '', 'maxwidth500');
1734 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1735 print '</tr>';
1736 print '</table>';
1737 print '</form>';
1738 }
1739
1740 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1741 print '<input type="hidden" name="token" value="'.newToken().'">';
1742 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1743 print '<input type="hidden" name="type" value="'.$typeid.'">';
1744 print '<input type="hidden" name="id" value="'.$object->id.'">';
1745 print '<input type="hidden" name="action" value="list">';
1746
1747 print '<br>';
1748 $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = '';
1749
1750 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1751 print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit);
1752
1753 print "<table class='noborder centpercent'>\n";
1754 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1755
1756 if (count($objects) > 0) {
1757 $i = 0;
1758 foreach ($objects as $key => $supplier_invoice) {
1759 $i++;
1760 if ($i > $limit) {
1761 break;
1762 }
1763
1764 print "\t".'<tr class="oddeven">'."\n";
1765 print '<td class="nowrap tdtop">';
1766 print $supplier_invoice->getNomUrl(1);
1767 print "</td>\n";
1768 print '<td class="tdtop">'.$supplier_invoice->ref."</td>\n";
1769 // Link to delete from category
1770 print '<td class="right">';
1771 if ($permission) {
1772 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$supplier_invoice->id."'>";
1773 print $langs->trans("DeleteFromCat");
1774 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1775 print "</a>";
1776 }
1777 print "</tr>\n";
1778 }
1779 } else {
1780 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1781 }
1782 print "</table>\n";
1783
1784 print "</form>\n";
1785 }
1786}
1787
1788// Note that $action and $object may have been modified by some hooks
1789$parameters = array('type' => $type, 'id' => $id, 'label' => $label);
1790$reshook = $hookmanager->executeHooks('addMoreCategoriesList', $parameters, $object, $action);
1791
1792// End of page
1793llxFooter();
1794$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 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.
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.