diff --git a/ChangeLog b/ChangeLog index c400db96fe9..b13f0bc1586 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,7 @@ For users: - New: Add an admin page to make a mass init of barcode values for all products. - New: Automatic events for sending mails showing info about mail linked objects. - New: Price management enhancement (multiprice level, price by customer, if MAIN_FEATURES_LEVEL=2 Price by qty) +- New: Add filter on text and status into survey list. Can also sorter on id, text and date end. - Fix: Project Task numbering rule customs rule works TODO diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index 9240cfe49b4..b10122ee269 100644 --- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql +++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql @@ -18,10 +18,10 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); ALTER TABLE llx_bookmark ADD COLUMN entity integer DEFAULT 1 NOT NULL; - ALTER TABLE llx_bookmark MODIFY COLUMN url varchar(255) NOT NULL; -ALTER TABLE llx_opensurvey_sondage ADD COLUMN allow_comments tinyint NOT NULL DEFAULT 1 AFTER canedit; +ALTER TABLE llx_opensurvey_sondage ADD COLUMN entity integer DEFAULT 1 NOT NULL; +ALTER TABLE llx_opensurvey_sondage ADD COLUMN allow_comments tinyint NOT NULL DEFAULT 1; -- ALTER TABLE llx_opensurvey_sondage DROP COLUMN survey_link_visible; -- ALTER TABLE llx_opensurvey_sondage DROP INDEX idx_id_sondage_admin; -- ALTER TABLE llx_opensurvey_sondage DROP COLUMN id_sondage_admin; @@ -33,6 +33,7 @@ ALTER TABLE llx_opensurvey_sondage CHANGE COLUMN mailsonde mailsonde tinyint NOT ALTER TABLE llx_opensurvey_sondage CHANGE COLUMN titre titre TEXT NOT NULL; ALTER TABLE llx_opensurvey_sondage CHANGE COLUMN date_fin date_fin DATETIME NOT NULL; ALTER TABLE llx_opensurvey_sondage CHANGE COLUMN format format VARCHAR(2) NOT NULL; +ALTER TABLE llx_opensurvey_sondage ADD COLUMN sujet TEXT; ALTER TABLE llx_facture_rec CHANGE COLUMN usenewprice usenewprice INTEGER DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql index d8c3d74571c..dca50aba6f7 100644 --- a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql +++ b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql @@ -16,17 +16,18 @@ -- ============================================================================ CREATE TABLE llx_opensurvey_sondage ( - id_sondage VARCHAR(16) PRIMARY KEY, - commentaires text, - mail_admin VARCHAR(128), - nom_admin VARCHAR(64), - fk_user_creat integer NOT NULL, - titre TEXT NOT NULL, - date_fin DATETIME NOT NULL, - format VARCHAR(2) NOT NULL, - mailsonde tinyint NOT NULL DEFAULT 0, - allow_comments tinyint NOT NULL DEFAULT 1, - allow_spy tinyint NOT NULL DEFAULT 1, - tms TIMESTAMP, - sujet TEXT + id_sondage VARCHAR(16) PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + commentaires text, + mail_admin VARCHAR(128), + nom_admin VARCHAR(64), + fk_user_creat integer NOT NULL, + titre TEXT NOT NULL, + date_fin DATETIME NOT NULL, + format VARCHAR(2) NOT NULL, + mailsonde tinyint NOT NULL DEFAULT 0, + allow_comments tinyint NOT NULL DEFAULT 1, + allow_spy tinyint NOT NULL DEFAULT 1, + tms TIMESTAMP, + sujet TEXT ) ENGINE=InnoDB; \ No newline at end of file diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index a9b36ca7a1c..76a3b959d2b 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2014 Marcos García +/* Copyright (C) 2013-2014 Laurent Destailleur + * Copyright (C) 2014 Marcos García * * 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 @@ -32,15 +32,37 @@ if (!$user->rights->opensurvey->read) accessforbidden(); $action=GETPOST('action'); $id=GETPOST('id'); $numsondage= $id; +$surveytitle=GETPOST('surveytitle'); +$status=GETPOST('status'); +//if (! isset($_POST['status']) && ! isset($_GET['status'])) $status='opened'; // If filter unknown, we choose 'opened' -if (! $sortorder) $sortorder="ASC"; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0; } +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; if (! $sortfield) $sortfield="p.titre"; +if (! $sortorder) $sortorder="ASC"; if ($page < 0) { $page = 0; } $limit = $conf->liste_limit; $offset = $limit * $page; +$langs->load("opensurvey"); + +/* + * Actions + */ + +if (GETPOST('button_removefilter')) +{ + $status=''; + $surveytitle=''; +} + /* * View @@ -48,18 +70,49 @@ $offset = $limit * $page; $form=new Form($db); -$langs->load("opensurvey"); +$now = dol_now(); + llxHeader(); -print '
'."\n"; +$param=''; + +print '
'."\n"; print_fiche_titre($langs->trans("OpenSurveyArea")); -// tableau qui affiche tous les sondages de la base -print ''."\n"; -print ''."\n"; +// List of surveys into database -$sql = "SELECT id_sondage, fk_user_creat, u.login, format, date_fin, titre, nom_admin"; +print ''; +print ''; +print ''; +print ''; +print ''; + +print '
'. $langs->trans("Ref").''. $langs->trans("Title") .''. $langs->trans("Type") .''. $langs->trans("Author") .''. $langs->trans("ExpireDate") .''. $langs->trans("NbOfVoters") .'
'."\n"; +print ''; +print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.id_sondage",$param,"","",$sortfield,$sortorder); +print_liste_field_titre($langs->trans("Title"), $_SERVER["PHP_SELF"], "p.titre",$param,"","",$sortfield,$sortorder); +print ''; +print ''; +print_liste_field_titre($langs->trans("ExpireDate"), $_SERVER["PHP_SELF"], "p.date_fin",$param,"",'align="center"',$sortfield,$sortorder); +print ''; +print ''."\n"; + +print ''; +print ''; +print ''; +print ''; +print ''; +$arraystatus=array(''=>' ','expired'=>$langs->trans("Expired"),'opened'=>$langs->trans("Opened")); +print ''; +print ''; +print ''."\n"; + +$sql = "SELECT p.id_sondage, p.fk_user_creat, p.format, p.date_fin, p.titre, p.nom_admin,"; +$sql.= " u.login"; $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"; // Count total nb of records @@ -69,8 +122,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } -$sql.= " ORDER BY $sortfield $sortorder "; -$sql.= " ".$db->plimit($conf->liste_limit+1, $offset); +$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 ($surveytitle) $sql.=" AND titre LIKE '%".$db->escape($surveytitle)."%'"; +$sql.= $db->order($sortfield,$sortorder); +$sql.= $db->plimit($conf->liste_limit+1, $offset); $resql=$db->query($sql); if (! $resql) dol_print_error($db); @@ -100,22 +157,22 @@ while ($i < min($num,$limit)) 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"); print ''; print ''; print''."\n"; @@ -125,6 +182,9 @@ while ($i < min($num,$limit)) } print '
'. $langs->trans("Type") .''. $langs->trans("Author") .''. $langs->trans("NbOfVoters") .'
'. $form->selectarray('status', $arraystatus, $status).''; +print ''; +print ''; +print '
'; - + // Author if ($obj->fk_user_creat) { $userstatic = new User($db); $userstatic->id = $obj->fk_user_creat; $userstatic->login = $obj->login; - + print $userstatic->getLoginUrl(1); } else { print dol_htmlentities($obj->nom_admin); } - + print ''.dol_print_date($db->jdate($obj->date_fin),'day'); - if ($db->jdate($obj->date_fin) < time()) { print ' '.img_warning(); } + if ($db->jdate($obj->date_fin) < time()) { print ' ('.$langs->trans("Expired").')'; } print ''.$nbuser.'
'."\n"; + +print ''; + print '
'."\n"; llxFooter(); diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 28330586070..09576449f0b 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -260,7 +260,7 @@ else } else { - print '
'; + print ''; print ''; print ''; print ''; @@ -277,7 +277,7 @@ else if (empty($conf->global->PRODUIT_MULTIPRICES)) $colspan++; if ($user->rights->fournisseur->lire) $colspan++; if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1) $colspan+=2; - + if (! empty($conf->categorie->enabled)) { $moreforfilter.=$langs->trans('Categories'). ': '; @@ -361,10 +361,10 @@ else print ''; } - print ''; + print ''; print $form->selectarray('tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$tosell,1); print ''; - + print ''; print $form->selectarray('tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')),$tobuy,1); print ''; @@ -492,7 +492,7 @@ else print ''.$product_static->LibStatut($objp->tobuy,5,1).''; print ' '; - + print "\n"; $i++; }