Subversion Repositories Applications.gtt

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 jpm 1
<?php
2
// +------------------------------------------------------------------------------------------------------+
3
// | PHP version 4.1                                                                                      |
4
// +------------------------------------------------------------------------------------------------------+
5
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// +------------------------------------------------------------------------------------------------------+
7
// | This library is free software; you can redistribute it and/or                                        |
8
// | modify it under the terms of the GNU Lesser General Public                                           |
9
// | License as published by the Free Software Foundation; either                                         |
10
// | version 2.1 of the License, or (at your option) any later version.                                   |
11
// |                                                                                                      |
12
// | This library is distributed in the hope that it will be useful,                                      |
13
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
14
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
15
// | Lesser General Public License for more details.                                                      |
16
// |                                                                                                      |
17
// | You should have received a copy of the GNU Lesser General Public                                     |
18
// | License along with this library; if not, write to the Free Software                                  |
19
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
20
// +------------------------------------------------------------------------------------------------------+
21
 
22
// |@author ABDOOL RAHEEM shaheen   shaheenar50@hotmail.com                                                 |
23
// |@version 3
24
 
25
/**
26
  * class Prevision
27
  */
28
 
29
class Prevision
30
{
31
  /**Attributes: */
32
    var $_date_prevue;
33
    var $_duree_prevue;
34
    var $_utilisateur;
35
    var $_tache;
36
 
37
  /**
38
  *fonction creant une prevision
39
  *@param u : identifiant d'un utilisateur
40
  *@param t : identifiant de la tache
41
  */
42
  function Prevision($u,$t)
43
  {
44
      $this->_utilisateur=$u;
45
      $this->_tache=$t;
46
  }
47
 
48
  /**
49
  *fonction creant une nouvelle prevision
50
  */
51
  function construirePrevision($tableau)
52
  {
53
      $this->_utilisateur=$tableau[GEST_CHAMPS_ID_UTILISATEUR];
54
      $this->_tache=$tableau[GEST_CHAMPS_ID_TACHE];
55
      $this->_date_prevue=$tableau[GEST_CHAMPS_DATE_PREVISION];
56
      $this->_duree_prevue=$tableau[GEST_CHAMPS_DUREE_PREVISION];
57
  }
58
  /**
59
   *fonction enregistrant une nouvelle prevision
60
    */
61
  function enregistrerNewPrevision()
62
  {
63
    $table=GEST_PREVISION;
64
    $champs=array(
65
        GEST_CHAMPS_ID_UTILISATEUR =>$this->_utilisateur,
66
	GEST_CHAMPS_ID_TACHE =>$this->_tache,
67
	GEST_CHAMPS_DATE_PREVISION =>$this->_date_prevue,
68
	GEST_CHAMPS_DUREE_PREVISION =>$this->_duree_prevue);
69
 
70
    $resultat =$GLOBALS['db']->autoExecute($table,$champs,DB_AUTOQUERY_INSERT);
71
    if (DB::isError($resultat)) {
72
        die($resultat->getMessage());
73
    }
74
 
75
    $j=$GLOBALS['db']->affectedRows();
76
 
77
    if ($j==1)
78
    {
79
	return 1;
80
    }elseif($j==0){
81
	return 0;
82
    }else{
83
	return -1;
84
    }
85
  }
86
 
87
  /**
88
  *fonction qui met a jour une prevision dans la base de donnees
89
  *renvoie 1 si mise a jour effectuee
90
  *renvoie -1 sinon
91
  */
92
  function mettreAJourPrevision()
93
  {
94
   $requete="UPDATE ".GEST_PREVISION.
95
            " SET ".GEST_CHAMPS_DUREE_PREVISION." = $this->_duree_prevue".
96
            " WHERE ".GEST_CHAMPS_ID_UTILISATEUR." = $this->_utilisateur".
97
            " AND ".GEST_CHAMPS_ID_TACHE." = $this->_tache".
98
            " AND ".GEST_CHAMPS_DATE_PREVISION." =\" $this->_date_prevue\"";
99
 
100
 
101
   $resultat =$GLOBALS['db']->query($requete) ;
102
 
103
   (DB::isError($resultat)) ?
104
	die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
105
 
106
   $nb_ligne_modifie = $GLOBALS['db']->affectedRows();
107
 
108
   if ($nb_ligne_modifie==1)
109
      {
110
         return 1;
111
       }
112
       else return -1;
113
 
114
 
115
  }
116
 
117
 
118
  /**
119
  *fonction renvoyant la somme des previsions faites pour une journee
120
  *par un utilisateur
121
  *@param $id : identifiant de l'utilisateur
122
  *@param $date : date pour laquelle on veut la somme
123
  @return somme des heures prevues pour ce jour par cet utilisateur
124
    */
125
  function sommeHeurePrevision($id, $date)
126
  {
127
      $requete= "SELECT SUM(".GEST_CHAMPS_DUREE_PREVISION." ) ".
128
                " FROM ".GEST_PREVISION.
129
		" WHERE ".GEST_CHAMPS_ID_UTILISATEUR." = $id ".
130
		" AND ".GEST_CHAMPS_DATE_PREVISION." =\" $date\" ";
131
	$resultat = $GLOBALS['db']->query($requete);
132
 
133
	(DB::isError($resultat)) ?
134
	  die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
135
 
136
	$ligne=$resultat->fetchRow(DB_FETCHMODE_ORDERED);
137
	return $ligne[0];
138
 
139
  }
140
  /**
141
  *fonction verifiant si une prevision a deja etet faite pour cette tache
142
  *si une duree a ete rentree pour une date, utilisateur et tache donnees
143
  *@return la duree prevue si elle xiste deja
144
  *@return 0 si aucune prevision
145
  *@return -1 si erreur
146
  */
147
  function existePrevision()
148
  {
149
      $requete= "SELECT  * ".
150
                " FROM ".GEST_PREVISION.
151
		" WHERE ".GEST_CHAMPS_ID_TACHE." = $this->_tache ".
152
		" AND ".GEST_CHAMPS_ID_UTILISATEUR." =$this->_utilisateur  ".
153
		" AND ".GEST_CHAMPS_DATE_PREVISION."=  \"$this->_date_prevue \"";
154
 
155
 
156
      $resultat = $GLOBALS['db']->query($requete);
157
 
158
      $ligne=$resultat->fetchRow(DB_FETCHMODE_ASSOC);
159
 
160
     (DB::isError($resultat)) ?
161
           die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
162
 
163
     $j=$resultat->numRows();
164
     if ($j==1)
165
    {
166
	return $ligne[GEST_CHAMPS_DUREE_PREVISION];
167
 
168
    }elseif($j==0){
169
	return 0;
170
 
171
    }else{
172
	return -1;
173
    }
174
 
175
  }
176
 
177
  /**
178
    * fonction renvoyant la duree d'une tache prevue
179
    */
180
  function getDureePrevision()
181
  {
182
    return $this->_duree_prevue;
183
  }
184
  /**
185
  *fonction renvoyant la det d'une prevision
186
  */
187
  function getDatePrevision()
188
  {
189
     return $this->_date_prevue;
190
  }
191
  /**
192
  *fonction renvoyant l'identifiant de l'utilisateur
193
  */
194
  function getIdUserPrevision()
195
  {
196
      return $this->_utilisateur;
197
  }
198
 
199
  /**
200
    *fonction creant la date de prevision
201
    * @param Date
202
    */
203
  function setDate( $date )
204
  {
205
    $this->_date_prevue=$date;
206
  }
207
 
208
 
209
  /**
210
   *fonction creant la duree
211
   *@param $Duree
212
    */
213
  function setDuree( $duree )
214
  {
215
    $this->_duree_prevue=$duree;
216
  }
217
}
218
?>