[ Index ] |
|
Code source de Dolibarr 2.0.1 |
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: index.php,v 1.45 2005/11/07 22:33:58 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/contrat/index.php,v $ 21 */ 22 23 /** 24 \file htdocs/contrat/index.php 25 \ingroup contrat 26 \brief Page liste des contrats 27 \version $Revision: 1.45 $ 28 */ 29 30 require ("./pre.inc.php"); 31 require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); 32 33 $langs->load("products"); 34 $langs->load("companies"); 35 36 37 llxHeader(); 38 39 $sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; 40 $sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; 41 $page = isset($_GET["page"])?$_GET["page"]:$_POST["page"]; 42 43 $statut=isset($_GET["statut"])?$_GET["statut"]:1; 44 45 // Sécurité accés client 46 $socidp=''; 47 if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; } 48 if ($user->societe_id > 0) 49 { 50 $action = ''; 51 $socidp = $user->societe_id; 52 } 53 54 print_fiche_titre($langs->trans("ContractsArea")); 55 56 57 print '<table class="notopnoleftnoright" width="100%">'; 58 59 print '<tr><td width="30%" valign="top" class="notopnoleft">'; 60 61 /* 62 * Recherche Contrat 63 */ 64 if ($conf->contrat->enabled) 65 { 66 $var=false; 67 print '<form method="post" action="'.DOL_URL_ROOT.'/contrat/liste.php">'; 68 print '<table class="noborder" width="100%">'; 69 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAContract").'</td></tr>'; 70 print '<tr '.$bc[$var].'>'; 71 print '<td nowrap>'.$langs->trans("Ref").':</td><td><input type="text" class="flat" name="search_contract" size="18"></td>'; 72 print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>'; 73 print '<tr '.$bc[$var].'><td nowrap>'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>'; 74 print '</tr>'; 75 print "</table></form>\n"; 76 print "<br>"; 77 } 78 79 // Légende 80 $var=false; 81 print '<table class="noborder" width="100%">'; 82 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("ServicesLegend").'</td></tr>'; 83 print '<tr '.$bc[$var].'><td nowrap>'; 84 print img_statut(0,$langs->trans("ServiceStatusInitial")).' '.$langs->trans("ServiceStatusInitial").'<br />'; 85 print img_statut(4,$langs->trans("ServiceStatusRunning")).' '.$langs->trans("ServiceStatusRunning").'<br />'; 86 print img_statut(5,$langs->trans("ServiceStatusClosed")).' '.$langs->trans("ServiceStatusClosed").'<br />'; 87 print '</td></tr>'; 88 print '</table>'; 89 90 91 print '</td><td width="70%" valign="top" class="notopnoleftnoright">'; 92 93 94 // Last contracts 95 $max=5; 96 $sql = 'SELECT '; 97 $sql.= ' sum('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,'; 98 $sql.= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > sysdate()",1,0).') as nb_running,'; 99 $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,'; 100 $sql.= ' sum('.$db->ifsql("cd.statut=5",1,0).') as nb_closed,'; 101 $sql.= " c.rowid as cid, c.ref, c.datec, c.statut, s.nom, s.idp as sidp"; 102 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; 103 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; 104 $sql.= " WHERE c.fk_soc = s.idp "; 105 if ($socidp > 0) $sql .= " AND s.idp = ".$socidp; 106 $sql.= " GROUP BY c.rowid, c.datec, c.statut, s.nom, s.idp"; 107 $sql.= " ORDER BY c.datec DESC"; 108 $sql.= " LIMIT $max"; 109 110 $result=$db->query($sql); 111 if ($result) 112 { 113 $num = $db->num_rows($result); 114 $i = 0; 115 116 print '<table class="noborder" width="100%">'; 117 118 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("LastContracts",5).'</td>'; 119 print '<td align="center">'.$langs->trans("DateCreation").'</td>'; 120 print '<td align="center">'.$langs->trans("Status").'</td>'; 121 print '<td width="16">'.img_statut(0,$langs->trans("ServiceStatusInitial")).'</td>'; 122 print '<td width="16">'.img_statut(4,$langs->trans("ServiceStatusRunning")).'</td>'; 123 print '<td width="16">'.img_statut(5,$langs->trans("ServiceStatusClosed")).'</td>'; 124 print "</tr>\n"; 125 126 $contratstatic=new Contrat($db); 127 128 $var=True; 129 while ($i < $num) 130 { 131 $obj = $db->fetch_object($result); 132 $var=!$var; 133 134 print "<tr $bc[$var]>"; 135 print "<td><a href=\"fiche.php?id=$obj->cid\">"; 136 print img_object($langs->trans("ShowContract"),"contract").' ' 137 . (isset($obj->ref) ? $obj->ref : $obj->cid).'</a>'; 138 if ($obj->nb_late) print img_warning($langs->trans("Late")); 139 print '</td>'; 140 print '<td><a href="../comm/fiche.php?socid='.$obj->sidp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>'; 141 print '<td align="center">'.dolibarr_print_date($obj->datec).'</td>'; 142 print '<td align="center">'.$contratstatic->LibStatut($obj->statut).'</td>'; 143 print '<td align="center">'.($obj->nb_initial>0?$obj->nb_initial:'').'</td>'; 144 print '<td align="center">'.($obj->nb_running+$obj->nb_late>0?$obj->nb_running+$obj->nb_late:'').'</td>'; 145 print '<td align="center">'.($obj->nb_closed>0?$obj->nb_closed:'').'</td>'; 146 print "</tr>\n"; 147 $i++; 148 } 149 $db->free($result); 150 151 print "</table>"; 152 153 } 154 else 155 { 156 dolibarr_print_error($db); 157 } 158 159 print '<br>'; 160 161 162 // Not activated services 163 $sql = "SELECT cd.rowid as cid, c.ref, cd.statut, cd.label, cd.description as note, cd.fk_contrat, c.fk_soc, s.nom"; 164 $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; 165 $sql.= " WHERE c.statut=1 AND cd.statut = 0"; 166 $sql.= " AND cd.fk_contrat = c.rowid AND c.fk_soc = s.idp"; 167 if ($socidp > 0) $sql.= " AND s.idp = ".$socidp; 168 $sql.= " ORDER BY cd.tms DESC"; 169 170 if ( $db->query($sql) ) 171 { 172 $num = $db->num_rows(); 173 $i = 0; 174 175 print '<table class="noborder" width="100%">'; 176 177 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("NotActivatedServices").'</td>'; 178 print "</tr>\n"; 179 180 $var=True; 181 while ($i < $num) 182 { 183 $obj = $db->fetch_object(); 184 $var=!$var; 185 print "<tr $bc[$var]>"; 186 187 print '<td width="50"><a href="'.DOL_URL_ROOT.'/contrat/fiche.php?id='.$obj->fk_contrat.'">'.img_object($langs->trans("ShowContract"),"contract").' ' 188 .(isset($obj->ref) ? $obj->ref : $obj->fk_contrat).'</a></td>'; 189 print '<td><a href="'.DOL_URL_ROOT.'/contrat/fiche.php?id='.$obj->fk_contrat.'">'.img_object($langs->trans("ShowService"),"service"); 190 if ($obj->label) print ' '.dolibarr_trunc($obj->label,20).'</a></td>'; 191 else print '</a> '.dolibarr_trunc($obj->note,20).'</td>'; 192 print '<td><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$obj->fk_soc.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,44).'</a></td>'; 193 print '<td width="16"><a href="ligne.php?id='.$obj->fk_contrat.'&ligne='.$obj->cid.'"><img src="./statut'.$obj->statut.'.png" border="0" alt="statut"></a></td>'; 194 print "</tr>\n"; 195 $i++; 196 } 197 $db->free(); 198 199 print "</table>"; 200 201 } 202 else 203 { 204 dolibarr_print_error($db); 205 } 206 207 print '<br>'; 208 209 // Last modified services 210 $max=5; 211 212 $sql = "SELECT cd.rowid as cid, c.ref, cd.statut, cd.label, cd.description as note, cd.fk_contrat, c.fk_soc, s.nom"; 213 $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; 214 $sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.idp"; 215 if ($socidp > 0) $sql.= " AND s.idp = ".$socidp; 216 $sql.= " ORDER BY cd.tms DESC"; 217 218 if ( $db->query($sql) ) 219 { 220 $num = $db->num_rows(); 221 $i = 0; 222 223 print '<table class="noborder" width="100%">'; 224 225 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("LastModifiedServices",min($num,$max)).'</td>'; 226 print "</tr>\n"; 227 228 $var=True; 229 while ($i < min($num,$max)) 230 { 231 $obj = $db->fetch_object(); 232 $var=!$var; 233 print "<tr $bc[$var]>"; 234 // width="50" nowrap 235 print '<td><a href="'.DOL_URL_ROOT.'/contrat/fiche.php?id='.$obj->fk_contrat.'">'.img_object($langs->trans("ShowContract"),"contract").' ' 236 .(isset($obj->ref) ? $obj->ref : $obj->fk_contrat).'</a>'; 237 if ($obj->nb_late) print img_warning($langs->trans("Late")); 238 print '</td>'; 239 print '<td><a href="'.DOL_URL_ROOT.'/contrat/fiche.php?id='.$obj->fk_contrat.'">'.img_object($langs->trans("ShowService"),"service"); 240 if ($obj->label) print ' '.dolibarr_trunc($obj->label,20).'</a></td>'; 241 else print '</a> '.dolibarr_trunc($obj->note,20).'</td>'; 242 print '<td><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$obj->fk_soc.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,44).'</a></td>'; 243 print '<td width="16"><a href="ligne.php?id='.$obj->fk_contrat.'&ligne='.$obj->cid.'"><img src="./statut'.$obj->statut.'.png" border="0" alt="statut"></a></td>'; 244 print "</tr>\n"; 245 $i++; 246 } 247 $db->free(); 248 249 print "</table>"; 250 251 } 252 else 253 { 254 dolibarr_print_error($db); 255 } 256 257 print '</td></tr></table>'; 258 259 print '<br>'; 260 261 $db->close(); 262 263 llxFooter('$Date: 2005/11/07 22:33:58 $ - $Revision: 1.45 $'); 264 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |