<?global $vis_language;?>	
<div id='integration_details'>
	<input type="hidden" name="vis_integration_id"  id="vis_integration_id" value="<? echo $sms_details[0]['integration_id']; ?>"/>
	<div class="form-group">
		<label class="col-sm-2 control-label"><?= $vis_language['TXTAPI']; ?></label>
					<div class="col-sm-10">
					
					<select class='form-control input-sm selectpicker' name="vis_api" id="vis_api" onchange="var domainId = $('#vis_domain').val();$('#vis_workpanel_div').visExecution('load_area',{'vis_module':'setting', 'vis_operation':'integration_list', 'vis_integration_type':'3', 'vis_api':$(this).val(),'vis_domain':domainId })">
						   <option value="1" <?= ($sms_details == -1 || $operation['vis_api'] ==1) ? ' selected="selected"':'';?>> <? echo $vis_language['TXTCLICKATELL'];  ?></option>
							<option value="2" <?= ($operation['vis_api'] ==2 || $hostNm==2)? ' selected="selected"':''; ?>><?echo $vis_language['TXTTWOSMS']; ?></option>
							<option value="3" <?= ($operation['vis_api'] ==3)? ' selected="selected"':''; ?>><?echo $vis_language['TXTTWILIO']; ?> </option>
					</select>
						
						
					<!-- <div class="radio i-checks pull-left m-r-lg" id="vis_api_smsint_host">
						<label>
							<input type="radio" name="vis_api" value="1" <?//= ($sms_details == -1 || $operation['vis_api'] ==1) ? ' checked="checked"':'';?> onclick="var domainId = $('#vis_domain').val();$('#vis_workpanel_div').visExecution('load_area',{'vis_module':'setting', 'vis_operation':'integration_list', 'vis_integration_type':'3', 'vis_api':$(this).val(),'vis_domain':domainId })"><i></i>
							<? //echo $vis_language['TXTCLICKATELL']; ?>
						</label></div>
						<div class="radio i-checks pull-left">
						<label>
							<input type="radio" name="vis_api" value="2" <?//= ($operation['vis_api'] ==2 || $hostNm==2)? ' checked="checked"':''; ?> onclick="  var domainId = $('#vis_domain').val();$('#vis_workpanel_div').visExecution('load_area',{'vis_module':'setting', 'vis_operation':'integration_list', 'vis_integration_type':'3', 'vis_api':$(this).val(),'vis_domain':domainId })"><i></i>
							<? //echo $vis_language['TXTTWOSMS']; ?>
						</label></div>	-->
					</div>	
	</div>
	<div id ="select_twilio">
	<div class="form-group">
		<label class="col-sm-2 control-label"><? echo$vis_language['TXTUSERNAME']; ?></label>
		<div class="col-sm-10">
			<input type="text" class="form-control input-sm" name="vis_username" id="vis_username" value="<? echo $sms_details[0]['user_name']; ?>"/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label"><? echo$vis_language['TXTPASSWORD']; ?></label>
		<div class="col-sm-10">
			<input type="password" class="form-control input-sm" name="vis_password" id="vis_password" value="<? echo base64_decode($sms_details[0]['db_password']); ?>"/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label"><? echo$vis_language['TXTURL']; ?></label>
		<div class="col-sm-10">
			<input type="text" class="form-control input-sm" name="vis_baseurl" id="vis_baseurl" value="<? echo $sms_details[0]['billing_url']; ?>" />
		</div>
	</div>
	
	<div class="form-group" id="vis_api_id">
		<label class="col-sm-2 control-label"  ><? echo $vis_language['TXTAPIID']; ?></label>
		<div class="col-sm-10">
			<input type="text" class="form-control input-sm" name="vis_apiid" id="vis_apiid" value="<? echo $sms_details[0]['api_key']; ?>"/>
		</div>
	</div>

</div>
<div id="twilio_setting">
    <?if($twilio_details !=-1 && !empty($twilio_details)) { ?>
	<div class="form-group">
	  <label class="col-sm-2 control-label"><? echo $vis_language['TXTSTATUS']; ?></label>
	 
			<div class="col-sm-2">
				<label class="checkbox m-n i-checks pull-left">
					<input type="checkbox" name="vis_check" id="vis_check" value="1" <?= ($sms_details != -1 && $sms_details[0]['db_prefix'] ==1) ? ' checked="checked"':'';?>><i></i>
				<label class="control-label m-l-xs"><? echo $vis_language['TXTTWILIOMESSAGE']; ?></label>
				</label>
			</div>
			
	   <?} else{ ?>
	 <div class="col-sm-2"></div>
	    <label class="col-sm-8 control-label" style="text-align:left; color:red;"><? echo $vis_language['TXTCONFIGTWILIO']; ?></label><div class="line b-b line-lg pull-in" ></div><br/>
	   <?}?>
	</div>
	
	
</div>
    <?if($twilio_details == -1 || $twilio_details==''){$config = 1;}else{$config=0;}?>
	<div class="line b-b line-lg pull-in" ></div><br/>
	<div class="form-group" id="buttons">
	     <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':'update_sms', 'vis_form':'vis_integration_form'})"><? echo (isset($sms_details[0]) && $sms_details[0]!=-1)?$vis_language['TXTUPDATE']:$vis_language['TXTADD']; ?></button>
                        <? if($sms_details !=-1 && !empty($sms_details)) {?>
			<button type="button" class="btn btn-primary m-l" id="delete" onclick="check_all_domains()" <a href="javascript:void(0);" data-toggle="ajaxModal"><? echo $vis_language['TXTDELETE']; ?></a></button>
                        <? } ?>
		</div>
	</div>	
</div>	
<script>
function check_all_domains(){
	var api = $('#vis_api').val();
	var domain = $('#vis_domain').val();
	if ($('#vis_all_domains').is(':checked'))
	{
		$('#delete').attr('data-modal-arguments', 'vis_module=setting&vis_operation=get_sms_delete&vis_all_domains=1&vis_integration_id=<? echo $sms_details[0]['integration_id']; ?>&vis_static_area=vis_sms_delete_form&vis_domain='+domain+'&vis_api='+api);
	}
	else
	{
		$('#delete').attr('data-modal-arguments', 'vis_module=setting&vis_operation=get_sms_delete&vis_integration_id=<? echo $sms_details[0]['integration_id']; ?>&vis_static_area=vis_sms_delete_form&vis_domain='+domain+'&vis_api='+api);
	}	
}
$(document).ready(function(){
	var flag = <?echo $config;?>;
	
   if($('#vis_api').val() == 1)
	{
		$('#vis_api_id').show();
		 $('#twilio_setting').hide();
	}
	else
	{
		$('#vis_api_id').hide();
		 $('#twilio_setting').hide();
	}

    if($('#vis_api').val() == 3)
	{
	 $('#select_twilio').hide();
	  $('#twilio_setting').show();
       	 
	}
    if($('#vis_api').val() == 3 && flag == 1)
    {
	 $('#buttons').hide();	
	}		
});


</script>