public function create(Input $input) { $promotions = $input->get('promotion'); if ($promotions != []) { foreach ($promotions as $n => $promotion) { $dpt = new Promotion(); $dpt->firstOrCreate(['nom' => Str::upper($promotion)]); } Session::flash('flash_success', 'Vos promotions ont bien été créées'); } else { Session::flash('flash_error', 'Aucun champs n\'a été envoyé'); } $promotions = $this->promotion->all(); return redirect(route('admin_promotion_get', compact('promotions'))); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $new_promo = $this->request->all(); $new_promo['business_afm'] = \Auth::user()->afm; $promo = Promotion::create($new_promo); return \Redirect::route('business.promotions'); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $today = date('Y-m-d'); $promotion = Promotion::with('Product', 'Shop')->find($id); $samepromo = Promotion::with('Shop')->where('product_id', '=', $promotion->product_id)->where('id', '!=', $id)->where('start', '<=', $today)->where('end', '>=', $today)->get(); return view('promotion.show', compact('promotion', 'samepromo')); }
/** * Retourne tableau des promotions * Chaque promotion possède un tableau de ses specialitees */ public function promotionWithSpecialiteArray() { $promotions = Promotion::with('specialites')->get(); $result = []; foreach ($promotions as $promotion) { array_push($result, $promotion->specialites->lists('nom', 'id')); } return $result; }
public function run() { DB::table('specialites')->delete(); Specialite::create(['nom' => 'AL'])->promotion()->attach(\App\Promotion::where('nom', 'SI5')->first()); Specialite::create(['nom' => 'IHM'])->promotion()->attach(\App\Promotion::where('nom', 'SI5')->first()); Specialite::create(['nom' => 'GMD'])->promotion()->attach(\App\Promotion::where('nom', 'SI5')->first()); Specialite::create(['nom' => 'IMAFA'])->promotion()->attach(\App\Promotion::where('nom', 'SI5')->first()); Specialite::create(['nom' => 'CASPAR'])->promotion()->attach(\App\Promotion::where('nom', 'SI5')->first()); Specialite::create(['nom' => 'WEB'])->promotion()->attach(\App\Promotion::where('nom', 'SI5')->first()); Specialite::create(['nom' => 'IAM'])->promotion()->attach(\App\Promotion::where('nom', 'SI5')->first()); Specialite::where('nom', 'GMD')->first()->promotion()->attach(\App\Promotion::where('nom', 'MAM5')->first()); Specialite::where('nom', 'IMAFA')->first()->promotion()->attach(\App\Promotion::where('nom', 'MAM5')->first()); }
public function listPromotion($shopId = null, $categoryId = null) { $today = date('Y-m-d'); $promotions = Promotion::with(['Product.Photo' => function ($query) { return $query->where('dimension', '=', '400x700')->get(); }])->with('Shop')->where('start', '<=', $today)->where('end', '>=', $today); //filter by category if (isset($categoryId)) { $promotions->whereHas('product', function ($query) use($categoryId) { $query->where('category_id', '=', $categoryId); }); } //filter by shop if (isset($shopId)) { $promotions->where('shop_id', '=', $shopId); } return $promotions = $promotions->paginate(20); }
/** * Affiche le profil étudiant * * @return View */ public function getEtudiantProfil() { $array['etudiant'] = Auth::user()->user; $array['promotions'] = Promotion::with('specialites')->get()->toJson(); //Si aucune promotion n'est liée à l'étudiant if (isset($array['etudiant']->promotion_id)) { $array['etudiant_promotion'] = Auth::user()->user->promotion()->first(); } $array['profile'] = ProfileEtudiant::where('etudiant_id', $array['etudiant']->id)->first(); //Si aucune promotion n'est liée à l'étudiant if (isset($array['etudiant_promotion'])) { $array['specialites'] = Promotion::find($array['etudiant']->promotion_id)->specialites()->get(); } $array['etudiant_specialite'] = Auth::user()->user->specialite()->first(); //calculer le pourcentage du profil de l'etudiant $array['pourcentage'] = $this->getPourcentageProfilEtudiant(); return View::make('etudiant.profil')->with($array); }
public function run() { DB::table('promotions')->delete(); Promotion::create(['nom' => 'SI3']); Promotion::create(['nom' => 'SI4']); Promotion::create(['nom' => 'SI5']); Promotion::create(['nom' => 'MAM3']); Promotion::create(['nom' => 'MAM4']); Promotion::create(['nom' => 'MAM5']); Promotion::create(['nom' => 'BAT3']); Promotion::create(['nom' => 'BAT4']); Promotion::create(['nom' => 'BAT5']); Promotion::create(['nom' => 'ELEC3']); Promotion::create(['nom' => 'ELEC4']); Promotion::create(['nom' => 'ELEC5']); Promotion::create(['nom' => 'GE3']); Promotion::create(['nom' => 'GE4']); Promotion::create(['nom' => 'GE5']); Promotion::create(['nom' => 'GB3']); Promotion::create(['nom' => 'GB4']); Promotion::create(['nom' => 'GB5']); Promotion::create(['nom' => 'CIP1']); Promotion::create(['nom' => 'CIP2']); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $promotion = Promotion::findOrFail($id); $promotion->delete(); return redirect('promotion'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(OffreStageRequest $request, $id, CompetenceRepository $competence) { $offre = OffreStage::find($id); $offre->user_id = Auth::user()->id; $offre->title = Input::get('title'); $offre->promotion_id = Promotion::find(Input::get('promotion'))->id; $offre->specialite_id = Input::get('specialite'); //TODO parse date peut etre en faire un service? $date = Input::get('date_debut'); $offre->date_debut = date('Y-m-d', strtotime($date)); $offre->duree = Input::get('duree'); $offre->description = Input::get('description'); $offre->nom_contact = Input::get('nom_contact'); $offre->email = Input::get('email'); $offre->tel = Input::get('tel'); $offre->horaire = Input::get('horaire'); $offre->adresse_stage = Input::get('adresse_stage'); $offre->gratification = Input::get('gratification'); $offre->save(); $competence->saveMultipe(Input::get('competence'), $offre); return $offre; }
public static function getGift($id, $supplier = '1') { $type_promo = Promotion::whereRaw("cid_product={$id} AND status='0'")->orderBy("type_promo", "ASC")->first(); $data_product = array(); if (!empty($type_promo->type_promo)) { if ($type_promo->type_promo == '2') { $sql_online = "\n SELECT \n\n\t\t\t\t\td.name,d.description,d.id AS idpromotion\n\t\t\t\t\tFROM ( \n\t\t\t\t\t\t\t pro_product AS a INNER JOIN pro_supplier_product AS s ON a.id=s.cid_product \n\t\t\t\t\t\t\t\tINNER JOIN pro_promotion_product as c ON c.cid_product=s.id )\n\t\t\t\t\t\t\t\tINNER JOIN promo_online as d ON d.id=c.cid_promotion\n\t\t\t\t\tWHERE a.is_status_series='1' AND a.is_status_cate='1' AND a.status='1'\n\t\t\t\t\tAND d.active='1' AND c.type_promo='2'\n\t\t\t\t\tAND s.id={$id} AND s.cid_supplier={$supplier}\n "; $v = DB::select($sql_online); if (!empty($v[0])) { $data_product['online'] = $v; } } elseif ($type_promo->type_promo == '3') { $sql_press = "\n SELECT \n\n\t\t\t\t\td.name,d.description,d.id AS idpromotion\n\t\t\t\t\t\n\t\t\t\t\tFROM ( \n\t\t\t\t\t\t\t pro_product AS a \n\t\t\t\t\t\t\t INNER JOIN pro_supplier_product AS s ON a.id=s.cid_product \n\t\t\t\t\t\t\t INNER JOIN pro_promotion_product as c ON c.cid_product=s.id \n\t\t\t\t\t\t\t INNER JOIN promo_press as d ON d.id=c.cid_promotion\n\t\t\t\t\t\t)\n\t\t\t\t\tWHERE a.is_status_series='1' AND a.is_status_cate='1' AND a.status='1'\n\t\t\t\t\tAND d.active='1' AND c.type_promo='3'\n\t\t\t\t\tAND s.id={$id} AND s.cid_supplier={$supplier}\n "; $v = DB::select($sql_press); if (!empty($v[0])) { $data_product['press'] = $v; } } elseif ($type_promo->type_promo == '4' || $type_promo->type_promo == '1') { $sql = "\n\t\t\t\t\tSELECT \n\n\t\t\t\t\td.name,d.description,d.id AS idpromotion\n\t\t\t\t\tFROM ( \n\t\t\t\t\t\t\t pro_product AS a INNER JOIN pro_supplier_product AS s ON a.id=s.cid_product \n\t\t\t\t\t\t\t\tINNER JOIN pro_promotion_product as c ON c.cid_product=s.id )\n\t\t\t\t\t\t\t\tINNER JOIN promo_text as d ON d.id=c.cid_promotion\n\t\t\t\t\tWHERE a.is_status_series='1' AND a.is_status_cate='1' AND a.status='1'\n\t\t\t\t\tAND d.active='1' AND c.type_promo='4'\n\t\t\t\t\tAND s.id={$id} AND s.cid_supplier={$supplier}\n\t\t\t\t"; $v = DB::select($sql); if (!empty($v[0])) { $data_product['text'] = $v; } } } $sql_gift = "\n\t\t\tSELECT \n\t\t\ta.isprice,a.status,\n\t\t\tc.cid_product,c.cid_gift,c.cid_supplier,\n\t\t\td.id,d.name,d.amount\n\t\t\t\n\t\t\tFROM ( pro_product AS a\n\t\t\t\t INNER JOIN pro_supplier_product AS b ON a.id=b.cid_product\n\t\t\t\t INNER JOIN pro_gift_product as c ON c.cid_product=a.id )\n\t\t\tINNER JOIN pro_gift as d ON d.id=c.cid_gift\n\t\t\tWHERE a.is_status_series='1' AND a.is_status_cate='1' AND a.status='1'\n\t\t\tAND b.id={$id} AND c.cid_supplier={$supplier}\n\t\t\tGROUP BY d.id\n\t\t"; $v = DB::select($sql_gift); if (!empty($v[0])) { $data_product['gift'] = $v; } if (count($data_product) > 0) { return $data_product; } else { return null; } }
public function getdatetime($id, $supplier) { $result = array(); $a = Promotion::getProduct_Price($id, $supplier); if (!empty($a)) { $result = (array) $a[0]; $result['date_end'] = date("F j, Y H:i:s", strtotime($result['date_end'])); } return Response::json($result); }
public function postNewPromotion(Request $request) { $this->validate($request, ['name' => 'required|max:50', 'discount' => 'required|numeric|min:1|max:100', 'type' => 'required|numeric|min:1|max:100', 'image' => 'image', 'promo_date' => 'max:23']); //create a new promotion $promotion = Promotion::create(['name' => $request->name, 'discount' => $request->discount, 'type' => $request->type, 'description' => $request->description]); //process dates if (!empty($request->promo_date)) { $dates = explode(" - ", $request->promo_date); $promotion->start_date = DateTime::createFromFormat('m/d/Y', $dates[0])->format('Y-m-d'); $promotion->end_date = DateTime::createFromFormat('m/d/Y', $dates[1])->format('Y-m-d'); //check if promotion is activated on create if ($dates[0] <= new DateTime("now") && $dates[1] > new DateTime("now")) { $promotion_status = 1; } else { $promotion_status = 0; } } if (Input::hasFile('image')) { $file = Input::file('image'); $imagename = 'promotion_' . $promotion->id . '.' . Input::file('image')->getClientOriginalExtension(); $file->move('uploads', $imagename); $promotion->image = $imagename; } $promotion->save(); //attach promotion to selected items $cruises = Input::get('cruises'); $cabins = Input::get('cabins'); $amenities = Input::get('amenities'); if (!empty($cruises)) { foreach ($cruises as $key => $val) { $cruise = Cruise::find($val); $cruise->promotion_id = $promotion->id; $cruise->save(); } } else { if (!empty($cabins)) { foreach ($cabins as $key => $val) { $cabin = Cabin::find($val); $cabin->promotion_id = $promotion->id; $cabin->save(); } } else { if (!empty($amenities)) { foreach ($amenities as $key => $val) { $amenity = Amenity::find($val); $amenity->promotion_id = $promotion->id; $amenity->save(); } } } } return redirect('/admin/promotion/' . $promotion->id)->with('status', 'Promotion created!'); }
public static function createPromotionTable($session, $term_id) { try { //create new record for this table in the termly records table $promotion = new Promotion(); $promotion->table_name = 'promotions_' . $session . '_' . $term_id; $promotion->session = $session; $promotion->term = $term_id; $promotion->save(); \Schema::create('promotions_' . $session . '_' . $term_id, function (Blueprint $table) { $table->increments('id'); $table->integer('student_id'); $table->integer('class_id'); $table->integer('average_score'); $table->softDeletes(); $table->timestamps(); }); } catch (\Illuminate\Database\QueryException $e) { $errorCode = $e->errorInfo[1]; if ($errorCode == 1050) { $error_msg[] = 'Promotion table for chosen session and term already exists.'; // session()->flash('flash_message', 'Invoices table for chosen session and term already exists.'); // return \Redirect::back()->withInput(); } } }
public function promotion($limit) { $a = Promotion::List_All_Promotion($limit); return Response::json($a); }
public function four() { if (!Session::has("orderdmcl") && !Session::has("ordercustomer")) { return '1'; } $filter = new MrValidateData(); $number_order = $filter->dateToNumber(date("d-m-Y H:i:s")) . $filter->randd(8); $data_payment = Session::get("orderdmcl"); $data_customer = Session::get("ordercustomer"); $salettotal = 0; $total = 0; $array_supplier = array(); foreach ($data_payment as $key => $value) { if (!array_key_exists($value['product']['cid_supplier'], $array_supplier)) { $array_supplier[$value['product']['cid_supplier']] = $value['product']['cid_supplier']; } $salettotal = $value['product']['saleprice'] * $value['order']['limit'] + $salettotal; if (!empty($value['coupon'])) { $total = $value['product']['discount'] * $value['order']['limit'] - $value['coupon'] + $total; } else { $total = $value['product']['discount'] * $value['order']['limit'] + $total; } } foreach ($array_supplier as $idnhacungcap) { //OR ORDER $news_order = new Ororder(); $news_order->code_order = $number_order; if (Auth::check()) { $news_order->id_cus = Auth::user()->id; } $news_order->pay_type = $data_customer['pay'] == '2' ? "Thanh toán tại siêu thị" : "Thanh toán tại nhà"; $news_order->total_or = $total; //tong gia ban kèm số lượng $news_order->date_bill = date("Y-m-d H:i:s"); $news_order->date_ship = !empty($data_customer['getdate']) ? date("Y-m-d H:i:s", strtotime($data_customer['getdate'])) : date("Y-m-d H:i:s"); $news_order->order_info = !empty($data_customer['note']) ? $data_customer['note'] : ""; $news_order->approved = '0'; $news_order->dis_price = $salettotal - $total; //tong gia giảm kèm số lượng $news_order->type_payment = $data_customer['pay']; $news_order->cid_bank = 0; $news_order->flag = '1'; $news_order->session = 1; $news_order->code_coupon = ""; $news_order->code_voucher = Session::has("coupon") ? Session::get("coupon") : ""; $news_order->mode = '0'; $news_order->cid_supplier = $idnhacungcap; $news_order->save(); //OR SHIPPING $news_shipping = new Orshipping(); $news_shipping->cid_order = $news_order->id; $news_shipping->fullname = $data_customer['name']; $news_shipping->phone = $data_customer['phone']; $news_shipping->email = $data_customer['email']; $news_shipping->address = $data_customer['address']; $news_shipping->distict = $data_customer['state']; $news_shipping->city = $data_customer['city']; $news_shipping->save(); //OR DETAIL foreach ($data_payment as $key => $value) { if ($idnhacungcap == $value['product']['cid_supplier']) { $Gift = Promotion::getGift($value['product']['cid_res'], $value['product']['cid_supplier']); $getpromotion = Promotion::getDetail($value['product']['cid_res'], $value['product']['cid_supplier']); $news = new Ordetail(); $news->cid_order = $news_order->id; $news->cid_product = $value['product']['myid']; $news->cid_color = $value['order']['color']; $news->cid_promotion = !empty($getpromotion->cid_promotion) ? $getpromotion->cid_promotion : ""; $news->amount = $value['order']['limit']; $news->sale_price = $value['product']['saleprice']; // ko kèm số lưog if (!empty($value['coupon'])) { $news->total = $value['order']['limit'] * $value['product']['discount'] - $value['coupon']; $news->dis_price = $value['coupon']; //khong kèm số lượng } else { $news->total = $value['order']['limit'] * $value['product']['discount']; $news->dis_price = $value['product']['saleprice'] - $value['product']['discount']; //khong kèm số lượng } $news->choose = !empty($getpromotion->type_promo) ? $getpromotion->type_promo : 0; $news->code_coupon = Session::has("coupon") ? Session::get("coupon") : ""; $news->cid_supplier = $value['product']['cid_supplier']; $news->save(); if (!empty($getpromotion->type_promo)) { //print_r($getpromotion->type_promo);exit; //print_r($Gift);exit; if ($getpromotion->type_promo == '2') { $news->cid_gift = '1'; if (!empty($Gift['online']) && is_object($Gift['online'])) { $gift_online = $Gift['online']; $news_gift = new Orgift(); $news_gift->cid_detail = $news->id; $news_gift->cid_gift = $gift_online[0]->idpromotion; $news_gift->type = '0'; $news_gift->save(); } } elseif ($getpromotion->type_promo == '3') { $news->cid_gift = '1'; if (!empty($Gift['press'])) { $gift_press = $Gift['press']; $news_gift = new Orgift(); $news_gift->cid_detail = $news->id; $news_gift->cid_gift = $gift_press[0]->idpromotion; $news_gift->type = '0'; $news_gift->save(); } } elseif ($getpromotion->type_promo == '4' || $getpromotion->type_promo == '1') { $news->cid_gift = '1'; if (!empty($Gift['text'])) { foreach ($Gift['text'] as $gift_text) { $news_gift = new Orgift(); $news_gift->cid_detail = $news->id; $news_gift->cid_gift = $gift_text->idpromotion; $news_gift->type = '0'; $news_gift->save(); } } } } if (!empty($Gift['gift'])) { $news->cid_gift = '1'; for ($i = 0; $i < count($Gift['gift']); $i++) { # code... $news_gift = new Orgift(); $news_gift->cid_detail = $news->id; $news_gift->cid_gift = $Gift['gift'][$i]->cid_gift; $news_gift->type = '1'; $news_gift->save(); } } $news->save(); } } } Session::flush(); return $number_order; }