diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 5e1261b5b..e79e3b0f8 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -266,6 +266,8 @@ $path = array( "save_filter"=>"ajax_search_filter", // Load a search filter "load_filter"=>"ajax_search_filter", + // display a list of filter (alias saved search) + "display_list_filter"=>"ajax_search_filter", // display tag for filter 'display_filter_tag'=>'ajax_search_filter', // search operation to reconcile diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 6298d53ad..7ca3b0422 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -1672,6 +1672,28 @@ function reset_filter(p_div) { // By default , unpaid is uncked $(p_div + "operation_filter").value = "all"; } +function display_list_filter(p_dossier,access_code,ledger_type) +{ + new Ajax.Request("ajax_misc.php",{ + parameters:{"gDossier":p_dossier + ,"op":"display_list_filter" + ,"ac":access_code + ,'ledger_type':ledger_type + }, + method:'GET', + onSuccess: function (responseHtml) { + try { + var posy=calcy(250) + var div = create_div({"id":"display_list_filter_div", + 'cssclass': "inner_box", 'style': 'width:90%,right:5%;top:'+posy+"px"}); + div.update(responseHtml.responseText); + div.show(); + }catch (e) { + console.error(e.message); + } + } + }) +} /** * propose to duplicate an operation diff --git a/include/ajax/ajax_search_filter.php b/include/ajax/ajax_search_filter.php index 7301c4ba3..e895707ad 100644 --- a/include/ajax/ajax_search_filter.php +++ b/include/ajax/ajax_search_filter.php @@ -111,13 +111,7 @@ if ($op=="load_filter") $answer['filter_id']=0; $answer['message']=""; $filter=new User_filter_SQL($cn, $filter_id); - $record=$filter->to_array(); - - $record['desc']=$record['description']; - $record['r_jrn']=explode(",", $record['r_jrn']??""); - $record['tag']=explode(",",$record['uf_tag']??""); - $record['tag_option']=$record["uf_tag_option"]; - $record['p_currency_code']=$record['uf_currency_code']; + $record=Acc_Ledger_Search::build_array($filter); $result=array_merge($answer, $record); @@ -227,4 +221,25 @@ if ($op=='display_filter_tag') $tag_operation->update_search_cell($div); } } + return; +} +//--------------------------------------------------------------------------------------------------------------- +// display_list_filter : display a list of saved search alias filter +//---------------------------------------------------------------------------------------------------------------- +if ($op=='display_list_filter') +{ + echo \HtmlInput::title_box("Recherches sauvées",'display_list_filter_div'); + + $ledger_search=new Acc_Ledger_Search($http->request("ledger_type")); + $ledger_search->display_list_filter(); +?> + + + +div."filter_new"); - $name->placeholder=_("Nom du filtre"); + $name->placeholder=_("Nom de la recherche"); $r=$name->input(); $bt=new IButton($this->div."save_ok",_("Ajout")); $bt->javascript=sprintf("save_filter('%s','%s')",$this->div,Dossier::id()); @@ -724,7 +726,7 @@ class Acc_Ledger_Search $r.=HtmlInput::submit('search', _('Rechercher')); - $button_search=new IButton("{$this->div}button", _('Filtre')); + $button_search=new IButton("{$this->div}button", _('Recherches sauvées')); $button_search->javascript=$this->build_search_filter(); $r.=$button_search->input(); @@ -1313,4 +1315,48 @@ class Acc_Ledger_Search return $ret; } + /** + * @brief use a user_filter row and turns it into an array for + * javascript purpose + * @param User_Filter_SQL $user_filter_sql + * @return array + */ + static function build_array(User_Filter_SQL $user_filter_sql) + { + $record=$user_filter_sql->to_array(); + + $record['desc']=$record['description']; + $record['r_jrn']=explode(",", $record['r_jrn']??""); + $record['tag']=explode(",",$record['uf_tag']??""); + $record['tag_option']=$record["uf_tag_option"]; + $record['p_currency_code']=$record['uf_currency_code']; + return $record; + } + + /** + * @brief build an HTML string with a button to show the list of + * saved search + * @return string HTML button + * @throws Exception if $_REQUEST['ac'] is not set + */ + public function button_propose_filter() + { + $http=new HttpInput(); + $button=HtmlInput::button_action("Recherches sauvées", + sprintf("display_list_filter('%s','%s','%s')" + ,Dossier::id() + , $http->request("ac") + ,$this->type + ),uniqid(),'smallbutton'); + return $button; + } + + /** + * @brief display a list of saved search + */ + public function display_list_filter() + { + require_once NOALYSS_TEMPLATE."/acc_ledger_search-display_list_filter.php"; + + } } diff --git a/include/history_operation.inc.php b/include/history_operation.inc.php index 56b8ab3c2..a983cd50a 100644 --- a/include/history_operation.inc.php +++ b/include/history_operation.inc.php @@ -32,31 +32,33 @@ global $g_user,$cn,$http; $p_array = $_GET; $ledger_type=$http->get("ledger_type","string", 'ALL'); -$Ledger=new Acc_Ledger_Search($ledger_type,0,'search_op'); switch($ledger_type) { - case 'ACH': - $ask_pay=1; - $p_array['ledger_type']='ACH'; - break; - case 'ODS': - $ask_pay=0; - $p_array['ledger_type']='ODS'; - break; - case 'ALL': - $ask_pay=0; - $p_array['ledger_type']='ALL'; - break; - case 'VEN': - $ask_pay=1; - $p_array['ledger_type']='VEN'; - break; - case 'FIN': - $ask_pay=0; - $p_array['ledger_type']='FIN'; - break; + case 'ACH': + $ask_pay=1; + $p_array['ledger_type']='ACH'; + break; + case 'ODS': + $ask_pay=0; + $p_array['ledger_type']='ODS'; + break; + case 'ALL': + $ask_pay=0; + $p_array['ledger_type']='ALL'; + break; + case 'VEN': + $ask_pay=1; + $p_array['ledger_type']='VEN'; + break; + case 'FIN': + $ask_pay=0; + $p_array['ledger_type']='FIN'; + break; + default: + throw new \Exception("HO58 : ledger_type unknown"); } +$Ledger=new Acc_Ledger_Search($p_array['ledger_type'],0,'search_op'); echo '
'; // Check privilege $p_jrn=$http->request("p_jrn", "string",-1); @@ -113,8 +115,9 @@ $offset=(isNumber($offset)==0)?0:$offset; $bar = navigation_bar($offset, $max_line, $step, $page); echo $msg; -echo $Ledger->display_search_form(); +echo $Ledger->button_propose_filter(); echo HtmlInput::filter_table('history_operation_t', '0,1,2,3,4,5,6,7', 1); +echo $Ledger->display_search_form(); echo $bar; echo '
'; echo HtmlInput::hidden("ac", $http->request('ac')); diff --git a/include/template/acc_ledger_search-display_list_filter.php b/include/template/acc_ledger_search-display_list_filter.php new file mode 100644 index 000000000..879b3589d --- /dev/null +++ b/include/template/acc_ledger_search-display_list_filter.php @@ -0,0 +1,103 @@ +cn->get_array("select id,filter_name,description,ledger_type +from public.user_filter where login=$1 and ledger_type=$2", +[$g_user->getLogin(),$this->type]); +$nb_array=count($array); +$http=new HttpInput(); +$div="search_op"; +?> +

+ Cliquez sur un lien pour affiche le résultat de la recherche +

+ + + + diff --git a/include/template/follow_up_filter-display_list.php b/include/template/follow_up_filter-display_list.php index 01fe4f112..56abaafdd 100644 --- a/include/template/follow_up_filter-display_list.php +++ b/include/template/follow_up_filter-display_list.php @@ -35,7 +35,7 @@ from action_gestion_filter where af_user=$1 order by lower(af_name)", [$login]); if (count($a_list) == 0) { - echo_warning("Aucun filtre"); + echo_warning("Aucune recherche sauvée"); echo \HtmlInput::button_close($div); return; } @@ -43,7 +43,7 @@ if (count($a_list) == 0) { ?>

- Cliquer sur un filtre pour chercher + Cliquez sur un lien pour affiche le résultat de la recherche