[ 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/ -> remconso.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: remconso.php,v 1.3 2005/09/13 13:48:11 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/distributeurs/remconso.php,v $
  20   *
  21   */
  22  require ("./pre.inc.php");
  23  
  24  if ($user->distributeur_id)
  25  {
  26    $_GET["id"] = $user->distributeur_id;
  27  }
  28  
  29  llxHeader();
  30  
  31  
  32  $page = $_GET["page"];
  33  $sortorder = $_GET["sortorder"];
  34  $sortfield = $_GET["sortfield"];
  35  if ($sortorder == "") $sortorder="DESC";
  36  if ($sortfield == "") $sortfield="p.datepo";
  37  
  38  /*
  39   *
  40   *
  41   */
  42  
  43  if ($_GET["id"])
  44  {
  45    $h = 0;
  46    $distri = new DistributeurTelephonie($db);
  47    $distri->fetch($_GET["id"]);
  48  
  49    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$distri->id;
  50    $head[$h][1] = $distri->nom;
  51    $h++;
  52  
  53    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/contrat.php?id='.$distri->id;
  54    $head[$h][1] = "Contrat";
  55    $h++;
  56  
  57    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/commissions.php?id='.$distri->id;
  58    $head[$h][1] = "Rémunérations";
  59    $h++;
  60  
  61    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remav.php?id='.$distri->id;
  62    $head[$h][1] = "Rém. avance";
  63    $h++;
  64  
  65    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remconso.php?id='.$distri->id;
  66    $head[$h][1] = "Rém. conso";
  67    $hselected = $h;
  68    $h++;
  69  
  70    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/po.php?id='.$distri->id;
  71    $head[$h][1] = "Prises d'ordre";
  72    $h++;
  73    
  74    $head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id;
  75    $head[$h][1] = "Statistiques";
  76    $h++;
  77  
  78    dolibarr_fiche_head($head, $hselected, "Distributeur");
  79  
  80    print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
  81    print '<tr><td width="70%" valign="top">';  
  82    
  83    if ($page == -1) { $page = 0 ; }
  84  
  85    $offset = $conf->liste_limit * $page ;
  86    $pageprev = $page - 1;
  87    $pagenext = $page + 1;
  88    
  89    /*
  90     * Mode Liste
  91     *
  92     */
  93  
  94    if ($_GET["month"] > 0)
  95      {
  96        $datetime = mktime(12,12,12,substr($_GET["month"], -2), 1 , substr($_GET["month"],0,4));
  97      }
  98    else
  99      {
 100        $datetime = time();
 101      }
 102  
 103    $month = substr("00".strftime("%m", $datetime), -2);
 104    $year = strftime("%Y", $datetime);      
 105    $mois = strftime("%B %Y", $datetime);
 106  
 107    $sql = "SELECT s.idp, s.nom, a.fk_contrat, sum(a.montant) as montant";
 108  
 109    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_conso as a";
 110    $sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
 111    $sql .= " , ".MAIN_DB_PREFIX."societe as s";
 112    
 113    $sql .= " WHERE a.fk_distributeur =".$distri->id;
 114    $sql .= " AND a.fk_contrat = c.rowid"; 
 115    $sql .= " AND c.fk_soc = s.idp";
 116    $sql .= " AND a.date ='".$year.$month."'";
 117    $sql .= " AND a.avance = 0";
 118    $sql .= " GROUP BY s.idp";
 119    $sql .= " ORDER BY s.nom ASC";
 120    
 121    $resql = $db->query($sql);
 122    if ($resql)
 123      {
 124        $num = $db->num_rows($resql);
 125        $i = 0;
 126        
 127        print_barre_liste("Rémunération sur consommations pour $mois", $page, "po.php", "", $sortfield, $sortorder, '', $num);
 128        
 129        print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
 130        print '<tr class="liste_titre"><td>Client</td>';
 131        print '<td align="right">Montant</td>';
 132        print "</tr>\n";
 133        
 134        $var=True;
 135        
 136        while ($i < min($num,$conf->liste_limit))
 137      {
 138        $obj = $db->fetch_object($resql);
 139        $var=!$var;
 140        
 141        print "<tr $bc[$var]>";      
 142        print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">';
 143        print img_file();
 144        print '</a>&nbsp;';      
 145        print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">'.$obj->nom."</a></td>\n";
 146        print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n";      
 147        print "</tr>\n";
 148        $i++;
 149      }
 150        print "</table>";
 151        $db->free();
 152      }
 153    else 
 154      {
 155        print $db->error() . ' ' . $sql;
 156      }
 157  
 158  
 159    print '</td><td width="30%" valign="top">';
 160  
 161  
 162    $sql = "SELECT distinct(a.date)";
 163  
 164    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_conso as a";
 165    $sql .= " WHERE a.avance = 0";
 166    $sql .= " ORDER BY a.date DESC";
 167    
 168    $resql = $db->query($sql);
 169    if ($resql)
 170      {
 171        $num = $db->num_rows($resql);
 172        $i = 0;
 173        print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
 174        print '<tr class="liste_titre"><td>Mois</td>';
 175        print "</tr>\n";
 176        
 177        $var=True;
 178        
 179        while ( $obj = $db->fetch_object($resql))
 180      {
 181        $var=!$var;
 182        
 183        print "<tr $bc[$var]><td>";
 184        print '<a href="'.DOL_URL_ROOT.'/telephonie/distributeurs/remconso.php?id='.$_GET["id"];
 185        print '&amp;month='.$obj->date.'">'.$obj->date."</a></td>\n";
 186        print "</tr>\n";
 187      }
 188        print "</table>";
 189        $db->free();
 190      }
 191    else 
 192      {
 193        print $db->error() . ' ' . $sql;
 194      }
 195  
 196  
 197    print '</td></tr></table>';  
 198  }
 199  
 200  $db->close();
 201  
 202  llxFooter("<em>Derni&egrave;re modification $Date: 2005/09/13 13:48:11 $ r&eacute;vision $Revision: 1.3 $</em>");
 203  ?>


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