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

   1  <?php
   2  /* Copyright (C) 2001-2004 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: liste.php,v 1.16 2005/10/31 05:19:56 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/contrat/liste.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/contrat/liste.php
  25          \ingroup    contrat
  26          \brief      Page liste des contrats
  27          \version    $Revision: 1.16 $
  28  */
  29  
  30  require ("./pre.inc.php");
  31  require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php");
  32  
  33  $langs->load("contracts");
  34  $langs->load("products");
  35  $langs->load("companies");
  36  
  37  
  38  llxHeader();
  39  
  40  $sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
  41  $sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
  42  $page = isset($_GET["page"])?$_GET["page"]:$_POST["page"];
  43  if ($page == -1) { $page = 0 ; }
  44  $limit = $conf->liste_limit;
  45  $offset = $limit * $page ;
  46  
  47  $search_nom=isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"];
  48  $search_contract=isset($_GET["search_contract"])?$_GET["search_contract"]:$_POST["search_contract"];
  49  $sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"];
  50  $statut=isset($_GET["statut"])?$_GET["statut"]:1;
  51  $socid=$_GET["socid"];
  52  
  53  if (! $sortfield) $sortfield="c.rowid";
  54  if (! $sortorder) $sortorder="DESC";
  55  
  56  // Sécurité accés client
  57  if ($user->societe_id > 0)
  58  {
  59      $action = '';
  60      $socid = $user->societe_id;
  61  }
  62  
  63  
  64  
  65  $sql = 'SELECT';
  66  $sql.= ' sum('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,';
  67  $sql.= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > sysdate()",1,0).') as nb_running,';
  68  $sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= sysdate())",1,0).') as nb_late,';
  69  $sql.= ' sum('.$db->ifsql("cd.statut=5",1,0).') as nb_closed,';
  70  $sql.= " c.rowid as cid, c.ref, c.datec, c.statut, s.nom, s.idp as sidp";
  71  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
  72  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
  73  $sql.= " WHERE c.fk_soc = s.idp ";
  74  if ($search_nom)      $sql.= " AND s.nom like '%".$search_nom."%'";
  75  if ($search_contract) $sql.= " AND c.rowid = '".$search_contract."'";
  76  if ($sall)            $sql.= " AND (s.nom like '%".$sall."%' OR cd.label like '%".$sall."%' OR cd.description like '%".$sall."%')";
  77  if ($socid > 0)       $sql.= " AND s.idp = $socid";
  78  $sql.= " GROUP BY c.rowid, c.datec, c.statut, s.nom, s.idp";
  79  $sql.= " ORDER BY $sortfield $sortorder";
  80  $sql.= $db->plimit($limit + 1 ,$offset);
  81  
  82  $resql=$db->query($sql);
  83  if ($resql)
  84  {
  85      $num = $db->num_rows($resql);
  86      $i = 0;
  87  
  88      print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num);
  89  
  90      print '<table class="liste" width="100%">';
  91  
  92      print '<tr class="liste_titre">';
  93      $param='&amp;search_contract='.$search_contract;
  94      $param.='&amp;search_nom='.$search_nom;
  95      print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","$param",'width="50"',$sortfield);
  96      print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"], "s.nom","","$param","",$sortfield);
  97      print_liste_field_titre($langs->trans("DateCreation"), $_SERVER["PHP_SELF"], "c.datec","","$param",'align="center"',$sortfield);
  98      print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"], "c.statut","","$param",'align="center"',$sortfield);
  99      print '<td class="liste_titre" width="16">'.img_statut(0,$langs->trans("ServiceStatusInitial")).'</td>';
 100      print '<td class="liste_titre" width="16">'.img_statut(4,$langs->trans("ServiceStatusRunning")).'</td>';
 101      print '<td class="liste_titre" width="16">'.img_statut(5,$langs->trans("ServiceStatusClosed")).'</td>';
 102      print "</tr>\n";
 103  
 104      print '<form method="POST" action="liste.php">';
 105      print '<tr class="liste_titre">';
 106      print '<td class="liste_titre">';
 107      print '<input type="text" class="flat" size="3" name="search_contract" value="'.stripslashes($search_contract).'">';
 108      print '</td>';
 109      print '<td class="liste_titre" valign="right">';
 110      print '<input type="text" class="flat" size="24" name="search_nom" value="'.stripslashes($search_nom).'">';
 111      print '</td>';
 112      print '<td class="liste_titre">&nbsp;</td>';
 113      print '<td class="liste_titre">&nbsp;</td>';
 114      print '<td colspan="3" class="liste_titre" align="right"><input class="liste_titre" type="image" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
 115      print "</td>";
 116      print "</tr>\n";
 117      print '</form>';
 118      $contratstatic=new Contrat($db);
 119  
 120      $now=mktime();
 121      $var=True;
 122      while ($i < min($num,$limit))
 123      {
 124          $obj = $db->fetch_object($resql);
 125          $var=!$var;
 126          print "<tr $bc[$var]>";
 127          print "<td nowrap><a href=\"fiche.php?id=$obj->cid\">";
 128          print img_object($langs->trans("ShowContract"),"contract").' '
 129                  . (isset($obj->ref) ? $obj->ref : $obj->cid) .'</a>';
 130          if ($obj->nb_late) print img_warning($langs->trans("Late"));
 131          print '</td>';
 132          print '<td><a href="../comm/fiche.php?socid='.$obj->sidp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
 133          print '<td align="center">'.dolibarr_print_date($obj->datec).'</td>';
 134          print '<td align="center">'.$contratstatic->LibStatut($obj->statut).'</td>';
 135          print '<td align="center">'.($obj->nb_initial>0?$obj->nb_initial:'').'</td>';
 136          print '<td align="center">'.($obj->nb_running+$obj->nb_late>0?$obj->nb_running+$obj->nb_late:'').'</td>';
 137          print '<td align="center">'.($obj->nb_closed>0?$obj->nb_closed:'').'</td>';
 138          print "</tr>\n";
 139          $i++;
 140      }
 141      $db->free($resql);
 142  
 143      print "</table>";
 144  
 145  }
 146  else
 147  {
 148      dolibarr_print_error($db);
 149  }
 150  
 151  
 152  $db->close();
 153  
 154  llxFooter('$Date: 2005/10/31 05:19:56 $ - $Revision: 1.16 $');
 155  ?>


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