<? 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['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>
         <? if($is_setting==1){ ?><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="#/home/view_alerts/<? echo $vis_language['TXTALERTS']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTALERTS']; ?>',{'vis_module':'home','vis_operation':'view_alerts'});" class="link"><? echo $operation['view_title']; ?></a></li>
         <li class="active"> <? echo $vis_language['TXTUPDATEALERT'];?></li>
      </ul>
      <div>
      </div>
   </div>
</section>
<section class="padder">
   <section class="panel panel-default">
      <header class="panel-heading sub_header"><? echo $vis_language['TXTUPDATEALERT']; ?></header>
      <div class="panel-body">
         <form  class="form-horizontal" id="vis_edit_alert_form_<? echo $alert['alert_id']; ?>" name="vis_edit_alert_form_<? echo $alert['alert_id']; ?>" method="post">
            <input type="hidden" name="total_ealert_critaria" id="total_alert_critaria_<? echo $alert['alert_id']; ?>" value="0" />
            <input type="hidden" name="total_ealert_critaria_or" id="total_alert_critaria_or_<? echo $alert['alert_id']; ?>" value="0" />
            <input type="hidden" name="vis_alert_id" id="vis_alert_id" value="<? echo $alert['alert_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_alert_title" id="vis_alert_title" value="<? echo htmlentities($alert['alert_name'], ENT_COMPAT, 'UTF-8'); ?>" >
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTEMAILTEMPLATE']; ?></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"><?= $vis_language['TXTNONE'] ?></option>
                     <?
                        for($i=0;$i<count($etemplate);$i++) echo '<option value="'.$etemplate[$i]['etemplate_id'].'"'.(($etemplate[$i]['etemplate_id']==$alert['template'])?' selected="selected"':'').'>'.$etemplate[$i]['etemplate_name'].'</option>'; ?>
                  </select>
               </div>
            </div>

             <?
               if(VIS_DOMAIN_ACCESS===0) { ?>
             <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTTEAM']; ?></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>
            <? }
               if(VIS_DOMAIN_ACCESS===0) { ?>
            <div class="form-group" >
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSTAFF']; ?></label>
               <div class="col-sm-10">
					<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[]" <? if(in_array($staff_details[$i]['staff_id'], $staff_owner)) echo ' checked="checked"'; ?> value="<? echo $staff_details[$i]['staff_id']; ?>" /> <i></i>&nbsp;<? echo $staff_details[$i]['first_name'].' '.$staff_details[$i]['last_name']; ?></label><br/>
					  <?
						 } ?>
				   </div>
               </div>
            </div>
            <?
               }
               else {
                   echo '<input type="hidden" name="vis_staff" value="'.VIS_STAFF_ID.'" />';
               } ?>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTEVENT']; ?></label>
               <div class="col-sm-10">
					<div class="dept_access_list">
				   <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="0" <? echo ($alert_event[0]==1)?' checked="checked"':''; ?> /> <i></i>&nbsp;<? echo $vis_language['TXTNEWTICKET']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="1" <? echo ($alert_event[1]==1)?' checked="checked"':''; ?> /> <i></i>&nbsp;<? echo $vis_language['TXTNEWCLIENTREPLY']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="2" <? echo ($alert_event[2]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTNEWSTAFFREPLY']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="3" <? echo ($alert_event[3]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTCLIENTADD']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="4" <? echo ($alert_event[4]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTCLIENTDELETE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="5" <? echo ($alert_event[5]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTTICKETDEPARTMENTCHANGE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="6" <? echo ($alert_event[6]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTTICKETSTATUSCHANGE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="7" <? echo ($alert_event[7]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTTICKETPRIORITYCHANGE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
				  <input type="checkbox" name="vis_event[]" value="50" <? echo ($alert_event[50]==1)?' checked="checked"':''; ?> /> <i></i>&nbsp;<? echo $vis_language['TXTCHANGECATEGORY']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
				  <input type="checkbox" name="vis_event[]" value="51" <? echo ($alert_event[51]==1)?' checked="checked"':''; ?> /> <i></i>&nbsp;<? echo $vis_language['TXTCHANGESUBCATEGORY']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
				  <input type="checkbox" name="vis_event[]" value="52" <? echo ($alert_event[52]==1)?' checked="checked"':''; ?> /> <i></i>&nbsp;<? echo $vis_language['TXTCHANGEITEM']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
				  <input type="checkbox" name="vis_event[]" value="53" <? echo ($alert_event[53]==1)?' checked="checked"':''; ?> /> <i></i>&nbsp;<? echo $vis_language['TXTCHANGELEVEL']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="8" <? echo ($alert_event[8]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTTICKETASSIGNE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="9" <? echo ($alert_event[9]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTTICKETMERGE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="10" <? echo ($alert_event[10]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTNOTEADD']; ?></label><br/>
				  <?if(VIS_MODULE_ACCESS_BILLING==1){?><label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="11" <? echo ($alert_event[11]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTINVOICECREATED']; ?></label><br/><? } ?>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="12" <? echo ($alert_event[12]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTTICKETPOSTDELETE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="13" <? echo ($alert_event[13]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTMOVETOTRASH']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="14" <? echo ($alert_event[14]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTFLAGCHANGE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="15" <? echo ($alert_event[15]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTTYPECHANGE']; ?></label><br/>
                  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="16" <? echo ($alert_event[16]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTONOVERDUE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="17" <? echo ($alert_event[17]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTONUNRESOLVED']; ?></label><br/>
                  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="49" <? echo ($alert_event[49]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTADDCOMMENT']; ?></label><br/>
					</div>
               </div>
            </div>
<!-- For ITIL purpose -->
			 <?php if(VIS_ITIL==1 && (isset($module['itil']) && $module['itil']==1)){?>
             <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTITILEVENT']; ?></label>
			   <div class="col-sm-10">
			   <div class="dept_access_list">
				   <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="18" <? echo ($alert_event[18]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTNEWPROBLEM']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="19" <? echo ($alert_event[19]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATEPROBLEMDEPT']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="20" <? echo ($alert_event[20]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATEPROBLEMSTATUS']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="21" <? echo ($alert_event[21]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATEPROBLEMPRIORITY']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="22" <? echo ($alert_event[22]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATEPROBLEMIMPACT']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="23" <? echo ($alert_event[23]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTPROBLEMASSIGN']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="24" <? echo ($alert_event[24]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTADDROOTCAUSE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="25" <? echo ($alert_event[25]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTADDPROBLEMIMPACT']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="26" <? echo ($alert_event[26]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTADDPROBLEMSYMPTOMS']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="27" <? echo ($alert_event[27]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTLINKPERMANENTSOLUTION']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="28" <? echo ($alert_event[28]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTLINKWORKAROUNDSOLUTION']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="29" <? echo ($alert_event[29]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTNEWCHANGE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="30" <? echo ($alert_event[30]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATECHANGEDEPT']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="31" <? echo ($alert_event[31]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATECHANGESTATUS']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="32" <? echo ($alert_event[32]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATEPCHANGEPRIORITY']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="33" <? echo ($alert_event[33]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATEPCHANGEIMPACT']; ?></label><br/>
                  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="34" <? echo ($alert_event[34]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATEPCHANGERISK']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="35"<? echo ($alert_event[35]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTCHANGEASSIGN']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="36"<? echo ($alert_event[36]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATEPCHANGETYPE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="37" <? echo ($alert_event[37]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTCHANGEREASON']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="38"<? echo ($alert_event[38]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTADDCHANGEIMPACT']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="39"<? echo ($alert_event[39]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTADDROLLOUTPLAN']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="40"<? echo ($alert_event[40]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTADDBACKOUTPLAN']; ?></label><br/>
                  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="41" <? echo ($alert_event[41]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTNEWRELEASE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="42"<? echo ($alert_event[42]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATERELEASEEDEPT']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="43"<? echo ($alert_event[43]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATERELEASESTATUS']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="44" <? echo ($alert_event[44]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATEPRELEASEPRIORITY']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="45"<? echo ($alert_event[45]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTUPDATERELEASETYPE']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="46"<? echo ($alert_event[46]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTRELEASEASSIGN']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="47"<? echo ($alert_event[47]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTADDBUILDPLAN']; ?></label><br/>
				  <label class="checkbox-inline i-checks">
                  <input type="checkbox" name="vis_event[]" value="48"<? echo ($alert_event[48]==1)?' checked="checked"':''; ?>/> <i></i>&nbsp;<? echo $vis_language['TXTADDTESTPLAN']; ?></label><br/>
				  <? if(!empty($locations)){?>
				  <label class="checkbox-inline i-checks">
				  <input type="checkbox" name="vis_event[]" value="54" <? echo ($alert_event[54]==1)?' checked="checked"':''; ?> /> <i></i>&nbsp;<? echo $vis_language['TXTCHANGELOCATION']; ?></label><br/>
				  <? }?>
				</div>
               </div>
             </div>
             <?php }?>
            <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_alert_order" id="vis_alert_order" value="<? echo $alert['display_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_alert_options_<? echo $alert['alert_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_alert_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_alert_or_options_<? echo $alert['alert_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_alert_or_criteria()"><? echo $vis_language['TXTADDCRITERIA']; ?></button>
                  </label>
               </div>
            </div>

            <div class="line b-b line-lg pull-in"></div>
            <br/>
            <? if($sms_setting[1]!=-1) { ?>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSMSALERT']; ?></label>
               <div class="col-sm-10">
                  <div class="radio i-checks m-r-lg pull-left">
				  <label>
                  <input name="vis_alert_status" id="vis_alert_status_yes" type="radio" value="1"  <? if($alert['sms_enabled']==1) echo 'checked="checked"'; ?>  /><i></i><? echo $vis_language['TXTENABLE']; ?></label></div>
                  <div class="radio i-checks pull-left">
				  <label>
                  <input name="vis_alert_status" id="vis_alert_status_no" type="radio" value="0"  <? if($alert['sms_enabled']==0) echo 'checked="checked"'; ?> /> <i></i>&nbsp;<? echo $vis_language['TXTDISABLE']; ?>
                  </label></div>
               </div>
            </div>
            <? } ?>
         
            <? if($hipchat_setting[1]!=-1 && $hipchat_setting!='') { ?>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTHIPCHATALERT']; ?></label>
               <div class="col-sm-10">
                  <div class="radio i-checks m-r-lg pull-left">
				  <label>
                  <input name="vis_hipchat_alert_status" id="vis_hipchat_alert_status_yes" type="radio" value="1" onclick= "hide_hipchat_div(1)" <? if($alert['hipchat_enabled']==1) echo 'checked="checked"'; ?>  /><i></i><? echo $vis_language['TXTENABLE']; ?></label></div>
                  <div class="radio i-checks pull-left">
				  <label>
                  <input name="vis_hipchat_alert_status" id="vis_hipchat_alert_status_no" type="radio" value="0"  onclick= "hide_hipchat_div(0)"<? if($alert['hipchat_enabled']==0) echo 'checked="checked"'; ?> /> <i></i>&nbsp;<? echo $vis_language['TXTDISABLE']; ?>
                  </label></div>
               </div>
            </div>
            <div id = 'vis_hipchat_div'>
             <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTNOTIFICATIONTO']; ?></label>
               <div class="col-sm-10">
                  <div class="radio i-checks m-r-lg pull-left">
				  <label>
                  <input name="vis_hipchat_notification" id="vis_hipchat_alert_status_yes" type="radio" value="1" onclick= "hide_room_list('');"<? echo ($alert['hipchat_room_ids']=='')?'checked="checked"':'';?> /><i></i>
                  <? echo $vis_language['TXTSTAFF']; ?></label></div>
                  <div class="radio i-checks pull-left">
				  <label>
                  <input name="vis_hipchat_notification" id="vis_hipchat_alert_status_no" type="radio" value="0" onclick= "hide_room_list('1');" <? echo ($alert['hipchat_room_ids']!='')?'checked="checked"':'';?>/> <i></i>
                  <? echo $vis_language['TXTROOM']; ?>
                  </label></div>
               </div>
            </div>
            
            <div class="form-group" id='hipchat_room_list'>
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTROOM']; ?></label>
			   <div class="col-sm-10">
			   <div class=" dept_access_list">
                  <? 
                  if($alert['hipchat_room_ids']!='')
                  {
					 $room_ids =  explode(',',$alert['hipchat_room_ids']);
				  }
                      for($i=0;$i<count($roomlist);$i++) { $row = get_object_vars($roomlist[$i]);
						  if(in_array($row['id'] ,$room_ids))$selected ='checked="checked"';
						  else $selected ='';
						  ?>
						    <label class="checkbox-inline i-checks">
                  <input type="checkbox" <? echo $selected;?> name="vis_room_ids[]" value="<? echo $row['id']; ?>" /> <i></i>&nbsp;<? echo $row['name']; ?></label><br/> 
						 <? 
						  }
                  ?>
				  </div>
               </div>
            </div>
            </div>
            <? } ?>
            <? if($slack_setting[1]!=-1 && $slack_setting!='') { ?>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSLACKALERT']; ?></label>
               <div class="col-sm-10">
                  <div class="radio i-checks m-r-lg pull-left">
				  <label>
                  <input name="vis_slack_alert_status" id="vis_slack_alert_status_yes" type="radio" value="1" onclick= "hide_slack_div(1)"  <? if($alert['slack_enabled']==1) echo 'checked="checked"'; ?>  /><i></i><? echo $vis_language['TXTENABLE']; ?></label></div>
                  <div class="radio i-checks pull-left">
				  <label>
                  <input name="vis_slack_alert_status" id="vis_slack_alert_status_no" type="radio" value="0" onclick= "hide_slack_div(0)" onclick <? if($alert['slack_enabled']==0) echo 'checked="checked"'; ?> /> <i></i>&nbsp;<? echo $vis_language['TXTDISABLE']; ?>
                  </label></div>
               </div>
            </div>
            
             <div id = 'vis_slack_div'>
             <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTNOTIFICATIONTO']; ?></label>
               <div class="col-sm-10">
                  <div class="radio i-checks m-r-lg pull-left">
				  <label>
                  <input name="vis_slack_notification" id="vis_slack_alert_status_yes" type="radio" value="1"  onclick= "hide_channel_list('');"<? echo ($alert['slack_chennel_id']=='')?'checked="checked"':'';?> /><i></i>
                  <? echo $vis_language['TXTSTAFF']; ?></label></div>
                  <div class="radio i-checks pull-left">
				  <label>
                  <input name="vis_slack_notification" id="vis_slack_alert_status_no" type="radio" value="0" onclick= "hide_channel_list('1');" <? echo ($alert['slack_chennel_id']!='')?'checked="checked"':'';?>/> <i></i>
                  <? echo $vis_language['TXTCHANNEL']; ?>
                  </label></div>
               </div>
            </div>
            
            <div class="form-group" id='slack_channel_list'>
				<label class="col-sm-2 control-label"><? echo $vis_language['TXTROOM']; ?></label>
			   <div class="col-sm-10">
			   <div class=" dept_access_list">
                  <? 
                
                  if($alert['slack_chennel_id']!='')
                  {
					 $channel_ids =  explode(',',$alert['slack_chennel_id']);
				  }
                      for($i=0;$i<count($channel_list);$i++) { $row = get_object_vars($channel_list[$i]);
						 
						  if(in_array($row['id'] ,$channel_ids))$selected ='checked="checked"';
						  else $selected ='';
						  ?>
						    <label class="checkbox-inline i-checks">
                  <input type="checkbox" <? echo $selected;?> name="vis_channel_ids[]" value="<? echo $row['id']; ?>" /> <i></i>&nbsp;<? echo $row['name']; ?></label><br/> 
						 <? 
						  }
                  ?>
				  </div>
               </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($alert['is_enabled']==0) echo 'radio-no-uncheck'; ?>">
                  <input type="checkbox" name="vis_status"  id="vis_status" <? if($alert['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':'home', 'vis_operation':'update_alert', 'vis_form':'vis_edit_alert_form_<? echo $alert['alert_id']; ?>'})"><? echo $vis_language['TXTUPDATE']; ?></button>
               </div>
            </div>
      </div>
      </form>
      </div>
   </section>
</section>
<style>
.selectpicker span:nth-child(2){
color:#000000 !important;
}
</style>
<script>
   $(".selectpicker").selectpicker();
   function select_picker()
   {
   $('.start').datetimepicker();
   $(".selectpicker").selectpicker();
   }
</script>
<script>
   function add_alert_criteria(mid) {
       var total=document.getElementById("total_alert_critaria_<? echo $alert['alert_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_ealert'+num+'" id="vis_main_alert_<? echo $alert['alert_id']; ?>'+num+'" onchange="changeeAlertOption('+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="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="34"><? echo $vis_language['TXTTICKETCATEGORY'];?></option><option value="35"><? echo $vis_language['TXTTICKETSUBCATEGORY'];?></option><option value="36"><? echo $vis_language['TXTTICKETITEM'];?></option><option value="37"><? echo $vis_language['TXTTICKETLEVEL'];?></option><? if(VIS_ITIL==1 && !empty($locations)) {?><option value="38"><? 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><?php if(VIS_ITIL==1 && (isset($module['itil']) && $module['itil']==1)){?><option value="30"><? echo $vis_language['TXTIMPACT'];?></option><option value="31"><? echo $vis_language['TXTRISK'];?></option><option value="32"><? echo $vis_language['TXTCHANGETYPE'];?></option><option value="33"><? echo $vis_language['TXTRELEASETYPE'];?></option><?php }?><option value="39"><? echo $vis_language['TXTSCHEDULE'];?></option></select></div><div class="col-sm-3" id="vis_criteria_option_<? echo $alert['alert_id']; ?>'+num+'"><select class="form-control input-sm selectpicker" name="vis_sub_ealert'+num+'" id="vis_sub_ealert_<? echo $alert['alert_id']; ?>'+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_<? echo $alert['alert_id']; ?>'+num+'"><input name="vis_ealert_text'+num+'" id="vis_ealert_text'+num+'" type="text"  class="form-control input-sm" /></div><label class="col-sm-1"><i class="vh vh-cross"  onclick="javascript:close_ealert_criteria('+num+',1)" style="cursor:pointer" title="<? echo $vis_language['TXTCLOSE']; ?>"></i></label></div>';

    newDiv.id="vis_alert_sub_criteria_<? echo $alert['alert_id']; ?>"+num;
       newDiv.innerHTML=newCritera;
       document.getElementById("vis_alert_options_<? echo $alert['alert_id']; ?>").appendChild(newDiv);
       if(typeof mid !="undefined") $("#vis_main_alert_<? echo $alert['alert_id']; ?>"+num).val(mid);
   select_picker();
   }
   function add_alert_or_criteria(mid) {
       var total=document.getElementById("total_alert_critaria_or_<? echo $alert['alert_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_ealert_or'+num+'" id="vis_main_alert_or_<? echo $alert['alert_id']; ?>'+num+'" onchange="changeeAlertOption('+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="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="34"><? echo $vis_language['TXTTICKETCATEGORY'];?></option><option value="35"><? echo $vis_language['TXTTICKETSUBCATEGORY'];?></option><option value="36"><? echo $vis_language['TXTTICKETITEM'];?></option><option value="37"><? echo $vis_language['TXTTICKETLEVEL'];?></option><? if(VIS_ITIL==1 && !empty($locations)) {?><option value="38"><? 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><?php if(VIS_ITIL==1 && (isset($module['itil']) && $module['itil']==1)){?><option value="30"><? echo $vis_language['TXTIMPACT'];?></option><option value="31"><? echo $vis_language['TXTRISK'];?></option><option value="32"><? echo $vis_language['TXTCHANGETYPE'];?></option><option value="33"><? echo $vis_language['TXTRELEASETYPE'];?></option><?php }?><option value="39"><? echo $vis_language['TXTSCHEDULE'];?></option></select></div><div class="col-sm-3" id="vis_criteria_option_or_<? echo $alert['alert_id']; ?>'+num+'"><select class="form-control input-sm selectpicker" name="vis_sub_ealert_or'+num+'" id="vis_sub_ealert_or_<? echo $alert['alert_id']; ?>'+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_<? echo $alert['alert_id']; ?>'+num+'"><input name="vis_ealert_text_or'+num+'" id="vis_ealert_text_or'+num+'" type="text"  class="form-control input-sm" /></div><label class="col-sm-1"><i class="vh vh-cross"  onclick="javascript:close_ealert_criteria('+num+',0)" style="cursor:pointer" title="<? echo $vis_language['TXTCLOSE']; ?>"></i></label></div>';

    newDiv.id="vis_alert_sub_criteria_or_<? echo $alert['alert_id']; ?>"+num;
       newDiv.innerHTML=newCritera;
       document.getElementById("vis_alert_or_options_<? echo $alert['alert_id']; ?>").appendChild(newDiv);
       if(typeof mid !="undefined") $("#vis_main_alert_or_<? echo $alert['alert_id']; ?>"+num).val(mid);
   select_picker();
   }
   function changeeAlertOption(num, sid, cont, condition) {
       var tempcondition='';
       if(condition==0) tempcondition='_or';
       var mainOpt=document.getElementById("vis_main_alert"+tempcondition+"_<? echo $alert['alert_id']; ?>"+num).value;
       var subOpt=document.getElementById("vis_criteria_option"+tempcondition+"_<? echo $alert['alert_id']; ?>"+num);
       var subTxt=document.getElementById("vis_criteria_text"+tempcondition+"_<? echo $alert['alert_id']; ?>"+num);
       if(mainOpt==0 || mainOpt==4 || mainOpt==5 || mainOpt==25) {
           subOpt.innerHTML='<select name="vis_sub_ealert'+tempcondition+num+'" id="vis_sub_ealert_<? echo $alert['alert_id']; ?>'+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_ealert'+tempcondition+num+'" id="vis_sub_ealert_<? echo $alert['alert_id']; ?>'+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==30 || mainOpt==31 || mainOpt==32 || mainOpt==33 || mainOpt==34 || mainOpt==35 || mainOpt==36 || mainOpt==37 || mainOpt==38 || mainOpt==39) {
           subOpt.innerHTML='<select name="vis_sub_ealert'+tempcondition+num+'" id="vis_sub_ealert_<? echo $alert['alert_id']; ?>'+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 || mainOpt==16) {
           subOpt.innerHTML='<select name="vis_sub_ealert'+tempcondition+num+'" id="vis_sub_ealert_<? echo $alert['alert_id']; ?>'+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_ealert'+tempcondition+num+'" id="vis_sub_ealert'+tempcondition+'_<? echo $alert['alert_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_ealert'+tempcondition+num+'" id="vis_sub_ealert'+tempcondition+'_<? echo $alert['alert_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_ealert'+tempcondition+num+'" id="vis_sub_ealert'+tempcondition+'_<? echo $alert['alert_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_ealert'+tempcondition+num+'" id="vis_sub_ealert'+tempcondition+'_<? echo $alert['alert_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==3 || mainOpt==4 || mainOpt==5 || mainOpt==20 || mainOpt==25) {
           subTxt.innerHTML='<input name="vis_ealert_text'+tempcondition+num+'" id="vis_ealert_text'+tempcondition+num+'" type="text" value="" class="form-control input-sm"  />';
       }
       else if(mainOpt==6) { <?
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker">';
      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==7) { <?
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker">';
      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) { <?
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker">';
      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) { <?
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker">';
      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==34) { <?
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker">';
      for($i=0;$i<count($categories);$i++) $temp.='<option value="'.$categories[$i]['category_id'].'">'.addslashes($categories[$i]['title']).'</option>';
      $temp.='</select>';
      echo "subTxt.innerHTML='".$temp."';"; ?>
       }
	   else if(mainOpt==35) { <?
        $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker">';
	    for($i=0;$i<count($categories);$i++){ 
			$temp.='<optgroup label="'.addslashes($categories[$i]['title']).'">';
			for($j=0;$j<count($subcategories);$j++){
				if($categories[$i]['category_id'] == $subcategories[$j]['category_id']) {
					$temp.='<option value="'.$subcategories[$j]['subcategory_id'].'">'.addslashes($subcategories[$j]['title']).'</option>';
				}
			}
			$temp.='</optgroup>';
	    }     
        $temp.='</select>';
      echo "subTxt.innerHTML='".$temp."';"; ?>
       }
	   else if(mainOpt==36) { <?
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'"  class="form-control input-sm selectpicker">';
	   for($i=0;$i<count($subcategories);$i++){
		$temp.='<optgroup label="'.addslashes($subcategories[$i]['title']).'">';
			for($j=0;$j<count($items);$j++) {
				if($subcategories[$i]['subcategory_id'] == $items[$j]['subcategory_id']) {
					$temp.='<option value="'.$items[$j]['item_id'].'">'.addslashes($items[$j]['title']).'</option>';
				}
			}
			$temp.='</optgroup>';
	   }
      $temp.='</select>';
      echo "subTxt.innerHTML='".$temp."';"; ?>
       }
	   else if(mainOpt==37) { <?
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker">';
      for($i=0;$i<count($levels);$i++) $temp.='<option value="'.$levels[$i]['level_id'].'">'.addslashes($levels[$i]['title']).'</option>';
      $temp.='</select>';
      echo "subTxt.innerHTML='".$temp."';"; ?>
       }
	    else if(mainOpt==38) { <?
    if(count($locations)>10) $select1= 'data-live-search="true"';
                $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
               $temp .= vis_show_subcategories($locations,'');
			   function vis_show_subcategories($locations,$call=NULL) {
				   for($i=0;$i<count($locations);$i++){ 
					   $temp.='<option value="'.$locations[$i]['location_id'].'">'.addslashes($locations[$i]['name']).'</option>';
					   if($locations[$i]['subcat']!=NULL) { 
					    	$temp .= vis_show_subcategories($locations[$i]['subcat'],'sub_cat'); 
					   }
				   }
				   return $temp;
			   }
               $temp.='</select>';
               echo "subTxt.innerHTML='".$temp."'";  ?>
       }
       else if(mainOpt==10 || mainOpt==29) { <?
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"><option value="0">'.$vis_language['TXTOPERATOR'].'</option>';
      for($i=0;$i<count($staff_details);$i++) $temp.='<option value="'.$staff_details[$i]['staff_id'].'">'.addslashes(trim($staff_details[$i]['first_name'].' '.$staff_details[$i]['last_name'])).'</option>';
      $temp.='</select>';
      echo "subTxt.innerHTML='".$temp."';"; ?>
       }
       else if(mainOpt==11) { <?
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker">';
      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 || mainOpt==16) {
           subTxt.innerHTML='<input name="vis_ealert_text'+tempcondition+num+'" id="vis_ealert_text'+tempcondition+num+'" type="text" value="" class="form-control input-sm start"  />';
       }
       else if(mainOpt==15) { <?
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker">';
      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_ealert_text'+tempcondition+num+'" id="vis_ealert_text'+tempcondition+num+'" class="form-control input-sm selectpicker" ><option value="0"><? echo $vis_language['TXTTRUE'];?></option></select>';
       }
       else if(mainOpt==21) { <?
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker">';
      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_ealert_text\'+tempcondition+num+\'" id="vis_ealert_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_ealert_text\'+tempcondition+num+\'" id="vis_ealert_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) { <?
        $select1='';
      if(count($channel_details)>10) $select1= 'data-live-search="true"';
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_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) {
            subTxt.innerHTML='<input name="vis_ealert_text'+tempcondition+num+'_hr" id="vis_ealert_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_ealert_text'+tempcondition+num+'_mi" id="vis_ealert_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) { <?
	   $select1='';
      if(count($impact)>10) $select1= 'data-live-search="true"';
		$temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
      for($i=0;$i<count($impact);$i++) $temp.='<option value="'.$impact[$i]['impact_id'].'">'.addslashes($impact[$i]['name']).'</option>';
      $temp.='</select>';
      echo "subTxt.innerHTML='".$temp."';"; ?>
       }else if(mainOpt==31) { <?
	    $select1='';
      if(count($risks)>10) $select1= 'data-live-search="true"';
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
      for($i=0;$i<count($risks);$i++) $temp.='<option value="'.$risks[$i]['risk_id'].'">'.addslashes($risks[$i]['name']).'</option>';
      $temp.='</select>';
      echo "subTxt.innerHTML='".$temp."';"; ?>
       }else if(mainOpt==32) { <?
	   $select1='';
      if(count($release_type)>10) $select1= 'data-live-search="true"';
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
      for($i=0;$i<count($release_type);$i++) $temp.='<option value="'.$release_type[$i]['release_type_id'].'">'.addslashes($release_type[$i]['name']).'</option>';
      $temp.='</select>';
      echo "subTxt.innerHTML='".$temp."';"; ?>
       }else if(mainOpt==33) { <?
	   $select1='';
      if(count($change_type)>10) $select1= 'data-live-search="true"';
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker"'.$select1.'>';
      for($i=0;$i<count($change_type);$i++) $temp.='<option value="'.$change_type[$i]['change_type_id'].'">'.addslashes($change_type[$i]['name']).'</option>';
      $temp.='</select>';
      echo "subTxt.innerHTML='".$temp."';"; ?>
       }else if(mainOpt==39) { <?
      $temp='<select name="vis_ealert_text\'+tempcondition+num+\'" id="vis_ealert_text\'+tempcondition+num+\'" class="form-control input-sm selectpicker">';
      for($i=0;$i<count($schedule);$i++) $temp.='<option value="'.$schedule[$i]['schedule_id'].'">'.addslashes($schedule[$i]['schedule_name']).'</option>';
      $temp.='</select>';
      echo "subTxt.innerHTML='".$temp."';"; ?>
       }
       if(typeof sid !="undefined") {
           $("#vis_sub_ealert"+tempcondition+"_<? echo $alert['alert_id']; ?>"+num).val(sid);
           if(mainOpt==26 || mainOpt==27 || mainOpt==17){
               var temptime=cont.split(":");
               $("#vis_ealert_text"+tempcondition+num+'_hr').val(temptime[0]);
               $("#vis_ealert_text"+tempcondition+num+'_mi').val(temptime[1]);
           }else $("#vis_ealert_text"+tempcondition+num).val(cont);
       }
   select_picker();
   }
   function close_ealert_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_alert_sub_criteria"+tempcondition+"_<? echo $alert['alert_id']; ?>"+num).innerHTML="";
   }
   function reset_ealert_filter() {
       document.getElementById("vis_alert_options_<? echo $alert['alert_id']; ?>").innerHTML="";
       document.getElementById("total_alert_critaria_<? echo $alert['alert_id']; ?>").value=0;
       add_alert_criteria();
   }
 <?
      if($alert_criteria!=-1){
         $j=1;
         for($i=0;$i<count($alert_criteria);$i++){
            if($alert_criteria[$i]['concat_type']=='and'){
               echo 'add_alert_criteria('.$alert_criteria[$i]['base_criteria'].'); changeeAlertOption('.($j++).', '.$alert_criteria[$i]['sub_criteria'].', "'.addslashes($alert_criteria[$i]['content']).'",1); ';
            }
         }
         $j=1;
         for($i=0;$i<count($alert_criteria);$i++){
            if($alert_criteria[$i]['concat_type']=='or'){
               echo 'add_alert_or_criteria('.$alert_criteria[$i]['base_criteria'].'); changeeAlertOption('.($j++).', '.$alert_criteria[$i]['sub_criteria'].', "'.addslashes($alert_criteria[$i]['content']).'",0); ';
            }
         }
      }
      ?>
      hide_room_list('<?php echo $alert['hipchat_room_ids'];?>');
      hide_hipchat_div(<?php echo $alert['hipchat_enabled'];?>);
      
      hide_channel_list('<?php echo $alert['slack_chennel_id'];?>');
      hide_slack_div(<?php echo $alert['slack_enabled'];?>);
      function hide_room_list(room_ids)
      {
		  if(room_ids!='')$('#hipchat_room_list').show();
		  else $('#hipchat_room_list').hide();
	  }
	  function hide_hipchat_div(hipchat_status)
      {
		  if(hipchat_status==1)$('#vis_hipchat_div').show();
		  else $('#vis_hipchat_div').hide();
	  }
	  
	  function hide_channel_list(room_ids)
	  {
		  if(room_ids!='')$('#slack_channel_list').show();
		  else $('#slack_channel_list').hide();
	  }
	  function hide_slack_div(slack_status)
	  {
		  if(slack_status==1)$('#vis_slack_div').show();
		  else $('#vis_slack_div').hide();
	  }
	  
</script>
