Skip to content
Snippets Groups Projects
Commit 7f4e23cd authored by Nicolas Dubois's avatar Nicolas Dubois
Browse files

Bugs

parent cf4edac2
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
......@@ -38,7 +38,7 @@ class AuthController extends Controller
// DEV ndubois droits responsable
if ($tequila_attributes["uniqueid"] == "167916") {
$payload["role"] = 'responsable';
// $payload["role"] = 'responsable';
}
......
......@@ -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);
}
}
......
......@@ -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 ()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment