noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 21/219: Improve debugging and improve manage_


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 21/219: Improve debugging and improve manage_table_sql element will be added at the right place Manage_Table_SQL can work also with a SQL query or a view Icon place can be modified
Date: Mon, 18 Dec 2017 13:22:29 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit a5ef1138a41736e038aa192ef35327765697c3a5
Author: Dany De Bontridder <address@hidden>
Date:   Sun Jul 23 13:24:53 2017 +0200

    Improve debugging and improve manage_table_sql
     element will be added at the right place
    Manage_Table_SQL can work also with a SQL query or a view
    Icon place can be modified
---
 html/ajax_test.php                                 |  65 ++++
 html/js/managetable.js                             |  56 +++-
 html/js/sorttable.js                               |   2 +-
 include/class/acc_plan_mtable.class.php            | 120 ++++++++
 include/database/acc_plan_sql.class.php            | 162 ++++++++++
 include/database/tmp_pcmn_sql.class.php            |  63 ++++
 .../{noalyss_sql.class.php => data_sql.class.php}  | 152 ++--------
 include/lib/manage_table_sql.class.php             | 329 +++++++++++++++------
 include/lib/noalyss_sql.class.php                  |  28 +-
 ...nage_table_sql.php => ajax_acc_plan_mtable.php} |  38 +--
 scenario/ajax_manage_table_sql.php                 |  36 ++-
 scenario/test_acc_plan_mtable.php                  |  50 ++++
 scenario/test_manage_table_sql.php                 |  10 +-
 unit-test/README                                   |   2 +
 14 files changed, 865 insertions(+), 248 deletions(-)

diff --git a/html/ajax_test.php b/html/ajax_test.php
new file mode 100644
index 0000000..3ee7ad9
--- /dev/null
+++ b/html/ajax_test.php
@@ -0,0 +1,65 @@
+<?php
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   NOALYSS 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.
+ *
+ *   NOALYSS 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 NOALYSS; 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 this file let you debug and test the different functionnalities, 
there are 2 important things to do
+ * It is only a quick and dirty testing. You should use a tool as PHPUNIT for 
the unit testing
+ * 
+ *  - first do not forget to create the authorized_debug file in the html 
folder
+ *  - secund the test must adapted to this page : if you do a post (or get) 
from a test, you won't get any result
+ * if the $_REQUEST[test_select] is not set, so set it . 
+ */
+
+
+
+include_once  "../include/constant.php";
+include_once NOALYSS_INCLUDE."/lib/ac_common.php";
+require_once  NOALYSS_INCLUDE."/lib/database.class.php";
+require_once  NOALYSS_INCLUDE."/class/dossier.class.php";
+require_once  NOALYSS_INCLUDE."/lib/html_input.class.php";
+require_once  NOALYSS_INCLUDE."/lib/http_input.class.php";
+require_once  NOALYSS_INCLUDE."/lib/function_javascript.php";
+require_once  NOALYSS_INCLUDE."/class/user.class.php";
+$http=new HttpInput();
+$gDossier=$http->request('gDossier', "numeric",-1);
+if ($gDossier==-1)
+{
+    echo " Vous devez donner le dossier avec paramètre gDossier dans l'url, 
exemple http://localhost/noalyss/html/test.php?gDossier=25";;
+    exit();
+}
+$gDossierLogInput=$gDossier;
+global $cn, $g_user, $g_succeed, $g_failed;
+$cn=Dossier::connect();
+
+$g_parameter=new Own($cn);
+$g_user=new User($cn);
+
+if (!file_exists('authorized_debug'))
+{
+    echo "Pour pouvoir utiliser ce fichier vous devez creer un fichier nomme 
authorized_debug
+    dans le repertoire html du server";
+    exit();
+}
+define('ALLOWED', 1);
+define('AJAX_TEST', 1);
+
+$w=$http->request("TestAjaxFile");
+
+require_once $w;
diff --git a/html/js/managetable.js b/html/js/managetable.js
index 29e2f07..84c2d88 100644
--- a/html/js/managetable.js
+++ b/html/js/managetable.js
@@ -74,7 +74,51 @@ var ManageTable = function (p_table_name)
 {
     this.callback = "ajax.php"; //!< File to call
     this.control = "dtr"; //<! Prefix Id of dialog box, table, row
+    
+    this.sort_column=0;
     this.param = {"table": p_table_name, "ctl_id": this.control}; //<! default 
value to pass
+    /**
+     * Set the sort , 
+     * @param {string} p_column  column number start from 0
+     * @param {string} p_type type of sort (string, numeric)
+     * @returns {ManageTable.set_sort}
+     */
+    var set_sort = function (p_column) {
+      
+      this.sort_column=p_column;
+    };
+    /**
+     * Insert the row a the right location
+     * @param {type} p_element_row DOMElement TR
+     * @returns nothing
+     */
+    this.insertRow=function(p_table,p_element_row,sort_column) {
+        try {
+        // use the table
+        //compute the length of row
+        //if rows == 0 or the sort is not defined then append 
+        if ( sort_column=-1 || p_table.rows.length < 2 || 
p_table.rows[1].cells[sort_column] == undefined || 
p_table.rows[1].cells[sort_column].getAttribute('sort_value') == undefined ) {
+            p_table.appendChild(p_element_row);
+            return;
+        }
+        // loop for each row , compare the innerHTML of the column with the
+        // value if less than insert before
+        var i = 0;
+        for (i = 1;i<p_table.rows.length;i++) {
+            if (p_table.rows[i].cells[sort_column].getAttribute('sort_value') 
> p_element_row.cells[sort_column].getAttribute('sort_value')) {
+                var row=p_table.insertRow(i);
+                row.innerHTML=p_element_row.innerHTML;
+                row.id=p_element_row.id;
+                return;
+            }
+        }
+        p_table.appendChild(p_element_row);
+    } catch(e) {
+        console.log("insertRow failed with "+e.message);
+        throw e;
+    }
+        
+    };
     var answer = {};
     /**
      address@hidden ManageTable.set_control 
@@ -170,7 +214,10 @@ var ManageTable = function (p_table_name)
                         var new_row = new Element("tr");
                         new_row.id = answer['ctl_row'];
                         new_row.innerHTML = answer['html'];
-                        $("tb"+answer['ctl']).appendChild(new_row);
+                        /**
+                         *  put the element at the right place
+                         */
+                        here.insertRow($("tb"+answer['ctl']) , 
new_row,here.sort_column);
                     }
                     new Effect.Highlight(answer['ctl_row'] ,{startcolor: 
'#FAD4D4',endcolor: '#F78082' });
                     alternate_row_color("tb"+answer['ctl']);
@@ -203,6 +250,7 @@ var ManageTable = function (p_table_name)
         this.param['action'] = 'delete';
         this.param['ctl'] = p_ctl;
         var here=this;
+        $(p_ctl+"_"+p_id).addClassName("highlight");
         smoke.confirm("Confirmez ?",
         function (e)
         {
@@ -222,6 +270,9 @@ var ManageTable = function (p_table_name)
                     }
                 }); 
             }
+            else {
+               $(p_ctl+"_"+p_id).removeClassName("highlight");
+            }
         })   ;
     
     };
@@ -238,6 +289,7 @@ var ManageTable = function (p_table_name)
         this.param['ctl'] = p_ctl;
         var control = this.control;
         var here = this;
+         
         // display the form to enter data
         new Ajax.Request(this.callback, {
             parameters: this.param,
@@ -249,7 +301,7 @@ var ManageTable = function (p_table_name)
                     var obj = {id: control, "cssclass": "inner_box", "html": 
loading()};
                     add_div(obj);
                     var pos = calcy(250);
-                    $(obj.id).setStyle({position: "absolute", top: pos + 'px', 
width: "auto", "margin-left": "20%"});
+                    $(obj.id).setStyle({position: "fixed", top:  '250px', 
width: "auto", "margin-left": "20%"});
                     $(obj.id).update(x['html']);
                 } catch (e) {
                     smoke.alert("ERREUR " + e.message);
diff --git a/html/js/sorttable.js b/html/js/sorttable.js
index d2de7e5..2873e98 100644
--- a/html/js/sorttable.js
+++ b/html/js/sorttable.js
@@ -39,7 +39,7 @@
 
 var stIsIE = /address@hidden@*/false;
 
-sorttable = {
+var sorttable = {
     init: function () {
         // quit if this function has already been called
         if (arguments.callee.done)
diff --git a/include/class/acc_plan_mtable.class.php 
b/include/class/acc_plan_mtable.class.php
new file mode 100644
index 0000000..ef1af27
--- /dev/null
+++ b/include/class/acc_plan_mtable.class.php
@@ -0,0 +1,120 @@
+<?php
+
+/*
+ * Copyright (C) 2017 Dany De Bontridder <address@hidden>
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+/***
+ * @file 
+ * @brief
+ *
+ */
+require_once NOALYSS_INCLUDE.'/database/acc_plan_sql.class.php';
+require_once NOALYSS_INCLUDE.'/lib/manage_table_sql.class.php';
+
+class Acc_Plan_MTable extends Manage_Table_SQL
+{
+    function __construct(Acc_Plan_SQL $p_table)
+    {
+        $this->table = $p_table;
+        parent::__construct($p_table);
+        //--------------------------------------------------------------
+        //Set the table header 
+        //--------------------------------------------------------------
+        $this->set_col_label("pcm_val", _("Poste Comptable"));
+        $this->set_col_label("pcm_type", _("Type"));
+        $this->set_col_label("pcm_lib", _("Libellé"));
+        $this->set_col_label("parent_accounting", _("Dépend"));
+        $this->set_col_label("fiche_qcode", _("Fiche"));
+        //--------------------------------------------------------------
+        $this->set_property_visible("id", FALSE);
+        $this->set_property_updatable("fiche_qcode", FALSE);
+        $this->set_col_type("pcm_type", "select", [
+            ["label"=>_("Actif"),"value"=>"ACT"],
+            ["label"=>_("Actif inversé"),"value"=>"ACTINV"],
+            ["label"=>_("Passif"),"value"=>"PAS"],
+            ["label"=>_("Passif Inversé"),"value"=>"PASINV"],
+            ["label"=>_("Charge"),"value"=>"CHA"],
+            ["label"=>_("Charge inversé"),"value"=>"CHAINV"],
+            ["label"=>_("Produit"),"value"=>"PRO"],
+            ["label"=>_("Produit inversé"),"value"=>"PROINV"],
+            ["label"=>_("Contexte"),"value"=>"CON"]
+        ]);
+    }
+    /**
+     * Display a row
+     * @param type $p_row array of value key column=>value
+     */
+    function display_row($p_row)
+    {
+         printf('<tr  id="%s_%s">', 
+                 $this->object_name,
+                $p_row[$this->table->primary_key])
+        ;
+        
+        
+        $nb_order=count($this->a_order);
+        for ($i=0; $i<$nb_order; $i++)
+        {
+            $v=$this->a_order[$i];
+            if ($v=="pcm_val")
+            {
+                $js=sprintf("onclick=\"%s.input('%s','%s');\"", 
$this->object_name,
+                        $p_row[$this->table->primary_key], $this->object_name);
+                echo sprintf('<td sort_type="text" sort_value="X%s">%s',
+                htmlspecialchars($p_row[$v]),
+                        HtmlInput::anchor($p_row[$v], "", $js)).'</td>';
+            }
+            elseif ($v == "fiche_qcode") {
+                $count=$this->table->cn->get_value("select count(*) from 
fiche_detail where ad_id=5 and ad_value=$1",array($p_row['pcm_val']));
+               if ($count ==  0) echo td("");
+               elseif ($count == 1 ) { echo td($p_row[$v]) ; }
+               elseif ($count > 1) { echo td($p_row[$v] . " ($count) ");} 
+            }
+            else
+            {
+                if ( ! $this->get_property_visible($v)) continue;
+                    echo td($p_row[$v]);
+            }
+        }
+        $this->display_icon_del($p_row);
+
+
+
+        echo '</tr>';
+    }
+    function check() 
+    {
+        $cn=Dossier::connect();
+        $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = 
$1 and id <> $2",
+                    array($this->table->pcm_val,$this->table->id));
+        if ($count > 0 ) {
+            $this->set_error("pcm_val", _("Poste comptable est unique"));
+        }
+        if ( trim($this->table->pcm_val) == "") {
+            $this->set_error("pcm_val", _("Poste comptable ne peut être 
vide"));
+        }
+        if ( trim($this->table->parent_accounting) == "") {
+            $this->set_error("parent_accounting", _("Poste comptable dépendant 
ne peut pas être vide"));
+        }
+        if ( count($this->aerror) > 0 ) return false;
+        return true;
+    }
+   
+    
+}
diff --git a/include/database/acc_plan_sql.class.php 
b/include/database/acc_plan_sql.class.php
new file mode 100644
index 0000000..40d93b0
--- /dev/null
+++ b/include/database/acc_plan_sql.class.php
@@ -0,0 +1,162 @@
+<?php
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   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 (2016) Author Dany De Bontridder <address@hidden>
+
+/**
+ * @file
+ * @brief 
+ * @param type $name Descriptionara
+ */
+require_once NOALYSS_INCLUDE."/lib/data_sql.class.php";
+require_once NOALYSS_INCLUDE."/database/tmp_pcmn_sql.class.php";
+
+class Acc_Plan_SQL extends Data_SQL
+{   
+
+        private $limit_fiche_qcode;
+    function __construct($p_cn, $p_id=-1)
+    {
+        $this->table = "accounting_card";
+        $this->primary_key = "id";
+        $this->limit_fiche_qcode=0;
+        $this->name = array(
+            "id" => "id",
+            "pcm_val"=>"pcm_val",
+            "parent_accounting"=>"parent_accounting",
+            "pcm_lib"=>"pcm_lib",
+            "pcm_type"=>"pcm_type",
+            "fiche_qcode"=>"fiche_qcode"
+        );
+
+        $this->type = array(
+            "id" => "numeric",
+            "pcm_val" => "text",
+            "parent_accounting" => "text",
+            "pcm_lib" => "text",
+            "pcm_type" => "text",
+            "fiche_qcode"=>"string"
+        );
+
+        $this->default = array(
+            "id" => "auto",
+            "fiche_qcode"=>"auto"
+        );
+        $this->sql="
+      SELECT pcm_val,
+      pcm_lib, 
+      pcm_val_parent as parent_accounting, 
+      pcm_type, 
+      id,
+        (select string_agg(m.fiche_qcode,' , ') 
+        from (select a.ad_value as fiche_qcode 
+            from fiche_detail as a 
+            join fiche_detail as b on (a.ad_id=23 and a.f_id=b.f_id and 
b.ad_id=5) 
+            where b.ad_value=pcm_val::text order by a.ad_value %s)as m) as 
fiche_qcode
+      FROM public.tmp_pcmn
+            
+";
+        parent::__construct($p_cn,$p_id);
+     }
+
+    public function count($p_where="", $p_array=null)
+    {
+        throw new Exception("not implemented");
+    }
+
+    public function delete()
+    {
+        $obj=new Tmp_Pcmn_SQL($this->cn,$this->id);
+        return $obj->delete();
+        
+    }
+
+    public function exist()
+    {
+        $obj=new Tmp_Pcmn_SQL($this->cn,$this->id);
+        return $obj->exist();
+    }
+
+    public function insert()
+    {
+        $obj=new Tmp_Pcmn_SQL($this->cn);
+        $obj->set("pcm_val",$this->pcm_val);
+        $obj->set("pcm_lib",$this->pcm_lib);
+        $obj->set("pcm_type",$this->pcm_type);
+        $obj->set("pcm_val_parent",$this->parent_accounting);
+        $obj->insert();
+        $this->id=$obj->id;
+    }
+
+    public function load()
+    {
+        $pk=$this->primary_key;
+        if ( $this->get_limit_fiche_qcode() != 0 ) 
+        {
+            $sql=sprintf($this->sql," limit ".$this->get_limit_fiche_qcode());
+        } else
+        {
+            $sql=sprintf($this->sql,"  ");
+        }
+        $result=$this->cn->get_array($sql. " where id=$1",array ($this->$pk));
+        if ($this->cn->count()==0)
+        {
+            $this->$pk=-1;
+            return;
+        }
+
+        foreach ($result[0] as $key=> $value)
+        {
+            $this->$key=$value;
+        }
+    }
+
+    public function seek($cond='', $p_array=null)
+    {
+        if ( $this->get_limit_fiche_qcode() != 0 ) 
+        {
+            $sql=sprintf($this->sql," limit ".$this->get_limit_fiche_qcode());
+        } else
+        {
+            $sql=sprintf($this->sql,"  ");
+        }
+        $ret=$this->cn->exec_sql($sql." ".$cond,$p_array);
+        return $ret;
+    }
+
+    public function update()
+    {
+       $obj=new Tmp_Pcmn_SQL($this->cn,$this->id);
+       $obj->set("pcm_val",$this->pcm_val);
+       $obj->set("pcm_lib",$this->pcm_lib);
+       $obj->set("pcm_type",$this->pcm_type);
+       $obj->set("pcm_val_parent",$this->parent_accounting);
+       $obj->update(); 
+    }
+     public function get_limit_fiche_qcode()
+    {
+        return $this->limit_fiche_qcode;
+    }
+
+    public function set_limit_fiche_qcode($limit_fiche_qcode)
+    {
+        $this->limit_fiche_qcode=$limit_fiche_qcode;
+    }
+
+}
\ No newline at end of file
diff --git a/include/database/tmp_pcmn_sql.class.php 
b/include/database/tmp_pcmn_sql.class.php
new file mode 100644
index 0000000..183886d
--- /dev/null
+++ b/include/database/tmp_pcmn_sql.class.php
@@ -0,0 +1,63 @@
+<?php
+
+/*
+ * Copyright (C) 2017 Dany De Bontridder <address@hidden>
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+/* * *
+ * @file 
+ * @brief
+ *
+ */
+require_once NOALYSS_INCLUDE."/lib/noalyss_sql.class.php";
+class Tmp_Pcmn_SQL extends Noalyss_SQL
+{
+
+    /**
+     * @brief manage table key_distribution_detail
+     */
+    function __construct(&$p_cn, $p_id=-1)
+    {
+
+        $this->table="public.tmp_pcmn";
+        $this->primary_key="id";
+
+        $this->name=array(
+            "id"=>"id",
+            "pcm_val"=>"pcm_val",
+            "pcm_type"=>"pcm_type",
+            "pcm_val_parent"=>"pcm_val_parent",
+            "pcm_lib"=>"pcm_lib"
+        );
+
+        $this->type=array(
+            "id"=>"numeric",
+            "pcm_val"=>"text",
+            "pcm_type"=>"text",
+            "pcm_val_parent"=>"text",
+            "pcm_lib"=>"text"
+        );
+
+        $this->default=array(
+            "id"=>"auto"
+        );
+
+        parent::__construct($p_cn, $p_id);
+    }
+
+}
diff --git a/include/lib/noalyss_sql.class.php b/include/lib/data_sql.class.php
similarity index 62%
copy from include/lib/noalyss_sql.class.php
copy to include/lib/data_sql.class.php
index 35b5677..99f1af6 100644
--- a/include/lib/noalyss_sql.class.php
+++ b/include/lib/data_sql.class.php
@@ -23,9 +23,22 @@
 /**
  * @file
  * @brief this wrapper is used to created easily a wrapper to a table
+ * You must create a class extending this one, in the constructor
+ * these variables have to be defined
+ * 
+ *   - table = name of the view or empty
+ *   - select = name of the select
+ *   - name = array of column name, match between logic and actual name
+ *   - type = array , match between column and type of data
+ *   - default = array of column with a default value
+ *   - date_format = format of the date
+ * 
+ * After you call the parent constructor
+ * @note the view or the table must include an unique key, otherwise the load 
+ * doesn't work.
  *
  * @class Noalyss_SQL
- * Match a table into an object, you need to add the code for each table
+ * Match a table or a view into an object, you need to add the code for each 
table
  * @note : the primary key must be an integer
  *
  * @code
@@ -39,7 +52,7 @@
 
   $this->name=array(
   "id"=>"o_id",
-  "dolibarr"=>"o_doli",
+  "program"=>"o_prog",
   "date"=>"o_date",
   "qcode"=>"o_qcode",
   "fiche"=>"f_id",
@@ -49,7 +62,7 @@
 
   $this->type = array(
   "o_id"=>"numeric",
-  "o_doli"=>"numeric",
+  "o_prog"=>"numeric",
   "o_date"=>"date",
   "o_qcode"=>"text",
   "f_id"=>"numeric",
@@ -69,10 +82,10 @@
  * @endcode
  *
  */
-abstract class Noalyss_SQL
+abstract class Data_SQL
 {
 
-    function __construct(&$p_cn, $p_id=-1)
+   function __construct($p_cn, $p_id=-1)
     {
         $this->cn=$p_cn;
         $pk=$this->primary_key;
@@ -154,79 +167,13 @@ abstract class Noalyss_SQL
             throw new Exception(__FILE__.":".__LINE__.$p_string.'Erreur 
attribut inexistant '.$p_string);
     }
 
-    public function insert()
-    {
-        $this->verify();
-        $sql="insert into ".$this->table." ( ";
-        $sep="";
-        $par="";
-        $idx=1;
-        $array=array();
-        foreach ($this->name as $key=> $value)
-        {
-            if 
(isset($this->default[$value])&&$this->default[$value]=="auto"&&$this->$value==null)
-                continue;
-            if ($value==$this->primary_key&&$this->$value==-1)
-                continue;
-            $sql.=$sep.$value;
-            switch ($this->type[$value])
-            {
-                case "date":
-                    if ($this->date_format=="")
-                        throw new Exception('Format Date invalide');
-                    $par 
.=$sep.'to_timestamp($'.$idx.",'".$this->date_format."')";
-                    break;
-                default:
-                    $par .= $sep."$".$idx;
-            }
+    abstract function insert();
 
-            $array[]=$this->$value;
-            $sep=",";
-            $idx++;
-        }
-        $sql.=") values (".$par.") returning ".$this->primary_key;
-        $pk=$this->primary_key;
-        $this->$pk=$this->cn->get_value($sql, $array);
-    }
+    abstract function delete();
 
-    public function delete()
-    {
-        $pk=$this->primary_key;
-        $sql=" delete from ".$this->table." where ".$this->primary_key."= $1";
-        $this->cn->exec_sql($sql,array($this->$pk));
-    }
+    abstract  function update();
 
-    public function update()
-    {
-        $this->verify();
-        $pk=$this->primary_key;
-        $sql="update ".$this->table."  ";
-        $sep="";
-        $idx=1;
-        $array=array();
-        $set=" set ";
-        foreach ($this->name as $key=> $value)        {
-            if (isset($this->default[$value])&&$this->default[$value]=="auto")
-                continue;
-            switch ($this->type[$value])
-            {
-                case "date":
-                    
$par=$value.'=to_timestamp($'.$idx.",'".$this->date_format."')";
-                    break;
-                default:
-                    $par=$value."= $".$idx;
-            }
-            $sql.=$sep." $set ".$par;
-            $array[]=$this->$value;
-            $sep=",";
-            $set="";
-            $idx++;
-        }
-        $array[]=$this->$pk;
-        $sql.=" where ".$this->primary_key." = $".$idx;
-        $this->cn->exec_sql($sql, $array);
-    }
-     public function set_pk_value($p_value)
+    public function set_pk_value($p_value)
      {
          $pk=$this->primary_key;
            $this->$pk=$p_value;
@@ -237,38 +184,7 @@ abstract class Noalyss_SQL
           return $this->$pk;
     }
 
-    public function load()
-    {
-        $sql=" select ";
-        $sep="";
-        foreach ($this->name as $key)       {
-            switch ($this->type[$key])
-            {
-                case "date":
-                    $sql .= $sep.'to_char('.$key.",'".$this->date_format."') 
as ".$key;
-                    break;
-                default:
-                    $sql.=$sep.$key;
-            }
-            $sep=",";
-        }
-        $pk=$this->primary_key;
-        $sql.=" from ".$this->table;
-        
-        $sql.=" where ".$this->primary_key." = $1";
-       
-        $result=$this->cn->get_array($sql,array ($this->$pk));
-        if ($this->cn->count()==0)
-        {
-            $this->$pk=-1;
-            return;
-        }
-
-        foreach ($result[0] as $key=> $value)
-        {
-            $this->$key=$value;
-        }
-    }
+    abstract function load();
 
     public function get_info()
     {
@@ -331,12 +247,7 @@ abstract class Noalyss_SQL
      * @see Database::exec_sql get_object  Database::num_row
      * @return the return value of exec_sql
      */
-    function seek($cond='', $p_array=null)
-    {
-        $sql="select * from ".$this->table."  $cond";
-        $ret=$this->cn->exec_sql($sql, $p_array);
-        return $ret;
-    }
+    abstract  function seek($cond='', $p_array=null);
 
     /**
      * get_seek return the next object, the return of the query must have all 
the column
@@ -361,7 +272,8 @@ abstract class Noalyss_SQL
     }
 
     /**
-     * @brief return an array of objects. Do not use this function if they are 
too many objects, it takes a lot of memory,
+     * @brief return an array of objects. 
+     * Do not use this function if they are too many objects, it takes a lot 
of memory,
      * and could slow down your application.
      * @param $cond condition, order...
      * @param $p_array array to use for a condition
@@ -382,19 +294,13 @@ abstract class Noalyss_SQL
         }
         return $a_return;
     }
-    public function count($p_where="",$p_array=null) {
-        $count=$this->cn->get_value("select count(*) from 
$this->table".$p_where,$p_array);
-        return $count;
-    }
+    abstract function count($p_where="",$p_array=null) ;
+    
     /**
      * Count the number of record with the id ,
      * @return integer  0 doesn't exist , 1 exists
      */
-    public function exist() {
-        $pk=$this->primary_key;
-        $count=$this->cn->get_value("select count(*) from ".$this->table." 
where ".$this->primary_key."=$1",array($this->$pk));
-        return $count;
-    }
+    abstract function exist() ;
 }
 
 ?>
diff --git a/include/lib/manage_table_sql.class.php 
b/include/lib/manage_table_sql.class.php
index 0ea82c7..0021c55 100644
--- a/include/lib/manage_table_sql.class.php
+++ b/include/lib/manage_table_sql.class.php
@@ -50,34 +50,42 @@
   $objet->param_set($json);
 
   // Display the box
-  $xml=$objet->ajax_input();
+    header('Content-type: text/xml; charset=UTF-8');
+    $xml=$objet->ajax_input();
+    echo $xml->save_XML();
   @endcode
  * @see ManageTable.js
  */
 class Manage_Table_SQL
 {
 
-    private $table; //!< Object Noalyss_SQL
-    private $a_label_displaid; //!< Label of the col. of the datarow
-    private $a_order; //!< order of the col
-    private $a_prop; //!< property for each col.
-    private $a_type; //!< Type of the column : date , select ... Only in input
-    private $a_select; //!< Possible value if a_type is a SELECT
-    private $object_name; //!< Object_name is used for the javascript
-    private $row_delete; //!< Flag to indicate if rows can be deleted
-    private $row_update; //!< Flag to indicate if rows can be updated
-    private $row_append; //!< Flag to indicate if rows can be added
-    private $json_parameter; //!< Default parameter to add (gDossier...)
-    private $aerror; //!< Array containing the error of the input data
+    protected $table; //!< Object Data_SQL
+    protected $a_label_displaid; //!< Label of the col. of the datarow
+    protected $a_order; //!< order of the col
+    protected $a_prop; //!< property for each col.
+    protected $a_type; //!< Type of the column : date , select ... Only in 
input
+    protected $a_select; //!< Possible value if a_type is a SELECT
+    protected $object_name; //!< Object_name is used for the javascript
+    protected $row_delete; //!< Flag to indicate if rows can be deleted
+    protected $row_update; //!< Flag to indicate if rows can be updated
+    protected $row_append; //!< Flag to indicate if rows can be added
+    protected $json_parameter; //!< Default parameter to add (gDossier...)
+    protected $aerror; //!< Array containing the error of the input data
+    protected $col_sort; //!< when inserting, it is the column to sort,-1 to 
disable it and append only
+
     const UPDATABLE=1;
     const VISIBLE=2;
 
+    private $icon_mod; //!< place of right or left the icon update or mod, 
default right, accepted value=left,right,first column for mod
+    private $icon_del; //!< place of right or left the icon update or mod, 
default right, accepted value=left,right
+
     /**
      * @brief Constructor : set the label to the column name,
      * the order of the column , set the properties and the
      * permission for updating or deleting row
      */
-    function __construct(Noalyss_SQL $p_table)
+
+    function __construct(Data_SQL $p_table)
     {
         $this->table=$p_table;
         $order=0;
@@ -96,26 +104,62 @@ class Manage_Table_SQL
         $this->row_update=TRUE;
         $this->row_append=TRUE;
         $this->callback="ajax.php";
-        $this->json=json_encode(array("gDossier"=>Dossier::id(),
+        $this->json_parameter=json_encode(array("gDossier"=>Dossier::id(),
             "op"=>"managetable"));
         $this->aerror=[];
+        $this->icon_mod="right";
+        $this->icon_del="right";
+        $this->col_sort=0;
+    }
+    /**
+     * When adding an element , it is column we checked to insert before,
+     * @return none
+     */
+    function get_col_sort() {
+        return $this->col_sort;
     }
-    function get_table() {
+    /**
+     * When adding an element ,we place it thanks the DOM Attribute sort_value
+     * set it to -1 if you want one to append
+     * @param numeric $pn_num
+     * @note you must be aware that the icon_mod or icon_del is in the first 
col, 
+     * this column is skipped
+     */
+    function set_col_sort($p_num) {
+        $this->col_sort=$p_num;
+    }
+    function get_icon_mod()
+    {
+        return $this->icon_mod;
+    }
+    function get_icon_del()
+    {
+        return $this->icon_del;
+    }
+    function get_table()
+    {
         return $this->table;
     }
-    function set_table(Noalyss_SQL $p_noalyss_sql) {
+
+    function set_table(Data_SQL $p_noalyss_sql)
+    {
         $this->table=$p_noalyss_sql;
     }
+    function get_order()
+    {
+        return $this->a_order;
+    }
     /**
      * @brief set the error message for a wrong input
      * @param $p_col the column name 
      * @param $p_message the error message
      * @see check
      */
-    function set_error($p_col,$p_message) 
+    function set_error($p_col, $p_message)
     {
         $this->aerror[$p_col]=$p_message;
     }
+
     /**
      * @brief retrieve the error message
      * @param $p_col column name
@@ -124,9 +168,11 @@ class Manage_Table_SQL
      */
     function get_error($p_col)
     {
-        if ( isset ($this->aerror[$p_col])) return $this->aerror[$p_col];
+        if (isset($this->aerror[$p_col]))
+            return $this->aerror[$p_col];
         return "";
     }
+
     /**
      * This function can be overrided to check the data before 
      * inserting , updating or removing,
@@ -137,6 +183,7 @@ class Manage_Table_SQL
     {
         return true;
     }
+
     /**
      * @brief set the type of a column , it will change in the input db box , 
the
      * select must supply an array of possible values [val=> , label=>] with
@@ -157,6 +204,7 @@ class Manage_Table_SQL
         $this->a_type[$p_key]=$p_value;
         $this->a_select[$p_key]=$p_array;
     }
+
     /**
      * @brief return the type of a column 
      * @param $p_key col name
@@ -180,19 +228,44 @@ class Manage_Table_SQL
     {
         return $this->object_name;
     }
-
+    /**
+     * Add json parameter to the current one
+     */
+    function add_json_param($p_attribute,$p_value) {
+        $x=json_decode($this->json_parameter,TRUE);
+        $x[$p_attribute]=$p_value;
+        $this->json_parameter=json_encode($x);
+    }
+    function get_json()
+    {
+        return $this->json_parameter;
+    }
+    function get_object_name() {
+        return $this->object_name;
+    }
     /**
      * Set the parameter of the object (gDossier, ac, plugin_code...)
      * @detail By default , only gDossier will be set . The default value
      * is given in the constructor
      * @param string with json format $p_json 
-     * 
+     * @deprecated since version 692
+     * @see set_json
      */
     function param_set($p_json)
     {
+        $this->set_json($p_json);
+    }
+    /**
+     * Set the parameter of the object (gDossier, ac, plugin_code...)
+     * @detail By default , only gDossier will be set . The default value
+     * is given in the constructor
+     * @param string with json format $p_json 
+     */
+    function set_json($p_json)
+    {
         $this->json_parameter=$p_json;
+        
     }
-
     /**
      * @brief set the callback function that is passed to javascript
      * @param $p_file  : callback file by default ajax.php
@@ -213,6 +286,7 @@ class Manage_Table_SQL
                var {$this->object_name}=new 
ManageTable(\"{$this->table->table}\");
                {$this->object_name}.set_callback(\"{$this->callback}\");
                {$this->object_name}.param_add({$this->json_parameter});
+               {$this->object_name}.set_sort({$this->get_col_sort()});
                </script>
 
        ";
@@ -220,7 +294,8 @@ class Manage_Table_SQL
 
     /**
      * Set the object_name 
-     * @param string $p_object_name name of the JS var, used in ajax response
+     * @param string $p_object_name name of the JS var, used in ajax 
response,id
+     * of the part of the id DOMElement to modify
      */
     function set_object_name($p_object_name)
     {
@@ -234,8 +309,10 @@ class Manage_Table_SQL
      */
     function set_property_updatable($p_key, $p_value)
     {
-        if (!$this->a_prop[$p_key])
+        if (! isset($this->a_prop[$p_key]))
             throw new Exception(__FILE__.":".__LINE__."$p_key invalid index");
+        // if already done returns 
+        if ( $this->get_property_updatable($p_key) == $p_value)return;
         if ($p_value==False)
             $this->a_prop[$p_key]=$this->a_prop[$p_key]-self::UPDATABLE;
         elseif ($p_value==True)
@@ -252,7 +329,27 @@ class Manage_Table_SQL
 
         return $this->row_update;
     }
-
+    /**
+     * Set the icon to modify at the right ,the first col or left of the row
+     * 
+     * @param type $pString
+     * @throws Exception
+     */
+    function set_icon_mod($pString) {
+        if ($pString != "right" && $pString != "left" && $pString!="first") 
+            throw new Exception('set_icon_mod invalide '.$pString);
+        $this->icon_mod=$pString;
+    }
+    /**
+     * Set the icon to delete at the right or left of the row
+     * @param type $pString
+     * @throws Exception
+     */
+    function set_icon_del($pString) {
+        if ($pString != "right" && $pString != "left" ) 
+            throw new Exception('set_icon_del invalide '.$pString);
+        $this->icon_del=$pString;
+    }
     /**
      * @brief return false if the append of the row is forbidden
      */
@@ -322,8 +419,11 @@ class Manage_Table_SQL
      */
     function set_property_visible($p_key, $p_value)
     {
-        if (!$this->a_prop[$p_key])
+        if (!isset ($this->a_prop[$p_key]) )
             throw new Exception(__FILE__.":".__LINE__."$p_key invalid index");
+        // if already done return
+        if ( $this->get_property_visible($p_key) == $p_value)return;
+        
         if ($p_value==False)
             $this->a_prop[$p_key]=$this->a_prop[$p_key]-self::VISIBLE;
         elseif ($p_value==True)
@@ -422,17 +522,24 @@ class Manage_Table_SQL
 
     /**
      * @brief display the data of the table
+     * @param $p_order is the cond or order of the rows, 
+     * if empty the primary key will be used
+     * @param $p_array array of the bind variables
+     * @note the function create_js_script MUST be called before this function
      */
-    function display_table()
+    function display_table($p_order="", $p_array=NULL)
     {
-        $ret=$this->table->seek("order by ".$this->table->primary_key);
+        if ($p_order=="")
+        {
+            $p_order="order by {$this->table->primary_key}";
+        }
+        $ret=$this->table->seek($p_order, $p_array);
         $nb=Database::num_row($ret);
         if ($this->can_append_row()==TRUE)
         {
             echo HtmlInput::button_action(" "._("Ajout"),
-                    sprintf("%s.input('-1','%s')", 
-                            $this->object_name,
-                            $this->object_name),"xx","smallbutton",BUTTONADD);
+                    sprintf("%s.input('-1','%s')", $this->object_name,
+                            $this->object_name), "xx", "smallbutton", 
BUTTONADD);
         }
         $nb_order=count($this->a_order);
         $virg=""; $result="";
@@ -458,12 +565,12 @@ class Manage_Table_SQL
         echo "</table>";
         if ($this->can_append_row()==TRUE)
         {
-              echo HtmlInput::button_action(" "._("Ajout"),
-                    sprintf("%s.input('-1','%s')", 
-                            $this->object_name,
-                            $this->object_name),"xx","smallbutton",BUTTONADD);
+            echo HtmlInput::button_action(" "._("Ajout"),
+                    sprintf("%s.input('-1','%s')", $this->object_name,
+                            $this->object_name), "xx", "smallbutton", 
BUTTONADD);
         }
-        printf ('<script> alternate_row_color("tb%s");</script>', 
$this->object_name);
+        printf('<script> alternate_row_color("tb%s");</script>',
+                $this->object_name);
     }
 
     /**
@@ -475,19 +582,29 @@ class Manage_Table_SQL
         $nb=count($this->a_order);
         echo "<tr>";
 
+        if ($this->can_update_row() && $this->icon_mod=="left")
+        {
+            echo th("  ", 'style="width:40px"');
+        }
+        if ($this->can_delete_row() && $this->icon_del=="left")
+        {
+            echo th(" ", 'style="width:40px"');
+        }
         for ($i=0; $i<$nb; $i++)
         {
 
             $key=$this->a_order[$i];
 
             if ($this->get_property_visible($key)==true)
-                echo th($this->a_label_displaid[$key]);
+                echo th("","",$this->a_label_displaid[$key]);
         }
-        if ($this->can_update_row()) {
-            echo th("  ",'style="width:40px"');
+        if ($this->can_update_row() && $this->icon_mod=="right")
+        {
+            echo th("  ", 'style="width:40px"');
         }
-        if ($this->can_delete_row()) {
-            echo th(" ",'style="width:40px"');
+        if ($this->can_delete_row() && $this->icon_del=="right")
+        {
+            echo th(" ", 'style="width:40px"');
         }
         echo "</tr>";
     }
@@ -511,53 +628,90 @@ class Manage_Table_SQL
         $nb=count($this->a_order);
         for ($i=0; $i<$nb; $i++)
         {
-            $v=HtmlInput::default_value_request($this->a_order[$i], "");
+            
             $key=$this->a_order[$i];
-            if ( $this->get_property_visible($key) == TRUE 
-                    && $this->get_property_updatable($key) == TRUE )
+            if 
($this->get_property_visible($key)==TRUE&&$this->get_property_updatable($key)
+                    ==TRUE)
             {
+                $v=HtmlInput::default_value_request($this->a_order[$i], "");
                 $this->table->$key=strip_tags($v);
             }
         }
     }
 
+    function display_icon_mod($p_row)
+    {
+        if ($this->can_update_row())
+        {
+            echo "<td>";
+            $js=sprintf("%s.input('%s','%s');", $this->object_name,
+                    $p_row[$this->table->primary_key], $this->object_name
+            );
+            echo HtmlInput::image_click("edit.png", $js, _("Modifier"));
+            echo "</td>";
+        }
+    }
+
+    function display_icon_del($p_row)
+    {
+        if ($this->can_delete_row())
+        {
+            echo "<td>";
+            $js=sprintf("%s.delete('%s','%s');", $this->object_name,
+                    $p_row[$this->table->primary_key], $this->object_name
+            );
+            echo HtmlInput::image_click("delete.gif", $js, _("Effacer"));
+            echo "</td>";
+        }
+    }
+
     /**
      * @brief display a data row in the table, with the order defined
      * in a_order and depending of the visibility of the column
      * @see display_table
      */
-    private function display_row($p_row)
+    function display_row($p_row)
     {
 
         printf('<tr id="%s_%s">', $this->object_name,
                 $p_row[$this->table->primary_key])
         ;
-
+        
+        if ($this->icon_mod=="left")
+            $this->display_icon_mod($p_row);
+        if ($this->icon_del=="left")
+            $this->display_icon_del($p_row);
+        
         $nb_order=count($this->a_order);
         for ($i=0; $i<$nb_order; $i++)
         {
             $v=$this->a_order[$i];
-            if ($this->get_property_visible($v))
+            if ($i==0&&$this->icon_mod=="first"&&$this->can_update_row())
+            {
+                $js=sprintf("onclick=\"%s.input('%s','%s');\"", 
$this->object_name,
+                        $p_row[$this->table->primary_key], $this->object_name);
+                $td=($i == $this->col_sort ) ? sprintf('<td sort_value="X%s" 
>',$p_row[$v]):"<td>";
+                echo $td.HtmlInput::anchor($p_row[$v], "", $js).'</td>';
+            }
+            elseif ( $i == $this->col_sort && $this->get_property_visible($v))
+            {
+                echo td($p_row[$v],sprintf(' sort_value="X%s" ',$p_row[$v]));
+            }
+            elseif ( ! $this->get_property_visible($v)) { 
+                continue;
+            }
+            else
+            {
                 echo td($p_row[$v]);
+            }
         }
-        echo "<td>";
-        if ($this->can_update_row())
-        {
-            $js=sprintf("%s.input('%s','%s');", $this->object_name,
-                    $p_row[$this->table->primary_key], $this->object_name
-            );
-            echo HtmlInput::image_click("edit.png",$js,_("Modifier"));
-        }
-        echo "</td>";
-        echo "<td>";
-        if ($this->can_delete_row())
-        {
-            $js=sprintf("%s.delete('%s','%s');", $this->object_name,
-                    $p_row[$this->table->primary_key], $this->object_name
-            );
-            echo HtmlInput::image_click("delete.gif", $js,_("Effacer"));
-        }
-        echo "</td>";
+        if ($this->icon_mod=="right")
+            $this->display_icon_mod($p_row);
+        if ($this->icon_del=="right")
+            $this->display_icon_del($p_row);
+
+
+
         echo '</tr>';
     }
 
@@ -587,7 +741,7 @@ class Manage_Table_SQL
                     echo "<td>";
                     if ($this->a_type[$key]=="select")
                     {
-                        $select = new ISelect($key);
+                        $select=new ISelect($key);
                         $select->value=$this->a_select[$key];
                         $select->selected=$value;
                         echo $select->input();
@@ -647,10 +801,13 @@ class Manage_Table_SQL
             // Check if the data are valid , if not then display the
             // input values with the error message 
             //
-            if ( $this->check() == false ) {
+            if ($this->check()==false)
+            {
                 $xml=$this->ajax_input("NOK");
                 return $xml;
-            } else {
+            }
+            else
+            {
                 // Data are valid so we can save them
                 $this->save();
                 // compose the answer
@@ -665,7 +822,7 @@ class Manage_Table_SQL
                 $this->display_row($array);
                 $html=ob_get_contents();
                 ob_end_clean();
-                $s3=$xml->createElement("html" );
+                $s3=$xml->createElement("html");
                 $t1=$xml->createTextNode($html);
                 $s3->appendChild($t1);
             }
@@ -681,7 +838,7 @@ class Manage_Table_SQL
         {
             $s1=$xml->createElement("status", "NOK");
             $s2=$xml->createElement("ctl_row",
-            $this->object_name+"_"+$this->table->get_pk_value());
+                    $this->object_name+"_"+$this->table->get_pk_value());
             $s4=$xml->createElement("ctl", $this->object_name);
             $s3=$xml->createElement("html", $ex->getTraceAsString());
             $root=$xml->createElement("data");
@@ -710,7 +867,7 @@ class Manage_Table_SQL
         {
             $status=$p_status;
             ob_start();
-               
+
             echo HtmlInput::title_box("Donnée", "dtr");
             printf('<form id="frm%s_%s" method="POST" 
onsubmit="%s.save(\'frm%s_%s\');return false;">',
                     $this->object_name, $this->table->get_pk_value(),
@@ -729,12 +886,12 @@ class Manage_Table_SQL
             HtmlInput::submit('update', _("OK")),
             '</li>',
             '<li>',
-            HtmlInput::button_action(_("Cancel"), $close,"","smallbutton"),
+            HtmlInput::button_action(_("Cancel"), $close, "", "smallbutton"),
             '</li>',
             '</ul>';
             echo "</form>";
-            
-            
+
+
             $html=ob_get_contents();
             ob_end_clean();
 
@@ -742,7 +899,7 @@ class Manage_Table_SQL
             $ctl=$this->object_name."_".$this->table->get_pk_value();
             $s2=$xml->createElement("ctl_row", $ctl);
             $s4=$xml->createElement("ctl", $this->object_name);
-            $s3=$xml->createElement("html" );
+            $s3=$xml->createElement("html");
             $t1=$xml->createTextNode($html);
             $s3->appendChild($t1);
 
@@ -821,13 +978,13 @@ class Manage_Table_SQL
     }
 
     /**
-     * @brief save the Noalyss_SQL Object
+     * @brief save the Data_SQL Object
      * The noalyss_SQL is not empty
      * @see from_request
      */
     function save()
     {
-       $this->table->save();
+        $this->table->save();
     }
 
     /**
@@ -859,6 +1016,7 @@ class Manage_Table_SQL
     {
         $this->table->set($p_key, $p_value);
     }
+
     /**
      * Display a list of the error collected
      * @see get_error set_error 
@@ -867,16 +1025,17 @@ class Manage_Table_SQL
     function display_error()
     {
         $nb_order=count($this->a_order);
-        if ( count($this->aerror) == 0)return;
+        if (count($this->aerror)==0)
+            return;
         echo "<span class=\"notice\">Liste erreurs :</span>";
-        for ($i=0; $i<$nb_order; $i++)        
+        for ($i=0; $i<$nb_order; $i++)
         {
-             $key=$this->a_order[$i];
-             $label=$this->a_label_displaid[$key];
-             $error=$this->get_error($key);
-             $error=($error=="")?"":"<span class=\"notice\" 
style=\"font-weight:normal;font-style:normal;display:block\">".h($label)." : 
".h($this->get_error($key))."</span>";
-             
-             echo $error;
+            $key=$this->a_order[$i];
+            $label=$this->a_label_displaid[$key];
+            $error=$this->get_error($key);
+            $error=($error=="")?"":"<span class=\"notice\" 
style=\"font-weight:normal;font-style:normal;display:block\">".h($label)." : 
".h($this->get_error($key))."</span>";
+
+            echo $error;
         }
         echo "</ul>";
     }
diff --git a/include/lib/noalyss_sql.class.php 
b/include/lib/noalyss_sql.class.php
index 35b5677..043d659 100644
--- a/include/lib/noalyss_sql.class.php
+++ b/include/lib/noalyss_sql.class.php
@@ -23,9 +23,22 @@
 /**
  * @file
  * @brief this wrapper is used to created easily a wrapper to a table
+ * You must create a class extending this one, in the constructor
+ * these variables have to be defined
+ * 
+ *   - table = name of the view or empty
+ *   - select = name of the select
+ *   - name = array of column name, match between logic and actual name
+ *   - type = array , match between column and type of data
+ *   - default = array of column with a default value
+ *   - date_format = format of the date
+ * 
+ * After you call the parent constructor
+ * @note the view or the table must include an unique key, otherwise the load 
+ * doesn't work.
  *
  * @class Noalyss_SQL
- * Match a table into an object, you need to add the code for each table
+ * Match a table or a view into an object, you need to add the code for each 
table
  * @note : the primary key must be an integer
  *
  * @code
@@ -39,7 +52,7 @@
 
   $this->name=array(
   "id"=>"o_id",
-  "dolibarr"=>"o_doli",
+  "program"=>"o_prog",
   "date"=>"o_date",
   "qcode"=>"o_qcode",
   "fiche"=>"f_id",
@@ -49,7 +62,7 @@
 
   $this->type = array(
   "o_id"=>"numeric",
-  "o_doli"=>"numeric",
+  "o_prog"=>"numeric",
   "o_date"=>"date",
   "o_qcode"=>"text",
   "f_id"=>"numeric",
@@ -69,7 +82,9 @@
  * @endcode
  *
  */
-abstract class Noalyss_SQL
+require NOALYSS_INCLUDE."/lib/data_sql.class.php";
+
+abstract class Noalyss_SQL extends Data_SQL
 {
 
     function __construct(&$p_cn, $p_id=-1)
@@ -122,7 +137,7 @@ abstract class Noalyss_SQL
     public function set($p_string, $p_value)
     {
         if (array_key_exists($p_string, $this->type))    {
-            $this->$idx=$p_value;
+            $this->$p_string=$p_value;
         }        else
             throw new Exception(__FILE__.":".__LINE__.$p_string.'Erreur 
attribut inexistant '.$p_string);
     }
@@ -361,7 +376,8 @@ abstract class Noalyss_SQL
     }
 
     /**
-     * @brief return an array of objects. Do not use this function if they are 
too many objects, it takes a lot of memory,
+     * @brief return an array of objects. 
+     * Do not use this function if they are too many objects, it takes a lot 
of memory,
      * and could slow down your application.
      * @param $cond condition, order...
      * @param $p_array array to use for a condition
diff --git a/scenario/ajax_manage_table_sql.php 
b/scenario/ajax_acc_plan_mtable.php
similarity index 64%
copy from scenario/ajax_manage_table_sql.php
copy to scenario/ajax_acc_plan_mtable.php
index 8ae6e27..16d6407 100644
--- a/scenario/ajax_manage_table_sql.php
+++ b/scenario/ajax_acc_plan_mtable.php
@@ -21,8 +21,8 @@
 
 if (!defined('ALLOWED'))
     die('Appel direct ne sont pas permis');
-if ( ! defined ("AJAX_TEST ")) {
-     echo "Can not be called directly but via AJAX";
+if ( ! defined ("AJAX_TEST")) {
+     echo "Can not be called directly but via ajax_test.php";
      return;
 }
 /**
@@ -31,31 +31,35 @@ if ( ! defined ("AJAX_TEST ")) {
  */
 $http=new HttpInput();
 try {
-$table=$http->get('table');
-$action=$http->get('action');
-$p_id=$http->get('p_id', "numeric");
-$ctl_id=$http->get('ctl');
+$table=$http->request('table');
+$action=$http->request('action');
+$p_id=$http->request('p_id', "numeric");
+$ctl_id=$http->request('ctl');
 } catch(Exception $e) {
    
     echo $e->getMessage();
 }
 require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php";
-require_once NOALYSS_INCLUDE."/database/acc_plan_sql.class.php";
+require_once NOALYSS_INCLUDE."/class/acc_plan_mtable.class.php";
 
-$obj=new Acc_Plan_SQL($cn, $p_id);
-$manage_table=new Manage_Table_SQL($obj);
+$obj=new Acc_Plan_SQL($cn);
+$obj->set_limit_fiche_qcode(5);
+$obj->set_pk_value($p_id);
+$obj->load();
+$manage_table=new Acc_Plan_MTable($obj);
 $manage_table->add_json_param("TestAjaxFile",
-        NOALYSS_HOME."/../scenario/ajax_manage_table_sql.php");
-
+        NOALYSS_HOME."/../scenario/ajax_acc_plan_mtable.php");
+$manage_table->set_object_name($ctl_id);
+$manage_table->set_callback("ajax_test.php");
 if ($action=="input")
 {
-    $manage_table->set_object_name($ctl_id);
-    $manage_table->set_col_label('pcm_val', "Poste");
-    $manage_table->set_col_label('parent_accounting', "Dépend");
-    $manage_table->set_col_label('pcm_lib', "Libellé");
-    $manage_table->set_col_label('pcm_type',
-            "Type de menu".HtmlInput::infobulle(33));
     header('Content-type: text/xml; charset=UTF-8');
     echo $manage_table->ajax_input()->saveXML();
     return;
+}
+elseif ($action == "save") 
+{
+    $xml=$manage_table->ajax_save();
+     header('Content-type: text/xml; charset=UTF-8');
+     echo $xml->saveXML();
 }
\ No newline at end of file
diff --git a/scenario/ajax_manage_table_sql.php 
b/scenario/ajax_manage_table_sql.php
index 8ae6e27..22c0e64 100644
--- a/scenario/ajax_manage_table_sql.php
+++ b/scenario/ajax_manage_table_sql.php
@@ -21,7 +21,7 @@
 
 if (!defined('ALLOWED'))
     die('Appel direct ne sont pas permis');
-if ( ! defined ("AJAX_TEST ")) {
+if ( ! defined ("AJAX_TEST")) {
      echo "Can not be called directly but via AJAX";
      return;
 }
@@ -31,10 +31,10 @@ if ( ! defined ("AJAX_TEST ")) {
  */
 $http=new HttpInput();
 try {
-$table=$http->get('table');
-$action=$http->get('action');
-$p_id=$http->get('p_id', "numeric");
-$ctl_id=$http->get('ctl');
+$table=$http->request('table');
+$action=$http->request('action');
+$p_id=$http->request('p_id', "numeric");
+$ctl_id=$http->request('ctl');
 } catch(Exception $e) {
    
     echo $e->getMessage();
@@ -42,13 +42,18 @@ $ctl_id=$http->get('ctl');
 require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php";
 require_once NOALYSS_INCLUDE."/database/acc_plan_sql.class.php";
 
-$obj=new Acc_Plan_SQL($cn, $p_id);
-$manage_table=new Manage_Table_SQL($obj);
-$manage_table->add_json_param("TestAjaxFile",
-        NOALYSS_HOME."/../scenario/ajax_manage_table_sql.php");
+
 
 if ($action=="input")
 {
+    $obj=new Acc_Plan_SQL($cn);
+    $obj->set_limit_fiche_qcode(5);
+    $obj->set_pk_value($p_id);
+    $obj->load();
+    $manage_table=new Manage_Table_SQL($obj);
+    $manage_table->add_json_param("TestAjaxFile",
+        NOALYSS_HOME."/../scenario/ajax_manage_table_sql.php");
+
     $manage_table->set_object_name($ctl_id);
     $manage_table->set_col_label('pcm_val', "Poste");
     $manage_table->set_col_label('parent_accounting', "Dépend");
@@ -58,4 +63,17 @@ if ($action=="input")
     header('Content-type: text/xml; charset=UTF-8');
     echo $manage_table->ajax_input()->saveXML();
     return;
+} elseif ($action=="save")
+{
+$obj=new Acc_Plan_SQL($cn);
+    $obj->set_limit_fiche_qcode(5);
+    $obj->set_pk_value($p_id);
+    $obj->load();
+    $manage_table=new Manage_Table_SQL($obj);
+    $manage_table->set_object_name($ctl_id);
+    $manage_table->add_json_param("TestAjaxFile",
+        NOALYSS_HOME."/../scenario/ajax_manage_table_sql.php");
+     header('Content-type: text/xml; charset=UTF-8');
+    echo $manage_table->ajax_save()->saveXML();
+    return;
 }
\ No newline at end of file
diff --git a/scenario/test_acc_plan_mtable.php 
b/scenario/test_acc_plan_mtable.php
new file mode 100644
index 0000000..70a6383
--- /dev/null
+++ b/scenario/test_acc_plan_mtable.php
@@ -0,0 +1,50 @@
+<?php
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   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 (2016) Author Dany De Bontridder <address@hidden>
+
+if (!defined('ALLOWED'))
+    die('Appel direct ne sont pas permis');
+ //@description:Test the class Acc_Plan_mtable , ajax and javascript
+
+ $_GET=array (
+);
+$_POST=array (
+);
+$_POST['gDossier']=$gDossierLogInput;
+$_GET['gDossier']=$gDossierLogInput;
+$_REQUEST=array_merge($_GET,$_POST);
+require_once NOALYSS_INCLUDE."/class/acc_plan_mtable.class.php";
+require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php";
+/**
+ * @file
+ * @brief Test the Acc_Plan_MTable
+ */
+$obj=new Acc_Plan_SQL($cn);
+/**
+ * Test $obj
+ */
+
+$mtable=new Acc_Plan_MTable($obj);
+$obj->set_limit_fiche_qcode(5);
+$mtable->set_callback("ajax_test.php");
+$mtable->add_json_param("TestAjaxFile",NOALYSS_HOME."/../scenario/ajax_acc_plan_mtable.php");
+$mtable->create_js_script();
+echo $mtable->display_table(" where pcm_val::text like '4%' order by 
pcm_val::text limit 30");
+
diff --git a/scenario/test_manage_table_sql.php 
b/scenario/test_manage_table_sql.php
index d0a9f2b..fe08c5a 100644
--- a/scenario/test_manage_table_sql.php
+++ b/scenario/test_manage_table_sql.php
@@ -80,24 +80,24 @@ test_visible_update($manage_table, "parent_accounting", 
TRUE, TRUE);
 echo "<h1>"."Icon MODIFY place"."</h1>";
 echo "<h2>"." Mod left"."</h2>";
 $manage_table->set_icon_mod("left");
-$manage_table->display_table(" order by pcm_val::text limit 10");
+$manage_table->display_table("where pcm_val::text >= '400' order by 
pcm_val::text limit 10");
 
 echo "<h2>"." Mod right"."</h2>";
 $manage_table->set_icon_mod("right");
-$manage_table->display_table(" order by pcm_val::text limit 10");
+$manage_table->display_table("where pcm_val::text >= '400'  order by 
pcm_val::text limit 10");
 
 echo "<h2>"." Mod first"."</h2>";
 $manage_table->set_icon_mod("first");
-$manage_table->display_table(" order by pcm_val::text limit 10");
+$manage_table->display_table("where pcm_val::text >= '400'  order by 
pcm_val::text limit 10");
 
 echo "<h1>"."Icon DELETE place"."</h1>";
 echo "<h2>"." Delete left"."</h2>";
 $manage_table->set_icon_del("left");
-$manage_table->display_table(" order by pcm_val::text limit 10");
+$manage_table->display_table("where pcm_val::text >= '400'  order by 
pcm_val::text limit 10");
 
 echo "<h2>"." Delete right"."</h2>";
 $manage_table->set_icon_del("right");
-$manage_table->display_table(" order by pcm_val::text limit 10");
+$manage_table->display_table("where pcm_val::text >= '400'  order by 
pcm_val::text limit 10");
 
 
  ?>
diff --git a/unit-test/README b/unit-test/README
index a613b00..119aedd 100644
--- a/unit-test/README
+++ b/unit-test/README
@@ -25,3 +25,5 @@ Génération pour tous les fichiers
 =================================
 Permet de voir les lignes de code qui ont été testées
 php <chemin>/phpunit.phar --coverage-html html --bootstrap bootstrap.php 
include
+
+exemple depuis NETBEANS "/usr/bin/php" 
"/home/dany/Program/phpunit-skelgen.phar" "--ansi" "generate-test" 
"--bootstrap=/home/dany/developpement/phpcompta/noalyss/unit-test/bootstrap.php"
 "View_SQL" 
"/home/dany/developpement/phpcompta/noalyss/include/lib/view_sql.class.php" 
"View_SQLTest" 
"/home/dany/developpement/phpcompta/noalyss/unit-test/include/lib/view_sql.classTest.php"



reply via email to

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