2011-08-21 15:01:34 +02:00
< ? php
2012-08-16 19:18:24 +02:00
/* Copyright ( C ) 2002 - 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2014-08-15 23:20:31 +02:00
* Copyright ( C ) 2004 - 2014 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2012-08-16 19:18:24 +02:00
* Copyright ( C ) 2011 - 2012 Juanjo Menent < jmenent @ 2 byte . es >
2013-09-10 16:43:06 +02:00
* Copyright ( C ) 2013 Cédric Salvador < csalvador @ gpcsolutions . fr >
2016-07-06 10:28:34 +02:00
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
2011-08-21 15:01:34 +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
2011-08-21 15:01:34 +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
* along with this program . If not , see < http :// www . gnu . org / licenses />.
*/
/**
* \file htdocs / fichinter / list . php
* \brief List of all interventions
* \ingroup ficheinter
*/
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2016-08-23 15:43:48 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2011-08-21 15:01:34 +02:00
$langs -> load ( " companies " );
2014-09-06 19:10:59 +02:00
$langs -> load ( " bills " );
2011-08-21 15:01:34 +02:00
$langs -> load ( " interventions " );
2017-04-09 14:31:56 +02:00
$action = GETPOST ( 'action' , 'alpha' );
$massaction = GETPOST ( 'massaction' , 'alpha' );
$show_files = GETPOST ( 'show_files' , 'int' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$toselect = GETPOST ( 'toselect' , 'array' );
$search_ref = GETPOST ( 'search_ref' ) ? GETPOST ( 'search_ref' , 'alpha' ) : GETPOST ( 'search_inter' , 'alpha' );
$search_company = GETPOST ( 'search_company' , 'alpha' );
$search_desc = GETPOST ( 'search_desc' , 'alpha' );
$search_status = GETPOST ( 'search_status' );
2017-12-12 11:31:30 +01:00
$sall = trim (( GETPOST ( 'search_all' , 'alphanohtml' ) != '' ) ? GETPOST ( 'search_all' , 'alphanohtml' ) : GETPOST ( 'sall' , 'alphanohtml' ));
2017-04-09 14:31:56 +02:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2012-02-27 22:26:22 +01:00
$socid = GETPOST ( 'socid' , 'int' );
2011-08-21 15:01:34 +02:00
// Security check
2017-04-09 14:31:56 +02:00
$id = GETPOST ( 'id' , 'int' );
2011-08-21 15:01:34 +02:00
if ( $user -> societe_id ) $socid = $user -> societe_id ;
2017-04-09 14:31:56 +02:00
$result = restrictedArea ( $user , 'ficheinter' , $id , 'fichinter' );
$diroutputmassaction = $conf -> ficheinter -> dir_output . '/temp/massgeneration/' . $user -> id ;
2011-08-21 15:01:34 +02:00
2016-02-11 20:40:33 +01:00
$limit = GETPOST ( 'limit' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2012-06-01 10:52:39 +02:00
$sortfield = GETPOST ( 'sortfield' , 'alpha' );
$sortorder = GETPOST ( 'sortorder' , 'alpha' );
$page = GETPOST ( 'page' , 'int' );
2017-06-06 10:53:53 +02:00
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
2015-12-16 19:38:40 +01:00
$offset = $limit * $page ;
2012-06-01 10:52:39 +02:00
$pageprev = $page - 1 ;
2012-03-05 11:16:30 +01:00
$pagenext = $page + 1 ;
2011-08-21 15:01:34 +02:00
if ( ! $sortorder ) $sortorder = " DESC " ;
2014-10-17 13:09:18 +02:00
if ( ! $sortfield )
{
if ( empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS )) $sortfield = " fd.date " ;
else $sortfield = " f.ref " ;
}
2011-08-21 15:01:34 +02:00
2017-04-09 14:31:56 +02:00
// Initialize technical object to manage context to save list fields
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'interventionlist' ;
2011-08-21 15:01:34 +02:00
2017-12-12 11:31:30 +01:00
$sall = trim (( GETPOST ( 'search_all' , 'alphanohtml' ) != '' ) ? GETPOST ( 'search_all' , 'alphanohtml' ) : GETPOST ( 'sall' , 'alphanohtml' ));
2014-11-03 17:48:10 +01:00
$search_ref = GETPOST ( 'search_ref' ) ? GETPOST ( 'search_ref' , 'alpha' ) : GETPOST ( 'search_inter' , 'alpha' );
2012-03-05 11:16:30 +01:00
$search_company = GETPOST ( 'search_company' , 'alpha' );
$search_desc = GETPOST ( 'search_desc' , 'alpha' );
2014-09-06 19:10:59 +02:00
$search_status = GETPOST ( 'search_status' );
2015-10-04 10:45:57 +02:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2011-08-21 15:01:34 +02:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2017-04-09 14:31:56 +02:00
$hookmanager -> initHooks ( array ( $contextpage ));
2016-07-06 10:28:34 +02:00
$extrafields = new ExtraFields ( $db );
// fetch optionals attributes and labels
$extralabels = $extrafields -> fetch_name_optionals_label ( 'fichinter' );
$search_array_options = $extrafields -> getOptionalsFromPost ( $extralabels , '' , 'search_' );
2011-08-21 15:01:34 +02:00
2015-10-17 00:52:35 +02:00
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
2017-10-13 13:28:26 +02:00
'f.ref' => 'Ref' ,
's.nom' => " ThirdParty " ,
'f.description' => 'Description' ,
'f.note_public' => 'NotePublic' ,
2015-10-17 00:52:35 +02:00
);
if ( empty ( $user -> socid )) $fieldstosearchall [ " f.note_private " ] = " NotePrivate " ;
if ( ! empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS )) unset ( $fieldstosearchall [ 'f.description' ]);
2016-07-06 10:28:34 +02:00
// Definition of fields for list
$arrayfields = array (
2017-10-13 13:28:26 +02:00
'f.ref' => array ( 'label' => $langs -> trans ( " Ref " ), 'checked' => 1 ),
's.nom' => array ( 'label' => $langs -> trans ( " ThirdParty " ), 'checked' => 1 ),
2016-07-06 10:28:34 +02:00
'f.fk_project' => array ( 'label' => $langs -> trans ( " Project " ), 'checked' => 1 ),
2017-10-13 13:28:26 +02:00
'f.fk_contrat' => array ( 'label' => $langs -> trans ( " Contract " ), 'checked' => 1 ),
'f.description' => array ( 'label' => $langs -> trans ( " Description " ), 'checked' => 1 ),
'fd.description' => array ( 'label' => " xx " , 'checked' => 1 , 'enabled' => empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS ) ? 1 : 0 ),
'fd.date' => array ( 'label' => $langs -> trans ( " Date " ), 'checked' => 1 , 'enabled' => empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS ) ? 1 : 0 ),
'fd.duree' => array ( 'label' => $langs -> trans ( " Duration " ), 'checked' => 1 , 'enabled' => empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS ) ? 1 : 0 ),
2016-07-06 10:28:34 +02:00
'f.datec' => array ( 'label' => $langs -> trans ( " DateCreation " ), 'checked' => 0 , 'position' => 500 ),
2017-10-13 13:28:26 +02:00
'f.tms' => array ( 'label' => $langs -> trans ( " DateModificationShort " ), 'checked' => 0 , 'position' => 500 ),
'f.fk_statut' => array ( 'label' => $langs -> trans ( " Status " ), 'checked' => 1 , 'position' => 1000 ),
2016-07-06 10:28:34 +02:00
);
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
2017-06-19 14:31:08 +02:00
foreach ( $extrafields -> attribute_label as $key => $val )
2016-07-06 10:28:34 +02:00
{
2017-10-29 11:00:02 +01:00
if ( ! empty ( $extrafields -> attribute_list [ $key ])) $arrayfields [ " ef. " . $key ] = array ( 'label' => $extrafields -> attribute_label [ $key ], 'checked' => (( $extrafields -> attribute_list [ $key ] < 0 ) ? 0 : 1 ), 'position' => $extrafields -> attribute_pos [ $key ], 'enabled' => ( abs ( $extrafields -> attribute_list [ $key ]) != 3 && $extrafields -> attribute_perms [ $key ]));
2016-07-06 10:28:34 +02:00
}
}
/*
2017-04-09 14:31:56 +02:00
* Actions
2016-07-06 10:28:34 +02:00
*/
2017-09-15 10:50:50 +02:00
if ( GETPOST ( 'cancel' , 'alpha' )) { $action = 'list' ; $massaction = '' ; }
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills' ) { $massaction = '' ; }
2016-07-06 10:28:34 +02:00
2017-04-09 14:31:56 +02:00
$parameters = array ( 'socid' => $socid );
$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' );
2016-07-06 10:28:34 +02:00
2017-04-09 14:31:56 +02:00
if ( empty ( $reshook ))
2016-07-06 10:28:34 +02:00
{
2017-10-13 13:28:26 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
2017-04-09 14:31:56 +02:00
2017-10-13 13:28:26 +02:00
// Purge search criteria
2017-07-13 00:35:10 +02:00
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
2017-04-09 14:31:56 +02:00
{
$search_ref = " " ;
$search_company = " " ;
$search_project = " " ;
$search_contract = " " ;
$search_desc = " " ;
$search_status = " " ;
2017-10-13 13:28:26 +02:00
$toselect = '' ;
2017-04-09 14:31:56 +02:00
$search_array_options = array ();
}
// Mass actions
$objectclass = 'Fichinter' ;
$objectlabel = 'Interventions' ;
$permtoread = $user -> rights -> ficheinter -> lire ;
$permtodelete = $user -> rights -> ficheinter -> supprimer ;
$uploaddir = $conf -> ficheinter -> dir_output ;
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
2016-07-06 10:28:34 +02:00
}
2015-10-17 00:52:35 +02:00
2011-08-21 15:01:34 +02:00
/*
* View
*/
2017-04-09 14:31:56 +02:00
$now = dol_now ();
2014-09-06 19:10:59 +02:00
$form = new Form ( $db );
2016-08-23 15:43:48 +02:00
$formfile = new FormFile ( $db );
$objectstatic = new Fichinter ( $db );
2017-03-28 18:42:23 +02:00
$companystatic = new Societe ( $db );
2017-04-09 14:31:56 +02:00
$title = $langs -> trans ( " ListOfInterventions " );
llxHeader ( '' , $title );
2011-08-21 15:01:34 +02:00
$sql = " SELECT " ;
2016-08-23 15:43:48 +02:00
$sql .= " f.ref, f.rowid, f.fk_statut, f.description, f.datec as date_creation, f.tms as date_update, f.note_private, " ;
2014-10-17 13:09:18 +02:00
if ( empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS )) $sql .= " fd.description as descriptiondetail, fd.date as dp, fd.duree, " ;
2014-10-04 17:20:17 +02:00
$sql .= " s.nom as name, s.rowid as socid, s.client " ;
2016-07-06 10:28:34 +02:00
// Add fields from extrafields
foreach ( $extrafields -> attribute_label as $key => $val ) $sql .= ( $extrafields -> attribute_type [ $key ] != 'separate' ? " ,ef. " . $key . ' as options_' . $key : '' );
// Add fields from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
$sql .= " FROM " . MAIN_DB_PREFIX . " fichinter as f " ;
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " fichinter_extrafields as ef on (f.rowid = ef.fk_object) " ;
2014-10-17 13:09:18 +02:00
if ( empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " fichinterdet as fd ON fd.fk_fichinter = f.rowid " ;
2016-07-06 10:28:34 +02:00
if ( ! $user -> rights -> societe -> client -> voir && empty ( $socid )) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
2011-08-21 15:01:34 +02:00
$sql .= " WHERE f.fk_soc = s.rowid " ;
$sql .= " AND f.entity = " . $conf -> entity ;
2013-09-10 16:43:06 +02:00
if ( $search_ref ) {
2017-10-13 13:28:26 +02:00
$sql .= natural_search ( 'f.ref' , $search_ref );
2013-09-10 16:43:06 +02:00
}
if ( $search_company ) {
2017-10-13 13:28:26 +02:00
$sql .= natural_search ( 's.nom' , $search_company );
2013-09-10 16:43:06 +02:00
}
if ( $search_desc ) {
2017-10-13 13:28:26 +02:00
if ( empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS )) $sql .= natural_search ( array ( 'f.description' , 'fd.description' ), $search_desc );
else $sql .= natural_search ( array ( 'f.description' ), $search_desc );
2013-09-10 16:43:06 +02:00
}
2014-09-06 19:10:59 +02:00
if ( $search_status != '' && $search_status >= 0 ) {
2017-10-13 13:28:26 +02:00
$sql .= ' AND f.fk_statut = ' . $search_status ;
2014-09-06 19:10:59 +02:00
}
2012-08-16 19:18:24 +02:00
if ( ! $user -> rights -> societe -> client -> voir && empty ( $socid ))
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
if ( $socid )
$sql .= " AND s.rowid = " . $socid ;
2014-11-03 17:48:10 +01:00
if ( $sall ) {
2015-10-17 00:52:35 +02:00
$sql .= natural_search ( array_keys ( $fieldstosearchall ), $sall );
2014-11-03 17:48:10 +01:00
}
2016-07-06 10:28:34 +02:00
// Add where from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php' ;
2016-07-06 10:28:34 +02:00
// Add where from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2016-02-11 20:40:33 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2017-04-09 14:31:56 +02:00
// Count total nb of records
$nbtotalofrecords = '' ;
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
2015-12-28 00:20:48 +01:00
{
2017-04-09 14:31:56 +02:00
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
2015-12-28 00:20:48 +01:00
}
2016-02-11 20:40:33 +01:00
2012-01-08 00:52:07 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2014-10-17 13:09:18 +02:00
//print $sql;
2011-08-21 15:01:34 +02:00
2017-04-09 14:31:56 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
2011-08-21 15:01:34 +02:00
{
2017-04-09 14:31:56 +02:00
$num = $db -> num_rows ( $resql );
2011-08-21 15:01:34 +02:00
2017-04-09 14:31:56 +02:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2017-06-19 14:31:08 +02:00
2017-07-18 14:47:44 +02:00
if ( $socid > 0 )
2017-07-17 11:04:48 +02:00
{
$soc = new Societe ( $db );
$soc -> fetch ( $socid );
if ( empty ( $search_company )) $search_company = $soc -> name ;
}
2017-07-23 19:09:00 +02:00
2016-02-11 20:40:33 +01:00
$param = '' ;
2017-10-13 13:28:26 +02:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
2016-06-07 14:06:00 +02:00
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
2016-09-09 13:58:41 +02:00
if ( $sall ) $urlparam .= " &sall= " . $sall ;
2016-02-11 20:40:33 +01:00
if ( $socid ) $param .= " &socid= " . $socid ;
if ( $search_ref ) $param .= " &search_ref= " . urlencode ( $search_ref );
if ( $search_company ) $param .= " &search_company= " . urlencode ( $search_company );
if ( $search_desc ) $param .= " &search_desc= " . urlencode ( $search_desc );
if ( $search_status != '' && $search_status > - 1 ) $param .= " &search_status= " . urlencode ( $search_status );
2017-10-13 13:28:26 +02:00
if ( $show_files ) $param .= '&show_files=' . $show_files ;
2016-02-11 20:40:33 +01:00
if ( $optioncss != '' ) $param .= '&optioncss=' . $optioncss ;
2017-10-13 13:28:26 +02:00
// Add $param from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
2017-10-13 13:28:26 +02:00
// List of mass actions available
$arrayofmassactions = array (
//'presend'=>$langs->trans("SendByMail"),
'builddoc' => $langs -> trans ( " PDFMerge " ),
);
2017-11-15 11:39:11 +01:00
if ( $user -> rights -> ficheinter -> supprimer ) $arrayofmassactions [ 'predelete' ] = $langs -> trans ( " Delete " );
if ( in_array ( $massaction , array ( 'presend' , 'predelete' ))) $arrayofmassactions = array ();
2017-10-13 13:28:26 +02:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2017-06-19 14:31:08 +02:00
2017-04-09 14:31:56 +02:00
// Lines of title fields
2017-10-13 13:28:26 +02:00
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' . " \n " ;
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2016-02-16 17:43:05 +01:00
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
2017-10-13 13:28:26 +02:00
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="page" value="' . $page . '">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2017-06-19 14:31:08 +02:00
2017-04-09 14:31:56 +02:00
print_barre_liste ( $title , $page , $_SERVER [ 'PHP_SELF' ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'title_commercial.png' , 0 , '' , '' , $limit );
2017-06-19 14:31:08 +02:00
2017-11-15 11:39:11 +01:00
$topicmail = " Information " ;
$modelmail = " intervention " ;
2017-11-23 20:00:54 +01:00
$objecttmp = new Fichinter ( $db );
2017-11-15 11:39:11 +01:00
$trackid = 'int' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2016-02-11 20:40:33 +01:00
if ( $sall )
2017-10-13 13:28:26 +02:00
{
foreach ( $fieldstosearchall as $key => $val ) $fieldstosearchall [ $key ] = $langs -> trans ( $val );
print $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall );
}
2011-08-21 15:01:34 +02:00
2017-10-13 13:28:26 +02:00
$moreforfilter = '' ;
2017-06-19 14:31:08 +02:00
2017-10-13 13:28:26 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook )) $moreforfilter .= $hookmanager -> resPrint ;
else $moreforfilter = $hookmanager -> resPrint ;
2017-06-19 14:31:08 +02:00
2017-10-13 13:28:26 +02:00
if ( ! empty ( $moreforfilter ))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
print '</div>' ;
}
2017-06-19 14:31:08 +02:00
2016-07-06 10:28:34 +02:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2017-04-09 14:31:56 +02:00
if ( $massactionbutton ) $selectedfields .= $form -> showCheckAddButtons ( 'checkforselect' , 1 );
2017-06-19 14:31:08 +02:00
2017-10-13 13:28:26 +02:00
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2011-08-21 15:01:34 +02:00
2017-03-28 18:42:23 +02:00
print '<tr class="liste_titre_filter">' ;
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'f.ref' ][ 'checked' ]))
{
2016-07-06 10:28:34 +02:00
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_ref" value="' . $search_ref . '" size="8">' ;
print '</td>' ;
2017-10-13 13:28:26 +02:00
}
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
2016-07-06 10:28:34 +02:00
print '<input type="text" class="flat" name="search_company" value="' . $search_company . '" size="10">' ;
print '</td>' ;
2017-10-13 13:28:26 +02:00
}
if ( ! empty ( $arrayfields [ 'f.description' ][ 'checked' ]))
{
2016-07-06 10:28:34 +02:00
print '<td class="liste_titre">' ;
2017-10-13 13:28:26 +02:00
print '<input type="text" class="flat" name="search_desc" value="' . $search_desc . '" size="12">' ;
2016-07-06 10:28:34 +02:00
print '</td>' ;
2017-10-13 13:28:26 +02:00
}
if ( ! empty ( $arrayfields [ 'fd.description' ][ 'checked' ]))
{
// Desc of line
print '<td class="liste_titre"> </td>' ;
}
if ( ! empty ( $arrayfields [ 'fd.date' ][ 'checked' ]))
{
print '<td class="liste_titre"> </td>' ;
}
if ( ! empty ( $arrayfields [ 'fd.duree' ][ 'checked' ]))
{
2014-08-15 23:20:31 +02:00
print '<td class="liste_titre"> </td>' ;
}
2016-07-06 10:28:34 +02:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
2017-10-13 13:28:26 +02:00
// Fields from hook
2016-07-06 10:28:34 +02:00
$parameters = array ( 'arrayfields' => $arrayfields );
2017-10-13 13:28:26 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 'f.datec' ][ 'checked' ]))
{
// Date creation
print '<td class="liste_titre">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'f.tms' ][ 'checked' ]))
{
// Date modification
print '<td class="liste_titre">' ;
print '</td>' ;
}
// Status
2016-07-06 10:28:34 +02:00
if ( ! empty ( $arrayfields [ 'f.fk_statut' ][ 'checked' ]))
2017-10-13 13:28:26 +02:00
{
2016-07-06 10:28:34 +02:00
print '<td class="liste_titre" align="right">' ;
2016-08-23 15:43:48 +02:00
$liststatus = $objectstatic -> statuts_short ;
2016-09-19 13:09:50 +02:00
if ( empty ( $conf -> global -> FICHINTER_CLASSIFY_BILLED )) unset ( $liststatus [ 2 ]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
2016-07-06 10:28:34 +02:00
print $form -> selectarray ( 'search_status' , $liststatus , $search_status , 1 , 0 , 0 , '' , 1 );
print '</td>' ;
2017-10-13 13:28:26 +02:00
}
2016-02-07 15:50:48 +01:00
print '<td class="liste_titre" align="right">' ;
2017-05-14 21:06:33 +02:00
$searchpicto = $form -> showFilterButtons ();
print $searchpicto ;
2016-02-07 15:50:48 +01:00
print '</td>' ;
2017-06-19 14:31:08 +02:00
2017-10-13 13:28:26 +02:00
print " </tr> \n " ;
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'f.ref' ][ 'checked' ])) print_liste_field_titre ( " Ref " , $_SERVER [ " PHP_SELF " ], " f.ref " , " " , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) print_liste_field_titre ( " ThirdParty " , $_SERVER [ " PHP_SELF " ], " s.nom " , " " , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'f.description' ][ 'checked' ])) print_liste_field_titre ( " Description " , $_SERVER [ " PHP_SELF " ], " f.description " , " " , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'fd.description' ][ 'checked' ])) print_liste_field_titre ( '' , $_SERVER [ " PHP_SELF " ], '' );
if ( ! empty ( $arrayfields [ 'fd.date' ][ 'checked' ])) print_liste_field_titre ( " Date " , $_SERVER [ " PHP_SELF " ], " fd.date " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'fd.duree' ][ 'checked' ])) print_liste_field_titre ( " Duration " , $_SERVER [ " PHP_SELF " ], " fd.duree " , " " , $param , 'align="right"' , $sortfield , $sortorder );
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
2017-10-13 13:28:26 +02:00
// Hook fields
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 'f.datec' ][ 'checked' ])) print_liste_field_titre ( " DateCreationShort " , $_SERVER [ " PHP_SELF " ], " f.datec " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'f.tms' ][ 'checked' ])) print_liste_field_titre ( " DateModificationShort " , $_SERVER [ " PHP_SELF " ], " f.tms " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'f.fk_statut' ][ 'checked' ])) print_liste_field_titre ( " Status " , $_SERVER [ " PHP_SELF " ], " f.fk_statut " , " " , $param , 'align="right"' , $sortfield , $sortorder );
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' );
print " </tr> \n " ;
2017-06-19 14:31:08 +02:00
2011-08-21 15:01:34 +02:00
$total = 0 ;
$i = 0 ;
2016-07-06 10:28:34 +02:00
$totalarray = array ();
2011-08-21 15:01:34 +02:00
while ( $i < min ( $num , $limit ))
{
2017-04-09 14:31:56 +02:00
$obj = $db -> fetch_object ( $resql );
2017-06-19 14:31:08 +02:00
2016-08-23 15:43:48 +02:00
$objectstatic -> id = $obj -> rowid ;
$objectstatic -> ref = $obj -> ref ;
$objectstatic -> statut = $obj -> fk_statut ;
2017-06-19 14:31:08 +02:00
2017-04-09 14:31:56 +02:00
print '<tr class="oddeven">' ;
2017-06-19 14:31:08 +02:00
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'f.ref' ][ 'checked' ]))
2016-07-06 10:28:34 +02:00
{
print " <td> " ;
2017-06-19 14:31:08 +02:00
2016-08-23 15:43:48 +02:00
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
2017-10-13 13:28:26 +02:00
// Picto + Ref
print '<td class="nobordernopadding nowrap">' ;
print $objectstatic -> getNomUrl ( 1 );
print '</td>' ;
// Warning
$warnornote = '' ;
//if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
if ( ! empty ( $obj -> note_private ))
{
$warnornote .= ( $warnornote ? ' ' : '' );
$warnornote .= '<span class="note">' ;
$warnornote .= '<a href="note.php?id=' . $obj -> rowid . '">' . img_picto ( $langs -> trans ( " ViewPrivateNote " ), 'object_generic' ) . '</a>' ;
$warnornote .= '</span>' ;
}
if ( $warnornote )
{
print '<td style="min-width: 20px" class="nobordernopadding nowrap">' ;
print $warnornote ;
print '</td>' ;
}
// Other picto tool
print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">' ;
$filename = dol_sanitizeFileName ( $obj -> ref );
$filedir = $conf -> ficheinter -> dir_output . '/' . dol_sanitizeFileName ( $obj -> ref );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $obj -> rowid ;
print $formfile -> getDocumentsLink ( $objectstatic -> element , $filename , $filedir );
print '</td></tr></table>' ;
2017-06-19 14:31:08 +02:00
2016-07-06 10:28:34 +02:00
print " </td> \n " ;
2017-10-13 13:28:26 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-07-06 10:28:34 +02:00
}
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ]))
2016-07-06 10:28:34 +02:00
{
print '<td>' ;
$companystatic -> name = $obj -> name ;
$companystatic -> id = $obj -> socid ;
$companystatic -> client = $obj -> client ;
print $companystatic -> getNomUrl ( 1 , '' , 44 );
print '</td>' ;
2017-10-13 13:28:26 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-07-06 10:28:34 +02:00
}
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'f.description' ][ 'checked' ]))
2016-07-06 10:28:34 +02:00
{
print '<td>' . dol_trunc ( dolGetFirstLineOfText ( $obj -> description ), 48 ) . '</td>' ;
2017-10-13 13:28:26 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-07-06 10:28:34 +02:00
}
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'fd.description' ][ 'checked' ]))
2016-07-06 10:28:34 +02:00
{
//print '<td>'.dol_trunc(dol_escape_htmltag(dolGetFirstLineOfText($obj->descriptiondetail)),48).'</td>';
print '<td>' . dolGetFirstLineOfText ( $obj -> descriptiondetail ) . '</td>' ;
2017-10-13 13:28:26 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-07-06 10:28:34 +02:00
}
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'fd.date' ][ 'checked' ]))
2014-08-15 23:20:31 +02:00
{
2016-07-06 10:28:34 +02:00
print '<td align="center">' . dol_print_date ( $db -> jdate ( $obj -> dp ), 'dayhour' ) . " </td> \n " ;
2017-10-13 13:28:26 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-07-06 10:28:34 +02:00
}
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'fd.duree' ][ 'checked' ]))
2016-07-06 10:28:34 +02:00
{
print '<td align="right">' . convertSecondToTime ( $obj -> duree , 'allhourmin' ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-10-13 13:28:26 +02:00
if ( ! $i ) $totalarray [ 'totaldurationfield' ] = $totalarray [ 'nbfield' ];
$totalarray [ 'totalduration' ] += $obj -> duree ;
2014-08-15 23:20:31 +02:00
}
2014-12-23 18:00:14 +01:00
2017-10-13 13:28:26 +02:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
2017-10-13 13:28:26 +02:00
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj );
2016-07-06 10:28:34 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
2017-10-13 13:28:26 +02:00
print $hookmanager -> resPrint ;
// Date creation
if ( ! empty ( $arrayfields [ 'f.datec' ][ 'checked' ]))
{
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Date modification
if ( ! empty ( $arrayfields [ 'f.tms' ][ 'checked' ]))
{
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Status
if ( ! empty ( $arrayfields [ 'f.fk_statut' ][ 'checked' ]))
{
2016-08-23 15:43:48 +02:00
print '<td align="right">' . $objectstatic -> LibStatut ( $obj -> fk_statut , 5 ) . '</td>' ;
2017-10-13 13:28:26 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// 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' ] ++ ;
2017-06-19 14:31:08 +02:00
2011-08-21 15:01:34 +02:00
print " </tr> \n " ;
2016-07-06 10:28:34 +02:00
$total += $obj -> duree ;
2011-08-21 15:01:34 +02:00
$i ++ ;
}
2016-07-06 10:28:34 +02:00
// Show total line
if ( isset ( $totalarray [ 'totalduration' ]))
2014-08-15 23:20:31 +02:00
{
2017-10-13 13:28:26 +02:00
print '<tr class="liste_total">' ;
$i = 0 ;
while ( $i < $totalarray [ 'nbfield' ])
{
$i ++ ;
if ( $i == 1 )
{
if ( $num < $limit && empty ( $offset )) print '<td align="left">' . $langs -> trans ( " Total " ) . '</td>' ;
else print '<td align="left">' . $langs -> trans ( " Totalforthispage " ) . '</td>' ;
}
elseif ( $totalarray [ 'totaldurationfield' ] == $i ) print '<td align="right">' . convertSecondToTime ( $totalarray [ 'totalduration' ], 'allhourmin' ) . '</td>' ;
else print '<td></td>' ;
}
print '</tr>' ;
2014-08-15 23:20:31 +02:00
}
2014-12-23 18:00:14 +01:00
2017-04-09 14:31:56 +02:00
$db -> free ( $resql );
2017-06-19 14:31:08 +02:00
2017-04-09 14:31:56 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2017-06-19 14:31:08 +02:00
2017-04-09 14:31:56 +02:00
print '</table>' . " \n " ;
2017-01-22 13:19:07 +01:00
print '</div>' ;
2017-06-19 14:31:08 +02:00
2011-08-21 15:01:34 +02:00
print " </form> \n " ;
2017-04-09 14:31:56 +02:00
if ( $massaction == 'builddoc' || $action == 'remove_file' || $show_files )
{
2017-10-13 13:28:26 +02:00
/*
2017-04-09 14:31:56 +02:00
* Show list of available documents
*/
2017-10-13 13:28:26 +02:00
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder ;
$urlsource .= str_replace ( '&' , '&' , $param );
2017-06-19 14:31:08 +02:00
2017-10-13 13:28:26 +02:00
$filedir = $diroutputmassaction ;
$genallowed = $user -> rights -> ficheinter -> lire ;
2017-10-18 19:51:29 +02:00
$delallowed = $user -> rights -> ficheinter -> creer ;
2017-06-19 14:31:08 +02:00
2017-10-13 13:28:26 +02:00
print $formfile -> showdocuments ( 'massfilesarea_interventions' , '' , $filedir , $urlsource , 0 , $delallowed , '' , 1 , 1 , 0 , 48 , 1 , $param , $title , '' );
2017-04-09 14:31:56 +02:00
}
else
{
2017-10-13 13:28:26 +02:00
print '<br><a name="show_files"></a><a href="' . $_SERVER [ " PHP_SELF " ] . '?show_files=1' . $param . '#show_files">' . $langs -> trans ( " ShowTempMassFilesArea " ) . '</a>' ;
2017-04-09 14:31:56 +02:00
}
2017-06-19 14:31:08 +02:00
2011-08-21 15:01:34 +02:00
}
else
{
dol_print_error ( $db );
}
2011-08-27 16:24:16 +02:00
llxFooter ();
2016-07-06 10:28:34 +02:00
$db -> close ();