示例#1
0
 public function getTimeSlot($service_id)
 {
     Activity::log(['contentId' => $service_id, 'contentType' => 'Outlet', 'action' => 'getTimeSlot', 'description' => 'getTimeSlot of Service', 'details' => 'Service Id: ' . $service_id, 'updated' => false]);
     $service = Service::find($service_id);
     $outlet = Outlet::find($service->outlet_id);
     $startTime = explode(':', $outlet->startTime);
     $endTime = explode(':', $outlet->endTime);
     if (count($startTime) < 2 || count($endTime) < 2) {
         return array();
     }
     $start = mktime($startTime[0], $startTime[1], 0, 8, 12, 2014);
     $end = mktime($endTime[0], $endTime[1], 0, 8, 12, 2014);
     $hourArray = array();
     $count = 1;
     $hourArray[] = $start;
     while ($start < $end && $count < 1000) {
         $date = $start + $service->time_operate * 60;
         $hourArray[] = $date;
         $start = $date;
         $count++;
     }
     return $hourArray;
 }
示例#2
0
 public function postBook()
 {
     $response = null;
     $Bill = null;
     $spa_id = Input::get('spaName');
     $outlet_id = Input::get('spaLocation');
     $service_id = Input::get('serviceName');
     $apptDate = Input::get('apptDate');
     $apptTime = Input::get('timeSlot');
     if (!empty($spa_id) && !empty($outlet_id) && !empty($service_id) && !empty($apptDate)) {
         $apptDateTime = strtotime($apptDate . " " . $apptTime);
         $service = Service::find($service_id);
         $response = array("retailerName" => Retailer::find($spa_id)->name, "outletName" => Outlet::find($outlet_id)->name, "serviceName" => $service->name . " (" . $service->time_operate . " mins)", "apptDateTime" => $apptDateTime, "price" => $service->price);
         if (!Auth::user()) {
             return View::make('site/user/book', compact('response', 'Bill'));
         }
         $deal = Deal::where('service_id', '=', $service_id)->where('deal_type', '=', 'Service')->first();
         if ($deal == null) {
             $deal = new Deal();
             $deal->service_id = $service_id;
             $deal->deal_type = 'Service';
             $deal->title = $service->name;
             $deal->amount = $service->price;
             $deal->discount = 0;
             $deal->special_request = "";
             $deal->status = "active";
             $deal->save();
         }
         $Bill = new DealTransaction();
         $Bill->deal_id = $deal->id;
         $Bill->consumer_id = Auth::user()->id;
         $Bill->consumer_email = Auth::user()->email;
         $Bill->qty = 1;
         $Bill->amount = $service->price;
         $Bill->total = $service->price;
         $Bill->save();
         return View::make('site/user/book', compact('response', 'Bill'));
     }
     return Redirect::to('/');
 }