<?php namespace AloVoice; include("header.php"); ?>
<?php if($this->isAmi || $this->appInstalled) { ?>
	<script src="//api.bitrix24.com/api/v1/"></script>
	<script> BX24.init(function(){ BX24.installFinish();  location.href = '<?=$this->alvhost?>'; }); </script>
<?php } else { ?>
<center><h1>Добро пожаловать в <b>AloVoice BX24</b></h1></center>
<div class="card mt-4">
	<div class="card-header">
		<?php if(!empty($this->_error)){ ?>
			<span style="padding:10px;  color:#f00;"><?php echo (is_array($this->_error)) ? json_encode($this->_error) : $this->_error; ?></span> <!-- border:1px solid #f00; -->
		<?php } else { ?>
			Система не настроена. Настроим? 
		<?php } ?>
	</div>
	<div class="card-body">
		<h5 id="toggler_asterisk_settings" class="card-title">Введите параметры для сервера <strong>"<?=$this->alvhost?>"</strong></h5>
		
		<form id="sms-settings">
			<div class="card-text">
				<input type="hidden" name="save" value="Y">
				<input type="hidden" name="access_token" value="<?=$access_token?>">
				<input type="hidden" name="application_token" value="<?=$application_token?>">
				<input type="hidden" name="refresh_token" value="<?=$refresh_token?>">
				<input type="hidden" name="expires_in" value="<?=$expires_in?>">
				<input type="hidden" name="domain" value="<?=$bxDomain?>">
				<input type="hidden" name="member_id" value="<?=$member_id?>">

				<div class="form-group"> 
					<label class="col-sm-2 col-form-label">Aдрес Битрикс24:</label> 
					<div class="col-sm-10"><input type="text" class="form-control"  value="<?php echo $bxDomain; ?>" disabled> </div>
				</div>
				
				<div class="form-group"> 
					<label class="col-sm-2 col-form-label">Aдрес AMI:</label> 
					<div class="col-sm-10"><input type="text" class="form-control" name="ami_host" id="ami_host" value="127.0.0.1"> </div> 
				</div>
				
				<div class="form-group"> 
					<label class="col-sm-2 col-form-label">Порт AMI:</label>
					<div class="col-sm-10"> <input type="text" class="form-control" name="ami_port" id="ami_port" value="5038"></div>
				</div>
				
				<div class="form-group"> 
					<label class="col-sm-2 col-form-label">Пользователь AMI:</label> 
					<div class="col-sm-10">
						<input type="text" class="form-control" name="ami_user" id="ami_user" value="<?=$ami_user?>"> 
					</div> 
				</div>
				<div class="form-group"> 
					<label class="col-sm-2 col-form-label">Пароль AMI:</label> 
					<div class="col-sm-10">
						<input type="password" class="form-control" name="ami_pass" id="ami_pass" value="<?=$ami_pass?>"> 
					</div> 
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn btn-save">Сохранить</button>
				</div>
				
			</div>
		</form>
		<!--a href="#" class="btn btn-primary">Вернуться в Битрикс24</a-->
	</div>
</div>
<?php } ?>
<?php include("footer.php"); ?>