[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 34/38: Gestion : possibilité de sauvegarder l
From: |
dwm |
Subject: |
[Noalyss-commit] [noalyss] 34/38: Gestion : possibilité de sauvegarder les recherches |
Date: |
Sun, 18 Feb 2024 07:30:48 -0500 (EST) |
sparkyx pushed a commit to branch devel
in repository noalyss.
commit 6f859d6ef9d697f04e2d0912ea98866bf624a819
Author: Dany wm <danydb@noalyss.eu>
AuthorDate: Sat Feb 17 20:47:07 2024 +0100
Gestion : possibilité de sauvegarder les recherches
---
html/ajax_misc.php | 4 +
html/js/gestion.js | 62 ++++++++++++++
include/action.common.inc.php | 10 +++
include/ajax/ajax_follow_up.php | 14 ++++
include/class/card_pdf.class.php | 2 +-
include/class/follow_up_filter.class.php | 95 ++++++++++++++++++++++
include/template/action_search.php | 66 +++++++++------
include/template/follow_up_filter-display_list.php | 86 ++++++++++++++++++++
sql/upgrade.sql | 2 +
9 files changed, 313 insertions(+), 28 deletions(-)
diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index 63b197768..6879065ca 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -344,6 +344,10 @@ $path = array(
"operation_exercice+text"=>"ajax_operation_exercice",
// transfer operation to accountancy
'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)) {
diff --git a/html/js/gestion.js b/html/js/gestion.js
index 66e65f200..4e0258ed7 100644
--- a/html/js/gestion.js
+++ b/html/js/gestion.js
@@ -398,4 +398,66 @@ function action_save_short()
alert_box('action_add ' + e.message);
}
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();
+ }
+ }
+ );
+ }
+ }
+ );
}
\ No newline at end of file
diff --git a/include/action.common.inc.php b/include/action.common.inc.php
index ea1f14b7d..6725f0607 100644
--- a/include/action.common.inc.php
+++ b/include/action.common.inc.php
@@ -312,6 +312,16 @@ if ($sub_action == "list")
echo HtmlInput::hidden("export_type", "detail");
echo HtmlInput::submit("follow_up_csv", _("Export CSV
détaillé"),'','smallbutton');
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);
}
//--------------------------------------------------------------------------------
diff --git a/include/ajax/ajax_follow_up.php b/include/ajax/ajax_follow_up.php
index 5a8b885b9..f5a0e5028 100644
--- a/include/ajax/ajax_follow_up.php
+++ b/include/ajax/ajax_follow_up.php
@@ -138,4 +138,18 @@ if ($op == 'followup_comment_oneedit') {
break;
}
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()]);
}
\ No newline at end of file
diff --git a/include/class/card_pdf.class.php b/include/class/card_pdf.class.php
index 3618d4431..59971489d 100644
--- a/include/class/card_pdf.class.php
+++ b/include/class/card_pdf.class.php
@@ -61,7 +61,7 @@ class Card_PDF extends \PDF
$this->write_cell(100,5,$this->card->attribut[$i]->av_text,$border);
$this->line_new(5);
}
-
+
$filename=$this->card->strAttribut(1)."-".$this->card->strAttribut(32).".pdf";
$filename=sanitize_filename($filename);
diff --git a/include/class/follow_up_filter.class.php
b/include/class/follow_up_filter.class.php
new file mode 100644
index 000000000..9612ab068
--- /dev/null
+++ b/include/class/follow_up_filter.class.php
@@ -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";
+ }
+}
\ No newline at end of file
diff --git a/include/template/action_search.php
b/include/template/action_search.php
index 00d11ec39..5bec1f597 100644
--- a/include/template/action_search.php
+++ b/include/template/action_search.php
@@ -65,22 +65,24 @@
<td><?php echo
$hsExcptype_state->input()?></td>
</tr>
<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>
<td style="text-align:right"><?php echo
_('Type de document')?></td>
<td><?php echo $type_doc->input();?></td>
</tr>
-
+
</tr>
<tr>
<td style="text-align:right"><?php echo
_('Uniquement actions internes')?></td>
<td><?php echo $only_internal->input()?>
</td>
</tr>
- </table>
- <table style="display:inline;width:30%">
+
+ </table>
+
+ <table style="display:inline;width:30%">
<tr>
<td style="text-align:right">
<?php printf(_("Après le "))?>
@@ -107,11 +109,7 @@
<?php echo $remind_date_end->input();?>
</td>
</tr>
-
-
- </table>
- <table style="display:inline;width:30%">
<tr>
<td style="text-align:right"> <?php echo
_("Référence");?></td>
<td>
@@ -124,26 +122,11 @@
<?php $num=new INum('ag_id');echo
$num->input();?>
</td>
</tr>
-
+
</table>
<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
echo _("Option étiquettes");
$iselect= new ISelect("tag_option");
@@ -154,8 +137,37 @@
$iselect->set_value($http->request("tag_option","number",0));
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>
-
+ <?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">
<?php echo $supl_hidden?>
<ul class="aligned-block">
diff --git a/include/template/follow_up_filter-display_list.php
b/include/template/follow_up_filter-display_list.php
new file mode 100644
index 000000000..d8802c6b1
--- /dev/null
+++ b/include/template/follow_up_filter-display_list.php
@@ -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>
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index 37c18bc69..c0a22bc29 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -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);
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);
- [Noalyss-commit] [noalyss] 18/38: Fix cosmetic bug : duplicate operation with autoreverse VAT has an VAT amount, (continued)
- [Noalyss-commit] [noalyss] 18/38: Fix cosmetic bug : duplicate operation with autoreverse VAT has an VAT amount, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 20/38: Fix : auto numbering receipt, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 21/38: Merge branch 'devel', dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 25/38: cosmetic, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 37/38: Cosmetic, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 38/38: Upgrade SQL, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 28/38: DB protect against JS Injection, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 07/38: SUIVI : ajout prénom, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 14/38: integre changement SQL, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 30/38: redirect via javascript, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 34/38: Gestion : possibilité de sauvegarder les recherches,
dwm <=