From 868dbdfbd070a8a22827a29274d3a07004eebe5d Mon Sep 17 00:00:00 2001 From: sparkyx Date: Wed, 14 Feb 2024 18:21:32 +0100 Subject: [PATCH] Nouveau #00022980002298: detail fiche ,historique du suivi --- html/ajax_misc.php | 2 + html/js/acc_ledger.js | 38 +++++++++++ html/js/card.js | 3 + include/ajax/ajax_card.php | 3 +- include/ajax/ajax_follow_up.php | 16 +++++ include/class/follow_up.class.php | 76 ++++++++++++++++----- include/template/follow_up-view_list.php | 87 ++++++++++++++++++++++++ 7 files changed, 206 insertions(+), 19 deletions(-) create mode 100644 include/template/follow_up-view_list.php diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 63b197768..e3d97138d 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -344,6 +344,8 @@ $path = array( "operation_exercice+text"=>"ajax_operation_exercice", // transfer operation to accountancy 'operation_exercice+transfer'=>"ajax_operation_exercice", + // view list of followup for a card + "view_followup_card"=>"ajax_follow_up", ) ; if (array_key_exists($op, $path)) { diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 9929335ed..6298d53ad 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -930,6 +930,44 @@ function view_history_card(p_value, dossier, p_exercice) { } ); } +/*! + * \brief list followup of a card + * \param p_value int fiche.f_id of the card + */ +function view_followup_card(p_value, dossier) { + layer++; + var idbox = 'detfu' + layer; + var popup = { + 'id': idbox, + 'cssclass': 'inner_box', + 'html': loading(), + 'drag': false + }; + var querystring = { + 'gDossier': dossier, + 'f_id': p_value, + 'div': idbox, + "l": layer, + "op": "view_followup_card", + }; + waiting_box(); + var action = new Ajax.Request( + "ajax_misc.php", + { + method: 'get', + parameters: querystring, + onFailure: error_box, + onSuccess: function (req, xml) { + remove_waiting_box(); + if (req.responseText === 'NOCONX') { reconnect();return;} + + add_div(popup); + $(idbox).update(req.responseText); + g(idbox).style.top = calcy(140 + (layer * 3)) + "px"; + } + } + ); +} /** * update history view after changing the exercice diff --git a/html/js/card.js b/html/js/card.js index 3eb1947c6..71c78754a 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -634,6 +634,9 @@ function fill_ipopcard(obj) if ( obj.nohistory != undefined) { queryString+='&nohistory'; } + if ( obj.nofollowup != undefined) { + queryString+='&nofollowup'; + } queryString=encodeURI(queryString); var action=new Ajax.Request ( 'ajax_misc.php', { diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php index 22ca1c2e5..267872812 100644 --- a/include/ajax/ajax_card.php +++ b/include/ajax/ajax_card.php @@ -29,7 +29,7 @@ * - gDossier * - op - dc Detail of a card - parameter : $qcode , optional ro for readonly and nohistory without the history button + parameter : $qcode , optional ro for readonly and nohistory without the history button, nofollowup - bc Blank Card : display form for adding a card parameter fd_id (fiche_def:fd_id) - st Show Type : select type of card @@ -168,6 +168,7 @@ case 'dc': $html.=HtmlInput::submit('save',_('Sauver')); } if ( ! isset ($nohistory))$html.=HtmlInput::history_card_button($f->id,_('Historique')); + if ( ! isset ($nofollowup))$html.=HtmlInput::followup_card_button($f->id,_('Suivi')); // Display a remove button if not used and can modify card if ( $can_modify == 1 && $f->is_used()==FALSE) { diff --git a/include/ajax/ajax_follow_up.php b/include/ajax/ajax_follow_up.php index 5a8b885b9..51c416e9d 100644 --- a/include/ajax/ajax_follow_up.php +++ b/include/ajax/ajax_follow_up.php @@ -25,6 +25,7 @@ if (!defined('ALLOWED')) * @file * @brief Update description on file */ +global $http,$cn; $op=$http->request('op'); global $g_user; @@ -138,4 +139,19 @@ if ($op == 'followup_comment_oneedit') { break; } return; +} + +/************************************************************************** + * See list of follow-up evebt + *************************************************************************/ +if ($op =="view_followup_card") +{ + $div=$http->get("div"); + $card=new Fiche($cn,$http->get("f_id","number")); + echo HtmlInput::title_box("Suivi ".h($card->strAttribut(ATTR_DEF_NAME)),$div); + $query=Follow_Up::create_query($cn,["qcode"=>$card->strAttribut(ATTR_DEF_QUICKCODE)]); + $followup=new Follow_Up($cn); + echo $followup->view_list($query); + echo \HtmlInput::button_close($div); + return; } \ No newline at end of file diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php index ecdfeb88f..fe0467890 100644 --- a/include/class/follow_up.class.php +++ b/include/class/follow_up.class.php @@ -634,13 +634,56 @@ class Follow_Up $this->insert_operation(); $this->insert_action(); } - + /** + * @brief return the SQL to make a list of actions + * Colum : + * - my_date string date action format DD.MM.YYYY + * - my_remind string date reminder format DD.MM.YYYY + * - str_last_comment string last colemnt format DD.MM.YYYY + * - last_comment date last comment + * - f_id_dest int fiche.f_id concerned card + * - s_value string state of the action (cloturé, à suivre ,...) + * - s_id int id of document_state + * - ag_title string Title of the follow-up + * - dt_value string Type of document + * - ag_ref, string ref of the action + * - ag_priority int priority of the action + * - ag_state, int state of the followup (see table : document_state ) + * - dest string profil group + * - name string name of the recipient + * - qcode string qcode of the recipient + * - tag string list of tags separated by comma + * - tags_color string list of tag colors separated by comma + * @returns a SQL string to retrieve list of actions + */ + public static function SQL_list_action():string + { + $sql = " select ag_id,to_char(ag_timestamp,'DD.MM.YYYY') as my_date, + to_char(ag_remind_date,'DD.MM.YYYY') as my_remind, + to_char(coalesce((select max(agc_date) from action_gestion_comment as agc where agc.ag_id=ag.ag_id),ag_timestamp),'DD.MM.YY') as str_last_comment, + coalesce((select max(agc_date) from action_gestion_comment as agc where agc.ag_id=ag.ag_id),ag_timestamp) as last_comment, + f_id_dest, + s_id, + s_value, + ag_title,dt_value,ag_ref, ag_priority,ag_state, + coalesce((select p_name from profile where p_id=ag_dest),'Aucun groupe') as dest, + (select ad_value from fiche_Detail where f_id=ag.f_id_dest and ad_id=1) as name, + (select ad_value from fiche_Detail where f_id=ag.f_id_dest and ad_id=23) as qcode, + array_to_string((select array_agg(t1.t_tag) from action_tags as a1 join tags as t1 on (a1.t_id=t1.t_id) where a1.ag_id=ag.ag_id ),',') as tags, + array_to_string((select array_agg(t1.t_color) from action_tags as a1 join tags as t1 on (a1.t_id=t1.t_id) where a1.ag_id=ag.ag_id ),',') as tags_color + from action_gestion as ag + join document_type on (ag_type=dt_id) + join document_state on (ag_state=s_id) + "; + return $sql; + } /** * @brief myList($p_base, $p_filter = "", $p_search = "") * Show list of action by default if sorted on date * @param $p_base base url with ac... * @param $p_filter filters on the document_type * @param $p_search must a valid sql command ( ex 'and ag_title like upper('%hjkh%')) + * @see Follow_Up::create_query() * @return string containing html code */ function myList($p_base, $p_filter="", $p_search="") @@ -676,23 +719,9 @@ class Follow_Up else $p_filter_doc=" 1=1 "; - $sql=" - select ag_id,to_char(ag_timestamp,'DD.MM.YYYY') as my_date, - to_char(ag_remind_date,'DD.MM.YYYY') as my_remind, - to_char(coalesce((select max(agc_date) from action_gestion_comment as agc where agc.ag_id=ag.ag_id),ag_timestamp),'DD.MM.YY') as str_last_comment, - coalesce((select max(agc_date) from action_gestion_comment as agc where agc.ag_id=ag.ag_id),ag_timestamp) as last_comment, - f_id_dest, - s_value, - ag_title,dt_value,ag_ref, ag_priority,ag_state, - coalesce((select p_name from profile where p_id=ag_dest),'Aucun groupe') as dest, - (select ad_value from fiche_Detail where f_id=ag.f_id_dest and ad_id=1) as name, - (select ad_value from fiche_Detail where f_id=ag.f_id_dest and ad_id=23) as qcode, - array_to_string((select array_agg(t1.t_tag) from action_tags as a1 join tags as t1 on (a1.t_id=t1.t_id) where a1.ag_id=ag.ag_id ),',') as tags, - array_to_string((select array_agg(t1.t_color) from action_tags as a1 join tags as t1 on (a1.t_id=t1.t_id) where a1.ag_id=ag.ag_id ),',') as tags_color - from action_gestion as ag - join document_type on (ag_type=dt_id) - join document_state on (ag_state=s_id) - where $p_filter_doc $p_search $sort"; + // make SQL to find the action + $sql=Follow_Up::SQL_list_action()." where $p_filter_doc $p_search $sort"; + $max_line=$this->db->count_sql($sql); $step=$_SESSION[SESSION_KEY.'g_pagesize']; $page=(isset($_GET['offset']))?$_GET['page']:1; @@ -823,6 +852,17 @@ class Follow_Up return $r; } + /** + * @brief display list of followup , used with card + * @param $query string SQL query + * @return void + */ + function view_list($query) + { + $sql=Follow_Up::SQL_list_action(); + $sql = " $sql $query"; + require_once NOALYSS_TEMPLATE."/follow_up-view_list.php"; + } //---------------------------------------------------------------------- /** * \brief Update the data into the database, the field ag_description could contain some HTML tags and must be diff --git a/include/template/follow_up-view_list.php b/include/template/follow_up-view_list.php new file mode 100644 index 000000000..225831451 --- /dev/null +++ b/include/template/follow_up-view_list.php @@ -0,0 +1,87 @@ +get_array($sql); +if (empty ($array)) { + echo_warning("Aucun suivi "); + return; +} +$idx=0; +?> + + + + + + + + + + + + + + + + + > + + + + + + + + + + +
DateRéférenceTitreQCODEDernier commentaireEtat
+ + + + + %s', $aColor[$x], $aTags[$x]); + printf(" "); + } // end loop $x + + } + ?> +