Initial commit

This commit is contained in:
2020-01-27 08:56:08 +01:00
commit b7525048d6
27129 changed files with 3409855 additions and 0 deletions

View File

@@ -0,0 +1,217 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) Octolys Development */
/* email : thelia@octolys.fr */
/* web : http://www.octolys.fr */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* */
/*************************************************************************************/
?>
<?php
include_once(realpath(dirname(__FILE__)) . "/../../../classes/PluginsClassiques.class.php");
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Variable.class.php");
class Magasin extends PluginsClassiques{
var $id;
var $nom;
var $adresse;
var $cp;
var $ville;
var $tel;
var $fax;
var $lat;
var $lon;
var $table = "magasin";
var $bddvars=array("id", "nom", "adresse", "cp", "ville", "tel", "fax", "lat", "lon");
function init(){
$cnx = new Cnx();
$query_magasin = "CREATE TABLE `magasin` (
`id` int(11) NOT NULL auto_increment,
`nom` text NOT NULL,
`adresse` text NOT NULL,
`cp` text NOT NULL,
`ville` text NOT NULL,
`tel` text NOT NULL,
`fax` text NOT NULL,
`lat` text NOT NULL,
`lon` text NOT NULL,
PRIMARY KEY (`id`)
) ;";
$resul_magasin = mysql_query($query_magasin, $cnx->link);
@mkdir("../client/gfx/magasin",0755);
@mkdir("../client/cache/magasin",0755);
$variable = new Variable();
if(!$variable->charger("cle_google_map")){
$variable->nom = "cle_google_map";
$variable->add();
}
}
function Magasin(){
$this->PluginsClassiques();
}
function charger($id){
return $this->getVars("select * from $this->table where id=\"$id\"");
}
function charger_ville($ville){
return $this->getVars("select * from $this->table where ville=\"$ville\"");
}
function boucle($texte, $args){
// r?cup?ration des arguments
$boucle = lireTag($args, "boucle");
if($boucle == "codepostal")
return $this->boucle_codepostal($texte, $args);
if($boucle == "ville")
return $this->boucle_ville($texte, $args);
else if($boucle == "magasin")
return $this->boucle_magasin($texte, $args);
}
function boucle_codepostal($texte, $args){
$search="";
$res="";
$order = "order by cp";
$query = "select distinct(cp) from $this->table $order";
$resul = mysql_query($query);
$nbres = mysql_num_rows($resul);
if(!$nbres) return "";
while( $row = mysql_fetch_object($resul)){
$temp = str_replace("#CP", "$row->cp", $texte);
if(isset($_GET['cp']) && $_GET['cp'] == $row->cp)
$temp = str_replace("#SELECTED", "selected=\"selected\"", $temp);
else
$temp = str_replace("#SELECTED", "", $temp);
$res .= $temp;
}
return $res;
}
function boucle_ville($texte, $args){
$search="";
$res="";
$order = "order by ville";
$query = "select distinct(ville) from $this->table $order";
$resul = mysql_query($query);
$nbres = mysql_num_rows($resul);
if(!$nbres) return "";
while( $row = mysql_fetch_object($resul)){
$temp = str_replace("#VILLE", "$row->ville", $texte);
$this->charger_ville($row->ville);
$temp = str_replace("#CP", "$this->cp", $temp);
if(isset($_GET['cp']) && $_GET['cp'] == $this->cp)
$temp = str_replace("#SELECTED", "selected=\"selected\"", $temp);
else
$temp = str_replace("#SELECTED", "", $temp);
$res .= $temp;
}
return $res;
}
function boucle_magasin($texte, $args){
$cp = lireTag($args, "cp");
$largeur_image = lireTag($args, "largeur_image");
$search="";
$res="";
if($cp != "")
$search .= " and cp=\"$cp\"";
if($ville != "")
$search .= " and ville=\"$ville\"";
$order = "order by cp";
$query = "select * from $this->table where 1 $search $order";
$resul = mysql_query($query);
$nbres = mysql_num_rows($resul);
if(!$nbres) return "";
while( $row = mysql_fetch_object($resul)){
$temp = str_replace("#CP", "$row->cp", $texte);
$temp = str_replace("#NOM", "$row->nom", $temp);
$temp = str_replace("#ADRESSE", "$row->adresse", $temp);
$temp = str_replace("#CP", "$row->cp", $temp);
$temp = str_replace("#VILLE", "$row->ville", $temp);
$temp = str_replace("#TEL", "$row->tel", $temp);
$temp = str_replace("#FAX", "$row->fax", $temp);
$temp = str_replace("#LAT", "$row->lat", $temp);
$temp = str_replace("#LON", "$row->lon", $temp);
if(file_exists("client/gfx/magasin/" . $row->id . ".jpg"))
$temp = str_replace("#IMAGE", "client/plugins/magasin/redimlive.php?nomorig=../../gfx/magasin/" . $row->id . ".jpg&width=$largeur_image", $temp);
else
$temp = str_replace("#IMAGE", "", $temp);
$res .= $temp;
}
return $res;
}
function action(){
global $res;
if($_GET['cp'])
$res = str_replace("#MAGASIN_CP", $_GET['cp'], $res);
else
$res = str_replace("#MAGASIN_CP", "75020", $res);
}
}
?>

View File

@@ -0,0 +1,11 @@
Ce plugin vous permet de gérer une liste de points de vente et de les afficher sur une carte google map.
Le répertoire template comporte un template "exemple".
Veuillez simplement glisser le répertoire magasin dans le dossier client/plugins de votre Thelia.
Puis glisser le fichier plugins/magasin/template/magasin.html dans le dossier template de thelia 1.5
Indiquez dans la gestion des variables (configuration) la valeur de votre clé google map.
Auteur : Yoan De Macedo
yoandm@gmail.com

View File

@@ -0,0 +1,59 @@
<?php
include_once(realpath(dirname(__FILE__)) . "/Magasin.class.php");
?>
<?php
function convert($chaine){
$avant = "àáâãäåòóôõöøèéêëçìíîïùúûüÿñÁÂÀÅÃÄÇÉÊÈËÓÔÒØÕÖÚÛÙÜ";
$apres = "aaaaaaooooooeeeeciiiiuuuuynaaaaaaceeeeoooooouuuu";
$chaine = strtolower($chaine);
$chaine = strtr($chaine, $avant, $apres);
return $chaine;
}
$key = new Variable();
$key->charger("cle_google_map");
$rec = file_get_contents("http://maps.google.fr/maps/geo?q=". $_GET['cp']."&output=csv&key=" . $key->valeur);
$coord = explode(",", $rec);
$lat = $coord[2] ;
$lon = $coord[3];
$magasin = new Magasin();
$query = "select * from $magasin->table where cp=\"" . $_GET['cp'] . "\"";
$resul = mysql_query($query, $magasin->link);
header("Content-type: text/xml");
echo'<?xml version="1.0" encoding="iso-8859-1"?>';
echo '<markers>';
while($row = mysql_fetch_object($resul)){
$row->adresse = convert($row->adresse);
$row->nom = convert($row->nom);
if(! $row->lat){
$row->lat = $lat;
$row->lon = $lon;
}
echo '<marker ';
echo 'nom="' . $row->nom . '" ';
echo 'adresse="' . $row->adresse . '" ';
echo 'cp="'. $row->cp . '" ';
echo 'ville="' . $row->ville . '" ';
echo 'tel="' . $row->tel . '" ';
echo 'fax="' . $row->tel . '" ';
echo 'lat="' . $row->lat . '" ';
echo 'lng="' . $row->lon . '" ';
echo '/>';
}
echo '</markers>';
?>

32
client/plugins/magasin/jquery.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
<?php
include_once(realpath(dirname(__FILE__)) . "/Magasin.class.php");
$magasin = new Magasin();
$magasin->charger($_GET['id']);
$magasin->lat = $_GET['lat'];
$magasin->lon = $_GET['lon'];
$magasin->maj();
?>

View File

@@ -0,0 +1,114 @@
<?php
include_once(realpath(dirname(__FILE__)) . "/../../../fonctions/authplugins.php");
autorisation("magasin");
?>
<?php
include_once(realpath(dirname(__FILE__)) . "/Magasin.class.php");
$magasin = new Magasin();
if($action == "supprimer"){
$magasin = new Magasin();
$magasin->charger($_GET['id']);
$magasin->delete();
}
?>
<?php
if($_REQUEST['action'] == "" || $_REQUEST['action'] == "supprimer"){
?>
<script type="text/javascript">
function confirmSupp(id){
if(confirm("Confirmez-vous cette action de suppression ?"))
location = "module.php?nom=magasin&action=supprimer&id=" + id;
}
</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="1" class="lien04">Gestion des magasins</a></p>
<table width="710" border="0" cellpadding="5" cellspacing="0">
<tr>
<td width="600" height="30" class="titre_cellule_tres_sombre">MAGASINS</td>
<td class="titre_cellule_tres_sombre">
<?php
$query = "select distinct(cp) from $magasin->table order by cp";
$resul = mysql_query($query, $magasin->link);
?>
<select name="cp" onChange="location='module.php?nom=magasin&cp=' + this.value;">
<?php
while($row = mysql_fetch_object($resul)){
?>
<option value="<?php echo $row->cp; ?>" <?php if($_REQUEST['cp'] == $row->cp) echo "selected=\"selected\"";?>><?php echo $row->cp; ?></option>
<?php
}
?>
</select>
</td>
</tr>
</table>
<table width="710" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td height="30" class="titre_cellule">NOM</td>
<td height="30" class="titre_cellule">CODE POSTAL</td>
<td height="30" class="titre_cellule">VILLE</td>
<td height="30" class="titre_cellule">&nbsp;</td>
<td height="30" class="titre_cellule">&nbsp;</td>
</tr>
<?php
$i = 0;
if($_REQUEST['cp'] != ""){
$query = "select * from $magasin->table where cp=\"" . $_REQUEST['cp'] . "\"";
$resul = mysql_query($query, $magasin->link);
while($row = mysql_fetch_object($resul)){
if(!($i%2)) $fond="cellule_sombre";
else $fond="cellule_claire";
$i++;
?>
<tr class="<?php echo $fond; ?>">
<td height="30"><?php echo $row->nom; ?></td>
<td height="30"><?php echo $row->cp; ?></td>
<td height="30"><?php echo $row->ville; ?></td>
<td height="30"><a href="module.php?nom=magasin&action=visualiser&id=<?php echo $row->id; ?>" class="txt_vert_11">Poursuivre</a> <img src="gfx/suivant.gif" width="12" height="9" border="0" /></td>
<td height="30"><a href="#" onClick="confirmSupp('<?php echo $row->id; ?>')"><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></td>
</tr>
<?php
}
}
?>
</table>
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="cellule_claire">
<td width="21%" height="30">Cr&eacute;er un magasin</td>
<td width="63%" height="30"></td>
<td width="16%" height="30">
<div align="left"><a href="module.php?nom=magasin&action=visualiser" class="txt_vert_11">Poursuivre </a><img src="gfx/suivant.gif" width="12" height="9" border="0" /></div>
</td>
</tr>
</table>
</div>
<?php
}
else if($action == "visualiser")
include_once("../client/plugins/magasin/visualiser.php");
?>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Migration automatique depuis le fichier original, sauvegardé dans plugin.xml.save-->
<plugin>
<descriptif lang="fr">
<titre>Magasin</titre>
<chapo></chapo>
<description>Affichage des points de vente sur une google map.</description>
<postscriptum></postscriptum>
</descriptif>
<version>1.1</version>
<auteur>
<nom>Yoan De Macedo - yoandm@gmail.com</nom>
<societe></societe>
<email></email>
<web></web>
</auteur>
<type>classique</type>
<prerequis/>
<thelia>1.5.0</thelia>
<etat>production</etat>
<documentation>Readme.txt</documentation>
<urlmiseajour></urlmiseajour>
</plugin>

View File

@@ -0,0 +1,242 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) Octolys Development */
/* email : thelia@octolys.fr */
/* web : http://www.octolys.fr */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* */
/*************************************************************************************/
?>
<?php
// redimensionnement des images + effets
include_once(realpath(dirname(__FILE__)) . "/../../../fonctions/divers.php");
// Déclaration des variables
if(isset($_REQUEST['nomorig']))
$nomorig = $_REQUEST['nomorig'] ; else $nomorig = "";
if(isset($_REQUEST['height']))
$height = $_REQUEST['height'] ; else $height = "";
if(isset($_REQUEST['width']))
$width=$_REQUEST['width']; else $width="";
if(isset($_REQUEST['opacite']))
$opacite=$_REQUEST['opacite']; else $opacite="";
if(isset($_REQUEST['nb']))
$nb=$_REQUEST['nb']; else $nb="";
if(isset($_REQUEST['miroir']))
$miroir=$_REQUEST['miroir']; else $miroir="";
// function de retournement d'image
function imageflip(&$dest, &$src) {
$w = imagesx($src);
$h = imagesy($src);
$alpha = 127;
for($y=0; $y<$h; $y++) {
for ($x=0; $x<$w; $x++) {
$couleur = imagecolorsforindex($src, imagecolorat($src, $x, $y));
$couleurAlpha = imagecolorallocatealpha($dest, $couleur['red'], $couleur['green'], $couleur['blue'], $alpha);
imagesetpixel($dest, $x, ($h-$y), $couleurAlpha);
}
if($alpha > 1) $alpha--;
}
}
if (file_exists($nomorig) || url_exists($nomorig))
{
$extension = substr($nomorig, strlen($nomorig)-3);
$type = "magasin";
eregi("/([^\/]*.(jpg|gif|png))", $nomorig, $nsimple);
$nomcache = "../../client/cache/" . $type . "/" . $width . "_" . $height . "_" . $opacite . "_" . $nb . "_" . $miroir . "_" . $nsimple[1];
if(file_exists("../$nomcache")) { header("Location: ../$nomcache"); exit; }
// Cacul des nouvelles dimensions
list($width_orig, $height_orig) = getimagesize($nomorig);
// si l'image est plus grande
$image_p_largeur = "";
$image_p_hauteur = "";
if ( ($width_orig > $width) || ($height_orig > $height) )
{
if (($width_orig > $width) && $width!="")
{
# Calcul 1 : la largeur
$facteur_div = $width_orig / $width ;
$image_p_largeur = $width ; /* Nouvelle largeur */
$image_p_hauteur = $height_orig / $facteur_div ; /* Nouvelle hauteur */
}
else {
$image_p_largeur = $width_orig ; /* Nouvelle largeur */
$image_p_hauteur = $height_orig ; /* Nouvelle hauteur */
}
if (($image_p_hauteur > $height) && $height!="")
{
# Calcul 2 : la hauteur
$facteur_div = $image_p_hauteur / $height ;
$image_p_largeur = $image_p_largeur / $facteur_div ; /* Nouvelle largeur */
$image_p_hauteur = $height ; /* Nouvelle hauteur */
}
$width = $image_p_largeur ;
$height = $image_p_hauteur ;
}
else
{
$width = "";
$height = "";
}
if($width=="") $width=$width_orig;
if($height=="") $height=$height_orig;
$image_new = imagecreatetruecolor($width, $height);
// chargement img origine
if(strtolower($extension) == "gif"){
$image_orig = imagecreatefromgif($nomorig);
}
else if(strtolower($extension) == "jpg" || strtolower($extension) == "png"){
if(strtolower($extension) == "jpg")
$image_orig = imagecreatefromjpeg($nomorig);
else if(strtolower($extension) == "png") {
$image_orig = imagecreatefrompng($nomorig);
$trnprt_indx = imagecolortransparent($image_orig);
// If we have a specific transparent color
if ($trnprt_indx >= 0) {
// Get the original image's transparent color's RGB values
$trnprt_color = imagecolorsforindex($image_orig, $trnprt_indx);
// Allocate the same color in the new image resource
$trnprt_indx = imagecolorallocate($image_new, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
// Completely fill the background of the new image with allocated color.
imagefill($image_new, 0, 0, $trnprt_indx);
// Set the background color for new image to transparent
imagecolortransparent($image_new, $trnprt_indx);
}
else {
// Turn off transparency blending (temporarily)
imagealphablending($image_new, false);
// Create a new transparent color for image
$color = imagecolorallocatealpha($image_new, 0, 0, 0, 127);
// Completely fill the background of the new image with allocated color.
imagefill($image_new, 0, 0, $color);
// Restore transparency blending
imagesavealpha($image_new, true);
}
}
}
if($opacite != ""){
$opac_img = imagecreatetruecolor($width_orig, $height_orig);
$white = ImageColorAllocate ($opac_img, 255, 255, 255);
imagefill($opac_img, 0, 0, $white);
imagecopymerge($opac_img, $image_orig, 0,0,0,0, $width_orig, $height_orig, $opacite);
$image_orig = $opac_img;
}
// Redimensionnement
imagecopyresampled($image_new, $image_orig, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Noir et blanc
if($nb != ""){
imagetruecolortopalette($image_new, false, 256);
$total = ImageColorsTotal($image_new);
for( $i=0; $i<$total; $i++){
$old = ImageColorsForIndex($image_new, $i);
$commongrey = (int)(($old[red] + $old[green] + $old[blue]) / 3);
ImageColorSet($image_new, $i, $commongrey, $commongrey, $commongrey);
}
}
if($miroir != ""){
$largeur = imagesx($image_new);
$hauteur = imagesy($image_new);
$temporaireUn = imagecreatetruecolor($largeur, 50);
$temporaireDeux = imagecreatetruecolor($largeur, 50);
$resultat = imagecreatetruecolor($largeur, $hauteur+50);
$blancUn = imagecolorallocate($resultat, 255, 255, 255);
imagefill($resultat, 1, 1, $blancUn);
$blancDeux = imagecolorallocate($temporaireDeux, 255, 255, 255);
imagefill($temporaireDeux, 1, 1, $blancDeux);
imagecopy ($resultat, $image_new, 0, 0, 0, 0, $largeur, $hauteur);
imagecopy ($temporaireUn, $image_new, 0, 0, 0, $hauteur-50, $largeur, 50);
imageflip($temporaireDeux, $temporaireUn);
imagecopy ($resultat, $temporaireDeux, 0, $hauteur, 0, 0, $largeur, 50);
$image_new = $resultat;
imagejpeg($resultat, null, 100);
}
if(strtolower($extension) == "gif"){
imagegif($image_new, "../$nomcache", 100);
imagegif($image_new, null, 100);
}
else if(strtolower($extension) == "jpg"){
imagejpeg($image_new, "../$nomcache", 100);
imagejpeg($image_new, null, 100);
}
else if(strtolower($extension) == "png"){
imagepng($image_new, "../$nomcache");
imagepng($image_new);
}
}
?>

View File

@@ -0,0 +1,70 @@
<?php
include_once("../Magasin.class.php");
include_once("../../../../classes/Variable.class.php");
?>
<?php
$cle = new Variable();
$cle->charger("cle_google_map");
function convert($chaine){
$avant = "àáâãäåòóôõöøèéêëçìíîïùúûüÿñÁÂÀÅÃÄÇÉÊÈËÓÔÒØÕÖÚÛÙÜ&";
$apres = "aaaaaaooooooeeeeciiiiuuuuynaaaaaaceeeeoooooouuuu-";
$chaine = strtolower($chaine);
$chaine = strtr($chaine, $avant, $apres);
return $chaine;
}
$france = 0;
if(! $_GET['cp']){
$_GET['cp'] = "France";
$france = 1;
}
$rec = file_get_contents("http://maps.google.fr/maps/geo?q=". $_GET['cp']."&output=csv&key=" . $cle->valeur);
$coord = explode(",", $rec);
$lat = $coord[2] ;
$lon = $coord[3];
$magasin = new Magasin();
if(! $france)
$query = "select * from $magasin->table where cp=\"" . $_GET['cp'] . "\" and lat<>'' and lon<>''";
else
$query = "select * from $magasin->table";
$resul = mysql_query($query, $magasin->link);
header("Content-type: text/xml");
echo'<?xml version="1.0" encoding="iso-8859-1"?>';
echo '<markers>';
while($row = mysql_fetch_object($resul)){
$row->adresse = convert($row->adresse);
$row->nom = convert($row->nom);
if(! $row->lat){
$row->lat = $lat;
$row->lon = $lon;
}
echo '<marker ';
echo 'id="' . $row->id . '" ';
echo 'nom="' . $row->nom . '" ';
echo 'adresse="' . $row->adresse . '" ';
echo 'cp="'. $row->cp . '" ';
echo 'ville="' . $row->ville . '" ';
echo 'tel="' . $row->tel . '" ';
echo 'fax="' . $row->tel . '" ';
echo 'lat="' . $row->lat . '" ';
echo 'lng="' . $row->lon . '" ';
echo '/>';
}
echo '</markers>';
?>

View File

@@ -0,0 +1,75 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Magasin</title>
<script src="http://maps.google.com/maps?file=api&v=2.89&key=#VARIABLE(cle_google_map)" type="text/javascript"></script>
<script type="text/javascript">
function loadCP(cp) {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
GDownloadUrl("#VARIABLE(urlsite)/client/plugins/magasin/template/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 id = markers[i].getAttribute("id");
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, id, name, address, codepostal, ville, tel, fax);
map.addOverlay(marker);
}
});
}
}
function createMarker(point, id, name, address, codepostal, ville, tel, fax) {
var marker = new GMarker(point,G_DEFAULT_ICON);
var html = "<img src='client/plugins/magasin/redimlive.php?nomorig=../../../client/gfx/magasin/"+id+".jpg&width=100' />" + "<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>
<script type="text/javascript">
var urlrefresh = "#VARIABLE(urlsite)/?fond=magasin&cp=";
</script>
</head>
<body onLoad="loadCP('#MAGASIN_CP')">
<select name="cp" onchange="location = urlrefresh + this.value;">
<option value="" >Code Postal</option>
<THELIA_cp type="MAGASIN" boucle="codepostal">
<option value="#CP" #SELECTED>#CP</option>
</THELIA_cp>
</select>
<div id="map" style="width: 475px; height: 475px"></div>
<THELIA_mag type="MAGASIN" boucle="magasin" cp="#MAGASIN_CP" largeur_image="200">
#NOM<br />
#ADRESSE<br />
#CP<br />
#VILLE<br />
#TEL<br />
<img src="#IMAGE" /> <br />
#FAX<br />
#LAT<br />
#LON<br /><hr /><br />
</THELIA_mag>
</body>
</html>

View File

@@ -0,0 +1,185 @@
<?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&eacute;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&eacute;es du magasin</a></span> <img src="gfx/suivant.gif" width="12" height="9" border="0" /></span></td>
</tr>
</table>
</div>