2005-07-03 23:58:20 +02:00
< ? php
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2016-06-06 16:31:50 +02:00
* Copyright ( C ) 2004 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2015-04-18 21:28:55 +02:00
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
2018-04-20 10:38:16 +02:00
* Copyright ( C ) 2018 Ferran Marcet < fmarcet @ 2 byte . es >
2005-07-03 23:58:20 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2005-07-03 23:58:20 +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
2011-08-01 01:45:11 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2005-07-03 23:58:20 +02:00
*/
/**
2017-10-29 11:00:02 +01:00
* \file htdocs / contrat / services_list . php
2009-07-08 12:10:35 +02:00
* \ingroup contrat
2009-07-22 15:35:09 +02:00
* \brief Page to list services in contracts
2009-07-08 12:10:35 +02:00
*/
2005-07-03 23:58:20 +02:00
2010-03-27 15:50:05 +01:00
require ( " ../main.inc.php " );
2010-04-28 10:35:57 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /contrat/class/contrat.class.php " );
2010-04-28 23:29:12 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /product/class/product.class.php " );
2010-04-29 16:54:12 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /societe/class/societe.class.php " );
2005-07-03 23:58:20 +02:00
2018-05-26 20:32:23 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'products' , 'contracts' , 'companies' ));
2005-07-03 23:58:20 +02:00
2017-06-08 14:55:12 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2011-11-23 18:10:10 +01:00
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
2012-10-13 14:47:46 +02:00
$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
2016-12-16 01:12:24 +01:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2005-08-13 01:31:45 +02:00
if ( ! $sortfield ) $sortfield = " c.rowid " ;
if ( ! $sortorder ) $sortorder = " ASC " ;
2016-12-16 01:12:24 +01:00
$mode = GETPOST ( " mode " );
2011-11-23 18:10:10 +01:00
$filter = GETPOST ( " filter " );
2014-11-03 06:12:57 +01:00
$search_name = GETPOST ( " search_name " );
2011-11-23 18:10:10 +01:00
$search_contract = GETPOST ( " search_contract " );
$search_service = GETPOST ( " search_service " );
2015-11-29 13:03:46 +01:00
$search_status = GETPOST ( " search_status " , " alpha " );
2012-07-25 11:46:33 +02:00
$statut = GETPOST ( 'statut' ) ? GETPOST ( 'statut' ) : 1 ;
2016-11-09 16:11:02 +01:00
$search_product_category = GETPOST ( 'search_product_category' , 'int' );
2012-02-27 22:26:22 +01:00
$socid = GETPOST ( 'socid' , 'int' );
2018-03-31 18:48:27 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'contractservicelist' . $mode ;
2005-07-03 23:58:20 +02:00
2016-07-24 22:17:12 +02:00
$opouvertureprevuemonth = GETPOST ( 'opouvertureprevuemonth' );
$opouvertureprevueday = GETPOST ( 'opouvertureprevueday' );
$opouvertureprevueyear = GETPOST ( 'opouvertureprevueyear' );
$filter_opouvertureprevue = GETPOST ( 'filter_opouvertureprevue' );
2012-07-25 11:46:33 +02:00
$op1month = GETPOST ( 'op1month' );
$op1day = GETPOST ( 'op1day' );
$op1year = GETPOST ( 'op1year' );
$filter_op1 = GETPOST ( 'filter_op1' );
2016-07-24 22:17:12 +02:00
2012-07-25 11:46:33 +02:00
$op2month = GETPOST ( 'op2month' );
$op2day = GETPOST ( 'op2day' );
$op2year = GETPOST ( 'op2year' );
$filter_op2 = GETPOST ( 'filter_op2' );
2016-07-24 22:17:12 +02:00
$opcloturemonth = GETPOST ( 'opcloturemonth' );
$opclotureday = GETPOST ( 'opclotureday' );
$opclotureyear = GETPOST ( 'opclotureyear' );
$filter_opcloture = GETPOST ( 'filter_opcloture' );
2016-12-16 01:12:24 +01: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
2018-03-31 18:48:27 +02:00
$object = new ContratLigne ( $db );
$hookmanager -> initHooks ( array ( 'contractservicelist' ));
2016-12-16 01:12:24 +01:00
$extrafields = new ExtraFields ( $db );
// fetch optionals attributes and labels
$extralabels = $extrafields -> fetch_name_optionals_label ( 'contratdet' );
$search_array_options = $extrafields -> getOptionalsFromPost ( $extralabels , '' , 'search_' );
2008-02-25 17:30:43 +01:00
// Security check
2012-02-27 22:26:22 +01:00
$contratid = GETPOST ( 'id' , 'int' );
2012-07-25 11:46:33 +02:00
if ( ! empty ( $user -> societe_id )) $socid = $user -> societe_id ;
$result = restrictedArea ( $user , 'contrat' , $contratid );
2008-02-25 17:30:43 +01:00
2015-11-29 13:03:46 +01:00
if ( $search_status != '' )
{
2017-10-13 13:28:26 +02:00
$tmp = explode ( '&' , $search_status );
$mode = $tmp [ 0 ];
if ( empty ( $tmp [ 1 ])) $filter = '' ;
else
{
if ( $tmp [ 1 ] == 'filter=notexpired' ) $filter = 'notexpired' ;
if ( $tmp [ 1 ] == 'filter=expired' ) $filter = 'expired' ;
}
2015-11-29 13:03:46 +01:00
}
else
{
2017-10-13 13:28:26 +02:00
$search_status = $mode ;
if ( $filter == 'expired' ) $search_status .= '&filter=expired' ;
if ( $filter == 'notexpired' ) $search_status .= '&filter=notexpired' ;
2015-11-29 13:03:46 +01:00
}
2005-07-03 23:58:20 +02:00
2006-03-18 18:41:36 +01:00
$staticcontrat = new Contrat ( $db );
$staticcontratligne = new ContratLigne ( $db );
2008-12-15 19:48:42 +01:00
$companystatic = new Societe ( $db );
2005-07-03 23:58:20 +02:00
2016-12-16 01:12:24 +01:00
$arrayfields = array (
2017-10-13 13:28:26 +02:00
'c.ref' => array ( 'label' => $langs -> trans ( " Contract " ), 'checked' => 1 , 'position' => 80 ),
'p.description' => array ( 'label' => $langs -> trans ( " Service " ), 'checked' => 1 , 'position' => 80 ),
2017-09-26 15:15:39 +02:00
'cd.qty' => array ( 'label' => $langs -> trans ( " Qty " ), 'checked' => 0 , 'position' => 100 ),
'cd.total_ht' => array ( 'label' => $langs -> trans ( " TotalHT " ), 'checked' => 0 , 'position' => 100 ),
'cd.total_tva' => array ( 'label' => $langs -> trans ( " TotalVAT " ), 'checked' => 0 , 'position' => 100 ),
'cd.tva_tx' => array ( 'label' => $langs -> trans ( " VAT " ), 'checked' => 0 , 'position' => 100 ),
'cd.subprice' => array ( 'label' => $langs -> trans ( " PriceUHT " ), 'checked' => 0 , 'position' => 100 ),
2017-10-13 13:28:26 +02:00
's.nom' => array ( 'label' => $langs -> trans ( " ThirdParty " ), 'checked' => 1 , 'position' => 100 ),
'cd.date_ouverture_prevue' => array ( 'label' => $langs -> trans ( " DateStartPlannedShort " ), 'checked' => (( $mode == " " || $mode == - 1 ) || $mode == " 0 " )),
'cd.date_ouverture' => array ( 'label' => $langs -> trans ( " DateStartRealShort " ), 'checked' => (( $mode == " " || $mode == - 1 ) || $mode > 0 )),
'cd.date_fin_validite' => array ( 'label' => $langs -> trans ( " DateEndPlannedShort " ), 'checked' => (( $mode == " " || $mode == - 1 ) || $mode < 5 )),
'cd.date_cloture' => array ( 'label' => $langs -> trans ( " DateEndRealShort " ), 'checked' => (( $mode == " " || $mode == - 1 ) || $mode >= 5 )),
'status' => array ( 'label' => $langs -> trans ( " Status " ), 'checked' => 1 ),
//'cd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'cd.tms' => array ( 'label' => $langs -> trans ( " DateModificationShort " ), 'checked' => 0 , 'position' => 500 )
2016-12-16 01:12:24 +01:00
);
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
2017-10-13 13:28:26 +02:00
foreach ( $extrafields -> attribute_label as $key => $val )
{
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 ]));
2017-10-13 13:28:26 +02:00
}
2016-12-16 01:12:24 +01:00
}
2016-11-09 16:11:02 +01:00
2016-07-24 22:17:12 +02:00
/*
* Actions
*/
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-12-16 01:12:24 +01: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' );
if ( empty ( $reshook ))
2014-11-03 06:12:57 +01:00
{
2017-10-13 13:28:26 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
2016-12-16 01:12:24 +01:00
2017-10-13 13:28:26 +02:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) // All test are required to be compatible with all browsers
{
2017-08-24 14:22:45 +02:00
$search_product_category = 0 ;
2017-10-13 13:28:26 +02:00
$search_name = " " ;
$search_contract = " " ;
$search_service = " " ;
$search_status =- 1 ;
$opouvertureprevuemonth = " " ;
$opouvertureprevueday = " " ;
$opouvertureprevueyear = " " ;
$filter_opouvertureprevue = " " ;
$op1month = " " ;
$op1day = " " ;
$op1year = " " ;
$filter_op1 = " " ;
$op2month = " " ;
$op2day = " " ;
$op2year = " " ;
$filter_op2 = " " ;
$opcloturemonth = " " ;
$opclotureday = " " ;
$opclotureyear = " " ;
$filter_opcloture = " " ;
$mode = '' ;
$filter = '' ;
$toselect = '' ;
$search_array_options = array ();
}
2014-11-03 06:12:57 +01:00
}
2016-12-16 01:12:24 +01:00
2006-03-18 18:41:36 +01:00
/*
2008-09-06 00:15:46 +02:00
* View
2006-03-18 18:41:36 +01:00
*/
2008-09-06 00:15:46 +02:00
2012-02-06 05:31:19 +01:00
$now = dol_now ();
2008-10-28 21:05:23 +01:00
2008-10-20 23:42:11 +02:00
$form = new Form ( $db );
2008-10-28 21:05:23 +01:00
$sql = " SELECT c.rowid as cid, c.ref, c.statut as cstatut, " ;
2018-08-15 15:07:23 +02:00
$sql .= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur, " ;
2009-10-10 18:26:06 +02:00
$sql .= " cd.rowid, cd.description, cd.statut, " ;
2015-10-29 12:28:28 +01:00
$sql .= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity, " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " sc.fk_soc, sc.fk_user, " ;
2010-05-08 21:21:57 +02:00
$sql .= " cd.date_ouverture_prevue, " ;
$sql .= " cd.date_ouverture, " ;
$sql .= " cd.date_fin_validite, " ;
2018-04-20 09:45:49 +02:00
$sql .= " cd.date_cloture, " ;
2017-09-26 15:15:39 +02:00
$sql .= " cd.qty, " ;
$sql .= " cd.total_ht, " ;
$sql .= " cd.total_tva, " ;
$sql .= " cd.tva_tx, " ;
$sql .= " cd.subprice, " ;
2016-12-16 01:12:24 +01:00
//$sql.= " cd.date_c as date_creation,";
$sql .= " cd.tms as date_update " ;
// 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 ;
2006-06-12 01:21:59 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " contrat as c, " ;
$sql .= " " . MAIN_DB_PREFIX . " societe as s, " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " " . MAIN_DB_PREFIX . " societe_commerciaux as sc, " ;
2006-06-12 01:21:59 +02:00
$sql .= " " . MAIN_DB_PREFIX . " contratdet as cd " ;
2016-12-16 01:12:24 +01:00
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " contratdet_extrafields as ef on (cd.rowid = ef.fk_object) " ;
2006-06-12 01:21:59 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product as p ON cd.fk_product = p.rowid " ;
2016-11-09 16:11:02 +01:00
if ( $search_product_category > 0 ) $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie_product as cp ON cp.fk_product=cd.fk_product' ;
2012-02-11 10:18:09 +01:00
$sql .= " WHERE c.entity = " . $conf -> entity ;
$sql .= " AND c.rowid = cd.fk_contrat " ;
2016-11-09 16:11:02 +01:00
if ( $search_product_category > 0 ) $sql .= " AND cp.fk_categorie = " . $search_product_category ;
2007-06-12 00:51:47 +02:00
$sql .= " AND c.fk_soc = s.rowid " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2005-07-03 23:58:20 +02:00
if ( $mode == " 0 " ) $sql .= " AND cd.statut = 0 " ;
if ( $mode == " 4 " ) $sql .= " AND cd.statut = 4 " ;
if ( $mode == " 5 " ) $sql .= " AND cd.statut = 5 " ;
2011-08-08 16:25:44 +02:00
if ( $filter == " expired " ) $sql .= " AND cd.date_fin_validite < ' " . $db -> idate ( $now ) . " ' " ;
2015-11-29 13:03:46 +01:00
if ( $filter == " notexpired " ) $sql .= " AND cd.date_fin_validite >= ' " . $db -> idate ( $now ) . " ' " ;
2014-11-03 06:12:57 +01:00
if ( $search_name ) $sql .= " AND s.nom LIKE '% " . $db -> escape ( $search_name ) . " %' " ;
2017-08-02 12:14:36 +02:00
if ( $search_contract ) $sql .= " AND c.ref LIKE '% " . $db -> escape ( $search_contract ) . " %' " ;
2012-07-25 11:46:33 +02:00
if ( $search_service ) $sql .= " AND (p.ref LIKE '% " . $db -> escape ( $search_service ) . " %' OR p.description LIKE '% " . $db -> escape ( $search_service ) . " %' OR cd.description LIKE '% " . $db -> escape ( $search_service ) . " %') " ;
2007-06-12 00:51:47 +02:00
if ( $socid > 0 ) $sql .= " AND s.rowid = " . $socid ;
2016-07-24 22:17:12 +02:00
$filter_dateouvertureprevue = dol_mktime ( 0 , 0 , 0 , $opouvertureprevuemonth , $opouvertureprevueday , $opouvertureprevueyear );
2012-07-25 11:46:33 +02:00
$filter_date1 = dol_mktime ( 0 , 0 , 0 , $op1month , $op1day , $op1year );
$filter_date2 = dol_mktime ( 0 , 0 , 0 , $op2month , $op2day , $op2year );
2016-07-24 22:17:12 +02:00
$filter_datecloture = dol_mktime ( 0 , 0 , 0 , $opcloturemonth , $opclotureday , $opclotureyear );
if ( ! empty ( $filter_opouvertureprevue ) && $filter_opouvertureprevue != - 1 && $filter_dateouvertureprevue != '' ) $sql .= " AND cd.date_ouverture_prevue " . $filter_opouvertureprevue . " ' " . $db -> idate ( $filter_dateouvertureprevue ) . " ' " ;
if ( ! empty ( $filter_op1 ) && $filter_op1 != - 1 && $filter_date1 != '' ) $sql .= " AND cd.date_ouverture " . $filter_op1 . " ' " . $db -> idate ( $filter_date1 ) . " ' " ;
if ( ! empty ( $filter_op2 ) && $filter_op2 != - 1 && $filter_date2 != '' ) $sql .= " AND cd.date_fin_validite " . $filter_op2 . " ' " . $db -> idate ( $filter_date2 ) . " ' " ;
if ( ! empty ( $filter_opcloture ) && $filter_opcloture != - 1 && $filter_datecloture != '' ) $sql .= " AND cd.date_cloture " . $filter_opcloture . " ' " . $db -> idate ( $filter_datecloture ) . " ' " ;
2017-09-15 12:17:18 +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-12-16 01:12:24 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2017-01-15 20:49:20 +01:00
$nbtotalofrecords = '' ;
2016-12-16 01:12:24 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
2015-12-28 00:20:48 +01:00
{
2017-10-13 13:28:26 +02:00
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
2018-04-24 11:37:57 +02:00
if (( $page * $limit ) > $nbtotalofrecords ) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0 ;
$offset = 0 ;
}
2015-12-28 00:20:48 +01:00
}
2016-12-16 01:12:24 +01:00
2012-03-18 19:23:01 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2005-07-03 23:58:20 +02:00
2008-02-25 17:48:16 +01:00
//print $sql;
2017-10-29 11:00:02 +01:00
dol_syslog ( " contrat/services_list.php " , LOG_DEBUG );
2005-07-03 23:58:20 +02:00
$resql = $db -> query ( $sql );
2016-12-16 01:12:24 +01:00
if ( ! $resql )
2005-07-03 23:58:20 +02:00
{
2017-10-13 13:28:26 +02:00
dol_print_error ( $db );
exit ;
2016-12-16 01:12:24 +01:00
}
2016-11-09 16:11:02 +01:00
2016-12-16 01:12:24 +01:00
$num = $db -> num_rows ( $resql );
/*
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $search_all )
{
$obj = $db -> fetch_object ( $resql );
$id = $obj -> id ;
header ( " Location: " . DOL_URL_ROOT . '/projet/tasks/task.php?id=' . $id . '&withprojet=1' );
exit ;
} */
llxHeader ( null , $langs -> trans ( " Services " ));
$param = '' ;
2017-09-16 22:03:25 +02:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . urlencode ( $contextpage );
2016-12-16 01:12:24 +01:00
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
if ( $search_contract ) $param .= '&search_contract=' . urlencode ( $search_contract );
if ( $search_name ) $param .= '&search_name=' . urlencode ( $search_name );
if ( $search_service ) $param .= '&search_service=' . urlencode ( $search_service );
if ( $mode ) $param .= '&mode=' . urlencode ( $mode );
if ( $filter ) $param .= '&filter=' . urlencode ( $filter );
if ( ! empty ( $filter_opouvertureprevue ) && $filter_opouvertureprevue != - 1 ) $param .= '&filter_opouvertureprevue=' . urlencode ( $filter_opouvertureprevue );
if ( ! empty ( $filter_op1 ) && $filter_op1 != - 1 ) $param .= '&filter_op1=' . urlencode ( $filter_op1 );
if ( ! empty ( $filter_op2 ) && $filter_op2 != - 1 ) $param .= '&filter_op2=' . urlencode ( $filter_op2 );
if ( ! empty ( $filter_opcloture ) && $filter_opcloture != - 1 ) $param .= '&filter_opcloture=' . urlencode ( $filter_opcloture );
if ( $filter_dateouvertureprevue != '' ) $param .= '&opouvertureprevueday=' . $opouvertureprevueday . '&opouvertureprevuemonth=' . $opouvertureprevuemonth . '&opouvertureprevueyear=' . $opouvertureprevueyear ;
if ( $filter_date1 != '' ) $param .= '&op1day=' . $op1day . '&op1month=' . $op1month . '&op1year=' . $op1year ;
if ( $filter_date2 != '' ) $param .= '&op2day=' . $op2day . '&op2month=' . $op2month . '&op2year=' . $op2year ;
if ( $filter_datecloture != '' ) $param .= '&opclotureday=' . $op2day . '&opcloturemonth=' . $op2month . '&opclotureyear=' . $op2year ;
if ( $optioncss != '' ) $param .= '&optioncss=' . $optioncss ;
// 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' ;
2016-12-16 01:12:24 +01:00
// List of mass actions available
$arrayofmassactions = array (
2017-10-13 13:28:26 +02:00
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
2016-12-16 01:12:24 +01:00
);
2017-11-15 11:39:11 +01:00
//if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
2017-11-11 16:03:22 +01:00
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
2016-12-16 01:12:24 +01:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
print '<form method="POST" 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 . '">' ;
2017-05-21 02:43:51 +02:00
print '<input type="hidden" name="page" value="' . $page . '">' ;
2017-09-16 22:03:25 +02:00
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2016-12-16 01:12:24 +01:00
$title = $langs -> trans ( " ListOfServices " );
if ( $mode == " 0 " ) $title = $langs -> trans ( " ListOfInactiveServices " ); // Must use == "0"
if ( $mode == " 4 " && $filter != " expired " ) $title = $langs -> trans ( " ListOfRunningServices " );
if ( $mode == " 4 " && $filter == " expired " ) $title = $langs -> trans ( " ListOfExpiredServices " );
if ( $mode == " 5 " ) $title = $langs -> trans ( " ListOfClosedServices " );
print_barre_liste ( $title , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'title_commercial.png' , 0 , '' , '' , $limit );
if ( $sall )
{
2017-10-13 13:28:26 +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>' ;
2016-12-16 01:12:24 +01:00
}
$morefilter = '' ;
// If the user can view categories of products
if ( $conf -> categorie -> enabled && ( $user -> rights -> produit -> lire || $user -> rights -> service -> lire ))
{
2017-10-13 13:28:26 +02:00
include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'IncludingProductWithTag' ) . ': ' ;
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_PRODUCT , null , 'parent' , null , null , 1 );
$moreforfilter .= $form -> selectarray ( 'search_product_category' , $cate_arbo , $search_product_category , 1 , 0 , 0 , '' , 0 , 0 , 0 , 0 , 'maxwidth300' , 1 );
$moreforfilter .= '</div>' ;
2016-12-16 01:12:24 +01: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 ;
if ( ! empty ( $moreforfilter ))
{
2017-10-13 13:28:26 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
print '</div>' ;
2016-12-16 01:12:24 +01:00
}
2009-07-08 12:10:35 +02:00
2016-12-16 01:12:24 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'c.ref' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'c.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " c.ref " , " " , $param , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.description' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.description' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.description " , " " , $param , " " , $sortfield , $sortorder );
2017-09-26 15:15:39 +02:00
if ( ! empty ( $arrayfields [ 'cd.qty' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'cd.qty' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.qty " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'cd.total_ht' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'cd.total_ht' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.total_ht " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'cd.total_tva' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'cd.total_tva' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.total_tva " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'cd.tva_tx' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'cd.tva_tx' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.tva_tx " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'cd.subprice' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'cd.subprice' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.subprice " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
2016-12-16 01:12:24 +01:00
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 's.nom' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " s.nom " , " " , $param , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'cd.date_ouverture_prevue' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'cd.date_ouverture_prevue' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.date_ouverture_prevue " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'cd.date_ouverture' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'cd.date_ouverture' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.date_ouverture " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'cd.date_fin_validite' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'cd.date_fin_validite' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.date_fin_validite " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'cd.date_cloture' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'cd.date_cloture' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.date_cloture " , " " , $param , 'align="center"' , $sortfield , $sortorder );
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
2016-12-16 01:12:24 +01:00
// Hook fields
2018-04-20 10:38:16 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
2016-12-16 01:12:24 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 'cd.datec' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'cd.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.datec " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'cd.tms' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'cd.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.tms " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'status' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'status' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.statut,c.statut " , " " , $param , 'align="right"' , $sortfield , $sortorder );
2017-04-07 14:18:04 +02:00
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' );
2016-12-16 01:12:24 +01:00
print " </tr> \n " ;
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'c.ref' ][ 'checked' ]))
{
2009-07-08 12:10:35 +02:00
print '<td class="liste_titre">' ;
print '<input type="hidden" name="filter" value="' . $filter . '">' ;
print '<input type="hidden" name="mode" value="' . $mode . '">' ;
2011-11-23 18:10:10 +01:00
print '<input type="text" class="flat" size="3" name="search_contract" value="' . dol_escape_htmltag ( $search_contract ) . '">' ;
2009-07-08 12:10:35 +02:00
print '</td>' ;
2016-12-16 01:12:24 +01:00
}
// Service label
if ( ! empty ( $arrayfields [ 'p.description' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
2016-12-16 01:12:24 +01:00
print '<input type="text" class="flat maxwidth100" name="search_service" value="' . dol_escape_htmltag ( $search_service ) . '">' ;
2009-07-08 12:10:35 +02:00
print '</td>' ;
2016-12-16 01:12:24 +01:00
}
2017-09-26 15:15:39 +02:00
// detail lines
if ( ! empty ( $arrayfields [ 'cd.qty' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'cd.total_ht' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'cd.total_tva' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'cd.tva_tx' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'cd.subprice' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
2016-12-16 01:12:24 +01:00
// Third party
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
2016-12-16 01:12:24 +01:00
print '<input type="text" class="flat maxwidth100" name="search_name" value="' . dol_escape_htmltag ( $search_name ) . '">' ;
2009-07-08 12:10:35 +02:00
print '</td>' ;
2016-12-16 01:12:24 +01:00
}
2017-09-26 15:15:39 +02:00
2016-12-16 01:12:24 +01:00
if ( ! empty ( $arrayfields [ 'cd.date_ouverture_prevue' ][ 'checked' ]))
{
print '<td class="liste_titre" align="center">' ;
2017-10-13 13:28:26 +02:00
$arrayofoperators = array ( '<' => '<' , '>' => '>' );
2016-12-16 01:12:24 +01:00
print $form -> selectarray ( 'filter_opouvertureprevue' , $arrayofoperators , $filter_opouvertureprevue , 1 );
print ' ' ;
$filter_dateouvertureprevue = dol_mktime ( 0 , 0 , 0 , $opouvertureprevuemonth , $opouvertureprevueday , $opouvertureprevueyear );
print $form -> select_date ( $filter_dateouvertureprevue , 'opouvertureprevue' , 0 , 0 , 1 , '' , 1 , 0 , 1 );
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'cd.date_ouverture' ][ 'checked' ]))
{
print '<td class="liste_titre" align="center">' ;
2017-10-13 13:28:26 +02:00
$arrayofoperators = array ( '<' => '<' , '>' => '>' );
2016-12-16 01:12:24 +01:00
print $form -> selectarray ( 'filter_op1' , $arrayofoperators , $filter_op1 , 1 );
print ' ' ;
$filter_date1 = dol_mktime ( 0 , 0 , 0 , $op1month , $op1day , $op1year );
print $form -> select_date ( $filter_date1 , 'op1' , 0 , 0 , 1 , '' , 1 , 0 , 1 );
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'cd.date_fin_validite' ][ 'checked' ]))
{
print '<td class="liste_titre" align="center">' ;
$arrayofoperators = array ( '<' => '<' , '>' => '>' );
print $form -> selectarray ( 'filter_op2' , $arrayofoperators , $filter_op2 , 1 );
print ' ' ;
$filter_date2 = dol_mktime ( 0 , 0 , 0 , $op2month , $op2day , $op2year );
print $form -> select_date ( $filter_date2 , 'op2' , 0 , 0 , 1 , '' , 1 , 0 , 1 );
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'cd.date_cloture' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre" align="center">' ;
$arrayofoperators = array ( '<' => '<' , '>' => '>' );
print $form -> selectarray ( 'filter_opcloture' , $arrayofoperators , $filter_opcloture , 1 );
print ' ' ;
$filter_date_cloture = dol_mktime ( 0 , 0 , 0 , $opcloturemonth , $opclotureday , $opclotureyear );
print $form -> select_date ( $filter_date_cloture , 'opcloture' , 0 , 0 , 1 , '' , 1 , 0 , 1 );
print '</td>' ;
2016-12-16 01:12:24 +01:00
}
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
2016-12-16 01:12:24 +01:00
// 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 [ 'cd.datec' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
// Date creation
print '<td class="liste_titre">' ;
print '</td>' ;
2016-12-16 01:12:24 +01:00
}
if ( ! empty ( $arrayfields [ 'cd.tms' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
// Date modification
print '<td class="liste_titre">' ;
print '</td>' ;
2016-12-16 01:12:24 +01:00
}
if ( ! empty ( $arrayfields [ 'status' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
// Status
print '<td class="liste_titre" align="right">' ;
2015-11-29 13:03:46 +01:00
$arrayofstatus = array (
2017-10-13 13:28:26 +02:00
'0' => $langs -> trans ( " ServiceStatusInitial " ),
'4' => $langs -> trans ( " ServiceStatusRunning " ),
'4&filter=notexpired' => $langs -> trans ( " ServiceStatusNotLate " ),
'4&filter=expired' => $langs -> trans ( " ServiceStatusLate " ),
'5' => $langs -> trans ( " ServiceStatusClosed " )
2015-11-29 13:03:46 +01:00
);
2016-12-16 01:12:24 +01:00
print $form -> selectarray ( 'search_status' , $arrayofstatus , ( strstr ( $search_status , ',' ) ? - 1 : $search_status ), 1 , 0 , '' , 0 , 0 , 0 , '' , 'maxwidth100onsmartphone' );
2016-02-07 15:50:48 +01:00
print '</td>' ;
2016-12-16 01:12:24 +01:00
}
// Action column
print '<td class="liste_titre" align="right">' ;
2017-05-14 21:06:33 +02:00
$searchpicto = $form -> showFilterAndCheckAddButtons ( 0 );
print $searchpicto ;
2016-12-16 01:12:24 +01:00
print '</td>' ;
print " </tr> \n " ;
$contractstatic = new Contrat ( $db );
$productstatic = new Product ( $db );
2018-04-17 15:40:12 +02:00
$i = 0 ;
$totalarray = array ();
2016-12-16 01:12:24 +01:00
while ( $i < min ( $num , $limit ))
{
$obj = $db -> fetch_object ( $resql );
2017-06-19 14:31:08 +02:00
2016-12-16 01:12:24 +01:00
$contractstatic -> id = $obj -> cid ;
$contractstatic -> ref = $obj -> ref ? $obj -> ref : $obj -> cid ;
2017-06-19 14:31:08 +02:00
2018-08-15 15:07:23 +02:00
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> name ;
$companystatic -> email = $obj -> email ;
$companystatic -> client = $obj -> client ;
$companystatic -> fournisseur = $obj -> fournisseur ;
2017-06-19 14:31:08 +02:00
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2017-06-19 14:31:08 +02:00
2016-12-16 01:12:24 +01:00
// Ref
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'c.ref' ][ 'checked' ]))
{
print '<td>' ;
2009-08-23 22:47:29 +02:00
print $contractstatic -> getNomUrl ( 1 , 16 );
2009-07-08 12:10:35 +02:00
print '</td>' ;
2018-04-17 15:40:12 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-10-13 13:28:26 +02:00
}
2016-12-16 01:12:24 +01:00
// Service
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'p.description' ][ 'checked' ]))
{
print '<td>' ;
2018-08-15 15:07:23 +02:00
if ( $obj -> pid > 0 )
2011-03-13 01:08:26 +01:00
{
$productstatic -> id = $obj -> pid ;
$productstatic -> type = $obj -> ptype ;
2011-05-03 20:45:37 +02:00
$productstatic -> ref = $obj -> pref ;
2015-10-29 12:28:28 +01:00
$productstatic -> entity = $obj -> pentity ;
2016-06-06 17:21:18 +02:00
print $productstatic -> getNomUrl ( 1 , '' , 24 );
2017-10-13 13:28:26 +02:00
print $obj -> label ? ' - ' . dol_trunc ( $obj -> label , 16 ) : '' ;
if ( ! empty ( $obj -> description ) && ! empty ( $conf -> global -> PRODUCT_DESC_IN_LIST )) print '<br>' . dol_nl2br ( $obj -> description );
2011-03-13 01:08:26 +01:00
}
else
{
2016-06-06 17:21:18 +02:00
if ( $obj -> type == 0 ) print img_object ( $obj -> description , 'product' ) . ' ' . dol_trunc ( $obj -> description , 24 );
if ( $obj -> type == 1 ) print img_object ( $obj -> description , 'service' ) . ' ' . dol_trunc ( $obj -> description , 24 );
2011-03-13 01:08:26 +01:00
}
2009-07-08 12:10:35 +02:00
print '</td>' ;
2018-04-17 15:40:12 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-10-13 13:28:26 +02:00
}
if ( ! empty ( $arrayfields [ 'cd.qty' ][ 'checked' ]))
{
print '<td>' ;
print $obj -> qty ;
print '</td>' ;
2018-04-17 15:40:12 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-10-13 13:28:26 +02:00
}
if ( ! empty ( $arrayfields [ 'cd.total_ht' ][ 'checked' ]))
{
2018-04-17 15:40:12 +02:00
print '<td align="right">' ;
2017-10-13 13:28:26 +02:00
print price ( $obj -> total_ht );
print '</td>' ;
2018-04-17 15:40:12 +02:00
$totalarray [ 'totalht' ] += $obj -> total_ht ;
if ( ! $i ) {
$totalarray [ 'displaytotalline' ] ++ ;
$totalarray [ 'nbfield' ] ++ ;
$totalarray [ 'totalhtfield' ] = $totalarray [ 'nbfield' ];
}
}
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'cd.total_tva' ][ 'checked' ]))
{
2018-04-17 15:40:12 +02:00
print '<td align="right">' ;
2017-10-13 13:28:26 +02:00
print price ( $obj -> total_tva );
print '</td>' ;
2018-04-17 15:40:12 +02:00
$totalarray [ 'totalvat' ] += $obj -> total_tva ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
$totalarray [ 'totalvatfield' ] = $totalarray [ 'nbfield' ];
$totalarray [ 'displaytotalline' ] ++ ;
}
}
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'cd.tva_tx' ][ 'checked' ]))
{
2018-04-17 15:40:12 +02:00
print '<td align="right">' ;
2017-10-13 13:28:26 +02:00
print price2num ( $obj -> tva_tx ) . '%' ;
print '</td>' ;
2018-04-17 15:40:12 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-10-13 13:28:26 +02:00
}
if ( ! empty ( $arrayfields [ 'cd.subprice' ][ 'checked' ]))
{
2018-04-17 15:40:12 +02:00
print '<td align="right">' ;
2017-10-13 13:28:26 +02:00
print price ( $obj -> subprice );
print '</td>' ;
2018-04-17 15:40:12 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-10-13 13:28:26 +02:00
}
2017-09-26 15:15:39 +02:00
2016-12-16 01:12:24 +01:00
// Third party
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ]))
{
print '<td>' ;
2009-08-23 22:47:29 +02:00
print $companystatic -> getNomUrl ( 1 , 'customer' , 28 );
2008-12-15 19:48:42 +01:00
print '</td>' ;
2018-04-17 15:40:12 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-10-13 13:28:26 +02:00
}
2017-06-19 14:31:08 +02:00
2016-12-16 01:12:24 +01:00
// Start date
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'cd.date_ouverture_prevue' ][ 'checked' ]))
{
2016-12-16 01:12:24 +01:00
print '<td align="center">' ;
2018-04-20 09:45:49 +02:00
print ( $obj -> date_ouverture_prevue ? dol_print_date ( $db -> jdate ( $obj -> date_ouverture_prevue ), 'dayhour' ) : ' ' );
2016-12-16 01:12:24 +01:00
if ( $db -> jdate ( $obj -> date_ouverture_prevue ) && ( $db -> jdate ( $obj -> date_ouverture_prevue ) < ( $now - $conf -> contrat -> services -> inactifs -> warning_delay )) && $obj -> statut == 0 )
print ' ' . img_picto ( $langs -> trans ( " Late " ), " warning " );
else print ' ' ;
2009-07-08 12:10:35 +02:00
print '</td>' ;
2018-04-17 15:40:12 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-12-16 01:12:24 +01:00
}
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'cd.date_ouverture' ][ 'checked' ]))
{
2018-04-20 09:45:49 +02:00
print '<td align="center">' . ( $obj -> date_ouverture ? dol_print_date ( $db -> jdate ( $obj -> date_ouverture ), 'dayhour' ) : ' ' ) . '</td>' ;
2018-04-17 15:40:12 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-12-16 01:12:24 +01:00
}
// End date
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'cd.date_fin_validite' ][ 'checked' ]))
{
2018-04-20 09:45:49 +02:00
print '<td align="center">' . ( $obj -> date_fin_validite ? dol_print_date ( $db -> jdate ( $obj -> date_fin_validite ), 'dayhour' ) : ' ' );
2017-06-19 14:31:08 +02:00
if ( $obj -> date_fin_validite && $db -> jdate ( $obj -> date_fin_validite ) < ( $now - $conf -> contrat -> services -> expires -> warning_delay ) && $obj -> statut < 5 )
2009-07-08 12:10:35 +02:00
{
2017-10-13 13:28:26 +02:00
$warning_delay = $conf -> contrat -> services -> expires -> warning_delay / 3600 / 24 ;
$textlate = $langs -> trans ( " Late " ) . ' = ' . $langs -> trans ( " DateReference " ) . ' > ' . $langs -> trans ( " DateToday " ) . ' ' . ( ceil ( $warning_delay ) >= 0 ? '+' : '' ) . ceil ( $warning_delay ) . ' ' . $langs -> trans ( " days " );
print img_warning ( $textlate );
2009-07-08 12:10:35 +02:00
}
2016-12-16 01:12:24 +01:00
else print ' ' ;
2017-10-13 13:28:26 +02:00
print '</td>' ;
2018-04-17 15:40:12 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-10-13 13:28:26 +02:00
}
2018-04-20 09:45:49 +02:00
// Close date (real end date)
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'cd.date_cloture' ][ 'checked' ]))
{
2018-04-20 09:45:49 +02:00
print '<td align="center">' . dol_print_date ( $db -> jdate ( $obj -> date_cloture ), 'dayhour' ) . '</td>' ;
2018-04-17 15:40:12 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-10-13 13:28:26 +02:00
}
2009-07-08 12:10:35 +02:00
2016-12-16 01:12:24 +01:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
2016-12-16 01:12:24 +01:00
// 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 [ 'cd.datec' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-12-16 01:12:24 +01:00
}
// Date modification
if ( ! empty ( $arrayfields [ 'cd.tms' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-12-16 01:12:24 +01:00
}
// Status
if ( ! empty ( $arrayfields [ 'status' ][ 'checked' ]))
{
print '<td align="right">' ;
if ( $obj -> cstatut == 0 ) // If contract is draft, we say line is also draft
{
2017-10-13 13:28:26 +02:00
print $contractstatic -> LibStatut ( 0 , 5 ,( $obj -> date_fin_validite && $db -> jdate ( $obj -> date_fin_validite ) < $now ));
2016-12-16 01:12:24 +01:00
}
else
{
2017-10-13 13:28:26 +02:00
print $staticcontratligne -> LibStatut ( $obj -> statut , 5 ,( $obj -> date_fin_validite && $db -> jdate ( $obj -> date_fin_validite ) < $now ) ? 1 : 0 );
2016-12-16 01:12:24 +01:00
}
print '</td>' ;
2018-04-17 15:40:12 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-12-16 01:12:24 +01:00
}
// 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
{
2017-10-13 13:28:26 +02:00
$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"' : '' ) . '>' ;
2016-12-16 01:12:24 +01:00
}
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-06-19 14:31:08 +02:00
2016-12-16 01:12:24 +01:00
print " </tr> \n " ;
$i ++ ;
2005-07-03 23:58:20 +02:00
}
2018-04-17 15:40:12 +02:00
// Show total line
if ( isset ( $totalarray [ 'displaytotalline' ])) {
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 [ '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>' ;
}
2016-12-16 01:12:24 +01:00
$db -> free ( $resql );
$parameters = array ( 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
print '</table>' ;
print '</div>' ;
print '</form>' ;
2005-07-03 23:58:20 +02:00
2011-08-27 16:24:16 +02:00
llxFooter ();
2015-11-29 13:03:46 +01:00
$db -> close ();