Skip to content
Snippets Groups Projects
Commit 2037fcbd authored by nicrausaz's avatar nicrausaz
Browse files

Fonctionnalité visualiser nouvelle candidature formateurs

parent 65438fa2
No related branches found
No related tags found
No related merge requests found
Showing
with 111 additions and 23 deletions
......@@ -55,7 +55,7 @@ class AccessLevelHelper
{
$default_access_groups = self::getDefaultAccessGroups();
$user_alloweds = [];
$user_role = 'responsable'; // formateur
$user_role = 'formateur'; // formateur
$user_groups = explode(',', $user_groups);
foreach ($default_access_groups as $group => $accesses) {
......
......@@ -69,4 +69,31 @@ class UsersController extends Controller
"mail" => $info[0]['mail'][0]
]);
}
public function getLastConnection ()
{
$last_connection = DB::table('last_connection')->where('last_connection_sciper', $this->user_sciper)->first();
return $last_connection ? ["last_connection" => $last_connection] : ["last_connection" => null];
}
public function setLastConnection ()
{
$last_connection = DB::table('last_connection')->where('last_connection_sciper', $this->user_sciper)->first();
if ($last_connection) {
// Get tmp -> set to date, actual date to tmp
$new_date = date("Y-m-d H:i:s");
DB::table('last_connection')->where('last_connection_id', $last_connection->last_connection_id)->update([
'last_connection_date' => $last_connection->last_connection_tmp_date,
'last_connection_tmp_date' => $new_date
]);
} else {
// insert
$new_date = date("Y-m-d H:i:s");
$inserted_id = DB::table('last_connection')->insert([
"last_connection_sciper" => $this->user_sciper,
"last_connection_date" => $new_date,
'last_connection_tmp_date' => $new_date
]);
}
}
}
......@@ -9,6 +9,8 @@ $router->group(['middleware' => 'jwt.auth'], function () use ($router) {
$router->get('api/user/permittedjobs', 'UsersController@getPermittedJobs');
$router->get('api/user/hascommentedormarked', 'UsersController@getCommentedAndMarkedApplicantsByUser');
$router->get('api/user/data/{sciper}', 'UsersController@getUserDataBySciper');
$router->get('api/user/connection', 'UsersController@getLastConnection');
$router->patch('api/user/connection', 'UsersController@setLastConnection');
// Applicants
$router->get('api/applicants', 'ApplicantsController@getAll');
......
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (1, 'informaticienEntreprise', 'Informaticien-ne CFC; filire entreprise');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (2, 'informaticienSysteme', 'Informaticien-ne CFC; filire technique des systmes');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (3, 'informaticienDev', 'Informaticien-ne CFC; filire dveloppement d\'applications');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (1, 'informaticienEntreprise', 'Informaticien-ne CFC; filière entreprise');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (2, 'informaticienSysteme', 'Informaticien-ne CFC; filière technique des systèmes');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (3, 'informaticienDev', 'Informaticien-ne CFC; filière dèveloppement d\'applications');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (4, 'laborantinBiologie', 'Laborantin-e CFC; option biologie');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (5, 'laborantinChimie', 'Laborantin-e CFC; option chimie');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (6, 'laborantinPhysique', 'Laborantin-e CFC; option physique');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (14, 'logisticien', 'Logisticien-ne CFC');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (15, 'planificateurElectricien', 'Planificateur-trice lctricien-ne CFC');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (15, 'planificateurElectricien', 'Planificateur-trice éléctricien-ne CFC');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (16, 'electronicien', 'Electronicien-ne CFC');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (17, 'polyMecanicien', 'Polymcanicien-ne CFC');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (18, 'employeCommerce', 'Employ-e de commerce CFC');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (17, 'polyMecanicien', 'Polymécanicien-ne CFC');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (18, 'employeCommerce', 'Employé-e de commerce CFC');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (19, 'gardienAnimaux', 'Gardien-ne d\'animaux CFC');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (20, 'interactiveMediaDesigner', 'Interactive Media Designer CFC');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (21, 'informaticien', 'Informaticien-ne CFC; pas de filire prfre');
INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (21, 'informaticien', 'Informaticien-ne CFC; pas de filière préfèrèe');
......@@ -2,4 +2,4 @@ INSERT INTO `status` (`status_value`) VALUES ('Nouveau');
INSERT INTO `status` (`status_value`) VALUES ('Valide');
INSERT INTO `status` (`status_value`) VALUES ('Incomplet');
INSERT INTO `status` (`status_value`) VALUES ('Invalide');
INSERT INTO `status` (`status_value`) VALUES ('Refus');
INSERT INTO `status` (`status_value`) VALUES ('Refusé');
-- MySQL Script generated by MySQL Workbench
-- Thu Apr 18 09:44:04 2019
-- Tue May 7 09:00:54 2019
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
......@@ -295,3 +295,18 @@ CREATE TABLE IF NOT EXISTS `canap_db`.`training` (
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `canap_db`.`last_connection`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `canap_db`.`last_connection` ;
CREATE TABLE IF NOT EXISTS `canap_db`.`last_connection` (
`last_connection_id` INT NOT NULL AUTO_INCREMENT,
`last_connection_sciper` VARCHAR(10) NOT NULL,
`last_connection_date` DATETIME NOT NULL,
`last_connection_tmp_date` DATETIME NULL,
PRIMARY KEY (`last_connection_id`),
UNIQUE INDEX `last_connection_sciper_UNIQUE` (`last_connection_sciper` ASC))
ENGINE = InnoDB;
\ No newline at end of file
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -19,9 +19,11 @@ import MainFooter from '@/layouts/MainFooter.vue'
import alertSnackbar from '@/components/alertSnackbar.vue'
export default {
created () {
created() {
if (!this.$store.getters['moduleUser/userIsLogedIn']) {
this.$store.dispatch('moduleUser/login')
} else {
this.$store.dispatch('moduleUser/getLastConnection')
}
},
components: {
......
......@@ -32,6 +32,6 @@ export function getResponsibleNewApplications(state) {
return state.applications.filter(x => x.fk_status == 'Nouveau')
}
export function getFormateurNewApplications(state) {
return state.applications
export function getFormateurNewApplications(state, getters, rootState) {
return state.applications.filter(x => x.applicant_application_date > rootState.moduleUser.lastConnection.last_connection_date)
}
\ No newline at end of file
......@@ -11,15 +11,19 @@ export function login() {
} else {
localStorage.setItem('stored_token', response.data.token);
location.reload()
// setLastConnection().then(() => {
// })
}
})
}
export function logout(context, fullLogout) {
localStorage.removeItem('stored_token');
if (fullLogout) {
window.location = 'https://tequila.epfl.ch/logout'
}
setLastConnection().then(() => {
localStorage.removeItem('stored_token');
if (fullLogout) {
window.location = 'https://tequila.epfl.ch/logout'
}
})
}
export function getUserData(context) {
......@@ -46,4 +50,24 @@ export function getUserPermittedJobs(context) {
.then(response => {
context.commit('setPermittedJobs', response.data)
})
}
export function getLastConnection(context) {
axios({
method: 'get',
url: '/user/connection'
})
.then(response => {
context.commit('setLastConnection', response.data.last_connection)
})
}
export function setLastConnection() {
return new Promise((resolve) => {
axios({
method: 'patch',
url: '/user/connection'
})
.then(resolve())
})
}
\ No newline at end of file
......@@ -4,4 +4,8 @@ export function setUserData(state, data) {
export function setPermittedJobs(state, data) {
state.permittedJobs = data
}
export function setLastConnection(state, data) {
state.lastConnection = data
}
\ No newline at end of file
......@@ -10,5 +10,6 @@ export default {
role: '',
permissions: []
},
permittedJobs: []
permittedJobs: [],
lastConnection: {}
}
\ No newline at end of file
......@@ -27,7 +27,10 @@
:search="$store.state.moduleApplications.filters.search"
>
<template v-slot:items="props">
<tr :class="props.item.fk_status === 'Nouveau' ? 'isNew' : ''">
<span></span>
<tr
:class="{ isNew: isNew(props.item.fk_status, props.item.applicant_application_date) }"
>
<td v-if="$store.getters['moduleUser/userIsResponsible']">
<v-checkbox v-model="props.selected" hide-details color="primary"></v-checkbox>
</td>
......@@ -160,6 +163,13 @@ export default {
})
this.$store.dispatch('moduleApplications/getApplications')
}
},
isNew(status, date) {
if (this.$store.getters['moduleUser/userIsResponsible']) {
return status === 'Nouveau'
} else {
return date > this.$store.state.moduleUser.lastConnection.last_connection_date
}
}
},
components: {
......
......@@ -3,10 +3,13 @@
<h1>Accueil</h1>
<v-container id="grid" fluid grid-list-sm tag="section">
<v-layout row wrap>
<v-flex d-flex xs12 order-xs5>
<v-layout column>
<h2><router-link to="applications">{{applicationNumber}} nouvelles candidatures</router-link> à traiter</h2>
</v-layout>
<v-flex d-flex xs12 order-xs5 v-if="applicationNumber">
<v-alert
style="cursor: pointer;"
:value="true"
type="info"
@click="$router.push('/applications')"
>Il y a <b>{{applicationNumber}}</b> nouvelles candidatures à traiter depuis votre dernière connexion.</v-alert>
</v-flex>
</v-layout>
</v-container>
......
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