Baseobj(); } function charger($ref){ return $this->getVars("select * from $this->table where ref=\"$ref\""); } function init(){ $cnx = new Cnx(); $query_mventes = "CREATE TABLE IF NOT EXISTS `mventes` ( `id` int(11) NOT NULL auto_increment, `ref` text NOT NULL, `nb_ventes` int(11) NOT NULL, PRIMARY KEY (`id`) ) AUTO_INCREMENT=1 ; "; $resul_mventes = mysql_query($query_mventes, $cnx->link); } function boucle($texte, $args){ // récupération des arguments $num = lireTag($args, "num"); $classement = lireTag($args, "classement"); $exclusion = lireTag($args, "exclusion"); $search =""; $res=""; if($classement == "inverse") $ordre = "ASC"; else $ordre = "DESC"; if($exclusion != "") $search .= " and ref not in($exclusion)"; $query_mventes = "select * from $this->table where ref<>'' $search order by nb_ventes $ordre limit 0,$num "; $resul_mventes = mysql_query($query_mventes, $this->link); if(! mysql_num_rows($resul_mventes)) return ""; while( $row = mysql_fetch_object($resul_mventes)){ $temp = str_replace("#ID", "$row->id", $texte); $temp = str_replace("#REF", "$row->ref", $temp); $temp = str_replace("#NB", "$row->nb_ventes", $temp); $res .= $temp; } return $res; } function statut($commande){ if($commande->statut != 2){ $venteprod = new Venteprod(); $query = "select * from $venteprod->table where commande=" . $commande->id; $resul = mysql_query($query, $venteprod->link); while($row = mysql_fetch_object($resul)){ if($this->charger($row->ref)){ $this->nb_ventes += $row->quantite; $this->maj(); } else { $this->ref = $row->ref; $this->nb_ventes = 1; $this->add(); } } } } function confirmation($commande){ $this->statut($commande); } } ?>