<? 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"><span><? echo $vis_language['TXTQUESTADD'];?><span id="total_cnt"></span></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 class="link" href="#/setting/view_gamification/<? echo $vis_language['TXTGAMIFICATION'];?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTGAMIFICATION'];?>',{'vis_module':'setting','vis_operation':'view_gamification'});"><? echo $vis_language['TXTGAMIFICATION']; ?></a></li>
         <li><a class="link" href="#/setting/view_quest/<? echo $vis_language['TXTQUEST']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTQUEST'];?>',{'vis_module':'setting','vis_operation':'view_quest'});"><? echo $vis_language['TXTQUEST']; ?></a></li>
         <li class="active"><?  echo $vis_language['TXTQUESTADD']; ?></li>
      </ul>
   </div>
</section>
<section class="padder">
   <section class="panel panel-default">
      <header class="panel-heading sub_header"><? echo $vis_language['TXTQUESTADD']; ?></header>
      <div class="panel-body">
         <form class="form-horizontal" id="vis_quest_form" name="vis_quest_form" method="post" >
            <input type="hidden" name="total_ticket_critaria" id="total_ticket_critaria" value="0" />
            <input type="hidden" name="total_selfhelp_critaria" id="total_selfhelp_critaria" value="0" />
            <input type="hidden" name="total_ticket_or_critaria" id="total_ticket_or_critaria" value="0" />
            <input type="hidden" name="total_selfhelp_or_critaria" id="total_selfhelp_or_critaria" value="0" />
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTNAMEYOURQUEST'] ;?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text"  name="vis_quest_name" id="vis_quest_name" value="" >
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTQUESTDESCRIPTION'] ;?></label>
               <div class="col-sm-10">
                  <textarea class="form-control input-sm" type="text"  name="vis_quest_description" id="vis_quest_description" value="" > </textarea>
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTBADGE'] ;?></label>
               <div class="col-xl-1" id="vis_badge_area">
                  <input type="hidden" name="vis_badge_name" >
                  <div style="display: inline;" class="bootstrap-filestyle"><label class="btn btn-link link " for="filestyle-0"><span   data-modal-arguments="vis_module=setting&vis_operation=set_quest_image" data-toggle="ajaxModal" style="cursor:pointer;">Upload image</span></label></div>
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSTARTDATE'] ;?></label>
               <div class="col-sm-10">
                  <span class="input-group-addon no-padder no-borders start">   <input class="form-control input-sm" type="text"  name="vis_start_date" id="vis_start_date" value=""></span>
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTBONUSPOINT'] ;?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text"  name="vis_bonus_points" id="vis_bonus_points" value="<?=$point_details['points'];?>" >
               </div>
            </div>

            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSTAFFGROUP'];  ?></label>
               <div class="col-sm-10">
				<div class="dept_access_list">
                  <?
                     foreach($staff_group as $staff_group) { ?>
                  <label class="checkbox-inline i-checks">
                  <input type="checkbox" value="<? echo $staff_group['group_id']; ?>" name="vis_staff_group_id[]" /> <i></i><? echo $staff_group['group_name']; ?></label><br/>
                  <? } ?>
                </div>
               </div>
            </div>

            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTQUESTTYPE'] ;?></label>
               <div class="col-sm-10">
                  <div class="radio i-checks m-r-lg pull-left">
                     <label>
                     <input type="radio" value="1" checked="checked" id="vis_quest_type1" name="vis_quest_type" onclick="DisplayQuest(this.value)"><i></i><? echo $vis_language['TXTRESOLVINGTYPE'] ;?></label>
                  </div>
                  <div class="radio i-checks pull-left">
                     <label>
                     <input type="radio" value="2" id="vis_quest_type2" name="vis_quest_type" onclick="DisplayQuest(this.value)"><i></i><? echo $vis_language['TXTSELFHELFARTICLE'] ;?></label>
                  </div>
               </div>
            </div>

            <div class="form-group">
               <label class="col-sm-2 control-label" id="condition_lable1"><? echo $vis_language['TXTRESOLVE']; ?></label>
               <div class="col-sm-2">
                  <input class="form-control input-sm" type="text" name="vis_quest_condition_count" id="vis_quest_condition_count" value="<?=$point_details['points'];?>" >
               </div>
               <label class="col-sm-2 control-label" id="condition_lable2"><? echo $vis_language['TXTTICKETSLOVEDSPAN']; ?></label>
               <div class="col-sm-2">
                  <select class="form-control input-sm selectpicker"  name="vis_quest_duration">
                     <option value="" ><? echo $vis_language['TXTSELECT']; ?></option>
                     <option value="+1 day" >1 Day</option>
                     <option value="+2 day" >2 Days</option>
                     <option value="+1 Week" >1 Week</option>
                     <option value="+2 Week" >2 Weeks</option>
                     <option value="+1 Month" >1 Month</option>
                     <option value="+1 year" >1 Year</option>
                  </select>
               </div>
               <label class="col-sm-1.5 control-label"><?  echo $vis_language['TXTTICKETMATCHINGBELOWCONTAIN']; ?></label>
            </div>

            <div id="vis_quest_div" >
                <div class="form-group">
                   <label class="col-sm-2 control-label"><? echo $vis_language['TXTMATCHANDCONDITIONS']; ?></label>
                   <div class="col-sm-10"><div id="vis_resolve_ticket_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_quest_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_resolve_ticket_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_quest_or_criteria()"><? echo $vis_language['TXTADDCRITERIA']; ?></button>
                      </label>
                   </div>
                </div>
            </div>


            <!-- Div for Quest type Selfhelp article  -->
            <div id="vis_quest_selfthelp_div" style="display: none" >
                <div class="form-group">
                   <label class="col-sm-2 control-label"><? echo $vis_language['TXTMATCHANDCONDITIONS']; ?></label>
                   <div class="col-sm-10"><div id="vis_selfhelpquest_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_quest_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_selfhelpquest_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_quest_or_criteria()"><? echo $vis_language['TXTADDCRITERIA']; ?></button>
                      </label>
                   </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">
                  <input type="checkbox" name="vis_quest_status" id="vis_quest_status" 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':'add_quest', 'vis_form':'vis_quest_form'})"><? echo $vis_language['TXTADD']; ?></button>
               </div>
            </div>
      </div>
      </form>
      </div>
      </div>
   </section>
</section>
<script>
     // $("#vis_start_date").datetimepicker({showButtonPanel: true, dateFormat: 'yy-mm-dd'});
      $('.start').datetimepicker({
        format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>"
	 });
      $(".selectpicker").selectpicker();
      function select_picker()
      {
          $('.start').datetimepicker();
          $(".selectpicker").selectpicker();
      }
      function add_quest_criteria()
      {
            if($('input[name="vis_quest_type"]:checked').val() == 1)
            {
                 var total=document.getElementById("total_ticket_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_ticket'+num+'" id="vis_main_ticket'+num+'" onchange="changequestOption('+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['TXTSTATUS'];?></option><option value="2"><? echo $vis_language['TXTPRIORITY'];?></option><option value="3"><? echo $vis_language['TXTTICKETTYPE'];?></option><option value="4"><? echo $vis_language['TXTFLAGTYPE'];?></option><option value="5"><? echo $vis_language['TXTSLAPLAN'];?></option><option value="7"><? echo $vis_language['TXTCREATIONTIME'];?></option><option value="8"><? echo $vis_language['TXTRESOLUTIONDUETIME'];?></option><option value="6"><? echo $vis_language['TXTOVERDUETIME'];?></option><option value="9"><? echo $vis_language['TXTLASTREPLIER'];?></option><option value="10"><? echo $vis_language['TXTOPERATOR'];?></option></select></div><div class="col-sm-3"  id="vis_criteria_option_ticket'+num+'"><select class="form-control input-sm selectpicker" name="vis_sub_ticket_quest'+num+'" id="vis_sub_ticket_quest'+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_ticket'+num+'"><input name="vis_ticket_quest_text'+num+'" id="vis_ticket_quest_text'+num+'" type="text" class="form-control input-sm" /></div><label class="col-sm-1"><i class="vh vh-cross" title="<? echo $vis_language['TXTCLOSE']; ?>" onclick="javascript:close_workflow_criteria('+num+',1)" style="cursor:pointer"></i></label></div>';

                 newDiv.id="vis_ticket_quest_sub_criteria"+num;
                 newDiv.innerHTML=newCritera;
                 document.getElementById("vis_resolve_ticket_options").appendChild(newDiv);
            }
            else if($('input[name="vis_quest_type"]:checked').val() == 2)
            {
                var total=document.getElementById("total_selfhelp_critaria");
                var num=parseInt(total.value)+1;
                total.value=num;
                var newDiv=document.createElement("DIV"); //vis_main_workflow
                var newCritera='<div class="form-group"><div class="col-sm-3"><select name="vis_main_selfhelp'+num+'" id="vis_main_selfhelp'+num+'" onchange="changequestOption('+num+',1)" class="form-control input-sm selectpicker" data-live-search="true"><option value="0"><? echo $vis_language['TXTARTICLECOUNT'];?></option><option value="1"><? echo $vis_language['TXTARTICLELIKE'];?></option></select></div><div class="col-sm-3"  id="vis_criteria_option_selfhelp'+num+'"><select name="vis_sub_selfhelp'+num+'" id="vis_sub_selfhelp'+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTGREATERTHAN'];?></option><option value="1"><? echo $vis_language['TXTEQUAL'];?></option><option value="2"><? echo $vis_language['TXTLESSTHAN'];?></option></select></div><div class="col-sm-3"  id="vis_criteria_text_selfhelp'+num+'"><input name="vis_article_text'+num+'" id="vis_article_text'+num+'" type="text" class="form-control input-sm" /></div><label class="col-sm-1"><i class="vh vh-cross" title="<? echo $vis_language['TXTCLOSE']; ?>" onclick="javascript:close_workflow_criteria('+num+',1)" style="cursor:pointer"></i></label></div>';

               newDiv.id="vis_selfhelp_quest_sub_criteria"+num;
               newDiv.innerHTML=newCritera;
               document.getElementById("vis_selfhelpquest_options").appendChild(newDiv);
             }
             select_picker();
      }

      function add_quest_or_criteria()
      {
            if($('input[name="vis_quest_type"]:checked').val() == 1)
            {
                 var total=document.getElementById("total_ticket_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_ticket_or'+num+'" id="vis_main_ticket_or'+num+'" onchange="changequestOption('+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['TXTSTATUS'];?></option><option value="2"><? echo $vis_language['TXTPRIORITY'];?></option><option value="3"><? echo $vis_language['TXTTICKETTYPE'];?></option><option value="4"><? echo $vis_language['TXTFLAGTYPE'];?></option><option value="5"><? echo $vis_language['TXTSLAPLAN'];?></option><option value="7"><? echo $vis_language['TXTCREATIONTIME'];?></option><option value="8"><? echo $vis_language['TXTRESOLUTIONDUETIME'];?></option><option value="6"><? echo $vis_language['TXTOVERDUETIME'];?></option><option value="9"><? echo $vis_language['TXTLASTREPLIER'];?></option><option value="10"><? echo $vis_language['TXTOPERATOR'];?></option></select></div><div class="col-sm-3"  id="vis_criteria_option_ticket_or'+num+'"><select class="form-control input-sm selectpicker" name="vis_sub_ticket_quest_or'+num+'" id="vis_sub_ticket_quest_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_ticket_or'+num+'"><input name="vis_ticket_quest_text_or'+num+'" id="vis_ticket_quest_text_or'+num+'" type="text" class="form-control input-sm" /></div><label class="col-sm-1"><i class="vh vh-cross" title="<? echo $vis_language['TXTCLOSE']; ?>" onclick="javascript:close_workflow_criteria('+num+',0)" style="cursor:pointer"></i></label></div>';

                 newDiv.id="vis_ticket_quest_sub_or_criteria"+num;
                 newDiv.innerHTML=newCritera;
                 document.getElementById("vis_resolve_ticket_or_options").appendChild(newDiv);
            }
            else if($('input[name="vis_quest_type"]:checked').val() == 2)
            {
                var total=document.getElementById("total_selfhelp_or_critaria");
                var num=parseInt(total.value)+1;
                total.value=num;
                var newDiv=document.createElement("DIV"); //vis_main_workflow
                var newCritera='<div class="form-group"><div class="col-sm-3"><select name="vis_main_selfhelp_or'+num+'" id="vis_main_selfhelp_or'+num+'" onchange="changequestOption('+num+',0)" class="form-control input-sm selectpicker" data-live-search="true"><option value="0"><? echo $vis_language['TXTARTICLECOUNT'];?></option><option value="1"><? echo $vis_language['TXTARTICLELIKE'];?></option></select></div><div class="col-sm-3"  id="vis_criteria_option_selfhelp_or'+num+'"><select name="vis_sub_selfhelp_or'+num+'" id="vis_sub_selfhelp_or'+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTGREATERTHAN'];?></option><option value="1"><? echo $vis_language['TXTEQUAL'];?></option><option value="2"><? echo $vis_language['TXTLESSTHAN'];?></option></select></div><div class="col-sm-3"  id="vis_criteria_text_selfhelp_or'+num+'"><input name="vis_article_text_or'+num+'" id="vis_article_text_or'+num+'" type="text" class="form-control input-sm" /></div><label class="col-sm-1"><i class="vh vh-cross" title="<? echo $vis_language['TXTCLOSE']; ?>" onclick="javascript:close_workflow_criteria('+num+',0)" style="cursor:pointer"></i></label></div>';

               newDiv.id="vis_selfhelp_quest_sub_or_criteria"+num;
               newDiv.innerHTML=newCritera;
               document.getElementById("vis_selfhelpquest_or_options").appendChild(newDiv);
             }
             select_picker();
      }

      function changequestOption(num,condition)
      {
            var tempcondition='';
            if(condition==0) tempcondition='_or';
            if($('input[name="vis_quest_type"]:checked').val() == 1)
            {
                  var mainOpt=document.getElementById("vis_main_ticket"+tempcondition+num).value;
                  var subOpt=document.getElementById("vis_criteria_option_ticket"+tempcondition+num);
                  var subTxt=document.getElementById("vis_criteria_text_ticket"+tempcondition+num);
                  if(mainOpt==0)
                  {
                         subOpt.innerHTML='<select name="vis_sub_ticket_quest'+tempcondition+num+'" id="vis_sub_ticket_quest'+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==4 || mainOpt==5)
                  {
                         subOpt.innerHTML='<select name="vis_sub_ticket_quest'+tempcondition+num+'" id="vis_sub_ticket_quest'+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==6 || mainOpt==8)
                  {
                         subOpt.innerHTML='<select name="vis_sub_ticket_quest'+tempcondition+num+'" id="vis_sub_ticket_quest'+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==7)
                  {
                         subOpt.innerHTML='<select name="vis_sub_ticket_quest'+tempcondition+num+'" id="vis_sub_ticket_quest'+tempcondition+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTAFTER'];?></option></select>';
                  }
                  else if(mainOpt==9)
                  {
                         subOpt.innerHTML='<select name="vis_sub_ticket_quest'+tempcondition+num+'" id="vis_sub_ticket_quest'+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==10)
                  {
                         subOpt.innerHTML='<select name="vis_sub_ticket_quest'+tempcondition+num+'" id="vis_sub_ticket_quest'+tempcondition+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTSTAFF'];?></option></select>';
                  }

                  if(mainOpt==1)
                  { <?
                        if(count($status)>10) $select1= 'data-live-search="true"';
                        $temp='<select name="vis_ticket_quest_text\'+tempcondition+num+\'" id="vis_ticket_quest_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
                        for($i=0;$i<count($status);$i++) $temp.='<option value="'.$status[$i]['status_id'].'">'.$status[$i]['status_name'].'</option>';
                        $temp.='</select>';
                        echo "subTxt.innerHTML='".$temp."';"; ?>
                  }
                  else if(mainOpt==2)
                  { <?
                      if(count($priorities)>10) $select1= 'data-live-search="true"';
                      $temp='<select name="vis_ticket_quest_text\'+tempcondition+num+\'" id="vis_ticket_quest_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
                      for($i=0;$i<count($priorities);$i++) $temp.='<option value="'.$priorities[$i]['priority_id'].'">'.$priorities[$i]['priority_name'].'</option>';
                      $temp.='</select>';
                      echo "subTxt.innerHTML='".$temp."';"; ?>
                  }
                  else if(mainOpt==3)
                  { <?
                      if(count($ticket_types)>10) $select1= 'data-live-search="true"';
                      $temp='<select name="vis_ticket_quest_text\'+tempcondition+num+\'" id="vis_ticket_quest_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'].'">'.$ticket_types[$i]['type_name'].'</option>';
                      $temp.='</select>';
                      echo "subTxt.innerHTML='".$temp."'"; ?>
                  }
                  else if(mainOpt==4)
                  { <?
                      if(count($flags)>10) $select1= 'data-live-search="true"';
                      $temp='<select name="vis_ticket_quest_text\'+tempcondition+num+\'" id="vis_ticket_quest_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-o";
                           $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.'">'.$flags[$i]['flag_name'].'</option>';
                      }
                      $temp.='</select>';
                      echo "subTxt.innerHTML='".$temp."';"; ?>
                  }
                  else if(mainOpt==5)
                  { <?
                          if(count($sla)>10) $select1= 'data-live-search="true"';
                          $temp='<select name="vis_ticket_quest_text\'+tempcondition+num+\'" id="vis_ticket_quest_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'].'">'.$sla[$i]['sla_name'].'</option>';
                          $temp.='</select>';
                          echo "subTxt.innerHTML='".$temp."';"; ?>
                 }
                 else if(mainOpt==6 || mainOpt==7 || mainOpt==8)
                 {
                         subTxt.innerHTML='<input name="vis_ticket_quest_text'+tempcondition+num+'_hr" id="vis_ticket_quest_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_ticket_quest_text'+tempcondition+num+'_mi" id="vis_ticket_quest_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==10)
                 {
                    <?
                      if(count($staff_details)>10) $select1= 'data-live-search="true"';
                      $temp='<select name="vis_ticket_quest_text\'+tempcondition+num+\'" id="vis_ticket_quest_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
                      for($i=0;$i<count($staff_details);$i++) $temp.='<option value="'.$staff_details[$i]['staff_id'].'">'.trim($staff_details[$i]['first_name'].' '.$staff_details[$i]['last_name']).'</option>';
                      $temp.='</select>';
                      echo "subTxt.innerHTML='".$temp."'"; ?>
                 }
                 else if(mainOpt==9)
                 {
                         subTxt.innerHTML='';
                 }
              }
              else if($('input[name="vis_quest_type"]:checked').val() == 2)
              {
                    var mainOpt=document.getElementById("vis_main_selfhelp"+tempcondition+num).value;
                    var subOpt=document.getElementById("vis_criteria_option_selfhelp"+tempcondition+num);
                    var subTxt=document.getElementById("vis_criteria_text_selfhelp"+tempcondition+num);
                    if(mainOpt==1 || mainOpt==0)
                    {
                        subOpt.innerHTML='<select name="vis_sub_selfhelp'+tempcondition+num+'" id="vis_sub_selfhelp'+tempcondition+num+'" class="form-control input-sm selectpicker"><option value="0"><? echo $vis_language['TXTGREATERTHAN'];?></option><option value="1"><? echo $vis_language['TXTEQUAL'];?></option><option value="2"><? echo $vis_language['TXTLESSTHAN'];?></option></select>';
                    }
                    if(mainOpt==0 ) {
                        subTxt.innerHTML='<input name="vis_article_text'+tempcondition+num+'" id="vis_article_text'+tempcondition+num+'" type="text" value="" class="form-control input-sm" />';
                    }
                    else if(mainOpt==1) { <?
      $select1= 'data-live-search="true"';
                $temp='<select name="vis_article_text\'+tempcondition+num+\'" id="vis_article_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
                for($i=1;$i<=5;$i++) $temp.='<option value="'.$i.'">'.$i.'</option>';
                $temp.='</select>';
                echo "subTxt.innerHTML='".$temp."';"; ?>
                   }
              }
              select_picker();
         }
         function close_workflow_criteria(num,condition)
         {
             var tempcondition='';
             if(condition==0) tempcondition='_or';
             if($('input[name="vis_quest_type"]:checked').val() == 1)
             {
                   document.getElementById("vis_ticket_quest_sub_criteria"+tempcondition+num).innerHTML="";
             }
             else if($('input[name="vis_quest_type"]:checked').val() == 2)
             {
                   document.getElementById("vis_selfhelp_quest_sub_criteria"+tempcondition+num).innerHTML="";
             }
         }
         function reset_quest_filter()
         {
             if($('input[name="vis_quest_type"]:checked').val() == 1)
             {
                   document.getElementById("vis_resolve_ticket_options").innerHTML="";
                   document.getElementById("total_ticket_critaria").value=0;
             }
             else
             {
                   document.getElementById("vis_selfhelpquest_options").innerHTML="";
                   document.getElementById("total_selfhelp_critaria").value=0;
             }
             add_quest_criteria();
             select_picker();
         }
         function DisplayQuest(sel)
         {
             if(sel == 1){
                   $('#vis_quest_div').show();
                   $('#vis_quest_selfthelp_div').hide();
                   $('#condition_lable1').html('<?php echo $vis_language['TXTRESOLVE'];?>');
                   $('#condition_lable2').html('<?php echo $vis_language['TXTTICKETSLOVEDSPAN'];  ?>');

             }
             else
             {
                   $('#vis_quest_selfthelp_div').show();
                   $('#condition_lable1').html('<?php echo $vis_language['TXTCREATE'];  ?>');
                   $('#condition_lable2').html('<?php echo $vis_language['TXTARTICLEQUESTTIMEKNOW']; ?>');
                   $('#vis_quest_div').hide();
             }
         }
         add_quest_criteria();
         add_quest_or_criteria();
</script>
