noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 08/27: Add new keys


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 08/27: Add new keys
Date: Thu, 02 Oct 2014 14:23:10 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit 8ff0a762d45d3b1369999d3e06aa5f9f81bfe816
Author: Dany De Bontridder <address@hidden>
Date:   Tue Sep 16 21:52:14 2014 +0200

    Add new keys
---
 include/anc_key.inc.php   |    7 +++++--
 include/class_anc_key.php |   20 ++++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/include/anc_key.inc.php b/include/anc_key.inc.php
index 0365fae..2527934 100644
--- a/include/anc_key.inc.php
+++ b/include/anc_key.inc.php
@@ -37,10 +37,11 @@ switch ($op)
 {
     case 'list':
         Anc_Key::display_list();
+        Anc_Key::key_add();
         break;
     case 'consult':
-        $id=HtmlInput::default_value_request("key", "-1");
-        if (isNumber($id)==0||$id==-1)
+        $id=HtmlInput::default_value_request("key", "0");
+        if (isNumber($id)==0||$id==0)
         {
             die(_('Clef invalide'));
         }
@@ -51,6 +52,8 @@ switch ($op)
             {
                 $key->save($_POST);
                 Anc_Key::display_list();
+                Anc_Key::key_add();
+
                 break;
             }
             catch (Exception $e)
diff --git a/include/class_anc_key.php b/include/class_anc_key.php
index 0cd492b..c277a52 100644
--- a/include/class_anc_key.php
+++ b/include/class_anc_key.php
@@ -131,6 +131,9 @@ class Anc_Key
         {
             throw new Exception(_('Le total ne vaut pas 100, total calculé = 
').$tot_percent);
         }
+        if ($p_array['name_key']=='') {
+            throw new Exception (_('Le nom ne peut être vide'));
+        }
     }
 
     /**
@@ -198,6 +201,9 @@ class Anc_Key
         $a_plan=$p_array['pa'];
         try
         {
+            $this->key->setp('name',$p_array['name_key']);
+            $this->key->setp('description',$p_array['description_key']);
+            $this->key->save();
             for ($i=0; $i<count($a_row); $i++)
             {
                 //save key_distribution_row
@@ -236,6 +242,7 @@ class Anc_Key
                 $ledger->jrn_def_id=$a_ledger[$k];
                 $ledger->save();
             }
+            
         }
         catch (Exception $e)
         {
@@ -299,4 +306,17 @@ class Anc_Key
         
     }
 
+    static function key_add()
+    {
+        $key=new Anc_Key();
+        $key->key->setp('name',_('Nouvelle clef'));
+        $key->key->setp('description',_('Description de la nouvelle clef'));
+        ?>
+<input type="button" class="smallbutton" value="<?php echo  _('Ajout')?>" 
onclick="$('key_add_div_id').show()">
+<div id="key_add_div_id" style="display: none">
+<?php
+        $key->input();
+        echo '</div>';
+        
+    }
 }



reply via email to

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