Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
legi
soft
gestex
Commits
9ed64945
Commit
9ed64945
authored
Oct 03, 2020
by
Gabriel Moreau
Browse files
Bug when summit datasheet
parent
9b96ebd3
Changes
3
Hide whitespace changes
Inline
Side-by-side
equipment-create.php
View file @
9ed64945
...
...
@@ -84,6 +84,8 @@ if ($pdo = connect_db()) {
echo
'Erreur : '
.
$err_msg
.
'<br>'
;
if
(
$notice
!=
''
)
$id_datasheet
=
set_datasheet_new
(
$pdo
,
$id_equipment
,
$_FILES
[
"notice"
][
"name"
],
$_FILES
[
"notice"
][
"tmp_name"
]);
if
(
!
$id_datasheet
)
echo
'Erreur : la notice n\'est pas prise en compte car elle n\'est pas un fichier au format PDF !<br>'
;
}
//end if connect
echo
'<br>Ajout de '
.
$nom
.
' validée'
;
...
...
equipment-update.php
View file @
9ed64945
...
...
@@ -99,7 +99,8 @@ if ($pdo = connect_db()) {
echo
'Erreur : '
.
$err_msg
.
'<br>'
;
if
(
$notice
!=
''
)
{
$id_datasheet
=
set_datasheet_new
(
$pdo
,
$id_equipment
,
$_FILES
[
"notice"
][
"name"
],
$_FILES
[
"notice"
][
"tmp_name"
]);
echo
"New datasheet "
.
$id_equipment
.
" number # "
.
$id_datasheet
;
if
(
!
$id_datasheet
)
echo
'Erreur : la notice n\'est pas prise en compte car elle n\'est pas un fichier au format PDF !<br>'
;
}
}
// end if modif
else
{
...
...
module/db-functions.php
View file @
9ed64945
...
...
@@ -95,19 +95,20 @@ function get_datasheet_count_by_equipment($pdo, $id_equipment) {
// ---------------------------------------------------------------------
function
set_datasheet_new
(
$pdo
,
$equipment_id
,
$
equipment_name
,
$tmp_file
)
{
if
(
!
preg_match
(
'/\.pdf$/i'
,
$
tmp_file
))
function
set_datasheet_new
(
$pdo
,
$equipment_id
,
$
datasheet_filename_upload
,
$tmp_file
)
{
if
(
!
preg_match
(
'/\.pdf$/i'
,
$
datasheet_filename_upload
))
return
false
;
$new_datasheet_path
=
'./data/datasheet'
;
if
(
!
is_dir
(
$new_datasheet_path
))
mkdir
(
$new_datasheet_path
,
0755
);
$datasheet_filename_kebab
=
string_to_filename_kebab
(
$equipment_name
);
$datasheet_filename_kebab
=
string_to_filename_kebab
(
$datasheet_filename_upload
);
$datasheet_filename_no_ext
=
pathinfo
(
$datasheet_filename_upload
,
PATHINFO_FILENAME
);
$sql1
=
'INSERT INTO datasheet (description, id_equipment) VALUES (?, ?);'
;
$stmt1
=
$pdo
->
prepare
(
$sql1
);
$stmt1
->
execute
(
array
(
$
equipment_name
,
$equipment_id
));
$stmt1
->
execute
(
array
(
$
datasheet_filename_no_ext
,
$equipment_id
));
$id_datasheet
=
$pdo
->
lastInsertId
();
$sub_path
=
$id_datasheet
.
'-'
.
random_string
(
8
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment