Skip to content

Commit

Permalink
[Add] visited at column on follow and all appointment blade.php
Browse files Browse the repository at this point in the history
  • Loading branch information
menoc61 committed May 9, 2024
1 parent 36a7a37 commit 3cd2d22
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 93 deletions.
36 changes: 14 additions & 22 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,47 @@

namespace App\Helpers;

use Illuminate\Support\Facades\Auth;
use App\User;
use App\Setting;
use Carbon\Carbon;
use Illuminate\Support\Facades\File;

if(!function_exists('get_option')){

function get_option( $option_name, $option_value = null ) {

if (!function_exists('get_option')) {
function get_option($option_name, $option_value = null)
{
$return = Setting::where('option_name', $option_name)->pluck('option_value')->first();

if( !$return )
if (!$return) {
return $option_value;
}

return $return;

}
}

if(!function_exists('update_option')){

function update_option($option_name, $option_value ) {
if (!function_exists('update_option')) {
function update_option($option_name, $option_value)
{
// update if already exists - create if it doesn't
$option = Setting::firstOrCreate(['option_name' => $option_name]);
$option->option_value = $option_value;
$option->save();

return $option;

}
}

if(!function_exists('get_visitor_status')){
function get_visitor_status( $type) {

if (!function_exists('get_visitor_status')) {
function get_visitor_status($type)
{
$types = ['1' => __('Sentence.Pending'), '2' => __('Sentence.Ongoing'), '3' => __('Sentence.Archived')];

return $types[$type];

}
}

if(!function_exists('yes_or_no')){
function yes_or_no( $value) {

if (!function_exists('yes_or_no')) {
function yes_or_no($value)
{
$types = ['1' => __('Sentence.Yes'), '0' => __('Sentence.No')];

return $types[$value];

}
}
49 changes: 22 additions & 27 deletions app/Http/Controllers/AppointmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DateTime;
use App\User;
use App\Patient;
use App\Appointment;
use App\Setting;
use Redirect;
use Nexmo;
use Auth;
use App\Notifications\WhatsAppNotification;
use App\Notifications\NewAppointmentByEmailNotification;
use App\Notifications\WhatsAppNotification;
use App\Setting;
use App\User;
use Illuminate\Http\Request;

class AppointmentController extends Controller
{
Expand Down Expand Up @@ -41,7 +36,7 @@ public function create_By_id($id)

return view('appointment.create_By_user', [
'userName' => $user->name,
'praticiens' => $praticiens
'praticiens' => $praticiens,
])->with('userId', $id);
}

Expand All @@ -63,8 +58,8 @@ public function available_slot($date, $start, $end)
public function getTimeSlot($date)
{
$day = date('l', strtotime($date));
$day_from = strtolower($day . '_from');
$day_to = strtolower($day . '_to');
$day_from = strtolower($day.'_from');
$day_to = strtolower($day.'_to');

$start = Setting::get_option($day_from);
$end = Setting::get_option($day_to);
Expand All @@ -79,8 +74,8 @@ public function getTimeSlot($date)
$time = [];
while (strtotime($start_time) <= strtotime($end_time)) {
$start = $start_time;
$end = date('H:i', strtotime('+' . $interval . ' minutes', strtotime($start_time)));
$start_time = date('H:i', strtotime('+' . $interval . ' minutes', strtotime($start_time)));
$end = date('H:i', strtotime('+'.$interval.' minutes', strtotime($start_time)));
$start_time = date('H:i', strtotime('+'.$interval.' minutes', strtotime($start_time)));
++$i;
if (strtotime($start_time) <= strtotime($end_time)) {
$time[$i]['start'] = $start;
Expand All @@ -96,7 +91,6 @@ public function store(Request $request)
{
$validatedData = $request->validate([
'patient' => ['required', 'exists:users,id'],
'create_by' => ['required', 'exists:users,id'],
'rdv_time_date' => ['required'],
'rdv_time_start' => ['required'],
'rdv_time_end' => ['required'],
Expand All @@ -110,7 +104,6 @@ public function store(Request $request)
$appointment->time_end = $request->rdv_time_end;
$appointment->visited = 0;
$appointment->reason = $request->reason;
$appointment->create_by = $request->create_by;
$appointment->save();

if ($request->send_sms == 1) {
Expand All @@ -120,11 +113,11 @@ public function store(Request $request)
\Nexmo::message()->send([
'to' => $phone,
'from' => '213794616181',
'text' => 'You have an appointment on ' . $request->rdv_time_date . ' at ' . $request->rdv_time_start . ' at Sai i lama',
'text' => 'You have an appointment on '.$request->rdv_time_date.' at '.$request->rdv_time_start.' at Sai i lama',
]);
}

if (Auth::user()->role_id == 3) {
if (\Auth::user()->role_id == 3) {
return back()->with('success', 'Rendez-vous crée avec succès!');
} else {
return back()->with('success', 'Appointment Created Successfully!');
Expand Down Expand Up @@ -156,7 +149,7 @@ public function store_id(Request $request)
\Nexmo::message()->send([
'to' => $phone,
'from' => '213794616181',
'text' => 'You have an appointment on ' . $request->rdv_time_date . ' at ' . $request->rdv_time_start . ' at Sai i lama',
'text' => 'You have an appointment on '.$request->rdv_time_date.' at '.$request->rdv_time_start.' at Sai i lama',
]);
}

Expand All @@ -179,7 +172,7 @@ public function store_edit(Request $request)

public function all()
{
$user = Auth::user();
$user = \Auth::user();
$appointments = Appointment::orderBy('id', 'DESC')->paginate(25);
$Myappointments = Appointment::where('user_id', $user);

Expand All @@ -195,18 +188,18 @@ public function calendar()

public function pending()
{

if (Auth::user()->role == '3') {
if (\Auth::user()->role == '3') {
$appointments = Appointment::where('user_id', Auth()->id())->where('visited', 0)->orderBy('date', 'ASC')->paginate(25);
} else {
$appointments = Appointment::where('visited', 0)->orderBy('date', 'ASC')->paginate(25);
}

return view('appointment.all', ['appointments' => $appointments]);
}

public function treated()
{
if (Auth::user()->role == '3') {
if (\Auth::user()->role == '3') {
$appointments = Appointment::where('user_id', Auth()->id())->where('visited', 1)->orderBy('date', 'ASC')->paginate(25);
} else {
$appointments = Appointment::where('visited', 1)->orderBy('date', 'ASC')->paginate(25);
Expand All @@ -217,7 +210,7 @@ public function treated()

public function cancelled()
{
if (Auth::user()->role == '3') {
if (\Auth::user()->role == '3') {
$appointments = Appointment::where('user_id', Auth()->id())->where('visited', 2)->orderBy('date', 'ASC')->paginate(25);
} else {
$appointments = Appointment::where('visited', 2)->orderBy('date', 'ASC')->paginate(25);
Expand All @@ -228,11 +221,12 @@ public function cancelled()

public function today()
{
if (Auth::user()->role == '3') {
if (\Auth::user()->role == '3') {
$appointments = Appointment::where('user_id', Auth()->id())->where('date', today())->orderBy('date', 'DESC')->paginate(25);
} else {
$appointments = Appointment::where('date', today())->orderBy('date', 'DESC')->paginate(25);
}

return view('appointment.all', ['appointments' => $appointments]);
}

Expand All @@ -245,18 +239,18 @@ public function destroy($id)

public function notify_whatsapp($id)
{

$appointment = Appointment::findorfail($id);

$appointment->User->Patient->notify(new WhatsAppNotification($appointment));

return back()->with('success', 'Patient Notified Successfully!');
}

public function notify_email($id)
{

$appointment = Appointment::findorfail($id);
$appointment->User->notify(new NewAppointmentByEmailNotification($appointment));

return back()->with('success', __('Patient Notified Successfully'));
}

Expand All @@ -266,6 +260,7 @@ public function getAppointments($id)
$userAppointments = $userAppointments->map(function ($item) {
// Utilisez toDateString() pour formater la date au format "YYYY-MM-DD".
$item->date = $item->date->toDateString();

return $item;
});

Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/WaitingroomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\User;
use App\Waiting_room;
use Illuminate\Http\Request;
use App\Helpers\Helper;

class WaitingroomController extends Controller
{
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"Database\\Seeders\\": "database/seeders/"

},
"files": [
"app/Helpers/Helper.php"
],
"classmap": [
"database/seeders",
"database/factories"
Expand Down
8 changes: 0 additions & 8 deletions database/seeders/WaitingroomRoleSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
namespace Database\Seeders;

use Illuminate\Database\Seeder;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;
use Spatie\Permission\PermissionRegistrar;
use App\User;

class WaitingroomRoleSeeder extends Seeder
{
Expand All @@ -22,7 +16,5 @@ public function run()
{
// Reset cached roles and permissions
app()[PermissionRegistrar::class]->forgetCachedPermissions();


}
}
11 changes: 6 additions & 5 deletions resources/lang/fr/sentence.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,10 @@
'set meetings' => 'Créer des rendez-vous a suivre',
'Reason for visit' => 'Motif de la Visite',
'Send SMS' => 'Envoyer un SMS',
'Cancelled'=>'Supprimer',
'Pending'=>'En attente',
'Treated'=>'Visité',
'My Account'=>'Mon Compte'

'Cancelled' => 'Supprimer',
'Pending' => 'En attente',
'Treated' => 'Visité',
'My Account' => 'Mon Compte',
'Reason code' => 'Code du rendez-vous',
'Visited At' => 'Visite le',
];
42 changes: 22 additions & 20 deletions resources/views/appointment/all.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class="fas fa-user-check"></i> {{ __('sentence.Treated') }}</a>
<div class="col">
@can('create appointment')
<a type="button" class="btn btn-primary btn-sm my-4 float-right"
href="{{ route('appointment.create_by', ['id' => Auth::user()->id]) }}"><i class="fa fa-plus"></i>
href="{{ route('appointment.create_by', ['id' => Auth::user()->id]) }}"><i class="fa fa-plus"></i>
{{ __('sentence.New Appointment') }}</a>
@endcan
</div>
Expand Down Expand Up @@ -118,6 +118,7 @@ class="btn btn-outline-danger btn-circle btn-sm"><i class="fas fa-trash"></i></a
<th class="text-center">{{ __('sentence.Schedule Info') }}</th>
<th class="text-center">{{ __('sentence.Status') }}</th>
<th class="text-center">{{ __('sentence.Created at') }}</th>
<th class="text-center">{{ __('sentence.Visited At') }}</th>
<th class="text-center">{{ __('sentence.Actions') }}</th>
</tr>
</thead>
Expand Down Expand Up @@ -155,26 +156,26 @@ class="badge badge-primary-soft">{{ $appointment->reason }}</label></td>
@endif
</td>
<td class="text-center">{{ $appointment->created_at->format('d M Y H:i') }}</td>
<td class="text-center">
@if ($appointment->visited == 1)
<label class="badge badge-primary-soft">
<i class="fas fa-calendar"></i>
{{ $appointment->updated_at->format('d M Y H:i') }}
</label>
@endif
</td>
<td align="center">
@can('edit appointment')
@php
$appointmentDate = \Carbon\Carbon::parse($appointment->date);
$appointmentTimeStart = \Carbon\Carbon::parse($appointment->time_start);
$currentDateTime = now();
$isFutureDateTime =
$appointmentDate->isFuture() ||
($appointmentDate->isToday() && $appointmentTimeStart->isFuture());
@endphp

<a data-rdv_id="{{ $appointment->id }}"
data-rdv_date="{{ $appointment->date->format('d M Y') }}"
data-rdv_time_start="{{ $appointment->time_start }}"
data-rdv_time_end="{{ $appointment->time_end }}"
data-patient_name="{{ $appointment->User->name }}"
class="btn btn-outline-success btn-circle btn-sm{{ $isFutureDateTime || $appointment->visited != 1 ? ' disabled opacity-button' : '' }}"
data-toggle="modal" data-target="#EDITRDVModal">
<i class="fas fa-check "></i>
</a>
<a data-rdv_id="{{ $appointment->id }}"
data-rdv_date="{{ $appointment->date->format('d M Y') }}"
data-rdv_time_start="{{ $appointment->time_start }}"
data-rdv_time_end="{{ $appointment->time_end }}"
data-patient_name="{{ $appointment->User->name }}"
class=" btn btn-outline-success btn-circle btn-sm
{{ $appointment->visited == 1 ? ' disabled opacity-button' : '' }}"
data-toggle="modal" data-target="#EDITRDVModal">
<i class="fas fa-check"></i>
</a>
@endcan
@can('delete appointment')
@if ($appointment->visited != 1)
Expand All @@ -189,7 +190,8 @@ class="btn btn-outline-danger btn-circle btn-sm">
@empty
<tr>
<td colspan="7" align="center"><img src="{{ asset('img/rest.png') }} " />
<br><br> <b class="text-muted">Vous n'avez pas de Rendez-Vous</b></td>
<br><br> <b class="text-muted">Vous n'avez pas de Rendez-Vous</b>
</td>
</tr>
@endforelse
</tbody>
Expand Down
Loading

0 comments on commit 3cd2d22

Please sign in to comment.