noalyss Version-9
cfgfiche.inc.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/*! \file
21 * \brief module to manage the card (removing, listing, creating, modify attribut)
22 */
23if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
24require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
25require_once NOALYSS_INCLUDE.'/lib/user_menu.php';
26global $http;
27
28$retour=HtmlInput::button_anchor("Retour à la liste", HtmlInput::get_to_string(array("gDossier","ac")));
29$action=$http->post('action',"string", '');
30/*******************************************************************************************/
31// Add an attribut
32/*******************************************************************************************/
33if ( $action == 'add_line')
34{
35 $fd_id=$http->request("fd_id","number");
36 $ad_id=$http->request("ad_id","number");
38 $fiche_def->InsertAttribut($ad_id);
39 echo $fiche_def->input_detail();
40 echo $retour;
41 return;
42}
43/*******************************************************************************************/
44// Remove an attribut
45/*******************************************************************************************/
46if ( $action == 'remove_line' )
47{
48 $fd_id=$http->request("fd_id","number");
50 try
51 {
52 $ck_remove=$http->request('chk_remove');
53 $fiche_def->RemoveAttribut($ck_remove);
54 }
55 catch (Exception $exc)
56 {
57 throw new Exception(_("Vous devez choisir au moins une ligne"));
58 }
59 finally
60 {
61 echo $fiche_def->input_detail();
62 echo $retour;
63 return;
64 }
65
66}
67/*******************************************************************************************/
68// Try to remove a category
69/*******************************************************************************************/
70if ( $action == 'remove_cat' )
71{
72 $post_id=$http->request("fd_id","number");
73 if ($post_id == 0 || $post_id >= 500000)
74 {
75 alert(_('Impossible d\'enlever cette catégorie'));
76 } else {
77 $fd_id=new Fiche_Def($cn,$post_id);
78 $remains=$fd_id->remove();
79 if ( $remains != 0 ) {
80 /* some card are not removed because it is used */
81 alert(_('Impossible d\'enlever cette catégorie, certaines fiches sont encore utilisées'."\n".
82 'Les fiches non utilisées ont cependant été effacées'));
83 }
84 }
85}
86/*******************************************************************************************/
87// Change some basis info
88/*******************************************************************************************/
89if ( isset ($_POST['change_name']))
90{
91 if (isset ($_REQUEST['label']) )
92 {
93 $fiche_def=new Fiche_Def($cn,$_REQUEST['fd_id']);
94 $label=$http->request("label");
95 $fiche_def->SaveLabel($label);
96 if ( isset($_REQUEST['create']))
97 {
98 $fiche_def->set_autocreate(true);
99 }
100 else
101 {
102 $fiche_def->set_autocreate(false);
103 }
104 $fiche_def->save_class_base($http->request('class_base'));
105 $fiche_def->save_description($http->request('fd_description'));
106
107 }
108 echo $fiche_def->input_detail();
109 echo $retour;
110 return;
111}
112/*******************************************************************************************/
113// Save order of the attributes
114/*******************************************************************************************/
115if ( $action == 'save_line' )
116{
117 $fd_id=$http->request("fd_id","number");
119 $fiche_def->save_order($_POST);
120 echo $fiche_def->input_detail();
121 echo $retour;
122 return;
123}
124/*******************************************************************************************/
125// Save a new category of card
126/*******************************************************************************************/
127if ( isset($_POST['add_modele']))
128{
129 $single=new Single_Record("dup");
130 if ($single->get_count()==0)
131 {
132 $single->save();
134 /**
135 * Check if we have all needed information
136 */
137 if ( $fiche_def->Add($_POST) == 0 )
138 {
139 echo $fiche_def->input_detail();
140 echo $retour;
141 return;
142 }
143 else
144 {
145 $fiche_def->input_new();
146 echo $retour;
147 return;
148 }
149 }
150 else
151 {
152 alert(_('Doublon'));
153 }
154}
155$fiche_def=new Fiche_def($cn);
156
157$fiche_def->display();
159?>
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
$_REQUEST['ac']
global $http
$retour
$action
$dossier
if($action=='add_line') if( $action=='remove_line') if($action=='remove_cat') if(isset($_POST['change_name'])) if($action=='save_line') if(isset($_POST['add_modele'])) $fiche_def
static id()
return the 'gDossier' value after a check
define Class fiche and fiche def, those class are using class attribut
static get_to_string($array, $start="?")
transform $_GET data to string
static button_anchor($p_label, $p_value, $p_name="", $p_javascript="", $p_class="smallbutton")
create a button with a ref
Objec to check a double insert into the database, this duplicate occurs after a refresh of the web pa...
$_POST['ac']
Definition: do.php:310
$fd_id
Definition: fiche.inc.php:104