<?php  $this->load->view('master/common/header.php',$data);
$base_name = $data['base_name'];
?>

    <div class="content">
        
        <!-- Start Content-->
        <div class="container-fluid">
            
            <!-- start page title -->
            <div class="row">
                <div class="col-12">
                    <div class="page-title-box">
                        <div class="page-title-right">
                            <ol class="breadcrumb m-0">
                                <li class="breadcrumb-item"><a href="javascript: void(0);"><?= $base_name;?></a></li>
                                <li class="breadcrumb-item active text-capitalize"><?= $page;?></li>
                            </ol>
                        </div>
                        <h4 class="page-title text-uppercase"><?= $page;?></h4>
                    </div>
                </div>
            </div>     
            <!-- end page title --> 

            <div class="row">
                <div class="col-md-6 col-xl-6">
                    <div class="card-box">
                        <div class="row">
                            <div class="col-sm-12">
                                <form class="form-horizontal" action="<?= base_url('master/end_category/edit_content/'.$end_category['ecat_id']);?>" method="post" enctype="multipart/form-data">
                                    <input type="hidden" name="table" value="tbl_end_category" />
                                    <input type="hidden" name="page" value="end_category/edit/<?=$end_category['ecat_id'];?>" />
                                    <div class="form-group">
                                        <label for="userName">Top Category <span class="text-danger">*</span></label>
                                        <select name="tcat_id" required=""  id="tcat_id"  onchange="myFunction()" class="form-control" >
                                            <option value=""> Select Top Category </option>
                                            
                                            <?php if (!empty($top_category)) {?>
                                                <?php foreach ($top_category as $row) {?>
                                                    <option value="<?=$row['tcat_id'];?>" <?=($end_category['tcat_id'] == $row['tcat_id']) ? 'selected' : '';?>><?=$row['tcat_name'];?></option>
                                                <?php } ?>
                                            <?php } ?>
                                        </select>
                                    </div>
                                    
                                    <div class="form-group">
                                        <label for="userName">Mid Category <span class="text-danger">*</span></label>
                                        <select name="mcat_id" required="" id="mcat_id" class="form-control" value="<?=$mid_category['mcat_id'];?>">
                                            <?php if(isset($mid_category)){ ?>
                                            <option value="<?=$mid_category['mcat_id'];?>"><?=$mid_category['mcat_name'];?></option>
                                            <?php } ?>
                                        </select>
                                    </div>
                                    <h4 class="header-title mb-4">Photo (225 X 225)px </h4>
                                    <input type="file" name="ecat_pic" class="dropify" data-default-file="<?= base_url('uploads/shop/end_category/'.$end_category['ecat_pic']);?>" data-max-file-size="1M" />
                                    '
                                    <h4 class="header-title mb-4">Name</h4>
                                    <div class="form-group">
                                        <input type="text" name="ecat_name" required="" value="<?=$end_category['ecat_name'];?>" class="form-control" />
                                    </div>
                                 
                                    <h4 class="header-title">Status</h4>
                                    <div class="form-group mb-5">
                                        <div class="custom-control custom-radio float-left">
        									<input class="custom-control-input" value="1" type="radio" id="statusActive" required name="status"  <?php echo ($end_category['status'] == 1) ? 'checked' : '';?>>
        									<label for="statusActive" class="custom-control-label">Active</label>
        								</div>
        								<div class="custom-control custom-radio float-left ml-3">
        									<input class="custom-control-input" value="0" type="radio" id="statusBlock" required name="status" <?php echo ($end_category['status'] == 0) ? 'checked' : '';?>>
        									<label for="statusBlock" class="custom-control-label">Block</label>
        								</div>
                                    </div>
                                    
                                    
                                    <h4 class="header-title mb-4">Status Home</h4>
                                    <div class="form-group mb-5">
                                        <div class="custom-control custom-radio float-left">
        									<input class="custom-control-input" value="1" type="radio" id="statushomeActive" required name="status_home"  <?php echo ($end_category['status_home'] == 1) ? 'checked' : '';?>>
        									<label for="statushomeActive" class="custom-control-label">Active</label>
        								</div>
        								<div class="custom-control custom-radio float-left ml-3">
        									<input class="custom-control-input" value="0" type="radio" id="statushomeBlock" required name="status_home" <?php echo ($end_category['status_home'] == 0) ? 'checked' : '';?>>
        									<label for="statushomeBlock" class="custom-control-label">Block</label>
        								</div>
                                    </div>
                                    
                                    <div class="form-group">
                                        <button type="submit" class="btn btn-success float-right m-2">Submit</button>
                                        <a href="<?php echo base_url().'master/end_category/'?>" class="btn float-right m-2 btn-secondary" title="">Back</a>
                                    </div>
                                
                                </form>
				            </div>
					    </div>
					</div>
				</div>
				<!-- /.col-md-6 -->
			</div>
			<!-- /.row -->
		</div>
		<!-- /.container-fluid -->
	</div>
	<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<?php $this->load->view('master/common/footer.php'); ?>
<script>
	function myFunction(){
	    var tcat_id = $("#tcat_id").val();
	   // alert(tcat_id);
        $.post("<?php echo base_url();?>master/end_category/get_mid_category ",
        {
            tcat_id: tcat_id
        },
  function(data, status){
    //   alert(data);
     $("#mcat_id").html(data);
  });
	   

	}
</script>