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

   1  <?php
   2  /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004      Éric Seigne          <eric.seigne@ryxeo.com>
   4   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   5   *
   6   * This program is free software; you can redistribute it and/or modify
   7   * it under the terms of the GNU General Public License as published by
   8   * the Free Software Foundation; either version 2 of the License, or
   9   * (at your option) any later version.
  10   *
  11   * This program is distributed in the hope that it will be useful,
  12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14   * GNU General Public License for more details.
  15   *
  16   * You should have received a copy of the GNU General Public License
  17   * along with this program; if not, write to the Free Software
  18   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19   *
  20   * $Id: impayees.php,v 1.19 2005/11/12 21:10:02 eldy Exp $
  21   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/facture/impayees.php,v $
  22   */
  23  
  24  /**
  25          \file       htdocs/compta/facture.php
  26          \ingroup    facture
  27          \brief      Page de création d'une facture
  28          \version    $Revision: 1.19 $
  29  */
  30  
  31  require ("./pre.inc.php");
  32  require_once (DOL_DOCUMENT_ROOT."/facture.class.php");
  33  require_once(DOL_DOCUMENT_ROOT."/paiement.class.php");
  34  
  35  $user->getrights('facture');
  36  $user->getrights('banque');
  37  
  38  if (!$user->rights->facture->lire)
  39    accessforbidden();
  40  
  41  $langs->load("main"); // BUG De chargement de traduction ne pas modifier cette ligne
  42  $langs->load("bills");
  43  
  44  
  45  
  46  if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; }
  47  
  48  // Sécurité accés client
  49  if ($user->societe_id > 0)
  50  {
  51    $action = '';
  52    $socidp = $user->societe_id;
  53  }
  54  
  55  
  56  llxHeader('',$langs->trans("BillsCustomersUnpayed"));
  57  
  58  
  59  /***************************************************************************
  60  *                                                                         *
  61  *                      Mode Liste                                         *
  62  *                                                                         *
  63  ***************************************************************************/
  64  $page = $_GET["page"];
  65  $sortfield=$_GET["sortfield"];
  66  $sortorder=$_GET["sortorder"];
  67  if (! $sortfield) $sortfield="f.date_lim_reglement";
  68  if (! $sortorder) $sortorder="ASC";
  69  
  70  if ($user->rights->facture->lire)
  71  {
  72    $limit = $conf->liste_limit;
  73    $offset = $limit * $page ;
  74    
  75    $sql = "SELECT s.nom,s.idp,f.facnumber,f.increment,f.total,f.total_ttc,";
  76    $sql.= $db->pdate("f.datef")." as df, ".$db->pdate("f.date_lim_reglement")." as datelimite, ";
  77    $sql.= " f.paye as paye, f.rowid as facid, f.fk_statut, sum(pf.amount) as am";
  78    $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
  79    $sql.= ",".MAIN_DB_PREFIX."facture as f";
  80    $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture ";
  81    $sql.= " WHERE f.fk_soc = s.idp";
  82    $sql.= " AND f.paye = 0 AND f.fk_statut = 1";
  83    if ($socidp) $sql .= " AND s.idp = $socidp";
  84    
  85    if ($_GET["filtre"])
  86      {
  87        $filtrearr = split(",", $_GET["filtre"]);
  88        foreach ($filtrearr as $fil)
  89          {
  90        $filt = split(":", $fil);
  91        $sql .= " AND " . $filt[0] . " = " . $filt[1];
  92          }
  93      }
  94    
  95    if ($_GET["search_ref"])
  96      {
  97        $sql .= " AND f.facnumber like '%".$_GET["search_ref"]."%'";
  98      }
  99    
 100    if ($_GET["search_societe"])
 101      {
 102        $sql .= " AND s.nom like '%".$_GET["search_societe"]."%'";
 103      }
 104    
 105    if ($_GET["search_montant_ht"])
 106      {
 107        $sql .= " AND f.total = '".$_GET["search_montant_ht"]."'";
 108      }
 109    
 110    if ($_GET["search_montant_ttc"])
 111      {
 112        $sql .= " AND f.total_ttc = '".$_GET["search_montant_ttc"]."'";
 113      }
 114    
 115    if (strlen($_POST["sf_ref"]) > 0)
 116      {
 117        $sql .= " AND f.facnumber like '%".$_POST["sf_ref"] . "%'";
 118      }
 119      $sql.= " GROUP BY f.facnumber";
 120  
 121      $sql.= " ORDER BY ";
 122      $listfield=split(',',$sortfield);
 123      foreach ($listfield as $key => $value) $sql.=$listfield[$key]." ".$sortorder.",";
 124      $sql.= " f.facnumber DESC";
 125  
 126      //$sql .= $db->plimit($limit+1,$offset);
 127  
 128      $result = $db->query($sql);
 129  
 130      if ($result)
 131      {
 132        $num = $db->num_rows($result);
 133        
 134        if ($socidp)
 135          {
 136        $soc = new Societe($db);
 137        $soc->fetch($socidp);
 138          }
 139        
 140        $titre=($socidp?$langs->trans("BillsCustomersUnpayedForCompany",$soc->nom):$langs->trans("BillsCustomersUnpayed"));
 141        print_barre_liste($titre,$page,"impayees.php","&amp;socidp=$socidp",$sortfield,$sortorder,'',$num);
 142        $i = 0;
 143        print '<table class="liste" width="100%">';
 144        print '<tr class="liste_titre">';
 145        
 146        print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","","&amp;socidp=$socidp","",$sortfield);
 147        print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","","&amp;socidp=$socidp",'align="center"',$sortfield);
 148        print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","","&amp;socidp=$socidp",'align="center"',$sortfield);
 149        print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&amp;socidp=$socidp","",$sortfield);
 150        print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total","","&amp;socidp=$socidp",'align="right"',$sortfield);
 151        print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","","&amp;socidp=$socidp",'align="right"',$sortfield);
 152        print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","","&amp;socidp=$socidp",'align="right"',$sortfield);
 153        print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye","","&amp;socidp=$socidp",'align="right"',$sortfield);
 154        print "</tr>\n";
 155        
 156        // Lignes des champs de filtre
 157        print '<form method="get" action="impayees.php">';
 158        print '<tr class="liste_titre">';
 159        print '<td class="liste_titre" valign="right">';
 160        print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET["search_ref"].'"></td>';
 161        print '<td class="liste_titre">&nbsp;</td>';
 162        print '<td class="liste_titre">&nbsp;</td>';
 163        print '<td class="liste_titre" align="left">';
 164        print '<input class="flat" type="text" name="search_societe" value="'.$_GET["search_societe"].'">';
 165        print '</td><td class="liste_titre" align="right">';
 166        print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$_GET["search_montant_ht"].'">';
 167        print '</td><td class="liste_titre" align="right">';
 168        print '<input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$_GET["search_montant_ttc"].'">';
 169        print '</td><td class="liste_titre" colspan="2" align="right">';
 170        print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
 171        print '</td>';
 172        print "</tr>\n";
 173        print '</form>';
 174        
 175        if ($num > 0)
 176          {
 177        $var=True;
 178        $total=0;
 179        $totalrecu=0;
 180        
 181        while ($i < $num)
 182              {
 183            $objp = $db->fetch_object($result);
 184            
 185                  $var=!$var;
 186          
 187                  print "<tr $bc[$var]>";
 188                  $class = "impayee";
 189          
 190                  print '<td nowrap><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill")."</a> ";
 191                  print '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.$objp->facnumber.'</a>'.$objp->increment;
 192                  if ($objp->datelimite < (time() - $conf->facture->client->warning_delay) && ! $objp->paye && $objp->fk_statut == 1) print img_warning($langs->trans("Late"));
 193                  print "</td>\n";
 194  
 195                  print "<td nowrap align=\"center\">".dolibarr_print_date($objp->df)."</td>\n";
 196                  print "<td nowrap align=\"center\">".dolibarr_print_date($objp->datelimite)."</td>\n";
 197  
 198                  print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,32).'</a></td>';
 199  
 200                  print "<td align=\"right\">".price($objp->total)."</td>";
 201                  print "<td align=\"right\">".price($objp->total_ttc)."</td>";
 202                  print "<td align=\"right\">".price($objp->am)."</td>";
 203  
 204                  // Affiche statut de la facture
 205                  if (! $objp->paye)
 206                  {
 207                      if ($objp->fk_statut == 0)
 208                      {
 209                          print '<td align="center">'.$langs->trans("BillShortStatusDraft").'</td>';
 210                      }
 211                      elseif ($objp->fk_statut == 3)
 212                      {
 213                          print '<td align="center">'.$langs->trans("BillShortStatusCanceled").'</td>';
 214                      }
 215                      else
 216                      {
 217                          print '<td align="center"><a class="'.$class.'" href="'.$_SERVER["PHP_SELF"].'?filtre=paye:0,fk_statut:1">'.($objp->am?$langs->trans("BillShortStatusStarted"):$langs->trans("BillShortStatusNotPayed")).'</a></td>';
 218                      }
 219                  }
 220                  else
 221                  {
 222                      print '<td align="center">'.$langs->trans("BillShortStatusPayed").'</td>';
 223                  }
 224  
 225                  print "</tr>\n";
 226                  $total+=$objp->total;
 227                  $total_ttc+=$objp->total_ttc;
 228                  $totalrecu+=$objp->am;
 229  
 230                  $i++;
 231              }
 232  
 233              print '<tr class="liste_total">';
 234              print "<td colspan=\"4\" align=\"left\">".$langs->trans("Total").": </td>";
 235              print "<td align=\"right\"><b>".price($total)."</b></td>";
 236              print "<td align=\"right\"><b>".price($total_ttc)."</b></td>";
 237              print "<td align=\"right\"><b>".price($totalrecu)."</b></td>";
 238              print '<td align="center">&nbsp;</td>';
 239              print "</tr>\n";
 240          }
 241  
 242          print "</table>";
 243          $db->free();
 244      }
 245      else
 246      {
 247          dolibarr_print_error($db);
 248      }
 249  
 250  }
 251  
 252  
 253  
 254  
 255  $db->close();
 256  
 257  llxFooter("<em>Derni&egrave;re modification $Date: 2005/11/12 21:10:02 $ r&eacute;vision $Revision: 1.19 $</em>");
 258  ?>


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