$offset = new NumericSField('offset');
- $sql = 'SELECT SQL_CALC_FOUND_ROWS
- DISTINCT r.matricule,u.matricule_ax,u.user_id,
+ $sql = 'SELECT SQL_CALC_FOUND_ROWS
+ DISTINCT '.$qSearch->get_mark_statement().',r.matricule,u.matricule_ax,u.user_id,
UPPER(IF(u.nom!="",u.nom,u.nom_ini)) AS nom,
IF(u.prenom!="",u.prenom,u.prenom_ini) AS prenom,
u.promo AS promo,
LEFT JOIN watch_nonins AS w ON (w.ni_id=u.user_id AND w.uid='.((array_key_exists('uid',$_SESSION))?$_SESSION['uid']:0).')
'.$globals->search_result_where_statement.'
WHERE '.$fields->get_where_statement().'
+ HAVING mark>0
ORDER BY '.(logged() && !empty($_REQUEST['mod_date_sort']) ? 'date DESC,' :'')
.implode(',',array_filter(array($fields->get_order_statement(),'u.promo DESC,NomSortKey,prenom'))).'
LIMIT '.$offset->value.','.$globals->search_results_per_page;
function get_where_statement() {
$where = Array();
- if(count($this->strings) == 1) {
- $t = '%'.str_replace('*', '%', $this->strings[0]).'%';
- $t = str_replace('%%', '%', $t);
- $where[] = "(r.nom LIKE '$t' OR r.epouse LIKE '$t')";
- } else foreach($this->strings as $s) {
+ foreach($this->strings as $s) {
$t = '%'.str_replace('*', '%', $s).'%';
$t = str_replace('%%', '%', $t);
$where[] = "(r.nom LIKE '$t' OR r.epouse LIKE '$t' OR r.prenom LIKE '$t')";
return join(" AND ", $where);
}
- function get_order_statement() {
- if(empty($this->strings)) return false;
+ function get_mark_statement() {
+ if(empty($this->strings)) return "1 AS mark";
$order = Array();
foreach($this->strings as $s) {
- $order[] = "(r.nom='$s' OR r.prenom='$s' OR r.epouse='$s')*100 + "
- . "(r.nom LIKE '$s%' OR r.prenom LIKE '$s%' OR r.epouse LIKE '$s%')";
+ $order[] = "(r.nom='$s' OR r.epouse='$s')*100 + "
+ . "(r.prenom='$s') * 10 + "
+ . "(r.nom LIKE '$s%' OR r.epouse LIKE '$s%')";
}
$res = join(' + ', $order);
- if($res) return "$res DESC";
+ if($res) return "$res AS mark";
+ }
+ function get_order_statement() {
+ if(empty($this->strings)) return false;
+ return "mark DESC";
}
}
fwrite($fd, $result);
fclose($fd);
- exec($globals->spoolroot."/scripts/xhtml/validate.pl ".$this->cache_dir."valid.html", $val);
+ exec($globals->spoolroot."/bin/xhtml/validate.pl ".$this->cache_dir."valid.html", $val);
foreach ($val as $h) {
if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) {
if ($m[1]) {