<? 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>
         <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_form_groups/<? echo $vis_language['TXTFORMGROUP']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTFORMGROUP']; ?>',{'vis_module':'setting','vis_operation':'view_form_groups'});" class="link"><? echo $operation['view_title']; ?></a></li>
         <li class="active"> <? echo $vis_language['TXTUPDATEFORMGROUP'];?></li>
      </ul>
      <div>
      </div>
   </div>
</section>
<section class="padder">
   <section class="panel panel-default">
      <header class="panel-heading sub_header"><? echo $vis_language['TXTUPDATEFORMGROUP']; ?></header>
      <div class="panel-body">
         <form  class="form-horizontal" id="vis_formgroup_form" name="vis_formgroup_form" method="post">
            <input type="hidden" name="vis_group_id" value="<? echo $custom_group_details[0]['formgroup_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_formgroup_name" id="vis_formgroup_name" value="<? echo htmlentities($custom_group_details[0]['formgroup_name'], ENT_COMPAT, 'UTF-8'); ?>" >
               </div>
            </div>
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTDISPLAYTITLE']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" name="vis_form_name" id="vis_form_name" value="<? echo $custom_group_details[0]['form_name']; ?>" >
               </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_displayorder" id="vis_displayorder" value="<? echo $custom_group_details[0]['display_order']; ?>" >
               </div>
            </div>
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTFORMTYPE']; ?></label>
               <div class="col-sm-10">
                  <div class="radio i-checks m-r-lg pull-left">
						<label><input name="vis_formtype" id="vis_formtype" type="radio" value="1" onclick="show_note('note_email');" <?php if( $custom_group_details[0]['form_type']==1){ echo 'checked'; } ?>  ><i></i> <? echo $vis_language['TXTEMAIL']; ?></label>
					</div>
					<div class="radio i-checks m-r-lg pull-left">
						<label><input name="vis_formtype" id="vis_formtype" type="radio" value="0" onclick="show_note('note_call');" <?php if($custom_group_details[0]['form_type']==0){ echo 'checked'; } ?> ><i></i> <? echo $vis_language['TXTCALL']; ?></label>
					</div>
               </div>
            </div>
			<div class="form-group">
               <label class="col-sm-2 control-label"> </label>
               <div class="col-sm-10">                 
						<label id="note_email"  style="<?php echo ($custom_group_details[0]['form_type']==1)?'display:block;':'display:none;'; ?>"><?php echo $vis_language['MSGMANDATORYEMAILFIELD']; ?></label>
						<label id="note_call" style="<?php echo ($custom_group_details[0]['form_type']==0)?'display:block;':'display:none;'; ?>"><?php echo $vis_language['MSGMANDATORYCALLFIELD']; ?></label>		
               </div>
            </div>
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTEBABLECAPTCHA']; ?></label>
               <div class="col-sm-10">
                  <div class="radio i-checks m-r-lg pull-left">
						<label><input name="vis_captcha" id="vis_captcha" type="radio" value="1" <?php if($custom_group_details[0]['captcha']==1){ echo 'checked'; } ?> ><i></i> <? echo $vis_language['TXTYES']; ?></label>
					</div>
					<div class="radio i-checks m-r-lg pull-left">
						<label><input name="vis_captcha" id="vis_captcha" type="radio" value="0" <?php if($custom_group_details[0]['captcha']==0){ echo 'checked'; } ?> ><i></i> <? echo $vis_language['TXTNO']; ?></label>
					</div>
               </div>
            </div>
			
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTFORMHEADER']; ?></label>
               <div class="col-sm-10">
                  <div class="radio i-checks m-r-lg pull-left">
						<label><input name="vis_hdformheader" id="vis_hdformheader" type="radio" value="1" <?php if($custom_group_details[0]['hdformheader']==1){ echo 'checked'; } ?> ><i></i> <? echo $vis_language['TXTYES']; ?></label>
					</div>
					<div class="radio i-checks m-r-lg pull-left">
						<label><input name="vis_hdformheader" id="vis_hdformheader" type="radio" value="0" <?php if($custom_group_details[0]['hdformheader']==0){ echo 'checked'; } ?> ><i></i> <? echo $vis_language['TXTNO']; ?></label>
					</div>
               </div>
            </div>
			<div class="form-group">
		          <label class="col-sm-2 control-label"><? echo $vis_language['TXTDEPARTMENT']; ?></label>
                    <div class="col-sm-10">
						<select name="vis_department" id="vis_department_new" class="form-control input-sm selectpicker"<? if(count($departments)>10) echo ' data-live-search="true"';?> onchange="get_channel_list(this.value);"><? 
							if($departments!=-1){ 
								for($i=0;$i<count($departments); $i++){
									$selected = ($custom_group_details[0]['department']== $departments[$i]['domain_id'].':'.$departments[$i]['department_id'])?'selected="selected"':'';
									echo '<option value="'.$departments[$i]['domain_id'].':'.$departments[$i]['department_id'].'" '.$selected.'>'.$departments[$i]['domain_name'].' :: '.$departments[$i]['department_name'].'</option>';
								}
							}						?>
							</select>
					</div>
            </div>
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSUBJECT']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" name="vis_subject" id="vis_subject" value="<? echo $custom_group_details[0]['subject']; ?>" >
               </div>
            </div>
            <!--<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTDESCRIPTION']; ?></label>
               <div class="col-sm-10">
                  <textarea class="form-control input-sm" type="text" name="vis_description" id="vis_description" ><? echo $custom_group_details[0]['description']; ?></textarea>
               </div>
            </div> -->
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSCRIPT']; ?></label>
               <div class="col-sm-10">
                  <textarea class="form-control input-sm"  name="vis_script" id="vis_script"  placeholder="<? echo $vis_language['TXTOPTIONAL']; ?>" ><? echo stripslashes($custom_group_details[0]['script']); ?></textarea>
               </div>
            </div>
            	
			<? //print_r($_SERVER);
				$arr= explode('manage',$_SERVER['REQUEST_URI']);?>		
			
			<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTHELPDESKURL']; ?></label>
               <div class="col-sm-10">
                  <textarea class="form-control input-sm" readonly  ><?php echo  $domain_detaiis[0]['domain_url'].'index.php?/ticket/forms/'.$custom_group_details[0]['formgroup_id']; ?></textarea>
               </div>
            </div>
			 <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTIFRAMEURL']; ?></label>
               <div class="col-sm-10">
                  <textarea class="form-control input-sm" readonly ><? echo '<iframe id="frm_des" name="frm_des" style="width:100%;height:100%;" src="'.$domain_detaiis[0]['domain_url'].'index.php?/ticket/forms/'.$custom_group_details[0]['formgroup_id'].'" frameBorder="0" onload="resizeIframe(this)" > </iframe>'; ?></textarea>
               </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($custom_group_details[0]['is_enabled']==0) echo 'radio-no-uncheck'; ?>">
                  <input type="checkbox" name="vis_status"  id="vis_status" <? if($custom_group_details[0]['is_enabled']==1) echo 'checked="checked"'; ?>  >
                  <span ></span>
                  </label>
               </div>
            </div>
            <? if($language_details!=-1) { ?>
            <div class="form-group">
               <div class="col-sm-12"><h5><? echo $vis_language['MSGLANGTRANSFORFORMFIELDGROUP']; ?></h5></div>
            </div>
            <div class="line b-b line-lg pull-in"></div>
            <br/>
            <?
               for($i=0;$i<count($language_details);$i++) { ?>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $language_details[$i]['language_name']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" name="vis_language_<? echo $language_details[$i]['language_id']; ?>" type="text" value="<? echo $formfieldgroup_lang[$language_details[$i]['language_id']]; ?>" />
               </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="update_form();"><? echo $vis_language['TXTUPDATE']; ?></button>
               </div>
            </div>
      </div>
      </form>
      </div>
   </section>
</section>
<script>
function update_form(){
	var string = $("#vis_script").val();
	var encodedString = btoa(string);
     //console.log(encodedString); 
	var decodedString = atob(encodedString);
     //console.log(decodedString); 
	$('#vis_workpanel_div').visExecution('submit_form',{'vis_module':'setting', 'vis_operation':'update_form_group',  'vis_script_base_enc':encodedString,'vis_form':'vis_formgroup_form'});
}

   $(".selectpicker").selectpicker();
   function show_note(id){
	   if(id=='note_email'){
		   $("#note_email").show();
		   $("#note_call").hide();
	   }else{
		   $("#note_email").hide();
		   $("#note_call").show();
	   }
   }
</script>
