/** * @before _secure */ public function invoice($order_id) { $this->setLayout("layouts/blank"); $this->seo(array("title" => "Invoice", "view" => $this->getLayoutView())); $view = $this->getActionView(); $order = Order::first(array("id = ?" => $order_id, "user_id = ?" => $this->user->id)); $patient = User::first(array("id = ?" => $order->user_id)); $appointments = Appointment::all(array("order_id = ?" => $order_id)); $instamojo = Instamojo::first(array("purpose = ?" => "order", "purpose_id = ?" => $order_id), array("payment_request_id")); $view->set("order", $order); $view->set("patient", $patient); $view->set("appointments", $appointments); $view->set("instamojo", $instamojo); }
public function generateinvoice($order_id, $instamojo_id = "not found", $action = "gen") { if ($instamojo_id == "not found") { $this->redirect("/patient/profile"); } $view = new Framework\View(array("file" => APP_PATH . "/application/views/layouts/others/invoice.html")); $order = Order::first(array("id = ?" => $order_id)); $instamojo = Instamojo::first(array("id = ?" => $instamojo_id)); $patient = User::first(array("id = ?" => $order->user_id)); $appointments = Appointment::all(array("order_id = ?" => $order->id)); $view->set("order", $order); $view->set("patient", $patient); $view->set("appointments", $appointments); $view->set("instamojo", $instamojo); if (!file_exists(APP_PATH . "/public/assets/uploads/files/orders/{$order->id}.pdf")) { $this->generatepdf($view->render(), $order->id); } if ($action == "show") { $this->redirect("/public/assets/uploads/files/orders/{$order->id}.pdf"); } }