Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="change_ausleiher" class="tab-pane fade in">
- <h3><p align="center"><br/><b>Geliehene Werkzeuge auf einen anderen Nutzer übertragen:</b></p><br/></h3>
- <form name="form" class="form-horizontal" method="post">
- <fieldset>
- <div class="form-group">
- <label class="col-md-4 control-label" for="selectbasic">Barcode</label>
- <div class="col-md-4">
- <select id="tid" name="tid" class="form-control">
- <?php
- $abfrage = "SELECT tid
- FROM tools
- WHERE ausleiher != ''
- ORDER BY tid ASC";
- $result = mysql_query($abfrage);
- if (!$result) {
- die('Ungültige Anfrage: ' . mysql_error());
- }
- while ($row = mysql_fetch_array($result)) {
- echo "<option value=". $row[tid] .">". $row[tid] ."</option>\n";
- }
- unset($row);
- ?>
- </select>
- </div>
- </div>
- <div class="form-group">
- <label class="col-md-4 control-label" for="selectbasic">Neuer Ausleiher</label>
- <div class="col-md-4">
- <select id="neuer_ausleiher" name="neuer_ausleiher" class="form-control">
- <?php
- $abfrage = "SELECT name
- FROM users
- ORDER BY name ASC";
- $result = mysql_query($abfrage);
- if (!$result) {
- die('Ungültige Anfrage: ' . mysql_error());
- }
- while ($row = mysql_fetch_array($result)) {
- echo '<option value="'.$row[name].'">'.$row[name].'</option>';
- }
- unset($row);
- ?>
- </select>
- </div>
- </div>
- <div class="center-block" style="width:600px">
- <button id="change_ausleiher_submit" name="change_ausleiher_submit" class="btn btn-lg btn-success btn-block" type="submit">Ausleiher ändern</button>
- </div>
- </fieldset>
- </form>
- <?php
- $tid = $_POST['tid'];
- $neuer_ausleiher = $_POST['neuer_ausleiher'];
- if (isset($_REQUEST['change_ausleiher_submit'])) {
- if (empty($tid) || empty($neuer_ausleiher)) {
- // ERROR
- } else {
- mysql_query("UPDATE tools SET ausleiher ='" . $neuer_ausleiher . "' WHERE tid ='" . $tid . "'");
- $result = mysql_query("SELECT last_log FROM logs WHERE tid='". $tid ."'");
- if (!$result) {
- die('Ungültige Anfrage: ' . mysql_error());
- }
- $last_log = mysql_fetch_row($result)[0];
- $last_log_explode = explode(";", $last_log);
- $log = $last_log_explode[0]+1 . ";" . date("d.m.Y") . " - " . date("H:i") . ";" . $neuer_ausleiher . ";" . $last_log_explode[3];
- mysql_query("UPDATE logs SET last_log ='" . $log . "', log=CONCAT(log, '\n', '". $log ."') WHERE tid='". $tid ."'");
- }
- }
- ?>
- </div>
- document.querySelector('#change_ausleiher_submit').addEventListener('click', function(e) {
- var neuer_ausleiher = $( "#neuer_ausleiher option:selected" ).text();
- var tid = $( "#tid option:selected" ).text();
- $.ajax({
- url: 'mail.php?ausleiher=&email=&email_liste=&tid=' + tid + '&neuer_ausleiher=' + neuer_ausleiher,
- type: 'GET',
- success: function(s){
- if(s == 'status'){
- $(z).html(y);}
- if(s == 'error') {
- alert('Error Processing your Request!');}
- },
- error: function(e){
- alert('Error Processing your Request!!');
- }
- });
- location.reload();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement