[ 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/client/ -> factures.php (source)

   1  <?PHP
   2  /* Copyright (C) 2004-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: factures.php,v 1.9 2005/10/31 10:01:27 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/client/factures.php,v $
  20   *
  21   */
  22  
  23  require ("./pre.inc.php");
  24  
  25  llxHeader("","Téléphonie - Factures client");
  26  
  27  if ($cancel == $langs->trans("Cancel"))
  28  {
  29    $action = '';
  30  }
  31  /*
  32   * Affichage
  33   *
  34   */
  35  
  36  if ($_GET["id"])
  37  {
  38    $soc = new Societe($db);
  39    $result = $soc->fetch($_GET["id"], $user);
  40  
  41    if (!$soc->perm_read)
  42      {
  43        print "Lecture non authorisée";
  44      }
  45  
  46    if ( $result == 1 && $soc->perm_read)
  47      { 
  48        if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
  49      {
  50        $h=0;
  51        $head[$h][0] = DOL_URL_ROOT."/telephonie/client/fiche.php?id=".$soc->id;
  52        $head[$h][1] = $langs->trans("Contrats");
  53        $h++;
  54  
  55        $head[$h][0] = DOL_URL_ROOT."/telephonie/client/lignes.php?id=".$soc->id;
  56        $head[$h][1] = $langs->trans("Lignes");
  57        $h++;
  58  
  59        $head[$h][0] = DOL_URL_ROOT."/telephonie/client/factures.php?id=".$soc->id;
  60        $head[$h][1] = $langs->trans("Factures");
  61        $hselected = $h;
  62        $h++;
  63  
  64        $head[$h][0] = DOL_URL_ROOT."/telephonie/client/stats.php?id=".$soc->id;
  65        $head[$h][1] = $langs->trans("Stats");
  66        $h++;
  67  
  68        $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."telephonie_tarif_client";
  69        $sql .= " WHERE fk_client = '".$soc->id."';";
  70        $resql = $db->query($sql);
  71  
  72        if ($resql)
  73          {
  74            $row = $db->fetch_row($resql);
  75            $db->free($resql);
  76          }
  77  
  78        $head[$h][0] = DOL_URL_ROOT."/telephonie/client/tarifs.php?id=".$soc->id;
  79        $head[$h][1] = $langs->trans("Tarifs (".$row[0].")");           
  80        $h++;
  81            
  82        dolibarr_fiche_head($head, $hselected, 'Client : '.$soc->nom);
  83  
  84        print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
  85        print '<tr><td width="20%">'.$langs->trans('Name').'</td><td>'.$soc->nom.'</td><td>'.$langs->trans('Code Client').'</td><td>'.$soc->code_client.'</td></tr>';
  86        
  87        print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($soc->adresse)."<br>".$soc->cp." ".$soc->ville." ".$soc->pays."</td></tr>";
  88        
  89        print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dolibarr_print_phone($soc->tel).'</td>';
  90        print '<td>'.$langs->trans('Fax').'</td><td>'.dolibarr_print_phone($soc->fax).'</td></tr>';
  91              
  92        print '</table><br />';
  93  
  94        /*
  95         * Factures
  96         *
  97         */
  98  
  99        if ($page == -1) { $page = 0 ; }
 100  
 101        if ($sortorder == "") {
 102          $sortorder="DESC";
 103        }
 104        if ($sortfield == "") {
 105          $sortfield="f.date";
 106        }
 107        $offset = $conf->liste_limit * $page ;
 108        $pageprev = $page - 1;
 109        $pagenext = $page + 1;
 110        
 111        $sql = "SELECT f.rowid, f.date, sum(f.cout_vente) as cout_vente, f.fk_facture";
 112        $sql .= " ,s.nom, s.idp";
 113        $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f";
 114        $sql .= " , ".MAIN_DB_PREFIX."societe as s";
 115        $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
 116        
 117        $sql .= " WHERE s.idp = l.fk_soc_facture AND l.rowid = f.fk_ligne";
 118        $sql .= " AND s.idp = ".$soc->id;
 119        $sql .= " GROUP BY f.fk_facture";
 120        $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
 121        
 122        $resql = $db->query($sql);
 123        if ($resql)
 124          {
 125            $num = $db->num_rows($resql);
 126            $i = 0;
 127                      
 128            print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
 129            print '<tr class="liste_titre">';          
 130            print '<td align="center">Date</td><td align="right">Montant HT</td>';
 131            print '<td align="center">Facture</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  
 143            print '<td align="center">'.$obj->date."</td>\n";
 144            print '<td align="right">'.sprintf("%01.4f",$obj->cout_vente)."</td>\n";
 145  
 146            print '<td align="center"><a href="facture.php?facid='.$obj->fk_facture.'">'.$obj->fk_facture."</a></td>\n";
 147            print "</tr>\n";
 148            $i++;
 149          }
 150            print "</table>";
 151            $db->free($resql);
 152          }
 153        else 
 154          {
 155            print $db->error() . ' ' . $sql;
 156          }      
 157      }
 158      }
 159  }
 160  else
 161  {
 162    print "Error";
 163  }
 164  
 165  print '</div>';
 166  
 167  /* ************************************************************************** */
 168  /*                                                                            */ 
 169  /* Barre d'action                                                             */ 
 170  /*                                                                            */ 
 171  /* ************************************************************************** */
 172  
 173  $db->close();
 174  
 175  llxFooter("<em>Derni&egrave;re modification $Date: 2005/10/31 10:01:27 $ 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