Commit 2fbd4fdd authored by Gabriel Moreau's avatar Gabriel Moreau
Browse files

Update table intervention

parent 90f26a38
......@@ -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 `interventions` (
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`),
......@@ -22,7 +22,7 @@ if ($mode == 'Ajouter') {
en_tete('Ajouter une intervention');
} else if ($mode == 'Modifier') {
en_tete('Modifier une intervention');
$intervention_fetch = get_interventions_all_by_equipment($pdo, $equipment_id);
$intervention_fetch = get_intervention_listall_by_equipment($pdo, $equipment_id);
}
?>
......
......@@ -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
// ---------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment