コード例 #1
0
ファイル: orders.php プロジェクト: brunocoelhor/photoecomm
use app\classes\cover;
use app\classes\slug;
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);
});
コード例 #2
0
ファイル: customer.php プロジェクト: brunocoelhor/photoecomm
        $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];
    $images = new \app\models\images();
    $images->atualizar($id, $attributes);
});
$app->get('/image/purchased/:id', function ($id) use($app) {
    $attributes = ['purchased' => 0];
コード例 #3
0
ファイル: painel.php プロジェクト: brunocoelhor/photoecomm
<?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);
});
コード例 #4
0
    } 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');
        $app->redirect('/admin/categories');
    } else {
        $attributes = ['name' => $name, 'slug' => $slug];
        $category = new categories();
        $category->atualizar($id, $attributes);
        $app->flash('sucesso', 'Categoria alterada com sucesso !');
        $app->redirect('/admin/categories');
    }
});
$app->post('/admin/categories/cover/:id', function () use($app) {
    $id = $app->request()->post('category-id');
    $foto = $_FILES['foto']['name'];
    $temp_foto = $_FILES['foto']['tmp_name'];
    $extensoes_permitidas = array('jpg', 'jpeg', 'png');
    if (empty($foto)) {
        $app->flash('mensagem', '<div class="alert alert-danger">Escolha uma foto.</div>');
        $app->redirect('/admin/categories');
    } else {
        $isImage = imagem::isImage($foto);