186 lines
7.4 KiB
PHP
186 lines
7.4 KiB
PHP
<?php
|
|
include_once(realpath(dirname(__FILE__)) . "/Magasin.class.php");
|
|
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Variable.class.php");
|
|
|
|
$cle = new Variable();
|
|
$cle->charger("cle_google_map");
|
|
|
|
$urlsite = new Variable();
|
|
$urlsite->charger("urlsite");
|
|
|
|
$magasin = new Magasin();
|
|
$magasin->charger($_REQUEST['id']);
|
|
|
|
if($_REQUEST['enregistrer'] == "1"){
|
|
if($magasin->adresse != $_REQUEST['adresse_magasin'] || $magasin->cp != $_REQUEST['cp_magasin'] || $magasin->ville != $_REQUEST['ville_magasin']){
|
|
|
|
$q = $_REQUEST['adresse_magasin'] . " " . $_REQUEST['cp_magasin'] . " " . $_REQUEST['ville_magasin'];
|
|
$rec = file_get_contents("http://maps.google.fr/maps/geo?q=". urlencode($q)."&output=csv&key=" . $cle->valeur);
|
|
|
|
$coord = explode(",", $rec);
|
|
$lat = $coord[2] ;
|
|
$lon = $coord[3];
|
|
|
|
$magasin->lat = $lat;
|
|
$magasin->lon = $lon;
|
|
}
|
|
$magasin->nom = $_REQUEST['nom_magasin'];
|
|
$magasin->adresse = $_REQUEST['adresse_magasin'];
|
|
$magasin->cp = $_REQUEST['cp_magasin'];
|
|
$magasin->ville = $_REQUEST['ville_magasin'];
|
|
$magasin->tel = $_REQUEST['tel_magasin'];
|
|
$magasin->fax = $_REQUEST['fax_magasin'];
|
|
|
|
if($_REQUEST['id'])
|
|
$magasin->maj();
|
|
else
|
|
$id = $magasin->add();
|
|
|
|
|
|
if($id == "")
|
|
$id = $magasin->id;
|
|
|
|
$photo = $_FILES["photo_magasin"]['tmp_name'];
|
|
$photo_name = $_FILES["photo_magasin"]['name'];
|
|
|
|
if($photo != "")
|
|
copy("$photo", "../client/gfx/magasin/" . $id . ".jpg");
|
|
|
|
}
|
|
?>
|
|
<script type="text/javascript" src="../client/plugins/magasin/jquery.js"></script>
|
|
<script src="http://maps.google.com/maps?file=api&v=2.89&key=<?php echo $cle->valeur; ?>" type="text/javascript"></script>
|
|
<script type="text/javascript">
|
|
|
|
function load(cp) {
|
|
if (GBrowserIsCompatible()) {
|
|
|
|
var map = new GMap2(document.getElementById("map"));
|
|
map.addControl(new GSmallMapControl());
|
|
map.addControl(new GMapTypeControl());
|
|
|
|
GDownloadUrl("../client/plugins/magasin/carte.php?cp="+ cp, function(data) {
|
|
var xml = GXml.parse(data);
|
|
var markers = xml.getElementsByTagName("marker");
|
|
|
|
for (var i = 0; i < markers.length; i++) {
|
|
var name = markers[i].getAttribute("nom");
|
|
var address = markers[i].getAttribute("adresse");
|
|
var codepostal = markers[i].getAttribute("cp");
|
|
var ville = markers[i].getAttribute("ville");
|
|
var tel = markers[i].getAttribute("tel");
|
|
var fax = markers[i].getAttribute("fax");
|
|
var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
|
|
parseFloat(markers[i].getAttribute("lng")));
|
|
map.setCenter(point,8);
|
|
var marker = createMarker(point, name, address, codepostal, ville, tel, fax);
|
|
map.addOverlay(marker);
|
|
GEvent.addListener(marker, "dragend", function() {
|
|
$.ajax({type:'GET', url:'../client/plugins/magasin/localisation.php', data:'id=<?php echo $_REQUEST['id']; ?>&lat=' + marker.getLatLng().lat() + '&lon=' + marker.getLatLng().lng()})
|
|
});
|
|
}
|
|
|
|
});
|
|
}
|
|
}
|
|
|
|
function createMarker(point, name, address, codepostal, ville, tel, fax) {
|
|
var option = { draggable:true };
|
|
|
|
|
|
var marker = new GMarker(point,option);
|
|
var html = <?php if(file_exists("../client/gfx/magasin/$id.jpg")) { ?> "<img src='<?php echo $urlsite->valeur; ?>/client/plugins/magasin/redimlive.php?nomorig=../../gfx/magasin/<?php echo $id; ?>.jpg&width=100' />" + <?php } ?>"<b>" + "</b> <br/>"+ name+" <br/>" + address +" <br/>" + codepostal +" "+ ville +" <br/> tel : " + tel+" <br/> fax : " + fax;
|
|
GEvent.addListener(marker, 'mouseover', function() {
|
|
marker.openInfoWindowHtml(html);
|
|
});
|
|
return marker;
|
|
}
|
|
//]]>
|
|
</script>
|
|
|
|
<div id="contenu_int">
|
|
<p class="titre_rubrique">Magasins</p>
|
|
|
|
<p align="right" class="geneva11Reg_3B4B5B"><a href="accueil.php" class="lien04">Accueil </a><img src="gfx/suivant.gif" width="12" height="9" border="0" /><a href="module.php?nom=magasin" class="lien04">Magasins</a> <img src="gfx/suivant.gif" width="12" height="9" border="0" /><a href="#" class="lien04"><?php if($_REQUEST['id']) echo "Visualiser"; else echo "Ajouter"; ?></a>
|
|
</p>
|
|
<table width="710" border="0" cellpadding="5" cellspacing="0">
|
|
<tr>
|
|
<td height="30" class="cellule_sombre2"><span class="sous_titre_rubrique"><span class="geneva11Reg_3B4B5B"><a href="#" onClick="document.getElementById('formulaire').submit();" class="txt_vert_11">Modifier les coordonnées du magasin</a></span> <img src="gfx/suivant.gif" width="12" height="9" border="0" /></span></td>
|
|
</tr>
|
|
</table>
|
|
<table width="710" border="0" cellpadding="5" cellspacing="0">
|
|
|
|
<tr>
|
|
<td width="600" height="30" class="titre_cellule_tres_sombre">INFORMATIONS SUR LE MAGASIN</td>
|
|
</tr>
|
|
</table>
|
|
<form id='formulaire' action="module.php" method="post" ENCTYPE="multipart/form-data">
|
|
<input type="hidden" name="nom" value="magasin" />
|
|
<input type="hidden" name="action" value="visualiser" />
|
|
<input type="hidden" name="id" value="<?php echo $id; ?>" />
|
|
<input type="hidden" name="enregistrer" value="1" />
|
|
|
|
|
|
<table width="710" border="0" cellpadding="5" cellspacing="0">
|
|
<tr>
|
|
<td class="titre_cellule" width="150" height="30">NOM</td>
|
|
|
|
<td class="cellule_sombre"><input type="text" name="nom_magasin" value="<?php echo $magasin->nom; ?>" size="50" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td height="30" class="titre_cellule">ADRESSE</td>
|
|
<td class="cellule_sombre"><input type="text" name="adresse_magasin" value="<?php echo $magasin->adresse; ?>" size="50" /></td>
|
|
</tr>
|
|
<tr>
|
|
|
|
<td height="30" class="titre_cellule">CODE POSTAL</td>
|
|
<td class="cellule_sombre"><input type="text" name="cp_magasin" value="<?php echo $magasin->cp; ?>" size="50" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td height="30" class="titre_cellule">VILLE</td>
|
|
<td class="cellule_claire"><input type="text" name="ville_magasin" value="<?php echo $magasin->ville; ?>" size="50" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
<td height="30" class="titre_cellule">TEL</td>
|
|
<td class="cellule_claire"><input type="text" name="tel_magasin" value="<?php echo $magasin->tel; ?>" size="50" /></td>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td height="30" class="titre_cellule">FAX</td>
|
|
|
|
<td class="cellule_claire"><input type="text" name="fax_magasin" value="<?php echo $magasin->fax; ?>" size="50" /></td>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td height="30" class="titre_cellule">PHOTO</td>
|
|
|
|
<td class="cellule_claire"><input type="file" name="photo_magasin" size="50" />
|
|
<br />
|
|
<?php if(file_exists("../client/gfx/magasin/$id.jpg")) { ?>
|
|
<img src="../client/plugins/magasin/redimlive.php?nomorig=../../gfx/magasin/<?php echo $id; ?>.jpg&width=100" />
|
|
<?php } ?>
|
|
</td>
|
|
</td>
|
|
</tr>
|
|
|
|
</table>
|
|
</form>
|
|
|
|
<body onLoad="load('<?php echo $magasin->cp; ?>')">
|
|
|
|
<div id="map" style="width: 610; height: 475px"></div>
|
|
|
|
|
|
<br />
|
|
<table width="710" border="0" cellpadding="5" cellspacing="0">
|
|
<tr>
|
|
<td height="30" class="cellule_sombre2"><span class="sous_titre_rubrique"><span class="geneva11Reg_3B4B5B"><a href="#" onClick="document.getElementById('formulaire').submit();" class="txt_vert_11">Modifier les coordonnées du magasin</a></span> <img src="gfx/suivant.gif" width="12" height="9" border="0" /></span></td>
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
|
|
</div>
|