noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 146/323: Ergonomy : ask exercice and periode


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 146/323: Ergonomy : ask exercice and periode separately in preference
Date: Wed, 14 Mar 2018 17:38:40 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 37435125f42817b417e1e5fa541524f4665f738c
Author: Dany De Bontridder <address@hidden>
Date:   Wed Feb 7 17:36:08 2018 +0100

    Ergonomy : ask exercice and periode separately in preference
---
 html/ajax_misc.php               | 13 +++++++++++++
 html/js/scripts.js               |  5 +++++
 include/ajax/ajax_preference.php | 35 ++++++++++++++++++++++++++---------
 include/class/exercice.class.php |  2 +-
 include/lib/iperiod.class.php    |  9 +++++++--
 5 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index c77c74c..1432864 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -245,6 +245,19 @@ if (array_key_exists($op, $path)) {
 }
 switch ($op)
 {
+    case "pref_exercice":
+        $iperiod = new IPeriod("period");
+        $iperiod->id="setting_period";
+        $iperiod->user = $g_user;
+        $iperiod->cn = $cn;
+        $iperiod->filter_year = true;
+        $iperiod->exercice=$http->get("exercice");
+        
+        $iperiod->type = ALL;
+        echo $iperiod->input();
+        
+        return;
+    break;
        case "remove_anc":
                if ($g_user->check_module('ANCODS') == 0)
                        exit();
diff --git a/html/js/scripts.js b/html/js/scripts.js
index 42942da..027e8a4 100644
--- a/html/js/scripts.js
+++ b/html/js/scripts.js
@@ -3480,3 +3480,8 @@ function progress_bar_check(p_idx, p_taskid)
 }
                                                 
 
+function updatePeriodePreference(p_dossier)
+{
+    var exercice=$('exercice').value;
+    new 
Ajax.Updater('setting_period',"ajax_misc.php",{method:"get",parameters:{ 
"op":"pref_exercice","gDossier":p_dossier,"exercice":exercice}});  
+}
\ No newline at end of file
diff --git a/include/ajax/ajax_preference.php b/include/ajax/ajax_preference.php
index 1b92a86..f2d1aac 100644
--- a/include/ajax/ajax_preference.php
+++ b/include/ajax/ajax_preference.php
@@ -27,6 +27,7 @@ require_once NOALYSS_INCLUDE.'/lib/iselect.class.php';
 require_once NOALYSS_INCLUDE.'/lib/iperiod.class.php';
 require_once NOALYSS_INCLUDE.'/class/acc_report.class.php';
 require_once NOALYSS_INCLUDE.'/class/periode.class.php';
+require_once NOALYSS_INCLUDE.'/class/exercice.class.php';
 echo HtmlInput::title_box(_('Préférence'), 'preference_div');
 echo '<DIV class="content">';
 echo '<p class="notice">';
@@ -105,21 +106,37 @@ if (isset($_REQUEST['gDossier']) && 
$_REQUEST['gDossier']<>0)
 
                    $period->p_id = $l_user_per;
                    $period->jrn_def_id = 0;
+                    $selected_exercice=$period->get_exercice();
+                    
$js=sprintf('onchange="updatePeriodePreference(%d);"',Dossier::id());
+                    $exercice=new Exercice($cn);
+                    
                    if ($period->is_closed($l_user_per) == 1)
                    {
                        $msg = _('Attention cette période est fermée, vous ne 
pourrez rien modifier dans le module comptable');
                        $msg = '<h2 class="notice">' . $msg . '</h2>';
                    }
-
-                   $period = new IPeriod("period");
-                   $period->user = $g_user;
-                   $period->cn = $cn;
-                   $period->filter_year = false;
-                   $period->value = $l_user_per;
-                   $period->type = ALL;
-                   $l_form_per = $period->input();
+                    
+                   $iperiod = new IPeriod("period");
+                    $iperiod->id="setting_period";
+                   $iperiod->user = $g_user;
+                   $iperiod->cn = $cn;
+                   $iperiod->filter_year = true;
+                    $iperiod->exercice=$selected_exercice;
+                   $iperiod->value = $l_user_per;
+                   $iperiod->type = ALL;
+                   $l_form_per = $iperiod->input();
                    ?>
-               <tr><td><?php echo _('Période');?></td>
+                <tr>
+                    <td>
+                        <?=_("Exercice")?>
+                    </td>
+                    <td>
+                        
<?=$exercice->select("exercice",$selected_exercice,$js)->input();?>
+                    </td>
+                </tr>
+               <tr>
+                    
+                    <td><?php echo _('Période');?></td>
                    <td>
                            <?php printf(' %s ', $l_form_per);?>
                    </td>
diff --git a/include/class/exercice.class.php b/include/class/exercice.class.php
index 991eea4..56290e4 100644
--- a/include/class/exercice.class.php
+++ b/include/class/exercice.class.php
@@ -26,7 +26,7 @@ require_once NOALYSS_INCLUDE.'/lib/database.class.php';
 require_once NOALYSS_INCLUDE.'/lib/iselect.class.php';
 class Exercice
 {
-  function __construct(&$cn)
+  function __construct($cn)
   {
     $this->cn=$cn;
   }
diff --git a/include/lib/iperiod.class.php b/include/lib/iperiod.class.php
index 6b70d08..a4f1b6e 100644
--- a/include/lib/iperiod.class.php
+++ b/include/lib/iperiod.class.php
@@ -55,7 +55,8 @@ class IPeriod extends HtmlInput
         $this->extra2="all";
         $this->show_start_date=true;
         $this->show_end_date=true;
-               $this->exercice=$p_exercice;
+        $this->exercice=$p_exercice;
+        $this->id=$p_name;
     }
     /*!
      * \brief show the input html for a periode
@@ -121,7 +122,11 @@ class IPeriod extends HtmlInput
         $Res=$this->cn->exec_sql($sql);
         $Max=$this->cn->size($Res);
         if ( $Max == 0 )  throw new Exception(_('Aucune periode trouvée'),1);
-        $ret='<SELECT NAME="'.$this->name.'" '.$this->javascript.'>';
+        $ret=sprintf('<SELECT NAME="%s" id="%s" %s>',
+                $this->name,
+                $this->id,
+                $this->javascript)
+                ;
         for ( $i = 0; $i < $Max;$i++)
         {
             $l_line=$this->cn->fetch($i);



reply via email to

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