noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 213/219: Code rewrite : move the function Htm


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 213/219: Code rewrite : move the function HtmlInput::select_ledger into Acc_Ledger_Search::select_ledger
Date: Mon, 18 Dec 2017 13:23:04 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 8cd083ccd0ee98c8c0d28816918a26b69d10f9ac
Author: Dany De Bontridder <address@hidden>
Date:   Sat Dec 16 10:27:01 2017 +0100

    Code rewrite : move the function HtmlInput::select_ledger into 
Acc_Ledger_Search::select_ledger
---
 include/ajax/ajax_ledger_show.php         |  5 ++-
 include/class/acc_ledger_search.class.php | 67 ++++++++++++++++++++++++++++++-
 include/lib/html_input.class.php          | 66 +-----------------------------
 3 files changed, 70 insertions(+), 68 deletions(-)

diff --git a/include/ajax/ajax_ledger_show.php 
b/include/ajax/ajax_ledger_show.php
index 2557270..efaa80d 100644
--- a/include/ajax/ajax_ledger_show.php
+++ b/include/ajax/ajax_ledger_show.php
@@ -14,12 +14,13 @@
  */
 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
 
-require_once NOALYSS_INCLUDE.'/class/acc_ledger.class.php';
+require_once NOALYSS_INCLUDE.'/class/acc_ledger_search.class.php';
 require_once NOALYSS_INCLUDE.'/lib/html_input.class.php';
 if ( ! isset ($r_jrn)) { $r_jrn=null;}
 $ctl='div_jrn'.$div;
 ob_start();
-echo HtmlInput::select_ledger($type,$r_jrn, $div);
+$ledger=new Acc_Ledger_Search($type,1,$ctl);
+echo $ledger->select_ledger($r_jrn,$div);
 
 $response = ob_get_clean();
 $html = escape_xml($response);
diff --git a/include/class/acc_ledger_search.class.php 
b/include/class/acc_ledger_search.class.php
index c739bba..cd84656 100644
--- a/include/class/acc_ledger_search.class.php
+++ b/include/class/acc_ledger_search.class.php
@@ -241,7 +241,7 @@ class Acc_Ledger_Search
      *         - 1 means all the ledger of this type
      *         - 0 No have the "Tous les journaux" availables
      */
-    private function build_search_filter()
+    function build_search_filter()
     {
         $json=json_encode(["div"=>$this->div, "ledger_type"=>$this->type, 
"all_type"=>$this->all,
             "dossier"=>Dossier::id()]);
@@ -1047,5 +1047,70 @@ class Acc_Ledger_Search
         $r.='</table>';
         return array($count, $r);
     }
+     /**
+     * return the html code to create an hidden div and a button
+     * to show this DIV. This contains all the available ledgers
+     * for the user in READ or RW
+     address@hidden $p_selected is an array of checkbox
+     address@hidden $p_div div suffix for the list of ledgers
+     address@hidden the choosen ledger are stored in the array r_jrn (_GET)
+     */
+    function select_ledger($p_selected,$p_div)
+    {
+        global $g_user;
+       $r = '';
+       /* security : filter ledger on user */
+       $p_array = $g_user->get_ledger($this->type, 3);
+        
+        ob_start();
+        
+
+        /* create a hidden div for the ledger */
+        echo '<div id="div_jrn'.$p_div.'" >';
+        echo HtmlInput::title_box(_("Journaux"), $p_div."jrn_search");
+        echo '<div style="padding:5px">';
+        echo '<form method="GET" id="'.$p_div.'search_frm" onsubmit="return 
hide_ledger_choice(\''.$p_div.'search_frm\')">';
+        echo HtmlInput::hidden('nb_jrn', count($p_array));
+        echo _('Filtre ').HtmlInput::filter_table($p_div.'tb_jrn', '0,1,2', 2);
+        echo '<table class="result" id="'.$p_div.'tb_jrn">';
+        echo '<tr>';
+        echo th(_('Nom'));
+        echo th(_('Description'));
+        echo th(_('Type'));
+        echo '</tr>';
+        echo '<tr>';
+        echo '<td>';
+        echo HtmlInput::button('sel_'.$p_div,_('Inverser la sélection'),' 
onclick = "toggle_checkbox(\''."{$p_div}search_frm".'\')"');
+        echo '</td>';
+        echo '</tr>';
+        for ($e=0;$e<count($p_array);$e++)
+        {
+            $row=$p_array[$e];
+            $r=new ICheckBox($p_div.'r_jrn'.$e,$row['jrn_def_id']);
+            $idx=$row['jrn_def_id'];
+            if ( $p_selected != null &&  
in_array($row['jrn_def_id'],$p_selected))
+            {
+                $r->selected=true;
+            }
+            $class=($e%2==0)?' class="even" ':' class="odd" ';
+            echo '<tr '.$class.'>';
+            echo '<td style="white-space: 
nowrap">'.$r->input().$row['jrn_def_name'].'</td>';
+            echo '<td >'.$row['jrn_def_description'].'</td>';
+            echo '<td >'.$row['jrn_def_type'].'</td>';
+            echo '</tr>';
+
+        }
+        echo '</table>';
+        echo HtmlInput::hidden('div',$p_div);
+        echo HtmlInput::submit('save',_('Valider'));
+        echo HtmlInput::button_close($p_div."jrn_search");
+        echo '</form>';
+        echo '</div>';
+        echo '</div>';
+  
+        $ret=ob_get_contents();
+        ob_end_clean();
+        return $ret;
+    }
 
 }
diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php
index a153306..18909af 100755
--- a/include/lib/html_input.class.php
+++ b/include/lib/html_input.class.php
@@ -358,71 +358,7 @@ class HtmlInput
         return $view_history;
     }
 
-    /**
-     * return the html code to create an hidden div and a button
-     * to show this DIV. This contains all the available ledgers
-     * for the user in READ or RW
-     address@hidden $selected is an array of checkbox
-     address@hidden $div div suffix
-     address@hidden the choosen ledger are stored in the array r_jrn (_GET)
-     */
-    static function select_ledger($p_type,$p_selected,$div='')
-    {
-        global $g_user;
-       $r = '';
-       /* security : filter ledger on user */
-       $p_array = $g_user->get_ledger($p_type, 3);
-        
-        ob_start();
-        
-
-        /* create a hidden div for the ledger */
-        echo '<div id="div_jrn'.$div.'" >';
-        echo HtmlInput::title_box(_("Journaux"), $div."jrn_search");
-        echo '<div style="padding:5px">';
-        echo '<form method="GET" id="'.$div.'search_frm" onsubmit="return 
hide_ledger_choice(\''.$div.'search_frm\')">';
-        echo HtmlInput::hidden('nb_jrn', count($p_array));
-        echo _('Filtre ').HtmlInput::filter_table($div.'tb_jrn', '0,1,2', 2);
-        echo '<table class="result" id="'.$div.'tb_jrn">';
-        echo '<tr>';
-        echo th(_('Nom'));
-        echo th(_('Description'));
-        echo th(_('Type'));
-        echo '</tr>';
-        echo '<tr>';
-        echo '<td>';
-        echo HtmlInput::button('sel_'.$div,_('Inverser la sélection'),' 
onclick = "toggle_checkbox(\''."{$div}search_frm".'\')"');
-        echo '</td>';
-        echo '</tr>';
-        for ($e=0;$e<count($p_array);$e++)
-        {
-            $row=$p_array[$e];
-            $r=new ICheckBox($div.'r_jrn'.$e,$row['jrn_def_id']);
-            $idx=$row['jrn_def_id'];
-            if ( $p_selected != null &&  
in_array($row['jrn_def_id'],$p_selected))
-            {
-                $r->selected=true;
-            }
-            $class=($e%2==0)?' class="even" ':' class="odd" ';
-            echo '<tr '.$class.'>';
-            echo '<td style="white-space: 
nowrap">'.$r->input().$row['jrn_def_name'].'</td>';
-            echo '<td >'.$row['jrn_def_description'].'</td>';
-            echo '<td >'.$row['jrn_def_type'].'</td>';
-            echo '</tr>';
-
-        }
-        echo '</table>';
-        echo HtmlInput::hidden('div',$div);
-        echo HtmlInput::submit('save',_('Valider'));
-        echo HtmlInput::button_close($div."jrn_search");
-        echo '</form>';
-        echo '</div>';
-        echo '</div>';
-  
-        $ret=ob_get_contents();
-        ob_end_clean();
-        return $ret;
-    }
+   
     /**
      *create a hidden plus button to select the cat of ledger
      address@hidden the selected value is stored in the array p_cat



reply via email to

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