diff --git a/canapGEST/API/app/Http/Controllers/ApplicantsController.php b/canapGEST/API/app/Http/Controllers/ApplicantsController.php index a063dfff42eb934ed6ebb21cdc053b68cd25d44a..b44af965a27a6ad61a7754e5646b46536ac567b3 100644 --- a/canapGEST/API/app/Http/Controllers/ApplicantsController.php +++ b/canapGEST/API/app/Http/Controllers/ApplicantsController.php @@ -30,11 +30,14 @@ class ApplicantsController extends Controller // Récupère toutes les candidatures autorisées $applicants = []; - $job_applicants = DB::table('applicant') - ->join('position', 'applicant.fk_position', '=', 'position.position_id') - ->join('job', 'position.fk_job', '=', 'job.job_id') - ->join('location', 'position.fk_location', '=', 'location.location_id') - ->get(); + if (AccessLevelHelper::hasPermittedRole($this->user_role, 'responsable')) { + + $job_applicants = DB::table('applicant') + ->join('position', 'applicant.fk_position', '=', 'position.position_id') + ->join('job', 'position.fk_job', '=', 'job.job_id') + ->join('location', 'position.fk_location', '=', 'location.location_id') + ->get(); + } if (AccessLevelHelper::hasPermittedRole($this->user_role, 'formateur')) { $job_applicants = DB::table('applicant') @@ -47,6 +50,13 @@ class ApplicantsController extends Controller }) ->where('fk_status', 'Valide') ->get(); + + // $job_applicants = DB::table('applicant') + // ->join('position', 'applicant.fk_position', '=', 'position.position_id') + // ->join('job', 'position.fk_job', '=', 'job.job_id') + // ->join('location', 'position.fk_location', '=', 'location.location_id') + // ->where('fk_status', 'Valide') + // ->get(); } foreach ($job_applicants as $key => $applicant) { @@ -109,6 +119,20 @@ class ApplicantsController extends Controller $has_access = AccessLevelHelper::hasAccessToJob($applicant_job, $this->user_permissions); $has_permitted_role = AccessLevelHelper::hasPermittedRole($this->user_role, 'responsable'); if ($has_access && $has_permitted_role) { + + // Delete Applicant files and folder + $applicant_files = DB::table('file')->where('fk_applicant_id', $id)->get(); + $applicant_folder = ""; + foreach ($applicant_files as $file) { + unlink($file->file_path); + $applicant_folder = dirname($file->file_path); + } + // delete applicant folder + if ($applicant_folder != "") { + rmdir($applicant_folder); + } + + // Delete Applicant from DB DB::table('applicant')->where('applicant_id', $id)->delete(); return ["message" => lang::get('http.success.deleted.application')]; } else { diff --git a/canapGEST/API/app/Http/Controllers/AuthController.php b/canapGEST/API/app/Http/Controllers/AuthController.php index 155d50d4bc3d200be3dfbf5a0654b8e8d4578c59..258d7fac8933a57e4631ea5d8ad463fa01b549b8 100644 --- a/canapGEST/API/app/Http/Controllers/AuthController.php +++ b/canapGEST/API/app/Http/Controllers/AuthController.php @@ -38,7 +38,7 @@ class AuthController extends Controller // DEV ndubois droits responsable if ($tequila_attributes["uniqueid"] == "167916") { - $payload["role"] = 'responsable'; + // $payload["role"] = 'responsable'; } diff --git a/canapGEST/API/app/Http/Controllers/MarkersController.php b/canapGEST/API/app/Http/Controllers/MarkersController.php index 275620549775a960325f567196f0a8b0b23a5759..d678c93c3190f2e378caee80e90eb3ee4d02b81b 100644 --- a/canapGEST/API/app/Http/Controllers/MarkersController.php +++ b/canapGEST/API/app/Http/Controllers/MarkersController.php @@ -45,13 +45,24 @@ class MarkersController extends Controller $has_access = AccessLevelHelper::hasAccessToJob($applicant_job, $this->user_permissions); if ($has_access) { + + $marker_exists = DB::table('marker')->where('fk_applicant_id', $new_applicant_id)->where('marker_owner_sciper', $this->user_sciper)->first(); + if ($marker_exists) { + $id = $marker_exists->marker_id; + DB::table('marker')->where('marker_id', $id)->update(['marker_value' => $new_value]); + return ["message" => lang::get('http.success.created.marker'), "id" => $id]; + + } else { + $inserted_id = DB::table('marker')->insertGetId([ "marker_owner_sciper" => $this->user_sciper, "marker_value" => $new_value, "fk_applicant_id" => $new_applicant_id ]); return ["message" => lang::get('http.success.created.marker'), "id" => $inserted_id]; - } else { + + } + } else { return response()->json(['error' => 403, 'message' => lang::get('http.unauthorized')], 403); } } diff --git a/canapGEST/API/app/Http/Controllers/UsersController.php b/canapGEST/API/app/Http/Controllers/UsersController.php index f02a8080c14e7f4b70f8b69d9c68ff2dc92dd772..a9af721c42fdbcdb682a833ffeef2a3b1073ab3f 100644 --- a/canapGEST/API/app/Http/Controllers/UsersController.php +++ b/canapGEST/API/app/Http/Controllers/UsersController.php @@ -74,7 +74,8 @@ class UsersController extends Controller { // TODO: this dont work, must be auth $last_connection = DB::table('last_connection')->where('last_connection_sciper', $this->user_sciper)->first(); - return $last_connection ? ["last_connection" => $last_connection] : ["last_connection" => null]; + $now = date("Y-m-d H:i:s"); + return $last_connection ? ["last_connection" => $last_connection] : ["last_connection" => $now]; } public function setLastConnection ()