/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // $input = $request->all(); $validator = Validator::make($input, ['price' => 'required', 'job_type' => 'required', 'job_id' => 'required', 'paper_id' => 'required']); if ($validator->fails()) { return \Redirect::back()->withErrors($validator)->withInput(); } array_forget($request, "_token"); $all_request = $request->all(); $price = Price::find($id); $papers = Paper::all(); $jobs = Job::all(); foreach ($all_request as $key => $value) { $price->{$key} = $value; } $price->update(); $prices = Price::all(); if ($request->ajax()) { if ($prices) { foreach ($prices as $price) { echo "\n <tr>\n <td>{$price->id}</td>\n <td>"; foreach ($papers as $paper) { if ($paper->id == $price->paper_id) { $paperid = $paper->name; echo $paper->name . ", " . $paper->size; } } echo " </td>\n <td>"; foreach ($jobs as $job) { if ($job->id == $price->job_id) { $jobid = $job->name; echo $job->name; } } echo "</td>\n <td>{$price->job_type}</td>\n <td>{$price->price}</td>\n <td><button class='edtPriceLink btn-primary' cpaperid='{$paperid}' cjobtype='{$price->job_type}' cid='{$price->id}' cjobid='{$price->job_id}' cprice='{$price->price}'><span class='glyphicon glyphicon-pencil'></span></button></td>\n <td><button class='btn-danger' data-target='#myModalPaperEdit' data-toggle='modal'><span class='glyphicon glyphicon-trash'></span></button></td>\n </tr>\n "; } } exit; } else { try { if ($price->update()) { \Session::flash("success_message", "New Price Record Updated Successfully"); return \Redirect::back(); } } catch (\Illuminate\Database\QueryException $e) { \Session::flash("error_message", $e->getMessage()); return \Redirect::back(); } catch (\PDOException $e) { \Session::flash("error_message", $e->getMessage()); return \Redirect::back(); } catch (\Exception $e) { \Session::flash("error_message", $e->getMessage()); return \Redirect::back(); } } return View("settings.priceedit", ['jobs' => $jobs, 'papers' => $papers, 'title' => 'Job Setting']); }
/** * Display a listing of the resource. * * @return Response */ public function index($location_id) { if ($location_id) { $prices = Price::where('location_id', $location_id); } else { $prices = Price::all(); } return view('prices.index', compact('prices')); }
public function printReport(Request $request) { $this->data['reward'] = Price::all(); $this->data['company'] = $request->input('company'); $this->data['date_from'] = $request->input('date_from'); $this->data['date_to'] = $request->input('date_to'); foreach ($request->input('select') as $val) { $this->data['orders'][] = Order::findOrFail($val); $order = Order::findOrFail($val); if ($order->departure_order_type == 1) { $this->data['dep'][] = $order->departure_passengers * $this->data['reward'][0]->reward; } else { $this->data['dep'][] = $this->data['reward'][$order->departure_order_type - 1]->reward; } if ($order->arrivals_order_type == 1) { $this->data['arr'][] = $order->arrivals_passengers * $this->data['reward'][0]->reward; } else { $this->data['arr'][] = $this->data['reward'][$order->departure_order_type - 1]->reward; } } return $this->render('reports.print-report'); }
/** * Форма нового заказа */ public function getNewOrder($user_id = null) { $this->page->title = 'Новый заказ'; $this->page->desc = 'Оформление заказа'; if ($user_id != null && is_numeric($user_id)) { $this->data['person'] = Person::findOrFail($user_id); } else { $this->data['person'] = null; } $this->data['price'] = Price::all(); // Список операторов $this->data['operators'] = Operator::where('user_id', '=', $this->user->id)->lists('name', 'id'); // Список аэропортов $this->data['airports'] = Airport::all()->lists('airport', 'id'); // Кол-во пассажиров $this->data['passengers'] = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10); $transfer = TransferType::all(); foreach ($transfer as $key => $value) { $this->data['transfer_out_' . $value->id] = Discount::where('type', '=', $value->id)->where('date_to', '>=', date('Y-m-d'))->where('date_from', '<=', date('Y-m-d'))->where('direction', '=', 'departure')->first(); } $transfer = TransferType::all(); foreach ($transfer as $key => $value) { $this->data['transfer_in_' . $value->id] = Discount::where('type', '=', $value->id)->where('date_to', '>=', date('Y-m-d'))->where('date_from', '<=', date('Y-m-d'))->where('direction', '=', 'arrivals')->first(); } return $this->render('order.new'); }
public function postPrice(Request $request) { array_forget($request, "_token"); $all_request = $request->all(); $price = new Price(); foreach ($all_request as $key => $value) { $price->{$key} = $value; } $price->save(); $prices = Price::all(); if ($request->ajax()) { if ($prices) { foreach ($prices as $price) { echo "\n <tr>\n <td>{$price->id}</td>\n <td>{$price->name}</td>\n\n <td>{$price->description}</td>\n <td>{$price->created_at}</td>\n <td>{$price->updated_at}</td>\n <td></td>\n <td></td>\n </tr>\n "; } } exit; } return View("settings.price", ['prices' => $prices, 'papers' => Paper::all(), 'jobs' => Job::all(), 'title' => 'Job Price Setting']); }
/** * Запрос цены на дату */ public function getPrice(Request $request) { // Обрабатываем только AJAX запрос if ($request->ajax()) { $price1 = Discount::where('date_from', '<=', date("Y-m-d 00:00:00", strtotime($request->input('date'))))->where('date_to', '>=', date("Y-m-d 23:59:59", strtotime($request->input('date'))))->where('type', 1)->first(); $price2 = Discount::where('date_from', '<=', date("Y-m-d 00:00:00", strtotime($request->input('date'))))->where('date_to', '>=', date("Y-m-d 23:59:59", strtotime($request->input('date'))))->where('type', 2)->first(); $price3 = Discount::where('date_from', '<=', date("Y-m-d 00:00:00", strtotime($request->input('date'))))->where('date_to', '>=', date("Y-m-d 23:59:59", strtotime($request->input('date'))))->where('type', 3)->first(); $price4 = Discount::where('date_from', '<=', date("Y-m-d 00:00:00", strtotime($request->input('date'))))->where('date_to', '>=', date("Y-m-d 23:59:59", strtotime($request->input('date'))))->where('type', 4)->first(); $base_price = Price::all(); $sum1 = $base_price[0]->price; $sum2 = $base_price[1]->price; $sum3 = $base_price[2]->price; $sum4 = $base_price[3]->price; if ($price1) { $sum1 = $price1->sum; } if ($price2) { $sum2 = $price1->sum; } if ($price3) { $sum3 = $price1->sum; } if ($price4) { $sum4 = $price1->sum; } $res_order = array('price1' => $sum1, 'price2' => $sum2, 'price3' => $sum3, 'price4' => $sum4); return response()->json($res_order); } else { return redirect()->back(); } }
public function index() { $prices = Price::all(); return response()->json($prices); }