예제 #1
0
 public function get_category()
 {
     if ($this->category == 0) {
         return "All books";
     } else {
         $a = new \models\Category($this->category);
         return $a->get_name();
     }
 }
예제 #2
0
 public function getNodesListJSON()
 {
     $this->setAJAXLayout();
     $model = new \models\Category($this->fw->get('PARAMS.table'));
     if ($model->isMapped() && $this->fw->exists('GET.pid')) {
         $pid = $this->fw->get('GET.pid');
         $cat = $model->getSubcategories($pid, false);
         $items = array();
         foreach ($cat as $v) {
             $items[] = array('id' => $v['id'], 'name' => $v['title']);
         }
         $result = array('items' => $items);
     } else {
         $result = array('type' => 'error');
     }
     $this->fw->set('content', json_encode($result));
 }
예제 #3
0
<?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;
예제 #4
0
$app->get('/categorias/:id/editar', 'auth', function ($id) use($app) {
    $model = new models\Category();
    $categoria = $model->getId($id);
    $app->render('categories/form.html', ['categoria' => $categoria]);
});
$app->post('/categorias/:id/editar', 'auth', function ($id) use($app) {
    $data = $app->request()->post();
    $data['id'] = $id;
    $category = new models\Category();
    $category->update($data);
    $app->redirect($app->url . '/categorias');
});
$app->get('/categorias/:id/delete', 'auth', function ($id) use($app) {
    $model = new models\Category();
    $model->delete($id);
    $app->redirect($app->url . '/categorias');
});
$app->get('/categorias/modal/novo', 'auth', function () use($app) {
    $app->render('categories/modal.html');
});
$app->post('/categorias/modal/novo', 'auth', function () use($app) {
    $data = $app->request()->post();
    $category = new models\Category();
    $category->insert($data);
});
$app->get('/categorias/select', 'auth', function () use($app) {
    $model = new models\Category();
    $categorias = $model->getAll('titulo', 'ASC');
    $last = $model->get();
    $app->render('categories/select.html', ['categorias' => $categorias, 'id' => $last[0]['id']]);
});