PDQ.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php include_once('pdqconnect.inc'); ?>
  2. <html>
  3. <head>
  4. <script src="jquery.min.js"></script>
  5. <script>$(document).ready(function(){ // jquery stuff in here
  6. Reload();
  7. setInterval(function(){
  8. if(dontreload==0){
  9. Reload();
  10. }
  11. },120000); // 1000 = 1 second
  12. $( "#messages" ).focusout(function() {
  13. var newData=$(this).html();
  14. billsMessage(newData);
  15. $(this).attr("contenteditable", "false");
  16. $(this).css("background-color", "orange");
  17. })
  18. $( "#messages" ).dblclick(function() {
  19. dontreload=1;
  20. globalOldData = $(this).html();
  21. if($(this).attr("contenteditable")=="true"){
  22. return;
  23. } else {
  24. $(this).css("background-color", "yellow");
  25. $(this).attr("contenteditable", "true");
  26. }
  27. })
  28. })
  29. </script>
  30. <script>
  31. var globalOldData;
  32. var dontreload=0;
  33. function Reload(){
  34. $.get( "bin/ICGstable.php", function( data ) {
  35. $( "#billstable" ).html( data );
  36. $( ".updatableDiv" ).focusout(function() {
  37. var subKID=$(this).attr("data-subKID");
  38. var newData=$(this).html();
  39. var column=$(this).attr("data-column");
  40. if($(this).html()==globalOldData){
  41. $(this).css("background-color", "");
  42. $(this).attr("contenteditable", "false");
  43. dontreload=0;
  44. } else {
  45. sendUpdates(subKID, newData, column, this);
  46. $(this).attr("contenteditable", "false");
  47. $(this).css("background-color", "orange");
  48. }
  49. })
  50. $( ".updatableDiv" ).dblclick(function() {
  51. dontreload=1;
  52. globalOldData = $(this).html();
  53. if($(this).attr("contenteditable")=="true"){
  54. return;
  55. } else {
  56. $(this).css("background-color", "yellow");
  57. $(this).attr("contenteditable", "true");
  58. }
  59. })
  60. $( ".updateStatus" ).dblclick(function() {
  61. dontreload=1;
  62. var column=$(this).attr("data-column");
  63. var subKID=$(this).attr("data-subKID");
  64. sendUpdates(subKID, $(this).html(), column, this);
  65. })
  66. })
  67. }
  68. function billsMessage(newmessage){
  69. var sendMe = 'newmessage=' + encodeURIComponent(newmessage);
  70. $.post("bin/PDQmessage.php",sendMe,
  71. function(data,status){
  72. dontreload=0;
  73. if(data=='Success' ){
  74. $("#messages").css("background-color", '');
  75. } else {
  76. $("#messages").css("background-color", 'red');
  77. alert("error: " + data);
  78. }
  79. }
  80. );
  81. }
  82. function sendUpdates(subKID, newData, column, callingObject){
  83. var sendMe = 'subKID=' + encodeURIComponent(subKID) + '&newData=' + encodeURIComponent(newData) + '&column=' + encodeURIComponent(column);
  84. $.post("bin/PDQUpdates.php",sendMe,
  85. function(data,status){
  86. dontreload=0;
  87. if(data=='Success' ){
  88. $(callingObject).css("background-color", '');
  89. } else {
  90. $(callingObject).css("background-color", 'red');
  91. alert("error: " + data);
  92. }
  93. if(column=="subKstatus"){Reload();}
  94. }
  95. );
  96. }
  97. </script>
  98. <style>
  99. #messages{
  100. min-height:30px;
  101. font-size:18pt;
  102. border: 1px solid;
  103. }
  104. body{
  105. margin-left:5%;
  106. }
  107. .smaller{
  108. font-size:18pt;
  109. }
  110. .right{
  111. text-align:right;
  112. }
  113. .center{
  114. text-align:center;
  115. }
  116. .tc{
  117. display:table-cell;
  118. padding-left:25px;
  119. font-size:16pt;
  120. }
  121. th{
  122. padding-left:25px;
  123. padding-right:25px;
  124. font-size:30pt;
  125. }
  126. td{
  127. padding-left:25px;
  128. padding-right:25px;
  129. font-size:30pt;
  130. }
  131. tr:hover{
  132. background-color:rgba(49,13,84,.08);
  133. }
  134. .colorRow{
  135. background-color:rgba(49,13,84,.08);
  136. }
  137. .rjust{
  138. text-align:right;
  139. }
  140. .smalltext{
  141. font-size:10pt;
  142. }
  143. </style>
  144. </head>
  145. <body>
  146. <div id='messages' contenteditable="False" >
  147. <?php
  148. $sql = "select message from PDQMessage where PDQMid=0";
  149. $rs=mysqli_query($mydb,$sql) or die(mysqli_error($mydb));
  150. $row=mysqli_fetch_assoc($rs);
  151. echo $row['message'];
  152. ?>
  153. </div>
  154. <div>
  155. <button onclick="location.href='bin/PDQAddOne.php'">Add One</button>
  156. </div>
  157. <div id='billstable'>
  158. </div>
  159. </body>
  160. </html>