2004-10-19 22:19:58 +02:00
< ? php
2004-02-07 20:20:06 +01:00
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2011-05-13 22:00:43 +02:00
* Copyright ( C ) 2004 - 2011 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2011-06-12 23:25:59 +02:00
* Copyright ( C ) 2011 Philippe Grand < philippe . grand @ atoo - net . com >
2013-04-05 13:01:15 +02:00
* Copyright ( C ) 2013 Florian Henry < florian . henry @ open - concept . pro >
2013-09-10 16:43:06 +02:00
* Copyright ( C ) 2013 Cédric Salvador < csalvador @ gpcsolutions . fr >
2004-02-07 20:20:06 +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
2004-02-07 20:20:06 +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-03 02:45:22 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2004-02-07 20:20:06 +01:00
*/
2004-10-30 14:14:18 +02:00
2005-01-01 19:51:06 +01:00
/**
2011-08-21 15:12:47 +02:00
* \file htdocs / comm / prospect / list . php
2008-11-16 01:06:26 +01:00
* \ingroup prospect
2010-03-16 20:50:07 +01:00
* \brief Page to list prospects
2008-09-11 00:22:48 +02:00
*/
2004-10-30 14:14:18 +02: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 . '/comm/prospect/class/prospect.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2004-02-07 20:20:06 +01:00
2004-11-07 15:08:42 +01:00
$langs -> load ( " propal " );
2008-10-28 01:19:36 +01:00
$langs -> load ( " companies " );
2004-11-07 15:08:42 +01:00
2008-02-25 17:30:43 +01:00
// Security check
2010-11-20 14:08:44 +01:00
$socid = GETPOST ( " socid " , '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 , 'societe' , $socid , '' );
2004-02-07 20:20:06 +01:00
2012-07-28 12:35:11 +02:00
$action = GETPOST ( 'action' , 'alpha' );
2011-06-12 23:25:59 +02:00
$socname = GETPOST ( " socname " , 'alpha' );
$stcomm = GETPOST ( " stcomm " , 'int' );
$search_nom = GETPOST ( " search_nom " );
2012-10-22 11:05:55 +02:00
$search_zipcode = GETPOST ( " search_zipcode " );
2013-02-27 11:58:50 +01:00
$search_town = GETPOST ( " search_town " );
$search_state = GETPOST ( " search_state " );
2011-06-12 23:25:59 +02:00
$search_datec = GETPOST ( " search_datec " );
2012-07-28 22:07:27 +02:00
$search_categ = GETPOST ( " search_categ " , 'int' );
2013-11-12 15:22:11 +01:00
$search_status = GETPOST ( " search_status " , 'int' );
if ( $search_status == '' ) $search_status = 1 ; // always display activ customer first
2012-07-28 22:07:27 +02:00
$catid = GETPOST ( " catid " , 'int' );
2008-03-31 05:57:05 +02:00
2010-11-20 14:08:44 +01:00
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
2011-06-12 23:25:59 +02:00
$page = GETPOST ( " page " , 'int' );
2006-08-13 02:34:16 +02:00
if ( $page == - 1 ) { $page = 0 ; }
$offset = $conf -> liste_limit * $page ;
2004-02-07 20:20:06 +01:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2008-03-31 05:57:05 +02:00
if ( ! $sortorder ) $sortorder = " ASC " ;
if ( ! $sortfield ) $sortfield = " s.nom " ;
2004-02-07 20:20:06 +01:00
2010-11-20 14:08:44 +01:00
$search_level_from = GETPOST ( " search_level_from " , " alpha " );
2011-06-12 23:25:59 +02:00
$search_level_to = GETPOST ( " search_level_to " , " alpha " );
2008-10-28 01:19:36 +01:00
// If both parameters are set, search for everything BETWEEN them
if ( $search_level_from != '' && $search_level_to != '' )
2009-07-07 18:28:10 +02:00
{
2008-10-28 01:19:36 +01:00
// Ensure that these parameters are numbers
$search_level_from = ( int ) $search_level_from ;
$search_level_to = ( int ) $search_level_to ;
2009-07-07 18:28:10 +02:00
2008-10-28 01:19:36 +01:00
// If from is greater than to, reverse orders
if ( $search_level_from > $search_level_to )
{
$tmp = $search_level_to ;
$search_level_to = $search_level_from ;
$search_level_from = $tmp ;
}
2005-10-31 19:26:37 +01:00
2008-10-28 01:19:36 +01:00
// Generate the SQL request
$sortwhere = '(sortorder BETWEEN ' . $search_level_from . ' AND ' . $search_level_to . ') AS is_in_range' ;
}
// If only "from" parameter is set, search for everything GREATER THAN it
else if ( $search_level_from != '' )
{
// Ensure that this parameter is a number
$search_level_from = ( int ) $search_level_from ;
2009-07-07 18:28:10 +02:00
2008-10-28 01:19:36 +01:00
// Generate the SQL request
$sortwhere = '(sortorder >= ' . $search_level_from . ') AS is_in_range' ;
}
// If only "to" parameter is set, search for everything LOWER THAN it
else if ( $search_level_to != '' )
{
// Ensure that this parameter is a number
$search_level_to = ( int ) $search_level_to ;
2009-07-07 18:28:10 +02:00
2008-10-28 01:19:36 +01:00
// Generate the SQL request
$sortwhere = '(sortorder <= ' . $search_level_to . ') AS is_in_range' ;
}
// If no parameters are set, dont search for anything
else
{
$sortwhere = '0 as is_in_range' ;
}
// Select every potentiels, and note each potentiels which fit in search parameters
2009-02-20 23:53:15 +01:00
dol_syslog ( 'prospects::prospects_prospect_level' , LOG_DEBUG );
2008-10-28 01:19:36 +01:00
$sql = " SELECT code, label, sortorder, " . $sortwhere ;
$sql .= " FROM " . MAIN_DB_PREFIX . " c_prospectlevel " ;
$sql .= " WHERE active > 0 " ;
$sql .= " ORDER BY sortorder " ;
2010-03-16 20:50:07 +01:00
2008-10-28 01:19:36 +01:00
$resql = $db -> query ( $sql );
if ( $resql )
{
$tab_level = array ();
$search_levels = array ();
2009-07-07 18:28:10 +02:00
2008-10-28 01:19:36 +01:00
while ( $obj = $db -> fetch_object ( $resql ))
{
// Compute level text
$level = $langs -> trans ( $obj -> code );
if ( $level == $obj -> code ) $level = $langs -> trans ( $obj -> label );
2009-07-07 18:28:10 +02:00
2008-10-28 01:19:36 +01:00
// Put it in the array sorted by sortorder
$tab_level [ $obj -> sortorder ] = $level ;
2009-07-07 18:28:10 +02:00
2008-10-28 01:19:36 +01:00
// If this potentiel fit in parameters, add its code to the $search_levels array
if ( $obj -> is_in_range == 1 )
{
$search_levels [] = '"' . preg_replace ( '[^A-Za-z0-9_-]' , '' , $obj -> code ) . '"' ;
}
}
2009-07-07 18:28:10 +02:00
2008-10-28 01:19:36 +01:00
// Implode the $search_levels array so that it can be use in a "IN (...)" where clause.
// If no paramters was set, $search_levels will be empty
$search_levels = implode ( ',' , $search_levels );
}
2009-02-20 23:53:15 +01:00
else dol_print_error ( $db );
2008-10-28 01:19:36 +01:00
// Load sale and categ filters
2012-07-28 12:35:11 +02:00
$search_sale = GETPOST ( 'search_sale' );
$search_categ = GETPOST ( 'search_categ' );
2013-12-14 15:21:15 +01:00
// If the internal user must only see his prospect, force searching by him
2008-10-28 01:19:36 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $search_sale = $user -> id ;
// List of avaible states; we'll need that for each lines (quick changing prospect states) and for search bar (filter by prospect state)
$sts = array ( - 1 , 0 , 1 , 2 , 3 );
2005-10-31 19:26:37 +01:00
2012-10-20 10:53:44 +02:00
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager -> initHooks ( array ( 'prospectlist' ));
2008-09-11 00:22:48 +02:00
/*
2005-10-31 19:26:37 +01:00
* Actions
*/
2012-10-20 10:53:44 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters ); // Note that $action and $object may have been modified by some hooks
2012-07-28 12:35:11 +02:00
if ( $action == 'cstc' )
2005-10-31 19:26:37 +01:00
{
2008-09-11 00:22:48 +02:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " societe SET fk_stcomm = " . $_GET [ " pstcomm " ];
$sql .= " WHERE rowid = " . $_GET [ " socid " ];
$result = $db -> query ( $sql );
2005-10-31 19:26:37 +01:00
}
/*
2010-01-05 21:03:37 +01:00
* View
2005-10-31 19:26:37 +01:00
*/
2012-06-23 20:39:20 +02:00
$formother = new FormOther ( $db );
2013-11-12 15:22:11 +01:00
$form = new Form ( $db );
2010-03-16 20:50:07 +01:00
2013-11-13 13:17:32 +01:00
$sql = " SELECT s.rowid, s.nom, s.zip, s.town, s.datec, s.datea, s.status as status, s.code_client, s.client, " ;
2008-03-01 02:12:55 +01:00
$sql .= " st.libelle as stcomm, s.prefix_comm, s.fk_stcomm, s.fk_prospectlevel, " ;
$sql .= " d.nom as departement " ;
2013-12-14 15:21:15 +01:00
if (( ! $user -> rights -> societe -> client -> voir && ! $socid ) || $search_sale ) $sql .= " , sc.fk_soc, sc.fk_user " ; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
2007-09-20 21:08:23 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " c_stcomm as st " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
2008-03-01 02:12:55 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_departements as d on (d.rowid = s.fk_departement) " ;
2012-07-28 00:53:51 +02:00
if ( ! empty ( $search_categ ) || ! empty ( $catid )) $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . " categorie_societe as cs ON s.rowid = cs.fk_societe " ; // We need this table joined to the select in order to filter by categ
2013-12-14 15:21:15 +01:00
if (( ! $user -> rights -> societe -> client -> voir && ! $socid ) || $search_sale ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ; // We need this table joined to the select in order to filter by sale
2009-04-27 22:37:50 +02:00
$sql .= " WHERE s.fk_stcomm = st.id " ;
2011-09-30 13:49:40 +02:00
$sql .= " AND s.client IN (2, 3) " ;
2012-01-11 14:14:14 +01:00
$sql .= ' AND s.entity IN (' . getEntity ( 'societe' , 1 ) . ')' ;
2013-12-14 15:21:15 +01:00
if (( ! $user -> rights -> societe -> client -> voir && ! $socid ) || $search_sale ) $sql .= " AND s.rowid = sc.fk_soc " ;
if ( $socid ) $sql .= " AND s.rowid = " . $socid ;
2009-04-27 22:37:50 +02:00
if ( isset ( $stcomm ) && $stcomm != '' ) $sql .= " AND s.fk_stcomm= " . $stcomm ;
2012-07-28 22:07:27 +02:00
if ( $catid > 0 ) $sql .= " AND cs.fk_categorie = " . $catid ;
if ( $catid == - 2 ) $sql .= " AND cs.fk_categorie IS NULL " ;
if ( $search_categ > 0 ) $sql .= " AND cs.fk_categorie = " . $search_categ ;
if ( $search_categ == - 2 ) $sql .= " AND cs.fk_categorie IS NULL " ;
2013-09-10 16:43:06 +02:00
if ( $search_nom ) {
2013-09-13 10:52:04 +02:00
$sql .= natural_search ( 's.nom' , $search_nom );
2013-09-10 16:43:06 +02:00
}
2013-02-24 17:08:52 +01:00
if ( $search_zipcode ) $sql .= " AND s.zip LIKE ' " . $db -> escape ( strtolower ( $search_zipcode )) . " %' " ;
2013-09-10 16:43:06 +02:00
if ( $search_town ) {
2013-09-13 10:52:04 +02:00
$sql .= natural_search ( 's.town' , $search_town );
2013-09-10 16:43:06 +02:00
}
if ( $search_state ) {
2013-09-13 10:52:04 +02:00
$sql .= natural_search ( 'd.nom' , $search_state );
2013-09-10 16:43:06 +02:00
}
2011-06-12 23:25:59 +02:00
if ( $search_datec ) $sql .= " AND s.datec LIKE '% " . $db -> escape ( $search_datec ) . " %' " ;
2013-11-12 15:22:11 +01:00
if ( $search_status != '' ) $sql .= " AND s.status = " . $db -> escape ( $search_status );
2008-10-28 01:19:36 +01:00
// Insert levels filters
if ( $search_levels )
{
$sql .= " AND s.fk_prospectlevel IN ( " . $search_levels . ')' ;
}
2010-03-16 20:50:07 +01:00
// Insert sale filter
2008-10-28 01:19:36 +01:00
if ( $search_sale )
{
2011-02-24 19:22:24 +01:00
$sql .= " AND sc.fk_user = " . $db -> escape ( $search_sale );
2008-10-28 01:19:36 +01:00
}
2013-09-10 16:43:06 +02:00
if ( $socname ) {
2013-09-13 10:52:04 +02:00
$sql .= natural_search ( 's.nom' , $search_nom );
2008-09-11 00:22:48 +02:00
$sortfield = " s.nom " ;
$sortorder = " ASC " ;
2004-02-07 20:20:06 +01:00
}
2008-03-06 18:56:12 +01:00
// Count total nb of records
$nbtotalofrecords = 0 ;
2008-03-06 19:12:07 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
2008-03-06 18:56:12 +01:00
{
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
}
2010-03-16 20:50:07 +01:00
$sql .= " ORDER BY $sortfield $sortorder , s.nom ASC " ;
$sql .= $db -> plimit ( $conf -> liste_limit + 1 , $offset );
2004-10-30 14:14:18 +02:00
2013-11-12 15:22:11 +01:00
dol_syslog ( 'comm/prospect/list.php sql=' . $sql , LOG_DEBUG );
2005-09-14 16:44:00 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
2004-02-07 20:20:06 +01:00
{
2008-09-11 00:22:48 +02:00
$num = $db -> num_rows ( $resql );
if ( $num == 1 && $socname )
{
$obj = $db -> fetch_object ( $resql );
2012-08-31 05:58:38 +02:00
header ( " Location: fiche.php?socid= " . $obj -> rowid );
2008-09-11 00:22:48 +02:00
exit ;
}
else
{
2011-05-13 20:45:18 +02:00
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas' ;
llxHeader ( '' , $langs -> trans ( " ThirdParty " ), $help_url );
2008-09-11 00:22:48 +02:00
}
2004-02-07 20:20:06 +01:00
2013-07-19 14:00:08 +02:00
$param = '&stcomm=' . $stcomm . '&search_nom=' . urlencode ( $search_nom ) . '&search_zipcode=' . urlencode ( $search_zipcode ) . '&search_town=' . urlencode ( $search_town );
2008-10-28 01:19:36 +01:00
// Store the status filter in the URL
if ( isSet ( $search_cstc ))
{
foreach ( $search_cstc as $key => $value )
{
if ( $value == 'true' )
$param .= '&search_cstc[' . (( int ) $key ) . ']=true' ;
else
$param .= '&search_cstc[' . (( int ) $key ) . ']=false' ;
}
}
2010-03-16 20:50:07 +01:00
if ( $search_level_from != '' ) $param .= '&search_level_from=' . $search_level_from ;
if ( $search_level_to != '' ) $param .= '&search_level_to=' . $search_level_to ;
if ( $search_categ != '' ) $param .= '&search_categ=' . $search_categ ;
if ( $search_sale != '' ) $param .= '&search_sale=' . $search_sale ;
2013-11-12 15:22:11 +01:00
if ( $search_status != '' ) $param .= '&search_status=' . $search_status ;
2008-10-28 01:19:36 +01:00
// $param and $urladd should have the same value
$urladd = $param ;
2009-07-07 18:28:10 +02:00
2008-09-11 00:22:48 +02:00
print_barre_liste ( $langs -> trans ( " ListOfProspects " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , '' , $num , $nbtotalofrecords );
2009-07-07 18:28:10 +02:00
2008-10-28 01:19:36 +01:00
// Print the search-by-sale and search-by-categ filters
2012-10-20 10:53:44 +02:00
print '<form method="GET" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2009-07-07 18:28:10 +02:00
2010-03-16 20:50:07 +01:00
// Filter on categories
$moreforfilter = '' ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> categorie -> enabled ))
2010-03-16 20:50:07 +01:00
{
$moreforfilter .= $langs -> trans ( 'Categories' ) . ': ' ;
2012-07-28 00:53:51 +02:00
$moreforfilter .= $formother -> select_categories ( 2 , $search_categ , 'search_categ' , 1 );
2010-03-16 20:50:07 +01:00
$moreforfilter .= ' ' ;
}
2008-10-28 01:19:36 +01:00
// If the user can view prospects other than his'
if ( $user -> rights -> societe -> client -> voir || $socid )
{
2010-03-16 20:50:07 +01:00
$moreforfilter .= $langs -> trans ( 'SalesRepresentatives' ) . ': ' ;
2012-06-23 20:39:20 +02:00
$moreforfilter .= $formother -> select_salesrepresentatives ( $search_sale , 'search_sale' , $user );
2008-10-28 01:19:36 +01:00
}
2010-03-16 20:50:07 +01:00
if ( $moreforfilter )
2008-10-28 01:19:36 +01:00
{
2012-10-20 10:53:44 +02:00
print '<div class="liste_titre">' ;
2010-03-16 20:50:07 +01:00
print $moreforfilter ;
2012-10-20 10:53:44 +02:00
print '</div>' ;
2008-10-28 01:19:36 +01:00
}
2009-07-07 18:28:10 +02:00
2012-10-20 10:53:44 +02:00
print '<table class="liste" width="100%">' ;
2008-09-11 00:22:48 +02:00
print '<tr class="liste_titre">' ;
2011-09-30 13:49:40 +02:00
print_liste_field_titre ( $langs -> trans ( " Company " ), $_SERVER [ " PHP_SELF " ], " s.nom " , " " , $param , '' , $sortfield , $sortorder );
2013-02-24 17:08:52 +01:00
print_liste_field_titre ( $langs -> trans ( " Zip " ), $_SERVER [ " PHP_SELF " ], " s.zip " , " " , $param , " " , $sortfield , $sortorder );
2013-02-22 16:14:52 +01:00
print_liste_field_titre ( $langs -> trans ( " Town " ), $_SERVER [ " PHP_SELF " ], " s.town " , " " , $param , " " , $sortfield , $sortorder );
2011-09-30 13:49:40 +02:00
print_liste_field_titre ( $langs -> trans ( " State " ), $_SERVER [ " PHP_SELF " ], " s.fk_departement " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " DateCreation " ), $_SERVER [ " PHP_SELF " ], " s.datec " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " ProspectLevelShort " ), $_SERVER [ " PHP_SELF " ], " s.fk_prospectlevel " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " StatusProsp " ), $_SERVER [ " PHP_SELF " ], " s.fk_stcomm " , " " , $param , 'align="center"' , $sortfield , $sortorder );
2011-05-13 22:00:43 +02:00
print '<td class="liste_titre"> </td>' ;
2013-11-12 15:22:11 +01:00
print_liste_field_titre ( $langs -> trans ( " Status " ), $_SERVER [ " PHP_SELF " ], " s.status " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print '<td class="liste_titre"> </td>' ;
2012-10-20 10:53:44 +02:00
$parameters = array ();
$formconfirm = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
2008-09-11 00:22:48 +02:00
print " </tr> \n " ;
print '<tr class="liste_titre">' ;
print '<td class="liste_titre">' ;
2011-06-12 23:25:59 +02:00
print '<input type="text" class="flat" name="search_nom" size="10" value="' . $search_nom . '">' ;
2012-10-22 11:05:55 +02:00
print '</td>' ;
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_zipcode" size="10" value="' . $search_zipcode . '">' ;
print '</td>' ;
print '<td class="liste_titre">' ;
2013-02-22 16:14:52 +01:00
print '<input type="text" class="flat" name="search_town" size="10" value="' . $search_town . '">' ;
2008-09-11 00:22:48 +02:00
print '</td>' ;
2011-06-12 23:25:59 +02:00
print '<td class="liste_titre" align="center">' ;
2013-02-27 11:58:50 +01:00
print '<input type="text" class="flat" name="search_state" size="10" value="' . $search_state . '">' ;
2008-10-28 01:19:36 +01:00
print '</td>' ;
2011-06-12 23:25:59 +02:00
print '<td align="center" class="liste_titre">' ;
print '<input class="flat" type="text" size="10" name="search_datec" value="' . $search_datec . '">' ;
2008-10-28 01:19:36 +01:00
print '</td>' ;
2009-07-07 18:28:10 +02:00
2011-08-21 15:12:47 +02:00
// Added by Matelli
2009-07-07 18:28:10 +02:00
print '<td class="liste_titre" align="center">' ;
2008-10-28 01:19:36 +01:00
// Generate in $options_from the list of each option sorted
$options_from = '<option value=""> </option>' ;
foreach ( $tab_level as $tab_level_sortorder => $tab_level_label )
{
2010-11-01 17:00:38 +01:00
$options_from .= '<option value="' . $tab_level_sortorder . '"' . ( $search_level_from == $tab_level_sortorder ? ' selected="selected"' : '' ) . '>' ;
2008-10-28 01:19:36 +01:00
$options_from .= $langs -> trans ( $tab_level_label );
2009-07-07 18:28:10 +02:00
$options_from .= '</option>' ;
2008-10-28 01:19:36 +01:00
}
2009-07-07 18:28:10 +02:00
2008-10-28 01:19:36 +01:00
// Reverse the list
array_reverse ( $tab_level , true );
2009-07-07 18:28:10 +02:00
2008-10-28 01:19:36 +01:00
// Generate in $options_to the list of each option sorted in the reversed order
$options_to = '<option value=""> </option>' ;
foreach ( $tab_level as $tab_level_sortorder => $tab_level_label )
{
2010-11-01 17:00:38 +01:00
$options_to .= '<option value="' . $tab_level_sortorder . '"' . ( $search_level_to == $tab_level_sortorder ? ' selected="selected"' : '' ) . '>' ;
2008-10-28 01:19:36 +01:00
$options_to .= $langs -> trans ( $tab_level_label );
2009-07-07 18:28:10 +02:00
$options_to .= '</option>' ;
2008-10-28 01:19:36 +01:00
}
2009-07-07 18:28:10 +02:00
2008-10-28 01:19:36 +01:00
// Print these two select
print $langs -> trans ( " From " ) . ' <select class="flat" name="search_level_from">' . $options_from . '</select>' ;
2009-07-07 18:28:10 +02:00
print ' ' ;
2008-10-28 01:19:36 +01:00
print $langs -> trans ( " To " ) . ' <select class="flat" name="search_level_to">' . $options_to . '</select>' ;
print '</td>' ;
2011-05-13 22:00:43 +02:00
2008-10-28 01:19:36 +01:00
print '<td class="liste_titre" align="center">' ;
print ' ' ;
print '</td>' ;
2009-07-07 18:28:10 +02:00
2011-05-13 22:00:43 +02:00
print '<td class="liste_titre" align="center">' ;
print ' ' ;
print '</td>' ;
2013-11-12 15:22:11 +01:00
print '<td class="liste_titre" align="center">' ;
print $form -> selectarray ( 'search_status' , array ( '0' => $langs -> trans ( 'ActivityCeased' ), '1' => $langs -> trans ( 'InActivity' )), $search_status );
print '</td>' ;
2011-05-13 22:00:43 +02:00
// Print the search button
print '<td class="liste_titre" align="right">' ;
2014-01-13 09:43:21 +01:00
print '<input class="liste_titre" name="button_search" type="image" src="' . img_picto ( $langs -> trans ( " Search " ), 'search.png' , '' , '' , 1 ) . '" value="' . dol_escape_htmltag ( $langs -> trans ( " Search " )) . '" title="' . dol_escape_htmltag ( $langs -> trans ( " Search " )) . '">' ;
2008-09-11 00:22:48 +02:00
print '</td>' ;
2012-10-20 10:53:44 +02:00
$parameters = array ();
$formconfirm = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
2008-09-11 00:22:48 +02:00
print " </tr> \n " ;
$i = 0 ;
$var = true ;
$prospectstatic = new Prospect ( $db );
$prospectstatic -> client = 2 ;
while ( $i < min ( $num , $conf -> liste_limit ))
{
$obj = $db -> fetch_object ( $resql );
$var =! $var ;
2011-06-12 23:25:59 +02:00
print '<tr ' . $bc [ $var ] . '>' ;
2008-09-11 00:22:48 +02:00
print '<td>' ;
$prospectstatic -> id = $obj -> rowid ;
$prospectstatic -> nom = $obj -> nom ;
2011-05-13 22:00:43 +02:00
$prospectstatic -> status = $obj -> status ;
2013-11-13 13:17:32 +01:00
$prospectstatic -> code_client = $obj -> code_client ;
$prospectstatic -> client = $obj -> client ;
2013-02-14 15:08:22 +01:00
$prospectstatic -> fk_prospectlevel = $obj -> fk_prospectlevel ;
2011-05-13 22:00:43 +02:00
print $prospectstatic -> getNomUrl ( 1 , 'prospect' );
print '</td>' ;
2012-10-22 11:05:55 +02:00
print " <td> " . $obj -> zip . " </td> " ;
2013-02-22 16:14:52 +01:00
print " <td> " . $obj -> town . " </td> " ;
2011-09-30 13:49:40 +02:00
print '<td align="center">' . $obj -> departement . '</td>' ;
2008-09-11 00:22:48 +02:00
// Creation date
2011-09-30 13:49:40 +02:00
print '<td align="center">' . dol_print_date ( $db -> jdate ( $obj -> datec )) . '</td>' ;
2008-09-11 00:22:48 +02:00
// Level
2011-09-30 13:49:40 +02:00
print '<td align="center">' ;
2013-02-14 15:08:22 +01:00
print $prospectstatic -> getLibProspLevel ();
2008-09-11 00:22:48 +02:00
print " </td> " ;
// Statut
2013-04-25 01:13:13 +02:00
print '<td align="center" class="nowrap">' ;
2011-05-13 22:00:43 +02:00
print $prospectstatic -> LibProspStatut ( $obj -> fk_stcomm , 2 );
2008-09-11 00:22:48 +02:00
print " </td> " ;
2008-10-28 01:19:36 +01:00
//$sts = array(-1,0,1,2,3);
2013-04-25 01:13:13 +02:00
print '<td align="right" class="nowrap">' ;
2008-09-11 00:22:48 +02:00
foreach ( $sts as $key => $value )
{
if ( $value <> $obj -> fk_stcomm )
{
2011-09-30 13:49:40 +02:00
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?socid=' . $obj -> rowid . '&pstcomm=' . $value . '&action=cstc&' . $param . ( $page ? '&page=' . $page : '' ) . '">' ;
2008-09-11 00:22:48 +02:00
print img_action ( 0 , $value );
print '</a> ' ;
}
}
print '</td>' ;
2013-11-12 15:22:11 +01:00
print '<td align="center">' ;
2013-02-14 15:08:22 +01:00
print $prospectstatic -> LibStatut ( $prospectstatic -> status , 3 );
2011-05-13 22:00:43 +02:00
print '</td>' ;
2013-11-12 15:22:11 +01:00
print '<td></td>' ;
2011-05-13 22:00:43 +02:00
2012-10-20 10:53:44 +02:00
$parameters = array ( 'obj' => $obj );
$formconfirm = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
2011-05-13 22:00:43 +02:00
print " </tr> \n " ;
2008-09-11 00:22:48 +02:00
$i ++ ;
}
if ( $num > $conf -> liste_limit || $page > 0 ) print_barre_liste ( '' , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , '' , $num , $nbtotalofrecords );
print " </table> " ;
2009-07-07 18:28:10 +02:00
2008-10-01 21:26:01 +02:00
print " </form> " ;
2009-07-07 18:28:10 +02:00
2008-09-11 00:22:48 +02:00
$db -> free ( $resql );
2012-10-20 10:53:44 +02:00
$parameters = array ( 'sql' => $sql );
$formconfirm = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters ); // Note that $action and $object may have been modified by hook
2004-02-07 20:20:06 +01:00
}
else
{
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2004-02-07 20:20:06 +01:00
}
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-07-28 12:35:11 +02:00
$db -> close ();
2013-04-05 22:59:06 +02:00
?>