-
Notifications
You must be signed in to change notification settings - Fork 1
/
edit_intervention_ajout.php
164 lines (145 loc) · 5.88 KB
/
edit_intervention_ajout.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<? include "verification.php" ?>
<?php
//if ($_POST['Submit'] == "OK")
if (isset($_POST['Submit']) || isset($_POST['Submit_x']))
{
if ($_POST['fnbcontrev'] == "") //Si le champ 'nombre de contrevenants' est vide alors j'insere la valeur null
{ $nbcontrev = 'null'; }
else { $nbcontrev = $_POST[fnbcontrev] ;
}
//correction des magic_quotes_gpc (protection des chaînes de caractères)
$observation = pg_escape_string($_POST[fobs]);
$query= "INSERT INTO interventions.t_interventions (date, type_intervention_id, commune_id, secteur_id, coord_x, coord_y, statutzone_id, observation, nbcontrevenants, the_geom_3857)
VALUES(to_date('$_POST[fdate]','dd/mm/yyyy'),'$_POST[fintervention]','$_POST[fcomm]', '$_POST[fsect]','$_POST[fx]','$_POST[fy]','$_POST[fstatut]','$observation', $nbcontrev, ST_Transform(ST_SetSrid(ST_MakePoint('$_POST[fx]', '$_POST[fy]'),4326), 3857))";
pg_query($query) or die( "Erreur requete" );
$queryid = "SELECT id_intervention from interventions.t_interventions
ORDER BY id_intervention DESC
LIMIT 1";
$result = pg_query($queryid) or die ('Échec requête : ' . pg_last_error()) ;
$val = pg_fetch_assoc($result);
$newid = $val['id_intervention'];
pg_close($dbconn);
header("Location: edit_intervention_infraction_ajout.php?id=$newid");
}
else {
}
?>
<? include "header_front.php" ?>
<!-- Librairie Jquery utilisée par Datepicker -->
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<!-- Datepicker pour afficher un joli calendrier dans les champs dates -->
<link type="text/css" href="js/datepicker/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/datepicker/ui/i18n/ui.datepicker-fr.js"></script>
<script type="text/javascript" src="js/datepicker/ui/ui.datepicker.js"></script>
<script type="text/javascript">
$(function() {
jQuery.datepicker.setDefaults(jQuery.datepicker.regional['fr']);
$("#datepicker").datepicker({maxDate: '+0D'});
});
</script>
<!-- Javascript permettant de vérifier que les champs obligatoires sont bien remplis -->
<script type="text/javascript" src="js/forms_verifications.js"></script>
<!-- Chargement des fichiers javascripts de l'outil carto (OpenLayers) -->
<script type="text/javascript" src="js/application.ol.js"></script>
<script type="text/javascript" src="conf/conf_carto.js"></script>
<script type="text/javascript" src="js/openlayers/OpenLayers.js"></script>
<script type="text/javascript" src="http://api.ign.fr/geoportail/api/js/2.0.0/GeoportalMin.js"></script>
<title>Police du <? echo $etablissement_abv; ?> - Ajouter une intervention</title>
</head>
<body onload="create_ol.init(<?=$ol_x_center;?>,<?=$ol_y_center;?>,9,'<?=$wms_url;?>','<?=$wms_proj;?>','<?=$min_x;?>','<?=$min_y;?>','<?=$max_x;?>','<?=$max_y;?>',false)">
<? include "menu_general.php" ?>
<div id="news">
<h1>
<img src="images/icones/ajouter.gif" alt="Ajouter une intervention" title="Ajouter une intervention" border="0" align="absmiddle">
Ajouter une intervention
</h1>
</div>
<? $ajd = date("d/m/Y"); ?>
<form action="edit_intervention_ajout.php" method="post" name="intervention" onsubmit="return VerifFormIntervention();">
<div id="liste">
<p>
<b>ETAPE 1 - RENSEIGNEMENTS GENERAUX</b> | Etape 2 - Infractions | Etape 3 - Agents
</p>
<hr color="#dcdcdc" >
<div class="blocos">
<table width="100%" border="0" cellspacing="5px" cellpadding="5px" align="center">
<tr>
<td>
Date de l'infraction
</td>
<td>
<input type="text" id="datepicker" name="fdate" value="<? echo $ajd; ?>">
</td>
</tr>
<tr>
<td>Type d'intervention</td>
<td>
<select name="fintervention" >
<option value="">...</option>
<?
//Declarer et executer une requete permettant de lister les enregistrements d'une table secondaire liée pour renseigner la liste déroulante
$sql_infr = "SELECT id_type_intervention, type_intervention
FROM interventions.bib_types_interventions
ORDER BY type_intervention";
$result = pg_query($sql_infr) or die ("Erreur requête") ;
while ($val = pg_fetch_assoc($result)){
?>
<!-- Stocker l'id correspondant à la valeur selectionnée. -->
<option value="<?=$val['id_type_intervention'];?>"><?=$val['type_intervention']?></option>
<? } ?>
</select>
</td>
</tr>
</table>
</div>
<div class="blocos">
<table width="100%" border="0" cellspacing="5px" cellpadding="5px" align="center">
<tr>
<td>
Localisation :<br/>
<? include "carto/localisation-ajout.php" ?>
</td>
</tr>
</table>
</div>
<div class="blocos">
<table width="100%" border="0" cellspacing="5px" cellpadding="5px" align="center">
<tr>
<td>Nombre de contrevenants</td>
<td><input type="text" name="fnbcontrev"></td>
</tr>
<tr>
<td>Observations</td>
<td><textarea name="fobs" cols="50" rows="5"></textarea></td>
</tr>
</table>
</div>
<table width="100%" border="0" cellspacing="5px" cellpadding="5px" align="center">
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing = "0" cellpadding="2" align="center">
<tr>
<td>
<a href="interventions_liste.php"><img src="images/icones/retour.gif" alt="Annuler" title="Annuler" border="0" align="absmiddle"> Annuler</a>
</td>
<td align="right">Enregistrer
<input name="Submit" id="Submit" value="OK" type="image" src = "images/icones/suivant.gif" alt="Enregistrer" title="Enregistrer" border="0" align="absmiddle">
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
<?
pg_close($dbconn);
?>
<!-- Fermer le div contenu -->
</div>
<div id="bottom"></div>
<!-- Fermer le div conteneur -->
</div>
<? include "menu_pied.php" ?>
</body>
</html>