public function postPrint() { Session::reflash(); $result = NULL; $tpl_id = Input::get('template', 0); $count = Input::get('count', 1); $type = Input::get('type'); $voucher_ids = Session::get('vouchers', ['0']); $parser = new TemplateParser(); $template = VoucherTemplate::find($tpl_id); switch ($type) { case 'prepaid_voucher': $vouchers = Voucher::variables($voucher_ids); break; case 'refill_coupon': $vouchers = refillcoupons::variables($voucher_ids); break; default: throw new Exception("Could not determine form type. Could not proceed."); break; } $i = 1; foreach ($vouchers as $voucher) { $parser->initData((array) $voucher); $result .= $parser->parseTemplateData($template->body); if ($i % $count == 0) { $result .= "<br />"; } else { $result .= " "; } $i++; } if ($i > 1) { $result .= "<br />" . Form::button('Print This Page', ['onclick' => 'window.print()', 'class' => 'btn btn-primary col-lg-offset-1']); } else { $result = "Please select atleast one voucher"; } return View::make('admin.vouchers.print')->with('vouchers', $result); }