<?
if(empty($this->row['path'])){
 	$this->row['path'] = "/serval-".md5(time().'x'.rand(1,10000).'||'.time()+rand(1,10000)).".php";
}
if(empty($this->row['spath'])){
 	$this->row['spath'] = ".";
}
if(empty($this->row['ext'])){
 	$this->row['ext'] = $this->settings['default_ext'];
}
if(empty($this->row['check_hour'])){
	$this->row['check_hour'] = 3;
}
if(empty($this->row['maxdir'])){
	$this->row['maxdir'] = "";
}
$users = Serval::call('db')->Select("mod_users","","");
?>
<form method="post" name="project" class="form-base">
    <div class="grid">
        <div class="grid_cell form-base_lbl">Домен (без http:// и / в конце):</div>
        <div class="grid_cell grid form-base_inp">
			<div class="grid_cell protocol_cell">
				<select name="protocol">
					<option <?=$this->row['protocol']=="http://" ? 'selected' : ''?> value="http://">http://</option>
					<option <?=$this->row['protocol']=="https://" ? 'selected' : ''?> value="https://">https://</option>
				</select>
			</div>
			<div class="grid_cell">
				<input required class="inp-base" type="text" name="domain" value="<?=$this->row['domain']?>">
			</div>
		</div>
    </div>
    <?if(Serval::call('Auth')->Data['type']=="admin"){?>
    <div class="grid">
        <div class="grid_cell form-base_lbl">Владелец:</div>
        <div class="grid_cell form-base_inp">
					<select name="users_id">
						<?if($users){
							foreach($users as $val){?>
	            	<option <?=($this->row['users_id']==$val['id'] ? 'selected' : '')?> value="<?=$val['id']?>"><?=$val['fio']?></option>
	            <?}?>  
						<?}?>
					</select>
				</div>
    </div>
    <?}?>
    <div class="grid">
        <div class="grid_cell form-base_lbl">Адрес скрипта мониторинга:</div>
        <div class="grid_cell form-base_inp"><input required class="inp-base" type="text" name="path" value="<?=$this->row['path']?>"></div>
    </div>
    <div class="grid">
        <div class="grid_cell form-base_lbl">Стартовый путь мониторинга:</div>
        <div class="grid_cell form-base_inp"><input required class="inp-base" type="text" name="spath" value="<?=$this->row['spath']?>"></div>
    </div>
    <div class="grid">
        <div class="grid_cell form-base_lbl">Секретный код:</div>
        <div class="grid_cell form-base_inp"><input required class="inp-base" type="text" name="scode" value="<?=$this->row['scode'] ? $this->row['scode'] : md5(time())?>"></div>
    </div>
    <div class="grid">
        <div class="grid_cell form-base_lbl">Расширения сканируемых файлов:<br> <span class="note">(через запятую)</span></div>
        <div class="grid_cell form-base_inp">   
					<input required class="inp-base" type="text" name="ext" value="<?=$this->row['ext']?>">
				</div>
    </div>
    <div class="grid">
        <div class="grid_cell form-base_lbl">Пропускать папки:<br> <span class="note">(через запятую, для маски используйте *)</span></div>
        <div class="grid_cell form-base_inp"><input class="inp-base" type="text" name="exc" value="<?=$this->row['exc']?>"></div>
    </div>
    <div class="grid">
        <div class="grid_cell form-base_lbl">Пропускать файлы:<br> <span class="note">(через запятую, для маски используйте *)</span></div>
        <div class="grid_cell form-base_inp"><input class="inp-base" type="text" name="excf" value="<?=$this->row['excf']?>"></div>
    </div>
    
    <div class="grid">
        <div class="grid_cell form-base_lbl">Интервал сканирования:</div>
        <div class="grid_cell form-base_inp"><input class="inp-base" type="text" style="width:100px" name="check_hour" value="<?=$this->row['check_hour']?>"> ч.</div>
    </div>
    <div class="grid">
        <div class="grid_cell form-base_lbl">Тип кодирования:</div>
        <div class="grid_cell form-base_inp">
					<select name="crypt_type">
						<option <?=$this->row['crypt_type']!="lite" ? 'selected' : ''?> value="lite">Упрощенный</option>
						<option <?=$this->row['crypt_type']=="default" ? 'selected' : ''?> value="default">Нормальный</option>
						<option <?=$this->row['crypt_type']=="reinforced" ? 'selected' : ''?> value="reinforced">Усиленный</option>
						
					</select>
				</div>
    </div>
    <div class="grid">
        <div class="grid_cell form-base_lbl">Кол-во папок за раз:</div>
        <div class="grid_cell form-base_inp">
			<input class="inp-base" type="text" style="width:100px" placeholder="<?=$this->settings['scanner_maxdir']?>" name="maxdir" value="<?=$this->row['maxdir']?>">
		</div>
    </div>
	<div class="grid">
        <div class="grid_cell form-base_lbl">Максимальное время сканирования:</div>
        <div class="grid_cell form-base_inp">
			<input class="inp-base" type="text" style="width:100px" placeholder="60" name="maxtime" value="<?=$this->row['maxtime']>0 ? $this->row['maxtime'] : ''?>"> сек.
		</div>
    </div>
    <div class="grid">
        <div class="grid_cell form-base_lbl">Активность:</div>
        <div class="grid_cell form-base_inp">
			<select name="is_active">
				<option <?=$this->row['is_active']!="no" ? 'selected' : ''?> value="yes">Мониторим</option>
				<option <?=$this->row['is_active']=="no" ? 'selected' : ''?> value="no">Остановлен</option>
			</select>
		</div>
    </div>
	<div class="grid">
        <div class="grid_cell form-base_lbl">Отправка изменений в теле письма:</div>
        <div class="grid_cell form-base_inp">
					<select name="is_change_email">
						<option <?=$this->row['is_change_email']=="yes" ? 'selected' : ''?> value="yes">Да</option>
						<option <?=$this->row['is_change_email']!="yes" ? 'selected' : ''?> value="no">Нет</option>
						
					</select>
				</div>
    </div>
    
    <?if(!$this->editProject || $this->row['users_id']==Serval::call('Auth')->ID || Serval::call('Auth')->Data['type']=="admin"){?>
	    <?if($users){?>
			<div class="grid">
	        <div class="grid_cell form-base_lbl">Доступ:</div>
	        <div class="grid_cell form-base_inp">
	            <select name="users[]" multiple data-text="">
							<?
							foreach($users as $val){
								if($val['type']!="user") continue;
							?>
	            	<option <?=(is_array($this->row['_users']) && in_array($val['id'],$this->row['_users'])) ? 'selected' : ''?> value="<?=$val['id']?>"><?=$val['fio']?></option>
	            <?}?>                                                                                          
	            </select>
	        </div>
	    </div>
	    <?}?>
    <?}?>
    <div class="form-base_bttns">
    <?if($this->editProject){?>
    	<input type="hidden" name="id" value="<?=$this->row['id']?>">
    <?}?>
        <button class="btn __primary ic_edit">Сохранить</button>
    </div>
</form>
