phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r586 - in trunk/rapport_avance: . include include/templa


From: phpcompta-dev
Subject: [Phpcompta-dev] r586 - in trunk/rapport_avance: . include include/template
Date: Sat, 23 Nov 2013 14:08:07 +0100 (CET)

Author: danydb
Date: 2013-11-23 14:08:07 +0100 (Sat, 23 Nov 2013)
New Revision: 586

Added:
   trunk/rapport_avance/ajax_save_param_listing.php
Modified:
   trunk/rapport_avance/
   trunk/rapport_avance/ajax.php
   trunk/rapport_avance/include/class_rapav_listing_formula.php
   trunk/rapport_avance/include/class_rapav_listing_param.php
   trunk/rapport_avance/include/class_rapport_avance_sql.php
   trunk/rapport_avance/include/template/listing_param_input.php
   trunk/rapport_avance/include/template/rapav_listing_definition.php
   trunk/rapport_avance/rapav_javascript.js
Log:
Save Formula_attribute for Listing


Property changes on: trunk/rapport_avance
___________________________________________________________________
Name: svn:ignore
   + .a.kate-swp


Modified: trunk/rapport_avance/ajax.php
===================================================================
--- trunk/rapport_avance/ajax.php       2013-11-23 13:06:01 UTC (rev 585)
+++ trunk/rapport_avance/ajax.php       2013-11-23 13:08:07 UTC (rev 586)
@@ -145,6 +145,12 @@
     case 'listing_param_add':
         include 'ajax_listing_param_add.php';
         exit();
+    
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    // save a param to a listing
+    
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    case 'save_param_listing':
+        include 'ajax_save_param_listing.php';
+        exit();
     default:
         if ( DEBUG) var_dump($_GET);
         die ("Aucune action demandée");

Added: trunk/rapport_avance/ajax_save_param_listing.php
===================================================================
--- trunk/rapport_avance/ajax_save_param_listing.php                            
(rev 0)
+++ trunk/rapport_avance/ajax_save_param_listing.php    2013-11-23 13:08:07 UTC 
(rev 586)
@@ -0,0 +1,144 @@
+<?php
+/**
+ * @file
+ * @brief sauve la nouvelle ligne de détail (listing) et renvoie un xml
+ * avec code = ok ou nok, p_id pk de formulaire_param et html le code html à 
afficher : soit une ligne à ajouter à la table
+ * soit le message d'erreur à ajouter dans le div
+ * 
+ * Paramètre entrée
+ *    - gDossier
+ *    - ac
+ *    - plugin_code
+ *    - p_id 
+ *    - tab valeurs : formula, compute_id, new_account_id, new_attribute_id
+ *
+ * Pour attribut : 
+ *    - attribute_card : numérique ad_id
+ *
+ */
+require_once 'class_impress.php';
+require_once 'include/class_rapav_listing_param.php';
+$formula = new RAPAV_Listing_Param_SQL();
+// var_dump($_GET);
+switch ($tab)
+{
+   /* case 'formula':
+        $acc_formula = new RAPAV_Formula();
+        $acc_formula->fp_formula = $formula_new;
+        $acc_formula->p_id = $p_id;
+        $acc_formula->type_detail = 1;
+        $acc_formula->jrn_def_id = $p_ledger;
+        $acc_formula->date_paid = (isset($p_paid)) ? 1 : 0;
+        if ($acc_formula->verify() == 1)
+        {
+            $code = 'nok';
+            $html = $acc_formula->errcode;
+        } else
+        {
+            $acc_formula->insert();
+            $fp_id = $acc_formula->fp_id;
+            $code = 'ok';
+            $html = '<td>';
+            ob_start();
+            $acc_formula->display_row();
+            $html.=ob_get_contents();
+            ob_end_clean();
+            $html.= '</td>';
+            $html.='<td id="del_' . $acc_formula->fp_id . '">';
+            $html.=HtmlInput::anchor("Effacer", "", 
sprintf("onclick=\"delete_param_detail('%s','%s','%s','%s')\""
+                                    , $_REQUEST['plugin_code'], 
$_REQUEST['ac'], $_REQUEST['gDossier'], $acc_formula->fp_id));
+            $html.='</td>';
+        }
+        break;
+    case 'compute_id':
+        $acc_compute = new RAPAV_Compute();
+        $acc_compute->fp_formula = $form_compute;
+        $acc_compute->p_id = $p_id;
+        $acc_compute->type_detail = 3;
+        $acc_compute->jrn_def_id = null;
+        if ($acc_compute->verify() == 1)
+        {
+            $code = 'nok';
+            $html = $acc_compute->errcode;
+        } else
+        {
+            $acc_compute->insert();
+            $fp_id = $acc_compute->fp_id;
+            $code = 'ok';
+            $html = '<td>';
+            ob_start();
+            $acc_compute->display_row();
+            $html.=ob_get_contents();
+            ob_end_clean();
+            $html.= '</td>';
+            $html.='<td id="del_' . $acc_compute->fp_id . '">';
+            $html.=HtmlInput::anchor("Effacer", "", 
sprintf("onclick=\"delete_param_detail('%s','%s','%s','%s')\""
+                                    , $_REQUEST['plugin_code'], 
$_REQUEST['ac'], $_REQUEST['gDossier'], $acc_compute->fp_id));
+            $html.='</td>';
+        }
+        break;
+    case 'new_account_id':
+        $acc_account = new RAPAV_Account();
+        $acc_account->tmp_val = $account_first;
+        $acc_account->with_tmp_val = $account_second;
+        $acc_account->p_id = $p_id;
+        $acc_account->type_detail = 4;
+        $acc_account->type_sum_account = $account_sum_type;
+        $acc_account->jrn_def_id = $p_ledger;
+        $acc_account->date_paid = (isset($p_paid)) ? 1 : 0;
+        if ($acc_account->verify() == 1)
+        {
+            $code = 'nok';
+            $html = $acc_account->errcode;
+        } else
+        {
+            $acc_account->insert();
+            $fp_id = $acc_account->fp_id;
+            $code = 'ok';
+            $html = '<td>';
+            ob_start();
+            $acc_account->display_row();
+            $html.=ob_get_contents();
+            ob_end_clean();
+            $html.= '</td>';
+            $html.='<td id="del_' . $acc_account->fp_id . '">';
+            $html.=HtmlInput::anchor("Effacer", "", 
sprintf("onclick=\"delete_param_detail('%s','%s','%s','%s')\""
+                                    , $_REQUEST['plugin_code'], 
$_REQUEST['ac'], $_REQUEST['gDossier'], $acc_account->fp_id));
+            $html.='</td>';
+        }
+        break;*/
+    case 'new_attribute_id':
+        ob_start();
+        $attr = new RAPAV_Formula_Attribute($formula, $listing_id);
+        $attr->save($_GET);
+        $attr->load();
+        $lp_id=$attr->data->getp("lp_id");
+        $code = 'ok';
+        $html="";
+        echo td($attr->display_code());
+        echo td($attr->display_comment());
+        echo td($attr->display_order());
+        echo td($attr->display());
+        $html.=ob_get_contents();
+        ob_end_clean();
+        $html.='<td id="del_' .$lp_id . '">';
+        $html.=HtmlInput::anchor("Effacer", "", 
sprintf("onclick=\"delete_listing_detail('%s','%s','%s','%s')\""
+                                , $_REQUEST['plugin_code'], $_REQUEST['ac'], 
$_REQUEST['gDossier'], $lp_id));
+        $html.='</td>';
+        break;
+}
+
+//echo $html;exit();
+$html = escape_xml($html);
+
+header('Content-type: text/xml; charset=UTF-8');
+echo <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<data>
+<code>$code</code>
+<html>$html</html>
+<lp_id>$lp_id</lp_id>
+<l_id>$listing_id</l_id>
+</data>
+EOF;
+?>        
\ No newline at end of file

Modified: trunk/rapport_avance/include/class_rapav_listing_formula.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_formula.php        
2013-11-23 13:06:01 UTC (rev 585)
+++ trunk/rapport_avance/include/class_rapav_listing_formula.php        
2013-11-23 13:08:07 UTC (rev 586)
@@ -13,15 +13,177 @@
  */
 abstract class RAPAV_Listing_Formula
 {
-    abstract public function display();
-    abstract public function compute();
+
+    abstract public function compute($p_start, $p_end);
+
     abstract public function input();
-    /**
-     * 
-     * @param $p_obj RAPAV_Listing_Param_SQL
-     */
-    public function make_object($p_obj)
+
+    abstract function save($p_array);
+
+    function save_computed()
     {
         
     }
+
+    function get_ledger_name()
+    {
+        global $cn;
+        $ledger = "";
+        if ($this->data->jrn_def_id == null || $this->data->jrn_def_id == -1)
+        {
+            $ledger = " tous les journaux";
+        } else
+        {
+            $tledger = $cn->get_value('select jrn_def_name from jrn_def where 
jrn_def_id=$1', array($this->data->jrn_def_id));
+            $ledger.="  le journal " . $tledger;
+        }
+        return $ledger;
+    }
+
+    static function input_ledger()
+    {
+        global $cn;
+        $select = new ISelect('p_ledger');
+        $a_ledger = $cn->make_array('select jrn_def_id,jrn_def_name from 
jrn_def order by 2', 1);
+        $a_ledger[0]['label'] = '-- Tous les journaux -- ';
+        $select->value = $a_ledger;
+
+        echo '<p> Filtrage par journal ' . $select->input() . '</p>';
+    }
+
+    static function input_date_paiement()
+    {
+        $ck_paid = new ICheckBox('p_paid');
+        echo '<p> La date donnée concerne la date de paiement, ce qui limitera 
la recherche aux journaux VEN et ACH ';
+        echo HtmlInput::infobulle(36);
+        echo $ck_paid->input();
+        echo '</p>';
+    }
+
+    function set($p_array)
+    {
+        $this->data->setp("code", $p_array["code_id"]);
+        $this->data->setp("comment", $p_array["comment"]);
+        $this->data->setp("order", $p_array["order"]);
+    }
+
+    function set_to_null($p_array)
+    {
+        foreach ($p_array as $key)
+        {
+            $this->data->$key = null;
+        }
+    }
+
+    static function make_object(RAPAV_Listing_Param_SQL $obj)
+    {
+        switch ($obj->getp('formula_type'))
+        {
+            case 'ATTR':
+                $ret=new Rapav_Formula_Attribute($obj);
+                break;
+
+            default:
+                throw new Exception ('Object '.$obj.' invalide ');
+                break;
+           
+        }
+        return $ret;
+    }
+    function display_code()
+    {
+        return $this->data->getp('code');
+    }
+    function display_comment()
+    {
+        return $this->data->getp('comment');
+    }
+    function display_order()
+    {
+        return $this->data->getp('order');
+    }
+    function load()
+    {
+        $this->data->load();
+    }
+
 }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// RAPAV_Formula_Attribute
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @brief Class for the listing detail attribute, this class use 
RAPAV_Listing_Param_SQL
+ * the specific columns are attribut_card
+ */
+class RAPAV_Formula_Attribute extends RAPAV_Listing_Formula
+{
+
+    var $data;           /**< RAPAV_Listing_Param_SQL objet */
+    var $cat;            /**< categorie id */
+    var $sig;            /**< Object signature */
+
+    function __construct(RAPAV_Listing_Param_SQL $obj, $p_cat_id = 0)
+    {
+        global $cn;
+        $this->data = $obj;
+        if ($p_cat_id == 0)
+        {
+            $this->cat = $cn->get_value('select fd_id 
+                                from rapport_advanced.listing 
+                                where
+                                l_id=$1
+                                ', array($this->data->getp('listing_id')));
+            if ($this->cat == "")
+                throw new Exception(__FILE__ . ':' . __LINE__ . 'Aucune 
catégorie définie');
+        }
+        else
+        {
+            $this->cat = $p_cat_id;
+        }
+        $this->sig = 'ATTR';
+    }
+
+    function display()
+    {
+        global $cn;
+        $desc = $cn->get_value('select ad_text from attr_def where ad_id=$1', 
array($this->data->getp('attribut_card')));
+        return "Utilisant l'attribut " . h($desc);
+    }
+
+    function compute($p_start, $p_end)
+    {
+        return 0;
+    }
+
+    function input()
+    {
+        global $cn;
+        $select = new ISelect('p_attribute');
+
+        $select->value = $cn->make_array('select a.ad_id,a.ad_text 
+                                        from
+                                        attr_def as a join jnt_fic_attr as j 
on (a.ad_id=j.ad_id)
+                                        where
+                                        fd_id=' . $this->cat . ' order by 2');
+
+        $select->selected = $this->data->getp('attribut_card');
+        return $select->input();
+    }
+
+    function save($p_array)
+    {
+        parent::set($p_array);
+        $this->data->setp('listing_id', $p_array['listing_id']);
+        /* Clean everything but keep the lp_id, l_id, with_Card and ad_id  + 
common */
+        $a_toclean = explode(',', 'operation_pcm_val,with_tmp_val,tmp_val, 
date_paid,jrn_def_id,type_sum_account, tt_id, jrn_def_type, fp_signed, 
fp_formula, tva_id' .
+                ',lp_card_saldo');
+
+        parent::set_to_null($a_toclean);
+        $this->data->setp('with_card', 'N');
+        $this->data->setp('attribut_card', $p_array['p_attribute']);
+        $this->data->setp('formula_type', 'ATTR');
+        $this->data->save();
+    }
+
+}

Modified: trunk/rapport_avance/include/class_rapav_listing_param.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_param.php  2013-11-23 
13:06:01 UTC (rev 585)
+++ trunk/rapport_avance/include/class_rapav_listing_param.php  2013-11-23 
13:08:07 UTC (rev 586)
@@ -13,9 +13,10 @@
  * @author danydb
  */
 require_once 'class_rapport_avance_sql.php';
+require_once 'class_rapav_listing_formula.php';
 
 class RAPAV_Listing_Param {
-    private  $Param;  /*!< RAPAV_Listing_Param_SQL */
+    var  $Param;  /*!< RAPAV_Listing_Param_SQL */
     
     /**
      * constructor, initialize Data with a RAPAV_Listing_Param_SQL
@@ -64,7 +65,7 @@
        
        for ($i=0;$i<count($a_param_id);$i++)
        {
-           $a_listing_param[]=new 
RAPAV_Listing_Param($a_param_id['lp_id'][$i]);
+           $a_listing_param[]=new 
RAPAV_Listing_Param($a_param_id[$i]['lp_id']);
        }
        return $a_listing_param;
     }
@@ -77,7 +78,8 @@
         $code=new IText('code_id');
         $comment=new IText('comment');
         $order=new INum('order');
-        
+        $order->value=10;
+        $attribute=new RAPAV_Formula_Attribute($this->Param,$p_id);
         require 'template/listing_param_input.php';
     }
 }

Modified: trunk/rapport_avance/include/class_rapport_avance_sql.php
===================================================================
--- trunk/rapport_avance/include/class_rapport_avance_sql.php   2013-11-23 
13:06:01 UTC (rev 585)
+++ trunk/rapport_avance/include/class_rapport_avance_sql.php   2013-11-23 
13:08:07 UTC (rev 586)
@@ -319,7 +319,9 @@
 
 class RAPAV_Listing_Param_SQL extends Phpcompta_Sql
 {
-
+/*
+ *  
operation_pcm_val,with_tmp_val,tmp_val,date_paid,jrn_def_id,type_sum_account,type_detail,tt_id,jrn_def_type,fp_signed,fp_formula,tva_id,lp_with_card,lp_card_saldo,ad_id,l_order,l_card,lp_comment,lp_code,l_id,lp_id
+ */
     function __construct($p_id = -1)
     {
 

Modified: trunk/rapport_avance/include/template/listing_param_input.php
===================================================================
--- trunk/rapport_avance/include/template/listing_param_input.php       
2013-11-23 13:06:01 UTC (rev 585)
+++ trunk/rapport_avance/include/template/listing_param_input.php       
2013-11-23 13:08:07 UTC (rev 586)
@@ -1,32 +1,41 @@
 <div>
-    <table>
+    <form id="common_frm">
+    <?php echo HtmlInput::hidden("listing_id", $p_id); ?>
+        <table >
+            <tr>
+                <td>
+                    <label>Code</label> 
+                   
+                </td>
+                <td>
+                    <?php echo $code->input() ?>
+                </tD>
+                <td>
+                     <p id="code_id_span" class="error"></p>
+                </td>
+                
+                
+            </tr>
+            <tr>
+                <td>
+                    <label>Commentaire</label>
+                </td>
+                <td>
+                    <?php echo $comment->input(); ?>
+                </td>
+            </tr>
+            <tr>
+                <td>
+                    <label>Ordre d'apparition</label>
+                </td>
+                <td>
+                    <?php echo $order->input(); ?>
+                </td>
+            </tr>
+        </table>
+    </form>
+    <table id="table_<?php echo $p_id;?>" style="width:90%;margin-left:5%" >
         <tr>
-            <td>
-                <label>Code</label> 
-            </td>
-            <td>
-                <?php echo $code->input() ?>
-            </tD>
-        </tr>
-        <tr>
-            <td>
-                <label>Commentaire</label>
-            </td>
-            <td>
-                <?php echo $comment->input(); ?>
-            </td>
-        </tr>
-        <tr>
-            <td>
-                <label>Order apparition</label>
-            </td>
-            <td>
-                <?php echo $order->input(); ?>
-            </td>
-        </tr>
-    </table>
-    <table style="width:90%;margin-left:5%" >
-        <tr>
             <td id="new_formula_id_bt" class="tool" style="background:red">
                 <a class="mtitle"  href="javascript:void(0)"  
onclick="show_listing_formula('new_formula_id')">
                     Formule
@@ -44,10 +53,15 @@
                     Poste comptable
                 </a>
             </td>
+            <td id="new_attribute_id_bt"  class="tool" 
style="background:inherit">
+                <a class="mtitle" href="javascript:void(0)"   
onclick="show_listing_formula('new_attribute_id')">
+                    Attribut
+                </a>
+            </td>
         </tr>
     </table>
-    <div style="width:100%;height:290px;margin:1px">
-        <span class="error" id="param_detail_info_div"></span>
+    <div style="width:90%;height:290px;margin-left:5%">
+        <span class="error" id="info_listing_param_input_div_id"></span>
 
         <div style="padding: 10px">
             <div id="new_formula_id" style="display:block">
@@ -95,10 +109,27 @@
                     <?php echo HtmlInput::hidden('tab', 'new_account_id') ?>
                     <?php echo "account" ?>
 
-                    <?php echo HtmlInput::submit('save', 'Sauve') ?>
+                    <p>
+                        <?php echo HtmlInput::submit('save', 'Sauve') ?>
+                    </p>
 
                 </form>
             </div>
+            <div id="new_attribute_id" style="display:none">
+                <form id="new_padeattr" method="POST" 
onsubmit="save_param_listing('new_padeattr');
+                        return false">
+
+                    <?php echo HtmlInput::request_to_hidden(array('gDossier', 
'ac', 'plugin_code', 'p_id')) ?>
+
+                    <?php echo HtmlInput::hidden('tab', 'new_attribute_id') ?>
+                    <?php echo $attribute->input(); ?>
+
+                    <p>
+                        <?php echo HtmlInput::submit('save', 'Sauve') ?>
+                    </p>
+
+                </form>
+            </div>
         </div>
     </div>
 </div>
\ No newline at end of file

Modified: trunk/rapport_avance/include/template/rapav_listing_definition.php
===================================================================
--- trunk/rapport_avance/include/template/rapav_listing_definition.php  
2013-11-23 13:06:01 UTC (rev 585)
+++ trunk/rapport_avance/include/template/rapav_listing_definition.php  
2013-11-23 13:08:07 UTC (rev 586)
@@ -30,6 +30,9 @@
             Formules
         </th>
         <th>
+            Ordre
+        </th>
+        <th>
             action
         </th>
     </tr>
@@ -37,17 +40,23 @@
     $nb=count($this->a_detail);
     for ($i=0;$i<$nb;$i++):
 ?>
-    <tr>
+    <tr id="tr_<?php echo $this->a_detail[$i]->Param->getp('lp_id')?>">
         <td>
-           <?php $this->a_detail[$i]->Param->getp('code'); ?>
+           <?php echo $this->a_detail[$i]->Param->getp('code'); ?>
         </td>
         <td>
-           <?php $this->a_detail[$i]->Param->getp('comment'); ?>
+           <?php echo h($this->a_detail[$i]->Param->getp('comment')); ?>
         </td>
         <td>
-            Formule
+            <?php 
+            $obj=   
RAPAV_Listing_Formula::make_object($this->a_detail[$i]->Param);
+            echo $obj->display();
+            ?>
         </td>
         <td>
+            <?php echo $this->a_detail[$i]->Param->getp('order'); ?>
+        </td>
+        <td>
             Efface / modifie
         </td>
         

Modified: trunk/rapport_avance/rapav_javascript.js
===================================================================
--- trunk/rapport_avance/rapav_javascript.js    2013-11-23 13:06:01 UTC (rev 
585)
+++ trunk/rapport_avance/rapav_javascript.js    2013-11-23 13:08:07 UTC (rev 
586)
@@ -1,9 +1,9 @@
 
 
-content[200]="Le code doit être unique pour ce formulaire";
-content[201]="Formula TODO";
-content[203]="Utiliser le % pour indiquer les postes comptables qui en 
dépendent ex: 70% pour reprendre tous les comptes commençant par 70";
-content[204]="Filtrer en donnant une date, partie de la description ou de la 
déclaration";
+content[200] = "Le code doit être unique pour ce formulaire";
+content[201] = "Formula TODO";
+content[203] = "Utiliser le % pour indiquer les postes comptables qui en 
dépendent ex: 70% pour reprendre tous les comptes commençant par 70";
+content[204] = "Filtrer en donnant une date, partie de la description ou de la 
déclaration";
 
 /**
  address@hidden show the definition of a form and let it modify it
@@ -12,226 +12,228 @@
  address@hidden dossier gDossier
  address@hidden f_id pk of form_def
  */
-function rapav_form_def(plugin_code,ac,dossier,f_id)
+function rapav_form_def(plugin_code, ac, dossier, f_id)
 {
-       try
-       {
-               $('form_list_div').hide();
-               $('form_mod_div').innerHTML="";
-               $('form_mod_div').show();
-               waiting_box();
-               var 
querystring='plugin_code='+plugin_code+'&ac='+ac+'&gDossier='+dossier+'&act=mod_form'+"&f_id="+f_id;
-               var action=new Ajax.Request(
-                       "ajax.php",
-                       {
-                               method:'get',
-                               parameters:querystring,
-                               onFailure:error_get_predef,
-                               onSuccess:function(req){
-                                       remove_waiting_box();
-                                       var answer=req.responseText;
-                                       $('form_mod_div').innerHTML=answer;
-                                       answer.evalScripts()
-                               }
-                       }
-                       );
-       }
-       catch(e)
-       {
-               alert(e.message);
-       }
+    try
+    {
+        $('form_list_div').hide();
+        $('form_mod_div').innerHTML = "";
+        $('form_mod_div').show();
+        waiting_box();
+        var querystring = 'plugin_code=' + plugin_code + '&ac=' + ac + 
'&gDossier=' + dossier + '&act=mod_form' + "&f_id=" + f_id;
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: querystring,
+                    onFailure: error_get_predef,
+                    onSuccess: function(req) {
+                        remove_waiting_box();
+                        var answer = req.responseText;
+                        $('form_mod_div').innerHTML = answer;
+                        answer.evalScripts()
+                    }
+                }
+        );
+    }
+    catch (e)
+    {
+        alert(e.message);
+    }
 }
 /**
  * @brief Add a row to the table in formulaire_definition
  * table id = table_formulaire_definition_id
  */
-function add_row_definition(plugin_code,ac,dossier)
+function add_row_definition(plugin_code, ac, dossier)
 {
-       try
-       {
-               var 
querystring='plugin_code='+plugin_code+'&ac='+ac+'&gDossier='+dossier+'&act=add_row_definition';
-               waiting_box();
-               var action=new Ajax.Request(
-                       "ajax.php",
-                       {
-                               method:'get',
-                               parameters:querystring,
-                               onFailure:error_get_predef,
-                               onSuccess:function(req){
-                                       remove_waiting_box();
-                                       var answer=req.responseText;
-                                       var 
mytable=g("table_formulaire_definition_id").tBodies[0];
-                                       var nNumberRow=mytable.rows.length;
-                                       var oRow=mytable.insertRow(nNumberRow);
-                                       oRow.innerHTML=answer;
-                               }
-                       }
-                       );
+    try
+    {
+        var querystring = 'plugin_code=' + plugin_code + '&ac=' + ac + 
'&gDossier=' + dossier + '&act=add_row_definition';
+        waiting_box();
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: querystring,
+                    onFailure: error_get_predef,
+                    onSuccess: function(req) {
+                        remove_waiting_box();
+                        var answer = req.responseText;
+                        var mytable = 
g("table_formulaire_definition_id").tBodies[0];
+                        var nNumberRow = mytable.rows.length;
+                        var oRow = mytable.insertRow(nNumberRow);
+                        oRow.innerHTML = answer;
+                    }
+                }
+        );
 
-       }catch (e)
-       {
-               alert(e.message);
-       }
+    } catch (e)
+    {
+        alert(e.message);
+    }
 }
 
 /**
  * @brief Add a row to the table in formulaire_parametre
  * table id = table p_id
  */
-function add_param_detail(plugin_code,ac,dossier,p_id)
+function add_param_detail(plugin_code, ac, dossier, p_id)
 {
-       try
-       {
-               var 
querystring='plugin_code='+plugin_code+'&ac='+ac+'&gDossier='+dossier+'&act=add_param_detail'+"&p_id="+p_id;
-               waiting_box();
-               var action=new Ajax.Request(
-                       "ajax.php",
-                       {
-                               method:'get',
-                               parameters:querystring,
-                               onFailure:error_get_predef,
-                               onSuccess:function(req){
-                                       remove_waiting_box();
-                                       removeDiv('param_detail_div');
-                                       var nTop=calcy(90);
-                                       var nLeft="200px";
-                                       var 
str_style="top:"+nTop+"px;left:"+nLeft+";width:70em;height:auto";
-                                       add_div({
-                                               id:'param_detail_div',
-                                               style:str_style,
-                                               cssclass:'inner_box',
-                                               drag:1
-                                       });
-                                       
$('param_detail_div').innerHTML=req.responseText;
-                                       req.responseText.evalScripts();
-                               }
-                       }
-                       );
+    try
+    {
+        var querystring = 'plugin_code=' + plugin_code + '&ac=' + ac + 
'&gDossier=' + dossier + '&act=add_param_detail' + "&p_id=" + p_id;
+        waiting_box();
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: querystring,
+                    onFailure: error_get_predef,
+                    onSuccess: function(req) {
+                        remove_waiting_box();
+                        removeDiv('param_detail_div');
+                        var nTop = calcy(90);
+                        var nLeft = "200px";
+                        var str_style = "top:" + nTop + "px;left:" + nLeft + 
";width:70em;height:auto";
+                        add_div({
+                            id: 'param_detail_div',
+                            style: str_style,
+                            cssclass: 'inner_box',
+                            drag: 1
+                        });
+                        $('param_detail_div').innerHTML = req.responseText;
+                        req.responseText.evalScripts();
+                    }
+                }
+        );
 
-       }catch (e)
-       {
-               alert("add_param_detail"+e.message);
-       }
+    } catch (e)
+    {
+        alert("add_param_detail" + e.message);
+    }
 }
 /**
  address@hidden display a popup and let you select an existing code
  */
-function rapav_search_code(ac,plugin_code,dossier,f_id)
+function rapav_search_code(ac, plugin_code, dossier, f_id)
 {
-       try
-       {
-               var 
querystring='plugin_code='+plugin_code+'&ac='+ac+'&gDossier='+dossier+'&act=rapav_search_code'+"&f_id="+f_id;
-               waiting_box();
-               var action=new Ajax.Request(
-                       "ajax.php",
-                       {
-                               method:'get',
-                               parameters:querystring,
-                               onFailure:error_get_predef,
-                               onSuccess:function(req){
-                                       remove_waiting_box();
-                                       removeDiv('search_code_div');
-                                       var nTop=calcy(80);
-                                       var nLeft="400px";
-                                       var 
str_style="top:"+nTop+"px;left:"+nLeft+";width:50em;height:auto;z-index:4";
-                                       add_div({
-                                               id:'search_code_div',
-                                               style:str_style,
-                                               cssclass:'inner_box',
-                                               drag:1
-                                       });
-                                       
$('search_code_div').innerHTML=req.responseText;
-                               //req.responseText.evalScripts();
-                               }
-                       }
-                       );
+    try
+    {
+        var querystring = 'plugin_code=' + plugin_code + '&ac=' + ac + 
'&gDossier=' + dossier + '&act=rapav_search_code' + "&f_id=" + f_id;
+        waiting_box();
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: querystring,
+                    onFailure: error_get_predef,
+                    onSuccess: function(req) {
+                        remove_waiting_box();
+                        removeDiv('search_code_div');
+                        var nTop = calcy(80);
+                        var nLeft = "400px";
+                        var str_style = "top:" + nTop + "px;left:" + nLeft + 
";width:50em;height:auto;z-index:4";
+                        add_div({
+                            id: 'search_code_div',
+                            style: str_style,
+                            cssclass: 'inner_box',
+                            drag: 1
+                        });
+                        $('search_code_div').innerHTML = req.responseText;
+                        //req.responseText.evalScripts();
+                    }
+                }
+        );
 
-       }catch (e)
-       {
-               alert("add_param_detail"+e.message);
-       }
+    } catch (e)
+    {
+        alert("add_param_detail" + e.message);
+    }
 }
 /**
  address@hidden delete a parameter detail
  */
-function delete_param_detail(plugin_code,ac,dossier,fp_id)
+function delete_param_detail(plugin_code, ac, dossier, fp_id)
 {
-       try
-       {
-               if ( ! confirm("Confirmez-vous l'effacement ?")) { return 
false;}
-               waiting_box();
+    try
+    {
+        if (!confirm("Confirmez-vous l'effacement ?")) {
+            return false;
+        }
+        waiting_box();
 
-               var 
querystring='plugin_code='+plugin_code+'&ac='+ac+'&gDossier='+dossier+'&act=delete_param_detail'+"&fp_id="+fp_id;
-               var action=new Ajax.Request(
-                       "ajax.php",
-                       {
-                               method:'get',
-                               parameters:querystring,
-                               onFailure:error_get_predef,
-                               onSuccess:function(req){
-                                       remove_waiting_box();
-                                       
$('tr_'+fp_id).style.textDecoration="line-through";
-                                       $('tr_'+fp_id).style.color="red";
-                                       $('del_'+fp_id).innerHTML="";
-                               }
-                       }
-                       );
-       }catch (e)
-       {
-               alert(e);
-       }
+        var querystring = 'plugin_code=' + plugin_code + '&ac=' + ac + 
'&gDossier=' + dossier + '&act=delete_param_detail' + "&fp_id=" + fp_id;
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: querystring,
+                    onFailure: error_get_predef,
+                    onSuccess: function(req) {
+                        remove_waiting_box();
+                        $('tr_' + fp_id).style.textDecoration = "line-through";
+                        $('tr_' + fp_id).style.color = "red";
+                        $('del_' + fp_id).innerHTML = "";
+                    }
+                }
+        );
+    } catch (e)
+    {
+        alert(e);
+    }
 }
 /**
  * @brief  montre les détails d'un formulaire
  */
-function rapav_form_param(plugin_code,ac,dossier,f_id)
+function rapav_form_param(plugin_code, ac, dossier, f_id)
 {
-       try
-       {
-               $('form_list_div').hide();
-               $('form_mod_div').innerHTML="";
-               $('form_mod_div').show();
-               waiting_box();
-               var 
querystring='plugin_code='+plugin_code+'&ac='+ac+'&gDossier='+dossier+'&act=mod_param'+"&f_id="+f_id;
-               var action=new Ajax.Request(
-                       "ajax.php",
-                       {
-                               method:'get',
-                               parameters:querystring,
-                               onFailure:error_get_predef,
-                               onSuccess:function(req){
-                                       remove_waiting_box();
-                                       var answer=req.responseText;
-                                       $('form_mod_div').innerHTML=answer;
-                                       answer.evalScripts()
-                               }
-                       }
-                       );
-       }
-       catch(e)
-       {
-               alert(e.message);
-       }
+    try
+    {
+        $('form_list_div').hide();
+        $('form_mod_div').innerHTML = "";
+        $('form_mod_div').show();
+        waiting_box();
+        var querystring = 'plugin_code=' + plugin_code + '&ac=' + ac + 
'&gDossier=' + dossier + '&act=mod_param' + "&f_id=" + f_id;
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: querystring,
+                    onFailure: error_get_predef,
+                    onSuccess: function(req) {
+                        remove_waiting_box();
+                        var answer = req.responseText;
+                        $('form_mod_div').innerHTML = answer;
+                        answer.evalScripts()
+                    }
+                }
+        );
+    }
+    catch (e)
+    {
+        alert(e.message);
+    }
 }
 /**
  * @brief montre le div contenant le type de formule pour les rapports
  */
 function show_rapport_formula(p_toshow)
 {
-       try
-       {
-               var 
div=['new_account_tva_id','new_formula_id','new_compute_id','new_account_id','new_reconcile_id'];
-               for (var r =0;r<div.length;r++ ) {
-                       $(div[r]).hide();
-                       $(div[r]+'_bt').style.backgroundColor="inherit";
+    try
+    {
+        var div = ['new_account_tva_id', 'new_formula_id', 'new_compute_id', 
'new_account_id', 'new_reconcile_id'];
+        for (var r = 0; r < div.length; r++) {
+            $(div[r]).hide();
+            $(div[r] + '_bt').style.backgroundColor = "inherit";
 
-               }
-               $(p_toshow).show();
-               $(p_toshow+'_bt').style.backgroundColor="red";
-       } catch (e)
-{
-               alert (e.message);
-       }
+        }
+        $(p_toshow).show();
+        $(p_toshow + '_bt').style.backgroundColor = "red";
+    } catch (e)
+    {
+        alert(e.message);
+    }
 
 }
 /**
@@ -239,20 +241,20 @@
  */
 function show_listing_formula(p_toshow)
 {
-       try
-       {
-               var div=['new_formula_id','new_compute_id','new_account_id'];
-               for (var r =0;r<div.length;r++ ) {
-                       $(div[r]).hide();
-                       $(div[r]+'_bt').style.backgroundColor="inherit";
+    try
+    {
+        var div = ['new_formula_id', 'new_compute_id', 'new_account_id', 
'new_attribute_id'];
+        for (var r = 0; r < div.length; r++) {
+            $(div[r]).hide();
+            $(div[r] + '_bt').style.backgroundColor = "inherit";
 
-               }
-               $(p_toshow).show();
-               $(p_toshow+'_bt').style.backgroundColor="red";
-       } catch (e)
-{
-               alert (e.message);
-       }
+        }
+        $(p_toshow).show();
+        $(p_toshow + '_bt').style.backgroundColor = "red";
+    } catch (e)
+    {
+        alert(e.message);
+    }
 
 }
 /**
@@ -260,128 +262,130 @@
  */
 function save_param_detail(p_form_id)
 {
-       try
-       {
-               var qs=$(p_form_id).serialize()+'&act=save_param_detail';
-               waiting_box();
-               var action=new Ajax.Request(
-                       "ajax.php",
-                       {
-                               method:'get',
-                               parameters:qs,
-                               onFailure:error_get_predef,
-                               onSuccess:function infodiv(req,json) {
-                                       try{
-                                               remove_waiting_box();
-                                               var answer=req.responseXML;
-                                               var 
acode=answer.getElementsByTagName('code');
-                                               var 
ap_id=answer.getElementsByTagName('p_id');
-                                               var 
html=answer.getElementsByTagName('html');
+    try
+    {
+        var qs = $(p_form_id).serialize() + '&act=save_param_detail';
+        waiting_box();
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: qs,
+                    onFailure: error_get_predef,
+                    onSuccess: function infodiv(req, json) {
+                        try {
+                            remove_waiting_box();
+                            var answer = req.responseXML;
+                            var acode = answer.getElementsByTagName('code');
+                            var ap_id = answer.getElementsByTagName('p_id');
+                            var html = answer.getElementsByTagName('html');
 
-                                               if ( acode.length == 0 ) {
-                                                       var 
rec=req.responseText;
-                                                       alert ('erreur :'+rec);
-                                               }
-                                               var 
code=acode[0].firstChild.nodeValue;
-                                               var 
code_xml=getNodeText(html[0]);
-                                               var 
code_html=unescape_xml(code_xml);
-                                               if ( code == 'ok')
-                                                       {
-                                                               var 
afpid=answer.getElementsByTagName('fp_id');
-                                                               var 
fp_id=afpid[0].firstChild.nodeValue;
-                                                               var 
p_id=ap_id[0].firstChild.nodeValue;
-                                                               // Ajoute une 
ligne avec résultat
-                                                               var 
mytable=g("table_"+p_id).tBodies[0];
-                                                               var 
nNumberRow=mytable.rows.length;
-                                                               var 
oRow=mytable.insertRow(nNumberRow);
-                                                               
oRow.id="tr_"+fp_id;
-                                                               
oRow.innerHTML=code_html;
-                                                               
removeDiv('param_detail_div');
+                            if (acode.length == 0) {
+                                var rec = req.responseText;
+                                alert('erreur :' + rec);
+                            }
+                            var code = acode[0].firstChild.nodeValue;
+                            var code_xml = getNodeText(html[0]);
+                            var code_html = unescape_xml(code_xml);
+                            if (code == 'ok')
+                            {
+                                var afpid = 
answer.getElementsByTagName('fp_id');
+                                var fp_id = afpid[0].firstChild.nodeValue;
+                                var p_id = ap_id[0].firstChild.nodeValue;
+                                // Ajoute une ligne avec résultat
+                                var mytable = g("table_" + p_id).tBodies[0];
+                                var nNumberRow = mytable.rows.length;
+                                var oRow = mytable.insertRow(nNumberRow);
+                                oRow.id = "tr_" + fp_id;
+                                oRow.innerHTML = code_html;
+                                removeDiv('param_detail_div');
 
-                                                       }
-                                               if (code == 'nok')
-                                                       {
-                                                               // montre erreur
-                                                               
$('param_detail_info_div').innerHTML=code_html;
-                                                       }
-                                       }
-                                       catch (e) {
-                                               alert("save_param_detail 
"+e.message);
-                                       }
-                                       try{
-                                               code_html.evalScripts();
-                                       }
-                                       catch(e){
-                                               alert("save_param_detail 
Impossible executer script de la reponse\n"+e.message);
-                                       }
+                            }
+                            if (code == 'nok')
+                            {
+                                // montre erreur
+                                $('param_detail_info_div').innerHTML = 
code_html;
+                            }
+                        }
+                        catch (e) {
+                            alert("save_param_detail " + e.message);
+                        }
+                        try {
+                            code_html.evalScripts();
+                        }
+                        catch (e) {
+                            alert("save_param_detail Impossible executer 
script de la reponse\n" + e.message);
+                        }
 
-                               }
-                       }
-                       );
-       }
-       catch(e)
-       {
-               alert(e.message);
-       }
+                    }
+                }
+        );
+    }
+    catch (e)
+    {
+        alert(e.message);
+    }
 
-       return false;
+    return false;
 }
-function rapav_declaration_display(plugin_code,ac,dossier,d_id)
+function rapav_declaration_display(plugin_code, ac, dossier, d_id)
 {
-       try
-       {
-               $('declaration_list_div').hide();
-               $('declaration_display_div').innerHTML="";
-               $('declaration_display_div').show();
-               waiting_box();
-               var 
querystring='plugin_code='+plugin_code+'&ac='+ac+'&gDossier='+dossier+'&act=rapav_declaration_display'+"&d_id="+d_id;
-               var action=new Ajax.Request(
-                       "ajax.php",
-                       {
-                               method:'get',
-                               parameters:querystring,
-                               onFailure:error_get_predef,
-                               onSuccess:function(req){
-                                       remove_waiting_box();
-                                       var answer=req.responseText;
-                                       
$('declaration_display_div').innerHTML=answer;
-                                       answer.evalScripts()
-                               }
-                       }
-                       );
-       }
-       catch(e)
-       {
-               alert(e.message);
-       }
+    try
+    {
+        $('declaration_list_div').hide();
+        $('declaration_display_div').innerHTML = "";
+        $('declaration_display_div').show();
+        waiting_box();
+        var querystring = 'plugin_code=' + plugin_code + '&ac=' + ac + 
'&gDossier=' + dossier + '&act=rapav_declaration_display' + "&d_id=" + d_id;
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: querystring,
+                    onFailure: error_get_predef,
+                    onSuccess: function(req) {
+                        remove_waiting_box();
+                        var answer = req.responseText;
+                        $('declaration_display_div').innerHTML = answer;
+                        answer.evalScripts()
+                    }
+                }
+        );
+    }
+    catch (e)
+    {
+        alert(e.message);
+    }
 }
-function rapav_declaration_delete(plugin_code,ac,dossier,d_id)
+function rapav_declaration_delete(plugin_code, ac, dossier, d_id)
 {
-       try
-       {
-               if ( confirm('Confirmez-vous l\'effacement ?') == false) { 
return;}
-               waiting_box();
-               var 
querystring='plugin_code='+plugin_code+'&ac='+ac+'&gDossier='+dossier+'&act=rapav_declaration_delete'+"&d_id="+d_id;
-               var action=new Ajax.Request(
-                       "ajax.php",
-                       {
-                               method:'get',
-                               parameters:querystring,
-                               onFailure:error_get_predef,
-                               onSuccess:function(req){
-                                       remove_waiting_box();
-                                       
$('tr_'+d_id).style.textDecoration="line-through";
-                                       $('tr_'+d_id).style.color="red";
-                                       $('del_'+d_id).innerHTML="";
-                                       $('mod_'+d_id).innerHTML="";
-                               }
-                       }
-                       );
-       }
-       catch(e)
-       {
-               alert(e.message);
-       }
+    try
+    {
+        if (confirm('Confirmez-vous l\'effacement ?') == false) {
+            return;
+        }
+        waiting_box();
+        var querystring = 'plugin_code=' + plugin_code + '&ac=' + ac + 
'&gDossier=' + dossier + '&act=rapav_declaration_delete' + "&d_id=" + d_id;
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: querystring,
+                    onFailure: error_get_predef,
+                    onSuccess: function(req) {
+                        remove_waiting_box();
+                        $('tr_' + d_id).style.textDecoration = "line-through";
+                        $('tr_' + d_id).style.color = "red";
+                        $('del_' + d_id).innerHTML = "";
+                        $('mod_' + d_id).innerHTML = "";
+                    }
+                }
+        );
+    }
+    catch (e)
+    {
+        alert(e.message);
+    }
 }
 /**
  * @brief export of a form
@@ -391,24 +395,24 @@
  * @param d_id id
  * @returns {undefined}
  */
-function rapav_form_export(plugin_code,ac,dossier,d_id)
+function rapav_form_export(plugin_code, ac, dossier, d_id)
 {
-       try {
-               var 
querystring='plugin_code='+plugin_code+'&ac='+ac+'&gDossier='+dossier+'&act=rapav_form_export'+"&d_id="+d_id;
-               var action=new Ajax.Request(
-                       "ajax.php",
-                       {
-                               method:'get',
-                               parameters:querystring,
-                               onFailure:error_get_predef,
-                               onSuccess:null
-                       }
-                       );
+    try {
+        var querystring = 'plugin_code=' + plugin_code + '&ac=' + ac + 
'&gDossier=' + dossier + '&act=rapav_form_export' + "&d_id=" + d_id;
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: querystring,
+                    onFailure: error_get_predef,
+                    onSuccess: null
+                }
+        );
 
-       }catch (e)
-       {
-               alert(e.message);
-       }
+    } catch (e)
+    {
+        alert(e.message);
+    }
 }
 /**
  * @brief Remove a template
@@ -418,38 +422,38 @@
  * @param f_id pk of form_def
  *
  * @note sprintf("rapav_remove_doc_template('%s','%s','%s','%s')",
-                                               $_REQUEST['plugin_code'],
-                                               $_REQUEST['ac'],
-                                               $_REQUEST['gDossier'],
-                                               $this->f_id
-*/
-function rapav_remove_doc_template(plugin_code,ac,dossier,f_id)
+ $_REQUEST['plugin_code'],
+ $_REQUEST['ac'],
+ $_REQUEST['gDossier'],
+ $this->f_id
+ */
+function rapav_remove_doc_template(plugin_code, ac, dossier, f_id)
 {
-       if ( ! confirm ("Confirmez-vous l'effacement de ce modèle ?"))
-               {
-                       return;
-               }
-       try {
-               var 
querystring='plugin_code='+plugin_code+'&ac='+ac+'&gDossier='+dossier+'&act=rapav_remove_doc_template'+"&f_id="+f_id;
-               var action=new Ajax.Request(
-                       "ajax.php",
-                       {
-                               method:'get',
-                               parameters:querystring,
-                               onFailure:error_get_predef,
-                               onSuccess:function() {
-                                       
$('rapav_template').style.textDecoration='line-through';
-                                       $('rapav_template').style.color='red';
-                                       $('rapav_template_ctl').innerHTML='';
-                                       
$('rapav_new_file').style.display='block';
-                               }
-                       }
-                       );
+    if (!confirm("Confirmez-vous l'effacement de ce modèle ?"))
+    {
+        return;
+    }
+    try {
+        var querystring = 'plugin_code=' + plugin_code + '&ac=' + ac + 
'&gDossier=' + dossier + '&act=rapav_remove_doc_template' + "&f_id=" + f_id;
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: querystring,
+                    onFailure: error_get_predef,
+                    onSuccess: function() {
+                        $('rapav_template').style.textDecoration = 
'line-through';
+                        $('rapav_template').style.color = 'red';
+                        $('rapav_template_ctl').innerHTML = '';
+                        $('rapav_new_file').style.display = 'block';
+                    }
+                }
+        );
 
-       }catch (e)
-       {
-               alert(e.message);
-       }
+    } catch (e)
+    {
+        alert(e.message);
+    }
 }
 /**
  * Receive a json object and display a window to add a new listing
@@ -464,7 +468,7 @@
 {
     console.log(json)
     try {
-        var querystring = 'plugin_code=' + json.pc + '&ac=' + json.ac + 
'&gDossier=' + json.gDossier + '&act=listing_modify' + "&cin=" + json.cin + 
'&cout=' + json.cout+'&id='+json.id;
+        var querystring = 'plugin_code=' + json.pc + '&ac=' + json.ac + 
'&gDossier=' + json.gDossier + '&act=listing_modify' + "&cin=" + json.cin + 
'&cout=' + json.cout + '&id=' + json.id;
         waiting_box();
         var action = new Ajax.Request(
                 "ajax.php",
@@ -482,10 +486,10 @@
                                 throw 'cannot find ctl element';
                             }
                             remove_waiting_box();
-                            var code_html = getNodeText(html[0]); 
+                            var code_html = getNodeText(html[0]);
                             code_html = unescape_xml(code_html);
-                            var position=fixed_position(451,217);
-                            
add_div({'id':json.cout,'cssclass':'inner_box','drag':1,'style':position});
+                            var position = fixed_position(451, 217);
+                            add_div({'id': json.cout, 'cssclass': 'inner_box', 
'drag': 1, 'style': position});
                             $(json.cout).innerHTML = code_html;
                         } catch (e) {
                             console.log(e);
@@ -508,8 +512,8 @@
  */
 function check_listing_add(form_id)
 {
-    var str=$(form_id)['name'].value;
-    if ( str.trim()=='') {
+    var str = $(form_id)['name'].value;
+    if (str.trim() == '') {
         error_message('Le nom est obligatoire');
         return false;
     }
@@ -528,7 +532,7 @@
 {
     console.log(json)
     try {
-        var querystring = 'plugin_code=' + json.pc + '&ac=' + json.ac + 
'&gDossier=' + json.gDossier + '&act=listing_remove_modele' + "&cin=" + 
json.cin + '&cout=' + json.cout+'&id='+json.id;
+        var querystring = 'plugin_code=' + json.pc + '&ac=' + json.ac + 
'&gDossier=' + json.gDossier + '&act=listing_remove_modele' + "&cin=" + 
json.cin + '&cout=' + json.cout + '&id=' + json.id;
         waiting_box();
         var action = new Ajax.Request(
                 "ajax.php",
@@ -546,10 +550,10 @@
                                 throw 'cannot find ctl element';
                             }
                             remove_waiting_box();
-                            var code_html = getNodeText(html[0]); 
+                            var code_html = getNodeText(html[0]);
                             code_html = unescape_xml(code_html);
-                             console.log(code_html);
-                           $(json.cout).innerHTML = code_html;
+                            console.log(code_html);
+                            $(json.cout).innerHTML = code_html;
                         } catch (e) {
                             console.log(e);
                             console.log(code_html);
@@ -576,11 +580,11 @@
  *     - cout
  *
  */
-function listing_definition (json)
+function listing_definition(json)
 {
     console.log(json)
     try {
-        var querystring = 'plugin_code=' + json.pc + '&ac=' + json.ac + 
'&gDossier=' + json.gDossier + '&act=listing_display_definition' + "&cin=" + 
json.cin + '&cout=' + json.cout+'&id='+json.id;
+        var querystring = 'plugin_code=' + json.pc + '&ac=' + json.ac + 
'&gDossier=' + json.gDossier + '&act=listing_display_definition' + "&cin=" + 
json.cin + '&cout=' + json.cout + '&id=' + json.id;
         waiting_box();
         var action = new Ajax.Request(
                 "ajax.php",
@@ -598,10 +602,10 @@
                                 throw 'cannot find ctl element';
                             }
                             remove_waiting_box();
-                            var code_html = getNodeText(html[0]); 
+                            var code_html = getNodeText(html[0]);
                             code_html = unescape_xml(code_html);
-                             console.log(code_html);
-                           $(json.cout).innerHTML = code_html;
+                            console.log(code_html);
+                            $(json.cout).innerHTML = code_html;
                         } catch (e) {
                             console.log(e);
                             console.log(code_html);
@@ -630,7 +634,7 @@
 {
     console.log(json);
     try {
-        var querystring = 'plugin_code=' + json.pc + '&ac=' + json.ac + 
'&gDossier=' + json.gDossier + '&act=listing_param_add' + "&cin=" + json.cin 
+'&id='+json.id;
+        var querystring = 'plugin_code=' + json.pc + '&ac=' + json.ac + 
'&gDossier=' + json.gDossier + '&act=listing_param_add' + "&cin=" + json.cin + 
'&id=' + json.id;
         waiting_box();
         var action = new Ajax.Request(
                 "ajax.php",
@@ -648,12 +652,12 @@
                                 throw 'cannot find ctl element';
                             }
                             remove_waiting_box();
-                            var code_html = getNodeText(html[0]); 
+                            var code_html = getNodeText(html[0]);
                             code_html = unescape_xml(code_html);
                             console.log(code_html);
-                            var position=fixed_position(451,217)+';width:50%';
-                            
add_div({'id':json.cin,'cssclass':'inner_box','drag':1,'style':position});
-                           $(json.cin).innerHTML = code_html;
+                            var position = fixed_position(451, 217) + 
';width:50%';
+                            add_div({'id': json.cin, 'cssclass': 'inner_box', 
'drag': 1, 'style': position});
+                            $(json.cin).innerHTML = code_html;
                         } catch (e) {
                             console.log(e);
                             console.log(code_html);
@@ -667,4 +671,84 @@
         alert(e.message);
 
     }
+}
+/**
+ * @brief sauve les données pour nouvelle formule, code,...
+ * @param p_form_id id du form
+ */
+function save_param_listing(p_form_id)
+{
+    /**
+     * code_id can not be empty
+     */
+    if ( $('code_id').value.trim()=='') {
+       $('code_id').style.border="solid 2px red";
+       $('code_id_span').innerHTML=' Code ne peut pas être vide';
+        return false;
+    }
+    try
+    {
+        var qs = $(p_form_id).serialize() + 
'&act=save_param_listing&'+$('common_frm').serialize();
+        waiting_box();
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: qs,
+                    onFailure: error_get_predef,
+                    onSuccess: function infodiv(req, json) {
+                        try {
+                            remove_waiting_box();
+                            var answer = req.responseXML;
+                            var acode = answer.getElementsByTagName('code');
+                            var ap_id = answer.getElementsByTagName('l_id');
+                            var html = answer.getElementsByTagName('html');
+
+                            if (acode.length == 0) {
+                                var rec = req.responseText;
+                                alert('erreur :' + rec);
+                            }
+                            var code = acode[0].firstChild.nodeValue;
+                            var code_xml = getNodeText(html[0]);
+                            var code_html = unescape_xml(code_xml);
+                            if (code == 'ok')
+                            {
+                                var afpid = 
answer.getElementsByTagName('lp_id');
+                                var fp_id = afpid[0].firstChild.nodeValue;
+                                var p_id = ap_id[0].firstChild.nodeValue;
+                                // Ajoute une ligne avec résultat
+                                var mytable = g("definition_tb_id").tBodies[0];
+                                var nNumberRow = mytable.rows.length;
+                                var oRow = mytable.insertRow(nNumberRow);
+                                oRow.id = "tr_" + fp_id;
+                                oRow.innerHTML = code_html;
+                                removeDiv('listing_param_input_div_id');
+
+                            }
+                            if (code == 'nok')
+                            {
+                                // montre erreur
+                                $('info_listing_param_input_div_id').innerHTML 
= code_html;
+                            }
+                        }
+                        catch (e) {
+                            alert("save_param_detail " + e.message);
+                        }
+                        try {
+                            code_html.evalScripts();
+                        }
+                        catch (e) {
+                            alert("save_param_detail Impossible executer 
script de la reponse\n" + e.message);
+                        }
+
+                    }
+                }
+        );
+    }
+    catch (e)
+    {
+        alert(e.message);
+    }
+
+    return false;
 }
\ No newline at end of file



---
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]