Advertisement
Guest User

Untitled

a guest
Jun 1st, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. <?php
  2. require_once '../../dbinfo.inc.php';
  3. session_start();
  4.  
  5. // CHECK IF THE USER IS LOGGED ON ACCORDING
  6. // TO THE APPLICATION AUTHENTICATION
  7. if(!isset($_SESSION['username'])){
  8. echo <<< EOD
  9. <h1>You are UNAUTHORIZED !</h1>
  10. <p>INVALID usernames/passwords<p>
  11. <p><a href="../../login.php">LOGIN PAGE</a><p>
  12. EOD;
  13. exit;
  14. }
  15. // GENERATE THE APPLICATION PAGE
  16. $conn = oci_pconnect(ORA_CON_UN, ORA_CON_PW, ORA_CON_DB);
  17.  
  18. // 1. SET THE CLIENT IDENTIFIER AFTER EVERY CALL
  19. // 2. USING UNIQUE VALUE FOR BACK END USER
  20. oci_set_client_identifier($conn, $_SESSION['username']);
  21. $username = htmlentities($_SESSION['username'], ENT_QUOTES);
  22. ?>
  23. <!doctype html>
  24. <html>
  25. <head>
  26. <script type="text/javascript" src="../../jQuery/jquery-1.11.0.min.js"></script>
  27. <script type="text/javascript">
  28.  
  29. $( document ).ready(function() {
  30. var
  31. total = parseInt($('#quantityRequired').text()),
  32. inputs = $('input[type="number"]');
  33.  
  34. inputs
  35. .attr('max', total)
  36. .change(function() {
  37.  
  38. //Make sure that current value is in range
  39. if($(this).val() > parseInt($(this).attr('max'))) {
  40. $(this).val($(this).attr('max'));
  41. } else if ($(this).val() < parseInt($(this).attr('min'))) {
  42. $(this).val($(this).attr('min'));
  43. }
  44.  
  45. //Get currently available total
  46. var current = available();
  47.  
  48. //Now update max on each input
  49. $('input').each(function(indx) {
  50. $(this).attr('max', parseInt($(this).val()) + total - current);
  51. });
  52. });
  53. });
  54.  
  55. function available() {
  56. var sum = 0;
  57. inputs.each(function() {
  58. sum += parseInt($(this).val());
  59. });
  60. return sum;
  61. }
  62. </script>
  63. </head>
  64.  
  65. <body>
  66. <?php
  67. $projectName = strval($_GET['project']);
  68. $thicknessValue = intval($_GET['thicknessValue']);
  69. $baseplateValue = strval($_GET['baseplateValue']);
  70.  
  71. $query = "SELECT QTY_REQUIRED, QTY_CUT FROM COMPONENT
  72. WHERE THICKNESS = :thicknessVal
  73. AND PROJECT_NAME = :projectName
  74. AND BASE_PLATE = :baseplateVal
  75. AND REQUEST_STATUS = 'OPEN'";
  76.  
  77. $result = oci_parse($conn, $query);
  78.  
  79. oci_bind_by_name($result, ":projectName", $projectName);
  80. oci_bind_by_name($result, ":thicknessVal", $thicknessValue);
  81. oci_bind_by_name($result, ":baseplateVal", $baseplateValue);
  82.  
  83. oci_execute($result);
  84. ?>
  85.  
  86. <?php
  87. while ($row = oci_fetch_array($result, OCI_BOTH)){
  88.  
  89. $qtyAvailable = $row['QTY_REQUIRED'] - $row['QTY_CUT'];
  90.  
  91. echo '<span id="quantityRequired">'.$qtyAvailable.'</span>';
  92.  
  93. echo '<input id="cncQty" name="cncQty" type="number" min="0" value="0" placeholder="CNC" required>';
  94. echo '<input id="scatorQty" name="scatorQty" type="number" min="0" value="0" placeholder="SCATOR" required>';
  95. echo '<input id="manualQty" name="manualQty" type="number" min="0" value="0" placeholder="MANUAL" required>';
  96. echo '<br/>';
  97. }
  98. ?>
  99. </body>
  100. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement