/[dolibarr]/dolibarr/htdocs/telephonie/distributeurs/commissions.php
ViewVC logotype

Diff of /dolibarr/htdocs/telephonie/distributeurs/commissions.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by rodolphe, Thu Aug 11 16:40:59 2005 UTC revision 1.4 by rodolphe, Fri Aug 12 12:47:22 2005 UTC
# Line 51  if ($_GET["id"]) Line 51  if ($_GET["id"])
51    
52    dolibarr_fiche_head($head, $hselected, "Distributeur");    dolibarr_fiche_head($head, $hselected, "Distributeur");
53    
   print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';  
   
   print '<tr><td width="50%" valign="top">';  
     
   
   
   
     
   /* Commissions */  
54    
55      /* Conso */
56      $conso_total = 0;
57    $consos = array();    $consos = array();
58    
59    $sql = "SELECT c.date, sum(c.montant)";    $sql = "SELECT c.date, sum(c.montant)";
60    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_conso as c";    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_conso as c";  
     
61    $sql .= " WHERE c.fk_distributeur = ".$_GET["id"];    $sql .= " WHERE c.fk_distributeur = ".$_GET["id"];
   
62    $sql .= " GROUP BY c.date DESC";    $sql .= " GROUP BY c.date DESC";
63    
64    $resql = $db->query($sql);    $resql = $db->query($sql);
65        
66    if ($resql)    if ($resql)
67      {      {
68        $num = $db->num_rows();        $num = $db->num_rows($resql);
69        $i = 0;        $i = 0;
70                
71        while ($i < $num)        while ($i < $num)
72          {          {
73            $row = $db->fetch_row($i);                $row = $db->fetch_row($resql);        
74            $consos[$row[0]] = $row[1];                $consos[$row[0]] = $row[1];    
75              $conso_total += $row[1];
76              $i++;
77            }
78          $db->free($resql);
79        }
80      else
81        {
82          print $db->error() . ' ' . $sql;
83        }
84    
85    
86      /* Commission */
87      $comm_total = 0;
88      $commissions = array();
89    
90      $sql = "SELECT c.date, c.montant";
91      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as c";  
92      $sql .= " WHERE c.fk_distributeur = ".$_GET["id"];
93      $sql .= " ORDER BY c.date DESC";
94    
95      $resql = $db->query($sql);
96      
97      if ($resql)
98        {
99          $num = $db->num_rows($resql);
100          $i = 0;
101          
102          while ($i < $num)
103            {
104              $row = $db->fetch_row($resql);        
105              $commissions[$row[0]] = $row[1];        
106              $comm_total += $row[1];
107            $i++;            $i++;
108          }          }
109        $db->free();        $db->free($resql);
110      }      }
111    else    else
112      {      {
# Line 91  if ($_GET["id"]) Line 114  if ($_GET["id"])
114      }      }
115    
116    
117    
118      print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
119    
120      print '<tr><td width="50%" valign="top">';
121      
122      
123    print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';    print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
124    print '<tr class="liste_titre">';    print '<tr class="liste_titre">';
125    print '<td>Date</td><td>Versé</td><td>Consos</td><td>Solde</td></tr>';    print '<td>Date</td><td align="right">Versé</td><td align="right">Consos</td><td align="right">Solde</td></tr>';
126      $var=1;
127      print '<tr class="liste_titre">';
128      print '<td>Total</td><td align="right">'.price($comm_total).' HT</td><td align="right">'.price($conso_total).' HT</td><td align="right">'.price($comm_total - $conso_total).' HT</td></tr>';
129    
130    $sql = "SELECT c.date, c.montant";    $sql = "SELECT c.date, c.montant";
131    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as c";    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as c";
     
132    $sql .= " WHERE c.fk_distributeur = ".$_GET["id"];    $sql .= " WHERE c.fk_distributeur = ".$_GET["id"];
133    
134    $sql .= " ORDER BY c.date DESC";    $sql .= " ORDER BY c.date DESC";
# Line 112  if ($_GET["id"]) Line 143  if ($_GET["id"])
143                
144        while ($i < $num)        while ($i < $num)
145          {          {
146            $row = $db->fetch_row($i);                $row = $db->fetch_row($resql);
147                        
148            $var=!$var;            $var=!$var;
149                        
150            print "<tr $bc[$var]>";            print "<tr $bc[$var]>";
151                        
152            print '<td>'.substr($row[0], -2).'/'.substr($row[0],0,4).'</td>';            print '<td>'.substr($row[0], -2).'/'.substr($row[0],0,4).'</td>';
153            print '<td>'.price($row[1]).' HT</td>';            print '<td align="right">'.price($row[1]).' HT</td>';
154            print '<td>'.price($consos[$row[0]]).' HT</td>';            print '<td align="right">'.price($consos[$row[0]]).' HT</td>';
155            print '<td>'.price($consos[$row[0]] - $row[1]).' HT</td>';            print '<td align="right">'.price($consos[$row[0]] - $row[1]).' HT</td>';
156                        
157            $i++;            $i++;
158          }          }
159        $db->free();        $db->free($resql);
160      }      }
161    else    else
162      {      {

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26