2004-10-19 22:43:23 +02:00
< ? php
2005-04-15 10:05:18 +02:00
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2015-06-30 01:34:17 +02:00
* Copyright ( C ) 2004 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2005 - 2010 Regis Houssin < regis . houssin @ capnetworks . com >
2018-04-20 10:38:16 +02:00
* Copyright ( C ) 2016 - 2018 Ferran Marcet < fmarcet @ 2 byte . es >
2003-11-13 18:36:45 +01:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2003-11-13 18:36:45 +01:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2011-08-01 01:45:11 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2003-11-13 18:36:45 +01:00
*/
2005-04-04 21:38:17 +02:00
/**
2014-09-18 20:33:37 +02:00
* \file htdocs / expedition / list . php
2009-08-24 15:01:29 +02:00
* \ingroup expedition
2010-04-21 10:53:55 +02:00
* \brief Page to list all shipments
2009-08-24 15:01:29 +02:00
*/
2003-11-13 18:36:45 +01:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php' ;
2016-04-08 01:00:02 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
2016-04-08 02:39:57 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2003-11-13 18:36:45 +01:00
2018-05-26 20:51:17 +02:00
// Load translation files required by the page
2017-12-01 16:48:43 +01:00
$langs -> loadLangs ( array ( " sendings " , " deliveries " , 'companies' , 'bills' ));
2008-01-17 11:27:59 +01:00
2018-03-31 18:48:27 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'shipmentlist' ; // To manage different context of search
2016-01-28 12:30:49 +01:00
$socid = GETPOST ( 'socid' , 'int' );
2008-02-25 17:30:43 +01:00
// Security check
2012-03-08 15:28:32 +01:00
$expeditionid = GETPOST ( 'id' , 'int' );
2008-02-25 21:03:21 +01:00
if ( $user -> societe_id ) $socid = $user -> societe_id ;
2008-03-01 02:26:41 +01:00
$result = restrictedArea ( $user , 'expedition' , $expeditionid , '' );
2008-02-25 17:30:43 +01:00
2016-04-08 02:53:10 +02:00
$diroutputmassaction = $conf -> expedition -> dir_output . '/temp/massgeneration/' . $user -> id ;
2017-10-03 16:00:52 +02:00
$search_ref_exp = GETPOST ( " search_ref_exp " , 'alpha' );
$search_ref_liv = GETPOST ( 'search_ref_liv' , 'alpha' );
$search_ref_customer = GETPOST ( 'search_ref_customer' , 'alpha' );
$search_company = GETPOST ( " search_company " , 'alpha' );
2016-04-08 01:00:02 +02:00
$search_town = GETPOST ( 'search_town' , 'alpha' );
$search_zip = GETPOST ( 'search_zip' , 'alpha' );
$search_state = trim ( GETPOST ( " search_state " ));
$search_country = GETPOST ( " search_country " , 'int' );
$search_type_thirdparty = GETPOST ( " search_type_thirdparty " , 'int' );
2017-08-02 17:15:51 +02:00
$search_billed = GETPOST ( " search_billed " , 'int' );
2017-12-12 11:31:30 +01:00
$sall = trim (( GETPOST ( 'search_all' , 'alphanohtml' ) != '' ) ? GETPOST ( 'search_all' , 'alphanohtml' ) : GETPOST ( 'sall' , 'alphanohtml' ));
2015-10-04 10:45:57 +02:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2014-09-17 17:58:37 +02:00
2017-06-08 14:55:12 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2012-03-08 15:28:32 +01:00
$sortfield = GETPOST ( 'sortfield' , 'alpha' );
$sortorder = GETPOST ( 'sortorder' , 'alpha' );
$page = GETPOST ( 'page' , 'int' );
2016-02-10 23:37:34 +01:00
if ( ! $sortfield ) $sortfield = " e.ref " ;
if ( ! $sortorder ) $sortorder = " DESC " ;
2017-06-06 10:53:53 +02:00
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
2015-12-16 19:38:40 +01:00
$offset = $limit * $page ;
2010-11-20 14:08:44 +01:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2005-04-14 22:08:48 +02:00
2015-04-18 01:21:22 +02:00
$viewstatut = GETPOST ( 'viewstatut' );
2018-12-16 18:44:58 +01:00
$object = new Expedition ( $db );
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
2016-04-08 01:00:02 +02:00
$hookmanager -> initHooks ( array ( 'shipmentlist' ));
$extrafields = new ExtraFields ( $db );
// fetch optionals attributes and labels
2016-04-08 02:39:57 +02:00
$extralabels = $extrafields -> fetch_name_optionals_label ( 'expedition' );
2016-04-08 01:00:02 +02:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $extralabels , '' , 'search_' );
2005-08-15 00:29:38 +02:00
2016-01-08 23:59:02 +01:00
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
2017-10-13 13:28:26 +02:00
'e.ref' => " Ref " ,
's.nom' => " ThirdParty " ,
'e.note_public' => 'NotePublic' ,
2016-01-08 23:59:02 +01:00
);
2016-09-03 12:56:49 +02:00
if ( empty ( $user -> socid )) $fieldstosearchall [ " e.note_private " ] = " NotePrivate " ;
2016-01-08 23:59:02 +01:00
2016-04-08 01:00:02 +02:00
$checkedtypetiers = 0 ;
2016-02-10 23:37:34 +01:00
$arrayfields = array (
2017-10-13 13:28:26 +02:00
'e.ref' => array ( 'label' => $langs -> trans ( " Ref " ), 'checked' => 1 ),
'e.ref_customer' => array ( 'label' => $langs -> trans ( " RefCustomer " ), 'checked' => 1 ),
's.nom' => array ( 'label' => $langs -> trans ( " ThirdParty " ), 'checked' => 1 ),
's.town' => array ( 'label' => $langs -> trans ( " Town " ), 'checked' => 1 ),
's.zip' => array ( 'label' => $langs -> trans ( " Zip " ), 'checked' => 1 ),
'state.nom' => array ( 'label' => $langs -> trans ( " StateShort " ), 'checked' => 0 ),
'country.code_iso' => array ( 'label' => $langs -> trans ( " Country " ), 'checked' => 0 ),
'typent.code' => array ( 'label' => $langs -> trans ( " ThirdPartyType " ), 'checked' => $checkedtypetiers ),
'e.date_delivery' => array ( 'label' => $langs -> trans ( " DateDeliveryPlanned " ), 'checked' => 1 ),
'e.datec' => array ( 'label' => $langs -> trans ( " DateCreation " ), 'checked' => 0 , 'position' => 500 ),
'e.tms' => array ( 'label' => $langs -> trans ( " DateModificationShort " ), 'checked' => 0 , 'position' => 500 ),
'e.fk_statut' => array ( 'label' => $langs -> trans ( " Status " ), 'checked' => 1 , 'position' => 1000 ),
2018-01-13 17:21:56 +01:00
'l.ref' => array ( 'label' => $langs -> trans ( " DeliveryRef " ), 'checked' => 1 , 'enabled' => ( empty ( $conf -> livraison_bon -> enabled ) ? 0 : 1 )),
'l.date_delivery' => array ( 'label' => $langs -> trans ( " DateReceived " ), 'checked' => 1 , 'enabled' => ( empty ( $conf -> livraison_bon -> enabled ) ? 0 : 1 )),
2017-10-13 13:28:26 +02:00
'e.billed' => array ( 'label' => $langs -> trans ( " Billed " ), 'checked' => 1 , 'position' => 1000 , 'enabled' => ( ! empty ( $conf -> global -> WORKFLOW_BILL_ON_SHIPMENT )))
2016-02-10 23:37:34 +01:00
);
2016-04-08 01:00:02 +02:00
2016-02-10 23:37:34 +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-02-10 23:37:34 +01:00
}
2016-01-08 23:59:02 +01:00
2016-04-08 01:00:02 +02:00
/*
* Actions
*/
2017-09-15 10:50:50 +02:00
if ( GETPOST ( 'cancel' , 'alpha' )) { $action = 'list' ; $massaction = '' ; }
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' )) { $massaction = '' ; }
2016-04-08 01:00:02 +02:00
$parameters = array ( 'socid' => $socid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
2017-07-13 00:35:10 +02:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) // All tests are required to be compatible with all browsers
2016-04-08 01:00:02 +02:00
{
2017-10-13 13:28:26 +02:00
$search_ref_exp = '' ;
$search_ref_liv = '' ;
$search_ref_customer = '' ;
$search_company = '' ;
$search_town = '' ;
2016-04-08 01:00:02 +02:00
$search_zip = " " ;
2017-10-13 13:28:26 +02:00
$search_state = " " ;
2016-04-08 01:00:02 +02:00
$search_type = '' ;
$search_country = '' ;
$search_type_thirdparty = '' ;
2017-08-02 17:15:51 +02:00
$search_billed = '' ;
2017-10-13 13:28:26 +02:00
$viewstatut = '' ;
$search_array_options = array ();
2016-04-08 01:00:02 +02:00
}
if ( empty ( $reshook ))
{
2017-10-13 13:28:26 +02:00
// Mass actions. Controls on number of lines checked
$maxformassaction = 1000 ;
2018-04-02 09:44:45 +02:00
$numtoselect = ( is_array ( $toselect ) ? count ( $toselect ) : 0 );
if ( ! empty ( $massaction ) && $numtoselect < 1 )
2017-10-13 13:28:26 +02:00
{
$error ++ ;
setEventMessages ( $langs -> trans ( " NoLineChecked " ), null , " warnings " );
}
2018-04-02 09:44:45 +02:00
if ( ! $error && $numtoselect > $maxformassaction )
2017-10-13 13:28:26 +02:00
{
setEventMessages ( $langs -> trans ( 'TooManyRecordForMassAction' , $maxformassaction ), null , 'errors' );
$error ++ ;
}
2016-04-08 01:00:02 +02:00
}
2017-06-19 14:31:08 +02:00
2016-04-08 01:00:02 +02:00
2009-08-24 15:01:29 +02:00
/*
* View
*/
2005-08-15 00:29:38 +02:00
2016-03-01 00:59:42 +01:00
$form = new Form ( $db );
2010-04-21 10:53:55 +02:00
$companystatic = new Societe ( $db );
2010-05-27 00:06:27 +02:00
$shipment = new Expedition ( $db );
2016-04-08 01:00:02 +02:00
$formcompany = new FormCompany ( $db );
2010-04-21 10:53:55 +02:00
2009-08-24 15:01:29 +02:00
$helpurl = 'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones' ;
llxHeader ( '' , $langs -> trans ( 'ListOfSendings' ), $helpurl );
2006-05-06 12:50:56 +02:00
2017-08-02 17:15:51 +02:00
$sql = " SELECT e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.date_delivery as date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed, " ;
2016-04-08 02:39:57 +02:00
$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ' ;
$sql .= " typent.code as typent_code, " ;
$sql .= " state.code_departement as state_code, state.nom as state_name, " ;
$sql .= ' e.date_creation as date_creation, e.tms as date_update' ;
2016-04-08 01:00:02 +02:00
// Add fields from extrafields
foreach ( $extrafields -> attribute_label as $key => $val ) $sql .= ( $extrafields -> attribute_type [ $key ] != 'separate' ? " ,ef. " . $key . ' as options_' . $key : '' );
// Add fields from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2016-04-08 02:39:57 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " expedition as e " ;
2016-04-08 01:00:02 +02:00
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " expedition_extrafields as ef on (e.rowid = ef.fk_object) " ;
2008-01-17 11:27:59 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s ON s.rowid = e.fk_soc " ;
2016-04-08 01:00:02 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_country as country on (country.rowid = s.fk_pays) " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_typent as typent on (typent.id = s.fk_typent) " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_departements as state on (state.rowid = s.fk_departement) " ;
2015-04-18 01:09:16 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery' " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " livraison as l ON l.rowid = ee.fk_target " ;
2016-04-08 02:39:57 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) // Internal user with no permission to see all
{
$sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
}
2017-05-30 18:50:54 +02:00
$sql .= " WHERE e.entity IN ( " . getEntity ( 'expedition' ) . " ) " ;
2010-02-27 18:30:17 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) // Internal user with no permission to see all
2008-01-17 11:27:59 +01:00
{
2010-02-27 18:30:17 +01:00
$sql .= " AND e.fk_soc = sc.fk_soc " ;
2009-04-27 22:37:50 +02:00
$sql .= " AND sc.fk_user = " . $user -> id ;
2008-01-17 11:27:59 +01:00
}
2006-09-13 20:56:30 +02:00
if ( $socid )
2009-08-24 15:01:29 +02:00
{
2010-04-21 10:53:55 +02:00
$sql .= " AND e.fk_soc = " . $socid ;
2003-11-13 18:36:45 +01:00
}
2016-01-13 20:56:20 +01:00
if ( $viewstatut <> '' && $viewstatut >= 0 ) {
2015-04-18 01:21:22 +02:00
$sql .= " AND e.fk_statut = " . $viewstatut ;
}
2017-10-03 16:00:52 +02:00
if ( $search_ref_customer != '' ) $sql .= natural_search ( 'e.ref_customer' , $search_ref_customer );
2017-08-02 17:15:51 +02:00
if ( $search_billed != '' && $search_billed >= 0 ) $sql .= ' AND e.billed = ' . $search_billed ;
2016-04-08 02:39:57 +02:00
if ( $search_town ) $sql .= natural_search ( 's.town' , $search_town );
if ( $search_zip ) $sql .= natural_search ( " s.zip " , $search_zip );
if ( $search_state ) $sql .= natural_search ( " state.nom " , $search_state );
if ( $search_country ) $sql .= " AND s.fk_pays IN ( " . $search_country . ')' ;
if ( $search_type_thirdparty ) $sql .= " AND s.fk_typent IN ( " . $search_type_thirdparty . ')' ;
2014-09-17 17:58:37 +02:00
if ( $search_ref_exp ) $sql .= natural_search ( 'e.ref' , $search_ref_exp );
if ( $search_ref_liv ) $sql .= natural_search ( 'l.ref' , $search_ref_liv );
2014-11-20 06:55:38 +01:00
if ( $search_company ) $sql .= natural_search ( 's.nom' , $search_company );
2016-01-08 23:59:02 +01:00
if ( $sall ) $sql .= natural_search ( array_keys ( $fieldstosearchall ), $sall );
2003-11-13 18:36:45 +01:00
2016-04-08 01:00:02 +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-04-08 01:00:02 +02:00
// Add where from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2018-04-24 11:37:57 +02:00
$sql .= $db -> order ( $sortfield , $sortorder );
2017-01-15 20:49:20 +01:00
$nbtotalofrecords = '' ;
2016-01-12 08:41:25 +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 );
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 ;
}
2016-01-12 08:41:25 +01:00
}
2008-01-17 11:27:59 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2003-11-13 18:36:45 +01:00
2016-01-13 20:56:20 +01:00
//print $sql;
2005-04-04 21:38:17 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
2003-11-13 18:36:45 +01:00
{
2010-04-21 10:53:55 +02:00
$num = $db -> num_rows ( $resql );
$expedition = new Expedition ( $db );
2016-02-10 23:37:34 +01:00
$param = '' ;
2017-10-13 13:28:26 +02:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . urlencode ( $contextpage );
2018-05-25 13:14:58 +02:00
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . urlencode ( $limit );
2017-10-03 16:00:52 +02:00
if ( $sall ) $param .= " &sall= " . urlencode ( $sall );
2018-05-25 13:14:58 +02:00
if ( $search_ref_exp ) $param .= " &search_ref_exp= " . urlencode ( $search_ref_exp );
if ( $search_ref_liv ) $param .= " &search_ref_liv= " . urlencode ( $search_ref_liv );
2017-10-03 16:00:52 +02:00
if ( $search_ref_customer ) $param .= " &search_ref_customer= " . urlencode ( $search_ref_customer );
2018-05-25 13:14:58 +02:00
if ( $search_company ) $param .= " &search_company= " . urlencode ( $search_company );
if ( $search_town ) $param .= '&search_town=' . urlencode ( $search_town );
if ( $search_zip ) $param .= '&search_zip=' . urlencode ( $search_zip );
if ( $viewstatut != '' ) $param .= '&viewstatut=' . urlencode ( $viewstatut );
if ( $optioncss != '' ) $param .= '&optioncss=' . urlencode ( $optioncss );
2016-04-08 01:00:02 +02:00
// Add $param from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
2017-06-19 14:31:08 +02:00
2016-04-08 01:00:02 +02:00
//$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
2017-06-19 14:31:08 +02:00
2018-03-30 16:54:38 +02:00
$newcardbutton = '' ;
if ( $user -> rights -> expedition -> creer )
{
2018-06-13 22:57:41 +02:00
$newcardbutton = '<a class="butActionNew" href="' . DOL_URL_ROOT . '/expedition/card.php?action=create2"><span class="valignmiddle">' . $langs -> trans ( 'NewSending' ) . '</span>' ;
2018-04-18 03:26:15 +02:00
$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>' ;
$newcardbutton .= '</a>' ;
2018-03-30 16:54:38 +02:00
}
2010-04-21 10:53:55 +02:00
$i = 0 ;
2017-10-13 13:28:26 +02:00
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '">' . " \n " ;
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="page" value="' . $page . '">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
2017-06-19 14:31:08 +02:00
2018-03-30 16:54:38 +02:00
print_barre_liste ( $langs -> trans ( 'ListOfSendings' ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , '' , $num , $nbtotalofrecords , '' , 0 , $newcardbutton , '' , $limit );
2016-01-08 23:59:02 +01:00
2017-10-13 13:28:26 +02:00
if ( $sall )
{
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>' ;
2017-10-13 13:28:26 +02:00
}
$moreforfilter = '' ;
if ( ! empty ( $moreforfilter ))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
$parameters = array ( 'type' => $type );
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
print '</div>' ;
}
$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 " ;
2010-04-21 10:53:55 +02:00
2014-09-17 17:58:37 +02:00
// Lignes des champs de filtre
2017-03-30 15:39:50 +02:00
print '<tr class="liste_titre_filter">' ;
2016-04-08 01:00:02 +02:00
// Ref
2017-06-19 14:31:08 +02:00
if ( ! empty ( $arrayfields [ 'e.ref' ][ 'checked' ]))
2016-04-08 01:00:02 +02:00
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" size="6" type="text" name="search_ref_exp" value="' . $search_ref_exp . '">' ;
print '</td>' ;
2016-10-29 14:45:54 +02:00
}
// Ref customer
2017-06-19 14:31:08 +02:00
if ( ! empty ( $arrayfields [ 'e.ref_customer' ][ 'checked' ]))
2016-10-29 14:45:54 +02:00
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" size="6" type="text" name="search_ref_customer" value="' . $search_ref_customer . '">' ;
print '</td>' ;
2016-04-08 01:00:02 +02:00
}
// Thirdparty
2017-06-19 14:31:08 +02:00
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ]))
2016-04-08 01:00:02 +02:00
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre" align="left">' ;
print '<input class="flat" type="text" size="8" name="search_company" value="' . dol_escape_htmltag ( $search_company ) . '">' ;
print '</td>' ;
2016-04-08 01:00:02 +02:00
}
// Town
if ( ! empty ( $arrayfields [ 's.town' ][ 'checked' ])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="' . $search_town . '"></td>' ;
// Zip
if ( ! empty ( $arrayfields [ 's.zip' ][ 'checked' ])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="' . $search_zip . '"></td>' ;
// State
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'state.nom' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '<input class="flat" size="4" type="text" name="search_state" value="' . dol_escape_htmltag ( $search_state ) . '">' ;
print '</td>' ;
}
// Country
if ( ! empty ( $arrayfields [ 'country.code_iso' ][ 'checked' ]))
{
print '<td class="liste_titre" align="center">' ;
print $form -> select_country ( $search_country , 'search_country' , '' , 0 , 'maxwidth100' );
print '</td>' ;
}
2016-04-08 01:00:02 +02:00
// Company type
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'typent.code' ][ 'checked' ]))
{
print '<td class="liste_titre maxwidthonsmartphone" align="center">' ;
print $form -> selectarray ( " search_type_thirdparty " , $formcompany -> typent_array ( 0 ), $search_type_thirdparty , 0 , 0 , 0 , '' , 0 , 0 , 0 , ( empty ( $conf -> global -> SOCIETE_SORT_ON_TYPEENT ) ? 'ASC' : $conf -> global -> SOCIETE_SORT_ON_TYPEENT ));
print '</td>' ;
}
2016-04-08 01:00:02 +02:00
// Date delivery planned
2017-06-19 14:31:08 +02:00
if ( ! empty ( $arrayfields [ 'e.date_delivery' ][ 'checked' ]))
2016-04-08 01:00:02 +02:00
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre"> </td>' ;
2016-04-08 01:00:02 +02:00
}
2017-06-19 14:31:08 +02:00
if ( ! empty ( $arrayfields [ 'l.ref' ][ 'checked' ]))
2016-04-08 01:00:02 +02:00
{
2017-10-13 13:28:26 +02:00
// Delivery ref
2014-09-17 17:58:37 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" size="10" type="text" name="search_ref_liv" value="' . $search_ref_liv . '"' ;
print '</td>' ;
2016-04-08 01:00:02 +02:00
}
2017-06-19 14:31:08 +02:00
if ( ! empty ( $arrayfields [ 'l.date_delivery' ][ 'checked' ]))
2016-04-08 01:00:02 +02:00
{
2017-10-13 13:28:26 +02:00
// Date received
2014-09-17 17:58:37 +02:00
print '<td class="liste_titre"> </td>' ;
2014-07-25 16:31:41 +02:00
}
2016-04-08 01:00:02 +02:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
2016-04-08 01:00:02 +02: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 ;
// Date creation
if ( ! empty ( $arrayfields [ 'e.datec' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
2016-04-08 01:00:02 +02:00
}
// Date modification
if ( ! empty ( $arrayfields [ 'e.tms' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
2016-04-08 01:00:02 +02:00
}
2015-06-30 01:34:17 +02:00
// Status
2016-04-08 01:00:02 +02:00
if ( ! empty ( $arrayfields [ 'e.fk_statut' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre maxwidthonsmartphone" align="right">' ;
print $form -> selectarray ( 'viewstatut' , array ( '0' => $langs -> trans ( 'StatusSendingDraftShort' ), '1' => $langs -> trans ( 'StatusSendingValidatedShort' ), '2' => $langs -> trans ( 'StatusSendingProcessedShort' )), $viewstatut , 1 );
print '</td>' ;
2016-04-08 01:00:02 +02:00
}
2017-08-02 17:15:51 +02:00
// Status billed
if ( ! empty ( $arrayfields [ 'e.billed' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre maxwidthonsmartphone" align="center">' ;
print $form -> selectyesno ( 'search_billed' , $search_billed , 1 , 0 , 1 );
print '</td>' ;
2017-08-02 17:15:51 +02:00
}
2016-04-08 01:00:02 +02:00
// Action column
2016-04-08 02:39:57 +02:00
print '<td class="liste_titre" align="middle">' ;
2017-05-14 21:06:33 +02:00
$searchpicto = $form -> showFilterAndCheckAddButtons ( 0 );
print $searchpicto ;
2017-10-13 13:28:26 +02:00
print '</td>' ;
2010-04-21 10:53:55 +02:00
print " </tr> \n " ;
2014-10-04 17:20:17 +02:00
2017-03-30 15:39:50 +02:00
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'e.ref' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.ref " , " " , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'e.ref_customer' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.ref_customer' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.ref_customer " , " " , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 's.nom' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " s.nom " , " " , $param , 'align="left"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 's.town' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 's.town' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 's.town' , '' , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 's.zip' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 's.zip' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 's.zip' , '' , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'state.nom' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'state.nom' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " state.nom " , " " , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'country.code_iso' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'country.code_iso' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " country.code_iso " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'typent.code' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'typent.code' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " typent.code " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'e.date_delivery' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.date_delivery' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.date_delivery " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'l.ref' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'l.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " l.ref " , " " , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'l.date_delivery' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'l.date_delivery' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " l.date_delivery " , " " , $param , 'align="center"' , $sortfield , $sortorder );
// 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 )
{
if ( ! empty ( $arrayfields [ " ef. " . $key ][ 'checked' ]))
{
$align = $extrafields -> getAlignFlag ( $key );
$sortonfield = " ef. " . $key ;
if ( ! empty ( $extrafields -> attribute_computed [ $key ])) $sortonfield = '' ;
print_liste_field_titre ( $extralabels [ $key ], $_SERVER [ " PHP_SELF " ], $sortonfield , " " , $param ,( $align ? 'align="' . $align . '"' : '' ), $sortfield , $sortorder );
}
}
2017-03-30 15:39:50 +02:00
}
// Hook fields
2018-04-20 10:38:16 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
2017-03-30 15:39:50 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 'e.datec' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.date_creation " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'e.tms' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.tms " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'e.fk_statut' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.fk_statut' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.fk_statut " , " " , $param , 'align="right"' , $sortfield , $sortorder );
2017-08-02 17:51:19 +02:00
if ( ! empty ( $arrayfields [ 'e.billed' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.billed' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.billed " , " " , $param , 'align="center"' , $sortfield , $sortorder );
2017-04-07 14:18:04 +02:00
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' );
2017-03-30 15:39:50 +02:00
print " </tr> \n " ;
2017-06-19 14:31:08 +02:00
2016-04-08 02:39:57 +02:00
$i = 0 ;
$totalarray = array ();
2010-04-21 10:53:55 +02:00
while ( $i < min ( $num , $limit ))
{
2016-04-08 02:39:57 +02:00
$obj = $db -> fetch_object ( $resql );
2010-04-21 10:53:55 +02:00
2017-10-13 13:28:26 +02:00
$shipment -> id = $obj -> rowid ;
$shipment -> ref = $obj -> ref ;
2017-06-19 14:31:08 +02:00
2017-10-13 13:28:26 +02:00
$companystatic -> id = $obj -> socid ;
$companystatic -> ref = $obj -> name ;
$companystatic -> name = $obj -> name ;
2017-06-19 14:31:08 +02:00
2017-10-13 13:28:26 +02:00
print '<tr class="oddeven">' ;
2017-06-19 14:31:08 +02:00
2015-06-30 01:34:17 +02:00
// Ref
2016-04-08 02:39:57 +02:00
if ( ! empty ( $arrayfields [ 'e.ref' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print " <td> " ;
print $shipment -> getNomUrl ( 1 );
print " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-04-08 02:39:57 +02:00
}
2017-06-19 14:31:08 +02:00
2016-10-29 14:45:54 +02:00
// Ref customer
if ( ! empty ( $arrayfields [ 'e.ref_customer' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print " <td> " ;
print $obj -> ref_customer ;
print " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-06-19 14:31:08 +02:00
}
2010-04-21 10:53:55 +02:00
// Third party
2016-04-08 02:39:57 +02:00
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td>' ;
print $companystatic -> getNomUrl ( 1 );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-04-08 02:39:57 +02:00
}
// Town
if ( ! empty ( $arrayfields [ 's.town' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="nocellnopadd">' ;
print $obj -> town ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-04-08 02:39:57 +02:00
}
// Zip
if ( ! empty ( $arrayfields [ 's.zip' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="nocellnopadd">' ;
print $obj -> zip ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-04-08 02:39:57 +02:00
}
// State
if ( ! empty ( $arrayfields [ 'state.nom' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print " <td> " . $obj -> state_name . " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-04-08 02:39:57 +02:00
}
// Country
if ( ! empty ( $arrayfields [ 'country.code_iso' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td align="center">' ;
$tmparray = getCountry ( $obj -> fk_pays , 'all' );
print $tmparray [ 'label' ];
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-04-08 02:39:57 +02:00
}
// Type ent
if ( ! empty ( $arrayfields [ 'typent.code' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td align="center">' ;
if ( count ( $typenArray ) == 0 ) $typenArray = $formcompany -> typent_array ( 1 );
print $typenArray [ $obj -> typent_code ];
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-04-08 02:39:57 +02:00
}
2017-06-19 14:31:08 +02:00
2014-11-20 06:55:38 +01:00
// Date delivery planed
2016-04-08 02:39:57 +02:00
if ( ! empty ( $arrayfields [ 'e.date_delivery' ][ 'checked' ]))
2010-04-21 10:53:55 +02:00
{
2017-10-13 13:28:26 +02:00
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_livraison ), " day " );
/* $now = time ();
2016-04-08 02:39:57 +02:00
if ( ( $now - $db -> jdate ( $obj -> date_expedition )) > $conf -> warnings -> lim && $obj -> statutid == 1 )
{
} */
2017-10-13 13:28:26 +02:00
print " </td> \n " ;
2016-04-08 02:39:57 +02:00
}
2017-06-19 14:31:08 +02:00
2016-04-08 02:39:57 +02:00
if ( ! empty ( $arrayfields [ 'l.ref' ][ 'checked' ]) || ! empty ( $arrayfields [ 'l.date_delivery' ][ 'checked' ]))
2017-10-13 13:28:26 +02:00
{
$shipment -> fetchObjectLinked ( $shipment -> id , $shipment -> element );
$receiving = '' ;
2018-04-02 09:44:45 +02:00
if ( is_array ( $shipment -> linkedObjects [ 'delivery' ]) && count ( $shipment -> linkedObjects [ 'delivery' ]) > 0 ) $receiving = reset ( $shipment -> linkedObjects [ 'delivery' ]);
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'l.ref' ][ 'checked' ]))
{
// Ref
print '<td>' ;
print ! empty ( $receiving ) ? $receiving -> getNomUrl ( $db ) : '' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'l.date_delivery' ][ 'checked' ]))
{
// Date received
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_reception ), " day " );
print '</td>' . " \n " ;
}
2014-07-25 16:31:41 +02:00
}
2010-04-21 10:53:55 +02:00
2016-04-08 02:39:57 +02:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
2016-04-08 02:39:57 +02: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 [ 'e.datec' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td align="center" class="nowrap">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-04-08 02:39:57 +02:00
}
// Date modification
if ( ! empty ( $arrayfields [ 'e.tms' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td align="center" class="nowrap">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-04-08 02:39:57 +02:00
}
// Status
if ( ! empty ( $arrayfields [ 'e.fk_statut' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td align="right" class="nowrap">' . $shipment -> LibStatut ( $obj -> fk_statut , 5 ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-04-08 02:39:57 +02:00
}
2017-08-02 17:15:51 +02:00
// Billed
if ( ! empty ( $arrayfields [ 'e.billed' ][ 'checked' ]))
{
print '<td align="center">' . yn ( $obj -> billed ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2016-04-08 02:39:57 +02:00
// Action column
2015-06-30 01:34:17 +02:00
print '<td></td>' ;
2016-04-08 02:39:57 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-06-19 14:31:08 +02:00
2010-04-21 10:53:55 +02:00
print " </tr> \n " ;
$i ++ ;
}
print " </table> " ;
2016-11-27 11:41:10 +01:00
print " </div> " ;
print '</form>' ;
2010-04-21 10:53:55 +02:00
$db -> free ( $resql );
2003-11-26 17:04:22 +01:00
}
else
{
2010-04-21 10:53:55 +02:00
dol_print_error ( $db );
2003-11-26 17:04:22 +01:00
}
2003-11-13 18:36:45 +01:00
2011-08-27 16:24:16 +02:00
llxFooter ();
2015-12-11 19:37:12 +01:00
$db -> close ();