<? //$widget_code = '<iframe id="ifr" allowtransparency="true" height="49px" width="125px" frameborder="0" scrolling="no" style=" overflow: hidden; position: fixed; display: block;  z-index: 999999; bottom: 20px; visibility:visible; right: 20px; outline: none;" src="'.$domain[0]['domain_url'].'index.php?/setting/widget"></iframe>';
if($widget_details==-1) $widget_color='#588F27'; else $widget_color=$widget_details[2]['content'];
if($widget_details==-1) $widget_name = 'Help'; else $widget_name = $widget_details[4]['content'];
?>
<link href="<?= VIS_PATH_SCRIPT; ?>colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
<div class="form-group">
   <label class="col-sm-2 control-label"><? echo $vis_language['TXTWIDGET'].' '.strtolower($vis_language['TXTCOLOR']); ?></label>
   <div class="col-sm-10">
      <input class="form-control input-sm demo-auto" type="text" name="vis_color" id="vis_color" value="<? echo $widget_color; ?>">
   </div>
</div>
<div class="form-group">
   <label class="col-sm-2 control-label"><? echo $vis_language['TXTBUTTONNAME']; ?></label>
   <div class="col-sm-10">
      <input class="form-control input-sm" onkeyup="set_position($('input[name=vis_position]:checked', '#vis_widget_form').val(),this.value,$('input[name=vis_btn_type]:checked', '#vis_widget_form').val(),$('input[name=vis_wd_feature]:checked', '#vis_widget_form').val());" type="text" name="vis_btn_name" id="vis_btn_name" value="<? echo $widget_name; ?>" >
   </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label"><? echo $vis_language['TXTWIDPOSITION']; ?></label>
      <div class="col-sm-10">
          <div id="vis_api_smsint_host" class="radio i-checks pull-left m-r-lg">
          <label>
              <input type="radio" <? if($widget_details[0]['content']==1 || $widget_details==-1) echo 'checked="checked"';?> value="1" onclick="set_position(1,$('#vis_btn_name').val(),$('input[name=vis_btn_type]:checked', '#vis_widget_form').val(),$('input[name=vis_wd_feature]:checked', '#vis_widget_form').val());" name="vis_position" id="vis_position"><i></i>
              <? echo $vis_language['TXTWIDRIGHTBOTTOM']; ?></label>
          </div>
          <div class="radio i-checks pull-left m-r-lg">
          <label>
              <input type="radio" value="2" <? if($widget_details[0]['content']==2) echo 'checked="checked"';?> name="vis_position" id="vis_position" onclick="set_position(2,$('#vis_btn_name').val(),$('input[name=vis_btn_type]:checked', '#vis_widget_form').val(),$('input[name=vis_wd_feature]:checked', '#vis_widget_form').val());"><i></i>
              <? echo $vis_language['TXTWIDLEFTBOTTOM']; ?></label>
          </div>
          <div class="radio i-checks pull-left">
          <label>
              <input type="radio" value="3" <? if($widget_details[0]['content']==3) echo 'checked="checked"';?> name="vis_position" id="vis_position" onclick="set_position(3,$('#vis_btn_name').val(),$('input[name=vis_btn_type]:checked', '#vis_widget_form').val(),$('input[name=vis_wd_feature]:checked', '#vis_widget_form').val());"><i></i>
              <? echo $vis_language['TXTWIDRIGHTTOP']; ?></label>
          </div>	
      </div>	
</div>
<div class="form-group">
    <label class="col-sm-2 control-label"><? echo $vis_language['TXTWIDBUTTONTYPE']; ?></label>
      <div class="col-sm-10">
          <div id="vis_api_smsint_host" class="radio i-checks pull-left m-r-lg">
          <label>
              <input type="radio" <? if($widget_details[3]['content']==1 || $widget_details==-1) echo 'checked="checked"';?> value="1" onclick="set_position($('input[name=vis_position]:checked', '#vis_widget_form').val(),$('#vis_btn_name').val(),1,$('input[name=vis_wd_feature]:checked', '#vis_widget_form').val());" name="vis_btn_type" id="vis_btn_type"><i></i>
              <? echo $vis_language['TXTWIDROUNDED']; ?></label>
          </div>
          <div class="radio i-checks pull-left m-r-lg">
          <label>
              <input type="radio" value="2" <? if($widget_details[3]['content']==2) echo 'checked="checked"';?> name="vis_btn_type" id="vis_btn_type" onclick="set_position($('input[name=vis_position]:checked', '#vis_widget_form').val(),$('#vis_btn_name').val(),2,$('input[name=vis_wd_feature]:checked', '#vis_widget_form').val());"><i></i>
             <? echo $vis_language['TXTWIDSQUARE']; ?></label>
          </div>
          <!--<div class="radio i-checks pull-left">
          <label>
              <input type="radio" value="3" <? if($widget_details[1]['content']==3) echo 'checked="checked"';?> name="vis_btn_type" id="vis_btn_type" onclick="set_position(3);"><i></i>
             <button type="button" class="btn btn-primary">Button3</button></label></label>
          </div>-->	
      </div>	
</div>
<div class="form-group">
    <label class="col-sm-2 control-label"><? echo $vis_language['TXTWIDFEATURE']; ?></label>
      <div class="col-sm-10">
          <div id="vis_api_smsint_host" class="radio i-checks pull-left m-r-lg">
          <label>
              <input type="radio" <? if($widget_details[1]['content']==1 || $widget_details==-1) echo 'checked="checked"';?> value="1" onclick="set_position($('input[name=vis_position]:checked', '#vis_widget_form').val(),$('#vis_btn_name').val(),$('input[name=vis_btn_type]:checked', '#vis_widget_form').val(),1);" name="vis_wd_feature" id="vis_wd_feature"><i></i>
              <? echo $vis_language['TXTSUBMITTICKET']; ?></label>
          </div>
          <div class="radio i-checks pull-left m-r-lg">
          <label>
              <input type="radio" value="2" <? if($widget_details[1]['content']==2) echo 'checked="checked"';?> name="vis_wd_feature" id="vis_wd_feature" onclick="set_position($('input[name=vis_position]:checked', '#vis_widget_form').val(),$('#vis_btn_name').val(),$('input[name=vis_btn_type]:checked', '#vis_widget_form').val(),2);"><i></i>
             <? echo $vis_language['TXTSELFHELP']; ?></label>
          </div>
          <div class="radio i-checks pull-left">
          <label>
              <input type="radio" value="3" <? if($widget_details[1]['content']==3) echo 'checked="checked"';?> name="vis_wd_feature" id="vis_wd_feature" onclick="set_position($('input[name=vis_position]:checked', '#vis_widget_form').val(),$('#vis_btn_name').val(),$('input[name=vis_btn_type]:checked', '#vis_widget_form').val(),3);"><i></i>
          <? echo $vis_language['TXTWIDBOTH']; ?></label>
          </div>	
      </div>	
</div>

<div id="widget_code" class="form-group" style=" <? //echo $style;?>">
   <label class="col-sm-2 control-label"><? echo $vis_language['TXTWIDGETCODE']; ?></label>
   <div class="col-sm-10" id="widget_code_text">
      <textarea class="form-control input-sm" type="text" readonly="readonly" name="vis_widget_code" id="vis_widget_code"  ></textarea>
   </div>
</div>
<? if($widget_details!=-1){?>
<div id="widget_code" class="form-group" style=" <? //echo $style;?>">
   <label class="col-sm-2 control-label"><? echo $vis_language['TXTWIDPREVIEW']; ?></label>
   <div class="col-sm-10" id="btn_preview">      
   </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':'subsetting', 'vis_operation':'update_widget','vis_form':'vis_widget_form'})"><? echo $vis_language['TXTUPDATE']; ?></button>
        <button type="button" class="btn btn-primary m-l" onclick="copy_widget()"><? echo $vis_language['TXTSELECTCODE']; ?></button>
    </div>
</div>
</form>
<script src="<?= VIS_PATH_SCRIPT; ?>colorpicker/js/bootstrap-colorpicker.js"></script>
<script type="application/javascript">
 $(function() {
   	function createColorpickers(){
   		$('.demo-auto').colorpicker();
   	}
   	createColorpickers();
   });
   function copy_widget() {
	  $('#vis_widget_code').select();
   }
   <? if($widget_details==-1){?>
   set_position('1','<?=$widget_name;?>','1','1');
   <? }else{?>
       set_position('<?=$widget_details[0]['content'];?>','<?=$widget_name;?>','<?=$widget_details[3]['content'];?>','<?=$widget_details[1]['content'];?>');
   <? }?>
   function set_position(pos,btnname,btntype,feature){
	   var script1='<script>';
	   var script2='<\/script>';
	   var vis_color=$('#vis_color').val();
	   if(btntype==1){
		   if(btnname==''){
		   $('#btn_preview').html('<button type="button" class="btn btn-primary rounded btn-lg btn-icon " style="background-color:'+vis_color+'; color:white;"><i class="vh vh-lg vh-question-round"></i></button>');
		   }else{
			   $('#btn_preview').html('<button type="button" class="btn btn-lg btn-primary rounded" style="background-color:'+vis_color+'; color:white;">'+btnname+'&nbsp;<i class="vh vh-lg vh-question-round"></i></button>');
		   }
		  
	   }else if(btntype==2){
		   if(btnname==''){
		   $('#btn_preview').html('<button type="button" class="btn btn-primary btn-lg btn-icon" style="background-color:'+vis_color+'; color:white;"><i class="vh vh-lg vh-question-round"></i></button>');
		   }else{
			   $('#btn_preview').html('<button type="button" class="btn btn-lg btn-primary" style="background-color:'+vis_color+'; color:white;">'+btnname+'&nbsp;<i class="vh vh-lg vh-question-round"></i></button>');
		   }
	   }
	   if(pos==1){
	   var widget_code = "var fileref=document.createElement('script'); fileref.setAttribute('type','text/javascript'); fileref.setAttribute('src','<?=$domain[0]['domain_url']?>scripts/vh-widget.js'); document.head.appendChild(fileref);var VHURL='<?=$domain[0]['domain_url']?>';var VHBTNCL='"+vis_color+"';var VHBTNPOS1='bottom';var VHBTNPOS2='right';var VHBTNNAME='"+btnname+"';var VHBTNTYPE='"+btntype+"';var VHWDFTR='"+feature+"';var CRURL=window.location.href;";
	    $('#vis_widget_code').val(script1+widget_code+script2);
	   }
	   if(pos==2){
	   var widget_code = "var fileref=document.createElement('script'); fileref.setAttribute('type','text/javascript'); fileref.setAttribute('src','<?=$domain[0]['domain_url']?>scripts/vh-widget.js'); document.head.appendChild(fileref);var VHURL='<?=$domain[0]['domain_url']?>';var VHBTNCL='"+vis_color+"';var VHBTNPOS1='bottom';var VHBTNPOS2='left';var VHBTNNAME='"+btnname+"';var VHBTNTYPE='"+btntype+"';var VHWDFTR='"+feature+"';var CRURL=window.location.href;";
	    $('#vis_widget_code').val(script1+widget_code+script2);
	   }
	   if(pos==3){
	   var widget_code = "var fileref=document.createElement('script'); fileref.setAttribute('type','text/javascript'); fileref.setAttribute('src','<?=$domain[0]['domain_url']?>scripts/vh-widget.js'); document.head.appendChild(fileref);var VHURL='<?=$domain[0]['domain_url']?>';var VHBTNCL='"+vis_color+"';var VHBTNPOS1='top';var VHBTNPOS2='right';var VHBTNNAME='"+btnname+"';var VHBTNTYPE='"+btntype+"';var VHWDFTR='"+feature+"';var CRURL=window.location.href;";
	   $('#vis_widget_code').val(script1+widget_code+script2);
	   }
   }
</script>   