[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/compta/voyage/ -> bilan.php (source)

   1  <?php
   2  /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   *
   4   * This program is free software; you can redistribute it and/or modify
   5   * it under the terms of the GNU General Public License as published by
   6   * the Free Software Foundation; either version 2 of the License, or
   7   * (at your option) any later version.
   8   *
   9   * This program is distributed in the hope that it will be useful,
  10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12   * GNU General Public License for more details.
  13   *
  14   * You should have received a copy of the GNU General Public License
  15   * along with this program; if not, write to the Free Software
  16   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17   *
  18   * $Id: bilan.php,v 1.9 2005/09/17 00:53:50 eldy Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/voyage/bilan.php,v $
  20   *
  21   */
  22  
  23  require ("./pre.inc.php");
  24  require ("./reduc.class.php");
  25  
  26  
  27  llxHeader();
  28  
  29  if ($action == 'add') {
  30  
  31    $sql = "INSERT INTO ".MAIN_DB_PREFIX."voyage (date_depart, date_arrivee, amount, depart, arrivee, fk_reduc) ";
  32    $sql .= " VALUES ('$date_depart','$date_arrivee',$amount,'$depart','$arrivee',$reduc);";
  33  
  34    $result = $db->query($sql);
  35    if ($result) {
  36      $rowid = $db->last_insert_id(MAIN_DB_PREFIX."voyage");
  37  
  38    } else {
  39      print $db->error();
  40      print "<p>$sql";
  41    }
  42  
  43  }
  44  if ($action == 'del') {
  45    /*  $sql = "DELETE FROM ".MAIN_DB_PREFIX."voyage WHERE rowid = $rowid";
  46     *$result = $db->query($sql);
  47     */
  48  }
  49  
  50  if ($vline) {
  51    $viewline = $vline;
  52  } else {
  53    $viewline = 20;
  54  }
  55  
  56  $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."voyage_reduc;";
  57  $result = $db->query($sql);
  58  if ($result) {
  59    $var=True;  
  60    $num = $db->num_rows();
  61    $i = 0;
  62    $options = "<option value=\"0\" selected=\"true\"></option>";
  63    while ($i < $num) {
  64      $obj = $db->fetch_object($result);
  65      $options .= "<option value=\"$obj->rowid\">$obj->label</option>\n"; $i++;
  66    }
  67    $db->free();
  68  }
  69  
  70  
  71  print_titre("Bilan des reductions");
  72  /*
  73   * Cartes
  74   *
  75   */
  76  $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."voyage_reduc";
  77  
  78  $result = $db->query($sql);
  79  if ($result) {
  80    $cartes= array();
  81    $i = 0;
  82    while ($i < $num) {
  83      $obj = $db->fetch_object($result);
  84      $cartes[$i] = $obj->rowid;
  85      $i++;
  86    }
  87    $db->free;
  88  }
  89  /*
  90   *
  91   */
  92  
  93  for ($j = 0 ; $j < sizeof($cartes) ; $j++) {
  94  
  95    $reduc = new Reduc($db);
  96    $reduc->fetch($cartes[$j]);
  97  
  98    print "<table class=\border\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
  99    print "<tr>";
 100    print '<td colspan="2">'.$langs->trans("Description").'</td>';
 101    print '<td align="right">Montant</td>';
 102    print '<td>&nbsp;</td>';
 103    print "</tr>\n";
 104  
 105    print '<tr><td colspan="2">'.$reduc->label.'</td><td align="right">'.$reduc->price.'</td>';
 106    print '<td>&nbsp;</TD></tr>';
 107   
 108    /*
 109     *
 110     */
 111    $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";
 112    $sql .= " FROM ".MAIN_DB_PREFIX."voyage as b WHERE fk_reduc=".$reduc->id." ORDER BY b.date_depart ASC"; 
 113  
 114    $result = $db->query($sql);
 115    if ($result) {
 116  
 117      print "<tr class=\"liste_titre\">";
 118      print '<td>Date</td><td>'.$langs->trans("Description").'</td>';
 119      print "<td align=\"right\">Montant</td>";
 120      print "<td align=\"right\">Réduction</td>";
 121      print "</tr>\n";
 122    
 123  
 124      $var=True;  
 125      $num = $db->num_rows();
 126      $i = 0; 
 127      $total = 0;
 128      $total_reduc = 0;
 129  
 130      while ($i < $num) {
 131        $objp = $db->fetch_object($result);
 132        $total = $total + $objp->amount;
 133        $total_reduc = $total_reduc + $objp->reduction;
 134        $time = time();
 135  
 136        $var=!$var;
 137  
 138        print "<tr $bc[$var]>";
 139        print "<td>".strftime("%d&nbsp;%b&nbsp;%y&nbsp;%H:%M",$objp->date_depart)."<br>\n";
 140        print "".strftime("%d %b %y %H:%M",$objp->date_arrivee)."</TD>\n";
 141  
 142        print "<td>$objp->depart<br>$objp->arrivee</td>";
 143  
 144        print "<td align=\"right\">".price($objp->amount)."</TD>\n";
 145        print "<td align=\"right\">".price($objp->reduction)."</TD>\n";
 146  
 147        print "</tr>";
 148  
 149  
 150        $i++;
 151      }
 152      $db->free();
 153  
 154  
 155      print "<tr><td align=\"right\" colspan=\"2\">Total :</td>";
 156      print "<td align=\"right\"><b>".price($total)."</b></td><td align=\"right\">".price($total_reduc)."</td></tr>\n";
 157  
 158      print "<tr><td align=\"right\" colspan=\"3\">Carte :</td>";
 159      print "<td align=\"right\">".price($reduc->price)."</td></tr>\n";
 160  
 161      print "<tr><td align=\"right\" colspan=\"3\">Gain :</td>";
 162      print "<td align=\"right\">".price($total_reduc - $reduc->price)."</td></tr>\n";
 163  
 164  
 165  
 166      print "</table>";
 167    } else {
 168      print "<p>".$db->error();
 169  
 170    }
 171  }
 172  
 173  $db->close();
 174  
 175  llxFooter("<em>Derni&egrave;re modification $Date: 2005/09/17 00:53:50 $ r&eacute;vision $Revision: 1.9 $</em>");
 176  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics