Exemple #1
4
 /**
  * 解释评价信息
  *
  * @return  Response
  */
 public function postExplain()
 {
     $commentID = base64_decode(Input::get('comment_id'));
     $shopID = base64_decode(Input::get('shop_id'));
     $mainOrderID = base64_decode(Input::get('main_order_id'));
     $explain = Input::get('explain');
     $rate = Rate::where('wy_comment_id', $commentID)->where('wy_shop_id', $shopID)->where('wy_main_order_id', $mainOrderID)->first();
 }
 public function rateUpdate()
 {
     $rate;
     $id = Input::get("id");
     $title = Input::get("title");
     $content = Input::get("content");
     $top_content1 = Input::get("top_content1");
     $top_content2 = Input::get("top_content2");
     $top_content3 = Input::get("top_content3");
     $update_day = Input::get("update_day");
     $insert_array = array("title" => $title, "update_day" => $update_day, "image" => Input::file('image'), "content" => $content);
     $rules = ['title' => 'required', 'content' => 'required'];
     $validator = Validator::make($insert_array, $rules);
     if ($validator->fails()) {
         return Redirect::to('/rate/' . $id)->withErrors($validator);
     } else {
         if (Input::hasFile('image')) {
             $file = Input::file('image');
             //  print_r($file);
             //  echo $file->getSize();
             $size = $file->getSize();
             $file_max = 2048;
             $size = $size / 1024;
             if ($size > $file_max) {
                 return "檔案上傳限制只有2MB." . '<button onclick="goBack()">回到上一頁</button>' . "<script>\nfunction goBack() {\nwindow.history.back();\n}\n</script>";
             }
             $destinationPath = public_path() . '/img';
             $filename = str_random(6) . '_' . $file->getClientOriginalName();
             $uploadSuccess = $file->move($destinationPath, $filename);
             $rate = Rate::where('id', $id)->update(array('title' => $title, 'image' => '/img/' . $filename, "update_day" => $update_day, "top_content1" => $top_content1, "top_content2" => $top_content2, "top_content3" => $top_content3, 'content' => $content));
         } else {
             $rate = Rate::where('id', $id)->update(array('title' => $title, "update_day" => $update_day, "top_content1" => $top_content1, "top_content2" => $top_content2, "top_content3" => $top_content3, 'content' => $content));
         }
         return Redirect::to('rates')->withInput()->with('success', '更新成功');
     }
 }
 public function getRate($slug = '')
 {
     $type = Type::where('type', 'rate')->first();
     $posts = Post::where('type_id', '=', $type->id)->where('status', 1)->where('parent', '=', '0')->orderBy('created_at', 'desc')->get();
     $posts_child = Post::where('type_id', '=', $type->id)->where('status', 1)->where('parent', '!=', '0')->orderBy('created_at', 'desc')->get();
     if (!empty($slug)) {
         $row = Post::where('slug', $slug)->first();
         $posts_child = Post::where('type_id', '=', $type->id)->where('parent', $row->id)->where('status', 1)->orderBy('created_at', 'desc')->get();
         $blade = 'home.page-menu-title';
     } else {
         $tv = Rate::where('type', 'tv')->where('status', 1)->orderBy('position', 'asc')->get();
         $inet = Rate::where('type', 'inet')->first();
         $inetOption = Rate::where('type', 'inetOption')->where('status', 1)->orderBy('position', 'asc')->get();
         $row = array('inet' => json_decode($inet->description), 'inetOption' => $inetOption, 'tv' => $tv);
         $blade = 'home.page-rate';
     }
     $view = array('posts' => $posts, 'posts_child' => $posts_child, 'type' => $type, 'row' => $row);
     return View::make($blade, $view);
 }
Exemple #4
0
 public static function lowestRoomRate($hotel_id, $room_type_id, $specification_id, $meal_basis_id, $st_date, $ed_date)
 {
     if (Session::has('adult_child')) {
         $adult = Session::get('adult');
         $child = Session::get('child');
     } else {
         $adult = Session::get('adult');
         $child = Session::get('child');
     }
     $x = 0;
     $room_rates = 0;
     $room_rate = 0;
     if (Session::has('market')) {
         $market = Session::get('market');
     } else {
         $market = 1;
     }
     $get_market_details = Market::where('id', $market)->first();
     $tax_type = $get_market_details->tax_type;
     $tax = $get_market_details->tax + 100;
     $handling_fee_type = $get_market_details->handling_fee_type;
     $handling_fee = $get_market_details->handling_fee;
     $from_date = date('Y-m-d', strtotime(str_replace('-', '/', $st_date)));
     $to_date = date('Y-m-d', strtotime(str_replace('-', '/', $ed_date)));
     $dates = (strtotime($ed_date) - strtotime($st_date)) / 86400;
     // dd($hotel_id .'/'. $room_type_id .'/'. $specification_id .'/'. $meal_basis_id .'/'. $st_date .'/'. $ed_date);
     for ($x = 1; $x <= $dates; $x++) {
         $get_room_rate = Rate::where('hotel_id', '=', $hotel_id)->where('room_type_id', $room_type_id)->where('room_specification_id', $specification_id)->where('meal_basis_id', $meal_basis_id)->where('from', '<=', $from_date)->where('to', '>', $from_date)->where('market_id', $market)->get();
         foreach ($get_room_rate as $low_rates) {
             $room_rate = $low_rates->rate;
         }
         $from_date = date('Y-m-d', strtotime($from_date . ' + 1 days'));
         $room_rates = $room_rates + $room_rate;
     }
     $lowest_room_rate = number_format($room_rates / $dates, 2);
     return $lowest_room_rate;
 }
Exemple #5
0
    Route::post('/mailcontentsUpdate', "MailcontentController@update");
    //CategoryController
    Route::get('/delCategory/{id}', "CategoryController@delCategory");
    Route::get('/categories', "CategoryController@index");
    Route::get('/categories/create', "CategoryController@create");
    Route::get('/category/{id}', "CategoryController@edit");
    Route::post('/categoryStore', "CategoryController@categoryStore");
    Route::post('/categoryUpdate', "CategoryController@categoryUpdate");
    Route::get('/delCate', function () {
        $id = Input::get("id");
        Cate::find($id)->delete();
    });
});
Route::post('/delRateImage', function () {
    // print_r(Input::get() );
    $rate = Rate::where("id", Input::get("id"))->update(array("image" => ''));
    if (Input::get("id") > 0) {
        return 1;
    } else {
        return 0;
    }
    // return View::make("frontend.hotcase");
});
// App::missing(function($exception)
// {
//
// 		Log::info('This is some useful information.');
//
// 		Log::warning('Something could be going wrong.');
//
// 		Log::error('Something is really going wrong.');
 public function updateSupplementRates($hotelid)
 {
     $validator = Validator::make($data = Input::all(), SupplementRate::$rules);
     if ($validator->fails()) {
         return Response::json(array("errors" => $validator->errors()));
     }
     $rates = Input::get('rates');
     $keys = Input::get('keys');
     $market = Input::get('market_id');
     $inserted_ids = array();
     $rates = explode(',', $rates);
     $keys = explode(',', $keys);
     $data = array();
     $deleted_items = false;
     $i = -1;
     foreach ($rates as $rate) {
         $i++;
         $ids = explode("-", $keys[$i]);
         $data = array('from' => Input::get("from"), 'to' => Input::get("to"), 'supplement_name' => Input::get("supplement_name"), 'rate' => $rate, 'hotel_id' => $hotelid, 'meal_basis_id' => $ids[0], 'room_specification_id' => $ids[1], 'room_type_id' => Input::get("room_type_id"), 'user_id' => Auth::user()->id, 'val' => 1, 'market_id' => $market);
         $from = $data["from"];
         $to = $data["to"];
         $conditions = array('meal_basis_id' => $ids[0], 'room_specification_id' => $ids[1], 'room_type_id' => Input::get("room_type_id"), 'market_id' => $market);
         $newperiods = array();
         $newperiods[] = array('from' => $from, 'to' => $to, 'rate' => $rate);
         $from_date = new DateTime($from);
         $to_date = new DateTime($to);
         $from_date->sub(new DateInterval('P1D'));
         $to_date->add(new DateInterval('P1D'));
         /*
          * <------------|------------------|--------------|-------------------|----------------->
          *              a         <        x      <       y         <         b
          */
         $existing = SupplementRate::where($conditions)->where('from', '<', $from)->where('to', '>', $to)->first();
         if (!empty($existing->id)) {
             $newperiods = array(array("from" => $existing["from"], "to" => $from_date->format('Y-m-d'), "rate" => $existing->rate), array("from" => $from, "to" => $to, "rate" => $rate), array("from" => $to_date->format('Y-m-d'), "to" => $existing->to, "rate" => $existing->rate));
             $this->insertRates($newperiods, $data);
             SupplementRate::where("id", $existing->id)->delete();
         } else {
             /*
              * <------------|------------------|--------------|-------------------|----------------->
              *              x         <        a      <       b         <         y
              */
             $existing1 = SupplementRate::where($conditions)->where('from', '>=', $from)->where('to', '<=', $to)->get();
             if ($existing1->count()) {
                 $conflicting_ids = array();
                 foreach ($existing1 as $conflict) {
                     $conflicting_ids[] = $conflict->id;
                 }
                 SupplementRate::whereIn('id', $conflicting_ids)->delete();
                 $newperiods = array(array('from' => $from, 'to' => $to, 'rate' => $rate));
                 $this->insertRates($newperiods, $data);
             }
             /*
              * <------------|------------------|--------------|-------------------|----------------->
              *              a         <        x      <       b         <         y
              */
             $existing_condition_1 = SupplementRate::where($conditions)->where('from', '<=', $from)->where('to', '>=', $from)->where('to', '<', $to)->first();
             if (!empty($existing_condition_1->id)) {
                 SupplementRate::where('id', $existing_condition_1->id)->delete();
                 $newperiods = array(array('from' => $existing_condition_1->from, 'to' => $from_date->format('Y-m-d'), 'rate' => $existing_condition_1->rate), array('from' => $from, 'to' => $to, 'rate' => $rate));
                 $this->insertRates($newperiods, $data);
             }
             /*
              * <------------|------------------|--------------|-------------------|----------------->
              *              x         <        a      <       y         <         b
              */
             $existing_condition_2 = SupplementRate::where($conditions)->where('from', '>=', $from)->where('from', '<=', $to)->where('to', '>', $to)->first();
             if (!empty($existing_condition_2->id)) {
                 SupplementRate::where('id', $existing_condition_2->id)->delete();
                 $newperiods = array(array('from' => $from, 'to' => $to, 'rate' => $rate), array('from' => $to_date->format('Y-m-d'), 'to' => $existing_condition_2->to, 'rate' => $existing_condition_2->rate));
                 $this->insertRates($newperiods, $data);
             } else {
                 if (!$deleted_items) {
                     Rate::where(array('from' => Input::get('old_from'), 'to' => Input::get('old_to'), 'room_type_id' => Input::get('room_type_id'), 'market_id' => Input::get('market_id')))->delete();
                     $deleted_items = true;
                 }
                 $this->insertRates($newperiods, $data);
             }
         }
     }
     return Response::json('/control-panel/hotel/hotels/' . $hotelid . '/supplement-rates');
 }
 public function checkRatePas()
 {
     $data = Input::all();
     $rate_id = $data['rate_id'];
     $rate = Rate::where("id", $rate_id)->first();
     if ($rate->secret == $data['val']) {
         // Cookie::make('key', 'yes', 3600);
         // Cookie::make('key', 'yes', 3600);
         Session::put('key' . $rate_id, 'yes');
         echo 'yes';
     } else {
         echo 'no';
     }
 }