<?php require_once('includes/check-login.php'); ?>
<?php require_once('includes/header.php'); ?>
    <?php require_once('includes/menu.php'); ?>

        <!-- Datatable CSS -->
        <link href='data_tables/datatables.min.css' rel='stylesheet' type='text/css' />        

        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">                
                    <small><a href="javascript:void(0);" class="newCat"><i class="fa fa-plus"></i> Secondary Category</a></small>
                   
                    <ol class="breadcrumb">
                        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>                    
                        <li class="active"><a href="secondary-category.php">Secondary Category</a></li>           
                    </ol>                
            </section>

            <!-- Main content -->
            <section class="content">                
                <!-- Default box -->
                <div class="box box-form">
                    <div class="box-header with-border">
                        <h3 class="box-title">Secondary Category</h3>
                        <div class="box-tools pull-right">
                            <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
                                <i class="fa fa-minus"></i></button>
                            <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
                                <i class="fa fa-times"></i></button>
                        </div>
                    </div>
                    <div class="box-body">                        
                        <table id='SecondaryCategory' class='display dataTable table table-bordered table-hover'>
                            <thead>
                            <tr>
                                <th>Primary Category</th>
                                <th>Secondary Category</th>                                
                                <th>Active</th>
                                <th>Avatar</th>
                                <th>Created On</th>
                                <th>Edit</th>
                                <th>Delete</th>
                            </tr>
                            </thead>                
                        </table>
                    </div>
                    <!-- /.box-body -->                    
                    <div class="col-lg-12 message"></div>
                </div>
                <!-- /.box -->

            </section>
            <!-- /.content -->                                        
        </div>
        <!-- /.content-wrapper -->        


        <div class="modal fade" id="categoryModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="categoryTitle"></h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-lg-12 message"></div>
                            <form role="form" id="categoryForm">                                
                                <div class="col-md-12">

                                    <div class="form-group">
                                        <label>Primary Category</label>
                                        <br>
                                        <?php 
                                            require_once('includes/config.php');
                                            $psql = "SELECT category_id, category_name FROM parent_categories WHERE active = 1 AND category_id NOT IN ( 1, 2 )";
                                            $pexe = mysqli_query( $con, $psql );
                                            ?>
                                        <select id="category_name" name="category_name" class="form-control">
                                            <option value="-1">---Select---</option>
                                            <?php while( $prows = mysqli_fetch_assoc( $pexe ) ) { ?>
                                                <option value="<?php echo $prows['category_id']; ?>"><?php echo $prows['category_name']; ?></option>
                                            <?php } ?>
                                        </select>
                                    </div>

                                    <div class="form-group">
                                        <label>Category Name</label>
                                        <br>
                                        <input type="text" class="form-control" id="sec_category_name" name="sec_category_name" placeholder="Secondary Category Name" value="" />
                                    </div>                                    

                                    <div class="form-group">
                                        <label>Category Image</label>
                                        <br>
                                        <input type="file" class="fa fa-file form-control" id="cat_img" name="cat_img" />
                                    </div>

                                    <div class="form-group">
                                        <label>Active</label>
                                        <br>
                                        <select id="active" name="active" class="form-control">
                                            <option value="-1">-- Active --</option>
                                            <option value="1" selected="selected">Active</option>
                                            <option value="0">Inactive</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-xs-12">
                                    <button type="button" class="btn btn-primary" id="CategoryBtn">Save</button>
                                    <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
  <div class="modal fade" id="descriptionTitleModal" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Edit Secondary Category</h4>
        </div>
        <div class="modal-body">
          <!-- edit content start -->
            <form id="editSecondaryCat" enctype="multipart/form-data">
                <center><div class="message"></div></center>
                <input type="hidden" id="id" name="id" class="form-control">

                <div class="col-md-12">
                    <div class="form-group">
                        <label>Primary Category</label>
                            <select class="form-control" id="primary_name" name="primary_name">
                                <option value="-1">---Select---</option>
                                <?php
                                $dtsql = "SELECT category_id,category_name FROM parent_categories  WHERE active = 1";
                                $dtexe = mysqli_query( $con, $dtsql );
                                ?>                                        
                                <?php
                                while( $dtrows = mysqli_fetch_assoc( $dtexe ) ) { ?>
                                    <option value="<?php echo $dtrows['category_id']; ?>">
                                        <?php echo $dtrows['category_name']; ?>                                            
                                    </option>
                                <?php } ?>                                        
                            </select> 
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="form-group">
                        <label>Category Name</label>
                        <input type="text" id="subCat_name" name="subCat_name" class="form-control">
                    </div>
                </div>

                <div class="col-md-12">
                    <div class="form-group">
                        <label>Category Image</label>
                        <input type="hidden" id="old_img" name="old_img">
                        <input type="file" id="img_cat" name="img_cat" class="form-control">
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="form-group">
                        <label>Status</label>
                            <select class="form-control" name="status" id="status">
                                <option value="-1">---Select---</option>
                                <option value="1">Active</option>
                                <option value="0">In-active</option>
                            </select> 
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="form-group">
                        <button type="button" name="edit_description" id="edit_description" value="Update" class="btn btn-primary float-left updateSecCat" >Save</button>
                        <button type="button" class="btn btn-primary float-left" data-dismiss="modal" >Close</button>
                    </div>
                </div>    
            </form> 
          <!-- edit content end -->
        </div>
        <br />
        <div class="modal-footer">
        </div>
      </div>
      
    </div>
  </div>                
<script src="js/common.js"></script>         
<script src="js/sc/script.js"></script>     
<?php require_once('includes/footer.php'); ?>