<?php include 'topmost.php';
// echo code_generator(5);

?>
<!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>Outlet App</title>

 <?php include 'toplinks.php'; ?>
</head>

<body id="page-top">

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


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




        <?php include 'top.php';   ?>
            

            
                <div class="container-fluid">
<?php  include 'process.php';  ?>  
                    
                   <?php  include 'greet.php';  ?><br>
  







<?php if(isset($_GET['standard'])){?>
<div class="row">
    <!--Category-->
<div class="col-md-12"><div class="card">
<div class="card-header bg-dark text-white"># Branches </div><div class="card-body">
 <table class="table table-bordered table-hover table-striped">
 <tr class="small"><th>#</th><th>Name</th><th>Address</th><th>RecptName</th><th>Phone</th><th>Email</th><th>Motto</th><th>Logo</th><th>Status</th><th>Action</th></tr><?php $mkp=1; 
foreach(QueryDB("SELECT * FROM branch ")as $myB){
echo '<tr class="small"><th>'.$mkp.'</th><th>'.$myB['shrt_name'].'</th><td>'.$myB['address'].'</td><td>'.$myB['branch_name'].'</td><td>'.$myB['phone'].'</td><td>'.$myB['email'].'</td><td>'.$myB['motto'].'</td><td><img style="width:50px;" src="'.$myB['logo'].'"/></td>'; 

 if($myB['status']==1){ echo '<td><a onclick="return confirm("Are you Sure?");" class="btn btn-success btn-sm" href="?editRouteD='.$myB['id'].'&new_states='.$myB['status'].'"><i class="fa fa-unlock "></i></a></td>'; }else{ echo '<td><a onclick="return confirm("Are you Sure?");" class="btn btn-danger btn-sm" href="?editRouteD='.$myB['id'].'&new_states='.$myB['status'].'"><i class="fa fa-lock "></i></a></td>';  }
echo '<td><a href="" data-toggle="modal" data-target="#modKey'.$mkp.'" class="btn btn-warning small text-white btn-sm"><i class="fa fa-edit"></i></a></td>';
 echo '</tr>';?>


 <div class="modal fade" id="modKey<?php echo $mkp;  ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"><div class="modal-dialog modal-center modal-md" role="document"><div class="modal-content"><div class="modal-header bg-primary text-white"><h5 class="modal-title small" id="exampleModalLabel">#Edit Branch Information</h5><button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div><div class="modal-body"><form action="" method="POST" enctype="multipart/form-data">
<h5><strong>Name: </strong><?php echo  $myB['shrt_name']; ?></h5>
<?php echo '<div class="row">
<div class="col-md-12 mb-2">
<center><img src="'.$myB['logo'].'" style="width:70px;"/></center>
</div>
<input type="hidden" name="where" value="'.$myB['id'].'"/>
<input type="hidden" name="prevImg" value="'.$myB['logo'].'"/>

<div class="col-md-6 mb-2"><label>Branch Name</label><input type="text" name="shtName" class="form-control" required value='.$myB['shrt_name'].'></div>

<div class="col-md-6"><label>Phone Number</label><input type="text" name="phNumb" class="form-control mb-2" required value='.$myB['phone'].'></div>

<div class="col-md-12"><label>Receipt Address</label><input type="text" name="adrs" class="form-control mb-2" required value='.$myB['address'].'></div>  

<div class="col-md-12"><label>Receipt Name</label><input type="text" name="RcptName" class="form-control mb-2" required value='.$myB['branch_name'].'></div> 

<div class="col-md-12"><label>Email & Website</label><input type="text" name="eml" class="form-control mb-2" required value='.$myB['email'].'></div> 

 <div class="col-md-12"><label>Motto</label><input type="text" name="motto" class="form-control mb-2" required value='.$myB['motto'].'></div> 
 <div class="col-md-12"><input type="file" name="getImage" class="form-control mb-2"></div> 

</div>';?>

   <div class="form-group col-md-12"><input type="submit" name="updateBranch" value="Update" class="form-control btn btn-secondary"></div></div></form></div></div></div></div>
<?php $mkp++; }?>
 </table></div></div></div>


<div class="col-md-2"><div class="card small">
<div class="card-header bg-dark text-white">#Category</div><div class="card-body">
 <table class="table table-bordered table-hover table-striped">
 <tr class="small"><th>#</th><th>Name</th></tr><?php $mkb=1; for($i=0;$i<count($brand);$i++){
    echo '<tr class="small"><th>'.$mkb.'</th><th>'.$brand[$i].'</th></tr>';$mkb++;}?>
 </table></div></div></div>

<!--Sizes-->
<div class="col-md-2"><div class="card small">
<div class="card-header bg-primary text-white">#SIZES/RANGE</div><div class="card-body">
 <table class="table table-bordered table-hover table-striped">
 <tr class="small"><th>#</th><th>Name</th></tr><?php $mkb=1; for($i=0;$i<count($sized_by);$i++){
    echo '<tr class="small"><th>'.$mkb.'</th><th>'.$sized_by[$i].'</th></tr>';$mkb++;}?>
 </table></div></div></div><!--end-->

<!--Company-->
<div class="col-md-2"><div class="card small">
<div class="card-header bg-success text-white">#Company</div><div class="card-body">
 <table class="table table-bordered table-hover table-striped">
 <tr class="small"><th>#</th><th>Name</th></tr><?php $mka=1; for($i=0;$i<count($company);$i++){
    echo '<tr class="small"><th>'.$mka.'</th><th>'.$company[$i].'</th></tr>';$mka++;}?>
 </table></div></div></div><!--end-->


<!--Colors-->
<div class="col-md-2"><div class="card small">
<div class="card-header bg-warning text-white">#Colors</div><div class="card-body">
 <table class="table table-bordered table-hover table-striped">
 <tr class="small"><th>#</th><th>Name</th></tr><?php $mkc=1; for($i=0;$i<count($colored_by);$i++){echo '<tr class="small"><th>'.$mkc.'</th><th>'.$colored_by[$i].'</th></tr>';$mkc++;}?>
 </table></div></div></div><!--end-->


<!--Pay Route-->
<div class="col-md-4"><div class="card small">
<div class="card-header bg-info text-white">#Pay Route</div><div class="card-body">
 <table class="table table-bordered table-hover table-striped">
 <tr class="small"><th>#</th><th>Name</th><th>Status</th><th>Branch</th><th>Action</th></tr><?php $mkk=1; 
foreach(QueryDB("SELECT * FROM paymth ")as $mtd){
echo '<tr class="small"><th>'.$mkk.'</th><th>'.$mtd['mth_name'].'</th>';
if($mtd['status']==1){ echo '<td><i class="fa fa-unlock text-success"></i></td>'; }else{ echo '<td><i class="fa fa-lock text-danger"></i></td>';  }
echo '<td>'.@get_branch_name($mtd['branch_c']).'</td><td>';

 echo '<a href="?editRoute='.$mtd['id'].'&new_state='.$mtd['status'].'"><i class="fa fa-edit btn btn-info btn-sm"></i></a></td></tr>';$mkk++;}?>
 </table></div></div></div><!--end-->


</div><?php }else{?>
                    <div class="card shadow mb-4">
                        <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between bg-dark text-white"><h6 class="m-0 font-weight-bold text-white"># Product Overview </h6><div class="dropdown no-arrow">
<button class="btn btn-warning btn-sm"><a class="dropdown-item" href="#" data-toggle="modal" data-target="#filterProduct"><i class="fa fa-filter text-dark">Filter</i></a></button>
</div></div>

<div class="card-body">
<?php  
if(isset($_POST['sendFilter'])){ $filter = 1;
if(!empty($_POST['eqCourse'])){ $selCrs =' and loader="'.$_POST['eqCourse'].'" ';  }else{
    $selCrs ='';
}
if(!empty($_POST['date'])){ $month =' and date_="'.$_POST['date'].'"  ';  }else{
    $month ='';
}

$query = ("SELECT * FROM products where id!='' $selCrs $month  ");
    }else{ $query ="SELECT * FROM products ORDER by item_name ASC";

}
     ?>
<div class="row d-block d-md-none">
<?php  $ctD =1; $counterAttack =1; foreach(QueryDB($query)as $reg_std){?>
    <div class="col-md-12 mt-1 mb-2" style="box-shadow: 8px 7px 10px gray;min-height:80px;border-radius: 2px;border-left:6px solid green;padding-bottom:5px;">
<div class="row">
   <div class="col-6"><span style="font-size:20px;"><b><?php echo strtoupper($reg_std['item_name']);  ?></span></b><br> <b><?php  echo $sized_by[$reg_std['size']].','.$colored_by[$reg_std['color']];  ?></b>


   </div>   
<div class="col-2 mt-1"><span class="bg-dark text-white badge"><?php echo $ctD;  ?></span></div>

<div class="col-4"><?php if(file_exists(explode(',',$reg_std['item_img'])[0])){
    $view_sel_img =explode(',',$reg_std['item_img'])[0];?> 
<img src="<?php echo $view_sel_img; ?>" class="img img-thumbnail" style="width:100%;height:100px"> <?php }?></div>

<div class="col-12"><?php  echo $company[$reg_std['company']].', '.$brand[$reg_std['brand']];  ?></div>
<div class="col-6 small"><b>Status: </b><?php if($reg_std['tm_status']==1){ echo '<span class="text-success"><b>Available</b></span>';}else{
    echo '<span class="text-danger"><b>Removed</b></span>';
}  ?></div>
<div class="col-6 small"><b>Added:</b> <?php echo date('d-m-Y',$reg_std['tm_added']);  ?></div>
<div class="col-10 small"><b>By:</b> <?php echo get_staff_name($reg_std['loader']);  ?></div>

<div class="col-2"></div>

<div class="col-12 small img img-thumbnail mb-2 mt-2"><span class="text-danger"><?php  echo $reg_std['item_desc']; ?></span></div>

<div class="col-12 small float-right text-right">

<a  data-toggle="modal" class="text-dark btn btn-primary" style="padding:3px;" data-target="#loadimgM<?php echo $counterAttack; ?>"><svg xmlns="http://www.w3.org/2000/svg" height="16" width="30" viewBox="0 0 512 512"><path d="M149.1 64.8L138.7 96H64C28.7 96 0 124.7 0 160V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V160c0-35.3-28.7-64-64-64H373.3L362.9 64.8C356.4 45.2 338.1 32 317.4 32H194.6c-20.7 0-39 13.2-45.5 32.8zM256 192a96 96 0 1 1 0 192 96 96 0 1 1 0-192z"/></svg></a>


<div class="modal fade" id="loadimgM<?php echo $counterAttack; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"><div class="modal-dialog" role="document">
<div class="modal-content"><div class="modal-header bg-secondary text-white"><h5 class="modal-title " id="exampleModalLabel">#Product Image - <span class="text-white"><?php echo $reg_std['item_name']; ?></span></h5><button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div><div class="modal-body">
    <div class="row">
<?php  $getImg =QueryDB("SELECT item_img FROM products WHERE id='".$reg_std['id']."' ");
        $myrows =$getImg->fetch(PDO::FETCH_ASSOC);
    if($myrows['item_img']!='') {
        for($i=0;$i<count(explode(',',$myrows['item_img']));$i++) {
    
?>

<div class="col-4"><img src="<?php  echo explode(',',$myrows['item_img'])[$i];  ?>" class="img img-thumbnail">
<center><button title="<?php  echo $reg_std['id'];  ?>" id="<?php echo $i; ?>" class="remvImgMobile"><i class="fa fa-trash text-danger"></i></button></center>
</div><?php } }?></div>

<form method='post' action='' enctype="multipart/form-data">
<input type="file" id='filesM<?php echo $counterAttack;  ?>' class="form-control" name="files[]" multiple><br>
<input type="hidden" id="whereasM<?php echo $counterAttack;  ?>" value="<?php echo $reg_std['id'];  ?>">
<input type="hidden" id="prevImgsM<?php echo $counterAttack;  ?>" value="<?php if(!empty($reg_std['item_img'])){echo $reg_std['item_img'];}  ?>">
<input type="button" id="submitM<?php echo $counterAttack;  ?>" value='Upload' class="btn btn-secondary text-white form-control"></form><div id='previewM<?php echo $counterAttack;  ?>' class="row"></div>
</div><div class="modal-footer"><button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button></div></div></div></div>





<a  data-toggle="modal" class="btn btn-warning small text-dark" style="padding:3px;" data-target="#addRegedM<?php echo $ctD; ?>"><i class="fa fa-edit text-dark small"> Edit</i></a>&nbsp;&nbsp; <a href="whrs_itemView?view_sales_history=<?php echo $reg_std['id']; ?>" class="btn btn-dark small text-dark" style="padding:3px;"><i class="fa fa-eye text-white small"> Sales History</i></a>


<!--Modify Product-->
<div class="modal fade" id="addRegedM<?php echo $ctD; ?>"  role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"><div class="modal-dialog" role="document">
<div class="modal-content"><div class="modal-header bg-secondary text-white"><h5 class="modal-title " id="exampleModalLabel">#Modify Product - <span class="text-white"><?php echo $reg_std['item_name']; ?></span></h5><button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div><div class="modal-body">

<form action="" method="POST"><div class="row"><div class="form-group col-md-8"><input type="text" name="prodname" class="form-control" required placeholder="Product Name e.g. LK100 or 3.75KVA" value="<?php echo $reg_std['item_name'];  ?>"></div>
<div class="form-group col-md-4"><input type="text" name="cost" class="form-control" required placeholder="cost" onkeypress="return isNumberKey(event)" value="<?php echo $reg_std['item_cost'] ?>"></div>
<div class="col-md-12"><textarea class="form-control" placeholder="Product Description" name="item_desc" maxlength="160" minlength="10" required><?php echo $reg_std['item_desc'];  ?></textarea></div>
<input type="hidden" name="where" value="<?php echo $reg_std['id']; ?>">
  <div class="form-group col-md-6"><select class="form-control" required name="company"><?php 
for($i=0;$i<count($company);$i++){?><option value="<?php  echo $i; ?>" <?php if($i==$reg_std['company']){echo 'selected';}  ?>><?php echo $company[$i]; ?></option><?php }?></select></div><div class="form-group col-md-6"><select class="form-control" required name="brand"><option value="">--Brand--</option> <?php for($i=0;$i<count($brand);$i++){?><option value="<?php  echo $i; ?>" <?php if($i==$reg_std['brand']){echo 'selected';}  ?>><?php echo $brand[$i]; ?></option><?php }?></select></div>
<div class="form-group col-md-4"><select class="form-control" required name="size"><option value="">--Sized By-</option> <?php for($i=0;$i<count($sized_by);$i++){?>
<option value="<?php  echo $i; ?>" <?php if($i==$reg_std['size']){echo 'selected';}  ?>><?php echo $sized_by[$i]; ?></option><?php }?><</select></div><div class="form-group col-md-4"><select class="form-control" required name="color"><option value="">--Colour--</option> <?php for($i=0;$i<count($colored_by);$i++){?>
<option value="<?php  echo $i; ?>" <?php if($i==$reg_std['color']){echo 'selected';}  ?>><?php echo $colored_by[$i]; ?></option><?php }?></select></div>

<div class="col-md-12 mt-2"><textarea class="form-control content" rows="5" placeholder="Product Details" name="item_details" maxlength="160" minlength="10" required></textarea></div>


<div class="form-group col-md-4"><select class="form-control" required name="tm_status"><option value="1" <?php  if($reg_std['tm_status']==1){ echo 'selected';} ?>>Visible</option><option value="0" <?php  if($reg_std['tm_status']==0){ echo 'selected';} ?>>Remove</option></select></div><div class="form-group col-md-12"><input type="submit" name="EditProduct" value="Edit Product" class="form-control btn btn-secondary"></div></div></form>



</div><div class="modal-footer"><button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button></div></div></div></div>

</div>
</div></div><?php $ctD++; $counterAttack++; } ?></div>



   




<!--Desktop View of Products-->
<div class="table-responsive d-none d-md-block">
<table class="table table-bordered std_table" id="example1" width="100%" cellspacing="0">
    <!-- <p class="text-center text-dark"><strong>FILTER PRODUCTS BY</strong></p> -->
<thead><tr><th>#</th><th>Name</th><th>Size</th><th>Color</th><th>Company</th><th>Category</th><th>Status</th><th>Image</th><th>Date</th><th>By</th>
    <th>Action</th></tr></thead>

<?php
$count=1;
foreach(QueryDB($query)as $reg_std){?>
<tbody><tr><td class="small text-dark"><?php echo $count++; ?></td><td class="small text-dark"><b><?php echo strtoupper($reg_std['item_name']);  ?></b>&nbsp; 
<a  data-toggle="modal" class="text-dark" style="padding:3px;" data-target="#loadimgD<?php echo $count; ?>"><svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512"><path d="M149.1 64.8L138.7 96H64C28.7 96 0 124.7 0 160V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V160c0-35.3-28.7-64-64-64H373.3L362.9 64.8C356.4 45.2 338.1 32 317.4 32H194.6c-20.7 0-39 13.2-45.5 32.8zM256 192a96 96 0 1 1 0 192 96 96 0 1 1 0-192z"/></svg></a>


<div class="modal fade" id="loadimgD<?php echo $count; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"><div class="modal-dialog" role="document">
<div class="modal-content"><div class="modal-header bg-secondary text-white"><h5 class="modal-title " id="exampleModalLabel">#Product Image - <span class="text-warning"><?php echo $reg_std['item_name']; ?></span></h5><button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div><div class="modal-body">
    <div class="row">
<?php  $getImg =QueryDB("SELECT item_img FROM products WHERE id='".$reg_std['id']."' ");
        $myrows =$getImg->fetch(PDO::FETCH_ASSOC);
    if($myrows['item_img']!='') {
        for($i=0;$i<count(explode(',',$myrows['item_img']));$i++) {
    
?>

<div class="col-md-4"><img src="<?php  echo explode(',',$myrows['item_img'])[$i];  ?>" class="img img-thumbnail">
<center><button title="<?php  echo $reg_std['id'];  ?>" id="<?php echo $i; ?>" class="remvImg"><i class="fa fa-trash text-danger"></i></button></center>
</div>

<?php } }?>        


    </div>

<form method='post' action='' enctype="multipart/form-data">
<input type="file" id='files<?php echo $count;  ?>' class="form-control" name="files[]" multiple><br>
<input type="hidden" id="whereas<?php echo $count;  ?>" value="<?php echo $reg_std['id'];  ?>">
<input type="hidden" id="prevImgs<?php echo $count;  ?>" value="<?php if(!empty($reg_std['item_img'])){echo $reg_std['item_img'];}  ?>">
        <input type="button" id="submit<?php echo $count;  ?>" value='Upload' class="btn btn-secondary text-white form-control">
    </form>

<div id='preview<?php echo $count;  ?>' class="row"></div>


  </div><div class="modal-footer"><button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button></div></div></div></div>





</td><td class="small text-dark">
    <?php echo $sized_by[$reg_std['size']];  ?></td><td class="small text-dark">
    <?php echo $colored_by[$reg_std['color']];  ?></td><td class="small text-dark">
    <?php echo $company[$reg_std['company']];  ?></td><td class="small text-dark">
    <?php echo $brand[$reg_std['brand']];  ?></td>
<td class="small"><?php if($reg_std['tm_status']==1){ echo '<span class="text-success"><b>Available</b></span>';}else{
    echo '<span class="text-danger"><b>Removed</b></span>';
}  ?></td>
<td><?php if(file_exists(explode(',',$reg_std['item_img'])[0])){
    $view_sel_img =explode(',',$reg_std['item_img'])[0];
    ?> 

    <img src="<?php echo $view_sel_img; ?>" class="img img-thumbnail" style="width:100%;height:100px"> <?php }?>

</td>
    <td class="small"><?php echo date('d-m-Y',$reg_std['tm_added']);  ?></td><td class="small"><?php echo get_staff_name($reg_std['loader']);  ?></td>


   
<td class="small text-dark"><a  data-toggle="modal" class="btn btn-warning small text-dark" style="padding:3px;" data-target="#addReged<?php echo $count; ?>"><i class="fa fa-edit text-dark"></i></a>&nbsp;&nbsp; <a href="whrs_itemView?view_sales_history=<?php echo $reg_std['id']; ?>" class="btn btn-dark small text-dark" style="padding:3px;"><i class="fa fa-eye text-white"></i></a></td></tr>

<!--Edit Product Registratin-->
<div class="modal fade" id="addReged<?php echo $count; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"><div class="modal-dialog" role="document">
<div class="modal-content"><div class="modal-header bg-secondary text-white"><h5 class="modal-title " id="exampleModalLabel">#Modify Product - <span class="text-white"><?php echo $reg_std['item_name']; ?></span></h5><button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div><div class="modal-body">

<form action="" method="POST"><div class="row"><div class="form-group col-md-8"><input type="text" name="prodname" class="form-control" required placeholder="Product Name e.g. LK100 or 3.75KVA" value="<?php echo $reg_std['item_name'];  ?>"></div>
<div class="form-group col-md-4"><input type="text" name="cost" class="form-control" required placeholder="cost" onkeypress="return isNumberKey(event)" value="<?php echo $reg_std['item_cost'] ?>"></div>
<div class="col-md-12"><textarea class="form-control" placeholder="Product Description" name="item_desc" maxlength="160" minlength="10" required><?php echo $reg_std['item_desc'];  ?></textarea></div>


<input type="hidden" name="where" value="<?php echo $reg_std['id']; ?>">
  <div class="form-group col-md-6"><select class="form-control" required name="company"><?php 
for($i=0;$i<count($company);$i++){?><option value="<?php  echo $i; ?>" <?php if($i==$reg_std['company']){echo 'selected';}  ?>><?php echo $company[$i]; ?></option><?php }?></select></div><div class="form-group col-md-6"><select class="form-control" required name="brand"><option value="">--Brand--</option> <?php for($i=0;$i<count($brand);$i++){?><option value="<?php  echo $i; ?>" <?php if($i==$reg_std['brand']){echo 'selected';}  ?>><?php echo $brand[$i]; ?></option><?php }?></select></div>
<div class="form-group col-md-4"><select class="form-control" required name="size"><option value="">--Sized By-</option> <?php for($i=0;$i<count($sized_by);$i++){?>
<option value="<?php  echo $i; ?>" <?php if($i==$reg_std['size']){echo 'selected';}  ?>><?php echo $sized_by[$i]; ?></option><?php }?><</select></div><div class="form-group col-md-4"><select class="form-control" required name="color"><option value="">--Colour--</option> <?php for($i=0;$i<count($colored_by);$i++){?>
<option value="<?php  echo $i; ?>" <?php if($i==$reg_std['color']){echo 'selected';}  ?>><?php echo $colored_by[$i]; ?></option><?php }?></select></div>
<div class="form-group col-md-4"><select class="form-control" required name="tm_status"><option value="1" <?php  if($reg_std['tm_status']==1){ echo 'selected';} ?>>Visible</option><option value="0" <?php  if($reg_std['tm_status']==0){ echo 'selected';} ?>>Remove</option></select></div>

<div class="col-md-12 mt-2"><textarea class="form-control" rows="5" placeholder="Product Details" name="item_details" maxlength="160" minlength="10" required>
    <?php  echo $reg_std['item_details']; ?></textarea></div>

<div class="form-group col-md-12"><input type="submit" name="EditProduct" value="Edit Product" class="form-control btn btn-secondary"></div></div></form>


  </div><div class="modal-footer"><button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button></div></div></div></div>
<?php  } ?></tbody></table></div>
</div>  </div><?php  } ?>




                   

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

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



<?php include('bottom_most.php') ?>
<script type="text/javascript">
//Desktop Keys
$('.remvImg').click(function(e){if(confirm('Are you Sure?')==true){e.preventDefault();
$id =$(this).attr('title'); $item =$(this).attr('id');
$.ajax({data: {item_id: $id,item_index:$item},type: "post",url: "ajaxpage",success: function(data){
    alert('Image Removed');
},error: function(jqXHR, textStatus, errorThrown) { 
$(function(){ setTimeout(function() { alert('There was an Error');}, 5000);})}
});
$(this).prop('disabled',true); $(this).html('removed');
}});

//Mobile keys
$('.remvImgMobile').click(function(e){if(confirm('Are you Sure?')==true){e.preventDefault();
$id =$(this).attr('title'); $item =$(this).attr('id');
$.ajax({data: {item_id: $id,item_index:$item},type: "post",url: "ajaxpage",success: function(data){
    alert('Image Removed');
},error: function(jqXHR, textStatus, errorThrown) { 
$(function(){ setTimeout(function() { alert('There was an Error');}, 5000);})}
});
$(this).prop('disabled',true); $(this).html('removed');
}});



$(document).ready(function(){
$('[id^=submit]').click(function(){ $id =$(this).attr('id').slice(6); var form_data = new FormData(); 
            
// Read selected files
var totalfiles = document.getElementById('files'+$id).files.length;
for (var index = 0; index < totalfiles; index++) {
form_data.append("files[]", document.getElementById('files'+$id).files[index]);}

whereAs =$('#whereas'+$id).val();   prevImgs =$('#prevImgs'+$id).val();
form_data.append('where',whereAs);  form_data.append('prevImg',prevImgs);

$.ajax({url: 'ajaxfile',type: 'post',data: form_data,dataType: 'html',contentType: false,
    processData: false,
success: function (response) { var array = response.split(",");        
for(var index = 0; index < array.length; index++) {var src = array[index];
$('#preview'+$id).append('<div class="col-md-6"><img src="'+src+'" width="90%" class="img img-thumbnail" height="250px"></div>');
}
alert('Upload was Successful');
},error: function(xhr, textStatus, error){ alert('There was a probem');
console.log(xhr.statusText);console.log(textStatus);console.log(error);
}
}); });     });


//Mobile
$(document).ready(function(){
$('[id^=submitM]').click(function(){ $id =$(this).attr('id').slice(7); 
    var form_data = new FormData(); 
            
// Read selected files
var totalfiles = document.getElementById('filesM'+$id).files.length;
for (var index = 0; index < totalfiles; index++) {
form_data.append("files[]", document.getElementById('filesM'+$id).files[index]);}

whereAs =$('#whereasM'+$id).val();   prevImgs =$('#prevImgsM'+$id).val();
form_data.append('where',whereAs);  form_data.append('prevImg',prevImgs);

$.ajax({url: 'ajaxfile',type: 'post',data: form_data,dataType: 'html',contentType: false,
    processData: false,
success: function (response) { var array = response.split(",");        
for(var index = 0; index < array.length; index++) {var src = array[index];
$('#previewM'+$id).append('<div class="col-6"><img src="'+src+'" width="90%" class="img img-thumbnail" height="250px"></div>');
}
alert('Upload was Successful');
},error: function(xhr, textStatus, error){ alert('There was a probem');
console.log(xhr.statusText);console.log(textStatus);console.log(error);
}
}); });     });

    </script>
</body>

</html>