dolibarr 21.0.0-alpha
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) 2024 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
33// Load Dolibarr environment
34require '../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
39
40// Load translation files required by the page
41$langs->loadLangs(array("categories", "compta"));
42
43$id = GETPOSTINT('id');
44$label = GETPOST('label', 'alpha');
45$removeelem = GETPOSTINT('removeelem');
46$elemid = GETPOSTINT('elemid');
47
48$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
49$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
50$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
51$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
52$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
53$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
54$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'categorylist'; // To manage different context of search
55$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
56$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
57
58
59// Load variable for pagination
60$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
61$sortfield = GETPOST('sortfield', 'aZ09comma');
62$sortorder = GETPOST('sortorder', 'aZ09comma');
63$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
64if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
65 $page = 0;
66} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
67$offset = $limit * $page;
68$pageprev = $page - 1;
69$pagenext = $page + 1;
70
71if ($id == "" && $label == "") {
72 dol_print_error(null, 'Missing parameter id');
73 exit();
74}
75
76// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array
77$hookmanager->initHooks(array('categorycard', 'globalcard'));
78
79// Security check
80$result = restrictedArea($user, 'categorie', $id, '&category');
81
82$object = new Categorie($db);
83$result = $object->fetch($id, $label);
84if ($result <= 0) {
85 dol_print_error($db, $object->error);
86 exit;
87}
88
89$type = $object->type;
90if (is_numeric($type)) {
91 $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
92}
93
94$extrafields = new ExtraFields($db);
95$extrafields->fetch_name_optionals_label($object->table_element);
96
97/*
98 * Actions
99 */
100
101if ($confirm == 'no') {
102 if ($backtopage) {
103 header("Location: ".$backtopage);
104 exit;
105 }
106}
107
108$parameters = array('type' => $type, 'id' => $id, 'label' => $label);
109$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
110// Remove element from category
111if ($id > 0 && $removeelem > 0 && $action == 'unlink') { // Test on permission not required here. Done later according to type of object.
112 $tmpobject = null;
113 if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
114 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
115 $tmpobject = new Product($db);
116 $result = $tmpobject->fetch($removeelem);
117 $elementtype = 'product';
118 } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) {
119 $tmpobject = new Societe($db);
120 $result = $tmpobject->fetch($removeelem);
121 $elementtype = 'supplier';
122 } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) {
123 $tmpobject = new Societe($db);
124 $result = $tmpobject->fetch($removeelem);
125 $elementtype = 'customer';
126 } elseif ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) {
127 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
128 $tmpobject = new Adherent($db);
129 $result = $tmpobject->fetch($removeelem);
130 $elementtype = 'member';
131 } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) {
132 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
133 $tmpobject = new Contact($db);
134 $result = $tmpobject->fetch($removeelem);
135 $elementtype = 'contact';
136 } elseif ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) {
137 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
138 $tmpobject = new Account($db);
139 $result = $tmpobject->fetch($removeelem);
140 $elementtype = 'account';
141 } elseif ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) {
142 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
143 $tmpobject = new Project($db);
144 $result = $tmpobject->fetch($removeelem);
145 $elementtype = 'project';
146 } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) {
147 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
148 $tmpobject = new User($db);
149 $result = $tmpobject->fetch($removeelem);
150 $elementtype = 'user';
151 } elseif ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) {
152 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
153 $tmpobject = new Ticket($db);
154 $result = $tmpobject->fetch($removeelem);
155 $elementtype = 'ticket';
156 }
157
158 $result = $object->del_type($tmpobject, $elementtype);
159 if ($result < 0) {
160 dol_print_error(null, $object->error);
161 }
162}
163
164if ($user->hasRight('categorie', 'supprimer') && $action == 'confirm_delete' && $confirm == 'yes') {
165 if ($object->delete($user) >= 0) {
166 if ($backtopage) {
167 header("Location: ".$backtopage);
168 exit;
169 } else {
170 header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type);
171 exit;
172 }
173 } else {
174 setEventMessages($object->error, $object->errors, 'errors');
175 }
176}
177
178if ($elemid && $action == 'addintocategory') { // Test on permission not required here. Done just after depending on object type
179 if (($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) ||
180 ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) ||
181 ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) ||
182 ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) ||
183 ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) ||
184 ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) ||
185 ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) ||
186 ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) ||
187 ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer'))
188 ) {
189 $newobject = null;
190 if ($type == Categorie::TYPE_PRODUCT) {
191 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
192 $newobject = new Product($db);
193 $elementtype = 'product';
194 } elseif ($type == Categorie::TYPE_CUSTOMER) {
195 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
196 $newobject = new Societe($db);
197 $elementtype = 'customer';
198 } elseif ($type == Categorie::TYPE_SUPPLIER) {
199 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
200 $newobject = new Societe($db);
201 $elementtype = 'supplier';
202 } elseif ($type == Categorie::TYPE_TICKET) {
203 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
204 $newobject = new Ticket($db);
205 $elementtype = 'ticket';
206 } elseif ($type == Categorie::TYPE_PROJECT) {
207 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
208 $newobject = new Project($db);
209 $elementtype = 'project';
210 } elseif ($type == Categorie::TYPE_MEMBER) {
211 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
212 $newobject = new Adherent($db);
213 $elementtype = 'member';
214 } elseif ($type == Categorie::TYPE_CONTACT) {
215 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
216 $newobject = new Contact($db);
217 $elementtype = 'contact';
218 } elseif ($type == Categorie::TYPE_USER) {
219 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
220 $newobject = new User($db);
221 $elementtype = 'user';
222 } elseif ($type == Categorie::TYPE_ACCOUNT) {
223 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
224 $newobject = new Account($db);
225 $elementtype = 'bank_account';
226 } else {
227 dol_print_error(null, "Not supported value of type = ".$type);
228 }
229 if ($newobject !== null) {
230 $result = $newobject->fetch($elemid);
231 }
232
233 // Add into category
234 $result = $object->add_type($newobject, $elementtype);
235 if ($result >= 0) {
236 setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs');
237 } else {
238 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
239 setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
240 } else {
241 setEventMessages($object->error, $object->errors, 'errors');
242 }
243 }
244 }
245}
246
247
248/*
249 * View
250 */
251
252$form = new Form($db);
253$formother = new FormOther($db);
254
255$arrayofjs = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
256$arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
257
258$help_url = '';
259
260llxHeader("", $langs->trans("Categories"), $help_url, '', 0, 0, $arrayofjs, $arrayofcss);
261
262$title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
263
264$head = categories_prepare_head($object, $type);
265print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category');
266
267$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type));
268$linkback = '<a href="'.dol_sanitizeUrl($backtolist).'">'.$langs->trans("BackToList").'</a>';
269$object->next_prev_filter = 'type = '.((int) $object->type);
270$object->ref = $object->label;
271$morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type).'">'.$langs->trans("Root").'</a> >> ';
272$ways = $object->print_all_ways(" &gt;&gt; ", '', 1);
273foreach ($ways as $way) {
274 $morehtmlref .= $way."<br>\n";
275}
276$morehtmlref .= '</div>';
277
278dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.urlencode($type), 0, '', '', 1);
279
280
281/*
282 * Confirmation suppression
283 */
284
285if ($action == 'delete') {
286 if ($backtopage) {
287 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2);
288 } else {
289 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
290 }
291}
292
293print '<br>';
294
295print '<div class="fichecenter">';
296print '<div class="underbanner clearboth"></div>';
297print '<table class="border centpercent tableforfield">';
298
299// Description
300print '<tr><td class="titlefield notopnoleft tdtop">';
301print $langs->trans("Description").'</td><td>';
302print dol_htmlentitiesbr($object->description);
303print '</td></tr>';
304
305// Color
306print '<tr><td class="notopnoleft">';
307print $langs->trans("Color").'</td><td>';
308print $formother->showColor($object->color);
309print '</td></tr>';
310
311// Position
312print '<tr><td class="titlefield notopnoleft">';
313print $langs->trans("Position").'</td><td>';
314print $object->position;
315print '</td></tr>';
316
317// Other attributes
318include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
319
320print '</table>';
321print '</div>';
322
323print dol_get_fiche_end();
324
325
326/*
327 * Boutons actions
328 */
329
330print "<div class='tabsAction'>\n";
331$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
332if ($reshook < 0) {
333 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
334}
335if (empty($reshook)) {
336 if ($user->hasRight('categorie', 'creer')) {
337 $socid = ($object->socid ? "&socid=".$object->socid : "");
338 print '<a class="butAction" href="edit.php?id='.$object->id.$socid.'&type='.$type.'">'.$langs->trans("Modify").'</a>';
339 }
340
341 if ($user->hasRight('categorie', 'supprimer')) {
342 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'&type='.$type.'&backtolist='.urlencode($backtolist).'">'.$langs->trans("Delete").'</a>';
343 }
344}
345
346print "</div>";
347
348$newcardbutton = '';
349if ($user->hasRight('categorie', 'creer')) {
350 $link = DOL_URL_ROOT.'/categories/card.php';
351 $link .= '?action=create';
352 $link .= '&type='.$type;
353 $link .= '&catorigin='.$object->id;
354 $link .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.'&id='.$id);
355
356 $newcardbutton = '<div class="right">';
357 $newcardbutton .= dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', $link);
358 $newcardbutton .= '</div>';
359}
360
361
362/*
363 * Sub-category tree view of this category
364 */
365
366print '<div class="fichecenter">';
367
368print load_fiche_titre($langs->trans("SubCats"), $newcardbutton, 'object_category');
369
370
371print '<table class="liste nohover centpercent borderbottom">';
372
373print '<tr class="liste_titre">';
374print '<td>'.$langs->trans("SubCats").'</td>';
375print '<td></td>';
376print '<td class="right">';
377
378if (!empty($conf->use_javascript_ajax)) {
379 print '<div id="iddivjstreecontrol">';
380 print '<a class="notasortlink" href="#">'.img_picto('', 'folder').' '.$langs->trans("UndoExpandAll").'</a>';
381 print " | ";
382 print '<a class="notasortlink" href="#">'.img_picto('', 'folder-open').' '.$langs->trans("ExpandAll").'</a>';
383 print '</div>';
384}
385
386print '</td>';
387print '</tr>';
388
389$cats = $object->get_filles();
390if ($cats < 0) {
391 dol_print_error($db, $object->error, $object->errors);
392} elseif (count($cats) < 1) {
393 print '<tr class="oddeven nobottom">';
394 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("NoSubCat").'</span></td>';
395 print '</tr>';
396} else {
397 $categstatic = new Categorie($db);
398
399 $fulltree = $categstatic->get_full_arbo($type, $object->id, 1);
400
401 // Load possible missing includes
402 if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) {
403 if ($type == Categorie::TYPE_MEMBER) {
404 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
405 }
406 if ($type == Categorie::TYPE_ACCOUNT) {
407 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
408 }
409 if ($type == Categorie::TYPE_PROJECT) {
410 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
411 }
412 if ($type == Categorie::TYPE_USER) {
413 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
414 }
415 }
416
417 // Define data (format for treeview)
418 $data = array();
419 $data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => "racine", 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => '');
420 foreach ($fulltree as $key => $val) {
421 $categstatic->id = $val['id'];
422 $categstatic->ref = $val['label'];
423 $categstatic->color = $val['color'];
424 $categstatic->type = $type;
425 $desc = dol_htmlcleanlastbr($val['description']);
426
427 $counter = '';
428 if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) {
429 // we need only a count of the elements, so it is enough to consume only the id's from the database
430 $elements = $categstatic->getObjectsInCateg($type, 1);
431
432 $counter = "<td class='left' width='40px;'>".(is_array($elements) ? count($elements) : '0')."</td>";
433 }
434
435 $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"';
436 $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type));
437
438 $entry = '<table class="nobordernopadding centpercent">';
439 $entry .= '<tr>';
440
441 $entry .= '<td>';
442 $entry .= '<span class="noborderoncategories" '.$color.'>'.$li.'</span>';
443 $entry .= '</td>';
444
445 $entry .= $counter;
446
447 $entry .= '<td class="right" width="20px;">';
448 $entry .= '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'">'.img_view().'</a>';
449 $entry .= '</td>';
450 $entry .= '<td class="right" width="20px;">';
451 $entry .= '<a class="editfielda" href="'.DOL_URL_ROOT.'/categories/edit.php?id='.$val['id'].'&type='.$type.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'">'.img_edit().'</a>';
452 $entry .= '</td>';
453 $entry .= '<td class="right" width="20px;">';
454 $entry .= '<a class="deletefilelink" href="'.DOL_URL_ROOT.'/categories/viewcat.php?action=delete&token='.newToken().'&id='.$val['id'].'&type='.$type.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'">'.img_delete().'</a>';
455 $entry .= '</td>';
456
457 $entry .= '</tr>';
458 $entry .= '</table>';
459
460 $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
461 }
462
463 $nbofentries = (count($data) - 1);
464 if ($nbofentries > 0) {
465 require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
466 print '<tr class="pair">';
467 print '<td colspan="3">';
468
469 // $data[0] is the current shown category, to don'T show the current category use $data[1] instead
470 tree_recur($data, $data[1], 0);
471
472 print '</td>';
473 print '</tr>';
474 } else {
475 print '<tr class="pair">';
476 print '<td colspan="3">';
477 print '<table class="nobordernopadding">';
478
479 print '<tr class="nobordernopadding">';
480 print '<td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
481 print '<td class="valignmiddle"><span class="opacitymedium">'.$langs->trans("NoCategoryYet").'</span></td>';
482 print '<td>&nbsp;</td>';
483 print '</tr>';
484
485 print '</table>';
486 print '</td>';
487 print '</tr>';
488 }
489}
490
491print "</table>";
492print "</div>";
493
494// List of mass actions available
495$arrayofmassactions = array(
496 //'validate'=>$langs->trans("Validate"),
497 //'generate_doc'=>$langs->trans("ReGeneratePDF"),
498 //'builddoc'=>$langs->trans("PDFMerge"),
499 //'presend'=>$langs->trans("SendByMail"),
500);
501$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
502
503$typeid = $type;
504
505
506// List of products or services (type is type of category)
507if ($type == Categorie::TYPE_PRODUCT) {
508 if ($user->hasRight("product", "read") || $user->hasRight("service", "read")) {
509 $permission = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'));
510
511 $prods = $object->getObjectsInCateg($type, 0, $limit, $offset);
512 if ($prods < 0) {
513 dol_print_error($db, $object->error, $object->errors);
514 } else {
516 '@phan-var-force Product[] $prods';
517 // Form to add record into the category
518 $showclassifyform = 1;
519 if ($showclassifyform) {
520 print '<br>';
521 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
522 print '<input type="hidden" name="token" value="'.newToken().'">';
523 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
524 print '<input type="hidden" name="type" value="'.$typeid.'">';
525 print '<input type="hidden" name="id" value="'.$object->id.'">';
526 print '<input type="hidden" name="action" value="addintocategory">';
527 print '<table class="noborder centpercent">';
528 print '<tr class="liste_titre"><td>';
529 print $langs->trans("AddProductServiceIntoCategory").' &nbsp;';
530 $form->select_produits('', 'elemid', '', 0, 0, -1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null);
531 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
532 print '</tr>';
533 print '</table>';
534 print '</form>';
535 }
536
537 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
538 print '<input type="hidden" name="token" value="'.newToken().'">';
539 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
540 print '<input type="hidden" name="type" value="'.$typeid.'">';
541 print '<input type="hidden" name="id" value="'.$object->id.'">';
542 print '<input type="hidden" name="action" value="list">';
543
544 print '<br>';
545 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
546 $num = count($prods);
547 $nbtotalofrecords = '';
548 $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'));
549
550 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
551 print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit);
552
553
554 print '<table class="noborder centpercent">'."\n";
555 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
556
557 if (count($prods) > 0) {
558 $i = 0;
559 foreach ($prods as $prod) {
560 $i++;
561 if ($i > $limit) {
562 break;
563 }
564
565 print "\t".'<tr class="oddeven">'."\n";
566 print '<td class="nowrap" valign="top">';
567 print $prod->getNomUrl(1);
568 print "</td>\n";
569 print '<td class="tdtop">'.$prod->label."</td>\n";
570 // Link to delete from category
571 print '<td class="right">';
572 if ($permission) {
573 print '<a class="reposition" href= "'.$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".((int) $object->id)."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".$prod->id.'">';
574 print $langs->trans("DeleteFromCat");
575 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
576 print "</a>";
577 }
578 print '</td>';
579 print "</tr>\n";
580 }
581 } else {
582 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
583 }
584 print "</table>\n";
585
586 print '</form>'."\n";
587 }
588 } else {
589 print_barre_liste($langs->trans("ProductsAndServices"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'products');
590 accessforbidden("NotEnoughPermissions", 0, 0);
591 }
592}
593
594// List of customers
595if ($type == Categorie::TYPE_CUSTOMER) {
596 if ($user->hasRight("societe", "read")) {
597 $permission = $user->hasRight('societe', 'creer');
598
599 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset);
600 if ($socs < 0) {
601 dol_print_error($db, $object->error, $object->errors);
602 } else {
604 '@phan-var-force Societe[] $socs';
605 // Form to add record into a category
606 $showclassifyform = 1;
607 if ($showclassifyform) {
608 print '<br>';
609 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
610 print '<input type="hidden" name="token" value="'.newToken().'">';
611 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
612 print '<input type="hidden" name="type" value="'.$typeid.'">';
613 print '<input type="hidden" name="id" value="'.$object->id.'">';
614 print '<input type="hidden" name="action" value="addintocategory">';
615 print '<table class="noborder centpercent">';
616 print '<tr class="liste_titre"><td>';
617 print $langs->trans("AddCustomerIntoCategory").' &nbsp;';
618 $filter = '(s.client:IN:1,3)';
619 print $form->select_company('', 'elemid', $filter);
620 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
621 print '</tr>';
622 print '</table>';
623 print '</form>';
624 }
625
626 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
627 print '<input type="hidden" name="token" value="'.newToken().'">';
628 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
629 print '<input type="hidden" name="type" value="'.$typeid.'">';
630 print '<input type="hidden" name="id" value="'.$object->id.'">';
631 print '<input type="hidden" name="action" value="list">';
632
633 print '<br>';
634 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
635 $num = count($socs);
636 $nbtotalofrecords = '';
637 $newcardbutton = dolGetButtonTitle($langs->trans("AddThirdParty"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&client=3&custcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->hasRight('societe', 'creer'));
638
639 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
640 print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
641
642 print '<table class="noborder centpercent">'."\n";
643 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name").'</td></tr>'."\n";
644
645 if (count($socs) > 0) {
646 $i = 0;
647 foreach ($socs as $key => $soc) {
648 $i++;
649 if ($i > $limit) {
650 break;
651 }
652
653 print "\t".'<tr class="oddeven">'."\n";
654 print '<td class="nowrap tdtop">';
655 print $soc->getNomUrl(1);
656 print "</td>\n";
657 // Link to delete from category
658 print '<td class="right">';
659 if ($permission) {
660 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$soc->id."'>";
661 print $langs->trans("DeleteFromCat");
662 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
663 print "</a>";
664 }
665 print '</td>';
666 print "</tr>\n";
667 }
668 } else {
669 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
670 }
671 print "</table>\n";
672
673 print '</form>'."\n";
674 }
675 } else {
676 print_barre_liste($langs->trans("Customers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
677 accessforbidden("NotEnoughPermissions", 0, 0);
678 }
679}
680
681// List of suppliers
682if ($type == Categorie::TYPE_SUPPLIER) {
683 if ($user->hasRight("fournisseur", "read")) {
684 $permission = $user->hasRight('societe', 'creer');
685
686 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset);
687
688 if ($socs < 0) {
689 dol_print_error($db, $object->error, $object->errors);
690 } else {
692 '@phan-var-force Fournisseur[] $socs';
693 // Form to add record into a category
694 $showclassifyform = 1;
695 if ($showclassifyform) {
696 print '<br>';
697 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
698 print '<input type="hidden" name="token" value="'.newToken().'">';
699 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
700 print '<input type="hidden" name="type" value="'.$typeid.'">';
701 print '<input type="hidden" name="id" value="'.$object->id.'">';
702 print '<input type="hidden" name="action" value="addintocategory">';
703 print '<table class="noborder centpercent">';
704 print '<tr class="liste_titre"><td>';
705 print $langs->trans("AddSupplierIntoCategory").' &nbsp;';
706 $filter = '(s.fournisseur:=:1)';
707 print $form->select_company('', 'elemid', $filter);
708 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
709 print '</tr>';
710 print '</table>';
711 print '</form>';
712 }
713
714 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
715 print '<input type="hidden" name="token" value="'.newToken().'">';
716 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
717 print '<input type="hidden" name="type" value="'.$typeid.'">';
718 print '<input type="hidden" name="id" value="'.$object->id.'">';
719 print '<input type="hidden" name="action" value="list">';
720
721 print '<br>';
722 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
723 $num = count($socs);
724 $nbtotalofrecords = '';
725 $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'));
726
727 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
728 print_barre_liste($langs->trans("Suppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
729
730 print '<table class="noborder centpercent">'."\n";
731 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name")."</td></tr>\n";
732
733 if (count($socs) > 0) {
734 $i = 0;
735 foreach ($socs as $soc) {
736 $i++;
737 if ($i > $limit) {
738 break;
739 }
740
741 print "\t".'<tr class="oddeven">'."\n";
742 print '<td class="nowrap tdtop">';
743 print $soc->getNomUrl(1);
744 print "</td>\n";
745 // Link to delete from category
746 print '<td class="right">';
747 if ($permission) {
748 print '<a class="reposition" href="'.$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$soc->id.($limit ? '&limit='.$limit : '').'">';
749 print $langs->trans("DeleteFromCat");
750 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
751 print "</a>";
752 }
753 print '</td>';
754
755 print "</tr>\n";
756 }
757 } else {
758 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
759 }
760 print "</table>\n";
761
762 print '</form>'."\n";
763 }
764 } else {
765 print_barre_liste($langs->trans("Suppliers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
766 accessforbidden("NotEnoughPermissions", 0, 0);
767 }
768}
769
770// List of members
771if ($type == Categorie::TYPE_MEMBER) {
772 if ($user->hasRight("adherent", "read")) {
773 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
774
775 $permission = $user->hasRight('adherent', 'creer');
776
777 $members = $object->getObjectsInCateg($type, 0, $limit, $offset);
778 if ($members < 0) {
779 dol_print_error($db, $object->error, $object->errors);
780 } else {
782 '@phan-var-force Adherent[] $members';
783 // Form to add record into a category
784 $showclassifyform = 1;
785 if ($showclassifyform) {
786 print '<br>';
787 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
788 print '<input type="hidden" name="token" value="'.newToken().'">';
789 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
790 print '<input type="hidden" name="type" value="'.$typeid.'">';
791 print '<input type="hidden" name="id" value="'.$object->id.'">';
792 print '<input type="hidden" name="action" value="addintocategory">';
793 print '<table class="noborder centpercent">';
794 print '<tr class="liste_titre"><td>';
795 print $langs->trans("AssignCategoryTo").' &nbsp;';
796 print $form->selectMembers('', 'elemid');
797 print '<input type="submit" class="button buttongen" value="'.$langs->trans("Save").'"></td>';
798 print '</tr>';
799 print '</table>';
800 print '</form>';
801 }
802
803 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
804 print '<input type="hidden" name="token" value="'.newToken().'">';
805 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
806 print '<input type="hidden" name="type" value="'.$typeid.'">';
807 print '<input type="hidden" name="id" value="'.$object->id.'">';
808 print '<input type="hidden" name="action" value="list">';
809
810 print '<br>';
811 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
812 $num = count($members);
813 $nbtotalofrecords = '';
814 $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'));
815
816 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
817 print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit);
818
819 print '<table class="noborder centpercent">'."\n";
820 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Name").'</td></tr>'."\n";
821
822 if (count($members) > 0) {
823 $i = 0;
824 foreach ($members as $key => $member) {
825 $i++;
826 if ($i > $limit) {
827 break;
828 }
829
830 print "\t".'<tr class="oddeven">'."\n";
831 print '<td class="nowrap tdtop">';
832 $member->ref = $member->login;
833 print $member->getNomUrl(1, 0);
834 print "</td>\n";
835 print '<td class="tdtop">'.$member->lastname."</td>\n";
836 print '<td class="tdtop">'.$member->firstname."</td>\n";
837 // Link to delete from category
838 print '<td class="right">';
839 if ($permission) {
840 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$member->id."'>";
841 print $langs->trans("DeleteFromCat");
842 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
843 print "</a>";
844 }
845 print '</td>';
846 print "</tr>\n";
847 }
848 } else {
849 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
850 }
851 print "</table>\n";
852
853 print '</form>'."\n";
854 }
855 } else {
856 print_barre_liste($langs->trans("Member"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'members');
857 accessforbidden("NotEnoughPermissions", 0, 0);
858 }
859}
860
861// List of contacts
862if ($type == Categorie::TYPE_CONTACT) {
863 if ($user->hasRight("societe", "read")) {
864 $permission = $user->hasRight('societe', 'creer');
865
866 $contacts = $object->getObjectsInCateg($type, 0, $limit, $offset);
867 if (is_numeric($contacts) && $contacts < 0) {
868 dol_print_error($db, $object->error, $object->errors);
869 } else {
871 '@phan-var-force Contact[] $contacts';
872 // Form to add record into a category
873 $showclassifyform = 1;
874 if ($showclassifyform) {
875 print '<br>';
876 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
877 print '<input type="hidden" name="token" value="'.newToken().'">';
878 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
879 print '<input type="hidden" name="type" value="'.$typeid.'">';
880 print '<input type="hidden" name="id" value="'.$object->id.'">';
881 print '<input type="hidden" name="action" value="addintocategory">';
882 print '<table class="noborder centpercent">';
883 print '<tr class="liste_titre"><td>';
884 print $langs->trans("AssignCategoryTo").' &nbsp;';
885 //print $form->selectcontacts('', '', 'elemid');
886 print $form->select_contact(0, '', 'elemid', '', '', '', 0, 'maxwidth300 widthcentpercentminusx');
887 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
888 print '</tr>';
889 print '</table>';
890 print '</form>';
891 }
892 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
893 print '<input type="hidden" name="token" value="'.newToken().'">';
894 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
895 print '<input type="hidden" name="type" value="'.$typeid.'">';
896 print '<input type="hidden" name="id" value="'.$object->id.'">';
897 print '<input type="hidden" name="action" value="list">';
898
899 print '<br>';
900 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
901 $num = count($contacts);
902 $nbtotalofrecords = '';
903 $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'));
904
905 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
906 print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contact', 0, $newcardbutton, '', $limit);
907
908 $objsoc = new Societe($db);
909
910 print '<table class="noborder centpercent">'."\n";
911 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Ref").'</td></tr>'."\n";
912
913 if (is_array($contacts) && count($contacts) > 0) {
914 $i = 0;
915 foreach ($contacts as $key => $contact) {
916 $i++;
917 if ($i > $limit) {
918 break;
919 }
920
921 print "\t".'<tr class="oddeven">'."\n";
922 print '<td class="nowrap tdtop">';
923 print $contact->getNomUrl(1, 'category');
924 if ($contact->socid > 0) {
925 $objsoc->fetch($contact->socid);
926 print ' - ';
927 print $objsoc->getNomUrl(1, 'contact');
928 }
929 print "</td>\n";
930 // Link to delete from category
931 print '<td class="right">';
932 if ($permission) {
933 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$contact->id."'>";
934 print $langs->trans("DeleteFromCat");
935 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
936 print "</a>";
937 }
938 print '</td>';
939 print "</tr>\n";
940 }
941 } else {
942 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
943 }
944 print "</table>\n";
945
946 print '</form>'."\n";
947 }
948 } else {
949 print_barre_liste($langs->trans("Contact"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'contact');
950 accessforbidden("NotEnoughPermissions", 0, 0);
951 }
952}
953
954// List of bank accounts
955if ($type == Categorie::TYPE_ACCOUNT) {
956 if ($user->hasRight("banque", "read")) {
957 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
958
959 $permission = $user->hasRight('banque', 'creer');
960
961 $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset);
962 if ($accounts < 0) {
963 dol_print_error($db, $object->error, $object->errors);
964 } else {
966 '@phan-var-force Account[] $accounts';
967 // Form to add record into a category
968 $showclassifyform = 1;
969 if ($showclassifyform) {
970 print '<br>';
971 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
972 print '<input type="hidden" name="token" value="'.newToken().'">';
973 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
974 print '<input type="hidden" name="type" value="'.$typeid.'">';
975 print '<input type="hidden" name="id" value="'.$object->id.'">';
976 print '<input type="hidden" name="action" value="addintocategory">';
977 print '<table class="noborder centpercent">';
978 print '<tr class="liste_titre"><td>';
979 print $langs->trans("AddObjectIntoCategory").' &nbsp;';
980 print $form->select_comptes('', 'elemid', 0, '', 0, '', 0, '', 1);
981 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
982 print '</tr>';
983 print '</table>';
984 print '</form>';
985 }
986
987 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
988 print '<input type="hidden" name="token" value="'.newToken().'">';
989 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
990 print '<input type="hidden" name="type" value="'.$typeid.'">';
991 print '<input type="hidden" name="id" value="'.$object->id.'">';
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 print '<table class="noborder centpercent">'."\n";
1004 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1005
1006 if (count($accounts) > 0) {
1007 $i = 0;
1008 foreach ($accounts as $key => $account) {
1009 $i++;
1010 if ($i > $limit) {
1011 break;
1012 }
1013
1014 print "\t".'<tr class="oddeven">'."\n";
1015 print '<td class="nowrap tdtop">';
1016 print $account->getNomUrl(1, 0);
1017 print "</td>\n";
1018 print '<td class="tdtop">'.$account->bank."</td>\n";
1019 print '<td class="tdtop">'.$account->number."</td>\n";
1020 // Link to delete from category
1021 print '<td class="right">';
1022 if ($permission) {
1023 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$account->id."'>";
1024 print $langs->trans("DeleteFromCat");
1025 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1026 print "</a>";
1027 }
1028 print '</td>';
1029 print "</tr>\n";
1030 }
1031 } else {
1032 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1033 }
1034 print "</table>\n";
1035
1036 print '</form>'."\n";
1037 }
1038 } else {
1039 print_barre_liste($langs->trans("Banque"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'bank');
1040 accessforbidden("NotEnoughPermissions", 0, 0);
1041 }
1042}
1043
1044// List of Project
1045if ($type == Categorie::TYPE_PROJECT) {
1046 if ($user->hasRight("project", "read")) {
1047 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
1048
1049 $permission = $user->hasRight('projet', 'creer');
1050
1051 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1052 if ($objects < 0) {
1053 dol_print_error($db, $object->error, $object->errors);
1054 } else {
1056 '@phan-var-force Project $object';
1057 // Form to add record into a category
1058 $showclassifyform = 1;
1059 if ($showclassifyform) {
1060 print '<br>';
1061 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1062 print '<input type="hidden" name="token" value="'.newToken().'">';
1063 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1064 print '<input type="hidden" name="type" value="'.$typeid.'">';
1065 print '<input type="hidden" name="id" value="'.$object->id.'">';
1066 print '<input type="hidden" name="action" value="addintocategory">';
1067 print '<table class="noborder centpercent">';
1068 print '<tr class="liste_titre"><td>';
1069 print $langs->trans("AddObjectIntoCategory").' &nbsp;';
1070 $form->selectProjects('', 'elemid');
1071 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1072 print '</tr>';
1073 print '</table>';
1074 print '</form>';
1075 }
1076
1077 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1078 print '<input type="hidden" name="token" value="'.newToken().'">';
1079 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1080 print '<input type="hidden" name="type" value="'.$typeid.'">';
1081 print '<input type="hidden" name="id" value="'.$object->id.'">';
1082 print '<input type="hidden" name="action" value="list">';
1083
1084 print '<br>';
1085 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1086 $num = count($objects);
1087 $nbtotalofrecords = '';
1088 $newcardbutton = '';
1089
1090 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1091 print_barre_liste($langs->trans("Project"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit);
1092
1093 print '<table class="noborder centpercent">'."\n";
1094 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1095
1096 if (count($objects) > 0) {
1097 $i = 0;
1098 foreach ($objects as $key => $project) {
1099 $i++;
1100 if ($i > $limit) {
1101 break;
1102 }
1103
1104 print "\t".'<tr class="oddeven">'."\n";
1105 print '<td class="nowrap tdtop">';
1106 print $project->getNomUrl(1);
1107 print "</td>\n";
1108 print '<td class="tdtop">'.$project->ref."</td>\n";
1109 print '<td class="tdtop">'.$project->title."</td>\n";
1110 // Link to delete from category
1111 print '<td class="right">';
1112 if ($permission) {
1113 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$project->id."'>";
1114 print $langs->trans("DeleteFromCat");
1115 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1116 print "</a>";
1117 }
1118 print '</td>';
1119 print "</tr>\n";
1120 }
1121 } else {
1122 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1123 }
1124 print "</table>\n";
1125
1126 print '</form>'."\n";
1127 }
1128 } else {
1129 print_barre_liste($langs->trans("Project"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'project');
1130 accessforbidden("NotEnoughPermissions", 0, 0);
1131 }
1132}
1133
1134// List of users
1135if ($type == Categorie::TYPE_USER) {
1136 if ($user->hasRight("user", "user", "read")) {
1137 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
1138
1139 $users = $object->getObjectsInCateg($type);
1140 if ($users < 0) {
1141 dol_print_error($db, $object->error, $object->errors);
1142 } else {
1144 '@phan-var-force User[] $users';
1145 // Form to add record into a category
1146 $showclassifyform = 1;
1147 if ($showclassifyform) {
1148 print '<br>';
1149 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1150 print '<input type="hidden" name="token" value="'.newToken().'">';
1151 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1152 print '<input type="hidden" name="type" value="'.$typeid.'">';
1153 print '<input type="hidden" name="id" value="'.$object->id.'">';
1154 print '<input type="hidden" name="action" value="addintocategory">';
1155 print '<table class="noborder centpercent">';
1156 print '<tr class="liste_titre"><td>';
1157 $force_entity = getEntity($object->element); // So we will get same filter than the getObjectsInCateg()
1158 print img_picto('', $type, 'class="pictofixedwidth"');
1159 print $form->select_dolusers('', 'elemid', 1, null, 0, '', '', $force_entity);
1160 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1161 print '</tr>';
1162 print '</table>';
1163 print '</form>';
1164 }
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="action" value="list">';
1171
1172 print '<br>';
1173
1174 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1175 $num = count($users);
1176 $nbtotalofrecords = '';
1177 $newcardbutton = '';
1178
1179 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1180 print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, '', '', $limit);
1181
1182 print '<table class="noborder centpercent">'."\n";
1183 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Users").' <span class="badge">'.$num.'</span></td></tr>'."\n";
1184
1185 if (count($users) > 0) {
1186 // Use "$userentry" here, because "$user" is the current user
1187 foreach ($users as $key => $userentry) {
1188 print "\t".'<tr class="oddeven">'."\n";
1189 print '<td class="nowrap tdtop">';
1190 print $userentry->getNomUrl(-1);
1191 print "</td>\n";
1192 print '<td class="tdtop">'.$userentry->job."</td>\n";
1193
1194 // Link to delete from category
1195 print '<td class="right">';
1196 if ($user->hasRight('user', 'user', 'creer')) {
1197 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$userentry->id."'>";
1198 print $langs->trans("DeleteFromCat");
1199 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1200 print "</a>";
1201 }
1202 print '</td>';
1203 print "</tr>\n";
1204 }
1205 } else {
1206 print '<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1207 }
1208 print "</table>\n";
1209
1210 print '</form>'."\n";
1211 }
1212 } else {
1213 print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'user');
1214 accessforbidden("NotEnoughPermissions", 0, 0);
1215 }
1216}
1217
1218
1219// List of warehouses
1220if ($type == Categorie::TYPE_WAREHOUSE) {
1221 if ($user->hasRight("stock", "read")) {
1222 $permission = $user->hasRight('stock', 'creer');
1223
1224 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
1225
1226 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1227 if ($objects < 0) {
1228 dol_print_error($db, $object->error, $object->errors);
1229 } else {
1231 '@phan-var-force Entrepot[] $objects';
1232 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1233 print '<input type="hidden" name="token" value="'.newToken().'">';
1234 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1235 print '<input type="hidden" name="type" value="'.$typeid.'">';
1236 print '<input type="hidden" name="id" value="'.$object->id.'">';
1237 print '<input type="hidden" name="action" value="list">';
1238
1239 print '<br>';
1240 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1241 $num = count($objects);
1242 $nbtotalofrecords = '';
1243 $newcardbutton = '';
1244
1245 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1246 print_barre_liste($langs->trans("Warehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit);
1247
1248 print '<table class="noborder centpercent">'."\n";
1249 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1250
1251 if (count($objects) > 0) {
1252 $i = 0;
1253 foreach ($objects as $key => $warehouse) {
1254 $i++;
1255 if ($i > $limit) {
1256 break;
1257 }
1258
1259 print "\t".'<tr class="oddeven">'."\n";
1260 print '<td class="nowrap tdtop">';
1261 print $warehouse->getNomUrl(1);
1262 print "</td>\n";
1263 print '<td class="tdtop">'.$warehouse->ref."</td>\n";
1264 print '<td class="tdtop">'.$warehouse->lieu."</td>\n";
1265 // Link to delete from category
1266 print '<td class="right">';
1267 if ($permission) {
1268 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$warehouse->id."'>";
1269 print $langs->trans("DeleteFromCat");
1270 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1271 print "</a>";
1272 }
1273 print '</td>';
1274 print "</tr>\n";
1275 }
1276 } else {
1277 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1278 }
1279 print "</table>\n";
1280
1281 print '</form>'."\n";
1282 }
1283 } else {
1284 print_barre_liste($langs->trans("Warehouse"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'stock');
1285 accessforbidden("NotEnoughPermissions", 0, 0);
1286 }
1287}
1288
1289// List of tickets
1290if ($type == Categorie::TYPE_TICKET) {
1291 if ($user->hasRight("ticket", "read")) {
1292 $permission = $user->hasRight('categorie', 'creer');
1293
1294 $tickets = $object->getObjectsInCateg($type, 0, $limit, $offset);
1295 if ($tickets < 0) {
1296 dol_print_error($db, $object->error, $object->errors);
1297 } else {
1299 '@phan-var-force Ticket[] $tickets';
1300 // Form to add record into a category
1301 $showclassifyform = 1;
1302 if ($showclassifyform) {
1303 print '<br>';
1304 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1305 print '<input type="hidden" name="token" value="'.newToken().'">';
1306 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1307 print '<input type="hidden" name="type" value="'.$typeid.'">';
1308 print '<input type="hidden" name="id" value="'.$object->id.'">';
1309 print '<input type="hidden" name="action" value="addintocategory">';
1310 print '<table class="noborder centpercent">';
1311 print '<tr class="liste_titre"><td>';
1312 print $langs->trans("AddTicketIntoCategory").' &nbsp;';
1313 $form->selectTickets('', 'elemid');
1314 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1315 print '</tr>';
1316 print '</table>';
1317 print '</form>';
1318 }
1319
1320 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1321 print '<input type="hidden" name="token" value="'.newToken().'">';
1322 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1323 print '<input type="hidden" name="type" value="'.$typeid.'">';
1324 print '<input type="hidden" name="id" value="'.$object->id.'">';
1325 print '<input type="hidden" name="action" value="list">';
1326
1327 print '<br>';
1328 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1329 $num = count($tickets);
1330 $nbtotalofrecords = '';
1331 $newcardbutton = '';
1332
1333 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1334 print_barre_liste($langs->trans("Ticket"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'ticket', 0, $newcardbutton, '', $limit);
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->label."</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=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$ticket->id."'>";
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// Note that $action and $object may have been modified by some hooks
1378$parameters = array('type' => $type, 'id' => $id, 'label' => $label);
1379$reshook = $hookmanager->executeHooks('addMoreCategoriesList', $parameters, $object, $action);
1380
1381// End of page
1382llxFooter();
1383$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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:70
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 contact/addresses.
Class to manage standard extra fields.
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.
llxFooter()
Footer empty.
Definition document.php:107
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_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
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'.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
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.
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.