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
7b8a0786
Commit
7b8a0786
authored
6 years ago
by
nicrausaz
Browse files
Options
Downloads
Patches
Plain Diff
insert if new items on edit working
parent
de3ece98
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
canapEPFL/helpers.php
+44
-28
44 additions, 28 deletions
canapEPFL/helpers.php
with
44 additions
and
28 deletions
canapEPFL/helpers.php
+
44
−
28
View file @
7b8a0786
...
@@ -324,6 +324,7 @@ function updatePostulation ($pdo, $posted_data) {
...
@@ -324,6 +324,7 @@ function updatePostulation ($pdo, $posted_data) {
$sqlreq
=
"UPDATE applicant
$sqlreq
=
"UPDATE applicant
SET
SET
applicant_maturity= :applicant_maturity,
applicant_maturity= :applicant_maturity,
applicant_it_section=:applicant_it_section,
applicant_gender= :applicant_gender,
applicant_gender= :applicant_gender,
applicant_address_street= :applicant_address_street,
applicant_address_street= :applicant_address_street,
applicant_address_npa= :applicant_address_npa,
applicant_address_npa= :applicant_address_npa,
...
@@ -352,6 +353,7 @@ function updatePostulation ($pdo, $posted_data) {
...
@@ -352,6 +353,7 @@ function updatePostulation ($pdo, $posted_data) {
$query
=
$pdo
->
prepare
(
$sqlreq
);
$query
=
$pdo
->
prepare
(
$sqlreq
);
$query
->
bindParam
(
':id'
,
$posted_data
->
id
,
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':id'
,
$posted_data
->
id
,
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':applicant_maturity'
,
$posted_data
->
maturite
,
PDO
::
PARAM_BOOL
);
$query
->
bindParam
(
':applicant_maturity'
,
$posted_data
->
maturite
,
PDO
::
PARAM_BOOL
);
$query
->
bindParam
(
':applicant_it_section'
,
$posted_data
->
filiere
,
PDO
::
PARAM_BOOL
);
$query
->
bindParam
(
':applicant_gender'
,
$posted_data
->
genreApprenti
,
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':applicant_gender'
,
$posted_data
->
genreApprenti
,
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':applicant_address_street'
,
$posted_data
->
addresseApprentiComplete
[
'rue'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':applicant_address_street'
,
$posted_data
->
addresseApprentiComplete
[
'rue'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':applicant_address_npa'
,
$posted_data
->
addresseApprentiComplete
[
'NPA'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':applicant_address_npa'
,
$posted_data
->
addresseApprentiComplete
[
'NPA'
],
PDO
::
PARAM_STR
);
...
@@ -412,54 +414,69 @@ function updatePostulation ($pdo, $posted_data) {
...
@@ -412,54 +414,69 @@ function updatePostulation ($pdo, $posted_data) {
}
}
// update scolarities
// update scolarities
$to_add
=
[];
$sqlreq
=
"UPDATE scolarity SET scolarity_school=:scolarity_school, scolarity_location=:scolarity_location, scolarity_level=:scolarity_level, scolarity_years=:scolarity_years
$sqlreq
=
"UPDATE scolarity SET scolarity_school=:scolarity_school, scolarity_location=:scolarity_location, scolarity_level=:scolarity_level, scolarity_years=:scolarity_years
WHERE fk_applicant_id=:applicant_id AND scolarity_id=:scolarity_id"
;
WHERE fk_applicant_id=:applicant_id AND scolarity_id=:scolarity_id"
;
foreach
(
$posted_data
->
scolarite
as
$scolarity
)
{
foreach
(
$posted_data
->
scolarite
as
$scolarity
)
{
$query
=
$pdo
->
prepare
(
$sqlreq
);
if
(
isset
(
$scolarity
[
'id'
]))
{
$query
->
bindParam
(
':applicant_id'
,
$posted_data
->
id
,
PDO
::
PARAM_INT
);
$query
=
$pdo
->
prepare
(
$sqlreq
);
$query
->
bindParam
(
':scolarity_id'
,
$scolarity
[
'id'
],
PDO
::
PARAM_INT
);
$query
->
bindParam
(
':applicant_id'
,
$posted_data
->
id
,
PDO
::
PARAM_INT
);
$query
->
bindParam
(
':scolarity_school'
,
$scolarity
[
'ecole'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':scolarity_id'
,
$scolarity
[
'id'
],
PDO
::
PARAM_INT
);
$query
->
bindParam
(
':scolarity_location'
,
$scolarity
[
'lieu'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':scolarity_school'
,
$scolarity
[
'ecole'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':scolarity_level'
,
$scolarity
[
'niveau'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':scolarity_location'
,
$scolarity
[
'lieu'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':scolarity_years'
,
$scolarity
[
'annees'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':scolarity_level'
,
$scolarity
[
'niveau'
],
PDO
::
PARAM_STR
);
$query
->
execute
();
$query
->
bindParam
(
':scolarity_years'
,
$scolarity
[
'annees'
],
PDO
::
PARAM_STR
);
$query
->
execute
();
}
else
{
array_push
(
$to_add
,
$scolarity
);
}
}
}
insertScolarities
(
$pdo
,
$to_add
,
$posted_data
->
id
);
// TODO: si y en a des nouveaux ?
// update pro activities
// update pro activities
$to_add
=
[];
$sqlreq
=
"UPDATE professional_activity SET professional_activity_company=:professional_activity_company, professional_activity_location=:professional_activity_location, professional_activity_activity=:professional_activity_activity, professional_activity_years=:professional_activity_years
$sqlreq
=
"UPDATE professional_activity SET professional_activity_company=:professional_activity_company, professional_activity_location=:professional_activity_location, professional_activity_activity=:professional_activity_activity, professional_activity_years=:professional_activity_years
WHERE fk_applicant_id=:applicant_id AND professional_activity_id=:professional_activity_id"
;
WHERE fk_applicant_id=:applicant_id AND professional_activity_id=:professional_activity_id"
;
foreach
(
$posted_data
->
activitesProfessionnelles
as
$activity
)
{
foreach
(
$posted_data
->
activitesProfessionnelles
as
$activity
)
{
$query
=
$pdo
->
prepare
(
$sqlreq
);
if
(
isset
(
$activity
[
'id'
]))
{
$query
->
bindParam
(
':applicant_id'
,
$posted_data
->
id
,
PDO
::
PARAM_INT
);
$query
=
$pdo
->
prepare
(
$sqlreq
);
$query
->
bindParam
(
':professional_activity_id'
,
$activity
[
'id'
],
PDO
::
PARAM_INT
);
$query
->
bindParam
(
':applicant_id'
,
$posted_data
->
id
,
PDO
::
PARAM_INT
);
$query
->
bindParam
(
':professional_activity_company'
,
$activity
[
'employeur'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':professional_activity_id'
,
$activity
[
'id'
],
PDO
::
PARAM_INT
);
$query
->
bindParam
(
':professional_activity_location'
,
$activity
[
'lieu'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':professional_activity_company'
,
$activity
[
'employeur'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':professional_activity_activity'
,
$activity
[
'activite'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':professional_activity_location'
,
$activity
[
'lieu'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':professional_activity_years'
,
$activity
[
'annees'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':professional_activity_activity'
,
$activity
[
'activite'
],
PDO
::
PARAM_STR
);
$query
->
execute
();
$query
->
bindParam
(
':professional_activity_years'
,
$activity
[
'annees'
],
PDO
::
PARAM_STR
);
$query
->
execute
();
}
else
{
array_push
(
$to_add
,
$activity
);
}
}
}
insertProActivities
(
$pdo
,
$to_add
,
$posted_data
->
id
);
// TODO: si y en a des nouveaux ?
// update trainings
// update trainings
$to_add
=
[];
$sqlreq
=
"UPDATE training SET training_job=:training_job, training_company=:training_company
$sqlreq
=
"UPDATE training SET training_job=:training_job, training_company=:training_company
WHERE fk_applicant_id=:applicant_id AND training_id=:training_id"
;
WHERE fk_applicant_id=:applicant_id AND training_id=:training_id"
;
foreach
(
$posted_data
->
stages
as
$training
)
{
foreach
(
$posted_data
->
stages
as
$training
)
{
$query
=
$pdo
->
prepare
(
$sqlreq
);
if
(
isset
(
$training
[
'id'
]))
{
$query
->
bindParam
(
':applicant_id'
,
$posted_data
->
id
,
PDO
::
PARAM_INT
);
$query
=
$pdo
->
prepare
(
$sqlreq
);
$query
->
bindParam
(
':training_id'
,
$training
[
'id'
],
PDO
::
PARAM_INT
);
$query
->
bindParam
(
':applicant_id'
,
$posted_data
->
id
,
PDO
::
PARAM_INT
);
$query
->
bindParam
(
':training_company'
,
$training
[
'metier'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':training_id'
,
$training
[
'id'
],
PDO
::
PARAM_INT
);
$query
->
bindParam
(
':training_job'
,
$training
[
'employeur'
],
PDO
::
PARAM_STR
);
$query
->
bindParam
(
':training_company'
,
$training
[
'metier'
],
PDO
::
PARAM_STR
);
$query
->
execute
();
$query
->
bindParam
(
':training_job'
,
$training
[
'employeur'
],
PDO
::
PARAM_STR
);
$query
->
execute
();
}
else
{
array_push
(
$to_add
,
$training
);
}
}
}
insertTrainings
(
$pdo
,
$to_add
,
$posted_data
->
id
);
echo
"<pre>"
;
// TODO: files
// TODO: files
echo
"<pre>"
;
foreach
(
$posted_files
as
$key
=>
$file
)
{
foreach
(
$posted_files
as
$key
=>
$file
)
{
if
(
$file
[
'name'
]
!=
''
)
{
if
(
$file
[
'name'
]
!=
''
)
{
...
@@ -472,7 +489,6 @@ foreach ($posted_files as $key => $file) {
...
@@ -472,7 +489,6 @@ foreach ($posted_files as $key => $file) {
// if ($_FILES['file'.$i]['name']) {
// if ($_FILES['file'.$i]['name']) {
// $file_data = getOneFile($pdo, $posted_data['file_id'.$i], $id);
// $file_data = getOneFile($pdo, $posted_data['file_id'.$i], $id);
// if (move_uploaded_file($_FILES['file'.$i]['tmp_name'], $file_data['file_path'])) {
// if (move_uploaded_file($_FILES['file'.$i]['tmp_name'], $file_data['file_path'])) {
// } else {
// } else {
// // Le fichier est ouvert
// // Le fichier est ouvert
// $_SESSION['edit_error']['files'] = "Erreur lors du remplacement du fichier" . $_FILES['file'.$i]['name'] . ", réessayez plus tard.";
// $_SESSION['edit_error']['files'] = "Erreur lors du remplacement du fichier" . $_FILES['file'.$i]['name'] . ", réessayez plus tard.";
...
...
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