public function index($id = '')
 {
     $categories_all = Categories::find();
     if ($id) {
         $categories = array(Categories::findByPk($id));
     } else {
         $categories = Categories::find();
     }
     $this->render('Articles/list', array('categories_all' => $categories_all, 'categories' => $categories));
 }
Exemple #2
0
    }
    ?>
><?php 
    echo $category->category;
    ?>
</option><?php 
}
?>
</select>
</form>

<table><?php 
if (@$_GET["category_id"] != 0) {
    $categories = array(Categories::findByPk($_GET["category_id"]));
} else {
    $categories = Categories::find();
}
foreach ($categories as $category) {
    ?>
	<tr><td colspan="4"><h2><?php 
    echo $category->category;
    ?>
</h2></td></tr>
	<tr>
		<th>Image</th>
		<th>Titre</th>
		<th>Prix</th>
		<th>Panier</th>
	</tr><?php 
    $articles = $category->articles;
    foreach ($articles as $article) {
Exemple #3
0
 public function products()
 {
     $products_m = new Products();
     $product = $products_m->getProducts();
     $product_data = array();
     $d_product = $products_m->getDayProduct();
     $d_product_data = array();
     $d_product_data['id'] = $d_product->getId();
     $d_product_data['name'] = $d_product->getName();
     $d_product_data['img'] = $d_product->getImage();
     $d_product_data['price'] = $d_product->getPrice();
     $s_products = $products_m->getSliderProducts();
     $s_products_data = array();
     if (!empty($s_products)) {
         foreach ($s_products as $key => $p) {
             $s_product_data[$key]['id'] = $p->getId();
             $s_product_data[$key]['name'] = $p->getName();
             $s_product_data[$key]['img'] = $p->getImage();
             $s_product_data[$key]['price'] = $p->getPrice();
         }
     }
     if (!empty($product)) {
         foreach ($product as $key => $p) {
             $product_data[$key]['id'] = $p->getId();
             $product_data[$key]['name'] = $p->getName();
             $product_data[$key]['img'] = $p->getImage();
             $product_data[$key]['quantity'] = $p->getQuantity();
             $product_data[$key]['price'] = $p->getPrice();
         }
     }
     $cats_array = array();
     $sub_cats_array = array();
     $categories_m = new Categories();
     $cats = $categories_m->getCategories();
     $sub_categories = new SubCategories();
     $sub_cats = $sub_categories->getSubCategories();
     $cats_array = array();
     if (!empty($cats)) {
         foreach ($cats as $key => $c) {
             $cats_array[$key]['name'] = $c->getCategoryName();
             $cats_array[$key]['id'] = $c->getCategoryId();
         }
     }
     $sub_cats_array = array();
     if (!empty($sub_cats)) {
         foreach ($sub_cats as $key => $c) {
             $sub_cats_array[$key]['name'] = $c->getSubCategoryName();
             $sub_cats_array[$key]['id'] = $c->getSubCategoryId();
         }
     }
     echo $this->render('adminproducts', array('products' => $product_data, 'day_product' => $d_product_data, 'slider_products' => $s_product_data, 'cats' => $cats_array, 'sub_cats' => $sub_cats_array));
 }
Exemple #4
0
    if ($category->primaryKey == @$_GET["category_id"]) {
        echo 'selected="selected"';
    }
    ?>
><?php 
    echo $category->category;
    ?>
</option><?php 
}
?>
        </select>
    </form>
    <table><?php 
//Si une categorie est selectionnée, on n'affiche que celle-ci, sinon on affiche tout
if (@$_GET["category_id"] && $_GET["category_id"] != 0) {
    $catSelected = \Models\Categories::findByPk($_GET["category_id"]);
    ?>
            <tr>
                <td colspan="4"><h2><?php 
    echo $catSelected->category;
    ?>
</h2></td>
            </tr>
            <tr>
                <th>Image</th>
                <th>Titre</th>
                <th>Prix</th>
                <th>Panier</th>
            </tr><?php 
    //Selection des articles d'une categorie
    $catArticles = $catSelected->articles;