<?php

/*
 * awframework from aw.inc present aw controller
 * it will help you develop easy and fast with secure tools
 * you can edit and add what you feel right
 * don't change in strucure of file
 */

require_once("imp/_imp.php");

class Controllers {

    //public vars
    public $smarty;
    public $hosturl;

    // it will run in everytime with
    // default requried
    public function __construct() {
        require_once("../public/aw_config.php");
        $this->smarty = $smarty;
        $this->hosturl = $hosturl;


        $controlname = 'gallery';
        $this->smarty->assign('gallery', 1);

        require_once("header.php");
        require_once("footer.php");
    }

    //here the frist page and
    //the frist action in this class
    public function index() {

        //Category
        $allCategory = R::getAll('select distinct productscategory.* from productscategory, products where productscategory.id = products.category_id and productscategory.del = 0 and products.del = 0 order by productscategory.id desc');
        $this->smarty->assign('allCategory', $allCategory);

        //Products
        $allProduct = R::findAll('products', 'del = 0 order by id desc');
        foreach ($allProduct as $product) {
            $product->image = R::findOne('productsgallery', 'product_id = ' . $product->id)->name;
        }
        $this->smarty->assign('allProduct', $allProduct);


        header::headershow($this->smarty, $this->hosturl);
        $this->smarty->display('templates/' . default_lang_interface . '/album-photo.html');
        footer::footershow($this->smarty, $this->hosturl);
    }

// at the end of class call
    public function __destruct() {
//close connection
        R::close();
    }

}
