<? global $vis_language; ?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
   <div class="col-sm-6">
      <h3 class="m-b-xs text-black"><? echo ($operation['show_report']==6)?$vis_language['TXTCUSTOMREPORT']:$vis_language['TXTSEARCH']; ?></h3>
      <ul class="breadcrumb bg-empty no-border m-b-xxs no-padder">
         <li><a class="link" href="#/home/quick_view/<? echo $vis_language['TXTHOME']; ?>"><? echo $vis_language['TXTHOME']; ?></a></li>
         <? if($operation['show_report']==6){ ?>
           <li><a class="link" href="#/report/report_list/<? echo $vis_language['TXTREPORTS']; ?>"><?= $vis_language['TXTREPORTS']; ?></a></li>
         <? }else{ ?>
         <li><a class="link" href="#/ticket/filter_ticket/<? echo $vis_language['TXTTICKETS']; ?>/1"><?= $vis_language['TXTINBOX']; ?></a></li>
         <? }?>
         <li class="active"><? echo ($operation['show_report']==6)?$vis_language['TXTCUSTOMREPORT']:$vis_language['TXTSEARCH']; ?></li>
      </ul>
   </div>
    <? if(!isset($operation['show_report'])){ ?>
   <div class="col-sm-6 text-right text-left-xs m-t-lg">
		<div class="btn-group">
			<button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="vh vh-action text-muted"></i> <b class="caret"></b></button>
     <ul class="dropdown-menu dropdown-menu-right text-left">
         <li><a class="link" href="#/ticket/view_filters/<? echo $vis_language['TXTFILTERS']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module', '<? echo $vis_language['TXTFILTERS']; ?>', {'vis_module':'ticket', 'vis_operation':'view_filters'})"><? echo $vis_language['TXTFILTERS']; ?></a></li>
         </ul>
   </div>
	</div>
     <? }else {?><div class="col-sm-6 text-right text-left-xs m-t-lg">
    <? include(VIS_PATH_TEMPLATE.'report_left_menu.php'); ?>
	</div><? } ?>
</section>
<section class="padder">
   <section class="panel panel-default">
      <header class="panel-heading sub_header"><? echo $vis_language['TXTSEARCH']; ?></header>
      <div class="panel-body">
         <form  class="form-horizontal"  name="vis_search_form" id="vis_search_form" target="_blank">
            <input type="hidden" name="total_critaria" id="total_critaria" value="0" />
            <input type="hidden" name="total_or_critaria" id="total_or_critaria" value="0" />
            <input type="hidden" name="vis_concate_option" id="vis_concate_option" value="and" />
            <input type="hidden" name="vis_operation" value="advance_search" />
            <? if($operation['show_report']==6){?>
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTDURATION']; ?></label>
               <div class="col-sm-2">
				<select name="vis_main_search" id="vis_main_search" class="form-control input-sm selectpicker">
					<option value="16"><? echo $vis_language['TXTCREATIONDATE'];?></option>
					<option value="12"><? echo $vis_language['TXTLASTACTIVITY'];?></option>
				</select>
			   </div>
			   <label class="col-sm-1 control-label"><? echo $vis_language['TXTFROM']; ?></label>
			   <div class="col-sm-2">
				  <div class="text-muted pull-center from_date"><input type="text" name="vis_from_date" id="vis_from_date" value="<?= date(VIS_EDITDATETIMEPICKER_FORMAT,strtotime(date('Y-m-d H:i')." -3 months") + VIS_TIMEZONE);?>" class="input-sm form-control"/></div>
			  </div>
			  <label class="col-sm-1 control-label"><? echo $vis_language['TXTTO']; ?></label>
			  <div class="col-sm-2">
				  <div class="text-muted pull-center to_date"><input type="text" name="vis_to_date" id="vis_to_date" value="<?//=date("M-d, Y H:i",strtotime(date('Y-m-d H:i')));?>" class="input-sm form-control"/></div>
			  </div>
            </div>
            <div class="line b-b line-lg pull-in"></div>
            <input type="hidden" name="vis_report" value="1" />
             <? } ?>
            <br/>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTMATCHANDCONDITIONS']; ?></label>
               <div class="col-sm-10">
			   <div id="vis_search_options" ></div>
			   </div>
            </div>
            <div class="form-group m-t-n-md">
               <label class="col-sm-10 control-label"></label>
               <div class="col-sm-2">
                  <label>
                  <button type="button" class="btn btn-primary btn-xs"  onclick="javascript:add_criteria()"><? echo $vis_language['TXTADDCRITERIA']; ?></button>
                  </label>
               </div>
            </div><br/><br/>
             <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTMATCHORCONDITIONS']; ?></label>
               <div class="col-sm-10">
			   <div id="vis_search_or_options" ></div>
			   </div>
            </div>
            <div class="form-group m-t-n-md">
               <label class="col-sm-10 control-label"></label>
               <div class="col-sm-2">
				  <label>
                  <button type="button" class="btn btn-primary btn-xs"  onclick="javascript:add_or_criteria()"><? echo $vis_language['TXTADDCRITERIA']; ?></button>
                  </label>
               </div>
            </div>
            <div class="line b-b line-lg pull-in"></div>
            <br/>
            <? if(!isset($operation['show_report'])){ ?>
            <div class="form-group">
               <label class="col-sm-2 control-label p-d-sm"><? echo $vis_language['TXTOPTIONS']; ?></label>
               <div class="col-sm-10">
                  <div class="checkbox i-checks m-r-lg pull-left p-d-sm">
				  <label>
                  <input type="checkbox"  name="vis_search_trash" id="vis_search_trash" value="1"/><i></i> <? echo $vis_language['TXTSEARCHTRASH']; ?>
                  </label>
                  </div>
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 setting-list"></label>
               <div class="col-sm-10">
                  <div class="checkbox i-checks m-r-lg pull-left p-d-sm">
				  <label>
                  <input type="checkbox"  name="vis_search_spam" id="vis_search_spam" value="1"/><i></i> <? echo $vis_language['TXTSEARCHSPAM']; ?>
                  </label>
                  </div>
               </div>
            </div><? } ?>
			
			
            <div class="form-group">
               <label class="col-sm-2 control-label p-d-sm"><? echo ($operation['show_report']==6)?$vis_language['TXTOPTIONS']:''; ?></label>
               <div class="col-sm-10">
                  <div class="checkbox i-checks m-r-lg pull-left p-d-sm">
				  <label>
                  <input type="checkbox"  value="1" id="vis_save_filter" name="vis_save_filter" /><i></i> <? echo ($operation['show_report']==6)?$vis_language['TXTSAVE']:$vis_language['TXTSAVEASFILTER']; ?>
                  </label>
                  </div>
               </div>
            </div>
            <div class="line b-b line-lg pull-in"></div> 
			<input type="hidden" name="vis_is_report" id="vis_is_report" value="<? echo (!isset($operation['show_report']))?0:1; ?>" />
            <br/>
            <div class="form-group">
               <div class="col-sm-4 col-sm-offset-2">
                  <button type="button" id="search" class="btn btn-primary" ><? echo $vis_language['TXTSEARCH']; ?></button>
               </div>
            </div>
            </form>
      </div>
   </section>
</section>
<style>
.selectpicker span:nth-child(2){
color:#000000 !important;
}
</style>
<script>

	 select_picker();
		<? if($operation['show_report']==6){?>
	  $('#search').click(function () {
		  if ($('#vis_save_filter').is(':checked')) {
			var vis_is_report=$('#vis_is_report').val();
			  $('#search').attr('data-toggle','ajaxModal');
			  $('#search').attr('data-modal-arguments','vis_module=report&vis_operation=save_customfilter&vis_form=vis_search_form&vis_is_report='+vis_is_report);
		  }
		  else
		  {
			  $('#search').removeAttr('data-toggle');
			  $('#search').removeAttr('data-modal-arguments');
			  $('#vis_workpanel_div').visExecution('submit_form', {'vis_module':'report', 'vis_operation':'custom_search_result', 'vis_form':'vis_search_form','vis_search':1});
		  }
	  });
			<? }else{ ?>
			$('#search').click(function () {
		  if ($('#vis_save_filter').is(':checked')) {
			var vis_is_report=$('#vis_is_report').val();
			  $('#search').attr('data-toggle','ajaxModal');
			  $('#search').attr('data-modal-arguments','vis_module=ticket&vis_operation=save_filter&vis_form=vis_search_form&vis_is_report='+vis_is_report);
		  }
		  else
		  {
			  $('#search').removeAttr('data-toggle');
			  $('#search').removeAttr('data-modal-arguments');
			  $('#vis_workpanel_div').visExecution('submit_form', {'vis_module':'ticket', 'vis_operation':'ticket_search_result', 'vis_form':'vis_search_form','vis_search':1});
		  }
	  });
			
			<? }?>
    $(".selectpicker").selectpicker();
     function select_picker()
     {
		// var newDate = new Date()
		// newDate.setMonth(newDate.getMonth() - 3);
		// console.log(newDate);

         $(".selectpicker").selectpicker();

		 $('.from_date').datetimepicker({
			//defaultDate: newDate,
			format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>",
		 });
		 $('.to_date').datetimepicker({
			format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>",
		 });
		 $('.to_date').click();
		 //$('.from_date').click();
		 $('.bootstrap-datetimepicker-widget').hide();
$('.creates_date').datetimepicker({
			format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>",
		 });
     }
      function add_criteria() {
          var total=document.getElementById("total_critaria");
          var num=parseInt(total.value)+1;
          total.value=num;
          var newDiv=document.createElement("DIV");
          var newCritera='<div class="form-group"><div class="col-sm-3"><select name="vis_main_search'+num+'" id="vis_main_search'+num+'" onchange="changeSearchOption('+num+',1)" class="form-control input-sm selectpicker" data-live-search="true"><option value="0"><? echo $vis_language['TXTSUBJECT']; ?></option><option value="1"><? echo $vis_language['TXTMESSAGE']; ?></option><option value="37"><? echo $vis_language['TXTTICKETHASH'];?></option><option value="2"><? echo $vis_language['TXTTICKETNOTE']; ?></option><option value="3"><?echo $vis_language['TXTTICKETCOMMENT']; ?></option><option value="4"><? echo $vis_language['TXTCLIENTNAME']; ?></option><option value="5"><? echo $vis_language['TXTCLIENTEMAIL']; ?></option><option value="6"><? echo$vis_language['TXTORGANIZATION']; ?></option><option value="22"><? echo $vis_language['TXTCLIENTLANGUAGE'];?></option><option value="18"><? echo $vis_language['TXTDOMAIN']; ?></option><option value="7"><? echo $vis_language['TXTDEPARTMENT']; ?></option><option value="8"><? echo $vis_language['TXTSTATUS']; ?></option><option value="9"><?echo $vis_language['TXTPRIORITY'];?></option><option value="23"><? echo $vis_language['TXTLABEL'];?></option><option value="21"><? echo $vis_language['TXTTICKETTYPE'];?></option><option value="31"><? echo $vis_language['TXTTICKETCATEGORY'];?></option><option value="32"><? echo $vis_language['TXTTICKETSUBCATEGORY'];?></option><option value="33"><? echo $vis_language['TXTTICKETITEM'];?></option><option value="34"><? echo $vis_language['TXTTICKETLEVEL'];?></option><? if(VIS_ITIL==1 && !empty($location_details)) {?><option value="35"><? echo $vis_language['TXTLOCATION'];?></option><?}?><option value="10"><? echo $vis_language['TXTOWNER'];?></option><option value="29"><? echo $vis_language['TXTOPERATOR'];?></option><option value="11"><? echo $vis_language['TXTFLAGTYPE'];?></option><option value="28"><? echo $vis_language['TXTLASTREPLIER'];?></option><? if($operation['show_report']!=6){?><option value="38"><? echo $vis_language['TXTCREATIONDATE'];?></option><? }?><option value="15"><? echo $vis_language['TXTSLAPLAN'];?></option><option value="19"><? echo $vis_language['TXTHASATTACHMENT'];?></option><?if(VIS_MODULE_ACCESS_BILLING==1){?><option value="20"><? echo $vis_language['TXTINVOICEDESCRIPTION']; ?></option><? } ?><option value="24"><? echo $vis_language['TXTCHANNEL'];?></option><option value="25"><? echo $vis_language['TXTTOEMAIL'];?></option><option value="26"><? echo $vis_language['TXTCREATIONTIME'];?></option><option value="17"><? echo $vis_language['TXTOVERDUETIME'];?></option><option value="27"><? echo $vis_language['TXTRESOLUTIONDUETIME'];?></option><option value="39"><? echo $vis_language['TXTCIATTACHED'];?></option></select></div><div class="col-sm-3"  id="vis_criteria_option'+num+'"><select class="form-control input-sm selectpicker" name="vis_sub_search'+num+'" id="vis_sub_search'+num+'"><option value="0"><? echo $vis_language['TXTCONTAIN'];?></option><option value="1"><? echo $vis_language['TXTDOESNOTCONTAIN'];?></option><option value="2"><? echo $vis_language['TXTEQUAL'];?></option><option value="3"><? echo $vis_language['TXTNOTEQUAL'];?></option></select></div><div class="col-sm-3"  id="vis_criteria_text'+num+'"><input name="vis_search_text'+num+'" id="vis_search_text'+num+'" type="text" class="form-control input-sm" /></div><label class="col-sm-1" onclick="javascript:close_criteria('+num+',1)" style="cursor:pointer"><i class="vh vh-cross  m-t-sm"></i></label></div>';
          newDiv.id="vis_search_sub_criteria"+num;
          newDiv.innerHTML=newCritera;
          document.getElementById("vis_search_options").appendChild(newDiv);
          select_picker();
      }
      function add_or_criteria() {
          var total=document.getElementById("total_or_critaria");
          var num=parseInt(total.value)+1;
          total.value=num;
          var newDiv=document.createElement("DIV");
           var newCritera='<div class="form-group"><div class="col-sm-3"><select name="vis_main_search_or'+num+'" id="vis_main_search_or'+num+'" onchange="changeSearchOption('+num+',0)" class="form-control input-sm selectpicker" data-live-search="true"><option value="0"><? echo $vis_language['TXTSUBJECT']; ?></option><option value="1"><? echo $vis_language['TXTMESSAGE']; ?></option><option value="37"><? echo $vis_language['TXTTICKETHASH'];?></option><option value="2"><? echo $vis_language['TXTTICKETNOTE']; ?></option><option value="3"><?echo $vis_language['TXTTICKETCOMMENT']; ?></option><option value="4"><? echo $vis_language['TXTCLIENTNAME']; ?></option><option value="5"><? echo $vis_language['TXTCLIENTEMAIL']; ?></option><option value="6"><? echo$vis_language['TXTORGANIZATION']; ?></option><option value="22"><? echo $vis_language['TXTCLIENTLANGUAGE'];?></option><option value="18"><? echo $vis_language['TXTDOMAIN']; ?></option><option value="7"><? echo $vis_language['TXTDEPARTMENT']; ?></option><option value="8"><? echo $vis_language['TXTSTATUS']; ?></option><option value="9"><?echo $vis_language['TXTPRIORITY'];?></option><option value="23"><? echo $vis_language['TXTLABEL'];?></option><option value="21"><? echo $vis_language['TXTTICKETTYPE'];?></option><option value="31"><? echo $vis_language['TXTTICKETCATEGORY'];?></option><option value="32"><? echo $vis_language['TXTTICKETSUBCATEGORY'];?></option><option value="33"><? echo $vis_language['TXTTICKETITEM'];?></option><option value="34"><? echo $vis_language['TXTTICKETLEVEL'];?></option><? if(VIS_ITIL==1 && !empty($location_details)) {?><option value="35"><? echo $vis_language['TXTLOCATION'];?></option><? } ?><option value="10"><? echo $vis_language['TXTOWNER'];?></option><option value="29"><? echo $vis_language['TXTOPERATOR'];?></option><option value="11"><? echo $vis_language['TXTFLAGTYPE'];?></option><option value="28"><? echo $vis_language['TXTLASTREPLIER'];?></option><? if($operation['show_report']!=6){?><option value="38"><? echo $vis_language['TXTCREATIONDATE'];?></option><? }?><option value="15"><? echo $vis_language['TXTSLAPLAN'];?></option><option value="19"><? echo $vis_language['TXTHASATTACHMENT'];?></option><?if(VIS_MODULE_ACCESS_BILLING==1){?><option value="20"><? echo $vis_language['TXTINVOICEDESCRIPTION']; ?></option><? } ?><option value="24"><? echo $vis_language['TXTCHANNEL'];?></option><option value="25"><? echo $vis_language['TXTTOEMAIL'];?></option><option value="26"><? echo $vis_language['TXTCREATIONTIME'];?></option><option value="17"><? echo $vis_language['TXTOVERDUETIME'];?></option><option value="27"><? echo $vis_language['TXTRESOLUTIONDUETIME'];?></option><option value="39"><? echo $vis_language['TXTCIATTACHED'];?></option></select></div><div class="col-sm-3"  id="vis_criteria_option_or'+num+'"><select class="form-control input-sm selectpicker" name="vis_sub_search_or'+num+'" id="vis_sub_search_or'+num+'"><option value="0"><? echo $vis_language['TXTCONTAIN'];?></option><option value="1"><? echo $vis_language['TXTDOESNOTCONTAIN'];?></option><option value="2"><? echo $vis_language['TXTEQUAL'];?></option><option value="3"><? echo $vis_language['TXTNOTEQUAL'];?></option></select></div><div class="col-sm-3"  id="vis_criteria_text_or'+num+'"><input name="vis_search_text_or'+num+'" id="vis_search_text_or'+num+'" type="text" class="form-control input-sm" /></div><label class="col-sm-1" onclick="javascript:close_criteria('+num+',0)" style="cursor:pointer"><i class="vh vh-cross  m-t-sm"></i></label></div>';
          newDiv.id="vis_search_sub_or_criteria"+num;
          newDiv.innerHTML=newCritera;
          document.getElementById("vis_search_or_options").appendChild(newDiv);
          select_picker();
      }
      function changeSearchOption(num,condition) {
          var tempcondition='';
          if(condition==0) tempcondition='_or';
          var mainOpt=document.getElementById("vis_main_search"+tempcondition+num).value;
          var subOpt=document.getElementById("vis_criteria_option"+tempcondition+num);
          var subTxt=document.getElementById("vis_criteria_text"+tempcondition+num);
          if(mainOpt==0 || mainOpt==4 || mainOpt==5 || mainOpt==25 || mainOpt==37 ||  mainOpt==39) {
              subOpt.innerHTML='<select name="vis_sub_search'+tempcondition+num+'" id="vis_sub_search'+tempcondition+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTCONTAIN'];?></option><option value="1"><? echo $vis_language['TXTDOESNOTCONTAIN'];?></option><option value="2"><? echo $vis_language['TXTEQUAL'];?></option><option value="3"><? echo $vis_language['TXTNOTEQUAL'];?></option></select>';
          }
          else if(mainOpt==1 || mainOpt==2 || mainOpt==3 || mainOpt==20) {
              subOpt.innerHTML='<select name="vis_sub_search'+tempcondition+num+'" id="vis_sub_search'+tempcondition+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTCONTAIN'];?></option><option value="1"><? echo $vis_language['TXTDOESNOTCONTAIN'];?></option></select>';
          }
          else if(mainOpt==6 || mainOpt==7 || mainOpt==8 || mainOpt==9 || mainOpt==10 || mainOpt==11 || mainOpt==15 || mainOpt==18 || mainOpt==19 || mainOpt==21 || mainOpt==22 || mainOpt==23 || mainOpt==24 || mainOpt==31 || mainOpt==32 || mainOpt==33 || mainOpt==34 || mainOpt==35) {
              subOpt.innerHTML='<select name="vis_sub_search'+tempcondition+num+'" id="vis_sub_search'+tempcondition+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTEQUAL'];?></option><option value="1"><? echo $vis_language['TXTNOTEQUAL'];?></option></select>';
          }
          else if(mainOpt==12 || mainOpt==13 || mainOpt==14 ) {
              subOpt.innerHTML='<select name="vis_sub_search'+tempcondition+num+'" id="vis_sub_search'+tempcondition+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTLESSTHAN'];?></option><option value="1"><? echo $vis_language['TXTGREATEREQLTHAN'];?></option></select>';
										}else if(mainOpt==38) {
              subOpt.innerHTML='<select name="vis_sub_search'+tempcondition+num+'" id="vis_sub_search'+tempcondition+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTLESSTHAN'];?></option><option value="1"><? echo $vis_language['TXTGREATERTHAN'];?></option></select>';	
          }else if(mainOpt==26) {
            subOpt.innerHTML='<select name="vis_sub_search'+tempcondition+num+'" id="vis_sub_search'+tempcondition+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTAFTER'];?></option></select>';
        }else if(mainOpt==27 || mainOpt==17) {
            subOpt.innerHTML='<select name="vis_sub_search'+tempcondition+num+'" id="vis_sub_search'+tempcondition+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTAFTER'];?></option><option value="1"><? echo $vis_language['TXTBEFORE'];?></option></select>';
        }else if(mainOpt==28) {
            subOpt.innerHTML='<select name="vis_sub_search'+tempcondition+num+'" id="vis_sub_search'+tempcondition+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTSTAFF'];?></option><option value="1"><? echo $vis_language['TXTCLIENT'];?></option></select>';
        }else if(mainOpt==29) {
            subOpt.innerHTML='<select name="vis_sub_search'+tempcondition+num+'" id="vis_sub_search'+tempcondition+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTSTAFF'];?></option></select>';
        }

          if(mainOpt==0 || mainOpt==2 || mainOpt==3 || mainOpt==4 || mainOpt==5 || mainOpt==20 || mainOpt==25 || mainOpt==39) {
              subTxt.innerHTML='<input name="vis_search_text'+tempcondition+num+'" id="vis_search_text'+tempcondition+num+'" type="text" value="" class="form-control input-sm"/>';
          }
          else if(mainOpt==1) {
              //subTxt.innerHTML='<input name="vis_search_text'+tempcondition+num+'" id="vis_search_text'+tempcondition+num+'" type="text" value="" class="form-control input-sm"/><label>Search from recent </label><select name="vis_search_post_count" class="form-control input-sm selectpicker" ><option value="1000">1000 entries</option><option value="10000">10000 entries</option><option value="50000">50000 entries</option><option value="100000">100000 entries</option><option value="1000000">1000000 entries</option><option value="0">All entries</option></select>';
              subTxt.innerHTML='<input name="vis_search_text'+tempcondition+num+'" id="vis_search_text'+tempcondition+num+'" type="text" value="" class="form-control input-sm"/>';
          }
          else if(mainOpt==6) { <?
      if(count($user_groups)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' >';
              for($i=0;$i<count($user_groups);$i++) $temp.='<option value="'.$user_groups[$i]['group_id'].'">'.addslashes($user_groups[$i]['group_name']).'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."';"; ?>
          }
          else if(mainOpt==18) { <?
      if(count($domains)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' >';
              for($i=0;$i<count($domains);$i++) $temp.='<option value="'.$domains[$i]['domain_id'].'">'.addslashes($domains[$i]['domain_name']).'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."';"; ?>
          }
          else if(mainOpt==7) { <?
      if(count($departments)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' >';
              for($i=0;$i<count($departments);$i++) $temp.='<option value="'.$departments[$i]['department_id'].'">'.addslashes($departments[$i]['domain_name']).' : '.addslashes($departments[$i]['department_name']).'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."';"; ?>
          }
          else if(mainOpt==8) { <?
      if(count($status)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' >';
              for($i=0;$i<count($status);$i++) $temp.='<option value="'.$status[$i]['status_id'].'">'.addslashes($status[$i]['status_name']).'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."';"; ?>
          }
          else if(mainOpt==9) { <?
      if(count($priorities)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' >';
              for($i=0;$i<count($priorities);$i++) $temp.='<option value="'.$priorities[$i]['priority_id'].'">'.addslashes($priorities[$i]['priority_name']).'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."';"; ?>
          }
          else if(mainOpt==10 || mainOpt==29) { <?
      if(count($owner)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_report_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' ><option value="0">'.$vis_language['TXTUNASSIGNED'].'</option>';
              for($i=0;$i<count($owner);$i++) $temp.='<option value="'.$owner[$i]['staff_id'].'">'.addslashes($owner[$i]['first_name']).' '.addslashes($owner[$i]['last_name']).'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."';"; ?>
          }
          else if(mainOpt==11) { <?
			   if(count($flags)>10) $select1= 'data-live-search="true"';
                $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker" '.$select1.'>';
               for($i=0;$i<count($flags);$i++)
			   {
			   		 if($flags[$i]['flag_color']=='#ffffff'){
					 $class_var="vh-flag-empty";
					 $color='';
					 }
					 else{
					 $class_var="vh-flag";
					 $color=$flags[$i]['flag_color'];
					 }
			   $temp.='<option value="'.$flags[$i]['flag_id'].'" data-icon="vh vh-lg '.$class_var.'" style="color:'.$color.'">'.addslashes($flags[$i]['flag_name']).'</option>';
			   }
               $temp.='</select>';
               echo "subTxt.innerHTML='".$temp."';"; ?>
          }
          else if(mainOpt==12 || mainOpt==13 || mainOpt==14) {
              subTxt.innerHTML='<input name="vis_search_text'+tempcondition+num+'" id="vis_search_text'+tempcondition+num+'" type="text" value="" class="form-control input-sm start" />';
          }
										else if(mainOpt==38) {
              subTxt.innerHTML='<input name="vis_search_text'+tempcondition+num+'" id="vis_search_text'+tempcondition+num+'" type="text" value="" class="form-control input-sm start creates_date" />';
          }
          else if(mainOpt==15) { <?
      if(count($sla)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_report_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' >';
              for($i=0;$i<count($sla);$i++) $temp.='<option value="'.$sla[$i]['sla_id'].'">'.addslashes($sla[$i]['sla_name']).'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."';"; ?>
          }
          else if(mainOpt==19) {
              subTxt.innerHTML='<select name="vis_search_text'+tempcondition+num+'" id="vis_search_text'+tempcondition+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTTRUE'];?></option></select>';
          }
          else if(mainOpt==21) { <?
              if(count($ticket_types)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' >';
              for($i=0;$i<count($ticket_types);$i++) $temp.='<option value="'.$ticket_types[$i]['type_id'].'">'.addslashes($ticket_types[$i]['type_name']).'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."'"; ?>
          }
          else if(mainOpt==22) { <?
              if(count($client_language)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' >';
              for($i=0;$i<count($client_language);$i++) $temp.='<option value="'.$client_language[$i]['language_id'].'">'.$client_language[$i]['language_name'].'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."'"; ?>
          }
           else if(mainOpt==23) { <?
			   if(count($label_details)>10) $select1= 'data-live-search="true"';
			  $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_alert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
			  for($i=0;$i<count($label_details);$i++) $temp .= '<option data-id="alert_label" data-bgcolor="'.$label_details[$i]['label_color'].'" value="'.$label_details[$i]['label_id'].'">'.addslashes($label_details[$i]['label_name']).'</option>';
			  $temp.='</select>';
			  echo "subTxt.innerHTML='".$temp."'"; ?>
       }
          else if(mainOpt==24) { <?
              if(count($channel_details)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' >';
              for($i=0;$i<count($channel_details);$i++) $temp.='<option value="'.$channel_details[$i]['channel_id'].'">'.$channel_details[$i]['channel_name'].'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."'"; ?>
          }else if(mainOpt==26 || mainOpt==27 || mainOpt==17) {
            subTxt.innerHTML='<input name="vis_search_text'+tempcondition+num+'_hr" id="vis_search_text'+tempcondition+num+'_hr" type="text" value="" class="form-control input-sm tkt_right_menu vis_fl" /><label class="vis_fl">&nbsp;hr&nbsp;&nbsp;&nbsp;</label><input name="vis_search_text'+tempcondition+num+'_mi" id="vis_search_text'+tempcondition+num+'_mi" type="text" value="" class="form-control input-sm tkt_right_menu vis_fl" /><label class="vis_fl">&nbsp;min</label>';
        }
        else if(mainOpt==28) {
            subTxt.innerHTML='';
        }else if(mainOpt==31) { <?
      if(count($category_details)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' >';
              for($i=0;$i<count($category_details);$i++) $temp.='<option value="'.$category_details[$i]['category_id'].'">'.addslashes($category_details[$i]['title']).'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."';"; ?>
        }
		else if(mainOpt==32) { <?
      if(count($subcategory_details)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' >';
              for($i=0;$i<count($subcategory_details);$i++) $temp.='<option value="'.$subcategory_details[$i]['subcategory_id'].'">'.addslashes($subcategory_details[$i]['title']).'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."';"; ?>
        }
		else if(mainOpt==33) { <?
      if(count($item_details)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' >';
              for($i=0;$i<count($item_details);$i++) $temp.='<option value="'.$item_details[$i]['item_id'].'">'.addslashes($item_details[$i]['title']).'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."';"; ?>
        }
		else if(mainOpt==34) { <?
      if(count($level_details)>10) $select1= 'data-live-search="true"';
              $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.' >';
              for($i=0;$i<count($level_details);$i++) $temp.='<option value="'.$level_details[$i]['level_id'].'">'.addslashes($level_details[$i]['title']).'</option>';
              $temp.='</select>';
              echo "subTxt.innerHTML='".$temp."';"; ?>
        }
		else if(mainOpt==35) { <?
			if(count($location_details)>10) $select1= 'data-live-search="true"';
	           $temp='<select name="vis_search_text\'+tempcondition+num+\'" id="vis_search_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
               $temp .= vis_show_subcategories($location_details,'');
			   function vis_show_subcategories($location_details,$call=NULL) {
				   for($i=0;$i<count($location_details);$i++){ 
					   $temp.='<option value="'.$location_details[$i]['location_id'].'">'.addslashes($location_details[$i]['name']).'</option>';
					   if($location_details[$i]['subcat']!=NULL) { 
					    	$temp .= vis_show_subcategories($location_details[$i]['subcat'],'sub_cat'); 
					   }
				   }
				   return $temp;
			   }
               $temp.='</select>';
               echo "subTxt.innerHTML='".$temp."'"; ?>
          }
          select_picker();
      }
      function close_criteria(num,condition) {
          var tempcondition='';
          if(condition==0) tempcondition='_or';
          if(num==1)  $("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['MSGDEFAULTCRITERIA']; ?>");
          else document.getElementById("vis_search_sub"+tempcondition+"_criteria"+num).innerHTML="";
      }
      function reset_filter() {
          document.getElementById("vis_search_options").innerHTML="";
          document.getElementById("total_critaria").value=0;
          add_criteria();
      }
      add_criteria();
      add_or_criteria();
</script>
