<!DOCTYPE html>
<html>
    
    <head>
		<?php
		include("../includes/header-links.php");
		?>
    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
        <link href="../bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
        <link href="../assets/styles.css" rel="stylesheet" media="screen">
        <link href="../assets/DT_bootstrap.css" rel="stylesheet" media="screen">
        <link rel="stylesheet" href="../data-table-css/bootstrap-table.css">
    <link rel="stylesheet" href="../data-table-css/bootstrap-editable.css">
        <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="vendors/flot/excanvas.min.js"></script><![endif]-->
        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
        <script src="../vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script>
    </head>
    
    <body>
        <script type="text/javascript">
    function FormatCurrency(ctrl) {
                  //Check if arrow keys are pressed - we want to allow navigation around textbox using arrow keys
                  if (event.keyCode == 37 || event.keyCode == 38 || event.keyCode == 39 || event.keyCode == 40) {
                      return;
                  }

                  var val = ctrl.value;

                  val = val.replace(/,/g, "")
                  ctrl.value = "";
                  val += '';
                  x = val.split('.');
                  x1 = x[0];
                  x2 = x.length > 1 ? '.' + x[1] : '';

                  var rgx = /(\d+)(\d{3})/;

                  while (rgx.test(x1)) {
                      x1 = x1.replace(rgx, '$1' + ',' + '$2');
                  }

                  ctrl.value = x1 + x2;
              }

              function CheckNumeric() {
                  return event.keyCode >= 48 && event.keyCode <= 57 || event.keyCode == 46;
              }
</script>
        <?php include '../includes/header.php'; ?>
        <div class="container-fluid">
            <div class="row-fluid">
                <?php include '../includes/sidebar.php'; ?>
                <!--/span-->
                <div class="span10" id="content">

                     <div class="row-fluid">
                        <!-- block -->
                        <div class="block">
                            <div class="navbar navbar-inner block-header">
                                <div class="muted pull-left">General store products available</div>
                                <div class="muted pull-right"><a href="store.php"><button class="btn btn-primary">store </button></a> <a href="storelogs.php"><button class="bt btn-primary">store logs</button> </a></div>
                                
                            </div>
                            <div class="block-content collapse in">
                                <div class="span12">
                                   
                                 
										<!--Model Ends here -->
                                                 <?php
                                    include '../includes/connection.php';
                                                                       // Create connection
                                    $sql = mysqli_query($con,"SELECT *  from stores where  business_id='$business'");
                                    //$result = mysqli_query($con, $sql);

                                    if (mysqli_num_rows($sql) > 0) {
                                        // output data of each row
    


                                   ?>
                                    
                                    <div id="toolbar">
                                        <select class="form-control">
                                                <option value="">Export Basic</option>
                                                <option value="all">Export All</option>
                                                <option value="selected">Export Selected</option>
                                            </select>
                                    </div>
                                    <table  id="table" data-toggle="table" data-pagination="true" data-search="true" data-show-columns="true" data-show-pagination-switch="true" data-show-refresh="false" data-key-events="true" data-show-toggle="false" data-resizable="false" data-cookie="true"
                                        data-cookie-id-table="saveId" data-show-export="true" data-click-to-select="true" data-toolbar="#toolbar" data-export-options='{"fileName": "Testing_filename"}'>
                                        <thead>
                                            <tr>
                                                <th>S/NO</th>
                                                <th>Product Name</th>
                                               
                                                <th>Quantity</th>

                                                <th>Actual Quantity</th>
                                                <th>Action</th>

                                            </tr>
                                        </thead>
                                        <tbody>
                                        
                                        <?php
                                        $n=0;
while($row = mysqli_fetch_assoc($sql)) {
  $pid=$row['id'];
  $n++;
 
    ?>
<tr class="gradeU">
   


                                                <td><?php echo $n; ?></td>
                                                <td><?php echo $row['product_name']; ?></td>
                                                <td> 

                                                    <?php echo $row['quantity']; ?></td>
                                                <td> <?php echo $row['added'];?></td>
                                                    
                                                <td>
                                                    <form method="POST" action="">
                                                     <input type="hidden" value="<?php echo $row['added'];?>" name="actual" >

                                                    <input type="hidden" name="rid" value="<?php echo $pid;?>" required="required">
                                             <input type="number"  name="addm">
                                                <button class="btn btn-primary" type="submit" name="save">Add </button> 
                                            </form>
                                            </td>
                                                
                                                
                                                
                                              
                                       </tr>
                                            
                                            <?php


    }
    ?>
                                        </tbody>
                                    </table>
                                    <?php                              
} else {
    echo "0 results";
}


?>
<div class="form-actions">
                                        <a href="save_added.php">  <button  class="btn btn-primary">Save Changes </button></a>
                                          
                                        </div>  

<?php
if (isset($_POST['save'])) {
    $rid=$_POST['rid'];
    $actual=$_POST['actual'];
    $addm=$_POST['addm'];
    $newactual=(int)$actual+(int)$addm;
    $updateactual = mysqli_query($con,"UPDATE stores set added='$newactual' where id='$rid' ");
    if ($updateactual) {
        ?>
        <meta http-equiv="refresh" content="0;URL='reconcile_store.php'" />
        <?php
    }else{
        echo "Error".mysqli_error($con);
    }

}
?>
                                        
                                </div>
                            </div>
                        </div>
                        <!-- /block -->
                    </div>
                </div>
            </div>
            <hr>
            <?php include '../includes/footer.php'; ?>
        </div>
        <!--/.fluid-container-->

        <!--==========Footer js======-->
		<?php require_once("../includes/footerjs.php");?>
        <!--==========Footer js======-->
   <script type = "text/javascript">
    function confirmationDelete(anchor){
        var conf = confirm("Are you sure you want to delete this record?");
        if(conf){
            window.location = anchor.attr("href");
        }
    } 
    function confirmationSuspend(anchor){
        var conf1 = confirm("Are you sure you want to Suspend this supplier?");
        if(conf1){
            window.location = anchor.attr("href");
        }
    }  
    function confirmationReturn(anchor){
        var conf2 = confirm("Are you sure you want to Return this Supplier?");
        if(conf2){
            window.location = anchor.attr("href");
        }
    }      
</script>
<script src="../data-table-js/bootstrap-table.js"></script>
    <script src="../data-table-js/tableExport.js"></script>
    <script src="../data-table-js/data-table-active.js"></script>
    <script src="../data-table-js/bootstrap-table-editable.js"></script>
    <script src="../data-table-js/bootstrap-editable.js"></script>
    <script src="../data-table-js/bootstrap-table-resizable.js"></script>
    <script src="../data-table-js/colResizable-1.5.source.js"></script>
    <script src="../data-table-js/bootstrap-table-export.js"></script>
    </body>

 
</html>

