1291 lines
32 KiB
PHP
1291 lines
32 KiB
PHP
<?php
|
|
include_once("_inc/config.php");
|
|
$GLOBALS["section"] = "pharmacies";
|
|
$file = $_SERVER["SCRIPT_NAME"];
|
|
$break = explode('/', $file);
|
|
$pfile = $break[count($break) - 1];
|
|
|
|
if(isset($_REQUEST["export"]))
|
|
{
|
|
include('_inc/classes/FichierExcel.php');
|
|
|
|
function suppRetours($s)
|
|
{
|
|
return str_replace( array( '<br>', '<br />', "\n", "\r" ), array( ' ', ' ', ' ', ' ' ), $s );
|
|
}
|
|
|
|
$fichier = new FichierExcel();
|
|
$fichier->Colonne(strtoupper("CIP;CODE CLIENT;PHARMACIE;PASSWORD;ADRESSE;CP;VILLE;TEL;E-MAIL;CDM;CODE SECTEUR;DATE INSCRIPTION ESPACE PHARMACIE;AMBASSADEUR;NOM;PRENOM;DATE DE NAISSANCE;PORTABLE;E-MAIL;ENGAGEMENT 1;ENGAGEMENT 2;ENGAGEMENT 3;GROUPT;GROUPT2"));
|
|
$items = getPharmacies(0,9999999);
|
|
|
|
foreach($items as $item)
|
|
{
|
|
$date = $item->date;
|
|
if($item->password == "") $date = "";
|
|
$engagement1 = "non";
|
|
$engagement2 = "non";
|
|
$engagement3 = "non";
|
|
|
|
$query = "SELECT * FROM `".$GLOBALS['sql_prefixe']."parcours` WHERE `pharmacie_id` = '".$item -> id."' AND `engagement_id` = '1' ";
|
|
$result = mysql_query($query);
|
|
if(mysql_num_rows($result) > 0)
|
|
$engagement1 = "oui";
|
|
|
|
$query = "SELECT * FROM `".$GLOBALS['sql_prefixe']."parcours` WHERE `pharmacie_id` = '".$item -> id."' AND `engagement_id` = '2' ";
|
|
$result = mysql_query($query);
|
|
if(mysql_num_rows($result) > 0)
|
|
$engagement2 = "oui";
|
|
|
|
$query = "SELECT * FROM `".$GLOBALS['sql_prefixe']."parcours` WHERE `pharmacie_id` = '".$item -> id."' AND `engagement_id` = '3' ";
|
|
$result = mysql_query($query);
|
|
if(mysql_num_rows($result) > 0)
|
|
$engagement3 = "oui";
|
|
|
|
|
|
|
|
$fichier->Insertion(
|
|
$item->CIP. ";".
|
|
'"'.$item->code_client.'"'.";".
|
|
$item->name.";".
|
|
$item->password_clear.";".
|
|
$item->address.";".
|
|
$item->cp.";".
|
|
$item->city.";".
|
|
$item->tel.";".
|
|
$item->email.";".
|
|
$item->mage." (".$item -> date_mage.");".
|
|
//$item->mage.";".
|
|
$item->secteur.";".
|
|
$date.";".
|
|
$item->ambassadeur.";".
|
|
$item->ambassadeur_lastname.";".
|
|
$item->ambassadeur_firstname.";".
|
|
$item->ambassadeur_birthdate.";".
|
|
$item->ambassadeur_mobile.";".
|
|
$item->ambassadeur_email.";".
|
|
//$item->ambassadeur_opt_sms.";".
|
|
//$item->ambassadeur_opt_email.";".
|
|
//$item->newsletter.";".
|
|
$engagement1.";".
|
|
$engagement2.";".
|
|
$engagement3.";".
|
|
$item->groupt.";".
|
|
$item->groupt2
|
|
);
|
|
}
|
|
$fichier->output('Pharmacies');
|
|
}
|
|
|
|
// ACTIONS
|
|
|
|
if(isset($_REQUEST["action"]))
|
|
{
|
|
header("Content-type: application/json");
|
|
echo '{"results":{';
|
|
include_once("_inc/classes/ImgUtil.php");
|
|
$imgUtil = new ImgUtil();
|
|
$tmpfilename = time();
|
|
$CURRET_TABLE = "pharmacies";
|
|
|
|
function genCIP()
|
|
{
|
|
$length = 7;
|
|
$characters = "0123456789";
|
|
$string = "";
|
|
|
|
for ($p = 0; $p < $length; $p++)
|
|
$string .= $characters[mt_rand(0, strlen($characters))];
|
|
|
|
return strtoupper($string);
|
|
}
|
|
|
|
|
|
switch($_REQUEST["action"])
|
|
{
|
|
case "saveFile" :
|
|
$filename = sqlEscape($_POST["filename"]);
|
|
if($filename != "")
|
|
{
|
|
include_once('_inc/classes/excel_reader2.php');
|
|
$xls_datas = new Spreadsheet_Excel_Reader("tmp/" . $filename);
|
|
|
|
$nbRows = $xls_datas -> rowcount();
|
|
|
|
$i = 2;
|
|
while($i <= $nbRows)
|
|
{
|
|
$CIP = sqlEscape($xls_datas -> val($i,1));
|
|
$code_client = sqlEscape($xls_datas -> val($i,2));
|
|
$len = strlen($code_client);
|
|
|
|
if($len == 3)
|
|
$code_client = "0000" . $code_client;
|
|
|
|
if($len == 4)
|
|
$code_client = "000" . $code_client;
|
|
|
|
if($len == 5)
|
|
$code_client = "00" . $code_client;
|
|
|
|
if($len == 6)
|
|
$code_client = "0" . $code_client;
|
|
|
|
$name = sqlEscape($xls_datas->val($i,3));
|
|
$address = sqlEscape($xls_datas->val($i,4));
|
|
$cp = sqlEscape($xls_datas->val($i,5));
|
|
$city = sqlEscape($xls_datas->val($i,6));
|
|
$tel = sqlEscape($xls_datas->val($i,7));
|
|
$email = sqlEscape($xls_datas->val($i,8));
|
|
$secteur = sqlEscape($xls_datas->val($i,9));
|
|
$mage = sqlEscape($xls_datas->val($i,10));
|
|
$ambassadeur = sqlEscape($xls_datas->val($i,11));
|
|
$ambassadeur_lastname = sqlEscape($xls_datas->val($i,12));
|
|
$ambassadeur_firstname = sqlEscape($xls_datas->val($i,13));
|
|
$ambassadeur_birthdate = sqlEscape($xls_datas->val($i,14));
|
|
$ambassadeur_mobile = sqlEscape($xls_datas->val($i,15));
|
|
$ambassadeur_email = sqlEscape($xls_datas->val($i,16));
|
|
|
|
$current_pharmacie = getPharmacieByCode($code_client);
|
|
|
|
|
|
|
|
if(isset($current_pharmacie -> id))
|
|
{
|
|
$query = "UPDATE `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."`
|
|
SET
|
|
`CIP` = '".$CIP."' ,
|
|
`secteur` = '".$secteur."' ,
|
|
`name` = '".$name."' ,
|
|
`address` = '".$address."' ,
|
|
`cp` = '".$cp."' ,
|
|
`city` = '".$city."' ,
|
|
`tel` = '".$tel."'
|
|
WHERE
|
|
`id` = '".$current_pharmacie -> id."';";
|
|
|
|
$result = mysql_query($query);
|
|
}
|
|
else
|
|
{
|
|
$query = "INSERT INTO `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."`
|
|
(`published`, `CIP`, `code_client`, `secteur`, `name`, `address`, `cp`, `city`, `tel`, `email`, `mage`,`ambassadeur`,`ambassadeur_lastname`,`ambassadeur_firstname`,`ambassadeur_birthdate`,`ambassadeur_mobile`,`ambassadeur_email`)
|
|
VALUES
|
|
('1', '".$CIP."', '".$code_client."', '".$secteur."', '".$name."', '".$address."', '".$cp."', '".$city."', '".$tel."', '".$email."', '".$mage."', '".$ambassadeur."', '".$ambassadeur_lastname."', '".$ambassadeur_firstname."', '".$ambassadeur_birthdate."', '".$ambassadeur_mobile."', '".$ambassadeur_email."');";
|
|
|
|
$result = mysql_query($query);
|
|
$id = mysql_insert_id();
|
|
}
|
|
$i++;
|
|
}
|
|
|
|
unlink("tmp/" . $filename);
|
|
echo '"complete":"1"';
|
|
recordLastUpdate();
|
|
}
|
|
else
|
|
{
|
|
echo '"error":"pas de fichier uploadé"';
|
|
}
|
|
break;
|
|
|
|
case "add" :
|
|
|
|
$published = sqlEscape($_POST["published"]);
|
|
$CIP = sqlEscape($_POST["CIP"]);
|
|
$code_client = sqlEscape($_POST["code_client"]);
|
|
$secteur = sqlEscape($_POST["secteur"]);
|
|
$name = sqlEscape($_POST["name"]);
|
|
$address = sqlEscape($_POST["address"]);
|
|
$cp = sqlEscape($_POST["cp"]);
|
|
$city = sqlEscape($_POST["city"]);
|
|
$tel = sqlEscape($_POST["tel"]);
|
|
$email = sqlEscape($_POST["email"]);
|
|
$mage = sqlEscape($_POST["mage"]);
|
|
$groupt = sqlEscape($_POST["groupt"]);
|
|
$groupt2 = sqlEscape($_POST["groupt2"]);
|
|
|
|
//génération aléatoire
|
|
$query = "INSERT INTO `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."`
|
|
(`published`, `CIP`, `code_client`, `secteur`, `name`, `address`, `cp`, `city`, `tel`, `email`, `mage`, `groupt`, `groupt2`)
|
|
VALUES
|
|
('".$published."', '".$CIP."', '".$code_client."', '".$secteur."', '".$name."', '".$address."', '".$cp."', '".$city."', '".$tel."', '".$email."', '".$mage."', '".$groupt."', '".$groupt2."');";
|
|
|
|
$result = mysql_query($query);
|
|
$id = mysql_insert_id();
|
|
echo '"complete":"1","id":"'.$id.'"';
|
|
recordLastUpdate();
|
|
break;
|
|
|
|
case "edit" :
|
|
$id = sqlEscape($_POST["id"]);
|
|
$published = sqlEscape($_POST["published"]);
|
|
$CIP = sqlEscape($_POST["CIP"]);
|
|
$code_client = sqlEscape($_POST["code_client"]);
|
|
$secteur = sqlEscape($_POST["secteur"]);
|
|
$name = sqlEscape($_POST["name"]);
|
|
$address = sqlEscape($_POST["address"]);
|
|
$cp = sqlEscape($_POST["cp"]);
|
|
$city = sqlEscape($_POST["city"]);
|
|
$tel = sqlEscape($_POST["tel"]);
|
|
$email = sqlEscape($_POST["email"]);
|
|
$mage = sqlEscape($_POST["mage"]);
|
|
|
|
|
|
$query = "UPDATE `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."`
|
|
SET
|
|
`published` = '".$published."' ,
|
|
`CIP` = '".$CIP."' ,
|
|
`code_client` = '".$code_client."' ,
|
|
`secteur` = '".$secteur."' ,
|
|
`name` = '".$name."' ,
|
|
`address` = '".$address."' ,
|
|
`cp` = '".$cp."' ,
|
|
`city` = '".$city."' ,
|
|
`tel` = '".$tel."' ,
|
|
`email` = '".$email."' ,
|
|
`mage` = '".$mage."'
|
|
WHERE
|
|
`id` = '".$id."' ;";
|
|
|
|
$result = mysql_query($query);
|
|
echo '"complete":"1","id":"'.$id.'"';
|
|
recordLastUpdate();
|
|
break;
|
|
|
|
case "delete" :
|
|
|
|
$ids = $_REQUEST["ids"];
|
|
|
|
if(isset($_GET["ids"]))
|
|
$ids = explode(",",$_GET["ids"]);
|
|
|
|
$nbIds = sizeof($ids);
|
|
|
|
$i = 0;
|
|
while($i <= $nbIds-1)
|
|
{
|
|
$id = $ids[$i];
|
|
$query = "SELECT * FROM `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."` WHERE `id` = '".$id."' ";
|
|
$results = mysql_query($query);
|
|
$item = mysql_fetch_object($results);
|
|
$query = "DELETE FROM `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."` WHERE `id` = '".$id."' ";
|
|
$result = mysql_query($query);
|
|
$i++;
|
|
}
|
|
echo '"complete":"1"';
|
|
break;
|
|
|
|
case "switchPublished" :
|
|
$id = $_REQUEST["id"];
|
|
$query = "SELECT * FROM `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."` WHERE `id` = '".$id."' ";
|
|
$results = mysql_query($query);
|
|
$item = mysql_fetch_object($results);
|
|
$newStatus = 1;
|
|
|
|
if($item -> published == 1)
|
|
$newStatus = 0;
|
|
|
|
$query = "UPDATE `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."`
|
|
SET
|
|
`published` = '".$newStatus."'
|
|
WHERE
|
|
`id` = '".$id."' ;";
|
|
|
|
$result = mysql_query($query);
|
|
|
|
if($result)
|
|
{
|
|
echo '"complete":"1"';
|
|
recordLastUpdate();
|
|
}
|
|
else
|
|
{
|
|
echo '"error":"mise à jour impossible"';
|
|
}
|
|
break;
|
|
|
|
case "publish" :
|
|
$ids = $_REQUEST["ids"];
|
|
$query = "UPDATE `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."`
|
|
SET
|
|
`published` = '1'
|
|
WHERE
|
|
`id` = '".$ids[0]."' ";
|
|
|
|
$i = 1;
|
|
$nbIds = sizeof($ids);
|
|
while($i <= $nbIds-1)
|
|
{
|
|
$query .= " OR `id` = '".$ids[$i]."' ";
|
|
$i++;
|
|
}
|
|
|
|
$result = mysql_query($query);
|
|
|
|
if($result){
|
|
echo '"complete":"1"';
|
|
recordLastUpdate();
|
|
}else{
|
|
echo '"error":"mise à jour impossible"';
|
|
}
|
|
break;
|
|
|
|
case "unpublish" :
|
|
$ids = $_REQUEST["ids"];
|
|
$query = "UPDATE `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."`
|
|
SET
|
|
`published` = '0'
|
|
WHERE
|
|
`id` = '".$ids[0]."' ";
|
|
|
|
$i = 1;
|
|
$nbIds = sizeof($ids);
|
|
while($i <= $nbIds-1)
|
|
{
|
|
$query .= " OR `id` = '".$ids[$i]."' ";
|
|
$i++;
|
|
}
|
|
|
|
$result = mysql_query($query);
|
|
|
|
if($result){
|
|
echo '"complete":"1"';
|
|
recordLastUpdate();
|
|
}else{
|
|
echo '"error":"mise à jour impossible"';
|
|
}
|
|
break;
|
|
|
|
case "update" :
|
|
$ids = $_REQUEST["ids"];
|
|
$varName = $_REQUEST["varName"];
|
|
$value = $_REQUEST["value"];
|
|
|
|
if(isset($_GET["ids"]))
|
|
$ids = explode(",",$_GET["ids"]);
|
|
|
|
$query = "UPDATE `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."`
|
|
SET
|
|
`".$varName."` = '".$value."'
|
|
WHERE
|
|
`id` = '".$ids[0]."' ";
|
|
|
|
$i = 1;
|
|
$nbIds = sizeof($ids);
|
|
while($i <= $nbIds-1)
|
|
{
|
|
$query .= " OR `id` = '".$ids[$i]."' ";
|
|
$i++;
|
|
}
|
|
|
|
$result = mysql_query($query);
|
|
|
|
if($result)
|
|
{
|
|
echo '"complete":"1"';
|
|
recordLastUpdate();
|
|
}
|
|
else
|
|
{
|
|
echo '"error":"mise à jour impossible"';
|
|
}
|
|
break;
|
|
|
|
|
|
case "up" :
|
|
$id = $_REQUEST["id"];
|
|
|
|
$query = "SELECT * FROM `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."` WHERE `id` = '".$id."' ";
|
|
$results = mysql_query($query);
|
|
$item = mysql_fetch_object($results);
|
|
|
|
$query = "UPDATE `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."` SET `position` = '".$item->position."' WHERE `position` = '".($item->position-1)."' ";
|
|
$result = mysql_query($query);
|
|
$query = "UPDATE `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."` SET `position` = '".($item->position-1)."' WHERE `id` = '".$id."' ";
|
|
$result = mysql_query($query);
|
|
|
|
if($result)
|
|
echo '"complete":"1"';
|
|
else
|
|
echo '"error":"mise à jour impossible"';
|
|
|
|
break;
|
|
|
|
case "down" :
|
|
$id = $_REQUEST["id"];
|
|
|
|
$query = "SELECT * FROM `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."` WHERE `id` = '".$id."' ";
|
|
$results = mysql_query($query);
|
|
$item = mysql_fetch_object($results);
|
|
|
|
|
|
$query = "UPDATE `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."` SET `position` = '".$item->position."' WHERE `position` ='".($item->position+1)."' ";
|
|
$result = mysql_query($query);
|
|
$query = "UPDATE `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."` SET `position` = '".($item->position+1)."' WHERE `id` = '".$id."' ";
|
|
$result = mysql_query($query);
|
|
|
|
if($result)
|
|
echo '"complete":"1"';
|
|
else
|
|
echo '"error":"mise à jour impossible"';
|
|
|
|
break;
|
|
|
|
case "desactivation" :
|
|
$id = $_REQUEST["id"];
|
|
|
|
$query = "UPDATE `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."` SET `password` = '' WHERE `id` = '".$id."' ";
|
|
$result = mysql_query($query);
|
|
|
|
if($result)
|
|
echo '"complete":"1"';
|
|
else
|
|
echo '"error":"mise à jour impossible"';
|
|
|
|
break;
|
|
|
|
|
|
case "getItemInfos" :
|
|
$id = $_REQUEST["id"];
|
|
$query = "SELECT * FROM `".$GLOBALS['sql_prefixe'].$CURRET_TABLE."` WHERE `id` = '".$id."' ";
|
|
|
|
$result = mysql_query($query);
|
|
|
|
if($result)
|
|
{
|
|
echo '"complete":"1"';
|
|
echo ',"datas":{"id":"'.$id.'"';
|
|
$rows = mysql_fetch_assoc($result);
|
|
foreach($rows as $key => $value)
|
|
echo ',"'.$key.'":"'.parseJson($value).'"';
|
|
|
|
echo '}';
|
|
}
|
|
else
|
|
{
|
|
echo '"error":"données introuvables"';
|
|
}
|
|
break;
|
|
}
|
|
echo "}}";
|
|
exit();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
$festival_id = -1;
|
|
|
|
if(isset($_GET['festival_id'])){
|
|
$festival_id = $_GET['festival_id'];
|
|
}
|
|
|
|
|
|
/*-------------------------------------------------------------*/
|
|
include_once("_inc/assets/head.php");
|
|
/*-------------------------------------------------------------*/
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="blockFile xls">
|
|
<div class="loader"><img src="_img/animated_loader.gif" alt="loader" class="loader" /></div>
|
|
<div class="title">Importer les données depuis un fichier (XLS) </div>
|
|
<div class="inner">
|
|
|
|
<div class="file">
|
|
<input type="hidden" name="recap_filename" value="" />
|
|
<input type="file" id="file_upload_recap" />
|
|
<script type="text/javascript">
|
|
// $(function() {
|
|
// $("#file_upload_recap").uploadify({
|
|
// 'method' : 'post',
|
|
// 'multi' : false,
|
|
// 'buttonText' : 'Parcourir...',
|
|
// 'fileSizeLimit' : '0',
|
|
// 'height' : '20',
|
|
// 'width' : '100',
|
|
// 'removeCompleted' : true,
|
|
// 'fileTypeExts' : '*.xls',
|
|
// 'formData' : { 'filename' : (new Date().getTime() + Math.random()*1000) } ,
|
|
// 'swf' : 'uploadify/uploadify.swf',
|
|
// 'uploader' : 'uploadify/uploadify.php',
|
|
// 'onUploadSuccess' : function(file, data, response) {
|
|
// var fileName = data;
|
|
// $(".blockFile input[name='recap_filename']").val(fileName);
|
|
// $(".blockFile .save").attr("disabled",null);
|
|
// $(".blockFile .save").css("opacity",1);
|
|
// }
|
|
// });
|
|
});
|
|
</script>
|
|
</div>
|
|
<div>
|
|
<input type="submit" value="Mettre à jour" class="save" disabled="disabled" />
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script type="application/javascript">
|
|
$(".blockFile .save").click(function(e) {
|
|
$(".blockFile .loader").css("display","block");
|
|
$(".blockFile .save").attr("disabled","disabled");
|
|
|
|
var datas = {};
|
|
|
|
datas.action = "saveFile";
|
|
datas.filename = $(".blockFile input[name='recap_filename']").val();
|
|
|
|
$.ajax({
|
|
url: "pharmacies.php",
|
|
dataType: 'json',
|
|
data: datas,
|
|
type: 'POST',
|
|
success: function(){
|
|
$(".blockFile .loader").css("display","none");
|
|
$(".blockFile .save").attr("disabled","disabled");
|
|
$(".blockFile .save").css("opacity",0.3);
|
|
reloadList();
|
|
},
|
|
error: onDatasError
|
|
});
|
|
|
|
});
|
|
</script>
|
|
|
|
|
|
|
|
<div id="subNav">
|
|
<a href="pharmacies.php" class="selected">les pharmacies</a>
|
|
<a href="mod_masse_amb.php">Modification des statuts</a>
|
|
</div>
|
|
|
|
|
|
<h1>Les pharmacies</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="editForm" id="addForm" >
|
|
<h2>Ajouter un élément</h2>
|
|
|
|
<div class="line">
|
|
<label>CIP : </label>
|
|
<input type="text" class="saisie" name="CIP" value="" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>code client : </label>
|
|
<input type="text" class="saisie" name="code_client" value="" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>secteur : </label>
|
|
<input type="text" class="saisie" name="secteur" value="" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>nom : </label>
|
|
<input type="text" class="saisie" name="name" value="" style="width:500px;" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>adresse : </label>
|
|
<input type="text" class="saisie" name="address" value="" style="width:500px;" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>code postal : </label>
|
|
<input type="text" class="saisie" name="cp" value="" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>ville : </label>
|
|
<input type="text" class="saisie" name="city" value="" style="width:500px;" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>téléphone : </label>
|
|
<input type="text" class="saisie" name="tel" value="" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>email : </label>
|
|
<input type="text" class="saisie" name="email" value="" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>C. des mages</label>
|
|
<input type="checkbox" name="mage" value="1" /> oui
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>Publié</label>
|
|
<input type="checkbox" name="published" value="1" checked="checked" /> oui
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>groupt : </label>
|
|
<input type="text" class="saisie" name="groupt" value="" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>groupt2 : </label>
|
|
<input type="text" class="saisie" name="groupt2" value="" />
|
|
</div>
|
|
|
|
<div class="actions">
|
|
<img src="_img/animated_loader.gif" alt="loading" class="formLoader" />
|
|
<input type="submit" name="sendAdd" value="créer" class="send" />
|
|
<input type="button" value="annuler" name="cancel" class="cancel" />
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="editForm" id="editForm" >
|
|
<h2>Mettre à jour de l'élément</h2>
|
|
|
|
<input type="hidden" name="id" value="" />
|
|
|
|
<div class="line">
|
|
<label>CIP : </label>
|
|
<input type="text" class="saisie" name="CIP" value="" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>code client : </label>
|
|
<input type="text" class="saisie" name="code_client" value="" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>secteur : </label>
|
|
<input type="text" class="saisie" name="secteur" value="" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>nom : </label>
|
|
<input type="text" class="saisie" name="name" value="" style="width:500px;" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>adresse : </label>
|
|
<input type="text" class="saisie" name="address" value="" style="width:500px;" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>code postal : </label>
|
|
<input type="text" class="saisie" name="cp" value="" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>ville : </label>
|
|
<input type="text" class="saisie" name="city" value="" style="width:500px;" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>téléphone : </label>
|
|
<input type="text" class="saisie" name="tel" value="" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>email : </label>
|
|
<input type="text" class="saisie" name="email" value="" />
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>C. des mages</label>
|
|
<input type="checkbox" name="mage" value="1" /> oui
|
|
</div>
|
|
|
|
<div class="line">
|
|
<label>Publié</label>
|
|
<input type="checkbox" name="published" value="1" checked="checked" /> oui
|
|
</div>
|
|
|
|
<div class="actions">
|
|
<img src="_img/animated_loader.gif" alt="loading" class="formLoader" />
|
|
<input type="submit" name="sendEdit" value="enregistrer" class="send" />
|
|
<input type="button" value="annuler" name="cancel" class="cancel" />
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="actionsPanel">
|
|
<input type="submit" value="Ajouter un élément" name="add" class="addLink" />
|
|
<input type="submit" value="Exporter les données" name="export" class="exportXLS" />
|
|
</div>
|
|
|
|
|
|
<!-- ######################### LIST ########################## -->
|
|
|
|
<div id="itemsList" class="itemsListContainer">
|
|
<div class="listPopins">
|
|
<div class="listPopin listLoader">
|
|
<span class="listLoaderTxt">chargement en cours...</span><br />
|
|
<img src="_img/animated_loader.gif" alt="loader" />
|
|
</div>
|
|
</div>
|
|
<div class="listContent"></div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
// --- export -- //
|
|
|
|
$(".exportXLS").click(function(e) {
|
|
document.location.href='?export=1';
|
|
});
|
|
|
|
// ------------------- SELECTION --------------------------- //
|
|
|
|
|
|
|
|
// ------------------- FORMULAIRES ------------------------- //
|
|
|
|
//var descriptionAdd = CKEDITOR.replace( 'descriptionAdd' );
|
|
//var categoryAdd = CKEDITOR.replace( 'categoryAdd' );
|
|
|
|
//var descriptionEdit = CKEDITOR.replace( 'descriptionEdit' );
|
|
//var categoryEdit = CKEDITOR.replace( 'categoryEdit' );
|
|
|
|
|
|
|
|
function closeForms(){
|
|
$(".editForm").slideUp(300);
|
|
//$(".editForm").css("display","none");
|
|
//TweenLite.to($(".editForm"), 0.2, {css:{height:0}});
|
|
}
|
|
|
|
function showAddForm(){
|
|
$("#addForm input").attr("disabled",null);
|
|
$("#addForm .formLoader").css("display","none");
|
|
|
|
//remise à zero des champs
|
|
|
|
$("#addForm .saisie").val('');
|
|
$("#addForm div.saisie").html('');
|
|
// $('#file_upload_add').uploadify('cancel','*');
|
|
$("#addForm .filename").val('');
|
|
$("#addForm .pdf_filename").val('');
|
|
$("#addForm .imgPreview").html("");
|
|
|
|
|
|
//$("#addForm input[name='color']").val("000000");
|
|
|
|
|
|
|
|
TweenLite.to($("#addForm"), 0.1, {css:{opacity:1}});
|
|
|
|
$("#editForm").slideUp(300);
|
|
$("#addForm").slideDown(300,function(){
|
|
$("body").scrollTo(245,400);
|
|
});
|
|
}
|
|
|
|
function showEditForm(){
|
|
$("#editForm input").attr("disabled",null);
|
|
$("#editForm .formLoader").css("display","none");
|
|
|
|
// $('#file_upload_edit').uploadify('cancel','*');
|
|
$("#editForm .filename").val('');
|
|
$("#editForm .pdf_filename").val('');
|
|
|
|
$("#editForm .imgPreview").html("");
|
|
|
|
TweenLite.to($("#editForm"), 0.1, {css:{opacity:1}});
|
|
|
|
$("#addForm").slideUp(300);
|
|
$("#editForm").slideDown(300,function(){
|
|
$("body").scrollTo(245,400);
|
|
});
|
|
}
|
|
|
|
$(".actionsPanel input[name='add']").click(showAddForm);
|
|
$(".editForm input[name='cancel']").click(closeForms);
|
|
|
|
/////////////////
|
|
|
|
$("#addForm input[name='sendAdd']").click(function(e) {
|
|
$("#addForm .formLoader").fadeIn(100);
|
|
$("#addForm input").attr("disabled","disabled");
|
|
TweenLite.to($("#addForm"), 0.2, {css:{opacity:0.6}});
|
|
|
|
var datas = {};
|
|
|
|
datas.action = "add";
|
|
datas.published = 0;
|
|
if( $("#addForm input[name='published']:checked").length > 0) {
|
|
datas.published = 1;
|
|
}
|
|
datas.nouveau = 0;
|
|
if( $("#addForm input[name='nouveau']:checked").length > 0) {
|
|
datas.nouveau = 1;
|
|
}
|
|
|
|
datas.mage = 0;
|
|
if( $("#addForm input[name='mage']:checked").length > 0) {
|
|
datas.mage = 1;
|
|
}
|
|
|
|
//boucle de base
|
|
$("#addForm input.saisie,#addForm input.textarea").each(function(index, element) {
|
|
datas[$(this).attr("name")] = $(this).val();
|
|
});
|
|
|
|
console.log(datas);
|
|
//datas.rubrique_id = $("#addForm select[name='rubrique_id'] option:selected").val();
|
|
/*
|
|
datas.filename = $("#addForm input[name='filename']").val();
|
|
datas.pdf_filename = $("#addForm input[name='pdf_filename']").val();
|
|
$("#addForm div.saisie").each(function(index, element) {
|
|
datas[$(this).attr("name")] = $(this).html();
|
|
});
|
|
*/
|
|
|
|
$.ajax({
|
|
url: "<?php echo $pfile; ?>",
|
|
dataType: 'json',
|
|
data: datas,
|
|
type: 'POST',
|
|
success: onAddComplete,
|
|
error: onDatasError
|
|
});
|
|
|
|
|
|
});
|
|
|
|
function onAddComplete($datas)
|
|
{
|
|
if($datas.results.complete == 1){
|
|
closeForms();
|
|
reloadList();
|
|
}else if($datas.results.error){
|
|
alert($datas.results.error);
|
|
}else{
|
|
alert("Erreur inconnue...");
|
|
}
|
|
}
|
|
|
|
|
|
$("#editForm input[name='sendEdit']").click(function(e) {
|
|
$("#editForm .formLoader").fadeIn(100);
|
|
$("#editForm input").attr("disabled","disabled");
|
|
TweenLite.to($("#editForm"), 0.2, {css:{opacity:0.6}});
|
|
|
|
var datas = {};
|
|
|
|
datas.action = "edit";
|
|
datas.id = $("#editForm input[name='id']").val();
|
|
datas.published = 0;
|
|
if( $("#editForm input[name='published']:checked").length > 0) {
|
|
datas.published = 1;
|
|
}
|
|
datas.mage = 0;
|
|
if( $("#editForm input[name='mage']:checked").length > 0) {
|
|
datas.mage = 1;
|
|
}
|
|
|
|
//boucle de base
|
|
$("#editForm input.saisie,#editForm input.textarea").each(function(index, element) {
|
|
datas[$(this).attr("name")] = $(this).val();
|
|
});
|
|
$("#editForm div.saisie").each(function(index, element) {
|
|
datas[$(this).attr("name")] = $(this).html();
|
|
});
|
|
|
|
/*
|
|
datas.filename = $("#editForm input[name='filename']").val();
|
|
datas.pdf_filename = $("#editForm input[name='pdf_filename']").val();
|
|
datas.nouveau = 0;
|
|
if( $("#editForm input[name='nouveau']:checked").length > 0) {
|
|
datas.nouveau = 1;
|
|
}
|
|
*/
|
|
|
|
//datas.rubrique_id = $("#editForm select[name='rubrique_id'] option:selected").val();
|
|
//datas.filename = $("#editForm input[name='filename']").val();
|
|
|
|
$.ajax({
|
|
url: "<?php echo $pfile; ?>",
|
|
dataType: 'json',
|
|
data: datas,
|
|
type: 'POST',
|
|
success: onEditComplete,
|
|
error: onDatasError
|
|
});
|
|
|
|
|
|
});
|
|
|
|
function onEditComplete($datas)
|
|
{
|
|
if($datas.results.complete == 1){
|
|
closeForms();
|
|
reloadList();
|
|
}else if($datas.results.error){
|
|
alert($datas.results.error);
|
|
}else{
|
|
alert("Erreur inconnue...");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
// ------------------- LISTE ------------------------- //
|
|
|
|
|
|
var currentListPage = 0;
|
|
var currentFilter = "";
|
|
function getList($page,$filter)
|
|
{
|
|
|
|
//var rubrique_id = $(".selectorPanel select[name='rubrique_id'] option:selected").val();
|
|
|
|
|
|
if(!$filter) $filter = "";
|
|
currentFilter = $filter;
|
|
currentListPage = $page;
|
|
loading();
|
|
$('#itemsList .listContent').load('_listes/pharmacies.php?page=' + $page + '&filter=' + $filter, function() {
|
|
loaded();
|
|
});
|
|
}
|
|
|
|
function getPage($page)
|
|
{
|
|
getList($page,currentFilter);
|
|
}
|
|
|
|
function loading($message)
|
|
{
|
|
if(!$message) $message = "Chargement en cours...";
|
|
$("#itemsList .listLoader .listLoaderTxt").html($message);
|
|
$("#itemsList .listLoader").fadeIn(500);
|
|
$("#itemsList .listContent").animate({opacity:0.3},200);
|
|
}
|
|
|
|
function loaded()
|
|
{
|
|
$("#itemsList .listLoader").fadeOut(200);
|
|
$("#itemsList .listContent").animate({opacity:1},400);
|
|
}
|
|
|
|
function reloadList(){
|
|
getList(currentListPage,currentFilter);
|
|
}
|
|
|
|
// ------------------- ACTIONS ------------------------- //
|
|
|
|
//suppression d'un élément
|
|
function deleteItems($itemsIds){
|
|
closeForms();
|
|
loading("suppression en cours...");
|
|
|
|
var datas = {};
|
|
datas.action = "delete";
|
|
datas.ids = $itemsIds;
|
|
|
|
$.ajax({
|
|
url: "<?php echo $pfile; ?>",
|
|
dataType: 'json',
|
|
data: datas,
|
|
type: 'POST',
|
|
success: onDatasComplete,
|
|
error: onDatasError
|
|
});
|
|
}
|
|
|
|
function switchPublished($itemId){
|
|
closeForms();
|
|
loading("traitement en cours...");
|
|
|
|
var datas = {};
|
|
datas.action = "switchPublished";
|
|
datas.id = $itemId;
|
|
|
|
$.ajax({
|
|
url: "<?php echo $pfile; ?>",
|
|
dataType: 'json',
|
|
data: datas,
|
|
type: 'POST',
|
|
success: onDatasComplete,
|
|
error: onDatasError
|
|
});
|
|
}
|
|
|
|
function publishItems($itemsIds){
|
|
closeForms();
|
|
loading("traitement en cours...");
|
|
|
|
var datas = {};
|
|
datas.action = "publish";
|
|
datas.ids = $itemsIds;
|
|
|
|
$.ajax({
|
|
url: "<?php echo $pfile; ?>",
|
|
dataType: 'json',
|
|
data: datas,
|
|
type: 'POST',
|
|
success: onDatasComplete,
|
|
error: onDatasError
|
|
});
|
|
}
|
|
|
|
function unpublishItems($itemsIds){
|
|
closeForms();
|
|
loading("traitement en cours...");
|
|
|
|
var datas = {};
|
|
datas.action = "unpublish";
|
|
datas.ids = $itemsIds;
|
|
|
|
$.ajax({
|
|
url: "<?php echo $pfile; ?>",
|
|
dataType: 'json',
|
|
data: datas,
|
|
type: 'POST',
|
|
success: onDatasComplete,
|
|
error: onDatasError
|
|
});
|
|
}
|
|
|
|
function update($itemsIds,$varName,$value){
|
|
closeForms();
|
|
loading("traitement en cours...");
|
|
|
|
var datas = {};
|
|
datas.action = "update";
|
|
datas.ids = $itemsIds;
|
|
datas.varName = $varName;
|
|
datas.value = $value;
|
|
|
|
$.ajax({
|
|
url: "<?php echo $pfile; ?>",
|
|
dataType: 'json',
|
|
data: datas,
|
|
type: 'POST',
|
|
success: onDatasComplete,
|
|
error: onDatasError
|
|
});
|
|
}
|
|
|
|
|
|
function itemUp($itemId){
|
|
closeForms();
|
|
loading("repositionnement en cours...");
|
|
|
|
var datas = {};
|
|
datas.action = "up";
|
|
datas.id = $itemId;
|
|
|
|
$.ajax({
|
|
url: "<?php echo $pfile; ?>",
|
|
dataType: 'json',
|
|
data: datas,
|
|
type: 'POST',
|
|
success: onDatasComplete,
|
|
error: onDatasError
|
|
});
|
|
}
|
|
|
|
function desactivation($itemId){
|
|
closeForms();
|
|
loading("désactivation en cours...");
|
|
|
|
var datas = {};
|
|
datas.action = "desactivation";
|
|
datas.id = $itemId;
|
|
|
|
$.ajax({
|
|
url: "<?php echo $pfile; ?>",
|
|
dataType: 'json',
|
|
data: datas,
|
|
type: 'POST',
|
|
success: onDatasComplete,
|
|
error: onDatasError
|
|
});
|
|
}
|
|
|
|
function itemDown($itemId){
|
|
closeForms();
|
|
loading("repositionnement en cours...");
|
|
|
|
var datas = {};
|
|
datas.action = "down";
|
|
datas.id = $itemId;
|
|
|
|
$.ajax({
|
|
url: "<?php echo $pfile; ?>",
|
|
dataType: 'json',
|
|
data: datas,
|
|
type: 'POST',
|
|
success: onDatasComplete,
|
|
error: onDatasError
|
|
});
|
|
}
|
|
|
|
function editItem($id){
|
|
closeForms();
|
|
loading("traitement en cours...");
|
|
|
|
var datas = {};
|
|
datas.action = "getItemInfos";
|
|
datas.id = $id;
|
|
|
|
$.ajax({
|
|
url: "<?php echo $pfile; ?>",
|
|
dataType: 'json',
|
|
data: datas,
|
|
type: 'POST',
|
|
success: onDatasEditForm,
|
|
error: onDatasError
|
|
});
|
|
}
|
|
|
|
function onDatasEditForm($datas){
|
|
if($datas.results.complete == 1){
|
|
$formDatas = $datas.results.datas;
|
|
|
|
$("#editForm input[name='id']").val($formDatas.id);
|
|
if($formDatas.published == 1){
|
|
$("#editForm input[name='published']").attr("checked","checked");
|
|
}else{
|
|
$("#editForm input[name='published']").attr("checked",null);
|
|
}
|
|
|
|
//boucle de base
|
|
for (var prop in $formDatas)
|
|
{
|
|
var element = $("#editForm *[name='"+prop+"']");
|
|
if(element.length > 0){
|
|
var tagName = element.get(0).tagName.toLowerCase();
|
|
if(tagName == "div"){
|
|
$("#editForm *[name='"+prop+"']").html($formDatas[prop]);
|
|
}else{
|
|
$("#editForm *[name='"+prop+"']").val($formDatas[prop]);
|
|
}
|
|
}
|
|
}
|
|
|
|
if($formDatas.nouveau == 1){
|
|
$("#editForm input[name='nouveau']").attr("checked","checked");
|
|
}else{
|
|
$("#editForm input[name='nouveau']").attr("checked",null);
|
|
}
|
|
|
|
if($formDatas.mage == 1){
|
|
$("#editForm input[name='mage']").attr("checked","checked");
|
|
}else{
|
|
$("#editForm input[name='mage']").attr("checked",null);
|
|
}
|
|
|
|
loaded();
|
|
showEditForm();
|
|
|
|
//visuel
|
|
//$("#editForm .imgPreview").html("<img src='../files/produits/thumbs/" + $formDatas.id + ".jpg'>");
|
|
|
|
}else if($datas.results.error){
|
|
alert($datas.results.error);
|
|
}else{
|
|
alert("Erreur inconnue...");
|
|
}
|
|
}
|
|
|
|
|
|
function infosItem($id){
|
|
|
|
closeForms();
|
|
|
|
loading("traitement en cours...");
|
|
|
|
var datas = {};
|
|
datas.action = "getItemInfos";
|
|
datas.id = $id;
|
|
|
|
$.ajax({
|
|
url: "<?php echo $pfile; ?>",
|
|
dataType: 'json',
|
|
data: datas,
|
|
type: 'POST',
|
|
success: onDatasInfosForm,
|
|
error: onDatasError
|
|
});
|
|
}
|
|
|
|
function onDatasInfosForm($datas){
|
|
|
|
|
|
if($datas.results.complete == 1){
|
|
|
|
$datas = $datas.results.datas;
|
|
|
|
$("#id").val($datas.id);
|
|
|
|
$("#infosForm .code").html($datas.code);
|
|
$("#infosForm .date").html($datas.date);
|
|
$("#infosForm .email").html($datas.email);
|
|
|
|
loaded();
|
|
Shadowbox.setup();
|
|
|
|
$("#infosForm").slideDown(300,function(){
|
|
onResize();
|
|
$("body").scrollTo(245,400);
|
|
});
|
|
}else if($datas.results.error){
|
|
alert($datas.results.error);
|
|
}else{
|
|
alert("Erreur inconnue...");
|
|
}
|
|
}
|
|
|
|
function onDatasComplete($datas)
|
|
{
|
|
if($datas.results.complete == 1){
|
|
reloadList();
|
|
}else if($datas.results.error){
|
|
alert($datas.results.error);
|
|
}else{
|
|
alert("Erreur inconnue...");
|
|
}
|
|
}
|
|
|
|
function onDatasError(jqXHR, textStatus, errorThrown)
|
|
{
|
|
alert("error : " + textStatus);
|
|
loaded();
|
|
}
|
|
|
|
|
|
// ------------------- INIT ------------------------- //
|
|
getList(0);
|
|
|
|
</script>
|
|
|
|
<!-- ########################################################## -->
|
|
|
|
|
|
<?php
|
|
/*-------------------------------------------------------------*/
|
|
include_once("_inc/assets/footer.php");
|
|
/*-------------------------------------------------------------*/
|
|
?>
|