<?php $app->get('/relatorios/problemas', 'auth', function () use($app) { $model = new models\Problem(); for ($i = 0; $i < 12; $i++) { $relatorio[$i] = $model->countByMonth('2015', $i + 1); } $app->render('relatories/problems_by_month.html', ['relatorio' => $relatorio]); }); $app->get('/relatorios/topicos', 'auth', function () use($app) { $model = new models\Problem(); $relatorio = $model->costByProblem(1); return var_dump($relatorio); $app->render('relatories/problems_by_month.html', ['relatorio' => $relatorio]); });
<?php $app->get('/problemas', 'auth', function () use($app) { $model = new models\Problem(); $problemas = $model->getAll(); $app->render('problems/index.html', ['problemas' => $problemas]); }); $app->get('/problemas/novo', 'auth', function () use($app) { $client = new models\Client(); $clientes = $client->getAll(); $category = new models\Category(); $categorias = $category->getAll('titulo', 'ASC'); $app->render('problems/form.html', ['clientes' => $clientes, 'categorias' => $categorias]); }); $app->post('/problemas/novo', 'auth', function () use($app) { $data = $app->request()->post(); $helpers = new lib\Helpers(); $data['cliente_id'] = $data['cliente_id']; $data['categoria_id'] = $data['categoria_id']; $data['data_hora'] = $helpers->dateTimeDB($data['data'], $data['hora']); unset($data['data']); unset($data['hora']); unset($data['_wysihtml5_mode']); $data['usuario_id'] = $_SESSION['user']['id']; $problem = new models\Problem(); $problem->insert($data); $app->redirect($app->url . '/problemas'); }); $app->post('/problemas/:id/editar', 'auth', function ($id) use($app) { $data = $app->request()->post(); $data['id'] = $id;
<?php // GET index route $app->get('/', 'auth', function () use($app) { $problem = new models\Problem(); $topic = new models\Topic(); $client = new models\Client(); $programmer = new models\Programmer(); $count['problemas'] = $problem->count(); $count['topicos'] = $topic->count(); $count['clientes'] = $client->count(); $count['programadores'] = $programmer->count(); $problemas = $problem->get(10); $topicos = $topic->get(10); $app->render('index.html', ['count' => $count, 'problemas' => $problemas, 'topicos' => $topicos]); });
$problem = new models\Problem(); $problemas = $problem->getAll(); $programmer = new models\Programmer(); $programadores = $programmer->getAll(); $app->render('topics/form.html', ['problemas' => $problemas, 'programadores' => $programadores, 'id' => $id]); }); $app->post('/topicos/novo', 'auth', function () use($app) { $data = $app->request()->post(); $data['tempo'] = (int) $data['tempo']; unset($data['_wysihtml5_mode']); $topic = new models\Topic(); $topic->insert($data); $app->redirect($app->url . '/topicos'); }); $app->get('/topico/:id/editar', 'auth', function ($id) use($app) { $problem = new models\Problem(); $problemas = $problem->getAll(); $programmer = new models\Programmer(); $programadores = $programmer->getAll(); $topic = new models\Topic(); $topico = $topic->getId($id); $app->render('topics/form.html', ['problemas' => $problemas, 'programadores' => $programadores, 'topico' => $topico]); }); $app->post('/topico/:id/editar', 'auth', function ($id) use($app) { $data = $app->request()->post(); $data['id'] = $id; $data['tempo'] = (int) $data['tempo']; unset($data['problema_id']); unset($data['programador_id']); unset($data['titulo']); unset($data['descricao']);