[ 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/facture/ -> liste.php (source)

   1  <?PHP
   2  /* Copyright (C) 2004 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: liste.php,v 1.9 2005/12/02 10:42:52 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/facture/liste.php,v $
  20   *
  21   */
  22  require ("./pre.inc.php");
  23  
  24  if (!$user->rights->telephonie->facture->lire) accessforbidden();
  25  
  26  $page = $_GET["page"];
  27  $sortorder = $_GET["sortorder"];
  28  $sortfield = $_GET["sortfield"];
  29  
  30  llxHeader();
  31  
  32  /*
  33   * Sécurité accés client
  34   */
  35  if ($user->societe_id > 0) 
  36  {
  37    $action = '';
  38    $socidp = $user->societe_id;
  39  }
  40  
  41  if ($sortorder == "") {
  42    $sortorder="";
  43  }
  44  if ($sortfield == "") {
  45    $sortfield="f.date DESC, f.gain ASC";
  46  }
  47  
  48  /*
  49   * Recherche
  50   *
  51   *
  52   */
  53  
  54  if ($page == -1) { $page = 0 ; }
  55  
  56  $offset = $conf->liste_limit * $page ;
  57  $pageprev = $page - 1;
  58  $pagenext = $page + 1;
  59  
  60  /*
  61   * Mode Liste
  62   *
  63   *
  64   *
  65   */
  66  
  67  $sql = "SELECT f.rowid, f.date, f.ligne, f.fourn_montant, f.cout_vente, f.gain, f.fk_facture";
  68  $sql .= " ,s.nom, s.idp";
  69  $sql .= " , fac.facnumber as ref";
  70  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f";
  71  $sql .= " , ".MAIN_DB_PREFIX."societe as s";
  72  $sql .= " , ".MAIN_DB_PREFIX."facture as fac";
  73  $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
  74  $sql .= ",".MAIN_DB_PREFIX."societe_perms as sp";
  75  
  76  $sql .= " WHERE s.idp = l.fk_soc_facture AND l.rowid = f.fk_ligne";
  77  $sql .= " AND l.fk_soc_facture = s.idp";
  78  $sql .= " AND l.fk_client_comm = sp.fk_soc";
  79  $sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1";
  80  
  81  $sql .= " AND f.fk_facture = fac.rowid";
  82  
  83  if ($_GET["search_ligne"])
  84  {
  85    $sql .= " AND f.ligne LIKE '%".$_GET["search_ligne"]."%'";
  86  }
  87  
  88  if ($_GET["search_client"])
  89  {
  90    $sql .= " AND s.nom LIKE '%".$_GET["search_client"]."%'";
  91  }
  92  
  93  if ($_GET["search_facture"])
  94  {
  95    $sql .= " AND fac.facnumber LIKE '%".$_GET["search_facture"]."%'";
  96  }
  97  
  98  $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
  99  
 100  $result = $db->query($sql);
 101  if ($result)
 102  {
 103    $num = $db->num_rows();
 104    $i = 0;
 105    
 106    print_barre_liste("Factures", $page, "liste.php", "", $sortfield, $sortorder, '', $num);
 107  
 108    print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
 109    print '<tr class="liste_titre">';
 110    print_liste_field_titre("Client","liste.php","s.nom");
 111  
 112    print_liste_field_titre("Ligne","liste.php","l.ligne");
 113    print '<td align="center">Date</td><td align="right">Montant HT</td>';
 114  
 115    if ($user->rights->telephonie->ligne->gain)
 116      {
 117        print '<td align="right">Coût fournisseur HT</td>';
 118        print_liste_field_titre("Marge","liste.php","f.gain",'','','align="right"');
 119      }
 120    print '<td align="center">Facture</td>';
 121    print "</tr>\n";
 122  
 123    print '<tr class="liste_titre">';
 124    print '<form action="liste.php" method="GET">';
 125    print '<td><input type="text" name="search_client" size="20" value="'.$_GET["search_client"].'"></td>';
 126    print '<td><input type="text" name="search_ligne" size="20" value="'.$_GET["search_ligne"].'"></td>';
 127  
 128    print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td>';
 129  
 130    print '<td>&nbsp;</td>';
 131  
 132    if ($user->rights->telephonie->ligne->gain)
 133      {
 134        print '<td>&nbsp;</td>';
 135        print '<td>&nbsp;</td>';
 136      }
 137  
 138    print '<td align="center" ><input type="text" name="search_facture" size="8" maxlength="10" value="'.$_GET["search_facture"].'"></td>';
 139    print '</form>';
 140    print '</tr>';
 141  
 142  
 143    $var=True;
 144  
 145    $ligne = new LigneTel($db);
 146  
 147    while ($i < min($num,$conf->liste_limit))
 148      {
 149        $obj = $db->fetch_object($i);    
 150        $var=!$var;
 151  
 152        print "<tr $bc[$var]>";
 153  
 154        print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">';
 155        print img_file();      
 156        print '</a>&nbsp;';
 157  
 158        print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->idp.'">'.$obj->nom."</a></td>\n";
 159        print '<td><a href="'.DOL_URL_ROOT.'/telephonie/ligne/fiche.php?numero='.$obj->ligne.'">'.dolibarr_print_phone($obj->ligne)."</a></td>\n";
 160        print '<td align="center">'.$obj->date."</td>\n";
 161        print '<td align="right">'.sprintf("%01.4f",$obj->cout_vente)."</td>\n";
 162  
 163        if ($user->rights->telephonie->ligne->gain)
 164      {
 165        print '<td align="right">'.sprintf("%01.4f",$obj->fourn_montant)."</td>\n";
 166  
 167        print '<td align="right">';
 168        if ($obj->gain < 0 && $obj->cout_vente)
 169          {
 170            print '<font color="red"><b>';
 171            print sprintf("%01.4f",$obj->gain);
 172            print "</b></font>";
 173          }
 174        else
 175          {
 176            print sprintf("%01.4f",$obj->gain);
 177          }
 178        print "</td>\n";
 179      }
 180        print '<td align="center"><a href="'.DOL_URL_ROOT.'/telephonie/client/facture.php?facid='.$obj->fk_facture.'">'.$obj->ref."</a></td>\n";
 181        print "</tr>\n";
 182        $i++;
 183      }
 184    print "</table>";
 185    $db->free();
 186  }
 187  else 
 188  {
 189    print $db->error() . ' ' . $sql;
 190  }
 191  
 192  $db->close();
 193  
 194  llxFooter("<em>Derni&egrave;re modification $Date: 2005/12/02 10:42:52 $ r&eacute;vision $Revision: 1.9 $</em>");
 195  ?>


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