noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 49/323: Tak #1522 : Journaux peuvent être in


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 49/323: Tak #1522 : Journaux peuvent être inactif
Date: Wed, 14 Mar 2018 17:38:16 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 5b9362c903d6c332a43aabd1af8502433358fff3
Author: Dany De Bontridder <address@hidden>
Date:   Wed Jan 10 18:42:49 2018 +0100

    Tak #1522 : Journaux peuvent être inactif
---
 include/cfgledger.inc.php                 |  4 +++-
 include/class/acc_ledger.class.php        | 14 ++++++++++++++
 include/class/acc_ledger_search.class.php |  1 +
 include/class/user.class.php              | 10 +++++-----
 include/database/jrn_def_sql.class.php    | 10 ++++++++--
 include/template/param_jrn.php            | 23 +++++++++++++++--------
 sql/upgrade.sql                           |  4 ++++
 7 files changed, 50 insertions(+), 16 deletions(-)

diff --git a/include/cfgledger.inc.php b/include/cfgledger.inc.php
index d9fc2b3..2a1c28f 100644
--- a/include/cfgledger.inc.php
+++ b/include/cfgledger.inc.php
@@ -78,7 +78,9 @@ if ($action_frm == 'delete' )
                $ledger->delete_ledger();
                $sa="";
                echo '<div id="jrn_name_div">';
-               echo '<h2 id="jrn_name">'.h($name). "  est effacé"."</h2>";
+               echo '<h2 id="jrn_name">';
+                printf(_(" %s est effacé"),h($name));
+                echo "</h2>";
                echo '</div>';
                 $show_menu=1;
        }
diff --git a/include/class/acc_ledger.class.php 
b/include/class/acc_ledger.class.php
index 4f278d3..7a2333e 100644
--- a/include/class/acc_ledger.class.php
+++ b/include/class/acc_ledger.class.php
@@ -2705,6 +2705,12 @@ class Acc_Ledger extends jrn_def_sql
         $new=0;
         $cn=$this->db;
         echo $hidden;
+        $actif=new ISelect("jrn_enable");
+        $actif->value=[
+            ["label"=>_("Activé"),"value"=>1],
+            ["label"=>_("Désactivé"),"value"=>0]
+        ];
+        $actif->selected=$this->jrn_enable;
         require_once NOALYSS_TEMPLATE.'/param_jrn.php';
     }
 
@@ -2784,6 +2790,7 @@ class Acc_Ledger extends jrn_def_sql
         $this->jrn_def_pj_pref=$jrn_def_pj_pref;
         $this->jrn_deb_max_line=($min_row<1)?1:$min_row;
         $this->jrn_def_description=$p_description;
+        $this->jrn_enable=$jrn_enable;
         switch ($this->jrn_def_type)
         {
             case 'ACH':
@@ -3239,6 +3246,13 @@ class Acc_Ledger extends jrn_def_sql
                         "image/bouton-plus.png");
         return $str_add_button;
     }
+    /**
+     * Check if a ledger is enabled , 1 for yes and 0 if disabled
+     */
+    function is_enable()
+    {
+       return $this->db->get_value("select jrn_enable from jrn_def where 
jrn_def_id=$1",[$this->id]); 
+    }
 
 }
 
diff --git a/include/class/acc_ledger_search.class.php 
b/include/class/acc_ledger_search.class.php
index ff1654e..a90f53b 100644
--- a/include/class/acc_ledger_search.class.php
+++ b/include/class/acc_ledger_search.class.php
@@ -1094,6 +1094,7 @@ class Acc_Ledger_Search
         for ($e=0;$e<count($p_array);$e++)
         {
             $row=$p_array[$e];
+            if ( $row['jrn_enable']==0) continue;
             $r=new ICheckBox($p_div.'r_jrn'.$e,$row['jrn_def_id']);
             $r->set_attribute("ledger_type", $row['jrn_def_type']);
             $idx=$row['jrn_def_id'];
diff --git a/include/class/user.class.php b/include/class/user.class.php
index 4849af9..256b5e3 100644
--- a/include/class/user.class.php
+++ b/include/class/user.class.php
@@ -317,10 +317,10 @@ class User
                        switch ($p_access)
                        {
                                case 3:
-                                       $sql_access = " and uj_priv!= 'X'";
+                                       $sql_access = " and uj_priv!= 'X' ";
                                        break;
                                case 2:
-                                       $sql_access = " and uj_priv = 'W'";
+                                       $sql_access = " and uj_priv = 'W' and 
jrn_enable=1 ";
                                        break;
 
                                case 1:
@@ -332,7 +332,7 @@ class User
                  
jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
                  jrn_deb_max_line,jrn_cred_max_line,jrn_def_description
                  from jrn_def join jrn_type on jrn_def_type=jrn_type_id
-                 join user_sec_jrn on uj_jrn_id=jrn_def_id
+                 join user_sec_jrn on uj_jrn_id=jrn_def_id,jrn_enable
                  where
                  uj_login='" . $this->login . "'" .
                                        $sql_type . $sql_access .
@@ -340,9 +340,9 @@ class User
                }
                else
                {
-                       $sql_type = ($p_type == 'ALL') ? '' : "where 
jrn_def_type=upper('" . sql_string($p_type) . "')";
+                       $sql_type = ($p_type == 'ALL') ? '  ' : "where 
jrn_def_type=upper('" . sql_string($p_type) . "') ";
                        $sql = "select 
jrn_def_id,jrn_def_type,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_deb_max_line,jrn_cred_max_line,
-                 jrn_type_id,jrn_desc,'W' as uj_priv,jrn_def_description
+                 jrn_type_id,jrn_desc,'W' as 
uj_priv,jrn_def_description,jrn_enable
                  from jrn_def join jrn_type on jrn_def_type=jrn_type_id
                  $sql_type
                  order by jrn_Def_name";
diff --git a/include/database/jrn_def_sql.class.php 
b/include/database/jrn_def_sql.class.php
index e430a43..4840fbc 100644
--- a/include/database/jrn_def_sql.class.php
+++ b/include/database/jrn_def_sql.class.php
@@ -266,7 +266,8 @@ class Jrn_Def_sql
 ,jrn_def_bank
 ,jrn_def_num_op
 ,jrn_def_id
-,jrn_def_description) values ($1
+,jrn_def_description,
+jrn_enable) values ($1
 ,$2
 ,$3
 ,$4
@@ -282,6 +283,7 @@ class Jrn_Def_sql
 ,$14
 ,$15
 ,$16
+,1
 ) returning jrn_def_id";
 
                        $this->jrn_def_id = $this->db->get_value(
@@ -325,6 +327,7 @@ class Jrn_Def_sql
 ,jrn_def_bank = $13
 ,jrn_def_num_op = $14
 ,jrn_def_description = $15
+,jrn_enable=$17
  where jrn_def_id= $16";
                $res = $this->db->exec_sql(
                                $sql, array($this->jrn_def_name
@@ -342,7 +345,9 @@ class Jrn_Def_sql
                        , $this->jrn_def_bank
                        , $this->jrn_def_num_op
                        , strip_tags($this->jrn_def_description)
-                       , $this->jrn_def_id)
+                       , $this->jrn_def_id
+                        , $this->jrn_enable
+                        )
                );
        }
 
@@ -368,6 +373,7 @@ class Jrn_Def_sql
 ,jrn_def_bank
 ,jrn_def_num_op
 ,jrn_def_description
+,jrn_enable
  from public.jrn_def where jrn_def_id=$1";
                /* please adapt */
                $res = $this->db->get_array(
diff --git a/include/template/param_jrn.php b/include/template/param_jrn.php
index d31b6b6..4634d0d 100644
--- a/include/template/param_jrn.php
+++ b/include/template/param_jrn.php
@@ -73,7 +73,14 @@ echo $str_add_button;
 </tr>
 <tr><td><INPUT TYPE="hidden" id="p_ech_lib" NAME="p_ech_lib" 
VALUE="echeance"></td>
 </tr>
-
+<tr>
+    <td style="width: 200px">
+    <?php echo _('Description') ?>
+    </TD>
+    <td style="width: 500px">
+     <?php echo $str_description; ?>   
+    </td>
+</tr>    
 <TR>
 <TD><?php echo _('Type de journal')?> </TD>
 <TD>
@@ -113,15 +120,15 @@ echo $str_add_button;
    
 </TD>
 </tr>
-<?php endif; ?>
 <tr>
-    <td style="width: 200px">
-    <?php echo _('Description') ?>
-    </TD>
-    <td style="width: 500px">
-     <?php echo $str_description; ?>   
+    <td>
+        <?=_("Journal actif")?>
     </td>
-</tr>    
+    <td>
+        <?=$actif->input()?>
+    </td>
+<?php endif; ?>
+
 </TABLE>
 <hr>
     <?php
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index 2e8ecfa..9811e0e 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -86,3 +86,7 @@ ALTER TABLE public.user_active_security ADD CONSTRAINT 
user_active_security_acti
 
 insert into user_active_security (us_login,us_ledger,us_action)  select 
user_name,'Y','Y' from profile_user;
 
+alter table jrn_def add jrn_enable int;
+alter table jrn_def alter  jrn_enable set default 1;
+update jrn_def set jrn_enable=1;
+comment on column jrn_def.jrn_enable is 'Set to 1 if the ledger is enable ';
\ No newline at end of file



reply via email to

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