Gestion : possibilité de sauvegarder les recherches

This commit is contained in:
Dany wm 2024-02-17 20:47:07 +01:00 committed by sparkyx
parent d9cf4cf71c
commit 6f859d6ef9
9 changed files with 313 additions and 28 deletions

View file

@ -344,6 +344,10 @@ $path = array(
"operation_exercice+text"=>"ajax_operation_exercice", "operation_exercice+text"=>"ajax_operation_exercice",
// transfer operation to accountancy // transfer operation to accountancy
'operation_exercice+transfer'=>"ajax_operation_exercice", 'operation_exercice+transfer'=>"ajax_operation_exercice",
//list filter for followup
'list_filter_followup'=>"ajax_follow_up",
//delete a filter for followup
'delete_filter_followup'=>"ajax_follow_up",
) ; ) ;
if (array_key_exists($op, $path)) { if (array_key_exists($op, $path)) {

View file

@ -398,4 +398,66 @@ function action_save_short()
alert_box('action_add ' + e.message); alert_box('action_add ' + e.message);
} }
return false; return false;
}
/**
* list of filter for follow up
* @param p_dossier int dossier id
* @param access_code string access_code
*/
function list_filter_followup(p_dossier,access_code)
{
var queryString={
"gDossier":p_dossier,
"op":"list_filter_followup",
"ctl":"filter_followup_id",
"ac":access_code
};
var action=new Ajax.Request (
"ajax_misc.php",
{
method:'get',
parameters:queryString,
onSuccess:function(responseHtml)
{
var posy=calcy(250)
var div = create_div({"id":"filter_followup_id",
'cssclass': "inner_box", 'style': 'width:90%,right:5%;top:'+posy+"px"});
div.update(responseHtml.responseText);
div.show();
}
}
);
}
/**
* @brief delete a filter of follow-up
* @param p_dossier int dossier id
* @param filter_id int table: action_gestion_comment.af_id
*/
function delete_filter_followup(p_dossier,filter_id)
{
smoke.confirm(content[47], function (e) {
if (e) {
var queryString = {
"gDossier": p_dossier,
"op": "delete_filter_followup",
"ctl": "filter_followup_id",
"filter_id": filter_id
};
var action = new Ajax.Request(
"ajax_misc.php",
{
method: 'get',
parameters: queryString,
onSuccess: function (responseHtml) {
$('item_fu' + filter_id).remove();
}
}
);
}
}
);
} }

View file

@ -312,6 +312,16 @@ if ($sub_action == "list")
echo HtmlInput::hidden("export_type", "detail"); echo HtmlInput::hidden("export_type", "detail");
echo HtmlInput::submit("follow_up_csv", _("Export CSV détaillé"),'','smallbutton'); echo HtmlInput::submit("follow_up_csv", _("Export CSV détaillé"),'','smallbutton');
echo "</form>"; echo "</form>";
//if filter_name exists then we save the $_GET into the DB as a JSON object
$filter_name=$http->get("filter_name","string",null);
if ( noalyss_trim($filter_name) != "" ) {
// save filter
// $follow_up_filter=new Follow_Up_Filter($cn);
$a_content=json_encode($_GET);
$action_gestion_filter=new Follow_Up_Filter($filter_name,$a_content);
$action_gestion_filter->save();
}
// si filtered on charge la DB
Follow_Up::show_action_list($cn, $base); Follow_Up::show_action_list($cn, $base);
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------

View file

@ -138,4 +138,18 @@ if ($op == 'followup_comment_oneedit') {
break; break;
} }
return; return;
}
/********************************************************************************************************************
* list the existing filter for followup
******************************************************************************************************************/
if ( $op == 'list_filter_followup') {
$followup_filter=Follow_Up_Filter::display_list($g_user->getLogin());
return;
}
/*******************************************************************************************************************
* delete_filter_followup(p_dossier,filter_id)
*******************************************************************************************************************/
if ( $op == 'delete_filter_followup') {
$cn->exec_delete("delete from action_gestion_id where af_id=$1 and af_user=$2",
[$http->get("filter_id","number"),$g_user->getLogin()]);
} }

View file

@ -61,7 +61,7 @@ class Card_PDF extends \PDF
$this->write_cell(100,5,$this->card->attribut[$i]->av_text,$border); $this->write_cell(100,5,$this->card->attribut[$i]->av_text,$border);
$this->line_new(5); $this->line_new(5);
} }
$filename=$this->card->strAttribut(1)."-".$this->card->strAttribut(32).".pdf"; $filename=$this->card->strAttribut(1)."-".$this->card->strAttribut(32).".pdf";
$filename=sanitize_filename($filename); $filename=sanitize_filename($filename);

View file

@ -0,0 +1,95 @@
<?php
/*
* This file is part of NOALYSS.
*
* NOALYSS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* NOALYSS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOALYSS; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder danydb@noalyss.eu
class Follow_Up_Filter
{
protected $name;
protected $json_content;
public function __construct($name,$json_content)
{
$this->name=$name;
$this->json_content=$json_content;
}
/**
* @return mixed
*/
public function getName():string
{
return $this->name;
}
/**
* @param mixed $name
*/
public function setName($name): Follow_Up_Filter
{
$this->name = $name;
return $this;
}
/**
* @return mixed
*/
public function getaContent():array
{
return $this->json_content;
}
/**
* @param mixed $json_content
*/
public function setaContent($json_content): Follow_Up_Filter
{
$this->json_content = $json_content;
return $this;
}
public function save() {
global $cn,$g_user;
$this->name=trim($this->name);
$exist=$cn->get_value("select count(*) from action_gestion_filter where af_user=$1 and
af_name=$2" , [$g_user->getLogin(),$this->name]);
if ( $exist == 0 ) {
$cn->exec_sql("insert into action_gestion_filter(af_user,af_name,af_search) values ($1,$2,$3)",
[$g_user->getLogin(),$this->name,$this->json_content]);
} else {
$cn->exec_sql("update action_gestion_filter set af_search=$3 where
af_user=$1 and
af_name=$2" ,
[$g_user->getLogin(),$this->name,$this->json_content]);
}
}
/**
* @brief display the list of recorded search
* @param $login string Login of the user
* @return void
*/
public static function display_list($login):void
{
require NOALYSS_TEMPLATE."/follow_up_filter-display_list.php";
}
}

View file

@ -65,22 +65,24 @@
<td><?php echo $hsExcptype_state->input()?></td> <td><?php echo $hsExcptype_state->input()?></td>
</tr> </tr>
<td style="text-align:right"><?php printf(_('contenant le mot'))?></td> <td style="text-align:right"><?php printf(_('contenant le mot'))?></td>
<td ><input class="input_text" style="width:40%" type="text" name="action_query" value="<?php echo $a?>"></td> <td ><input class="input_text" style="width:100%" type="text" name="action_query" value="<?php echo $a?>"></td>
</tr> </tr>
<tr> <tr>
<td style="text-align:right"><?php echo _('Type de document')?></td> <td style="text-align:right"><?php echo _('Type de document')?></td>
<td><?php echo $type_doc->input();?></td> <td><?php echo $type_doc->input();?></td>
</tr> </tr>
</tr> </tr>
<tr> <tr>
<td style="text-align:right"><?php echo _('Uniquement actions internes')?></td> <td style="text-align:right"><?php echo _('Uniquement actions internes')?></td>
<td><?php echo $only_internal->input()?> <td><?php echo $only_internal->input()?>
</td> </td>
</tr> </tr>
</table>
<table style="display:inline;width:30%">
</table>
<table style="display:inline;width:30%">
<tr> <tr>
<td style="text-align:right"> <td style="text-align:right">
<?php printf(_("Après le "))?> <?php printf(_("Après le "))?>
@ -107,11 +109,7 @@
<?php echo $remind_date_end->input();?> <?php echo $remind_date_end->input();?>
</td> </td>
</tr> </tr>
</table>
<table style="display:inline;width:30%">
<tr> <tr>
<td style="text-align:right"> <?php echo _("Référence");?></td> <td style="text-align:right"> <?php echo _("Référence");?></td>
<td> <td>
@ -124,26 +122,11 @@
<?php $num=new INum('ag_id');echo $num->input();?> <?php $num=new INum('ag_id');echo $num->input();?>
</td> </td>
</tr> </tr>
</table> </table>
<p> <p>
<?php echo _('Etiquette'); ?>
<span id="searchtag_choose_td">
<?php echo Tag_Action::select_tag_search('search'); ?>
<?php
if ( isset($_GET['searchtag'])) {
$http=new HttpInput();
echo Tag_Action::add_clear_button('search');
$asearchtag= $http->get("searchtag","array",array());
for ($i=0;$i<count($asearchtag);$i++) {
$t=new Tag_Action($cn, $asearchtag[$i]);
echo $t->update_search_cell('search');
}
}
?>
</span>
</p>
<p>
<?php <?php
echo _("Option étiquettes"); echo _("Option étiquettes");
$iselect= new ISelect("tag_option"); $iselect= new ISelect("tag_option");
@ -154,8 +137,37 @@
$iselect->set_value($http->request("tag_option","number",0)); $iselect->set_value($http->request("tag_option","number",0));
echo $iselect->input(); echo $iselect->input();
?> ?>
<?php echo _('Etiquette'); ?>
<span id="searchtag_choose_td">
<?php echo Tag_Action::select_tag_search('search'); ?>
<?php
if ( isset($_GET['searchtag'])) {
$http=new HttpInput();
echo Tag_Action::add_clear_button('search');
$asearchtag= $http->get("searchtag","array",array());
for ($i=0;$i<count($asearchtag);$i++) {
$t=new Tag_Action($cn, $asearchtag[$i]);
echo $t->update_search_cell('search');
}
}
?>
</span>
</p> </p>
<?php if (! $inner ) : ?>
<p>
Nom Filtre <?php
echo \Icon_Action::tips("Donner un nom pour sauver la recheche et la réutiliser");
$filter_name=new IText("filter_name");
echo $filter_name->input();
?>
Filtre existant :
<?php
// charge les filtres existants et les propose
//ajout bouton pour charge ce filtre-là et non pas les conditions existantes
echo \HtmlInput::button_action("Liste des filtres",sprintf("list_filter_followup('%s','%s')",Dossier::id(),$http->request("ac")));
?>
</p>
<?php endif;?>
<input type="hidden" name="sa" value="list"> <input type="hidden" name="sa" value="list">
<?php echo $supl_hidden?> <?php echo $supl_hidden?>
<ul class="aligned-block"> <ul class="aligned-block">

View file

@ -0,0 +1,86 @@
<?php
/*
* * Copyright (C) 2015 Dany De Bontridder <dany@alchimerys.be>
*
* 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 the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
/**
* @file
* @brief display a list of filter for followup
*/
global $cn;
$http = new HttpInput();
$div = $http->request("ctl");
$acces_code=$http->get("ac");
echo \HtmlInput::title_box("liste ",$div);
$a_list = $cn->get_array("select af_id, af_name,af_search
from action_gestion_filter
where af_user=$1
order by lower(af_name)", [$login]);
if (count($a_list) == 0) {
echo_warning("Aucun filtre");
echo \HtmlInput::button_close($div);
return;
}
?>
<p>
Cliquer sur un filtre pour chercher
</p>
<ul>
<?php
foreach ($a_list as $item) :
$array = json_decode($item['af_search']);
$url = "do.php?" . http_build_query($array);
$dossier_id = Dossier::id();
?>
<li id="item_fu<?=$item['af_id']?>">
<a href="<?=$url?>" class="line">
<?php
echo h($item['af_name']);
?>
</a>
<?php
echo \Icon_Action::trash(uniqid(), sprintf("delete_filter_followup('%s','%s')",
$dossier_id, $item['af_id']));
?>
<?php
endforeach;
?>
<li>
<?php
$url = "do.php?".http_build_query(["ac"=> $acces_code,"gDossier"=>$dossier_id]);
?>
<a href="<?=$url?>" >
Aucun filtre
</a>
</li>
</ul>
<ul class="aligned-block">
<li>
<?php
echo \HtmlInput::button_close("$div");
?>
</li>
</ul>

View file

@ -24,3 +24,5 @@ INSERT INTO public.menu_ref (me_code,me_menu,me_file,me_url,me_description,me_pa
('PDF:card','export Fiche détail PDF','export_card_pdf.php',NULL,NULL,NULL,NULL,'PR',NULL); ('PDF:card','export Fiche détail PDF','export_card_pdf.php',NULL,NULL,NULL,NULL,'PR',NULL);
insert into public.profile_menu (me_code,p_id,p_type_display) select 'PDF:card',p_id,'P' from profile; insert into public.profile_menu (me_code,p_id,p_type_display) select 'PDF:card',p_id,'P' from profile;
create table action_gestion_filter(af_id bigint generated always as identity, af_user text not null, af_name text not null , ag_search text not null);