From 6f859d6ef9d697f04e2d0912ea98866bf624a819 Mon Sep 17 00:00:00 2001 From: Dany wm Date: Sat, 17 Feb 2024 20:47:07 +0100 Subject: [PATCH] =?UTF-8?q?Gestion=20:=20possibilit=C3=A9=20de=20sauvegard?= =?UTF-8?q?er=20les=20recherches?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 +++++++------ .../follow_up_filter-display_list.php | 86 +++++++++++++++++ sql/upgrade.sql | 2 + 9 files changed, 313 insertions(+), 28 deletions(-) create mode 100644 include/class/follow_up_filter.class.php create mode 100644 include/template/follow_up_filter-display_list.php 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 ""; + //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 @@ +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 @@ input()?> - + input();?> - + input()?> - - + +
+ + - - -
@@ -107,11 +109,7 @@ input();?>
- - +
@@ -124,26 +122,11 @@ input();?>

- - - - get("searchtag","array",array()); - for ($i=0;$iupdate_search_cell('search'); - } - } - ?> - -

-

+ + set_value($http->request("tag_option","number",0)); echo $iselect->input(); ?> + + + + get("searchtag","array",array()); + for ($i=0;$iupdate_search_cell('search'); + } + } + ?> +

- + +

+ Nom Filtre input(); + ?> + Filtre existant : + request("ac"))); + ?> +

+