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
//fichier langues
26
include_once CHEMIN_LANGUES.'gtt_langue_fr.inc.php';
27
//classe projet
28
include_once CHEMIN_CLASSES_METIER.'gtt_projet.class.php';
29
 
30
class Tache
31
{
32
   var $_id_tache;
33
    var $_nom_tache;
34
    var $_description_tache;
35
    var $_date_debut_tache;
36
    var $_duree_prevue_tache;
37
    var $_duree_reelle_tache;
38
    var $_avancement_tache;
39
 
40
    //identifiant du projet auquel il appartient
41
    var $_projet;
42
    /*tableau des predecesseurs */
43
    var $_tab_pred= array ();
44
    /*tableau des sucesseurs */
45
   var $_tab_succ= array ();
46
    /**
47
    *constructeur
48
    */
49
    function Tache($id)
50
    {
51
	$this->_id_tache=$id;
52
    }
53
   /**
54
   *fonction construisant une nouvelle tache
55
   *avec que les options obligatoires
56
   *@param : id : identifiant de la tache
57
   *@param : proj: identifiant du projet
58
   *@pâram : nom de la tache
59
   */
60
   function construireDefaultTache($proj,$nom)
61
   {
62
       $this->_id_tache=&Tache::nextId();
63
       $this->_projet=$proj;
64
       $this->_nom_tache=$nom;
65
       $p=&Projet::recupererProjet($proj);
66
       $this->_date_debut_tache=$p->getDateDeb();
67
       $this->_duree_prevue_tache=$p->getDureePrevue();
68
 
69
   }
70
 
71
  /**
72
    *enregistre une nouvelle tache par defaut
73
    *dasn la base de donnees
74
    *renvoie 1 si tache enregistree
75
    *0 si pas d'enregistrement
76
    *-1 si erreur
77
    */
78
  function enregistrerNewDefaultTache()
79
  {
80
    $table =GEST_TACHES;
81
    //Verification si identifiant deja attribue
82
 
83
    $b=&Tache::nextId();
84
    $this->_id_tache=$b;
85
 
86
    $champs = array(
87
              GEST_CHAMPS_ID_TACHE => $this->_id_tache,
88
	      GEST_CHAMPS_ID_PROJET=>$this->_projet,
89
	      GEST_CHAMPS_NOM_TACHE=> "$this->_nom_tache",
90
	      GEST_CHAMPS_DATE_DEB_TACHE=> $this->_date_debut_tache,
91
	      GEST_CHAMPS_DUREE_PREVUE_TACHE=>$this->_duree_prevue_tache);
92
 
93
 
94
    $resultat = $GLOBALS['db']->autoExecute($table, $champs, DB_AUTOQUERY_INSERT);
95
 
96
    if (DB::isError($resultat)) {
97
    die($resultat->getMessage());
98
    }
99
 
100
   $j=$GLOBALS['db']->affectedRows();
101
   switch ($j)
102
   {
103
       case 1 : return 1;
104
       case 0 :return 0;
105
       default :return -1;
106
   }
107
  }
108
 
109
 /**
110
 *recupere l'identifiant de la tache par defaut
111
 *renvoie l'identifiant si aucune erreur
112
 *-1 si erreur
113
 */
114
  function recupererIdentifiantDefaultTache()
115
  {
116
    $requete="SELECT ".GEST_CHAMPS_ID_TACHE.
117
             " FROM ".GEST_TACHES.
118
	     " WHERE ".GEST_CHAMPS_NOM_TACHE." = \"".GESTION_NOM_TACHE_DEFAUT_L."\"";
119
 
120
    $resultat = $GLOBALS['db']->query($requete);
121
 
122
    (DB::isError($resultat)) ?
123
               die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
124
 
125
    $res = $resultat->fetchRow(DB_FETCHMODE_ORDERED);
126
    $j=$resultat->numRows();
127
    if ($j==1)
128
    {
129
	return $res[0];
130
    }else return -1;
131
  }
132
 
133
 
134
  /**
135
    *supprime une tache de la base de donnees
136
    *@param $id_projet : supprime une tache a partir de l'identifiant
137
    *de la tache
138
    */
139
  function supprimerTache($id_tache)
140
  {
141
 
142
  }
143
 
144
 
145
 
146
 
147
 /**
148
 * met a jour l'etat d'avancement d'une tache
149
 */
150
 
151
  function setAvancement($avanc)
152
  {
153
    $this->avancement_tache=$avanc;
154
  }
155
 
156
  /**
157
   *recupere l'identifiant de la prochaine categorie
158
   *de la base de donnees
159
   */
160
 
161
   function nextId()
162
   {
163
    $requete = 'SELECT MAX('.GEST_CHAMPS_ID_TACHE.') AS maxi FROM '.GEST_TACHES;
164
    $resultat = $GLOBALS['db']->query($requete);
165
    if (DB::isError($resultat) || $resultat->numRows() > 1) {
166
        return false;
167
    }
168
 
169
    $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
170
    return $ligne->maxi + 1;
171
   }
172
 
173
}
174
?>