Skip to content

Commit

Permalink
get Top produits
Browse files Browse the repository at this point in the history
  • Loading branch information
NailaMelhem committed Apr 18, 2015
1 parent d25dcb8 commit 70ce0a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 12 additions & 1 deletion Application/Controllers/Produit.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,21 @@ public function getProduit($params) {
return $this->setApiResult(false, true, "erreur pendant la recuperation des produit");
}


}

public function getTopProduits($params) {
unset($params['method']);

$modelProduit = new \Application\Models\Produit();
$res = $modelProduit->fetchAll(" `top`='1' OR `top`='2' OR `top`='3' ");

if( !empty( $res ) ) {
return $this->setApiResult($res);
}else{
return $this->setApiResult(false, true, "erreur pendant la recuperation des produit");
}

}

public function insertProduit($params) {

Expand Down
13 changes: 6 additions & 7 deletions Application/Controllers/ViewRecette.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,18 @@ public function __construct() {
public function getAllViewRecettes($param) { // obtenir toutes les recettes

//si on cherche a recevoir qu'un les recettes d'une categorie...
$where = " 1 ";
$where = " 1 ORDER BY `titre` ";

if(isset($param['id_cat']) && !empty($param['id_cat']) ){
$where=" `id_cat`={$param['id_cat']} ";
$where = " `id_cat`={$param['id_cat']} ORDER BY `titre` ";
echo "tri selon la categorie";
}

else if(isset($param['top']) && !empty($param['top']) ){
$where=" `top`='1' OR `top`='2' OR `top`='3' ";
$where=" `top`='1' OR `top`='2' OR `top`='3' ORDER BY `top` ";
echo "tri selon le top";
}
else if(isset($param['type']) && !empty($param['type']) ){
$where=" `type`='{$param['type']}' ";
$where = " `type`='{$param['type']}' ORDER BY `titre` ";
echo "tri selon le type";
}

Expand All @@ -79,7 +78,7 @@ public function getAllViewRecettes($param) { // obtenir toutes les recettes
foreach ($notes as $note) {
$somme+=$note['value'];
}
$moyenne=-1;
$moyenne = -1;
if(count($notes)>0){
$moyenne=$somme/count($notes);
}
Expand Down Expand Up @@ -166,7 +165,7 @@ public function getViewRecette($param) { // obtenir une recette par son id
foreach ($notes as $note) {
$somme+=$note['value'];
}
$moyenne=-1;
$moyenne = -1;
if(count($notes)>0){
$moyenne=$somme/count($notes);
}
Expand Down

0 comments on commit 70ce0a5

Please sign in to comment.