1 |
fraynaud |
3 |
<?php |
2 |
|
|
/** |
3 |
|
|
* |
4 |
|
|
* |
5 |
|
|
* @package openmairie_exemple |
6 |
|
|
* @version SVN : $Id: sup.php 316 2010-12-06 12:14:36Z fmichon $ |
7 |
|
|
*/ |
8 |
|
|
|
9 |
|
|
require_once "../obj/utils.class.php"; |
10 |
|
|
$f = new utils(NULL, "gen", _("Generateur")." -> "._("Suppression")); |
11 |
|
|
|
12 |
|
|
/** |
13 |
|
|
* Declaration des fonctions d'affichage |
14 |
|
|
*/ |
15 |
|
|
function affichecol($col1, $col2, $col3) { |
16 |
|
|
echo "<tr class=\"tabcolData\">\n"; |
17 |
|
|
echo "\t<td class=\"reqmochecked\">".$col1."</td>\n"; |
18 |
|
|
echo "\t<td class=\"tabDataMouvement\">".$col2."</td>\n"; |
19 |
|
|
echo "\t<td class=\"reqmochecked0\">".$col3."</td>\n"; |
20 |
|
|
echo "</tr>\n"; |
21 |
|
|
} |
22 |
|
|
function affichetitre($titre, $align = "") { |
23 |
|
|
echo "<tr class=\"tabcol\">\n"; |
24 |
|
|
echo "\t<td colspan=\"3\">"; |
25 |
|
|
if ($align != "") { |
26 |
|
|
echo "<".$align.">"; |
27 |
|
|
} |
28 |
|
|
echo $titre; |
29 |
|
|
if ($align != "") { |
30 |
|
|
echo "</".$align.">"; |
31 |
|
|
}; |
32 |
|
|
echo "</td>\n"; |
33 |
|
|
echo "</tr>\n"; |
34 |
|
|
} |
35 |
|
|
function afficheinfo($col1, $col2){ |
36 |
|
|
echo "<tr class=\"tabcolData\">\n"; |
37 |
|
|
echo "\t<td class=\"reqmochecked0\">".$col1."</td>\n"; |
38 |
|
|
echo "\t<td class=\"reqmochecked0\">".$col2."</td>\n"; |
39 |
|
|
echo "</tr>\n"; |
40 |
|
|
} |
41 |
|
|
function automsg($nomfichier){ |
42 |
|
|
$retour = "<br/>"._("Fichier")." \"".$nomfichier."\""; |
43 |
|
|
$retour .= " => "._("Suppression non souhaitee"); |
44 |
|
|
return $retour; |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
/** |
48 |
|
|
* Initialisation des variables |
49 |
|
|
*/ |
50 |
|
|
// |
51 |
|
|
(isset($_GET["table"]) ? $table = $_GET["table"] : $table = ""); |
52 |
|
|
// |
53 |
|
|
$rubriks = array( |
54 |
|
|
"formulaire" => array("tableincgen", "tableinc", "tableformincgen", "tableforminc", "tableobj", "obj"), |
55 |
|
|
"edition" => array("editioninc"), |
56 |
|
|
"reqmo" => array("reqmoinc"), |
57 |
|
|
"divers" => array("importinc"), |
58 |
|
|
); |
59 |
|
|
// |
60 |
|
|
$params = array( |
61 |
|
|
"tableincgen" => array( |
62 |
|
|
"path" => "../gen/sql/".OM_DB_PHPTYPE."/".$table.".inc.php", |
63 |
|
|
"checked" => true, |
64 |
|
|
), |
65 |
|
|
"tableinc" => array( |
66 |
|
|
"path" => "../sql/".OM_DB_PHPTYPE."/".$table.".inc", |
67 |
|
|
"checked" => false, |
68 |
|
|
), |
69 |
|
|
"tableformincgen" => array( |
70 |
|
|
"path" => "../gen/sql/".OM_DB_PHPTYPE."/".$table.".form.inc.php", |
71 |
|
|
"checked" => true, |
72 |
|
|
), |
73 |
|
|
"tableforminc" => array( |
74 |
|
|
"path" => "../sql/".OM_DB_PHPTYPE."/".$table.".form.inc", |
75 |
|
|
"checked" => false, |
76 |
|
|
), |
77 |
|
|
"tableobj" => array( |
78 |
|
|
"path" => "../gen/obj/".$table.".class.php", |
79 |
|
|
"checked" => true, |
80 |
|
|
), |
81 |
|
|
"obj" => array( |
82 |
|
|
"path" => "../obj/".$table.".class.php", |
83 |
|
|
"checked" => false, |
84 |
|
|
), |
85 |
|
|
"editioninc" => array( |
86 |
|
|
"path" => "../sql/".OM_DB_PHPTYPE."/".$table.".pdf.inc", |
87 |
|
|
"checked" => false, |
88 |
|
|
), |
89 |
|
|
"reqmoinc" => array( |
90 |
|
|
"path" => "../sql/".OM_DB_PHPTYPE."/".$table.".reqmo.inc", |
91 |
|
|
"checked" => false, |
92 |
|
|
), |
93 |
|
|
"importinc" => array( |
94 |
|
|
"path" => "../sql/".OM_DB_PHPTYPE."/".$table.".import.inc", |
95 |
|
|
"checked" => false, |
96 |
|
|
), |
97 |
|
|
); |
98 |
|
|
// Variables POST |
99 |
|
|
foreach ($params as $key => $elem) { |
100 |
|
|
if (isset($_POST[$key])) { |
101 |
|
|
${$key} = 1; |
102 |
|
|
} else { |
103 |
|
|
${$key} = 0; |
104 |
|
|
} |
105 |
|
|
} |
106 |
|
|
|
107 |
|
|
/** |
108 |
|
|
* Classe gen |
109 |
|
|
*/ |
110 |
|
|
require_once (PATH_OPENMAIRIE."gen.class.php"); |
111 |
|
|
$g = new gen($table, $f->db, OM_DB_DATABASE, OM_DB_PHPTYPE, "", OM_DB_SCHEMA); |
112 |
|
|
|
113 |
|
|
/** |
114 |
|
|
* Ouverture du conteneur de la page |
115 |
|
|
*/ |
116 |
|
|
// |
117 |
|
|
echo "\n<div id=\"generator-delete\">\n"; |
118 |
|
|
// |
119 |
|
|
echo "<div id=\"formulaire\">\n\n"; |
120 |
|
|
// |
121 |
|
|
echo "<ul>\n"; |
122 |
|
|
echo "\t<li><a href=\"#tabs-1\">".$table."</a></li>\n"; |
123 |
|
|
echo "</ul>\n"; |
124 |
|
|
// |
125 |
|
|
echo "\n<div id=\"tabs-1\">\n"; |
126 |
|
|
|
127 |
|
|
/** |
128 |
|
|
* |
129 |
|
|
*/ |
130 |
|
|
// |
131 |
|
|
$title = _("Analyse de la base de donnees")." ".OM_DB_PHPTYPE." -> "; |
132 |
|
|
$title .= (OM_DB_SCHEMA == "" ?"":OM_DB_SCHEMA.".").OM_DB_DATABASE; |
133 |
|
|
$f->displaySubTitle($title); |
134 |
|
|
// Ouverture de la balise table |
135 |
|
|
echo "<table cellpadding=\"0\" class=\"formEntete ui-corner-all\">\n"; |
136 |
|
|
// tables de la base |
137 |
|
|
$contenu = ""; |
138 |
|
|
if (!empty($g->tablebase)) { |
139 |
|
|
foreach ($g->tablebase as $elem) { |
140 |
|
|
$contenu .= " [ ".$elem. " ] "; |
141 |
|
|
} |
142 |
|
|
$lib = _("Tables de la base de donnees"); |
143 |
|
|
afficheinfo($lib, $contenu); |
144 |
|
|
} |
145 |
|
|
// table |
146 |
|
|
$contenu = ""; |
147 |
|
|
$lib = _("Table :")." <b>".$table."</b>"; |
148 |
|
|
$contenu .= "[ "._('cle')." ".$g->typecle." - "; |
149 |
|
|
if ($g->typecle == 'N') { // XXX - Ce test est-il correct ? |
150 |
|
|
$contenu .= _("cle automatique")." ]"; |
151 |
|
|
} else { |
152 |
|
|
$contenu .= _("cle manuelle")." ]"; |
153 |
|
|
} |
154 |
|
|
$contenu .=" [ "._('longueur')." "._("enregistrement")." : ".$g->longueur." ]"; |
155 |
|
|
afficheinfo($lib, $contenu); |
156 |
|
|
// champs |
157 |
|
|
$contenu = ""; |
158 |
|
|
$lib = _("Champs"); |
159 |
|
|
foreach ($g->info as $elem) { |
160 |
|
|
$contenu .= "[ ".$elem["name"]." ".$elem["len"]." ".$elem["type"]." ] "; |
161 |
|
|
} |
162 |
|
|
afficheinfo($lib, $contenu); |
163 |
|
|
// sous formulaire |
164 |
|
|
$contenu = ""; |
165 |
|
|
if (!empty($g->sousformulaire)) { |
166 |
|
|
foreach ($g->sousformulaire as $elem) { |
167 |
|
|
$contenu .= " [ ".$elem. " ] "; |
168 |
|
|
} |
169 |
|
|
} |
170 |
|
|
$lib= _("Sous formulaire"); |
171 |
|
|
afficheinfo($lib, $contenu); |
172 |
|
|
// cle secondaire |
173 |
|
|
$contenu = ""; |
174 |
|
|
if (!empty($g->clesecondaire)) { |
175 |
|
|
foreach ($g->clesecondaire as $elem) { |
176 |
|
|
$contenu .= " [ ".$elem. " ] "; |
177 |
|
|
// sous etat / cle secondaire |
178 |
|
|
if (isset($_POST['sousetatinc_'.$elem])) { |
179 |
|
|
$sousetatinc[$elem] = 1; |
180 |
|
|
} else { |
181 |
|
|
$sousetatinc[$elem] = 0; |
182 |
|
|
} |
183 |
|
|
// |
184 |
|
|
if (isset($_POST['reqmo_'.$elem])) { |
185 |
|
|
$reqmo[$elem] = 1; |
186 |
|
|
} else { |
187 |
|
|
$reqmo[$elem] = 0; |
188 |
|
|
} |
189 |
|
|
} |
190 |
|
|
} |
191 |
|
|
$lib = _("Cle secondaire"); |
192 |
|
|
afficheinfo($lib, $contenu); |
193 |
|
|
// Fermeture de la balise table |
194 |
|
|
echo "</table>"; |
195 |
|
|
|
196 |
|
|
/** |
197 |
|
|
* Affichage du formulaire de selection des fichiers a supprimer |
198 |
|
|
*/ |
199 |
|
|
// |
200 |
|
|
$title = _("Choix des fichiers a supprimer"); |
201 |
|
|
$f->displaySubTitle($title); |
202 |
|
|
// Traitement si validation du formulaire |
203 |
|
|
if (isset($_POST["valid_gen_supprimer"])) { |
204 |
|
|
// |
205 |
|
|
foreach ($rubriks as $key => $rubrik) { |
206 |
|
|
// |
207 |
|
|
foreach ($rubrik as $param) { |
208 |
|
|
if (${$param} == 1) { |
209 |
|
|
$g->supprimerfichier($params[$param]["path"]); |
210 |
|
|
} else { |
211 |
|
|
$g->msg .= automsg($params[$param]["path"]); |
212 |
|
|
} |
213 |
|
|
} |
214 |
|
|
// |
215 |
|
|
if ($key == "reqmo") { |
216 |
|
|
// sous reqmo |
217 |
|
|
if (!empty($g->clesecondaire)) { |
218 |
|
|
foreach ($g->clesecondaire as $elem) { |
219 |
|
|
$file = "../sql/".OM_DB_PHPTYPE."/".$table."_".$elem.".reqmo.inc"; |
220 |
|
|
if ($reqmo[$elem] == 1) { |
221 |
|
|
$g->supprimerfichier($file); |
222 |
|
|
} else { |
223 |
|
|
$g->msg .= automsg($file); |
224 |
|
|
} |
225 |
|
|
} |
226 |
|
|
} |
227 |
|
|
} |
228 |
|
|
} |
229 |
|
|
// Affichage du message de validation du traitement |
230 |
|
|
$f->displayMessage("valid", $g->msg); |
231 |
|
|
} |
232 |
|
|
// Ouverture de la balise formulaire |
233 |
|
|
echo "<form method=\"post\" action=\"sup.php?table=".$table."\" name=\"f1\">\n"; |
234 |
|
|
// Ouverture de la balise table |
235 |
|
|
echo "<table cellpadding=\"0\" class=\"formEntete ui-corner-all\">\n"; |
236 |
|
|
// |
237 |
|
|
foreach ($rubriks as $key => $rubrik) { |
238 |
|
|
// |
239 |
|
|
affichetitre("<b>"._($key)."</b>"); |
240 |
|
|
// |
241 |
|
|
foreach ($rubrik as $param) { |
242 |
|
|
if (file_exists($params[$param]["path"])) { |
243 |
|
|
// |
244 |
|
|
$lib = array_pop(explode("/", $params[$param]["path"])); |
245 |
|
|
// |
246 |
|
|
$box = "<input type=\"checkbox\" name=\"".$param."\""; |
247 |
|
|
$box .= ($params[$param]["checked"] ? " checked=\"checked\"":""); |
248 |
|
|
$box .= " class=\"champFormulaire\" />"; |
249 |
|
|
// |
250 |
|
|
$msg = "<a href=\"javascript:aff('".$params[$param]["path"]."')\">"; |
251 |
|
|
$msg .= $params[$param]["path"]; |
252 |
|
|
$msg .= "</a>"; |
253 |
|
|
// |
254 |
|
|
affichecol($box, $lib, $msg); |
255 |
|
|
} |
256 |
|
|
} |
257 |
|
|
// |
258 |
|
|
if ($key == "reqmo") { |
259 |
|
|
// sous reqmo |
260 |
|
|
if (!empty($g->clesecondaire)) { |
261 |
|
|
foreach ($g->clesecondaire as $elem) { |
262 |
|
|
$file = "../sql/".OM_DB_PHPTYPE."/".$table."_".$elem.".reqmo.inc"; |
263 |
|
|
// |
264 |
|
|
if (file_exists($file)) { |
265 |
|
|
// |
266 |
|
|
$lib = array_pop(explode("/", $file)); |
267 |
|
|
// |
268 |
|
|
$box = "<input type=\"checkbox\" name=\"reqmo_".$elem."\""; |
269 |
|
|
$box .= " class=\"champFormulaire\" />"; |
270 |
|
|
// |
271 |
|
|
$msg = "<a href=\"javascript:aff('".$file."')\">"; |
272 |
|
|
$msg .= $file; |
273 |
|
|
$msg .= "</a>"; |
274 |
|
|
// |
275 |
|
|
affichecol($box,$lib,$msg); |
276 |
|
|
} |
277 |
|
|
} |
278 |
|
|
} |
279 |
|
|
} |
280 |
|
|
} |
281 |
|
|
// Fermeture de la balise table |
282 |
|
|
echo "</table>\n"; |
283 |
|
|
// Affichage des actions de controles du formulaire |
284 |
|
|
echo "<div class=\"formControls\">"; |
285 |
|
|
// Bouton de validation du formulaire |
286 |
|
|
echo "<input type=\"submit\" name=\"valid.gen.supprimer\" value=\""._("Supprimer les fichiers de la table :")." '".$table."'\" />"; |
287 |
|
|
// Lien retour |
288 |
|
|
echo "<a href=\"gen.php\" class=\"retour\">"; |
289 |
|
|
echo _("Retour"); |
290 |
|
|
echo "</a>"; |
291 |
|
|
// Fermeture du conteneur des actions de controles du formulaire |
292 |
|
|
echo "</div>"; |
293 |
|
|
// Fermeture de la balise formulaire |
294 |
|
|
echo "\n</form>\n"; |
295 |
|
|
|
296 |
|
|
/** |
297 |
|
|
* Fermeture du conteneur de la page |
298 |
|
|
*/ |
299 |
|
|
// |
300 |
|
|
echo "</div>\n"; |
301 |
|
|
// |
302 |
|
|
echo "</div>\n"; |
303 |
|
|
// |
304 |
|
|
echo "</div>\n"; |
305 |
|
|
|
306 |
|
|
?> |