2005-04-13 14:04:02 +02:00
< ? php
2015-05-23 18:52:31 +02:00
/* Copyright ( C ) 2005 Matthieu Valleton < mv @ seeschloss . org >
2020-04-02 15:11:46 +02:00
* Copyright ( C ) 2006 - 2020 Laurent Destailleur < eldy @ users . sourceforge . net >
2015-05-23 18:52:31 +02:00
* Copyright ( C ) 2007 Patrick Raguin < patrick . raguin @ gmail . com >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2015-05-23 18:52:31 +02:00
* Copyright ( C ) 2015 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2020-03-25 10:31:40 +01:00
* Copyright ( C ) 2020 Tobias Sekan < tobias . sekan @ startmail . com >
2020-10-22 16:12:01 +02:00
* Copyright ( C ) 2020 Josep Lluís Amador < joseplluis @ lliuretic . cat >
2005-04-13 14:04:02 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2005-04-13 14:04:02 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2005-04-13 14:04:02 +02:00
*/
2006-08-15 20:52:02 +02:00
/**
2009-07-22 19:02:49 +02:00
* \file htdocs / categories / viewcat . php
* \ingroup category
2010-03-20 01:07:47 +01:00
* \brief Page to show a category card
2009-07-22 19:02:49 +02:00
*/
2006-08-15 20:52:02 +02:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/categories.lib.php' ;
2014-03-16 16:04:18 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2015-09-17 19:51:56 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2014-03-16 16:04:18 +01:00
2018-05-27 09:58:23 +02:00
// Load translation files required by the page
2011-03-14 12:21:46 +01:00
$langs -> load ( " categories " );
2019-09-10 01:44:36 +02:00
$id = GETPOST ( 'id' , 'int' );
$label = GETPOST ( 'label' , 'alpha' );
2019-01-27 11:55:16 +01:00
$removeelem = GETPOST ( 'removeelem' , 'int' );
2019-09-06 15:20:04 +02:00
$elemid = GETPOST ( 'elemid' , 'int' );
2011-03-11 15:59:35 +01:00
2019-11-13 19:35:39 +01:00
$action = GETPOST ( 'action' , 'aZ09' ) ? GETPOST ( 'action' , 'aZ09' ) : 'view' ; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST ( 'massaction' , 'alpha' ); // The bulk action (combo box choice into lists)
$show_files = GETPOST ( 'show_files' , 'int' ); // Show files area generated by bulk actions ?
$confirm = GETPOST ( 'confirm' , 'alpha' ); // Result of a confirmation
$cancel = GETPOST ( 'cancel' , 'alpha' ); // We click on a Cancel button
$toselect = GETPOST ( 'toselect' , 'array' ); // Array of ids of elements selected into a list
2020-09-25 10:27:30 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'categorylist' ; // To manage different context of search
2019-11-13 19:35:39 +01:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' ); // Go back to a dedicated page
2021-02-23 18:04:37 +01:00
$optioncss = GETPOST ( 'optioncss' , 'aZ' ); // Option for the css output (always '' except when 'print')
2019-09-10 01:44:36 +02:00
2020-09-23 16:36:19 +02:00
2019-09-10 01:44:36 +02:00
// Load variable for pagination
2019-11-13 19:35:39 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2020-09-18 17:13:01 +02:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
2020-09-17 14:31:25 +02:00
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2021-02-23 18:04:37 +01:00
if ( empty ( $page ) || $page == - 1 || GETPOST ( 'button_search' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' ) || ( empty ( $toselect ) && $massaction === '0' )) {
$page = 0 ;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
2019-09-10 01:44:36 +02:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2021-02-23 18:04:37 +01:00
if ( $id == " " && $label == " " ) {
2019-01-27 11:55:16 +01:00
dol_print_error ( '' , 'Missing parameter id' );
2009-11-04 20:13:37 +01:00
exit ();
2006-03-30 17:02:24 +02:00
}
2011-08-20 11:02:56 +02:00
// Security check
2012-03-20 15:45:15 +01:00
$result = restrictedArea ( $user , 'categorie' , $id , '&category' );
2011-08-20 11:02:56 +02:00
2011-03-11 15:59:35 +01:00
$object = new Categorie ( $db );
2020-11-21 13:28:37 +01:00
$result = $object -> fetch ( $id , $label );
2018-02-21 14:48:25 +01:00
if ( $result <= 0 ) {
2019-01-27 11:55:16 +01:00
dol_print_error ( $db , $object -> error ); exit ;
2018-02-21 14:48:25 +01:00
}
2007-02-22 21:59:41 +01:00
2020-11-21 13:28:37 +01:00
$type = $object -> type ;
2021-02-23 18:04:37 +01:00
if ( is_numeric ( $type )) {
$type = Categorie :: $MAP_ID_TO_CODE [ $type ]; // For backward compatibility
}
2007-02-22 21:59:41 +01:00
2014-03-16 16:04:18 +01:00
$extrafields = new ExtraFields ( $db );
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2007-02-22 21:59:41 +01:00
2015-06-12 16:10:23 +02:00
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
2019-11-13 19:35:39 +01:00
$hookmanager -> initHooks ( array ( 'categorycard' , 'globalcard' ));
2015-06-12 16:10:23 +02:00
2007-02-22 21:59:41 +01:00
/*
2009-07-22 19:02:49 +02:00
* Actions
*/
2020-11-23 19:53:58 +01:00
2021-02-23 18:04:37 +01:00
if ( $confirm == 'no' ) {
2020-11-21 22:40:31 +01:00
if ( $backtopage ) {
header ( " Location: " . $backtopage );
exit ;
}
}
2019-11-13 19:35:39 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2013-06-05 16:24:32 +02:00
// Remove element from category
2021-02-23 18:04:37 +01:00
if ( $id > 0 && $removeelem > 0 ) {
if ( $type == Categorie :: TYPE_PRODUCT && ( $user -> rights -> produit -> creer || $user -> rights -> service -> creer )) {
2013-06-05 16:24:32 +02:00
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php' ;
$tmpobject = new Product ( $db );
$result = $tmpobject -> fetch ( $removeelem );
$elementtype = 'product' ;
2021-02-23 18:04:37 +01:00
} elseif ( $type == Categorie :: TYPE_SUPPLIER && $user -> rights -> societe -> creer ) {
2013-06-05 16:24:32 +02:00
$tmpobject = new Societe ( $db );
$result = $tmpobject -> fetch ( $removeelem );
2017-11-03 17:29:25 +01:00
$elementtype = 'supplier' ;
2021-02-23 18:04:37 +01:00
} elseif ( $type == Categorie :: TYPE_CUSTOMER && $user -> rights -> societe -> creer ) {
2013-06-05 16:24:32 +02:00
$tmpobject = new Societe ( $db );
$result = $tmpobject -> fetch ( $removeelem );
2017-11-03 17:29:25 +01:00
$elementtype = 'customer' ;
2021-02-23 18:04:37 +01:00
} elseif ( $type == Categorie :: TYPE_MEMBER && $user -> rights -> adherent -> creer ) {
2013-06-05 16:24:32 +02:00
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ;
$tmpobject = new Adherent ( $db );
$result = $tmpobject -> fetch ( $removeelem );
2013-04-21 23:44:33 +02:00
$elementtype = 'member' ;
2020-05-21 15:05:19 +02:00
} elseif ( $type == Categorie :: TYPE_CONTACT && $user -> rights -> societe -> creer ) {
2013-07-30 17:28:08 +02:00
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
$tmpobject = new Contact ( $db );
$result = $tmpobject -> fetch ( $removeelem );
$elementtype = 'contact' ;
2021-02-23 18:04:37 +01:00
} elseif ( $type == Categorie :: TYPE_ACCOUNT && $user -> rights -> banque -> configurer ) {
2020-10-31 14:32:18 +01:00
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
$tmpobject = new Account ( $db );
$result = $tmpobject -> fetch ( $removeelem );
$elementtype = 'account' ;
2021-02-23 18:04:37 +01:00
} elseif ( $type == Categorie :: TYPE_PROJECT && $user -> rights -> projet -> creer ) {
2020-10-31 14:32:18 +01:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
$tmpobject = new Project ( $db );
$result = $tmpobject -> fetch ( $removeelem );
$elementtype = 'project' ;
2021-02-23 18:04:37 +01:00
} elseif ( $type == Categorie :: TYPE_USER && $user -> rights -> user -> user -> creer ) {
2020-02-03 11:01:58 +01:00
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
$tmpobject = new User ( $db );
$result = $tmpobject -> fetch ( $removeelem );
$elementtype = 'user' ;
2021-07-01 19:30:00 +02:00
} elseif ( $type == Categorie :: TYPE_TICKET && $user -> rights -> ticket -> write ) {
require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php' ;
$tmpobject = new Ticket ( $db );
$result = $tmpobject -> fetch ( $removeelem );
$elementtype = 'ticket' ;
2020-02-03 11:01:58 +01:00
}
2014-01-12 15:54:28 +01:00
2019-11-13 19:35:39 +01:00
$result = $object -> del_type ( $tmpobject , $elementtype );
2021-02-23 18:04:37 +01:00
if ( $result < 0 ) {
dol_print_error ( '' , $object -> error );
}
2013-06-05 16:24:32 +02:00
}
2013-04-21 23:44:33 +02:00
2021-02-23 18:04:37 +01:00
if ( $user -> rights -> categorie -> supprimer && $action == 'confirm_delete' && $confirm == 'yes' ) {
if ( $object -> delete ( $user ) >= 0 ) {
2020-11-21 22:40:31 +01:00
if ( $backtopage ) {
header ( " Location: " . $backtopage );
exit ;
} else {
header ( " Location: " . DOL_URL_ROOT . '/categories/index.php?type=' . $type );
exit ;
}
2020-05-21 15:05:19 +02:00
} else {
2015-11-06 09:36:16 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2007-02-22 21:59:41 +01:00
}
2005-04-13 14:04:02 +02:00
}
2020-10-22 16:15:16 +02:00
if ( $elemid && $action == 'addintocategory' &&
2020-10-31 14:32:18 +01:00
(( $type == Categorie :: TYPE_PRODUCT && ( $user -> rights -> produit -> creer || $user -> rights -> service -> creer )) ||
( $type == Categorie :: TYPE_CUSTOMER && $user -> rights -> societe -> creer ) ||
2021-07-01 19:30:00 +02:00
( $type == Categorie :: TYPE_SUPPLIER && $user -> rights -> societe -> creer ) ||
2021-10-22 16:46:55 +02:00
( $type == Categorie :: TYPE_TICKET && $user -> rights -> ticket -> write ) ||
( $type == Categorie :: TYPE_PROJECT && $user -> rights -> projet -> creer ) ||
( $type == Categorie :: TYPE_MEMBER && $user -> rights -> projet -> creer ) ||
2021-10-22 16:54:31 +02:00
( $type == Categorie :: TYPE_CONTACT && $user -> rights -> societe -> creer ) ||
2021-10-22 17:15:51 +02:00
( $type == Categorie :: TYPE_USER && $user -> rights -> user -> user -> creer ) ||
( $type == Categorie :: TYPE_ACCOUNT && $user -> rights -> banque -> configurer )
2021-02-23 18:04:37 +01:00
)) {
if ( $type == Categorie :: TYPE_PRODUCT ) {
2020-10-22 16:12:01 +02:00
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php' ;
$newobject = new Product ( $db );
$elementtype = 'product' ;
2021-02-23 18:04:37 +01:00
} elseif ( $type == Categorie :: TYPE_CUSTOMER ) {
2020-10-22 16:12:01 +02:00
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php' ;
$newobject = new Societe ( $db );
$elementtype = 'customer' ;
2021-02-23 18:04:37 +01:00
} elseif ( $type == Categorie :: TYPE_SUPPLIER ) {
2020-10-22 16:12:01 +02:00
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php' ;
$newobject = new Societe ( $db );
$elementtype = 'supplier' ;
2021-07-01 19:30:00 +02:00
} elseif ( $type == Categorie :: TYPE_TICKET ) {
require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php' ;
$newobject = new Ticket ( $db );
$elementtype = 'ticket' ;
2021-10-22 15:48:39 +02:00
} elseif ( $type == Categorie :: TYPE_PROJECT ) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
$newobject = new Project ( $db );
$elementtype = 'project' ;
2021-10-22 16:13:54 +02:00
} elseif ( $type == Categorie :: TYPE_MEMBER ) {
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ;
$newobject = new Adherent ( $db );
$elementtype = 'member' ;
2021-10-22 16:46:55 +02:00
} elseif ( $type == Categorie :: TYPE_CONTACT ) {
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
$newobject = new Contact ( $db );
$elementtype = 'contact' ;
2021-10-22 16:54:31 +02:00
} elseif ( $type == Categorie :: TYPE_USER ) {
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
$newobject = new User ( $db );
$elementtype = 'user' ;
2021-10-22 17:15:51 +02:00
} elseif ( $type == Categorie :: TYPE_ACCOUNT ) {
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
$newobject = new User ( $db );
$elementtype = 'bank_account' ;
2020-10-22 16:12:01 +02:00
}
2014-10-09 17:18:14 +02:00
$result = $newobject -> fetch ( $elemid );
2015-05-04 12:29:26 +02:00
2014-10-07 21:39:10 +02:00
// TODO Add into categ
2019-11-13 19:35:39 +01:00
$result = $object -> add_type ( $newobject , $elementtype );
2021-02-23 18:04:37 +01:00
if ( $result >= 0 ) {
2019-01-27 11:55:16 +01:00
setEventMessages ( $langs -> trans ( " WasAddedSuccessfully " , $newobject -> ref ), null , 'mesgs' );
2020-05-21 15:05:19 +02:00
} else {
2021-10-22 15:33:57 +02:00
if ( $object -> error == 'DB_ERROR_RECORD_ALREADY_EXISTS' ) {
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> trans ( " ObjectAlreadyLinkedToCategory " ), null , 'warnings' );
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2014-10-09 17:18:14 +02:00
}
}
}
2014-10-07 21:39:10 +02:00
2005-04-13 14:04:02 +02:00
2006-03-03 21:52:01 +01:00
/*
2008-07-01 21:30:39 +02:00
* View
2006-03-03 21:52:01 +01:00
*/
2008-07-01 21:30:39 +02:00
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2015-09-17 19:51:56 +02:00
$formother = new FormOther ( $db );
2008-07-16 18:27:26 +02:00
2020-04-10 10:59:32 +02:00
$arrayofjs = array ( '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js' , '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js' );
$arrayofcss = array ( '/includes/jquery/plugins/jquerytreeview/jquery.treeview.css' );
2021-03-19 09:27:29 +01:00
$help_url = '' ;
llxHeader ( " " , $langs -> trans ( " Categories " ), $help_url , '' , 0 , 0 , $arrayofjs , $arrayofcss );
2020-03-26 12:36:53 +01:00
2020-04-12 00:37:05 +02:00
$title = Categorie :: $MAP_TYPE_TITLE_AREA [ $type ];
2007-11-10 13:51:57 +01:00
2019-01-27 11:55:16 +01:00
$head = categories_prepare_head ( $object , $type );
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'card' , $langs -> trans ( $title ), - 1 , 'category' );
2020-11-21 15:57:11 +01:00
2021-03-14 15:06:40 +01:00
$backtolist = ( GETPOST ( 'backtolist' ) ? GETPOST ( 'backtolist' ) : DOL_URL_ROOT . '/categories/index.php?leftmenu=cat&type=' . urlencode ( $type ));
$linkback = '<a href="' . dol_sanitizeUrl ( $backtolist ) . '">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2020-04-10 10:59:32 +02:00
$object -> next_prev_filter = ' type = ' . $object -> type ;
2017-01-22 12:13:32 +01:00
$object -> ref = $object -> label ;
2021-03-14 15:06:40 +01:00
$morehtmlref = '<br><div class="refidno"><a href="' . DOL_URL_ROOT . '/categories/index.php?leftmenu=cat&type=' . urlencode ( $type ) . '">' . $langs -> trans ( " Root " ) . '</a> >> ' ;
2017-01-22 12:13:32 +01:00
$ways = $object -> print_all_ways ( " >> " , '' , 1 );
2021-02-23 18:04:37 +01:00
foreach ( $ways as $way ) {
2020-10-31 14:32:18 +01:00
$morehtmlref .= $way . " <br> \n " ;
2017-01-22 12:13:32 +01:00
}
2020-04-10 10:59:32 +02:00
$morehtmlref .= '</div>' ;
2017-01-22 12:13:32 +01:00
2021-03-14 15:06:40 +01:00
dol_banner_tab ( $object , 'label' , $linkback , ( $user -> socid ? 0 : 1 ), 'label' , 'label' , $morehtmlref , '&type=' . urlencode ( $type ), 0 , '' , '' , 1 );
2017-01-22 12:13:32 +01:00
2006-03-03 21:52:01 +01:00
2007-02-22 21:59:41 +01:00
/*
2009-07-22 19:02:49 +02:00
* Confirmation suppression
*/
2014-10-07 21:39:10 +02:00
2021-02-23 18:04:37 +01:00
if ( $action == 'delete' ) {
2020-11-21 22:40:31 +01:00
if ( $backtopage ) {
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&type=' . $type . '&backtopage=' . urlencode ( $backtopage ), $langs -> trans ( 'DeleteCategory' ), $langs -> trans ( 'ConfirmDeleteCategory' ), 'confirm_delete' , '' , '' , 2 );
} else {
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&type=' . $type , $langs -> trans ( 'DeleteCategory' ), $langs -> trans ( 'ConfirmDeleteCategory' ), 'confirm_delete' , '' , '' , 1 );
}
2007-02-22 21:59:41 +01:00
}
2017-01-22 12:13:32 +01:00
print '<br>' ;
2005-04-13 14:04:02 +02:00
2017-04-05 14:48:24 +02:00
print '<div class="fichecenter">' ;
2017-01-22 12:13:32 +01:00
print '<div class="underbanner clearboth"></div>' ;
2020-05-26 14:43:50 +02:00
print '<table class="border centpercent tableforfield">' ;
2006-08-15 20:52:02 +02:00
2009-07-22 19:02:49 +02:00
// Description
2017-04-09 15:02:55 +02:00
print '<tr><td class="titlefield notopnoleft tdtop">' ;
2006-08-15 20:52:02 +02:00
print $langs -> trans ( " Description " ) . '</td><td>' ;
2015-05-14 20:49:22 +02:00
print dol_htmlentitiesbr ( $object -> description );
2006-08-15 20:52:02 +02:00
print '</td></tr>' ;
2015-09-17 19:51:56 +02:00
// Color
print '<tr><td class="notopnoleft">' ;
print $langs -> trans ( " Color " ) . '</td><td>' ;
print $formother -> showColor ( $object -> color );
print '</td></tr>' ;
2017-06-07 16:44:04 +02:00
// Other attributes
2019-11-13 19:35:39 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2014-03-16 16:04:18 +01:00
2006-08-15 20:52:02 +02:00
print '</table>' ;
2017-04-05 14:48:24 +02:00
print '</div>' ;
2006-08-15 20:52:02 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2006-08-15 20:52:02 +02:00
/*
* Boutons actions
*/
2015-05-14 20:49:22 +02:00
2006-08-15 20:52:02 +02:00
print " <div class='tabsAction'> \n " ;
2021-02-05 11:36:12 +01:00
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-23 18:04:37 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2021-02-05 11:36:12 +01:00
if ( empty ( $reshook )) {
2021-02-23 18:04:37 +01:00
if ( $user -> rights -> categorie -> creer ) {
2021-02-06 01:14:48 +01:00
$socid = ( $object -> socid ? " &socid= " . $object -> socid : " " );
print '<a class="butAction" href="edit.php?id=' . $object -> id . $socid . '&type=' . $type . '">' . $langs -> trans ( " Modify " ) . '</a>' ;
2021-02-05 11:36:12 +01:00
}
2006-08-15 20:52:02 +02:00
2021-02-23 18:04:37 +01:00
if ( $user -> rights -> categorie -> supprimer ) {
2021-02-06 01:17:05 +01:00
print '<a class="butActionDelete" href="' . $_SERVER [ " PHP_SELF " ] . '?action=delete&token=' . newToken () . '&id=' . $object -> id . '&type=' . $type . '&backtolist=' . urlencode ( $backtolist ) . '">' . $langs -> trans ( " Delete " ) . '</a>' ;
2021-02-05 11:36:12 +01:00
}
2006-08-15 20:52:02 +02:00
}
2005-04-13 14:04:02 +02:00
print " </div> " ;
2020-04-02 14:32:54 +02:00
$newcardbutton = '' ;
2021-02-23 18:04:37 +01:00
if ( ! empty ( $user -> rights -> categorie -> creer )) {
2020-03-25 10:31:40 +01:00
$link = DOL_URL_ROOT . '/categories/card.php' ;
$link .= '?action=create' ;
$link .= '&type=' . $type ;
$link .= '&catorigin=' . $object -> id ;
$link .= '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?type=' . $type . '&id=' . $id );
2020-04-02 14:32:54 +02:00
$newcardbutton = '<div class="right">' ;
$newcardbutton .= dolGetButtonTitle ( $langs -> trans ( 'NewCategory' ), '' , 'fa fa-plus-circle' , $link );
$newcardbutton .= '</div>' ;
2020-03-25 10:31:40 +01:00
}
2006-08-15 20:52:02 +02:00
2020-03-26 12:36:53 +01:00
/*
* Sub - category tree view of this category
*/
print '<div class="fichecenter">' ;
2020-04-02 14:32:54 +02:00
2020-04-09 16:36:39 +02:00
print load_fiche_titre ( $langs -> trans ( " SubCats " ), $newcardbutton , 'object_category' );
2020-04-02 14:32:54 +02:00
2020-03-26 12:36:53 +01:00
print '<table class="liste nohover" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " SubCats " ) . '</td>' ;
print '<td></td>' ;
print '<td class="right">' ;
2021-02-23 18:04:37 +01:00
if ( ! empty ( $conf -> use_javascript_ajax )) {
2020-03-26 12:36:53 +01:00
print '<div id="iddivjstreecontrol">' ;
2020-04-22 00:55:38 +02:00
print '<a class="notasortlink" href="#">' . img_picto ( '' , 'folder' ) . ' ' . $langs -> trans ( " UndoExpandAll " ) . '</a>' ;
2020-03-26 12:36:53 +01:00
print " | " ;
2020-04-22 00:55:38 +02:00
print '<a class="notasortlink" href="#">' . img_picto ( '' , 'folder-open' ) . ' ' . $langs -> trans ( " ExpandAll " ) . '</a>' ;
2020-03-26 12:36:53 +01:00
print '</div>' ;
}
print '</td>' ;
print '</tr>' ;
2011-03-11 15:59:35 +01:00
$cats = $object -> get_filles ();
2021-02-23 18:04:37 +01:00
if ( $cats < 0 ) {
2020-09-28 09:13:15 +02:00
dol_print_error ( $db , $object -> error , $object -> errors );
2021-02-23 18:04:37 +01:00
} elseif ( count ( $cats ) < 1 ) {
2020-03-26 12:36:53 +01:00
print '<tr class="oddeven">' ;
print '<td colspan="3" class="opacitymedium">' . $langs -> trans ( " NoSubCat " ) . '</td>' ;
print '</tr>' ;
2020-05-21 15:05:19 +02:00
} else {
2020-03-26 12:36:53 +01:00
$categstatic = new Categorie ( $db );
2020-04-12 00:37:05 +02:00
$fulltree = $categstatic -> get_full_arbo ( $type , $object -> id , 1 );
2020-03-26 12:36:53 +01:00
// Load possible missing includes
2021-02-23 18:04:37 +01:00
if ( $conf -> global -> CATEGORY_SHOW_COUNTS ) {
if ( $type == Categorie :: TYPE_MEMBER ) {
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ;
}
if ( $type == Categorie :: TYPE_ACCOUNT ) {
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
}
if ( $type == Categorie :: TYPE_PROJECT ) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
}
if ( $type == Categorie :: TYPE_USER ) {
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
}
2010-03-20 01:07:47 +01:00
}
2020-03-26 12:36:53 +01:00
// Define data (format for treeview)
$data = array ();
$data [] = array ( 'rowid' => 0 , 'fk_menu' =>- 1 , 'title' => " racine " , 'mainmenu' => '' , 'leftmenu' => '' , 'fk_mainmenu' => '' , 'fk_leftmenu' => '' );
2021-02-23 18:04:37 +01:00
foreach ( $fulltree as $key => $val ) {
2020-03-26 12:36:53 +01:00
$categstatic -> id = $val [ 'id' ];
$categstatic -> ref = $val [ 'label' ];
$categstatic -> color = $val [ 'color' ];
$categstatic -> type = $type ;
$desc = dol_htmlcleanlastbr ( $val [ 'description' ]);
2020-11-21 22:40:31 +01:00
$counter = '' ;
2021-02-23 18:04:37 +01:00
if ( $conf -> global -> CATEGORY_SHOW_COUNTS ) {
2020-03-26 12:36:53 +01:00
// we need only a count of the elements, so it is enough to consume only the id's from the database
$elements = $type == Categorie :: TYPE_ACCOUNT
? $categstatic -> getObjectsInCateg ( " account " , 1 ) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account"
: $categstatic -> getObjectsInCateg ( $type , 1 );
2021-11-28 15:43:22 +01:00
$counter = " <td class='left' width='40px;'> " . ( is_array ( $elements ) ? count ( $elements ) : '0' ) . " </td> " ;
2006-03-03 21:52:01 +01:00
}
2020-03-26 12:36:53 +01:00
2020-11-21 22:40:31 +01:00
$color = $categstatic -> color ? ' style="background: #' . sprintf ( " %06s " , $categstatic -> color ) . ';"' : ' style="background: #bbb"' ;
$li = $categstatic -> getNomUrl ( 1 , '' , 60 , '&backtolist=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $id . '&type=' . $type ));
2020-03-26 12:36:53 +01:00
$entry = '<table class="nobordernopadding centpercent">' ;
$entry .= '<tr>' ;
$entry .= '<td>' ;
2020-11-21 22:40:31 +01:00
$entry .= '<span class="noborderoncategories" ' . $color . '>' . $li . '</span>' ;
2020-03-26 12:36:53 +01:00
$entry .= '</td>' ;
2020-11-21 22:40:31 +01:00
$entry .= $counter ;
2020-03-26 12:36:53 +01:00
$entry .= '<td class="right" width="20px;">' ;
2020-11-21 22:40:31 +01:00
$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>' ;
$entry .= '</td>' ;
$entry .= '<td class="right" width="20px;">' ;
$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>' ;
$entry .= '</td>' ;
$entry .= '<td class="right" width="20px;">' ;
$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>' ;
2020-03-26 12:36:53 +01:00
$entry .= '</td>' ;
$entry .= '</tr>' ;
$entry .= '</table>' ;
$data [] = array ( 'rowid' => $val [ 'rowid' ], 'fk_menu' => $val [ 'fk_parent' ], 'entry' => $entry );
}
2020-11-21 22:40:31 +01:00
$nbofentries = ( count ( $data ) - 1 );
2021-02-23 18:04:37 +01:00
if ( $nbofentries > 0 ) {
2020-03-26 12:36:53 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/treeview.lib.php' ;
print '<tr class="pair">' ;
print '<td colspan="3">' ;
// $data[0] is the current shown category, to don'T show the current category use $data[1] instead
tree_recur ( $data , $data [ 1 ], 0 );
print '</td>' ;
print '</tr>' ;
2020-05-21 15:05:19 +02:00
} else {
2020-03-26 12:36:53 +01:00
print '<tr class="pair">' ;
print '<td colspan="3">' ;
print '<table class="nobordernopadding">' ;
print '<tr class="nobordernopadding">' ;
print '<td>' . img_picto_common ( '' , 'treemenu/branchbottom.gif' ) . '</td>' ;
print '<td valign="middle">' . $langs -> trans ( " NoCategoryYet " ) . '</td>' ;
print '<td> </td>' ;
print '</tr>' ;
print '</table>' ;
print '</td>' ;
print '</tr>' ;
2006-03-03 21:52:01 +01:00
}
2005-04-13 14:04:02 +02:00
}
2020-03-26 12:36:53 +01:00
print " </table> " ;
print " </div> " ;
2015-12-19 13:55:27 +01:00
2019-09-10 01:44:36 +02:00
// List of mass actions available
2019-11-13 19:35:39 +01:00
$arrayofmassactions = array (
2019-09-10 01:44:36 +02:00
//'validate'=>$langs->trans("Validate"),
//'generate_doc'=>$langs->trans("ReGeneratePDF"),
//'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
);
2019-11-13 19:35:39 +01:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2019-09-10 01:44:36 +02:00
2020-04-02 14:32:54 +02:00
$typeid = $type ;
2014-10-07 21:39:10 +02:00
// List of products or services (type is type of category)
2021-02-23 18:04:37 +01:00
if ( $type == Categorie :: TYPE_PRODUCT ) {
2020-04-02 14:32:54 +02:00
$permission = ( $user -> rights -> produit -> creer || $user -> rights -> service -> creer );
$prods = $object -> getObjectsInCateg ( $type , 0 , $limit , $offset );
2021-02-23 18:04:37 +01:00
if ( $prods < 0 ) {
2020-09-28 09:13:15 +02:00
dol_print_error ( $db , $object -> error , $object -> errors );
2020-05-21 15:05:19 +02:00
} else {
2014-10-09 17:18:14 +02:00
// Form to add record into a category
2020-04-02 14:32:54 +02:00
$showclassifyform = 1 ;
2021-02-23 18:04:37 +01:00
if ( $showclassifyform ) {
2014-10-07 21:39:10 +02:00
print '<br>' ;
2014-10-09 17:18:14 +02:00
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2014-10-09 17:18:14 +02:00
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
2014-10-07 21:39:10 +02:00
print '<input type="hidden" name="action" value="addintocategory">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2019-03-15 10:48:10 +01:00
print '<tr class="liste_titre"><td>' ;
2014-10-09 17:18:14 +02:00
print $langs -> trans ( " AddProductServiceIntoCategory " ) . ' ' ;
2019-11-28 21:23:53 +01:00
$form -> select_produits ( '' , 'elemid' , '' , 0 , 0 , - 1 , 2 , '' , 1 );
2020-04-02 14:32:54 +02:00
print '<input type="submit" class="button buttongen" value="' . $langs -> trans ( " ClassifyInCategory " ) . '"></td>' ;
2014-10-09 17:18:14 +02:00
print '</tr>' ;
print '</table>' ;
print '</form>' ;
}
2015-05-04 12:29:26 +02:00
2019-09-10 01:44:36 +02:00
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-09-10 01:44:36 +02:00
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<br>' ;
$param = '&limit=' . $limit . '&id=' . $id . '&type=' . $type ; $num = count ( $prods ); $nbtotalofrecords = '' ; $newcardbutton = '' ;
2020-04-02 14:32:54 +02:00
print_barre_liste ( $langs -> trans ( " ProductsAndServices " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'products' , 0 , $newcardbutton , '' , $limit );
2019-09-10 01:44:36 +02:00
2020-04-02 14:32:54 +02:00
print '<table class="noborder centpercent">' . " \n " ;
2019-09-10 01:44:36 +02:00
print '<tr class="liste_titre"><td colspan="3">' . $langs -> trans ( " Ref " ) . '</td></tr>' . " \n " ;
2009-01-30 22:21:22 +01:00
2021-02-23 18:04:37 +01:00
if ( count ( $prods ) > 0 ) {
2019-09-10 01:44:36 +02:00
$i = 0 ;
2021-02-23 18:04:37 +01:00
foreach ( $prods as $prod ) {
2019-09-10 01:44:36 +02:00
$i ++ ;
2021-02-23 18:04:37 +01:00
if ( $i > $limit ) {
break ;
}
2019-09-10 01:44:36 +02:00
2017-05-06 10:54:28 +02:00
print " \t " . '<tr class="oddeven">' . " \n " ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap" valign="top">' ;
2015-12-19 13:55:27 +01:00
print $prod -> getNomUrl ( 1 );
2013-04-21 23:44:33 +02:00
print " </td> \n " ;
2017-01-22 12:13:32 +01:00
print '<td class="tdtop">' . $prod -> label . " </td> \n " ;
2013-04-21 23:44:33 +02:00
// Link to delete from category
2019-01-22 13:56:14 +01:00
print '<td class="right">' ;
2021-02-23 18:04:37 +01:00
if ( $permission ) {
2019-11-13 19:35:39 +01:00
print " <a href= ' " . $_SERVER [ 'PHP_SELF' ] . " ? " . ( empty ( $socid ) ? 'id' : 'socid' ) . " = " . $object -> id . " &type= " . $typeid . " &removeelem= " . $prod -> id . " '> " ;
2019-03-15 10:48:10 +01:00
print $langs -> trans ( " DeleteFromCat " );
2020-04-02 14:32:54 +02:00
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' , '' , false , 0 , 0 , '' , 'paddingleft' );
2019-03-15 10:48:10 +01:00
print " </a> " ;
2013-04-21 23:44:33 +02:00
}
print '</td>' ;
2007-04-30 12:53:58 +02:00
print " </tr> \n " ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-04-02 14:32:54 +02:00
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoItems " ) . '</td></tr>' ;
2007-04-30 12:53:58 +02:00
}
print " </table> \n " ;
2019-09-10 01:44:36 +02:00
print '</form>' . " \n " ;
2007-04-30 12:53:58 +02:00
}
2005-04-13 14:04:02 +02:00
}
2007-04-30 12:53:58 +02:00
2021-10-22 17:15:51 +02:00
// List of customers
2021-02-23 18:04:37 +01:00
if ( $type == Categorie :: TYPE_CUSTOMER ) {
2020-04-02 14:32:54 +02:00
$permission = $user -> rights -> societe -> creer ;
$socs = $object -> getObjectsInCateg ( $type , 0 , $limit , $offset );
2021-02-23 18:04:37 +01:00
if ( $socs < 0 ) {
2020-09-28 09:13:15 +02:00
dol_print_error ( $db , $object -> error , $object -> errors );
2020-05-21 15:05:19 +02:00
} else {
2020-10-22 16:12:01 +02:00
// Form to add record into a category
$showclassifyform = 1 ;
2021-02-23 18:04:37 +01:00
if ( $showclassifyform ) {
2020-10-22 16:12:01 +02:00
print '<br>' ;
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="addintocategory">' ;
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre"><td>' ;
2020-11-23 19:53:58 +01:00
print $langs -> trans ( " AddCustomerIntoCategory " ) . ' ' ;
print $form -> select_company ( '' , 'elemid' , 's.client IN (1,3)' );
2020-10-22 16:12:01 +02:00
print '<input type="submit" class="button buttongen" value="' . $langs -> trans ( " ClassifyInCategory " ) . '"></td>' ;
print '</tr>' ;
print '</table>' ;
print '</form>' ;
}
2019-09-10 01:44:36 +02:00
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-09-10 01:44:36 +02:00
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<br>' ;
$param = '&limit=' . $limit . '&id=' . $id . '&type=' . $type ; $num = count ( $socs ); $nbtotalofrecords = '' ; $newcardbutton = '' ;
2020-11-23 19:53:58 +01:00
print_barre_liste ( $langs -> trans ( " Customers " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'companies' , 0 , $newcardbutton , '' , $limit );
2019-09-10 01:44:36 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' . " \n " ;
2020-11-23 19:53:58 +01:00
print '<tr class="liste_titre"><td colspan="2">' . $langs -> trans ( " Name " ) . '</td></tr>' . " \n " ;
2009-01-30 22:21:22 +01:00
2021-02-23 18:04:37 +01:00
if ( count ( $socs ) > 0 ) {
2019-09-10 01:44:36 +02:00
$i = 0 ;
2021-02-23 18:04:37 +01:00
foreach ( $socs as $key => $soc ) {
2019-09-10 01:44:36 +02:00
$i ++ ;
2021-02-23 18:04:37 +01:00
if ( $i > $limit ) {
break ;
}
2019-09-10 01:44:36 +02:00
2017-05-06 10:54:28 +02:00
print " \t " . '<tr class="oddeven">' . " \n " ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap" valign="top">' ;
2015-12-19 13:55:27 +01:00
print $soc -> getNomUrl ( 1 );
2010-03-20 21:24:32 +01:00
print " </td> \n " ;
2013-06-05 16:24:32 +02:00
// Link to delete from category
2019-01-22 13:56:14 +01:00
print '<td class="right">' ;
2021-02-23 18:04:37 +01:00
if ( $permission ) {
2019-11-13 19:35:39 +01:00
print " <a href= ' " . $_SERVER [ 'PHP_SELF' ] . " ? " . ( empty ( $socid ) ? 'id' : 'socid' ) . " = " . $object -> id . " &type= " . $typeid . " &removeelem= " . $soc -> id . " '> " ;
2019-03-15 10:48:10 +01:00
print $langs -> trans ( " DeleteFromCat " );
2020-04-02 14:32:54 +02:00
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' , '' , false , 0 , 0 , '' , 'paddingleft' );
2019-03-15 10:48:10 +01:00
print " </a> " ;
2013-06-05 16:24:32 +02:00
}
print '</td>' ;
2007-04-30 12:53:58 +02:00
print " </tr> \n " ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-04-02 14:32:54 +02:00
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoItems " ) . '</td></tr>' ;
2007-04-30 12:53:58 +02:00
}
print " </table> \n " ;
2019-09-10 01:44:36 +02:00
print '</form>' . " \n " ;
2007-04-30 12:53:58 +02:00
}
}
2021-10-22 17:15:51 +02:00
// List of suppliers
2021-02-23 18:04:37 +01:00
if ( $type == Categorie :: TYPE_SUPPLIER ) {
2020-04-02 14:32:54 +02:00
$permission = $user -> rights -> societe -> creer ;
$socs = $object -> getObjectsInCateg ( $type , 0 , $limit , $offset );
2021-02-23 18:04:37 +01:00
if ( $socs < 0 ) {
2020-09-28 09:13:15 +02:00
dol_print_error ( $db , $object -> error , $object -> errors );
2020-05-21 15:05:19 +02:00
} else {
2020-10-22 16:12:01 +02:00
// Form to add record into a category
$showclassifyform = 1 ;
2021-02-23 18:04:37 +01:00
if ( $showclassifyform ) {
2020-10-22 16:12:01 +02:00
print '<br>' ;
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="addintocategory">' ;
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre"><td>' ;
2020-11-23 19:53:58 +01:00
print $langs -> trans ( " AddSupplierIntoCategory " ) . ' ' ;
print $form -> select_company ( '' , 'elemid' , 's.fournisseur = 1' );
2020-10-22 16:12:01 +02:00
print '<input type="submit" class="button buttongen" value="' . $langs -> trans ( " ClassifyInCategory " ) . '"></td>' ;
print '</tr>' ;
print '</table>' ;
print '</form>' ;
}
2019-09-10 01:44:36 +02:00
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-09-10 01:44:36 +02:00
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<br>' ;
$param = '&limit=' . $limit . '&id=' . $id . '&type=' . $type ; $num = count ( $socs ); $nbtotalofrecords = '' ; $newcardbutton = '' ;
2020-11-23 19:53:58 +01:00
print_barre_liste ( $langs -> trans ( " Suppliers " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'companies' , 0 , $newcardbutton , '' , $limit );
2019-09-10 01:44:36 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' . " \n " ;
2020-11-23 19:53:58 +01:00
print '<tr class="liste_titre"><td colspan="2">' . $langs -> trans ( " Name " ) . " </td></tr> \n " ;
2009-01-30 22:21:22 +01:00
2021-02-23 18:04:37 +01:00
if ( count ( $socs ) > 0 ) {
2007-04-30 12:53:58 +02:00
$i = 0 ;
2021-02-23 18:04:37 +01:00
foreach ( $socs as $soc ) {
2007-04-30 12:53:58 +02:00
$i ++ ;
2021-02-23 18:04:37 +01:00
if ( $i > $limit ) {
break ;
}
2017-06-07 16:44:04 +02:00
2017-05-06 10:54:28 +02:00
print " \t " . '<tr class="oddeven">' . " \n " ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap" valign="top">' ;
2015-12-19 13:55:27 +01:00
print $soc -> getNomUrl ( 1 );
2010-03-20 21:24:32 +01:00
print " </td> \n " ;
2013-06-05 16:24:32 +02:00
// Link to delete from category
2019-01-22 13:56:14 +01:00
print '<td class="right">' ;
2021-02-23 18:04:37 +01:00
if ( $permission ) {
2019-11-13 19:35:39 +01:00
print " <a href= ' " . $_SERVER [ 'PHP_SELF' ] . " ? " . ( empty ( $socid ) ? 'id' : 'socid' ) . " = " . $object -> id . " &type= " . $typeid . " &removeelem= " . $soc -> id . " '> " ;
2019-03-15 10:48:10 +01:00
print $langs -> trans ( " DeleteFromCat " );
2020-04-02 14:32:54 +02:00
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' , '' , false , 0 , 0 , '' , 'paddingleft' );
2019-03-15 10:48:10 +01:00
print " </a> " ;
2013-06-05 16:24:32 +02:00
}
2013-04-21 23:44:33 +02:00
print '</td>' ;
2020-11-23 19:53:58 +01:00
2007-04-30 12:53:58 +02:00
print " </tr> \n " ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-04-02 14:32:54 +02:00
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoItems " ) . '</td></tr>' ;
2007-04-30 12:53:58 +02:00
}
print " </table> \n " ;
2019-09-10 01:44:36 +02:00
print '</form>' . " \n " ;
2006-03-03 21:52:01 +01:00
}
2005-04-13 14:04:02 +02:00
}
2010-03-20 01:07:47 +01:00
// List of members
2021-02-23 18:04:37 +01:00
if ( $type == Categorie :: TYPE_MEMBER ) {
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ;
2010-03-20 01:07:47 +01:00
2020-04-02 14:32:54 +02:00
$permission = $user -> rights -> adherent -> creer ;
$prods = $object -> getObjectsInCateg ( $type , 0 , $limit , $offset );
2021-02-23 18:04:37 +01:00
if ( $prods < 0 ) {
2020-09-28 09:13:15 +02:00
dol_print_error ( $db , $object -> error , $object -> errors );
2020-05-21 15:05:19 +02:00
} else {
2021-10-22 16:13:54 +02:00
// Form to add record into a category
$showclassifyform = 1 ;
if ( $showclassifyform ) {
print '<br>' ;
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="addintocategory">' ;
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre"><td>' ;
print $langs -> trans ( " AddMemberIntoCategory " ) . ' ' ;
print $form -> selectMembers ( '' , 'elemid' );
print '<input type="submit" class="button buttongen" value="' . $langs -> trans ( " ClassifyInCategory " ) . '"></td>' ;
print '</tr>' ;
print '</table>' ;
print '</form>' ;
}
2019-09-10 01:44:36 +02:00
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-09-10 01:44:36 +02:00
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<br>' ;
$param = '&limit=' . $limit . '&id=' . $id . '&type=' . $type ; $num = count ( $prods ); $nbtotalofrecords = '' ; $newcardbutton = '' ;
2020-04-02 15:11:46 +02:00
print_barre_liste ( $langs -> trans ( " Member " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'members' , 0 , $newcardbutton , '' , $limit );
2019-09-10 01:44:36 +02:00
2010-03-20 01:07:47 +01:00
print " <table class='noborder' width='100%'> \n " ;
2019-09-10 01:44:36 +02:00
print '<tr class="liste_titre"><td colspan="4">' . $langs -> trans ( " Name " ) . '</td></tr>' . " \n " ;
2010-03-20 01:07:47 +01:00
2021-02-23 18:04:37 +01:00
if ( count ( $prods ) > 0 ) {
2019-09-10 01:44:36 +02:00
$i = 0 ;
2021-02-23 18:04:37 +01:00
foreach ( $prods as $key => $member ) {
2019-09-10 01:44:36 +02:00
$i ++ ;
2021-02-23 18:04:37 +01:00
if ( $i > $limit ) {
break ;
}
2019-09-10 01:44:36 +02:00
2017-05-06 10:54:28 +02:00
print " \t " . '<tr class="oddeven">' . " \n " ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap" valign="top">' ;
2019-11-13 19:35:39 +01:00
$member -> ref = $member -> login ;
2019-01-27 11:55:16 +01:00
print $member -> getNomUrl ( 1 , 0 );
2010-03-20 21:24:32 +01:00
print " </td> \n " ;
2017-01-22 12:13:32 +01:00
print '<td class="tdtop">' . $member -> lastname . " </td> \n " ;
print '<td class="tdtop">' . $member -> firstname . " </td> \n " ;
2013-04-21 23:44:33 +02:00
// Link to delete from category
2019-01-22 13:56:14 +01:00
print '<td class="right">' ;
2021-02-23 18:04:37 +01:00
if ( $permission ) {
2019-11-13 19:35:39 +01:00
print " <a href= ' " . $_SERVER [ 'PHP_SELF' ] . " ? " . ( empty ( $socid ) ? 'id' : 'socid' ) . " = " . $object -> id . " &type= " . $typeid . " &removeelem= " . $member -> id . " '> " ;
2019-03-15 10:48:10 +01:00
print $langs -> trans ( " DeleteFromCat " );
2020-04-02 14:32:54 +02:00
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' , '' , false , 0 , 0 , '' , 'paddingleft' );
2019-03-15 10:48:10 +01:00
print " </a> " ;
2013-04-21 23:44:33 +02:00
}
2010-03-20 01:07:47 +01:00
print " </tr> \n " ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-04-02 14:32:54 +02:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoItems " ) . '</td></tr>' ;
2010-03-20 01:07:47 +01:00
}
print " </table> \n " ;
2019-09-10 01:44:36 +02:00
print '</form>' . " \n " ;
2010-03-20 01:07:47 +01:00
}
}
2015-12-19 13:55:27 +01:00
// Categorie contact
2021-02-23 18:04:37 +01:00
if ( $type == Categorie :: TYPE_CONTACT ) {
2020-04-02 14:32:54 +02:00
$permission = $user -> rights -> societe -> creer ;
$contacts = $object -> getObjectsInCateg ( $type , 0 , $limit , $offset );
2021-10-31 17:36:56 +01:00
if ( is_numeric ( $contacts ) && $contacts < 0 ) {
2020-09-28 09:13:15 +02:00
dol_print_error ( $db , $object -> error , $object -> errors );
2020-05-21 15:05:19 +02:00
} else {
2021-10-22 16:46:55 +02:00
// Form to add record into a category
$showclassifyform = 1 ;
if ( $showclassifyform ) {
print '<br>' ;
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="addintocategory">' ;
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre"><td>' ;
print $langs -> trans ( " AddContactIntoCategory " ) . ' ' ;
2021-10-22 17:46:16 +02:00
print $form -> selectContacts ( '' , '' , 'elemid' );
2021-10-22 16:46:55 +02:00
print '<input type="submit" class="button buttongen" value="' . $langs -> trans ( " ClassifyInCategory " ) . '"></td>' ;
print '</tr>' ;
print '</table>' ;
print '</form>' ;
}
2019-09-10 01:44:36 +02:00
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-09-10 01:44:36 +02:00
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<br>' ;
2020-04-02 14:32:54 +02:00
$param = '&limit=' . $limit . '&id=' . $id . '&type=' . $type ;
$num = count ( $contacts );
$nbtotalofrecords = '' ;
$newcardbutton = '' ;
2021-05-13 00:40:56 +02:00
$objsoc = new Societe ( $db );
2020-05-17 13:34:16 +02:00
print_barre_liste ( $langs -> trans ( " Contact " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'contact' , 0 , $newcardbutton , '' , $limit );
2019-09-10 01:44:36 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' . " \n " ;
2019-09-10 01:44:36 +02:00
print '<tr class="liste_titre"><td colspan="2">' . $langs -> trans ( " Ref " ) . '</td></tr>' . " \n " ;
2013-07-30 17:04:09 +02:00
2021-10-21 15:57:54 +02:00
if ( is_array ( $contacts ) && count ( $contacts ) > 0 ) {
2013-07-30 17:04:09 +02:00
$i = 0 ;
2021-02-23 18:04:37 +01:00
foreach ( $contacts as $key => $contact ) {
2013-07-30 17:04:09 +02:00
$i ++ ;
2021-02-23 18:04:37 +01:00
if ( $i > $limit ) {
break ;
}
2017-06-07 16:44:04 +02:00
2017-05-06 10:54:28 +02:00
print " \t " . '<tr class="oddeven">' . " \n " ;
2013-07-30 17:04:09 +02:00
print '<td class="nowrap" valign="top">' ;
2019-01-27 11:55:16 +01:00
print $contact -> getNomUrl ( 1 , 'category' );
2021-05-17 09:54:04 +02:00
if ( $contact -> socid > 0 ) {
$objsoc -> fetch ( $contact -> socid );
2021-05-13 00:40:56 +02:00
print ' - ' ;
print $objsoc -> getNomUrl ( 1 , 'contact' );
}
2013-07-30 17:04:09 +02:00
print " </td> \n " ;
// Link to delete from category
2019-01-22 13:56:14 +01:00
print '<td class="right">' ;
2021-02-23 18:04:37 +01:00
if ( $permission ) {
2019-11-13 19:35:39 +01:00
print " <a href= ' " . $_SERVER [ 'PHP_SELF' ] . " ? " . ( empty ( $socid ) ? 'id' : 'socid' ) . " = " . $object -> id . " &type= " . $typeid . " &removeelem= " . $contact -> id . " '> " ;
2019-03-15 10:48:10 +01:00
print $langs -> trans ( " DeleteFromCat " );
2020-04-02 14:32:54 +02:00
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' , '' , false , 0 , 0 , '' , 'paddingleft' );
2019-03-15 10:48:10 +01:00
print " </a> " ;
2013-07-30 17:04:09 +02:00
}
print '</td>' ;
print " </tr> \n " ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-04-02 14:32:54 +02:00
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoItems " ) . '</td></tr>' ;
2013-07-30 17:04:09 +02:00
}
print " </table> \n " ;
2019-09-10 01:44:36 +02:00
print '</form>' . " \n " ;
2013-07-30 17:04:09 +02:00
}
}
2020-04-09 16:36:39 +02:00
// List of bank accounts
2021-02-23 18:04:37 +01:00
if ( $type == Categorie :: TYPE_ACCOUNT ) {
2020-10-31 14:32:18 +01:00
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
$permission = $user -> rights -> banque -> creer ;
$accounts = $object -> getObjectsInCateg ( $type , 0 , $limit , $offset );
2021-02-23 18:04:37 +01:00
if ( $accounts < 0 ) {
2020-10-31 14:32:18 +01:00
dol_print_error ( $db , $object -> error , $object -> errors );
} else {
2021-10-22 17:15:51 +02:00
// Form to add record into a category
$showclassifyform = 1 ;
if ( $showclassifyform ) {
print '<br>' ;
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="addintocategory">' ;
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre"><td>' ;
print $langs -> trans ( " AddAccountIntoCategory " ) . ' ' ;
$form -> select_comptes ( '' , 'elemid' );
print '<input type="submit" class="button buttongen" value="' . $langs -> trans ( " ClassifyInCategory " ) . '"></td>' ;
print '</tr>' ;
print '</table>' ;
print '</form>' ;
}
2020-10-31 14:32:18 +01:00
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<br>' ;
$param = '&limit=' . $limit . '&id=' . $id . '&type=' . $type ; $num = count ( $accounts ); $nbtotalofrecords = '' ; $newcardbutton = '' ;
print_barre_liste ( $langs -> trans ( " Account " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'bank_account' , 0 , $newcardbutton , '' , $limit );
print " <table class='noborder' width='100%'> \n " ;
print '<tr class="liste_titre"><td colspan="4">' . $langs -> trans ( " Ref " ) . '</td></tr>' . " \n " ;
2021-02-23 18:04:37 +01:00
if ( count ( $accounts ) > 0 ) {
2020-10-31 14:32:18 +01:00
$i = 0 ;
2021-02-23 18:04:37 +01:00
foreach ( $accounts as $key => $account ) {
2020-10-31 14:32:18 +01:00
$i ++ ;
2021-02-23 18:04:37 +01:00
if ( $i > $limit ) {
break ;
}
2020-10-31 14:32:18 +01:00
print " \t " . '<tr class="oddeven">' . " \n " ;
print '<td class="nowrap" valign="top">' ;
print $account -> getNomUrl ( 1 , 0 );
print " </td> \n " ;
print '<td class="tdtop">' . $account -> bank . " </td> \n " ;
print '<td class="tdtop">' . $account -> number . " </td> \n " ;
// Link to delete from category
print '<td class="right">' ;
2021-02-23 18:04:37 +01:00
if ( $permission ) {
2020-10-31 14:32:18 +01:00
print " <a href= ' " . $_SERVER [ 'PHP_SELF' ] . " ? " . ( empty ( $socid ) ? 'id' : 'socid' ) . " = " . $object -> id . " &type= " . $typeid . " &removeelem= " . $account -> id . " '> " ;
print $langs -> trans ( " DeleteFromCat " );
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' , '' , false , 0 , 0 , '' , 'paddingleft' );
print " </a> " ;
}
print " </tr> \n " ;
}
} else {
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoItems " ) . '</td></tr>' ;
}
print " </table> \n " ;
print '</form>' . " \n " ;
}
2016-04-30 14:45:24 +02:00
}
2005-04-13 14:04:02 +02:00
2016-08-29 10:41:14 +02:00
// List of Project
2021-02-23 18:04:37 +01:00
if ( $type == Categorie :: TYPE_PROJECT ) {
2016-08-29 10:41:14 +02:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
2020-04-02 14:32:54 +02:00
$permission = $user -> rights -> projet -> creer ;
$objects = $object -> getObjectsInCateg ( $type , 0 , $limit , $offset );
2021-02-23 18:04:37 +01:00
if ( $objects < 0 ) {
2016-08-29 10:41:14 +02:00
dol_print_error ( $db , $object -> error , $object -> errors );
2020-05-21 15:05:19 +02:00
} else {
2021-10-22 15:48:39 +02:00
// Form to add record into a category
$showclassifyform = 1 ;
if ( $showclassifyform ) {
print '<br>' ;
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="addintocategory">' ;
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre"><td>' ;
print $langs -> trans ( " AddProjectIntoCategory " ) . ' ' ;
$form -> selectProjects ( '' , 'elemid' );
print '<input type="submit" class="button buttongen" value="' . $langs -> trans ( " ClassifyInCategory " ) . '"></td>' ;
print '</tr>' ;
print '</table>' ;
print '</form>' ;
}
2019-09-10 01:44:36 +02:00
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-09-10 01:44:36 +02:00
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<br>' ;
2020-04-02 14:32:54 +02:00
$param = '&limit=' . $limit . '&id=' . $id . '&type=' . $type ; $num = count ( $objects ); $nbtotalofrecords = '' ; $newcardbutton = '' ;
2020-04-02 15:11:46 +02:00
print_barre_liste ( $langs -> trans ( " Project " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'project' , 0 , $newcardbutton , '' , $limit );
2019-09-10 01:44:36 +02:00
2016-08-29 10:41:14 +02:00
print " <table class='noborder' width='100%'> \n " ;
2019-09-10 01:44:36 +02:00
print '<tr class="liste_titre"><td colspan="4">' . $langs -> trans ( " Ref " ) . '</td></tr>' . " \n " ;
2016-08-29 10:41:14 +02:00
2021-02-23 18:04:37 +01:00
if ( count ( $objects ) > 0 ) {
2019-09-10 01:44:36 +02:00
$i = 0 ;
2021-02-23 18:04:37 +01:00
foreach ( $objects as $key => $project ) {
2019-09-10 01:44:36 +02:00
$i ++ ;
2021-02-23 18:04:37 +01:00
if ( $i > $limit ) {
break ;
}
2019-09-10 01:44:36 +02:00
2017-05-06 10:54:28 +02:00
print " \t " . '<tr class="oddeven">' . " \n " ;
2016-08-29 10:41:14 +02:00
print '<td class="nowrap" valign="top">' ;
2018-04-10 14:10:40 +02:00
print $project -> getNomUrl ( 1 );
2016-08-29 10:41:14 +02:00
print " </td> \n " ;
2017-01-22 12:13:32 +01:00
print '<td class="tdtop">' . $project -> ref . " </td> \n " ;
print '<td class="tdtop">' . $project -> title . " </td> \n " ;
2016-08-29 10:41:14 +02:00
// Link to delete from category
2019-01-22 13:56:14 +01:00
print '<td class="right">' ;
2021-02-23 18:04:37 +01:00
if ( $permission ) {
2019-11-13 19:35:39 +01:00
print " <a href= ' " . $_SERVER [ 'PHP_SELF' ] . " ? " . ( empty ( $socid ) ? 'id' : 'socid' ) . " = " . $object -> id . " &type= " . $typeid . " &removeelem= " . $project -> id . " '> " ;
2019-03-15 10:48:10 +01:00
print $langs -> trans ( " DeleteFromCat " );
2020-04-02 14:32:54 +02:00
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' , '' , false , 0 , 0 , '' , 'paddingleft' );
2019-03-15 10:48:10 +01:00
print " </a> " ;
2016-08-29 10:41:14 +02:00
}
print " </tr> \n " ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-04-02 14:32:54 +02:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoItems " ) . '</td></tr>' ;
2016-08-29 10:41:14 +02:00
}
print " </table> \n " ;
2019-09-10 01:44:36 +02:00
print '</form>' . " \n " ;
2016-08-29 10:41:14 +02:00
}
}
2020-02-03 11:01:58 +01:00
// List of users
2021-02-23 18:04:37 +01:00
if ( $type == Categorie :: TYPE_USER ) {
2020-02-03 11:01:58 +01:00
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
2020-04-02 14:32:54 +02:00
$users = $object -> getObjectsInCateg ( $type );
2021-02-23 18:04:37 +01:00
if ( $users < 0 ) {
2020-02-03 11:01:58 +01:00
dol_print_error ( $db , $object -> error , $object -> errors );
2020-05-21 15:05:19 +02:00
} else {
2021-10-22 16:54:31 +02:00
// Form to add record into a category
$showclassifyform = 1 ;
if ( $showclassifyform ) {
print '<br>' ;
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="addintocategory">' ;
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre"><td>' ;
print $langs -> trans ( " AddProjectIntoCategory " ) . ' ' ;
2021-10-23 22:39:27 +02:00
print $form -> select_dolusers ( '' , 'elemid' );
2021-10-22 16:54:31 +02:00
print '<input type="submit" class="button buttongen" value="' . $langs -> trans ( " ClassifyInCategory " ) . '"></td>' ;
print '</tr>' ;
print '</table>' ;
print '</form>' ;
}
2020-04-02 14:32:54 +02:00
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<br>' ;
2020-09-28 08:31:39 +02:00
$param = '&limit=' . $limit . '&id=' . $id . '&type=' . $type ;
$num = count ( $users );
print_barre_liste ( $langs -> trans ( " Users " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , '' , 'user' , 0 , '' , '' , $limit );
2020-04-02 14:32:54 +02:00
2020-02-03 11:01:58 +01:00
print " <table class='noborder' width='100%'> \n " ;
2020-09-28 08:31:39 +02:00
print '<tr class="liste_titre"><td colspan="4">' . $langs -> trans ( " Users " ) . ' <span class="badge">' . $num . '</span></td></tr>' . " \n " ;
2020-02-03 11:01:58 +01:00
2021-02-23 18:04:37 +01:00
if ( count ( $users ) > 0 ) {
2020-02-03 11:01:58 +01:00
// Use "$userentry" here, because "$user" is the current user
2021-02-23 18:04:37 +01:00
foreach ( $users as $key => $userentry ) {
2020-02-03 11:01:58 +01:00
print " \t " . '<tr class="oddeven">' . " \n " ;
print '<td class="nowrap" valign="top">' ;
print $userentry -> getNomUrl ( 1 );
print " </td> \n " ;
print '<td class="tdtop">' . $userentry -> job . " </td> \n " ;
// Link to delete from category
print '<td class="right">' ;
2021-02-23 18:04:37 +01:00
if ( $user -> rights -> user -> user -> creer ) {
2020-04-10 10:59:32 +02:00
print " <a href= ' " . $_SERVER [ 'PHP_SELF' ] . " ? " . ( empty ( $socid ) ? 'id' : 'socid' ) . " = " . $object -> id . " &type= " . $type . " &removeelem= " . $userentry -> id . " '> " ;
2020-02-03 11:01:58 +01:00
print $langs -> trans ( " DeleteFromCat " );
2020-04-02 14:32:54 +02:00
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' , '' , false , 0 , 0 , '' , 'paddingleft' );
2020-02-03 11:01:58 +01:00
print " </a> " ;
}
print " </tr> \n " ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-04-02 14:32:54 +02:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoItems " ) . '</td></tr>' ;
2020-02-03 11:01:58 +01:00
}
print " </table> \n " ;
2020-04-02 14:32:54 +02:00
print '</form>' . " \n " ;
2020-02-03 11:01:58 +01:00
}
}
2020-04-02 14:32:54 +02:00
2020-09-28 08:31:39 +02:00
// List of warehouses
2021-02-23 18:04:37 +01:00
if ( $type == Categorie :: TYPE_WAREHOUSE ) {
2020-04-02 14:32:54 +02:00
$permission = $user -> rights -> stock -> creer ;
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php' ;
$objects = $object -> getObjectsInCateg ( $type , 0 , $limit , $offset );
2021-02-23 18:04:37 +01:00
if ( $objects < 0 ) {
2020-04-02 14:32:54 +02:00
dol_print_error ( $db , $object -> error , $object -> errors );
2020-05-21 15:05:19 +02:00
} else {
2020-04-02 14:32:54 +02:00
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<br>' ;
$param = '&limit=' . $limit . '&id=' . $id . '&type=' . $type ; $num = count ( $objects ); $nbtotalofrecords = '' ; $newcardbutton = '' ;
2020-05-17 13:34:16 +02:00
print_barre_liste ( $langs -> trans ( " Warehouses " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'stock' , 0 , $newcardbutton , '' , $limit );
2020-04-02 14:32:54 +02:00
print " <table class='noborder' width='100%'> \n " ;
print '<tr class="liste_titre"><td colspan="4">' . $langs -> trans ( " Ref " ) . '</td></tr>' . " \n " ;
2021-02-23 18:04:37 +01:00
if ( count ( $objects ) > 0 ) {
2020-04-02 14:32:54 +02:00
$i = 0 ;
2021-02-23 18:04:37 +01:00
foreach ( $objects as $key => $project ) {
2020-04-02 14:32:54 +02:00
$i ++ ;
2021-02-23 18:04:37 +01:00
if ( $i > $limit ) {
break ;
}
2020-04-02 14:32:54 +02:00
print " \t " . '<tr class="oddeven">' . " \n " ;
print '<td class="nowrap" valign="top">' ;
print $project -> getNomUrl ( 1 );
print " </td> \n " ;
print '<td class="tdtop">' . $project -> ref . " </td> \n " ;
print '<td class="tdtop">' . $project -> title . " </td> \n " ;
// Link to delete from category
print '<td class="right">' ;
2021-02-23 18:04:37 +01:00
if ( $permission ) {
2020-04-02 14:32:54 +02:00
print " <a href= ' " . $_SERVER [ 'PHP_SELF' ] . " ? " . ( empty ( $socid ) ? 'id' : 'socid' ) . " = " . $object -> id . " &type= " . $typeid . " &removeelem= " . $project -> id . " '> " ;
print $langs -> trans ( " DeleteFromCat " );
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' , '' , false , 0 , 0 , '' , 'paddingleft' );
print " </a> " ;
}
print " </tr> \n " ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-04-02 14:32:54 +02:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoItems " ) . '</td></tr>' ;
}
print " </table> \n " ;
print '</form>' . " \n " ;
}
}
2021-07-12 09:17:08 +02:00
if ( $type == Categorie :: TYPE_TICKET ) {
2021-07-01 19:30:00 +02:00
$permission = ( $user -> rights -> categorie -> creer || $user -> rights -> categorie -> creer );
$tickets = $object -> getObjectsInCateg ( $type , 0 , $limit , $offset );
2021-07-12 09:17:08 +02:00
if ( $tickets < 0 ) {
2021-07-01 19:30:00 +02:00
dol_print_error ( $db , $object -> error , $object -> errors );
} else {
// Form to add record into a category
$showclassifyform = 1 ;
2021-07-12 09:17:08 +02:00
if ( $showclassifyform ) {
2021-07-01 19:30:00 +02:00
print '<br>' ;
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="addintocategory">' ;
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre"><td>' ;
print $langs -> trans ( " AddTicketIntoCategory " ) . ' ' ;
2021-07-12 14:12:20 +02:00
$form -> selectTickets ( '' , 'elemid' );
2021-07-01 19:30:00 +02:00
print '<input type="submit" class="button buttongen" value="' . $langs -> trans ( " ClassifyInCategory " ) . '"></td>' ;
print '</tr>' ;
print '</table>' ;
print '</form>' ;
}
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="typeid" value="' . $typeid . '">' ;
print '<input type="hidden" name="type" value="' . $typeid . '">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<br>' ;
$param = '&limit=' . $limit . '&id=' . $id . '&type=' . $type ; $num = count ( $tickets ); $nbtotalofrecords = '' ; $newcardbutton = '' ;
print_barre_liste ( $langs -> trans ( " Ticket " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'ticket' , 0 , $newcardbutton , '' , $limit );
print '<table class="noborder centpercent">' . " \n " ;
print '<tr class="liste_titre"><td colspan="3">' . $langs -> trans ( " Ref " ) . '</td></tr>' . " \n " ;
2021-07-12 09:17:08 +02:00
if ( count ( $tickets ) > 0 ) {
2021-07-01 19:30:00 +02:00
$i = 0 ;
2021-07-12 09:17:08 +02:00
foreach ( $tickets as $ticket ) {
2021-07-01 19:30:00 +02:00
$i ++ ;
if ( $i > $limit ) break ;
print " \t " . '<tr class="oddeven">' . " \n " ;
print '<td class="nowrap" valign="top">' ;
print $ticket -> getNomUrl ( 1 );
print " </td> \n " ;
print '<td class="tdtop">' . $ticket -> label . " </td> \n " ;
// Link to delete from category
print '<td class="right">' ;
2021-07-12 09:17:08 +02:00
if ( $permission ) {
2021-07-01 19:30:00 +02:00
print " <a href= ' " . $_SERVER [ 'PHP_SELF' ] . " ? " . ( empty ( $socid ) ? 'id' : 'socid' ) . " = " . $object -> id . " &type= " . $typeid . " &removeelem= " . $ticket -> id . " '> " ;
print $langs -> trans ( " DeleteFromCat " );
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' , '' , false , 0 , 0 , '' , 'paddingleft' );
print " </a> " ;
}
print '</td>' ;
print " </tr> \n " ;
}
} else {
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoItems " ) . '</td></tr>' ;
}
print " </table> \n " ;
print '</form>' . " \n " ;
}
}
2020-04-02 14:32:54 +02:00
2018-07-29 13:40:35 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-03-28 19:39:56 +02:00
$db -> close ();