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