Exemplo n.º 1
0
 function order($id)
 {
     $userId = Session::get('user_id');
     if (!isset($userId)) {
         return Redirect::to('/');
     }
     $order = Order::find($id);
     if (isset($order)) {
         $orderItems = OrderItem::where('order_id', $order->id)->get();
         return View::make('user.order')->with('order', $order)->with('orderItems', $orderItems);
     } else {
         return Redirect::to('/');
     }
 }
Exemplo n.º 2
0
 public function adminInvoice($id)
 {
     if (isset($id)) {
         $order = Order::find($id);
         if (isset($order)) {
             //  Session::put('order_id', $id);
             $orderItems = OrderItem::where('order_id', $order->id)->get();
             $couriers = Courier::where('status', 'active')->get();
             $pdf = PDF::loadView('pdf.adminInvoice', ['order' => $order, 'orderItems' => $orderItems, 'couriers' => $couriers]);
             //                return $pdf->download('invoice.pdf');
             return $pdf->stream();
         } else {
             return Redirect::to('/');
         }
     } else {
         return Redirect::to('/');
     }
 }
Exemplo n.º 3
0
 public static function saveInvoice($id)
 {
     if (isset($id)) {
         $order = Order::find($id);
         if (isset($order)) {
             //  Session::put('order_id', $id);
             $orderItems = OrderItem::where('order_id', $order->id)->get();
             $couriers = Courier::where('status', 'active')->get();
             $pdf = PDF::loadView('pdf.adminInvoice', ['order' => $order, 'orderItems' => $orderItems, 'couriers' => $couriers]);
             $output = $pdf->output();
             $file_to_save = './public/uploads/pdf/order_' . $order->id . '.pdf';
             file_put_contents($file_to_save, $output);
             return true;
         } else {
             return Redirect::to('/');
         }
     } else {
         return Redirect::to('/');
     }
 }
Exemplo n.º 4
0
 public function transactionSuccess()
 {
     $transactionId = Session::get('transactionId');
     if ($transactionId) {
         $status = Input::get('status');
         if ($status == 'success') {
             $payment_mode = Input::get('mode');
             $gateway_payment_id = Input::get('mihpayid');
             $net_amount_debit = Input::get('net_amount_debit');
             $order = Order::where('transaction_id', $transactionId)->first();
             if (isset($order)) {
                 $order->payment_mode = $payment_mode;
                 $order->gateway_payment_id = $gateway_payment_id;
                 $order->net_amount_debit = $net_amount_debit;
                 $order->save();
                 $order_id = $order->id;
                 $mail = SendMailController::userInvoiceMail($order_id);
                 if ($mail) {
                     $order = Order::find($order_id);
                     $orderItems = OrderItem::where('order_id', $order_id)->get();
                     return View::make('checkout.transaction-success')->with('order', $order)->with('orderItems', $orderItems);
                 }
             } else {
                 return Redirect::to('/transaction-failure');
             }
         } else {
             return Redirect::to('/transaction-failure');
         }
     } else {
         return Redirect::to('/');
     }
 }
Exemplo n.º 5
0
 public function orders()
 {
     $user_id = Session::get('user_id');
     if (is_null($user_id)) {
         return Redirect::to('/');
     }
     $orders = Order::where('user_id', $user_id)->get();
     $orderItems = array();
     if (isset($orders) && count($orders) > 0) {
         foreach ($orders as $order) {
             $orderItems[] = OrderItem::where('order_id', $order->id)->get();
         }
     }
     if (isset($orderItems) && count($orderItems) > 0) {
         return View::make('order.list')->with('found', true)->with('orders', $orders)->with('orderItems', $orderItems);
     } else {
         return View::make('order.list')->with('found', false);
     }
 }
Exemplo n.º 6
0
 public function viewOrder($id)
 {
     $adminId = Session::get('admin_id');
     if (!isset($adminId)) {
         return Redirect::to('/');
     }
     if (isset($id)) {
         $order = Order::find($id);
         if (isset($order)) {
             Session::put('order_id', $id);
             $orderItems = OrderItem::where('order_id', $order->id)->get();
             $couriers = Courier::where('status', 'active')->get();
             return View::make('admin.view-order')->with('order', $order)->with('orderItems', $orderItems)->with('couriers', $couriers);
         } else {
             return Redirect::to('/');
         }
     } else {
         return Redirect::to('/');
     }
 }