2005-07-03 23:58:20 +02:00
< ? php
2018-09-09 09:36:12 +02:00
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2018-09-09 09:36:12 +02:00
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
* Copyright ( C ) 2018 Ferran Marcet < fmarcet @ 2 byte . es >
* Copyright ( C ) 2018 Frédéric France < frederic . france @ netlogic . fr >
2019-05-11 17:00:55 +02:00
* Copyright ( C ) 2019 Juanjo Menent < jmenent @ 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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// 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
2018-07-26 11:57:25 +02:00
require " ../main.inc.php " ;
require_once DOL_DOCUMENT_ROOT . " /contrat/class/contrat.class.php " ;
require_once DOL_DOCUMENT_ROOT . " /product/class/product.class.php " ;
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
2021-08-17 02:33:58 +02:00
$optioncss = GETPOST ( 'optioncss' , 'aZ09' );
2021-10-23 23:12:42 +02:00
$massaction = GETPOST ( 'massaction' , 'alpha' );
2019-11-13 19:35:39 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2022-01-13 11:09:37 +01:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2021-02-23 21:24:38 +01: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 ;
2021-02-23 21:24:38 +01:00
if ( ! $sortfield ) {
$sortfield = " c.rowid " ;
}
if ( ! $sortorder ) {
$sortorder = " ASC " ;
}
2005-08-13 01:31:45 +02:00
2016-12-16 01:12:24 +01:00
$mode = GETPOST ( " mode " );
2019-11-13 19:35:39 +01:00
$filter = GETPOST ( " filter " );
$search_name = GETPOST ( " search_name " , 'alpha' );
$search_contract = GETPOST ( " search_contract " , 'alpha' );
$search_service = GETPOST ( " search_service " , 'alpha' );
$search_status = GETPOST ( " search_status " , 'alpha' );
$search_product_category = GETPOST ( 'search_product_category' , 'int' );
$socid = GETPOST ( 'socid' , 'int' );
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'contractservicelist' . $mode ;
$opouvertureprevuemonth = GETPOST ( 'opouvertureprevuemonth' );
$opouvertureprevueday = GETPOST ( 'opouvertureprevueday' );
$opouvertureprevueyear = GETPOST ( 'opouvertureprevueyear' );
$filter_opouvertureprevue = GETPOST ( 'filter_opouvertureprevue' );
$op1month = GETPOST ( 'op1month' , 'int' );
$op1day = GETPOST ( 'op1day' , 'int' );
$op1year = GETPOST ( 'op1year' , 'int' );
$filter_op1 = GETPOST ( 'filter_op1' , 'alpha' );
$op2month = GETPOST ( 'op2month' , 'int' );
$op2day = GETPOST ( 'op2day' , 'int' );
$op2year = GETPOST ( 'op2year' , 'int' );
$filter_op2 = GETPOST ( 'filter_op2' , 'alpha' );
$opcloturemonth = GETPOST ( 'opcloturemonth' , 'int' );
$opclotureday = GETPOST ( 'opclotureday' , 'int' );
$opclotureyear = GETPOST ( 'opclotureyear' , 'int' );
$filter_opcloture = GETPOST ( 'filter_opcloture' , 'alpha' );
2016-07-24 22:17:12 +02:00
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
2020-08-04 12:47:09 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2019-10-06 14:41:52 +02:00
2020-01-30 01:48:28 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
2016-12-16 01:12:24 +01:00
2008-02-25 17:30:43 +01:00
// Security check
2019-01-27 11:55:16 +01:00
$contratid = GETPOST ( 'id' , 'int' );
2021-02-23 21:24:38 +01:00
if ( ! empty ( $user -> socid )) {
$socid = $user -> socid ;
}
2019-01-27 11:55:16 +01:00
$result = restrictedArea ( $user , 'contrat' , $contratid );
2008-02-25 17:30:43 +01:00
2021-02-23 21:24:38 +01:00
if ( $search_status != '' ) {
2020-01-30 01:48:28 +01:00
$tmp = explode ( '&' , $search_status );
$mode = $tmp [ 0 ];
2021-02-23 21:24:38 +01:00
if ( empty ( $tmp [ 1 ])) {
$filter = '' ;
} else {
if ( $tmp [ 1 ] == 'filter=notexpired' ) {
$filter = 'notexpired' ;
}
if ( $tmp [ 1 ] == 'filter=expired' ) {
$filter = 'expired' ;
}
2017-10-13 13:28:26 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2017-10-13 13:28:26 +02:00
$search_status = $mode ;
2021-02-23 21:24:38 +01:00
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
2020-01-30 01:48:28 +01:00
$staticcontrat = new Contrat ( $db );
$staticcontratligne = new ContratLigne ( $db );
$companystatic = new Societe ( $db );
2005-07-03 23:58:20 +02:00
2020-01-30 01:48:28 +01:00
$arrayfields = array (
2021-04-15 14:20:59 +02:00
'c.ref' => array ( 'label' => " Contract " , 'checked' => 1 , 'position' => 80 ),
'p.description' => array ( 'label' => " Service " , 'checked' => 1 , 'position' => 80 ),
's.nom' => array ( 'label' => " ThirdParty " , 'checked' => 1 , 'position' => 90 ),
'cd.tva_tx' => array ( 'label' => " VATRate " , 'checked' =>- 1 , 'position' => 100 ),
'cd.subprice' => array ( 'label' => " PriceUHT " , 'checked' =>- 1 , 'position' => 105 ),
'cd.qty' => array ( 'label' => " Qty " , 'checked' =>- 1 , 'position' => 108 ),
'cd.total_ht' => array ( 'label' => " TotalHT " , 'checked' =>- 1 , 'position' => 109 ),
'cd.total_tva' => array ( 'label' => " TotalVAT " , 'checked' =>- 1 , 'position' => 110 ),
'cd.date_ouverture_prevue' => array ( 'label' => " DateStartPlannedShort " , 'checked' => (( $mode == " " || $mode == - 1 ) || $mode == " 0 " ), 'position' => 150 ),
'cd.date_ouverture' => array ( 'label' => " DateStartRealShort " , 'checked' => (( $mode == " " || $mode == - 1 ) || $mode > 0 ), 'position' => 160 ),
'cd.date_fin_validite' => array ( 'label' => " DateEndPlannedShort " , 'checked' => (( $mode == " " || $mode == - 1 ) || $mode < 5 ), 'position' => 170 ),
'cd.date_cloture' => array ( 'label' => " DateEndRealShort " , 'checked' => (( $mode == " " || $mode == - 1 ) || $mode >= 5 ), 'position' => 180 ),
2017-10-13 13:28:26 +02:00
//'cd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
2021-04-15 14:20:59 +02:00
'cd.tms' => array ( 'label' => " DateModificationShort " , 'checked' => 0 , 'position' => 500 ),
'status' => array ( 'label' => " Status " , 'checked' => 1 , 'position' => 1000 )
2016-12-16 01:12:24 +01:00
);
// Extra fields
2020-12-23 19:14:47 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php' ;
2019-09-02 03:58:00 +02:00
$object -> fields = dol_sort_array ( $object -> fields , 'position' );
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
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
*/
2021-02-23 21:24:38 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
$action = 'list' ; $massaction = '' ;
}
2022-04-25 14:28:57 +02:00
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) {
2021-02-23 21:24:38 +01:00
$massaction = '' ;
}
2016-12-16 01:12:24 +01:00
2019-11-13 19:35:39 +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
2021-02-23 21:24:38 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2016-12-16 01:12:24 +01:00
2021-02-23 21:24:38 +01:00
if ( empty ( $reshook )) {
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
2021-02-23 21:24:38 +01: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
$search_product_category = 0 ;
2019-11-13 19:35:39 +01: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 = '' ;
2022-05-08 18:25:22 +02:00
$toselect = array ();
2019-11-13 19:35:39 +01:00
$search_array_options = array ();
2017-10-13 13:28:26 +02:00
}
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
2020-01-30 01:48:28 +01:00
$now = dol_now ();
2008-10-28 21:05:23 +01:00
2020-01-30 01:48:28 +01:00
$form = new Form ( $db );
2008-10-20 23:42:11 +02:00
2020-08-27 09:32:00 +02:00
$sql = " SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier, " ;
2020-01-30 01:48:28 +01:00
$sql .= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur, " ;
$sql .= " cd.rowid, cd.description, cd.statut, " ;
2022-06-26 21:00:46 +02:00
$sql .= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.tobuy, p.tosell, p.barcode, p.entity as pentity, " ;
2021-10-22 22:15:59 +02:00
if ( empty ( $user -> rights -> societe -> client -> voir ) && ! $socid ) {
2021-02-23 21:24:38 +01:00
$sql .= " sc.fk_soc, sc.fk_user, " ;
}
2020-01-30 01:48:28 +01:00
$sql .= " cd.date_ouverture_prevue, " ;
$sql .= " cd.date_ouverture, " ;
$sql .= " cd.date_fin_validite, " ;
$sql .= " cd.date_cloture, " ;
$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,";
2020-01-30 01:48:28 +01:00
$sql .= " cd.tms as date_update " ;
2016-12-16 01:12:24 +01:00
// Add fields from extrafields
2020-01-30 01:48:28 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-23 21:24:38 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) {
2021-08-27 22:42:04 +02:00
$sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " , ef. " . $key . " as options_ " . $key : '' );
2021-02-23 21:24:38 +01:00
}
2019-10-16 03:34:32 +02:00
}
2016-12-16 01:12:24 +01:00
// Add fields from hooks
2020-01-30 01:48:28 +01:00
$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 . " contrat as c, " ;
$sql .= " " . MAIN_DB_PREFIX . " societe as s, " ;
2021-10-22 22:15:59 +02:00
if ( empty ( $user -> rights -> societe -> client -> voir ) && ! $socid ) {
2021-02-23 21:24:38 +01:00
$sql .= " " . MAIN_DB_PREFIX . " societe_commerciaux as sc, " ;
}
2020-01-30 01:48:28 +01:00
$sql .= " " . MAIN_DB_PREFIX . " contratdet as cd " ;
2021-10-23 23:12:42 +02:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && is_array ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-23 21:24:38 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object -> table_element . " _extrafields as ef on (cd.rowid = ef.fk_object) " ;
}
2020-01-30 01:48:28 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product as p ON cd.fk_product = p.rowid " ;
2021-02-23 21:24:38 +01:00
if ( $search_product_category > 0 ) {
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie_product as cp ON cp.fk_product=cd.fk_product' ;
}
2020-01-30 01:48:28 +01:00
$sql .= " WHERE c.entity = " . $conf -> entity ;
$sql .= " AND c.rowid = cd.fk_contrat " ;
2021-02-23 21:24:38 +01:00
if ( $search_product_category > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND cp.fk_categorie = " . (( int ) $search_product_category );
2021-02-23 21:24:38 +01:00
}
2020-01-30 01:48:28 +01:00
$sql .= " AND c.fk_soc = s.rowid " ;
2021-10-22 22:15:59 +02:00
if ( empty ( $user -> rights -> societe -> client -> voir ) && ! $socid ) {
2021-08-23 17:41:11 +02:00
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . (( int ) $user -> id );
2021-02-23 21:24:38 +01: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 " ;
}
if ( $filter == " expired " ) {
$sql .= " AND cd.date_fin_validite < ' " . $db -> idate ( $now ) . " ' " ;
}
if ( $filter == " notexpired " ) {
$sql .= " AND cd.date_fin_validite >= ' " . $db -> idate ( $now ) . " ' " ;
}
if ( $search_name ) {
$sql .= " AND s.nom LIKE '% " . $db -> escape ( $search_name ) . " %' " ;
}
if ( $search_contract ) {
$sql .= " AND c.ref LIKE '% " . $db -> escape ( $search_contract ) . " %' " ;
}
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 ) . " %') " ;
}
if ( $socid > 0 ) {
2021-04-24 20:18:11 +02:00
$sql .= " AND s.rowid = " . (( int ) $socid );
2021-02-23 21:24:38 +01:00
}
2020-01-24 15:10:57 +01:00
2021-08-18 11:47:59 +02:00
$filter_dateouvertureprevue = '' ;
$filter_date1 = '' ;
$filter_date2 = '' ;
$filter_opcloture = '' ;
2020-10-31 14:32:18 +01:00
$filter_dateouvertureprevue_start = dol_mktime ( 0 , 0 , 0 , $opouvertureprevuemonth , $opouvertureprevueday , $opouvertureprevueyear );
$filter_dateouvertureprevue_end = dol_mktime ( 23 , 59 , 59 , $opouvertureprevuemonth , $opouvertureprevueday , $opouvertureprevueyear );
2021-02-23 21:24:38 +01:00
if ( $filter_dateouvertureprevue_start != '' && $filter_opouvertureprevue == - 1 ) {
$filter_opouvertureprevue = ' BETWEEN ' ;
}
2020-05-05 18:14:38 +02:00
2020-10-31 14:32:18 +01:00
$filter_date1_start = dol_mktime ( 0 , 0 , 0 , $op1month , $op1day , $op1year );
$filter_date1_end = dol_mktime ( 23 , 59 , 59 , $op1month , $op1day , $op1year );
2021-02-23 21:24:38 +01:00
if ( $filter_date1_start != '' && $filter_op1 == - 1 ) {
$filter_op1 = ' BETWEEN ' ;
}
2020-05-05 18:14:38 +02:00
2020-10-31 14:32:18 +01:00
$filter_date2_start = dol_mktime ( 0 , 0 , 0 , $op2month , $op2day , $op2year );
$filter_date2_end = dol_mktime ( 23 , 59 , 59 , $op2month , $op2day , $op2year );
2021-02-23 21:24:38 +01:00
if ( $filter_date2_start != '' && $filter_op2 == - 1 ) {
$filter_op2 = ' BETWEEN ' ;
}
2020-05-05 18:14:38 +02:00
2020-10-31 14:32:18 +01:00
$filter_datecloture_start = dol_mktime ( 0 , 0 , 0 , $opcloturemonth , $opclotureday , $opclotureyear );
$filter_datecloture_end = dol_mktime ( 23 , 59 , 59 , $opcloturemonth , $opclotureday , $opclotureyear );
2021-02-23 21:24:38 +01:00
if ( $filter_datecloture_start != '' && $filter_opcloture == - 1 ) {
$filter_opcloture = ' BETWEEN ' ;
}
if ( ! empty ( $filter_opouvertureprevue ) && $filter_opouvertureprevue != - 1 && $filter_opouvertureprevue != ' BETWEEN ' && $filter_dateouvertureprevue_start != '' ) {
$sql .= " AND cd.date_ouverture_prevue " . $filter_opouvertureprevue . " ' " . $db -> idate ( $filter_dateouvertureprevue_start ) . " ' " ;
}
if ( ! empty ( $filter_opouvertureprevue ) && $filter_opouvertureprevue == ' BETWEEN ' ) {
2022-04-05 18:21:28 +02:00
$sql .= " AND cd.date_ouverture_prevue " . $filter_opouvertureprevue . " ' " . $db -> idate ( $filter_dateouvertureprevue_start ) . " ' AND ' " . $db -> idate ( $filter_dateouvertureprevue_end ) . " ' " ;
2021-02-23 21:24:38 +01:00
}
if ( ! empty ( $filter_op1 ) && $filter_op1 != - 1 && $filter_op1 != ' BETWEEN ' && $filter_date1_start != '' ) {
$sql .= " AND cd.date_ouverture " . $filter_op1 . " ' " . $db -> idate ( $filter_date1_start ) . " ' " ;
}
if ( ! empty ( $filter_op1 ) && $filter_op1 == ' BETWEEN ' ) {
2022-04-05 18:21:28 +02:00
$sql .= " AND cd.date_ouverture " . $filter_op1 . " ' " . $db -> idate ( $filter_date1_start ) . " ' AND ' " . $db -> idate ( $filter_date1_end ) . " ' " ;
2021-02-23 21:24:38 +01:00
}
if ( ! empty ( $filter_op2 ) && $filter_op2 != - 1 && $filter_op2 != ' BETWEEN ' && $filter_date2_start != '' ) {
$sql .= " AND cd.date_fin_validite " . $filter_op2 . " ' " . $db -> idate ( $filter_date2_start ) . " ' " ;
}
if ( ! empty ( $filter_op2 ) && $filter_op2 == ' BETWEEN ' ) {
2022-04-05 18:21:28 +02:00
$sql .= " AND cd.date_fin_validite " . $filter_op2 . " ' " . $db -> idate ( $filter_date2_start ) . " ' AND ' " . $db -> idate ( $filter_date2_end ) . " ' " ;
2021-02-23 21:24:38 +01:00
}
if ( ! empty ( $filter_opcloture ) && $filter_opcloture != ' BETWEEN ' && $filter_opcloture != - 1 && $filter_datecloture_start != '' ) {
$sql .= " AND cd.date_cloture " . $filter_opcloture . " ' " . $db -> idate ( $filter_datecloture_start ) . " ' " ;
}
if ( ! empty ( $filter_opcloture ) && $filter_opcloture == ' BETWEEN ' ) {
2022-04-05 18:21:28 +02:00
$sql .= " AND cd.date_cloture " . $filter_opcloture . " ' " . $db -> idate ( $filter_datecloture_start ) . " ' AND ' " . $db -> idate ( $filter_datecloture_end ) . " ' " ;
2021-02-23 21:24:38 +01:00
}
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' ;
2019-01-27 11:55:16 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2016-12-16 01:12:24 +01:00
2020-01-24 15:10:57 +01:00
//print $sql;
2017-01-15 20:49:20 +01:00
$nbtotalofrecords = '' ;
2021-02-23 21:24:38 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2017-10-13 13:28:26 +02:00
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
2021-02-23 21:24:38 +01:00
if (( $page * $limit ) > $nbtotalofrecords ) { // if total resultset is smaller then paging size (filtering), goto and load page 0
2018-04-24 11:37:57 +02:00
$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 );
2019-11-13 19:35:39 +01:00
$resql = $db -> query ( $sql );
2021-02-23 21:24:38 +01:00
if ( ! $resql ) {
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 )
{
2021-02-23 21:24:38 +01:00
$obj = $db -> fetch_object ( $resql );
$id = $obj -> id ;
header ( " Location: " . DOL_URL_ROOT . '/projet/tasks/task.php?id=' . $id . '&withprojet=1' );
exit ;
2016-12-16 01:12:24 +01:00
} */
llxHeader ( null , $langs -> trans ( " Services " ));
2019-11-13 19:35:39 +01:00
$param = '' ;
2021-02-23 21:24:38 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
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 );
}
2021-08-17 02:33:58 +02:00
if ( $filter_dateouvertureprevue_start != '' ) {
2021-12-12 23:47:40 +01:00
$param .= '&opouvertureprevueday=' . (( int ) $opouvertureprevueday ) . '&opouvertureprevuemonth=' . (( int ) $opouvertureprevuemonth ) . '&opouvertureprevueyear=' . (( int ) $opouvertureprevueyear );
2021-02-23 21:24:38 +01:00
}
2021-08-17 02:33:58 +02:00
if ( $filter_date1_start != '' ) {
2021-12-12 23:47:40 +01:00
$param .= '&op1day=' . (( int ) $op1day ) . '&op1month=' . (( int ) $op1month ) . '&op1year=' . (( int ) $op1year );
2021-02-23 21:24:38 +01:00
}
2021-08-17 02:33:58 +02:00
if ( $filter_date2_start != '' ) {
2021-12-12 23:47:40 +01:00
$param .= '&op2day=' . (( int ) $op2day ) . '&op2month=' . (( int ) $op2month ) . '&op2year=' . (( int ) $op2year );
2021-02-23 21:24:38 +01:00
}
2021-08-17 02:33:58 +02:00
if ( $filter_datecloture_start != '' ) {
2021-12-12 23:47:40 +01:00
$param .= '&opclotureday=' . (( int ) $op2day ) . '&opcloturemonth=' . (( int ) $op2month ) . '&opclotureyear=' . (( int ) $op2year );
2021-02-23 21:24:38 +01:00
}
2021-08-18 11:47:59 +02:00
2021-02-23 21:24:38 +01:00
if ( $optioncss != '' ) {
2021-12-12 23:47:40 +01:00
$param .= '&optioncss=' . urlencode ( $optioncss );
2021-02-23 21:24:38 +01:00
}
2016-12-16 01:12:24 +01: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' ;
2016-12-16 01:12:24 +01:00
// List of mass actions available
2019-11-13 19:35:39 +01:00
$arrayofmassactions = array (
2021-04-14 14:45:55 +02:00
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
2016-12-16 01:12:24 +01:00
);
2021-04-14 14:45:55 +02:00
//if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
2017-11-11 16:03:22 +01:00
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
2019-11-13 19:35:39 +01:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2016-12-16 01:12:24 +01:00
2019-11-13 19:35:39 +01:00
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2021-02-23 21:24:38 +01:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2016-12-16 01:12:24 +01:00
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
2019-11-13 19:35:39 +01:00
$title = $langs -> trans ( " ListOfServices " );
2021-02-23 21:24:38 +01:00
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 " );
}
2020-04-25 13:49:44 +02:00
print_barre_liste ( $title , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'contract' , 0 , '' , '' , $limit );
2016-12-16 01:12:24 +01:00
2021-08-18 22:29:09 +02:00
if ( ! empty ( $sall )) {
2021-02-23 21:24:38 +01:00
foreach ( $fieldstosearchall as $key => $val ) {
$fieldstosearchall [ $key ] = $langs -> trans ( $val );
}
2019-11-13 19:35:39 +01:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
2016-12-16 01:12:24 +01:00
}
$morefilter = '' ;
2021-08-16 12:52:44 +02:00
$moreforfilter = '' ;
2016-12-16 01:12:24 +01:00
// If the user can view categories of products
2022-06-09 22:41:59 +02:00
if ( isModEnabled ( 'categorie' ) && ( $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' ;
2019-11-13 19:35:39 +01:00
$moreforfilter .= '<div class="divsearchfield">' ;
2021-12-12 23:47:40 +01:00
$tmptitle = $langs -> trans ( 'IncludingProductWithTag' );
2017-10-13 13:28:26 +02:00
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_PRODUCT , null , 'parent' , null , null , 1 );
2021-12-12 23:47:40 +01:00
$moreforfilter .= img_picto ( $tmptitle , 'category' , 'class="pictofixedwidth"' ) . $form -> selectarray ( 'search_product_category' , $cate_arbo , $search_product_category , $tmptitle , 0 , 0 , '' , 0 , 0 , 0 , 0 , 'widthcentpercentminusx maxwidth300' , 1 );
2019-11-13 19:35:39 +01:00
$moreforfilter .= '</div>' ;
2016-12-16 01:12:24 +01:00
}
2019-11-13 19:35:39 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
2021-02-23 21:24:38 +01:00
if ( empty ( $reshook )) {
$moreforfilter .= $hookmanager -> resPrint ;
} else {
$moreforfilter = $hookmanager -> resPrint ;
}
2016-12-16 01:12:24 +01:00
2021-02-23 21:24:38 +01:00
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
2019-11-13 19:35:39 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2016-12-16 01:12:24 +01:00
print '<div class="div-table-responsive">' ;
2019-11-13 19:35:39 +01:00
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2016-12-16 01:12:24 +01:00
print '<tr class="liste_titre">' ;
2021-02-23 21:24:38 +01:00
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 );
}
2021-04-15 14:20:59 +02:00
if ( ! empty ( $arrayfields [ 'cd.tva_tx' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cd.tva_tx' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.tva_tx " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'cd.subprice' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cd.subprice' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.subprice " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'cd.qty' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cd.qty' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.qty " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'cd.total_ht' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cd.total_ht' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.total_ht " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'cd.total_tva' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cd.total_tva' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.total_tva " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
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 , '' , $sortfield , $sortorder , 'center ' );
}
if ( ! empty ( $arrayfields [ 'cd.date_ouverture' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cd.date_ouverture' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.date_ouverture " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
}
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 , '' , $sortfield , $sortorder , 'center ' );
}
if ( ! empty ( $arrayfields [ 'cd.date_cloture' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cd.date_cloture' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.date_cloture " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
}
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_title.tpl.php' ;
2016-12-16 01:12:24 +01:00
// Hook fields
2019-11-13 19:35:39 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
2016-12-16 01:12:24 +01:00
print $hookmanager -> resPrint ;
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'cd.datec' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cd.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.datec " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'cd.tms' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cd.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.tms " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'status' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'status' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " cd.statut,c.statut " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
2019-03-03 09:37:43 +01:00
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' );
2016-12-16 01:12:24 +01:00
print " </tr> \n " ;
print '<tr class="liste_titre">' ;
2021-02-23 21:24:38 +01:00
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
2021-02-23 21:24:38 +01:00
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
2021-04-15 14:20:59 +02:00
if ( ! empty ( $arrayfields [ 'cd.tva_tx' ][ 'checked' ])) {
2017-09-26 15:15:39 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
}
2021-04-15 14:20:59 +02:00
if ( ! empty ( $arrayfields [ 'cd.subprice' ][ 'checked' ])) {
2017-09-26 15:15:39 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
}
2021-04-15 14:20:59 +02:00
if ( ! empty ( $arrayfields [ 'cd.qty' ][ 'checked' ])) {
2017-09-26 15:15:39 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
}
2021-04-15 14:20:59 +02:00
if ( ! empty ( $arrayfields [ 'cd.total_ht' ][ 'checked' ])) {
2017-09-26 15:15:39 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
}
2021-04-15 14:20:59 +02:00
if ( ! empty ( $arrayfields [ 'cd.total_tva' ][ 'checked' ])) {
2017-09-26 15:15:39 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
}
2016-12-16 01:12:24 +01:00
// Third party
2021-02-23 21:24:38 +01:00
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
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'cd.date_ouverture_prevue' ][ 'checked' ])) {
2019-03-03 09:37:43 +01:00
print '<td class="liste_titre center">' ;
2019-11-13 19:35:39 +01:00
$arrayofoperators = array ( '<' => '<' , '>' => '>' );
2021-12-12 23:47:40 +01:00
print $form -> selectarray ( 'filter_opouvertureprevue' , $arrayofoperators , $filter_opouvertureprevue , 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'width50' );
2016-12-16 01:12:24 +01:00
print ' ' ;
2019-11-13 19:35:39 +01:00
$filter_dateouvertureprevue = dol_mktime ( 0 , 0 , 0 , $opouvertureprevuemonth , $opouvertureprevueday , $opouvertureprevueyear );
2018-09-09 09:36:12 +02:00
print $form -> selectDate ( $filter_dateouvertureprevue , 'opouvertureprevue' , 0 , 0 , 1 , '' , 1 , 0 );
2016-12-16 01:12:24 +01:00
print '</td>' ;
}
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'cd.date_ouverture' ][ 'checked' ])) {
2019-03-03 09:37:43 +01:00
print '<td class="liste_titre center">' ;
2019-11-13 19:35:39 +01:00
$arrayofoperators = array ( '<' => '<' , '>' => '>' );
2021-12-12 23:47:40 +01:00
print $form -> selectarray ( 'filter_op1' , $arrayofoperators , $filter_op1 , 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'width50' );
2016-12-16 01:12:24 +01:00
print ' ' ;
2019-11-13 19:35:39 +01:00
$filter_date1 = dol_mktime ( 0 , 0 , 0 , $op1month , $op1day , $op1year );
2018-09-09 09:36:12 +02:00
print $form -> selectDate ( $filter_date1 , 'op1' , 0 , 0 , 1 , '' , 1 , 0 );
2016-12-16 01:12:24 +01:00
print '</td>' ;
}
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'cd.date_fin_validite' ][ 'checked' ])) {
2019-03-03 09:37:43 +01:00
print '<td class="liste_titre center">' ;
2019-11-13 19:35:39 +01:00
$arrayofoperators = array ( '<' => '<' , '>' => '>' );
2021-12-12 23:47:40 +01:00
print $form -> selectarray ( 'filter_op2' , $arrayofoperators , $filter_op2 , 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'width50' );
2016-12-16 01:12:24 +01:00
print ' ' ;
2019-11-13 19:35:39 +01:00
$filter_date2 = dol_mktime ( 0 , 0 , 0 , $op2month , $op2day , $op2year );
2018-09-09 09:36:12 +02:00
print $form -> selectDate ( $filter_date2 , 'op2' , 0 , 0 , 1 , '' , 1 , 0 );
2016-12-16 01:12:24 +01:00
print '</td>' ;
}
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'cd.date_cloture' ][ 'checked' ])) {
2019-03-03 09:37:43 +01:00
print '<td class="liste_titre center">' ;
2019-11-13 19:35:39 +01:00
$arrayofoperators = array ( '<' => '<' , '>' => '>' );
2021-12-12 23:47:40 +01:00
print $form -> selectarray ( 'filter_opcloture' , $arrayofoperators , $filter_opcloture , 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'width50' );
2017-10-13 13:28:26 +02:00
print ' ' ;
2019-11-13 19:35:39 +01:00
$filter_date_cloture = dol_mktime ( 0 , 0 , 0 , $opcloturemonth , $opclotureday , $opclotureyear );
2018-09-09 09:36:12 +02:00
print $form -> selectDate ( $filter_date_cloture , 'opcloture' , 0 , 0 , 1 , '' , 1 , 0 );
2017-10-13 13:28:26 +02:00
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
2019-11-13 19:35:39 +01:00
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
2016-12-16 01:12:24 +01:00
print $hookmanager -> resPrint ;
2021-02-23 21:24:38 +01:00
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
}
2021-02-23 21:24:38 +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
}
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'status' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
// Status
2019-02-19 17:17:11 +01:00
print '<td class="liste_titre right">' ;
2019-11-13 19:35:39 +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
);
2022-06-26 17:00:45 +02:00
print $form -> selectarray ( 'search_status' , $arrayofstatus , ( strstr ( $search_status , ',' ) ? - 1 : $search_status ), 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'minwidth100imp maxwidth150' );
2016-02-07 15:50:48 +01:00
print '</td>' ;
2016-12-16 01:12:24 +01:00
}
// Action column
2019-05-19 13:51:47 +02:00
print '<td class="liste_titre maxwidthsearch">' ;
2019-11-13 19:35:39 +01:00
$searchpicto = $form -> showFilterAndCheckAddButtons ( 0 );
2017-05-14 21:06:33 +02:00
print $searchpicto ;
2016-12-16 01:12:24 +01:00
print '</td>' ;
print " </tr> \n " ;
2019-11-13 19:35:39 +01:00
$contractstatic = new Contrat ( $db );
$productstatic = new Product ( $db );
2016-12-16 01:12:24 +01:00
2019-11-13 19:35:39 +01:00
$i = 0 ;
$totalarray = array ();
2021-02-23 21:24:38 +01:00
while ( $i < min ( $num , $limit )) {
2016-12-16 01:12:24 +01:00
$obj = $db -> fetch_object ( $resql );
2017-06-19 14:31:08 +02:00
2019-11-13 19:35:39 +01:00
$contractstatic -> id = $obj -> cid ;
$contractstatic -> ref = $obj -> ref ? $obj -> ref : $obj -> cid ;
2020-08-27 09:32:00 +02:00
$contractstatic -> ref_customer = $obj -> ref_customer ;
$contractstatic -> ref_supplier = $obj -> ref_supplier ;
2017-06-19 14:31:08 +02:00
2019-11-13 19:35:39 +01: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
2022-06-26 21:00:46 +02:00
$productstatic -> id = $obj -> pid ;
$productstatic -> type = $obj -> ptype ;
$productstatic -> ref = $obj -> pref ;
$productstatic -> entity = $obj -> pentity ;
$productstatic -> status = $obj -> tosell ;
$productstatic -> status_buy = $obj -> tobuy ;
$productstatic -> label = $obj -> label ;
$productstatic -> description = $obj -> description ;
$productstatic -> barcode = $obj -> barcode ;
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
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'c.ref' ][ 'checked' ])) {
2020-07-09 13:56:29 +02:00
print '<td class="nowraponall">' ;
2019-01-27 11:55:16 +01:00
print $contractstatic -> getNomUrl ( 1 , 16 );
2009-07-08 12:10:35 +02:00
print '</td>' ;
2021-02-23 21:24:38 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2016-12-16 01:12:24 +01:00
// Service
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'p.description' ][ 'checked' ])) {
2022-06-26 21:00:46 +02:00
print '<td class="tdoverflowmax300">' ;
2021-02-23 21:24:38 +01:00
if ( $obj -> pid > 0 ) {
2019-01-27 11:55:16 +01:00
print $productstatic -> getNomUrl ( 1 , '' , 24 );
2019-11-13 19:35:39 +01:00
print $obj -> label ? ' - ' . dol_trunc ( $obj -> label , 16 ) : '' ;
2021-02-23 21:24:38 +01:00
if ( ! empty ( $obj -> description ) && ! empty ( $conf -> global -> PRODUCT_DESC_IN_LIST )) {
2022-06-26 21:00:46 +02:00
print '<br><span class="small">' . dol_nl2br ( $obj -> description ) . '</span>' ;
2021-02-23 21:24:38 +01:00
}
2020-05-21 15:05:19 +02:00
} else {
2021-02-23 21:24:38 +01: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>' ;
2021-02-23 21:24:38 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2021-04-15 14:20:59 +02:00
if ( ! empty ( $arrayfields [ 'cd.tva_tx' ][ 'checked' ])) {
2022-06-26 21:00:46 +02:00
print '<td class="right nowraponall">' ;
2021-04-15 14:20:59 +02:00
print price2num ( $obj -> tva_tx ) . '%' ;
2017-10-13 13:28:26 +02:00
print '</td>' ;
2021-02-23 21:24:38 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2021-04-15 14:20:59 +02:00
if ( ! empty ( $arrayfields [ 'cd.subprice' ][ 'checked' ])) {
2022-06-26 21:00:46 +02:00
print '<td class="right nowraponall">' ;
2021-04-15 14:20:59 +02:00
print price ( $obj -> subprice );
2017-10-13 13:28:26 +02:00
print '</td>' ;
2021-02-23 21:24:38 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-10-31 14:32:18 +01:00
}
2021-04-15 14:20:59 +02:00
if ( ! empty ( $arrayfields [ 'cd.qty' ][ 'checked' ])) {
2022-06-26 21:00:46 +02:00
print '<td class="right nowraponall">' ;
2021-04-15 14:20:59 +02:00
print $obj -> qty ;
2017-10-13 13:28:26 +02:00
print '</td>' ;
2021-02-23 21:24:38 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-10-31 14:32:18 +01:00
}
2021-04-15 14:20:59 +02:00
if ( ! empty ( $arrayfields [ 'cd.total_ht' ][ 'checked' ])) {
2022-06-26 21:00:46 +02:00
print '<td class="right nowraponall">' ;
2021-04-15 14:20:59 +02:00
print '<span class="amount">' . price ( $obj -> total_ht ) . '</span>' ;
2017-10-13 13:28:26 +02:00
print '</td>' ;
2021-02-23 21:24:38 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-04-15 14:20:59 +02:00
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'cd.total_ht' ;
}
$totalarray [ 'val' ][ 'cd.total_ht' ] += $obj -> total_ht ;
2017-10-13 13:28:26 +02:00
}
2021-04-15 14:20:59 +02:00
if ( ! empty ( $arrayfields [ 'cd.total_tva' ][ 'checked' ])) {
2022-06-26 21:00:46 +02:00
print '<td class="right nowraponall">' ;
2021-04-15 14:20:59 +02:00
print '<span class="amount">' . price ( $obj -> total_tva ) . '</span>' ;
2017-10-13 13:28:26 +02:00
print '</td>' ;
2021-02-23 21:24:38 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-04-15 14:20:59 +02:00
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'cd.total_tva' ;
}
$totalarray [ 'val' ][ 'cd.total_tva' ] += $obj -> total_tva ;
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
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
2021-04-15 14:20:59 +02:00
print '<td class="tdoverflowmax100">' ;
2019-01-27 11:55:16 +01:00
print $companystatic -> getNomUrl ( 1 , 'customer' , 28 );
2008-12-15 19:48:42 +01:00
print '</td>' ;
2021-02-23 21:24:38 +01: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
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'cd.date_ouverture_prevue' ][ 'checked' ])) {
2022-06-26 21:00:46 +02:00
print '<td class="center nowraponall">' ;
2020-01-30 01:48:28 +01:00
print ( $obj -> date_ouverture_prevue ? dol_print_date ( $db -> jdate ( $obj -> date_ouverture_prevue ), 'dayhour' ) : ' ' );
2021-02-23 21:24:38 +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>' ;
2021-02-23 21:24:38 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-12-16 01:12:24 +01:00
}
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'cd.date_ouverture' ][ 'checked' ])) {
2022-06-26 21:00:46 +02:00
print '<td class="center nowraponall">' . ( $obj -> date_ouverture ? dol_print_date ( $db -> jdate ( $obj -> date_ouverture ), 'dayhour' ) : ' ' ) . '</td>' ;
2021-02-23 21:24:38 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-12-16 01:12:24 +01:00
}
// End date
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'cd.date_fin_validite' ][ 'checked' ])) {
2022-06-26 21:00:46 +02:00
print '<td class="center nowraponall">' . ( $obj -> date_fin_validite ? dol_print_date ( $db -> jdate ( $obj -> date_fin_validite ), 'dayhour' ) : ' ' );
2021-02-23 21:24:38 +01:00
if ( $obj -> date_fin_validite && $db -> jdate ( $obj -> date_fin_validite ) < ( $now - $conf -> contrat -> services -> expires -> warning_delay ) && $obj -> statut < 5 ) {
2020-01-30 01:48:28 +01:00
$warning_delay = $conf -> contrat -> services -> expires -> warning_delay / 3600 / 24 ;
2017-10-13 13:28:26 +02:00
$textlate = $langs -> trans ( " Late " ) . ' = ' . $langs -> trans ( " DateReference " ) . ' > ' . $langs -> trans ( " DateToday " ) . ' ' . ( ceil ( $warning_delay ) >= 0 ? '+' : '' ) . ceil ( $warning_delay ) . ' ' . $langs -> trans ( " days " );
print img_warning ( $textlate );
2021-02-23 21:24:38 +01:00
} else {
print ' ' ;
}
2017-10-13 13:28:26 +02:00
print '</td>' ;
2021-02-23 21:24:38 +01: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)
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'cd.date_cloture' ][ 'checked' ])) {
2022-06-26 21:00:46 +02:00
print '<td class="center nowraponall">' . dol_print_date ( $db -> jdate ( $obj -> date_cloture ), 'dayhour' ) . '</td>' ;
2021-02-23 21:24:38 +01: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
2020-05-11 19:43:06 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj , 'i' => $i , 'totalarray' =>& $totalarray );
2020-01-30 01:48:28 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
2016-12-16 01:12:24 +01:00
print $hookmanager -> resPrint ;
// Date creation
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'cd.datec' ][ 'checked' ])) {
2019-03-03 09:37:43 +01:00
print '<td class="center">' ;
2017-10-13 13:28:26 +02:00
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
print '</td>' ;
2021-02-23 21:24:38 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-12-16 01:12:24 +01:00
}
// Date modification
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'cd.tms' ][ 'checked' ])) {
2022-06-26 21:00:46 +02:00
print '<td class="center nowraponall">' ;
2017-10-13 13:28:26 +02:00
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
print '</td>' ;
2021-02-23 21:24:38 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-12-16 01:12:24 +01:00
}
// Status
2021-02-23 21:24:38 +01:00
if ( ! empty ( $arrayfields [ 'status' ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
print '<td class="right">' ;
2021-02-23 21:24:38 +01:00
if ( $obj -> cstatut == 0 ) {
2019-10-26 18:23:51 +02:00
// If contract is draft, we say line is also draft
2020-10-31 14:32:18 +01:00
print $contractstatic -> LibStatut ( 0 , 5 );
} else {
print $staticcontratligne -> LibStatut ( $obj -> statut , 5 , ( $obj -> date_fin_validite && $db -> jdate ( $obj -> date_fin_validite ) < $now ) ? 1 : 0 );
}
print '</td>' ;
2021-02-23 21:24:38 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-12-16 01:12:24 +01:00
}
// Action column
2019-03-03 09:37:43 +01:00
print '<td class="nowrap center">' ;
2021-02-23 21:24:38 +01:00
if ( $massactionbutton || $massaction ) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2020-01-30 01:48:28 +01:00
$selected = 0 ;
2021-02-23 21:24:38 +01:00
if ( in_array ( $obj -> rowid , $arrayofselected )) {
$selected = 1 ;
}
2020-01-30 01:48:28 +01:00
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>' ;
2021-02-23 21:24:38 +01:00
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
2019-11-05 12:47:38 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php' ;
2018-04-17 15:40:12 +02:00
2016-12-16 01:12:24 +01:00
$db -> free ( $resql );
2019-11-13 19:35:39 +01:00
$parameters = array ( 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters ); // Note that $action and $object may have been modified by hook
2016-12-16 01:12:24 +01:00
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 ();