[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 * $Id: compteur.php,v 1.4 2005/08/10 15:39:43 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/energie/compteur.php,v $ 20 * 21 */ 22 23 /** 24 \file htdocs/energie/compteur.php 25 \ingroup energie 26 \brief Fiche compteur 27 \version $Revision: 1.4 $ 28 */ 29 30 require ("./pre.inc.php"); 31 32 /* 33 * 34 */ 35 36 if ($_POST["action"] == 'add') 37 { 38 $compteur = new EnergieCompteur($db, $user); 39 40 if ( $compteur->create($_POST["libelle"],$_POST["energie"]) == 0) 41 { 42 Header("Location: compteur.php?id=".$compteur->id); 43 } 44 else 45 { 46 Header("Location: compteur.php?action=create"); 47 } 48 } 49 50 51 if ($_POST["action"] == 'addvalue') 52 { 53 if ($_POST["releve"] > 0) 54 { 55 $compteur = new EnergieCompteur($db, $user); 56 if ( $compteur->fetch($_GET["id"]) == 0) 57 { 58 $date = mktime(12, 59 0 , 60 0, 61 $_POST["remonth"], 62 $_POST["reday"], 63 $_POST["reyear"]); 64 65 $compteur->AjoutReleve($date, $_POST["releve"]); 66 Header("Location: compteur.php?id=".$_GET["id"]); 67 } 68 } 69 } 70 /* 71 * 72 */ 73 74 llxHeader($langs, '',$langs->trans("Compteur"),"Compteur"); 75 76 /********************************************************************* 77 * 78 * Mode creation 79 * 80 * 81 ************************************************************************/ 82 if ($_GET["action"] == 'create') 83 { 84 $head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?action=create'; 85 $head[0][1] = "Nouveau compteur"; 86 $h++; 87 $a = 0; 88 89 dolibarr_fiche_head($head, $a, $soc->nom); 90 91 $html = new Form($db); 92 $compteur = new EnergieCompteur($db, $user); 93 94 print '<form action="compteur.php" method="post">'; 95 print '<input type="hidden" name="action" value="add">'; 96 97 print '<table class="border" width="100%">'; 98 99 print "<tr $bc[$var]>"; 100 101 print '<td>Libellé</td>'; 102 103 print '<td><input type="text" size="40" maxlength="255" name="libelle"></td></tr>'; 104 105 print "<tr $bc[$var]>"; 106 print '<td>Energie</td><td>'; 107 print $html->select_array("energie", $compteur->energies); 108 print '</td></tr>'; 109 110 print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>'; 111 112 print "</table></form><br>"; 113 print '</div>'; 114 115 } 116 else 117 /* *************************************************************************** */ 118 /* */ 119 /* Mode vue */ 120 /* */ 121 /* *************************************************************************** */ 122 { 123 if ($_GET["id"] > 0) 124 { 125 $compteur = new EnergieCompteur($db, $user); 126 if ( $compteur->fetch($_GET["id"]) == 0) 127 { 128 129 $head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id; 130 $head[0][1] = "Compteur"; 131 $h++; 132 $a = 0; 133 134 $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id; 135 $head[$h][1] = "Graph"; 136 $h++; 137 138 $head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id; 139 $head[$h][1] = "Relevés"; 140 $h++; 141 142 $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id; 143 $head[$h][1] = "Groupe"; 144 $h++; 145 146 dolibarr_fiche_head($head, $a, $soc->nom); 147 148 149 print '<table class="border" width="100%">'; 150 print "<tr><td>".$langs->trans("Compteur")."</td>"; 151 print '<td width="50%">'; 152 print $compteur->libelle; 153 print "</td></tr>"; 154 print "</table><br>"; 155 156 157 $html = new Form($db); 158 print '<form action="compteur.php?id='.$compteur->id.'" method="post">'; 159 print '<input type="hidden" name="action" value="addvalue">'; 160 print '<table class="border" width="100%">'; 161 162 $var=!$var; 163 print "<tr $bc[$var]>"; 164 165 print '<td>Date</td><td>'; 166 print $html->select_date(); 167 print '</td><td>Valeur relevée</td>'; 168 169 print '<td align="center"><input type="text" size="11" maxlength="10" name="releve"></td>'; 170 171 print '<td align="center"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>'; 172 173 print "</table></form><br>"; 174 175 print '</div>'; 176 177 178 179 print '<table class="noborder" width="100%">'; 180 print '<tr><td><a href="compteur_graph.php?id='.$compteur->id.'">'; 181 $file = "all.".$compteur->id.".png"; 182 print '<img border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">'; 183 print '</a></td></tr></table><br>'; 184 185 print '<table class="noborder" width="100%">'; 186 print '<tr class="liste_titre"><td>'.$langs->trans("Date").'</td>'; 187 print '<td>'.$langs->trans("Relevé").'</td></tr>'; 188 189 $sql = "SELECT ".$db->pdate("date_releve")." as date_releve, valeur"; 190 $sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur_releve as ecr"; 191 $sql .= " WHERE ecr.fk_compteur = '".$compteur->id."'"; 192 $sql .= " ORDER BY ecr.date_releve DESC LIMIT 5"; 193 $resql = $db->query($sql); 194 if ($resql) 195 { 196 $num = $db->num_rows($resql); 197 $i = 0; 198 $var=True; 199 while ($i < $num) 200 { 201 $obj = $db->fetch_object($resql); 202 $var=!$var; 203 print "<tr $bc[$var]><td>"; 204 print strftime("%a %e %B %Y",$obj->date_releve); 205 print '</td><td>'.$obj->valeur.'</td>'; 206 207 $i++; 208 } 209 } 210 print '</table>'; 211 print "<br>\n"; 212 } 213 else 214 { 215 /* Commande non trouvée */ 216 print "Compteur inexistant"; 217 } 218 } 219 else 220 { 221 print "Compteur inexistant"; 222 } 223 } 224 225 $db->close(); 226 227 llxFooter("<em>Dernière modification $Date: 2005/08/10 15:39:43 $ révision $Revision: 1.4 $</em>"); 228 ?>
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 |
![]() |