From 6d5f2b2f21cd752dfaba306237912f6d16f6b588 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Nov 2017 10:00:46 +0100 Subject: [PATCH] Fix filters on surveys --- htdocs/fourn/card.php | 2 +- htdocs/opensurvey/card.php | 2 +- htdocs/opensurvey/list.php | 42 +++++++++++++++++++++----------------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 08a57fae706..6f473f8deb3 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -132,7 +132,7 @@ if ($object->id > 0) dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), -1, 'company'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 4d71efe6395..2768b32ba3f 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -216,7 +216,7 @@ dol_fiche_head($head,'general',$langs->trans("Survey"), -1, DOL_URL_ROOT.'/opens $morehtmlref = ''; -$linkback = ''.$langs->trans("BackToList").''; +$linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'id_sondage', 'id_sondage', $morehtmlref); diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 0ca1819e7bc..41ae2778080 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2013-2017 Laurent Destailleur * Copyright (C) 2014 Marcos GarcĂ­a * * This program is free software; you can redistribute it and/or modify @@ -34,9 +34,8 @@ $action=GETPOST('action','aZ09'); $id=GETPOST('id','alpha'); $numsondage= $id; $search_ref = GETPOST('search_ref', 'alpha'); -$surveytitle=GETPOST('surveytitle', 'alpha'); -$status=GETPOST('status', 'int'); -//if (! isset($_POST['status']) && ! isset($_GET['status'])) $status='opened'; // If filter unknown, we choose 'opened' +$search_title = GETPOST('search_title', 'alpha'); +$search_status = GETPOST('search_status', 'alpha'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -58,10 +57,10 @@ $langs->load("opensurvey"); * Actions */ -if (GETPOST('button_removefilter')) +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 { - $status=''; - $surveytitle=''; + $search_status=''; + $search_title=''; $search_ref=''; } @@ -75,7 +74,7 @@ $opensurvey_static = new Opensurveysondage($db); $now = dol_now(); -llxHeader(); +llxHeader('', $langs->trans("OpenSurveyArea")); $param=''; $fieldtosortuser=empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?'firstname':'lastname'; @@ -98,13 +97,13 @@ print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -$arraystatus=array(''=>' ','expired'=>$langs->trans("Expired"),'opened'=>$langs->trans("Opened")); -print ''; print ''; +$arraystatus=array('-1'=>' ','0'=>$langs->trans("Draft"),'1'=>$langs->trans("Opened"),'2'=>$langs->trans("Closed")); +print ''; print ''."\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.id_sondage", $param,"","",$sortfield,$sortorder); print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "p.titre", $param,"","",$sortfield,$sortorder); -print_liste_field_titre("Type"); +print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "p.format", $param,"","",$sortfield,$sortorder); print_liste_field_titre("Author", $_SERVER["PHP_SELF"], "u.".$fieldtosortuser, $param,"","",$sortfield,$sortorder); print_liste_field_titre("NbOfVoters", $_SERVER["PHP_SELF"], "", $param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre("ExpireDate", $_SERVER["PHP_SELF"], "p.date_fin", $param,"",'align="center"',$sortfield,$sortorder); @@ -125,7 +124,7 @@ print ''."\n"; $sql = "SELECT p.id_sondage, p.fk_user_creat, p.format, p.date_fin, p.status, p.titre, p.nom_admin,"; $sql.= " u.login, u.firstname, u.lastname"; $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; -$sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -134,11 +133,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } $sql.= " WHERE p.entity = ".getEntity('survey'); -if ($status == 'expired') $sql.=" AND date_fin < '".$db->idate($now)."'"; -if ($status == 'opened') $sql.=" AND date_fin >= '".$db->idate($now)."'"; +if ($search_status != '-1' && $search_status != '') $sql.=natural_search("p.status", $search_status, 2); +if ($search_expired == 'expired') $sql.=" AND p.date_fin < '".$db->idate($now)."'"; +if ($search_expired == 'opened') $sql.=" AND p.date_fin >= '".$db->idate($now)."'"; if ($search_ref) $sql.=natural_search("p.id_sondage", $search_ref); -if ($surveytitle) $sql.=natural_search("p.titre", $surveytitle); - +if ($search_title) $sql.=natural_search("p.titre", $search_title); $sql.= $db->order($sortfield,$sortorder); // Count total nb of records @@ -149,7 +148,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->plimit($limit + 1,$offset); +$sql.= $db->plimit($limit+1, $offset); $resql=$db->query($sql); if (! $resql) dol_print_error($db); @@ -174,6 +173,7 @@ while ($i < min($num,$limit)) $opensurvey_static->ref=$obj->id_sondage; $opensurvey_static->title=$obj->titre; $opensurvey_static->status=$obj->status; + $opensurvey_static->date_fin=$db->jdate($obj->date_fin); print ''; @@ -183,7 +183,10 @@ while ($i < min($num,$limit)) print ''; // Title - print ''; + + // Type + print ''; + // Nb of voters print''."\n"; print '
'. $form->selectarray('status', $arraystatus, $status).''. $form->selectarray('search_status', $arraystatus, $search_status).''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; @@ -114,7 +113,7 @@ print '
'.dol_htmlentities($obj->titre).''; + print ''.dol_htmlentities($obj->titre).''; $type=($obj->format=='A')?'classic':'date'; print img_picto('',dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'),1),'width="16"',1); print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate"); @@ -204,6 +207,7 @@ while ($i < min($num,$limit)) print ''.$nbuser.''.dol_print_date($db->jdate($obj->date_fin),'day');