Skip to content
Snippets Groups Projects
Commit 93ef727b authored by nicrausaz's avatar nicrausaz
Browse files

get file working

parent ab484114
No related branches found
No related tags found
No related merge requests found
Showing
with 113 additions and 30 deletions
...@@ -38,6 +38,16 @@ ...@@ -38,6 +38,16 @@
] ]
]; ];
$FILIERES_INFOS = [
"entreprise" => "Informatique d'entreprise",
"techniqueSysteme" => "Technique des systèmes",
"developpementApplications" => "Développement d'applications",
"neSaisPas" => "Pas de filière préférée"
];
// ajouter le chemin des fichiers
// ajouter envois de mail actif / inactif
$POSTULATION_OPEN = true; // close/open postulation $POSTULATION_OPEN = true; // close/open postulation
if (!$POSTULATION_OPEN && $_SERVER['PHP_SELF'] != '/denied.php') { header("Location: ./denied.php"); } if (!$POSTULATION_OPEN && $_SERVER['PHP_SELF'] != '/denied.php') { header("Location: ./denied.php"); }
......
...@@ -109,8 +109,8 @@ ...@@ -109,8 +109,8 @@
<label for="adrApp">Rue *</label> <label for="adrApp">Rue *</label>
<input type="text" name="adrApp" id="adrApp" placeholder="Rue" class="form-control" value="<?php echo $_SESSION['postedForm']['adrApp'] != '' ? $_SESSION['postedForm']['adrApp'] : ''; ?>" minlength="2" maxlength="40" data-required/> <input type="text" name="adrApp" id="adrApp" placeholder="Rue" class="form-control" value="<?php echo $_SESSION['postedForm']['adrApp'] != '' ? $_SESSION['postedForm']['adrApp'] : ''; ?>" minlength="2" maxlength="40" data-required/>
<label for="nameApp">NPA\Domicile *</label> <label for="nameApp">NPA, Domicile *</label>
<input type="text" name="NPAApp" id="NPAApp" placeholder="NPA\Domicile" class="form-control" value="<?php echo $_SESSION['postedForm']['NPAApp'] != '' ? $_SESSION['postedForm']['NPAApp'] : ''; ?>" minlength="2" maxlength="40" data-required/> <input type="text" name="NPAApp" id="NPAApp" placeholder="NPA, Domicile" class="form-control" value="<?php echo $_SESSION['postedForm']['NPAApp'] != '' ? $_SESSION['postedForm']['NPAApp'] : ''; ?>" minlength="2" maxlength="40" data-required/>
<label for="telApp">Téléphone *</label> <label for="telApp">Téléphone *</label>
<input type="tel" name="telApp" id="telApp" placeholder="+41 21 123 45 67" class="form-control" value="<?php echo $_SESSION['postedForm']['telApp'] != '' ? $_SESSION['postedForm']['telApp'] : ''; ?>" minlength="2" maxlength="20" data-required/> <input type="tel" name="telApp" id="telApp" placeholder="+41 21 123 45 67" class="form-control" value="<?php echo $_SESSION['postedForm']['telApp'] != '' ? $_SESSION['postedForm']['telApp'] : ''; ?>" minlength="2" maxlength="20" data-required/>
...@@ -189,8 +189,8 @@ ...@@ -189,8 +189,8 @@
<input type="text" name="surnameRep1" id="surnameRep1" class="form-control" placeholder="Prénom" value="<?php echo $_SESSION['postedForm']['surnameRep1'] != '' ? $_SESSION['postedForm']['surnameRep1'] : ''; ?>"/> <input type="text" name="surnameRep1" id="surnameRep1" class="form-control" placeholder="Prénom" value="<?php echo $_SESSION['postedForm']['surnameRep1'] != '' ? $_SESSION['postedForm']['surnameRep1'] : ''; ?>"/>
<label for="adrRep1">Rue *</label> <label for="adrRep1">Rue *</label>
<input type="text" name="adrRep1" id="adrRep1" class="form-control" placeholder="Rue" value="<?php echo $_SESSION['postedForm']['adrRep1'] != '' ? $_SESSION['postedForm']['adrRep1'] : ''; ?>"/> <input type="text" name="adrRep1" id="adrRep1" class="form-control" placeholder="Rue" value="<?php echo $_SESSION['postedForm']['adrRep1'] != '' ? $_SESSION['postedForm']['adrRep1'] : ''; ?>"/>
<label for="NPARep1">NPA\Domicile *</label> <label for="NPARep1">NPA, Domicile *</label>
<input type="text" name="NPARep1" id="NPARep1" class="form-control" placeholder = "NPA\Domicile" value="<?php echo $_SESSION['postedForm']['NPARep1'] != '' ? $_SESSION['postedForm']['NPARep1'] : ''; ?>"/> <input type="text" name="NPARep1" id="NPARep1" class="form-control" placeholder = "NPA, Domicile" value="<?php echo $_SESSION['postedForm']['NPARep1'] != '' ? $_SESSION['postedForm']['NPARep1'] : ''; ?>"/>
<label for="telRep1">Téléphone *</label> <label for="telRep1">Téléphone *</label>
<input type="text" name="telRep1" id="telRep1" class="form-control" placeholder="+41 79 123 45 67" value="<?php echo $_SESSION['postedForm']['telRep1'] != '' ? $_SESSION['postedForm']['telRep1'] : ''; ?>"/> <input type="text" name="telRep1" id="telRep1" class="form-control" placeholder="+41 79 123 45 67" value="<?php echo $_SESSION['postedForm']['telRep1'] != '' ? $_SESSION['postedForm']['telRep1'] : ''; ?>"/>
...@@ -207,8 +207,8 @@ ...@@ -207,8 +207,8 @@
<input type="text" name="surnameRep2" id="surnameRep2" class="form-control" placeholder="Prénom" value="<?php echo $_SESSION['postedForm']['surnameRep2'] != '' ? $_SESSION['postedForm']['surnameRep2'] : ''; ?>"/> <input type="text" name="surnameRep2" id="surnameRep2" class="form-control" placeholder="Prénom" value="<?php echo $_SESSION['postedForm']['surnameRep2'] != '' ? $_SESSION['postedForm']['surnameRep2'] : ''; ?>"/>
<label for="adrRep2">Rue</label> <label for="adrRep2">Rue</label>
<input type="text" name="adrRep2" id="adrRep2" class="form-control" placeholder="Rue" value="<?php echo $_SESSION['postedForm']['adrRep2'] != '' ? $_SESSION['postedForm']['adrRep2'] : ''; ?>"/> <input type="text" name="adrRep2" id="adrRep2" class="form-control" placeholder="Rue" value="<?php echo $_SESSION['postedForm']['adrRep2'] != '' ? $_SESSION['postedForm']['adrRep2'] : ''; ?>"/>
<label for="NPARep2">NPA\Domicile</label> <label for="NPARep2">NPA, Domicile</label>
<input type="text" name="NPARep2" id="NPARep2" class="form-control" placeholder = "NPA\Domicile" value="<?php echo $_SESSION['postedForm']['NPARep2'] != '' ? $_SESSION['postedForm']['NPARep2'] : ''; ?>"/> <input type="text" name="NPARep2" id="NPARep2" class="form-control" placeholder = "NPA, Domicile" value="<?php echo $_SESSION['postedForm']['NPARep2'] != '' ? $_SESSION['postedForm']['NPARep2'] : ''; ?>"/>
<label for="telRep2">Téléphone</label> <label for="telRep2">Téléphone</label>
<input type="text" name="telRep2" id="telRep2" class="form-control" placeholder="+41 79 123 45 67" value="<?php echo $_SESSION['postedForm']['telRep2'] != '' ? $_SESSION['postedForm']['telRep2'] : ''; ?>"/> <input type="text" name="telRep2" id="telRep2" class="form-control" placeholder="+41 79 123 45 67" value="<?php echo $_SESSION['postedForm']['telRep2'] != '' ? $_SESSION['postedForm']['telRep2'] : ''; ?>"/>
</div> </div>
......
<?php
require('configs/db.php');
include('./helpers.php');
require_once("tequila/tequila.php");
$oClient = new TequilaClient();
$oClient->SetApplicationName('Formulaire apprentissage');
$oClient->SetWantedAttributes(array('uniqueid','firstname','name'));
$oClient->SetWishedAttributes(array('user'));
$oClient->SetAllowsFilter('categorie=epfl-guests');
$oClient->Authenticate();
$user = $oClient->getValue('user');
$firstname = $oClient->getValue('firstname');
$name = $oClient->getValue('name');
$guest_sciper = $oClient->getValue('uniqueid');
$sKey = $oClient->GetKey();
if (isset($_GET['id'])) {
// check if sciper is linked to file
$file = validFileAccess($pdo, $_GET['id'], $guest_sciper)[0];
if ($file) {
// get file
echo file_get_contents($file['file_path']);
// send file
header('Content-Disposition: attachment; filename='.$file['file_name']);
} else {
echo "Fichier inexistant ou accès refusé";
}
}
?>
\ No newline at end of file
...@@ -261,5 +261,14 @@ function getFilesById ($pdo, $id) { ...@@ -261,5 +261,14 @@ function getFilesById ($pdo, $id) {
$query->execute(); $query->execute();
return $query->fetchAll(); return $query->fetchAll();
} }
function validFileAccess ($pdo, $id, $sciper) {
$sqlreq = "SELECT file_name, file_path FROM file INNER JOIN applicant ON file.applicant_applicant_id = applicant.applicant_id WHERE applicant.applicant_guest_sciper = :sciper AND file_id = :id";
$query = $pdo->prepare($sqlreq);
$query->bindParam(':id', $id, PDO::PARAM_STR);
$query->bindParam(':sciper', $sciper, PDO::PARAM_STR);
$query->execute();
return $query->fetchAll();
}
#endregion #endregion
?> ?>
\ No newline at end of file
...@@ -9,6 +9,9 @@ $(document).ready(function () { ...@@ -9,6 +9,9 @@ $(document).ready(function () {
initDatepicker(); initDatepicker();
checkRequired(); checkRequired();
} }
if (location.pathname.split("/").slice(-1)[0] == "viewpostulation.php") {
initPostulationChange();
}
}); });
function checkDate () { function checkDate () {
...@@ -243,7 +246,14 @@ function showPolyAndInfoDivs(selectedFormation) { ...@@ -243,7 +246,14 @@ function showPolyAndInfoDivs(selectedFormation) {
} }
} }
function checkRequired() {
function initPostulationChange () {
$('#selectPost').on('change', function () {
document.forms['postSelector'].submit();
});
}
function checkRequired () {
$("form").submit(function (e) { $("form").submit(function (e) {
let errsNumber = 0; let errsNumber = 0;
......
...@@ -13,6 +13,14 @@ ...@@ -13,6 +13,14 @@
<script src="./script.js"></script> <script src="./script.js"></script>
<style>.error { color: red!important; }</style> <style>.error { color: red!important; }</style>
<noscript>Veuillez Activer JavaScript pour utiliser le service de postulation !</noscript> <noscript>Veuillez Activer JavaScript pour utiliser le service de postulation !</noscript>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-130041798-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-130041798-1', { 'anonymize_ip': true });
</script>
<?php <?php
ini_set("display_errors", 0); ini_set("display_errors", 0);
error_reporting(0); error_reporting(0);
......
<!-- <?php <?php
$files = getFilesById($pdo, $postulation['applicant_id']); $files = getFilesById($pdo, $postulation['applicant_id']);
?> --> ?>
<!--
<button class="collapse-title collapse-title-desktop collapsed" type="button" data-toggle="collapse" data-target="#collapse-files" aria-expanded="true" aria-controls="collapse-files"> <button class="collapse-title collapse-title-desktop collapsed" type="button" data-toggle="collapse" data-target="#collapse-files" aria-expanded="true" aria-controls="collapse-files">
Annexes Annexes
</button> </button>
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
</tr> </tr>
<tr> <tr>
<td>Entreprise</td> <td>Entreprise</td>
<td><a href="<?= $file['file_path']?>"><?= $file['file_name'] ?></a></td> <td><a href="/getFile?id=<?= $file['file_id']?>"><?= $file['file_name'] ?></a></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<?php } ?> <?php } ?>
</div> --> </div>
...@@ -10,10 +10,9 @@ ...@@ -10,10 +10,9 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<!-- TODO: format les date, afficher mieux le job -->
<tr> <tr>
<td>Formation, lieu</td> <td>Formation, lieu </td>
<td><?= $postulation['applicant_formation'] . " " . $postulation['applicant_it_section'] . ", " . $postulation['applicant_formation_location'] ?></td> <td><?= $LISTJOB[$postulation['applicant_formation_location']][$postulation['applicant_formation']] . " " . $FILIERES_INFOS[$postulation['applicant_it_section']] . ", " . $postulation['applicant_formation_location'] ?></td>
</tr> </tr>
<tr> <tr>
<td>Maturité intégrée</td> <td>Maturité intégrée</td>
......
...@@ -5,11 +5,14 @@ ...@@ -5,11 +5,14 @@
Stages Stages
</button> </button>
<div class="collapse collapse-item collapse-item-desktop" id="collapse-practices"> <div class="collapse collapse-item collapse-item-desktop" id="collapse-practices">
<?php foreach ($trainings as $training) { ?> <?php if (count($trainings) < 1) { ?>
<p style="text-align: center;">Aucune donnée fournie</p>
<?php } ?>
<?php foreach ($trainings as $key => $training) { ?>
<table class="table table-boxed mb-5"> <table class="table table-boxed mb-5">
<thead> <thead>
<tr> <tr>
<th>Stages</th> <th>Stage <?= $key + 1; ?></th>
<th>Données</th> <th>Données</th>
</tr> </tr>
</thead> </thead>
......
...@@ -5,11 +5,14 @@ ...@@ -5,11 +5,14 @@
Activités professionnelles Activités professionnelles
</button> </button>
<div class="collapse collapse-item collapse-item-desktop" id="collapse-pro"> <div class="collapse collapse-item collapse-item-desktop" id="collapse-pro">
<?php foreach ($proactivities as $activity) { ?> <?php if (count($proactivities) < 1) { ?>
<p style="text-align: center;">Aucune donnée fournie</p>
<?php } ?>
<?php foreach ($proactivities as $key => $activity) { ?>
<table class="table table-boxed mb-5"> <table class="table table-boxed mb-5">
<thead> <thead>
<tr> <tr>
<th>Activité professionnelle</th> <th>Activité professionnelle <?= $key + 1; ?></th>
<th>Données</th> <th>Données</th>
</tr> </tr>
</thead> </thead>
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
Représentants Représentants
</button> </button>
<div class="collapse collapse-item collapse-item-desktop" id="collapse-responsibles"> <div class="collapse collapse-item collapse-item-desktop" id="collapse-responsibles">
<?php if (!$main_resp) { ?>
<p style="text-align: center;">Aucune donnée fournie</p>
<?php } ?>
<?php if ($main_resp) { ?> <?php if ($main_resp) { ?>
<table class="table table-boxed mb-5"> <table class="table table-boxed mb-5">
<thead> <thead>
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
Scolarité Scolarité
</button> </button>
<div class="collapse collapse-item collapse-item-desktop" id="collapse-scolarite"> <div class="collapse collapse-item collapse-item-desktop" id="collapse-scolarite">
<?php foreach ($scolarites as $scolarity) { ?> <?php foreach ($scolarites as $key => $scolarity) { ?>
<table class="table table-boxed mb-5"> <table class="table table-boxed mb-5">
<thead> <thead>
<tr> <tr>
<th>Scolarité</th> <th>Scolarité <?= $key + 1; ?></th>
<th>Données</th> <th>Données</th>
</tr> </tr>
</thead> </thead>
......
...@@ -21,27 +21,36 @@ ...@@ -21,27 +21,36 @@
?> ?>
</head> </head>
<body> <body>
<?php include('templates/header.php'); $postulation = getPostulationBySciper($pdo, $guest_sciper)[0]; ?> <?php include('templates/header.php'); $postulations = getPostulationBySciper($pdo, $guest_sciper);?>
<main id="main" role="main" class="content container-grid"> <main id="main" role="main" class="content container-grid">
<h3 class="mb-5">Candidature pour un apprentissage</h3> <h3 class="mb-5">Candidature pour un apprentissage</h3>
<h5 class="mb-3">Votre candidature - <?= date('d/m/Y', strtotime($postulation['applicant_application_date'])) ?></h5> <!-- si plusieures postulations -->
<?php if (count($postulations) > 1) { ?>
<div class="form-group"> <div class="form-group">
<!-- si plusieures postulations --> <label>Vous avez effectué plusieurs postulations, merci de choisir</label>
<label>Vous avez postulé plusieurs fois, choisissez votre postulation</label> <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" name="postSelector">
<select id="select-input" class="custom-select mb-3"> <select id="selectPost" name="selected_post" class="custom-select mb-3" onselect="postSelector.submit()">
<option value="4">Job, date 1</option> <?php foreach ($postulations as $key => $postulation) { ?>
<option value="5">Job, date 2</option> <option <?= $key == $_POST['selected_post'] ? 'selected' : '' ?> value="<?=$key?>"><?=$LISTJOB[$postulation['applicant_formation_location']][$postulation['applicant_formation']] . ", " . date('d/m/Y', strtotime($postulation['applicant_application_date'])) ?></option>
</select> <?php } ?>
</select>
</form>
</div> </div>
<?php } ?>
<article> <article>
<?php <?php
if ($_POST['selected_post']) {
$postulation = $postulations[$_POST['selected_post']];
} else {
$postulation = $postulations[0];
}
include('templates/viewPostulationTables/personnalInfosTable.php'); include('templates/viewPostulationTables/personnalInfosTable.php');
include('templates/viewPostulationTables/responsiblesInfosTable.php'); include('templates/viewPostulationTables/responsiblesInfosTable.php');
include('templates/viewPostulationTables/scolaritiesInfosTable.php'); include('templates/viewPostulationTables/scolaritiesInfosTable.php');
include('templates/viewPostulationTables/proActivitiesInfosTable.php'); include('templates/viewPostulationTables/proActivitiesInfosTable.php');
include('templates/viewPostulationTables/practicesInfosTable.php'); include('templates/viewPostulationTables/practicesInfosTable.php');
include('templates/viewPostulationTables/filesTables.php'); include('templates/viewPostulationTables/filesTables.php');
// print_r($postulation);
?> ?>
</pre> </pre>
<button type="button" class="btn btn-primary btn-block btn-sm mt-3 mb-2" id="delPostB">Retirer ma postulation</button> <button type="button" class="btn btn-primary btn-block btn-sm mt-3 mb-2" id="delPostB">Retirer ma postulation</button>
......
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