Ejemplo n.º 1
0
 public function postOrders()
 {
     $input_start_date = \Input::get('start_date');
     if ($input_start_date == "") {
         $input_start_date = "01/01/1900";
     }
     $start_date = \DateTime::createFromFormat('d/m/Y', $input_start_date);
     $input_end_date = \Input::get('end_date');
     if ($input_end_date == "") {
         $end_date = new \DateTime("NOW");
     } else {
         $end_date = \DateTime::createFromFormat('d/m/Y', $input_end_date);
     }
     $data = Order::where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->orderBy('created_at', 'desc')->get();
     if (count($data) == 0) {
         $errors = new \Illuminate\Support\MessageBag();
         $errors->add('downloadError', "There's no data within the dates specified.");
         return \Redirect::to('admin/orders')->withErrors($errors);
     }
     \Excel::create('Redmin_Orders_Report', function ($excel) use($data) {
         $excel->sheet('Orders Report', function ($sheet) use($data) {
             $sheet->loadView('redminportal::reports/orders')->with('data', $data);
         });
     })->download('xlsx');
 }
Ejemplo n.º 2
0
 public function delete()
 {
     // Remove product association
     $order = Order::find($this->id);
     $order->pricelists()->detach();
     return $order->delete();
 }
Ejemplo n.º 3
0
 public function getUpdate($field = null, $sid = null, $status = null)
 {
     $field_pattern = '/^[a-zA-Z0-9_\\-]+$/';
     $text_pattern = '/^[a-zA-Z0-9 _\\-]+$/';
     $rules = ['field' => 'required|in:status|regex:' . $field_pattern, 'sid' => 'required|numeric', 'status' => 'required|regex:' . $text_pattern];
     $inputs = ['field' => $field, 'sid' => $sid, 'status' => $status];
     $messages = ['field.in' => trans('redminportal::messages.order_error_update_unsupported_field'), 'field.required' => trans('redminportal::messages.order_error_update_missing_field'), 'field.regex' => trans('redminportal::messages.error_remove_special_characters'), 'status.required' => trans('redminportal::messages.order_error_update_missing_status'), 'status.regex' => trans('redminportal::messages.error_remove_special_characters')];
     $validation = Validator::make($inputs, $rules, $messages);
     if ($validation->fails()) {
         return redirect($this->pageRoute)->withErrors($validation);
     }
     // Only supports status for now
     if ($field == 'status') {
         $order = Order::find($sid);
         $order->payment_status = $status;
         $order->save();
     }
     return redirect()->back();
 }
Ejemplo n.º 4
0
 public function getDelete($sid)
 {
     // Find the module using the user id
     $module = Module::find($sid);
     if ($module == null) {
         $errors = new \Illuminate\Support\MessageBag();
         $errors->add('deleteError', "We are having problem deleting this entry. Please try again.");
         return redirect()->back()->withErrors($errors);
     }
     $purchases = Order::join('order_pricelist', 'orders.id', '=', 'order_pricelist.id')->join('pricelists', 'pricelists.id', '=', 'order_pricelist.pricelist_id')->where('pricelists.module_id', $sid)->get();
     if (count($purchases) > 0) {
         $errors = new \Illuminate\Support\MessageBag();
         $errors->add('deleteError', "This module has been purchased before. You cannot delete it. Please disable it instead.");
         return redirect()->back()->withErrors($errors);
     }
     // Delete the module
     $module->delete();
     return redirect()->back();
 }