|
@@ -7,6 +7,7 @@ use App\Models\Bill;
|
|
|
use App\Models\Client;
|
|
|
use App\Models\McpRequest;
|
|
|
use App\Models\Note;
|
|
|
+use App\Models\Pro;
|
|
|
use App\Models\ProGeneralAvailability;
|
|
|
use App\Models\ProRate;
|
|
|
use App\Models\ProSpecificAvailability;
|
|
@@ -140,33 +141,49 @@ class PracticeManagementController extends Controller
|
|
|
return view('app.practice-management.my-text-shortcuts', compact('myTextShortcuts'));
|
|
|
}
|
|
|
|
|
|
- public function myAvailability(Request $request)
|
|
|
+ public function proAvailability(Request $request)
|
|
|
{
|
|
|
$performer = $this->performer();
|
|
|
$pro = $performer->pro;
|
|
|
+
|
|
|
+ if($request->get('pro_uid')){
|
|
|
+ $proUid = $request->get('pro_uid');
|
|
|
+ $pro = Pro::where('uid', $proUid)->first();
|
|
|
+ }
|
|
|
+
|
|
|
+ $pros = Pro::all();
|
|
|
+
|
|
|
$generalAvailabilitiesList = ProGeneralAvailability::where('pro_id', $pro->id)->where('is_cancelled', false)->orderBy('created_at', 'asc')->get();
|
|
|
- $generalAvailabilities = [];
|
|
|
+ $generalAvailabilities = [
|
|
|
+ 'MONDAY'=>[],
|
|
|
+ 'TUESDAY'=>[],
|
|
|
+ 'WEDNESDAY'=>[],
|
|
|
+ 'THURSDAY'=>[],
|
|
|
+ 'FRIDAY'=>[],
|
|
|
+ 'SATURDAY'=>[],
|
|
|
+ 'SUNDAY'=>[],
|
|
|
+ ];
|
|
|
foreach($generalAvailabilitiesList as $ga){
|
|
|
if($ga->day_of_week == 'MONDAY'){
|
|
|
- $generalAvailabilities['MONDAY'] = $ga;
|
|
|
+ $generalAvailabilities['MONDAY'][] = $ga;
|
|
|
}
|
|
|
if($ga->day_of_week == 'TUESDAY'){
|
|
|
- $generalAvailabilities['TUESDAY'] = $ga;
|
|
|
+ $generalAvailabilities['TUESDAY'][] = $ga;
|
|
|
}
|
|
|
if($ga->day_of_week == 'WEDNESDAY'){
|
|
|
- $generalAvailabilities['WEDNESDAY'] = $ga;
|
|
|
+ $generalAvailabilities['WEDNESDAY'][] = $ga;
|
|
|
}
|
|
|
if($ga->day_of_week == 'THURSDAY'){
|
|
|
- $generalAvailabilities['THURSDAY'] = $ga;
|
|
|
+ $generalAvailabilities['THURSDAY'][] = $ga;
|
|
|
}
|
|
|
if($ga->day_of_week == 'FRIDAY'){
|
|
|
- $generalAvailabilities['FRIDAY'] = $ga;
|
|
|
+ $generalAvailabilities['FRIDAY'][] = $ga;
|
|
|
}
|
|
|
if($ga->day_of_week == 'SATURDAY'){
|
|
|
- $generalAvailabilities['SATURDAY'] = $ga;
|
|
|
+ $generalAvailabilities['SATURDAY'][] = $ga;
|
|
|
}
|
|
|
if($ga->day_of_week == 'SUNDAY'){
|
|
|
- $generalAvailabilities['SUNDAY'] = $ga;
|
|
|
+ $generalAvailabilities['SUNDAY'][] = $ga;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -174,65 +191,32 @@ class PracticeManagementController extends Controller
|
|
|
$specificUnavailabilities = ProSpecificUnavailability::where('pro_id', $pro->id)->where('is_cancelled', false)->orderBy('start_time', 'asc')->get();
|
|
|
|
|
|
//events for the calendar
|
|
|
- $eventsData = [];
|
|
|
- $dayInts = [
|
|
|
- 'SUNDAY'=> 1,
|
|
|
- 'MONDAY'=> 2,
|
|
|
- 'TUESDAY'=> 3,
|
|
|
- 'WEDNESDAY'=> 4,
|
|
|
- 'THURSDAY'=> 5,
|
|
|
- 'FRIDAY'=> 6,
|
|
|
- 'SATURDAY'=> 7,
|
|
|
- ];
|
|
|
-
|
|
|
- foreach($specificUnavailabilities as $sa){
|
|
|
- $realTimezone = resolve_timezone($sa->timezone);
|
|
|
-
|
|
|
- $startTime = new DateTime($sa->start_time);
|
|
|
- $startTime->setTimezone(new DateTimeZone($realTimezone));
|
|
|
-
|
|
|
- $endTime = new DateTime($sa->end_time);
|
|
|
- $endTime->setTimezone(new DateTimeZone($realTimezone));
|
|
|
-
|
|
|
- $eventsData[] = [
|
|
|
- 'title' => $sa->title,
|
|
|
- 'start' => $startTime->format(DateTime::ISO8601),
|
|
|
- 'end' => $endTime->format(DateTime::ISO8601),
|
|
|
- 'backgroundColor' => 'red'
|
|
|
- ];
|
|
|
-
|
|
|
- }
|
|
|
+ $startDate = date('Y-m-d', strtotime("sunday -1 week"));
|
|
|
+ $endDateTime = new DateTime($startDate);
|
|
|
+ $endDateTime->modify('+6 day');
|
|
|
+ $endDate = $endDateTime->format("Y-m-d");
|
|
|
|
|
|
- foreach($specificAvailabilities as $su){
|
|
|
-
|
|
|
- $realTimezone = resolve_timezone($su->timezone);
|
|
|
-
|
|
|
- $startTime = new DateTime($su->start_time);
|
|
|
- $startTime->setTimezone(new DateTimeZone($realTimezone));
|
|
|
+ $eventsData = $pro->getAvailabilityEvents($startDate, $endDate);
|
|
|
+ $events = json_encode($eventsData);
|
|
|
|
|
|
- $endTime = new DateTime($su->end_time);
|
|
|
- $endTime->setTimezone(new DateTimeZone($realTimezone));
|
|
|
+ return view('app.practice-management.pro-availability', compact('pros','generalAvailabilities', 'specificAvailabilities', 'specificUnavailabilities','events'));
|
|
|
+ }
|
|
|
|
|
|
- $eventsData[] = [
|
|
|
- 'title' => $su->title,
|
|
|
- 'start' => $startTime->format(DateTime::ISO8601),
|
|
|
- 'end' => $endTime->format(DateTime::ISO8601),
|
|
|
- ];
|
|
|
- }
|
|
|
+ public function loadAvailability(Request $request){
|
|
|
+ $performer = $this->performer();
|
|
|
+ $pro = $performer->pro;
|
|
|
+ $startDate = $request->get('start');
|
|
|
+ $endDate = $request->get('end');
|
|
|
|
|
|
- foreach($generalAvailabilities as $day => $ga){
|
|
|
- $eventsData[] = [
|
|
|
- 'title' => 'General Availability',
|
|
|
- 'daysOfWeek' => [$dayInts[$day]],
|
|
|
- 'startTime' => $ga->start_time,
|
|
|
- 'endTime' => $ga->end_time,
|
|
|
- ];
|
|
|
+ if($request->get('pro_uid')){
|
|
|
+ $proUid = $request->get('pro_uid');
|
|
|
+ $pro = Pro::where('uid', $proUid)->first();
|
|
|
}
|
|
|
|
|
|
- $events = json_encode($eventsData);
|
|
|
-
|
|
|
-
|
|
|
- return view('app.practice-management.my-availability', compact('generalAvailabilities', 'specificAvailabilities', 'specificUnavailabilities','events'));
|
|
|
+ $eventsData = $pro->getAvailabilityEvents($startDate, $endDate);
|
|
|
+ //$events = json_encode($eventsData);
|
|
|
+
|
|
|
+ return $eventsData;
|
|
|
}
|
|
|
|
|
|
// video call page (RHS)
|