<?php

use lib\Config;
// Get user
$app->get('/purshares', function () use($app) {
    $purshare = new models\Purshare();
    $card = new models\Card();
    $purshares = $purshare->getPurshares();
    foreach ($purshares as $key => $value) {
        $c = $card->getCardById($value['card_id']);
        $purshares[$key]['card'] = $c[0]['number'] . ' / ' . $c[0]['serial'];
    }
    $cards = $card->getCards();
    $app->render('purshares/index.html', array('purshares' => $purshares, 'cards' => $cards, 'active_purshares' => 'active'));
});
$app->post('/purshare/create', function () use($app) {
    $data = $app->request()->post('purshare');
    $purshare = new models\Purshare();
    $purshare->create($data);
    $app->redirect('/purshares');
});
$app->get('/purshare/:id/destroy', function ($id) use($app) {
    $purshare = new models\Purshare();
    $purshare->destroy($id);
    $app->redirect('/purshares');
});
$route = "purshare";
Exemple #2
0
    $card = new models\Card();
    $res = $card->getCardById($id);
    $card = $res[0];
    if ($card) {
        $card['checked'] = '';
        if ($card['status'] == 1) {
            $card['checked'] = 'checked="checked"';
        }
        $app->render('cards/edit.html', array('card' => $card, 'id' => $id, 'active_cards' => 'active'));
    } else {
        $app->notFound();
    }
});
$app->get('/card/:id/view', function ($id) use($app) {
    $card = new models\Card();
    $purshare = new models\Purshare();
    $res = $card->getCardById($id);
    $c = $res[0];
    if ($c) {
        $c['status_name'] = $card->getStatusName($id);
        $app->render('cards/profile.html', array('card' => $c, 'id' => $id, 'active_cards' => 'active', 'purshares' => $purshare->getPurshares($id)));
    } else {
        $app->notFound();
    }
});
$app->get('/card/generator', function () use($app) {
    $app->render('cards/generator.html', array('active_cards' => 'active'));
});
$app->post('/card/check/number', function () use($app) {
    $data = $app->request()->post('generator');
    $card = new models\Card();