From c708213b0168d47dc4a167c69f9e7d3078bcc8b0 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Sat, 11 May 2002 17:19:18 +0000 Subject: [PATCH] *** empty log message *** --- htdocs/compta/voyage/bilan.php3 | 178 ++++++++++++++++++++++++++ htdocs/compta/voyage/index.php3 | 154 ++++++++++++++++++++++ htdocs/compta/voyage/pre.inc.php3 | 50 ++++++++ htdocs/compta/voyage/reduc.class.php3 | 58 +++++++++ htdocs/compta/voyage/reduc.php3 | 84 ++++++++++++ mysql/tables/llx_voyage.sql | 47 +++++++ 6 files changed, 571 insertions(+) create mode 100644 htdocs/compta/voyage/bilan.php3 create mode 100644 htdocs/compta/voyage/index.php3 create mode 100644 htdocs/compta/voyage/pre.inc.php3 create mode 100644 htdocs/compta/voyage/reduc.class.php3 create mode 100644 htdocs/compta/voyage/reduc.php3 create mode 100644 mysql/tables/llx_voyage.sql diff --git a/htdocs/compta/voyage/bilan.php3 b/htdocs/compta/voyage/bilan.php3 new file mode 100644 index 00000000000..4264de9aee3 --- /dev/null +++ b/htdocs/compta/voyage/bilan.php3 @@ -0,0 +1,178 @@ + + * + * $Id$ + * $Source$ + * + * 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. + * + */ + +require("./pre.inc.php3"); +require("./reduc.class.php3"); + + +llxHeader(); +$db = new Db(); + +if ($action == 'add') { + $author = $GLOBALS["REMOTE_USER"]; + + $sql = "INSERT INTO llx_voyage (date_depart, date_arrivee, amount, depart, arrivee, fk_reduc) "; + $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 "

$sql"; + } + +} +if ($action == 'del') { + /* $sql = "DELETE FROM llx_voyage WHERE rowid = $rowid"; + *$result = $db->query($sql); + */ +} + +if ($vline) { + $viewline = $vline; +} else { + $viewline = 20; +} + +$sql = "SELECT rowid, label FROM llx_voyage_reduc;"; +$result = $db->query($sql); +if ($result) { + $var=True; + $num = $db->num_rows(); + $i = 0; + $options = ""; + while ($i < $num) { + $obj = $db->fetch_object($i); + $options .= "\n"; $i++; + } + $db->free(); +} + + +print_titre("Bilan des reductions"); +/* + * Cartes + * + */ +$sql = "SELECT rowid FROM llx_voyage_reduc"; + +$result = $db->query($sql); +if ($result) { + $cartes= array(); + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($i); + $cartes[$i] = $obj->rowid; + $i++; + } + $db->free; +} +/* + * + */ + +for ($j = 0 ; $j < sizeof($cartes) ; $j++) { + + $reduc = new Reduc($db); + $reduc->fetch($cartes[$j]); + + print ""; + print ""; + print ''; + print ''; + print ''; + print "\n"; + + print ''; + print ''; + + /* + * + */ + $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"; + $sql .= " FROM llx_voyage as b WHERE fk_reduc=".$reduc->id." ORDER BY b.date_depart ASC"; + + $result = $db->query($sql); + if ($result) { + + print ""; + print ""; + print ""; + print ""; + print "\n"; + + + $var=True; + $num = $db->num_rows(); + $i = 0; + $total = 0; + $total_reduc = 0; + + while ($i < $num) { + $objp = $db->fetch_object( $i); + $total = $total + $objp->amount; + $total_reduc = $total_reduc + $objp->reduction; + $time = time(); + + $var=!$var; + + print ""; + print "\n"; + + print ""; + + print "\n"; + print "\n"; + + print ""; + + + $i++; + } + $db->free(); + + + print ""; + print "\n"; + + print ""; + print "\n"; + + print ""; + print "\n"; + + + + print "
DescriptionMontant 
'.$reduc->label.''.$reduc->price.' 
DateDescriptionMontantRéduction
".strftime("%d %b %y %H:%M",$objp->date_depart)."
\n"; + print "".strftime("%d %b %y %H:%M",$objp->date_arrivee)."
$objp->depart
$objp->arrivee
".price($objp->amount)."".price($objp->reduction)."
Total :".price($total)."".price($total_reduc)."
Carte :".price($reduc->price)."
Gain :".price($total_reduc - $reduc->price)."
"; + } else { + print "

".$db->error(); + + } +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/voyage/index.php3 b/htdocs/compta/voyage/index.php3 new file mode 100644 index 00000000000..54c7e3c58f0 --- /dev/null +++ b/htdocs/compta/voyage/index.php3 @@ -0,0 +1,154 @@ + + * + * $Id$ + * $Source$ + * + * 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. + * + */ + +require("./pre.inc.php3"); + +llxHeader(); +$db = new Db(); + +if ($action == 'add') { + $author = $GLOBALS["REMOTE_USER"]; + + $sql = "INSERT INTO llx_voyage (date_depart, date_arrivee, amount, depart, arrivee, fk_reduc, reduction) "; + $sql .= " VALUES ('$date_depart','$date_arrivee',$amount,'$depart','$arrivee',$reducid, $reduc);"; + + $result = $db->query($sql); + if ($result) { + $rowid = $db->last_insert_id(); + + } else { + print $db->error(); + print "

$sql"; + } + +} +if ($action == 'del') { + /* $sql = "DELETE FROM llx_voyage WHERE rowid = $rowid"; + *$result = $db->query($sql); + */ +} + +if ($vline) { + $viewline = $vline; +} else { + $viewline = 20; +} + +$sql = "SELECT rowid, label FROM llx_voyage_reduc;"; +$result = $db->query($sql); +if ($result) { + $var=True; + $num = $db->num_rows(); + $i = 0; + $options = ""; + while ($i < $num) { + $obj = $db->fetch_object($i); + $options .= "\n"; $i++; + } + $db->free(); +} + + +print_titre("Voyages"); + + +$sql = "SELECT b.rowid,".$db->pdate("b.date_depart")." as date_depart,".$db->pdate("b.date_arrivee")." as date_arrivee, b.amount, b.reduction,b.depart, b.arrivee "; +$sql .= " FROM llx_voyage as b ORDER BY b.date_depart ASC"; + +$result = $db->query($sql); +if ($result) { + + print "

"; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + + + $var=True; + $num = $db->num_rows(); + $i = 0; $total = 0; + + $sep = 0; + + while ($i < $num) { + $objp = $db->fetch_object( $i); + $total = $total + $objp->amount; + $time = time(); + + $var=!$var; + + print ""; + print "\n"; + + print ""; + + print "\n"; + print "\n"; + + + + print "\n"; + print ""; + print ""; + + + $i++; + } + $db->free(); + + + print ""; + print "\n"; + print ""; + print ""; + print ""; + + print ""; + + print ""; + + print ""; + + print ""; + + print ''; + print "
DateDescriptionMontantRéduction
".strftime("%d %b %y %H:%M",$objp->date_depart)."
\n"; + print "".strftime("%d %b %y %H:%M",$objp->date_arrivee)."
$objp->depart
$objp->arrivee
".price($objp->amount)."".price($objp->reduction)."".francs($objp->amount)."rowid\">[Del]
Total :".price($total)."".francs($total)."

"; + print "

"; + print "
"; + print "
Réductioneuros 
"; +} else { + print "

".$db->error(); + +} + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/voyage/pre.inc.php3 b/htdocs/compta/voyage/pre.inc.php3 new file mode 100644 index 00000000000..030c9ca2cf5 --- /dev/null +++ b/htdocs/compta/voyage/pre.inc.php3 @@ -0,0 +1,50 @@ + + * + * $Id$ + * $Source$ + * + * 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. + * + */ +require("../../main.inc.php3"); + +function llxHeader($head = "") { + global $user, $conf; + + + /* + * + * + */ + top_menu($head); + + $menu = new Menu(); + + $menu->add("index.php3","Voyages"); + + $menu->add_submenu("index.php3","Voyages"); + $menu->add_submenu("bilan.php3","Bilan"); + $menu->add_submenu("reduc.php3","Reduc"); + + $menu->add("/compta/facture.php3","Factures"); + + $menu->add("/compta/bank/index.php3","Bank"); + + left_menu($menu->liste); + +} + +?> diff --git a/htdocs/compta/voyage/reduc.class.php3 b/htdocs/compta/voyage/reduc.class.php3 new file mode 100644 index 00000000000..61663e068f6 --- /dev/null +++ b/htdocs/compta/voyage/reduc.class.php3 @@ -0,0 +1,58 @@ + + * + * $Id$ + * $Source$ + * + * 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. + * + */ + +class Reduc { + var $id; + var $price; + var $label; + + Function Reduc($DB, $rowid=0) { + global $config; + + $this->db = $DB; + $this->rowid = $rowid; + + return 1; + } + + Function fetch($id) { + $sql = "SELECT b.rowid,".$this->db->pdate("b.date_debut")." as debut,".$this->db->pdate("b.date_fin")." as fin, b.amount, b.label "; + $sql .= " FROM llx_voyage_reduc as b WHERE rowid = $id"; + + $result = $this->db->query($sql); + + if ($result) { + if ($this->db->num_rows()) { + $obj = $this->db->fetch_object( 0); + + $this->id = $obj->rowid; + $this->price = $obj->amount; + $this->label = $obj->label; + } + $this->db->free(); + } + } + + +} + +?> diff --git a/htdocs/compta/voyage/reduc.php3 b/htdocs/compta/voyage/reduc.php3 new file mode 100644 index 00000000000..afa406aca6d --- /dev/null +++ b/htdocs/compta/voyage/reduc.php3 @@ -0,0 +1,84 @@ + + * + * $Id$ + * $Source$ + * + * 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. + * + */ + +require("./pre.inc.php3"); + +llxHeader(); +$db = new Db(); + + +print_titre ("Abonnement de réduction"); + + +print ""; +print ""; +print ""; +print ""; +print ""; +print "\n"; + + +$sql = "SELECT b.rowid,".$db->pdate("b.date_debut")." as debut,".$db->pdate("b.date_fin")." as fin, b.amount, b.label "; +$sql .= " FROM llx_voyage_reduc as b "; + +$result = $db->query($sql); +if ($result) { + $var=True; + $num = $db->num_rows(); + $i = 0; $total = 0; + + $sep = 0; + + while ($i < $num) { + $objp = $db->fetch_object( $i); + $total = $total + $objp->amount; + $time = time(); + + $var=!$var; + + print ""; + print "\n"; + + print ""; + + print "\n"; + + print "\n"; + + print ""; + + $i++; + } + $db->free(); +} + +print ""; +print "\n"; + + +print "
DateDescriptionMontantFrancs
".strftime("%d %b %y",$objp->debut)." au ".strftime("%d %b %y",$objp->fin)."$objp->label".price($objp->amount)."".francs($objp->amount)."
Total :".price($total)."".francs($total)."
"; + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/mysql/tables/llx_voyage.sql b/mysql/tables/llx_voyage.sql new file mode 100644 index 00000000000..45f2522490d --- /dev/null +++ b/mysql/tables/llx_voyage.sql @@ -0,0 +1,47 @@ +-- =================================================================== +-- Copyright (C) 2001-2002 Rodolphe Quiedeville +-- +-- $Id$ +-- $Source$ +-- +-- 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. +-- +-- =================================================================== + + +create table llx_voyage +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + datec datetime, + + dateo date, -- date operation + date_depart datetime, -- date du voyage + date_arrivee datetime, -- date du voyage + amount real NOT NULL default 0, -- prix du billet + reduction real NOT NULL default 0, -- montant de la reduction obtenue + depart varchar(255), + arrivee varchar(255), + fk_type smallint, -- Train, Avion, Bateaux + fk_reduc integer, + distance integer, -- distance en kilometre + dossier varchar(50), -- numero de dossier + note text +); + +-- insert into llx_voyage (date_depart, date_arrivee, amount, depart, arrivee, fk_reduc) +-- values ('2002-04-21 12:05','2002-04-21 15:25',26.8,'Paris','Auray',1); + +-- insert into llx_voyage (date_depart, date_arrivee, amount, depart, arrivee, fk_reduc) +-- values ('2002-04-23 15:42','2002-04-23 19:10',26.8,'Auray','Paris',1);