<?
if ($level <= 3) {
  die(__('У вас нет прав доступа'));
}

$tmp = $system;
 
if (isset($_POST['ref_pct'])) {
  $tmp['ref_pct'] = (int) $_POST['ref_pct'];
  $tmp['ref_reg_wmr'] = round($_POST['ref_reg_wmr'], 2);
  $tmp['ref_status'] = (int) $_POST['ref_status'];
  $tmp['ref_exch'] = ($_POST['ref_exch'] ? 1 : 0);
  $tmp['ref_exch_pct'] = (int) $_POST['ref_exch_pct'];
  
  if (!isset($err) && save_dat($tmp, 'settings.system')) {
    $messages[] = __('Настройки успешно приняты');
  } else {
    $err[] = __('Ошибка при сохранении настроек');
  }
}

$system['title'] = __('Настройки партнерки');
require SYS . 'header.php';
?>
<div class="nav2">
<form class="form-horizontal" action="?func=<?= $func?>" method="POST" style="margin: 2px;">
  <div class="control-group">
    <label class="control-label" for="ref_pct"><?= __('Партнерский %')?></label>
    <div class="controls">
      <input type="text" id="ref_pct" name="ref_pct" value="<?= $tmp['ref_pct']?>" />
    </div>
  </div>
  
  <div class="control-group">
    <label class="control-label" for="ref_reg_wmr"><?= __('WMR за регистрацию')?></label>
    <div class="controls">
      <input type="text" id="ref_reg_wmr" name="ref_reg_wmr" value="<?= $tmp['ref_reg_wmr']?>" />
    </div>
  </div>
  
  <div class="control-group">
    <label class="control-label" for="ref_exch"><?= __('Биржа рефералов')?></label>
    <div class="controls">
  		<select name="ref_exch" id="ref_exch" class="span1" style="width: auto;">
  		  <option value='1' <?= ($tmp['ref_exch'] == 1 ? " selected='selected'" : null)?>><?= __('Включена')?></option>
  		  <option value='0' <?= ($tmp['ref_exch'] == 0 ? " selected='selected'" : null)?>><?= __('Отключена')?></option>
  		</select>
    </div>
  </div>
  
  <div class="control-group">
    <label class="control-label" for="ref_exch_pct"><?= __('Процент биржи')?></label>
    <div class="controls">
      <input type="text" id="ref_exch_pct" name="ref_exch_pct" value="<?= $tmp['ref_exch_pct']?>" />
    </div>
  </div>
  
  <div class="control-group">
    <label class="control-label" for="ref_status"><?= __('Режим модуля')?></label>
    <div class="controls">
  		<select name="ref_status" id="ref_status" class="span1" style="width: auto;">
  		  <option value='1' <?= ($tmp['ref_status'] == 1 ? " selected='selected'" : null)?>><?= __('Включен')?></option>
  		  <option value='0' <?= ($tmp['ref_status'] == 0 ? " selected='selected'" : null)?>><?= __('Отключен')?></option>
  		</select>
    </div>
  </div>

  <div class="control-group">
    <div class="controls">
      <button type="submit" class="btn"><?= __('Сохранить')?></button>
    </div>
  </div>
</form>
</div>

<div class="foot">
&laquo; <a href="?func=admin"><?= __('Админ панель')?></a>
</div>