Esempio n. 1
0
<?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";
Esempio n. 2
0
    } 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();
    $app->contentType('application/json');
    echo json_encode($card->isNumber($data['number']));
});
$app->post('/card/check/serial', function () use($app) {
    $data = $app->request()->post('generator');
    $card = new models\Card();
    $app->contentType('application/json');
    echo json_encode($card->isSerial($data['serial']));
});