30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/categories.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37 $langs->load(
"categories");
40 $label =
GETPOST(
'label',
'alpha');
41 $removeelem =
GETPOST(
'removeelem',
'int');
42 $elemid =
GETPOST(
'elemid',
'int');
44 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
45 $massaction =
GETPOST(
'massaction',
'alpha');
46 $show_files =
GETPOST(
'show_files',
'int');
47 $confirm =
GETPOST(
'confirm',
'alpha');
48 $cancel =
GETPOST(
'cancel',
'alpha');
49 $toselect =
GETPOST(
'toselect',
'array');
50 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'categorylist';
51 $backtopage =
GETPOST(
'backtopage',
'alpha');
52 $optioncss =
GETPOST(
'optioncss',
'aZ');
56 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
57 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
58 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
60 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
63 $offset = $limit * $page;
64 $pageprev = $page - 1;
65 $pagenext = $page + 1;
67 if ($id ==
"" && $label ==
"") {
76 $result = $object->fetch($id, $label);
81 $type = $object->type;
82 if (is_numeric($type)) {
83 $type = Categorie::$MAP_ID_TO_CODE[$type];
87 $extrafields->fetch_name_optionals_label($object->table_element);
90 $hookmanager->initHooks(array(
'categorycard',
'globalcard'));
96 if ($confirm ==
'no') {
98 header(
"Location: ".$backtopage);
103 $parameters = array();
104 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
106 if ($id > 0 && $removeelem > 0) {
107 if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) {
108 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
110 $result = $tmpobject->fetch($removeelem);
111 $elementtype =
'product';
112 } elseif ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) {
114 $result = $tmpobject->fetch($removeelem);
115 $elementtype =
'supplier';
116 } elseif ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) {
118 $result = $tmpobject->fetch($removeelem);
119 $elementtype =
'customer';
120 } elseif ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) {
121 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
123 $result = $tmpobject->fetch($removeelem);
124 $elementtype =
'member';
125 } elseif ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) {
126 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
128 $result = $tmpobject->fetch($removeelem);
129 $elementtype =
'contact';
130 } elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) {
131 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
133 $result = $tmpobject->fetch($removeelem);
134 $elementtype =
'account';
135 } elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) {
136 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
138 $result = $tmpobject->fetch($removeelem);
139 $elementtype =
'project';
140 } elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) {
141 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
142 $tmpobject =
new User($db);
143 $result = $tmpobject->fetch($removeelem);
144 $elementtype =
'user';
145 } elseif ($type == Categorie::TYPE_TICKET && $user->rights->ticket->write) {
146 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
147 $tmpobject =
new Ticket($db);
148 $result = $tmpobject->fetch($removeelem);
149 $elementtype =
'ticket';
152 $result = $object->del_type($tmpobject, $elementtype);
158 if ($user->rights->categorie->supprimer && $action ==
'confirm_delete' && $confirm ==
'yes') {
159 if ($object->delete($user) >= 0) {
161 header(
"Location: ".$backtopage);
164 header(
"Location: ".DOL_URL_ROOT.
'/categories/index.php?type='.$type);
172 if ($elemid && $action ==
'addintocategory' &&
173 (($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) ||
174 ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) ||
175 ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) ||
176 ($type == Categorie::TYPE_TICKET && $user->rights->ticket->write) ||
177 ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) ||
178 ($type == Categorie::TYPE_MEMBER && $user->rights->projet->creer) ||
179 ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) ||
180 ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) ||
181 ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer)
183 if ($type == Categorie::TYPE_PRODUCT) {
184 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
186 $elementtype =
'product';
187 } elseif ($type == Categorie::TYPE_CUSTOMER) {
188 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
190 $elementtype =
'customer';
191 } elseif ($type == Categorie::TYPE_SUPPLIER) {
192 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
194 $elementtype =
'supplier';
195 } elseif ($type == Categorie::TYPE_TICKET) {
196 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
197 $newobject =
new Ticket($db);
198 $elementtype =
'ticket';
199 } elseif ($type == Categorie::TYPE_PROJECT) {
200 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
202 $elementtype =
'project';
203 } elseif ($type == Categorie::TYPE_MEMBER) {
204 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
206 $elementtype =
'member';
207 } elseif ($type == Categorie::TYPE_CONTACT) {
208 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
210 $elementtype =
'contact';
211 } elseif ($type == Categorie::TYPE_USER) {
212 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
213 $newobject =
new User($db);
214 $elementtype =
'user';
215 } elseif ($type == Categorie::TYPE_ACCOUNT) {
216 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
217 $newobject =
new User($db);
218 $elementtype =
'bank_account';
220 $result = $newobject->fetch($elemid);
223 $result = $object->add_type($newobject, $elementtype);
225 setEventMessages($langs->trans(
"WasAddedSuccessfully", $newobject->ref),
null,
'mesgs');
227 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
228 setEventMessages($langs->trans(
"ObjectAlreadyLinkedToCategory"),
null,
'warnings');
243 $arrayofjs = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
'/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
244 $arrayofcss = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
248 llxHeader(
"", $langs->trans(
"Categories"),
$help_url,
'', 0, 0, $arrayofjs, $arrayofcss);
250 $title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
255 $backtolist = (
GETPOST(
'backtolist') ?
GETPOST(
'backtolist') : DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.urlencode($type));
256 $linkback =
'<a href="'.dol_sanitizeUrl($backtolist).
'">'.$langs->trans(
"BackToList").
'</a>';
257 $object->next_prev_filter =
' type = '.$object->type;
258 $object->ref = $object->label;
259 $morehtmlref =
'<br><div class="refidno"><a href="'.DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.urlencode($type).
'">'.$langs->trans(
"Root").
'</a> >> ';
260 $ways = $object->print_all_ways(
" >> ",
'', 1);
261 foreach ($ways as $way) {
262 $morehtmlref .= $way.
"<br>\n";
264 $morehtmlref .=
'</div>';
266 dol_banner_tab($object,
'label', $linkback, ($user->socid ? 0 : 1),
'label',
'label', $morehtmlref,
'&type='.urlencode($type), 0,
'',
'', 1);
273 if ($action ==
'delete') {
275 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&type='.$type.
'&backtopage='.urlencode($backtopage), $langs->trans(
'DeleteCategory'), $langs->trans(
'ConfirmDeleteCategory'),
'confirm_delete',
'',
'', 2);
277 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&type='.$type, $langs->trans(
'DeleteCategory'), $langs->trans(
'ConfirmDeleteCategory'),
'confirm_delete',
'',
'', 1);
283 print
'<div class="fichecenter">';
284 print
'<div class="underbanner clearboth"></div>';
285 print
'<table class="border centpercent tableforfield">';
288 print
'<tr><td class="titlefield notopnoleft tdtop">';
289 print $langs->trans(
"Description").
'</td><td>';
294 print
'<tr><td class="notopnoleft">';
295 print $langs->trans(
"Color").
'</td><td>';
296 print $formother->showColor($object->color);
300 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
312 print
"<div class='tabsAction'>\n";
313 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
317 if (empty($reshook)) {
318 if ($user->rights->categorie->creer) {
319 $socid = ($object->socid ?
"&socid=".$object->socid :
"");
320 print
'<a class="butAction" href="edit.php?id='.$object->id.$socid.
'&type='.$type.
'">'.$langs->trans(
"Modify").
'</a>';
323 if ($user->rights->categorie->supprimer) {
324 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id.
'&type='.$type.
'&backtolist='.urlencode($backtolist).
'">'.$langs->trans(
"Delete").
'</a>';
331 if (!empty($user->rights->categorie->creer)) {
332 $link = DOL_URL_ROOT.
'/categories/card.php';
333 $link .=
'?action=create';
334 $link .=
'&type='.$type;
335 $link .=
'&catorigin='.$object->id;
336 $link .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?type='.$type.
'&id='.$id);
338 $newcardbutton =
'<div class="right">';
339 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewCategory'),
'',
'fa fa-plus-circle', $link);
340 $newcardbutton .=
'</div>';
348 print
'<div class="fichecenter">';
350 print
load_fiche_titre($langs->trans(
"SubCats"), $newcardbutton,
'object_category');
353 print
'<table class="liste nohover" width="100%">';
355 print
'<tr class="liste_titre">';
356 print
'<td>'.$langs->trans(
"SubCats").
'</td>';
358 print
'<td class="right">';
360 if (!empty($conf->use_javascript_ajax)) {
361 print
'<div id="iddivjstreecontrol">';
362 print
'<a class="notasortlink" href="#">'.img_picto(
'',
'folder').
' '.$langs->trans(
"UndoExpandAll").
'</a>';
364 print
'<a class="notasortlink" href="#">'.img_picto(
'',
'folder-open').
' '.$langs->trans(
"ExpandAll").
'</a>';
371 $cats = $object->get_filles();
374 } elseif (count($cats) < 1) {
375 print
'<tr class="oddeven">';
376 print
'<td colspan="3" class="opacitymedium">'.$langs->trans(
"NoSubCat").
'</td>';
381 $fulltree = $categstatic->get_full_arbo($type, $object->id, 1);
385 if ($type == Categorie::TYPE_MEMBER) {
386 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
388 if ($type == Categorie::TYPE_ACCOUNT) {
389 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
391 if ($type == Categorie::TYPE_PROJECT) {
392 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
394 if ($type == Categorie::TYPE_USER) {
395 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
401 $data[] = array(
'rowid'=>0,
'fk_menu'=>-1,
'title'=>
"racine",
'mainmenu'=>
'',
'leftmenu'=>
'',
'fk_mainmenu'=>
'',
'fk_leftmenu'=>
'');
402 foreach ($fulltree as $key => $val) {
403 $categstatic->id = $val[
'id'];
404 $categstatic->ref = $val[
'label'];
405 $categstatic->color = $val[
'color'];
406 $categstatic->type = $type;
412 $elements = $categstatic->getObjectsInCateg($type, 1);
414 $counter =
"<td class='left' width='40px;'>".(is_array($elements) ? count($elements) :
'0').
"</td>";
417 $color = $categstatic->color ?
' style="background: #'.sprintf(
"%06s", $categstatic->color).
';"' :
' style="background: #bbb"';
418 $li = $categstatic->getNomUrl(1,
'', 60,
'&backtolist='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$id.
'&type='.$type));
420 $entry =
'<table class="nobordernopadding centpercent">';
424 $entry .=
'<span class="noborderoncategories" '.$color.
'>'.$li.
'</span>';
429 $entry .=
'<td class="right" width="20px;">';
430 $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>';
432 $entry .=
'<td class="right" width="20px;">';
433 $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>';
435 $entry .=
'<td class="right" width="20px;">';
436 $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 .=
'</table>';
442 $data[] = array(
'rowid' => $val[
'rowid'],
'fk_menu' => $val[
'fk_parent'],
'entry' => $entry);
445 $nbofentries = (count($data) - 1);
446 if ($nbofentries > 0) {
447 require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
448 print
'<tr class="pair">';
449 print
'<td colspan="3">';
457 print
'<tr class="pair">';
458 print
'<td colspan="3">';
459 print
'<table class="nobordernopadding">';
461 print
'<tr class="nobordernopadding">';
462 print
'<td>'.img_picto_common(
'',
'treemenu/branchbottom.gif').
'</td>';
463 print
'<td valign="middle">'.$langs->trans(
"NoCategoryYet").
'</td>';
464 print
'<td> </td>';
477 $arrayofmassactions = array(
483 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
489 if ($type == Categorie::TYPE_PRODUCT) {
490 $permission = ($user->rights->produit->creer || $user->rights->service->creer);
492 $prods = $object->getObjectsInCateg($type, 0, $limit, $offset);
497 $showclassifyform = 1;
498 if ($showclassifyform) {
500 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
501 print
'<input type="hidden" name="token" value="'.newToken().
'">';
502 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
503 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
504 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
505 print
'<input type="hidden" name="action" value="addintocategory">';
506 print
'<table class="noborder centpercent">';
507 print
'<tr class="liste_titre"><td>';
508 print $langs->trans(
"AddProductServiceIntoCategory").
' ';
509 $form->select_produits(
'',
'elemid',
'', 0, 0, -1, 2,
'', 1);
510 print
'<input type="submit" class="button buttongen" value="'.$langs->trans(
"ClassifyInCategory").
'"></td>';
516 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
517 print
'<input type="hidden" name="token" value="'.newToken().
'">';
518 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
519 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
520 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
521 print
'<input type="hidden" name="action" value="list">';
524 $param =
'&limit='.$limit.
'&id='.$id.
'&type='.$type; $num = count($prods); $nbtotalofrecords =
''; $newcardbutton =
'';
525 print_barre_liste($langs->trans(
"ProductsAndServices"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'products', 0, $newcardbutton,
'', $limit);
528 print
'<table class="noborder centpercent">'.
"\n";
529 print
'<tr class="liste_titre"><td colspan="3">'.$langs->trans(
"Ref").
'</td></tr>'.
"\n";
531 if (count($prods) > 0) {
533 foreach ($prods as $prod) {
539 print
"\t".
'<tr class="oddeven">'.
"\n";
540 print
'<td class="nowrap" valign="top">';
541 print $prod->getNomUrl(1);
543 print
'<td class="tdtop">'.$prod->label.
"</td>\n";
545 print
'<td class="right">';
547 print
"<a href= '".$_SERVER[
'PHP_SELF'].
"?".(empty($socid) ?
'id' :
'socid').
"=".$object->id.
"&type=".$typeid.
"&removeelem=".$prod->id.
"'>";
548 print $langs->trans(
"DeleteFromCat");
549 print
img_picto($langs->trans(
"DeleteFromCat"),
'unlink',
'',
false, 0, 0,
'',
'paddingleft');
556 print
'<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans(
"ThisCategoryHasNoItems").
'</td></tr>';
560 print
'</form>'.
"\n";
565 if ($type == Categorie::TYPE_CUSTOMER) {
566 $permission = $user->rights->societe->creer;
568 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset);
573 $showclassifyform = 1;
574 if ($showclassifyform) {
576 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
577 print
'<input type="hidden" name="token" value="'.newToken().
'">';
578 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
579 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
580 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
581 print
'<input type="hidden" name="action" value="addintocategory">';
582 print
'<table class="noborder centpercent">';
583 print
'<tr class="liste_titre"><td>';
584 print $langs->trans(
"AddCustomerIntoCategory").
' ';
585 print
$form->select_company(
'',
'elemid',
's.client IN (1,3)');
586 print
'<input type="submit" class="button buttongen" value="'.$langs->trans(
"ClassifyInCategory").
'"></td>';
592 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
593 print
'<input type="hidden" name="token" value="'.newToken().
'">';
594 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
595 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
596 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
597 print
'<input type="hidden" name="action" value="list">';
600 $param =
'&limit='.$limit.
'&id='.$id.
'&type='.$type; $num = count($socs); $nbtotalofrecords =
''; $newcardbutton =
'';
601 print_barre_liste($langs->trans(
"Customers"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'companies', 0, $newcardbutton,
'', $limit);
603 print
'<table class="noborder centpercent">'.
"\n";
604 print
'<tr class="liste_titre"><td colspan="2">'.$langs->trans(
"Name").
'</td></tr>'.
"\n";
606 if (count($socs) > 0) {
608 foreach ($socs as $key => $soc) {
614 print
"\t".
'<tr class="oddeven">'.
"\n";
615 print
'<td class="nowrap" valign="top">';
616 print $soc->getNomUrl(1);
619 print
'<td class="right">';
621 print
"<a href= '".$_SERVER[
'PHP_SELF'].
"?".(empty($socid) ?
'id' :
'socid').
"=".$object->id.
"&type=".$typeid.
"&removeelem=".$soc->id.
"'>";
622 print $langs->trans(
"DeleteFromCat");
623 print
img_picto($langs->trans(
"DeleteFromCat"),
'unlink',
'',
false, 0, 0,
'',
'paddingleft');
630 print
'<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans(
"ThisCategoryHasNoItems").
'</td></tr>';
634 print
'</form>'.
"\n";
639 if ($type == Categorie::TYPE_SUPPLIER) {
640 $permission = $user->rights->societe->creer;
642 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset);
647 $showclassifyform = 1;
648 if ($showclassifyform) {
650 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
651 print
'<input type="hidden" name="token" value="'.newToken().
'">';
652 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
653 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
654 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
655 print
'<input type="hidden" name="action" value="addintocategory">';
656 print
'<table class="noborder centpercent">';
657 print
'<tr class="liste_titre"><td>';
658 print $langs->trans(
"AddSupplierIntoCategory").
' ';
659 print
$form->select_company(
'',
'elemid',
's.fournisseur = 1');
660 print
'<input type="submit" class="button buttongen" value="'.$langs->trans(
"ClassifyInCategory").
'"></td>';
666 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
667 print
'<input type="hidden" name="token" value="'.newToken().
'">';
668 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
669 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
670 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
671 print
'<input type="hidden" name="action" value="list">';
674 $param =
'&limit='.$limit.
'&id='.$id.
'&type='.$type; $num = count($socs); $nbtotalofrecords =
''; $newcardbutton =
'';
675 print_barre_liste($langs->trans(
"Suppliers"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'companies', 0, $newcardbutton,
'', $limit);
677 print
'<table class="noborder centpercent">'.
"\n";
678 print
'<tr class="liste_titre"><td colspan="2">'.$langs->trans(
"Name").
"</td></tr>\n";
680 if (count($socs) > 0) {
682 foreach ($socs as $soc) {
688 print
"\t".
'<tr class="oddeven">'.
"\n";
689 print
'<td class="nowrap" valign="top">';
690 print $soc->getNomUrl(1);
693 print
'<td class="right">';
695 print
"<a href= '".$_SERVER[
'PHP_SELF'].
"?".(empty($socid) ?
'id' :
'socid').
"=".$object->id.
"&type=".$typeid.
"&removeelem=".$soc->id.
"'>";
696 print $langs->trans(
"DeleteFromCat");
697 print
img_picto($langs->trans(
"DeleteFromCat"),
'unlink',
'',
false, 0, 0,
'',
'paddingleft');
705 print
'<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans(
"ThisCategoryHasNoItems").
'</td></tr>';
709 print
'</form>'.
"\n";
714 if ($type == Categorie::TYPE_MEMBER) {
715 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
717 $permission = $user->rights->adherent->creer;
719 $prods = $object->getObjectsInCateg($type, 0, $limit, $offset);
724 $showclassifyform = 1;
725 if ($showclassifyform) {
727 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
728 print
'<input type="hidden" name="token" value="'.newToken().
'">';
729 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
730 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
731 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
732 print
'<input type="hidden" name="action" value="addintocategory">';
733 print
'<table class="noborder centpercent">';
734 print
'<tr class="liste_titre"><td>';
735 print $langs->trans(
"AssignCategoryTo").
' ';
736 print
$form->selectMembers(
'',
'elemid');
737 print
'<input type="submit" class="button buttongen" value="'.$langs->trans(
"Save").
'"></td>';
743 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
744 print
'<input type="hidden" name="token" value="'.newToken().
'">';
745 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
746 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
747 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
748 print
'<input type="hidden" name="action" value="list">';
751 $param =
'&limit='.$limit.
'&id='.$id.
'&type='.$type; $num = count($prods); $nbtotalofrecords =
''; $newcardbutton =
'';
752 print_barre_liste($langs->trans(
"Member"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'members', 0, $newcardbutton,
'', $limit);
754 print
"<table class='noborder' width='100%'>\n";
755 print
'<tr class="liste_titre"><td colspan="4">'.$langs->trans(
"Name").
'</td></tr>'.
"\n";
757 if (count($prods) > 0) {
759 foreach ($prods as $key => $member) {
765 print
"\t".
'<tr class="oddeven">'.
"\n";
766 print
'<td class="nowrap" valign="top">';
767 $member->ref = $member->login;
768 print $member->getNomUrl(1, 0);
770 print
'<td class="tdtop">'.$member->lastname.
"</td>\n";
771 print
'<td class="tdtop">'.$member->firstname.
"</td>\n";
773 print
'<td class="right">';
775 print
"<a href= '".$_SERVER[
'PHP_SELF'].
"?".(empty($socid) ?
'id' :
'socid').
"=".$object->id.
"&type=".$typeid.
"&removeelem=".$member->id.
"'>";
776 print $langs->trans(
"DeleteFromCat");
777 print
img_picto($langs->trans(
"DeleteFromCat"),
'unlink',
'',
false, 0, 0,
'',
'paddingleft');
783 print
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"ThisCategoryHasNoItems").
'</td></tr>';
787 print
'</form>'.
"\n";
792 if ($type == Categorie::TYPE_CONTACT) {
793 $permission = $user->rights->societe->creer;
795 $contacts = $object->getObjectsInCateg($type, 0, $limit, $offset);
796 if (is_numeric($contacts) && $contacts < 0) {
800 $showclassifyform = 1;
801 if ($showclassifyform) {
803 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
804 print
'<input type="hidden" name="token" value="'.newToken().
'">';
805 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
806 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
807 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
808 print
'<input type="hidden" name="action" value="addintocategory">';
809 print
'<table class="noborder centpercent">';
810 print
'<tr class="liste_titre"><td>';
811 print $langs->trans(
"AddContactIntoCategory").
' ';
812 print
$form->selectContacts(
'',
'',
'elemid');
813 print
'<input type="submit" class="button buttongen" value="'.$langs->trans(
"ClassifyInCategory").
'"></td>';
818 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
819 print
'<input type="hidden" name="token" value="'.newToken().
'">';
820 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
821 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
822 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
823 print
'<input type="hidden" name="action" value="list">';
826 $param =
'&limit='.$limit.
'&id='.$id.
'&type='.$type;
827 $num = count($contacts);
828 $nbtotalofrecords =
'';
831 print_barre_liste($langs->trans(
"Contact"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'contact', 0, $newcardbutton,
'', $limit);
833 print
'<table class="noborder centpercent">'.
"\n";
834 print
'<tr class="liste_titre"><td colspan="2">'.$langs->trans(
"Ref").
'</td></tr>'.
"\n";
836 if (is_array($contacts) && count($contacts) > 0) {
838 foreach ($contacts as $key => $contact) {
844 print
"\t".
'<tr class="oddeven">'.
"\n";
845 print
'<td class="nowrap" valign="top">';
846 print $contact->getNomUrl(1,
'category');
847 if ($contact->socid > 0) {
848 $objsoc->fetch($contact->socid);
850 print $objsoc->getNomUrl(1,
'contact');
854 print
'<td class="right">';
856 print
"<a href= '".$_SERVER[
'PHP_SELF'].
"?".(empty($socid) ?
'id' :
'socid').
"=".$object->id.
"&type=".$typeid.
"&removeelem=".$contact->id.
"'>";
857 print $langs->trans(
"DeleteFromCat");
858 print
img_picto($langs->trans(
"DeleteFromCat"),
'unlink',
'',
false, 0, 0,
'',
'paddingleft');
865 print
'<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans(
"ThisCategoryHasNoItems").
'</td></tr>';
869 print
'</form>'.
"\n";
874 if ($type == Categorie::TYPE_ACCOUNT) {
875 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
877 $permission = $user->rights->banque->creer;
879 $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset);
884 $showclassifyform = 1;
885 if ($showclassifyform) {
887 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
888 print
'<input type="hidden" name="token" value="'.newToken().
'">';
889 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
890 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
891 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
892 print
'<input type="hidden" name="action" value="addintocategory">';
893 print
'<table class="noborder centpercent">';
894 print
'<tr class="liste_titre"><td>';
895 print $langs->trans(
"AddAccountIntoCategory").
' ';
896 $form->select_comptes(
'',
'elemid');
897 print
'<input type="submit" class="button buttongen" value="'.$langs->trans(
"ClassifyInCategory").
'"></td>';
903 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
904 print
'<input type="hidden" name="token" value="'.newToken().
'">';
905 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
906 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
907 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
908 print
'<input type="hidden" name="action" value="list">';
911 $param =
'&limit='.$limit.
'&id='.$id.
'&type='.$type; $num = count($accounts); $nbtotalofrecords =
''; $newcardbutton =
'';
912 print_barre_liste($langs->trans(
"Account"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bank_account', 0, $newcardbutton,
'', $limit);
914 print
"<table class='noborder' width='100%'>\n";
915 print
'<tr class="liste_titre"><td colspan="4">'.$langs->trans(
"Ref").
'</td></tr>'.
"\n";
917 if (count($accounts) > 0) {
919 foreach ($accounts as $key => $account) {
925 print
"\t".
'<tr class="oddeven">'.
"\n";
926 print
'<td class="nowrap" valign="top">';
927 print $account->getNomUrl(1, 0);
929 print
'<td class="tdtop">'.$account->bank.
"</td>\n";
930 print
'<td class="tdtop">'.$account->number.
"</td>\n";
932 print
'<td class="right">';
934 print
"<a href= '".$_SERVER[
'PHP_SELF'].
"?".(empty($socid) ?
'id' :
'socid').
"=".$object->id.
"&type=".$typeid.
"&removeelem=".$account->id.
"'>";
935 print $langs->trans(
"DeleteFromCat");
936 print
img_picto($langs->trans(
"DeleteFromCat"),
'unlink',
'',
false, 0, 0,
'',
'paddingleft');
942 print
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"ThisCategoryHasNoItems").
'</td></tr>';
946 print
'</form>'.
"\n";
951 if ($type == Categorie::TYPE_PROJECT) {
952 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
954 $permission = $user->rights->projet->creer;
956 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
961 $showclassifyform = 1;
962 if ($showclassifyform) {
964 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
965 print
'<input type="hidden" name="token" value="'.newToken().
'">';
966 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
967 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
968 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
969 print
'<input type="hidden" name="action" value="addintocategory">';
970 print
'<table class="noborder centpercent">';
971 print
'<tr class="liste_titre"><td>';
972 print $langs->trans(
"AddProjectIntoCategory").
' ';
973 $form->selectProjects(
'',
'elemid');
974 print
'<input type="submit" class="button buttongen" value="'.$langs->trans(
"ClassifyInCategory").
'"></td>';
980 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
981 print
'<input type="hidden" name="token" value="'.newToken().
'">';
982 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
983 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
984 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
985 print
'<input type="hidden" name="action" value="list">';
988 $param =
'&limit='.$limit.
'&id='.$id.
'&type='.$type; $num = count($objects); $nbtotalofrecords =
''; $newcardbutton =
'';
990 print_barre_liste($langs->trans(
"Project"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'project', 0, $newcardbutton,
'', $limit);
992 print
"<table class='noborder' width='100%'>\n";
993 print
'<tr class="liste_titre"><td colspan="4">'.$langs->trans(
"Ref").
'</td></tr>'.
"\n";
995 if (count($objects) > 0) {
997 foreach ($objects as $key => $project) {
1003 print
"\t".
'<tr class="oddeven">'.
"\n";
1004 print
'<td class="nowrap" valign="top">';
1005 print $project->getNomUrl(1);
1007 print
'<td class="tdtop">'.$project->ref.
"</td>\n";
1008 print
'<td class="tdtop">'.$project->title.
"</td>\n";
1010 print
'<td class="right">';
1012 print
"<a href= '".$_SERVER[
'PHP_SELF'].
"?".(empty($socid) ?
'id' :
'socid').
"=".$object->id.
"&type=".$typeid.
"&removeelem=".$project->id.
"'>";
1013 print $langs->trans(
"DeleteFromCat");
1014 print
img_picto($langs->trans(
"DeleteFromCat"),
'unlink',
'',
false, 0, 0,
'',
'paddingleft');
1020 print
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"ThisCategoryHasNoItems").
'</td></tr>';
1024 print
'</form>'.
"\n";
1029 if ($type == Categorie::TYPE_USER) {
1030 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1032 $users = $object->getObjectsInCateg($type);
1037 $showclassifyform = 1;
1038 if ($showclassifyform) {
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="addintocategory">';
1046 print
'<table class="noborder centpercent">';
1047 print
'<tr class="liste_titre"><td>';
1048 print $langs->trans(
"AddObjectIntoCategory").
' ';
1049 print
$form->select_dolusers(
'',
'elemid');
1050 print
'<input type="submit" class="button buttongen" value="'.$langs->trans(
"ClassifyInCategory").
'"></td>';
1055 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
1056 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1057 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
1058 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
1059 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1060 print
'<input type="hidden" name="action" value="list">';
1064 $param =
'&limit='.$limit.
'&id='.$id.
'&type='.$type;
1065 $num = count($users);
1067 print_barre_liste($langs->trans(
"Users"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
'',
'user', 0,
'',
'', $limit);
1069 print
"<table class='noborder' width='100%'>\n";
1070 print
'<tr class="liste_titre"><td colspan="4">'.$langs->trans(
"Users").
' <span class="badge">'.$num.
'</span></td></tr>'.
"\n";
1072 if (count($users) > 0) {
1074 foreach ($users as $key => $userentry) {
1075 print
"\t".
'<tr class="oddeven">'.
"\n";
1076 print
'<td class="nowrap" valign="top">';
1077 print $userentry->getNomUrl(1);
1079 print
'<td class="tdtop">'.$userentry->job.
"</td>\n";
1082 print
'<td class="right">';
1083 if ($user->rights->user->user->creer) {
1084 print
"<a href= '".$_SERVER[
'PHP_SELF'].
"?".(empty($socid) ?
'id' :
'socid').
"=".$object->id.
"&type=".$type.
"&removeelem=".$userentry->id.
"'>";
1085 print $langs->trans(
"DeleteFromCat");
1086 print
img_picto($langs->trans(
"DeleteFromCat"),
'unlink',
'',
false, 0, 0,
'',
'paddingleft');
1092 print
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"ThisCategoryHasNoItems").
'</td></tr>';
1096 print
'</form>'.
"\n";
1102 if ($type == Categorie::TYPE_WAREHOUSE) {
1103 $permission = $user->rights->stock->creer;
1105 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
1107 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
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="list">';
1119 $param =
'&limit='.$limit.
'&id='.$id.
'&type='.$type; $num = count($objects); $nbtotalofrecords =
''; $newcardbutton =
'';
1121 print_barre_liste($langs->trans(
"Warehouses"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'stock', 0, $newcardbutton,
'', $limit);
1123 print
"<table class='noborder' width='100%'>\n";
1124 print
'<tr class="liste_titre"><td colspan="4">'.$langs->trans(
"Ref").
'</td></tr>'.
"\n";
1126 if (count($objects) > 0) {
1128 foreach ($objects as $key => $project) {
1134 print
"\t".
'<tr class="oddeven">'.
"\n";
1135 print
'<td class="nowrap" valign="top">';
1136 print $project->getNomUrl(1);
1138 print
'<td class="tdtop">'.$project->ref.
"</td>\n";
1139 print
'<td class="tdtop">'.$project->title.
"</td>\n";
1141 print
'<td class="right">';
1143 print
"<a href= '".$_SERVER[
'PHP_SELF'].
"?".(empty($socid) ?
'id' :
'socid').
"=".$object->id.
"&type=".$typeid.
"&removeelem=".$project->id.
"'>";
1144 print $langs->trans(
"DeleteFromCat");
1145 print
img_picto($langs->trans(
"DeleteFromCat"),
'unlink',
'',
false, 0, 0,
'',
'paddingleft');
1151 print
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"ThisCategoryHasNoItems").
'</td></tr>';
1155 print
'</form>'.
"\n";
1159 if ($type == Categorie::TYPE_TICKET) {
1160 $permission = ($user->rights->categorie->creer || $user->rights->categorie->creer);
1162 $tickets = $object->getObjectsInCateg($type, 0, $limit, $offset);
1167 $showclassifyform = 1;
1168 if ($showclassifyform) {
1170 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
1171 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1172 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
1173 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
1174 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1175 print
'<input type="hidden" name="action" value="addintocategory">';
1176 print
'<table class="noborder centpercent">';
1177 print
'<tr class="liste_titre"><td>';
1178 print $langs->trans(
"AddTicketIntoCategory").
' ';
1179 $form->selectTickets(
'',
'elemid');
1180 print
'<input type="submit" class="button buttongen" value="'.$langs->trans(
"ClassifyInCategory").
'"></td>';
1186 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
1187 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1188 print
'<input type="hidden" name="typeid" value="'.$typeid.
'">';
1189 print
'<input type="hidden" name="type" value="'.$typeid.
'">';
1190 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1191 print
'<input type="hidden" name="action" value="list">';
1194 $param =
'&limit='.$limit.
'&id='.$id.
'&type='.$type; $num = count($tickets); $nbtotalofrecords =
''; $newcardbutton =
'';
1195 print_barre_liste($langs->trans(
"Ticket"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'ticket', 0, $newcardbutton,
'', $limit);
1198 print
'<table class="noborder centpercent">'.
"\n";
1199 print
'<tr class="liste_titre"><td colspan="3">'.$langs->trans(
"Ref").
'</td></tr>'.
"\n";
1201 if (count($tickets) > 0) {
1203 foreach ($tickets as $ticket) {
1205 if ($i > $limit)
break;
1207 print
"\t".
'<tr class="oddeven">'.
"\n";
1208 print
'<td class="nowrap" valign="top">';
1209 print $ticket->getNomUrl(1);
1211 print
'<td class="tdtop">'.$ticket->label.
"</td>\n";
1213 print
'<td class="right">';
1215 print
"<a href= '".$_SERVER[
'PHP_SELF'].
"?".(empty($socid) ?
'id' :
'socid').
"=".$object->id.
"&type=".$typeid.
"&removeelem=".$ticket->id.
"'>";
1216 print $langs->trans(
"DeleteFromCat");
1217 print
img_picto($langs->trans(
"DeleteFromCat"),
'unlink',
'',
false, 0, 0,
'',
'paddingleft');
1224 print
'<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans(
"ThisCategoryHasNoItems").
'</td></tr>';
1228 print
'</form>'.
"\n";