DEL Old file.
[appart.git] / index.php
1 <?php
2 header('Content-Type: text/html; charset=UTF-8');
3 echo '<?xml version="1.0" encoding="UTF-8" ?>';
4
5 require ('constantes.php');
6
7 $dbconn = pg_connect("host=localhost port=5432 dbname=".$BD." user=appart password=soleil") or die('Connexion impossible : ' . pg_last_error());
8 pg_query("SET datestyle = 'SQL, DMY';");
9
10 $inputs;
11 $erreur;
12 $action;
13 require ('traitement_inputs.php');
14
15 ?>
16
17 <html>
18 <head>
19 <title>Appart</title>
20 <link rel="stylesheet" href="style.css" type="text/css" />
21 <script type="text/javascript" src="script.js" ></script>
22 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
23 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
24 <title>Google Maps JavaScript API Example</title>
25 <script src="http://maps.google.com/maps?file=api&amp;v=2.82&amp;key=ABQIAAAAQLBohykzX4xiepOOUu21GhS2JkdUHwPLqAOasxCB2_i_UFsNUhRbVpRM0k1S9wDSYhOD8Hj8bGnqag" type="text/javascript"></script>
26 </head>
27 <body onload="rafraichirFormulaire(); loadGMap()" onunload="GUnload()">
28 <?php
29 if (isset($erreur) && $erreur != '')
30 {
31 echo '<div id="erreur" >' . utf8_encode($erreur) . '</div>';
32 }
33 ?>
34
35 <div id="menus">
36 <div class="menu" id="appartements" >
37 <h1><a href="?">Appartements</a></h1>
38 <a href="index.php">detail</a> <a href="list.php">liste</a>
39
40 <form method="post" >
41 <input type="hidden" name="action" value="ajouter" />
42 <input type="submit" value="Nouveau" />
43 </form>
44 <?php
45 foreach ($statuts as $statut_num => $statut_nom)
46 {
47 echo "<h2>$statut_nom</h2>";
48
49 $result = pg_query("SELECT id, rue, date_visite FROM appart WHERE statut = $statut_num ORDER by statut, " . ($statut_num == '1'? 'date_visite' : 'id'));
50 while ($line = pg_fetch_array($result, null, PGSQL_ASSOC))
51 {
52 echo '<a '.($id == $line['id'] ? 'class="courant"' : '').' href="?action=voir&id='.$line['id'].'">' . $line['id'] . '. ' . $line['rue'] .
53 ($statut_num == '1' ? '<p>' .$line['date_visite'] . '</p>' : '' ).
54 '</a>';
55 }
56 pg_free_result($result);
57 }
58 ?>
59 </div>
60
61 <div class="menu">
62 <h1>Liens</h1>
63 <?php
64 foreach ($sites as $nom_site => $url)
65 {
66 echo '<a href="'.$url.'" >'.$nom_site.'</a>';
67 }
68 ?>
69 </div>
70 </div>
71
72 <div id="appartement" >
73 <?php
74 $appartData;
75 if ($action == "ajouter")
76 {
77 foreach($champs as $champ => $type)
78 $appartData[$champ] = $inputs[$champ];
79 }
80 else
81 {
82 $result = pg_query("SELECT * FROM appart WHERE id = $id");
83 $appartData = pg_fetch_array($result, null, PGSQL_ASSOC);
84 }
85 ?>
86 <form method="post" action="index.php?id=<?= $id ?>" >
87 <input id="modeFormulaire" type="hidden" name="mode" value="<?= $action == 'ajouter' ? 'enEdition' : 'enConsultation' ?>" />
88 <h1>Appartement N°<?= $id ?></h1>
89 <button type="button" id="boutonEditer" onclick="editer();" >éditer</button>
90 <div id="boutonsEdition" style="display:none">
91 <input type="submit" name="action" value="Supprimer" onclick="return supprimer('<?= $appartData['id'] ?>', '<?= $appartData['rue'] ?>')" />
92 <input type="submit" name="action" value="Annuler" />
93 <input type="submit" name="action" value="Mémoriser" />
94 </div>
95 <table id="tableauFormulaire">
96 <tr><th class="header1Label"></th><th class="headerInput"></th><th class="header2Label"></th><th class="headerInput"></th></tr>
97 <tr>
98 <td >
99 Statut
100 </td>
101 <td>
102 <select id="editionStatut" size="1" name="statut" style="display: none">
103 <?php
104 foreach ($statuts as $num => $statut)
105 echo '<option '. ($appartData['statut'] == $num ? 'selected' : '') . ' value="' . $num .'">' . $statuts[$num] . '</option>';
106 ?>
107 </select>
108 <p id="consultationStatut" style="display: none"><?= $statuts[$appartData['statut']] ?></p>
109 </td>
110 <td >Lien internet</td>
111 <td><input id="urlEdition" style="display:none" type="text" name="url" value="<?= $appartData['url'] ?>" /><a style="display:none" id="urlConsultation" href="<?= $appartData['url'] ?>">GO!</a></td>
112 </tr>
113 <tr>
114 <td >Prix + charges</td>
115 <td><input type="text" class="short" name="prix" value="<?= $appartData['prix'] ?>" /> + <input type="text" class="short" name="prixcharges" value="<?= $appartData['prixcharges'] ?>" /> = <bold><?= $appartData['prix'] + $appartData['prixcharges'] ?></bold></td>
116 <td rowspan="3" >Contact</td>
117 <td rowspan="3"><textarea name="contact" rows="4"><?= $appartData['contact'] ?></textarea></td>
118 </tr>
119 <tr>
120 <td >Libre à partir du <span class="exemple" >(ex: "1/08/2007")</span></td>
121 <td><input type="text" name="date_libre" value="<?= $appartData['date_libre'] ?>" /></td>
122 </tr>
123 <tr>
124 <td >Rue</td>
125 <td><input id="inputRue" type="text" name="rue" value="<?= $appartData['rue'] ?>" /></td>
126 </tr>
127 <tr>
128 <td >Localité</td>
129 <td><input id="inputLocalite" type="text" name="localite" value="<?= $appartData['localite'] ?>" /></td>
130 <td rowspan="5" >Description</td>
131 <td rowspan="5"><textarea rows="8" name="description"><?= $appartData['description'] ?></textarea></td>
132 </tr>
133 <tr>
134 <td >Nombre de pièce</td>
135 <td><input type="text" name="nbpiece" value="<?= $appartData['nbpiece'] ?>" /></td>
136 </tr>
137 <tr>
138 <td >Surface</td>
139 <td><input type="text" name="surface" value="<?= $appartData['surface'] ?>" /></td>
140 </tr>
141 <tr>
142 <td >Étage</td>
143 <td><input type="text" name="etage" value="<?= $appartData['etage'] ?>" /></td>
144 </tr>
145 <tr>
146 <td >Dernière rénovation (année)</td>
147 <td><input type="text" name="annee_construction" value="<?= $appartData['annee_construction'] ?>" /></td>
148 </tr>
149 <tr>
150 <td colspan="2" >Points Positifs</td>
151 <td colspan="2" >Points négatifs</td>
152 </tr>
153 <tr>
154 <td colspan="2"><textarea rows="5" name="points_positifs"><?= $appartData['points_positifs'] ?></textarea></td>
155 <td colspan="2"><textarea rows="5" name="points_negatifs"><?= $appartData['points_negatifs'] ?></textarea></td>
156 </tr>
157 <tr>
158 <td colspan="4">
159 <h2>Visite</h2>
160 </td>
161 </tr>
162 <tr>
163 <td >Date et heure de la visite <span class="exemple" >(ex: "23/07/2007 14:23")</span></td>
164 <td colspan="3"><input type="text" name="date_visite" value="<?= $appartData['date_visite'] ?>" /></td>
165 </tr>
166 <tr>
167 <td >Indications</td>
168 <td colspan="3"><textarea rows="3" name="visite_indications"><?= $appartData['visite_indications'] ?></textarea></td>
169 </tr>
170 <tr>
171 <td colspan="4">
172 <h2>Map</h2>
173 </td>
174 </tr>
175 <!-- tr>
176 <td>
177 Url google map
178 </td>
179 <td colspan="3"><input id="urlmapEdition" style="display:none" type="text" name="url_map" value="<?= $appartData['url_map'] ?>" /><a style="display:none" id="urlmapConsultation" href="<?= $appartData['url_map'] ?>">GO!</a></td>
180 </tr -->
181 <tr>
182 <td colspan="4" >
183 <div id="map"></div>
184 <div id="map2"></div>
185 </td>
186 </tr>
187 </table>
188 </form>
189 <?php
190 pg_free_result($result);
191 ?>
192 </div>
193
194 </body>
195 </html>
196
197 <?php
198 pg_close($dbconn);
199 ?>