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 Frais
27
{
28
 
29
 /**Attributes: */
30
 
31
    var $_id_frais; /*identifiant du frais equivalent au numero du plan comptable*/
32
    var $_libelle_frais;/*libelle  du plan comptable */
33
    var $_date_frais;/*date des frais */
34
    var $_utilisateur;/*utilisateur ayant occasioné la note de frais */
35
 
36
   /*constructeur */
37
 
38
  function Frais($id)
39
  {
40
      $this->_id_frais=$id;
41
  }
42
 
43
  /*
44
  *construit un frais a partir d'un tableau
45
  */
46
 
47
  function ConstruireFrais($tableau)
48
  {
49
   $this->_id_frais =$tableau[GEST_CHAMPS_ID_FRAIS];
50
   $this->_libelle_frais = $tableau[ GEST_CHAMPS_LIBELLE_FRAIS];
51
   $this->_date_frais = $tableau[GEST_CHAMPS_DATE_FRAIS];
52
   $this->_utilisateur = $tableau[GEST_CHAMPS_ID_UTILISATEUR];
53
  }
54
 
55
   /*accesseur */
56
   function getIdFrais()
57
   {
58
      return $this->_id_frais;
59
   }
60
 
61
   function getUtilisateur()
62
   {
63
	   return $this->_utilisateur;
64
   }
65
 
66
   function getDateFrais()
67
   {
68
	   return $this->_date_frais;
69
   }
70
 
71
/**enregistrer les frais dans la base de donnees
72
*enreigistre que l'identifiant et le libelle dans la table gestion_note_frais
73
*/
74
 
75
  function enregistrerFrais()
76
  {
77
 
78
	$table = GEST_FRAIS;
79
 
80
 
81
	$champs = array(
82
	GEST_CHAMPS_ID_FRAIS => $this_id_frais,
83
	GEST_CHAMPS_LIBELLE_FRAIS => "$this->_libelle_frais"
84
	);
85
	$resultat = $GLOBALS['db']->autoExecute($table, $champs, DB_AUTOQUERY_INSERT);
86
 
87
 
88
   	if (DB::isError($resultat)) {
89
	    die($resultat->getMessage());
90
	}
91
 
92
  }
93
 
94
  /**recuperer un frais de la base de donnees
95
  *pour pouvoir instancier l'objet frais
96
  *ne recupere que l'identifiant et le libelle*/
97
 
98
  function recupererFrais()
99
  {
100
     $requete = "SELECT * FROM ".GEST_FRAIS.
101
     		" WHERE ".GEST_CHAMPS_ID_FRAIS." = $this->_id_frais";
102
 
103
     $ligne = $GLOBALS['db']->query($requete);
104
 
105
     $resultat = $ligne->fetchRow(DB_FETCHMODE_ASSOC);
106
 
107
    (DB::isError($resultat)) ?
108
    	die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
109
 
110
    /*construction d'un nouvel entité frais */
111
   $nb_ligne_recupere= $resultat->numRows();
112
   if ($nb_ligne_recupere==1)
113
   {
114
    $nouveau_frais = new Frais ($resultat);
115
    return $nouveau_frais;
116
   }
117
   else
118
   {
119
	echo "frais inexistant ";
120
	return -1;
121
    }
122
  }
123
 
124
 /*supprimer un frais de la base de donnees */
125
  function supprimerFrais()
126
  {
127
    $requete= "DELETE FROM ".GEST_FRAIS." WHERE ".GEST_CHAMPS_ID_FRAIS." = $this->_id_frais";
128
 
129
     $resultat = $GLOBALS['db'] ->query($requete);
130
 
131
 
132
    (DB::isError($resultat)) ?
133
    	die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
134
 
135
    /*destruction de l'instance de l'objet */
136
 
137
 
138
 
139
  }
140
 
141
  /*afficher un frais */
142
 
143
  function afficheFrais()
144
  {
145
      echo "frais : \n";
146
      echo " $this->_id_frais \n ";
147
      echo " $this->_libelle_frais \n";
148
      echo " $this->_date_frais \n";
149
      echo " $this->_utilisateur \n ";
150
}
151
 
152
}
153
?>