[ 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/ -> distributeur.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: distributeur.php,v 1.23 2005/10/25 12:31:29 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/distributeurs/distributeur.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    $hselected = $h;
  47    $h++;
  48  
  49    if ($user->distributeur_id == 0 || $user->responsable_distributeur_id > 0)
  50      {
  51        $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/contrat.php?id='.$distri->id;
  52        $head[$h][1] = "Contrat";
  53        $h++;
  54  
  55        $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remuneration.php?id='.$distri->id;
  56        $head[$h][1] = "Rémunérations";
  57        $h++;
  58  
  59        $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/po.php?id='.$distri->id;
  60        $head[$h][1] = "Prises d'ordre";
  61        $h++;
  62        
  63        $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id;
  64        $head[$h][1] = "Statistiques";
  65        $h++;
  66      }
  67  
  68    dolibarr_fiche_head($head, $hselected, "Distributeur");
  69  
  70    print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
  71  
  72    print '<tr><td width="40%" valign="top">';
  73    
  74    print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
  75    print '<tr class="liste_titre"><td>Responsables</td></tr>';
  76  
  77    $sql = "SELECT u.rowid, u.firstname, u.name";
  78    $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
  79    $sql .= " , ".MAIN_DB_PREFIX."telephonie_distributeur_responsable as dc";  
  80    $sql .= " WHERE u.rowid = dc.fk_user ";
  81    $sql .= " AND dc.fk_distributeur = '".$_GET["id"]."'";
  82    $sql .= " ORDER BY u.name ASC;";
  83      
  84    $resql = $db->query($sql);
  85    
  86    if ($resql)
  87      {
  88        while ($row = $db->fetch_row($resql))
  89      {
  90        $var=!$var;
  91        print "<tr $bc[$var]>";
  92        print '<td>'.$row[1].' '.$row[2].'</td>';
  93      }
  94        $db->free($resql);
  95      }
  96    else 
  97      {
  98        print $db->error() . ' ' . $sql;
  99      }
 100    print '</table><br />';
 101  
 102  
 103  
 104    $sql = "SELECT u.rowid, u.firstname, u.name, u.email";
 105    $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
 106    $sql .= " , ".MAIN_DB_PREFIX."telephonie_distributeur_commerciaux as dc";  
 107    $sql .= " WHERE u.rowid = dc.fk_user ";
 108    $sql .= " AND dc.fk_distributeur = '".$_GET["id"]."'";
 109    $sql .= " ORDER BY u.name ASC;";
 110      
 111    $resql = $db->query($sql);
 112    
 113    if ($resql)
 114      {
 115        $num = $db->num_rows($resql);
 116  
 117        if ($num > 0 )
 118      {
 119        print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
 120        print '<tr class="liste_titre"><td>Commerciaux</td></tr>';
 121        while ($row = $db->fetch_row($resql))
 122          {
 123            $var=!$var;
 124            print "<tr $bc[$var]>";
 125            print '<td><a href="./comm/commercial.php?id='.$row[0].'&amp;did='.$_GET["id"].'">';;
 126            print $row[1].' '.$row[2].'</a>';
 127            if ($row[3] && $user->distributeur_id == 0)
 128          {
 129            print " &lt;".$row[3]."&gt;";
 130          }
 131            print '</td>';
 132          }
 133        
 134        print '</table><br />';
 135      }
 136        $db->free($resql);
 137      }
 138    else 
 139      {
 140        print $db->error() . ' ' . $sql;
 141      }
 142  
 143    if ($user->distributeur_id == 0 || $user->responsable_distributeur_id > 0)
 144      {
 145  
 146        print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
 147        print '<tr class="liste_titre"><td colspan="2">Total commission</td></tr>';
 148        
 149        $sql = "SELECT sum(c.montant)";
 150        $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as c";  
 151        $sql .= " WHERE c.fk_distributeur = ".$_GET["id"];
 152        
 153        $resql = $db->query($sql);
 154        
 155        if ($resql)
 156      {
 157        $num = $db->num_rows($resql);
 158        $i = 0;
 159        $total = 0;
 160        $var = 0;
 161        while ($i < $num)
 162          {
 163            $row = $db->fetch_row($resql);      
 164            $var=!$var;      
 165            print "<tr $bc[$var]>";      
 166            print '<td>Total</td>';
 167            print '<td align="right">'.price($row[0]).' HT</td>';
 168            
 169            $i++;
 170          }
 171        $db->free($resql);
 172      }
 173        else 
 174      {
 175        print $db->error() . ' ' . $sql;
 176      }
 177        print '</table><br />';
 178      }
 179  
 180    if ($user->distributeur_id == 0 || $user->responsable_distributeur_id > 0)
 181      {
 182  
 183    print '</td><td valign="top" width="30%">';
 184    
 185    /* comm */
 186  
 187  
 188  
 189    print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
 190  
 191    print '<tr class="liste_titre">';
 192    print '<td>Date</td><td align="right">Rémunérations</td></tr>';
 193  
 194    $sql = "SELECT c.date, c.montant";
 195    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as c";  
 196    $sql .= " WHERE c.fk_distributeur = ".$_GET["id"];
 197    $sql .= " ORDER BY c.date DESC";
 198      
 199    $resql = $db->query($sql);
 200    
 201    if ($resql)
 202      {
 203        $num = $db->num_rows($resql);
 204        $i = 0;
 205        $total = 0;
 206        
 207        while ($i < $num)
 208      {
 209        $row = $db->fetch_row($resql);    
 210        
 211        $var=!$var;      
 212        print "<tr $bc[$var]>";      
 213        print '<td>'.substr($row[0], -2).'/'.substr($row[0],0,4).'</td>';
 214        print '<td align="right">'.price($row[1]).' HT</td>';
 215        
 216        $i++;
 217      }
 218        $db->free($resql);
 219      }
 220    else 
 221      {
 222        print $db->error() . ' ' . $sql;
 223      }
 224    print '</table><br />';
 225      
 226  
 227    print '</td><td valign="top" width="30%">';
 228    print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
 229  
 230    print '<tr class="liste_titre">';
 231    print '<td>Date</td><td align="right">'."Prise d'ordre mensuelle</td></tr>";
 232  
 233    $sql = "SELECT ".$db->pdate("p.datepo") . " as datepo, sum(p.montant)";
 234    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_priseordre as p";
 235    $sql .= " WHERE p.fk_distributeur =".$distri->id;
 236    $sql .= " GROUP BY date_format(datepo,'%Y%m') DESC";  
 237  
 238    $resql = $db->query($sql);
 239    
 240    if ($resql)
 241      {
 242        $num = $db->num_rows($resql);
 243        $i = 0;
 244        $total = 0;
 245        
 246        while ($i < $num)
 247      {
 248        $row = $db->fetch_row($resql);    
 249        
 250        $var=!$var;
 251        
 252        print "<tr $bc[$var]>";
 253        
 254        print '<td>'.strftime("%m/%Y",$row[0]).'</td>';
 255        print '<td align="right">'.price($row[1]).' HT</td>';
 256        
 257        $i++;
 258      }
 259        $db->free($resql);
 260      }
 261    else 
 262      {
 263        print $db->error() . ' ' . $sql;
 264      }
 265    print '</table><br />';
 266      }
 267    print '</td></tr>';
 268    print '</table></div>';
 269  
 270    /* ************************************************************************** */
 271    /*                                                                            */ 
 272    /* Barre d'action                                                             */ 
 273    /*                                                                            */ 
 274    /* ************************************************************************** */
 275    print "\n<div class=\"tabsAction\">\n";
 276    
 277    if ($_GET["action"] == '' && $user->admin)
 278      {
 279        print "<a class=\"tabAction\" href=\"fiche.php?action=create_commercial&amp;distri=".$distri->id."\">".$langs->trans("Nouveau commercial")."</a>";
 280      }
 281    
 282    print "</div><br>";
 283   
 284    $db->close();
 285  }
 286  
 287  llxFooter("<em>Derni&egrave;re modification $Date: 2005/10/25 12:31:29 $ r&eacute;vision $Revision: 1.23 $</em>");
 288  ?>


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