Example #1
0
 public function testRenderWithStatusCode()
 {
     $mock = $this->getMock('View\\TemplateEngineInterface');
     $mock->expects($this->once())->method('render')->will($this->returnValue('Heya'));
     $app = new \App($mock);
     $this->assertEquals('Heya', $app->render('a/template.php', array(), 201));
     $this->assertEquals(201, $this->readStatusCode($app));
 }
Example #2
0
 public function index($page = array())
 {
     if (!$page) {
         App::render('docs/index.twig', $this->data);
     } else {
         $page = 'docs/' . implode('/', $page) . '.twig';
         App::render($page, $this->data);
     }
 }
Example #3
0
 public function render()
 {
     $html = '';
     if ($this->block !== null) {
         foreach ($this->block as $block) {
             $html .= App::render("components/{$block}");
         }
     }
     return $html;
 }
Example #4
0
 public function index()
 {
     $req = App::request();
     if ($req->isPost()) {
         if ($this->auth->login($req->post('user'), $req->post('passwd'))) {
             App::flash('info', "Your login was successful")->redirect('home');
         } else {
             App::flash('error', 'Your username or password was wrong');
         }
     }
     App::render('auth/login');
 }
Example #5
0
 public function positem()
 {
     $grid['folder'] = "Penjualan";
     $grid['title'] = "Entri penjualan item";
     $grid['url_item'] = APP::urlFor('item.dataset');
     $grid['url_item_uom'] = APP::urlFor('unitOM.dataset');
     $grid['url_item_batch'] = APP::urlFor('batch.stockEntries');
     $grid['url_dosis'] = APP::urlFor('selling.dosis');
     $grid['url_stok_balance'] = APP::urlFor('stok.balance');
     $grid["url_price_list"] = App::urlFor("selling.pricelist");
     $grid['url_gudang'] = APP::urlFor('warehouse.dataset');
     App::render('selling/form_penjualan', $grid);
 }
Example #6
0
 public function welcome()
 {
     $res = UBTSDK::getInstance()->getAccessToken();
     var_dump($res);
     exit;
     /*
     $app = Slim::getInstance();
     $app = $this->app;
     $memConfig = $app->config('memcache');
     $cacheHandler = MyPDOCacher::getInstance();
     */
     $this->loadCss('landing-page.css');
     $this->loadCss('font-awesome.min.css');
     $this->data['title'] = 'Welcome to iBus admin';
     App::render('welcome.twig', $this->data);
 }
Example #7
0
 public function v005($id = null)
 {
     $grid['folder'] = "Stock";
     $grid['title'] = "Form batch / Brand Item";
     $grid['url_submit'] = App::urlFor("batch.s003");
     $data = null;
     if (!is_null($id)) {
         $data = Batch::find($id);
         $grid['is_read_only'] = true;
     }
     $grid['data'] = $data;
     $grid['url_price_list'] = APP::urlFor('pricelist.dataset');
     $grid['url_item'] = APP::urlFor('item.dataset');
     App::render('batch/form_batch', $grid);
 }
Example #8
0
 public function v005($id = null)
 {
     $grid['folder'] = "Stock";
     $grid['title'] = "Form Unit of Measure / Satuan Item";
     $data = null;
     if (!is_null($id)) {
         $data = Principal::find($id);
     }
     $grid['data'] = $data;
     $grid['url_submit'] = App::urlFor("principal.s003");
     App::render('principal/form_principal', $grid);
 }
Example #9
0
 public function TestChat()
 {
     $grid["folder"] = "Chat";
     App::render('/viewku/test_chat', $grid);
 }
Example #10
0
 public function welcome()
 {
     $this->data['title'] = 'Actugaming - Accueil';
     App::render('welcome.twig', $this->data);
 }
Example #11
0
 /**
  * Stock Entry ada 3 jenis
  * - item issue (keluar)[from warehouse]
  * - item receipt (masuk)[to warehouse]
  * - item transfer (mutasi)[from wh to wh]
  */
 public function entry($tipe)
 {
     $tipe_arr = array('MASUK', 'KELUAR');
     if (in_array($tipe, $tipe_arr)) {
         $grid['folder'] = "Stok";
         $grid['title'] = "Stok " . $tipe;
         // Default Value
         $grid['data']['entry_kode'] = "STE-" . ZiUtil::GetNowID();
         $grid['data']['posting_date'] = date("Y-m-d");
         $grid['data']['posting_time'] = date("H:i:s");
         $grid['data']['stok_entry_tipe'] = $tipe;
         $grid['data']['from_warehouse'] = '7c87a8d69bc21df012ae8e3b17c5fff7';
         $grid['data']['to_warehouse'] = '';
         if ($tipe == 'MASUK') {
             $grid['data']['from_warehouse'] = '';
             $grid['data']['to_warehouse'] = '7c87a8d69bc21df012ae8e3b17c5fff7';
         }
         $grid['gridtitle'] = "Stock Entries";
         /****
          * barcode: "11245"
          * from_warehouse: "20151112698730750"
          * item_batch: "ITEM-KENALOG-5g-0001"
          * item_kode: "ITEM-KENALOG-5g"
          * item_nama: "KENALOG"
          * item_price: "4.566"
          * item_qty: "33.324"
          * item_serial: ""
          * item_uom: "BOX"
          * keterangan: "asdqweqw"
          * to_warehouse: "7c87a8d69bc21df012ae8e3b17c5fff7"
          */
         $cols = array();
         $cols[] = json_decode('{"field": "state", "checkbox": true}');
         $cols[] = json_decode('{ "title": "id", "field": "id", "visible": false}');
         $cols[] = json_decode('{ "title": "Serial No..", "field": "item_serial", "visible": false}');
         $cols[] = json_decode('{ "title": "Batch No.", "field": "item_batch", "visible": false}');
         $cols[] = json_decode('{ "title": "Kode Item", "field": "item_kode"}');
         $cols[] = json_decode('{ "title": "Nama Item","field": "item_nama"}');
         $cols[] = json_decode('{ "title": "UOM", "field": "item_uom", "visible": false}');
         $cols[] = json_decode('{ "title": "Keterangan", "field": "keterangan", "visible": false}');
         $cols[] = json_decode('{ "title": "Dari Gudang", "field": "from_warehouse", "visible": false}');
         $cols[] = json_decode('{ "title": "Dari Gudang", "field": "from_warehouse_nama"}');
         $cols[] = json_decode('{ "title": "Ke Gudang", "field": "to_warehouse", "visible": false}');
         $cols[] = json_decode('{ "title": "Ke Gudang", "field": "to_warehouse_nama"}');
         $cols[] = json_decode('{ "title": "Qty", "field": "item_qty"}');
         $cols[] = json_decode('{ "title": "Actual Qty", "field": "actual_qty"}');
         $cols[] = json_decode('{ "title": "Basic Rate", "field": "item_price", "visible": false}');
         $cols[] = json_decode('{ "title": "Total Harga", "field": "item_amount"}');
         $grid["cols"] = json_encode($cols);
         //    $grid['source_url'] = APP::urlFor('pasien.jenispasien');
         $grid['url_submit'] = APP::urlFor('stok.s003');
         $grid['url_entry_tipe'] = APP::urlFor('stok.entrytipe');
         $grid['url_gudang'] = APP::urlFor('warehouse.dataset');
         $grid['modal_form'] = APP::urlFor('stok.entryitem');
         App::render('stock/form_entry', $grid);
     } else {
         App::flash('info', 'Menu yang anda tuju tidak ada');
         App::redirect('stok.list_stock_entry');
     }
 }
Example #12
0
 public function v005($id = null)
 {
     $grid['folder'] = "<a href=\"" . App::urlFor('item.index') . "\">Stock</a>";
     $grid['title'] = "Form Item";
     //    $grid['data']['item_kode'] = "ITEM-".ZiUtil::GetNowID();
     $grid['url_itemprice'] = App::urlFor("itemprice.filter");
     $grid['url_submit'] = App::urlFor("item.s003");
     $grid['url_item_uom'] = APP::urlFor('unitOM.dataset');
     $grid['url_item_grup'] = APP::urlFor('item.grupitem');
     $grid['url_principal'] = APP::urlFor('principal.dataset');
     $grid['url_gudang'] = APP::urlFor('warehouse.dataset');
     $data = null;
     if (!is_null($id)) {
         $data = Item::find($id);
     }
     $grid['data'] = $data;
     App::render('item/form_item', $grid);
 }
Example #13
0
        $criteria['orderBy'] = $request->getParameter('orderBy');
    }
    if (!is_null($request->getParameter('limit'))) {
        $criteria['limit'] = $request->getParameter('limit');
    }
    $data = array('statuses' => $statusFinder->findAll($criteria));
    if ($request->guessBestFormat() === 'json') {
        return new JsonResponse($data);
    }
    return $app->render('index.php', $data);
});
/**
 * Get a status
 */
$app->get('/statuses/(\\d+)', function (Request $request, $id) use($app, $statusFinder) {
    if (is_null($status = $statusFinder->findOneById($id))) {
        throw new HttpException(404, 'Oups! This status cannot be found :(');
    }
    $data = array('status' => $status);
    if ($request->guessBestFormat() === 'json') {
        return new JsonResponse($data);
    }
    return $app->render('status.php', $data);
});
/**
 * Add a status
 */
$app->post('/statuses', function (Request $request) use($app, $statusFinder, $statusDM) {
    $status = new Status(null, $request->getParameter('message'), $request->getParameter('authorName'), new DateTime(), $request->getUserAgent());
    $statusDM->persist($status);
    if ($request->guessBestFormat() === 'json') {
        return new JsonResponse("statuses/" . count($statusFinder->findAll()), 201);
Example #14
0
<?php

session_start();
require_once __DIR__ . '/app/Config.php';
require_once ROOT_DIR . '/vendor/autoload.php';
require_once ROOT_DIR . '/app/App.php';
$app = new App();
$app->init();
$app->process();
$app->render();
$app->terminate();
Example #15
0
 /**
  * Display finish page
  */
 public function finish()
 {
     App::render('install/finish.twig', $this->data);
 }
Example #16
0
 public function v005($id = null)
 {
     $grid['folder'] = "Stock";
     $grid['title'] = "Form Unit of Measure / Satuan Item";
     $data = null;
     if (!is_null($id)) {
         $data = UOM::find($id);
     }
     $grid['data'] = $data;
     $grid['url_submit'] = App::urlFor("unitOM.s003");
     App::render('uom/form_uom', $grid);
 }
Example #17
0
     return $app->render('page_order', array('title' => 'Оформление заказа', 'aprtData' => $aprtData));
 });
 /**
  * http://demoshop.actionpay.ru/thankyou
  * Страница "спасибо за заказ"
  */
 $app->page('/thankyou', function (Order $order) use($app) {
     $aprtData = array('pageType' => \Actionpay\APRT::PAGETYPE_THANKYOU, 'purchasedProducts' => array(), 'orderInfo' => array('id' => $order->id, 'totalPrice' => $order->getTotalPrice()));
     foreach ($order->getOrderedProducts() as $orderProduct) {
         $aprtData['purchasedProducts'][] = array('id' => $orderProduct->getProduct()->id, 'name' => $orderProduct->getProduct()->name, 'price' => $orderProduct->getProduct()->price, 'quantity' => $orderProduct->count);
     }
     return $app->render('page_thankyou', array('title' => 'Спасибо за заказ', 'order' => $order, 'aprtData' => $aprtData));
 });
 /**
  * http://demoshop.actionpay.ru/admin/order?order=<ORDER_ID>
  * Страница просмотра заказа для сотрудника магазина
  */
 $app->page('/admin/order', function (Order $order, $status) use($app) {
     $status = (int) $status;
     // если запрошено изменение статуса заказа
     if (array_key_exists($status, Order::$statusList)) {
         $order->status = $status;
         $order->save();
         $app->redirect('/admin/order?order=' . $order->id);
         return '';
     }
     return $app->render('page_admin_order', array('title' => 'Заказ', 'order' => $order));
 });
 /**
  * http://demoshop.actionpay.ru/admin
  * Страница просмотра всех заказов для сотрудника магазина
  */
 $app->page('/admin', function () use($app) {
     $orders = Order::getAll(array(), array('id' => false));
     return $app->render('page_admin', array('title' => 'Заказы', 'orders' => $orders));
Example #18
0
}
$app = new App();
$app->register(new Silex\Provider\TwigServiceProvider(), ['twig.path' => __DIR__ . '/templates']);
$app->register(new Silex\Provider\DoctrineServiceProvider(), ['db.options' => ['driver' => 'pdo_sqlite', 'path' => __DIR__ . '/app.db']]);
$app->get('/', function () use($app) {
    return $app->render('home.html.twig');
});
$app->get('/tidus_laugh.{ext}', function ($ext) use($app) {
    $sth = $app['db']->prepare('SELECT mime_type FROM extensions WHERE extension = ?');
    $sth->bindValue(1, $ext, \PDO::PARAM_STR);
    $sth->execute();
    $mimeType = $sth->fetchColumn();
    if (!is_string($mimeType)) {
        $app->abort(404, 'No such extension');
    }
    $filename = __DIR__ . "/repository/tidus_laugh.{$ext}";
    $expiresDate = new \DateTime();
    $expiresDate->modify('+1 day');
    $response = new BinaryFileResponse($filename);
    $response->headers->set('Content-Type', $mimeType);
    $response->setPublic();
    $response->setExpires($expiresDate);
    return $response;
})->assert('ext', '^[0-9a-z]+$');
$app->get('/manage', function () use($app) {
    $extensions = $app['db']->fetchAll('SELECT * FROM extensions ORDER BY extension ASC');
    return $app->render('manage.html.twig', ['extensions' => $extensions]);
});
$app->post('/new', function (Request $request) use($app) {
    $extension = $request->request->get('extension');
    $mimeType = $request->request->get('mime_type');
    $password = $request->request->get('password');
Example #19
0
 public function welcome()
 {
     $this->data['title'] = 'Monitor';
     App::render('welcome.twig', $this->data);
 }
 /**
  * Redirect to the register view
  *
  * @return void
  **/
 public function register()
 {
     $this->data['title'] = 'Weather | Inscription';
     $this->data['template'] = 'home/form.twig';
     App::render('welcome.twig', $this->data);
 }
Example #21
0
 public function welcome()
 {
     $this->data['title'] = 'Welcome to Slim Starter Application';
     App::render('welcome.twig', $this->data);
 }
Example #22
0
    return $app->render('status.php', $data);
});
// Matches if the HTTP method is POST -> /statutes
$app->post('/statuses', function (Request $request) use($app, $statusFinder, $statusMapper, $userMapper) {
    $data['user'] = htmlspecialchars($request->getParameter('user'));
    $data['message'] = htmlspecialchars($request->getParameter('message'));
    if (empty($data['message'])) {
        $_SESSION['error'] = "Empty status";
        return $app->redirect('/statuses');
    }
    $status = new Status(null, $data['user'], $data['message'], date('Y-m-d H:i:s'));
    $statusMapper->persist($status);
    if ($request->guessBestFormat() === 'json') {
        return new JsonResponse(json_encode('statuses/' . $status), 201);
    }
    return $app->redirect('/statuses');
});
// Matches if the HTTP method is POST -> /login
$app->post('/login', function (Request $request) use($app, $userFinder) {
    $data['user'] = $request->getParameter('user');
    $data['password'] = $request->getParameter('password');
    if (Validation::validateConnection($data['user'], $data['password'])) {
        $data['error'] = 'Empty Username or password';
        return $app->render('login.php', $data);
    }
    if (null == ($user = $userFinder->findOneByUserName($data['user']))) {
        $data['error'] = 'Unknown user';
        return $app->render('login.php', $data);
    }
    if (!password_verify($data['password'], $user->getUserPassword())) {
        $data['error'] = 'Bad password';
        return $app->render('login.php', $data);
Example #23
0
    $content = $app->render("status.php", array('statuses' => $statuses, 'login' => $login));
    if (count($statuses) == 0) {
        $response = new Response($content, 204);
        $response->send();
        return;
    }
    if (Request::guessBestFormat() == "json") {
        $response = new Response(json_encode($statuses), 200);
        $response->send();
        return;
    }
    $response = new Response($content, 200);
    $response->send();
});
$app->get('/statuses/(\\d+)', function (Request $request, $id) use($app, $statusFinder) {
    if (!Verification::checkInteger($id)) {
        $response = new Response("Error with the object ID", 400);
        $response->send();
        return;
    }
    $status = $statusFinder->findOneById($id);
    if (!isset($status)) {
        $response = new Response("Object doesn't exist", 416);
        $response->send();
        return;
    }
    if (Request::guessBestFormat() == 'json') {
        $response = new Response(json_encode($status), 200);
        $response->send();
        return;
    }
    $content = $app->render("unStatus.php", array('status' => $status));
Example #24
0
 public function v005($id = null)
 {
     $grid['folder'] = "Stock";
     $grid['title'] = "Form Price list / Daftar Harga";
     $data = null;
     if (!is_null($id)) {
         $data = PriceList::find($id);
     }
     $grid['data'] = $data;
     $grid['url_submit'] = App::urlFor("pricelist.s003");
     App::render('pricelist/form_pricelist', $grid);
 }
Example #25
0
 public function v005($id = null)
 {
     $grid['folder'] = "Stock";
     $grid['title'] = "Form itemprice / Brand Item";
     $grid['url_submit'] = App::urlFor("itemprice.s003");
     $data = null;
     if (!is_null($id)) {
         $data = ItemPriceList::find($id);
     }
     $grid['data'] = $data;
     $grid['url_price_list'] = APP::urlFor('pricelist.dataset');
     $grid['url_item'] = APP::urlFor('item.dataset');
     App::render('itemprice/form_itemprice', $grid);
 }
Example #26
0
    return $app->render('statuses.php', array('array' => $statuses));
});
/*
 * GET /statuses/id
 */
$app->get('/statuses/(\\d+)', function (Request $request, $id) use($app, $statusFinder) {
    $status = $statusFinder->findOneById($id);
    if (!$status instanceof \Model\Status) {
        $app->redirect("/statusNotFound", 404);
    }
    $format = $request->guessBestFormat();
    if ('json' === $format) {
        $response = new Response(json_encode($status), 200, array('Content-Type' => 'application/json'));
        $response->send();
        return;
    }
    return $app->render('status.php', array('status' => $status));
});
/*
 *  GET /statusNotFound
 */
$app->get('/statusNotFound', function (Request $request) use($app) {
    return $app->render('statusNotFound.php', [], 404);
});
/*
 * GET /register
 */
$app->get('/register', function () use($app) {
    if (isset($_SESSION['username'])) {
        return $app->redirect('/');
    }
    return $app->render('register.php');
Example #27
0
    return $app->render('login.php');
});
// Matches if the HTTP method is GET -> /register
$app->get('/register', function () use($app) {
    return $app->render('register.php');
});
// Matches if the HTTP method is GET -> /logout
$app->get('/logout', function () use($app) {
    session_destroy();
    $app->redirect('/statuses');
});
// Matches if the HTTP method is GET -> /statuses
$app->get('/statuses', function (Request $request) use($app, $statusFinder) {
    $data = array('status' => $statusFinder->findAll());
    if ($request->guessBestFormat() === 'json') {
        return new JsonResponse($data);
    }
    if (isset($_SESSION['userName'])) {
        array_push($data, 'userName', $_SESSION['userName']);
    } else {
        array_push($data, 'userName', "NoUser");
    }
    return $app->render('index.php', $data);
});
// Matches if the HTTP method is GET -> /statuses/id
$app->get('/statuses/(\\d+)', function (Request $request, $id) use($app, $statusFinder) {
    if (null === ($status = $statusFinder->findOneById($id))) {
        throw new HttpException(404);
    }
    $data = array('status' => $status);
    if ($request->guessBestFormat() === 'json') {
        return new JsonResponse($data);
    }
    return $app->render('status.php', $data);
Example #28
0
 /**
  * @covers \Phix\App::render
  */
 public function testRenderSets406ErrorOnInvalidView()
 {
     $app = new App();
     $app->requestUri('/');
     $app->render('unknown');
     $this->assertEquals(406, $app->status());
     $this->assertTrue($app->stopped());
 }
Example #29
0
 public function index()
 {
     $grid["folder"] = "Dashboard";
     App::render("dashboard", $grid);
     //		App::render("left_sider_bar");
 }
Example #30
0
 public function v005($id = null)
 {
     $grid['folder'] = "Stock";
     $grid['title'] = "Form Warehouse";
     $data = null;
     if (!is_null($id)) {
         $data = Warehouse::find($id);
     }
     $grid['data'] = $data;
     $grid['url_submit'] = App::urlFor("warehouse.s003");
     App::render('warehouse/form_warehouse', $grid);
 }