--- /dev/null
+SET client_encoding = 'UTF-8';\r
+SET check_function_bodies = false;\r
+SET client_min_messages = warning;\r
+SET escape_string_warning = off;\r
+\r
+\r
+SET search_path = public, pg_catalog;\r
+\r
+\r
+CREATE SEQUENCE appart_id_seq\r
+ INCREMENT BY 1\r
+ NO MAXVALUE\r
+ NO MINVALUE\r
+ CACHE 1;\r
+\r
+ALTER TABLE public.appart_id_seq OWNER TO appart;\r
+\r
+\r
+SET default_tablespace = '';\r
+\r
+SET default_with_oids = false;\r
+\r
+\r
+/** Version 1 **/\r
+\r
+\r
+CREATE TABLE appart (\r
+ id integer DEFAULT nextval('appart_id_seq'::regclass) NOT NULL,\r
+ prix numeric(28,0),\r
+ prixcharges numeric(10,0),\r
+ rue text DEFAULT ''::text NOT NULL,\r
+ nbpiece character varying(28),\r
+ surface numeric(28,0),\r
+ description text DEFAULT ''::text NOT NULL,\r
+ contact text DEFAULT ''::text NOT NULL,\r
+ url character varying(200) DEFAULT ''::character varying NOT NULL,\r
+ etage numeric(5,0),\r
+ annee_construction numeric(28,0),\r
+ points_positifs text DEFAULT ''::text NOT NULL,\r
+ points_negatifs text DEFAULT ''::text NOT NULL,\r
+ date_visite date,\r
+ visite_indications text DEFAULT ''::text NOT NULL,\r
+ statut smallint DEFAULT 0 NOT NULL,\r
+ localite character varying(100) DEFAULT ''::character varying\r
+);\r
+\r
+\r
+ALTER TABLE public.appart OWNER TO appart;\r
+\r
+COMMENT ON COLUMN appart.statut IS 'statut : 0 = pas visité 1 = on a rendez-vous, 2 = visité, 3 = déjà pris :(';\r
+\r
+ALTER TABLE ONLY appart ADD CONSTRAINT appart_pkey PRIMARY KEY (id);\r
+\r
+REVOKE ALL ON SCHEMA public FROM PUBLIC;\r
+REVOKE ALL ON SCHEMA public FROM postgres;\r
+GRANT ALL ON SCHEMA public TO postgres;\r
+GRANT ALL ON SCHEMA public TO PUBLIC;\r
+\r
+REVOKE ALL ON TABLE appart FROM PUBLIC;\r
+REVOKE ALL ON TABLE appart FROM appart;\r
+GRANT ALL ON TABLE appart TO appart;\r
+GRANT ALL ON TABLE appart TO appart_group;\r
+\r
+REVOKE ALL ON TABLE site FROM PUBLIC;\r
+REVOKE ALL ON TABLE site FROM appart;\r
+GRANT ALL ON TABLE site TO appart;\r
+GRANT ALL ON TABLE site TO appart_group;\r
+\r
+\r
+/** Version 2 **/\r
+\r
+ALTER TABLE public.appart ALTER date_visite TYPE timestamp without time zone;\r
+ALTER TABLE public.appart ADD COLUMN date_libre date;\r
+\r
+ALTER TABLE public.appart ADD COLUMN url_map text;\r
+ALTER TABLE public.appart ALTER COLUMN url_map SET DEFAULT '';\r
+\r
--- /dev/null
+--
+-- PostgreSQL database dump
+--
+
+-- Started on 2009-05-18 22:01:44 CEST
+
+SET client_encoding = 'UTF8';
+SET standard_conforming_strings = off;
+SET check_function_bodies = false;
+SET client_min_messages = warning;
+SET escape_string_warning = off;
+
+--
+-- TOC entry 1750 (class 1262 OID 16394)
+-- Name: appart; Type: DATABASE; Schema: -; Owner: -
+--
+
+CREATE DATABASE appart WITH TEMPLATE = template0 ENCODING = 'UTF8';
+
+
+\connect appart
+
+SET client_encoding = 'UTF8';
+SET standard_conforming_strings = off;
+SET check_function_bodies = false;
+SET client_min_messages = warning;
+SET escape_string_warning = off;
+
+--
+-- TOC entry 294 (class 2612 OID 16506)
+-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -
+--
+
+CREATE PROCEDURAL LANGUAGE plpgsql;
+
+
+SET search_path = public, pg_catalog;
+
+--
+-- TOC entry 1466 (class 1259 OID 16507)
+-- Dependencies: 3
+-- Name: appart_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE appart_id_seq
+ INCREMENT BY 1
+ NO MAXVALUE
+ NO MINVALUE
+ CACHE 1;
+
+
+SET default_tablespace = '';
+
+SET default_with_oids = false;
+
+--
+-- TOC entry 1467 (class 1259 OID 16509)
+-- Dependencies: 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 3
+-- Name: appart; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE appart (
+ id integer DEFAULT nextval('appart_id_seq'::regclass) NOT NULL,
+ prix numeric(28,0),
+ prixcharges numeric(10,0),
+ rue text DEFAULT ''::text NOT NULL,
+ nbpiece character varying(28),
+ surface numeric(28,0),
+ description text DEFAULT ''::text NOT NULL,
+ contact text DEFAULT ''::text NOT NULL,
+ url character varying(200) DEFAULT ''::character varying NOT NULL,
+ etage numeric(5,0),
+ annee_construction numeric(28,0),
+ points_positifs text DEFAULT ''::text NOT NULL,
+ points_negatifs text DEFAULT ''::text NOT NULL,
+ visite_indications text DEFAULT ''::text NOT NULL,
+ statut smallint DEFAULT 0 NOT NULL,
+ localite character varying(100) DEFAULT ''::character varying,
+ date_visite timestamp without time zone,
+ date_libre date,
+ url_map text DEFAULT ''::text
+);
+
+
+--
+-- TOC entry 1753 (class 0 OID 0)
+-- Dependencies: 1467
+-- Name: COLUMN appart.statut; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN appart.statut IS 'statut : 0 = pas visité, 1 = visité, 2 = déjà pris, 3 = rdv pris';
+
+
+--
+-- TOC entry 1468 (class 1259 OID 16526)
+-- Dependencies: 3
+-- Name: site_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE site_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MAXVALUE
+ NO MINVALUE
+ CACHE 1;
+
+
+--
+-- TOC entry 1747 (class 2606 OID 16536)
+-- Dependencies: 1467 1467
+-- Name: appart_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY appart
+ ADD CONSTRAINT appart_pkey PRIMARY KEY (id);
+
+
+--
+-- TOC entry 1752 (class 0 OID 0)
+-- Dependencies: 3
+-- Name: public; Type: ACL; Schema: -; Owner: -
+--
+
+REVOKE ALL ON SCHEMA public FROM PUBLIC;
+REVOKE ALL ON SCHEMA public FROM postgres;
+GRANT ALL ON SCHEMA public TO postgres;
+GRANT ALL ON SCHEMA public TO PUBLIC;
+
+
+--
+-- TOC entry 1754 (class 0 OID 0)
+-- Dependencies: 1467
+-- Name: appart; Type: ACL; Schema: public; Owner: -
+--
+
+REVOKE ALL ON TABLE appart FROM PUBLIC;
+REVOKE ALL ON TABLE appart FROM appart;
+GRANT ALL ON TABLE appart TO appart;
+GRANT ALL ON TABLE appart TO appart_group;
+
+
+-- Completed on 2009-05-18 22:01:46 CEST
+
+--
+-- PostgreSQL database dump complete
+--
+
--- /dev/null
+<?php\r
+$sites = array(\r
+ 'etudiant.ch' => 'http://www.etudiant.ch/etudiant.sa.annonces.surf.ModuleLogement?categorie=5&nPage=1&entete=les%20offres%20de%20logements&affich=0&type=0',\r
+ 'students.ch' => 'http://www.students.ch/wohnungen/page_wohnungen.php?suchen=1&art=wo&plz=2000',\r
+ 'homegate.ch' => 'http://www.homegate.ch/homegate/objectlist;HGSESSIONID=BnS5Gf8TMmx3ZQDMr7LVB0jN0fLvJMkyphlyXJyQ1hGLJhyWd2wd!1228891005?MY_BUTTON=SEARCH&CURRENT_PAGE=1&SORT_ORDER=&z_von=2&z_bis=3.5&p_von=unlim.&p_bis=1300&s_type=egal&s_location=Neuch%C3%A2tel&m2_von=&m2_bis=&v_ab=egal',\r
+'anibis.ch' => 'http://www.anibis.ch/search.do?rt=1&re=1&of=2&ot=13&cf=500&ct=1500&sf=&st=&ci=2000&v=m&c=150113&as=1&v=m',\r
+'petites-annonces.ch' => 'http://www.petites-annonces.ch/recherche/?query=&tid=270113',\r
+'immostreet.ch' => 'http://neuch.immostreet.ch/asp/base.asp?LAN_CODE=FRE&ETAT=100400&STA_NUM=2&GDTYPE=1&RESE_ECHELLE=450&RESE_NUM=454&TYOBSE_NUM=2&OBJ_PRIX_MAX=2000&PCE_NUM=2&SKIN=is',\r
+'fidimmobil.ch centre' => 'http://www.sai-informatique.ch/cgi-bin-sai/REGCR.exe?LANGUE=FR&typobj=AP%3BCH%3BMA%3BVI%3BST&nbpiec=Indiff%E9rent&coregi=CVN&domimm=2000+Neuch%E2tel&loymin=0000&loymax=1200&datinj=--&datinm=----&datina=-----&Submit=Rechercher',\r
+'fidimmobil.ch haut' => 'http://www.sai-informatique.ch/cgi-bin-sai/REGCR.exe?LANGUE=FR&typobj=AP%3BCH%3BMA%3BVI%3BST&nbpiec=Indiff%E9rent&coregi=HVN&domimm=2000+Neuch%E2tel&loymin=0000&loymax=1200&datinj=--&datinm=----&datina=-----&Submit=Rechercher',\r
+'wincasa.ch' => 'http://www.homegate.ch/homegate/objectlist?description=Neuch%C3%A2tel&x=47&y=9&description=®iontype=PLACE&placelist_regiontype=NE',\r
+'littoral-gerance.ch' => 'http://www.littoral-gerance.ch/alouer.php',\r
+'pilote.ch' => 'http://www.pilote.ch/pilote/search/estate/search.htm?classMethod=doNewSearch&wasRedirected=true&searchParams=eNqFkV9rwjAUxb9KybtpKjonpBWcGxMmg83B3sY1vWhcmpQkVbtPv9R/6xDxKUnv/Z1zey4f7QoVbdA6aXRKEspIhFqYXOplSj7mT517Msr4GjbQ7upT9pUkJBIKnEtJU6YLBO3o5+xlgoFHS7KIm8UahT+1CVNQDYUUjpbVQklhtA5lulWCbnFBi4Ap6hCsWNFH58Hj+/4xA/c9DvIk4xsj86i0pkTr65SARTj0zOsSG0vnbZg9+5Elj493HjfUBStMpb2tp3kLe3i+RVnUfm48qBnsLn9xn0QBfkXHchmCkAWoMPVRMukxdtaPeHxgrzk5VKGK+atWUuOksuBD/I2n1D7r8bg5brBvuAzMNHcNBtZCfZo0wCRSqJd+FTZ6SlbqHHcpYSeXTvLPJsy8F7lmW5V5WFr+LrXASbhdCajyUtFDnSvTBJMM2aA/uGMs6Q55vP92M5+w4tbmuqyV7d+4Z4nGOPsFZX4DqQ==',\r
+'romandie.com' => 'http://annonces.romandie.com/search.html?q=&rub=4&cat=60&ccp=2&ccr=37&l=Neuch%E2tel&amm=0&cyl=0&bat=0&kmin=min&kmax=max&act=Rechercher&p=search&tri=date_parution&odr=1',\r
+'ne.ch' => 'http://www.ne.ch/neat/site/jsp/rubrique/rubrique.jsp?StyleType=marron&DocId=10432',\r
+'jouval.ch' => 'http://www.jouval.ch/01-1-location.html#Anchor-47857',\r
+'naef.ch' => 'http://www.naef.ch/index.php?mode=location&26510102=0-2000&26510105=NE&&26510101=26250',\r
+'optiGestionSA.ch' => 'http://www.optigestionsa.ch/liste_loca_objet_appart_villa.php',\r
+\r
+);\r
+\r
+$champs = array(\r
+ 'id' => 'serial',\r
+ 'prix' => 'int',\r
+ 'prixcharges' => 'int',\r
+ 'rue' => 'text',\r
+ 'localite' => 'text',\r
+ 'nbpiece' => 'text',\r
+ 'surface' => 'int',\r
+ 'description' => 'text',\r
+ 'contact' => 'text',\r
+ 'url' => 'text',\r
+ 'etage' => 'int',\r
+ 'annee_construction' => 'int',\r
+ 'points_positifs' => 'text',\r
+ 'points_negatifs' => 'text',\r
+ 'date_visite' => 'date',\r
+ 'visite_indications' => 'text',\r
+ 'statut' => 'int',\r
+ 'date_libre' => 'date',\r
+ 'points_positifs' => 'text',\r
+ 'points_negatifs' => 'text',\r
+ 'date_visite' => 'timestamp',\r
+ 'visite_indications' => 'text',\r
+ 'url_map' => 'text'\r
+ );\r
+\r
+$BD = 'appartement_olivier';\r
+$statuts = array('-1' => 'Gagné ! :-)', '5' => 'Inscrit', '0' => 'Pas visité', '1' => 'Rendez-vous', '2' => 'Visité', '3' => 'Déjà pris', '4' => 'Abandonné');\r
+\r
+ \r
+?>\r
--- /dev/null
+<?php\r
+/* Qq fonctions de debuggage\r
+* */\r
+\r
+// Affichage d'un tableau (recursif)\r
+function viewArray($arr)\r
+{\r
+ if (is_object($arr))\r
+ return viewArray(get_object_vars($arr));\r
+ else if (!is_array($arr))\r
+ {echo htmlspecialchars($arr); return;}\r
+\r
+ echo '<table cellpadding="0" cellspacing="0" border="1">';\r
+ foreach ($arr as $key1 => $elem1) {\r
+ echo '<tr>';\r
+ echo '<td>'.$key1.' </td>';\r
+ \r
+ echo '<td>';\r
+ viewArray($elem1);\r
+ echo ' </td>'; \r
+ \r
+ echo '</tr>';\r
+ }\r
+ echo '</table>';\r
+}\r
+\r
+function v($x){ viewarray($x);}\r
+\r
+?>\r
--- /dev/null
+<?php\r
+ header('Content-Type: text/html; charset=UTF-8');\r
+ echo '<?xml version="1.0" encoding="UTF-8" ?>';\r
+ \r
+ require ('constantes.php');\r
+\r
+ $dbconn = pg_connect("host=localhost port=5432 dbname=".$BD." user=appart password=soleil") or die('Connexion impossible : ' . pg_last_error());\r
+ pg_query("SET datestyle = 'SQL, DMY';"); \r
+ \r
+ $inputs;\r
+ $erreur;\r
+ $action;\r
+ require ('traitement_inputs.php');\r
+\r
+?>\r
+\r
+<html>\r
+ <head>\r
+ <title>Appart</title>\r
+ <link rel="stylesheet" href="style.css" type="text/css" />\r
+ <script type="text/javascript" src="script.js" ></script>\r
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\r
+ <meta http-equiv="content-type" content="text/html; charset=utf-8"/>\r
+ <title>Google Maps JavaScript API Example</title>\r
+ <script src="http://maps.google.com/maps?file=api&v=2.82&key=ABQIAAAAQLBohykzX4xiepOOUu21GhS2JkdUHwPLqAOasxCB2_i_UFsNUhRbVpRM0k1S9wDSYhOD8Hj8bGnqag" type="text/javascript"></script>\r
+ </head>\r
+ <body onload="rafraichirFormulaire(); loadGMap()" onunload="GUnload()">\r
+<?php\r
+ if (isset($erreur) && $erreur != '')\r
+ {\r
+ echo '<div id="erreur" >' . utf8_encode($erreur) . '</div>';\r
+ }\r
+?>\r
+ \r
+ <div id="menus">\r
+ <div class="menu" id="appartements" > \r
+ <h1><a href="?">Appartements</a></h1>\r
+ <a href="index.php">detail</a> <a href="list.php">liste</a>\r
+\r
+ <form method="post" >\r
+ <input type="hidden" name="action" value="ajouter" />\r
+ <input type="submit" value="Nouveau" />\r
+ </form>\r
+<?php\r
+ foreach ($statuts as $statut_num => $statut_nom)\r
+ {\r
+ echo "<h2>$statut_nom</h2>";\r
+\r
+ $result = pg_query("SELECT id, rue, date_visite FROM appart WHERE statut = $statut_num ORDER by statut, " . ($statut_num == '1'? 'date_visite' : 'id'));\r
+ while ($line = pg_fetch_array($result, null, PGSQL_ASSOC))\r
+ {\r
+ echo '<a '.($id == $line['id'] ? 'class="courant"' : '').' href="?action=voir&id='.$line['id'].'">' . $line['id'] . '. ' . $line['rue'] .\r
+ ($statut_num == '1' ? '<p>' .$line['date_visite'] . '</p>' : '' ).\r
+ '</a>';\r
+ }\r
+ pg_free_result($result);\r
+ }\r
+?>\r
+ </div>\r
+ \r
+ <div class="menu">\r
+ <h1>Liens</h1>\r
+<?php\r
+ foreach ($sites as $nom_site => $url)\r
+ {\r
+ echo '<a href="'.$url.'" >'.$nom_site.'</a>';\r
+ }\r
+?>\r
+ </div>\r
+ </div>\r
+ \r
+ <div id="appartement" >\r
+<?php\r
+ $appartData;\r
+ if ($action == "ajouter")\r
+ {\r
+ foreach($champs as $champ => $type)\r
+ $appartData[$champ] = $inputs[$champ];\r
+ }\r
+ else\r
+ {\r
+ $result = pg_query("SELECT * FROM appart WHERE id = $id");\r
+ $appartData = pg_fetch_array($result, null, PGSQL_ASSOC);\r
+ }\r
+?>\r
+ <form method="post" action="index.php?id=<?= $id ?>" >\r
+ <input id="modeFormulaire" type="hidden" name="mode" value="<?= $action == 'ajouter' ? 'enEdition' : 'enConsultation' ?>" />\r
+ <h1>Appartement N°<?= $id ?></h1>\r
+ <button type="button" id="boutonEditer" onclick="editer();" >éditer</button>\r
+ <div id="boutonsEdition" style="display:none">\r
+ <input type="submit" name="action" value="Supprimer" onclick="return supprimer('<?= $appartData['id'] ?>', '<?= $appartData['rue'] ?>')" />\r
+ <input type="submit" name="action" value="Annuler" />\r
+ <input type="submit" name="action" value="Mémoriser" />\r
+ </div>\r
+ <table id="tableauFormulaire">\r
+ <tr><th class="header1Label"></th><th class="headerInput"></th><th class="header2Label"></th><th class="headerInput"></th></tr>\r
+ <tr>\r
+ <td >\r
+ Statut\r
+ </td>\r
+ <td>\r
+ <select id="editionStatut" size="1" name="statut" style="display: none">\r
+<?php\r
+ foreach ($statuts as $num => $statut)\r
+ echo '<option '. ($appartData['statut'] == $num ? 'selected' : '') . ' value="' . $num .'">' . $statuts[$num] . '</option>';\r
+?>\r
+ </select>\r
+ <p id="consultationStatut" style="display: none"><?= $statuts[$appartData['statut']] ?></p>\r
+ </td>\r
+ <td >Lien internet</td>\r
+ <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>\r
+ </tr>\r
+ <tr>\r
+ <td >Prix + charges</td>\r
+ <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>\r
+ <td rowspan="3" >Contact</td>\r
+ <td rowspan="3"><textarea name="contact" rows="4"><?= $appartData['contact'] ?></textarea></td>\r
+ </tr>\r
+ <tr>\r
+ <td >Libre à partir du <span class="exemple" >(ex: "1/08/2007")</span></td>\r
+ <td><input type="text" name="date_libre" value="<?= $appartData['date_libre'] ?>" /></td>\r
+ </tr>\r
+ <tr>\r
+ <td >Rue</td>\r
+ <td><input id="inputRue" type="text" name="rue" value="<?= $appartData['rue'] ?>" /></td>\r
+ </tr>\r
+ <tr>\r
+ <td >Localité</td>\r
+ <td><input id="inputLocalite" type="text" name="localite" value="<?= $appartData['localite'] ?>" /></td>\r
+ <td rowspan="5" >Description</td>\r
+ <td rowspan="5"><textarea rows="8" name="description"><?= $appartData['description'] ?></textarea></td>\r
+ </tr>\r
+ <tr>\r
+ <td >Nombre de pièce</td>\r
+ <td><input type="text" name="nbpiece" value="<?= $appartData['nbpiece'] ?>" /></td>\r
+ </tr>\r
+ <tr>\r
+ <td >Surface</td>\r
+ <td><input type="text" name="surface" value="<?= $appartData['surface'] ?>" /></td>\r
+ </tr>\r
+ <tr>\r
+ <td >Étage</td>\r
+ <td><input type="text" name="etage" value="<?= $appartData['etage'] ?>" /></td>\r
+ </tr>\r
+ <tr>\r
+ <td >Dernière rénovation (année)</td>\r
+ <td><input type="text" name="annee_construction" value="<?= $appartData['annee_construction'] ?>" /></td>\r
+ </tr> \r
+ <tr>\r
+ <td colspan="2" >Points Positifs</td>\r
+ <td colspan="2" >Points négatifs</td>\r
+ </tr>\r
+ <tr>\r
+ <td colspan="2"><textarea rows="5" name="points_positifs"><?= $appartData['points_positifs'] ?></textarea></td>\r
+ <td colspan="2"><textarea rows="5" name="points_negatifs"><?= $appartData['points_negatifs'] ?></textarea></td>\r
+ </tr>\r
+ <tr>\r
+ <td colspan="4">\r
+ <h2>Visite</h2>\r
+ </td>\r
+ </tr>\r
+ <tr>\r
+ <td >Date et heure de la visite <span class="exemple" >(ex: "23/07/2007 14:23")</span></td>\r
+ <td colspan="3"><input type="text" name="date_visite" value="<?= $appartData['date_visite'] ?>" /></td>\r
+ </tr>\r
+ <tr>\r
+ <td >Indications</td>\r
+ <td colspan="3"><textarea rows="3" name="visite_indications"><?= $appartData['visite_indications'] ?></textarea></td>\r
+ </tr>\r
+ <tr>\r
+ <td colspan="4">\r
+ <h2>Map</h2>\r
+ </td>\r
+ </tr>\r
+ <!-- tr>\r
+ <td>\r
+ Url google map\r
+ </td>\r
+ <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>\r
+ </tr -->\r
+ <tr>\r
+ <td colspan="4" >\r
+ <div id="map"></div>\r
+ <div id="map2"></div>\r
+ </td>\r
+ </tr>\r
+ </table>\r
+ </form>\r
+<?php\r
+ pg_free_result($result);\r
+?>\r
+ </div>\r
+ \r
+ </body>\r
+</html>\r
+\r
+<?php\r
+ pg_close($dbconn);\r
+?>\r
--- /dev/null
+<?php\r
+ header('Content-Type: text/html; charset=UTF-8');\r
+ echo '<?xml version="1.0" encoding="UTF-8" ?>';\r
+ require('debug.inc'); \r
+ require ('constantes.php');\r
+\r
+ $dbconn = pg_connect("host=localhost dbname=".$BD." user=appart password=soleil") or die('Connexion impossible : ' . pg_last_error());\r
+ pg_query("SET datestyle = 'SQL, DMY';"); \r
+ \r
+ $inputs;\r
+ $erreur;\r
+ $action;\r
+ require ('traitement_inputs.php');\r
+\r
+?>\r
+\r
+<html>\r
+ <head>\r
+ <title>Appart</title>\r
+ <link rel="stylesheet" href="style.css" type="text/css" />\r
+ <script type="text/javascript" src="script.js" ></script>\r
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\r
+ <meta http-equiv="content-type" content="text/html; charset=utf-8"/>\r
+ <title>Google Maps JavaScript API Example</title>\r
+ <script src="http://maps.google.com/maps?file=api&v=2.82&key=ABQIAAAAQLBohykzX4xiepOOUu21GhS2JkdUHwPLqAOasxCB2_i_UFsNUhRbVpRM0k1S9wDSYhOD8Hj8bGnqag" type="text/javascript"></script>\r
+ </head>\r
+ <body onload="rafraichirFormulaire(); loadGMap()" onunload="GUnload()">\r
+<?php\r
+ if (isset($erreur) && $erreur != '')\r
+ {\r
+ echo '<div id="erreur" >' . utf8_encode($erreur) . '</div>';\r
+ }\r
+?>\r
+ \r
+ \r
+<div id="menus">\r
+ <div class="amenu" id="appartements" > \r
+ <h1><a href="?">Appartements</a></h1>\r
+ <a href="index.php">detail</a> <a href="list.php">liste</a>\r
+ </div>\r
+ \r
+<div id="liste" >\r
+ <table>\r
+ <tr>\r
+ <td style="font-weight:bold">id</td>\r
+ <td style="font-weight:bold">rue</td>\r
+ <td style="font-weight:bold">prix</td>\r
+ <td style="font-weight:bold">pièce</td>\r
+ <td style="font-weight:bold">contact</td>\r
+ <td style="font-weight:bold">date visite</td>\r
+ </tr>\r
+<?php\r
+ $appartData;\r
+ $statutPrec = "nawak";\r
+ $result = pg_query("SELECT * FROM appart ORDER BY statut, id");\r
+ while ($appartData = pg_fetch_array($result, null, PGSQL_ASSOC))\r
+ {\r
+ if ($appartData['statut'] != $statutPrec)\r
+ {\r
+ echo '<tr><td class="statut" colspan="6">' . $statuts[$appartData['statut']] . '</td></tr>';\r
+ $statutPrec = $appartData['statut'];\r
+ }\r
+\r
+ echo "<tr class=\"statut".$appartData['statut'] ."\">";\r
+ echo "<td><a style=\"display:block\" href=\"index.php?action=voir&id=".$appartData['id']."\"> ".$appartData['id']."</a></td>";\r
+ echo "<td> ".$appartData['rue']."<br><small>etage: " .$appartData['etage'] ."</small></td>";\r
+ echo "<td> ".($appartData['prix'] + $appartData['prixcharges'])."<br><small>" .$appartData['prix'] ."+". $appartData['prixcharges'] . "</small></td>";\r
+ echo "<td> ".$appartData['nbpiece']."</td>";\r
+ echo "<td> ".$appartData['contact']."</td>";\r
+ echo "<td> ".$appartData['date_visite']."</td>";\r
+ echo "</tr>";\r
+ }\r
+?>\r
+</table>\r
+\r
+<?php\r
+ pg_free_result($result);\r
+?>\r
+ </div>\r
+ \r
+ </body>\r
+</html>\r
+\r
+<?php\r
+ pg_close($dbconn);\r
+?>\r
--- /dev/null
+/**\r
+ * Affiche les données de l'appart soit en mode éditable soit en mode de consultation.\r
+ */\r
+function rafraichirFormulaire()\r
+{\r
+ var mode = document.getElementById("modeFormulaire")\r
+ \r
+ var edition = mode.value == "enEdition"\r
+ \r
+ document.getElementById("urlConsultation").style.display = edition ? "none" : "inline";\r
+ document.getElementById("urlEdition").style.display = edition ? "inline" : "none"; \r
+ \r
+ //document.getElementById("urlmapConsultation").style.display = edition ? "none" : "inline";\r
+ //document.getElementById("urlmapEdition").style.display = edition ? "inline" : "none";\r
+ \r
+ document.getElementById("boutonsEdition").style.display = edition ? "block" : "none";\r
+ \r
+ var tab = document.getElementById("tableauFormulaire")\r
+ var inputs = tab.getElementsByTagName("input");\r
+ var areas = tab.getElementsByTagName("textarea");\r
+ \r
+ for (var i = 0; i < inputs.length; i++)\r
+ if (edition) inputs[i].removeAttribute("readonly");\r
+ else inputs[i].setAttribute("readonly","readonly");\r
+ \r
+ for (var i = 0; i < areas.length; i++)\r
+ if (edition) areas[i].removeAttribute("readonly");\r
+ else areas[i].setAttribute("readonly","readonly");\r
+ \r
+ document.getElementById("boutonEditer").style.display = edition ? "none" : "inline";\r
+ \r
+ document.getElementById("editionStatut").style.display = edition ? "inline" : "none";\r
+ document.getElementById("consultationStatut").style.display = edition ? "none" : "inline";\r
+}\r
+\r
+/**\r
+ * passe les données sous la forme éditable.\r
+ */\r
+function editer()\r
+{\r
+ var mode = document.getElementById("modeFormulaire").value = "enEdition"\r
+ rafraichirFormulaire()\r
+}\r
+\r
+function supprimer(id, rue)\r
+{\r
+ return confirm("Voulez vous vraiment supprimer l'appartement n°" + id + " : " + rue); \r
+}\r
+\r
+function endroitTrouve(position)\r
+{\r
+ var marker = new GMarker(position);\r
+ \r
+ var map = new GMap2(document.getElementById("map"));\r
+ map.addControl(new GSmallMapControl());\r
+ map.addControl(new GMapTypeControl());\r
+ map.setCenter(position, 14);\r
+ map.addOverlay(marker)\r
+ \r
+ var map2 = new GMap2(document.getElementById("map2"));\r
+ map2.addControl(new GSmallMapControl());\r
+ map2.addControl(new GMapTypeControl());\r
+ map2.setCenter(position, 16);\r
+ map2.addOverlay(marker)\r
+}\r
+\r
+// voir : http://www.google.com/apis/maps/documentation/reference.html\r
+function loadGMap()\r
+{\r
+ if (GBrowserIsCompatible())\r
+ {\r
+ var geocoder = new GClientGeocoder();\r
+ \r
+ geocoder.setViewport(new GLatLngBounds(new GLatLng(46.8333, 7.1166), new GLatLng(46.7333, 7.2166))); \r
+ geocoder.getLatLng(document.getElementById("inputRue").value + " " + document.getElementById("inputLocalite").value, endroitTrouve);\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+body {\r
+ background-color: #DDF3DD;\r
+ min-width: 800px;\r
+ font-family: Arial;\r
+ font-size: 10pt;\r
+}\r
+\r
+a {\r
+ text-decoration: none;\r
+}\r
+a:link {\r
+ color: #3D3484;\r
+}\r
+a:visited {\r
+ color: #3D3484;\r
+}\r
+a:hover {\r
+ color: #7B72C4;\r
+ text-decoration: underline\r
+}\r
+a:active {\r
+ color: #D1CDF4;\r
+ text-decoration: underline\r
+}\r
+\r
+#erreur {\r
+ border: red solid 5px;\r
+ background-color: white;\r
+ position: fixed;\r
+ left: 10px;\r
+ top: 5px;\r
+ z-index: 10;\r
+}\r
+\r
+#menus {\r
+ position: absolute;\r
+ left: 10px;\r
+ top: 10px;\r
+}\r
+\r
+.menu {\r
+ float: left;\r
+ border: black solid 1px;\r
+ background-color: #F3F3F3;\r
+ padding: 5px;\r
+ width: 130px;\r
+ clear: both;\r
+ margin-bottom: 10px;\r
+}\r
+.menu > a {\r
+ display: block;\r
+ margin-left: 3px;\r
+ margin-bottom: 3px;\r
+ border-left: #0000A0 solid 4px;\r
+ padding-left: 3px;\r
+}\r
+.menu > a:hover {\r
+ border-left: #6161CA solid 4px;\r
+}\r
+.menu h1{\r
+ font-size: 13pt;\r
+ margin-top: 3px;\r
+ margin-bottom: 3px;\r
+ font-style: italic;\r
+ color: #0000A0;\r
+}\r
+.menu h2{\r
+ font-size: 11pt;\r
+ margin-bottom: 2px;\r
+}\r
+\r
+#appartements a.courant {\r
+ border-left: #A8A8E2 solid 4px;\r
+ background-color: #E0E0EE;\r
+ -moz-border-radius: 0px 9px 9px 0px;\r
+}\r
+\r
+#appartements a p {\r
+ margin-top: 0px;\r
+ margin-bottom: 0px;\r
+ font-size: 8pt;\r
+}\r
+\r
+#appartement {\r
+ padding-right: 10px;\r
+ padding-left: 170px;\r
+}\r
+#appartement th.header1Label{\r
+ width: 15%;\r
+}\r
+#appartement th.header2Label{\r
+ width: 10%;\r
+}\r
+#appartement textarea{\r
+ font-size: 10pt;\r
+ font-family: arial, helvetica, sans-serif;\r
+ width: 100%;\r
+}\r
+#appartement input{\r
+ width: 100%;\r
+}\r
+\r
+#appartement .short\r
+{\r
+ width: 40px;\r
+}\r
+\r
+#appartement #boutonsEdition input{\r
+ width: auto;\r
+}\r
+#appartement .exemple {\r
+ font-size: 8pt;\r
+ color: #666666;\r
+}\r
+#appartement #consultationStatut {\r
+ font-weight: bold;\r
+}\r
+#appartement h1 {\r
+ font-size: 15pt;\r
+}\r
+#appartement h2 {\r
+ font-size: 14pt;\r
+ margin-top: 10px;\r
+ margin-bottom: 5px;\r
+}\r
+#appartement td {\r
+ vertical-align: top;\r
+ font-size: 10pt;\r
+}\r
+#appartement #map{\r
+ page-break-before: always;\r
+ height: 500px;\r
+ width: 500px;\r
+ float: left;\r
+}\r
+#appartement #map2{\r
+ height: 500px;\r
+ width: 500px;\r
+ float: left;\r
+}\r
+#liste tbody\r
+{\r
+font-size: 0.8em;\r
+}\r
+#liste .statut0\r
+{\r
+/*background-color: white;*/\r
+}\r
+#liste .statut1\r
+{\r
+background-color: rgb(255,250,80);\r
+}\r
+#liste .statut2\r
+{\r
+background-color: orange;\r
+}\r
+#liste .statut3\r
+{\r
+background-color: rgb(200,55,55);\r
+}\r
+#liste .statut4\r
+{\r
+background-color: rgb(77, 77, 77);\r
+}\r
+\r
+#liste tr\r
+{\r
+margin: 0px;\r
+padding: 0px;\r
+}\r
+#liste td\r
+{\r
+border-bottom: 1px solid grey;\r
+}\r
+#liste tr:hover\r
+{\r
+background: rgb(155,200,155);\r
+}\r
+#liste .statut\r
+{\r
+font-size: 1.2em;\r
+font-weight: bold;\r
+}\r
--- /dev/null
+<?php\r
+\r
+ /**\r
+ * Renvoie la valeur "SQL" d'un champ.\r
+ * p1 : sa valeur\r
+ * p2 : son type\r
+ */ \r
+ function getChampSQL($valeur, $champ, $type)\r
+ { \r
+ $champSQL = trim($valeur); \r
+ if ($champ == 'statut' && $champSQL == '')\r
+ $champSQL = '0';\r
+ if ($type == 'int' && ($champSQL == '' OR !is_numeric($champSQL)))\r
+ $champSQL = 'NULL';\r
+ if ($type == 'date' && $champSQL == '')\r
+ $champSQL = 'NULL';\r
+ if ($type == 'timestamp' && $champSQL == '')\r
+ $champSQL = 'NULL';\r
+\r
+ if ($champSQL != 'NULL')\r
+ $champSQL = "'".(str_replace("'", "''", $champSQL))."'";\r
+ \r
+ return $champSQL;\r
+ }\r
+ \r
+ $inputs = array_merge($_GET, $_POST);\r
+ \r
+ $erreur = '';\r
+ \r
+ // l'id de l'appart afficher, à modifier, à ajouter ou à supprimer\r
+ $id = 1; \r
+ if (array_key_exists('id', $inputs))\r
+ $id = $inputs['id'];\r
+ \r
+ // l'action peut valoir :\r
+ // 'voir' pour voir un appartement\r
+ // 'mémoriser' pour modifier un appartement (ou ajouter)\r
+ // 'ajouter' pour ajouter un nouvel appart\r
+ // 'supprimer' pour supprimer un appart\r
+ $action = 'voir';\r
+ if (array_key_exists('action', $inputs))\r
+ $action = strtolower($inputs['action']);\r
+ \r
+ if ($action == 'ajouter')\r
+ {\r
+ $result = pg_query("SELECT nextval('appart_id_seq')");\r
+ $appartData = pg_fetch_row($result);\r
+ $id = $appartData[0];\r
+ pg_free_result($result);\r
+ }\r
+ else if ($action == 'mémoriser')\r
+ {\r
+ $result = pg_query("SELECT count(*) FROM appart WHERE id = $id");\r
+ $count = pg_fetch_row($result); \r
+ pg_free_result($result);\r
+ // modification d'un appart existant\r
+ \r
+ if ($count[0] == 1)\r
+ {\r
+ // met à jour tous les champs\r
+ foreach ($champs as $champ => $type)\r
+ {\r
+ $champSQL = getChampSQL($inputs[$champ], $champ, $type);\r
+ if (!@pg_query("UPDATE appart SET ".$champ." = ".$champSQL." WHERE id = $id"))\r
+ $erreur = pg_last_error();\r
+ #echo "UPDATE appart SET ".$champ." = ".$champSQL." WHERE id = $id<br/>";\r
+ }\r
+ }\r
+ // ajout d'un nouvel appart\r
+ else\r
+ { \r
+ $champsSQL = '';\r
+ $valuesSQL = '';\r
+ $debut = true;\r
+ foreach ($champs as $champ => $type)\r
+ {\r
+ $champSQL = getChampSQL($inputs[$champ], $champ, $type); \r
+ $champsSQL .= ($debut ? '' : ',') . $champ;\r
+ $valuesSQL .= ($debut ? '' : ',') . $champSQL;\r
+ $debut = false;\r
+ }\r
+ if(!@pg_query("INSERT INTO appart (".$champsSQL.") VALUES(".$valuesSQL.")"))\r
+ {\r
+ $erreur = pg_last_error();\r
+ $action = "ajouter";\r
+ }\r
+ #echo "INSERT INTO appart (".$champsSQL.") VALUES(".$valuesSQL.")";\r
+ }\r
+ }\r
+ else if ($action == 'supprimer')\r
+ {\r
+ @pg_query("DELETE FROM appart WHERE id = $id");\r
+ $id = 1;\r
+ }\r
+?>\r
+ \r