public static function inventory() { return function ($request, $response) { if ($request->session('admin')) { try { $response->header('Content-Type', 'application/pdf'); $stocks_report = Zend_Pdf::load('../pdf/inv.pdf'); $page = $stocks_report->pages[0]; $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_COURIER); $page->setFont($font, 10); $page->drawText(Time::unixToDate(time()), 290, 818); $row = 765; $stocks = Stock::all(); foreach ($stocks as $stock) { $page->drawText(sprintf("%10.39s", $stock->product->name), 32, $row); $page->drawText($stock->product->description, 280, $row); $page->drawText(sprintf("%4u", $stock->quantity), 550, $row); $row -= 15; } $page->drawText("Prepared by:", 300, 80); $page->drawText("________________________________", 300, 50); echo $stocks_report->render(); } catch (Exception $e) { $response->header('Content-Type', 'text/plain'); echo $e->getMessage(); } } else { $response->code(403); } }; }
public static function index() { return function ($request, $response) { if ($request->session('admin')) { switch ($request->method()) { case 'GET': # code... $stocks = Stock::all(); $response->json($stocks->as_array()); break; case 'POST': # code... $data = $request->data(); $stock = new Stock(); $stock->product = $data->product->id; $stock->quantity = $data->quantity; $stock->save(); $response->json($stock->as_array()); break; case 'DELETE': # code... echo "DELETE"; break; case 'PUT': # code... echo "PUT"; break; default: # code... break; } } else { $response->code(403); } }; }
<?php require_once '../general.php'; $stocks = Stock::all()->as_array(); print_r($stocks); echo time() . "\n"; echo Time::unixToDate(time()) . "\n"; echo date(DATE_RFC822, strtotime('thursday next week 10:30am', 1352710199)) . "\n"; echo date(DATE_RFC822, strtotime('next month', 1352710199)) . "\n";
/** * Display a listing of stocks * * @return Response */ public function index() { $stocks = Stock::all(); return View::make('stocks.index', compact('stocks')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $stocks = $this->stock->all(); return View::make('stocks.index', compact('stocks')); }