diff --git a/html/ajax_misc.php b/html/ajax_misc.php index b799da094..8e6f79a60 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -588,7 +588,7 @@ EOF; case 'tag_detail': require_once 'ajax_tag_detail.php'; break; - case 'save_tag': + case 'tag_save': require_once 'ajax_tag_save.php'; break; case 'tag_list': diff --git a/html/js/scripts.js b/html/js/scripts.js index c261dcbd6..949ddc4a5 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -1984,13 +1984,14 @@ function error_message(message) $('error_div').style.visibility='visible'; } /** - * @brief show the detail of a tag + * @brief show the detail of a tag and propose to save it */ -function show_tag(p_dossier,p_ac,p_tag_id) +function show_tag(p_dossier,p_ac,p_tag_id,p_post) { try { waiting_box(); - var queryString="op=tag_detail&tag="+p_tag_id+"&gDossier="+p_dossier+"&ac="+p_ac; + console.log(p_post); + var queryString="op=tag_detail&tag="+p_tag_id+"&gDossier="+p_dossier+"&ac="+p_ac+'&form='+p_post; var action = new Ajax.Request( "ajax_misc.php" , { @@ -2037,36 +2038,20 @@ function save_tag() var action = new Ajax.Request( "ajax_misc.php" , { - method:'get', parameters:queryString, + method:'get', + parameters:queryString, onFailure:ajax_misc_failure, onSuccess:function(req,j){ - var answer=req.responseXML; - var html=answer.getElementsByTagName('code'); - if ( html.length == 0 ) - { - var rec=req.responseText; - alert ('erreur :'+rec); - } - var code_html=getNodeText(html[0]); - code_html=unescape_xml(code_html); - remove_waiting_box(); - add_div({id:'tag_div',cssclass:'inner_box',drag:1}); - $('tag_div').innerHTML=code_html; - try - { - code_html.evalScripts(); - } - catch(e) - { - alert("answer_box Impossible executer script de la reponse\n"+e.message); - } - + remove_waiting_box(); + removeDiv('tag_div'); } } ); } catch (e) { error_message(e.getMessage); + return false; } + return false; } /** diff --git a/include/ajax_tag_detail.php b/include/ajax_tag_detail.php index 7a7fa1f06..7e3747e97 100644 --- a/include/ajax_tag_detail.php +++ b/include/ajax_tag_detail.php @@ -12,14 +12,25 @@ $tag->data->load(); echo HtmlInput::title_box("Détail du dossier / tag", "tag_div"); ?> -
+ + + + + data; require_once 'template/tag_detail.php'; - echo HtmlInput::submit("save_tag", "Valider"); + echo HtmlInput::submit("save_tag_sb", "Valider"); ?>
check(); - $tag->save($_POST); - $uos->save(); - } catch (Exception $e) + if ( ! isset ($_POST['remove'])) { - alert("déjà sauvé"); + try { + $uos->check(); + $tag->save($_POST); + $uos->save(); + } catch (Exception $e) + { + alert("déjà sauvé"); + } + } else { + $tag->remove($_POST); } } ?> @@ -49,6 +55,6 @@ if ( isset ($_POST['save_tag']))

show_list(); - $js=sprintf("onclick=\"show_tag('%s','%s','%s')\"",Dossier::id(),$_REQUEST['ac'],'-1'); - echo HtmlInput::button("tag_add", "Ajout d'un dossier", $js); + $js=sprintf("onclick=\"show_tag('%s','%s','%s','p')\"",Dossier::id(),$_REQUEST['ac'],'-1'); + echo HtmlInput::button("tag_add", "Ajout d'un tag", $js); ?> \ No newline at end of file diff --git a/include/class_follow_up.php b/include/class_follow_up.php index ee7db1566..688fb0552 100644 --- a/include/class_follow_up.php +++ b/include/class_follow_up.php @@ -676,14 +676,16 @@ class Follow_Up $url = HtmlInput::get_to_string(array("closed_action","remind_date_end","remind_date","sag_ref","only_internal","state","qcode", "ag_dest_query", "query", "tdoc", "date_start", "date_end", "hsstate")) . '&' . $p_base; $table = new Sort_Table(); - $table->add('Date', $url, 'order by ag_timestamp asc', 'order by ag_timestamp desc', 'da', 'dd'); + $table->add('Date Doc.', $url, 'order by ag_timestamp asc', 'order by ag_timestamp desc', 'da', 'dd'); + $table->add('Date Comm.', $url, 'order by last_comment', 'order by last_comment desc', 'dca', 'dcd'); $table->add('Date Limite', $url, 'order by ag_remind_date asc', 'order by ag_remind_date desc', 'ra', 'rd'); + $table->add('Tag', $url, 'order by tags asc', 'order by tags desc', 'taa', 'tad'); $table->add('Réf.', $url, 'order by ag_ref asc', 'order by ag_ref desc', 'ra', 'rd'); $table->add('Groupe', $url, "order by coalesce((select p_name from profile where p_id=ag_dest),'Aucun groupe')", "order by coalesce((select p_name from profile where p_id=ag_dest),'Aucun groupe') desc", 'dea', 'ded'); $table->add('Dest/Exp', $url, 'order by name asc', 'order by name desc', 'ea', 'ed'); $table->add('Titre', $url, 'order by ag_title asc', 'order by ag_title desc', 'ta', 'td'); - $ord = (!isset($_GET['ord'])) ? "dd" : $_GET['ord']; + $ord = (!isset($_GET['ord'])) ? "dcd" : $_GET['ord']; $sort = $table->get_sql_order($ord); if (strlen(trim($p_filter)) != 0) @@ -693,16 +695,17 @@ class Follow_Up $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, - 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=action_gestion.f_id_dest and ad_id=1) as name, - (select count(d_id) from document where document.ag_id=action_gestion.ag_id) as cnt_doc - from action_gestion - join document_type on (ag_type=dt_id) - join document_state on (ag_state=s_id) + 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 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, + 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 + 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"; $max_line = $this->db->count_sql($sql); $step = $_SESSION['g_pagesize']; @@ -727,9 +730,8 @@ class Follow_Up $r.='' . $table->get_header(3) . ''; $r.='' . $table->get_header(4) . ''; $r.='' . $table->get_header(5) . ''; - $r.=th(_("Nbre doc.")); - $r.='' . _('type') . ''; - $r.=th('Etat'); + $r.='' . $table->get_header(6) . ''; + $r.='' . $table->get_header(7) . ''; $r.=th('Priorité'); $r.=""; @@ -763,7 +765,9 @@ class Follow_Up $st = ' style="font-weight:bold;background:#FF0000"'; $r.=""; $r.="" . $href . smaller_date($row['my_date']) . '' . ""; + $r.="" . $href . $row['last_comment'] . '' . ""; $r.="" . $href . smaller_date($row['my_remind']) . '' . ""; + $r.="" . $href . h($row['tags']). '' . ""; $r.="" . $href . $row['ag_ref'] . '' . ""; $r.="" . $href . h($row['dest']) . '' . ""; @@ -786,14 +790,7 @@ class Follow_Up $r.='' . $href . h($row['ag_title']) . ""; - if ($row['cnt_doc'] != 0) - $r.="" . $href . h($row['cnt_doc']) . '' . ""; - else - $r.=""; - $r.="" . $row['dt_value'] . ""; - - $r.=td($row['s_value']); /* * State */ @@ -818,7 +815,6 @@ class Follow_Up $r.=""; $r.=$bar; - //$r.=""; return $r; } @@ -1365,14 +1361,17 @@ class Follow_Up 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_id),ag_timestamp),'DD.MM.YY') as last_comment, + 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_id ),',') as tags, (select ad_value from fiche_Detail where f_id=action_gestion.f_id_dest and ad_id=1) as name, 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 - from action_gestion + from action_gestion join document_type on (ag_type=dt_id) join document_state on(ag_state=s_id) where true $p_search order by ag_timestamp,ag_id"; @@ -1383,6 +1382,8 @@ class Follow_Up array("title"=>"doc id","type"=>"string"), array("title"=>"date","type"=>"date"), array("title"=>"rappel","type"=>"date"), + array("title"=>"dernier comm.","type"=>"date"), + array("title"=>"tags","type"=>"string"), array("title"=>"nom","type"=>"string"), array("title"=>"titre","type"=>"string"), array("title"=>"type document","type"=>"string"), @@ -1461,9 +1462,10 @@ class Follow_Up echo $a_tag[$e]['t_tag']; echo ''; echo ''; - echo HtmlInput::anchor("X", "javascript:void(0)", $js_remove).'  '; + echo HtmlInput::anchor("X", "javascript:void(0)", $js_remove); echo ''; echo ' '; + echo ' '; } $js=sprintf("onclick=\"action_tag_select('%s','%s')\"",dossier::id(),$this->ag_id); echo HtmlInput::button('tag_bt', 'Ajout tag',$js, 'smallbutton'); diff --git a/include/class_tag.php b/include/class_tag.php index c647e35d8..a950e520f 100644 --- a/include/class_tag.php +++ b/include/class_tag.php @@ -64,11 +64,17 @@ class Tag } function save($p_array) { + if ( trim($p_array['t_tag'])=="" ) return ; $this->data->t_id=$p_array['t_id']; $this->data->t_tag=str_ireplace('