<?php
include_once('../helpers/init.php');
include_once('header.php');

$id = $_GET['id'];
$staten = getWhere("products","id",$id);
foreach($staten as $rows)
?>
<!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">
        <meta name="description" content="">
        <meta name="author" content="">

        <title>Product List Management</title>

        <!-- Bootstrap Core CSS -->
        <link href="../css/bootstrap.min.css" rel="stylesheet">

        <!-- MetisMenu CSS -->
        <link href="../css/metisMenu.min.css" rel="stylesheet">

        <!-- DataTables CSS -->
        <link href="../css/dataTables/dataTables.bootstrap.css" rel="stylesheet">

        <!-- DataTables Responsive CSS -->
        <link href="../css/dataTables/dataTables.responsive.css" rel="stylesheet">

        <!-- Custom CSS -->
        <link href="../css/startmin.css" rel="stylesheet">

        <!-- Custom Fonts -->
        <link href="../css/font-awesome.min.css" rel="stylesheet" type="text/css">
    </head>
    <body>

        <div id="wrapper">

            <!-- Navigation -->
            <?php include 'navs.php'; ?>
            <div id="page-wrapper">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-lg-12">
                            <h1 class="page-header">Product List for <?= $rows['title'];?> </h1>
                        </div>
                        <!-- /.col-lg-12 -->
                    </div>
                    <!-- /.row -->
                    <div class="row">
                        <div class="col-lg-8">
                            <div class="panel panel-default">
                                
                                <div class="panel-heading">
                                    <b>Product List Here</b>
                                </div>
                                <?php
if(isset($_GET['result']) && $_GET['result']=="success"){
?>
<div class="alert alert-success alert-dismissible">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>Success!</strong> Added Successfully!
</div>
<?php
}
                                
if(isset($_GET['result']) && $_GET['result']=="picfaild"){
?>
<div class="alert alert-danger alert-dismissible">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>Error!</strong> Fix the Image Dimension Width-300px and Height-300px
</div>
<?php
}
                                
if(isset($_GET['result']) && $_GET['result']=="picfailer"){
?>
<div class="alert alert-danger alert-dismissible">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>Worning!</strong> Image Size Should not be greater than 350KB
</div>
<?php
}
 
if(isset($_GET['result']) && $_GET['result']=="dsuccess"){
?>
<div class="alert alert-success alert-dismissible">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>Success!</strong> Deleted Successfully!
</div>
<!---->                               
<?php
}
if(isset($_GET['result']) && $_GET['result']=="failer"){
?>
<div class="alert alert-danger alert-dismissible">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>Fail!</strong><?php if(isset($_GET['message'])){echo $_GET['message']; } ?>
</div>
<?php
}
?>
                                <!-- /.panel-heading -->
                                <div class="panel-body">                                    
                                    <div class="table-responsive">
                                        <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                            <thead>
                                                <tr>
                                                    <th>Product Name</th>
                                                    <th>Details</th>
                                                    <th style="width:85px;">Picture</th>
                                                    <th style="width:40px;">Action </th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                $texts = getWhere("productlist","proid",$id);
                                                foreach($texts as $row){
                                                ?>
                                                <tr class="odd gradeX">
                                                    <td><?php echo $row['name']; ?></td>
                                                    <td><?php echo $row['details']; ?></td>
                                                    <td><img style="width:85px;" src="../uploads/products/<?php echo $row['picture']; ?>"></td>
                                                    <td class="center">
                                                        <div class="btn-group">                      
                      	<a onclick="return confirm('Sure You Want to Delete?');" href="../process/productlist-functions.php?id=<?php echo $row['id']; ?>&action=delProduct"class="btn btn-sm btn-danger"><span class="fa fa-trash-o"></span> Del</a>
                                                            

                      </div>
                                                    </td>
                                                </tr>
                                                <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                    <!-- /.table-responsive -->                                    
                                </div>
                                <!-- /.panel-body -->
                            </div>
                            <!-- /.panel -->
                        </div>
                        <!-- /.left part ends here -->
                        <div class="col-lg-4">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <b>Add Product Here</b>
                                </div>
                                <!-- /.panel-heading -->
                                 <div class="panel-body">
                                    <div class="row">
                                        <div class="col-md-12">
                                            <form role="form" id="productForm" action="../process/productlist-functions.php" method="post" enctype="multipart/form-data">
                                                <div class="col-md-12">
                                                    <div class="form-group">
                                                          <div class="form-label-group">
                                                              <input type="hidden" name="proid" value="<?php echo $id; ?>">
                                                            <input  name="proname" type="text" id="name" class="form-control" placeholder="Enter Product Name" autofocus="autofocus" /> 
                                                          </div>
                                                    </div>
                                                    <div class="form-group">
                                                            <div class="form-label-group">
                                                             <textarea id="editor1" name="details" placeholder="Enter Product Details" autofocus="autofocus" class="form-control"></textarea>
                                                          </div>
                                                     </div>
                                                     <div class="form-group">
                                                    <input type="hidden" name="clid" value="<?php echo $row['id']; ?>">
                                                    <label>Image [W-300px || H-300px and size - 100KB]</label>
                                                    <input required type="file" name="file" class="form-control">
                                                </div>
                                                </div>   
                                                 <div class="form-group">
                                                    <input type="submit" name="addProduct" class="btn btn-primary productFormSubmit" value="Add Product" />
                                                 </div>
                                            </form>
                                        </div>
                                        <!-- /.col-lg-6 (nested) -->
                                    </div>
                                    <!-- /.row (nested) -->
                                </div>
                                <!-- /.panel-body ends here -->                                        
                            </div> 
                            <!-- /.panel -->
                        </div>
                        <!--//right part here-->
                    </div>
                    <!-- /.row --->
                </div>
                <!-- /.container-fluid -->
            </div>
            <!-- /#page-wrapper -->

        </div>
        <!-- /#wrapper -->

        <!-- jQuery -->
        <script src="../js/jquery.min.js"></script>

        <!-- Bootstrap Core JavaScript -->
        <script src="../js/bootstrap.min.js"></script>

        <!-- Metis Menu Plugin JavaScript -->
        <script src="../js/metisMenu.min.js"></script>
        
        <!-- DataTables JavaScript -->
        <script src="../js/dataTables/jquery.dataTables.min.js"></script>
        <script src="../js/dataTables/dataTables.bootstrap.min.js"></script>

        <!-- Custom Theme JavaScript -->
        <script src="../js/startmin.js"></script>
        <!-- Page-Level Demo Scripts - Tables - Use for reference -->
        <script>
            $(document).ready(function() {
                $('#dataTables-example').DataTable({
                        responsive: true
                });
            });
        </script>!-- Metis Menu Plugin JavaScript -->
        <script src="../js/metisMenu.min.js"></script>
        <script src="../assets/ckeditor/ckeditor.js"></script>
        <script src="../assets/jquery-ui/jquery-ui.js"></script>
        <script>
        CKEDITOR.replace( 'editor1' );
    </script>

    </body>
</html>
