예제 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Request::all();
     $avto = new Avto($input);
     $repair = new Repair($input);
     $customer = new Customer($input);
     $avto->save();
     $repair->save();
     $customer->save();
     $order = new Order(['date' => $input['date'], 'd_avto' => $avto->id, 'd_r' => $repair->id, 'customer_id' => $customer->id]);
     $order->save();
     //  dd($avto);<--Для дебага
     return redirect('orders/ordersuccess');
 }
예제 #2
0
 public function home()
 {
     $page_title = "لوحة التحكم";
     $section_title = "لوحة التحكم";
     Date::setLocale('ar');
     $date = Date::now()->format('j F Y');
     $day = Date::now()->format('l');
     $month = Date::now()->format('F');
     $year = Date::now()->format('Y');
     //**************Tasks***************
     $tasksToday = Task::orderBy('task_date', 'desc')->today()->take(5);
     $tasksWeek = Task::orderBy('task_date', 'desc')->thisweek()->take(5);
     $tasksMonth = Task::orderBy('task_date', 'desc')->thisMonth()->take(5);
     $tasks_count = count($tasksToday->toArray());
     //**************Fails***************
     $failsToday = Failure::orderBy('fail_time', 'desc')->today()->take(5);
     $failsWeek = Failure::orderBy('fail_time', 'desc')->thisweek()->take(5);
     $failsMonth = Failure::orderBy('fail_time', 'desc')->thisMonth()->take(5);
     $fails_count = count($failsToday->toArray());
     //**************Repairs***************
     $repairsToday = Repair::today();
     $repairsWeek = Repair::thisweek();
     $repairsMonth = Repair::thisMonth();
     $repairs_count = count($repairsToday->toArray());
     return view('dashboard.dashboard', compact('page_title', 'section_title', 'date', 'day', 'month', 'year', 'tasksToday', 'tasksMonth', 'tasksWeek', 'tasks_count', 'failsToday', 'failsMonth', 'failsWeek', 'fails_count', 'repairsToday', 'repairsMonth', 'repairsWeek', 'repairs_count'));
 }
 public function ongoingRepairs()
 {
     return view('report', ['title' => "Ongoing repairs", 'repairs' => Repair::where('Ongoing', 1)->get()]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Repair $repair)
 {
     $repair->delete();
     return Redirect::route('repairs.index')->with('message', 'Repair deleted');
 }
예제 #5
0
 public function finish(Request $request, $id)
 {
     $repair = Repair::findOrFail($id);
     $repair->update(['rep_status' => 'تم']);
     return redirect('maintainance/repairs');
 }
예제 #6
0
 public function handleAction(Request $request)
 {
     $action = $request->input('_action');
     if ($action == 'addDevice') {
         $this->validate($request, ['serial_number' => 'unique:devices']);
         $date = Device::convertDate($request->input('purchased_at'));
         $id = DB::table('devices')->insertGetId(['serial_number' => $request->input('serial_number'), 'purchased_at' => $date, 'model_id' => $request->input('model_id')]);
         //Device::create( $request->all() );
         return response(['status' => 'success', 'new_added_id' => $id]);
     } else {
         if ($action == 'createRepair') {
             if ($request['device_id'] != '') {
                 $id = File::create($request->all())->id;
                 Repair::create(['file_id' => $id, 'device_id' => $request->input('device_id'), 'accessory' => $request->input('accessory'), 'description' => $request->input('description')]);
                 $leftmenu['files'] = 'active';
                 $param['code_status_id'] = '4';
                 $param['file_id'] = $id;
                 $param['created_at'] = date('d/m/Y, H:i:s');
                 $param['user_id'] = Auth::user()->id;
                 $param['comment'] = '';
                 $response = StatusFile::create($param);
                 File::find($id)->touch();
                 if (isset($request['devis'])) {
                     $param['code_status_id'] = "15";
                     $response = StatusFile::create($param);
                     File::find($id)->touch();
                 }
                 return response(['status' => 'success', 'redirect' => '/file/repair/' . $id]);
             } else {
                 return response(['status' => 'error']);
             }
         } else {
             if ($action == 'createOrder') {
                 $order_details = session()->has('order_details') ? session('order_details') : false;
                 if ($order_details) {
                     $id = File::create($request->all())->id;
                     Order::create(["file_id" => $id, "total_details_amount" => $order_details['total']]);
                     $param['code_status_id'] = '4';
                     $param['file_id'] = $id;
                     $param['created_at'] = date('d/m/Y, H:i:s');
                     $param['user_id'] = Auth::user()->id;
                     $param['comment'] = '';
                     $response = StatusFile::create($param);
                     File::find($id)->touch();
                     foreach ($order_details as $order_item) {
                         if (isset($order_item['price'])) {
                             OrderDetails::create(["file_id" => $id, "article_id" => $order_item['article_id'], "price" => $order_item['price'], "quantity" => $order_item['quantity']]);
                         }
                     }
                     $request->session()->forget('order_details');
                     return response(['status' => 'success', 'redirect' => '/file/order/' . $id]);
                 }
                 return response(['status' => 'error']);
             } else {
                 if ($action == 'calculateOrder') {
                     $list = json_decode($request['_params'], true);
                     $response = Order::calculateTotal($list['orders']);
                     $list['orders']['total'] = $response;
                     $response != 0 ? Session::put('order_details', $list['orders']) : '';
                     $response = $response != 0 ? ['status' => 'success', 'total' => $response] : ['status' => 'error'];
                     return response($response);
                 } else {
                     return response(['status' => 'error']);
                 }
             }
         }
     }
 }
 public function finish(Request $request, $id)
 {
     /*  if (Gate::denies('maintain')) {
           abort(403, 'هذا الإجراء ليس من صلاحياتك');
         }*/
     $repair = Repair::findOrFail($id);
     $repair->update(['rep_status' => 'تم']);
     return redirect('maintainance/repairs/waiting');
 }