noalyss Version-9
ajax_add_menu.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
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/**
23 * @file
24 * @brief show the form for adding a menu.
25 * $type :
26 * # me , it is a menu to add , so it could have dependencies
27 * # pr , menu for Printing : no dependency
28 * $p_level:
29 * # 0 it is a module : no dependency p_type = M , refresh the detail of menu
30 * # 1 it is a menu with possible submenu p_type = E, refresh the table with menu
31 * # 2 it is a menu with no submenu , p_type = E
32 * $dep : is the profile_menu.pm_id of the parent menu
33 *
34 *
35 */
36if (!defined('ALLOWED'))
37 die('Appel direct ne sont pas permis');
38
39// Security
40if ($g_user->check_module('CFGPRO')==0)
41 die();
42
44
45try
46{
47 $type=$http->get('type');
48 $p_level=$http->get('p_level', "string",0);
49 $dep=$http->get('dep', "string",0);
50}
51catch (Exception $exc)
52{
53 echo $exc->getMessage();
54 error_log($exc->getTraceAsString());
55 return;
56}
57
58// if type == menu the
59if ($type=='me')
60{
61 if ( isNumber($p_level)==0 ) throw new Exception('invalid call');
62
63 if ($p_level==0)
64 {
65 // There is no dependency
66 // Menu which can be added
67 $ame_code=$cn->make_array("
68select me_code,me_code||' '||coalesce(me_menu,'')||' '||coalesce(me_description,'')
69 ||'('|| case when me_type='SP' then 'Special'
70 when me_type='PL' then 'Plugin'
71 when me_type='ME' and me_file is null and me_javascript is null and me_url is null then 'Module - Menu principal'
72 when me_type='ME' then 'Menu'
73 else
74 me_type
75 end||')'
76 from
77 menu_ref
78 where
79 me_type<>'PR'
80 order by 1
81 ");
82 }
83 elseif ($p_level==1)
84 {
85 // dependency is in dep
86 // Menu which can be added
87 $ame_code=$cn->make_array("
88select me_code,me_code||' '||coalesce(me_menu,'')||' '||coalesce(me_description,'')
89 ||'('|| case when me_type='SP' then 'Special'
90 when me_type='PL' then 'Plugin'
91 when me_type='ME' and me_file is null and me_javascript is null and me_url is null then 'Module - Menu principal'
92 when me_type='ME' then 'Menu'
93 else
94 me_type
95 end||')'
96 from
97 menu_ref
98 where
99 me_type<>'PR'
100 order by 1
101 ");
102 }
103 elseif ($p_level==2)
104 {
105 // menu can *NOT* have submenu
106 // Menu which can be added
107 $ame_code=$cn->make_array("
108select me_code,me_code||' '||coalesce(me_menu,'')||' '||coalesce(me_description,'')
109 ||'('|| case when me_type='SP' then 'Special'
110 when me_type='PL' then 'Plugin'
111 when me_type='ME' and me_file is null and me_javascript is null and me_url is null then 'Module - Menu principal'
112 when me_type='ME' then 'Menu'
113 else
114 me_type
115 end||')'
116 from
117 menu_ref
118 where
119 me_type<>'PR' and
120 (
121 coalesce(me_file,'') <> '' or
122 coalesce(me_url,'') <> '' or
123 coalesce(me_javascript,'') <> ''
124 )
125 order by 1
126 ");
127 }
128 else
129 {
130 throw new Exception('LEVEL ERROR');
131 }
132
133
134 $p_order=new INum("p_order", "10");
135
136 $me_code=new ISelect('me_code');
137 $me_code->rowsize=15;
138 $me_code->value=$ame_code;
139
140
141 $pm_default=new ICheckBox('pm_default');
142 echo HtmlInput::title_box(_("Nouveau"), $ctl);
143 ?>
144 <form method="POST" id="menu_new_frm" onsubmit="return confirm_box('menu_new_frm','<?php echo _('Vous confirmez'); ?> ?')">
145 <?php
146 echo HtmlInput::hidden('tab', 'profile_menu_div');
147 ?>
148 <?php echo HtmlInput::hidden('p_id', $p_id) ?>
149 <?php echo HtmlInput::hidden('add_menu', 1) ?>
150 <?php echo HtmlInput::hidden('p_level', $p_level) ?>
151 <?php echo HtmlInput::hidden('type', $type) ?>
152 <?php echo HtmlInput::hidden('dep', $dep) ?>
153 <table>
154 <tr>
155 <td><?php echo _("Code") ?></td>
156 <td><?php echo $me_code->input() ?></td>
157 </tr>
158
159 <tr>
160 <td><?php echo _("Ordre d'apparition") ?></td>
161 <td><?php echo $p_order->input() ?></td>
162 </tr>
163 <tr>
164 <td><?php echo _("Menu par défaut") ?></td>
165 <td><?php echo $pm_default->input() ?></td>
166 </tr>
167
168 </table>
169 <?php
170 echo HtmlInput::submit('add_menubt', _("Valider"));
171 echo '</form>';
172 return;
173 }
174
175// for printing menu (export CSV or PDF)
176 if ($type=='pr')
177 {
178
179 $ame_code=$cn->make_array("
180select me_code,me_code||' '||coalesce(me_menu,'')||' '||coalesce(me_description,'')
181 from
182 menu_ref
183 where me_type='PR'
184 and me_code not in (select me_code from profile_menu where p_id=$1)
185 order by 1
186 ", 0, array($p_id));
187
188 $me_code=new ISelect('me_code');
189 $me_code->value=$ame_code;
190
191 echo HtmlInput::title_box(_("Nouveau menu"), $ctl);
192 if (count($ame_code)==0)
193 {
194 echo h2(_("Aucune impression disponible à ajouter"),
195 'class="notice"');
196 return;
197 }
198 ?>
199 <form method="POST" id="menu_new2_frm" onsubmit="return confirm_box('menu_new2_frm','<?php echo _('Vous confirmez ?') ?>">
200 <?php
201 echo HtmlInput::hidden('tab', 'profile_print_div');
202 ?>
203 <?php echo HtmlInput::hidden('p_id', $p_id) ?>
204 <?php echo HtmlInput::hidden('p_order', 10) ?>
205 <?php echo HtmlInput::hidden('me_code_dep', '') ?>
206 <?php echo HtmlInput::hidden('p_type', 'PR') ?>
207 <?php echo HtmlInput::hidden('add_impress', 1) ?>
208 <table>
209 <tr>
210 <td><?php echo _("Code") ?></td>
211 <td><?php echo $me_code->input() ?></td>
212 </tr>
213
214 </table>
215 <?php
216 echo HtmlInput::submit('add_impressbt', _("Valider"));
217 echo '</form>';
218 return;
219 }
220 ?>
h2($p_string, $p_class="", $raw="")
Definition: ac_common.php:68
isNumber($p_int)
Definition: ac_common.php:215
tr($p_string, $p_extra='')
Definition: ac_common.php:88
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
global $g_user
if no group available , then stop
$http
$dep
$p_level
static hidden($p_name, $p_value, $p_id="")
static title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
manage the http input (get , post, request) and extract from an array
Html Input.
This class handles only the numeric input, the input will call a javascript to change comma to period...
Definition: inum.class.php:42
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
$all table
if( $delta< 0) elseif( $delta==0)