<? $global_language; ?>

<div class="form-group">
	<label class="col-sm-2 control-label"><? echo $vis_language['TXTSTATUS']; ?></label>
	<div class="col-sm-10">
		<select name="vis_status" class="form-control input-sm selectpicker" <? if(count($status_list)>10) echo 'data-live-search="true"';?>>
			<option value="0"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['status'] == 0) ? ' selected="selected"' : '';?>><? echo $vis_language['TXTNOCHANGE']; ?></option>
			<? 	if(isset($status_list) && $status_list != -1) {
			foreach($status_list as $list) { ?>                        
			<option value="<?= $list['status_id'];?>"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['status'] == $list['status_id']) ? ' selected="selected"' : '';?>><? echo $list['status_name']; ?></option>
	<? 		}					
		} ?>
		</select>					
	</div>
</div>
<? if(!isset($module_setting['vis_show_priority']) || (isset($module_setting['vis_show_priority']) && $module_setting['vis_show_priority']==1 || $module_setting['vis_show_priority']==2)){ ?>
<div class="form-group">
	<label class="col-sm-2 control-label"><? echo $vis_language['TXTPRIORITY']; ?></label>
	<div class="col-sm-10">
		<select name="vis_priority" class="form-control input-sm selectpicker" <? if(count($priority_list)>10) echo 'data-live-search="true"';?>>
		<option value="0"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['priority'] == 0) ? ' selected="selected"' : '';?>><? echo $vis_language['TXTNOCHANGE']; ?></option>
	<? 	if(isset($priority_list) && $priority_list != -1) {
			foreach($priority_list as $list) { ?>                        
			<option value="<?= $list['priority_id'];?>"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['priority'] == $list['priority_id']) ? ' selected="selected"' : '';?>><? echo $list['priority_name']; ?></option>
	<? 		}					
		} ?>
		</select>
	</div>
</div>
<? } ?>
<? if(!isset($module_setting['vis_show_tickettype']) || (isset($module_setting['vis_show_tickettype']) && $module_setting['vis_show_tickettype']==1 || $module_setting['vis_show_tickettype']==2)){ ?>
<div class="form-group">
	<label class="col-sm-2 control-label"><? echo $vis_language['TXTTYPE']; ?></label>
	<div class="col-sm-10">
		<select name="vis_type" class="form-control input-sm selectpicker" <? if(count($type_list)>10) echo 'data-live-search="true"';?>>
		<option value="0"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['type'] == 0) ? ' selected="selected"' : '';?>><? echo $vis_language['TXTNOCHANGE']; ?></option>
	<? 	if(isset($type_list) && $type_list != -1) { 
			foreach($type_list as $list) { ?>                        
			<option value="<?= $list['type_id'];?>"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['type'] == $list['type_id']) ? ' selected="selected"' : '';?>><? echo $list['type_name']; ?></option>
	<? 		}
		} ?>
		</select>					
	</div>
</div>
<? } ?>
<? if(isset($module_setting['vis_show_level']) && ($module_setting['vis_show_level']==1 || $module_setting['vis_show_level']==2)){ ?>
<div class="form-group">
	<label class="col-sm-2 control-label"><? echo $vis_language['TXTTICKETLEVEL']; ?></label>
	<div class="col-sm-10">
		<select name="vis_level" class="form-control input-sm selectpicker" <? if(count($level_list)>10) echo 'data-live-search="true"';?>>
		<option value="0"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['level_id'] == 0) ? ' selected="selected"' : '';?>><? echo $vis_language['TXTNOCHANGE']; ?></option>
	<? 	if(isset($level_list) && $level_list != -1) { 
			foreach($level_list as $levellist) { ?>                        
			<option value="<?= $levellist['level_id'];?>"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['level_id'] == $levellist['level_id']) ? ' selected="selected"' : '';?>><? echo $levellist['title']; ?></option>
	<? 		}
		} ?>
		</select>					
	</div>
</div>
<? }?>

<? if(isset($module_setting['vis_show_category']) && ($module_setting['vis_show_category']==1 || $module_setting['vis_show_category']==2)){ ?>
<div class="form-group">
	<label class="col-sm-2 control-label"><? echo $vis_language['TXTTICKETCATEGORY']; ?></label>
	<div class="col-sm-10">
		<select name="vis_category" onchange="get_subcategory(this.value,0)" class="form-control input-sm selectpicker" <? if(count($category_list)>10) echo 'data-live-search="true"';?>  onchange="" >
		<option value="0"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['category_id'] == 0) ? ' selected="selected"' : '';?>><? echo $vis_language['TXTNOCHANGE']; ?></option>
	<? 	if(isset($category_list) && $category_list != -1) { 
			foreach($category_list as $catlist) { ?>                        
			<option value="<?= $catlist['category_id'];?>"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['category_id'] == $catlist['category_id']) ? ' selected="selected"' : '';?>><? echo $catlist['title']; ?></option>
	<? 		}
		} ?>
		</select>					
	</div>
</div>

<? if(isset($module_setting['vis_show_subcategory']) && ($module_setting['vis_show_subcategory']==1 || $module_setting['vis_show_subcategory']==2)){ $displaySubCategory = 1;?>
<div class="form-group">
	<label class="col-sm-2 control-label"><? echo $vis_language['TXTTICKETSUBCATEGORY']; ?></label>
	<div class="col-sm-10">
    <div id="ajxsubcate">
		<select name="vis_subcategory" class="form-control input-sm selectpicker" <? if(count($subcategory_list)>10) echo 'data-live-search="true"';?>  onchange="getitem(this.value);" >
		<option value="0"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['subcategory_id'] == 0) ? ' selected="selected"' : '';?>><? echo $vis_language['TXTNOCHANGE']; ?></option>
<? 	if(isset($subcategory_list) && $subcategory_list != -1) { 
			foreach($subcategory_list as $subcatlist) { ?>                        
			<option value="<?= $subcatlist['subcategory_id'];?>"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['subcategory_id'] == $subcatlist['subcategory_id']) ? ' selected="selected"' : '';?>><? echo $subcatlist['title']; ?></option>
	<? 		}} ?>
		</select>	
        </div>				
	</div>
</div>
<? }?>

<? if(isset($module_setting['vis_show_item']) && ($module_setting['vis_show_item']==1 || $module_setting['vis_show_item']==2) &&  $displaySubCategory == 1){ ?>

<div class="form-group">
	<label class="col-sm-2 control-label"><? echo $vis_language['TXTTICKETITEM']; ?></label>
	<div class="col-sm-10">
    <div id="ajxsitem">
		<select name="vis_item" class="form-control input-sm selectpicker" <? if(count($item_list)>10) echo 'data-live-search="true"';?>>
		<option value="0"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['item_id'] == 0) ? ' selected="selected"' : '';?>><? echo $vis_language['TXTNOCHANGE']; ?></option>
<? 	if(isset($item_list) && $item_list != -1) { 
			foreach($item_list as $itemlist) { ?>                        
			<option value="<?= $itemlist['item_id'];?>"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['item_id'] == $itemlist['item_id']) ? ' selected="selected"' : '';?>><? echo $itemlist['title']; ?></option>
	<? 		}} ?>
		</select>		
        </div>			
	</div>
</div>
<? }?>

<? }?>


<? if(VIS_ITIL==1){?>
<div class="form-group">
	<label class="col-sm-2 control-label"><? echo $vis_language['TXTLOCATION']; ?></label>
	<div class="col-sm-10">
		<select name="vis_location"  class="form-control input-sm selectpicker" id="vis_location">
		<option value="0"><? echo $vis_language['TXTSELECT']; ?></option>
									    <?	if(isset($location_assets) && $location_assets!=NULL && $location_assets!=-1) {
										vis_show_subcategories($location_assets,'',$macro_details['location_id']); ?>
										<?  } ?>
		</select>					
	</div>
</div>
<? }?>

<div class="form-group">
	<label class="col-sm-2 control-label"><? echo $vis_language['TXTFLAG']; ?></label>
	<div class="col-sm-10">
    <div >
		<select name="vis_flag" class="form-control input-sm selectpicker" <? if(count($item_list)>10) echo 'data-live-search="true"';?>>
		<option value="0"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['flag_id'] == 0) ? ' selected="selected"' : '';?>><? echo $vis_language['TXTNOCHANGE']; ?></option>
<? 	if(isset($flag_list) && $flag_list != -1) { 
			foreach($flag_list as $flag_list) {
				 if($flag_list['flag_color']=='#ffffff'){
						 $class_var="vh-flag-empty";
						 $color='';
						 }
						 else{
						 $class_var="vh-flag";
						 $color=$flag_list['flag_color'];
						 }
				 ?>     
   <option data-icon="vh vh-lg <?=$class_var?>" style="color:<?=$color?>"  <? if($flag_list['flag_id']==$macro_details['flag_id']) echo 'selected="selected"';?>  value="<?= $flag_list['flag_id']; ?>"><?= $flag_list['flag_name'];?></option>                   
			
	<? 		}} ?>
		</select>		
        </div>			
	</div>
</div>

<div class="form-group">
	<label class="col-sm-2 control-label"><? echo $vis_language['TXTOWNER']; ?></label>
	<div class="col-sm-10">
		<label class="checkbox-inline i-checks"><input onchange="$('#dept_access_list').toggle();" type="checkbox" name="vis_owner[]" value="0"<?= (isset($macro_details) && $macro_details != -1 && $macro_details['owner'] == 0 || !isset($macro_details) ) ? ' checked="checked"' : '';?> /> <i></i>&nbsp;<? echo $vis_language['TXTNOCHANGE']; ?></label>
		<div class="dept_access_list m-t" style="<?= ($macro_details['owner'] != 0) ? '':'display:none;'?>" id="dept_access_list">
		<? $owner = explode(",", $macro_details['owner']); ?>
			<? for($i=0; $i<count($staff_list); $i++){ ?>
			<label class="checkbox-inline i-checks"><input type="checkbox" name="vis_owner[]" value="<?= $staff_list[$i]['staff_id']; ?>"<?= (isset($macro_details) && $macro_details != -1 && in_array($staff_list[$i]['staff_id'], $owner)) ? ' checked="checked"' : '';?> /> <i></i>&nbsp;<? echo $staff_list[$i]['first_name'].' '.$staff_list[$i]['last_name']; ?></label><br/>
			 <? } ?>
	   </div>
	</div>
</div>

    <div class="form-group">
        <label class="col-sm-2 control-label"><? echo $vis_language['TXTLABEL']; ?></label>
        <div class="col-sm-10">
            <div class="dept_access_list">
            <? 	$labels = explode(",", $macro_details['labels']);
                for($i=0;$i<count($labels_list);$i++){ ?>
                <label class="checkbox-inline i-checks"><input type="checkbox" name="vis_label[]" value="<?= $labels_list[$i]['label_id']; ?>"<?= (isset($macro_details) && $macro_details != -1 && in_array($labels_list[$i]['label_id'], $labels)) ? ' checked="checked"' : '';?> /> <i></i>&nbsp;<span style="background-color: <?= $labels_list[$i]['label_color']?>; color: #fff;" class="m-l-xs footer font-normal"><? echo $labels_list[$i]['label_name']; ?></span></label><br/>
                 <? } ?>
           </div>
       </div>
    </div>
	<?php
	function vis_show_subcategories($location_assets,$call=NULL,$location_id) {
         
        for($i=0;$i<count($location_assets);$i++) { if($location_id==$location_assets[$i]['location_id']){$selecteda=' selected="selected"'; }else{$selecteda='';} ?>
		 <? echo '<option value="'.$location_assets[$i]['location_id'].'" '.$selecteda.' >'.ucfirst($location_assets[$i]['name']). '</option>';?>
		 <?php 
			if(isset($location_assets[$i]['subcat']) && $location_assets[$i]['subcat']!=NULL) { 
					 
		     vis_show_subcategories($location_assets[$i]['subcat'],'sub_cat',$location_id); 
			}
		}
		
    }
	?>
    <style>
.selectpicker span:nth-child(2){
color:#000000 !important;
}
</style>
   <script type="text/javascript">
	   $(".selectpicker").selectpicker();
    
    function get_subcategory(catid,subcatid) {
	
	  if(subcatid ==0)getitem();
	  $('#ajxsubcate').visExecution('load_operations', {'vis_module':'home', 'vis_operation':'get_ticket_drp_subcategory', 'vis_category_id':catid}); 
	  
    }
   function getitem(subcatid)
   {
	  
	  $('#ajxsitem').visExecution('load_operations', {'vis_module':'home', 'vis_operation':'get_ticket_drp_item', 'vis_subcategory_id':subcatid}); 
	  
   }
   </script>
   
