dolibarr 22.0.5
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 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';
37require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
41
50// Load translation files required by the page
51$langs->loadLangs(array("categories", "compta"));
52
53$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
54$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
55$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
56$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
57$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
58$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
59$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'categorylist'; // To manage different context of search
60$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
61$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
62
63$id = GETPOSTINT('id');
64$label = GETPOST('label', 'alpha');
65$removeelem = GETPOSTINT('removeelem');
66$elemid = GETPOSTINT('elemid');
67
68if (GETPOST('addintocategory')) {
69 $action = 'addintocategory';
70}
71
72
73// Load variable for pagination
74$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
75$sortfield = GETPOST('sortfield', 'aZ09comma');
76$sortorder = GETPOST('sortorder', 'aZ09comma');
77$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
78if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
79 $page = 0;
80} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
81$offset = $limit * $page;
82$pageprev = $page - 1;
83$pagenext = $page + 1;
84
85if ($id == "" && $label == "") {
86 dol_print_error(null, 'Missing parameter id');
87 exit();
88}
89
90// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array
91$hookmanager->initHooks(array('categorycard', 'globalcard'));
92
93$object = new Categorie($db);
94$result = $object->fetch($id, $label);
95if ($result <= 0) {
96 dol_print_error($db, $object->error);
97 exit;
98}
99
100// Security check
101$result = restrictedArea($user, 'categorie', $object->id, '&category');
102
103$type = $object->type;
104if (is_numeric($type)) {
105 $type = array_search($type, $object->MAP_ID); // For backward compatibility
106}
107
108$extrafields = new ExtraFields($db);
109$extrafields->fetch_name_optionals_label($object->table_element);
110
111/*
112 * Actions
113 */
114
115if ($confirm == 'no') {
116 if ($backtopage) {
117 header("Location: ".$backtopage);
118 exit;
119 }
120}
121$parameters = array('type' => $type, 'id' => $id, 'label' => $label);
122$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
123// Remove element from category
124if ($id > 0 && $removeelem > 0 && $action == 'unlink') { // Test on permission not required here. Done later according to type of object.
125 $tmpobject = null;
126 $elementtype = '';
127 if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
128 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
129 $tmpobject = new Product($db);
130 $result = $tmpobject->fetch($removeelem);
131 $elementtype = 'product';
132 } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) {
133 $tmpobject = new Societe($db);
134 $result = $tmpobject->fetch($removeelem);
135 $elementtype = 'supplier';
136 } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) {
137 $tmpobject = new Societe($db);
138 $result = $tmpobject->fetch($removeelem);
139 $elementtype = 'customer';
140 } elseif ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) {
141 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
142 $tmpobject = new Adherent($db);
143 $result = $tmpobject->fetch($removeelem);
144 $elementtype = 'member';
145 } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) {
146 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
147 $tmpobject = new Contact($db);
148 $result = $tmpobject->fetch($removeelem);
149 $elementtype = 'contact';
150 } elseif ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) {
151 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
152 $tmpobject = new Account($db);
153 $result = $tmpobject->fetch($removeelem);
154 $elementtype = 'account';
155 } elseif ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) {
156 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
157 $tmpobject = new Project($db);
158 $result = $tmpobject->fetch($removeelem);
159 $elementtype = 'project';
160 } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) {
161 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
162 $tmpobject = new User($db);
163 $result = $tmpobject->fetch($removeelem);
164 $elementtype = 'user';
165 } elseif ($type == Categorie::TYPE_WAREHOUSE && $user->hasRight('stock', 'creer')) {
166 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
167 $tmpobject = new Entrepot($db);
168 $result = $tmpobject->fetch($removeelem);
169 $elementtype = 'warehouse';
170 } elseif ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) {
171 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
172 $tmpobject = new Ticket($db);
173 $result = $tmpobject->fetch($removeelem);
174 $elementtype = 'ticket';
175 } elseif ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) {
176 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
177 $tmpobject = new Fichinter($db);
178 $result = $tmpobject->fetch($removeelem);
179 $elementtype = 'fichinter';
180 } elseif ($type == Categorie::TYPE_ORDER && $user->hasRight('commande', 'creer')) {
181 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
182 $tmpobject = new Commande($db);
183 $result = $tmpobject->fetch($removeelem);
184 $elementtype = 'order';
185 } elseif ($type == Categorie::TYPE_INVOICE && $user->hasRight('facture', 'creer')) {
186 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
187 $tmpobject = new Facture($db);
188 $result = $tmpobject->fetch($removeelem);
189 $elementtype = 'invoice';
190 } elseif ($type == Categorie::TYPE_SUPPLIER_ORDER && $user->hasRight('fournisseur', 'commande', 'creer')) {
191 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
192 $tmpobject = new CommandeFournisseur($db);
193 $result = $tmpobject->fetch($removeelem);
194 $elementtype = 'supplier_order';
195 } elseif ($type == Categorie::TYPE_SUPPLIER_INVOICE && $user->hasRight('fournisseur', 'facture', 'creer')) {
196 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
197 $tmpobject = new FactureFournisseur($db);
198 $result = $tmpobject->fetch($removeelem);
199 $elementtype = 'supplier_invoice';
200 } else {
201 dol_print_error(null, "Not supported value of type = ".$type);
202 $result = -100;
203 }
204
205 if ($tmpobject !== null) {
206 // also enter here when item was not found to report error
207 $result = $object->del_type($tmpobject, $elementtype);
208 if ($result < 0) {
209 dol_print_error(null, $object->error);
210 }
211 }
212}
213
214if ($user->hasRight('categorie', 'supprimer') && $action == 'confirm_delete' && $confirm == 'yes') {
215 if ($object->delete($user) >= 0) {
216 if ($backtopage) {
217 header("Location: ".$backtopage);
218 exit;
219 } else {
220 header("Location: ".DOL_URL_ROOT.'/categories/categorie_list.php?type='.$type);
221 exit;
222 }
223 } else {
224 setEventMessages($object->error, $object->errors, 'errors');
225 }
226}
227
228if ($elemid && $action == 'addintocategory') { // Test on permission not required here. Done just after depending on object type
229 $newobject = null;
230 $elementtype = '';
231 if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
232 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
233 $newobject = new Product($db);
234 $elementtype = 'product';
235 } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) {
236 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
237 $newobject = new Societe($db);
238 $elementtype = 'customer';
239 } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) {
240 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
241 $newobject = new Societe($db);
242 $elementtype = 'supplier';
243 } elseif ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) {
244 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
245 $newobject = new Ticket($db);
246 $elementtype = 'ticket';
247 } elseif ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) {
248 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
249 $newobject = new Fichinter($db);
250 $elementtype = 'fichinter';
251 } elseif ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) {
252 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
253 $newobject = new Project($db);
254 $elementtype = 'project';
255 } elseif ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) {
256 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
257 $newobject = new Adherent($db);
258 $elementtype = 'member';
259 } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) {
260 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
261 $newobject = new Contact($db);
262 $elementtype = 'contact';
263 } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) {
264 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
265 $newobject = new User($db);
266 $elementtype = 'user';
267 } elseif ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) {
268 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
269 $newobject = new Account($db);
270 $elementtype = 'bank_account';
271 } elseif ($type == Categorie::TYPE_ORDER && $user->hasRight('commande', 'creer')) {
272 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
273 $newobject = new Commande($db);
274 $elementtype = 'order';
275 } elseif ($type == Categorie::TYPE_INVOICE && $user->hasRight('facture', 'creer')) {
276 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
277 $newobject = new Facture($db);
278 $elementtype = 'invoice';
279 } elseif ($type == Categorie::TYPE_SUPPLIER_ORDER && $user->hasRight('fournisseur', 'commande', 'creer')) {
280 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
281 $newobject = new CommandeFournisseur($db);
282 $elementtype = 'supplier_order';
283 } elseif ($type == Categorie::TYPE_SUPPLIER_INVOICE && $user->hasRight('fournisseur', 'facture', 'creer')) {
284 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
285 $newobject = new FactureFournisseur($db);
286 $elementtype = 'supplier_invoice';
287 } else {
288 // No permission to modify the objects of this type: refuse instead of reporting a success
289 $result = -1;
290 $object->error = $langs->trans("NotEnoughPermissions");
291 }
292 if ($newobject !== null) {
293 $result = $newobject->fetch($elemid);
294 }
295
296 if ($result >= 0 && $newobject !== null) {
297 // Add into category
298 $result = $object->add_type($newobject, $elementtype);
299 }
300 if ($result >= 0) {
301 setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs');
302 } else {
303 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
304 setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
305 } else {
306 setEventMessages($object->error, $object->errors, 'errors');
307 }
308 }
309}
310
311
312/*
313 * View
314 */
315
316$form = new Form($db);
317$formother = new FormOther($db);
318
319$arrayofjs = array(
320 '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
321 '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'
322);
323$arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
324
325$help_url = '';
326
327llxHeader("", $langs->trans("Categories"), $help_url, '', 0, 0, $arrayofjs, $arrayofcss);
328
329$title = $langs->trans("Categories");
330$title .= ' ('.$langs->trans(empty(Categorie::$MAP_TYPE_TITLE_AREA[$type]) ? ucfirst($type) : Categorie::$MAP_TYPE_TITLE_AREA[$type]).')';
331
332$head = categories_prepare_head($object, $type);
333print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category');
334
335$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/categorie_list.php?leftmenu=cat&type='.urlencode($type));
336$linkback = '<a href="'.dol_sanitizeUrl($backtolist).'">'.$langs->trans("BackToList").'</a>';
337$object->next_prev_filter = 'type:=:'.((int) $object->type);
338$object->ref = $object->label;
339$morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/categorie_list.php?leftmenu=cat&type='.urlencode($type).'">'.$langs->trans("Root").'</a> >> ';
340$ways = $object->print_all_ways(" &gt;&gt; ", '', 1);
341foreach ($ways as $way) {
342 $morehtmlref .= $way."<br>\n";
343}
344$morehtmlref .= '</div>';
345
346dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.urlencode($type), 0, '', '', 1);
347
348
349// Confirmation of deletion
350if ($action == 'delete') {
351 if ($backtopage) {
352 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.urlencode($type).'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2);
353 } else {
354 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.urlencode($type), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
355 }
356}
357
358print '<br>';
359
360print '<div class="fichecenter">';
361print '<div class="underbanner clearboth"></div>';
362print '<table class="border centpercent tableforfield">';
363
364// Description
365print '<tr><td class="titlefield notopnoleft tdtop">';
366print $langs->trans("Description").'</td><td>';
367print dol_htmlentitiesbr($object->description);
368print '</td></tr>';
369
370// Color
371print '<tr><td class="notopnoleft">';
372print $langs->trans("Color").'</td><td>';
373print $formother->showColor($object->color);
374print '</td></tr>';
375
376// Position
377print '<tr><td class="titlefield notopnoleft">';
378print $langs->trans("Position").'</td><td>';
379print $object->position ? $object->position : '';
380print '</td></tr>';
381
382// Other attributes
383include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
384
385print '</table>';
386print '</div>';
387
388print dol_get_fiche_end();
389
390
391/*
392 * Boutons actions
393 */
394
395print "<div class='tabsAction'>\n";
396$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
397if ($reshook < 0) {
398 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
399}
400if (empty($reshook)) {
401 if ($user->hasRight('categorie', 'creer')) {
402 $socid = ($object->socid ? "&socid=".$object->socid : "");
403 print '<a class="butAction" href="edit.php?id='.$object->id.$socid.'&type='.urlencode($type).'">'.$langs->trans("Modify").'</a>';
404 }
405
406 if ($user->hasRight('categorie', 'supprimer')) {
407 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'&type='.urlencode($type).'&backtolist='.urlencode($backtolist).'">'.$langs->trans("Delete").'</a>';
408 }
409}
410
411print "</div>";
412
413$newcardbutton = '';
414if ($user->hasRight('categorie', 'creer')) {
415 $link = DOL_URL_ROOT.'/categories/card.php';
416 $link .= '?action=create';
417 $link .= '&type='.urlencode($type);
418 $link .= '&catorigin='.((int) $object->id);
419 $link .= '&backtopage='.urlencode($_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="'.$_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="'.$_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="'.$_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="'.$_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="'.$_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="'.$_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 $object';
1084 // Form to add record into a category
1085 print '<form method="post" action="'.$_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 // Form to add record into a category
1165 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1166 print '<input type="hidden" name="token" value="'.newToken().'">';
1167 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1168 print '<input type="hidden" name="type" value="'.$typeid.'">';
1169 print '<input type="hidden" name="id" value="'.$object->id.'">';
1170 print '<input type="hidden" name="page_y" value="">';
1171 print '<input type="hidden" name="action" value="list">';
1172
1173 print '<br>';
1174
1175 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1176 $num = count($users);
1177 $nbtotalofrecords = '';
1178 $newcardbutton = '';
1179
1180 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1181 print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, '', '', $limit);
1182
1183 if ($showclassifyform) {
1184 print '<table class="noborder centpercent">';
1185 print '<tr class="liste_titre"><td>';
1186 $force_entity = getEntity($object->element); // So we will get same filter than the getObjectsInCateg()
1187 print img_picto('', $type, 'class="pictofixedwidth"');
1188 print $form->select_dolusers('', 'elemid', 1, null, 0, '', '', $force_entity);
1189 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1190 print '</tr>';
1191 print '</table>';
1192 }
1193
1194 print '<table class="noborder centpercent">'."\n";
1195 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Users").' <span class="badge">'.$num.'</span></td></tr>'."\n";
1196
1197 if (count($users) > 0) {
1198 // Use "$userentry" here, because "$user" is the current user
1199 foreach ($users as $key => $userentry) {
1200 print "\t".'<tr class="oddeven">'."\n";
1201 print '<td class="nowrap tdtop">';
1202 print $userentry->getNomUrl(-1);
1203 print "</td>\n";
1204 print '<td class="tdtop">'.$userentry->job."</td>\n";
1205
1206 // Link to delete from category
1207 print '<td class="right">';
1208 if ($user->hasRight('user', 'user', 'creer')) {
1209 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 : '')."'>";
1210 //print $langs->trans("DeleteFromCat");
1211 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1212 print "</a>";
1213 }
1214 print '</td>';
1215 print "</tr>\n";
1216 }
1217 } else {
1218 print '<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1219 }
1220 print "</table>\n";
1221
1222 print '</form>'."\n";
1223 }
1224 } else {
1225 print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'user');
1226 accessforbidden("NotEnoughPermissions", 0, 0);
1227 }
1228}
1229
1230// List of warehouses
1231if ($type == Categorie::TYPE_WAREHOUSE) {
1232 if ($user->hasRight("stock", "read")) {
1233 $permission = $user->hasRight('stock', 'creer');
1234
1235 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
1236
1237 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1238 if ($objects < 0) {
1239 dol_print_error($db, $object->error, $object->errors);
1240 } else {
1242 '@phan-var-force Entrepot[] $objects';
1243 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1244 print '<input type="hidden" name="token" value="'.newToken().'">';
1245 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1246 print '<input type="hidden" name="type" value="'.$typeid.'">';
1247 print '<input type="hidden" name="id" value="'.$object->id.'">';
1248 print '<input type="hidden" name="page_y" value="">';
1249 print '<input type="hidden" name="action" value="list">';
1250
1251 print '<br>';
1252 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1253 $num = count($objects);
1254 $nbtotalofrecords = '';
1255 $newcardbutton = '';
1256
1257 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1258 print_barre_liste($langs->trans("Warehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit);
1259
1260 print '<table class="noborder centpercent">'."\n";
1261 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1262
1263 if (count($objects) > 0) {
1264 $i = 0;
1265 foreach ($objects as $key => $warehouse) {
1266 $i++;
1267 if ($i > $limit) {
1268 break;
1269 }
1270
1271 print "\t".'<tr class="oddeven">'."\n";
1272 print '<td class="nowrap tdtop">';
1273 print $warehouse->getNomUrl(1);
1274 print "</td>\n";
1275 print '<td class="tdtop">'.$warehouse->ref."</td>\n";
1276 print '<td class="tdtop">'.$warehouse->lieu."</td>\n";
1277 // Link to delete from category
1278 print '<td class="right">';
1279 if ($permission) {
1280 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 : '')."'>";
1281 //print $langs->trans("DeleteFromCat");
1282 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1283 print "</a>";
1284 }
1285 print '</td>';
1286 print "</tr>\n";
1287 }
1288 } else {
1289 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1290 }
1291 print "</table>\n";
1292
1293 print '</form>'."\n";
1294 }
1295 } else {
1296 print_barre_liste($langs->trans("Warehouse"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'stock');
1297 accessforbidden("NotEnoughPermissions", 0, 0);
1298 }
1299}
1300
1301// List of tickets
1302if ($type == Categorie::TYPE_TICKET) {
1303 if ($user->hasRight("ticket", "read")) {
1304 $permission = $user->hasRight('categorie', 'creer');
1305 $showclassifyform = $user->hasRight('categorie', 'creer');
1306
1307 $tickets = $object->getObjectsInCateg($type, 0, $limit, $offset);
1308 if ($tickets < 0) {
1309 dol_print_error($db, $object->error, $object->errors);
1310 } else {
1312 '@phan-var-force Ticket[] $tickets';
1313 // Form to add record into a category
1314 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1315 print '<input type="hidden" name="token" value="'.newToken().'">';
1316 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1317 print '<input type="hidden" name="type" value="'.$typeid.'">';
1318 print '<input type="hidden" name="id" value="'.$object->id.'">';
1319 print '<input type="hidden" name="page_y" value="">';
1320 print '<input type="hidden" name="action" value="list">';
1321
1322 print '<br>';
1323 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1324 $num = count($tickets);
1325 $nbtotalofrecords = '';
1326 $newcardbutton = '';
1327
1328 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1329 print_barre_liste($langs->trans("Ticket"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'ticket', 0, $newcardbutton, '', $limit);
1330
1331 if ($showclassifyform) {
1332 print '<table class="noborder centpercent">';
1333 print '<tr class="liste_titre"><td>';
1334 print $langs->trans("AddTicketIntoCategory").' &nbsp;';
1335 $form->selectTickets('', 'elemid');
1336 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1337 print '</tr>';
1338 print '</table>';
1339 }
1340
1341 print '<table class="noborder centpercent">'."\n";
1342 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
1343
1344 if (count($tickets) > 0) {
1345 $i = 0;
1346 foreach ($tickets as $ticket) {
1347 $i++;
1348 if ($i > $limit) {
1349 break;
1350 }
1351
1352 print "\t".'<tr class="oddeven">'."\n";
1353 print '<td class="nowrap tdtop">';
1354 print $ticket->getNomUrl(1);
1355 print "</td>\n";
1356 print '<td class="tdtop">'.$ticket->label."</td>\n";
1357 // Link to delete from category
1358 print '<td class="right">';
1359 if ($permission) {
1360 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 : '')."'>";
1361 //print $langs->trans("DeleteFromCat");
1362 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1363 print "</a>";
1364 }
1365 print '</td>';
1366 print "</tr>\n";
1367 }
1368 } else {
1369 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1370 }
1371 print "</table>\n";
1372
1373 print '</form>'."\n";
1374 }
1375 } else {
1376 print_barre_liste($langs->trans("Ticket"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'ticket');
1377 accessforbidden("NotEnoughPermissions", 0, 0);
1378 }
1379}
1380
1381// List of Interventions
1382if ($type == Categorie::TYPE_FICHINTER) {
1383 if ($user->hasRight("fichinter", "lire")) {
1384 $permission = $user->hasRight('categorie', 'creer');
1385 $showclassifyform = $user->hasRight('categorie', 'creer');
1386
1387 $fichinters = $object->getObjectsInCateg($type, 0, $limit, $offset);
1388 if ($fichinters < 0) {
1389 dol_print_error($db, $object->error, $object->errors);
1390 } else {
1391 // Form to add record into a category
1392 if ($showclassifyform) {
1393 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formintervention.class.php';
1394 $formfichinter = new FormIntervention($db);
1395
1396 print '<br>';
1397 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1398 print '<input type="hidden" name="token" value="'.newToken().'">';
1399 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1400 print '<input type="hidden" name="type" value="'.$typeid.'">';
1401 print '<input type="hidden" name="id" value="'.$object->id.'">';
1402 print '<input type="hidden" name="action" value="addintocategory">';
1403 print '<table class="noborder centpercent">';
1404 print '<tr class="liste_titre"><td>';
1405 print $langs->trans("AddFichinterIntoCategory").' &nbsp;';
1406 print $formfichinter->select_interventions(-1, 0, 'elemid');
1407 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1408 print '</tr>';
1409 print '</table>';
1410 print '</form>';
1411 }
1412
1413 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1414 print '<input type="hidden" name="token" value="'.newToken().'">';
1415 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1416 print '<input type="hidden" name="type" value="'.$typeid.'">';
1417 print '<input type="hidden" name="id" value="'.$object->id.'">';
1418 print '<input type="hidden" name="action" value="list">';
1419
1420 print '<br>';
1421 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1422 $num = count($fichinters);
1423 $nbtotalofrecords = '';
1424 $newcardbutton = '';
1425
1426 $langs->load('interventions');
1427 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1428 print_barre_liste($langs->trans("Intervention"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_intervention', 0, $newcardbutton, '', $limit);
1429 print '<table class="noborder centpercent">'."\n";
1430 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
1431
1432 if (count($fichinters) > 0) {
1433 $i = 0;
1434 foreach ($fichinters as $fichinter) {
1435 $i++;
1436 if ($i > $limit) {
1437 break;
1438 }
1439
1440 print "\t".'<tr class="oddeven">'."\n";
1441 print '<td class="nowrap tdtop">';
1442 print $fichinter->getNomUrl(1);
1443 print "</td>\n";
1444 print '<td class="tdtop">'.$fichinter->description."</td>\n";
1445 // Link to delete from category
1446 print '<td class="right">';
1447 if ($permission) {
1448 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 : '')."'>";
1449 print $langs->trans("DeleteFromCat");
1450 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1451 print "</a>";
1452 }
1453 print '</td>';
1454 print "</tr>\n";
1455 }
1456 } else {
1457 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1458 }
1459 print "</table>\n";
1460 print '</form>'."\n";
1461 }
1462 } else {
1463 print_barre_liste($langs->trans("Intervention"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'fichinter');
1464 accessforbidden("NotEnoughPermissions", 0, 0);
1465 }
1466}
1467
1468// List of Orders
1469// The objects of the category are listed only to a user allowed to read them
1470if ($type == Categorie::TYPE_ORDER && !$user->hasRight('commande', 'lire')) {
1471 accessforbidden("NotEnoughPermissions", 0, 0);
1472}
1473if ($type == Categorie::TYPE_ORDER) {
1474 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
1475
1476 $permission = $user->rights->commande->creer;
1477
1478 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1479 if ($objects < 0) {
1480 dol_print_error($db, $object->error, $object->errors);
1481 } else {
1482 // Form to add record into a category
1483 $showclassifyform = $user->hasRight('order', 'write');
1484 if ($showclassifyform) {
1485 print '<br>';
1486 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1487 print '<input type="hidden" name="token" value="'.newToken().'">';
1488 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1489 print '<input type="hidden" name="type" value="'.$typeid.'">';
1490 print '<input type="hidden" name="id" value="'.$object->id.'">';
1491 print '<input type="hidden" name="action" value="addintocategory">';
1492 print '<table class="noborder centpercent">';
1493 print '<tr class="liste_titre"><td>';
1494 print $langs->trans("AddOrderIntoCategory").' &nbsp;';
1495 $form->selectOrder('', 'elemid');
1496 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1497 print '</tr>';
1498 print '</table>';
1499 print '</form>';
1500 }
1501
1502 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1503 print '<input type="hidden" name="token" value="'.newToken().'">';
1504 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1505 print '<input type="hidden" name="type" value="'.$typeid.'">';
1506 print '<input type="hidden" name="id" value="'.$object->id.'">';
1507 print '<input type="hidden" name="action" value="list">';
1508
1509 print '<br>';
1510 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1511 $num = count($objects);
1512 $nbtotalofrecords = '';
1513 $newcardbutton = '';
1514
1515 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1516 print_barre_liste($langs->trans("Orders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit);
1517
1518 print "<table class='noborder centpercent'>\n";
1519 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1520
1521 if (count($objects) > 0) {
1522 $i = 0;
1523 foreach ($objects as $key => $order) {
1524 $i++;
1525 if ($i > $limit) {
1526 break;
1527 }
1528
1529 print "\t".'<tr class="oddeven">'."\n";
1530 print '<td class="nowrap tdtop">';
1531 print $order->getNomUrl(1);
1532 print "</td>\n";
1533 print '<td class="tdtop">'.$order->ref."</td>\n";
1534 // Link to delete from category
1535 print '<td class="right">';
1536 if ($permission) {
1537 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$order->id."'>";
1538 print $langs->trans("DeleteFromCat");
1539 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1540 print "</a>";
1541 }
1542 print "</tr>\n";
1543 }
1544 } else {
1545 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1546 }
1547 print "</table>\n";
1548
1549 print '</form>'."\n";
1550 }
1551}
1552
1553// List of Invoices
1554if ($type == Categorie::TYPE_INVOICE && !$user->hasRight('facture', 'lire')) {
1555 accessforbidden("NotEnoughPermissions", 0, 0);
1556}
1557if ($type == Categorie::TYPE_INVOICE) {
1558 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1559
1560 $permission = $user->rights->facture->creer;
1561
1562 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1563 if ($objects < 0) {
1564 dol_print_error($db, $object->error, $object->errors);
1565 } else {
1566 // Form to add record into a category
1567 $showclassifyform = $user->hasRight('facture', 'write');
1568 if ($showclassifyform) {
1569 print '<br>';
1570 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1571 print '<input type="hidden" name="token" value="'.newToken().'">';
1572 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1573 print '<input type="hidden" name="type" value="'.$typeid.'">';
1574 print '<input type="hidden" name="id" value="'.$object->id.'">';
1575 print '<input type="hidden" name="action" value="addintocategory">';
1576 print '<table class="noborder centpercent">';
1577 print '<tr class="liste_titre"><td>';
1578 print $langs->trans("AddInvoiceIntoCategory").' &nbsp;';
1579 $form->selectInvoice(-1, '', 'elemid', 24, 0, '1', 0, 0, 0, 'maxwidth500', '', '');
1580 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1581 print '</tr>';
1582 print '</table>';
1583 print '</form>';
1584 }
1585
1586 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1587 print '<input type="hidden" name="token" value="'.newToken().'">';
1588 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1589 print '<input type="hidden" name="type" value="'.$typeid.'">';
1590 print '<input type="hidden" name="id" value="'.$object->id.'">';
1591 print '<input type="hidden" name="action" value="list">';
1592
1593 print '<br>';
1594 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1595 $num = count($objects);
1596 $nbtotalofrecords = '';
1597 $newcardbutton = '';
1598
1599 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1600 print_barre_liste($langs->trans("BillsCustomers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit);
1601
1602 print "<table class='noborder centpercent'>\n";
1603 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1604
1605 if (count($objects) > 0) {
1606 $i = 0;
1607 foreach ($objects as $key => $invoice) {
1608 $i++;
1609 if ($i > $limit) {
1610 break;
1611 }
1612
1613 print "\t".'<tr class="oddeven">'."\n";
1614 print '<td class="nowrap tdtop">';
1615 print $invoice->getNomUrl(1);
1616 print "</td>\n";
1617 print '<td class="tdtop">'.$invoice->ref."</td>\n";
1618 // Link to delete from category
1619 print '<td class="right">';
1620 if ($permission) {
1621 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$invoice->id."'>";
1622 print $langs->trans("DeleteFromCat");
1623 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1624 print "</a>";
1625 }
1626 print "</tr>\n";
1627 }
1628 } else {
1629 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1630 }
1631 print "</table>\n";
1632
1633 print '</form>'."\n";
1634 }
1635}
1636
1637// List of Supplier Orders
1638if ($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')))) {
1639 accessforbidden("NotEnoughPermissions", 0, 0);
1640}
1641if ($type == Categorie::TYPE_SUPPLIER_ORDER) {
1642 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
1643
1644 $permission = $user->rights->fournisseur->commande->creer;
1645
1646 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1647 if ($objects < 0) {
1648 dol_print_error($db, $object->error, $object->errors);
1649 } else {
1650 // Form to add record into a category
1651 $showclassifyform = $user->hasRight('fournisseur', 'commande', 'creer');
1652 ;
1653 if ($showclassifyform) {
1654 print '<br>';
1655 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1656 print '<input type="hidden" name="token" value="'.newToken().'">';
1657 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1658 print '<input type="hidden" name="type" value="'.$typeid.'">';
1659 print '<input type="hidden" name="id" value="'.$object->id.'">';
1660 print '<input type="hidden" name="action" value="addintocategory">';
1661 print '<table class="noborder centpercent">';
1662 print '<tr class="liste_titre"><td>';
1663 print $langs->trans("AddSupplierOrderIntoCategory").' &nbsp;';
1664 $form->selectSupplierOrder('', 'elemid');
1665 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1666 print '</tr>';
1667 print '</table>';
1668 print '</form>';
1669 }
1670
1671 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1672 print '<input type="hidden" name="token" value="'.newToken().'">';
1673 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1674 print '<input type="hidden" name="type" value="'.$typeid.'">';
1675 print '<input type="hidden" name="id" value="'.$object->id.'">';
1676 print '<input type="hidden" name="action" value="list">';
1677
1678 print '<br>';
1679 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1680 $num = count($objects);
1681 $nbtotalofrecords = '';
1682 $newcardbutton = '';
1683
1684 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1685 print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit);
1686
1687 print "<table class='noborder centpercent'>\n";
1688 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1689
1690 if (count($objects) > 0) {
1691 $i = 0;
1692 foreach ($objects as $key => $supplier_order) {
1693 $i++;
1694 if ($i > $limit) {
1695 break;
1696 }
1697
1698 print "\t".'<tr class="oddeven">'."\n";
1699 print '<td class="nowrap tdtop">';
1700 print $supplier_order->getNomUrl(1);
1701 print "</td>\n";
1702 print '<td class="tdtop">'.$supplier_order->ref."</td>\n";
1703 // Link to delete from category
1704 print '<td class="right">';
1705 if ($permission) {
1706 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$supplier_order->id."'>";
1707 print $langs->trans("DeleteFromCat");
1708 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1709 print "</a>";
1710 }
1711 print "</tr>\n";
1712 }
1713 } else {
1714 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1715 }
1716 print "</table>\n";
1717
1718 print '</form>'."\n";
1719 }
1720}
1721
1722// List of Supplier Invoices
1723if ($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')))) {
1724 accessforbidden("NotEnoughPermissions", 0, 0);
1725}
1726if ($type == Categorie::TYPE_SUPPLIER_INVOICE) {
1727 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1728
1729 $permission = $user->rights->fournisseur->facture->creer;
1730
1731 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1732 if ($objects < 0) {
1733 dol_print_error($db, $object->error, $object->errors);
1734 } else {
1735 // Form to add record into a category
1736 $showclassifyform = $user->hasRight('fournisseur', 'facture', 'creer');;
1737 if ($showclassifyform) {
1738 print '<br>';
1739 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1740 print '<input type="hidden" name="token" value="'.newToken().'">';
1741 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1742 print '<input type="hidden" name="type" value="'.$typeid.'">';
1743 print '<input type="hidden" name="id" value="'.$object->id.'">';
1744 print '<input type="hidden" name="action" value="addintocategory">';
1745 print '<table class="noborder centpercent">';
1746 print '<tr class="liste_titre"><td>';
1747 print $langs->trans("AddSupplierInvoiceIntoCategory").' &nbsp;';
1748 $form->selectSupplierInvoice('', 'elemid');
1749 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1750 print '</tr>';
1751 print '</table>';
1752 print '</form>';
1753 }
1754
1755 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1756 print '<input type="hidden" name="token" value="'.newToken().'">';
1757 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1758 print '<input type="hidden" name="type" value="'.$typeid.'">';
1759 print '<input type="hidden" name="id" value="'.$object->id.'">';
1760 print '<input type="hidden" name="action" value="list">';
1761
1762 print '<br>';
1763 $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = '';
1764
1765 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1766 print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit);
1767
1768 print "<table class='noborder centpercent'>\n";
1769 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1770
1771 if (count($objects) > 0) {
1772 $i = 0;
1773 foreach ($objects as $key => $supplier_invoice) {
1774 $i++;
1775 if ($i > $limit) {
1776 break;
1777 }
1778
1779 print "\t".'<tr class="oddeven">'."\n";
1780 print '<td class="nowrap tdtop">';
1781 print $supplier_invoice->getNomUrl(1);
1782 print "</td>\n";
1783 print '<td class="tdtop">'.$supplier_invoice->ref."</td>\n";
1784 // Link to delete from category
1785 print '<td class="right">';
1786 if ($permission) {
1787 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$supplier_invoice->id."'>";
1788 print $langs->trans("DeleteFromCat");
1789 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1790 print "</a>";
1791 }
1792 print "</tr>\n";
1793 }
1794 } else {
1795 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1796 }
1797 print "</table>\n";
1798
1799 print '</form>'."\n";
1800 }
1801}
1802
1803// Note that $action and $object may have been modified by some hooks
1804$parameters = array('type' => $type, 'id' => $id, 'label' => $label);
1805$reshook = $hookmanager->executeHooks('addMoreCategoriesList', $parameters, $object, $action);
1806
1807// End of page
1808llxFooter();
1809$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
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 to manage generation of HTML components for contract module.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
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...
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.