2018-03-10 04:23:59 +01:00
< ? php
2018-04-18 09:27:54 +02:00
/* Copyright ( C ) 2013 - 2018 Jean - François FERRY < hello @ librethic . io >
* Copyright ( C ) 2016 Christophe Battarel < christophe @ altairis . fr >
* Copyright ( C ) 2018 Regis Houssin < regis . houssin @ capnetworks . com >
2018-03-10 04:23:59 +01: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
2018-07-16 12:13:34 +02:00
* the Free Software Foundation ; either version 3 of the License , or
2018-03-10 04:23:59 +01: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
* along with this program . If not , see < http :// www . gnu . org / licenses />.
*/
/**
2018-06-04 21:49:29 +02:00
* \file htdocs / ticket / list . php
* \ingroup ticket
2018-07-16 12:13:34 +02:00
* \brief List page for tickets
2018-03-10 04:23:59 +01:00
*/
2018-03-11 10:34:21 +01:00
require '../main.inc.php' ;
2018-06-04 21:49:29 +02:00
require_once DOL_DOCUMENT_ROOT . '/ticket/class/actions_ticket.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formticket.class.php' ;
2018-03-10 04:23:59 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
2018-03-31 18:48:27 +02:00
include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
include_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php' ;
2018-03-10 04:23:59 +01:00
2018-05-26 16:35:29 +02:00
// Load translation files required by the page
2018-06-04 21:49:29 +02:00
$langs -> loadLangs ( array ( " ticket " , " companies " , " other " , " projects " ));
2018-03-10 04:23:59 +01:00
// Get parameters
$action = GETPOST ( 'action' , 'alpha' ) ? GETPOST ( 'action' , 'alpha' ) : '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
2018-06-04 21:49:29 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'ticketlist' ; // To manage different context of search
2018-03-10 04:23:59 +01:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' ); // Go back to a dedicated page
$optioncss = GETPOST ( 'optioncss' , 'aZ' ); // Option for the css output (always '' except when 'print')
$id = GETPOST ( 'id' , 'int' );
$msg_id = GETPOST ( 'msg_id' , 'int' );
$socid = GETPOST ( 'socid' , 'int' );
$projectid = GETPOST ( 'projectid' , 'int' );
2018-03-29 12:50:03 +02:00
$search_fk_soc = GETPOST ( '$search_fk_soc' , 'int' ) ? GETPOST ( '$search_fk_soc' , 'int' ) : GETPOST ( 'socid' , 'int' );
2018-03-29 12:31:17 +02:00
$search_fk_project = GETPOST ( 'search_fk_project' , 'int' ) ? GETPOST ( 'search_fk_project' , 'int' ) : GETPOST ( 'projectid' , 'int' );
2018-03-11 23:40:25 +01:00
$search_fk_status = GETPOST ( 'search_fk_status' , 'alpha' );
2018-03-10 04:23:59 +01:00
$mode = GETPOST ( 'mode' , 'alpha' );
// Load variable for pagination
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
$sortfield = GETPOST ( 'sortfield' , 'alpha' );
$sortorder = GETPOST ( 'sortorder' , 'alpha' );
$page = GETPOST ( 'page' , 'int' );
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
// Initialize technical objects
2018-06-04 21:49:29 +02:00
$object = new Ticket ( $db );
2018-03-10 04:23:59 +01:00
$extrafields = new ExtraFields ( $db );
2018-06-04 21:49:29 +02:00
$diroutputmassaction = $conf -> ticket -> dir_output . '/temp/massgeneration/' . $user -> id ;
2018-03-30 16:44:58 +02:00
if ( $socid > 0 ) $hookmanager -> initHooks ( array ( 'thirdpartyticket' ));
elseif ( $project > 0 ) $hookmanager -> initHooks ( array ( 'projectticket' ));
2018-06-04 21:49:29 +02:00
else $hookmanager -> initHooks ( array ( 'ticketlist' ));
2018-03-30 16:44:58 +02:00
2018-03-10 04:23:59 +01:00
// Fetch optionals attributes and labels
2018-06-04 21:49:29 +02:00
$extralabels = $extrafields -> fetch_name_optionals_label ( 'ticket' );
2018-03-10 04:23:59 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $extralabels , '' , 'search_' );
// Default sort order (if not yet defined by previous GETPOST)
if ( ! $sortfield ) $sortfield = " t. " . key ( $object -> fields ); // Set here default search field. By default 1st field in definition.
if ( ! $sortorder ) $sortorder = " ASC " ;
// Initialize array of search criterias
$search_all = trim ( GETPOST ( " search_all " , 'alpha' ));
$search = array ();
foreach ( $object -> fields as $key => $val )
{
2018-04-13 12:52:23 +02:00
if ( GETPOST ( 'search_' . $key , 'alpha' )) $search [ $key ] = GETPOST ( 'search_' . $key , 'alpha' );
2018-03-10 04:23:59 +01:00
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array ();
foreach ( $object -> fields as $key => $val )
{
2018-04-13 12:52:23 +02:00
if ( $val [ 'searchall' ]) $fieldstosearchall [ 't.' . $key ] = $val [ 'label' ];
2018-03-10 04:23:59 +01:00
}
// Definition of fields for list
$arrayfields = array ();
foreach ( $object -> fields as $key => $val )
{
2018-04-13 12:52:23 +02:00
// If $val['visible']==0, then we never show the field
if ( ! empty ( $val [ 'visible' ])) $arrayfields [ 't.' . $key ] = array ( 'label' => $val [ 'label' ], 'checked' => (( $val [ 'visible' ] < 0 ) ? 0 : 1 ), 'enabled' => $val [ 'enabled' ], 'position' => $val [ 'position' ]);
2018-03-10 04:23:59 +01:00
}
// Extra fields
2018-07-16 12:13:34 +02:00
if ( is_array ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) > 0 )
2018-03-10 04:23:59 +01:00
{
2018-04-13 12:52:23 +02:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val )
{
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'list' ][ $key ]))
$arrayfields [ " ef. " . $key ] = array ( 'label' => $extrafields -> attributes [ $object -> table_element ][ 'label' ][ $key ], 'checked' => (( $extrafields -> attributes [ $object -> table_element ][ 'list' ][ $key ] < 0 ) ? 0 : 1 ), 'position' => $extrafields -> attributes [ $object -> table_element ][ 'pos' ][ $key ], 'enabled' => ( abs ( $extrafields -> attributes [ $object -> table_element ][ 'list' ][ $key ]) != 3 && $extrafields -> attributes [ $object -> table_element ][ 'perms' ][ $key ]));
}
2018-03-10 04:23:59 +01:00
}
$object -> fields = dol_sort_array ( $object -> fields , 'position' );
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2018-03-29 12:52:35 +02:00
//if ($socid > 0) $arrayfields['t.fk_soc']['enabled']=0;
//if ($projectid > 0) $arrayfields['t.fk_project']['enabled']=0;
2018-03-10 04:23:59 +01:00
// Security check
2018-06-04 21:49:29 +02:00
if ( ! $user -> rights -> ticket -> read ) {
2018-03-10 04:23:59 +01:00
accessforbidden ();
}
// Store current page url
2018-06-04 21:49:29 +02:00
$url_page_current = dol_buildpath ( '/ticket/list.php' , 1 );
2018-03-10 04:23:59 +01:00
/*
* Actions
*/
if ( GETPOST ( 'cancel' , 'alpha' )) { $action = 'list' ; $massaction = '' ; }
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) { $massaction = '' ; }
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
if ( empty ( $reshook ))
{
2018-04-13 12:52:23 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) // All tests are required to be compatible with all browsers
{
foreach ( $object -> fields as $key => $val )
{
$search [ $key ] = '' ;
}
$toselect = '' ;
$search_array_options = array ();
}
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )
|| GETPOST ( 'button_search_x' , 'alpha' ) || GETPOST ( 'button_search.x' , 'alpha' ) || GETPOST ( 'button_search' , 'alpha' ))
{
$massaction = '' ; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
2018-04-15 16:35:18 +02:00
2018-04-13 12:52:23 +02:00
// Mass actions
2018-06-04 21:49:29 +02:00
$objectclass = 'Ticket' ;
$objectlabel = 'Ticket' ;
$permtoread = $user -> rights -> ticket -> read ;
$permtodelete = $user -> rights -> ticket -> delete ;
$uploaddir = $conf -> ticket -> dir_output ;
2018-04-13 12:52:23 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
2018-03-10 04:23:59 +01:00
}
2018-03-11 23:40:25 +01:00
/*
* View
*/
2018-07-16 12:13:34 +02:00
$form = new Form ( $db );
2018-06-04 21:49:29 +02:00
$formTicket = new FormTicket ( $db );
2018-03-10 04:23:59 +01:00
2018-07-16 12:13:34 +02:00
$now = dol_now ();
2018-03-10 04:23:59 +01:00
$user_assign = new User ( $db );
$user_create = new User ( $db );
$socstatic = new Societe ( $db );
2018-07-16 12:13:34 +02:00
$help_url = 'FR:DocumentationModuleTicket' ;
$title = $langs -> trans ( 'TicketList' );
llxHeader ( '' , $title , $help_url );
2018-03-10 04:23:59 +01:00
// Build and execute select
// --------------------------------------------------------------------
$sql = 'SELECT ' ;
foreach ( $object -> fields as $key => $val )
{
2018-04-13 12:52:23 +02:00
$sql .= 't.' . $key . ', ' ;
2018-03-10 04:23:59 +01:00
}
// Add fields from extrafields
2018-04-12 23:17:46 +02:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]))
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) $sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " ef. " . $key . ' as options_' . $key . ', ' : '' );
2018-03-10 04:23:59 +01:00
// Add fields from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters , $object ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
$sql = preg_replace ( '/, $/' , '' , $sql );
$sql .= " FROM " . MAIN_DB_PREFIX . $object -> table_element . " as t " ;
2018-07-16 12:13:34 +02:00
if ( is_array ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object -> table_element . " _extrafields as ef on (t.rowid = ef.fk_object) " ;
if ( $object -> ismultientitymanaged == 1 ) $sql .= " WHERE t.entity IN ( " . getEntity ( $object -> element ) . " ) " ;
2018-03-10 04:23:59 +01:00
else $sql .= " WHERE 1 = 1 " ;
foreach ( $search as $key => $val )
{
2018-03-13 13:56:45 +01:00
if ( $key == 'fk_statut' && $search [ $key ] == - 1 ) continue ;
2018-03-10 04:23:59 +01:00
$mode_search = (( $object -> isInt ( $object -> fields [ $key ]) || $object -> isFloat ( $object -> fields [ $key ])) ? 1 : 0 );
2018-03-13 13:56:45 +01:00
if ( $search [ $key ] != '' ) $sql .= natural_search ( $key , $search [ $key ], (( $key == 'fk_statut' ) ? 2 : $mode_search ));
2018-03-10 04:23:59 +01:00
}
if ( $search_all ) $sql .= natural_search ( array_keys ( $fieldstosearchall ), $search_all );
2018-09-14 13:07:27 +02:00
if ( $search_fk_soc ) $sql .= natural_search ( 'fk_soc' , $search_fk_soc , 2 );
if ( $search_fk_project ) $sql .= natural_search ( 'fk_project' , $search_fk_project , 2 );
2018-07-06 13:09:07 +02:00
if ( ! $user -> societe_id && ( $mode == " my_assign " || ( ! $user -> admin && $conf -> global -> TICKET_LIMIT_VIEW_ASSIGNED_ONLY ))) {
2018-03-10 04:23:59 +01:00
$sql .= " AND t.fk_user_assign= " . $user -> id ;
}
if ( isset ( $search_fk_status ) && $search_fk_status == 'non_closed' ) {
//$search['fk_statut'] = '0,1'; //
$sql .= " AND t.fk_statut IN (0, 1, 3, 4, 5, 6) " ;
}
// Add where from extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php' ;
// Add where from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters , $object ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
/* If a group by is required
2018-04-13 12:52:23 +02:00
$sql .= " GROUP BY "
foreach ( $object -> fields as $key => $val )
{
$sql .= 't.' . $key . ', ' ;
}
// Add fields from extrafields
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) $sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " ef. " . $key . ', ' : '' );
// Add where from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListGroupBy' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2018-07-16 12:13:34 +02:00
$sql = preg_replace ( '/, $/' , '' , $sql );
2018-04-13 12:52:23 +02:00
*/
2018-03-10 04:23:59 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
// Count total nb of records
$nbtotalofrecords = '' ;
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
{
2018-07-16 12:13:34 +02:00
$resql = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $resql );
if (( $page * $limit ) > $nbtotalofrecords ) // if total of record found is smaller than page * limit, goto and load page 0
2018-04-24 11:37:57 +02:00
{
$page = 0 ;
$offset = 0 ;
}
2018-03-10 04:23:59 +01:00
}
2018-07-16 12:13:34 +02:00
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
2018-03-10 04:23:59 +01:00
if ( is_numeric ( $nbtotalofrecords ) && $limit > $nbtotalofrecords )
{
2018-04-13 12:52:23 +02:00
$num = $nbtotalofrecords ;
2018-03-10 04:23:59 +01:00
}
else
{
2018-04-13 12:52:23 +02:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2018-03-11 18:28:27 +01:00
2018-04-13 12:52:23 +02:00
$resql = $db -> query ( $sql );
if ( ! $resql )
{
dol_print_error ( $db );
exit ;
}
2018-03-11 18:28:27 +01:00
2018-04-13 12:52:23 +02:00
$num = $db -> num_rows ( $resql );
2018-03-10 04:23:59 +01:00
}
// Direct jump if only one record found
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $search_all )
{
2018-04-13 12:52:23 +02:00
$obj = $db -> fetch_object ( $resql );
$id = $obj -> rowid ;
2018-06-04 21:49:29 +02:00
header ( " Location: " . DOL_URL_ROOT . '/ticket/card.php?id=' . $id );
2018-04-13 12:52:23 +02:00
exit ;
2018-03-10 04:23:59 +01:00
}
// Output page
// --------------------------------------------------------------------
if ( $socid && ! $projectid && $user -> rights -> societe -> lire ) {
$socstat = new Societe ( $db );
$res = $socstat -> fetch ( $socid );
if ( $res > 0 ) {
2018-03-13 13:26:03 +01:00
$tmpobject = $object ;
$object = $socstat ; // $object must be of type Societe when calling societe_prepare_head
2018-03-10 04:23:59 +01:00
$head = societe_prepare_head ( $socstat );
2018-03-13 13:26:03 +01:00
$object = $tmpobject ;
2018-06-04 21:49:29 +02:00
dol_fiche_head ( $head , 'ticket' , $langs -> trans ( " ThirdParty " ), - 1 , 'company' );
2018-03-10 04:23:59 +01:00
dol_banner_tab ( $socstat , 'socid' , '' , ( $user -> societe_id ? 0 : 1 ), 'rowid' , 'nom' );
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border centpercent">' ;
// Customer code
if ( $socstat -> client && ! empty ( $socstat -> code_client )) {
2018-03-13 13:26:03 +01:00
print '<tr><td class="titlefield">' ;
2018-04-17 14:49:21 +02:00
print $langs -> trans ( 'CustomerCode' ) . '</td><td>' ;
2018-03-10 04:23:59 +01:00
print $socstat -> code_client ;
if ( $socstat -> check_codeclient () != 0 ) {
print ' <font class="error">(' . $langs -> trans ( " WrongCustomerCode " ) . ')</font>' ;
}
print '</td>' ;
print '</tr>' ;
}
2018-04-17 14:51:08 +02:00
// Supplier code
if ( $socstat -> fournisseur && ! empty ( $socstat -> code_fournisseur )) {
print '<tr><td class="titlefield">' ;
print $langs -> trans ( 'SupplierCode' ) . '</td><td>' ;
print $socstat -> code_fournisseur ;
if ( $socstat -> check_codefournisseur () != 0 ) {
print ' <font class="error">(' . $langs -> trans ( " WrongSupplierCode " ) . ')</font>' ;
}
print '</td>' ;
print '</tr>' ;
}
2018-03-10 04:23:59 +01:00
print '</table>' ;
print '</div>' ;
dol_fiche_end ();
}
}
2018-03-29 12:31:17 +02:00
if ( $projectid > 0 ) {
2018-03-10 04:23:59 +01:00
$projectstat = new Project ( $db );
if ( $projectstat -> fetch ( $projectid ) > 0 ) {
$projectstat -> fetch_thirdparty ();
2018-03-29 12:31:17 +02:00
$savobject = $object ;
$object = $projectstat ;
2018-03-10 04:23:59 +01:00
// To verify role of users
//$userAccess = $object->restrictedProjectArea($user,'read');
$userWrite = $projectstat -> restrictedProjectArea ( $user , 'write' );
//$userDelete = $object->restrictedProjectArea($user,'delete');
//print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
$head = project_prepare_head ( $projectstat );
2018-06-04 21:49:29 +02:00
dol_fiche_head ( $head , 'ticket' , $langs -> trans ( " Project " ), - 1 , ( $projectstat -> public ? 'projectpub' : 'project' ));
2018-03-10 04:23:59 +01:00
2018-03-29 12:31:17 +02:00
// Project card
2018-03-10 04:23:59 +01:00
2018-03-29 12:31:17 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
$morehtmlref = '<div class="refidno">' ;
// Title
$morehtmlref .= $object -> title ;
// Thirdparty
if ( $object -> thirdparty -> id > 0 )
{
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' : ' . $object -> thirdparty -> getNomUrl ( 1 , 'project' );
}
$morehtmlref .= '</div>' ;
2018-03-10 04:23:59 +01:00
// Define a complementary filter for search of next/prev ref.
2018-03-29 12:31:17 +02:00
if ( ! $user -> rights -> projet -> all -> lire )
{
$objectsListId = $object -> getProjectsAuthorizedForUser ( $user , 0 , 0 );
$object -> next_prev_filter = " rowid in ( " . ( count ( $objectsListId ) ? join ( ',' , array_keys ( $objectsListId )) : '0' ) . " ) " ;
2018-03-10 04:23:59 +01:00
}
2018-03-29 12:31:17 +02:00
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
2018-03-10 04:23:59 +01:00
2018-03-29 12:31:17 +02:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2018-03-10 04:23:59 +01:00
2018-03-29 12:31:17 +02:00
print '<table class="border" width="100%">' ;
2018-03-10 04:23:59 +01:00
// Visibility
2018-03-29 12:31:17 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Visibility " ) . '</td><td>' ;
2018-03-10 04:23:59 +01:00
if ( $projectstat -> public ) {
print $langs -> trans ( 'SharedProject' );
} else {
print $langs -> trans ( 'PrivateProject' );
}
print '</td></tr>' ;
print " </table> " ;
print '</div>' ;
2018-03-29 12:31:17 +02:00
dol_fiche_end ();
$object = $savobject ;
2018-03-10 04:23:59 +01:00
} else {
print " ErrorRecordNotFound " ;
}
}
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
$param = '' ;
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . urlencode ( $contextpage );
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . urlencode ( $limit );
foreach ( $search as $key => $val )
{
2018-04-13 12:52:23 +02:00
$param .= '&search_' . $key . '=' . urlencode ( $search [ $key ]);
2018-03-10 04:23:59 +01:00
}
if ( $optioncss != '' ) $param .= '&optioncss=' . urlencode ( $optioncss );
// Add $param from extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
2018-03-29 12:50:03 +02:00
if ( $socid ) $param .= '&socid=' . urlencode ( $socid );
if ( $projectid ) $param .= '&projectid=' . urlencode ( $projectid );
2018-03-10 04:23:59 +01:00
// List of mass actions available
$arrayofmassactions = array (
2018-04-13 12:52:23 +02:00
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
2018-03-10 04:23:59 +01:00
);
2018-06-04 21:49:29 +02:00
if ( $user -> rights -> ticket -> delete ) $arrayofmassactions [ 'predelete' ] = $langs -> trans ( " Delete " );
2018-03-10 04:23:59 +01:00
if ( in_array ( $massaction , array ( 'presend' , 'predelete' ))) $arrayofmassactions = array ();
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="page" value="' . $page . '">' ;
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
print '<input type="hidden" name="mode" value="' . $mode . '" >' ;
2018-03-29 12:50:03 +02:00
if ( $socid ) print '<input type="hidden" name="socid" value="' . $socid . '" >' ;
if ( $projectid ) print '<input type="hidden" name="projectid" value="' . $projectid . '" >' ;
2018-03-10 04:23:59 +01:00
2018-04-15 17:37:49 +02:00
$newcardbutton = '' ;
2018-06-04 21:49:29 +02:00
if ( $user -> rights -> ticket -> write )
2018-04-15 17:37:49 +02:00
{
2018-06-13 22:57:41 +02:00
$newcardbutton = '<a class="butActionNew" href="' . DOL_URL_ROOT . '/ticket/new.php?action=create_ticket' . ( $socid ? '&socid=' . $socid : '' ) . ( $projectid ? '&origin=projet_project&originid=' . $projectid : '' ) . '"><span class="valignmiddle">' . $langs -> trans ( 'NewTicket' ) . '</span>' ;
2018-04-18 03:26:15 +02:00
$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>' ;
$newcardbutton .= '</a>' ;
2018-04-15 17:37:49 +02:00
}
2018-03-10 04:23:59 +01:00
2018-07-16 12:13:34 +02:00
print_barre_liste ( $title , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'title_ticket' , 0 , $newcardbutton , '' , $limit );
2018-03-10 04:23:59 +01:00
if ( $mode == 'my_assign' ) {
2018-03-11 23:40:25 +01:00
print '<div class="opacitymedium">' . $langs -> trans ( 'TicketAssignedToMeInfos' ) . '</div><br>' ;
2018-03-10 04:23:59 +01:00
}
// Add code for pre mass action (confirmation or email presend form)
2018-06-04 21:49:29 +02:00
$topicmail = " SendTicketRef " ;
$modelmail = " ticket " ;
$objecttmp = new Ticket ( $db );
2018-04-10 18:11:19 +02:00
$trackid = 'tick' . $object -> id ;
2018-03-10 04:23:59 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
if ( $sall )
{
2018-04-13 12:52:23 +02:00
foreach ( $fieldstosearchall as $key => $val ) $fieldstosearchall [ $key ] = $langs -> trans ( $val );
2018-06-22 22:53:53 +02:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
2018-03-10 04:23:59 +01:00
}
2018-06-13 22:57:41 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
2018-03-10 04:23:59 +01:00
if ( $search_fk_status == 'non_closed' ) {
2018-06-13 22:57:41 +02:00
print '<div class="divsearchfield"><a href="' . $url_page_current . '?search_fk_status=-1' . ( $socid ? '&socid=' . $socid : '' ) . '">' . $langs -> trans ( 'TicketViewAllTickets' ) . '</a></div>' ;
2018-03-10 04:23:59 +01:00
$param .= '&search_fk_status=non_closed' ;
} else {
2018-06-13 22:57:41 +02:00
print '<div class="divsearchfield"><a href="' . $url_page_current . '?search_fk_status=non_closed' . ( $socid ? '&socid=' . $socid : '' ) . '">' . $langs -> trans ( 'TicketViewNonClosedOnly' ) . '</a></div>' ;
2018-03-10 04:23:59 +01:00
$param .= '&search_fk_status=-1' ;
}
2018-06-13 22:57:41 +02:00
print '</div>' ;
2018-03-10 04:23:59 +01:00
$moreforfilter = '' ;
/* $moreforfilter .= '<div class="divsearchfield">' ;
2018-04-13 12:52:23 +02:00
$moreforfilter .= $langs -> trans ( 'MyFilter' ) . ': <input type="text" name="search_myfield" value="' . dol_escape_htmltag ( $search_myfield ) . '">' ;
$moreforfilter .= '</div>' ; */
2018-03-10 04:23:59 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters , $object ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook )) $moreforfilter .= $hookmanager -> resPrint ;
else $moreforfilter = $hookmanager -> resPrint ;
if ( ! empty ( $moreforfilter ))
{
2018-04-13 12:52:23 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
print '</div>' ;
2018-03-10 04:23:59 +01:00
}
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
$selectedfields .= ( count ( $arrayofmassactions ) ? $form -> showCheckAddButtons ( 'checkforselect' , 1 ) : '' );
print '<div class="div-table-responsive">' ; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre">' ;
foreach ( $object -> fields as $key => $val )
{
2018-04-13 12:52:23 +02:00
$align = '' ;
if ( in_array ( $val [ 'type' ], array ( 'date' , 'datetime' , 'timestamp' ))) $align .= ( $align ? ' ' : '' ) . 'center' ;
if ( in_array ( $val [ 'type' ], array ( 'timestamp' ))) $align .= ( $align ? ' ' : '' ) . 'nowrap' ;
if ( $key == 'status' ) $align .= ( $align ? ' ' : '' ) . 'center' ;
if ( ! empty ( $arrayfields [ 't.' . $key ][ 'checked' ])) {
if ( $key == 'type_code' ) {
print '<td class="liste_titre' . ( $align ? ' ' . $align : '' ) . '">' ;
$formTicket -> selectTypesTickets ( dol_escape_htmltag ( $search [ $key ]), 'search_' . $key . '' , '' , 0 , 1 , 1 , 0 , ( $val [ 'css' ] ? $val [ 'css' ] : 'maxwidth200' ));
print '</td>' ;
} elseif ( $key == 'category_code' ) {
print '<td class="liste_titre' . ( $align ? ' ' . $align : '' ) . '">' ;
$formTicket -> selectCategoriesTickets ( dol_escape_htmltag ( $search [ $key ]), 'search_' . $key . '' , '' , 0 , 1 , 1 , 0 , ( $val [ 'css' ] ? $val [ 'css' ] : 'maxwidth200' ));
print '</td>' ;
} elseif ( $key == 'severity_code' ) {
print '<td class="liste_titre' . ( $align ? ' ' . $align : '' ) . '">' ;
$formTicket -> selectSeveritiesTickets ( dol_escape_htmltag ( $search [ $key ]), 'search_' . $key . '' , '' , 0 , 1 , 1 , 0 , ( $val [ 'css' ] ? $val [ 'css' ] : 'maxwidth200' ));
print '</td>' ;
} elseif ( $key == 'fk_statut' ) {
print '<td class="liste_titre' . ( $align ? ' ' . $align : '' ) . '">' ;
$object -> printSelectStatus ( dol_escape_htmltag ( $search [ $key ]));
print '</td>' ;
}
else {
print '<td class="liste_titre' . ( $align ? ' ' . $align : '' ) . '"><input type="text" class="flat maxwidth75" name="search_' . $key . '" value="' . dol_escape_htmltag ( $search [ $key ]) . '"></td>' ;
}
}
2018-03-10 04:23:59 +01:00
}
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters , $object ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
// Action column
print '<td class="liste_titre" align="right">' ;
$searchpicto = $form -> showFilterButtons ();
print $searchpicto ;
print '</td>' ;
print '</tr>' . " \n " ;
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">' ;
foreach ( $object -> fields as $key => $val )
{
2018-04-13 12:52:23 +02:00
$align = '' ;
if ( in_array ( $val [ 'type' ], array ( 'date' , 'datetime' , 'timestamp' ))) $align .= ( $align ? ' ' : '' ) . 'center' ;
if ( in_array ( $val [ 'type' ], array ( 'timestamp' ))) $align .= ( $align ? ' ' : '' ) . 'nowrap' ;
if ( $key == 'status' ) $align .= ( $align ? ' ' : '' ) . 'center' ;
if ( ! empty ( $arrayfields [ 't.' . $key ][ 'checked' ])) print getTitleFieldOfList ( $arrayfields [ 't.' . $key ][ 'label' ], 0 , $_SERVER [ 'PHP_SELF' ], 't.' . $key , '' , $param , ( $align ? 'class="' . $align . '"' : '' ), $sortfield , $sortorder , $align . ' ' ) . " \n " ;
2018-03-10 04:23:59 +01:00
}
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
// Hook fields
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters , $object ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
print getTitleFieldOfList ( $selectedfields , 0 , $_SERVER [ " PHP_SELF " ], '' , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' ) . " \n " ;
print '</tr>' . " \n " ;
// Detect if we need a fetch on each output line
$needToFetchEachLine = 0 ;
2018-07-16 12:13:34 +02:00
if ( is_array ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ]) > 0 )
{
2018-04-18 09:27:54 +02:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ] as $key => $val )
{
if ( preg_match ( '/\$object/' , $val )) $needToFetchEachLine ++ ; // There is at least one compute field that use $object
}
2018-03-10 04:23:59 +01:00
}
2018-07-16 12:13:34 +02:00
2018-03-10 04:23:59 +01:00
// Loop on record
// --------------------------------------------------------------------
$i = 0 ;
$totalarray = array ();
while ( $i < min ( $num , $limit ))
{
2018-04-13 12:52:23 +02:00
$obj = $db -> fetch_object ( $resql );
if ( empty ( $obj )) break ; // Should not happen
// Store properties in $object
$object -> id = $obj -> rowid ;
foreach ( $object -> fields as $key => $val )
{
if ( isset ( $obj -> $key )) $object -> $key = $obj -> $key ;
}
// Show here line of result
print '<tr class="oddeven">' ;
foreach ( $object -> fields as $key => $val )
{
$align = '' ;
if ( in_array ( $val [ 'type' ], array ( 'date' , 'datetime' , 'timestamp' ))) $align .= ( $align ? ' ' : '' ) . 'center' ;
if ( in_array ( $val [ 'type' ], array ( 'timestamp' ))) $align .= ( $align ? ' ' : '' ) . 'nowrap' ;
if ( $key == 'status' ) $align .= ( $align ? ' ' : '' ) . 'center' ;
if ( ! empty ( $arrayfields [ 't.' . $key ][ 'checked' ]))
{
print '<td' ;
if ( $align ) print ' class="' . $align . '"' ;
print '>' ;
print $object -> showOutputField ( $val , $key , $obj -> $key , '' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
if ( ! empty ( $val [ 'isameasure' ]))
{
if ( ! $i ) $totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 't.' . $key ;
$totalarray [ 'val' ][ 't.' . $key ] += $obj -> $key ;
}
}
}
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj );
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters , $object ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
// Action column
print '<td class="nowrap" align="center">' ;
if ( $massactionbutton || $massaction ) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0 ;
if ( in_array ( $obj -> rowid , $arrayofselected )) $selected = 1 ;
print '<input id="cb' . $obj -> rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> rowid . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
}
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
print '</tr>' ;
$i ++ ;
2018-03-10 04:23:59 +01:00
}
// Show total line
if ( isset ( $totalarray [ 'pos' ]))
{
2018-04-13 12:52:23 +02:00
print '<tr class="liste_total">' ;
$i = 0 ;
while ( $i < $totalarray [ 'nbfield' ])
{
$i ++ ;
if ( ! empty ( $totalarray [ 'pos' ][ $i ])) print '<td align="right">' . price ( $totalarray [ 'val' ][ $totalarray [ 'pos' ][ $i ]]) . '</td>' ;
else
{
if ( $i == 1 )
{
if ( $num < $limit ) print '<td align="left">' . $langs -> trans ( " Total " ) . '</td>' ;
else print '<td align="left">' . $langs -> trans ( " Totalforthispage " ) . '</td>' ;
}
else print '<td></td>' ;
}
}
print '</tr>' ;
2018-03-10 04:23:59 +01:00
}
// If no record found
if ( $num == 0 )
{
2018-04-13 12:52:23 +02:00
$colspan = 1 ;
foreach ( $arrayfields as $key => $val ) { if ( ! empty ( $val [ 'checked' ])) $colspan ++ ; }
print '<tr><td colspan="' . $colspan . '" class="opacitymedium">' . $langs -> trans ( " NoRecordFound " ) . '</td></tr>' ;
2018-03-10 04:23:59 +01:00
}
$db -> free ( $resql );
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters , $object ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
print '</table>' . " \n " ;
print '</div>' . " \n " ;
print '</form>' . " \n " ;
if ( in_array ( 'builddoc' , $arrayofmassactions ) && ( $nbtotalofrecords === '' || $nbtotalofrecords ))
{
2018-04-13 12:52:23 +02:00
$hidegeneratedfilelistifempty = 1 ;
if ( $massaction == 'builddoc' || $action == 'remove_file' || $show_files ) $hidegeneratedfilelistifempty = 0 ;
2018-04-15 16:35:18 +02:00
2018-07-16 12:13:34 +02:00
require_once ( DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' );
2018-04-13 12:52:23 +02:00
$formfile = new FormFile ( $db );
2018-04-15 16:35:18 +02:00
2018-04-13 12:52:23 +02:00
// Show list of available documents
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder ;
$urlsource .= str_replace ( '&' , '&' , $param );
2018-04-15 16:35:18 +02:00
2018-04-13 12:52:23 +02:00
$filedir = $diroutputmassaction ;
2018-06-04 21:49:29 +02:00
$genallowed = $user -> rights -> ticket -> read ;
$delallowed = $user -> rights -> ticket -> write ;
2018-04-15 16:35:18 +02:00
2018-06-04 21:49:29 +02:00
print $formfile -> showdocuments ( 'massfilesarea_ticket' , '' , $filedir , $urlsource , 0 , $delallowed , '' , 1 , 1 , 0 , 48 , 1 , $param , $title , '' , '' , '' , null , $hidegeneratedfilelistifempty );
2018-03-10 04:23:59 +01:00
}
// End of page
2018-04-13 12:52:23 +02:00
llxFooter ();
2018-03-10 04:23:59 +01:00
$db -> close ();