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

   1  <?php
   2  /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: index.php,v 1.35 2005/12/05 20:52:44 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/fourn/facture/index.php,v $
  21   *
  22   */
  23  
  24  /**
  25          \file       htdocs/fourn/facture/index.php
  26          \ingroup    fournisseur,facture
  27          \brief      Lsite des factures fournisseurs
  28          \version    $Revision: 1.35 $
  29  */
  30  
  31  require ("./pre.inc.php");
  32  
  33  if (!$user->rights->fournisseur->facture->lire)
  34    accessforbidden();
  35  
  36  
  37  $socid = $_GET["socid"];
  38  
  39  // Sécurité accés client
  40  if ($user->societe_id > 0) 
  41  {
  42    $_GET["action"] = '';
  43    $socid = $user->societe_id;
  44  }
  45  
  46  if ($_GET["action"] == 'delete')
  47  {
  48    $fac = new FactureFournisseur($db);
  49    $fac->delete($_GET["facid"]);
  50    
  51    $facid = 0 ;
  52  }
  53  
  54  $page=$_GET["page"];
  55  $sortorder = $_GET["sortorder"];
  56  $sortfield = $_GET["sortfield"];
  57   
  58  if ($page == -1) { $page = 0 ; }
  59  $limit = $conf->liste_limit;
  60  $offset = $limit * $page ;
  61  $pageprev = $page - 1;
  62  $pagenext = $page + 1;
  63  if (! $sortorder) $sortorder="DESC";
  64  if (! $sortfield) $sortfield="fac.datef";
  65  
  66  
  67  /*
  68   * Recherche
  69   *
  70   */
  71  if ($_POST["mode"] == 'search')
  72  {
  73    if ($_POST["mode-search"] == 'soc')
  74      {
  75        $sql = "SELECT s.idp FROM ".MAIN_DB_PREFIX."societe as s ";
  76        $sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'";
  77      }
  78        
  79    if ( $db->query($sql) )
  80      {
  81        if ( $db->num_rows() == 1)
  82      {
  83        $obj = $db->fetch_object();
  84        $socid = $obj->idp;
  85      }
  86        $db->free();
  87      }
  88  }
  89    
  90  
  91  llxHeader();
  92  
  93  
  94  /*
  95   * Mode Liste
  96   *
  97   */
  98   
  99  $sql = "SELECT s.idp as socid, s.nom, ".$db->pdate("fac.date_lim_reglement")." as date_echeance, fac.total_ht, fac.total_ttc, fac.paye as paye, fac.fk_statut as fk_statut, fac.libelle, fac.rowid as facid, fac.facnumber";
 100  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as fac ";
 101  $sql .= " WHERE fac.fk_soc = s.idp";
 102  if ($socid)
 103  {
 104    $sql .= " AND s.idp = $socid";
 105  }
 106  if ($_GET["filtre"])
 107    {
 108      $filtrearr = split(",", $_GET["filtre"]);
 109      foreach ($filtrearr as $fil)
 110        {
 111      $filt = split(":", $fil);
 112      $sql .= " AND " . $filt[0] . " = " . $filt[1];
 113        }
 114    }
 115  
 116  if ($_GET["search_ref"])
 117    {
 118      $sql .= " AND fac.facnumber like '%".$_GET["search_ref"]."%'";
 119    }
 120  
 121  if ($_GET["search_libelle"])
 122    {
 123      $sql .= " AND fac.libelle like '%".$_GET["search_libelle"]."%'";
 124    }
 125  
 126  if ($_GET["search_societe"])
 127    {
 128      $sql .= " AND s.nom like '%".$_GET["search_societe"]."%'";
 129    }
 130  
 131  if ($_GET["search_montant_ht"])
 132    {
 133      $sql .= " AND fac.total_ht = '".$_GET["search_montant_ht"]."'";
 134    }
 135  
 136  if ($_GET["search_montant_ttc"])
 137    {
 138      $sql .= " AND fac.total_ttc = '".$_GET["search_montant_ttc"]."'";
 139    }
 140  
 141  $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit+1, $offset);
 142  
 143  $resql = $db->query($sql);
 144  
 145  if ($resql)
 146  {
 147      $num = $db->num_rows($resql);
 148      $i = 0;
 149  
 150      if ($socid) {
 151          $soc = new Societe($db);
 152          $soc->fetch($socid);
 153      }
 154  
 155      print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->nom":""),$page,"index.php","&amp;socidp=$socidp",$sortfield,$sortorder,'',$num);
 156  
 157      print '<table class="liste" width="100%">';
 158      print '<tr class="liste_titre">';
 159      print_liste_field_titre($langs->trans("Ref"),"index.php","facnumber","&amp;socid=$socid","","",$sortfield);
 160      print_liste_field_titre($langs->trans("DateEcheance"),"index.php","fac.datef","&amp;socid=$socid","","",$sortfield);
 161      print_liste_field_titre($langs->trans("Label"),"index.php","fac.libelle","&amp;socid=$socid","","",$sortfield);
 162      print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","&amp;socid=$socid","","",$sortfield);
 163      print_liste_field_titre($langs->trans("AmountHT"),"index.php","fac.total_ht","&amp;socid=$socid","",'align="right"',$sortfield);
 164      print_liste_field_titre($langs->trans("AmountTTC"),"index.php","fac.total_ttc","&amp;socid=$socid","",'align="right"',$sortfield);
 165      print_liste_field_titre($langs->trans("Status"),"index.php","fk_statut,paye","&amp;socid=$socid","",'align="center"',$sortfield);
 166      print "</tr>\n";
 167  
 168      // Lignes des champs de filtre
 169      print '<form method="get" action="index.php">';
 170      print '<tr class="liste_titre">';
 171      print '<td class="liste_titre" valign="right">';
 172      print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET["search_ref"].'">';
 173      print '</td><td class="liste_titre">&nbsp;</td>';
 174      print '<td class="liste_titre" align="left">';
 175      print '<input class="flat" type="text" name="search_libelle" value="'.$_GET["search_libelle"].'">';
 176      print '</td>';
 177      print '<td class="liste_titre" align="left">';
 178      print '<input class="flat" type="text" name="search_societe" value="'.$_GET["search_societe"].'" size="12">';
 179      print '</td><td class="liste_titre" align="right">';
 180      print '<input class="flat" type="text" size="8" name="search_montant_ht" value="'.$_GET["search_montant_ht"].'">';
 181      print '</td><td class="liste_titre" align="right">';
 182      print '<input class="flat" type="text" size="8" name="search_montant_ttc" value="'.$_GET["search_montant_ttc"].'">';
 183      print '</td><td class="liste_titre" colspan="2" align="center">';
 184      print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
 185      print '</td>';
 186      print "</tr>\n";
 187      print '</form>';
 188  
 189      $fac = new FactureFournisseur($db);
 190  
 191      $var=true;
 192      $total=0;
 193      $total_ttc=0;
 194      while ($i < min($num,$limit))
 195        {
 196          $obj = $db->fetch_object($resql);
 197          $var=!$var;
 198  
 199          print "<tr $bc[$var]>";
 200          print '<td nowrap><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$obj->facid.'" title="'.$obj->facnumber.'">'.img_object($langs->trans("ShowBill"),"bill").' '.dolibarr_trunc($obj->facnumber,20)."</a></td>\n";
 201          print '<td align="center" nowrap>'.dolibarr_print_date($obj->date_echeance).'</td>';
 202          print '<td>'.dolibarr_trunc(stripslashes("$obj->libelle"),44).'</td>';
 203          print '<td>';
 204          print '<a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"),"company").' '.$obj->nom.'</a</td>';
 205          print '<td align="right">'.price($obj->total_ht).'</td>';
 206          print '<td align="right">'.price($obj->total_ttc).'</td>';
 207          $total+=$obj->total_ht;
 208          $total_ttc+=$obj->total_ttc;
 209  
 210          // Affiche statut de la facture
 211          if ($obj->paye)
 212          {
 213        $class = "normal";
 214          }
 215          else
 216        {
 217              if ($obj->fk_statut == 0)
 218            {
 219                  $class = "normal";
 220            }
 221              else
 222            {
 223                  $class = "impayee";
 224            }
 225        }
 226      
 227          print '<td align="center">';
 228          if (! $obj->paye)
 229          {
 230        if ($obj->fk_statut == 0)
 231              {
 232            print $fac->PayedLibStatut($obj->paye,$obj->fk_statut);
 233              }
 234        elseif ($obj->fk_statut == 3)
 235              {
 236            print $fac->PayedLibStatut($obj->paye,$obj->fk_statut);
 237              }
 238        else
 239              {
 240            // \todo  le montant deja payé obj->am n'est pas définie
 241            print '<a class="'.$class.'" href=""index.php?filtre=paye:0,fk_statut:1">'.($fac->PayedLibStatut($obj->paye,$obj->fk_statut,$obj->am)).'</a>';
 242              }
 243          }
 244          else
 245        {
 246              print $fac->PayedLibStatut($obj->paye,$obj->fk_statut);
 247        }
 248          print '</td>';
 249      
 250          print "</tr>\n";
 251          $i++;
 252      
 253          if ($i == min($num,$limit)) {
 254        // Print total
 255        print '<tr class="liste_total">';
 256        print '<td class="liste_total" colspan="4" align="left">'.$langs->trans("Total").'</td>';
 257        print '<td class="liste_total" align="right">'.price($total).'</td>';
 258        print '<td class="liste_total" align="right">'.price($total_ttc).'</td>';
 259        print '<td class="liste_total" align="center">&nbsp;</td>';
 260        print "</tr>\n";
 261          }
 262        }
 263      
 264      print "</table>";
 265      $db->free($resql);
 266  }
 267  else
 268  {
 269    dolibarr_print_error($db);
 270  }
 271  
 272  $db->close();
 273  
 274  
 275  llxFooter('$Date: 2005/12/05 20:52:44 $ - $Revision: 1.35 $');
 276  ?>


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