21if (!defined(
'ALLOWED'))
22 die(
'Appel direct ne sont pas permis');
23require_once NOALYSS_INCLUDE.
'/database/profile_sql.class.php';
29if (isset(
$_POST[
'change_profile']))
33 $aRight=
$http->post(
"right",
"array",array());
34 $aUserProfile=
$http->post(
"ua_id",
"array",array());
36 $aProfile=
$http->post(
"ap_id",
"array",array());
37 for (
$e=0;
$e<count($aUserProfile);
$e++)
39 if ($aUserProfile[
$e]==
'X'&&$aUserProfile[
$e]==
'')
41 if ($aRight[
$e]==
'X'&&$aUserProfile[
$e]!=
'')
43 $cn->exec_sql(
"delete from user_sec_action_profile where p_id=$1 and p_granted=$2",
47 if ($aUserProfile[
$e]==
""&& $aRight[
$e] !=
'X')
49 $cn->exec_sql(
"insert into user_sec_action_profile (p_id,p_granted,ua_right) values($1,$2,$3)",
50 array(
$p_id, $aProfile[
$e], $aRight[
$e]));
53 if ($aUserProfile[
$e]!=
'')
55 $cn->exec_sql(
"update user_sec_action_profile set ua_right=$3 where p_id=$1 and p_granted=$2 ",
56 array(
$p_id, $aProfile[
$e], $aRight[
$e]));
61 catch (Exception $exc)
63 echo $exc->getMessage();
71if (isset(
$_POST[
'change_stock']))
76 $right=
$http->post(
"right",
"array",array());
77 $ar_id=
$http->post(
"ar_id",
"array",array());
78 $ur_id=
$http->post(
"ur_id",
"array",array());
80 for (
$e=0;
$e<count($right);
$e++)
82 if ($right[
$e]==
'X'&&$ur_id[
$e]==
'')
84 if ($right[
$e]==
'X'&&$ur_id[
$e]!=
'')
86 $cn->exec_sql(
"delete from profile_sec_repository where p_id=$1 and r_id=$2",
92 $cn->exec_sql(
"insert into profile_sec_repository (p_id,r_id,ur_right) values($1,$2,$3)",
98 $cn->exec_sql(
"update profile_sec_repository set ur_right=$3 where p_id=$1 and r_id=$2 ",
104 catch (Exception $exc)
106 echo $exc->getMessage();
115if (isset(
$_POST[
'save_name']))
118 $p_name=
$http->post(
"p_name");
123 $p_desc=
$http->post(
'p_desc');
127 throw new Exception(
"Nom ne peut être vide");
129 throw new Exception(
"profile Invalide");
133 $cn->exec_sql(
"update profile set p_name=$1,p_desc=$2,
134 with_calc=$3, with_direct_form=$4 ,with_search_card=$6
141 $p_id=
$cn->get_value(
"insert into profile (p_name,
142 p_desc,with_calc,with_direct_form,with_search_card) values
143 ($1,$2,$3,$4,$5) returning p_id",
157if (isset(
$_POST[
'clone']))
163 $new_id=
$cn->get_value(
"insert into profile(p_name,p_desc,with_calc,
164 with_direct_form,with_search_card)
165 select 'copie de '||p_name,p_desc,with_calc,
166 with_direct_form , with_search_card from profile where p_id=$1 returning p_id", array(
$p_id));
168 insert into profile_menu (p_id,me_code,me_code_dep,p_order,p_type_display,pm_default)
169 select $1,me_code,me_code_dep,p_order,p_type_display,pm_default from profile_menu
171 ", array($new_id,
$p_id));
172 $cn->exec_sql(
"select menu_complete_dependency($1)",array($new_id));
173 $cn->exec_sql(
"update profile_menu
174 set pm_id_dep=(select distinct higher_dep
175 from v_menu_dependency as a
177 a.pm_id= profile_menu.pm_id)
178 where pm_id_dep is null and p_id=$1",array($new_id));
182 $_GET[
'p_id'] = $new_id;
184 $_POST[
'tab']=
"profile_gen_div";
186 catch (Exception $exc)
188 echo
alert($exc->getMessage());
196if (isset(
$_POST[
'delete_profil']))
205 throw new Exception(
'On ne peut pas effacer le profil par défaut');
207 $new_id=
$cn->get_value(
"delete from profile
208 where p_id=$1 ", array(
$p_id));
211 catch (Exception $exc)
213 echo
alert($exc->getMessage());
225 $pm_id=
$http->post(
"pm_id",
"number");
239 $menu_type=
$cn->get_value(
"select me_type from menu_ref
240 where me_code=$1", array(
$me_code));
242 if ($menu_type==
'PR')
252 $cn->exec_sql(
"update profile_menu set pm_default=0
253 where pm_id_dep=(select pm_id_dep from profile_menu
255 pm_id=$1)", array($pm_id));
257 $cn->exec_sql(
"update profile_menu set me_code=$1,p_order=$2,pm_default=$3
280 $p_dep=
$http->post(
"dep",
"number",
null);
295 $menu_type=
$cn->get_value(
"select me_type from menu_ref
296 where me_code=$1", array(
$me_code));
298 if ($menu_type==
'PR')
316 $me_code_dep=
$cn->get_value(
'select me_code from profile_menu'
317 .
' where pm_id = $1 and p_id=$2', array($p_dep,
$p_id));
325 $inf=
$cn->get_value(
"select count(*) from profile_menu
326 where p_id=$1 and me_code_dep=$2 and me_code=$3",
329 throw new Exception(_(
"Boucle infinie"));
334 throw new Exception(_(
"Un menu ne peut pas dépendre de lui-même"));
340 $me_code_dep=($me_code_dep==-1)?
null:$me_code_dep;
345 $duplicate =
$cn->get_value(
" select count(*) from profile_menu where "
346 .
" pm_id_dep = $1 and me_code = $2",array($pm_id_dep,
$me_code));
347 if ( $duplicate > 0 ) {
348 throw new Exception(_(
'Doublon'));
352 insert into profile_menu (me_code,me_code_dep,p_id,p_order,pm_default,p_type_display,pm_id_dep)
353 values ($1,$2,$3,$4,$5,$6,$7)
360 catch (Exception $exc)
362 alert($exc->getMessage());
367echo
'<div id="list_profile" class="content">';
371$table->add(_(
'Nom'),
$url,
"order by p_name asc",
"order by p_name desc",
"na",
373$table->add(_(
'Description'),
$url,
"order by p_desc asc",
374 "order by p_desc desc",
"da",
"dd");
375$table->add(_(
'Calculatrice visible'),
$url,
"order by with_calc asc",
376 "order by with_calc desc",
"ca",
"cd");
377$table->add(_(
'Accès Direct visible'),
$url,
"order by with_direct_form asc",
378 "order by with_direct_form desc",
"fa",
"fd");
386echo
'<table class="result">';
388echo
'<th>'.$table->get_header(0).
'</th>';
389echo
'<th>'.$table->get_header(1).
'</th>';
390echo
'<th>'.$table->get_header(2).
'</th>';
391echo
'<th>'.$table->get_header(3).
'</th>';
398 $js=sprintf(
'<a href="javascript:void(0)" style="text-decoration:underline" onclick="get_profile_detail(\'%s\',\'%s\')">',
401 echo
"<td>".$js.$row->p_name.
'</a>'.
'</td>';
404 echo
td(
$row->with_direct_form);
407$js=sprintf(
'<a href="javascript:void(0)" class="button" onclick="get_profile_detail(\'%s\',\'%s\')">',
410echo
"<td>".$js._(
"Ajouter un profil").
" </td>";
420echo
'<div id="detail_profile" class="content">';
423 require_once NOALYSS_INCLUDE.
'/ajax/ajax_get_profile.php';
426 $(
'list_profile').hide()
432if (isset(
$_POST[
'delete_profil']))
437 $(
'list_profile').show()
445 var selected_menu=
"<?php echo $dep;?>";
446 function menu_select(rowid) {
447 $(
'sub'+rowid).addClassName(
"selectedmenu");
448 if ( selected_menu !=
"0" && rowid != selected_menu ) {
449 if ( $(
'sub'+selected_menu) ) {
450 $(
'sub'+selected_menu).removeClassName(
"selectedmenu");
noalyss_strlentrim($p_string)
record_log($p_message)
Record an error message into the log file of the server.
td($p_string='', $p_extra='')
surround the string with td
alert($p_msg, $buffer=false)
alert in javascript
static num_row($ret)
wrapper for the function pg_num_rows
static id()
return the 'gDossier' value after a check
static build($p_id, $profile_id)
Manage the table public.profile.
Description of class_syn_sort_table.
create_script($p_string)
create the HTML for adding the script tags around of the script
if(isset($_POST['delete_profil'])) $dep
for($i=0; $i< Database::num_row($ret); $i++) $js