Candidatures dans offres_stages.php

This commit is contained in:
Louis DUMONT 2022-03-23 15:33:52 +01:00
parent 4291b4d425
commit a0f2225c99
10 changed files with 149 additions and 35 deletions

View File

@ -131,7 +131,7 @@
.flex-row .flex-row
{ {
width: calc(100% / 2); width: calc(100% / 4);
text-align: center; text-align: center;
padding: 0.2em 0.2em; padding: 0.2em 0.2em;
} }
@ -227,6 +227,13 @@
font-size: 20px; font-size: 20px;
} }
.flex-row-modal
{
width: calc(100% / 2);
text-align: center;
padding: 0.2em 0.2em;
}
.close .close
{ {
color: #aaa; color: #aaa;

View File

@ -1,3 +1,5 @@
var ID_internship=0;
$(document).ready(function(){ $(document).ready(function(){
$("#li_stages").delay(2000).addClass("hover"); $("#li_stages").delay(2000).addClass("hover");
@ -27,8 +29,10 @@ $(document).ready(function(){
}); });
$(".button_postuler").click(function() { $(".button_postuler").click(function() {
$(".modal").show(); window.ID_internship = $(this).attr("id_internship");
$(".title_modal").html("Postuler pour " + $(this).attr("name_internship"));
$(".info_message").hide(); $(".info_message").hide();
$(".modal").show();
}); });
window.onclick = function(event) { window.onclick = function(event) {
@ -37,6 +41,13 @@ $(document).ready(function(){
} }
} }
$('.form_postuler').on('submit',(function(){
check = true;
if ($('#cv').get(0).files.length === 0 || $('#lm').get(0).files.length === 0) { check = false; }
if (check) {$(".form_postuler").append('<input type="hidden" name="ID_internship" value="'+ window.ID_internship +'">');}
return check;
}));
}); });

View File

@ -25,8 +25,6 @@ if (isset($_SESSION["username"])){
$query_candidatures = $bdd->prepare($sql); $query_candidatures = $bdd->prepare($sql);
$query_candidatures->execute(['user' => $_SESSION["username"]]); $query_candidatures->execute(['user' => $_SESSION["username"]]);
$results_candidatures = $query_candidatures->fetchALL(PDO::FETCH_OBJ); $results_candidatures = $query_candidatures->fetchALL(PDO::FETCH_OBJ);
?> ?>
<html lang="fr"> <html lang="fr">
<head> <head>
@ -60,22 +58,41 @@ if (isset($_SESSION["username"])){
<div class="divRight"> <div class="divRight">
<table> <table>
<div class="table_title">Fichiers en lien avec la candidature:</div> <div class="table_title">Fichiers en lien avec la candidature:</div>
<tr> <tr>
<td>Curriculum Vitae :</td> <td>Curriculum Vitae :</td>
<td><?= $result->cv_file_path_candidature; ?></td> <td>
<?php
if($result->cv_file_path_candidature != "") {echo 'Déposé <i style="color:green;" class="fas fa-check"></i>';}
else {echo 'Non disponible <i style="color:red;" class="fas fa-times"></i>';}
?>
</td>
</tr> </tr>
<tr> <tr>
<td>Lettre de motivation :</td> <td>Lettre de motivation :</td>
<td><?= $result->lm_file_path_candidature; ?></td> <td>
<?php
if($result->lm_file_path_candidature != "") {echo 'Déposé <i style="color:green;" class="fas fa-check"></i>';}
else {echo 'Non disponible <i style="color:red;" class="fas fa-times"></i>';}
?>
</td>
</tr> </tr>
<tr> <tr>
<td>Fiche de validation :</td> <td>Fiche de validation :</td>
<td><?= $result->validation_form_file_path_candidature; ?></td> <td>
<?php
if($result->validation_form_file_path_candidature != "") {echo 'Déposé <i style="color:green;" class="fas fa-check"></i>';}
else {echo 'Non disponible <i style="color:red;" class="fas fa-times"></i>';}
?>
</td>
</tr> </tr>
<tr> <tr>
<td>Convention de stage :</td> <td>Convention de stage :</td>
<td><?= $result->internship_agreement_file_path_candidature; ?></td> <td>
<?php
if($result->internship_agreement_file_path_candidature != "") {echo 'Déposé <i style="color:green;" class="fas fa-check"></i>';}
else {echo 'Non disponible <i style="color:red;" class="fas fa-times"></i>';}
?>
</td>
</tr> </tr>
</table> </table>
</div> </div>
@ -88,7 +105,7 @@ if (isset($_SESSION["username"])){
<div class="bubble"> <div class="bubble">
<div class="title_bubble">Tout est vide...</div> <div class="title_bubble">Tout est vide...</div>
<div class="text_content"> <div class="text_content">
Il n'y a aucun favori dans les parages &nbsp;<i class="fas fa-wind"></i> Vous n'avez aucune candidature en cours &nbsp;<i class="fas fa-wind"></i>
</div> </div>
</div> </div>
<?php } ?> <?php } ?>

BIN
controller/0 Normal file

Binary file not shown.

50
controller/Postuler.php Normal file
View File

@ -0,0 +1,50 @@
<?php
session_start();
if (isset($_SESSION["username"])){
include "../controller/ConnexionBDD.php";
if (!$error) {
if (is_uploaded_file($_FILES['cv']['tmp_name']) && is_uploaded_file($_FILES['lm']['tmp_name']) && isset($_POST["ID_internship"])) {
$query_ID_user = $bdd->prepare('SELECT ID_user FROM users WHERE username=:user;');
$query_ID_user->execute(['user' => $_SESSION["username"]]);
$ID_user = $query_ID_user->fetchALL(PDO::FETCH_OBJ)[0]->ID_user;
$location_cv = "/documents/users/".$ID_user."/candidatures/".$_POST["ID_internship"]."/".$_FILES['cv']['name'];
$location_lm = "/documents/users/".$ID_user."/candidatures/".$_POST["ID_internship"]."/".$_FILES['lm']['name'];
echo $location_cv;
echo "<br>";
echo $location_lm;
try {
if (!is_dir('../documents/')){
mkdir("../documents/", 0700);
}
if (!is_dir('../documents/users')){
mkdir("../documents/users", 0700);
}
if (!is_dir("../documents/users/".$ID_user."/")){
mkdir("../documents/users/".$ID_user."/", 0700);
}
if (!is_dir("../documents/users/".$ID_user."/"."candidatures/")){
mkdir("../documents/users/".$ID_user."/"."candidatures/", 0700);
}
if (!is_dir("../documents/users/".$ID_user."/"."candidatures/".$_POST["ID_internship"])){
mkdir("../documents/users/".$ID_user."/"."candidatures/".$_POST["ID_internship"], 0700);
}
move_uploaded_file($_FILES['cv']['tmp_name'], "..".$location_cv);
move_uploaded_file($_FILES['lm']['tmp_name'], "..".$location_lm);
$query_ID_user = $bdd->prepare('INSERT INTO candidatures VALUES (NULL, "1", :location_cv, :location_lm, NULL, NULL, :ID_user, :ID_internship);');
$query_ID_user->execute(['location_cv' => $location_cv, 'location_lm' => $location_lm, 'ID_user' => $ID_user, 'ID_internship' => $_POST["ID_internship"]]);
echo "<script>location.href='/offres_stages.php';</script>";
}
catch (Exception $e) {
echo "zut une erreur";
}
} else {echo "POST file incomplet";}
}
}
?>

Binary file not shown.

Binary file not shown.

View File

@ -4,7 +4,7 @@
session_start(); session_start();
if (isset($_SESSION["username"])){ if (isset($_SESSION["username"])){
$sql = 'SELECT ID_internship ,name_internship, description_internship, duration_internship, remuneration_internship, offer_date_internship, place_number_internship, competences_internship, city_localisation, postal_code_localisation, GROUP_CONCAT(name_promotion SEPARATOR ", ") AS "name_promotion", name_company, note FROM internships NATURAL JOIN localisations NATURAL JOIN companies NATURAL JOIN internship_for_promo NATURAL JOIN promotions NATURAL JOIN evaluate INNER JOIN users ON evaluate.ID_user=users.ID_user NATURAL JOIN roles WHERE name_role="Pilote" AND visibility_company="O"'; $sql = 'SELECT ID_internship ,name_internship, description_internship, duration_internship, remuneration_internship, offer_date_internship, place_number_internship, competences_internship, city_localisation, postal_code_localisation, GROUP_CONCAT(name_promotion SEPARATOR ", ") AS "name_promotion", name_company, email_company, email_company, note FROM internships NATURAL JOIN localisations NATURAL JOIN companies NATURAL JOIN internship_for_promo NATURAL JOIN promotions NATURAL JOIN evaluate INNER JOIN users ON evaluate.ID_user=users.ID_user NATURAL JOIN roles WHERE name_role="Pilote" AND visibility_company="O"';
$params = []; $params = [];
$selected = []; $selected = [];
if (isset($_GET["localisation"]) && isset($_GET["competences"]) && isset($_GET["confiance"]) && isset($_GET["dateoffre"]) && isset($_GET["duree"]) && isset($_GET["promotion"])){ if (isset($_GET["localisation"]) && isset($_GET["competences"]) && isset($_GET["confiance"]) && isset($_GET["dateoffre"]) && isset($_GET["duree"]) && isset($_GET["promotion"])){
@ -85,6 +85,14 @@ if (isset($_SESSION["username"])){
foreach ($results_wishlist as $result) { foreach ($results_wishlist as $result) {
array_push($wishlist, $result->ID_internship); array_push($wishlist, $result->ID_internship);
} }
$query_candidatures = $bdd->prepare('SELECT candidatures.ID_internship FROM candidatures NATURAL JOIN users INNER JOIN internships ON candidatures.ID_internship=internships.ID_internship WHERE username=:user;');
$query_candidatures->execute(['user' => $_SESSION["username"]]);
$results_candidatures = $query_candidatures->fetchALL(PDO::FETCH_OBJ);
$candidatures = [];
foreach ($results_candidatures as $result) {
array_push($candidatures, $result->ID_internship);
}
?> ?>
<html lang="fr"> <html lang="fr">
<head> <head>
@ -96,17 +104,17 @@ if (isset($_SESSION["username"])){
<div id="modal_postuler" class="modal"> <div id="modal_postuler" class="modal">
<div class="modal-content"> <div class="modal-content">
<span class="close">&times;</span> <span class="close">&times;</span>
<div class="title_modal">Postuler pour </div> <div class="title_modal"></div>
<form class="form_postuler" method="post" enctype="multipart/form-data"> <form class="form_postuler" action="controller/Postuler.php" method="post" enctype="multipart/form-data">
<div class="table-container"> <div class="table-container">
<div class="info_message"></div> <div class="info_message"></div>
<div class="flex-table"> <div class="flex-table">
<div class="flex-row name">Curriculum Vitae</div> <div class="flex-row-modal name">Curriculum Vitae</div>
<div class="flex-row value"><input id="cv" type="file" name="cv" require></div> <div class="flex-row-modal value"><input id="cv" type="file" name="cv" require></div>
</div> </div>
<div class="flex-table"> <div class="flex-table">
<div class="flex-row name">Lettre de motivation</div> <div class="flex-row-modal name">Lettre de motivation</div>
<div class="flex-row value"><input id="lm" type="file" name="lm" require></div> <div class="flex-row-modal value"><input id="lm" type="file" name="lm" require></div>
</div> </div>
</div> </div>
<button type="submit">Envoyer</button> <button type="submit">Envoyer</button>
@ -230,7 +238,7 @@ if (isset($_SESSION["username"])){
<div class="name_company"> <div class="name_company">
<?= $result->name_company; ?> <?= $result->name_company; ?>
</div> </div>
<?= $result->city_localisation; ?> <?= $result->postal_code_localisation; ?> <?= $result->city_localisation; ?> <?= $result->postal_code_localisation; ?> - <?= $result->email_company; ?>
<div class="description"> <div class="description">
<?= $result->description_internship; ?> <?= $result->description_internship; ?>
</div> </div>
@ -274,8 +282,14 @@ if (isset($_SESSION["username"])){
</tr> </tr>
</table> </table>
</div> </div>
<div class="button"> <div class="button">
<button id="button_postuler<?=$result->ID_internship?>" class="button_postuler">Postuler</button> <?php
if (!in_array($result->ID_internship, $candidatures)) { ?>
<button class="button_postuler" name_internship="<?=$result->name_internship;?>" id_internship="<?=$result->ID_internship?>">Postuler</button>
<?php } else { ?>
<button class="button_postuler" disabled>Déjà postulé</button>
<?php } ?>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,20 +1,35 @@
<html>
<body>
<?php <?php
session_start();
/* Get the name of the file uploaded to Apache */ if (isset($_SESSION["username"])){
$filename = $_FILES['file']['name']; include "controller/ConnexionBDD.php";
if (!$error) {
$query_ID_user = $bdd->prepare('SELECT ID_user FROM users WHERE username=:user;');
$query_ID_user->execute(['user' => $_SESSION["username"]]);
$ID_user = $query_ID_user->fetchALL(PDO::FETCH_OBJ)[0]->ID_user;
/* Prepare to save the file upload to the upload folder */ $location_cv = "./documents/users/".$ID_user."/".$_FILES['cv']['name'];
$location = "upload/".$filename; $location_lm = "./documents/users/".$ID_user."/".$_FILES['lm']['name'];
/* Permanently save the file upload to the upload folder */ if (!is_dir('./documents/')){
if ( move_uploaded_file($_FILES['file']['tmp_name'], $location) ) { mkdir("./documents/", 0700);
echo '<p>The HTML5 and php file upload was a success!</p>'; }
} else { if (!is_dir('./documents/users')){
echo '<p>The php and HTML5 file upload failed.</p>'; mkdir("./documents/users", 0700);
}
if (!is_dir("./documents/users/".$ID_user)){
mkdir("./documents/users/".$ID_user, 0700);
}
try {
move_uploaded_file($_FILES['cv']['tmp_name'], $location_cv);
move_uploaded_file($_FILES['lm']['tmp_name'], $location_lm);
echo "tout est ok";
}
catch (Exception $e) {
echo "zut une erreur";
}
}
} }
?> ?>
</body>
</html>

Binary file not shown.