154 lines
4.0 KiB
PHP
154 lines
4.0 KiB
PHP
<?php
|
|
/**
|
|
* @file
|
|
* Liste des prix
|
|
*
|
|
*/
|
|
setDbConn('graydon');
|
|
$q = Doctrine_Query::create($conn)
|
|
->from('Price p')
|
|
->leftJoin('p.Country c');
|
|
$results = $q->fetchArray();
|
|
|
|
$view = arg(2,$_REQUEST['q']);
|
|
switch ($view) {
|
|
|
|
case "multiplier" :
|
|
|
|
if (sizeof($_POST) > 0) {
|
|
|
|
$frm = $_POST;
|
|
$frm['immediate'] = str_replace(',', '.', $frm['immediate']);
|
|
$frm['normal'] = str_replace(',', '.', $frm['normal']);
|
|
$frm['superflash'] = str_replace(',', '.', $frm['superflash']);
|
|
|
|
if(is_numeric($frm['immediate']) || is_numeric($frm['normal']) || is_numeric($frm['superflash'])) {
|
|
|
|
multiplier($frm);
|
|
header("Location:".$_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
/******************************************************************************
|
|
* FONCTIONS
|
|
*****************************************************************************/
|
|
function multiplier($frm) {
|
|
|
|
/*
|
|
* Multiplie les valeurs des colonnes.
|
|
* Les champs sont dans la variable $frm
|
|
*
|
|
*/
|
|
|
|
$immediate = is_numeric($frm['immediate']) ? $frm['immediate'] : "";
|
|
$normal = is_numeric($frm['normal']) ? $frm['normal'] : "";
|
|
$superflash = is_numeric($frm['superflash']) ? $frm['superflash'] : "";
|
|
|
|
include("../mysql_inc.php");
|
|
|
|
$sql = "SELECT id, immediate, normal, superflash FROM price";
|
|
$result = mysql_query($sql) or die("Une erreur de connexion à la base s'est produite " . __LINE__ . ".<p></p>" . mysql_error());
|
|
|
|
while($col = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
|
|
|
if (!is_numeric($immediate) or !is_numeric($col['immediate'])) {
|
|
$result_immediate = $col['immediate'];
|
|
}
|
|
else {
|
|
$result_immediate = ($immediate * $col['immediate']);
|
|
}
|
|
|
|
if (!is_numeric($normal) or !is_numeric($col['normal'])) {
|
|
$result_normal = $col['normal'];
|
|
}
|
|
else {
|
|
$result_normal = ($normal * $col['normal']);
|
|
}
|
|
|
|
if (!is_numeric($superflash) or !is_numeric($col['superflash'])) {
|
|
$result_superflash = $col['superflash'];
|
|
}
|
|
else {
|
|
$result_superflash = ($superflash * $col['superflash']);
|
|
}
|
|
|
|
$sql = "UPDATE price
|
|
SET
|
|
immediate = '$result_immediate'
|
|
, normal = '$result_normal'
|
|
, superflash = '$result_superflash'
|
|
WHERE id = '".$col['id']."'
|
|
";
|
|
|
|
mysql_query($sql);
|
|
}
|
|
|
|
|
|
mysql_free_result($result);
|
|
mysql_close($connexion);
|
|
}
|
|
|
|
?>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('.immediate').editable('./modules/graydon/pricesave.php', {
|
|
event : "dblclick",
|
|
indicator : 'Sauvegarde...',
|
|
tooltip : 'Double-Clique pour éditer...',
|
|
submitdata : {col: "immediate"}
|
|
});
|
|
|
|
$('.normal').editable('./modules/graydon/pricesave.php', {
|
|
event : "dblclick",
|
|
indicator : 'Sauvegarde...',
|
|
tooltip : 'Double-Clique pour éditer...',
|
|
submitdata : {col: "normal"}
|
|
});
|
|
|
|
$('.superflash').editable('./modules/graydon/pricesave.php', {
|
|
event : "dblclick",
|
|
indicator : 'Sauvegarde...',
|
|
tooltip : 'Double-Clique pour éditer...',
|
|
submitdata : {col: "superflash"}
|
|
});
|
|
});
|
|
</script>
|
|
<style type="text/css">
|
|
table td {border-bottom:#ccc 1px solid; margin:0; padding:0;}
|
|
</style>
|
|
|
|
<table>
|
|
<tr>
|
|
<th>Pays</th>
|
|
<th>Immediate</th>
|
|
<th>Normal</th>
|
|
<th>Superflash</th>
|
|
</tr>
|
|
<?php
|
|
foreach($results as $prix){
|
|
?>
|
|
<tr>
|
|
<td><?php print $prix['Country']['graydon_country'];?></td>
|
|
<td align="center"><div id="<?php print $prix['id'];?>" class="immediate"><?php print $prix['immediate'];?></div></td>
|
|
<td align="center"><div id="<?php print $prix['id'];?>" class="normal"><?php print $prix['normal'];?></div></td>
|
|
<td align="center"><div id="<?php print $prix['id'];?>" class="superflash"><?php print $prix['superflash'];?></div></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
<tr>
|
|
<form name="multcol" action="./?q=graydon/prix/multiplier" method="post">
|
|
<td>Multiplier les prix par</td>
|
|
<td>x <input type="text" name="immediate" value="" size="2"/></td>
|
|
<td>x <input type="text" name="normal" value="" size="2"/></td>
|
|
<td>x <input type="text" name="superflash" value="" size="2"/></td>
|
|
<td><input type="submit" name="submit"/></td>
|
|
</form>
|
|
</tr>
|
|
</table>
|
|
<?php
|
|
|
|
|
|
?>
|