<? global $vis_language;
    $team_owner=is_numeric($roundrobin_action[1])?array(0=>$roundrobin_action[1]):explode(',', $roundrobin_action[1]);
    $escalation_day=floor($roundrobin_action[4]/86400);
                 $remaining_minutes=$roundrobin_action[4]%86400;
                 $escalation_hr = floor($remaining_minutes/3600);
                 $escalation_min = ($remaining_minutes%3600)/60;
?>
<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['view_title'];?></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>
         <li><a class="link" href="#/setting/setting_menu/<? echo $vis_language['TXTSETTINGS'];?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTSETTINGS'];?>',{'vis_module':'setting','vis_operation':'setting_menu'});"><? echo $vis_language['TXTSETTINGS']; ?></a></li>
         <li> <a href="#/setting/view_roundrobin/<? echo $vis_language['TXTROUNDROBIN'];?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTROUNDROBIN'];?>',{'vis_module':'setting','vis_operation':'view_roundrobin'});" class="link"><? echo $operation['view_title']; ?></a></li>
         <li class="active"><? echo $vis_language['TXTUPDATEROUNDROBIN']; ?></li>
      </ul>
      <div>
      </div>
   </div>
</section>
<section class="padder">
   <section class="panel panel-default">
      <header class="panel-heading sub_header"><? echo $vis_language['TXTUPDATEROUNDROBIN']; ?></header>
      <div class="panel-body">
         <form  class="form-horizontal" id="vis_roundrobin_form_<? echo $roundrobin_details['roundrobin_id']; ?>" name="vis_roundrobin_form_<? echo $roundrobin_details['roundrobin_id']; ?>" method="post">
            <input type="hidden" name="total_roundrobin_critaria" id="total_roundrobin_critaria_<? echo $roundrobin_details['roundrobin_id']; ?>" value="0" />
            <input type="hidden" name="total_roundrobin_critaria_or" id="total_roundrobin_critaria_or_<? echo $roundrobin_details['roundrobin_id']; ?>" value="0" />
            <input type="hidden" name="vis_roundrobin_id" id="vis_roundrobin_id" value="<? echo $roundrobin_details['roundrobin_id']; ?>" />
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTTITLE']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text"  name="vis_roundrobin_title" id="vis_roundrobin_title" value="<? echo htmlentities($roundrobin_details['roundrobin_name'], ENT_COMPAT, 'UTF-8'); ?>" >
               </div>
            </div>
             <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSCHEDULE']; ?></label>
               <div class="col-sm-10">
                  <select name="vis_schedule_id" id="vis_schedule_id" class="form-control input-sm selectpicker"  <? if(count($schedule)>10) echo 'data-live-search="true"';?>>
                     <? for($i=0;$i<count($schedule);$i++) echo '<option value="'.$schedule[$i]['schedule_id'].'"'.($roundrobin_details['schedule_id']==$schedule[$i]['schedule_id']?' selected="selected"':'').'>'.$schedule[$i]['schedule_name'].'</option>'; ?>
                  </select>
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTDISPLAYORDER']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" name="vis_execution_order" id="vis_execution_order"  value="<? echo $roundrobin_details['execution_order']; ?>"  >
               </div>
            </div>
            <div class="form-group">
               <div class="col-sm-2"><h5><? echo $vis_language['TXTCRITERIA']; ?></h5></div>
            </div>
            <div class="line b-b line-lg pull-in"></div>
            <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_eroundrobin_options_<? echo $roundrobin_details['roundrobin_id']; ?>" ></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_roundrobin_criteria_<? echo $roundrobin_details['roundrobin_id']; ?>()"><? 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_eroundrobin_or_options_<? echo $roundrobin_details['roundrobin_id']; ?>" ></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_roundrobin_or_criteria_<? echo $roundrobin_details['roundrobin_id']; ?>()"><? echo $vis_language['TXTADDCRITERIA']; ?></button>
                  </label>
               </div>
            </div>

            <div class="form-group">
               <div class="col-sm-2"><h5><? echo $vis_language['TXTACTION']; ?></h5></div>
            </div>
            <div class="line b-b line-lg pull-in"></div>
            <br/>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTASSIGNTEAM']; ?></label>
               <div class="col-sm-10">
				   <div class="dept_access_list">
                  <?
                     for($i=0; $i<count($staff_group); $i++) {
                         $staff_group_display_list.=$staff_group[$i]['group_id'].",";
                         if($staff_group[$i]['department_access']==0) $access_arr = 0;
                         else $access_arr = explode(',',$staff_group[$i]['department_access']);
                      ?>
                  <label class="checkbox-inline i-checks">
                  <input type="checkbox" value="<? echo $staff_group[$i]['group_id']; ?>"  name="vis_staff_team[]" <? if(in_array($staff_group[$i]['group_id'], $team_owner)) echo ' checked="checked"'; ?> /> <i></i>&nbsp;<? echo $staff_group[$i]['group_name']; ?></label><br/>
                  <? } ?>
                  <input type="hidden" value="<? echo $staff_group_display_list; ?>" name="staff_group_display_list" style="display:none;" />
               </div>
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTASSIGNSTAFF']; ?></label>
               <div class="col-sm-10">
                   <? $staffs=explode(',',$roundrobin_action[2]); ?>
                    <div class="dept_access_list">
                    <label class="checkbox-inline i-checks">
                    <input type="checkbox" name="vis_staff_id[]" value="VIS_STAFF_ID" <? echo (in_array('VIS_STAFF_ID',$staffs))?' checked="checked"':''; ?>/> <i></i>&nbsp;<?= $vis_language['TXTOPERATOR'] ?></label><br/>
                        <? for($i=0;$i<count($staff_details);$i++){ ?>
                          <label class="checkbox-inline i-checks">
                         <input type="checkbox" name="vis_staff_id[]" value="<?= $staff_details[$i]['staff_id']; ?>" <? echo (in_array($staff_details[$i]['staff_id'],$staffs))?' checked="checked"':''; ?> /> <i></i>&nbsp;<? echo $staff_details[$i]['first_name'].' '.$staff_details[$i]['last_name']; ?></label><br/>
                         <? } ?>
                   </div>
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSENDEMAILTOSTAFF']; ?></label>
               <div class="col-sm-10">
                  <select name="vis_template" id="vis_template" class="input-sm form-control selectpicker"  <? if(count($etemplate)>10) echo 'data-live-search="true"';?>>
                      <option value="0"><? echo$vis_language['TXTNOCHANGE']; ?></option>
                    <? for($i=0;$i<count($etemplate);$i++) echo '<option value="'.$etemplate[$i]['etemplate_id'].'"'.($roundrobin_action[3]==$etemplate[$i]['etemplate_id']?' selected="selected"':'').'>'.$etemplate[$i]['etemplate_name'].'</option>'; ?>
                  </select>
               </div>
            </div>
             <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTESCALATIONRULE']; ?></label>
               <div class="col-sm-1">
               <? if($escalation_day!=0 || $escalation_hr!=0 || $escalation_min!=0){$checkboxchked='checked="checked"';}else{$checkboxchked='';} ?>
               <div class="checkbox i-checks">
                  <label class=" ">
                  <input type="checkbox" name="vis_escon"  id="vis_escon" onclick="toggle_status_escl();" <? echo $checkboxchked;?>   >
                  <i></i>&nbsp;
                  </label>
                  </div>
               </div>
            </div>
            <div id="showesc" >
             <div class="form-group" >
              <label class="col-sm-2 control-label"><? echo $vis_language['MSGTICKETASSIGNBYESCALATIONRULE']; ?></label>
            <div class="col-sm-10">
                   
               
                <div class="col-sm-1" style="padding-left:0px;">
                  <input class="form-control input-sm" type="text" name="vis_eday" id="vis_eday" value="<? echo ($escalation_day!=0)?$escalation_day:''; ?>">
               </div>
               <div class="col-sm-1">
                  <? echo $vis_language['TXTDAYS']; ?>
               </div>
               <div class="col-sm-1">
                  <input class="form-control input-sm" type="text" name="vis_ehr" id="vis_ehr" value="<? echo ($escalation_hr!=0)?$escalation_hr:''; ?>">
               </div>
               <div class="col-sm-1">
                  <? echo $vis_language['TXTHOURS']; ?>
               </div>
               <div class="col-sm-1">
                  <input class="form-control input-sm" type="text" name="vis_emin" id="vis_emin" value="<? echo ($escalation_min!=0)?$escalation_min:''; ?>">
               </div>
               <div class="col-sm-1">
                  <? echo $vis_language['TXTMINUTES']; ?>
               </div>
               <div class="col-sm-4"></div>
            
               </div>
               </div>
             <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTASSIGNSTAFF']; ?></label>
               <div class="col-sm-10">
                   <? $staffs1=explode(',',$roundrobin_action[5]); ?>
                    <div class="dept_access_list">
                        <? for($i=0;$i<count($staff_details);$i++){ ?>
                          <label class="checkbox-inline i-checks">
                         <input type="checkbox" name="vis_staff_id1[]" value="<?= $staff_details[$i]['staff_id']; ?>" <? echo (in_array($staff_details[$i]['staff_id'],$staffs1))?' checked="checked"':''; ?> /> <i></i>&nbsp;<? echo $staff_details[$i]['first_name'].' '.$staff_details[$i]['last_name']; ?></label><br/>
                         <? } ?>
                   </div>
               </div>
            </div>
              <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['MSGSENDESCALATIONEMAIL']; ?></label>
               <div class="col-sm-10">
                  <select name="vis_template1" id="vis_template1" class="input-sm form-control selectpicker"  <? if(count($etemplate)>10) echo 'data-live-search="true"';?>>
                      <option value="0"><? echo$vis_language['TXTNOCHANGE']; ?></option>
                    <? for($i=0;$i<count($etemplate);$i++) echo '<option value="'.$etemplate[$i]['etemplate_id'].'"'.($roundrobin_action[6]==$etemplate[$i]['etemplate_id']?' selected="selected"':'').'>'.$etemplate[$i]['etemplate_name'].'</option>'; ?>
                  </select>
              
               </div>
            </div>
            </div>
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSTATUS']; ?></label>
               <div class="col-sm-1">
                  <label class="switch <? if($roundrobin_details['is_enabled']==0) echo 'radio-no-uncheck'; ?>">
                  <input type="checkbox" name="vis_status"  id="vis_status" <? if($roundrobin_details['is_enabled']==1) echo ' checked="checked"'; ?>  >
                  <span ></span>
                  </label>
               </div>
            </div>
            <div class="line b-b line-lg pull-in"></div>
            <br/>
            <div class="form-group">
               <div class="col-sm-4 col-sm-offset-2">
                  <button type="button" class="btn btn-primary" onclick="$('#vis_workpanel_div').visExecution('submit_form',{'vis_module':'setting', 'vis_operation':'update_roundrobin', 'vis_form':'vis_roundrobin_form_<? echo $roundrobin_details['roundrobin_id']; ?>'})"><? echo $vis_language['TXTUPDATE']; ?></button>
               </div>
            </div>
      </div>
      </form>
      </div>
   </section>
</section>
<style>
.selectpicker span:nth-child(2){
color:#000000 !important;
}
</style>
<script>
   $("#vis_sla_state_id").val("<? echo $roundrobin_action[28]; ?>");
   $(".selectpicker").selectpicker();
   function select_picker()
   {
   $('.start').datetimepicker();
   $(".selectpicker").selectpicker();
   }
			
			toggle_status_escl();
			function toggle_status_escl(){
	if($('#vis_escon').is(":checked")){ $('#showesc').show();}
	else { $('#showesc').hide();}
}
</script>
<script>
   function add_roundrobin_criteria_<? echo $roundrobin_details['roundrobin_id']; ?>(mid) {
       var total=document.getElementById("total_roundrobin_critaria_<? echo $roundrobin_details['roundrobin_id']; ?>");
       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_eroundrobin'+num+'" id="vis_main_eroundrobin_<? echo $roundrobin_details['roundrobin_id']; ?>'+num+'" onchange="changeeroundrobinOption('+num+')" 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="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="3"><? 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="30"><? echo $vis_language['TXTTICKETCATEGORY'];?></option><option value="31"><? echo $vis_language['TXTTICKETSUBCATEGORY'];?></option><option value="32"><? echo $vis_language['TXTTICKETITEM'];?></option><option value="33"><? echo $vis_language['TXTTICKETLEVEL'];?></option><? if(!empty($location) && VIS_ITIL==1){ ?><option value="34"><? 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="12"><? echo $vis_language['TXTLASTACTIVITY'];?></option><option value="28"><? echo $vis_language['TXTLASTREPLIER'];?></option><option value="16"><? echo $vis_language['TXTCREATIONDATE'];?></option><option value="15"><? echo $vis_language['TXTSLAPLAN'];?></option><option value="19"><? echo $vis_language['TXTHASATTACHMENT'];?></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></select></div><div class="col-sm-3"  id="vis_wcriteria_option_<? echo $roundrobin_details['roundrobin_id']; ?>'+num+'"><select name="vis_sub_eroundrobin'+num+'" id="vis_sub_eroundrobin_<? echo $roundrobin_details['roundrobin_id']; ?>'+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></div><div class="col-sm-3"  id="vis_wcriteria_text_<? echo $roundrobin_details['roundrobin_id']; ?>'+num+'"><input name="vis_roundrobin_text'+num+'" id="vis_roundrobin_text'+num+'" type="text" class="form-control input-sm" /></div><label class="col-sm-1"><i class="vh vh-cross" onclick="javascript:close_roundrobin_criteria('+num+');" style="cursor:pointer" title="<? echo $vis_language['TXTCLOSE']; ?>"></i></label></div>';
       newDiv.id="vis_roundrobin_sub_criteria_"+num;
       newDiv.innerHTML=newCritera;
       document.getElementById("vis_eroundrobin_options_<? echo $roundrobin_details['roundrobin_id']; ?>").appendChild(newDiv);
       if(typeof mid !="undefined") $("#vis_main_eroundrobin_<? echo $roundrobin_details['roundrobin_id']; ?>"+num).val(mid);
   select_picker();
   }
   function add_roundrobin_or_criteria_<? echo $roundrobin_details['roundrobin_id']; ?>(mid) {
       var total=document.getElementById("total_roundrobin_critaria_or_<? echo $roundrobin_details['roundrobin_id']; ?>");
       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_eroundrobin_or'+num+'" id="vis_main_eroundrobin_or_<? echo $roundrobin_details['roundrobin_id']; ?>'+num+'" onchange="changeeroundrobinOption('+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="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="3"><? 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="30"><? echo $vis_language['TXTTICKETCATEGORY'];?></option><option value="31"><? echo $vis_language['TXTTICKETSUBCATEGORY'];?></option><option value="32"><? echo $vis_language['TXTTICKETITEM'];?></option><option value="33"><? echo $vis_language['TXTTICKETLEVEL'];?></option><? if(!empty($location) && VIS_ITIL==1){ ?><option value="34"><? 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="12"><? echo $vis_language['TXTLASTACTIVITY'];?></option><option value="28"><? echo $vis_language['TXTLASTREPLIER'];?></option><option value="16"><? echo $vis_language['TXTCREATIONDATE'];?></option><option value="15"><? echo $vis_language['TXTSLAPLAN'];?></option><option value="19"><? echo $vis_language['TXTHASATTACHMENT'];?></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></select></div><div class="col-sm-3"  id="vis_wcriteria_option_or_<? echo $roundrobin_details['roundrobin_id']; ?>'+num+'"><select name="vis_sub_eroundrobin_or'+num+'" id="vis_sub_eroundrobin_or_<? echo $roundrobin_details['roundrobin_id']; ?>'+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></div><div class="col-sm-3"  id="vis_wcriteria_text_or_<? echo $roundrobin_details['roundrobin_id']; ?>'+num+'"><input name="vis_roundrobin_text_or'+num+'" id="vis_roundrobin_text_or'+num+'" type="text" class="form-control input-sm" /></div><label class="col-sm-1"><i class="vh vh-cross" onclick="javascript:close_roundrobin_criteria('+num+',0);" style="cursor:pointer" title="<? echo $vis_language['TXTCLOSE']; ?>"></i></label></div>';
       newDiv.id="vis_roundrobin_sub_criteria_or_"+num;
       newDiv.innerHTML=newCritera;
       document.getElementById("vis_eroundrobin_or_options_<? echo $roundrobin_details['roundrobin_id']; ?>").appendChild(newDiv);
       if(typeof mid !="undefined") $("#vis_main_eroundrobin_or_<? echo $roundrobin_details['roundrobin_id']; ?>"+num).val(mid);
   select_picker();
   }
   function changeeroundrobinOption(num, sid, cont,condition) {
       var tempcondition='';
       if(condition==0) tempcondition='_or';
       var mainOpt=document.getElementById("vis_main_eroundrobin"+tempcondition+"_<? echo $roundrobin_details['roundrobin_id']; ?>"+num).value;
       var subOpt=document.getElementById("vis_wcriteria_option"+tempcondition+"_<? echo $roundrobin_details['roundrobin_id']; ?>"+num);
       var subTxt=document.getElementById("vis_wcriteria_text"+tempcondition+"_<? echo $roundrobin_details['roundrobin_id']; ?>"+num);
       if(mainOpt==0 || mainOpt==4 || mainOpt==5 || mainOpt==25) {
           subOpt.innerHTML='<select name="vis_sub_eroundrobin'+tempcondition+num+'" id="vis_sub_eroundrobin'+tempcondition+'_<? echo $roundrobin_details['roundrobin_id']; ?>'+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==20) {
           subOpt.innerHTML='<select name="vis_sub_eroundrobin'+tempcondition+num+'" id="vis_sub_eroundrobin'+tempcondition+'_<? echo $roundrobin_details['roundrobin_id']; ?>'+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==3 || 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==30|| mainOpt==31|| mainOpt==32| mainOpt==33|| mainOpt==34) {
           subOpt.innerHTML='<select name="vis_sub_eroundrobin'+tempcondition+num+'" id="vis_sub_eroundrobin'+tempcondition+'_<? echo $roundrobin_details['roundrobin_id']; ?>'+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==13 || mainOpt==14 || mainOpt==16) {
           subOpt.innerHTML='<select name="vis_sub_eroundrobin'+tempcondition+num+'" id="vis_sub_eroundrobin'+tempcondition+'_<? echo $roundrobin_details['roundrobin_id']; ?>'+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==26 || mainOpt==12) {
           subOpt.innerHTML='<select name="vis_sub_eroundrobin'+tempcondition+num+'" id="vis_sub_eroundrobin'+tempcondition+'_<? echo $roundrobin_details['roundrobin_id']; ?>'+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_eroundrobin'+tempcondition+num+'" id="vis_sub_eroundrobin'+tempcondition+'_<? echo $roundrobin_details['roundrobin_id']; ?>'+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_eroundrobin'+tempcondition+num+'" id="vis_sub_eroundrobin'+tempcondition+'_<? echo $roundrobin_details['roundrobin_id']; ?>'+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_eroundrobin'+tempcondition+num+'" id="vis_sub_eroundrobin'+tempcondition+'_<? echo $roundrobin_details['roundrobin_id']; ?>'+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTSTAFF'];?></option></select>';
       }

       if(mainOpt==0 || mainOpt==1 || mainOpt==2 || mainOpt==4 || mainOpt==5 || mainOpt==20 || mainOpt==25) {
           subTxt.innerHTML='<input name="vis_roundrobin_text'+tempcondition+num+'" id="vis_roundrobin_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_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_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==3) { <?
      if(count($domains)>10) $select1= 'data-live-search="true"';
               $temp='<select name="vis_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_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_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_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_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_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_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_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($staff_details)>10) $select1= 'data-live-search="true"';
               $temp='<select name="vis_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'><option value="0">'.$vis_language['TXTUNASSIGNED'].'</option>';
               for($i=0;$i<count($staff_details);$i++) $temp.='<option value="'.$staff_details[$i]['staff_id'].'">'.addslashes($staff_details[$i]['first_name']).' '.addslashes($staff_details[$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_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_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==13 || mainOpt==14 || mainOpt==16) {
           subTxt.innerHTML='<input name="vis_roundrobin_text'+tempcondition+num+'" id="vis_roundrobin_text'+tempcondition+num+'" type="text" value="" class="form-control input-sm start" />';
       }
       else if(mainOpt==15) { <?
      if(count($sla)>10) $select1= 'data-live-search="true"';
               $temp='<select name="vis_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
               if($sla!=-1) 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==18 || mainOpt==19) {
           subTxt.innerHTML='<select name="vis_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_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_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_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) { <?
       $select1='';
      if(count($client_language)>10) $select1= 'data-live-search="true"';
               $temp='<select name="vis_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_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'].'">'.addslashes($client_language[$i]['language_name']).'</option>';
               $temp.='</select>';
               echo "subTxt.innerHTML='".$temp."';"; ?>
       }
       else if(mainOpt==23) { <?
       $select1='';
      if(count($label_details)>10) $select1= 'data-live-search="true"';
               $temp='<select name="vis_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
               for($i=0;$i<count($label_details);$i++) $temp.='<option data-id="roundrobin_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) { <?
       $select1='';
      if(count($channel_details)>10) $select1= 'data-live-search="true"';
               $temp='<select name="vis_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_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'].'">'.addslashes($channel_details[$i]['channel_name']).'</option>';
               $temp.='</select>';
               echo "subTxt.innerHTML='".$temp."';"; ?>
       }else if(mainOpt==26 || mainOpt==27 || mainOpt==17 || mainOpt==12) {
            subTxt.innerHTML='<input name="vis_roundrobin_text'+tempcondition+num+'_hr" id="vis_roundrobin_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_roundrobin_text'+tempcondition+num+'_mi" id="vis_roundrobin_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==30) { <?
       if(count($ticket_category)>10) $select1= 'data-live-search="true"';
               $temp='<select name="vis_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
               for($i=0;$i<count($ticket_category);$i++) $temp.='<option value="'.$ticket_category[$i]['category_id'].'">'.addslashes($ticket_category[$i]['title']).'</option>';
               $temp.='</select>';
               echo "subTxt.innerHTML='".$temp."'"; ?>
       }
       else if(mainOpt==31) { <?
       if(count($ticket_subcategory)>10) $select1= 'data-live-search="true"';
               $temp='<select name="vis_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
			    for($i=0;$i<count($ticket_category);$i++){ 
					$temp.='<optgroup label="'.addslashes($ticket_category[$i]['title']).'">';
					for($j=0;$j<count($ticket_subcategory);$j++) {
						if($ticket_category[$i]['category_id'] == $ticket_subcategory[$j]['category_id']) {
							$temp.='<option value="'.$ticket_subcategory[$j]['subcategory_id'].'">'.addslashes($ticket_subcategory[$j]['title']).'</option>';
						}
					}
					$temp.='</optgroup>';
				}
               $temp.='</select>';
               echo "subTxt.innerHTML='".$temp."'"; ?>
       }
      else if(mainOpt==32) { <? 
       if(count($ticket_item)>10) $select1= 'data-live-search="true"';
           $temp='<select name="vis_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
           for($i=0;$i<count($ticket_subcategory);$i++){ 
				$temp.='<optgroup label="'.addslashes($ticket_subcategory[$i]['title']).'">';
				for($j=0;$j<count($ticket_item);$j++) {
					if($ticket_subcategory[$i]['subcategory_id'] == $ticket_item[$j]['subcategory_id']) {
						$temp.='<option value="'.$ticket_item[$j]['item_id'].'">'.addslashes($ticket_item[$j]['title']).'</option>'; 
					}
				}
				$temp.='</optgroup>';
			}
		   $temp.='</select>';
		   echo "subTxt.innerHTML='".$temp."'"; ?>
       }
       else if(mainOpt==33) { <?
       if(count($ticket_level)>10) $select1= 'data-live-search="true"';
               $temp='<select name="vis_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
               for($i=0;$i<count($ticket_level);$i++) $temp.='<option value="'.$ticket_level[$i]['level_id'].'">'.addslashes($ticket_level[$i]['title']).'</option>';
               $temp.='</select>';
               echo "subTxt.innerHTML='".$temp."'"; ?>
       }
        else if(mainOpt==34) { <?
       if(count($location)>10) $select1= 'data-live-search="true"';
                $temp='<select name="vis_roundrobin_text\'+tempcondition+num+\'" id="vis_roundrobin_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
               $temp .= vis_show_subcategories($location,'');
			   function vis_show_subcategories($location,$call=NULL) {
				   for($i=0;$i<count($location);$i++){ 
					   $temp.='<option value="'.$location[$i]['location_id'].'">'.addslashes($location[$i]['name']).'</option>';
					   if($location[$i]['subcat']!=NULL) { 
					    	$temp .= vis_show_subcategories($location[$i]['subcat'],'sub_cat'); 
					   }
				   }
				   return $temp;
			   }
               $temp.='</select>';
               echo "subTxt.innerHTML='".$temp."'";  ?>
       }
       if(typeof sid !="undefined") {
           $("#vis_sub_eroundrobin"+tempcondition+"_<? echo $roundrobin_details['roundrobin_id']; ?>"+num).val(sid);
           if(mainOpt==26 || mainOpt==27 || mainOpt==17 ||  mainOpt==12){
               var temptime=cont.split(":");
               $("#vis_roundrobin_text"+tempcondition+num+'_hr').val(temptime[0]);
               $("#vis_roundrobin_text"+tempcondition+num+'_mi').val(temptime[1]);
           }else{
                $("#vis_roundrobin_text"+tempcondition+num).val(cont);
           }
       }
   select_picker();
   }
   function close_roundrobin_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_roundrobin_sub_criteria"+tempcondition+"_"+num).innerHTML="";
   }
   function reset_eroundrobin_filter() {
       document.getElementById("vis_eroundrobin_options_<? echo $roundrobin_details['roundrobin_id']; ?>").innerHTML="";
       document.getElementById("total_eroundrobin_critaria").value=0;
       add_roundrobin_criteria_<? echo $roundrobin_details['roundrobin_id']; ?>();
   	   select_picker();
   }
   <?
      if($roundrobin_criteria!=-1){
         $j=1;
         for($i=0;$i<count($roundrobin_criteria);$i++){
            if($roundrobin_criteria[$i]['concat_type']=='and'){
               echo 'add_roundrobin_criteria_'.$roundrobin_details['roundrobin_id'].'('.$roundrobin_criteria[$i]['base_criteria'].'); changeeroundrobinOption('.($j++).', '.$roundrobin_criteria[$i]['sub_criteria'].', "'.addslashes($roundrobin_criteria[$i]['content']).'",1); ';
            }
         }
         $j=1;
         for($i=0;$i<count($roundrobin_criteria);$i++){
            if($roundrobin_criteria[$i]['concat_type']=='or'){
               echo 'add_roundrobin_or_criteria_'.$roundrobin_details['roundrobin_id'].'('.$roundrobin_criteria[$i]['base_criteria'].'); changeeroundrobinOption('.($j++).', '.$roundrobin_criteria[$i]['sub_criteria'].', "'.addslashes($roundrobin_criteria[$i]['content']).'",0); ';
            }
         }
      }
      ?>
</script>
