$logado = login::banLogado('user_logado', $app); if ($logado) { $customer = customers::where('name', $_SESSION['name']); $categories = categories::listar(); $customer = customers::where('id', $id); $id = $customer->id; //$orders = orders::all(array('conditions' => array("id = $idOrder"))); $items_order = item_order::find_by_sql("SELECT image_id, amount, total, i.name FROM `item_order`\n\t\t\tJOIN images i ON(item_order.image_id = i.id)\n\t\t\tWHERE item_order.order_id = {$idOrder};"); $dados = array('categories' => $categories, 'customer' => $customer, 'items_order' => $items_order); $template = $twig->loadTemplate('order_detail.html'); $template->display($dados); } else { } }); $app->get('/area-do-cliente/:id/:slug', function ($id, $slug) use($app, $twig) { $logado = login::banLogado('user_logado', $app); if ($logado) { $customer = customers::where('name', $_SESSION['name']); } else { } $categories = \app\models\categories::listar(); $album = \app\models\albums::where('slug', $slug); $id = $album->id; $_SESSION['album'] = $id; $images = \app\models\images::all(array('conditions' => array('album_id = ?', $id))); $dados = array('categories' => $categories, 'album' => $album, 'images' => $images, 'customer' => $customer); $template = $twig->loadTemplate('customer-albums-photos.html'); $template->display($dados); }); $app->get('/image/buy/:id', function ($id) use($app) { $attributes = ['purchased' => 1];
$view = $app->view(); $view->setTemplatesDirectory(TEMPLATE_ADMIN); $customer = customers::where('id', $id); $albums = albums::find('all', array('order' => 'name asc')); $albumsCustomers = albumsCustomers::where('customers_id', $id, 'all'); $join = "JOIN albums_customers a ON(albums.id = a.albums_id) WHERE customers_id = {$id}"; // $manages = albums::all(array('joins' => $join)); $manages = albums::find_by_sql("SELECT a.id as ab, albums.name, albums.cover FROM albums JOIN albums_customers a ON ( albums.id = a.albums_id ) WHERE customers_id = {$id}"); $dados = array('pagina' => 'albums_customer', 'albums' => $albums, 'customer' => $customer, 'users' => $users, 'albumsCustomers' => $albumsCustomers, 'manages' => $manages); $app->render('layout.php', $dados); }); $app->post('/admin/customers/albums_manage/album_add', function () use($app) { login::estaLogado('user_logado', $app); $users = users::where('name', $_SESSION['name']); $customer = $app->request()->post('customer'); $album = $app->request()->post('album'); $attributes = array('customers_id' => $customer, 'albums_id' => $album); albumsCustomers::cadastrar($attributes); $app->flash('sucesso', 'Relação cadastrada com sucesso !'); $app->redirect("/admin/customers/albums_manage/{$customer} "); }); $app->delete('/admin/customers/albums_manage/album_del/:id', function ($id) use($app) { login::estaLogado('user_logado', $app); $users = users::where('name', $_SESSION['name']); $id = filter_var($id, FILTER_SANITIZE_NUMBER_INT); albumsCustomers::deletar($id); // $images = new images(); // // $images->deletar($id); // echo 'deletou'; });
$app->get('/:slug', function ($slug) use($app, $twig) { $logado = login::customerLogado('user_logado', $app); if ($logado) { $customer = customers::where('name', $_SESSION['name']); } else { $customer = null; } $categories = \app\models\categories::listar(); $category = \app\models\categories::where('slug', $slug); $id = $category->id; $albums = \app\models\albums::where('category_id', $id, 'all'); $dados = array('categories' => $categories, 'category' => $category, 'albums' => $albums, 'customer' => $customer); $template = $twig->loadTemplate('album.html'); $template->display($dados); }); $app->get('/:slug/:album', function ($slug, $album) use($app, $twig) { $logado = login::customerLogado('user_logado', $app); if ($logado) { $customer = customers::where('name', $_SESSION['name']); } else { $customer = null; } $categories = \app\models\categories::listar(); $album = \app\models\albums::where('slug', $album); $id = $album->id; //$images = \app\models\images::where('album_id',$id, 'all'); $images = \app\models\images::all(array('conditions' => array('album_id = ? AND open = ?', $id, 1))); $dados = array('categories' => $categories, 'album' => $album, 'images' => $images, 'customer' => $customer); $template = $twig->loadTemplate('photo.html'); $template->display($dados); });