2017-05-10 13:30:35 +02:00
< ? php
2017-05-27 13:46:34 +02:00
/* Copyright ( C ) 2007 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) --- Put here your own copyright and developer email ---
2017-05-10 13:30:35 +02:00
*
2017-05-27 13:46:34 +02:00
* This program is free software ; you can redistribute it and / or modify
2017-05-10 13:30:35 +02:00
* it under the terms of the GNU General Public License as published by
2017-05-27 13:46:34 +02:00
* the Free Software Foundation ; either version 3 of the License , or
2017-05-10 13:30:35 +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
2017-05-27 13:46:34 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2017-05-10 13:30:35 +02:00
*/
/**
2017-05-27 13:46:34 +02:00
* \file htdocs / modulebuilder / template / myobject_list . php
* \ingroup mymodule othermodule1 othermodule2
* \brief This file is an example of a php page
* Put here some comments
2017-05-10 13:30:35 +02:00
*/
2017-05-27 13:46:34 +02:00
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
2017-05-10 13:30:35 +02:00
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
2017-06-07 16:44:04 +02:00
// Change this following lines to use the correct relative path (../, ../../, etc)
2017-05-27 13:46:34 +02:00
$res = 0 ;
if ( ! $res && file_exists ( " ../main.inc.php " )) $res =@ include '../main.inc.php' ; // to work if your module directory is into dolibarr root htdocs directory
if ( ! $res && file_exists ( " ../../main.inc.php " )) $res =@ include '../../main.inc.php' ; // to work if your module directory is into a subdir of root htdocs directory
if ( ! $res && file_exists ( " ../../../dolibarr/htdocs/main.inc.php " )) $res =@ include '../../../dolibarr/htdocs/main.inc.php' ; // Used on dev env only
if ( ! $res && file_exists ( " ../../../../dolibarr/htdocs/main.inc.php " )) $res =@ include '../../../../dolibarr/htdocs/main.inc.php' ; // Used on dev env only
if ( ! $res ) die ( " Include of main fails " );
// Change this following line to use the correct relative path from htdocs
require_once ( DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' );
2017-05-10 13:30:35 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2017-05-27 13:46:34 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2017-05-28 14:43:17 +02:00
dol_include_once ( '/mymodule/class/myobject.class.php' );
2017-05-10 13:30:35 +02:00
2017-05-27 13:46:34 +02:00
// Load traductions files requiredby by page
2017-06-07 16:44:04 +02:00
$langs -> loadLangs ( array ( " mymodule " , " other " ));
2017-05-10 13:30:35 +02:00
2017-05-27 13:46:34 +02:00
$action = GETPOST ( 'action' , 'alpha' );
$massaction = GETPOST ( 'massaction' , 'alpha' );
$show_files = GETPOST ( 'show_files' , 'int' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$toselect = GETPOST ( 'toselect' , 'array' );
2017-05-10 13:30:35 +02:00
$id = GETPOST ( 'id' , 'int' );
$backtopage = GETPOST ( 'backtopage' );
$myparam = GETPOST ( 'myparam' , 'alpha' );
2017-05-27 13:46:34 +02:00
$search_all = trim ( GETPOST ( " sall " ));
$search_field1 = GETPOST ( " search_field1 " );
$search_field2 = GETPOST ( " search_field2 " );
$search_myfield = GETPOST ( 'search_myfield' );
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2017-05-10 13:30:35 +02:00
// Load variable for pagination
2017-06-08 14:55:12 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2017-05-10 13:30:35 +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
2017-05-10 13:30:35 +02:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
if ( ! $sortfield ) $sortfield = " t.rowid " ; // Set here default search field
if ( ! $sortorder ) $sortorder = " ASC " ;
// Protection if external user
2017-05-27 13:46:34 +02:00
$socid = 0 ;
2017-05-10 13:30:35 +02:00
if ( $user -> societe_id > 0 )
{
2017-05-27 13:46:34 +02:00
$socid = $user -> societe_id ;
2017-05-10 13:30:35 +02:00
//accessforbidden();
}
// Initialize technical object to manage context to save list fields
2017-06-07 16:44:04 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'myobjectlist' ;
2017-05-10 13:30:35 +02:00
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
2017-06-07 16:44:04 +02:00
$hookmanager -> initHooks ( array ( 'myobjectlist' ));
2017-05-10 13:30:35 +02:00
$extrafields = new ExtraFields ( $db );
2017-05-27 13:46:34 +02:00
// fetch optionals attributes and labels
2017-06-07 16:44:04 +02:00
$extralabels = $extrafields -> fetch_name_optionals_label ( 'myobject' );
2017-05-27 13:46:34 +02:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $extralabels , '' , 'search_' );
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
't.ref' => 'Ref' ,
't.note_public' => 'NotePublic' ,
);
if ( empty ( $user -> socid )) $fieldstosearchall [ " t.note_private " ] = " NotePrivate " ;
// Definition of fields for list
$arrayfields = array (
't.field1' => array ( 'label' => " Field1 " , 'checked' => 1 ),
't.field2' => array ( 'label' => " Field2 " , 'checked' => 1 ),
2017-06-06 07:57:03 +02:00
//'t.entity'=>array('label'=>"Entity", 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))),
2017-05-27 13:46:34 +02:00
't.datec' => array ( 'label' => " DateCreationShort " , 'checked' => 0 , 'position' => 500 ),
't.tms' => array ( 'label' => " DateModificationShort " , 'checked' => 0 , 'position' => 500 ),
//'t.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
);
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
$arrayfields [ " ef. " . $key ] = array ( 'label' => $extrafields -> attribute_label [ $key ], 'checked' => $extrafields -> attribute_list [ $key ], 'position' => $extrafields -> attribute_pos [ $key ], 'enabled' => $extrafields -> attribute_perms [ $key ]);
}
2017-05-10 13:30:35 +02:00
}
2017-05-27 13:46:34 +02:00
$object = new Skeleton_Class ( $db );
2017-05-10 13:30:35 +02:00
/*
* ACTIONS
*
* Put here all code to do according to value of " action " parameter
*/
if ( GETPOST ( 'cancel' )) { $action = 'list' ; $massaction = '' ; }
if ( ! GETPOST ( 'confirmmassaction' ) && $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 ))
{
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
if ( GETPOST ( " button_removefilter_x " ) || GETPOST ( " button_removefilter.x " ) || GETPOST ( " button_removefilter " )) // All tests are required to be compatible with all browsers
{
2017-05-27 13:46:34 +02:00
$search_field1 = '' ;
$search_field2 = '' ;
$search_date_creation = '' ;
$search_date_update = '' ;
2017-05-10 13:30:35 +02:00
$toselect = '' ;
$search_array_options = array ();
}
// Mass actions
$objectclass = 'Skeleton' ;
$objectlabel = 'Skeleton' ;
$permtoread = $user -> rights -> skeleton -> read ;
$permtodelete = $user -> rights -> skeleton -> delete ;
$uploaddir = $conf -> skeleton -> dir_output ;
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
}
2017-05-27 13:46:34 +02:00
2017-05-10 13:30:35 +02:00
/*
* VIEW
*
* Put here all code to build page
*/
2017-05-27 13:46:34 +02:00
$now = dol_now ();
2017-05-10 13:30:35 +02:00
2017-05-27 13:46:34 +02:00
$form = new Form ( $db );
//$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
$help_url = '' ;
$title = $langs -> trans ( 'MyModuleListTitle' );
2017-05-10 13:30:35 +02:00
// Put here content of your page
2017-05-27 13:46:34 +02:00
// Example : Adding jquery code
2017-05-10 13:30:35 +02:00
print ' < script type = " text/javascript " language = " javascript " >
jQuery ( document ) . ready ( function () {
function init_myfunc ()
{
jQuery ( " #myid " ) . removeAttr ( \ ' disabled\ ' );
jQuery ( " #myid " ) . attr ( \ ' disabled\ ' , \ ' disabled\ ' );
}
init_myfunc ();
jQuery ( " #mybutton " ) . click ( function () {
init_myfunc ();
});
});
</ script > ' ;
2017-05-27 13:46:34 +02:00
$sql = " SELECT " ;
$sql .= " t.rowid, " ;
$sql .= " t.field1, " ;
$sql .= " t.field2 " ;
// 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 . " mytable as t " ;
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " mytable_extrafields as ef on (t.rowid = ef.fk_object) " ;
$sql .= " WHERE 1 = 1 " ;
2017-05-30 18:50:54 +02:00
//$sql.= " WHERE u.entity IN (".getEntity('mytable').")";
2017-05-27 13:46:34 +02:00
if ( $search_field1 ) $sql .= natural_search ( " field1 " , $search_field1 );
if ( $search_field2 ) $sql .= natural_search ( " field2 " , $search_field2 );
if ( $sall ) $sql .= natural_search ( array_keys ( $fieldstosearchall ), $sall );
// Add where from extra fields
foreach ( $search_array_options as $key => $val )
{
$crit = $val ;
$tmpkey = preg_replace ( '/search_options_/' , '' , $key );
$typ = $extrafields -> attribute_type [ $tmpkey ];
$mode = 0 ;
if ( in_array ( $typ , array ( 'int' , 'double' ))) $mode = 1 ; // Search on a numeric
2017-06-07 16:44:04 +02:00
if ( $val && ( ( $crit != '' && ! in_array ( $typ , array ( 'select' ))) || ! empty ( $crit )))
2017-05-27 13:46:34 +02:00
{
$sql .= natural_search ( 'ef.' . $tmpkey , $crit , $mode );
}
}
// 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 ;
$sql .= $db -> order ( $sortfield , $sortorder );
// Count total nb of records
$nbtotalofrecords = '' ;
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
{
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
2017-06-07 16:44:04 +02:00
}
2017-05-27 13:46:34 +02:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
dol_syslog ( $script_file , LOG_DEBUG );
$resql = $db -> query ( $sql );
if ( ! $resql )
{
dol_print_error ( $db );
exit ;
}
$num = $db -> num_rows ( $resql );
// Direct jump if only one record found
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $search_all )
{
$obj = $db -> fetch_object ( $resql );
$id = $obj -> rowid ;
2017-06-07 16:44:04 +02:00
header ( " Location: " . DOL_URL_ROOT . '/mymodule/myobject_card.php?id=' . $id );
2017-05-27 13:46:34 +02:00
exit ;
}
llxHeader ( '' , $title , $help_url );
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
$param = '' ;
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
if ( $search_field1 != '' ) $param .= '&search_field1=' . urlencode ( $search_field1 );
if ( $search_field2 != '' ) $param .= '&search_field2=' . urlencode ( $search_field2 );
if ( $optioncss != '' ) $param .= '&optioncss=' . $optioncss ;
// Add $param from extra fields
foreach ( $search_array_options as $key => $val )
{
$crit = $val ;
$tmpkey = preg_replace ( '/search_options_/' , '' , $key );
if ( $val != '' ) $param .= '&search_options_' . $tmpkey . '=' . urlencode ( $val );
2017-06-07 16:44:04 +02:00
}
2017-05-27 13:46:34 +02:00
$arrayofmassactions = array (
'presend' => $langs -> trans ( " SendByMail " ),
'builddoc' => $langs -> trans ( " PDFMerge " ),
);
2017-06-07 16:44:04 +02:00
if ( $user -> rights -> mymodule -> delete ) $arrayofmassactions [ 'delete' ] = $langs -> trans ( " Delete " );
2017-05-27 13:46:34 +02:00
if ( $massaction == 'presend' ) $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_barre_liste ( $title , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , '' , $num , $nbtotalofrecords , 'title_companies' , 0 , '' , '' , $limit );
if ( $sall )
{
foreach ( $fieldstosearchall as $key => $val ) $fieldstosearchall [ $key ] = $langs -> trans ( $val );
print $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall );
}
$moreforfilter = '' ;
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'MyFilter' ) . ': <input type="text" name="search_myfield" value="' . dol_escape_htmltag ( $search_myfield ) . '">' ;
$moreforfilter .= '</div>' ;
$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 ;
if ( ! empty ( $moreforfilter ))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
print '</div>' ;
}
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2017-06-07 16:44:04 +02:00
if ( $massactionbutton ) $selectedfields .= $form -> showCheckAddButtons ( 'checkforselect' , 1 );
2017-05-10 13:30:35 +02:00
2017-05-27 13:46:34 +02:00
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2017-05-10 13:30:35 +02:00
2017-05-27 13:46:34 +02:00
// Fields title search
print '<tr class="liste_titre">' ;
// LIST_OF_TD_TITLE_SEARCH
//if (! empty($arrayfields['t.field1']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_field1" value="'.$search_field1.'" size="10"></td>';
//if (! empty($arrayfields['t.field2']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_field2" value="'.$search_field2.'" size="10"></td>';
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
2017-06-07 16:44:04 +02:00
foreach ( $extrafields -> attribute_label as $key => $val )
2017-05-27 13:46:34 +02:00
{
if ( ! empty ( $arrayfields [ " ef. " . $key ][ 'checked' ]))
{
$align = $extrafields -> getAlignFlag ( $key );
$typeofextrafield = $extrafields -> attribute_type [ $key ];
print '<td class="liste_titre' . ( $align ? ' ' . $align : '' ) . '">' ;
2017-06-07 16:44:04 +02:00
if ( in_array ( $typeofextrafield , array ( 'varchar' , 'int' , 'double' , 'select' )) && empty ( $extrafields -> attribute_computed [ $key ]))
{
$crit = $val ;
$tmpkey = preg_replace ( '/search_options_/' , '' , $key );
$searchclass = '' ;
if ( in_array ( $typeofextrafield , array ( 'varchar' , 'select' ))) $searchclass = 'searchstring' ;
if ( in_array ( $typeofextrafield , array ( 'int' , 'double' ))) $searchclass = 'searchnum' ;
print '<input class="flat' . ( $searchclass ? ' ' . $searchclass : '' ) . '" size="4" type="text" name="search_options_' . $tmpkey . '" value="' . dol_escape_htmltag ( $search_array_options [ 'search_options_' . $tmpkey ]) . '">' ;
}
2017-05-27 13:46:34 +02:00
print '</td>' ;
}
}
}
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 't.datec' ][ 'checked' ]))
{
// Date creation
print '<td class="liste_titre">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 't.tms' ][ 'checked' ]))
{
// Date modification
print '<td class="liste_titre">' ;
print '</td>' ;
}
/* if ( ! empty ( $arrayfields [ 'u.statut' ][ 'checked' ]))
2017-06-07 16:44:04 +02:00
{
// Status
print '<td class="liste_titre" align="center">' ;
print $form -> selectarray ( 'search_statut' , array ( '-1' => '' , '0' => $langs -> trans ( 'Disabled' ), '1' => $langs -> trans ( 'Enabled' )), $search_statut );
print '</td>' ;
} */
2017-05-27 13:46:34 +02:00
// Action column
print '<td class="liste_titre" align="right">' ;
2017-06-07 16:44:04 +02:00
$searchpicto = $form -> showFilterButtons ();
2017-05-27 13:46:34 +02:00
print $searchpicto ;
print '</td>' ;
print '</tr>' . " \n " ;
2017-06-07 16:44:04 +02:00
// Fields title
print '<tr class="liste_titre">' ;
// LIST_OF_TD_TITLE_FIELDS
//if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($arrayfields['t.field1']['label'],$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder);
//if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($arrayfields['t.field2']['label'],$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder);
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
if ( ! empty ( $arrayfields [ " ef. " . $key ][ 'checked' ]))
{
$align = $extrafields -> getAlignFlag ( $key );
$sortonfield = " ef. " . $key ;
if ( ! empty ( $extrafields -> attribute_computed [ $key ])) $sortonfield = '' ;
print_liste_field_titre ( $langs -> trans ( $extralabels [ $key ]), $_SERVER [ " PHP_SELF " ], $sortonfield , " " , $param ,( $align ? 'align="' . $align . '"' : '' ), $sortfield , $sortorder );
}
}
}
// 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 [ 't.datec' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.datec " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 't.tms' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.tms " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
//if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' );
print '</tr>' . " \n " ;
2017-05-27 13:46:34 +02:00
// Detect if we need a fetch on each output line
$needToFetchEachLine = 0 ;
foreach ( $extrafields -> attribute_computed as $key => $val )
{
if ( preg_match ( '/\$object/' , $val )) $needToFetchEachLine ++ ; // There is at least one compute field that use $object
}
2017-05-10 13:30:35 +02:00
2017-05-27 13:46:34 +02:00
$i = 0 ;
$totalarray = array ();
while ( $i < min ( $num , $limit ))
{
$obj = $db -> fetch_object ( $resql );
if ( $obj )
{
// Show here line of result
print '<tr class="oddeven">' ;
// LIST_OF_TD_FIELDS_LIST
/*
2017-06-07 16:44:04 +02:00
if ( ! empty ( $arrayfields [ 't.field1' ][ 'checked' ]))
2017-05-27 13:46:34 +02:00
{
print '<td>' . $obj -> field1 . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2017-06-07 16:44:04 +02:00
if ( ! empty ( $arrayfields [ 't.field2' ][ 'checked' ]))
2017-05-27 13:46:34 +02:00
{
print '<td>' . $obj -> field2 . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
} */
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
2017-06-07 16:44:04 +02:00
foreach ( $extrafields -> attribute_label as $key => $val )
2017-05-27 13:46:34 +02:00
{
2017-06-07 16:44:04 +02:00
if ( ! empty ( $arrayfields [ " ef. " . $key ][ 'checked' ]))
2017-05-27 13:46:34 +02:00
{
print '<td' ;
$align = $extrafields -> getAlignFlag ( $key );
if ( $align ) print ' align="' . $align . '"' ;
print '>' ;
$tmpkey = 'options_' . $key ;
print $extrafields -> showOutputField ( $key , $obj -> $tmpkey , '' , 1 );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
}
}
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj );
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
// Date creation
if ( ! empty ( $arrayfields [ 't.datec' ][ 'checked' ]))
{
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Date modification
if ( ! empty ( $arrayfields [ 't.tms' ][ 'checked' ]))
{
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Status
/*
if ( ! empty ( $arrayfields [ 'u.statut' ][ 'checked' ]))
{
$userstatic -> statut = $obj -> statut ;
print '<td align="center">' . $userstatic -> getLibStatut ( 3 ) . '</td>' ;
} */
// 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 ++ ;
}
// Show total line
if ( isset ( $totalarray [ 'totalhtfield' ]))
{
print '<tr class="liste_total">' ;
$i = 0 ;
while ( $i < $totalarray [ 'nbfield' ])
{
$i ++ ;
if ( $i == 1 )
{
if ( $num < $limit ) print '<td align="left">' . $langs -> trans ( " Total " ) . '</td>' ;
else print '<td align="left">' . $langs -> trans ( " Totalforthispage " ) . '</td>' ;
}
elseif ( $totalarray [ 'totalhtfield' ] == $i ) print '<td align="right">' . price ( $totalarray [ 'totalht' ]) . '</td>' ;
elseif ( $totalarray [ 'totalvatfield' ] == $i ) print '<td align="right">' . price ( $totalarray [ 'totalvat' ]) . '</td>' ;
elseif ( $totalarray [ 'totalttcfield' ] == $i ) print '<td align="right">' . price ( $totalarray [ 'totalttc' ]) . '</td>' ;
else print '<td></td>' ;
}
print '</tr>' ;
}
$db -> free ( $resql );
$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 ;
print '</table>' . " \n " ;
print '</div>' . " \n " ;
print '</form>' . " \n " ;
if ( $massaction == 'builddoc' || $action == 'remove_file' || $show_files )
{
// Show list of available documents
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder ;
$urlsource .= str_replace ( '&' , '&' , $param );
$filedir = $diroutputmassaction ;
$genallowed = $user -> rights -> facture -> lire ;
$delallowed = $user -> rights -> facture -> lire ;
print $formfile -> showdocuments ( 'massfilesarea_mymodule' , '' , $filedir , $urlsource , 0 , $delallowed , '' , 1 , 1 , 0 , 48 , 1 , $param , $title , '' );
}
else
{
print '<br><a name="show_files"></a><a href="' . $_SERVER [ " PHP_SELF " ] . '?show_files=1' . $param . '#show_files">' . $langs -> trans ( " ShowTempMassFilesArea " ) . '</a>' ;
}
2017-05-10 13:30:35 +02:00
// End of page
llxFooter ();
2017-05-27 13:46:34 +02:00
$db -> close ();