Beispiel #1
0
use app\classes\validation;
use app\models\users;
use app\models\customers;
use app\models\categories;
use app\models\albums;
use app\models\images;
use app\models\orders;
use app\models\item_order;
$app->get('/admin/orders/', function () use($app) {
    login::estaLogado('user_logado', $app);
    $users = users::where('name', $_SESSION['name']);
    $view = $app->view();
    $view->setTemplatesDirectory(TEMPLATE_ADMIN);
    $categories = categories::listar();
    $customers = customers::find('all', array('order' => 'name asc'));
    $albums = albums::find('all', array('order' => 'name asc'));
    $orders = orders::find_by_sql('SELECT order.id, order.date, order.customer_id, order.status, c.name FROM `order` JOIN customers c ON(order.customer_id = c.id) ORDER BY order.id DESC;');
    $dados = array('pagina' => 'orders', 'users' => $users, 'categories' => $categories, 'customers' => $customers, 'albums' => $albums, 'orders' => $orders);
    $app->render('layout.php', $dados);
});
$app->get('/admin/orders/orders_detail/:id', function ($id) use($app) {
    login::estaLogado('user_logado', $app);
    $users = users::where('name', $_SESSION['name']);
    $view = $app->view();
    $view->setTemplatesDirectory(TEMPLATE_ADMIN);
    $items_order = item_order::find_by_sql("SELECT image_id, amount, total, i.name FROM `item_order`\n\t\tJOIN images i ON(item_order.image_id = i.id)\n\t\tWHERE item_order.order_id = {$id};");
    $dados = array('pagina' => 'order_detail', 'users' => $users, 'items_order' => $items_order);
    $app->render('layout.php', $dados);
});
$app->post('/admin/orders/orders_detail/edit_status/:id', function ($id) use($app) {
    login::estaLogado('user_logado', $app);
Beispiel #2
0
            $app->flash('nameAlbum', $name);
            $app->redirect('/admin/customers');
        }
    }
});
$app->get('/admin/customers/albums_manage/:id', function ($id) use($app) {
    login::estaLogado('user_logado', $app);
    $users = users::where('name', $_SESSION['name']);
    $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);
Beispiel #3
0
<?php

use app\traits\login;
use app\models\users;
use app\models\categories;
use app\models\albums;
use app\models\images;
use app\models\orders;
$app->get('/painel', function () use($app) {
    login::estaLogado('user_logado', $app);
    $users = users::where('name', $_SESSION['name']);
    $categories = categories::find('all');
    $albums = albums::find('all');
    $images = images::find('all');
    $orders = orders::find('all');
    $view = $app->view();
    $view->setTemplatesDirectory(TEMPLATE_ADMIN);
    $dados = array('pagina' => 'painel', 'name' => $_SESSION['name'], 'users' => $users, 'categories' => $categories, 'albums' => $albums, 'images' => $images, 'orders' => $orders);
    $app->render('layout.php', $dados);
});
Beispiel #4
0
$app->get('/admin/images/photo/view/:id', function ($id) use($app) {
    login::estaLogado('user_logado', $app);
    $users = users::where('name', $_SESSION['name']);
    $view = $app->view();
    $view->setTemplatesDirectory(TEMPLATE_ADMIN);
    $album = albums::where('id', $id);
    $images = images::where('album_id', $id, 'all');
    $dados = array('pagina' => 'images_view', 'album' => $album, 'users' => $users, 'images' => $images);
    $app->render('layout.php', $dados);
});
$app->get('/admin/images/photo/delete/:id', function ($id) use($app) {
    login::estaLogado('user_logado', $app);
    $users = users::where('name', $_SESSION['name']);
    $view = $app->view();
    $view->setTemplatesDirectory(TEMPLATE_ADMIN);
    $album = albums::where('id', $id);
    $images = images::where('album_id', $id, 'all');
    $dados = array('pagina' => 'images_delete', 'album' => $album, 'users' => $users, 'images' => $images);
    $app->render('layout.php', $dados);
});
$app->get('/image/allow-access/:id', function ($id) use($app) {
    $attributes = ['open' => 1];
    $images = new images();
    $images->atualizar($id, $attributes);
});
$app->get('/image/deny-access/:id', function ($id) use($app) {
    $attributes = ['open' => 0];
    $images = new images();
    $images->atualizar($id, $attributes);
});
$app->delete('/image/delete/:id', function ($id) use($app) {
Beispiel #5
0
        //$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];
    $images = new \app\models\images();
    $images->atualizar($id, $attributes);
});
$app->get('/image/purchased/:id', function ($id) use($app) {
    $attributes = ['purchased' => 0];
    $images = new \app\models\images();
Beispiel #6
0
        } else {
            $attributes = array('name' => $name, 'slug' => $slug);
            categories::cadastrar($attributes);
            $app->flash('sucesso', 'Categoria cadastrada com sucesso !');
            $app->redirect('/admin/categories');
        }
    } else {
        $app->flash('erro', $validation->mostrarErros());
        $app->flash('nameCategory', $name);
        $app->redirect('/admin/categories');
    }
});
$app->post('/admin/categories/delete/:id', function ($id) use($app) {
    $categories = new categories();
    $albums = new albums();
    $albumCadastrado = albums::where('category_id', $id);
    if (count($albumCadastrado) > 0) {
        $app->flash('erro', 'Esta categoria possui albuns cadastrados');
        $app->redirect('/admin/categories');
    } else {
        $categories->deletar($id);
        $app->flash('sucesso', 'Categoria deletada com sucesso !');
        $app->redirect('/admin/categories');
    }
});
$app->post('/admin/categories/edit/:id', function () use($app) {
    $id = $app->request()->post('category-id');
    $name = $app->request()->post('category-name');
    $slug = $app->request()->post('category-slug');
    if (empty($name) || empty($slug)) {
        $app->flash('erro', 'Nome ou Slug não podem ser vazios');
Beispiel #7
0
    //$pass = $app->request()->post('album-password');
    $price = $app->request()->post('album-price');
    $slug = $app->request()->post('album-slug');
    if (empty($name) || empty($slug)) {
        $app->flash('erro', 'Nome ou Slug não podem ser vazios');
        $app->redirect('/admin/albums');
    } else {
        $attributes = ['name' => $name, 'category_id' => $category, 'price' => $price, 'slug' => $slug];
        $album = new albums();
        $album->atualizar($id, $attributes);
        $app->flash('sucesso', 'Categoria alterada com sucesso !');
        $app->redirect('/admin/albums');
    }
});
$app->post('/admin/albums/delete/:id', function ($id) use($app) {
    $albums = new albums();
    $images = new images();
    $imageCadastrada = images::where('album_id', $id);
    if (count($imageCadastrada) > 0) {
        $app->flash('erro', 'Este álbum possui fotos cadastradas');
        $app->redirect('/admin/albums');
    } else {
        $albums->deletar($id);
        $app->flash('sucesso', 'Álbum deletado com sucesso !');
        $app->redirect('/admin/albums');
    }
});
$app->post('/admin/albums/cover/:id', function () use($app) {
    $id = $app->request()->post('album-id');
    $foto = $_FILES['foto']['name'];
    $temp_foto = $_FILES['foto']['tmp_name'];