1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
| <?php
/*
* Drapeau pour signaler un produit de haut de gamme.
*
* @const HIGH_RANGE
* @var String
* @access public
*/
define('HIGH_RANGE', 'haute');
/**
* Drapeau pour signaler un produit de moyenne gamme
*
* @const NORMAL_RANGE
* @var String
* @access public
*/
define('NORMAL_RANGE', 'moyenne');
/**
* Drapeau pour signaler un produit bas de gamme
*
* @const POOR_RANGE
* @var String
* @access public
*/
define('POOR_RANGE', 'basse');
/**
* Produit
* --------------------------------
*
*/
class Produit {
const TB_PREFIX = 'achatsenfolie__';
/**
* Nom de la table utilisée
* @var String
*/
const TB_NAME = 'PRODUIT';
/**
* Numéro d'identifiant
* @access private
* @var Integer
*/
private $id = 0;
/**
* Nom
* @access private
* @var String
*/
private $nom = null;
/**
* Description
* @access private
* @var String
*/
private $description = null;
/**
* Prix
* @access private
* @var Float
*/
private $prix = 0.0;
/**
* Gamme (basse, moyenne, haute)
* @access private
* @var String
*/
private $gamme = 'moyenne';
/**
* Date de dernière modification
* @access private
* @var Integer
*/
private $date_modification = 0;
/**
* Date de création
* @access private
* @var Integer
*/
private $date_creation = 0;
/**
* S'affiche dans la liste des nouveautés
* @access private
* @var Boolean
*/
private $afficher_Dans_Nouveautes = true;
/**
* Est encore disponible
* @access private
* @var Boolean
*/
private $est_visible = true;
/**
* Est encore disponible
* @access private
* @var Boolean
*/
private $est_disponible = true;
/**
* Categorie dans laquelle est affiché le produit
* @var Categorie
*/
private $id_categorie = null;
/**
* illsutration est affiché du produit
* @var Categorie
*/
private $id_illustration = null;
private $_nouveautes = array();
/**
* Constructor
* @access protected
*/
public function __construct($id=0,$nom = "sans titre",$description = null,$prix=0, $gamme= null, $date_modification=0,$date_creation = 0,
$afficher_Dans_Nouveautes=1,$est_visible=1,$est_disponible=1,$id_categorie=NULL,$id_illustration=NULL ) {
$this->id = $id;
$this->nom = $nom;
$this->description = $description;
$this->prix = $prix;
$this->gamme = $gamme;
$this->date_modification = $date_modification;
$this->date_creation = $date_creation;
$this->afficher_Dans_Nouveautes = $afficher_Dans_Nouveautes;
$this->est_visible = $est_disponible;
$this->est_disponible = $est_disponible;
$this->id_categorie = $id_categorie;
$this->id_illustration = $id_illustration;
}
/*Recupere informations tous les sous categories par id*/
public function findProduitById($id){
$req ="SELECT * from ".self::TB_PREFIX."produit where id_categorie=".$id."";
$res = mysql_query($req) or die ('Erreur : '.mysql_error());
$ret = array();
while( $data = mysql_fetch_object($res) ) {
$ret[] = new Produit(
$data->id,
$data->nom,
$data->description,
$data->prix,
$data->gamme,
$data->date_modification,
$data->date_creation,
$data->afficher_dans_nouveautes,
$data->est_visible,
$data->est_disponible,
$data->id_categorie,
$data->id_illustration
);
}
if ( !empty($ret) )
return $ret;
return null;
}
/**
* Indique si le produit s'affiche dans les nouveautées ou non
*
* @access public
* @return boolean
*/
public function afficherLesNouveautes(){
foreach ($this->_nouveautes as $nouveaute)
{
echo $nouveaute;
}
}
}
?> |
Partager