<div class="page-content-wrapper">
                <div class="page-content">
                    <div class="page-bar">
                        <div class="page-title-breadcrumb">
                            <div class=" pull-left">
                                <div class="page-title"><?php if($isEdit){ echo 'Edit Category';} else { echo 'Add Category'; }?></div>
                            </div>
                            <ol class="breadcrumb page-breadcrumb pull-right">
                                <li><i class="fa fa-home"></i>&nbsp;<a class="parent-item" href="index.php?page=home">Home</a>&nbsp;<i class="fa fa-angle-right"></i>
                                </li>
                                <li><a class="parent-item" href="index.php?page=manage_technician">Technician</a>&nbsp;<i class="fa fa-angle-right"></i></li><li class="active">Add Category</li>
                            </ol>
                        </div>
                    </div>
<div class="row">
                        <div class="col-md-12 col-sm-12">
                            <div class="card card-box">
                                <div class="card-head">
                                    <header><?php if($isEdit){ echo 'Edit Category';} else { echo 'Add Category'; }?></header>                                    
                                </div>
                                <div class="card-body" id="bar-parent1">
                                	
                                	<?php if(isset($error) && $error!='') { ?> 
                                	<div class="alert alert-danger"><?php echo $error; ?></div>
                                	<?php } else if(isset($success) && $success!=''){ ?>                                		
                                		<div class="alert alert-success"><?php echo $success; ?></div>
                                	<?php } else if(isset($_REQUEST['success'])){ ?>                                		
                                		<div class="alert alert-success"><?php echo $_REQUEST['success']; ?></div>
                                	<?php } ?>
                                	                                	
                                    <form name="form_staff_add" action="" id="form_staff_add" class="form-horizontal" method="post">
                                        <div class="form-body">
                                        	                               	 
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Select Category<span class="required"> * </span></label>
                                                <div class="col-md-4">                                                    
                                                    <select name="category" id="category" >
                                                    	<option value="">--Select--</option>
										              <?php if(mysqli_num_rows($parentRs)>0){
										              	while($parentRec = mysqli_fetch_array($parentRs)){ 
										              		//get sub cat
										              		$hasSub = FALSE; $alreadyAdded = FALSE;
															if(isset($_REQUEST['tech_id'])){
																//check if already added if so hide it
																$chkRs = mysqli_query($con, "SELECT `id` FROM `tbl_technician_category` WHERE `technician_id` = '".$_REQUEST['tech_id']."' AND category_id = '".$parentRec['id']."'");
																if(mysqli_num_rows($chkRs)>0){ $alreadyAdded = true; }
															}
										              		$subRs = mysqli_query($con, "SELECT id, name FROM tbl_service_categories WHERE parent_id = '".$parentRec['id']."'");	
										              		if(mysqli_num_rows($subRs)>0){  $hasSub = TRUE;	} ?>
										              		<option value="<?php echo $parentRec['id']; ?>" <?php if(isset($_POST['category']) && $_POST['category']==$parentRec['id']) { echo 'selected="selected"'; } else if(isset($resEdit['category_id']) && $resEdit['category_id']==$parentRec['id']){ echo 'selected="selected"'; } else if($hasSub || $alreadyAdded){ echo 'disabled'; } ?> ><?php echo $parentRec['name']; ?></option>
										              		<?php if(mysqli_num_rows($subRs)>0){										              			
										              			while($subRec = mysqli_fetch_array($subRs)){
										              				$alreadyAdded = FALSE; 
										              				if(isset($_REQUEST['tech_id'])){
																		//check if already added if so hide it																		
																		$chkRs = mysqli_query($con, "SELECT `id` FROM `tbl_technician_category` WHERE `technician_id` = '".$_REQUEST['tech_id']."' AND category_id = '".$subRec['id']."'");
																		if(mysqli_num_rows($chkRs)>0){ $alreadyAdded = true; }
																	}?>
										              				<option value="<?php echo $subRec['id']; ?>" <?php if(isset($_POST['category']) && $_POST['category']==$subRec['id']) { echo 'selected="selected"'; } else if(isset($resEdit['category_id']) && $resEdit['category_id']==$subRec['id']){ echo 'selected="selected"'; } else if($alreadyAdded){ echo 'disabled'; } ?> ><?php echo '--'.$subRec['name']; ?></option>
										              		<?php } } ?>
										              <?php } } ?>
										            </select>
										            
                                                </div>
                                            </div>
                                            <!--<div class="form-group row">
                                                <label class="control-label col-md-3">Hourly Rate</label>
                                                <div class="col-md-4">                                                    
                                                    <input name="rate" type="text" id="rate" data-required="1" class="form-control" value="<?php if(isset($_POST['rate'])) { echo htmlentities(($_POST['rate']), ENT_QUOTES); } else if(isset($resEdit['rate']) && $resEdit['rate']!=''){ echo $resEdit['rate'];} ?>"/>
                                                </div>
                                            </div>-->
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Experience<span class="required"> * </span></label>
                                                <div class="col-md-4">                                                    
                                                    <select name="experience" id="experience" >
                                                    	<option value="">--Select--</option>
                                                    	<option value="fresher" <?php if(isset($_POST['experience']) && $_POST['experience']=='fresher'){ echo 'selected'; } else if(isset($resEdit['experience']) && $resEdit['experience']=='fresher'){ echo 'selected'; } ?> >Fresher</option>
                                                    	<option value="beginner" <?php if(isset($_POST['experience']) && $_POST['experience']=='beginner'){ echo 'selected'; } else if(isset($resEdit['experience']) && $resEdit['experience']=='beginner'){ echo 'selected'; } ?> >Beginner (0-1 yrs)</option>
                                                    	<option value="mid" <?php if(isset($_POST['experience']) && $_POST['experience']=='mid'){ echo 'selected'; } else if(isset($resEdit['experience']) && $resEdit['experience']=='mid'){ echo 'selected'; } ?> >Intermediate (1-5 yrs)</option>
                                                    	<option value="professional" <?php if(isset($_POST['experience']) && $_POST['experience']=='professional'){ echo 'selected'; } else if(isset($resEdit['experience']) && $resEdit['experience']=='professional'){ echo 'selected'; } ?> >Professional (5-10 yrs)</option>
                                                    	<option value="expertise" <?php if(isset($_POST['experience']) && $_POST['experience']=='expertise'){ echo 'selected'; } else if(isset($resEdit['experience']) && $resEdit['experience']=='expertise'){ echo 'selected'; } ?> >Expert (10+ yrs)</option>
                                                    </select>
                                                </div>
                                            </div>
                                            
                                            
                                        </div>                                        
                                      	<div class="form-group">
                                            <div class="offset-md-3 col-md-9">
                                            	<?php if($isEdit){ ?>
                                            		<button type="submit" name="update" class="btn btn-info">Update</button>
                                            	<?php } else { ?>
                                            		<button type="submit" name="add" class="btn btn-info">Submit</button>
                                            	<?php } ?>    
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
	</div>
</div>
