Fifth pass at adding key files
This commit is contained in:
46
site/stackreach/models.php
Executable file
46
site/stackreach/models.php
Executable file
@ -0,0 +1,46 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user