Commit 4dacf181 authored by Estéban Ristich's avatar Estéban Ristich
Browse files

Fix Issue #69 save max day in database

parent 01a82fa4
...@@ -33,6 +33,7 @@ $reparation = param_post('reparation'); ...@@ -33,6 +33,7 @@ $reparation = param_post('reparation');
$accessoires = param_post('accessoires'); $accessoires = param_post('accessoires');
$inventaire = param_post('inventaire'); $inventaire = param_post('inventaire');
$barcode = param_post('barcode'); $barcode = param_post('barcode');
$max_loan_day = param_post('max-loan-day', 0);
$loanable = param_post('loanable'); $loanable = param_post('loanable');
//variables ne pouvant etre nulles //variables ne pouvant etre nulles
if (empty($categorie)) if (empty($categorie))
...@@ -74,7 +75,7 @@ if (!empty($erreur)) { ...@@ -74,7 +75,7 @@ if (!empty($erreur)) {
$pdo = connect_db_or_alert(); $pdo = connect_db_or_alert();
if ($flag_new) { // new if ($flag_new) { // new
list($equipment_id, $err_msg) = set_equipment_new($pdo, $categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable); list($equipment_id, $err_msg) = set_equipment_new($pdo, $categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable, $max_loan_day);
if ($err_msg != '') { if ($err_msg != '') {
$message_alert = ($logged_level > 3 ? $err_msg : ''); $message_alert = ($logged_level > 3 ? $err_msg : '');
include_once('include/alert-data.php'); include_once('include/alert-data.php');
...@@ -117,11 +118,12 @@ if ( ($categorie != $equipment_selected['categorie']) ...@@ -117,11 +118,12 @@ if ( ($categorie != $equipment_selected['categorie'])
|| ($inventaire != $equipment_selected['inventaire']) || ($inventaire != $equipment_selected['inventaire'])
|| ($notice != $equipment_selected['notice']) || ($notice != $equipment_selected['notice'])
|| ($barcode != $equipment_selected['barcode']) || ($barcode != $equipment_selected['barcode'])
|| ($loanable != $equipment_selected['loanable'])) || ($loanable != $equipment_selected['loanable'])
|| ($max_loan_day != $equipment_selected['max_loan_day']))
$modif = true; $modif = true;
if ($modif) { if ($modif) {
$err_msg = set_equipment_update($pdo, $equipment_id, $categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable); $err_msg = set_equipment_update($pdo, $equipment_id, $categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $max_loan_day, $loanable);
if ($err_msg != '') { if ($err_msg != '') {
$title = 'Erreur appareil'; $title = 'Erreur appareil';
$action = 'equipment-view.php?id='.$equipment_id; $action = 'equipment-view.php?id='.$equipment_id;
......
...@@ -523,11 +523,11 @@ function get_equipment_by_loan_id($pdo, $loan_id) { ...@@ -523,11 +523,11 @@ function get_equipment_by_loan_id($pdo, $loan_id) {
* @return array|string Renvoie une chaine si echec sinon * @return array|string Renvoie une chaine si echec sinon
* un tableau avec l'ID et un msg d'erreur eventuellement * un tableau avec l'ID et un msg d'erreur eventuellement
*/ */
function set_equipment_new($pdo, $categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $max_loan_day, $loanable) { function set_equipment_new($pdo, $categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable, $max_loan_day) {
$sql = 'INSERT INTO Listing (categorie, nom, modele, gamme, equipe, fournisseur, achat, responsable, reparation, accessoires, inventaire, notice, barcode, max_loan_day, loanable)'; $sql = 'INSERT INTO Listing (categorie, nom, modele, gamme, equipe, fournisseur, achat, responsable, reparation, accessoires, inventaire, notice, barcode, loanable, max_loan_day)';
$sql .= ' VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ?);'; $sql .= ' VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);';
$stmt = $pdo->prepare($sql); $stmt = $pdo->prepare($sql);
$iostat = $stmt->execute(array($categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $max_loan_day, $loanable)); $iostat = $stmt->execute(array($categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable, $max_loan_day));
$err_msg = ''; $err_msg = '';
if (!$iostat) if (!$iostat)
$err_msg = $stmt->errorInfo()[2]; $err_msg = $stmt->errorInfo()[2];
......
Supports Markdown
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