<? global $vis_language;?>
   <form id="vis_staff_signature_form" name="vis_staff_signature_form" class="form-horizontal" method="post">
      <input type="hidden" name="vis_staff_id" id="vis_staff_id" value="<? echo $operation['vis_staff_id']; ?>" />
       <div class="form-group">
		   <label class="col-sm-2 control-label"><? echo $vis_language['TXTSIGNATURE']; ?></label>
		   <div class="col-sm-9">
			  <div class="radio i-checks m-r-lg pull-left "><label>
			  <input type="radio" <?  echo ' checked="checked"'; ?> value="1" id="vis_ticket_signature" name="vis_ticket_signature" onclick="load_ticket_signature();" /><i></i>
			  <? echo $vis_language['TXTTICKET']; ?></label> </div>
			  <?if(isset($mod_forum) && $mod_forum==1 && VIS_MODULE_ACCESS_FORUMS==1){?><div class="radio i-checks m-r-lg pull-left "><label>
			  <input type="radio"  value="0" id="vis_forum_signature" name="vis_ticket_signature" onclick="load_forum_signature();" /><i></i>
			  <? echo $vis_language['TXTFORUM']; ?>
			  </label> </div><? } ?>
		   </div>
       </div>
      <div id="load_ticket_signature">
      <div class="form-group">
         <label class="col-sm-2 control-label"><? echo $vis_language['TXTDEPARTMENT']; ?></label>
         <div class="col-sm-2">	
            <div class="checkbox m-n i-checks pull-left "><label><input type="checkbox" name="vis_sign_all_dept" id="vis_sign_all_dept" onchange="toggle_dept_list();" value="1"/><i></i><? echo $vis_language['TXTALLDEPARTMENTS']; ?></label></div>
         </div>
          <div class="col-sm-8" id="vis_department_list">	
            <select name="vis_department" id="vis_department" class="selectpicker" <? if(count($department)>10) echo 'data-live-search="true"';?>  onchange="vis_change_signature(this)">
            <?	 for($i=0;$i<count($department);$i++){
														if($selecteddpt==$department[$i]['department_id']){ 
				 echo '<option value="'.$department[$i]['department_id'].'" selected="selected">'.$department[$i]['domain_name'].' : '.$department[$i]['department_name'].'</option>';
												}else{
															 echo '<option value="'.$department[$i]['department_id'].'">'.$department[$i]['domain_name'].' : '.$department[$i]['department_name'].'</option>';
												}
					  }?>				
            </select>
         </div>
        
      </div>
      <div class="form-group">
         <label class="col-sm-2 control-label"></label>
         <div class="col-sm-10">
              <textarea name="vis_staff_signature_content" id="vis_staff_signature_content" class="form-control" rows="10" ><? echo $ticket_signature; ?></textarea>
         </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 onclick="$('#vis_workpanel_div').visExecution('submit_form',{'vis_module':'home', 'vis_operation':'update_staff_signature', 'vis_form':'vis_staff_signature_form','vis_staff_signature_content':$('.redactor-editor').html(), 'vis_staff_id':<? echo $operation['vis_staff_id']; ?>})" class="btn btn-primary" type="button"><? echo $vis_language['TXTUPDATE']; ?></button>
         </div>
      </div>
       </div>
	   <div id="load_forum_signature" style="display:none;">
			<? include(VIS_PATH_TEMPLATE.'forum_signature.php');?>
	   </div>   
   </form>
<script>
   var id= $('#vis_staff_id').val();
   $(".selectpicker").selectpicker();
    <? if (!defined('VIS_HTML_EDITOR') || VIS_HTML_EDITOR == 1) { ?>
  $(function(){
			$('#vis_staff_signature_content').redactor({
				buttonSource: true,			
				minHeight: 180, // pixels
				maxHeight: 180,
				imageUpload: "index.php?vis_tmpst="+new Date().getTime()+"&vis_module=ticket&vis_operation=upload_file&vis_static_area=editor_image_upload",           
				imageUploadParam: 'files',
				plugins: ['source'],
				deniedTags: ['html', 'head', 'link', 'body', 'meta', 'script','applet']
			});
		});  
		$("#vis_staff_signature_content").val("<? echo addslashes(trim($ticket_signature));?>");
	<? }  ?>
   function load_ticket_signature(){
	   $("#load_ticket_signature").show();
	   $("#load_forum_signature").hide();	  
   }
   function load_forum_signature(){
	   $("#load_ticket_signature").hide();
	   $("#load_forum_signature").show();
   }   
	/*function vis_change_signature(e) {
       $.ajax({
           url: 'index.php',
           data: { 'vis_module': "home", 'vis_operation': "load_signature",  'vis_staff_id': id,'vis_department': e.value},
           type: "POST",
           success: function(data) {
			$('.redactor_editor').html(data);
             // $('#vis_staff_signature_content').val(data);
           }
       });
   }*/
    function vis_change_signature(e){
			 $.ajax({
                url: 'index.php',
   			    data: {'vis_module':"home", 'vis_operation':"load_signature" ,'vis_department':e.value,'vis_staff_id':id},
   			    type: "POST",
                success: function(data) {
			           <? if (!defined('VIS_HTML_EDITOR') || VIS_HTML_EDITOR == 1) { ?>
							if(e.value==0) $(".redactor-editor").hide();
							else $('#vis_staff_signature_content').redactor('code.set', data);
					   <?php }
						else {?>
						$("#vis_staff_signature_content").val(data);
						<?php } ?>
   		        }
			});
      }
	  function toggle_dept_list()
	  {
	  	 if($('#vis_sign_all_dept').is(":checked")) $('#vis_department_list').hide();
     	  else $('#vis_department_list').show();
	  }
</script>
<script src="<?= VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>
