Erreur: cet identifiant n'existe pas
\n"; return false; } $rroom_name = pg_query("SELECT name FROM room WHERE idroom = '$a[5]'"); $aroom_name = pg_fetch_array($rroom_name); echo "Les modifications effectuées ici prendront effet dans un délai maximum de 1 heure.
\n"; } else { $r = pg_query("SELECT iduser, nom, prenom FROM user_pac WHERE idroom = $idroom"); // -- Supression de l'ancien user if($a = pg_fetch_array($r)) { if(!isset($_GET['confirm']) || $_GET['confirm'] != "1") { echo "Ajouter un utilisateur sur cette chambre ($idroom) supprimera l'ancien (".$a['nom']." ".$a['prenom'].").
\n";
echo "Voulez vous continuer ? [Oui] - [Non]
Erreur dans le formulaire
\n"; DisplayUser($_GET['id'], $_GET['act'], $_GET['room']); return false; } $_POST['name'] = str_replace("'", " ", $_POST['name']); $_POST['firstname'] = str_replace("'", " ", $_POST['firstname']); if ($_POST['extend'] == "checked") { $datedeco = (get_year(StartDate())+1)."-9-28"; } else { $datedeco = $_POST['datedeco']; } if($_POST['certif'] == "1" || $_POST['certif'] == "on" || $_POST['certif'] == "checked") $certif = 1; else $certif = 0; if(!isset($_POST['mail']) || $_POST['mail'] == "") $mail = "NULL"; else $mail = "'".$_POST['mail']."'"; if($_POST['special_case'] == "1" || $_POST['special_case'] == "on" || $_POST['special_case'] == "checked") {$special_case = 1;} else {$special_case = 0;} if(isset($_POST['comment'])) {$comment = $_POST['comment'];} else {$comment = "";} if($_GET['id']) { // needed for logging_actions $r = pg_query("SELECT nom, prenom, datedeco, certif FROM user_pac WHERE idroom = ".$_POST['idroom']); $am = pg_fetch_array($r); $edit = "edit"; if (new DateTime($am[2]) != new DateTime($datedeco)) { $edit = "new"; if(! isset($_POST['confirm_amount'])) { confirm_amount($am[2]); return false; } } if($am[3] == t) $cert = 'cert'; else $cert = 'nocert'; $oldopt = $am[0] . ' ' . $am[1] . ' ' . $am[2] . ' ' . $cert; // Update pg_query("UPDATE user_pac SET nom = '".strtoupper($_POST['name'])."', prenom = '".$_POST['firstname']."', datedeco = '$datedeco', mail = $mail, certif = '$certif', special_case = '$special_case', comment = '$comment' WHERE iduser = ".$_GET['id']); $r = pg_query("SELECT datedeco FROM user_pac WHERE iduser = ".$_GET['id']); $datedeco_db = pg_fetch_array($r); logging_actions($oldopt, $certif, $datedeco_db[0], $_POST['name'], $_POST['firstname'], $_GET['id'], $edit); return $_GET['id']; } else { // Insert if(! isset($_POST['confirm_amount'])) { confirm_amount("0"); return false; } $r = pg_query("SELECT MAX(iduser) FROM user_pac"); if($a = pg_fetch_array($r)) $newid = $a[0]+1; else $newid = 1; pg_query("INSERT INTO user_pac(iduser, nom, prenom, datedeco, mail, certif, idroom) VALUES($newid, '".strtoupper($_POST['name'])."', '".$_POST['firstname']."', '$datedeco', $mail, '$certif', ".$_POST['idroom'].")"); $oldopt = " "; logging_actions($oldopt, $certif, $datedeco, $_POST['name'], $_POST['firstname'], $newid, "new"); return $newid; } } function SellCable() { global $roles; $amount = 2; if(!$roles['inscription']) return false; if(! isset($_POST['confirm_amount'])) { if(AreAccountsClosed()) { echo "Impossible : trésorerie de l'année précédente non clôturée."; return false; } echo "Attention, si vous confirmez, cet argent vous sera demandé. Merci de remettre l'argent régulièrement aux trésoriers en précisant absolument votre nom.
"; echo ""; echo "\n"; return false; } UpdateAccount($amount); logging_actions(" ", " ", " ", " ", " ", $_GET['id'], "cable"); return true; } function UpdateAccount($amount) { global $auth_user; $r = pg_query("SELECT iduser FROM cam_user WHERE login = '$auth_user'"); $am = pg_fetch_array($r); $idcam_user = $am[0]; $r = pg_query("UPDATE account SET amount=amount+'$amount' WHERE iduser='$idcam_user'"); } // calcule le nombre de mois à faire payer quelle que soit la situation function months_to_pay($olddatedeco, $newdatedeco) { $startdate=date('Y-n-j'); if($olddatedeco != "0") { if(LowestDate($olddatedeco,$startdate) == $startdate) { $startdate=$olddatedeco; } } $year = get_year($newdatedeco); if ($year > get_year($startdate)) { $months = 12 - get_month($startdate) + get_month($newdatedeco) + 1; } else $months = get_month($newdatedeco) - get_month($startdate) + 1; // si la personne est déjà déconnectée, le 20 du mois est passé et au moins 2 mois sont demandés alors le premier mois n'est pas facturé if (($startdate != $olddatedeco) && (date(j) > 20) && ($months > 1)) $months--; return $months; } function AreAccountsClosed() { $r = pg_query("SELECT MAX(year) FROM money"); if($a = pg_fetch_array($r)) { if(isset($a[0]) && CompareDate($a[0], StartDate()) != 0) { $r = pg_query("SELECT SUM(amount) FROM account"); if($a = pg_fetch_array($r)) { if($a[0] != 0) { return true; } else { $r = pg_query("INSERT INTO money(year, amount) VALUES('".StartDate()."', '0')"); } } } elseif(! isset($a[0])) { $r = pg_query("INSERT INTO money(year, amount) VALUES('".StartDate()."', '0')"); } } return false; } function confirm_amount($olddatedeco) { $months = 0; $amount = 0; $new = $_GET['act']; if(AreAccountsClosed()) { echo "Impossible d'inscrire : trésorerie de l'année précédente non clôturée."; return false; } if($olddatedeco != "0") { // pour septembre, vérifier dans les logs que l'inscription n'a pas eu lieu cette année (paiement mensuel) if(LowestDate($olddatedeco,StartDate()) == $olddatedeco) { $new = "new"; } } $newdatedeco=$_POST['datedeco']; if($new == "new") { $months=months_to_pay("0", $newdatedeco); $amount = min($months * 6, 50); } else { if ($_POST['extend'] == "checked") { $newdatedeco=(get_year(StartDate())+1)."-9-28"; $r = pg_query("SELECT MAX(idlog) FROM action_log WHERE iduser = ".$_GET['id']." AND numaction = 5"); $am = pg_fetch_array($r); if ($am[0] != "") { $r = pg_query("SELECT amount FROM action_log WHERE idlog = ".$am[0]); $am = pg_fetch_array($r); if ($am[0] != "N/A") { if (! strstr($am[0], 'tresorier')) { $months=months_to_pay($olddatedeco, $newdatedeco); $amount = min(50 - intval($am[0]),$months*6); } else { echo "Erreur : il s'agit d'un cas particulier, merci de demander l'aide du trésorier."; return false;} } else { echo "Erreur : inscription introuvable dans les logs."; return false;} } else { echo "Erreur : inscription introuvable dans les logs."; return false;} } } if(($new == "new") || ($_POST['extend'] == "checked")) { echo "Attention, si vous confirmez, cet argent vous sera demandé. Merci de remettre l'argent régulièrement aux trésoriers en précisant absolument votre nom.
"; } else { echo "Montant ?
"; } echo ""; } else { echo ""; echo ""; echo ""; } echo "\n"; } function logging_actions($oldopt, $certif, $datedeco, $name, $firstname, $iduser, $act) { global $auth_user; if(isset($_POST['idroom'])) { $r = pg_query("SELECT idinterface FROM room WHERE idroom = ".$_POST['idroom']); if($am = pg_fetch_array($r)) { $id = $am[0]; } } $r = pg_query("SELECT MAX(idlog) FROM action_log"); if($am = pg_fetch_array($r)) $newid = $am[0]+1; else $newid = 1; if($certif) $cert = 'cert'; else $cert = 'nocert'; $opt = $name . ' ' .$firstname . ' ' . $datedeco . ' ' . $cert; $amount = "N/A"; if ($act=="edit") { $num = 8; } elseif ($act=="new") { $num = 5; $amount = $_POST['confirm_amount']; UpdateAccount($amount); if (isset($_POST['tresorier'])) { $amount .= " (tresorier)"; } } elseif ($act=="cable") { $num=9; $r = pg_query("SELECT nom, prenom, datedeco, certif, idroom FROM user_pac WHERE iduser = $iduser"); $a = pg_fetch_array($r); if($a[3]) $cert = 'cert'; else $cert = 'nocert'; $opt = $a[0] . ' ' .$a[1] . ' ' . $a[2] . ' ' . $cert; $r = pg_query("SELECT idinterface FROM room WHERE idroom = ".$a[4]); if($am = pg_fetch_array($r)) { $id = $am[0]; } $amount = $_POST['confirm_amount']; } $r = pg_query("INSERT INTO action_log VALUES($newid, '$auth_user', ".time().", $id, $num, '$oldopt', '$opt', '$iduser', '$amount')"); } function DisplayComputers($id) { global $roles; echo "Aucune machine
\n"; if($n < 3 && $roles['inscription']) echo "[Ajouter]
\n"; } function DisplayEthernetCable() { global $roles; if($roles['inscription']) { echo "\n