示例#1
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);
});
示例#2
0
$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);
    $users = users::where('name', $_SESSION['name']);
    $status = $app->request()->post('select-status');
    $attributes = ['status' => $status];
    $order = new orders();
    $order->atualizar($id, $attributes);
    $app->flash('sucesso', "Status do pedido {$id} alterado com sucesso !");
    $app->redirect('/admin/orders');
});
示例#3
0
    $categories = categories::listar();
    $customer = customers::where('id', $id);
    $id = $customer->id;
    $manages = albums::find_by_sql("SELECT a.id AS ac_id, a.customers_id, albums.name, albums.slug, albums.cover FROM albums JOIN albums_customers a ON ( albums.id = a.albums_id ) WHERE customers_id = {$id}");
    $dados = array('categories' => $categories, 'customer' => $customer, 'manages' => $manages);
    $template = $twig->loadTemplate('customer-albums.html');
    $template->display($dados);
});
$app->get('/area-do-cliente/:id/order', function ($id) use($app, $twig) {
    $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("customer_id = {$id}")));
        $dados = array('categories' => $categories, 'customer' => $customer, 'orders' => $orders);
        $template = $twig->loadTemplate('orders.html');
        $template->display($dados);
    } else {
    }
});
$app->get('/area-do-cliente/:id/order/orders_detail/:idOrder', function ($id, $idOrder) use($app, $twig) {
    $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};");