<? 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_custom_groups/<? echo $vis_language['TXTCUSTOMGROUP']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTCUSTOMGROUP']; ?>',{'vis_module':'setting','vis_operation':'view_custom_groups'});" class="link"><? echo $operation['view_title']; ?></a></li>
         <li class="active"> <? echo $vis_language['TXTADDCUSTOMGROUP'];?></li>
      </ul>
      <div>
      </div>
   </div>
</section>
<section class="padder">
   <section class="panel panel-default">
      <header class="panel-heading sub_header"><? echo $vis_language['TXTADDCUSTOMGROUP']; ?></header>
      <div class="panel-body">
         <form  class="form-horizontal" id="vis_customgroup_form" name="vis_customgroup_form" method="post">
            <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_customgroup_name" id="vis_customgroup_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="0">
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTGROUPTYPE']; ?></label>
               <div class="col-sm-10">
                  <select name="vis_grouptype" id="vis_grouptype" class="input-sm form-control selectpicker" onchange="toggle_departmentdetails(this.value); visible_chk(this.value);">
                     <option value="0"><? echo $vis_language['TXTUSERREGISTRATION']; ?></option>
                     <option value="1"><? echo $vis_language['TXTUSERTICKETCREATION']; ?></option>
                     <option value="2"><? echo $vis_language['TXTSTAFFTICKETCREATION']; ?></option>
					 <option value="11"><? echo $vis_language['TXTBOTHTICKETCREATION']; ?></option>
                     <option value="3"><? echo $vis_language['TXTUSERFEEDBACK']; ?></option>
                     <option value="12"><? echo $vis_language['TXTORGANIZATION']; ?></option>
                     <option value="13"><? echo $vis_language['TXTTASK']; ?></option>
                  </select>
               </div>
            </div>        
            <div class="form-group" id="div_visible" >
            	<label class="col-sm-2 control-label"><? echo $vis_language['TXTVISIBLETO']; ?></label>
                <div class="col-sm-10">
                	<select name="vis_visibleto" id="vis_visibleto" class="input-sm form-control selectpicker">
                    	<option value="0">Both</option>
                        <option value="1"><? echo $vis_language['TXTCLIENTS'];?></option>
                        <option value="2"><? echo $vis_language['TXTSTAFF'];?></option>
                    </select>
                </div>
            </div>          
            <div id="department_access123" style="display:none;">
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTDEPARTMENTACCESS']; ?></label>
               <div class="col-sm-10">
                  <label class="checkbox-inline i-checks">
                  <input type="checkbox" value="1" id="vis_department_all" checked="checked" onchange="toggle_dept_list();" name="vis_department_all"><i></i>
                  <? echo $vis_language['TXTALLDEPARTMENTS']; ?>
                  </label>
               </div>
            </div>
            <div id="vis_dept_list_section" class="form-group" style="<?= ($department_details['department_access']==0)?'display:none':'';?>">
               <label class="col-sm-2 control-label"></label>
               <div class="col-sm-10">
				  <div class=" dept_access_list">
                  <?
                      for($i=0;$i<count($department_details);$i++) {?>
                  <label class="checkbox-inline i-checks m">
                  <input type="checkbox"  name="vis_department[]" value="<? echo $department_details[$i]['department_id']; ?>" /> <i></i><? echo $department_details[$i]['domain_name'].' :: '.$department_details[$i]['department_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">
                  <input type="checkbox" checked="checked" name="vis_status"  id="vis_status" >
                  <span ></span>
                  </label>
               </div>
            </div>
			 <? if($language_details!=-1) { ?>
            <div class="form-group">
               <div class="col-sm-12"><h5><? echo $vis_language['MSGLANGTRANSFORCUSTOMFIELDGROUP']; ?></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 $priority_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="$('#vis_workpanel_div').visExecution('submit_form',{'vis_module':'setting', 'vis_operation':'add_custom_group', 'vis_form':'vis_customgroup_form'})"><? echo $vis_language['TXTADD']; ?></button>
               </div>
            </div>
      </div>
      </form>
      </div>
   </section>
</section>
<script>
   $(".selectpicker").selectpicker();
   $(document).ready(function () {
	   $('#vis_access_yes').click(function () {
		  $('#department_access123').hide();
   });
   $('#vis_access_no').click(function () {
		 $('#department_access123').show();
	});
  });
   function toggle_dept_list(){
       if($('#vis_department_all').is(":checked")) $('#vis_dept_list_section').hide();
       else $('#vis_dept_list_section').show();
	   $('.dept_access_list').each(function(index) {
        $(this).find('input[type="checkbox"]').removeAttr('checked');
       });
   }
   function toggle_departmentdetails(id){
       if(id==0){
           $('#department_access123').hide();
       }else{
           $('#department_access123').show();
       }
   }
   function visible_chk(id){
       if(id!=3 && id!=13){
           $('#div_visible').show();
       }else{
           $('#div_visible').hide();
           if(id==3){  $("#vis_visibleto").val('0');}
           else if(id==13){ $("#vis_visibleto").val('2');}          
       }
   }
</script>
