Qual: clean code

This commit is contained in:
Laurent Destailleur 2014-03-26 20:46:17 +01:00
parent 62a990d6cc
commit 9e771269c4
2 changed files with 10 additions and 11 deletions

View File

@ -20,7 +20,7 @@
/** /**
* \file htdocs/compta/deplacement/stats/index.php * \file htdocs/compta/deplacement/stats/index.php
* \ingroup deplacement * \ingroup deplacement
* \brief Page des stats deplacement et notes de frais * \brief Page for statistics of module trips and expenses
*/ */
require '../../../main.inc.php'; require '../../../main.inc.php';

View File

@ -732,9 +732,9 @@ class Form
* @return string HTML string with * @return string HTML string with
* @deprecated Use select_thirdparty instead * @deprecated Use select_thirdparty instead
*/ */
function select_company($selected='', $htmlname='socid', $filter='', $showempty=0, $showtype=0, $forcecombo=0, $events=array()) function select_company($selected='', $htmlname='socid', $filter='', $showempty=0, $showtype=0, $forcecombo=0, $events=array(), $limit=0)
{ {
return $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events); return $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit);
} }
/** /**
@ -752,7 +752,7 @@ class Form
* @param int $limit Limit number of answers * @param int $limit Limit number of answers
* @return string HTML string with * @return string HTML string with
*/ */
function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=20) function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=0)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
@ -774,25 +774,24 @@ class Form
$sql.=" AND ("; $sql.=" AND (";
if (! empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) // Can use index if (! empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) // Can use index
{ {
$sql.="(s.name LIKE '".$filterkey."%'"; $sql.="(s.name LIKE '".$this->db->escape($filterkey)."%')";
$sql.=")";
} }
else else
{ {
// For natural search // For natural search
$scrit = explode(' ', $filterkey); $scrit = explode(' ', $filterkey);
foreach ($scrit as $crit) { foreach ($scrit as $crit) {
$sql.=" AND (s.name LIKE '%".$crit."%'"; $sql.=" AND (s.name LIKE '%".$this->db->escape($crit)."%')";
$sql.=")";
} }
} }
if (! empty($conf->barcode->enabled)) if (! empty($conf->barcode->enabled))
{ {
$sql .= " OR s.barcode LIKE '".$filterkey."'"; $sql .= " OR s.barcode LIKE '".$this->db->escape($filterkey)."%'";
} }
$sql.=")"; $sql.=")";
} }
$sql.= " ORDER BY nom ASC"; $sql.=$this->db->order("nom","ASC");
if ($limit > 0) $sql.=$this->db->plimit($limit);
dol_syslog(get_class($this)."::select_thirdparty_list sql=".$sql); dol_syslog(get_class($this)."::select_thirdparty_list sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);