Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
canap
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SI-FSD
canap
Commits
c71058cd
Commit
c71058cd
authored
6 years ago
by
nicrausaz
Browse files
Options
Downloads
Patches
Plain Diff
insert & upload working
parent
d9e850e1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
canapEPFL/cible.php
+18
-23
18 additions, 23 deletions
canapEPFL/cible.php
canapEPFL/helpers.php
+21
-23
21 additions, 23 deletions
canapEPFL/helpers.php
canapEPFL/models/PersonnalData.php
+6
-7
6 additions, 7 deletions
canapEPFL/models/PersonnalData.php
with
45 additions
and
53 deletions
canapEPFL/cible.php
+
18
−
23
View file @
c71058cd
<!doctype html>
<html
lang=
"fr"
>
<head>
<?php
include
(
"templates/head.php"
);
include
(
'templates/isPostulationOpen.php'
);
require_once
(
"helpers.php"
);
require_once
(
"models/PersonnalData.php"
);
require_once
(
"models/PersonnalDataValidator.php"
);
?>
<title>
Postulation Apprentis | Confirmation
</title>
</head>
<body>
<head>
<?php
include
(
"templates/head.php"
);
include
(
'templates/isPostulationOpen.php'
);
require_once
(
"helpers.php"
);
require_once
(
"models/PersonnalData.php"
);
require_once
(
"models/PersonnalDataValidator.php"
);
?>
<title>
Postulation Apprentis | Confirmation
</title>
</head>
<body>
<?php
include
(
'templates/header.php'
);
// Init personnalData with postedData
...
...
@@ -18,18 +18,13 @@
// Init dataValidator
$validator
=
new
PersonnalDataValidator
(
$candidateData
);
if
(
$validator
->
isValid
()){
// Create folders
createCandidateFolders
(
$candidateData
);
// Upload files
$candidateData
=
uploadAllFiles
(
$candidateData
->
getPaths
()[
"pathAnnexes"
],
$candidateData
->
tmp_fichiers
,
$candidateData
);
// Create JSON file and upload it
$encodedJson
=
(
json_encode
(
$candidateData
,
JSON_UNESCAPED_UNICODE
|
JSON_PRETTY_PRINT
));
file_put_contents
(
$candidateData
->
getPaths
()[
"pathInfos"
]
.
'/informations.json'
,
$encodedJson
);
if
(
$validator
->
isValid
())
{
// write in DB
insertDataIntoDB
(
$pdo
,
$candidateData
);
// Send mails
$candidateId
=
insertDataIntoDB
(
$pdo
,
$candidateData
);
$filesPath
=
createFilesFolder
(
$candidateData
->
rootpath
,
$candidateId
);
$candidateData
=
uploadAllFiles
(
$filesPath
,
$candidateData
->
fichiers
,
$candidateData
);
insertFiles
(
$pdo
,
$candidateData
->
fichiers
,
$candidateId
,
$candidateData
->
rootpath
);
// mailToResp($candidateData->prenomApprenti, $candidateData->nomApprenti, $candidateData->formation);
// mailToApprenti($candidateData->mailApprenti, $candidateData->formation);
...
...
@@ -45,5 +40,5 @@
include
(
"templates/errorText.php"
);
}
?>
</body>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
canapEPFL/helpers.php
+
21
−
23
View file @
c71058cd
...
...
@@ -18,60 +18,58 @@ function mailToApprenti($to, $job){
mail
(
$to
,
$subject
,
$message
,
$headers
);
}
function
uploadFile
(
&
$candidateData
,
$pathAnnexes
,
$file
,
$name
){
function
uploadFile
(
&
$candidateData
,
$pathAnnexes
,
$file
,
$key
,
$name
){
$extension
=
strtolower
(
strrchr
(
$file
[
'name'
],
'.'
));
$file
[
'name'
]
=
$name
.
$extension
;
move_uploaded_file
(
$file
[
'tmp_name'
],
$pathAnnexes
.
$file
[
'name'
]);
$candidateData
->
fichiers
[
$name
]
=
$file
[
'name'
];
unset
(
$candidateData
->
fichiers
[
$key
]);
}
//Crée le dossier principal est ses 2 sous-dossiers
function
createCandidateFolders
(
$candidateData
){
$paths
=
$candidateData
->
getPaths
();
if
(
!
mkdir
(
$paths
[
"pathInfos"
],
0777
,
true
)){
die
(
'Echec lors de la création du dossier informations'
);
}
if
(
!
mkdir
(
$paths
[
"pathAnnexes"
],
0777
,
true
)){
die
(
'Echec lors de la création du dossier annexes'
);
}
// Crée le dossier annexes
function
createFilesFolder
(
$rootpath
,
$applicantId
)
{
$path
=
$rootpath
.
$applicantId
.
"/"
;
if
(
!
mkdir
(
$path
,
0777
,
true
))
{
die
(
'Echec lors de la création du dossier'
);
}
return
$path
;
}
function
uploadAllFiles
(
$pathAnnexes
,
$postedFiles
,
$candidateData
){
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'photo'
],
"photo-passeport"
);
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'idCard'
],
"carte-identite"
);
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'cv'
],
"curriculum-vitae"
);
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'lettre'
],
"lettre-motivation"
);
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'photo'
],
'photo'
,
"photo-passeport"
);
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'idCard'
],
'idCard'
,
"carte-identite"
);
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'cv'
],
'cv'
,
"curriculum-vitae"
);
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'lettre'
],
'lettre'
,
"lettre-motivation"
);
for
(
$i
=
1
;
$i
<=
9
;
$i
++
){
if
(
array_key_exists
(
'certifs'
.
$i
,
$postedFiles
)){
if
(
!
(
$postedFiles
[
'certifs'
.
$i
][
'name'
]
==
""
))
{
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'certifs'
.
$i
],
"annexe"
.
$i
);
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'certifs'
.
$i
],
'certifs'
.
$i
,
"annexe"
.
$i
);
}
}
}
if
(
$candidateData
->
formation
==
"polyMecanicien"
&&
isset
(
$postedFiles
[
'gimch'
])){
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'gimch'
],
"certificat-gimch"
);
if
(
$candidateData
->
formation
==
"polyMecanicien"
&&
isset
(
$postedFiles
[
'gimch'
]))
{
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'gimch'
],
'gimch'
,
"certificat-gimch"
);
}
if
(
$candidateData
->
formation
==
"informaticien"
&&
isset
(
$postedFiles
[
'griTestInput'
])){
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'griTestInput'
],
"certificat-gri"
);
if
(
$candidateData
->
formation
==
"informaticien"
&&
isset
(
$postedFiles
[
'griTestInput'
]))
{
uploadFile
(
$candidateData
,
$pathAnnexes
,
$postedFiles
[
'griTestInput'
],
'griTestInput'
,
"certificat-gri"
);
}
unset
(
$candidateData
->
tmp_fichiers
);
return
$candidateData
;
}
#region [DB Interactions]
function
insertDataIntoDB
(
$pdo
,
$candidateData
)
{
echo
"<pre>"
;
print_r
(
$candidateData
);
$id
=
insertPersonalInfos
(
$pdo
,
$candidateData
);
insertResponsibles
(
$pdo
,
$candidateData
->
representants
,
$id
);
insertScolarities
(
$pdo
,
$candidateData
->
scolarite
,
$id
);
insertProActivities
(
$pdo
,
$candidateData
->
activitesProfessionnelles
,
$id
);
insertTrainings
(
$pdo
,
$candidateData
->
stages
,
$id
);
insertFiles
(
$pdo
,
$candidateData
->
fichiers
,
$id
,
$candidateData
->
rootpath
);
return
$id
;
}
function
insertPersonalInfos
(
$pdo
,
$candidateData
)
{
...
...
This diff is collapsed.
Click to expand it.
canapEPFL/models/PersonnalData.php
+
6
−
7
View file @
c71058cd
...
...
@@ -47,7 +47,6 @@ class PersonnalData {
public
$anneeCandidature
=
""
;
public
$datePostulation
=
""
;
public
$fichiers
=
[];
public
$tmp_fichiers
=
[];
public
function
__construct
(
$postedData
,
$postedFiles
)
{
$this
->
dateNow
=
date
(
'Y-m-d_H-i-s'
);
...
...
@@ -84,23 +83,23 @@ class PersonnalData {
$this
->
setDejacand
();
$this
->
anneeFinScolarite
=
$postedData
[
'anneeFin'
];
$this
->
datePostulation
=
date
(
'j-n-o--'
.
'h:i:s'
);
$this
->
tmp_
fichiers
=
$this
->
setFiles
(
$postedFiles
);
$this
->
fichiers
=
$this
->
setFiles
(
$postedFiles
);
}
private
function
setRepresentants
(){
$rep1
=
array
(
"genre"
=>
$this
->
postedData
[
'genreRep1'
],
"nom"
=>
$this
->
postedData
[
'nameRep1'
],
"prenom"
=>
$this
->
postedData
[
'surnameRep1'
],
"addresse"
=>
array
(
"rue"
=>
$this
->
postedData
[
'adrRep1'
],
"NPA"
=>
$this
->
postedData
[
'NPARep1'
]),
"telephone"
=>
$this
->
postedData
[
'telRep1'
]);
$rep2
=
array
(
"genre"
=>
$this
->
postedData
[
'genreRep2'
],
"nom"
=>
$this
->
postedData
[
'nameRep2'
],
"prenom"
=>
$this
->
postedData
[
'surnameRep2'
],
"addresse"
=>
array
(
"rue"
=>
$this
->
postedData
[
'adrRep2'
],
"NPA"
=>
$this
->
postedData
[
'NPARep2'
]),
"telephone"
=>
$this
->
postedData
[
'telRep2'
]);
if
(
$rep1
){
if
(
$rep1
)
{
array_push
(
$this
->
representants
,
$rep1
);
}
if
(
$rep2
){
if
(
$rep2
)
{
array_push
(
$this
->
representants
,
$rep2
);
}
}
private
function
setScolarite
(){
for
(
$i
=
1
;
$i
<=
5
;
$i
++
)
{
if
(
array_key_exists
(
'ecole'
.
$i
,
$this
->
postedData
)){
if
(
array_key_exists
(
'ecole'
.
$i
,
$this
->
postedData
))
{
array_push
(
$this
->
scolarite
,
array
(
"ecole"
=>
$this
->
postedData
[
'ecole'
.
$i
],
"lieu"
=>
$this
->
postedData
[
'lieuEcole'
.
$i
],
"niveau"
=>
$this
->
postedData
[
'niveauEcole'
.
$i
],
"annees"
=>
$this
->
postedData
[
'anneesEcole'
.
$i
]));
}
}
...
...
@@ -125,8 +124,8 @@ class PersonnalData {
$this
->
anneeCandidature
=
$this
->
postedData
[
'dejaCandAnnee'
];
}
}
public
function
setLanguages
(
$languages
){
if
(
isset
(
$languages
)
&&
is_array
(
$languages
)){
public
function
setLanguages
(
$languages
)
{
if
(
isset
(
$languages
)
&&
is_array
(
$languages
))
{
$this
->
connaissancesLinguistiques
=
$languages
;
}
else
{
$this
->
connaissancesLinguistiques
=
[];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment