diff --git a/html/js/gestion.js b/html/js/gestion.js index f365f7b47..3ebda3096 100644 --- a/html/js/gestion.js +++ b/html/js/gestion.js @@ -45,6 +45,69 @@ function remove_document(p_dossier,p_id) ); +} +/** + *@brief remove the concerned operation of an action + *@param dossier + *@param p_id id pk action_comment_operation +*/ +function remove_operation(p_dossier,p_id) +{ + queryString="gDossier="+p_dossier+"&a=rmop&id="+p_id; + var action=new Ajax.Request ( + "show_document.php", + { + method:'get', + parameters:queryString, + onFailure:errorRemoveDoc, + onSuccess:successRemoveOp + } + + ); + +} +function successRemoveOp(request,json) +{ + try{ + var answer=request.responseText.evalJSON(true); + var action="acop"+answer.ago_id; + $(action).innerHTML=""; + var doc="op"+answer.ago_id; + $(doc).style.color="red"; + $(doc).href="javascript:alert('Commentaire Effacé')"; + $(doc).style.textDecoration="line-through"; + }catch(e){alert(e.message);} +} +/** + *@brief remove comment of an action + *@param dossier + *@param p_id pk action_gestion_comment +*/ +function remove_comment(p_dossier,p_id) +{ + queryString="gDossier="+p_dossier+"&a=rmcomment&id="+p_id; + var action=new Ajax.Request ( + "show_document.php", + { + method:'get', + parameters:queryString, + onFailure:errorRemoveDoc, + onSuccess:successRemoveComment + } + + ); + +} +function successRemoveComment(request,json) +{ + var answer=request.responseText.evalJSON(true); + var action="accom"+answer.agc_id; + $(action).innerHTML=""; + var doc="com"+answer.agc_id; + $(doc).style.color="red"; + $(doc).href="javascript:alert('Commentaire Effacé')"; + $(doc).style.textDecoration="line-through"; + } /** *@brief error if a document if removed diff --git a/html/show_document.php b/html/show_document.php index 8510841da..2ea86e2ed 100644 --- a/html/show_document.php +++ b/html/show_document.php @@ -58,3 +58,27 @@ if ( $action == 'rm' ) print $json; } } +/* remove the operation */ +if ( $action == 'rmop' ) +{ + if ($User->check_action(RMDOC)==1) + { + $cn->exec_sql("delete from action_gestion_operation where ago_id=$1", + array($_REQUEST['id'])); + $json=sprintf('{"ago_id":"%s"}',$_REQUEST['id']); + header("Content-type: text/html; charset: utf8",true); + print $json; + } +} +/* remove the comment*/ +if ( $action == 'rmcomment' ) +{ + if ($User->check_action(RMDOC)==1) + { + $cn->exec_sql("delete from action_gestion_comment where agc_id=$1", + array($_REQUEST['id'])); + $json=sprintf('{"agc_id":"%s"}',$_REQUEST['id']); + header("Content-type: text/html; charset: utf8",true); + print $json; + } +} diff --git a/include/action.common.inc.php b/include/action.common.inc.php index 68831c1b3..c321e04c5 100644 --- a/include/action.common.inc.php +++ b/include/action.common.inc.php @@ -292,10 +292,10 @@ function ShowActionList($cn,$p_base) "p_name as label ". " from profile order by 2"); $ag_dest=new ISelect(); -$ag_dest->name="ag_dest"; +$ag_dest->name="ag_dest_query"; $aAg_dest[]=array('value'=>0,'label'=>'Public'); $ag_dest->value=$aAg_dest; -$ag_dest->selected=(isset($_GET["ag_dest"]))?$_GET["ag_dest"]:0; +$ag_dest->selected=(isset($_GET["ag_dest_query"]))?$_GET["ag_dest_query"]:0; $str_ag_dest=$ag_dest->input(); ?> @@ -418,12 +418,12 @@ $str_ag_dest=$ag_dest->input(); $date_end=$_GET['date_end']; $query.=" and ag_timestamp <= to_date('$date_end','DD.MM.YYYY')"; } - if ( isset($_GET['ag_dest'])) + if ( isset($_GET['ag_dest_query'])) { - if ( $_GET['ag_dest']==0) + if ( $_GET['ag_dest_query']==0) $query .= "and ag_dest is null "; else - $query.= " and ag_dest = ".sql_string($_GET['ag_dest']); + $query.= " and ag_dest = ".sql_string($_GET['ag_dest_query']); } $r=$act->myList($p_base,"",$query.$str); echo $r; diff --git a/include/action.inc.php b/include/action.inc.php index a2044e29f..3654f90c1 100644 --- a/include/action.inc.php +++ b/include/action.inc.php @@ -23,7 +23,7 @@ */ require_once('class_ipopup.php'); global $g_user; -$retour=HtmlInput::button_anchor(_('Retour liste'),HtmlInput::get_to_string(array("ac","gDossier","qcode","ag_dest","query","tdoc","date_start","date_end","see_all","all_action")).'&my_action'); +$retour=HtmlInput::button_anchor(_('Retour liste'),HtmlInput::request_to_string(array("ac","gDossier","qcode","ag_dest_query","query","tdoc","date_start","date_end","see_all","all_action")).'&my_action'); //----------------------------------------------------- // Follow_Up //----------------------------------------------------- diff --git a/include/class_follow_up.php b/include/class_follow_up.php index 1ea64e587..f1b9099c3 100644 --- a/include/class_follow_up.php +++ b/include/class_follow_up.php @@ -161,6 +161,10 @@ class Follow_Up FROM action_gestion_comment where ag_id=$1 order by agc_id;", array($this->ag_id) ); + + // List opération liées + $operation=$this->db->get_array("select ago_id,j.jr_id,j.jr_internal,j.jr_comment from jrn as j join action_gestion_operation as ago on (j.jr_id=ago.jr_id)"); + $iconcerned=new IConcerned('operation'); // state // Retrieve the value $a=$this->db->make_array("select s_id,s_value from document_state "); @@ -488,7 +492,7 @@ class Follow_Up /* add the number of item */ $Hid=new IHidden(); $r.=$Hid->input("nb_item",MAX_ARTICLE); - + $r.=HtmlInput::request_to_hidden(array("qcode","ag_dest_query","query","tdoc","date_start","date_end","see_all","all_action")); /* get template */ ob_start(); require_once 'template/detail-action.php'; @@ -659,6 +663,7 @@ class Follow_Up $this->db->exec_sql("insert into action_gestion_comment (ag_id,tech_user,agc_comment) values ($1,$2,$3)" ,array($this->ag_id,$_SESSION['g_user'],$this->ag_comment)); } + $this->insert_operation(); } /*! myList($p_filter="") * \brief Show list of action by default if sorted on date @@ -671,7 +676,7 @@ class Follow_Up { $str_dossier=dossier::get(); // for the sort - $url=HtmlInput::get_to_string(array("qcode","ag_dest","query","tdoc","date_start","date_end","see_all","all_action")).$str_dossier.'&'.$p_base; + $url=HtmlInput::get_to_string(array("qcode","ag_dest_query","query","tdoc","date_start","date_end","see_all","all_action")).$str_dossier.'&'.$p_base; $table=new Sort_Table(); $table->add('Date',$url,'order by ag_timestamp asc','order by ag_timestamp desc','da','dd'); @@ -749,7 +754,7 @@ class Follow_Up //show the sub_action foreach ($a_row as $row ) { - $href=''; + $href=''; $i++; $tr=($i%2==0)?'even':'odd'; if ($row['ag_priority'] < 2) $tr='priority1'; @@ -977,6 +982,8 @@ class Follow_Up $this->db->exec_sql("insert into action_gestion_comment (ag_id,tech_user,agc_comment) values ($1,$2,$3)" ,array($this->ag_id,$_SESSION['g_user'],$this->ag_comment)); } + $this->insert_operation(); + $this->remove_operation(); return true; } @@ -1019,6 +1026,8 @@ class Follow_Up $this->ag_contact=(isset($p_array['ag_contact']))?$p_array['ag_contact']:""; $this->ag_comment=(isset($p_array['ag_comment']))?$p_array['ag_comment']:""; $this->ag_remind_date=(isset($p_array['ag_remind_date']))?$p_array['ag_remind_date']:null; + $this->operation=(isset($p_array['operation']))?$p_array['operation']:null; + $this->op=(isset($p_array['op']))?$p_array['op']:null; } /*!\brief remove the action @@ -1081,4 +1090,25 @@ class Follow_Up array($p_array[$i])); } } + function insert_operation() + { + if ( trim($this->operation)=='') return; + $array=explode(",",$this->operation); + for ($i=0;$idb->get_value("select count(*) from action_gestion_operation + where ag_id=$1 and jr_id=$2",array($this->ag_id,$array[$i]))==0) + { + $this->db->exec_sql("insert into action_gestion_operation (ag_id,jr_id) values ($1,$2)", + array($this->ag_id,$array[$i])); + } + } + } + function remove_operation() + { + if ($this->op==null) return; + $op=$this->op; + for ($i=0;$idb->exec_sql("delete from action_gestion_operation where ago_id=$1",array($op[$i])); + } + } } diff --git a/include/class_html_input.php b/include/class_html_input.php index e66ca4c7d..edf7ae845 100755 --- a/include/class_html_input.php +++ b/include/class_html_input.php @@ -230,7 +230,7 @@ class HtmlInput */ static function detail_op($p_jr_id,$p_mesg) { - return sprintf('%s', + return sprintf('%s', $p_jr_id,dossier::id(),$p_mesg); } /** diff --git a/include/template/detail-action.php b/include/template/detail-action.php index b057bf78c..d2ecea468 100644 --- a/include/template/detail-action.php +++ b/include/template/detail-action.php @@ -6,10 +6,10 @@ -
+
input(); ?> - +
@@ -74,7 +74,7 @@ -
+
@@ -136,7 +136,24 @@
+
+
    + Effacer'; + echo '
  1. '.h($operation[$o]['jr_comment'])." ".HtmlInput::detail_op($operation[$o]['jr_id'],$operation[$o]['jr_internal'])." " + .$js.'
  2. '; + } + + ?> +
+ input()?> +
@@ -166,7 +183,12 @@ function small(p_id_textarea){
n°'.$acomment[$c]['agc_id']." ".h($acomment[$c]['agc_comment']).'('.h($acomment[$c]['tech_user'])." ".smaller_date($acomment[$c]['str_agc_date']).')

'; + $rmComment=sprintf("javascript:if ( confirm('"._('Voulez-vous effacer ce commentaire ')."')==true ) {remove_comment('%s','%s');}", + dossier::id(), + $acomment[$c]['agc_id']); + $js= 'Effacer'; + echo '

n°'.$acomment[$c]['agc_id']." ".h($acomment[$c]['agc_comment']).'('.h($acomment[$c]['tech_user'])." ".smaller_date($acomment[$c]['str_agc_date']).')'. + $js.'

'; } echo $desc->input(); $style_enl='style="display:inline"';$style_small='style="display:none"'; diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 5dc6c709e..edba8e4f0 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -88,3 +88,20 @@ COMMENT ON COLUMN action_gestion_comment.tech_user IS 'user_login'; insert into action_gestion_comment (ag_id,agc_date,agc_comment,tech_user) select ag_id,ag_timestamp,ag_comment,ag_owner from action_gestion; ALTER TABLE action_gestion drop COLUMN ag_comment; + +CREATE TABLE action_gestion_operation +( + ago_id bigserial NOT NULL, -- pk + ag_id bigint, -- fk to action_gestion + jr_id bigint, -- fk to jrn + CONSTRAINT action_comment_operation_pkey PRIMARY KEY (ago_id ), + CONSTRAINT action_comment_operation_ag_id_fkey FOREIGN KEY (ag_id) + REFERENCES action_gestion (ag_id) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT action_comment_operation_jr_id_fkey FOREIGN KEY (jr_id) + REFERENCES jrn (jr_id) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE CASCADE +); +COMMENT ON COLUMN action_comment_operation.ago_id IS 'pk'; +COMMENT ON COLUMN action_comment_operation.ag_id IS 'fk to action_gestion'; +COMMENT ON COLUMN action_comment_operation.jr_id IS 'fk to jrn'; \ No newline at end of file