Файл: system/inc/buysystem.php
Строк: 1237
<?PHP
$action = $_REQUEST['action'];
include_once ENGINE_DIR.'/buysystem/init.php';
echoheader();
//-----------------------------------------
// массивы
$buy_payments_array = array();
foreach ($buy_system_payments as $id => $info ) {
$buy_payments_array[$info['idname']] = $info['name'];
}
$buy_payments_id_array = array();
foreach ($payments_array as $id => $info ) {
$buy_payments_id_array[$id] = $buy_system_payments[$info]['name'];
}
//-----------------------------------------
// Функции
function showRow($title="", $description="", $field="")
{
return "<tr><td style="padding:4px" class="option"><b>$title</b><br /><span class=small>$description</span></td>
<td width=394 align=middle >$field</td>
</tr><tr><td background="engine/skins/images/mline.gif" height=1 colspan=2></td></tr>";
}
function makeInputMoney($amount_value, $name, $pid = "")
{
global $buy_config;
$return = <<<HTML
<input class="edit" onBlur="ChangeMoney( this.value , '$pid');" type="text" style="text-align: center;" name="$name" value="$amount_value" size="20"> {$buy_config['currensy']}
HTML;
$amount_def = $buy_config['currenses'][$buy_config['currensy']];
foreach ($buy_config['currenses'] as $id => $value) {
if ($id==$buy_config['currensy']) continue;
$amount = currensy_exchange($amount_value, $amount_def, $value);
$return .= <<<HTML
<br /><span id="currensy_{$pid}_{$id}">$amount</span> $id
HTML;
}
return $return;
}
function makeDropDown($options, $name, $selected, $typeview = 0)
{
$output = "<select name="$name"";
if ($typeview != 2)
if ($typeview == 1 or ($typeview == 0 and is_array($selected)))
$output .= " multiple ";
$output .= ">rn";
if (is_array($options)) {
foreach($options as $value => $description)
{
$output .= "<option value="$value"";
if (is_array($selected)) {
if (in_array($value,$selected))
$output .= " selected ";
} else
if ($selected == $value) {
$output .= " selected ";
}
$output .= ">$description</option>n";
}
}
$output .= "</select>";
return $output;
}
function show_msg($name, $desc, $link) {
if ($link) $desc .= "<br /><br /><a href="$link">Вернуться назад</a>";
echo <<<HTML
<table width="100%">
<tr>
<td style="padding-left: 10px;" bgcolor="#efefef" height="29"><div class="navigation">{$name}</div></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
<tr>
<td align="center" height="100">$desc</td>
</tr>
</table>
HTML;
}
function show_navigation ( $page, $count_on_page, $count_all, $url = "" ) {
$return = "<div class="news_navigation" style="margin-bottom:5px; margin-top:5px;">";
$page_prev = $page - 1;
$page_next = $page + 1;
if( $page > 1 ) {
$return .= "<a onClick="javascript:search_submit(".($page - 1)."); return(false);" href="#" title="{$lang['edit_prev']}"><<</a> ";
} else {
$return .= "<span><<</span> ";
}
if( $count_all > $count_on_page ) {
$enpages_count = @ceil( $count_all / $count_on_page );
$enpages_start_from = 0;
$enpages = "";
if( $enpages_count <= 10 ) {
for($j = 1; $j <= $enpages_count; $j ++) {
if( $page != $j ) {
$enpages .= "<a onClick="javascript:search_submit($j); return(false);" href="#">$j</a> ";
} else {
$enpages .= "<span>$j</span> ";
}
$enpages_start_from += $page_count;
}
$return .= $enpages;
} else {
$start = 1;
$end = 10;
if( $start_from > 0 ) {
if( ($start_from / $page_count) > 4 ) {
$start = @ceil( $start_from / $page_count ) - 3;
$end = $start + 9;
if( $end > $enpages_count ) {
$start = $enpages_count - 10;
$end = $enpages_count - 1;
}
$enpages_start_from = ($start - 1) * $page_count;
}
}
if( $start > 2 ) {
$enpages .= "<a onClick="javascript:search_submit(0); return(false);" href="#">1</a> ... ";
}
for($j = $start; $j <= $end; $j ++) {
if( $page != $j ) {
$enpages .= "<a onClick="javascript:search_submit($j); return(false);" href="#">$j</a> ";
} else {
$enpages .= "<span>$j</span> ";
}
$enpages_start_from += $page_count;
}
$enpages_start_from = ($enpages_count - 1) * $count_on_page;
$enpages .= "... <a onClick="javascript:search_submit($j); return(false);" href="#">$enpages_count</a> ";
$return .= $enpages;
}
}
if( $page_all > $i ) {
if( $page_next > $page_count ) {
$page_next = $page_count;
}
$return .= "<a onClick="javascript:search_submit($page_next); return(false);" href="#" title="{$lang['edit_next']}">>></a>";
}
$return .= "</div>";
return $return;
}
//-----------------------------------------
// Шапка
echo <<<HTML
<table width="100%">
<tr>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" width="50%" style="padding-left:10px;">
<div class="navigation">
<b><a href="?mod=buysystem&action=config">Настройки</a></b><br />Настройки модуля
</div>
</td>
<td bgcolor="#EFEFEF" height="29" width="50%" style="padding-left:10px;">
<div class="navigation">
<b><a href="?mod=buysystem&action=config2">Настройки систем оплат</a></b><br />Настройки подключенных систем оплат
</div>
</td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td bgcolor="#EFEFEF" height="29" width="50%" style="padding-left:10px;">
<div class="navigation">
<b><a href="?mod=buysystem&action=stat">Статистика</a></b><br />Выводит статистику использования модуля
</div>
</td>
<td bgcolor="#EFEFEF" height="29" width="50%" style="padding-left:10px;">
<div class="navigation">
<b><a href="?mod=buysystem&action=log">Список логов</a></b><br />Выводит список логов оплат
</div>
</td>
</tr>
</table>
</td>
</div>
</form>
HTML;
//-----------------------------------------
// Модуль
//-----------------------------------------
// Ощая инфа
if ($action == "") {
$info = array();
$info['summ'] = 0;
$info['count'] = 0;
$sql_query = $db->query( "SELECT currensy, COUNT(*) as count, SUM(amount) as summ FROM " . PREFIX . "_buy_system WHERE status = '1' GROUP BY currensy");
while ( $row = $db->get_row ($sql_query) ) {
$row['summ'] = floatval(currensy_exchange($row['summ'], $buy_config['currenses'][$row['currensy']], $buy_config['currenses'][$buy_config['currensy']]));
$info['summ'] += $row['summ'];
$info['count'] += $row['count'];
}
$db->free($sql_query);
$info['summ'] = buysystem_showamount($info['summ']);
echo <<<HTML
<table width="100%">
<tr>
<td style="padding-left: 10px;" bgcolor="#efefef" height="29"><div class="navigation">Информация о модуле:</div></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
<tr>
<td style="padding: 2px;">Версия Buy System:</td>
<td>{$buy_config['version']}</td>
</tr>
<tr>
<td style="padding: 2px;" width="265">Оплатили с помощью скрипта:</td>
<td>{$info['count']} чел. на сумму {$info['summ']}</td>
</tr>
</table>
HTML;
echo <<<HTML
</tr>
</table>
</div><div style="padding-top: 5px; padding-bottom: 2px;">
<table width="100%">
<
<tr>
<td style="padding: 5px;" bgcolor="#ffffff">
HTML;
$buy_system_modules_str = "";
foreach ($buy_system_modules_all as $id => $info) {
$info_type = "Не установлено";
if (buysystem_exists( $id , 1 )) {
if ($buy_config_modules[$id]['enable']!="1")
$info_type = "<font color="red">Отключено</font>";
else
$info_type = "<font color="blue">Включено</font>";
}
$buy_system_modules_str .= <<<HTML
<tr>
<td style="padding: 2px;">{$info['name']}</td>
<td><b>{$info_type}</b></td>
</tr>
HTML;
}
$buy_system_payments_str = "";
foreach ($buy_system_payments_all as $id => $info) {
$info_type = "<b>Не установлено</b>";
if (buysystem_exists( $id , 2 )) {
if ($buy_config_payments[$id]['enable']!="1")
$info_type = "<font color="red"><b>Отключено</b></font>";
else
$info_type = "<font color="blue"><b>Включено</b></font>";
}
$buy_system_payments_str .= <<<HTML
<tr>
<td style="padding: 2px;">{$info['name']}</td>
<td>{$info_type}</td>
</tr>
HTML;
}
if ($buy_system_modules_str=="") {
$buy_system_modules_str = "<tr><td><b>Модулей оплаты не найдено</b></td></tr>";
}
echo <<<HTML
<table width="50%">
<tr>
<td style="padding-left: 10px;" bgcolor="#efefef" height="29"><div class="navigation">Модули и системы оплаты:</div></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
<tr>
<td width="50%" align="left" valign="top">
<b>Модули оплаты</b><br /><br />
<table width="100%">
{$buy_system_modules_str}
</table>
</td>
<td width="50%" align="left" valign="top">
<b>Системы оплаты</b><br /><br />
<table width="100%">
{$buy_system_payments_str}
</table>
</td>
</tr>
</table>
HTML;
} else
//-----------------------------------------
// Настройки модуля
if ($action == "config") {
$buy_system_option = init_buysystem_files ( '', 1 , 'config' );
$view_option = array();
$view_option[1] = "";
$view_option[2] = "";
$view_option[3] = "";
foreach ($buy_system_option as $idname => $info) {
$view_option[1] .= <<<HTML
document.getElementById('$idname').style.display = "none";
if(selectedOption == '$idname') {document.getElementById('$idname').style.display = "";}
HTML;
$view_option[2] .= <<<HTML
<td bgcolor="#EFEFEF" height="29" align="center">
<div class="navigation">
<b><a href="#" onclick="ChangeOption('$idname'); return false;">{$info['name']}</a></b>
</div>
</td>
HTML;
$view_option[3] .= <<<HTML
<table width="100%" style="display: none" id="$idname">
{$info['content']}
</table>
HTML;
}
echo "
<script language="JavaScript" type="text/javascript">
function ChangeMoney( amount, pid ) {
if (amount=="") amount = 0;
";
$amount_def = $buy_config['currenses'][$buy_config['currensy']];
foreach ($buy_config['currenses'] as $id => $amount_value) {
if ($id==$buy_config['currensy']) continue;
$amount_pref = currensy_exchange(1,$amount_def,$amount_value);
echo "
val = '$amount_pref';
val = val*amount;
document.getElementById('currensy_'+pid+'_{$id}').innerHTML = val.toFixed(2);
";
}
echo "
}
</script>
";
echo <<<HTML
<script language='JavaScript' type="text/javascript">
function ChangeOption(selectedOption) {
document.getElementById('system').style.display = "none";
if(selectedOption == 'system') {document.getElementById('system').style.display = "";}
{$view_option[1]}
}
</script>
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" width="20%" align="center">
<div class="navigation">
<b><a href="#" onclick="ChangeOption('system'); return false;">Основные</a></b>
</div>
</td>
{$view_option[2]}
</tr>
</table>
<div class="unterline"></div>
<form action="" method="post">
HTML;
//------------------------------------------------------
// Основные настройки
$currensy_array = array('usd'=>'Доллар США','rur'=>'Рубль','eur'=>'Евро');
echo "<table width="100%" id="system">";
echo showRow("Валюта сайта", "Единая валюта для установки цен. Настоятельно рекомендуется использовать <b>Доллар США</b>", makeDropDown($currensy_array, "buy_config[currensy]", $buy_config['currensy']));
echo showRow("Отношение <b>Доллара США</b> к валюте сайта", "Разделителем знаков является <b>точка</b>", "<input class=edit type=text style="text-align: center;" name='buy_config[currenses][usd]' value='{$buy_config['currenses']['usd']}' size=40>");
echo showRow("Отношение <b>Евро</b> к валюте сайта", "Разделителем знаков является <b>точка</b>", "<input class=edit type=text style="text-align: center;" name='buy_config[currenses][eur]' value='{$buy_config['currenses']['eur']}' size=40>");
echo showRow("Отношение <b>Рубля</b> к валюте сайта", "Разделителем знаков является <b>точка</b>", "<input class=edit type=text style="text-align: center;" name='buy_config[currenses][rur]' value='{$buy_config['currenses']['rur']}' size=40>");
echo showRow("Проверка системы", "При оплате появляется ссылка `check`, при нажатии на которую происходит оплата минуя биллинг", makeDropDown(array("1"=>"Вкл.","0"=>"Выкл."), "buy_config[check]", $buy_config['check']));
echo showRow("Создания лога", "При ошибке оплаты создаётся лог ошибок в файле <i>'engine/data/buy_log.txt'</i>", makeDropDown(array("1"=>"Вкл.","0"=>"Выкл."), "buy_config[log]", $buy_config['log']));
echo "</table>";
//------------------------------------------------------
echo $view_option[3];
//------------------------------------------------------
echo <<<HTML
<br />
<input type="submit" class="buttons" value=" {$lang['user_save']} ">
<input type="hidden" name="mod" value="buysystem">
<input type="hidden" name="user_hash" value="$dle_login_hash" />
<input type="hidden" name="action" value="configsave">
<br />
</form>
HTML;
} else
//-----------------------------------------
// Настройки систем оплат
if ($action == "config2") {
$buy_system_option = init_buysystem_files ( '', 2 , 'config' );
$view_option = array();
$view_option[1] = "";
$view_option[2] = "";
$view_option[3] = "";
$first_style = "";
foreach ($buy_system_option as $idname => $info) {
$view_option[1] .= <<<HTML
document.getElementById('$idname').style.display = "none";
if(selectedOption == '$idname') {document.getElementById('$idname').style.display = "";}
HTML;
$view_option[2] .= <<<HTML
<td bgcolor="#EFEFEF" height="29" align="center">
<div class="navigation">
<b><a href="#" onclick="ChangeOption('$idname'); return false;">{$info['name']}</a></b>
</div>
</td>
HTML;
$view_option[3] .= <<<HTML
<table width="100%" style="$first_style" id="$idname">
{$info['content']}
</table>
HTML;
$first_style = "display: none";
}
echo <<<HTML
<script language='JavaScript' type="text/javascript">
function ChangeOption(selectedOption) {
{$view_option[1]}
}
</script>
<table width="100%">
<tr>
{$view_option[2]}
</tr>
</table>
<div class="unterline"></div>
<form action="" method="post">
HTML;
//------------------------------------------------------
echo $view_option[3];
//------------------------------------------------------
echo <<<HTML
<br />
<input type="submit" class="buttons" value=" {$lang['user_save']} ">
<input type="hidden" name="mod" value="buysystem">
<input type="hidden" name="user_hash" value="$dle_login_hash" />
<input type="hidden" name="action" value="configsave">
<br />
</form>
HTML;
} else
//-----------------------------------------
// Настройки модуля - Сохранение
if ($action == "configsave") {
if($member_db[1] != 1){ show_msg( $lang['opt_denied'], $lang['opt_denied'], ""); }
function write_array($hfile, $xarray, $i = 0) {
foreach($xarray as $name => $value) {
$prefix_name = str_repeat(" ",$i);
if (!is_array($value)) {
$value = str_replace("$", "$", $value );
$value = str_replace("{", "{", $value );
$value = str_replace("}", "}", $value );
fwrite($hfile, "$prefix_name'{$name}' => "{$value}",n");
} else {
fwrite($hfile, "$prefix_name'{$name}' => array (n");
write_array($hfile, $value, $i+1);
fwrite($hfile, "$prefix_name),n");
}
}
}
if (isset($_POST['buy_config'])) {
$buy_config = array_merge($buy_config,$_POST['buy_config']);
}
if (isset($_POST['buy_config_modules'])) {
$buy_config_modules = array_merge($buy_config_modules,$_POST['buy_config_modules']);
}
if (isset($_POST['buy_config_payments'])) {
$buy_config_payments = array_merge($buy_config_payments,$_POST['buy_config_payments']);
}
$handler = fopen(ENGINE_DIR.'/data/buy.config.php', "w");
fwrite($handler, "<?PHP nn//Main Configurationsnn$buy_config = array (nn");
write_array($handler, $buy_config);
fwrite($handler, ");nn");
fwrite($handler, "//Buy Modules Configurationsnn$buy_config_modules = array (nn");
write_array($handler, $buy_config_modules);
fwrite($handler, ");nn");
fwrite($handler, "//Buy Payments Configurationsnn$buy_config_payments = array (nn");
write_array($handler, $buy_config_payments);
fwrite($handler, ");nn");
fclose($handler);
show_msg($lang['opt_sysok'],"Настройки модуля были успешно сохранены",$_SERVER['HTTP_REFERER']);
} else
//-----------------------------------------
// Настройки модуля - Сохранение
if ( $action == "log" ) {
//-----------------------------------------
if (isset($_REQUEST['search_author'])) $search_author = $db->safesql( trim( htmlspecialchars( stripslashes( urldecode( $_REQUEST['search_author'] ) ), ENT_QUOTES ) ) );
if (isset($_REQUEST['search_id'])) $search_id = intval( $_REQUEST['search_id'] ); else $search_id = 0;
if (isset($_REQUEST['search_fromdate'])) $search_fromdate = $db->safesql( trim( htmlspecialchars( stripslashes( $_REQUEST['search_fromdate'] ), ENT_QUOTES ) ) );
if (isset($_REQUEST['search_todate'])) $search_todate = $db->safesql( trim( htmlspecialchars( stripslashes( $_REQUEST['search_todate'] ), ENT_QUOTES ) ) );
if (isset($_REQUEST['page'])) $page = intval( $_REQUEST['page'] );
if (isset($_REQUEST['page_count'])) $page_count = intval( $_REQUEST['page_count'] );
if (isset($_REQUEST['buy_status'])) $buy_status = intval( $_REQUEST['buy_status'] );
if (isset($_REQUEST['buy_system'])) $buy_system = intval( $_REQUEST['buy_system'] );
//-----------------------------------------
if($page_count < 1 ) {
$page_count = 30;
}
if( $page > 1 ) {
$start_from = ($page-1)*$page_count;
} else {
$start_from = 0;
$page = 1;
}
$buy_status_sel = array ('1' => '', '2' => '', '3' => '' );
$buy_where = "";
if ( $search_id >0 ) {
if ($buy_where != "") $buy_where .= " AND ";
$buy_where .= "order_id = '$search_id' or order_res = '$search_id'";
} else $search_id = "";
if( $search_author != "" ) {
if ($buy_where != "") $buy_where .= " AND ";
$buy_where .= "buy_user_name like '%$search_author%'";
}
if( $search_fromdate != "" ) {
if ($buy_where != "") $buy_where .= " AND ";
$buy_where .= "date >= '$search_fromdate 00:00:00'";
}
if( $search_todate != "" ) {
if ($buy_where != "") $buy_where .= " AND ";
$buy_where .= "date <= '$search_todate 00:00:00'";
}
if ($buy_status>0) {
if ($buy_where != "") $buy_where .= " AND ";
$buy_status = $buy_status - 1;
$buy_where .= "status = '$buy_status'";
$buy_status_sel[$buy_status] = 'selected="selected"';
}
if ($buy_system != 0) {
if ($buy_where != "") $buy_where .= " AND ";
$buy_where .= "type = '$buy_system'";
}
if ($buy_where != "") $buy_where = " WHERE ".$buy_where;
$order_by = "date DESC";
$sql_result = $db->query( "SELECT * FROM " . PREFIX . "_buy_system " . $buy_where . " ORDER BY " . $order_by . " LIMIT $start_from,$page_count" );
$entries_i = 0;
$entries = "";
while ( $row = $db->get_array($sql_result) ) {
$entries_i ++;
$row['date'] = strtotime( $row['date'] );
$buy_title = langdate($config['timestamp_active'], $row['date']);
$buy_title .= " - ";
$buy_title .= "<a href="" . $config['http_home_url'] . "user/" . urlencode( $row['buy_user_name'] ) . "/">{$row['buy_user_name']}</a> (#:{$row['buy_user_id']})";
if ($row['pay_user_id']>0 or $row['pay_user_name']!='') {
$buy_title .= " for ";
$buy_title .= "<a href="" . $config['http_home_url'] . "user/" . urlencode( $row['pay_user_name'] ) . "/">{$row['pay_user_name']}</a> (#:{$row['pay_user_id']})";
}
if ($row['status']==0)
$buy_status = "<font color="red">Не оплачено</font>";
elseif ($row['status']==1)
$buy_status = "<font color="blue">Оплачено</font>";
elseif ($row['status']==2)
$buy_status = "<b>Отменено</b>";
elseif ($row['status']==3)
$buy_status = "<b>Удалено</b>";
$pay_id = intval($row['pay']);
$pay = $modules_array_all[$pay_id];
$type_id = intval($row['type']);
$type = $payments_array_all[$type_id];
$buy_system = $buy_system_modules_all[$pay]['namelite'];
if ($buy_system=="")
$buy_system = $buy_system_modules_all[$pay]['name'];
$buy_type = $buy_system_payments_all[$type]['namelite'];
if ($buy_type=="")
$buy_type = $buy_system_payments_all[$type]['name'];
$buy_amount = buysystem_showamount($row['amount'],$row['currensy']);
if ($entries_i % 2 == 1 )
$tr_color = "#E0F0F1";
else
$tr_color = "#EFF1E0";
$entries .= <<<HTML
<tr bgcolor="$tr_color">
<td align="center"><b>{$row['order_id']}</b></td>
<td align="center">{$row['order_res']}</td>
<td class="list" style="padding:4px;">$buy_title
HTML;
if ($row['buy_info']!="") {
if ($row['status']!=1) $entries .= "<font color="red">";
$entries .= <<<HTML
<div>{$row['buy_info']}</div>
HTML;
if ($row['status']!=1) $entries .= "</font>";
}
$entries .= <<<HTML
</td>
<td align="center">{$buy_amount}</td>
<td align="center">{$buy_system}</td>
<td align="center">{$buy_type}</td>
<td align="center">{$buy_status}</td>
<td align="center">[<a href="#" onclick="return cdelete('{$row['order_id']}')">Удалить</a>]</td>
</tr>
HTML;
}
$db->free($sql_result);
$result_count = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_buy_system" . $buy_where );
$page_all = $result_count['count'];
///////////////////////////////////////////
// Options Bar
echo <<<HTML
<!-- calendar stylesheet -->
<link rel="stylesheet" type="text/css" media="all" href="engine/skins/calendar-blue.css" title="win2k-cold-1" />
<script type="text/javascript" src="engine/skins/calendar.js"></script>
<script type="text/javascript" src="engine/skins/calendar-en.js"></script>
<script type="text/javascript" src="engine/skins/calendar-setup.js"></script>
<script language="javascript">
function search_submit(prm){
document.optionsbar.page.value=prm;
document.optionsbar.submit();
return false;
}
</script>
<form action="?mod=buysystem&action=log" method="POST" name="optionsbar" id="optionsbar">
<input type="hidden" name="mod" value="buysystem">
<input type="hidden" name="action" value="log">
HTML;
if ($buy_where != "") {
echo <<<HTML
<div style="padding-top:5px;padding-bottom:2px;" name="advancedsearch" id="advancedsearch">
HTML;
} else {
echo <<<HTML
<div style="padding-top:5px;padding-bottom:2px;display:none" name="advancedsearch" id="advancedsearch">
HTML;
}
echo <<<HTML
<table width="100%">
<tr>
<td width="4"><img src="engine/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
<td background="engine/skins/images/tl_oo.gif"><img src="engine/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
<td width="6"><img src="engine/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
</tr>
<tr>
<td background="engine/skins/images/tl_lb.gif"><img src="engine/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Показано <b>{$entries_i}</b> из <b>{$page_all}</b></div></td>
<td bgcolor="#EFEFEF" height="29" style="padding:5px;" align="right"><a href="javascript:ShowOrHide('advancedsearch');">Скрыть</a></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
<tr>
<td style="padding-left:5px;">Поиск по оплатившему</td>
<td style="padding-left:22px;"><input class="edit" name="search_author" value="{$search_author}" type="text" size="36"></td>
<td style="padding-left:5px;">Поиск по номеру операции</td>
<td style="padding-left:22px;"><input class="edit" name="search_id" value="{$search_id}" type="text" size="36"></td>
</tr>
<tr>
<td style="padding:5px;">Статус оплаты</td>
<td style="padding-left:22px;"><select name="buy_status" id="buy_status">
<option {$buy_status_sel['0']} value="0">Все</option>
<option {$buy_status_sel['0']} value="1">Не оплачено</option>
<option {$buy_status_sel['1']} value="2">Оплачено</option>
<option {$buy_status_sel['2']} value="3">Отменено</option></select>
</td>
<td style="padding:5px;">Системы оплаты</td>
<td style="padding-left:22px;"><select name="buy_system" id="buy_system">$buy_system_selected</select>
</td>
</tr>
<tr>
<td style="padding-left:5px;">Дата оплаты</td>
<td style="padding-left:22px;">{$lang['edit_fdate']} <input type="text" name="search_fromdate" id="search_fromdate" size="11" maxlength="16" class="edit" value="{$search_fromdate}">
<img src="engine/skins/images/img.gif" align="absmiddle" id="f_trigger_dnews" style="cursor: pointer; border: 0" title="{$lang['edit_ecal']}"/>
<script type="text/javascript">
Calendar.setup({
inputField : "search_fromdate", // id of the input field
ifFormat : "%Y-%m-%d, // format of the input field
button : "f_trigger_dnews", // trigger for the calendar (button ID)
align : "Br", // alignment
timeFormat : "24",
showsTime : false,
singleClick : true
});
</script> {$lang['edit_tdate']} <input type="text" name="search_todate" id="search_todate" size="11" maxlength="16" class="edit" value="{$search_todate}">
<img src="engine/skins/images/img.gif" align="absmiddle" id="f_trigger_tnews" style="cursor: pointer; border: 0" title="{$lang['edit_ecal']}"/>
<script type="text/javascript">
Calendar.setup({
inputField : "search_todate", // id of the input field
ifFormat : "%Y-%m-%d", // format of the input field
button : "f_trigger_tnews", // trigger for the calendar (button ID)
align : "Br", // alignment
timeFormat : "24",
showsTime : false,
singleClick : true
});
</script>
</td>
<td style="padding-left:5px;">кол-во логов на страницу</td>
<td style="padding-left:22px;"><input class="edit" style="text-align: center" name="page_count" value="{$page_count}" type="text" size="36"></td>
</tr>
<tr>
<td colspan="4"><div class="hr_line"></div></td>
</tr>
<tr>
<td style="padding:5px;"> </td>
<td colspan="3">
<input type="hidden" name="page" id="page" value="{$page}">
<input onClick="javascript:search_submit(0); return(false);" class="edit" type="submit" value="{$lang['edit_act_1']}">
</td>
</tr>
</table>
</td>
<td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
</tr>
<tr>
<td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
<td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
<td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
</tr>
</table>
</div>
</form>
HTML;
// End Options Bar
echo <<<HTML
<script type="text/javascript" src="engine/ajax/menu.js"></script>
<script language="javascript" type="text/javascript">
<!--
function cdelete(id){
var agree=confirm("Вы действительно хотите удалить оплату?");
if (agree)
document.location='?mod=buysystem&user_hash={$dle_login_hash}&action=logdodelete&id=' + id + '';
return false;
}
//-->
</script>
<form action="" method="post" name="editnews">
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
<tr>
<td width="4"><img src="engine/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
<td background="engine/skins/images/tl_oo.gif"><img src="engine/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
<td width="6"><img src="engine/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
</tr>
<tr>
<td background="engine/skins/images/tl_lb.gif"><img src="engine/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
<td style="padding:5px;" bgcolor="#FFFFFF">
HTML;
if( $entries_i == 0 ) {
echo <<<HTML
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Список оплат</div></td>
<td bgcolor="#EFEFEF" height="29" style="padding:5px;" align="right"><a href="javascript:ShowOrHide('advancedsearch');">Расширенный поиск</a></td>
</tr>
</table>
HTML;
} else {
echo <<<HTML
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Список оплат (Показано <b>{$entries_i}</b> из <b>{$page_all}</b>)</div></td>
<td bgcolor="#EFEFEF" height="29" style="padding:5px;" align="right"><a href="javascript:ShowOrHide('advancedsearch');">Расширенный поиск</a></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
<tr>
<td>
<table width=100%>
<tr>
<td width="25" align="center"><b><a href="#" class="hintanchor" onMouseover="showhint('ИД операции в системе сайта', this, event, '300px')">id</a></b></td>
<td width="80" align="center"><b><a href="#" class="hintanchor" onMouseover="showhint('ИД операции в платёжной системе биллинга<br />Необходим для уточнения даннх об операции по её индефикатору', this, event, '300px')">id bs</a></b></td>
<td> Описание</td>
<td width="100" align="center">Сумма оплаты</td>
<td width="80" align="center">Система оплаты</td>
<td width="80" align="center">Тип оплаты</td>
<td width="80" align="center">Статус</td>
<td width="100" align="center">Действие</td>
</tr>
<tr><td colspan="8"><div class="hr_line"></div></td></tr>
{$entries}
<tr><td colspan="8"><div class="hr_line"></div></td></tr>
HTML;
if ( $page_all > $page_count ) {
$npp_nav = show_navigation( $page, $page_count, $page_all);
echo <<<HTML
<tr><td colspan="6">{$npp_nav}</td></tr>
<tr><td colspan="6">
{$lang['edit_go_page']} <input class="edit" style="text-align: center" name="gopage" id="gopage" value="" type="text" size="3"> <input onClick="javascript:search_submit(document.getElementById('gopage').value); return(false);" class="edit" type="button" value=" ok ">
</td></tr>
HTML;
}
echo <<<HTML
</table>
HTML;
}
echo <<<HTML
</td>
</tr>
</table>
</td>
<td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
</tr>
<tr>
<td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
<td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
<td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
</tr>
</table>
</div>
HTML;
}
//-----------------------------------------
// Удаляем лог
elseif ($action == 'logdodelete') {
if( $_REQUEST['user_hash'] == "" or $_REQUEST['user_hash'] != $dle_login_hash ) {
die( "Hacking attempt! User not found" );
}
$id = intval( $_REQUEST['id'] );
if(!$id ) {
show_msg("Удаление лога оплаты", "Неизвестный ID", "$PHP_SELF?mod=buysystem&action=log");
}
$db->query( "DELETE FROM " . PREFIX . "_buy_system WHERE order_id='$id'" );
show_msg( "Удаление лога оплаты", "Лог оплаты #$id удалён", "$PHP_SELF?mod=buysystem&action=log" );
}
//-----------------------------------------
// Статистика
elseif ($action == 'stat') {
if (isset($_REQUEST['buy_system'])) $buy_system = $db->safesql( $_REQUEST['buy_system'] ); else $buy_system = "";
$buy_payments_id_array[''] = "Все";
$buy_system_selected = makeDropDown($buy_payments_id_array, 'buy_system',$buy_system);
if (isset($_REQUEST['log_limit'])) $log_limit = intval( $_REQUEST['log_limit'] ); else $log_limit = 0;
$log_limit_selected = array ('0' => '', '1' => '', '2' => '', '3' => '' );
$log_limit_selected[$log_limit] = "selected";
echo <<<HTML
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
<tr>
<td width="4"><img src="engine/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
<td background="engine/skins/images/tl_oo.gif"><img src="engine/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
<td width="6"><img src="engine/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
</tr>
<tr>
<td background="engine/skins/images/tl_lb.gif"><img src="engine/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Статистика оплат</div></td>
</tr>
</table>
<div class="unterline"></div>
<form action="?mod=buysystem&action=stat" method="POST" name="searchsbar" id="searchsbar">
<table width="100%">
<tr>
<td style="padding:5px;">Период статистики</td>
<td style="padding-left:22px;"><select name="log_limit" id="log_limit">
<option {$log_limit_selected['0']} value="0">Весь период</option>
<option {$log_limit_selected['1']} value="1">1 день</option>
<option {$log_limit_selected['2']} value="2">Неделя</option>
<option {$log_limit_selected['3']} value="3">Месяц</option></select>
</td>
<td style="padding:5px;">Системы оплаты</td>
<td style="padding-left:22px;">{$buy_system_selected}</td>
<td><input class="edit" type="submit" value="{$lang['edit_act_1']}"> </td>
</tr>
</table>
</form>
<div class="unterline"></div>
HTML;
$where = array();
$where2 = "";
if ($log_limit==1) $log_limit = 1;
elseif ($log_limit==2) $log_limit = 7;
elseif ($log_limit==3) $log_limit = 30;
if ($log_limit) {
$this_time = date( 'Y-m-d H:i:s', time() );
if ($log_limit==1)
$where[] = "date >= '$this_time' - INTERVAL 1 DAY AND date < '$this_time'";
elseif ($log_limit==2)
$where[] = "date >= '$this_time' - INTERVAL 7 DAY AND date < '$this_time'";
elseif ($log_limit==3)
$where[] = "date >= '$this_time' - INTERVAL 30 DAY AND date < '$this_time'";
}
if ($buy_system != "") {
$where[] .= "type = '$buy_system'";
}
if (count($where)>0) {
$where2 = implode(' AND ',$where);
$where = "WHERE ".$where2." ";
} else
$where = "";
$buy_status = array();
$sql_query = $db->query( "SELECT status, COUNT(*) as count, SUM(amount) as summ, currensy FROM " . PREFIX . "_buy_system ".$where."GROUP BY status, currensy" );
while ( $row = $db->get_row ($sql_query) ) {
$row['summ'] = floatval(currensy_exchange($row['summ'], $buy_config['currenses'][$row['currensy']], $buy_config['currenses'][$buy_config['currensy']]));
if (isset($buy_status[$row['status']])) {
$buy_status[$row['status']]['count'] += $row['count'];
$buy_status[$row['status']]['summ'] += $row['summ'];
} else
$buy_status[$row['status']] = array('count'=>$row['count'],'summ'=>$row['summ']);
}
$db->free($sql_query);
foreach ($buy_status as $id => $info) {
$buy_status[$id]['summ'] = buysystem_showamount($info['summ']);
}
echo <<<HTML
<b>Статистика оплат<b><br/>
<table>
<tr style="padding-top:5px">
<td width="200"></td>
<td width="200"></td>
<td width="200"></td>
</tr>
<tr height="20">
<td width="200"></td>
<td width="200"><font color="blue">Оплачено</font></td>
<td width="200">{$buy_status[1]['summ']} ({$buy_status[1]['count']} чел.)</td>
</tr>
<tr height="20">
<td width="200"></td>
<td width="200"><font color="red">Не оплачено</font></td>
<td width="200">{$buy_status[0]['summ']} ({$buy_status[0]['count']} чел.)</td>
</tr>
<tr height="20">
<td width="200"></td>
<td width="200"><b>Отменено</b></td>
<td width="200">{$buy_status[2]['summ']} ({$buy_status[2]['count']} чел.)</td>
</tr>
</table>
<div class="unterline"></div>
HTML;
echo <<<HTML
<b>Пользователи, больше всего оплатившие в системе<b><br/>
<table>
<tr height="20">
<td width="200"></td>
<td width="200"><b>Пользователь</b></td>
<td width="200"><b>Сумма</b></td>
</tr>
HTML;
if ($where2) $where2 = " AND ".$where2;
$sql_row = array();
$sql_query = $db->query( "SELECT buy_user_name, COUNT(*) as count, MAX(amount) as max, SUM(amount) as summ, currensy FROM " . PREFIX . "_buy_system WHERE status = '1' {$where2} GROUP BY buy_user_name, currensy LIMIT 0,3");
while ( $row = $db->get_row ($sql_query) ) {
if ($row['buy_user_name']=="") $row['buy_user_name'] = "Гость";
$row['summ'] = floatval(currensy_exchange($row['summ'], $buy_config['currenses'][$row['currensy']], $buy_config['currenses'][$buy_config['currensy']]));
if (isset($sql_row[$row['buy_user_name']])) {
$sql_row[$row['buy_user_name']]['count'] += $row['count'];
$sql_row[$row['buy_user_name']]['summ'] += $row['summ'];
} else {
$sql_row[$row['buy_user_name']] = $row;
if ($row['buy_user_name'] != "Гость" ) {
if( $config['allow_alt_url'] == "yes" )
$sql_row[$row['buy_user_name']]['buy_user_url'] = "<a href="" . $config['http_home_url'] . "user/" . urlencode( $row['buy_user_name'] ) . "/">{$row['buy_user_name']}</a>";
else
$sql_row[$row['buy_user_name']]['buy_user_url'] = "<a href="$PHP_SELF?subaction=userinfo&user=" . urlencode( $row['buy_user_name'] ) . "/">{$row['buy_user_name']}</a>";
}
}
}
$db->free($sql_query);
// Сортировку сделать
foreach ($sql_row as $id => $row) {
$row['summ'] = buysystem_showamount($row['summ']);
if (!isset($row['buy_user_url']))
$row['buy_user_url'] = $row['buy_user_name'];
echo <<<HTML
<tr height="20">
<td></td>
<td>{$row['buy_user_url']}</td>
<td>{$row['summ']} ({$row['count']} раз.)</td>
</tr>
HTML;
}
echo <<<HTML
</table>
<div class="unterline"></div>
HTML;
echo <<<HTML
<b>Популярная система оплаты<b><br/>
<table>
<tr height="20">
<td width="200"></td>
<td width="200"><b>Система оплаты</b></td>
<td width="200"><b>Сумма</b></td>
</tr>
HTML;
$sql_row = array();
$sql_query = $db->query( "SELECT currensy, type, COUNT(*) as count, MAX(amount) as max, SUM(amount) as summ FROM " . PREFIX . "_buy_system WHERE status = '1' {$where2} GROUP BY type LIMIT 0,3");
while ( $row = $db->get_row ($sql_query) ) {
$row['summ'] = floatval(currensy_exchange($row['summ'], $buy_config['currenses'][$row['currensy']], $buy_config['currenses'][$buy_config['currensy']]));
if (isset($sql_row[$row['type']])) {
$sql_row[$row['type']]['count'] += $row['count'];
$sql_row[$row['type']]['summ'] += $row['summ'];
} else {
$sql_row[$row['type']] = $row;
}
}
$db->free($sql_query);
// Сортировку сделать
foreach ($sql_row as $id => $row) {
$row['summ'] = buysystem_showamount($row['summ']);
$type = $payments_array[$row['type']];
$buy_type = $buy_system_payments_all[$type]['namelite'];
if ($buy_type=="")
$buy_type = $buy_system_payments_all[$type]['name'];
echo <<<HTML
<tr height="20">
<td></td>
<td>$buy_type</td>
<td>{$row['summ']} ({$row['count']} раз.)</td>
</tr>
HTML;
}
echo <<<HTML
</table>
<div class="unterline"></div>
HTML;
echo <<<HTML
<b>Популярный тип оплаты<b><br/>
<table>
<tr height="20">
<td width="200"></td>
<td width="200"><b>Тип оплаты</b></td>
<td width="200"><b>Сумма</b></td>
</tr>
HTML;
$sql_row = array();
$sql_query = $db->query( "SELECT currensy, pay, COUNT(*) as count, MAX(amount) as max, SUM(amount) as summ FROM " . PREFIX . "_buy_system WHERE status = '1' {$where2} GROUP BY currensy, pay LIMIT 0,3");
while ( $row = $db->get_row ($sql_query) ) {
$row['summ'] = floatval(currensy_exchange($row['summ'], $buy_config['currenses'][$row['currensy']], $buy_config['currenses'][$buy_config['currensy']]));
if (isset($sql_row[$row['pay']])) {
$sql_row[$row['pay']]['count'] += $row['count'];
$sql_row[$row['pay']]['summ'] += $row['summ'];
} else {
$sql_row[$row['pay']] = $row;
}
}
$db->free($sql_query);
foreach ($sql_row as $id => $row) {
$row['summ'] = buysystem_showamount($row['summ']);
$pay = $modules_array[$row['pay']];
$buy_pay = $buy_system_modules_all[$pay]['namelite'];
if ($buy_type=="")
$buy_pay = $buy_system_modules_all[$pay]['name'];
echo <<<HTML
<tr height="20">
<td></td>
<td>$buy_pay</td>
<td>{$row['summ']} ({$row['count']} раз.)</td>
</tr>
HTML;
}
echo <<<HTML
</table>
HTML;
echo <<<HTML
</td>
<td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
</tr>
<tr>
<td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
<td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
<td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
</tr>
</table>
</div>
HTML;
}
echo <<<HTML
</td>
<td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
</tr>
<tr>
<td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
<td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
<td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
</tr>
</table>
</div>
</form>
HTML;
echohtmlend();
?>