<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';

$temp_set = $set;
if (!isset($temp_set['smsc_set_mobile']))$temp_set['smsc_set_mobile'] = 1;
if (!isset($temp_set['smsc_set_time']))$temp_set['smsc_set_time'] = 24;
if (!isset($temp_set['smsc_set_offline']))$temp_set['smsc_set_offline'] = 3;
if (!isset($temp_set['smsc_set_mail']))$temp_set['smsc_set_mail'] = 1;
if (!isset($temp_set['smsc_set_gift']))$temp_set['smsc_set_gift'] = 1;
if (!isset($temp_set['smsc_set_friends']))$temp_set['smsc_set_friends'] = 1;
if (!isset($temp_set['smsc_set_start']))$temp_set['smsc_set_start'] = 1;

include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/adm_check.php';
include_once '../sys/inc/user.php';

user_access('adm_set_sys',null,'index.php?'.SID);
adm_check();

if (isset($_POST['save']))
{
	$temp_set['smsc_set_mobile'] = intval($_POST['smsc_set_mobile']);
	$temp_set['smsc_set_time'] = intval($_POST['smsc_set_time']);
  

  $temp_set['smsc_set_offline'] = (int) $_POST['smsc_set_offline'];
  $temp_set['smsc_set_start'] = intval($_POST['smsc_set_start']);
  $temp_set['smsc_set_mail'] = (isset($_POST['smsc_set_mail']) ? 1 : 0);
  $temp_set['smsc_set_gift'] = (isset($_POST['smsc_set_gift']) ? 1 : 0);
  $temp_set['smsc_set_friends'] = (isset($_POST['smsc_set_friends']) ? 1 : 0);
  
  if ($set['smsc_set_start'] != $temp_set['smsc_set_start']) {
    @mysql_query("DELETE FROM `cron` WHERE `id` = 'smsc_notification'");
  }
  

	if (save_settings($temp_set)) {
		admin_log('Настройки', 'Система', 'Изменение параметров уведомлений smsc.ru');
		
		$_SESSION['message'] = 'Настройки успешно приняты';
		header('Location: ?');
		exit;
	}
	else
	$err = 'Нет прав для изменения файла настроек';
}

$set['title'] = 'Настройки SMS оповещений';
include_once '../sys/inc/thead.php';
title();
aut();
err();


// Класс обработчика
include_once H.'sys/inc/smsc_api.php';

if (get_balance()) {
	echo '<div class="mess">';
	echo 'Баланс: ' . get_balance();
	echo '</div>';
}
?>
<form method="post" action="?">
Оповещать по смс:<br /><select name="smsc_set_mobile">
<option value='1' <?=($temp_set['smsc_set_mobile'] == 1 ? ' selected="selected"' : '') ?>>Да</option>
<option value='0' <?=($temp_set['smsc_set_mobile'] == 0 ? ' selected="selected"' : '') ?>>Нет</option>
</select><br />

Интервал оповещений:<br />
<select name="smsc_set_time">
<option value='1' <?=($temp_set['smsc_set_time'] == 1 ? ' selected="selected"' : '') ?>>1 час</option>
<option value='3' <?=($temp_set['smsc_set_time'] == 3 ? ' selected="selected"' : '') ?>>3 часа</option>
<option value='6' <?=($temp_set['smsc_set_time'] == 6 ? ' selected="selected"' : '') ?>>6 часов</option>
<option value='12' <?=($temp_set['smsc_set_time'] == 12 ? ' selected="selected"' : '') ?>>12 часов</option>
<option value='24' <?=($temp_set['smsc_set_time'] == 24 ? ' selected="selected"' : '') ?>>24 часа</option>
<option value='72' <?=($temp_set['smsc_set_time'] == 72 ? ' selected="selected"' : '') ?>>3 дня</option>
</select><br />

Если offline больше:<br />
<select name="smsc_set_offline">
<option value='1' <?=($temp_set['smsc_set_offline'] == 1 ? ' selected="selected"' : '') ?>>1 часа</option>
<option value='3' <?=($temp_set['smsc_set_offline'] == 3 ? ' selected="selected"' : '') ?>>3 часов</option>
<option value='6' <?=($temp_set['smsc_set_offline'] == 6 ? ' selected="selected"' : '') ?>>6 часов</option>
<option value='12' <?=($temp_set['smsc_set_offline'] == 12 ? ' selected="selected"' : '') ?>>12 часов</option>
<option value='24' <?=($temp_set['smsc_set_offline'] == 24 ? ' selected="selected"' : '') ?>>24 часа</option>
<option value='72' <?=($temp_set['smsc_set_offline'] == 72 ? ' selected="selected"' : '') ?>>3 дней</option>
</select><br />

Точка отсчета:<br />
<select name="smsc_set_start">
<? for ($i = 0; 24 > $i; $i++) { ?>
 <option value='<?= $i?>' <?=($temp_set['smsc_set_start'] == $i ? ' selected="selected"' : '') ?>><?= vremja($ftime + 60 * 60 * $i)?></option> 
<? } ?>
</select><br />

<label><input type="checkbox" name="smsc_set_mail" value="1" <?= ($temp_set['smsc_set_mail'] == 1 ? 'checked' : '')?>> Личные сообщения</label><br />
<label><input type="checkbox" name="smsc_set_friends" value="1" <?= ($temp_set['smsc_set_friends'] == 1 ? 'checked' : '')?>> Заявки в друзья</label><br />
<label><input type="checkbox" name="smsc_set_gift" value="1" <?= ($temp_set['smsc_set_gift'] == 1 ? 'checked' : '')?>> Подарки</label><br />

<input value="Сохранить" name="save" type="submit" /><br />
</form>

<div class='foot'>
&laquo; <a href='/adm_panel/smsc_center.php'>SMS центр</a></a><br />
&laquo; <a href='/adm_panel/'>В админку</a><br />
</div>
<?
include_once '../sys/inc/tfoot.php';
?>