[ 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/telephonie/distributeurs/ -> commissions.php (source)

   1  <?PHP
   2  /* Copyright (C) 2005 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: commissions.php,v 1.11 2005/09/13 13:36:53 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/distributeurs/commissions.php,v $
  20   *
  21   */
  22  require ("./pre.inc.php");
  23  
  24  
  25  if (!$user->rights->telephonie->lire) accessforbidden();
  26  
  27  llxHeader('','Telephonie - Statistiques - Distributeur');
  28  
  29  /*
  30   *
  31   */
  32  $h = 0;
  33  
  34  if ($user->distributeur_id)
  35  {
  36    $_GET["id"] = $user->distributeur_id;
  37  }
  38  
  39  if ($_GET["id"])
  40  {
  41    $distri = new DistributeurTelephonie($db);
  42    $distri->fetch($_GET["id"]);
  43  
  44    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$distri->id;
  45    $head[$h][1] = $distri->nom;
  46    $h++;
  47  
  48    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/contrat.php?id='.$distri->id;
  49    $head[$h][1] = "Contrat";
  50    $h++;
  51  
  52    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/commissions.php?id='.$distri->id;
  53    $head[$h][1] = "Rémunérations";
  54    $hselected = $h;
  55    $h++;
  56  
  57    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remav.php?id='.$distri->id;
  58    $head[$h][1] = "Rém. avance";
  59    $h++;
  60  
  61    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remconso.php?id='.$distri->id;
  62    $head[$h][1] = "Rém. conso";
  63    $h++;
  64  
  65    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/po.php?id='.$distri->id;
  66    $head[$h][1] = "Prises d'ordre";
  67    $h++;
  68  
  69    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id;
  70    $head[$h][1] = "Statistiques";
  71    $h++;
  72  
  73    dolibarr_fiche_head($head, $hselected, "Distributeur");
  74  
  75  
  76    /* Conso */
  77    $conso_total = 0;
  78    $consos = array();
  79  
  80    $sql = "SELECT c.date, sum(c.montant)";
  81    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_conso as c";  
  82    $sql .= " WHERE c.fk_distributeur = ".$_GET["id"];
  83    $sql .= " AND c.annul = 0";
  84    $sql .= " GROUP BY c.date DESC";
  85  
  86    $resql = $db->query($sql);
  87    
  88    if ($resql)
  89      {
  90        $num = $db->num_rows($resql);
  91        $i = 0;
  92        
  93        while ($i < $num)
  94      {
  95        $row = $db->fetch_row($resql);    
  96        $consos[$row[0]] = $row[1];      
  97        $conso_total += $row[1];
  98        $i++;
  99      }
 100        $db->free($resql);
 101      }
 102    else 
 103      {
 104        print $db->error() . ' ' . $sql;
 105      }
 106  
 107  
 108    /* Commission */
 109    $comm_total = 0;
 110    $commissions = array();
 111  
 112    $sql = "SELECT c.date, c.montant";
 113    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as c";  
 114    $sql .= " WHERE c.fk_distributeur = ".$_GET["id"];
 115    $sql .= " ORDER BY c.date DESC";
 116    $resql = $db->query($sql);
 117    
 118    if ($resql)
 119      {
 120        $num = $db->num_rows($resql);
 121        $i = 0;
 122        
 123        while ($row = $db->fetch_row($resql))
 124      {
 125        $commissions[$row[0]] = $row[1];      
 126        $comm_total += $row[1];
 127      }
 128        $db->free($resql);
 129      }
 130    else 
 131      {
 132        print $db->error() . ' ' . $sql;
 133      }
 134  
 135    print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
 136    print '<tr><td width="50%" valign="top">';
 137      
 138    print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
 139    print '<tr class="liste_titre">';
 140    print '<td>Date</td><td align="right">Rémunération</td>';
 141    print '</tr>';
 142    $var=1;
 143    print '<tr class="liste_titre">';
 144    print '<td>Total</td><td align="right">'.price($comm_total).' HT</td></tr>';
 145  
 146    $sql = "SELECT c.date, c.montant";
 147    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as c";
 148    $sql .= " WHERE c.fk_distributeur = ".$_GET["id"];
 149  
 150    $sql .= " ORDER BY c.date DESC";
 151      
 152    $resql = $db->query($sql);
 153    
 154    if ($resql)
 155      {
 156        $num = $db->num_rows($resql);
 157        $i = 0;
 158        $total = 0;
 159        
 160        while ($i < $num)
 161      {
 162        $row = $db->fetch_row($resql);
 163        
 164        $var=!$var;
 165        
 166        print "<tr $bc[$var]>";
 167        
 168        print '<td>'.substr($row[0], -2).'/'.substr($row[0],0,4).'</td>';
 169        print '<td align="right">'.price($row[1]).' HT</td>';
 170        /*
 171        print '<td align="right">'.price($consos[$row[0]]).' HT</td>';
 172        print '<td align="right">'.price($consos[$row[0]] - $row[1]).' HT</td>';
 173        */
 174        
 175        $i++;
 176      }
 177        $db->free($resql);
 178      }
 179    else 
 180      {
 181        print $db->error() . ' ' . $sql;
 182      }
 183    print '</table><br />';
 184  
 185  
 186    print '</td><td valign="top" width="50%">';
 187  
 188    print '</td></tr>';
 189    print '</table>';
 190   
 191   $db->close();
 192  }
 193  
 194  llxFooter("<em>Derni&egrave;re modification $Date: 2005/09/13 13:36:53 $ r&eacute;vision $Revision: 1.11 $</em>");
 195  ?>


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