Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. <div id="change_ausleiher" class="tab-pane fade in">
  2.  
  3. <h3><p align="center"><br/><b>Geliehene Werkzeuge auf einen anderen Nutzer übertragen:</b></p><br/></h3>
  4.  
  5. <form name="form" class="form-horizontal" method="post">
  6. <fieldset>
  7.  
  8. <div class="form-group">
  9. <label class="col-md-4 control-label" for="selectbasic">Barcode</label>
  10. <div class="col-md-4">
  11. <select id="tid" name="tid" class="form-control">
  12. <?php
  13. $abfrage = "SELECT tid
  14. FROM tools
  15. WHERE ausleiher != ''
  16. ORDER BY tid ASC";
  17.  
  18. $result = mysql_query($abfrage);
  19. if (!$result) {
  20. die('Ungültige Anfrage: ' . mysql_error());
  21. }
  22.  
  23. while ($row = mysql_fetch_array($result)) {
  24. echo "<option value=". $row[tid] .">". $row[tid] ."</option>\n";
  25. }
  26.  
  27. unset($row);
  28. ?>
  29. </select>
  30. </div>
  31. </div>
  32.  
  33. <div class="form-group">
  34. <label class="col-md-4 control-label" for="selectbasic">Neuer Ausleiher</label>
  35. <div class="col-md-4">
  36. <select id="neuer_ausleiher" name="neuer_ausleiher" class="form-control">
  37. <?php
  38. $abfrage = "SELECT name
  39. FROM users
  40. ORDER BY name ASC";
  41.  
  42. $result = mysql_query($abfrage);
  43. if (!$result) {
  44. die('Ungültige Anfrage: ' . mysql_error());
  45. }
  46.  
  47. while ($row = mysql_fetch_array($result)) {
  48. echo '<option value="'.$row[name].'">'.$row[name].'</option>';
  49. }
  50.  
  51. unset($row);
  52. ?>
  53. </select>
  54. </div>
  55. </div>
  56.  
  57. <div class="center-block" style="width:600px">
  58. <button id="change_ausleiher_submit" name="change_ausleiher_submit" class="btn btn-lg btn-success btn-block" type="submit">Ausleiher ändern</button>
  59. </div>
  60. </fieldset>
  61. </form>
  62.  
  63. <?php
  64. $tid = $_POST['tid'];
  65. $neuer_ausleiher = $_POST['neuer_ausleiher'];
  66.  
  67. if (isset($_REQUEST['change_ausleiher_submit'])) {
  68. if (empty($tid) || empty($neuer_ausleiher)) {
  69. // ERROR
  70. } else {
  71. mysql_query("UPDATE tools SET ausleiher ='" . $neuer_ausleiher . "' WHERE tid ='" . $tid . "'");
  72.  
  73. $result = mysql_query("SELECT last_log FROM logs WHERE tid='". $tid ."'");
  74.  
  75. if (!$result) {
  76. die('Ungültige Anfrage: ' . mysql_error());
  77. }
  78.  
  79. $last_log = mysql_fetch_row($result)[0];
  80.  
  81. $last_log_explode = explode(";", $last_log);
  82.  
  83. $log = $last_log_explode[0]+1 . ";" . date("d.m.Y") . " - " . date("H:i") . ";" . $neuer_ausleiher . ";" . $last_log_explode[3];
  84.  
  85. mysql_query("UPDATE logs SET last_log ='" . $log . "', log=CONCAT(log, '\n', '". $log ."') WHERE tid='". $tid ."'");
  86.  
  87. }
  88. }
  89.  
  90. ?>
  91.  
  92. </div>
  93.  
  94. document.querySelector('#change_ausleiher_submit').addEventListener('click', function(e) {
  95.  
  96. var neuer_ausleiher = $( "#neuer_ausleiher option:selected" ).text();
  97. var tid = $( "#tid option:selected" ).text();
  98.  
  99. $.ajax({
  100. url: 'mail.php?ausleiher=&email=&email_liste=&tid=' + tid + '&neuer_ausleiher=' + neuer_ausleiher,
  101. type: 'GET',
  102. success: function(s){
  103. if(s == 'status'){
  104. $(z).html(y);}
  105. if(s == 'error') {
  106. alert('Error Processing your Request!');}
  107. },
  108. error: function(e){
  109. alert('Error Processing your Request!!');
  110. }
  111.  
  112. });
  113. location.reload();
  114. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement