From 3ce147ccc1b5403a320e0a8ff246371fe2c76ed7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Oct 2015 02:41:09 +0200 Subject: [PATCH] Use new architecture for quick search for the account area. --- htdocs/adherents/index.php | 48 +++++++++++++++++--------------- htdocs/compta/facture/list.php | 25 ++++++++++++++++- htdocs/core/search.php | 16 +++++++++++ htdocs/don/list.php | 28 ++++++++++++++++++- htdocs/fourn/facture/list.php | 31 ++++++++++++++++++++- htdocs/projet/activity/index.php | 39 +++++++++++++++----------- htdocs/projet/index.php | 32 +++++++++++++-------- htdocs/projet/list.php | 5 ++++ htdocs/projet/tasks/index.php | 25 ++++++++++++++++- 9 files changed, 193 insertions(+), 56 deletions(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index d6c17337176..f6bdb81345c 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -125,29 +125,32 @@ if ($result) //print ''; print '
'; +// Search contact/address +if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire) +{ + $listofsearchfields['search_member']=array('text'=>'Member'); +} + +if (count($listofsearchfields)) +{ + print '
'; + print ''; + print ''; + $i=0; + foreach($listofsearchfields as $key => $value) + { + if ($i == 0) print ''; + print ''; + print ''; + if ($i == 0) print ''; + print ''; + $i++; + } + print '
'.$langs->trans("Search").'
:
'; + print '
'; + print '
'; +} -// Formulaire recherche adherent -print '
'; -print ''; -print ''; -print ''; -print ''; -print ''; -print "\n"; -$var=false; -print ""; -print ''; -print ""; -print ''; -print ""; -print ''; -print "
'.$langs->trans("SearchAMember").'
'; -print ':'; -print '
'; -print ':'; -print '
'; -print ':'; -print '
"; /* @@ -156,7 +159,6 @@ print ""; if ($conf->use_javascript_ajax) { - print '
'; print ''; print ''; print '
'.$langs->trans("Statistics").'
'; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index e4993eacb88..fc090ef52e0 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -107,6 +107,16 @@ $hookmanager->initHooks(array('invoicelist')); $now=dol_now(); +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'f.facnumber'=>'Ref', + 'f.ref_client'=>'RefCustomer', + 'fd.description'=>'Description', + 's.nom'=>"ThirdParty", + 'f.note_public'=>'NotePublic', +); +if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate"; + /* * Actions @@ -134,6 +144,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $month=''; } + /* * View @@ -232,7 +243,7 @@ if (! $sall) } else { - $sql .= natural_search(array('s.nom', 'f.facnumber', 'f.note_public', 'fd.description'), $sall); + $sql .= natural_search(array_keys($fieldstosearchall), $sall); } $sql.= ' ORDER BY '; $listfield=explode(',',$sortfield); @@ -275,7 +286,19 @@ if ($resql) $i = 0; print '
'."\n"; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($sall) + { + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall, join(', ',$fieldstosearchall)); + } + // If the user can view prospects other than his' $moreforfilter=''; if ($user->rights->societe->client->voir || $socid) diff --git a/htdocs/core/search.php b/htdocs/core/search.php index a0b6146caf6..0307a8c77d1 100644 --- a/htdocs/core/search.php +++ b/htdocs/core/search.php @@ -109,6 +109,22 @@ if (GETPOST('search_holiday') != '') header("Location: ".DOL_URL_ROOT.'/holiday/list.php?mode=search&sall='.urlencode(GETPOST('search_holiday'))); exit; } +if (GETPOST('search_member') != '') +{ + header("Location: ".DOL_URL_ROOT.'/adherents/list.php?mode=search&sall='.urlencode(GETPOST('search_member'))); + exit; +} +if (GETPOST('search_project') != '') +{ + header("Location: ".DOL_URL_ROOT.'/projet/list.php?mode=search&search_all='.urlencode(GETPOST('search_project'))); + exit; +} +if (GETPOST('search_task') != '') +{ + header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php?mode=search&search_all='.urlencode(GETPOST('search_task'))); + exit; +} + // If we are here, search was called with no supported criteria diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 9227b1a26eb..14389887faa 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -61,6 +61,20 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_amount=""; } +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('orderlist')); + + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'd.rowid'=>'Id', + 'd.ref'=>'Ref', + 'd.lastname'=>'Lastname', + 'd.firstname'=>'Firstname', +); + + + /* * View */ @@ -87,7 +101,7 @@ if (trim($search_ref) != '') } if (trim($search_all) != '') { - $sql .= natural_search(array('d.rowid', 'd.ref', 'd.lastname', 'd.firstname', 'd.societe'), $search_all); + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } if (trim($search_company) != '') { @@ -126,6 +140,18 @@ if ($resql) print ''."\n"; if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + if ($search_all) + { + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $search_all, join(', ',$fieldstosearchall)); + } + print ""; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid","", $param,"",$sortfield,$sortorder); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 05459d0bd69..ccf7169219b 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -68,6 +68,7 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="fac.datef,fac.rowid"; +$search_all = GETPOST('sall'); $search_ref = GETPOST("search_ref","int"); $search_ref_supplier = GETPOST("search_ref_supplier","alpha"); $search_label = GETPOST("search_label","alpha"); @@ -86,6 +87,7 @@ $optioncss = GETPOST('optioncss','alpha'); if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test must be present to be compatible with all browsers { + $search_all=""; $search_ref=""; $search_ref_supplier=""; $search_label=""; @@ -97,6 +99,18 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $filter=""; } +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'fac.ref'=>'Ref', + 'fac.ref_supplier'=>'RefSupplier', + //'fd.description'=>'Description', + 's.nom'=>"ThirdParty", + 'fac.note_public'=>'NotePublic', +); +if (empty($user->socid)) $fieldstosearchall["fac.note_private"]="NotePrivate"; + + + /* * Actions */ @@ -157,7 +171,10 @@ if ($filter && $filter != -1) // GETPOST('filtre') may be a string $sql .= " AND " . $filt[0] . " = " . $filt[1]; } } - +if ($search_all) +{ + $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +} if ($search_ref) { if (is_numeric($search_ref)) $sql .= natural_search(array('fac.ref'), $search_ref); @@ -255,6 +272,18 @@ if ($resql) print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->name.":""),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); print ''; if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + if ($search_all) + { + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $search_all, join(', ',$fieldstosearchall)); + } + print '
'; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"fac.ref,fac.rowid","",$param,"",$sortfield,$sortorder); diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index be97ad37a33..1be05aed2d8 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -68,30 +68,35 @@ else print '
'; - -// Search task +// Search project if (! empty($conf->projet->enabled) && $user->rights->projet->lire) { - $var=false; - print ''; + $listofsearchfields['search_task']=array('text'=>'Task'); +} + +if (count($listofsearchfields)) +{ + print ''; print ''; - print ''; - print ''; // All status - print '
'; - print ''; - print ''; - print ''; - print ''; - //print ''; - print ''; - print ''; - print "
'.$langs->trans("SearchATask").'
:
:
:
\n"; - print "
\n"; + print ''; + $i=0; + foreach($listofsearchfields as $key => $value) + { + if ($i == 0) print ''; + print ''; + print ''; + if ($i == 0) print ''; + print ''; + $i++; + } + print '
'.$langs->trans("Search").'
:
'; + print ''; + print '
'; } /* Affichage de la liste des projets d'aujourd'hui */ -print '
'; +print '
'; print ''; print ''; print ''; diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index e316603c2b7..2f45dce9906 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -101,19 +101,27 @@ print '
'; // Search project if (! empty($conf->projet->enabled) && $user->rights->projet->lire) { - $var=false; - print '
'; + $listofsearchfields['search_project']=array('text'=>'Project'); +} + +if (count($listofsearchfields)) +{ + print ''; print ''; - print '
'.$langs->trans('ActivityOnProjectToday').''.$langs->trans("Time").'
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "
'.$langs->trans("SearchAProject").'
:
:
:
\n"; - print "
\n"; + print ''; + $i=0; + foreach($listofsearchfields as $key => $value) + { + if ($i == 0) print ''; + print ''; + print ''; + if ($i == 0) print ''; + print ''; + $i++; + } + print '
'.$langs->trans("Search").'
:
'; + print ''; + print '
'; } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index ad617d2c849..17aa5cac222 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -242,6 +242,11 @@ if ($resql) print '
'; if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; // Show description of content if ($mine) print $langs->trans("MyProjectsDesc").'

'; diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php index 39484f05014..cd8e3af37bd 100644 --- a/htdocs/projet/tasks/index.php +++ b/htdocs/projet/tasks/index.php @@ -33,6 +33,8 @@ $langs->load('projects'); $langs->load('users'); $id=GETPOST('id','int'); + +$search_all=GETPOST('search_all'); $search_project=GETPOST('search_project'); if (! isset($_GET['search_status']) && ! isset($_POST['search_status'])) $search_status=1; else $search_status=GETPOST('search_status'); @@ -55,8 +57,9 @@ $page = $page == -1 ? 0 : $page; $mine = $_REQUEST['mode']=='mine' ? 1 : 0; // Purge criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { + $search_all=""; $search_project=""; $search_status=""; $search_task_ref=""; @@ -64,6 +67,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both } if (empty($search_status) && $search_status == '') $search_status=1; +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 't.ref'=>"Ref", + 't.label'=>"Label", +); + /* * Actions @@ -107,6 +116,7 @@ $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$so // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task assigned to a user can have a parent that is not assigned to him and we need such parents). $morewherefilter=''; +if ($search_all) $morewherefilter.=natural_search(array_keys($fieldstosearchall), $search_all); if ($search_task_ref) $morewherefilter.=natural_search('t.ref', $search_task_ref); if ($search_task_label) $morewherefilter.=natural_search('t.label', $search_task_label); $tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_project, $search_status, $morewherefilter, $search_project_user, $search_task_user); @@ -114,8 +124,21 @@ $tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $sea $tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : ''); print ''; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; print ''; +if ($search_all) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $search_all, join(', ',$fieldstosearchall)); +} + + // If the user can view users if ($user->rights->user->user->lire) {