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 >
2015-12-19 13:55:27 +01:00
* Copyright ( C ) 2006 - 2015 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 >
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-09-24 14:20:45 +02:00
$type = GETPOST ( 'type' , 'aZ09' );
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
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'myobjectlist' ; // To manage different context of search
$backtopage = GETPOST ( 'backtopage' , 'alpha' ); // Go back to a dedicated page
$optioncss = GETPOST ( 'optioncss' , 'aZ' ); // Option for the css output (always '' except when 'print')
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 ;
2019-09-10 01:44:36 +02:00
$sortfield = GETPOST ( 'sortfield' , 'alpha' );
$sortorder = GETPOST ( 'sortorder' , 'alpha' );
$page = GETPOST ( 'page' , 'int' );
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
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2017-07-10 12:47:21 +02:00
if ( $id == " " && $label == " " )
2006-03-30 17:02:24 +02:00
{
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 );
2019-11-13 19:35:39 +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
}
$object -> fetch_optionals ();
if ( $result <= 0 ) {
2019-01-27 11:55:16 +01:00
dol_print_error ( $db , $object -> error ); exit ;
2009-11-04 20:13:37 +01:00
}
2007-02-22 21:59:41 +01:00
2019-11-13 19:35:39 +01:00
$type = $object -> type ;
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
2017-01-22 12:13:32 +01:00
2007-02-22 21:59:41 +01:00
/*
2009-07-22 19:02:49 +02:00
* Actions
*/
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
if ( $id > 0 && $removeelem > 0 )
{
2015-05-23 18:52:31 +02:00
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' ;
}
2019-01-27 10:49:34 +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' ;
2013-06-05 16:24:32 +02:00
}
2019-01-27 10:49:34 +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' ;
2013-06-05 16:24:32 +02:00
}
2019-01-27 10:49:34 +01:00
elseif ( $type == Categorie :: TYPE_MEMBER && $user -> rights -> adherent -> creer )
2013-04-21 23:44:33 +02:00
{
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' ;
2013-06-05 16:24:32 +02:00
}
2019-01-27 10:49:34 +01: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' ;
2016-04-30 14:45:24 +02:00
}
2019-01-27 10:49:34 +01:00
elseif ( $type == Categorie :: TYPE_ACCOUNT && $user -> rights -> banque -> configurer )
2016-04-30 14:45:24 +02:00
{
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
$tmpobject = new Account ( $db );
$result = $tmpobject -> fetch ( $removeelem );
$elementtype = 'account' ;
}
2019-01-27 10:49:34 +01:00
elseif ( $type == Categorie :: TYPE_PROJECT && $user -> rights -> projet -> creer )
2016-08-29 10:32:00 +02:00
{
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
$tmpobject = new Project ( $db );
$result = $tmpobject -> fetch ( $removeelem );
$elementtype = 'project' ;
}
2020-02-03 11:01:58 +01:00
elseif ( $type == Categorie :: TYPE_USER && $user -> rights -> user -> user -> creer )
{
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
$tmpobject = new User ( $db );
$result = $tmpobject -> fetch ( $removeelem );
$elementtype = 'user' ;
}
2014-01-12 15:54:28 +01:00
2019-11-13 19:35:39 +01:00
$result = $object -> del_type ( $tmpobject , $elementtype );
2019-01-27 11:55:16 +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
2011-03-11 15:59:35 +01:00
if ( $user -> rights -> categorie -> supprimer && $action == 'confirm_delete' && $confirm == 'yes' )
2005-04-13 14:04:02 +02:00
{
2011-03-11 15:59:35 +01:00
if ( $object -> delete ( $user ) >= 0 )
2007-02-22 21:59:41 +01:00
{
2007-06-16 22:46:31 +02:00
header ( " Location: " . DOL_URL_ROOT . '/categories/index.php?type=' . $type );
2007-02-22 21:59:41 +01:00
exit ;
}
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
}
2015-05-23 18:52:31 +02:00
if ( $type == Categorie :: TYPE_PRODUCT && $elemid && $action == 'addintocategory' && ( $user -> rights -> produit -> creer || $user -> rights -> service -> creer ))
2014-10-07 21:39:10 +02:00
{
2014-10-09 17:18:14 +02:00
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php' ;
$newobject = new Product ( $db );
$result = $newobject -> fetch ( $elemid );
2014-10-07 21:39:10 +02:00
$elementtype = 'product' ;
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 );
2014-10-09 17:18:14 +02:00
if ( $result >= 0 )
{
2019-01-27 11:55:16 +01:00
setEventMessages ( $langs -> trans ( " WasAddedSuccessfully " , $newobject -> ref ), null , 'mesgs' );
2014-10-09 17:18:14 +02:00
}
else
{
if ( $cat -> error == 'DB_ERROR_RECORD_ALREADY_EXISTS' )
{
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> trans ( " ObjectAlreadyLinkedToCategory " ), null , 'warnings' );
2014-10-09 17:18:14 +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
2019-11-13 19:35:39 +01:00
$helpurl = '' ;
2019-01-27 11:55:16 +01:00
llxHeader ( " " , $langs -> trans ( " Categories " ), $helpurl );
2007-02-22 21:59:41 +01:00
2019-11-13 19:35:39 +01:00
if ( $type == Categorie :: TYPE_PRODUCT ) $title = $langs -> trans ( " ProductsCategoryShort " );
elseif ( $type == Categorie :: TYPE_SUPPLIER ) $title = $langs -> trans ( " SuppliersCategoryShort " );
elseif ( $type == Categorie :: TYPE_CUSTOMER ) $title = $langs -> trans ( " CustomersCategoryShort " );
elseif ( $type == Categorie :: TYPE_MEMBER ) $title = $langs -> trans ( " MembersCategoryShort " );
elseif ( $type == Categorie :: TYPE_CONTACT ) $title = $langs -> trans ( " ContactCategoriesShort " );
elseif ( $type == Categorie :: TYPE_ACCOUNT ) $title = $langs -> trans ( " AccountsCategoriesShort " );
elseif ( $type == Categorie :: TYPE_PROJECT ) $title = $langs -> trans ( " ProjectsCategoriesShort " );
2020-02-03 09:50:44 +01:00
elseif ( $type == Categorie :: TYPE_USER ) $title = $langs -> trans ( " UsersCategoriesShort " );
2019-11-13 19:35:39 +01:00
else $title = $langs -> trans ( " Category " );
2007-11-10 13:51:57 +01:00
2019-01-27 11:55:16 +01:00
$head = categories_prepare_head ( $object , $type );
2015-05-14 20:49:22 +02:00
2017-01-22 12:13:32 +01:00
2017-04-05 14:48:24 +02:00
dol_fiche_head ( $head , 'card' , $title , - 1 , 'category' );
2019-12-18 12:29:52 +01:00
$backtolist = ( GETPOST ( 'backtolist' ) ? GETPOST ( 'backtolist' ) : DOL_URL_ROOT . '/categories/index.php?leftmenu=cat&type=' . $type );
$linkback = '<a href="' . $backtolist . '\">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2017-07-10 12:47:21 +02:00
$object -> next_prev_filter = " type = " . $object -> type ;
2017-01-22 12:13:32 +01:00
$object -> ref = $object -> label ;
$morehtmlref = '<br><div class="refidno"><a href="' . DOL_URL_ROOT . '/categories/index.php?leftmenu=cat&type=' . $type . '">' . $langs -> trans ( " Root " ) . '</a> >> ' ;
$ways = $object -> print_all_ways ( " >> " , '' , 1 );
foreach ( $ways as $way )
{
$morehtmlref .= $way . " <br> \n " ;
}
$morehtmlref .= '</div>' ;
2019-10-31 20:46:31 +01:00
dol_banner_tab ( $object , 'label' , $linkback , ( $user -> socid ? 0 : 1 ), 'label' , 'label' , $morehtmlref , '' , 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
2011-03-11 15:59:35 +01:00
if ( $action == 'delete' )
2007-02-22 21:59:41 +01:00
{
2016-11-14 01:10:16 +01:00
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>' ;
print '<table width="100%" class="border">' ;
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
2015-05-14 20:49:22 +02:00
dol_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 " ;
if ( $user -> rights -> categorie -> creer )
{
2011-03-11 15:59:35 +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> " ;
2006-08-15 20:52:02 +02:00
}
if ( $user -> rights -> categorie -> supprimer )
{
2011-03-11 15:59:35 +01:00
print " <a class='butActionDelete' href=' " . DOL_URL_ROOT . " /categories/viewcat.php?action=delete&id= " . $object -> id . " &type= " . $type . " '> " . $langs -> trans ( " Delete " ) . " </a> " ;
2006-08-15 20:52:02 +02:00
}
2005-04-13 14:04:02 +02:00
print " </div> " ;
2006-08-15 20:52:02 +02:00
2011-03-11 15:59:35 +01:00
$cats = $object -> get_filles ();
2005-04-13 14:04:02 +02:00
if ( $cats < 0 )
{
2015-05-04 12:29:26 +02:00
dol_print_error ( $db , $cats -> error , $cats -> errors );
2005-04-13 14:04:02 +02:00
}
else
{
2006-03-03 21:52:01 +01:00
print " <br> " ;
print " <table class='noborder' width='100%'> \n " ;
2019-01-22 13:56:14 +01:00
print " <tr class='liste_titre'><td colspan='2'> " . $langs -> trans ( " SubCats " ) . '</td><td class="right">' ;
2010-03-20 01:07:47 +01:00
if ( $user -> rights -> categorie -> creer )
{
2014-09-18 21:18:25 +02:00
print " <a href=' " . DOL_URL_ROOT . " /categories/card.php?action=create&catorigin= " . $object -> id . " &socid= " . $object -> socid . " &type= " . $type . " &urlfrom= " . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&type=' . $type ) . " '> " ;
2019-01-27 11:55:16 +01:00
print img_picto ( $langs -> trans ( " Create " ), 'filenew' );
2010-03-20 01:07:47 +01:00
print " </a> " ;
}
print " </td> " ;
print " </tr> \n " ;
2011-08-28 04:18:20 +02:00
if ( count ( $cats ) > 0 )
2009-01-30 22:21:22 +01:00
{
2006-03-03 21:52:01 +01:00
foreach ( $cats as $cat )
2017-06-07 16:44:04 +02:00
{
2017-05-06 10:54:28 +02:00
print " \t " . '<tr class="oddeven">' . " \n " ;
2015-05-12 15:37:35 +02:00
print " \t \t " . '<td class="nowrap">' ;
2009-01-30 22:21:22 +01:00
print " <a href='viewcat.php?id= " . $cat -> id . " &type= " . $type . " '> " . $cat -> label . " </a> " ;
print " </td> \n " ;
2010-03-20 01:07:47 +01:00
print " \t \t " . '<td colspan="2">' . $cat -> description . " </td> \n " ;
2009-01-30 22:21:22 +01:00
2010-03-13 00:59:23 +01:00
/*
2006-03-30 17:02:24 +02:00
if ( $cat -> visible == 1 )
{
print " \t \t <td> " . $langs -> trans ( " ContentsVisibleByAllShort " ) . " </td> \n " ;
}
else
{
2006-03-30 17:17:39 +02:00
print " \t \t <td> " . $langs -> trans ( " ContentsNotVisibleByAllShort " ) . " </td> \n " ;
2006-03-30 17:02:24 +02:00
}
2010-03-13 00:59:23 +01:00
*/
2009-01-30 22:21:22 +01:00
2006-03-03 21:52:01 +01:00
print " \t </tr> \n " ;
}
}
else
{
2019-03-15 10:48:10 +01:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " NoSubCat " ) . '</td></tr>' ;
2006-03-03 21:52:01 +01:00
}
print " </table> \n " ;
2005-04-13 14:04:02 +02:00
}
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
2014-10-07 21:39:10 +02:00
// List of products or services (type is type of category)
2017-10-03 12:08:25 +02:00
if ( $type == Categorie :: TYPE_PRODUCT )
2005-04-13 14:04:02 +02:00
{
2019-09-10 01:44:36 +02:00
$prods = $object -> getObjectsInCateg ( " product " , 0 , $limit , $offset );
2007-04-30 12:53:58 +02:00
if ( $prods < 0 )
{
2015-05-04 12:29:26 +02:00
dol_print_error ( $db , $prods -> error , $prods -> errors );
2007-04-30 12:53:58 +02:00
}
else
{
2019-11-13 19:35:39 +01:00
$showclassifyform = 1 ; $typeid = Categorie :: TYPE_PRODUCT ;
2015-05-04 12:29:26 +02:00
2014-10-09 17:18:14 +02:00
// Form to add record into a category
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 );
2014-10-09 17:18:14 +02:00
print '<input type="submit" class="button" value="' . $langs -> trans ( " ClassifyInCategory " ) . '"></td>' ;
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 = '' ;
print_barre_liste ( $langs -> trans ( " ProductsAndServices " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , '' , 0 , $newcardbutton , '' , $limit );
2007-04-30 12:53:58 +02:00
print " <table class='noborder' width='100%'> \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
2011-08-28 04:18:20 +02:00
if ( count ( $prods ) > 0 )
2007-04-30 12:53:58 +02:00
{
2019-09-10 01:44:36 +02:00
$i = 0 ;
2007-04-30 12:53:58 +02:00
foreach ( $prods as $prod )
2017-06-07 16:44:04 +02:00
{
2019-09-10 01:44:36 +02:00
$i ++ ;
if ( $i > $limit ) break ;
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">' ;
2019-11-13 19:35:39 +01:00
$permission = 0 ;
if ( $type == Categorie :: TYPE_PRODUCT ) $permission = ( $user -> rights -> produit -> creer || $user -> rights -> service -> creer );
if ( $type == Categorie :: TYPE_SUPPLIER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_CUSTOMER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_MEMBER ) $permission = $user -> rights -> adherent -> creer ;
if ( $type == Categorie :: TYPE_PROJECT ) $permission = $user -> rights -> projet -> creer ;
2013-04-21 23:44:33 +02: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 " );
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' );
print " </a> " ;
2013-04-21 23:44:33 +02:00
}
print '</td>' ;
2007-04-30 12:53:58 +02:00
print " </tr> \n " ;
}
}
else
{
2019-03-15 10:48:10 +01:00
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoProduct " ) . '</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
2017-10-03 12:08:25 +02:00
if ( $type == Categorie :: TYPE_SUPPLIER )
2005-04-13 14:04:02 +02:00
{
2019-09-10 01:44:36 +02:00
$socs = $object -> getObjectsInCateg ( " supplier " , 0 , $limit , $offset );
2007-04-30 12:53:58 +02:00
if ( $socs < 0 )
2006-03-03 21:52:01 +01:00
{
2015-05-04 12:29:26 +02:00
dol_print_error ( $db , $socs -> error , $socs -> errors );
2007-04-30 12:53:58 +02:00
}
else
{
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 = '' ;
print_barre_liste ( $langs -> trans ( " Suppliers " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , '' , 0 , $newcardbutton , '' , $limit );
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 ( " Name " ) . " </td></tr> \n " ;
2009-01-30 22:21:22 +01:00
2011-08-28 04:18:20 +02:00
if ( count ( $socs ) > 0 )
2006-03-03 21:52:01 +01:00
{
2019-09-10 01:44:36 +02:00
$i = 0 ;
2007-04-30 12:53:58 +02:00
foreach ( $socs as $soc )
2017-06-07 16:44:04 +02:00
{
2019-09-10 01:44:36 +02:00
$i ++ ;
if ( $i > $limit ) break ;
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">' ;
2019-11-13 19:35:39 +01:00
$permission = 0 ;
if ( $type == Categorie :: TYPE_PRODUCT ) $permission = ( $user -> rights -> produit -> creer || $user -> rights -> service -> creer );
if ( $type == Categorie :: TYPE_SUPPLIER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_CUSTOMER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_MEMBER ) $permission = $user -> rights -> adherent -> creer ;
if ( $type == Categorie :: TYPE_PROJECT ) $permission = $user -> rights -> projet -> creer ;
2013-06-05 16:24:32 +02: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 " );
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' );
print " </a> " ;
2013-06-05 16:24:32 +02:00
}
print '</td>' ;
2014-01-12 15:54:28 +01:00
2007-04-30 12:53:58 +02:00
print " </tr> \n " ;
}
2006-03-03 21:52:01 +01:00
}
2007-04-30 12:53:58 +02:00
else
{
2019-03-15 10:48:10 +01:00
print '<tr class="oddeven"><td class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoSupplier " ) . '</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
}
}
2019-11-13 19:35:39 +01:00
if ( $type == Categorie :: TYPE_CUSTOMER )
2007-04-30 12:53:58 +02:00
{
2019-09-10 01:44:36 +02:00
$socs = $object -> getObjectsInCateg ( " customer " , 0 , $limit , $offset );
2007-04-30 12:53:58 +02:00
if ( $socs < 0 )
{
2015-05-04 12:29:26 +02:00
dol_print_error ( $db , $socs -> error , $socs -> errors );
2006-03-03 21:52:01 +01:00
}
else
{
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 = '' ;
print_barre_liste ( $langs -> trans ( " Customers " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , '' , 0 , $newcardbutton , '' , $limit );
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 ( " Name " ) . '</td></tr>' . " \n " ;
2009-01-30 22:21:22 +01:00
2011-08-28 04:18:20 +02:00
if ( count ( $socs ) > 0 )
2007-04-30 12:53:58 +02:00
{
$i = 0 ;
2010-03-20 21:24:32 +01:00
foreach ( $socs as $key => $soc )
2007-04-30 12:53:58 +02:00
{
$i ++ ;
2019-09-10 01:44:36 +02: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">' ;
2019-11-13 19:35:39 +01:00
$permission = 0 ;
if ( $type == Categorie :: TYPE_PRODUCT ) $permission = ( $user -> rights -> produit -> creer || $user -> rights -> service -> creer );
if ( $type == Categorie :: TYPE_SUPPLIER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_CUSTOMER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_MEMBER ) $permission = $user -> rights -> adherent -> creer ;
if ( $type == Categorie :: TYPE_PROJECT ) $permission = $user -> rights -> projet -> creer ;
2013-06-05 16:24:32 +02: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 " );
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' );
print " </a> " ;
2013-06-05 16:24:32 +02:00
}
2013-04-21 23:44:33 +02:00
print '</td>' ;
2007-04-30 12:53:58 +02:00
print " </tr> \n " ;
}
}
else
{
2019-03-15 10:48:10 +01:00
print '<tr class="oddeven"><td class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoCustomer " ) . '</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
2017-10-03 12:08:25 +02:00
if ( $type == Categorie :: TYPE_MEMBER )
2010-03-20 01:07:47 +01:00
{
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
2019-09-10 01:44:36 +02:00
$prods = $object -> getObjectsInCateg ( " member " , 0 , $limit , $offset );
2010-03-20 01:07:47 +01:00
if ( $prods < 0 )
{
2015-05-04 12:29:26 +02:00
dol_print_error ( $db , $prods -> error , $prods -> errors );
2010-03-20 01:07:47 +01:00
}
else
{
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 = '' ;
print_barre_liste ( $langs -> trans ( " Member " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , '' , 0 , $newcardbutton , '' , $limit );
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
2011-08-28 04:18:20 +02:00
if ( count ( $prods ) > 0 )
2010-03-20 01:07:47 +01:00
{
2019-09-10 01:44:36 +02:00
$i = 0 ;
2010-03-20 21:24:32 +01:00
foreach ( $prods as $key => $member )
2017-06-07 16:44:04 +02:00
{
2019-09-10 01:44:36 +02:00
$i ++ ;
if ( $i > $limit ) break ;
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">' ;
2019-11-13 19:35:39 +01:00
$permission = 0 ;
if ( $type == Categorie :: TYPE_PRODUCT ) $permission = ( $user -> rights -> produit -> creer || $user -> rights -> service -> creer );
if ( $type == Categorie :: TYPE_SUPPLIER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_CUSTOMER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_MEMBER ) $permission = $user -> rights -> adherent -> creer ;
if ( $type == Categorie :: TYPE_PROJECT ) $permission = $user -> rights -> projet -> creer ;
2013-04-21 23:44:33 +02: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 " );
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' );
print " </a> " ;
2013-04-21 23:44:33 +02:00
}
2010-03-20 01:07:47 +01:00
print " </tr> \n " ;
}
}
else
{
2019-03-15 10:48:10 +01:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoMember " ) . '</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
2017-10-03 12:08:25 +02:00
if ( $type == Categorie :: TYPE_CONTACT )
2013-07-30 17:04:09 +02:00
{
2019-09-10 01:44:36 +02:00
$contacts = $object -> getObjectsInCateg ( " contact " , 0 , $limit , $offset );
2013-07-30 17:04:09 +02:00
if ( $contacts < 0 )
{
2015-05-04 12:29:26 +02:00
dol_print_error ( $db , $contacts -> error , $contacts -> errors );
2013-07-30 17:04:09 +02:00
}
else
{
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 ( $contacts ); $nbtotalofrecords = '' ; $newcardbutton = '' ;
print_barre_liste ( $langs -> trans ( " Contact " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , '' , 0 , $newcardbutton , '' , $limit );
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
if ( count ( $contacts ) > 0 )
{
$i = 0 ;
foreach ( $contacts as $key => $contact )
{
$i ++ ;
2019-09-10 01:44:36 +02: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' );
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">' ;
2019-11-13 19:35:39 +01:00
$permission = 0 ;
if ( $type == Categorie :: TYPE_PRODUCT ) $permission = ( $user -> rights -> produit -> creer || $user -> rights -> service -> creer );
if ( $type == Categorie :: TYPE_SUPPLIER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_CUSTOMER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_MEMBER ) $permission = $user -> rights -> adherent -> creer ;
if ( $type == Categorie :: TYPE_PROJECT ) $permission = $user -> rights -> projet -> creer ;
2013-07-30 17:04:09 +02: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 " );
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' );
print " </a> " ;
2013-07-30 17:04:09 +02:00
}
print '</td>' ;
print " </tr> \n " ;
}
}
else
{
2019-03-15 10:48:10 +01:00
print '<tr class="oddeven"><td class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoContact " ) . '</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
}
}
2016-04-30 14:45:24 +02:00
// List of accounts
2017-10-03 12:08:25 +02:00
if ( $type == Categorie :: TYPE_ACCOUNT )
2016-04-30 14:45:24 +02:00
{
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
2019-09-10 01:44:36 +02:00
$accounts = $object -> getObjectsInCateg ( " account " , 0 , $limit , $offset );
2016-04-30 14:45:24 +02:00
if ( $accounts < 0 )
{
dol_print_error ( $db , $accounts -> error , $accounts -> errors );
}
else
{
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 ( $accounts ); $nbtotalofrecords = '' ; $newcardbutton = '' ;
print_barre_liste ( $langs -> trans ( " Account " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , '' , 0 , $newcardbutton , '' , $limit );
print " <table class='noborder' width='100%'> \n " ;
print '<tr class="liste_titre"><td colspan="4">' . $langs -> trans ( " Ref " ) . '</td></tr>' . " \n " ;
2016-04-30 14:45:24 +02:00
if ( count ( $accounts ) > 0 )
{
2019-09-10 01:44:36 +02:00
$i = 0 ;
2016-04-30 14:45:24 +02:00
foreach ( $accounts as $key => $account )
2017-06-07 16:44:04 +02:00
{
2019-09-10 01:44:36 +02:00
$i ++ ;
if ( $i > $limit ) break ;
2017-05-06 10:54:28 +02:00
print " \t " . '<tr class="oddeven">' . " \n " ;
2016-04-30 14:45:24 +02:00
print '<td class="nowrap" valign="top">' ;
2019-01-27 11:55:16 +01:00
print $account -> getNomUrl ( 1 , 0 );
2016-04-30 14:45:24 +02:00
print " </td> \n " ;
2017-01-22 12:13:32 +01:00
print '<td class="tdtop">' . $account -> bank . " </td> \n " ;
print '<td class="tdtop">' . $account -> number . " </td> \n " ;
2016-04-30 14:45:24 +02:00
// Link to delete from category
2019-01-22 13:56:14 +01:00
print '<td class="right">' ;
2019-11-13 19:35:39 +01:00
$permission = 0 ;
if ( $type == Categorie :: TYPE_PRODUCT ) $permission = ( $user -> rights -> produit -> creer || $user -> rights -> service -> creer );
if ( $type == Categorie :: TYPE_SUPPLIER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_CUSTOMER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_MEMBER ) $permission = $user -> rights -> adherent -> creer ;
if ( $type == Categorie :: TYPE_PROJECT ) $permission = $user -> rights -> projet -> creer ;
2016-04-30 14:45:24 +02: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= " . $account -> id . " '> " ;
2019-03-15 10:48:10 +01:00
print $langs -> trans ( " DeleteFromCat " );
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' );
print " </a> " ;
2016-04-30 14:45:24 +02:00
}
print " </tr> \n " ;
}
}
else
{
2019-03-15 10:48:10 +01:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoAccount " ) . '</td></tr>' ;
2016-04-30 14:45:24 +02:00
}
print " </table> \n " ;
2019-09-10 01:44:36 +02:00
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
2017-10-03 12:08:25 +02:00
if ( $type == Categorie :: TYPE_PROJECT )
2016-08-29 10:41:14 +02:00
{
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
2019-09-10 01:44:36 +02:00
$projects = $object -> getObjectsInCateg ( " project " , 0 , $limit , $offset );
2016-08-29 10:41:14 +02:00
if ( $projects < 0 )
{
dol_print_error ( $db , $object -> error , $object -> errors );
}
else
{
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 ( $projects ); $nbtotalofrecords = '' ; $newcardbutton = '' ;
print_barre_liste ( $langs -> trans ( " Project " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , '' , 0 , $newcardbutton , '' , $limit );
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
if ( count ( $projects ) > 0 )
{
2019-09-10 01:44:36 +02:00
$i = 0 ;
2016-08-29 10:41:14 +02:00
foreach ( $projects as $key => $project )
2017-06-07 16:44:04 +02:00
{
2019-09-10 01:44:36 +02:00
$i ++ ;
if ( $i > $limit ) break ;
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">' ;
2019-11-13 19:35:39 +01:00
$permission = 0 ;
if ( $type == Categorie :: TYPE_PRODUCT ) $permission = ( $user -> rights -> produit -> creer || $user -> rights -> service -> creer );
if ( $type == Categorie :: TYPE_SUPPLIER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_CUSTOMER ) $permission = $user -> rights -> societe -> creer ;
if ( $type == Categorie :: TYPE_MEMBER ) $permission = $user -> rights -> adherent -> creer ;
if ( $type == Categorie :: TYPE_PROJECT ) $permission = $user -> rights -> projet -> creer ;
2016-08-29 10:41:14 +02: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 " );
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' );
print " </a> " ;
2016-08-29 10:41:14 +02:00
}
print " </tr> \n " ;
}
}
else
{
2019-03-15 10:48:10 +01:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoProject " ) . '</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
if ( $type == Categorie :: TYPE_USER )
{
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
$users = $object -> getObjectsInCateg ( " user " );
if ( $users < 0 )
{
dol_print_error ( $db , $object -> error , $object -> errors );
}
else
{
print " <br> " ;
print " <table class='noborder' width='100%'> \n " ;
print '<tr class="liste_titre"><td colspan="4">' . $langs -> trans ( " Users " ) . ' <span class="badge">' . count ( $users ) . '</span></td></tr>' . " \n " ;
if ( count ( $users ) > 0 )
{
// Use "$userentry" here, because "$user" is the current user
foreach ( $users as $key => $userentry )
{
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">' ;
if ( $user -> rights -> user -> user -> creer )
{
print " <a href= ' " . $_SERVER [ 'PHP_SELF' ] . " ? " . ( empty ( $socid ) ? 'id' : 'socid' ) . " = " . $object -> id . " &type= " . $type . " &removeelem= " . $userentry -> id . " '> " ;
print $langs -> trans ( " DeleteFromCat " );
print img_picto ( $langs -> trans ( " DeleteFromCat " ), 'unlink' );
print " </a> " ;
}
print " </tr> \n " ;
}
}
else
{
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " ThisCategoryHasNoUsers " ) . '</td></tr>' ;
}
print " </table> \n " ;
}
}
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 ();