47 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
<?php
 | 
						|
 | 
						|
include_once './config.php';
 | 
						|
include_once './models/services/ModelService.php';
 | 
						|
include_once './models/services/BrandService.php';
 | 
						|
include_once './libs/Smarty.class.php';
 | 
						|
 | 
						|
if ($_SERVER['REQUEST_METHOD'] == 'GET')
 | 
						|
{
 | 
						|
    if (isset($_SESSION['brand']))
 | 
						|
    {
 | 
						|
        $name = $_SESSION['brand'];
 | 
						|
 | 
						|
        $brandService = new BrandService();
 | 
						|
        $brand = $brandService->getBrandByName($name);
 | 
						|
 | 
						|
        $modelService = new ModelService();
 | 
						|
        $models = $modelService->getAllModelsByBrand($brand->id, is_updater());
 | 
						|
 | 
						|
        if ($models)
 | 
						|
        {
 | 
						|
            $smarty = new Smarty;
 | 
						|
            $smarty->assign('brand', $name);
 | 
						|
            $smarty->assign('models', $models);
 | 
						|
            $smarty->assign('user_can_update', is_updater());  
 | 
						|
            $smarty->assign('user_logged_in', is_logged_in($user));      
 | 
						|
            $smarty->display('views/models.tpl');
 | 
						|
        }
 | 
						|
        else
 | 
						|
        {
 | 
						|
            header("location:add_model.php?brand=$name");
 | 
						|
        }
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
        $brandService = new BrandService();
 | 
						|
        $brands = $brandService->getAllBrands();
 | 
						|
 | 
						|
        $smarty = new Smarty;
 | 
						|
        $smarty->assign('brands', $brands);
 | 
						|
        $smarty->assign('action', "models.php");
 | 
						|
        $smarty->display('views/selectbrand.tpl');
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
?>
 |