/** * Show the form for editing the specified resource. * * @param \App\Product $product * @return \Illuminate\Http\Response */ public function edit(Product $product) { $productVariants = Product_variant::where('product_id', $product->product_id)->get(); $languages = Language::orderBy('order', 'asc')->get(); $categories = Category::all(); $discounts = Discount::all(); $taxes = Tax::all(); return view('intothesource.webshop.products.edit', compact('product', 'productVariants', 'languages', 'categories', 'discounts', 'taxes')); }
public function store(DiscountFormRequest $request) { $input['event_id'] = $request->input('event'); $input['type'] = $request->input('type'); $input['for'] = $request->input('for'); $input['value'] = $request->input('value'); $input['info'] = $request->input('info'); Discount::create($input); \Flash::success('Discount added successfully'); return Redirect::back()->with(['tabName' => 'discounts']); }
/** * @author: Arham * @return $this * @param: get request * desc: validate the assign discount details, * if validate success then insert discount details to database * created : 04/02/2016 */ public function addDiscount(Request $request) { $table1 = null; $add = 0; $id = 1; $values = '1'; $item = DB::table('items')->select('itName')->get(); $oldDiscount = 0; $validate = validator::make(input::all(), array('Percentage' => 'required|numeric|min:5|max:75', 'start_date' => 'required|date|after:yesterday', 'end_date' => 'required|date|after:start_date')); if ($validate->fails()) { return view('pages\\Discount\\discountpage', ['table2' => $table1, 'item' => $item, 'td' => $add, 'id' => $id, 'oldDiscount' => $oldDiscount, 'values' => $values])->withErrors($validate)->withInput(Input::get('Percentage')); } else { $itemcategory = Input::get('itmcat'); $discountype = Input::get('disctyp'); $Percentage = Input::get('Percentage'); $sdate = Input::get('start_date'); $edate = Input::get('end_date'); $imag = DB::table('items')->where('itName', '=', $itemcategory)->value('imName'); $itid = DB::table('items')->where('itName', '=', $itemcategory)->value('itID'); $price = DB::table('items')->where('itName', '=', $itemcategory)->value('price'); $disc = $Percentage / 100.0 * $price; $iprice2 = $price - $disc; $iprice = round($iprice2, 2); $itemid = DB::table('discount')->select('itid')->get(); foreach ($itemid as $itemid1) { if ($itid == $itemid1->itid) { $dtype = DB::table('discount')->where('itid', '=', $itid)->value('dtype'); if ($dtype == $discountype) { $id = 0; return view('pages\\Discount\\discountpage', ['table2' => $table1, 'item' => $item, 'td' => $add, 'id' => $id, 'oldDiscount' => $oldDiscount, 'values' => $values])->withErrors($validate); } } } $id = 1; $discount = new Discount(); $add = $discount->insert(array('iname' => $itemcategory, 'dtype' => $discountype, 'ipersentage' => $Percentage, 'iprice' => $iprice, 'imgpath' => $imag, 'sdate' => $sdate, 'edate' => $edate, 'itid' => $itid)); return view('pages\\Discount\\discountpage', ['table2' => $table1, 'item' => $item, 'td' => $add, 'id' => $id, 'oldDiscount' => $oldDiscount, 'values' => $values])->withErrors($validate); } }
public function run() { DB::table('discounts')->delete(); Discount::create(array('h1' => 'Заголовок 1', 'h2' => 'Заголовок 2', 'DeadLine' => date("H:i Y-m-d", mktime(date("H"), date("i"), 0, date("m"), date("d"), date("Y") + 1)))); }
/** * Форма нового заказа */ 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 DiscountGetDelete($id) { Cate::where("discount_id", $id)->update(["discount_id" => 0]); $discount = Discount::find($id); $discount->delete(); return redirect()->route("admin.discount.list"); }
/** * Запрос цены на дату */ 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(); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $dis = new Discount(); $dis->where('id', $id)->update(['is_active' => 0]); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $categories = Category::all(array('id', 'name', 'parent_id')); $parent_category['0'] = 'Выберите родительскую категорию'; foreach ($categories as $key => $category) { if ($category->parent_id == '') { $parent_category[$category->id] = $category->name; } } $product = Product::findOrFail($id); $images = Image::where('prod_id', '=', $id)->get(); $category = Category::findOrFail($product->cat_id); $par_cat = Category::where('id', '=', $category->parent_id)->lists('name', 'id'); $cat = array($category->id => $category->name); $discounts = ProdDiscount::where('prod_id', '=', $id)->get(); foreach ($discounts as $key => $discount) { $disc = Discount::where('id', '=', $discount->discount_id)->get(); $discounts[$key]->disc_name = $disc[0]->name; $discounts[$key]->disc_description = $disc[0]->description; $disc_old[$discounts[$key]->id] = $discounts[$key]->disc_name; } $discounts_all = Discount::all(array('id', 'name', 'description')); // $discounts['0'] = 'Выберите скидки'; foreach ($discounts_all as $key => $discount_all) { $disc_all[$discount_all->id] = $discount_all->name; } //dd($disc_old); return view('products.edit', compact('par_cat', 'cat', 'parent_category', 'images', 'discounts', 'disc_old', 'disc_all'))->withProduct($product); }
/** * Formats a messy form and presents the user with a confirmation page (form) before * proceeding to payment. */ public function confirmEntry(Request $request) { // returns a confirm view which then sends the user to the store function above. $data = $request->all(); $user = Auth::user(); $event = Event::findOrFail($data['event_id']); $compSubTotal = 0; $extraSubTotal = 0; //Format the competitions for display in the confirmation form $entries = array(); //$competitions[$id] = array('detail' => $detail, 'competition' => $competition) foreach ($data['competitions'] as $competition_id => $detail_id) { if ($detail_id != "noEntry") { $competition = Competition::findOrFail($competition_id); $detail = Detail::findOrFail($detail_id); $entries[$competition_id] = array('competition' => $competition, 'detail' => $detail); $compSubTotal += $competition->fee; } } //if for some reason the competitor has forgotten to select a competition, bump them back. if (empty($entries)) { \Flash::error('You need to select a competition to enter before you can proceed.'); return redirect(action('EventsController@show', $event->slug)); } //Format the extras for display in the confirmation form $extras = array(); if (key_exists('extras', $data)) { foreach ($data['extras'] as $extra_id => $extraOrder) { $multiple = 1; $infoRequired = NULL; if (is_string($extraOrder) == False) { //This is an extra order with an array of info if (array_key_exists('multiple', $extraOrder)) { $multiple = $extraOrder['multiple']; } if (array_key_exists('infoRequired', $extraOrder)) { $infoRequired = $extraOrder['infoRequired']; } } $extra = Extra::findOrFail($extra_id); $thisExtraTotal = $extra->cost * $multiple; $extraSubTotal += $thisExtraTotal; $extras[$extra_id] = array('id' => $extra_id, 'multiple' => $multiple, 'infoRequired' => $infoRequired, 'extra' => $extra, 'thisExtraCost' => $thisExtraTotal); } } //Format the discounts so that the fixed and percentage discounts //can be applied separately, fixed first. $discounts = array(); $fixedDiscounts = array(); $percentageDiscounts = array(); $discounts_applied = ""; if (key_exists('discounts', $data)) { foreach ($data['discounts'] as $discount_id => $discountApply) { if ($discountApply == 1) { $discount = Discount::findOrFail($discount_id); $discounts[] = $discount; $discounts_applied = $discounts_applied . $discount_id . "-"; } } $discounts = collect($discounts); $fixedDiscounts = $discounts->where('type', 'fixed'); $percentageDiscounts = $discounts->where('type', 'percentage'); } //total (just competitions and extras) $compExtraSubtotal = $compSubTotal + $extraSubTotal; //Apply any discounts to the compextrasubtotal & registration fee //fixed fees first, then %. $discountedSubtotal = $compExtraSubtotal; $discountedRegistrationFee = $event->registrationFee; $percentageDiscountValues = array(); foreach ($fixedDiscounts as $fd) { $discountedSubtotal = $discountedSubtotal - $fd->value; } foreach ($percentageDiscounts as $pd) { $percentage = $pd->value / 100; $discount = $discountedSubtotal * $percentage; $percentageDiscountValues[$pd->id] = $discount; $discountedSubtotal = $discount; $discountedRegistrationFee = $discountedRegistrationFee * $percentage; } //Charge a late entry fee? //if it's past the closing date $lateEntryFee = 0; if (Carbon::now()->gt($event->closingDate)) { $lateEntryFee = $event->lateEntriesFee; } //FORESIGHT FEE $foresightFee = 2.99; $finalsubtotal = $discountedSubtotal + $discountedRegistrationFee + $lateEntryFee + $foresightFee; //paypal fees (3.4% + 20p) $paypalFees = $finalsubtotal * 0.034 + 0.2; $feesTotal = $discountedRegistrationFee + $lateEntryFee + $foresightFee + $paypalFees; $grandTotal = $finalsubtotal + $paypalFees; $format = "%4.2f"; $variables = array('entrydata' => $data, 'event' => $event, 'user' => $user, 'entries' => $entries, 'extras' => $extras, 'fixedDiscounts' => $fixedDiscounts, 'percentageDiscounts' => $percentageDiscounts, 'percentageDiscountValues' => $percentageDiscountValues, 'compSubTotal' => sprintf($format, $compSubTotal), 'extraSubTotal' => sprintf($format, $extraSubTotal), 'compExtraSubtotal' => sprintf($format, $compExtraSubtotal), 'discountedSubtotal' => sprintf($format, $discountedSubtotal), 'discountedRegistrationFee' => sprintf($format, $discountedRegistrationFee), 'lateEntryFee' => sprintf($format, $lateEntryFee), 'paypalFees' => sprintf($format, $paypalFees), 'feesTotal' => sprintf($format, $feesTotal), 'grandTotal' => sprintf($format, $grandTotal), 'discounts_applied' => $discounts_applied, 'foresightFee' => sprintf($format, $foresightFee)); //dd($variables); return view('events.entryconfirm')->with($variables); }
public function postListDiscount() { return Discount::select('h1', 'h2', 'DeadLine')->get(); }
/** * Remove the specified resource from storage. * * @param int $id * * @return Response */ public function destroy($id) { Discount::destroy($id); Session::flash('flash_message', 'Discount deleted!'); return redirect('admin/discounts'); }
public function getDatatable() { return Datatable::collection(Discount::all(array('id', 'name', 'description', 'percent', 'quantity')))->showColumns('id', 'name', 'description', 'percent', 'quantity')->addColumn('created', function ($model) { return date('d-m-Y', strtotime(".{$model->created_at}.")); })->addColumn('actions', function ($model) { return '<a href="/discounts/' . $model->id . '">Просм</a> | <a href="/discounts/' . $model->id . '/edit" >Ред</a>'; })->searchColumns('name', 'description', 'percent', 'quantity')->orderColumns('name', 'description', 'percent', 'quantity')->make(); }