Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once '../../dbinfo.inc.php';
- session_start();
- // CHECK IF THE USER IS LOGGED ON ACCORDING
- // TO THE APPLICATION AUTHENTICATION
- if(!isset($_SESSION['username'])){
- echo <<< EOD
- <h1>You are UNAUTHORIZED !</h1>
- <p>INVALID usernames/passwords<p>
- <p><a href="../../login.php">LOGIN PAGE</a><p>
- EOD;
- exit;
- }
- // GENERATE THE APPLICATION PAGE
- $conn = oci_pconnect(ORA_CON_UN, ORA_CON_PW, ORA_CON_DB);
- // 1. SET THE CLIENT IDENTIFIER AFTER EVERY CALL
- // 2. USING UNIQUE VALUE FOR BACK END USER
- oci_set_client_identifier($conn, $_SESSION['username']);
- $username = htmlentities($_SESSION['username'], ENT_QUOTES);
- ?>
- <!doctype html>
- <html>
- <head>
- <script type="text/javascript" src="../../jQuery/jquery-1.11.0.min.js"></script>
- <script type="text/javascript">
- $( document ).ready(function() {
- var
- total = parseInt($('#quantityRequired').text()),
- inputs = $('input[type="number"]');
- inputs
- .attr('max', total)
- .change(function() {
- //Make sure that current value is in range
- if($(this).val() > parseInt($(this).attr('max'))) {
- $(this).val($(this).attr('max'));
- } else if ($(this).val() < parseInt($(this).attr('min'))) {
- $(this).val($(this).attr('min'));
- }
- //Get currently available total
- var current = available();
- //Now update max on each input
- $('input').each(function(indx) {
- $(this).attr('max', parseInt($(this).val()) + total - current);
- });
- });
- });
- function available() {
- var sum = 0;
- inputs.each(function() {
- sum += parseInt($(this).val());
- });
- return sum;
- }
- </script>
- </head>
- <body>
- <?php
- $projectName = strval($_GET['project']);
- $thicknessValue = intval($_GET['thicknessValue']);
- $baseplateValue = strval($_GET['baseplateValue']);
- $query = "SELECT QTY_REQUIRED, QTY_CUT FROM COMPONENT
- WHERE THICKNESS = :thicknessVal
- AND PROJECT_NAME = :projectName
- AND BASE_PLATE = :baseplateVal
- AND REQUEST_STATUS = 'OPEN'";
- $result = oci_parse($conn, $query);
- oci_bind_by_name($result, ":projectName", $projectName);
- oci_bind_by_name($result, ":thicknessVal", $thicknessValue);
- oci_bind_by_name($result, ":baseplateVal", $baseplateValue);
- oci_execute($result);
- ?>
- <?php
- while ($row = oci_fetch_array($result, OCI_BOTH)){
- $qtyAvailable = $row['QTY_REQUIRED'] - $row['QTY_CUT'];
- echo '<span id="quantityRequired">'.$qtyAvailable.'</span>';
- echo '<input id="cncQty" name="cncQty" type="number" min="0" value="0" placeholder="CNC" required>';
- echo '<input id="scatorQty" name="scatorQty" type="number" min="0" value="0" placeholder="SCATOR" required>';
- echo '<input id="manualQty" name="manualQty" type="number" min="0" value="0" placeholder="MANUAL" required>';
- echo '<br/>';
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement