2002-05-11 19:19:18 +02:00
< ? PHP
/* Copyright ( C ) 2001 - 2002 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
*
* $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 " <p> $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 = " <option value= \" 0 \" SELECTED></option> " ;
while ( $i < $num ) {
$obj = $db -> fetch_object ( $i );
$options .= " <option value= \" $obj->rowid\ " > $obj -> label </ option > \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 " <form method= \" post \" action= \" $PHP_SELF ?viewall= $viewall &vline= $vline &account= $account\ " > " ;
print " <input type= \" hidden \" name= \" action \" value= \" add \" > " ;
print " <TABLE border= \" 1 \" width= \" 100% \" cellspacing= \" 0 \" cellpadding= \" 2 \" > " ;
print " <TR class= \" liste_titre \" > " ;
print " <td>Date</td><td>Description</TD> " ;
print " <td align= \" right \" >Montant</TD> " ;
print " <td align= \" right \" >R<> duction</td> " ;
print " </TR> \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 " <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 " ;
2002-05-12 14:43:04 +02:00
print " <td> $objp->depart - $objp->arrivee </td> " ;
2002-05-11 19:19:18 +02:00
print " <td align= \" right \" > " . price ( $objp -> amount ) . " </TD> \n " ;
print " <td align= \" right \" > " . price ( $objp -> reduction ) . " </TD> \n " ;
print " <td align= \" right \" ><small> " . francs ( $objp -> amount ) . " </small></TD> \n " ;
print " <td align= \" center \" ><a href= \" $PHP_SELF ?action=del&rowid= $objp->rowid\ " > [ Del ] </ a ></ td > " ;
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 \" > " . francs ( $total ) . " </td></tr> \n " ;
print " <tr> " ;
print " <td><input name= \" date_depart \" type= \" text \" size=16 maxlength=16><br> " ;
print " <input name= \" date_arrivee \" type= \" text \" size=16 maxlength=16></td> " ;
print " <td><input name= \" depart \" type= \" text \" size=40><br> " ;
print " <input name= \" arrivee \" type= \" text \" size=40></td> " ;
print " <td><input name= \" amount \" type= \" text \" size=8></td> " ;
print " <td colspan= \" 2 \" align= \" center \" ><input type= \" submit \" value= \" ajouter \" </td> " ;
print " </tr><tr><td colspan= \" 1 \" >R<> duction</td> " ;
print " <td><select name= \" reducid \" > $options " ;
print " </select></td> " ;
print " <td><input name= \" reduc \" type= \" text \" size=6 value=0.00>euros</td><td> </td> " ;
print '</tr>' ;
print " </table></form> " ;
} else {
print " <p> " . $db -> error ();
}
$db -> close ();
llxFooter ( " <em>Dernière modification $Date $ révision $Revision $ </em> " );
?>