settings.php 7.5 KB
Newer Older
Kulya's avatar
Kulya committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
<?php namespace AloVoice; ?>
<center><h3 class="h3 card-body">Настройки</h3></center>

<form  id="alv_settings_form">
	<div class="form-row">
		<div class="form-group col-md-12">
			<label for="asterisk_host">IP или доменный Адрес Менеджера Астериск (AMI)</label>
			<input type="text" class="form-control form-control" id="asterisk_host" placeholder="" value="">
		</div>
	</div>
	
	
	<div class="form-row">
		<div class="form-group col-md-12">
			<label for="asterisk_port">Порт Менеджера Астериск (AMI)</label>
			<input type="text" class="form-control form-control" id="asterisk_port" placeholder="" value="">
		</div>
	</div>
  
	<div class="form-row">
		<div class="form-group col-md-12">
			<label for="asterisk_user">Пользователь Менеджера Астериск (AMI)</label>
			<input type="text" class="form-control form-control" id="asterisk_username" placeholder="" value="">
		</div>
	</div>
  
	<div class="form-row">
		<div class="form-group col-md-12">
			<label for="asterisk_pass">Пароль к Менеджеру Астериск (AMI)</label>
			<input type="password" class="form-control form-control" id="asterisk_secret" placeholder="" value="">
		</div>
	</div>  
	<div class="form-row">
		<div class="form-group mx-2">
			<label class="" for="asterisk_pass">Диапазон номеров для автоназначения сотрудникам</label>
		</div>
		<div class="form-group form-row">
			<div class="col-3">
				<input type="number" class="form-control" id="unumbers_from" placeholder="" value="">
			</div>
			<div class="col-1 text-center"> - </div>
			<div class="col-3">
				<input type="number" class="form-control" id="unumbers_to" placeholder="" value="">
			</div>
		</div>
	</div> 
	
	<div class="form-row">  
		<div class="form-group mx-2">
			<label class="" for="sipaddress_local">SIP адрес и порт (локальный)</label>
		</div>
		<div class="form-group form-row">
			<div class="col-4">
				<input type="text" class="form-control" id="sipaddress_local" placeholder="" value="">
			</div>
			<div class="col-1 text-center"> - </div>
			<div class="col-2">
				<input type="text" class="form-control" id="sipport_local" placeholder="" value="">
			</div>
		</div>
	</div>
	<div class="form-row">
		<div class="form-group mx-2">
			<label class="" for="sipaddress_out">SIP адрес и порт (внешний)</label>
		</div>
		<div class="form-group form-row">
			<div class="col-4">
				<input type="text" class="form-control" id="sipaddress_out" placeholder="" value="">
			</div>
			<div class="col-1 text-center"> - </div>
			<div class="col-2">
				<input type="text" class="form-control" id="sipport_out" placeholder="" value="">
			</div>
		</div>
	</div>
	<div class="form-row">
		<div class="form-group mx-2">
			<label class="" for="miscallagentname">Кто ОТВЕТСТВЕННЫЙ по умолчанию: </label>
		</div>
		<div class="form-group">
			<input class="form-control" type="text" id="miscallagentname" disabled>
			<input type="hidden" id="miscallagentid">
		</div>
		<div class="form-group">
			<div class="btn btn-primary mb-2" onclick="BX24.selectUser(selectmiscallagentid)">Выбрать...</div>
		</div>
	</div>
	

	
	<div class="form-group row">
		<div class="form-group ml-4">
		 	 <div class="form-check">
				<input class="form-check-input" type="checkbox" id="showcallcard">
				<label class="form-check-label" for="showcallcard">Запускать окно обработки звонка</label>
		  </div>
		</div>
  	</div>
	
Kulya's avatar
Kulya committed
100
	<!--div class="form-group row">
Kulya's avatar
Kulya committed
101 102 103 104 105 106 107 108 109 110 111
		<div class="form-group ml-4">
		 	 <div class="form-check">
				<label class="form-check-label" for="autocreateentity">Авто создание лида при вызове</label>
				<select id="autocreateentity">
					<option value="0" selected>Не создовать</option>
					<option value="1">Авто создание ЛИДа при вызове</option>
					<option value="2">Авто создание СДЕЛКи при вызове</option>
					<option value="3">Авто создание КОНТАКТа при вызове</option>
				</select>
		  </div>
		</div>
Kulya's avatar
Kulya committed
112
  	</div-->
Kulya's avatar
Kulya committed
113
	
Kulya's avatar
Kulya committed
114
	<div class="form-group row">
Kulya's avatar
Kulya committed
115 116 117 118 119 120
		<div class="form-group ml-4">
		 	 <div class="form-check">
				<input class="form-check-input" type="checkbox" id="autocreatelead">
				<label class="form-check-label" for="autocreatelead">Авто создание лида при вызове</label>
		  </div>
		</div>
Kulya's avatar
Kulya committed
121
  	</div>
Kulya's avatar
Kulya committed
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
	
	<div class="form-group row">
		<div class="form-group ml-4">
		 	 <div class="form-check">
				<input class="form-check-input" type="checkbox" id="add_to_chat">
				<label class="form-check-label" for="add_to_chat">Оповещать о всех звонках в чате</label>
		  </div>
		</div>
  	</div>
  
	
	<br>
	<a href="#" class="btn btn-primary" id="save_alovoice_settings">Сохранить</a>
</form>
<script>
//-lg
var afterLoadPage = function(){
	window.selectmiscallagentid = function(user){
		if(typeof user !== 'undefined' && typeof user.id !== 'undefined' && typeof user.name !== 'undefined'){
			$("#miscallagentid").val(user.id);
			$("#miscallagentname").val(user.name);
		}
	}
	
	loadAloVoiceInfo("alovoice_settings",function(res){
		/*
		// 'host' => $this->config["asterisk_host"],
		// 'port' => $this->config["asterisk_port"],
		// 'username' => $this->config["asterisk_username"],
		// 'secret' => $this->config["asterisk_secret"]
		*/
		console.log("AloVoice settings RES:",res);
		
		$.each(res,function(ks,vs){
			if($("#"+ks)){
				if($("#"+ks).prop("tagName")=="SELECT"){
					$("#"+ks).val(vs).change();
				}
				else if($("#"+ks).attr('type')=="checkbox"){
					$("#"+ks).prop('checked',(vs=="true") ? true : false);
				}
				else{
					$("#"+ks).val(vs);
				}
			}
		});
		
		// if(typeof res.host !== 'undefined' ){ $("#asterisk_host").val(res.host); }
		// if(typeof res.port !== 'undefined' ){ $("#asterisk_port").val(res.port); }
		// if(typeof res.username !== 'undefined' ){ $("#asterisk_user").val(res.username); }
		// if(typeof res.secret !== 'undefined' ){ $("#asterisk_pass").val(res.secret); }
		
		// if(typeof res.unumbers_from !== 'undefined' ){ $("#unumbers_from").val(res.unumbers_from); }
		// if(typeof res.unumbers_to !== 'undefined' ){ $("#unumbers_to").val(res.unumbers_to); }
		
		$("#save_alovoice_settings").click(function(){
			
			var saveElements = {};
			var last = $("input").length-1;
			
			$.each($("select"),function(ind,obj){
				console.log("Check VAL:",$(obj).attr("id"), "[",$(obj).val(),"]");
				saveElements[$(obj).attr("id")] = $(obj).val();
			});
			
			$.each($("input"),function(ind,obj){
				
				var iVal = ($(obj).attr('type')=="checkbox") ? $(obj).prop('checked') : $(obj).val();
				
				console.log("Check VAL:",$(obj).attr("id"), "[",iVal,"]");
				saveElements[$(obj).attr("id")] = iVal;
				
				
				if(last == ind){
					console.log("Finish: ",saveElements);
					saveElements["restmethod"] = "savealovoicesettings";
					loadAloVoiceInfo(saveElements,function(res){
						console.log("Save RES: ",res);
						$("#alv_settings_form").prepend('<div class="alert alert-success" id="savesuccesbox" role="alert">Настройки сохранены!</div>');
						setTimeout(function(){
							$("#savesuccesbox").remove();
						},3000);
					});
				}
			});
		});
		
	}); 
}
</script>