public function destroy(BusinessHour $business_hour)
 {
     if (!Helper::getMode()) {
         return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE'));
     }
     $business_hour->delete();
     return redirect('/configuration#business_hour')->withSuccess(config('constants.DELETED'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(BusinessRegRequest $request)
 {
     // dd($request->input('sub'));
     $biz = new Biz();
     $biz->name = $request->input('name');
     $biz->contactname = $request->input('contactname');
     $biz->email = $request->input('email');
     $biz->website = $request->input('website');
     $biz->phone1 = $request->input('phone1');
     $biz->phone2 = $request->input('phone2');
     $biz->user_id = \Auth::id();
     $biz->save();
     $add = new Address();
     $add->street = $request->input('address');
     $add->lga_id = $request->input('lga');
     $add->state_id = $request->input('state');
     $add->biz_id = $biz->id;
     $add->save();
     $category = $request->input('cats');
     $biz->cats()->sync($category);
     $subs = $request->input('sub');
     $biz->subcats()->sync($subs);
     $mon = BusinessHour::create(['day' => 'MON', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
     $tue = BusinessHour::create(['day' => 'TUE', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
     $wed = BusinessHour::create(['day' => 'WED', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
     $thu = BusinessHour::create(['day' => 'THU', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
     $fri = BusinessHour::create(['day' => 'FRI', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
     $sat = BusinessHour::create(['day' => 'SAT', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
     $sun = BusinessHour::create(['day' => 'SUN', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
     return redirect('/admin/biz')->withSuccess("The business '{$biz->name}' has been created.");
 }
示例#3
0
 public function showBusinessHour()
 {
     if (!config('config.show_business_hour')) {
         return redirect('/');
     }
     $business_hours = \App\BusinessHour::all();
     $service_times = \App\ServiceTime::all();
     $assets = ['hide_sidebar'];
     return view('page.business_hour', compact('assets', 'business_hours', 'service_times'));
 }
示例#4
0
 public function index()
 {
     $ticket_types = TicketType::all();
     $departments = Department::all();
     $business_hours = BusinessHour::all();
     $service_times = ServiceTime::all();
     $languages = Helper::getAllLanguages();
     $config = Helper::getConfiguration();
     $mail_config = Helper::getMail();
     $services = Helper::getServices();
     $next_ticket_no = \App\Ticket::max('ticket_no');
     $next_ticket_no = isset($next_ticket_no) ? $next_ticket_no + 1 : 1;
     $assets = ['datetimepicker', 'mail_config'];
     $week_days = config('list.week');
     $time_unit = config('list.time_unit');
     $priority = config('list.priority');
     $time_type = config('list.time_type');
     $roles = DB::table('roles')->get();
     $permissions = DB::table('permissions')->orderBy('category')->get();
     $permission_role = DB::table('permission_role')->select(DB::raw('CONCAT(role_id,"-",permission_id) AS detail,id'))->lists('detail', 'id');
     $data = ['languages' => $languages, 'config' => $config, 'mail_config' => $mail_config, 'services' => $services, 'roles' => $roles, 'permissions' => $permissions, 'permission_role' => $permission_role, 'assets' => $assets, 'ticket_types' => $ticket_types, 'departments' => $departments, 'week_days' => $week_days, 'business_hours' => $business_hours, 'service_times' => $service_times, 'time_unit' => $time_unit, 'priority' => $priority, 'time_type' => $time_type, 'next_ticket_no' => $next_ticket_no, 'category' => null];
     return view('configuration.index', $data);
 }
示例#5
0
 public static function calculateDueTime($time, $created_at)
 {
     $days = config('list.week');
     foreach ($days as $d) {
         $business_hour[$d]['start'] = config('config.default_working_start_time');
         $business_hour[$d]['end'] = config('config.default_working_end_time');
     }
     $business_hours = \App\BusinessHour::all();
     foreach ($business_hours as $hour) {
         $business_hour[$hour->day]['start'] = $hour->start;
         $business_hour[$hour->day]['end'] = $hour->end;
     }
     $holidays = \App\Holiday::where('date', '>=', date('Y-m-d', strtotime($created_at)))->lists('date')->all();
     while ($time > 0) {
         $date = isset($date) ? date('Y-m-d', strtotime($date . ' +1 day')) : $created_at;
         $day = date('l', strtotime($date));
         $end = date('Y-m-d', strtotime($date)) . ' ' . $business_hour[$day]['end'];
         $start = !isset($start) ? $date : date('Y-m-d', strtotime($date)) . ' ' . $business_hour[$day]['start'];
         if (in_array(date('Y-m-d', strtotime($date)), $holidays)) {
             continue;
         }
         $diff = round((strtotime($end) - strtotime($start)) / 60);
         if ($diff < 0) {
             $diff = 0;
         }
         if ($time <= $diff) {
             return date('Y-m-d, H:i', strtotime($start) + $time * 60);
         } else {
             $time -= $diff;
         }
     }
 }
 public function closed()
 {
     $bh_id = \Input::get('id');
     $newValue = \Input::get('data');
     $bh = \App\BusinessHour::whereId($bh_id)->first();
     $bh->close_time = $newValue;
     if ($bh->save()) {
         return \Response::json(array('status' => 1));
     } else {
         return \Response::json(array('status' => 'error', 'msg' => 'could not be updated'));
     }
 }