phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r4852 - in phpcompta/trunk: html html/js include include


From: phpcompta-dev
Subject: [Phpcompta-dev] r4852 - in phpcompta/trunk: html html/js include include/template sql
Date: Thu, 31 May 2012 04:51:51 +0200 (CEST)

Author: danydb
Date: 2012-05-31 04:51:49 +0200 (Thu, 31 May 2012)
New Revision: 4852

Added:
   phpcompta/trunk/include/class_irelated_action.php
   phpcompta/trunk/include/template/action_button.php
   phpcompta/trunk/include/template/action_search.php
   phpcompta/trunk/include/template/action_search_result.php
Modified:
   phpcompta/trunk/html/js/card.js
   phpcompta/trunk/html/js/gestion.js
   phpcompta/trunk/html/js/scripts.js
   phpcompta/trunk/html/show_document.php
   phpcompta/trunk/include/ajax_search_action.php
   phpcompta/trunk/include/class_follow_up.php
   phpcompta/trunk/include/class_html_input.php
   phpcompta/trunk/include/template/detail-action.php
   phpcompta/trunk/sql/upgrade.sql
Log:
Add : 
Multi comment
related operation
related action

Modified: phpcompta/trunk/html/js/card.js
===================================================================
--- phpcompta/trunk/html/js/card.js     2012-05-31 00:20:30 UTC (rev 4851)
+++ phpcompta/trunk/html/js/card.js     2012-05-31 02:51:49 UTC (rev 4852)
@@ -240,7 +240,7 @@
 }
 function update_value(text,li)
 {
-          ajaxFid(ctl);
+          ajaxFid(text);
 }
 /**
  address@hidden is called when something change in ICard

Modified: phpcompta/trunk/html/js/gestion.js
===================================================================
--- phpcompta/trunk/html/js/gestion.js  2012-05-31 00:20:30 UTC (rev 4851)
+++ phpcompta/trunk/html/js/gestion.js  2012-05-31 02:51:49 UTC (rev 4852)
@@ -33,17 +33,17 @@
 */
 function remove_document(p_dossier,p_id)
 {
-    queryString="gDossier="+p_dossier+"&a=rm&d_id="+p_id;
-    var action=new Ajax.Request (
-                   "show_document.php",
-                   {
-                   method:'get',
-                   parameters:queryString,
-                   onFailure:errorRemoveDoc,
-                   onSuccess:successRemoveDoc
-                   }
+       queryString="gDossier="+p_dossier+"&a=rm&d_id="+p_id;
+       var action=new Ajax.Request (
+               "show_document.php",
+               {
+                       method:'get',
+                       parameters:queryString,
+                       onFailure:errorRemoveDoc,
+                       onSuccess:successRemoveDoc
+               }
 
-               );
+               );
 
 }
 /**
@@ -53,60 +53,92 @@
 */
 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
-                   }
+       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);}
+               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);
+       }
 }
 /**
+ address@hidden remove the concerned operation of an action
+ address@hidden dossier
+ address@hidden p_id id pk action_comment_operation
+*/
+function remove_action(p_dossier,p_id,ag_id)
+{
+       
queryString="gDossier="+p_dossier+"&a=rmaction&id="+p_id+"&ag_id="+ag_id;
+       var action=new Ajax.Request (
+               "show_document.php",
+               {
+                       method:'get',
+                       parameters:queryString,
+                       onFailure:ajax_misc_failure,
+                       onSuccess:function(request,json) {
+                               try{
+                               var answer=request.responseText.evalJSON(true);
+                               var action="acact"+answer.act_id;
+                               $(action).innerHTML="";
+                               var doc="act"+answer.act_id;
+                               $(doc).style.color="red";
+                               $(doc).href="javascript:alert('Action 
Effacée')";
+                               $(doc).style.textDecoration="line-through";
+                               } catch (e){ alert(e.message);}
+                       }
+               }
+
+               );
+
+}
+/**
  address@hidden remove comment of an action
  address@hidden dossier
  address@hidden 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
-                   }
+       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";
+       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";
 
 }
 /**
@@ -114,20 +146,20 @@
  */
 function errorRemoveDoc()
 {
-    alert('Impossible d\'effacer ce document');
+       alert('Impossible d\'effacer ce document');
 }
 /**
  address@hidden success when removing a document
  */
 function successRemoveDoc(request,json)
 {
-    var answer=request.responseText.evalJSON(true);
-    var action="ac"+answer.d_id;
-    $(action).innerHTML="";
-    var doc="doc"+answer.d_id;
-    $(doc).style.color="red";
-    $(doc).href="javascript:alert('Document Effacé')";
-    $(doc).style.textDecoration="line-through";
+       var answer=request.responseText.evalJSON(true);
+       var action="ac"+answer.d_id;
+       $(action).innerHTML="";
+       var doc="doc"+answer.d_id;
+       $(doc).style.color="red";
+       $(doc).href="javascript:alert('Document Effacé')";
+       $(doc).style.textDecoration="line-through";
 
 }
 /**
@@ -136,17 +168,17 @@
 */
 function check_hour(p_ctl)
 {
-    try
-    {
-        var h=document.getElementById(p_ctl);
-       var re = /^\d{1,2}:\d{2}$/;
-        if ( trim(h.value) !='' && ! h.value.match(re))
-            alert("Format de l'heure est HH:MM ")
-        }
-    catch (erreur)
-    {
-        alert('fct : check_hour '+erreur);
-    }
+       try
+       {
+               var h=document.getElementById(p_ctl);
+               var re = /^\d{1,2}:\d{2}$/;
+               if ( trim(h.value) !='' && ! h.value.match(re))
+                       alert("Format de l'heure est HH:MM ")
+       }
+       catch (erreur)
+       {
+               alert('fct : check_hour '+erreur);
+       }
 
 }
 /**
@@ -157,21 +189,21 @@
 
 function removeStock(s_id,p_dossier)
 {
-    if ( ! confirm("Confirmez-vous l'effacement de cette entrée dans le 
stock?") )
-    {
-       return;
-    }
-    queryString="gDossier="+p_dossier+"&op=rm_stock&s_id="+s_id;
-    var action=new Ajax.Request (
-                   "ajax_misc.php",
-                   {
-                   method:'get',
-                   parameters:queryString,
-                   onFailure:errorRemoveStock,
-                   onSuccess:successRemoveStock
-                   }
+       if ( ! confirm("Confirmez-vous l'effacement de cette entrée dans le 
stock?") )
+       {
+               return;
+       }
+       queryString="gDossier="+p_dossier+"&op=rm_stock&s_id="+s_id;
+       var action=new Ajax.Request (
+               "ajax_misc.php",
+               {
+                       method:'get',
+                       parameters:queryString,
+                       onFailure:errorRemoveStock,
+                       onSuccess:successRemoveStock
+               }
 
-               );
+               );
 
 }
 /**
@@ -179,25 +211,25 @@
  */
 function errorRemoveStock()
 {
-    alert('Impossible d\'effacer ');
+       alert('Impossible d\'effacer ');
 }
 /**
  address@hidden success when removing a document
  */
 function successRemoveStock(request,json)
 {
-    try
-    {
-       var answer=request.responseText.evalJSON(true);
-       var doc="stock"+answer.d_id;
-       var href="href"+answer.d_id;
-       $(href).innerHTML='';
+       try
+       {
+               var answer=request.responseText.evalJSON(true);
+               var doc="stock"+answer.d_id;
+               var href="href"+answer.d_id;
+               $(href).innerHTML='';
 
-       $(doc).style.color="red";
-       //    $(doc).href="javascript:alert('Stock Effacé')";
-       $(doc).style.textDecoration="line-through";
-    } catch (e)
-    {
-       alert("success_box"+e.message);
-    }
+               $(doc).style.color="red";
+               //    $(doc).href="javascript:alert('Stock Effacé')";
+               $(doc).style.textDecoration="line-through";
+       } catch (e)
+{
+               alert("success_box"+e.message);
+       }
 }

Modified: phpcompta/trunk/html/js/scripts.js
===================================================================
--- phpcompta/trunk/html/js/scripts.js  2012-05-31 00:20:30 UTC (rev 4851)
+++ phpcompta/trunk/html/js/scripts.js  2012-05-31 02:51:49 UTC (rev 4852)
@@ -1175,7 +1175,7 @@
        var sx=p_sx;
        var sy=calcy(p_sy);
 
-    var str_style="top:"+sy+";left:"+sx+"position:absolute";
+    var str_style="top:"+sy+";left:"+sx+";position:absolute";
        return str_style;
 
 }
@@ -1384,8 +1384,10 @@
  */
 function search_action(dossier,ctl_concern)
 {
+       try
+       {
        var dossier=g('gDossier').value;
-       
+
        var target="search_action_div";
        removeDiv(target);
        var str_style=fixed_position(77, 99);
@@ -1408,10 +1410,76 @@
                                      parameters:qs,
                                      onFailure:null,
                                      onSuccess:function (req){
+                                                 try {
                                                  remove_waiting_box();
-                                                 
$('search_action').innerHTML=req.responseText;
+                                                 
$('search_action_div').innerHTML=req.responseText;
                                                  
req.responseText.evalScripts();
+                                                 }catch( e){alert(e.message);}
                                          }
                                  }
                                );
-}
\ No newline at end of file
+       }catch( e){alert(e.message);}
+}
+
+function result_search_action(obj)
+{
+     try
+    {
+        var queryString=$(obj).serialize()+"&op=search_action";
+               alert (queryString);
+        var action = new Ajax.Request(
+            "ajax_misc.php" ,
+            {method:'get',
+              parameters:queryString,
+              onFailure:ajax_misc_failure,
+              onSuccess:function (req){
+                                                 try {
+                                                 remove_waiting_box();
+                                                 
$('search_action_div').innerHTML=req.responseText;
+                                                 
req.responseText.evalScripts();
+                                                 }catch( e){alert(e.message);}
+                                         }
+            }
+        )
+
+    }
+    catch (e)
+    {
+        alert("display_periode "+e.message);
+    }
+
+    return false;
+}
+
+function set_action_related(p_obj)
+ {
+
+        try
+       {
+               var obj=$(p_obj);
+               var ctlc=obj.elements['ctlc'];
+
+               for (var e=0;e<obj.elements.length;e++)
+               {
+
+                       var elmt=obj.elements[e];
+                       if ( elmt.type == "checkbox")
+                       {
+                               if (elmt.checked==true )
+                               {
+                                       var str_name=elmt.name;
+                                               var nValue=elmt.value;
+                                               if ( $(ctlc.value).value != '') 
{$(ctlc.value).value+=',';}
+                                               $(ctlc.value).value+=nValue;
+                               }
+                       }
+               }
+               removeDiv('search_action_div');
+               return false;
+       }
+       catch(e)
+       {
+               alert(e.message);
+               return false;
+       }
+ }
\ No newline at end of file

Modified: phpcompta/trunk/html/show_document.php
===================================================================
--- phpcompta/trunk/html/show_document.php      2012-05-31 00:20:30 UTC (rev 
4851)
+++ phpcompta/trunk/html/show_document.php      2012-05-31 02:51:49 UTC (rev 
4852)
@@ -82,3 +82,17 @@
         print $json;
     }
 }
+/* remove the action*/
+if ( $action == 'rmaction' )
+{
+    if ($User->check_action(RMDOC)==1)
+    {
+               $cn->exec_sql("delete from action_gestion_related where 
aga_least=$1 and aga_greatest=$2",
+                               array($_REQUEST['id'],$_REQUEST['ag_id']));
+               $cn->exec_sql("delete from action_gestion_related where 
aga_least=$2 and aga_greatest=$1",
+                               array($_REQUEST['id'],$_REQUEST['ag_id']));
+        $json=sprintf('{"act_id":"%s"}',$_REQUEST['id']);
+        header("Content-type: text/html; charset: utf8",true);
+        print $json;
+    }
+}

Modified: phpcompta/trunk/include/ajax_search_action.php
===================================================================
--- phpcompta/trunk/include/ajax_search_action.php      2012-05-31 00:20:30 UTC 
(rev 4851)
+++ phpcompta/trunk/include/ajax_search_action.php      2012-05-31 02:51:49 UTC 
(rev 4852)
@@ -23,10 +23,13 @@
  */
 require_once('class_dossier.php');
 include_once("ac_common.php");
-require_once('class_action.php');
-$ac=$_REQUEST['ac'];
-$base='ac='.$ac;
+require_once('class_follow_up.php');
+$_REQUEST['ac']='FOLLOW';
 
-Action::ShowActionList($cn,"");
+echo Follow_Up::display_search($cn,true);
 
+$sql=  "true ".Follow_Up::create_query($cn);
+var_dump($_GET);
+echo $sql;
+echo Follow_Up::short_list($cn, $sql);
 ?>

Modified: phpcompta/trunk/include/class_follow_up.php
===================================================================
--- phpcompta/trunk/include/class_follow_up.php 2012-05-31 00:20:30 UTC (rev 
4851)
+++ phpcompta/trunk/include/class_follow_up.php 2012-05-31 02:51:49 UTC (rev 
4852)
@@ -15,7 +15,7 @@
  *   You should have received a copy of the GNU General Public License
  *   along with PhpCompta; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
+ */
 /* $Revision$ */
 // Copyright Author Dany De Bontridder address@hidden
 require_once('class_itextarea.php');
@@ -35,8 +35,9 @@
 require_once('class_follow_up_detail.php');
 require_once('class_inum.php');
 require_once 'class_sort_table.php';
+require_once 'class_irelated_action.php';
 
-/*!\file
+/* !\file
  * \brief class_action for manipulating actions
  * action can be :
  * <ul>
@@ -44,10 +45,10 @@
  * <li>a meeting
  * <li>an order
  * <li>a letter
- *</ul>
+ * </ul>
  * The table document_type are the possible actions
  */
-/*!
+/* !
  * \brief class_action for manipulating actions
  * action can be :
  * <ul>
@@ -60,644 +61,656 @@
 
 class Follow_Up
 {
-    var $db;         /*!<  $db  database connexion    */
-    var $ag_timestamp;  /*!<   $ag_timestamp document date 
(ag_gestion.ag_timestamp)*/
-    var $dt_id;         /*!<   $dt_id type of the document 
(document_type.dt_id)*/
-    var $ag_state;       /*!<   $ag_state stage of the document (printed, send 
to client...)*/
-    var $d_number;      /*!<   $d_number number of the document*/
-    var $d_filename;    /*!<   $d_filename filename's document      */
-    var $d_mimetype;    /*!<   $d_mimetype document's filename      */
-    var $ag_title;      /*!<   $ag_title title document              */
-    var $f_id;       /*!<   $f_id_dest fiche id (From field )  */
-    var $ag_ref_ag_id;   /*!<   $ag_ref_ag_id concern previous action*/
-    var $ag_ref;              /*!< $ag_ref is the ref  */
-    var $ag_hour;             /*!< $ag_hour is the hour of the meeting, action 
*/
-    var $ag_priority;    /*!< $ag_priority is the priority 1 High, 2 medium, 3 
low */
-    var $ag_dest;             /*!< $ag_dest person who is in charged */
-    var $ag_contact;     /*!< $ag_contact contact */
-    var $ag_remind_date;     /*!< $ag_contact contact */
-    /*!  constructor
-    * \brief constructor
-    * \param p_cn database connection
-    */
-    function __construct ($p_cn)
-    {
-        $this->db=$p_cn;
-        $this->f_id=0;
 
-    }
-    //----------------------------------------------------------------------
-    /*!
-     * \brief Display the object, the tags for the FORM
-     *        are in the caller. It will be used for adding and updating
-     *        action
-     *\note  If  ag_id is not equal to zero then it is an update otherwise
-     *        it is a new document
-     *
-     * \param $p_view if set to true the form will be in readonly mode (value: 
true or false)
-     * \param $p_gen true we show the tag for generating a doc (value : true 
or false)
-     *\param $p_base is the ac parameter
-     *\param $retour is the html code for the return button
-     * \note  update the reference number or the document type is not allowed
-     *
-     *
-     * \return string containing the html code
-     */
-    function Display($p_view,$p_gen,$p_base,$retour="")
-    {
-        if ( $p_view=='UPD')
-        {
-            $upd=true;
-            $readonly=false;
-        }
-        elseif ($p_view=="NEW")
-        {
-            $upd=false;
-            $readonly=false;
-        }
-        elseif ($p_view=='READ')
-        {
-            $upd=true;
-            $readonly=true;
-        }
-        else
-        {
-            exit('class_action'.__LINE__.'Follow_Up::Display error unknown 
parameter'.$p_view);
+       var $db;        /* !<  $db  database connexion    */
+       var $ag_timestamp;  /* !<   $ag_timestamp document date 
(ag_gestion.ag_timestamp) */
+       var $dt_id;   /* !<   $dt_id type of the document (document_type.dt_id) 
*/
+       var $ag_state;  /* !<   $ag_state stage of the document (printed, send 
to client...) */
+       var $d_number;   /* !<   $d_number number of the document */
+       var $d_filename; /* !<   $d_filename filename's document      */
+       var $d_mimetype; /* !<   $d_mimetype document's filename      */
+       var $ag_title;   /* !<   $ag_title title document             */
+       var $f_id;      /* !<   $f_id_dest fiche id (From field )  */
+       var $ag_ref_ag_id;   /* !<   $ag_ref_ag_id concern previous action */
+       var $ag_ref;  /* !< $ag_ref is the ref  */
+       var $ag_hour;  /* !< $ag_hour is the hour of the meeting, action */
+       var $ag_priority; /* !< $ag_priority is the priority 1 High, 2 medium, 
3 low */
+       var $ag_dest;  /* !< $ag_dest person who is in charged */
+       var $ag_contact;  /* !< $ag_contact contact */
+       var $ag_remind_date;  /* !< $ag_contact contact */
 
-        }
-        // Compute the widget
-        // Date
-        $date=new IDate();
-        $date->readonly=$readonly;
-        $date->name="ag_timestamp";
-        $date->value=$this->ag_timestamp;
+       /* !  constructor
+        * \brief constructor
+        * \param p_cn database connection
+        */
 
-               $remind_date=new IDate();
-        $remind_date->readonly=$readonly;
-        $remind_date->name="ag_remind_date";
-        $remind_date->value=$this->ag_remind_date;
+       function __construct($p_cn)
+       {
+               $this->db = $p_cn;
+               $this->f_id = 0;
+       }
 
+       //----------------------------------------------------------------------
+       /* !
+        * \brief Display the object, the tags for the FORM
+        *        are in the caller. It will be used for adding and updating
+        *        action
+        * \note  If  ag_id is not equal to zero then it is an update otherwise
+        *        it is a new document
+        *
+        * \param $p_view if set to true the form will be in readonly mode 
(value: true or false)
+        * \param $p_gen true we show the tag for generating a doc (value : 
true or false)
+        * \param $p_base is the ac parameter
+        * \param $retour is the html code for the return button
+        * \note  update the reference number or the document type is not 
allowed
+        *
+        *
+        * \return string containing the html code
+        */
+       function Display($p_view, $p_gen, $p_base, $retour = "")
+       {
+               if ($p_view == 'UPD')
+               {
+                       $upd = true;
+                       $readonly = false;
+               }
+               elseif ($p_view == "NEW")
+               {
+                       $upd = false;
+                       $readonly = false;
+               }
+               elseif ($p_view == 'READ')
+               {
+                       $upd = true;
+                       $readonly = true;
+               }
+               else
+               {
+                       exit('class_action' . __LINE__ . 'Follow_Up::Display 
error unknown parameter' . $p_view);
+               }
+               // Compute the widget
+               // Date
+               $date = new IDate();
+               $date->readonly = $readonly;
+               $date->name = "ag_timestamp";
+               $date->value = $this->ag_timestamp;
 
+               $remind_date = new IDate();
+               $remind_date->readonly = $readonly;
+               $remind_date->name = "ag_remind_date";
+               $remind_date->value = $this->ag_remind_date;
+
+
                // Doc Type
-               $doc_type=new ISelect();
-               $doc_type->name="dt_id";
-               $doc_type->value=$this->db->make_array("select dt_id,dt_value 
from document_type order by dt_value");
-               $doc_type->selected=$this->dt_id;
-               $doc_type->readonly=false;
-               $str_doc_type=$doc_type->input();
+               $doc_type = new ISelect();
+               $doc_type->name = "dt_id";
+               $doc_type->value = $this->db->make_array("select dt_id,dt_value 
from document_type order by dt_value");
+               $doc_type->selected = $this->dt_id;
+               $doc_type->readonly = false;
+               $str_doc_type = $doc_type->input();
 
-        // Description
-       $desc=new ITextArea();
-        $desc->width=70;
-        $desc->heigh=5;
-        $desc->name="ag_comment";
-        $desc->readonly=$readonly;
-        if ( strlen($desc->value) >300 )
-        {
-            $desc->width=120;
-            $desc->heigh=40;
-        }
-               $acomment=$this->db->get_array("SELECT agc_id, ag_id, 
to_char(agc_date,'DD.MM.YYYY') as str_agc_date, agc_comment, tech_user
-                                FROM action_gestion_comment where ag_id=$1 
order by agc_id;",
-                               array($this->ag_id)
-                               );
+               // Description
+               $desc = new ITextArea();
+               $desc->width = 70;
+               $desc->heigh = 5;
+               $desc->name = "ag_comment";
+               $desc->readonly = $readonly;
+               if (strlen($desc->value) > 300)
+               {
+                       $desc->width = 120;
+                       $desc->heigh = 40;
+               }
+               $acomment = $this->db->get_array("SELECT agc_id, ag_id, 
to_char(agc_date,'DD.MM.YYYY') as str_agc_date, agc_comment, tech_user
+                                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)
-                       where ag_id=$1",array($this->ag_id));
-               $iconcerned=new IConcerned('operation');
-        // state
-        // Retrieve the value
-        $a=$this->db->make_array("select s_id,s_value from document_state ");
-        $state=new ISelect();
-        $state->readonly=$readonly;
-        $state->name="ag_state";
-        $state->value=$a;
-        $state->selected=$this->ag_state;
-        $str_state=$state->input();
+               $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)
+                       where ag_id=$1", array($this->ag_id));
+               $iconcerned = new IConcerned('operation');
 
-        // Retrieve the value if there is an attached doc
-        $doc_ref="";
-        // Document id
+               // List related action
+               $action = $this->db->get_array("
+                       select ag_id,substr(ag_title,1,20) as 
sub_title,to_char(ag_timestamp,'DD.MM.YY') as str_date ,
+                               ag_timestamp
+                                       from action_gestion
+                               where
+                               ag_id in (select aga_greatest from 
action_gestion_related where aga_least =$1)
+                               or
+                               ag_id in (select aga_least from 
action_gestion_related where aga_greatest =$1)
+                               order by ag_timestamp",array($this->ag_id));
+               $iaction=new IRelated_Action('action');
+               // state
+               // Retrieve the value
+               $a = $this->db->make_array("select s_id,s_value from 
document_state ");
+               $state = new ISelect();
+               $state->readonly = $readonly;
+               $state->name = "ag_state";
+               $state->value = $a;
+               $state->selected = $this->ag_state;
+               $str_state = $state->input();
 
-        $h2=new IHidden();
-        $h2->name="d_id";
-        $h2->value=$this->d_id;
+               // Retrieve the value if there is an attached doc
+               $doc_ref = "";
+               // Document id
 
-        if ( $this->d_id != 0 && $this->d_id != "" )
-        {
-            $h2->readonly=($p_view=='NEW')?false:true;
-            $doc=new Document($this->db,$this->d_id);
-            $doc->get();
-            if ( strlen(trim($doc->d_lob)) != 0 )
-            {
-                $d_id=new IHidden();
-                $doc_ref="<p> Document ".$doc->a_ref().'</p>';
-                $doc_ref.=$h2->input().$d_id->input('d_id',$this->d_id);
-            }
+               $h2 = new IHidden();
+               $h2->name = "d_id";
+               $h2->value = $this->d_id;
 
-        }
+               if ($this->d_id != 0 && $this->d_id != "")
+               {
+                       $h2->readonly = ($p_view == 'NEW') ? false : true;
+                       $doc = new Document($this->db, $this->d_id);
+                       $doc->get();
+                       if (strlen(trim($doc->d_lob)) != 0)
+                       {
+                               $d_id = new IHidden();
+                               $doc_ref = "<p> Document " . $doc->a_ref() . 
'</p>';
+                               $doc_ref.=$h2->input() . $d_id->input('d_id', 
$this->d_id);
+                       }
+               }
 
 
-        // title
-        $title=new IText();
-        $title->readonly=$readonly;
-        $title->name="ag_title";
-        $title->value=$this->ag_title;
-        $title->size=60;
+               // title
+               $title = new IText();
+               $title->readonly = $readonly;
+               $title->name = "ag_title";
+               $title->value = $this->ag_title;
+               $title->size = 60;
 
-        // ag_cal
-        $ag_cal=new ICheckBox('ag_cal');
-        $ag_cal->readonly=$readonly;
-        $ag_cal->name="ag_cal";
+               // ag_cal
+               $ag_cal = new ICheckBox('ag_cal');
+               $ag_cal->readonly = $readonly;
+               $ag_cal->name = "ag_cal";
 
-        if ( $this->ag_cal=='C' )
-            $ag_cal->selected=true;
-        else
-            $ag_cal->selected=false;
+               if ($this->ag_cal == 'C')
+                       $ag_cal->selected = true;
+               else
+                       $ag_cal->selected = false;
 
-        $str_ag_cal=$ag_cal->input();
+               $str_ag_cal = $ag_cal->input();
 
-        // Priority of the ag_priority
-        $ag_priority=new ISelect();
-        $ag_priority->readonly=$readonly;
-        $ag_priority->name="ag_priority";
-        $ag_priority->selected=$this->ag_priority;
-        $ag_priority->value=array(array('value'=>1,'label'=>'Haute'),
-                                  array('value'=>2,'label'=>'Moyenne'),
-                                  array('value'=>3,'label'=>'Basse')
-                                 );
-        $str_ag_priority=$ag_priority->input();
+               // Priority of the ag_priority
+               $ag_priority = new ISelect();
+               $ag_priority->readonly = $readonly;
+               $ag_priority->name = "ag_priority";
+               $ag_priority->selected = $this->ag_priority;
+               $ag_priority->value = array(array('value' => 1, 'label' => 
'Haute'),
+                       array('value' => 2, 'label' => 'Moyenne'),
+                       array('value' => 3, 'label' => 'Basse')
+               );
+               $str_ag_priority = $ag_priority->input();
 
-        // hour of the action (meeting) ag_hour
-        $ag_hour=new IText();
-        $ag_hour->readonly=$readonly;
-        $ag_hour->name="ag_hour";
-        $ag_hour->value=$this->ag_hour;
-        $ag_hour->size=6;
-        $ag_hour->javascript=" onblur=check_hour('ag_hour');";
-        $str_ag_hour=$ag_hour->input();
+               // hour of the action (meeting) ag_hour
+               $ag_hour = new IText();
+               $ag_hour->readonly = $readonly;
+               $ag_hour->name = "ag_hour";
+               $ag_hour->value = $this->ag_hour;
+               $ag_hour->size = 6;
+               $ag_hour->javascript = " onblur=check_hour('ag_hour');";
+               $str_ag_hour = $ag_hour->input();
 
-        // Profile in charged of the action
-        $ag_dest=new ISelect();
-        $ag_dest->readonly=$readonly;
-        $ag_dest->name="ag_dest";
+               // Profile in charged of the action
+               $ag_dest = new ISelect();
+               $ag_dest->readonly = $readonly;
+               $ag_dest->name = "ag_dest";
                // select profile
-        $aAg_dest=$this->db->make_array("select  p_id as value, ".
-                                    "p_name as label ".
-                                    " from profile order by 2");
+               $aAg_dest = $this->db->make_array("select  p_id as value, " .
+                               "p_name as label " .
+                               " from profile order by 2");
 
-        $aAg_dest[]=array('value'=>0,'label'=>'Public');
-        $ag_dest->value=$aAg_dest;
-        $ag_dest->selected=$this->ag_dest;
-        $str_ag_dest=$ag_dest->input();
+               $aAg_dest[] = array('value' => 0, 'label' => 'Public');
+               $ag_dest->value = $aAg_dest;
+               $ag_dest->selected = $this->ag_dest;
+               $str_ag_dest = $ag_dest->input();
 
-        // ag_ref
-        // Always false for update
-        $ag_ref=new IText();
-        $ag_ref->readonly=$upd;
-        $ag_ref->name="ag_ref";
-        $ag_ref->value=sql_string($this->ag_ref);
-        $client_label=new ISpan();
+               // ag_ref
+               // Always false for update
+               $ag_ref = new IText();
+               $ag_ref->readonly = $upd;
+               $ag_ref->name = "ag_ref";
+               $ag_ref->value = sql_string($this->ag_ref);
+               $client_label = new ISpan();
 
-        /* Add button */
-        $f_add_button=new IButton('add_card');
-        $f_add_button->label=_('Créer une nouvelle fiche');
-        $f_add_button->set_attribute('ipopup','ipop_newcard');
-        $filter=$this->db->make_list('select fd_id from fiche_def ');
-        $f_add_button->set_attribute('filter',$filter);
+               /* Add button */
+               $f_add_button = new IButton('add_card');
+               $f_add_button->label = _('Créer une nouvelle fiche');
+               $f_add_button->set_attribute('ipopup', 'ipop_newcard');
+               $filter = $this->db->make_list('select fd_id from fiche_def ');
+               $f_add_button->set_attribute('filter', $filter);
 
-        $f_add_button->javascript=" select_card_type(this);";
-        $str_add_button=$f_add_button->input();
+               $f_add_button->javascript = " select_card_type(this);";
+               $str_add_button = $f_add_button->input();
 
-        // f_id_dest sender
-        if ( $this->qcode_dest != NOTFOUND && strlen(trim($this->qcode_dest)) 
!= 0)
-        {
-            $tiers=new Fiche($this->db);
-            $tiers->get_by_qcode($this->qcode_dest);
-            $qcode_dest_label=$tiers->strAttribut(1);
-            $this->f_id_dest=$tiers->id;
-        }
-        else
-        {
-            $qcode_dest_label=($this->f_id_dest==0 || 
trim($this->qcode_dest)=="")?'Interne ':'Error';
-        }
+               // f_id_dest sender
+               if ($this->qcode_dest != NOTFOUND && 
strlen(trim($this->qcode_dest)) != 0)
+               {
+                       $tiers = new Fiche($this->db);
+                       $tiers->get_by_qcode($this->qcode_dest);
+                       $qcode_dest_label = $tiers->strAttribut(1);
+                       $this->f_id_dest = $tiers->id;
+               }
+               else
+               {
+                       $qcode_dest_label = ($this->f_id_dest == 0 || 
trim($this->qcode_dest) == "") ? 'Interne ' : 'Error';
+               }
 
-        $h_ag_id=new IHidden();
-        // if concerns another action : show the link otherwise nothing
-        $lag_ref_ag_id=" 00 / 00 ";
+               $h_ag_id = new IHidden();
+               // if concerns another action : show the link otherwise nothing
+               $lag_ref_ag_id = " 00 / 00 ";
 
-        if ( $this->ag_ref_ag_id != 0 )
-        {
-            $supl_hidden='';
-            if( isset($_REQUEST['sc']))
-                $supl_hidden.='&sc='.$_REQUEST['sc'];
-            if( isset($_REQUEST['f_id']))
-                $supl_hidden.='&f_id='.$_REQUEST['f_id'];
-            if( isset($_REQUEST['sb']))
-                $supl_hidden.='&sb='.$_REQUEST['sb'];
+               if ($this->ag_ref_ag_id != 0)
+               {
+                       $supl_hidden = '';
+                       if (isset($_REQUEST['sc']))
+                               $supl_hidden.='&sc=' . $_REQUEST['sc'];
+                       if (isset($_REQUEST['f_id']))
+                               $supl_hidden.='&f_id=' . $_REQUEST['f_id'];
+                       if (isset($_REQUEST['sb']))
+                               $supl_hidden.='&sb=' . $_REQUEST['sb'];
 
-            $lag_ref_ag_id='<a class="line" 
href="?ac='.$_REQUEST['ac'].$supl_hidden.'&sa=detail&ag_id='.
-                           $this->ag_ref_ag_id.'&'.dossier::get().'">'.
-                               $this->db->get_value("select ag_ref from 
action_gestion where ag_id=$1",array($this->ag_ref_ag_id)).
-                               "</A>";
-        }
-        // sender
-        $w=new ICard();
-        $w->readonly=$readonly;
-        $w->jrn=0;
-        $w->name='qcode_dest';
-        $w->value=($this->f_id_dest != 0)?$this->qcode_dest:"";
-        $w->label="";
-        $list_recipient=$this->db->make_list('select fd_id from fiche_def 
where frd_id in (14,25,8,9,16)');
-        $w->extra=$list_recipient;
-        $w->set_attribute('typecard',$list_recipient);
-        $w->set_dblclick("fill_ipopcard(this);");
-        $w->set_attribute('ipopup','ipopcard');
+                       $lag_ref_ag_id = '<a class="line" href="?ac=' . 
$_REQUEST['ac'] . $supl_hidden . '&sa=detail&ag_id=' .
+                                       $this->ag_ref_ag_id . '&' . 
dossier::get() . '">' .
+                                       $this->db->get_value("select ag_ref 
from action_gestion where ag_id=$1", array($this->ag_ref_ag_id)) .
+                                       "</A>";
+               }
+               // sender
+               $w = new ICard();
+               $w->readonly = $readonly;
+               $w->jrn = 0;
+               $w->name = 'qcode_dest';
+               $w->value = ($this->f_id_dest != 0) ? $this->qcode_dest : "";
+               $w->label = "";
+               $list_recipient = $this->db->make_list('select fd_id from 
fiche_def where frd_id in (14,25,8,9,16)');
+               $w->extra = $list_recipient;
+               $w->set_attribute('typecard', $list_recipient);
+               $w->set_dblclick("fill_ipopcard(this);");
+               $w->set_attribute('ipopup', 'ipopcard');
 
-        // name of the field to update with the name of the card
-        $w->set_attribute('label','qcode_dest_label');
-        // name of the field to update with the name of the card
-        $w->set_attribute('typecard',$w->extra);
-        $w->set_function('fill_data');
-        $w->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ',
-                               $w->name);
+               // name of the field to update with the name of the card
+               $w->set_attribute('label', 'qcode_dest_label');
+               // name of the field to update with the name of the card
+               $w->set_attribute('typecard', $w->extra);
+               $w->set_function('fill_data');
+               $w->javascript = sprintf(' 
onchange="fill_data_onchange(\'%s\');" ', $w->name);
 
-        $sp=new ISpan();
-        $sp->name='qcode_dest_label';
-        $sp->value=$qcode_dest_label;
+               $sp = new ISpan();
+               $sp->name = 'qcode_dest_label';
+               $sp->value = $qcode_dest_label;
 
-        // contact
-        $ag_contact=new ICard();
-        $ag_contact->readonly=$readonly;
-        $ag_contact->jrn=0;
-        $ag_contact->name='ag_contact';
-        $ag_contact->value='';
-        $ag_contact->set_attribute('ipopup','ipopcard');
+               // contact
+               $ag_contact = new ICard();
+               $ag_contact->readonly = $readonly;
+               $ag_contact->jrn = 0;
+               $ag_contact->name = 'ag_contact';
+               $ag_contact->value = '';
+               $ag_contact->set_attribute('ipopup', 'ipopcard');
 
-        if( $this->ag_contact != 0 )
-        {
-            $contact=new Fiche($this->db,$this->ag_contact);
-            $ag_contact->value=$contact->get_quick_code();
-        }
+               if ($this->ag_contact != 0)
+               {
+                       $contact = new Fiche($this->db, $this->ag_contact);
+                       $ag_contact->value = $contact->get_quick_code();
+               }
 
-        $ag_contact->label="";
+               $ag_contact->label = "";
 
-        $list_contact=$this->db->make_list('select fd_id from fiche_def where 
frd_id=16');
-        $ag_contact->extra=$list_contact;
+               $list_contact = $this->db->make_list('select fd_id from 
fiche_def where frd_id=16');
+               $ag_contact->extra = $list_contact;
 
-        $ag_contact->set_dblclick("fill_ipopcard(this);");
-        // name of the field to update with the name of the card
-        $ag_contact->set_attribute('label','ag_contact_label');
-        // name of the field to update with the name of the card
-        $ag_contact->set_attribute('typecard',$list_contact);
-        $ag_contact->set_function('fill_data');
-        $ag_contact->javascript=sprintf(' 
onchange="fill_data_onchange(\'%s\');" ',
-                                        $ag_contact->name);
+               $ag_contact->set_dblclick("fill_ipopcard(this);");
+               // name of the field to update with the name of the card
+               $ag_contact->set_attribute('label', 'ag_contact_label');
+               // name of the field to update with the name of the card
+               $ag_contact->set_attribute('typecard', $list_contact);
+               $ag_contact->set_function('fill_data');
+               $ag_contact->javascript = sprintf(' 
onchange="fill_data_onchange(\'%s\');" ', $ag_contact->name);
 
-        $spcontact=new ISpan();
-        $spcontact->name='ag_contact_label';
-        $spcontact->value='';
-        $fiche_contact=new Fiche($this->db);
-        $fiche_contact->get_by_qcode($this->ag_contact);
-        if ( $fiche_contact->id != 0 )
-        {
-            $spcontact->value=$fiche_contact->strAttribut(ATTR_DEF_NAME);
-        }
+               $spcontact = new ISpan();
+               $spcontact->name = 'ag_contact_label';
+               $spcontact->value = '';
+               $fiche_contact = new Fiche($this->db);
+               $fiche_contact->get_by_qcode($this->ag_contact);
+               if ($fiche_contact->id != 0)
+               {
+                       $spcontact->value = 
$fiche_contact->strAttribut(ATTR_DEF_NAME);
+               }
 
 
-        $h_agrefid=new IHidden();
-        $str_ag_ref="<b>".(($this->ag_ref != "")?$this->ag_ref:" Nouveau 
")."</b>";
-        // Preparing the return string
-        $r="";
+               $h_agrefid = new IHidden();
+               $str_ag_ref = "<b>" . (($this->ag_ref != "") ? $this->ag_ref : 
" Nouveau ") . "</b>";
+               // Preparing the return string
+               $r = "";
 
-        /* for new files */
-        $upload=new IFile();
-        $upload->name="file_upload[]";
-        $upload->value="";
-        $aAttachedFile=$this->db->get_array('select 
d_id,d_filename,d_mimetype,'.
-                                            '\'show_document.php?'.
-                                            Dossier::get().'&d_id=\'||d_id as 
link'.
-                                                ' from document where 
ag_id=$1',
-                                                array($this->ag_id));
-        /* create the select for document */
-        $aDocMod=new ISelect();
-        $aDocMod->name='doc_mod';
-        $aDocMod->value=$this->db->make_array('select md_id,dt_value||\' : 
\'||md_name as md_name'.
-                                              ' from document_modele join 
document_type on (md_type=dt_id)'.
-                                              ' order by md_name');
-        $str_select_doc=$aDocMod->input();
-        /* if no document then do not show the generate button */
-        if ( empty($aDocMod->value) )
-            $str_submit_generate="";
-        else
-            $str_submit_generate=HtmlInput::submit("generate",_("Génére le 
document"));
+               /* for new files */
+               $upload = new IFile();
+               $upload->name = "file_upload[]";
+               $upload->value = "";
+               $aAttachedFile = $this->db->get_array('select 
d_id,d_filename,d_mimetype,' .
+                               '\'show_document.php?' .
+                               Dossier::get() . '&d_id=\'||d_id as link' .
+                               ' from document where ag_id=$1', 
array($this->ag_id));
+               /* create the select for document */
+               $aDocMod = new ISelect();
+               $aDocMod->name = 'doc_mod';
+               $aDocMod->value = $this->db->make_array('select 
md_id,dt_value||\' : \'||md_name as md_name' .
+                               ' from document_modele join document_type on 
(md_type=dt_id)' .
+                               ' order by md_name');
+               $str_select_doc = $aDocMod->input();
+               /* if no document then do not show the generate button */
+               if (empty($aDocMod->value))
+                       $str_submit_generate = "";
+               else
+                       $str_submit_generate = HtmlInput::submit("generate", 
_("Génére le document"));
 
-        $ag_id=$this->ag_id;
+               $ag_id = $this->ag_id;
 
-        /* fid = Icard  */
-        $icard=new ICard();
-        $icard->jrn=0;
-        $icard->table=0;
-        $icard->extra2='QuickCode';
-        $icard->noadd="no";
-        $icard->extra='all';
+               /* fid = Icard  */
+               $icard = new ICard();
+               $icard->jrn = 0;
+               $icard->table = 0;
+               $icard->extra2 = 'QuickCode';
+               $icard->noadd = "no";
+               $icard->extra = 'all';
 
-        /* Text desc  */
-        $text=new IText();
-        $num=new INum();
+               /* Text desc  */
+               $text = new IText();
+               $num = new INum();
 
-        /* TVA */
-        $itva=new ITva_Popup($this->db);
-        $itva->in_table=true;
+               /* TVA */
+               $itva = new ITva_Popup($this->db);
+               $itva->in_table = true;
 
-        /* create aArticle for the detail section */
-        for ($i=0;$i< MAX_ARTICLE;$i++)
-        {
-            /* fid = Icard  */
-            $icard=new ICard();
-            $icard->jrn=0;
-            $icard->table=0;
-            $icard->noadd="no";
-            $icard->extra='all';
-            $icard->name="e_march".$i;
-            
$tmp_ad=(isset($this->aAction_detail[$i]))?$this->aAction_detail[$i]:false;
-            $icard->value='';
-            if ( $tmp_ad )
-            {
-                $march=new Fiche($this->db);
-                $f=$tmp_ad->get_parameter('qcode');
-                if ( $f != 0 )
-                {
-                    $march->id=$f;
-                    $icard->value=$march->get_quick_code();
-                }
-            }
-            $icard->set_dblclick("fill_ipopcard(this);");
-            // name of the field to update with the name of the card
-            $icard->set_attribute('label',"e_march".$i."_label");
-            // name of the field to update with the name of the card
-            $icard->set_attribute('typecard',$icard->extra);
-            $icard->set_attribute('ipopup','ipopcard');
-            $icard->set_function('fill_data');
-            $icard->javascript=sprintf(' 
onchange="fill_data_onchange(\'%s\');" ',
-                                       $icard->name);
+               /* create aArticle for the detail section */
+               for ($i = 0; $i < MAX_ARTICLE; $i++)
+               {
+                       /* fid = Icard  */
+                       $icard = new ICard();
+                       $icard->jrn = 0;
+                       $icard->table = 0;
+                       $icard->noadd = "no";
+                       $icard->extra = 'all';
+                       $icard->name = "e_march" . $i;
+                       $tmp_ad = (isset($this->aAction_detail[$i])) ? 
$this->aAction_detail[$i] : false;
+                       $icard->value = '';
+                       if ($tmp_ad)
+                       {
+                               $march = new Fiche($this->db);
+                               $f = $tmp_ad->get_parameter('qcode');
+                               if ($f != 0)
+                               {
+                                       $march->id = $f;
+                                       $icard->value = 
$march->get_quick_code();
+                               }
+                       }
+                       $icard->set_dblclick("fill_ipopcard(this);");
+                       // name of the field to update with the name of the card
+                       $icard->set_attribute('label', "e_march" . $i . 
"_label");
+                       // name of the field to update with the name of the card
+                       $icard->set_attribute('typecard', $icard->extra);
+                       $icard->set_attribute('ipopup', 'ipopcard');
+                       $icard->set_function('fill_data');
+                       $icard->javascript = sprintf(' 
onchange="fill_data_onchange(\'%s\');" ', $icard->name);
 
-            $aArticle[$i]['fid']=$icard->search().$icard->input();
+                       $aArticle[$i]['fid'] = $icard->search() . 
$icard->input();
 
-            $text->javascript=' 
onchange="clean_tva('.$i.');compute_ledger('.$i.')"';
-            $text->name="e_march".$i."_label";
-            $text->size=40;
-            $text->value=($tmp_ad)?$tmp_ad->get_parameter('text'):"";
-            $aArticle[$i]['desc']=$text->input();
+                       $text->javascript = ' onchange="clean_tva(' . $i . 
');compute_ledger(' . $i . ')"';
+                       $text->name = "e_march" . $i . "_label";
+                       $text->size = 40;
+                       $text->value = ($tmp_ad) ? 
$tmp_ad->get_parameter('text') : "";
+                       $aArticle[$i]['desc'] = $text->input();
 
-            $num->javascript=' 
onchange="format_number(this);clean_tva('.$i.');compute_ledger('.$i.')"';
-            $num->name="e_march".$i."_price";
-            $num->size=8;
-            $num->value=($tmp_ad)?$tmp_ad->get_parameter('price_unit'):0;
-            $aArticle[$i]['pu']=$num->input();
+                       $num->javascript = ' 
onchange="format_number(this);clean_tva(' . $i . ');compute_ledger(' . $i . 
')"';
+                       $num->name = "e_march" . $i . "_price";
+                       $num->size = 8;
+                       $num->value = ($tmp_ad) ? 
$tmp_ad->get_parameter('price_unit') : 0;
+                       $aArticle[$i]['pu'] = $num->input();
 
-            $num->name="e_quant".$i;
-            $num->size=8;
-            $num->value=($tmp_ad)?$tmp_ad->get_parameter('quantity'):0;
-            $aArticle[$i]['quant']=$num->input();
+                       $num->name = "e_quant" . $i;
+                       $num->size = 8;
+                       $num->value = ($tmp_ad) ? 
$tmp_ad->get_parameter('quantity') : 0;
+                       $aArticle[$i]['quant'] = $num->input();
 
-            $itva->name='e_march'.$i.'_tva_id';
-            $itva->value=($tmp_ad)?$tmp_ad->get_parameter('tva_id'):0;
-            $itva->javascript=' 
onchange="format_number(this);clean_tva('.$i.');compute_ledger('.$i.')"';
-            $itva->set_attribute('compute',$i);
+                       $itva->name = 'e_march' . $i . '_tva_id';
+                       $itva->value = ($tmp_ad) ? 
$tmp_ad->get_parameter('tva_id') : 0;
+                       $itva->javascript = ' 
onchange="format_number(this);clean_tva(' . $i . ');compute_ledger(' . $i . 
')"';
+                       $itva->set_attribute('compute', $i);
 
-            $aArticle[$i]['tvaid']=$itva->input();
+                       $aArticle[$i]['tvaid'] = $itva->input();
 
-            $num->name="e_march".$i."_tva_amount";
-            $num->value=($tmp_ad)?$tmp_ad->get_parameter('tva_amount'):0;
-            $num->javascript=' onchange="compute_ledger('.$i.')"';
-            $num->size=8;
-            $aArticle[$i]['tva']=$num->input();
+                       $num->name = "e_march" . $i . "_tva_amount";
+                       $num->value = ($tmp_ad) ? 
$tmp_ad->get_parameter('tva_amount') : 0;
+                       $num->javascript = ' onchange="compute_ledger(' . $i . 
')"';
+                       $num->size = 8;
+                       $aArticle[$i]['tva'] = $num->input();
 
-            $num->name="tvac_march".$i;
-            $num->value=($tmp_ad)?$tmp_ad->get_parameter('total'):0;
-            $num->size=8;
-            $aArticle[$i]['tvac']=$num->input();
+                       $num->name = "tvac_march" . $i;
+                       $num->value = ($tmp_ad) ? 
$tmp_ad->get_parameter('total') : 0;
+                       $num->size = 8;
+                       $aArticle[$i]['tvac'] = $num->input();
 
-            $aArticle[$i]['hidden_htva']=HtmlInput::hidden('htva_march'.$i,0);
-            $aArticle[$i]['hidden_tva']=HtmlInput::hidden('tva_march'.$i,0);
-            $aArticle[$i]['ad_id']=    
($tmp_ad)?HtmlInput::hidden('ad_id'.$i,$tmp_ad->get_parameter('id')):HtmlInput::hidden('ad_id'.$i,0);
+                       $aArticle[$i]['hidden_htva'] = 
HtmlInput::hidden('htva_march' . $i, 0);
+                       $aArticle[$i]['hidden_tva'] = 
HtmlInput::hidden('tva_march' . $i, 0);
+                       $aArticle[$i]['ad_id'] = ($tmp_ad) ? 
HtmlInput::hidden('ad_id' . $i, $tmp_ad->get_parameter('id')) : 
HtmlInput::hidden('ad_id' . $i, 0);
+               }
 
+               /* Add the needed hidden values */
+               $r.=dossier::hidden();
 
-        }
+               /* 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';
+               $content = ob_get_contents();
+               ob_end_clean();
+               $r.=$content;
 
-        /* Add the needed hidden values */
-        $r.=dossier::hidden();
+               //hidden
+               $r.="<p>";
+               $r.=$h2->input();
+               $r.=$h_agrefid->input("ag_ref_ag_id", $this->ag_ref_ag_id);
+               $r.=$h_ag_id->input('ag_id', $this->ag_id);
+               $hidden2 = new IHidden();
+               $r.=$hidden2->input('f_id_dest', $this->f_id_dest);
+               $r.="</p>";
 
-        /* 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';
-        $content=ob_get_contents();
-        ob_end_clean();
-        $r.=$content;
-
-        //hidden
-        $r.="<p>";
-        $r.=$h2->input();
-        $r.=$h_agrefid->input("ag_ref_ag_id",$this->ag_ref_ag_id);
-        $r.=$h_ag_id->input('ag_id',$this->ag_id);
-        $hidden2=new IHidden();
-        $r.=$hidden2->input('f_id_dest',$this->f_id_dest);
-        $r.="</p>";
-
-        // show the list of the concern operation
-        if ( $this->db->count_sql('select * from action_gestion where 
ag_ref_ag_id!=0 and ag_ref_ag_id='.$this->ag_id.
-                                  " limit 2") > 0 )
-        {
-            $sql=sprintf(" and ag_id in (select action_get_tree from 
comptaproc.action_get_tree(%s)) ",$this->ag_id);
-            $r.=$this->myList($p_base,"",$sql);
-        }
+               // show the list of the concern operation
+               if ($this->db->count_sql('select * from action_gestion where 
ag_ref_ag_id!=0 and ag_ref_ag_id=' . $this->ag_id .
+                                               " limit 2") > 0)
+               {
+                       $sql = sprintf(" and ag_id in (select action_get_tree 
from comptaproc.action_get_tree(%s)) ", $this->ag_id);
+                       $r.=$this->myList($p_base, "", $sql);
+               }
                // New referecne
                ob_start();
-        require_once 'template/action-reference.php';
-        $content=ob_get_contents();
-        ob_end_clean();
+               require_once 'template/action-reference.php';
+               $content = ob_get_contents();
+               ob_end_clean();
 
                $r.=$content;
-        return $r;
+               return $r;
+       }
 
-    }
-    //----------------------------------------------------------------------
-    /*!\brief This function shows the detail of an action thanks the ag_id
-     */
-    function get()
-    {
-        $sql="select ag_id,to_char (ag_timestamp,'DD.MM.YYYY') as 
ag_timestamp,".
-             " f_id_dest,ag_title,ag_ref,d_id,ag_type,ag_state,  ".
-             " ag_ref_ag_id, ag_dest, ag_hour, ag_priority, 
ag_cal,ag_contact,to_char (ag_remind_date,'DD.MM.YYYY') as ag_remind_date ".
-             " from action_gestion left join document using (ag_id) where 
ag_id=".$this->ag_id;
-        $r=$this->db->exec_sql($sql);
-        $row=Database::fetch_all($r);
-        if ( $row==false) return;
-        $this->ag_timestamp=$row[0]['ag_timestamp'];
-        $this->ag_contact=$row[0]['ag_contact'];
-        $this->f_id_dest=$row[0]['f_id_dest'];
-        $this->ag_title=$row[0]['ag_title'];
-        $this->ag_type=$row[0]['ag_type'];
-        $this->ag_ref=$row[0]['ag_ref'];
-        $this->ag_state=$row[0]['ag_state'];
-        $this->ag_ref_ag_id=$row[0]['ag_ref_ag_id'];
-        $this->d_id=$row[0]['d_id'];
-        $this->ag_dest=$row[0]['ag_dest'];
-        $this->ag_hour=$row[0]['ag_hour'];
-        $this->ag_priority=$row[0]['ag_priority'];
-        $this->ag_cal=$row[0]['ag_cal'];
-        $this->ag_remind_date=$row[0]['ag_remind_date'];
+       //----------------------------------------------------------------------
+       /* !\brief This function shows the detail of an action thanks the ag_id
+        */
+       function get()
+       {
+               $sql = "select ag_id,to_char (ag_timestamp,'DD.MM.YYYY') as 
ag_timestamp," .
+                               " 
f_id_dest,ag_title,ag_ref,d_id,ag_type,ag_state,  " .
+                               " ag_ref_ag_id, ag_dest, ag_hour, ag_priority, 
ag_cal,ag_contact,to_char (ag_remind_date,'DD.MM.YYYY') as ag_remind_date " .
+                               " from action_gestion left join document using 
(ag_id) where ag_id=" . $this->ag_id;
+               $r = $this->db->exec_sql($sql);
+               $row = Database::fetch_all($r);
+               if ($row == false)
+                       return;
+               $this->ag_timestamp = $row[0]['ag_timestamp'];
+               $this->ag_contact = $row[0]['ag_contact'];
+               $this->f_id_dest = $row[0]['f_id_dest'];
+               $this->ag_title = $row[0]['ag_title'];
+               $this->ag_type = $row[0]['ag_type'];
+               $this->ag_ref = $row[0]['ag_ref'];
+               $this->ag_state = $row[0]['ag_state'];
+               $this->ag_ref_ag_id = $row[0]['ag_ref_ag_id'];
+               $this->d_id = $row[0]['d_id'];
+               $this->ag_dest = $row[0]['ag_dest'];
+               $this->ag_hour = $row[0]['ag_hour'];
+               $this->ag_priority = $row[0]['ag_priority'];
+               $this->ag_cal = $row[0]['ag_cal'];
+               $this->ag_remind_date = $row[0]['ag_remind_date'];
 
-        $action_detail=new Follow_Up_Detail($this->db);
-        $action_detail->set_parameter('ag_id',$this->ag_id);
-        $this->aAction_detail=$action_detail->load_all();
+               $action_detail = new Follow_Up_Detail($this->db);
+               $action_detail->set_parameter('ag_id', $this->ag_id);
+               $this->aAction_detail = $action_detail->load_all();
 
 
-        // if there is no document set 0 to d_id
-        if ( $this->d_id == "" )
-            $this->d_id=0;
-        // if there is a document fill the object
-        if ($this->d_id != 0 )
-        {
-            $this->state=$row['0']['ag_state'];
-            $this->ag_state=$row[0]['ag_state'];
-        }
-        $this->dt_id=$this->ag_type;
-        $aexp=new Fiche($this->db,$this->f_id_dest);
-        $this->qcode_dest=$aexp->strAttribut(ATTR_DEF_QUICKCODE);
+               // if there is no document set 0 to d_id
+               if ($this->d_id == "")
+                       $this->d_id = 0;
+               // if there is a document fill the object
+               if ($this->d_id != 0)
+               {
+                       $this->state = $row['0']['ag_state'];
+                       $this->ag_state = $row[0]['ag_state'];
+               }
+               $this->dt_id = $this->ag_type;
+               $aexp = new Fiche($this->db, $this->f_id_dest);
+               $this->qcode_dest = $aexp->strAttribut(ATTR_DEF_QUICKCODE);
+       }
 
-    }
+       /* !
+        * \brief Save the document and propose to save the generated document 
or
+        *  to upload one, the data are included except the file. Temporary the 
generated
+        * document is save
+        *
+        * \return
+        */
 
-    /*!
-     * \brief Save the document and propose to save the generated document or
-     *  to upload one, the data are included except the file. Temporary the 
generated
-     * document is save
-     *
-     * \return
-     */
-    function save()
-    {
+       function save()
+       {
 
-        // Get The sequence id,
-        $seq_name="seq_doc_type_".$this->dt_id;
-        $str_file="";
-        $add_file='';
+               // Get The sequence id,
+               $seq_name = "seq_doc_type_" . $this->dt_id;
+               $str_file = "";
+               $add_file = '';
 
-        // f_id exp
-        $exp=new Fiche($this->db);
-        $exp->get_by_qcode($this->qcode_dest);
+               // f_id exp
+               $exp = new Fiche($this->db);
+               $exp->get_by_qcode($this->qcode_dest);
 
-        $contact=new Fiche($this->db);
-        $contact->get_by_qcode($this->ag_contact);
+               $contact = new Fiche($this->db);
+               $contact->get_by_qcode($this->ag_contact);
 
-        if ( trim($this->ag_title) == "")
-        {
-            $doc_mod=new document_type($this->db);
-            $doc_mod->dt_id=$this->dt_id;
-            $doc_mod->get();
-            $this->ag_title=$doc_mod->dt_value;
-        }
-        $this->ag_id=$this->db->get_next_seq('action_gestion_ag_id_seq');
+               if (trim($this->ag_title) == "")
+               {
+                       $doc_mod = new document_type($this->db);
+                       $doc_mod->dt_id = $this->dt_id;
+                       $doc_mod->get();
+                       $this->ag_title = $doc_mod->dt_value;
+               }
+               $this->ag_id = 
$this->db->get_next_seq('action_gestion_ag_id_seq');
 
-        // Create the reference
-        $ref=$this->dt_id.'/'.$this->ag_id;
-        $this->ag_ref=$ref;
-        if ( $this->ag_cal=='on')
-            $ag_cal='C';
-        else
-            $ag_cal='I';
-        
$this->ag_ref_ag_id=(strlen(trim($this->ag_ref_ag_id))==0)?0:$this->ag_ref_ag_id;
-        // save into the database
-               if ($this->ag_remind_date != null || $this->ag_remind_date !='')
+               // Create the reference
+               $ref = $this->dt_id . '/' . $this->ag_id;
+               $this->ag_ref = $ref;
+               if ($this->ag_cal == 'on')
+                       $ag_cal = 'C';
+               else
+                       $ag_cal = 'I';
+               $this->ag_ref_ag_id = (strlen(trim($this->ag_ref_ag_id)) == 0) 
? 0 : $this->ag_ref_ag_id;
+               // save into the database
+               if ($this->ag_remind_date != null || $this->ag_remind_date != 
'')
                {
-                       $sql="insert into action_gestion".
-             
"(ag_id,ag_timestamp,ag_type,ag_title,f_id_dest,ag_ref,ag_ref_ag_id, ag_dest, ".
-             " ag_hour, 
ag_priority,ag_cal,ag_owner,ag_contact,ag_state,ag_remind_date) ".
-             " values 
($1,to_date($2,'DD.MM.YYYY'),$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,to_date($15,'DD.MM.YYYY'))";
-               } else
+                       $sql = "insert into action_gestion" .
+                                       
"(ag_id,ag_timestamp,ag_type,ag_title,f_id_dest,ag_ref,ag_ref_ag_id, ag_dest, " 
.
+                                       " ag_hour, 
ag_priority,ag_cal,ag_owner,ag_contact,ag_state,ag_remind_date) " .
+                                       " values 
($1,to_date($2,'DD.MM.YYYY'),$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,to_date($15,'DD.MM.YYYY'))";
+               }
+               else
                {
-                       $this->ag_remind_date=null;
-                       $sql="insert into action_gestion".
-             
"(ag_id,ag_timestamp,ag_type,ag_title,f_id_dest,ag_ref,ag_ref_ag_id, ag_dest, ".
-             " ag_hour, 
ag_priority,ag_cal,ag_owner,ag_contact,ag_state,ag_remind_date) ".
-             " values 
($1,to_date($2,'DD.MM.YYYY'),$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)";
+                       $this->ag_remind_date = null;
+                       $sql = "insert into action_gestion" .
+                                       
"(ag_id,ag_timestamp,ag_type,ag_title,f_id_dest,ag_ref,ag_ref_ag_id, ag_dest, " 
.
+                                       " ag_hour, 
ag_priority,ag_cal,ag_owner,ag_contact,ag_state,ag_remind_date) " .
+                                       " values 
($1,to_date($2,'DD.MM.YYYY'),$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)";
+               }
+               if ($this->ag_dest == 0)
+               {
+                       $this->ag_dest = null;
+               }
+               $this->db->exec_sql($sql, array($this->ag_id, /* 1 */
+                       $this->ag_timestamp, /* 2 */
+                       $this->dt_id, /* 3 */
+                       $this->ag_title, /* 4 */
+                       $exp->id, /* 5 */
+                       $ref, /* 7 */
+                       $this->ag_ref_ag_id, /* 8 */
+                       $this->ag_dest, /* 9 */
+                       $this->ag_hour, /* 10 */
+                       $this->ag_priority, /* 11 */
+                       $ag_cal, /* 12 */
+                       $_SESSION['g_user'], /* 13 */
+                       $contact->id, /* 14 */
+                       $this->ag_state, /* 15 */
+                       $this->ag_remind_date
+                               )
+               );
 
+               /* insert also the details */
+               for ($i = 0; $i < MAX_ARTICLE; $i++)
+               {
+                       $act = new Follow_Up_Detail($this->db);
+                       $act->from_array($_POST, $i);
+                       $act->ag_id = $this->ag_id;
+                       $act->save();
                }
-               if ( $this->ag_dest==0) {$this->ag_dest=null;}
-        $this->db->exec_sql($sql,array($this->ag_id, /* 1 */
-                                       $this->ag_timestamp, /* 2 */
-                                       $this->dt_id,   /* 3 */
-                                       $this->ag_title, /* 4 */
-                                       $exp->id,         /* 5 */
-                                       $ref,             /* 7 */
-                                       $this->ag_ref_ag_id,  /* 8 */
-                                       $this->ag_dest,    /* 9 */
-                                       $this->ag_hour,    /* 10 */
-                                       $this->ag_priority,   /* 11 */
-                                       $ag_cal,           /* 12 */
-                                       $_SESSION['g_user'], /* 13 */
-                                       $contact->id,     /* 14 */
-                                       $this->ag_state,          /* 15 */
-                                                                          
$this->ag_remind_date
-                                      )
-                           );
 
-        /* insert also the details */
-        for ( $i = 0; $i < MAX_ARTICLE;$i++)
-        {
-            $act=new Follow_Up_Detail($this->db);
-            $act->from_array($_POST,$i);
-            $act->ag_id=$this->ag_id;
-            $act->save();
-        }
-
-        /* Upload the documents */
-        $doc=new Document($this->db);
-        $doc->Upload($this->ag_id);
-               if ( trim($this->ag_comment)!='') {
+               /* Upload the documents */
+               $doc = new Document($this->db);
+               $doc->Upload($this->ag_id);
+               if (trim($this->ag_comment) != '')
+               {
                        $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));
+                                       , 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
-     *\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%'))
-     * \return string containing html code
-     */
-    function myList($p_base,$p_filter="",$p_search="")
-    {
-        $str_dossier=dossier::get();
-        // for the sort
-        
$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');
-               $table->add('Date Limite',$url,'order by ag_remind_date 
asc','order by ag_remind_date  desc','ra','rd');
-               $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');
-               $table->add('Concerne',$url,'order by ag_ref_ag_id asc','order 
by ag_ref_ag_id desc','ca','cd');
+       /* ! myList($p_filter="")
+        * \brief 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%'))
+        * \return string containing html code
+        */
 
-               $ord=(! isset($_GET['ord']))?"dd":$_GET['ord'];
-               $sort=$table->get_sql_order($ord);
+       function myList($p_base, $p_filter = "", $p_search = "")
+       {
+               $str_dossier = dossier::get();
+               // for the sort
+               $url = HtmlInput::get_to_string(array("qcode", "ag_dest_query", 
"query", "tdoc", "date_start", "date_end", "see_all", "all_action")) . 
$str_dossier . '&' . $p_base;
 
-        if ( strlen(trim($p_filter)) != 0 )
-            $p_filter_doc=" dt_id in ( $p_filter )";
-        else
-            $p_filter_doc=" 1=1 ";
+               $table = new Sort_Table();
+               $table->add('Date', $url, 'order by ag_timestamp asc', 'order 
by ag_timestamp desc', 'da', 'dd');
+               $table->add('Date Limite', $url, 'order by ag_remind_date asc', 
'order by ag_remind_date  desc', 'ra', 'rd');
+               $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');
+               $table->add('Concerne', $url, 'order by ag_ref_ag_id asc', 
'order by ag_ref_ag_id desc', 'ca', 'cd');
 
-        $sql="
+               $ord = (!isset($_GET['ord'])) ? "dd" : $_GET['ord'];
+               $sort = $table->get_sql_order($ord);
+
+               if (strlen(trim($p_filter)) != 0)
+                       $p_filter_doc = " dt_id in ( $p_filter )";
+               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,
                         ag_ref_ag_id,
@@ -709,605 +722,616 @@
              from action_gestion
              join document_type on (ag_type=dt_id)
              where $p_filter_doc $p_search $sort";
-        $max_line=$this->db->count_sql($sql);
-        $step=$_SESSION['g_pagesize'];
-        $page=(isset($_GET['offset']))?$_GET['page']:1;
-        
$offset=(isset($_GET['offset']))?Database::escape_string($_GET['offset']):0;
-        if ( $step != -1 ) $limit=" LIMIT $step OFFSET $offset ";
-        else $limit='';
-        $bar=jrn_navigation_bar($offset,$max_line,$step,$page);
+               $max_line = $this->db->count_sql($sql);
+               $step = $_SESSION['g_pagesize'];
+               $page = (isset($_GET['offset'])) ? $_GET['page'] : 1;
+               $offset = (isset($_GET['offset'])) ? 
Database::escape_string($_GET['offset']) : 0;
+               if ($step != -1)
+                       $limit = " LIMIT $step OFFSET $offset ";
+               else
+                       $limit = '';
+               $bar = jrn_navigation_bar($offset, $max_line, $step, $page);
 
-        $Res=$this->db->exec_sql($sql.$limit);
-        $a_row=Database::fetch_all($Res);
+               $Res = $this->db->exec_sql($sql . $limit);
+               $a_row = Database::fetch_all($Res);
 
-        $r="";
-        $r.=$bar;
-        $r.='<table class="document">';
-        $r.="<tr>";
-        $r.='<th>'.$table->get_header(0).'</th>';
-        $r.='<th>'.$table->get_header(1).'</th>';
-        $r.='<th>'.$table->get_header(2).'</th>';
-        $r.='<th>'.$table->get_header(3).'</th>';
-        $r.='<th>'.$table->get_header(4).'</th>';
-        $r.='<th>'.$table->get_header(5).'</th>';
+               $r = "";
+               $r.=$bar;
+               $r.='<table class="document">';
+               $r.="<tr>";
+               $r.='<th>' . $table->get_header(0) . '</th>';
+               $r.='<th>' . $table->get_header(1) . '</th>';
+               $r.='<th>' . $table->get_header(2) . '</th>';
+               $r.='<th>' . $table->get_header(3) . '</th>';
+               $r.='<th>' . $table->get_header(4) . '</th>';
+               $r.='<th>' . $table->get_header(5) . '</th>';
                $r.=th(_("Nbre doc."));
-        $r.='<th>'._('type').'</th>';
+               $r.='<th>' . _('type') . '</th>';
                $r.=th('Etat');
                $r.=th('Priorité');
-        $r.='<th>'.$table->get_header(6).'</th>';
-               if (isset($this->suppress)) {
+               $r.='<th>' . $table->get_header(6) . '</th>';
+               if (isset($this->suppress))
+               {
                        $r.="<th> Suppr. dépendance</th>";
                }
-        $r.="</tr>";
+               $r.="</tr>";
 
 
-        // if there are no records return a message
-        if ( sizeof ($a_row) == 0 or $a_row == false )
-        {
-            $r='<div style="clear:both">';
-            $r.='<hr>Aucun enregistrement trouvé';
-            $r.="</div>";
-            return $r;
+               // if there are no records return a message
+               if (sizeof($a_row) == 0 or $a_row == false)
+               {
+                       $r = '<div style="clear:both">';
+                       $r.='<hr>Aucun enregistrement trouvé';
+                       $r.="</div>";
+                       return $r;
+               }
+               $today = date('d.m.Y');
+               $i = 0;
+               //show the sub_action
+               foreach ($a_row as $row)
+               {
+                       $href = '<A class="document" HREF="do.php' . 
HtmlInput::get_to_string(array("gDossier", "qcode", "ag_dest_query", "query", 
"tdoc", "date_start", "date_end", "see_all", "ac", "all_action")) . "&" . 
$p_base . '&sa=detail&ag_id=' . $row['ag_id'] . '">';
+                       $i++;
+                       $tr = ($i % 2 == 0) ? 'even' : 'odd';
+                       if ($row['ag_priority'] < 2)
+                               $tr = 'priority1';
+                       $st = '';
+                       if ($row['my_date'] == $today)
+                               $st = ' style="font-weight:bold; border:2px 
solid orange;"';
+                       $date_remind = format_date($row['my_remind'], 
'DD.MM.YYYY', 'YYYYMMDD');
+                       $date_today = date('Ymd');
+                       if ($date_remind != "" && $date_remind == $date_today)
+                               $st = ' 
style="font-weight:bold;background:orange"';
+                       if ($date_remind != "" && $date_remind < $date_today)
+                               $st = ' 
style="font-weight:bold;background:#FF0000"';
+                       $r.="<tr class=\"$tr\" $st>";
+                       $r.="<td>" . $href . smaller_date($row['my_date']) . 
'</a>' . "</td>";
+                       $r.="<td>" . $href . smaller_date($row['my_remind']) . 
'</a>' . "</td>";
+                       $r.="<td>" . $href . $row['ag_ref'] . '</a>' . "</td>";
+                       $r.="<td>" . $href . h($row['dest']) . '</a>' . "</td>";
 
-        }
-        $today=date('d.m.Y');
-        $i=0;
-        //show the sub_action
-        foreach ($a_row as $row )
-        {
-            $href='<A class="document" 
HREF="do.php'.HtmlInput::get_to_string(array("gDossier","qcode","ag_dest_query","query","tdoc","date_start","date_end","see_all","ac","all_action"))."&".$p_base.'&sa=detail&ag_id='.$row['ag_id'].'">';
-            $i++;
-            $tr=($i%2==0)?'even':'odd';
-            if ($row['ag_priority'] < 2) $tr='priority1';
-            $st='';
-            if ($row['my_date']==$today) $st=' style="font-weight:bold; 
border:2px solid orange;"';
-                       $date_remind=  format_date($row['my_remind'], 
'DD.MM.YYYY','YYYYMMDD');
-                       $date_today=date('Ymd');
-            if ($date_remind !="" && $date_remind == $date_today) $st=' 
style="font-weight:bold;background:orange"';
-            if ($date_remind !="" && $date_remind < $date_today) $st=' 
style="font-weight:bold;background:#FF0000"';
-            $r.="<tr class=\"$tr\" $st>";
-            $r.="<td>".$href.smaller_date($row['my_date']).'</a>'."</td>";
-            $r.="<td>".$href.smaller_date($row['my_remind']).'</a>'."</td>";
-                       $r.="<td>".$href.$row['ag_ref'].'</a>'."</td>";
-                       $r.="<td>".$href.h($row['dest']).'</a>'."</td>";
+                       // Expediteur
+                       $fexp = new Fiche($this->db);
+                       $fexp->id = $row['f_id_dest'];
+                       $qcode_dest = $fexp->strAttribut(ATTR_DEF_QUICKCODE);
 
-            // Expediteur
-            $fexp=new Fiche($this->db);
-            $fexp->id=$row['f_id_dest'];
-            $qcode_dest=$fexp->strAttribut(ATTR_DEF_QUICKCODE);
+                       $qexp = ($qcode_dest == NOTFOUND) ? "Interne" : 
$qcode_dest;
+                       $jsexp = sprintf("javascript:showfiche('%s')", $qexp);
+                       if ($qexp != 'Interne')
+                       {
+                               $r.="<td>$href" . $qexp . " : " . 
$fexp->getName() . '</a></td>';
+                       }
+                       else
+                               $r.="<td>$href Interne </a></td>";
 
-            $qexp=($qcode_dest==NOTFOUND)?"Interne":$qcode_dest;
-            $jsexp=sprintf("javascript:showfiche('%s')",
-                           $qexp);
-            if ( $qexp != 'Interne' )
-            {
-                $r.="<td>$href".$qexp." : ".$fexp->getName().'</a></td>';
-            }
-            else
-                $r.="<td>$href Interne </a></td>";
+                       $ref = "";
 
-            $ref="";
+                       // show reference
+                       if ($row['ag_ref_ag_id'] != 0)
+                       {
+                               $retSqlStmt = $this->db->exec_sql(
+                                               "select ag_ref from 
action_gestion where ag_id=" . $row['ag_ref_ag_id']);
+                               $retSql = Database::fetch_all($retSqlStmt);
+                               if ($retSql != null)
+                               {
+                                       foreach ($retSql as $line)
+                                       {
+                                               $ref.='<A  href="do.php?' . 
$p_base . '&query=' . $line['ag_ref'] . '&' . $str_dossier . '">' .
+                                                               $line['ag_ref'] 
. "<A>";
+                                       }
+                               }
+                       }
 
-            // show reference
-            if ( $row['ag_ref_ag_id'] != 0 )
-            {
-                $retSqlStmt=$this->db->exec_sql(
-                                "select ag_ref from action_gestion where 
ag_id=".$row['ag_ref_ag_id']);
-                $retSql=Database::fetch_all($retSqlStmt);
-                if ( $retSql != null )
-                {
-                    foreach ($retSql as $line)
-                    {
-                        $ref.='<A  
href="do.php?'.$p_base.'&query='.$line['ag_ref'].'&'.$str_dossier.'">'.
-                              $line['ag_ref']."<A>";
-                    }
-                }
-            }
-
-            $r.='<td>'.$href.
-                h($row['ag_title'])."</A></td>";
-                               if ( $row['cnt_doc'] != 0)
-                               $r.="<td 
style=\"text-align:center\">".$href.h($row['cnt_doc']).'</a>'."</td>";
+                       $r.='<td>' . $href .
+                                       h($row['ag_title']) . "</A></td>";
+                       if ($row['cnt_doc'] != 0)
+                               $r.="<td style=\"text-align:center\">" . $href 
. h($row['cnt_doc']) . '</a>' . "</td>";
                        else
                                $r.="<td ></td>";
 
-            $r.="<td>".$row['dt_value']."</td>";
-           /*
-            * State
-            */
-           switch ( $row['ag_state'] )
-             {
-             case 1:
-               $state='Fermé';
-               break;
-             case 2:
-               $state="A suivre";
-               break;
-             case 3:
-               $state="A faire";
-               break;
-             case 4:
-               $state="Abandonné";
-               break;
-             }
-           $r.=td($state);
-           /*
-            * State
-            */
-           switch ( $row['ag_priority'] )
-             {
-             case 1:
-               $priority='Haute';
-               break;
-             case 2:
-               $priority="Moyenne";
-               break;
-             case 3:
-               $priority="Important";
-               break;
-             }
-           $r.=td($priority);
+                       $r.="<td>" . $row['dt_value'] . "</td>";
+                       /*
+                        * State
+                        */
+                       switch ($row['ag_state'])
+                       {
+                               case 1:
+                                       $state = 'Fermé';
+                                       break;
+                               case 2:
+                                       $state = "A suivre";
+                                       break;
+                               case 3:
+                                       $state = "A faire";
+                                       break;
+                               case 4:
+                                       $state = "Abandonné";
+                                       break;
+                       }
+                       $r.=td($state);
+                       /*
+                        * State
+                        */
+                       switch ($row['ag_priority'])
+                       {
+                               case 1:
+                                       $priority = 'Haute';
+                                       break;
+                               case 2:
+                                       $priority = "Moyenne";
+                                       break;
+                               case 3:
+                                       $priority = "Important";
+                                       break;
+                       }
+                       $r.=td($priority);
 
-            $r.="<td>" . $ref . "</td>";
+                       $r.="<td>" . $ref . "</td>";
                        if (isset($this->suppress))
                        {
                                $ck = new ICheckBox('sup_dep[]');
                                $ck->value = $row['ag_id'];
                                $r.="<td>" . $ck->input() . "</td>";
                        }
-            $r.="</tr>";
+                       $r.="</tr>";
+               }
 
-        }
+               $r.="</table>";
 
-        $r.="</table>";
+               $r.=$bar;
+               //$r.="</div>";
+               return $r;
+       }
 
-        $r.=$bar;
-        //$r.="</div>";
-        return $r;
-    }
-    //----------------------------------------------------------------------
-    /*!\brief Update the data into the database
-     *
-     * \return true on success otherwise false
-     */
-    function Update()
-    {
-        // if ag_id == 0 nothing to do
-        if ( $this->ag_id == 0 ) return ;
-        // retrieve customer
-        // f_id
+       //----------------------------------------------------------------------
+       /* !\brief Update the data into the database
+        *
+        * \return true on success otherwise false
+        */
+       function Update()
+       {
+               // if ag_id == 0 nothing to do
+               if ($this->ag_id == 0)
+                       return;
+               // retrieve customer
+               // f_id
 
-        if ( trim($this->qcode_dest) =="" )
-        {
-            // internal document
-            $this->f_id_dest=0; // internal document
-        }
-        else
-        {
-            $tiers=new Fiche($this->db);
-            if ( $tiers->get_by_qcode($this->qcode_dest) == -1 ) // Error we 
cannot retrieve this qcode
-                return false;
-            else
-                $this->f_id_dest=$tiers->id;
+               if (trim($this->qcode_dest) == "")
+               {
+                       // internal document
+                       $this->f_id_dest = 0; // internal document
+               }
+               else
+               {
+                       $tiers = new Fiche($this->db);
+                       if ($tiers->get_by_qcode($this->qcode_dest) == -1) // 
Error we cannot retrieve this qcode
+                               return false;
+                       else
+                               $this->f_id_dest = $tiers->id;
+               }
+               $contact = new Fiche($this->db);
+               if ($contact->get_by_qcode($this->ag_contact) == -1)
+                       $contact->id = 0;
 
-        }
-        $contact=new Fiche($this->db);
-        if ( $contact->get_by_qcode($this->ag_contact) == -1 )
-            $contact->id=0;
 
-
-        $ref=$this->dt_id.'/'.$this->ag_id;
-        if ( $this->ag_cal == 'on') $ag_cal='C';
-        else $ag_cal='I';
-        $this->ag_ref=$ref;
-               if ( $this->ag_dest==0) {$this->ag_dest=null;}
-               if ( $this->ag_remind_date != null )
+               $ref = $this->dt_id . '/' . $this->ag_id;
+               if ($this->ag_cal == 'on')
+                       $ag_cal = 'C';
+               else
+                       $ag_cal = 'I';
+               $this->ag_ref = $ref;
+               if ($this->ag_dest == 0)
                {
-                       $this->db->exec_sql("update action_gestion set ".
-                                                               " 
ag_timestamp=to_date($1,'DD.MM.YYYY'),".
-                                                               " ag_title=$2,".
-                                                               " ag_type=$3, ".
-                                                               " f_id_dest=$4, 
".
-                                                               " 
ag_ref_ag_id=$5 ,".
-                                                               "ag_state=$6,".
-                                                               " ag_hour = $8 
,".
-                                                               " ag_priority = 
$9 ,".
-                                                               " ag_dest = $10 
, ".
-                                                               " ag_cal = $11 
,".
-                                                               " ag_contact = 
$12, ".
-                                                               " ag_ref = $13, 
".
-                                                               " 
ag_remind_date=to_date($14,'DD.MM.YYYY') ".
-                                                               " where ag_id = 
$7",
-                                                               array (
-                                                                               
$this->ag_timestamp, /* 2 */
-                                                                               
$this->ag_title,     /* 3 */
-                                                                               
$this->dt_id,          /* 4 */
-                                                                               
$this->f_id_dest,     /* 5 */
-                                                                               
$this->ag_ref_ag_id, /* 6 */
-                                                                               
$this->ag_state,     /* 7 */
-                                                                               
$this->ag_id,      /* 8 */
-                                                                               
$this->ag_hour,    /* 9 */
-                                                                               
$this->ag_priority, /* 10 */
-                                                                               
$this->ag_dest,     /* 11 */
-                                                                               
$ag_cal,              /* 12 */
-                                                                               
$contact->id,   /* 13 */
-                                                                               
$this->ag_ref, /* 14 */
-                                                                               
$this->ag_remind_date /*15 */
-                                                                       ));
+                       $this->ag_dest = null;
                }
+               if ($this->ag_remind_date != null)
+               {
+                       $this->db->exec_sql("update action_gestion set " .
+                                       " 
ag_timestamp=to_date($1,'DD.MM.YYYY')," .
+                                       " ag_title=$2," .
+                                       " ag_type=$3, " .
+                                       " f_id_dest=$4, " .
+                                       " ag_ref_ag_id=$5 ," .
+                                       "ag_state=$6," .
+                                       " ag_hour = $8 ," .
+                                       " ag_priority = $9 ," .
+                                       " ag_dest = $10 , " .
+                                       " ag_cal = $11 ," .
+                                       " ag_contact = $12, " .
+                                       " ag_ref = $13, " .
+                                       " 
ag_remind_date=to_date($14,'DD.MM.YYYY') " .
+                                       " where ag_id = $7", array(
+                               $this->ag_timestamp, /* 2 */
+                               $this->ag_title, /* 3 */
+                               $this->dt_id, /* 4 */
+                               $this->f_id_dest, /* 5 */
+                               $this->ag_ref_ag_id, /* 6 */
+                               $this->ag_state, /* 7 */
+                               $this->ag_id, /* 8 */
+                               $this->ag_hour, /* 9 */
+                               $this->ag_priority, /* 10 */
+                               $this->ag_dest, /* 11 */
+                               $ag_cal, /* 12 */
+                               $contact->id, /* 13 */
+                               $this->ag_ref, /* 14 */
+                               $this->ag_remind_date /* 15 */
+                       ));
+               }
                else
                {
-                       $this->db->exec_sql("update action_gestion set ".
-                                                                       " 
ag_timestamp=to_date($1,'DD.MM.YYYY'),".
-                                                                       " 
ag_title=$2,".
-                                                                       " 
ag_type=$3, ".
-                                                                       " 
f_id_dest=$4, ".
-                                                                       " 
ag_ref_ag_id=$5 ,".
-                                                                       
"ag_state=$6,".
-                                                                       " 
ag_hour = $8 ,".
-                                                                       " 
ag_priority = $9 ,".
-                                                                       " 
ag_dest = $10 , ".
-                                                                       " 
ag_cal = $11 ,".
-                                                                       " 
ag_contact = $12, ".
-                                                                       " 
ag_ref = $13, ".
-                                                                       " 
ag_remind_date=null ".
-                                                                       " where 
ag_id = $7",
-                                                                       array (
-                                                                               
        $this->ag_timestamp, /* 2 */
-                                                                               
        $this->ag_title,     /* 3 */
-                                                                               
        $this->dt_id,          /* 4 */
-                                                                               
        $this->f_id_dest,     /* 5 */
-                                                                               
        $this->ag_ref_ag_id, /* 6 */
-                                                                               
        $this->ag_state,     /* 7 */
-                                                                               
        $this->ag_id,      /* 8 */
-                                                                               
        $this->ag_hour,    /* 9 */
-                                                                               
        $this->ag_priority, /* 10 */
-                                                                               
        $this->ag_dest,     /* 11 */
-                                                                               
        $ag_cal,              /* 12 */
-                                                                               
        $contact->id,   /* 13 */
-                                                                               
        $this->ag_ref /* 14 */
-                                                                               
));
-       }
-        // Upload  documents
-        $doc=new Document($this->db);
-        $doc->Upload($this->ag_id);
+                       $this->db->exec_sql("update action_gestion set " .
+                                       " 
ag_timestamp=to_date($1,'DD.MM.YYYY')," .
+                                       " ag_title=$2," .
+                                       " ag_type=$3, " .
+                                       " f_id_dest=$4, " .
+                                       " ag_ref_ag_id=$5 ," .
+                                       "ag_state=$6," .
+                                       " ag_hour = $8 ," .
+                                       " ag_priority = $9 ," .
+                                       " ag_dest = $10 , " .
+                                       " ag_cal = $11 ," .
+                                       " ag_contact = $12, " .
+                                       " ag_ref = $13, " .
+                                       " ag_remind_date=null " .
+                                       " where ag_id = $7", array(
+                               $this->ag_timestamp, /* 2 */
+                               $this->ag_title, /* 3 */
+                               $this->dt_id, /* 4 */
+                               $this->f_id_dest, /* 5 */
+                               $this->ag_ref_ag_id, /* 6 */
+                               $this->ag_state, /* 7 */
+                               $this->ag_id, /* 8 */
+                               $this->ag_hour, /* 9 */
+                               $this->ag_priority, /* 10 */
+                               $this->ag_dest, /* 11 */
+                               $ag_cal, /* 12 */
+                               $contact->id, /* 13 */
+                               $this->ag_ref /* 14 */
+                       ));
+               }
+               // Upload  documents
+               $doc = new Document($this->db);
+               $doc->Upload($this->ag_id);
 
-        /* save action details */
-        for ( $i = 0; $i < MAX_ARTICLE;$i++)
-        {
-            $act=new Follow_Up_Detail($this->db);
-            $act->from_array($_POST,$i);
-            $act->save();
-        }
-               if ( trim($this->ag_comment)!='') {
+               /* save action details */
+               for ($i = 0; $i < MAX_ARTICLE; $i++)
+               {
+                       $act = new Follow_Up_Detail($this->db);
+                       $act->from_array($_POST, $i);
+                       $act->save();
+               }
+               if (trim($this->ag_comment) != '')
+               {
                        $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));
+                                       , array($this->ag_id, 
$_SESSION['g_user'], $this->ag_comment));
                }
                $this->insert_operation();
-               $this->remove_operation();
-        return true;
+               $this->insert_action();
+               return true;
+       }
 
-    }
+       /* !\brief generate the document and add it to the action
+        * \param md_id is the id of the document_modele
+        * \param $p_array contains normally the $_POST
+        */
 
-    /*!\brief generate the document and add it to the action
-     * \param md_id is the id of the document_modele
-     * \param $p_array contains normally the $_POST
-     */
-    function generate_document($md_id,$p_array)
-    {
-        $doc=new Document($this->db);
-        $mod=new Document_Modele($this->db,$md_id);
-        $mod->load();
-        $doc->f_id=$this->f_id_dest;
-        $doc->md_id=$md_id;
-        $doc->ag_id=$this->ag_id;
-        $doc->Generate($p_array);
-    }
-    /*!\brief put an array in the variable member, the indice
-     * is the member name
-    *\param $p_array to parse
-    *\return nothing
-    */
-    function fromArray($p_array)
-    {
-        $this->ag_id=(isset($p_array['ag_id']))?$p_array['ag_id']:"";
-        
$this->qcode_dest=(isset($p_array['qcode_dest']))?$p_array['qcode_dest']:"";
-        
$this->f_id_dest=(isset($p_array['f_id_dest']))?$p_array['f_id_dest']:0;
-        
$this->ag_ref_ag_id=(isset($p_array['ag_ref_ag_id']))?$p_array['ag_ref_ag_id']:0;
-        
$this->ag_timestamp=(isset($p_array['ag_timestamp']))?$p_array['ag_timestamp']:date('d.m.Y');
-        
$this->qcode_dest=(isset($p_array['qcode_dest']))?$p_array['qcode_dest']:"";
-        $this->dt_id=(isset($p_array['dt_id']))?$p_array['dt_id']:"";
-        $this->ag_state=(isset($p_array['ag_state']))?$p_array['ag_state']:2;
-        $this->ag_ref=(isset($p_array['ag_ref']))?$p_array['ag_ref']:"";
-        $this->ag_title=(isset($p_array['ag_title']))?$p_array['ag_title']:"";
-        $this->ag_hour=(isset($p_array['ag_hour']))?$p_array['ag_hour']:"";
-        $this->ag_dest=(isset($p_array['ag_dest']))?$p_array['ag_dest']:"";
-        
$this->ag_priority=(isset($p_array['ag_priority']))?$p_array['ag_priority']:2;
-        $this->ag_cal=(isset($p_array['ag_cal']))?'on':"";
-        
$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;
+       function generate_document($md_id, $p_array)
+       {
+               $doc = new Document($this->db);
+               $mod = new Document_Modele($this->db, $md_id);
+               $mod->load();
+               $doc->f_id = $this->f_id_dest;
+               $doc->md_id = $md_id;
+               $doc->ag_id = $this->ag_id;
+               $doc->Generate($p_array);
+       }
 
-    }
-    /*!\brief remove the action
-     *
-     */
-    function remove()
-    {
-        $this->get();
-        // remove the key
-        $sql="delete from action_gestion where ag_id=$1";
-        $this->db->exec_sql($sql,array($this->ag_id));
+       /* !\brief put an array in the variable member, the indice
+        * is the member name
+        * \param $p_array to parse
+        * \return nothing
+        */
 
-        // remove the ref of the depending action
-        $sql="update action_gestion set ag_ref_ag_id=0 where ag_ref_ag_id=$1";
-        $this->db->exec_sql($sql,array($this->ag_id));
+       function fromArray($p_array)
+       {
+               $this->ag_id = (isset($p_array['ag_id'])) ? $p_array['ag_id'] : 
"";
+               $this->qcode_dest = (isset($p_array['qcode_dest'])) ? 
$p_array['qcode_dest'] : "";
+               $this->f_id_dest = (isset($p_array['f_id_dest'])) ? 
$p_array['f_id_dest'] : 0;
+               $this->ag_ref_ag_id = (isset($p_array['ag_ref_ag_id'])) ? 
$p_array['ag_ref_ag_id'] : 0;
+               $this->ag_timestamp = (isset($p_array['ag_timestamp'])) ? 
$p_array['ag_timestamp'] : date('d.m.Y');
+               $this->qcode_dest = (isset($p_array['qcode_dest'])) ? 
$p_array['qcode_dest'] : "";
+               $this->dt_id = (isset($p_array['dt_id'])) ? $p_array['dt_id'] : 
"";
+               $this->ag_state = (isset($p_array['ag_state'])) ? 
$p_array['ag_state'] : 2;
+               $this->ag_ref = (isset($p_array['ag_ref'])) ? 
$p_array['ag_ref'] : "";
+               $this->ag_title = (isset($p_array['ag_title'])) ? 
$p_array['ag_title'] : "";
+               $this->ag_hour = (isset($p_array['ag_hour'])) ? 
$p_array['ag_hour'] : "";
+               $this->ag_dest = (isset($p_array['ag_dest'])) ? 
$p_array['ag_dest'] : "";
+               $this->ag_priority = (isset($p_array['ag_priority'])) ? 
$p_array['ag_priority'] : 2;
+               $this->ag_cal = (isset($p_array['ag_cal'])) ? 'on' : "";
+               $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;
+               $this->action = (isset($p_array['action'])) ? 
$p_array['action'] : null;
 
-        /*  check the number of attached document */
-        $doc=new Document($this->db);
-        $aDoc=$doc->get_all($this->ag_id);
-        if ( ! empty ($aDoc))
-        {
-            // if there are documents
-            for ($i=0;$i <sizeof($aDoc);$i++)
-            {
-                $aDoc[$i]->remove();
-            }
-        }
-    }
-    /*!\brief return the last p_limit operation into an array
-     *\param $p_limit is the max of operation to return
-     *\return $p_array of Follow_Up object
-     */
-    function get_last($p_limit)
-    {
-        $sql="select coalesce(vw_name,'Interne') as 
vw_name,ag_id,ag_title,ag_ref, dt_value,to_char(ag_timestamp,'DD.MM.YYYY') as 
ag_timestamp_fmt,ag_timestamp ".
-             " from action_gestion join document_type ".
-             " on (ag_type=dt_id) left join vw_fiche_attr on (f_id=f_id_dest) 
where ag_state in (2,3) order by ag_timestamp desc limit $p_limit";
-        $array=$this->db->get_array($sql);
-        return $array;
-    }
+       }
+
+       /* !\brief remove the action
+        *
+        */
+
+       function remove()
+       {
+               $this->get();
+               // remove the key
+               $sql = "delete from action_gestion where ag_id=$1";
+               $this->db->exec_sql($sql, array($this->ag_id));
+
+               // remove the ref of the depending action
+               $sql = "update action_gestion set ag_ref_ag_id=0 where 
ag_ref_ag_id=$1";
+               $this->db->exec_sql($sql, array($this->ag_id));
+
+               /*  check the number of attached document */
+               $doc = new Document($this->db);
+               $aDoc = $doc->get_all($this->ag_id);
+               if (!empty($aDoc))
+               {
+                       // if there are documents
+                       for ($i = 0; $i < sizeof($aDoc); $i++)
+                       {
+                               $aDoc[$i]->remove();
+                       }
+               }
+       }
+
+       /* !\brief return the last p_limit operation into an array
+        * \param $p_limit is the max of operation to return
+        * \return $p_array of Follow_Up object
+        */
+
+       function get_last($p_limit)
+       {
+               $sql = "select coalesce(vw_name,'Interne') as 
vw_name,ag_id,ag_title,ag_ref, dt_value,to_char(ag_timestamp,'DD.MM.YYYY') as 
ag_timestamp_fmt,ag_timestamp " .
+                               " from action_gestion join document_type " .
+                               " on (ag_type=dt_id) left join vw_fiche_attr on 
(f_id=f_id_dest) where ag_state in (2,3) order by ag_timestamp desc limit 
$p_limit";
+               $array = $this->db->get_array($sql);
+               return $array;
+       }
+
        /**
-        address@hidden add an related action to the  current one
+        * @brief add an related action to the  current one
         */
        function add_depend($p_ref)
        {
-               if ($p_ref == 0 || $p_ref==$this->ag_id) return;
+               if ($p_ref == 0 || $p_ref == $this->ag_id)
+                       return;
                // check if action exist and is not already related to the 
current action
-               $exist=$this->db->get_value("select count(*) from 
action_gestion where ag_id=$1",array($p_ref));
-               if ( $exist == 0) return;
+               $exist = $this->db->get_value("select count(*) from 
action_gestion where ag_id=$1", array($p_ref));
+               if ($exist == 0)
+                       return;
 
-               $this->db->exec_sql("update action_gestion set ag_ref_ag_id=$1 
where ag_id=$2",
-                               array($this->ag_id,$p_ref));
+               $this->db->exec_sql("update action_gestion set ag_ref_ag_id=$1 
where ag_id=$2", array($this->ag_id, $p_ref));
+       }
 
-       }
        function suppress_depend($p_array)
        {
-               for ($i=0;$i<count($p_array);$i++)
+               for ($i = 0; $i < count($p_array); $i++)
                {
-                       $this->db->exec_sql("update action_gestion set 
ag_ref_ag_id=0 where ag_id=$1",
-                               array($p_array[$i]));
+                       $this->db->exec_sql("update action_gestion set 
ag_ref_ag_id=0 where ag_id=$1", array($p_array[$i]));
                }
        }
+
        function insert_operation()
        {
-               if ( trim($this->operation)=='') return;
-               $array=explode(",",$this->operation);
-               for ($i=0;$i<count($array);$i++) {
-                       if ( $this->db->get_value("select count(*) from 
action_gestion_operation
-                               where ag_id=$1 and 
jr_id=$2",array($this->ag_id,$array[$i]))==0)
+               if (trim($this->operation) == '')
+                       return;
+               $array = explode(",", $this->operation);
+               for ($i = 0; $i < count($array); $i++)
+               {
+                       if ($this->db->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]));
+                               $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;$i<count($op);$i++){
-                       $this->db->exec_sql("delete from 
action_gestion_operation where ago_id=$1",array($op[$i]));
+               if ($this->op == null)
+                       return;
+               $op = $this->op;
+               for ($i = 0; $i < count($op); $i++)
+               {
+                       $this->db->exec_sql("delete from 
action_gestion_operation where ago_id=$1", array($op[$i]));
                }
        }
-function ShowActionList($cn,$p_base)
-{
-  // show the search menu
-  ?>
-  <div id="search_action" class="op_detail_frame" 
style="position:absolute;display:none;margin-left:120px;width:70%;clear:both;z-index:2;height:auto;border:1px
 #000080 solid">
-        <? echo 
HtmlInput::anchor_hide('Fermer','$(\'search_action\').style.display=\'none\';');
 ?>
-    <h2 class="info">
-    <?=_('Recherche avancée')?>
-    </h2>
-    <form method="get" action="do.php" style="padding:10px">
-    <?php
-    echo dossier::hidden();
-  $a=(isset($_GET['query']))?$_GET['query']:"";
-  $qcode=(isset($_GET['qcode']))?$_GET['qcode']:"";
+       /**
+        *Display only a search box for searching an action
+        * @param $cn database connx
+        */
+       static function display_search($cn,$inner=false)
+       {
+               $a = (isset($_GET['query'])) ? $_GET['query'] : "";
+               $qcode = (isset($_GET['qcode'])) ? $_GET['qcode'] : "";
 
-  $supl_hidden='';
-  if( isset($_REQUEST['sc']))
-    $supl_hidden.=HtmlInput::hidden('sc',$_REQUEST['sc']);
-  if( isset($_REQUEST['f_id']))
-    {
-      $supl_hidden.=HtmlInput::hidden('f_id',$_REQUEST['f_id']);
-      $f=new Fiche($cn,$_REQUEST['f_id']);
-      $supl_hidden.=HtmlInput::hidden('qcode_dest',$f->get_quick_code());
-    }
-  if( isset($_REQUEST['sb']))
-    $supl_hidden.=HtmlInput::hidden('sb',$_REQUEST['sb']);
-    $supl_hidden.=HtmlInput::hidden('ac',$_REQUEST['ac']);
+               $supl_hidden = '';
+               if (isset($_REQUEST['sc']))
+                       $supl_hidden.=HtmlInput::hidden('sc', $_REQUEST['sc']);
+               if (isset($_REQUEST['f_id']))
+               {
+                       $supl_hidden.=HtmlInput::hidden('f_id', 
$_REQUEST['f_id']);
+                       $f = new Fiche($cn, $_REQUEST['f_id']);
+                       $supl_hidden.=HtmlInput::hidden('qcode_dest', 
$f->get_quick_code());
+               }
+               if (isset($_REQUEST['sb']))
+                       $supl_hidden.=HtmlInput::hidden('sb', $_REQUEST['sb']);
+               $supl_hidden.=HtmlInput::hidden('ac', $_REQUEST['ac']);
 
-  $w=new ICard();
-  $w->name='qcode';
-  $w->value=$qcode;
-  $w->extra="all";
-  $w->typecard='all';
-  $w->jrn=0;
-  $w->table=0;
-  $list=$cn->make_list("select fd_id from fiche_def where frd_id in 
(4,8,9,14,15,16,25)");
-  $w->extra=$list;
+               /**
+                * Show the default button (add action, show search...)
+                */
+               if (!$inner) require_once 'template/action_button.php';
 
+               $w = new ICard();
+               $w->name = 'qcode';
+               $w->id=$w->generate_id($w->name);
+               $w->value = $qcode;
+               $w->extra = "all";
+               $w->typecard = 'all';
+               $w->jrn = 0;
+               $w->table = 0;
+               $list = $cn->make_list("select fd_id from fiche_def where 
frd_id in (4,8,9,14,15,16,25)");
+               $w->extra = $list;
 
-  /* type of documents */
-  $type_doc=new ISelect ('tdoc');
-  $aTDoc=$cn->make_array('select dt_id,dt_value from document_type order by 
dt_value');
-  $aTDoc[]=array('value'=>'-1','label'=>_('Tous les types'));
-  $type_doc->value=$aTDoc;
-  $type_doc->selected=(isset ($_GET['tdoc']))?$_GET['tdoc']:-1;
 
-       // date
-  $start=new IDate('date_start');
-  $start->value=(isset($_GET['date_start']))?$_GET['date_start']:"";
-  $end=new IDate('date_end');
-  $end->value=(isset($_GET['date_end']))?$_GET['date_end']:"";
+               /* type of documents */
+               $type_doc = new ISelect('tdoc');
+               $aTDoc = $cn->make_array('select dt_id,dt_value from 
document_type order by dt_value');
+               $aTDoc[] = array('value' => '-1', 'label' => _('Tous les 
types'));
+               $type_doc->value = $aTDoc;
+               $type_doc->selected = (isset($_GET['tdoc'])) ? $_GET['tdoc'] : 
-1;
 
-  $see_all=new ICheckBox('see_all');
-  $see_all->selected=(isset($_GET['see_all']))?true:false;
-  $my_action=new ICheckBox('all_action');
-  $my_action->selected=(isset($_GET['all_action']))?true:false;
-  // select profile
-   $aAg_dest=$cn->make_array("select  p_id as value, ".
-                                    "p_name as label ".
-                                    " from profile order by 2");
-$ag_dest=new ISelect();
-$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_query"]))?$_GET["ag_dest_query"]:0;
-$str_ag_dest=$ag_dest->input();
+               // date
+               $start = new IDate('date_start');
+               $start->value = (isset($_GET['date_start'])) ? 
$_GET['date_start'] : "";
+               $end = new IDate('date_end');
+               $end->value = (isset($_GET['date_end'])) ? $_GET['date_end'] : 
"";
 
-  ?>
-               <table style="width:100%">
-                       <tr>
-                       <td style="width:180px;text-align:right"><? echo 
_('Destinataire') ?></td>
-                       <td ><?=$w->input().$w->search()?></td>
-                       <tr>
-                       <tr>
-                               <td style="text-align:right" 
><?=_("Profile")?></td>
-                               <td><?=$str_ag_dest?></td>
-                       </tr>
-                       <td style="text-align:right"><? printf (_('contenant le 
mot'))?></td>
-                       <td ><input class="input_text" style="width:100%" 
type="text" name="query" value="<?=$a?>"></td>
-                       </tr>
-                       <tr>
-                                       <td style="text-align:right"><?=_('Type 
de document')?></td>
-                                       <td><? echo $type_doc->input();?></td>
-                       </tr>
-                       <tr>
-                               <td style="text-align:right">
-                                       <? printf (_("Après le "))?>
-                               </td>
-                               <td >
-                                       <?=$start->input()?>
-                               </td>
-                       </tr>
-                       <tr>
-                               <td style="text-align:right"><?=_('Avant 
le')?></td>
-                               <td>
-                                       <?=$end->input()?>
-                               </td>
-                               </tr>
-                       </tr>
-                       <tr>
-                       <td style="text-align:right">
-                               <?=_('inclure les actions fermées ')?>
-                       </td>
-                       <td>
-                               <?=$see_all->input()?>
-                       </td>
-                       </tr>
-                       <tr>
-                               <td style="text-align:right"><?=_('les actions  
affectées à d\'autres')?></td>
-                               <td><?=$my_action->input()?>
-                               </td>
-                       </tr>
-  </table>
-    <input type="submit" class="button" name="submit_query" 
value="<?=_('recherche')?>">
-       <input type="hidden" name="sa" value="list">
+               $see_all = new ICheckBox('see_all');
+               $see_all->selected = (isset($_GET['see_all'])) ? true : false;
+               $my_action = new ICheckBox('all_action');
+               $my_action->selected = (isset($_GET['all_action'])) ? true : 
false;
+               // select profile
+               $aAg_dest = $cn->make_array("select  p_id as value, " .
+                               "p_name as label " .
+                               " from profile order by 2");
+               $ag_dest = new ISelect();
+               $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_query"])) ? 
$_GET["ag_dest_query"] : 0;
+               $str_ag_dest = $ag_dest->input();
+               // show the  action in
+               require_once 'template/action_search.php';
 
-       <?=$supl_hidden?>
-<?  echo 
HtmlInput::button_anchor(_('Fermer'),'javascript:void(0)','fsearch_form','onclick="$(\'search_action\').style.display=\'none\';"');
 ?>
-       </form>
-       </div>
+       }
 
-       <div class="content" >
-       <div>
-       <form  method="get" action="do.php">
-       <?php echo dossier::hidden();
-  ?>
-       <input type="submit" class="button" name="submit_query" 
value="<?=_("Ajout Action")?>">
-         <input type="hidden" name="ac" value="<?=$_REQUEST['ac']?>">
-         <input type="hidden" name="sa" value="add_action">
-         <?=$supl_hidden?>
-         <input id="bt_search" type="button" class="button" 
onclick="$('search_action').style.display='block'" value="<?=_('Recherche')?>">
+       static function ShowActionList($cn, $p_base)
+       {
 
+               Follow_Up::display_search($cn);
 
+               $act = new Follow_Up($cn);
+               /* ! \brief
+                *  \note The field 'recherche' is   about a part of the title 
or a ref. number
+                */
+               $query = Follow_Up::create_query($cn);
 
-             </form>
-             </div>
 
-             <?php
-             // show the  action in
-             $act=new Follow_Up($cn);
-         /*! \brief
-          *  \note The field 'recherche' is   about a part of the title or a 
ref. number
-          */
-         $query="";
 
-         if ( isset($_REQUEST['query']) )
-           {
-             // if a query is request build the sql stmt
-             $query="and (ag_title ~* '".sql_string($_REQUEST['query'])."' ".
-               "or ag_ref ='".trim(sql_string($_REQUEST['query'])).
-               "' or ag_id in (select ag_id from action_gestion_comment where 
agc_comment ~* '".trim(sql_string($_REQUEST['query']))."')".
-               ")";
-           }
+               $r = $act->myList($p_base, "", $query );
+               echo $r;
+       }
 
-         $str="";
-         if ( isset($_GET['qcode'] ))
-           {
+       /**
+        *Get date from $_GET and create the sql stmt for the query
+        * @see Follow_Up::ShowActionList
+        * @return string SQL condition
+        */
+       static function create_query($cn)
+       {
+               $query="";
+               if (isset($_REQUEST['query']))
+               {
+                       // if a query is request build the sql stmt
+                       $query = "and (ag_title ~* '" . 
sql_string($_REQUEST['query']) . "' " .
+                                       "or ag_ref ='" . 
trim(sql_string($_REQUEST['query'])) .
+                                       "' or ag_id in (select ag_id from 
action_gestion_comment where agc_comment ~* '" . 
trim(sql_string($_REQUEST['query'])) . "')" .
+                                       ")";
+               }
 
-             // verify that qcode is not empty
-             if ( strlen(trim($_REQUEST['qcode'] )) != 0 )
+               $str = "";
+               if (isset($_GET['qcode']))
                {
 
-                 $fiche=new Fiche($cn);
-                 $fiche->get_by_qcode($_REQUEST['qcode']);
-                 // if quick code not found then nothing
-                 if ( $fiche->id == 0 )
-                   $str=' and false ';
-                 else
-                   $str=" and (f_id_dest= ".$fiche->id." ) ";
+                       // verify that qcode is not empty
+                       if (strlen(trim($_REQUEST['qcode'])) != 0)
+                       {
+
+                               $fiche = new Fiche($cn);
+                               $fiche->get_by_qcode($_REQUEST['qcode']);
+                               // if quick code not found then nothing
+                               if ($fiche->id == 0)
+                                       $str = ' and false ';
+                               else
+                                       $str = " and (f_id_dest= " . $fiche->id 
. " ) ";
+                       }
                }
-           }
-         if (isset($_GET['tdoc']) && $_GET['tdoc'] != -1 )
-           {
-             $query .= ' and dt_id = '.Formatstring($_GET['tdoc']);
-           }
-         if ( ! $see_all->selected )      $query .= ' and ag_state in (2,3) ';
-         if ( ! $my_action->selected )     {
-                 $query .=" and (ag_owner='".$_SESSION['g_user']."' or ag_dest 
in (select p_id from profile_user where user_name='".$_SESSION['g_user']."') )";
-         }
-         if (isset ($_GET['date_start']) && isDate($_GET['date_start'])!= null 
) {
-                 $date_start=$_GET['date_start'];
-                 $query.=" and ag_timestamp >= 
to_date('$date_start','DD.MM.YYYY')";
-         }
-         if (isset ($_GET['date_end']) && isDate($_GET['date_end'])!= null ) {
-                 $date_end=$_GET['date_end'];
-                 $query.=" and ag_timestamp <= 
to_date('$date_end','DD.MM.YYYY')";
-         }
-         if ( isset($_GET['ag_dest_query']))
-         {
-                 if ( $_GET['ag_dest_query']==0)
-                       $query .= "and ag_dest is null ";
-                 else
-                       $query.= " and ag_dest = 
".sql_string($_GET['ag_dest_query']);
-         }
-         $r=$act->myList($p_base,"",$query.$str);
-         echo $r;
-}
+               if (isset($_GET['tdoc']) && $_GET['tdoc'] != -1)
+               {
+                       $query .= ' and dt_id = ' . Formatstring($_GET['tdoc']);
+               }
+               if (!isset($_GET['see_all']))
+                       $query .= ' and ag_state in (2,3) ';
+               if (! isset($_GET['all_action']))
+               {
+                       $query .=" and (ag_owner='" . $_SESSION['g_user'] . "' 
or ag_dest in (select p_id from profile_user where user_name='" . 
$_SESSION['g_user'] . "') or ag_dest is null )";
+               }
+               if (isset($_GET['date_start']) && isDate($_GET['date_start']) 
!= null)
+               {
+                       $date_start = $_GET['date_start'];
+                       $query.=" and ag_timestamp >= 
to_date('$date_start','DD.MM.YYYY')";
+               }
+               if (isset($_GET['date_end']) && isDate($_GET['date_end']) != 
null)
+               {
+                       $date_end = $_GET['date_end'];
+                       $query.=" and ag_timestamp <= 
to_date('$date_end','DD.MM.YYYY')";
+               }
+               if (isset($_GET['ag_dest_query']))
+               {
+                       if ($_GET['ag_dest_query'] != 0)
+                               $query.= " and ag_dest = " . 
sql_string($_GET['ag_dest_query']);
+               }
+               if ( isNumber($_GET['ag_id'])==1 && $_GET['ag_id'] != 0) {
+                       $query=" and ag_id= ".$_GET['ag_id'];
+               }
+               return $query. $str;
+       }
 
+       static function short_list($cn,$p_sql) {
+               $sql = "
+             select ag_id,to_char(ag_timestamp,'DD.MM.YY') as my_date,
+                        f_id_dest,
+             substr(ag_title,1,30) as sub_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
+             from action_gestion
+             join document_type on (ag_type=dt_id)
+             where $p_sql";
+               $max_line = $cn->count_sql($sql);
+
+               $limit=($max_line > 25)?25:$max_line;
+               $Res = $cn->exec_sql($sql . "limit ".$limit);
+               $a_row = Database::fetch_all($Res);
+               require_once 'template/action_search_result.php';
+
+       }
+
+       function insert_action()
+       {
+               if (trim($this->action) == '')
+                       return;
+               $array = explode(",", $this->action);
+               for ($i = 0; $i < count($array); $i++)
+               {
+                       if ($this->db->get_value("select count(*) from 
action_gestion_related
+                               where (aga_least=$1 and aga_greatest=$2) or 
(aga_greatest=$1 and aga_least=$2)", array($array[$i],$this->ag_id)) == 0 && 
$this->ag_id != $array[$i])
+                       {
+                               $this->db->exec_sql("insert into 
action_gestion_related(aga_least,aga_greatest) values ($1,$2)", 
array($this->ag_id, $array[$i]));
+                       }
+               }
+       }
+
 }

Modified: phpcompta/trunk/include/class_html_input.php
===================================================================
--- phpcompta/trunk/include/class_html_input.php        2012-05-31 00:20:30 UTC 
(rev 4851)
+++ phpcompta/trunk/include/class_html_input.php        2012-05-31 02:51:49 UTC 
(rev 4852)
@@ -425,7 +425,7 @@
     {
        $r='';
        $r.='<div style="float:right;right;margin:2;">';
-       $r.= '<A id="close_div" HREF="javascript:void(0)" 
onclick="'.$javascript.'");">'.$action.'</A>';
+       $r.= '<A id="close_div" HREF="javascript:void(0)" 
onclick="'.$javascript.'"">'.$action.'</A>';
        $r.='</div>';
        return $r;
     }

Added: phpcompta/trunk/include/class_irelated_action.php
===================================================================
--- phpcompta/trunk/include/class_irelated_action.php                           
(rev 0)
+++ phpcompta/trunk/include/class_irelated_action.php   2012-05-31 02:51:49 UTC 
(rev 4852)
@@ -0,0 +1,71 @@
+<?php
+/*
+ *   This file is part of PhpCompta.
+ *
+ *   PhpCompta 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.
+ *
+ *   PhpCompta 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 PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+// Copyright Author Dany De Bontridder address@hidden
+
+/*!\file
+ * \brief Html Input
+ *  - name is the name and id of the input
+ */
+require_once('class_html_input.php');
+class IRelated_Action extends HtmlInput
+{
+
+       public function __construct($p_name='',$p_value='')
+       {
+               $this->name=$p_name;
+               $this->value=$p_value;
+               $this->amount_id=null;
+               $this->paid='';
+       }
+    /*!\brief show the html  input of the widget*/
+    public function input($p_name=null,$p_value=null)
+    {
+        $this->name=($p_name==null)?$this->name:$p_name;
+        $this->value=($p_value==null)?$this->value:$p_value;
+        if ( $this->readOnly==true) return $this->display();
+
+
+
+        $r=sprintf("
+                   <INPUT TYPE=\"button\" 
onClick=\"search_action(".dossier::id().",'%s')\" value=\"?\">
+                   <INPUT TYPE=\"text\"  
style=\"color:black;background:lightyellow;border:solid 1px grey;\"  
NAME=\"%s\" ID=\"%s\" VALUE=\"%s\" SIZE=\"8\" readonly>
+                                  <INPUT TYPE=\"button\" 
onClick=\"$('%s').value=''\" value=\"X\">
+
+                   ",
+                   $this->name,
+                   $this->name,
+                   $this->name,
+                   $this->value,
+                   $this->name
+                  );
+        return $r;
+    }
+    /*!\brief print in html the readonly value of the widget*/
+    public function display()
+    {
+        $r=sprintf("<span><b>%s</b></span>",$this->value);
+        $r.=sprintf('<input type="hidden" name="%s" value="%s">', 
$this->name,$this->value);
+        return $r;
+
+    }
+    static public function test_me()
+    {
+    }
+}

Added: phpcompta/trunk/include/template/action_button.php
===================================================================
--- phpcompta/trunk/include/template/action_button.php                          
(rev 0)
+++ phpcompta/trunk/include/template/action_button.php  2012-05-31 02:51:49 UTC 
(rev 4852)
@@ -0,0 +1,44 @@
+<?php
+
+/*
+ *   This file is part of PhpCompta.
+ *
+ *   PhpCompta 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.
+ *
+ *   PhpCompta 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 PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+/* $Revision$ */
+
+// Copyright Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief show button in the list of actions
+ *
+ */
+?>
+<div class="content" >
+       <div>
+               <form  method="get" action="do.php">
+                       <?php echo dossier::hidden();
+                       ?>
+                       <input type="submit" class="button" name="submit_query" 
value="<?= _("Ajout Action")?>">
+                       <input type="hidden" name="ac" value="<?= 
$_REQUEST['ac']?>">
+                       <input type="hidden" name="sa" value="add_action">
+                       <?= $supl_hidden?>
+                       <input id="bt_search" type="button" class="button" 
onclick="$('search_action').style.display='block'" value="<?= _('Recherche')?>">
+
+
+
+               </form>
+       </div>
\ No newline at end of file

Added: phpcompta/trunk/include/template/action_search.php
===================================================================
--- phpcompta/trunk/include/template/action_search.php                          
(rev 0)
+++ phpcompta/trunk/include/template/action_search.php  2012-05-31 02:51:49 UTC 
(rev 4852)
@@ -0,0 +1,107 @@
+<?php
+/*
+ *   This file is part of PhpCompta.
+ *
+ *   PhpCompta 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.
+ *
+ *   PhpCompta 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 PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+/* $Revision$ */
+
+// Copyright Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief display the form for searching action
+ *
+ */
+?>
+<? if (! $inner ) : ?>
+<div id="search_action" class="op_detail_frame" 
style="position:absolute;display:none;margin-left:120px;width:70%;clear:both;z-index:2;height:auto;border:1px
 #000080 solid">
+       <? echo HtmlInput::anchor_hide('Fermer', 
"$('search_action').style.display='none';");?>
+<? endif; ?>
+<? if ( $inner ) : ?>
+<div id="search_action" class="op_detail_frame">
+       <? echo HtmlInput::anchor_hide('Fermer', 
"removeDiv('search_action_div');");?>
+
+       <? endif; ?>
+       <h2 class="info">
+               <?= _('Recherche avancée')?>
+       </h2>
+<? if (! $inner ) : ?>
+       <form method="get" action="do.php" style="padding:10px">
+<? endif; ?>
+<? if ( $inner ) : ?>
+       <form method="get" id="fsearchaction" style="padding:10px" 
onsubmit="result_search_action('fsearchaction');return false;">
+               <?=HtmlInput::hidden('ctlc',$_GET['ctlc'])?>
+<? endif; ?>
+               <?= dossier::hidden()?>
+               <table style="width:100%">
+                       <tr>
+                               <td style="width:180px;text-align:right"> 
Numéro document</td>
+                               <td>
+                                       <? $num=new INum('ag_id');echo 
$num->input();?>
+                               </td>
+                       <tr>
+                               <td style="width:180px;text-align:right"><? 
echo _('Destinataire')?></td>
+                               <? $label=$w->id."_label";?>
+                               <td ><?= $w->input() . $w->search()?><span 
id="<?=$label?>"></span></td>
+                       <tr>
+                       <tr>
+                               <td style="text-align:right" ><?= 
_("Profile")?></td>
+                               <td><?= $str_ag_dest?></td>
+                       </tr>
+                       <td style="text-align:right"><? printf(_('contenant le 
mot'))?></td>
+                       <td ><input class="input_text" style="width:100%" 
type="text" name="query" value="<?= $a?>"></td>
+                       </tr>
+                       <tr>
+                               <td style="text-align:right"><?= _('Type de 
document')?></td>
+                               <td><? echo $type_doc->input();?></td>
+                       </tr>
+                       <tr>
+                               <td style="text-align:right">
+                                       <? printf(_("Après le "))?>
+                               </td>
+                               <td >
+                                       <?= $start->input()?>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td style="text-align:right"><?= _('Avant 
le')?></td>
+                               <td>
+                                       <?= $end->input()?>
+                               </td>
+                       </tr>
+                       </tr>
+                       <tr>
+                               <td style="text-align:right">
+                                       <?= _('inclure les actions fermées ')?>
+                               </td>
+                               <td>
+                                       <?= $see_all->input()?>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td style="text-align:right"><?= _('les actions 
 affectées à d\'autres')?></td>
+                               <td><?= $my_action->input()?>
+                               </td>
+                       </tr>
+               </table>
+               <input type="submit" class="button" name="submit_query" 
value="<?= _('recherche')?>">
+               <input type="hidden" name="sa" value="list">
+
+               <?= $supl_hidden?>
+               <? echo HtmlInput::button_anchor(_('Fermer'), 
'javascript:void(0)', 'fsearch_form', 
'onclick="$(\'search_action\').style.display=\'none\';"');?>
+       </form>
+</div>
+

Added: phpcompta/trunk/include/template/action_search_result.php
===================================================================
--- phpcompta/trunk/include/template/action_search_result.php                   
        (rev 0)
+++ phpcompta/trunk/include/template/action_search_result.php   2012-05-31 
02:51:49 UTC (rev 4852)
@@ -0,0 +1,84 @@
+<?php
+
+/*
+ *   This file is part of PhpCompta.
+ *
+ *   PhpCompta 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.
+ *
+ *   PhpCompta 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 PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+/* $Revision$ */
+
+// Copyright Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief show the result of a search into a inner windows
+ *
+ */
+?>
+<form onsubmit="set_action_related('fresultaction');return false;" 
id="fresultaction">
+       <?=HtmlInput::hidden('ctlc',$_GET['ctlc'])?>
+<table class="result">
+
+       <tr>
+               <th>
+
+               </th>
+               <th>
+                       Date
+               </th>
+               <th>
+                       Ref
+               </th>
+               <th>
+                       Titre
+               </th>
+               <th>
+                       Destinataire
+               </th>
+               <th>
+                       Type
+               </th>
+       </tr>
+<? for ($i=0;$i<$limit;$i++):?>
+       <? $class=($i%2==0)?' class="odd" ':' class="info"'; ?>
+       <tr  <?=$class?>>
+               <td>
+                       <?
+                       $ck=new ICheckBox('ag_id[]');
+                        $ck->value=$a_row[$i]['ag_id'];
+                        echo $ck->input();
+                       ?>
+               </td>
+               <td >
+                       <?=h($a_row[$i]['my_date'])?>
+               </td>
+               <td>
+                       <?=h($a_row[$i]['ag_ref'])?>
+               </td>
+               <td>
+                       <?=h($a_row[$i]['sub_ag_title'])?>
+               </td>
+               <td>
+                       <?=h($a_row[$i]['name'])?>
+               </td>
+               <td>
+                       <?=h($a_row[$i]['dt_value'])?>
+               </td>
+       </tr>
+
+<? endfor;?>
+</table>
+       <?=HtmlInput::submit("save_action", "Mettre à jour")?>
+</form>
\ No newline at end of file

Modified: phpcompta/trunk/include/template/detail-action.php
===================================================================
--- phpcompta/trunk/include/template/detail-action.php  2012-05-31 00:20:30 UTC 
(rev 4851)
+++ phpcompta/trunk/include/template/detail-action.php  2012-05-31 02:51:49 UTC 
(rev 4852)
@@ -8,7 +8,7 @@
     ?>
   </div>
 <h2 class="gest_name"><?php echo $sp->input();   ?></h2>
-<div style="float:left;width:30%">
+<div style="float:left;width: 45%">
 
 
         <table >
@@ -86,7 +86,7 @@
  <?echo $str_add_button;?>
 
 </div>
-<div style="float:left;width:30%">
+<div style="float:left;width:45%">
         <table>
 
           <tr>
@@ -140,8 +140,9 @@
         </table>
 
 </div>
-       <div style="float:left;width:40%">
-               <h4 style="display:inline">Opérations</h3>
+<div style="float:right;clear:both"></div>
+       <div style="float:left;width:45%">
+               <h4 style="display:inline">Opérations</h4>
                <ol>
 
                <?
@@ -159,6 +160,26 @@
                </ol>
                <?=$iconcerned->input()?>
        </div>
+
+       <div style="float:left;width:45%">
+               <h4 style="display:inline">Actions concernées</h4>
+               <ol>
+
+               <?
+               for ($o=0;$o<count($action);$o++)
+               {
+                       $rmAction=sprintf("javascript:if ( 
confirm('"._('Voulez-vous effacer cette action ')."')==true ) 
{remove_action('%s','%s','%s');}",
+                                       dossier::id(),
+                                       
$action[$o]['ag_id'],$_REQUEST['ag_id']);
+                       $js= '<a class="mtitle" style="color:orange" 
id="acact'.$action[$o]['ag_id'].'" href="'.$rmAction.'">Effacer</a>';
+                       echo '<li 
id="act'.$action[$o]['ag_id'].'">'.$action[$o]['str_date']." 
".h($action[$o]['sub_title'])." "
+                               .$js.'</li>';
+               }
+
+               ?>
+               </ol>
+               <?=$iaction->input()?>
+       </div>
 </fieldset>
 <fieldset>
   <legend>
@@ -187,16 +208,19 @@
 <h4 class="info">   <?=_('Commentaire')?></h4>
     <div style="margin-left:100">
    <?php
+   $style_enl='style="display:inline"';$style_small='style="display:none"';
+
 for( $c=0;$c<count($acomment);$c++){
        $rmComment=sprintf("javascript:if ( confirm('"._('Voulez-vous effacer 
ce commentaire ')."')==true ) {remove_comment('%s','%s');}",
                                        dossier::id(),
                                        $acomment[$c]['agc_id']);
                        $js= '<a class="mtitle" style="color:orange" 
id="accom'.$acomment[$c]['agc_id'].'" href="'.$rmComment.'">Effacer</a>';
-       echo '<p id="com'.$acomment[$c]['agc_id'].'"> 
n°'.$acomment[$c]['agc_id']." 
".h($acomment[$c]['agc_comment']).'('.h($acomment[$c]['tech_user'])." 
".smaller_date($acomment[$c]['str_agc_date']).')'.
-                       $js.'</p>';
+       echo 'n°'.$acomment[$c]['agc_id'].'('.h($acomment[$c]['tech_user'])." 
".smaller_date($acomment[$c]['str_agc_date']).')'.$js.
+                       '<pre style="white-space: -moz-pre-wrap;white-space: 
pre-wrap;border:1px solid blue;width:70%;" id="com'.$acomment[$c]['agc_id'].'"> 
'.
+                       " ".h($acomment[$c]['agc_comment']).'</pre>'
+                       ;
 }
 echo $desc->input();
-$style_enl='style="display:inline"';$style_small='style="display:none"';
 ?>
 <input type="button" id="bt_enlarge" <?=$style_enl?> value="+" 
onclick="enlarge('ag_comment');return false;">
 <input type="button" id="bt_small"  <?=$style_small?> value="-" 
style="display:none" onclick="small('ag_comment');return false;">

Modified: phpcompta/trunk/sql/upgrade.sql
===================================================================
--- phpcompta/trunk/sql/upgrade.sql     2012-05-31 00:20:30 UTC (rev 4851)
+++ phpcompta/trunk/sql/upgrade.sql     2012-05-31 02:51:49 UTC (rev 4852)
@@ -104,4 +104,59 @@
 );
 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
+COMMENT ON COLUMN action_comment_operation.jr_id IS 'fk to jrn';
+
+
+
+
+CREATE TABLE action_gestion_related
+(
+  aga_id bigserial NOT NULL, -- pk
+  aga_least bigint NOT NULL, -- fk to action_gestion
+  aga_greatest bigint NOT NULL,
+  CONSTRAINT action_gestion_related_pkey PRIMARY KEY (aga_id ),
+  CONSTRAINT action_gestion_related_aga_greatest_fkey FOREIGN KEY 
(aga_greatest)
+      REFERENCES action_gestion (ag_id) MATCH SIMPLE
+      ON UPDATE CASCADE ON DELETE CASCADE,
+  CONSTRAINT action_gestion_related_aga_least_fkey FOREIGN KEY (aga_least)
+      REFERENCES action_gestion (ag_id) MATCH SIMPLE
+      ON UPDATE CASCADE ON DELETE CASCADE,
+  CONSTRAINT ux_aga_least_aga_greatest UNIQUE (aga_least , aga_greatest )
+);
+COMMENT ON COLUMN action_gestion_related.aga_id IS 'pk';
+COMMENT ON COLUMN action_gestion_related.aga_least IS 'fk to action_gestion, 
smallest ag_id';
+COMMENT ON COLUMN action_gestion_related.aga_greatest IS 'fk to action_gestion 
greatest ag_id';
+
+-- Trigger: trg_action_gestion_related on action_gestion_related
+CREATE OR REPLACE FUNCTION comptaproc.action_gestion_related_ins_up()
+  RETURNS trigger AS
+$BODY$
+declare
+       nTmp bigint;
+begin
+
+if NEW.aga_least > NEW.aga_greatest then
+       nTmp := NEW.aga_least;
+       NEW.aga_least := NEW.aga_greatest;
+       NEW.aga_greatest := nTmp;
+end if;
+
+if NEW.aga_least = NEW.aga_greatest then
+       return NULL;
+end if;
+
+return NEW;
+
+end;
+$BODY$
+  LANGUAGE plpgsql ;
+-- DROP TRIGGER trg_action_gestion_related ON action_gestion_related;
+
+CREATE TRIGGER trg_action_gestion_related
+  BEFORE INSERT OR UPDATE
+  ON action_gestion_related
+  FOR EACH ROW
+  EXECUTE PROCEDURE comptaproc.action_gestion_related_ins_up();
+
+
+



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]