<!DOCTYPE html>
<html>
    
     <head>
        <?php include("../includes/header-links.php");?>
       
        <!-- Bootstrap -->
        <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>
       
        <div class="container-fluid">
            <div class="row-fluid">
                
                <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">Licence Code</div>
                            </div>
                            <div class="block-content collapse in">
                                <div class="span12">
                                   
                                      <?php 
                                   session_start();
                                   $bid=$_SESSION['business_id'];

                                  


                                    ?>

                                      <div  >
											<div style="background-color: #08c; color: #ffff">
												<button data-dismiss="modal" class="close" type="button">&times;</button>
												<h3>Enter Your licence  code</h3>
											</div>
											<div class="modal-body">
												<form action="https://poscream.com/app/activate/index.php" method="GET">
                                       
												<label>Licence Code</label>
												<input type="text" name="bcode" class="input-xlarge focused" placeholder="your licence code">
                                                <input type="hidden" name="bid" value="<?php echo $bid ?>">
                                                
												<div class="form-actions">
                                          <button type="submit" name="submit" class="btn btn-primary">Activate</button>
                                          <a href="../index.php" class="btn btn-danger">Cancel</a>
                                        </div>	
												</form>
											</div>
										</div>
										<!--Model Ends here -->
                                     <div class="table-toolbar">
                                   </div>
                                   
                                    
                                  
                                </div>
                            </div>
                        </div>
                        <!-- /block -->
                    </div>
                </div>
            </div>
            <hr>
            <?php include '../includes/footer.php'; ?>
        </div>
        <!--/.fluid-container-->

        <script src="../vendors/jquery-1.9.1.js"></script>
        <script src="../bootstrap/js/bootstrap.min.js"></script>
        <script src="../vendors/datatables/js/jquery.dataTables.min.js"></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>

        <script src="../assets/scripts.js"></script>
        <script src="../assets/DT_bootstrap.js"></script>
        <script>
        $(function() {
            
        });
        </script>
    </body>

<?php


if(isset($_POST['add'])){
	include '../includes/connection.php';
$fullname=$_POST['fname'];
$username2=$_POST['uname'];
$contact=$_POST['contact'];
if ($_SESSION[role]=='General Admin') {
    $bnss=$_POST['business'];
 $brr=0; 
}else{
    $bnss=$_SESSION['business_id'];
  $brr=$_POST['branch'];  
}
$role=$_POST['role'];
$password2=md5($_POST['password']);



    $code = mt_rand(100000, 999999);

    $sqlstfaff = mysqli_query($conn,"INSERT INTO staff (full_name, staff_code,branch_id)
VALUES ('$fullname', '$code','$branch')");

$sql = "INSERT INTO users (name, user_name, contact, password, role,user_code,branch_id,business_id)
VALUES ('$fullname', '$username2', '$contact','$password2', '$role','$code','$brr','$bnss')";

if (mysqli_query($conn, $sql)) {

        $id_user=$_SESSION['id'];
  $activity="Added a new User ".$fullname. " as an ".$role;
  include '../includes/store_logs.php';
	?>

    <meta http-equiv="refresh" content="0;URL='users.php'" />  
    <?php
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}

mysqli_close($conn);
}

?>
 
</html>
