<?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 = 'companyPro';
//        $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() {
        $id = filter_input(INPUT_GET, 'ac');

        $category = R::load('trainer', $id);
        if (!$category || $category->del == 1)
            header('location:' . $this->hosturl);
        else {
            $this->smarty->assign('category', $category);

            //productscategory
            $catproducts = R::getAll("select companypro.*,companyprogallery.name
                from companypro
                join companyprogallery on companyprogallery.product_id = companypro.id
                join trainer on trainer.id = companypro.brand_id
                where companypro.del=0 and trainer.id=$id");
            $this->smarty->assign('catproducts', $catproducts);


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

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

}
