Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
legi
soft
gestex
Commits
2fbd4fdd
Commit
2fbd4fdd
authored
Jul 08, 2021
by
Gabriel Moreau
Browse files
Update table intervention
parent
90f26a38
Changes
3
Hide whitespace changes
Inline
Side-by-side
db-upgrade-4-5.sql
View file @
2fbd4fdd
...
...
@@ -8,6 +8,8 @@
--
ALTER
TABLE
`listing`
MODIFY
COLUMN
`barcode`
BIGINT
DEFAULT
NULL
;
ALTER
TABLE
`listing`
ADD
COLUMN
`max_loan_day`
INT
(
11
)
NOT
NULL
DEFAULT
0
;
UPDATE
`listing`
SET
`max_loan_day`
=
0
;
-- TIMESTAMP =< MySQL 5.5.x < DATETIME
...
...
@@ -20,18 +22,17 @@ UPDATE `pret` SET `status` = 'LOAN_BORROWED';
-- Fix global DB version
--
UPDATE
version
SET
version
=
5
WHERE
soft
=
'database'
;
UPDATE
`
version
`
SET
`
version
`
=
5
WHERE
`
soft
`
=
'database'
;
RENAME
TABLE
`intervention`
TO
`old_intervention`
;
CREATE
TABLE
IF
NOT
EXISTS
`intervention
s
`
(
id
INT
(
11
)
PRIMARY
KEY
NOT
NULL
AUTO_INCREMENT
,
supplier_id
INT
NOT
NULL
,
listing
_id
INT
NOT
NULL
,
description
VARCHAR
(
255
)
DEFAULT
NULL
,
date
DATE
NOT
NULL
DEFAULT
CURRENT_DATE
,
KEY
`company_id`
(
`supplier_
id`
),
FOREIGN
KEY
(
f_
supplier
)
REFERENCES
fournisseurs
(
id
),
FOREIGN
KEY
(
f_listing
)
REFERENCES
listing
(
id
)
CREATE
TABLE
IF
NOT
EXISTS
`intervention`
(
`
id
`
INT
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`
supplier_id
`
INT
(
11
)
NOT
NULL
,
`equipment
_id
`
INT
(
11
)
NOT
NULL
,
`
description
`
VARCHAR
(
255
)
DEFAULT
NULL
,
`
date
`
DATE
NOT
NULL
DEFAULT
CURRENT_DATE
,
PRIMARY
KEY
(
`
id`
),
FOREIGN
KEY
(
`
supplier
_id`
)
REFERENCES
`
fournisseurs
`
(
`
id
`
),
FOREIGN
KEY
(
`equipment_id`
)
REFERENCES
`
listing
`
(
`
id
`
)
)
ENGINE
=
MyISAM
AUTO_INCREMENT
=
700
CHARSET
=
utf8
;
ALTER
TABLE
listing
ADD
COLUMN
max_loan_day
INT
NOT
NULL
DEFAULT
0
;
\ No newline at end of file
-- KEY `company_id` (`supplier_id`),
intervention-edit.php
View file @
2fbd4fdd
...
...
@@ -22,7 +22,7 @@ if ($mode == 'Ajouter') {
en_tete
(
'Ajouter une intervention'
);
}
else
if
(
$mode
==
'Modifier'
)
{
en_tete
(
'Modifier une intervention'
);
$intervention_fetch
=
get_intervention
s
_all_by_equipment
(
$pdo
,
$equipment_id
);
$intervention_fetch
=
get_intervention_
list
all_by_equipment
(
$pdo
,
$equipment_id
);
}
?>
...
...
module/db-functions.php
View file @
2fbd4fdd
...
...
@@ -132,26 +132,6 @@ function check_val_in_db($pdo, $table, $col, $value) {
return
false
;
}
// ---------------------------------------------------------------------
// Intervention
// ---------------------------------------------------------------------
/**
* Récupère tout le contenu des intervention appartenant à un
* équipement
*
* @return false|array
*/
function
get_interventions_all_by_equipment
(
$pdo
,
$equipment_id
)
{
$sql
=
'SELECT * FROM interventions WHERE f_listing = ?;'
;
$stmt
=
$pdo
->
prepare
(
$sql
);
$stmt
->
execute
(
array
(
$equipment_id
));
$intervention_fetch
=
$stmt
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
if
(
count
(
$intervention_fetch
)
>
0
)
return
$intervention_fetch
;
return
false
;
}
// ---------------------------------------------------------------------
// Category
// ---------------------------------------------------------------------
...
...
@@ -564,6 +544,26 @@ function del_equipment_by_id($pdo, $id) {
return
$iostat
;
}
// ---------------------------------------------------------------------
// Intervention
// ---------------------------------------------------------------------
/**
* Récupère tout le contenu des intervention appartenant à un
* équipement
*
* @return false|array
*/
function
get_intervention_listall_by_equipment
(
$pdo
,
$equipment_id
)
{
$sql
=
'SELECT * FROM intervention WHERE equipment_id = ?;'
;
$stmt
=
$pdo
->
prepare
(
$sql
);
$stmt
->
execute
(
array
(
$equipment_id
));
$intervention_fetch
=
$stmt
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
if
(
count
(
$intervention_fetch
)
>
0
)
return
$intervention_fetch
;
return
false
;
}
// ---------------------------------------------------------------------
// Loan
// ---------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
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