noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
default_menu.class.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19// Copyright Author Dany De Bontridder danydb@aevalys.eu
20
21/**
22 * Description of class_default_menu
23 *
24 * @author dany
25 */
26require_once NOALYSS_INCLUDE.'/database/default_menu_sql.class.php';
27
29{
30
31 /**
32 * $a_menu_def is an array of Default_Menu_SQL
33 */
34 private $a_menu_def;
35
36 /**
37 * Possible values code_follow,code_invoice,code_feenote
38 */
39 private $code; //!< array with the valid code
40
41 function __construct()
42 {
43 global $cn;
45 $ret = $menu->seek();
46 for ($i = 0; $i < Database::num_row($ret); $i++)
47 {
48 $tmenu = $menu->next($ret, $i);
49 $idx = $tmenu->getp('md_code');
50 $this->a_menu_def[$idx] = $tmenu->getp('me_code');
51 }
52 $this->code = explode(',', 'code_follow,code_invoice,code_feenote',);
53 }
54
55 function input_value()
56 {
57 $code_invoice = new IText('code_invoice', $this->a_menu_def['code_invoice']);
58 $code_follow = new IText('code_follow', $this->a_menu_def['code_follow']);
59 $code_feenote = new IText('code_feenote', $this->a_menu_def['code_feenote']);
60 echo '<div class="form-group">';
61 echo '<div class="form-text">' .'<label for="code_invoice">'._('Code AD pour création facture depuis gestion').
62 "</label>"."</div>". '<div class="form-text">' .$code_invoice->input() . '</div>';
63
64 echo '<div class="form-text">' .'<label for="code_follow">'._('Code AD pour appel gestion').
65 "</label>"."</div>". '<div class="form-text">' .$code_follow->input() . '</div>';
66
67 echo '<div class="form-text">' .'<label for="code_feenote">'._('Code AD pour création note de frais ou facture achat').
68 "</label>"."</div>". '<div class="form-text">' .$code_feenote->input() . '</div>';
69 echo '</div>';
70 }
71
72 private function check_code($p_string)
73 {
74 global $cn;
75 $count = $cn->get_value('select count(*) from v_menu_description_favori where '
76 . 'code = $1', array($p_string));
77 if ($count != 0)
78 {
79 return ;
80 }
81 $count = $cn->get_value('select count(*) from menu_ref where '
82 . 'me_code = $1', array($p_string));
83 if ($count != 0)
84 {
85 return ;
86 }
87 throw new Exception('code_inexistant');
88 }
89
90 function verify()
91 {
92 foreach ($this->code as $code)
93 {
94 $this->check_code($this->a_menu_def[$code]);
95 }
96 }
97
98 function set($p_string, $p_value)
99 {
100 if (in_array($p_string, $this->code) == false)
101 {
102 throw new Exception("code_invalid");
103 }
104 $this->a_menu_def[$p_string] = $p_value;
105 }
106 function get ($p_string)
107 {
108 return $this->a_menu_def[$p_string];
109 }
110
111 function save()
112 {
113 global $cn;
114 try
115 {
116 $this->verify();
117 foreach ($this->a_menu_def as $key => $value)
118 {
119 $cn->exec_sql('update menu_default set me_code=$1 where
120 md_code =$2', array($value,$key));
121 }
122 } catch (Exception $e)
123 {
124 record_log($e);
125 echo $e->getMessage();
126 throw $e;
127 }
128 }
129
130
131}
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
_("actif, passif,charge,...")
static num_row($ret)
wrapper for the function pg_num_rows
Description of class_default_menu_sql.
Description of class_default_menu.
$a_menu_def
$a_menu_def is an array of Default_Menu_SQL
$code
Possible values code_follow,code_invoice,code_feenote.
check_code($p_string)
Html Input Text member :
$count