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