* Copyright (C) 2004 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ * */ /*! \file htdocs/contrat/contrat.class.php \ingroup contrat \brief Fichier de la classe des contrats \version $Revision$ */ require("./pre.inc.php"); $langs->load("products"); $langs->load("companies"); llxHeader(); $sortorder=$_GET["sortorder"]; $sortfield=$_GET["sortfield"]; $page=$_GET["page"]; $statut=isset($_GET["statut"])?$_GET["statut"]:1; $socid=$_GET["socid"]; /* * Sécurité accés client */ if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } if ($page == -1) { $page = 0 ; } $limit = $conf->liste_limit; $offset = $limit * $page ; if ($sortfield == "") { $sortfield="c.tms"; } if ($sortorder == "") { $sortorder="DESC"; } $sql = "SELECT c.rowid as cid, c.enservice, ".$db->pdate("c.fin_validite")." as fin_validite, c.fin_validite-sysdate() as delairestant, p.label, p.rowid as pid, s.nom, s.idp as sidp"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE c.fk_soc = s.idp AND c.fk_product = p.rowid"; if ($socid > 0) { $sql .= " AND s.idp = $socid"; } $sql .= " ORDER BY $sortfield $sortorder, delairestant"; $sql .= $db->plimit($limit + 1 ,$offset); if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; print_barre_liste("Liste des contrats", $page, "index.php", "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num); print ''; print ''; print ''; print ''; print "\n"; $now=mktime(); $var=True; while ($i < min($num,$limit)) { $obj = $db->fetch_object( $i); $var=!$var; print ""; print "\n"; print "\n"; print "\n"; // Affiche statut contrat if ($obj->enservice == 1) { if (! $obj->fin_validite || $obj->fin_validite >= $now) { $class = 'normal'; $statut= $langs->trans("ContractStatusRunning"); } else { $class = 'error'; $statut= $langs->trans("ContractStatusRunning").', '.img_warning().' '.$langs->trans("ContractStatusExpired"); } } elseif($obj->enservice == 2) { $class = "normal"; $statut= $langs->trans("Closed"); } else { $class = "warning"; $statut= $langs->trans("ContractStatusToRun"); } print ""; print "\n"; print ''; print "\n"; $i++; } $db->free(); print "
'; print_liste_field_titre($langs->trans("Ref"),"index.php", "c.rowid"); print ""; print_liste_field_titre($langs->trans("Label"),"index.php", "p.label"); print ""; print_liste_field_titre($langs->trans("Company"),"index.php", "s.nom"); print ''; print_liste_field_titre($langs->trans("Status"),"index.php", "c.enservice"); print ''; print_liste_field_titre("Date Fin","index.php", "c.fin_validite"); print ''; print_liste_field_titre($langs->trans("Action"),"index.php", "c.next"); print '
cid\">"; print img_file(); print " cid\">$obj->cidpid\">$obj->labelsidp\">$obj->nom"; print "$statut"; print ""; if ($obj->enservice > 0) { print dolibarr_print_date($obj->fin_validite); } else { print " "; } print "'; // \todo Créer action "Renouveler" print '
"; } else { dolibarr_print_error($db); } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>