<?php
include_once 'includes/processes.php';
$Process = new Login_Process;
$Process->check_status($_SERVER['SCRIPT_NAME']);
$chooseCategory = $Process->chooseCategory($_POST,$_POST['save']);
?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
  <title>Sell a Product | SellerHQ</title>

  <meta charset="utf-8">
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width">

  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,700italic,400,600,700">
  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,300,700">
  <link rel="stylesheet" href="./css/font-awesome.min.css">
  <link rel="stylesheet" href="./js/libs/css/ui-lightness/jquery-ui-1.9.2.custom.min.css">
  <link rel="stylesheet" href="./css/bootstrap.min.css">
  <link rel="stylesheet" href="./js/plugins/fileupload/bootstrap-fileupload.css">

    <!-- App CSS -->
  <link rel="stylesheet" href="./css/target-admin.css">
  <link rel="stylesheet" href="./css/custom.css">


  <script type="text/javascript" src="//code.jquery.com/jquery-1.8.3.js"></script>
  <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
  <![endif]-->
	<script>
	
	<?php echo $Process->JScategoriesOptionsFirstLevel(); ?>
	
	
	<?php echo $Process->JScategoriesOptionsSecondLevel(); ?>
		
	function selectchange(){
		var select = $('[name=subcat]');
		select.empty();
		$.each(categories[$(':selected', this).text()], function(){
			select.append('<option value="'+this.value+'">'+this.text+'</option>');
		});
	}
	
	function selectchange2(){
		var select2 = $('[name=subcat2]');
		select2.empty();
		select2.append('<option value="0" selected>None</option>');		
		$.each(subcategories[$(':selected', this).text()], function(){
			select2.append('<option value="'+this.value+'">'+this.text+'</option>');
		});
	}
	
	$(function(){
		$('[name=category]').on('change', selectchange);
	});
	
	$(function(){
		$('[name=subcat]').on('change', selectchange2);
	});

	</script>
</head>

<body>

 <?php include"includes/header.php"; ?>

<div class="container">

  <div class="content">

    <div class="content-container">

      

      <div class="content-header">
        <h2 class="content-header-title">Choose Product Category</h2>
        <ol class="breadcrumb">
          <li class="active">Choose Product Category</li>
          <li>Give Product Description</li>
          <li>Review Your Product and Submit</li>
        </ol>
      </div> <!-- /.content-header -->

      
	<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
      <div class="portlet">

        <div class="portlet-header">

          <h3>
            <i class="fa fa-tasks"></i>
           Choose Product Category
          </h3>

        </div> <!-- /.portlet-header -->

        <div class="portlet-content">

          <div class="row">

            <div class="col-sm-4">

              <div class="form-group">
                <label for="category">Category</label>
                <select multiple="multiple" id="category" name="category" class="form-control" size="10" required>
                  <?php 
					if(isset($_SESSION['level1_cat'])) {
						$Process->ListCategories($_SESSION['level1_cat']); 
					}else{
						$Process->ListCategories($_SESSION['level1_cat']);
					}
				  ?>
                </select>
              </div>
			  </div>

            <div class="col-sm-4">
			
              <div class="form-group">
                <label for="subcategory1">Sub-categories</label>
                <select multiple="multiple" id="subcategory1" name="subcat" class="form-control" size="10" required>
                  <?php 
					if(isset($_SESSION['level1_cat'])) {
						$Process->listSubCat($_SESSION['level1_cat'],$_SESSION['level2_cat']);
					}
					?>
                </select>
              </div>

            </div> <!-- /.col -->

            <div class="col-sm-4">
			
             <div class="form-group">
                <label for="subcategory2">Sub-categories</label>
                <select multiple="multiple" id="subcategory2" name="subcat2" class="form-control" size="10">
                  <?php 
					if(isset($_SESSION['level1_cat'])) {
						$Process->listSubCat($_SESSION['level2_cat'],$_SESSION['level3_cat']); 
					}
				  ?>
                </select>
              </div>
            </div> <!-- /.col -->

          </div> <!-- /.row -->


        </div> <!-- /.portlet-content -->

      </div> <!-- /.portlet -->

    
		<button type="submit" name="save" class="btn btn-success">Save & Continue</button>


        </form>

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

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

<?php include"includes/footer.php"; ?>

  <script src="./js/libs/jquery-1.10.1.min.js"></script>
  <script src="./js/libs/jquery-ui-1.9.2.custom.min.js"></script>
  <script src="./js/libs/bootstrap.min.js"></script>
  <script src="./js/plugins/fileupload/bootstrap-fileupload.js"></script>
  <script src="./js/plugins/ckeditor/ckeditor.js"></script>
  <script src="./js/plugins/autosize/jquery.autosize.min.js"></script>
  <script src="./js/plugins/textarea-counter/jquery.textarea-counter.js"></script>
  <!--[if lt IE 9]>
  <script src="./js/libs/excanvas.compiled.js"></script>
  <![endif]-->
  <!-- App JS -->
  <script src="./js/target-admin.js"></script>
  


  
</body>
</html>
