2004-10-19 22:35:36 +02:00
|
|
|
|
<?php
|
2002-05-11 19:19:18 +02:00
|
|
|
|
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
|
*
|
|
|
|
|
|
* 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.
|
|
|
|
|
|
*
|
2003-08-27 12:58:49 +02:00
|
|
|
|
* $Id$
|
|
|
|
|
|
* $Source$
|
|
|
|
|
|
*
|
2002-05-11 19:19:18 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
2003-09-11 22:18:51 +02:00
|
|
|
|
require("./pre.inc.php");
|
|
|
|
|
|
require("./reduc.class.php");
|
2002-05-11 19:19:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
llxHeader();
|
|
|
|
|
|
|
|
|
|
|
|
if ($action == 'add') {
|
|
|
|
|
|
|
2004-02-01 01:55:46 +01:00
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."voyage (date_depart, date_arrivee, amount, depart, arrivee, fk_reduc) ";
|
2002-05-11 19:19:18 +02:00
|
|
|
|
$sql .= " VALUES ('$date_depart','$date_arrivee',$amount,'$depart','$arrivee',$reduc);";
|
|
|
|
|
|
|
|
|
|
|
|
$result = $db->query($sql);
|
|
|
|
|
|
if ($result) {
|
|
|
|
|
|
$rowid = $db->last_insert_id();
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
print "<p>$sql";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if ($action == 'del') {
|
2004-02-01 01:55:46 +01:00
|
|
|
|
/* $sql = "DELETE FROM ".MAIN_DB_PREFIX."voyage WHERE rowid = $rowid";
|
2002-05-11 19:19:18 +02:00
|
|
|
|
*$result = $db->query($sql);
|
|
|
|
|
|
*/
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($vline) {
|
|
|
|
|
|
$viewline = $vline;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$viewline = 20;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-02-01 01:55:46 +01:00
|
|
|
|
$sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."voyage_reduc;";
|
2002-05-11 19:19:18 +02:00
|
|
|
|
$result = $db->query($sql);
|
|
|
|
|
|
if ($result) {
|
|
|
|
|
|
$var=True;
|
|
|
|
|
|
$num = $db->num_rows();
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
$options = "<option value=\"0\" SELECTED></option>";
|
|
|
|
|
|
while ($i < $num) {
|
2004-10-23 18:55:07 +02:00
|
|
|
|
$obj = $db->fetch_object($result);
|
2002-05-11 19:19:18 +02:00
|
|
|
|
$options .= "<option value=\"$obj->rowid\">$obj->label</option>\n"; $i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
$db->free();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print_titre("Bilan des reductions");
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Cartes
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-02-01 01:55:46 +01:00
|
|
|
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."voyage_reduc";
|
2002-05-11 19:19:18 +02:00
|
|
|
|
|
|
|
|
|
|
$result = $db->query($sql);
|
|
|
|
|
|
if ($result) {
|
|
|
|
|
|
$cartes= array();
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
while ($i < $num) {
|
2004-10-23 18:55:07 +02:00
|
|
|
|
$obj = $db->fetch_object($result);
|
2002-05-11 19:19:18 +02:00
|
|
|
|
$cartes[$i] = $obj->rowid;
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
$db->free;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
for ($j = 0 ; $j < sizeof($cartes) ; $j++) {
|
|
|
|
|
|
|
|
|
|
|
|
$reduc = new Reduc($db);
|
|
|
|
|
|
$reduc->fetch($cartes[$j]);
|
|
|
|
|
|
|
2004-08-29 21:03:50 +02:00
|
|
|
|
print "<table class=\border\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
|
|
|
|
|
|
print "<tr>";
|
|
|
|
|
|
print '<td colspan="2">'.$langs->trans("Description").'</td>';
|
|
|
|
|
|
print '<td align="right">Montant</td>';
|
|
|
|
|
|
print '<td> </td>';
|
|
|
|
|
|
print "</tr>\n";
|
2002-05-11 19:19:18 +02:00
|
|
|
|
|
|
|
|
|
|
print '<tr><td colspan="2">'.$reduc->label.'</td><td align="right">'.$reduc->price.'</td>';
|
|
|
|
|
|
print '<td> </TD></tr>';
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
$sql = "SELECT b.rowid,".$db->pdate("b.date_depart")." as date_depart,".$db->pdate("b.date_arrivee")." as date_arrivee, b.amount, b.depart, b.arrivee , b.reduction";
|
2004-02-01 01:55:46 +01:00
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."voyage as b WHERE fk_reduc=".$reduc->id." ORDER BY b.date_depart ASC";
|
2002-05-11 19:19:18 +02:00
|
|
|
|
|
|
|
|
|
|
$result = $db->query($sql);
|
|
|
|
|
|
if ($result) {
|
|
|
|
|
|
|
2004-08-29 21:03:50 +02:00
|
|
|
|
print "<tr class=\"liste_titre\">";
|
|
|
|
|
|
print '<td>Date</td><td>'.$langs->trans("Description").'</td>';
|
|
|
|
|
|
print "<td align=\"right\">Montant</td>";
|
2002-05-11 19:19:18 +02:00
|
|
|
|
print "<td align=\"right\">R<>duction</td>";
|
2004-08-29 21:03:50 +02:00
|
|
|
|
print "</tr>\n";
|
2002-05-11 19:19:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$var=True;
|
|
|
|
|
|
$num = $db->num_rows();
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
$total = 0;
|
|
|
|
|
|
$total_reduc = 0;
|
|
|
|
|
|
|
|
|
|
|
|
while ($i < $num) {
|
2004-10-23 18:55:07 +02:00
|
|
|
|
$objp = $db->fetch_object($result);
|
2002-05-11 19:19:18 +02:00
|
|
|
|
$total = $total + $objp->amount;
|
|
|
|
|
|
$total_reduc = $total_reduc + $objp->reduction;
|
|
|
|
|
|
$time = time();
|
|
|
|
|
|
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
|
|
|
|
|
|
print "<tr $bc[$var]>";
|
|
|
|
|
|
print "<td>".strftime("%d %b %y %H:%M",$objp->date_depart)."<br>\n";
|
|
|
|
|
|
print "".strftime("%d %b %y %H:%M",$objp->date_arrivee)."</TD>\n";
|
|
|
|
|
|
|
|
|
|
|
|
print "<td>$objp->depart<br>$objp->arrivee</td>";
|
|
|
|
|
|
|
|
|
|
|
|
print "<td align=\"right\">".price($objp->amount)."</TD>\n";
|
|
|
|
|
|
print "<td align=\"right\">".price($objp->reduction)."</TD>\n";
|
|
|
|
|
|
|
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
$db->free();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print "<tr><td align=\"right\" colspan=\"2\">Total :</td>";
|
|
|
|
|
|
print "<td align=\"right\"><b>".price($total)."</b></td><td align=\"right\">".price($total_reduc)."</td></tr>\n";
|
|
|
|
|
|
|
|
|
|
|
|
print "<tr><td align=\"right\" colspan=\"3\">Carte :</td>";
|
|
|
|
|
|
print "<td align=\"right\">".price($reduc->price)."</td></tr>\n";
|
|
|
|
|
|
|
|
|
|
|
|
print "<tr><td align=\"right\" colspan=\"3\">Gain :</td>";
|
|
|
|
|
|
print "<td align=\"right\">".price($total_reduc - $reduc->price)."</td></tr>\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print "</table>";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
print "<p>".$db->error();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
|
|
|
|
|
|
|
|
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
|
|
|
|
|
?>
|