Commit 18b51922 authored by Gabriel Moreau's avatar Gabriel Moreau
Browse files

Rename max_loan_day just max_day

parent 2fbd4fdd
......@@ -8,8 +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;
ALTER TABLE `listing` ADD COLUMN `max_day` INT(11) NOT NULL DEFAULT 0;
UPDATE `listing` SET `max_day` = 0;
-- TIMESTAMP =< MySQL 5.5.x < DATETIME
......
......@@ -220,10 +220,10 @@ $team_chief_id = param_post_key('responsable', $equipment_selected, 0);
<tr>
<th>
Nombre de jour max pour un emprunt (0 = inderterminé)
Nombre de jour max pour un emprunt (0 = inderterminé, max 90 jours)
</th>
<td>
<input type="number" name="max-loan-day" min="0" max="90" value="<?= param_post_key('max_loan_day', $equipment_selected, "0")?>" required>
<input type="number" name="max_day" min="0" max="90" value="<?= param_post_key('max_day', $equipment_selected, 0)?>" required>
</td>
</tr>
......
......@@ -33,7 +33,7 @@ $reparation = param_post('reparation');
$accessoires = param_post('accessoires');
$inventaire = param_post('inventaire');
$barcode = param_post('barcode');
$max_loan_day = param_post('max-loan-day', 0);
$max_day = param_post('max_day', 0);
$loanable = param_post('loanable');
//variables ne pouvant etre nulles
if (empty($categorie))
......@@ -75,7 +75,7 @@ if (!empty($erreur)) {
$pdo = connect_db_or_alert();
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, $max_loan_day);
list($equipment_id, $err_msg) = set_equipment_new($pdo, $categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable, $max_day);
if ($err_msg != '') {
$message_alert = ($logged_level > 3 ? $err_msg : '');
include_once('include/alert-data.php');
......@@ -119,11 +119,11 @@ if ( ($categorie != $equipment_selected['categorie'])
|| ($notice != $equipment_selected['notice'])
|| ($barcode != $equipment_selected['barcode'])
|| ($loanable != $equipment_selected['loanable'])
|| ($max_loan_day != $equipment_selected['max_loan_day']))
|| ($max_day != $equipment_selected['max_day']))
$modif = true;
if ($modif) {
$err_msg = set_equipment_update($pdo, $equipment_id, $categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable, $max_loan_day);
$err_msg = set_equipment_update($pdo, $equipment_id, $categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable, $max_day);
if ($err_msg != '') {
$title = 'Erreur appareil';
$action = 'equipment-view.php?id='.$equipment_id;
......
......@@ -49,9 +49,9 @@ if ($param_mode == "loan" || $param_mode == "booking") {
$day_diff = $date_out_rtn - $date_out_ymd;
$day_diff = intval(date('d', $day_diff));
if ($loan_id > 0) {
$equipment_max_day = get_equipment_all_by_id($pdo, get_equipment_by_loan_id($pdo, $loan_id))["max_loan_day"];
$equipment_max_day = get_equipment_all_by_id($pdo, get_equipment_by_loan_id($pdo, $loan_id))['max_day'];
} else {
$equipment_max_day = get_equipment_all_by_id($pdo, $equipment_id)["max_loan_day"];
$equipment_max_day = get_equipment_all_by_id($pdo, $equipment_id)['max_day'];
}
if ($equipment_max_day != 0) {
if ($day_diff > $equipment_max_day)
......
......@@ -503,11 +503,11 @@ function get_equipment_by_loan_id($pdo, $loan_id) {
* @return array|string Renvoie une chaine si echec sinon
* 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, $loanable, $max_loan_day) {
$sql = 'INSERT INTO Listing (categorie, nom, modele, gamme, equipe, fournisseur, achat, responsable, reparation, accessoires, inventaire, notice, barcode, loanable, max_loan_day)';
function set_equipment_new($pdo, $categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable, $max_day) {
$sql = 'INSERT INTO Listing (categorie, nom, modele, gamme, equipe, fournisseur, achat, responsable, reparation, accessoires, inventaire, notice, barcode, loanable, max_day)';
$sql .= ' VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);';
$stmt = $pdo->prepare($sql);
$iostat = $stmt->execute(array($categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable, $max_loan_day));
$iostat = $stmt->execute(array($categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable, $max_day));
$err_msg = '';
if (!$iostat)
$err_msg = $stmt->errorInfo()[2];
......@@ -522,10 +522,10 @@ function set_equipment_new($pdo, $categorie, $nom, $modele, $feature, $equipe, $
* @return string Renvoie une chaine vide
* si réussite sinon une chaine d'erreurs
*/
function set_equipment_update($pdo, $equipment_id, $categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable, $max_loan_day) {
$sql = 'UPDATE Listing SET categorie = ?, nom = ?, modele = ?, gamme = ?, equipe = ?, fournisseur = ?, achat = ?, responsable = ?, reparation = ?, accessoires = ?, inventaire = ?, notice = ?, barcode = ?, loanable = ?, max_loan_day = ? WHERE id = ?;)';
function set_equipment_update($pdo, $equipment_id, $categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable, $max_day) {
$sql = 'UPDATE Listing SET categorie = ?, nom = ?, modele = ?, gamme = ?, equipe = ?, fournisseur = ?, achat = ?, responsable = ?, reparation = ?, accessoires = ?, inventaire = ?, notice = ?, barcode = ?, loanable = ?, max_day = ? WHERE id = ?;)';
$stmt = $pdo->prepare($sql);
$iostat = $stmt->execute(array($categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable, $max_loan_day, $equipment_id));
$iostat = $stmt->execute(array($categorie, $nom, $modele, $feature, $equipe, $fourn, $achat, $tech, $reparation, $accessoires, $inventaire, $notice, $barcode, $loanable, $max_day, $equipment_id));
$err_msg = '';
if (!$iostat)
$err_msg = $stmt->errorInfo()[2];
......
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