<?php ob_start(); session_start();  if(!isset($_SESSION['sales'])){ header('location:login.php'); die();}

include 'xyz.php';
$_SESSION['my_branch_code'] = $my_branch_code;
   ?>
<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>myOutlet App</title>
   <?php  //include 'inc/toplinks.php';  ?>
   <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
<link href="css/sb-admin-2.min.css" rel="stylesheet">
<!-- <link href="vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet"> -->
<script src="vendor/jquery/jquery.min.js"></script>

<script type="text/javascript" src="tab/sweetalert.min.js"></script>
<link rel="stylesheet" type="text/css" href="tab/sweetalert.css">
<link rel="shortcut icon"  href="img/shop_9253640.png">
</head>

<body id="page-top">

    <!-- Page Wrapper -->
    <div id="wrapper">

      

            <?php  include 'inc/menus.php';  ?>


        <!-- End of Sidebar -->

        <?php include 'inc/top.php';   ?>
                <!-- End of Topbar -->

                <!-- Begin Page Content -->
                <div class="container-fluid">

                    <!-- Page Heading -->
                   <?php  include 'inc/greet.php';  ?><br>
                   
                    <!-- DataTales Example -->
                    <div class="card shadow mb-4">
                        <div class="card-header bg-secondary py-3">
    <h6 class="m-0 font-weight-bold text-white ">#PRODUCT SALES</h6>
                        </div>
                        <div class="card-body">
                            <div class="col-md-12" style="box-shadow:10px 10px 40px gray;">
<input type="hidden" name="allowStatus" value="<?php echo $restrict_status;  ?>" id="MaxRent">
<?php  include 'process.php';  ?>
 <form action="" id="form4" method="POST">
<?php    
$get_recent_ID = QueryDB("SELECT id FROM payment order by id DESC LIMIT 1"); 
$rec=$get_recent_ID->fetch(PDO::FETCH_ASSOC);
 $new_cus_ID = date('y').date('m').'#'.$rec['id'].'B'.rand(100,999);


?>
<div class="row"> <div class="form-group col-md-7 mt-3"><select name="userName" class="form-control myselect" required id="name" style="height:200px" >
<option value="<?php echo $new_cus_ID;  ?>"><?php echo $new_cus_ID;  ?></option>
    <?php foreach(QueryDB("SELECT * FROM customers order by frm_name ASC  ") as $rows){echo '<option value="'.$rows['id'].'">'.$rows['frm_name'].' '.$rows['frm_phone'].' ('.get_branch_name($rows['branch']).')</option>'; }?></select></div>
<div class="form-group col-md-3 col-3 mt-3">
<input type="text" readonly="" id="showTotal" class="form-control "></div>
<div class="form-group col-md-2 col-2 mt-3">
<button type="submit" class="btn btn-info  calcItem">Calculate</button></div>

<div class="form-group col-md-2"><select class="form-control" required name="eqSex" id="eqSex"><option value="">--Sex-</option>  <option value="M">Male</option> <option value="F">Female</option> </select></div>

<div class="form-group col-md-4"><select class="form-control" required name="prog_type" id="prog_type"><?php   foreach(QueryDB("SELECT * FROM category") as $crs){echo '<option value='.$crs['id'].'>'.$crs['type'].'</option>';}?></select></div>



<div class="form-group col-md-3"><input type="email" placeholder="Email" name="userEmail" class="form-control"  id="usemails"></div>

<div class="form-group col-md-3"><input type="text" name="userPhone" class="form-control"  id="usphones" placeholder="Phone" onkeypress="return isNumberKey(event);" maxlength="11" minlength="11"></div>

<div class="form-group col-md-12"><textarea class="form-control" name="myAddr" id="myAddr">
Lokoja
</textarea></div>

<div class="row no-gutters"><input type="hidden" name="order_type1" value="1">
 <?php  for($y=1;$y<11;$y++){?> <div class="form-group col-md-5 col-10">
<select class="form-control viewItem1 myselect2"  name='Item[]' id="orderProd<?php echo $y;  ?>" style="height:'350px'"><option value="">-Item <?php echo $y;  ?>-</option><?php foreach(QueryDB("SELECT * FROM products where tm_status=1 order by item_name ASC ")as $selProd){ 
        $leftQty = totalStock_branch($selProd['id'],'','',$my_branch_code)-getQuantity_Branch($selProd['id'],'','',$my_branch_code);

    echo '<option value='.$selProd['id'].'>'.$selProd['item_name'].' - '.$leftQty.     ' Left</option>';  }?></select></div>
<div class="form-group col-md-1 col-2">
<button id="blrBtn<?php echo $y;  ?>" class="btn btn-primary">Clear</button></div>
<div class="form-group col-md-2 col-3"><input type="number" name='QTY[]'   id="orderCount<?php echo $y;  ?>" class="form-control"></div>


<button id="grow<?php echo $y;  ?>" type="button" name="+" class="btn btn-primary btn-xs btn-sm col-1 sub d-block d-md-none" style="height:35px;">+</button><span class="d-block d-md-none">&nbsp;</span> <button id="duce<?php echo $y;  ?>" type="button" name='-' class="btn btn-success btn-xs btn-sm col-1 sub d-block d-md-none" style="height:35px;">-</button>

<div class="form-group col-md-2 col-3 text-center"><input type="text" name="singleCost[]" class="form-control"  id="wrapCost<?php echo $y;  ?>" >

</div>
<div class="form-group col-md-2 col-3"><input type="number" class="bulkCost" readonly="" id="orderCost<?php echo $y;  ?>" name="tCost[]" style="width:100%;height:100%;"></div><?php  } ?>

<div class="form-group col-md-3"><input type="text" name="realCost" id="price" readonly class="form-control" required></div>

<div class="form-group col-md-3"><input type="text" name="paying" class="form-control"  id="prod_costed" placeholder="Paid" required onkeypress="return isNumberKey(event);"></div>

<div class="form-group col-md-1 col-2 ml-1">
<button type="submit" class="btn btn-info  calcItem">Calculate</button></div>


<div class="form-group col-md-4"><select name="pay_mth" class="form-control" required><option value="">-Pay Method-</option>
<?php foreach(QueryDB("SELECT * FROM paymth where status=1 and (branch_c='$my_branch_code' || branch_c='' )")as $item){
echo '<option value='.$item['id'].'>'.$item['mth_name'].'</option>'; }?></select></div>
<button type="submit" class="btn btn-primary col-md-12 sendReq" id="barOrder" disabled>Pay</button>
  <div style="margin-bottom: 5px;">....</div>
</div>

</div></form>                               



   





                            </div>
                        </div>
                    </div>

                </div>
                <!-- /.container-fluid -->

            </div>
            <!-- End of Main Content -->

           
              <?php include 'inc/foot.php';  ?>
            

        </div>
        <!-- End of Content Wrapper -->

    </div>

<a class="scroll-to-top rounded" href="#page-top"><i class="fas fa-angle-up"></i>
    </a>

  

<?php  //include 'inc/bottom.php';  
 include 'inc/modals.php';?>

 <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
    <script src="js/sb-admin-2.min.js"></script>
   <!--  <script src="vendor/datatables/jquery.dataTables.min.js"></script>
    <script src="vendor/datatables/dataTables.bootstrap4.min.js"></script> -->
    <script type="text/javascript" src="js/select2.min.js"></script>
    <link rel="stylesheet" type="text/css" href="js/select2.min.css">
    <!-- <script src="js/demo/datatables-demo.js"></script> -->
     
    <script type="text/javascript" src="js/select2.min.js"></script>
    <link rel="stylesheet" type="text/css" href="js/select2.min.css">
    <script type="text/javascript" src="js/keyreturned.js"></script>
     <script type="text/javascript" src="js/lga.min.js"></script>
    <script type="text/javascript">
$(".myselect").select2({width:'100%',height:'1000px !important',theme: "classic",tags:true});
$(".myselect2").select2({width:'100%',height:'1000px !important',theme: "classic",tags:false});


    </script>


  <?php include 'js/foot_links.php';  ?>
<script>
$(window).on('load', function() { $('#showPay').modal('show');});

   setwhere =1;

$('#getInfo').change(function(e){$.ajax({data: {getProductInfo:$(this).val()},type:"post",dataType:'html',url: "processor",success: function(data){  
// alert(data);

  $('#showProdInfo').html(data);
},error: function(jqXHR, textStatus, errorThrown) { alert('Error');}
    });
})

status = $('#MaxRent').val();
if(status==0){ $('[id^=wrapCost]').prop('readonly',true);
$('#prod_costed').prop('readonly',true);

}else{ $('[id^=wrapCost]').prop('readonly',false);
$('#prod_costed').prop('readonly',true);

}




</script>
</body>

</html>