Exemplo n.º 1
0
</form>



<?php 
$prop[$i] = account::GetPROStat($fdate, $tdate, 0);
$testpro[$i] = account::GetStatOP(47, $fdate, $tdate);
$prop2[$i] = account::GetPROStat($fdate, $tdate);
$ppp[$i] = account::GetStatOP(array(8), $fdate, $tdate);
$gpp[$i] = account::GetStatOP(array(16, 17, 18, 34, 35), $fdate, $tdate, "", "RIGHT JOIN present ON billing_from_id = account_operations.id");
$fpp[$i] = account::GetStatOP(array(10, 11), $fdate, $tdate);
$fppc[$i] = account::GetStatOP(array(19), $fdate, $tdate);
$fppci[$i] = account::GetStatOP(array(20), $fdate, $tdate);
$cho[$i] = account::GetStatOP(array(21), $fdate, $tdate);
$konkCodes = new_projects::getContestOpCodes();
$konk[$i] = account::GetStatOP($konkCodes, $fdate, $tdate);
$upproj[$i] = account::GetStatOP(array(7), $fdate, $tdate);
$transf[$i] = account::GetStatOP(array(23), $fdate, $tdate);
$testbuypro[$i] = account::GetStatTestBuyPro($fdate, $tdate);
$bonuses[$i] = account::GetStatBonuses($fdate, $tdate);
// Статистика по регистрациям и привязке мобильных телефонов
$regs = stats::getRegStats($fdate, $tdate);
?>

<table  border="1" cellspacing="2" cellpadding="2"  class="brd-tbl">
<tr>
	<td width=200><strong>Проекты:</strong></td>
	<td>
        <?php 
$sql = "SELECT COUNT(*) as cnt FROM projects WHERE kind != 9 AND post_date >= ? AND post_date - '1 day'::interval < ?";
Exemplo n.º 2
0
function getOPProject($from_date = '2000-01-01', $to_date = 'now()', $bYear = false, $bYearAll = false, $ignore_str = '', $addit)
{
    global $DB;
    $query = $select = array();
    $type = $addit['type'];
    $is_konkurs = $addit['is_konkurs'];
    $is_bonus = $addit['is_bonus'];
    if ($ignore_str) {
        //$query[] = "account.uid NOT IN ({$ignore_str})";
        $ignore_str = "INNER JOIN account ON account.id=ac.billing_id AND account.uid NOT IN ({$ignore_str})";
    }
    if ($type !== '') {
        $query[] = "pay_type = {$type}";
        $select[] = "SUM(round(p.ammount,2)) as sum, COUNT(p.*) as ammount ";
        if ($bYear) {
            $to_char = 'MM';
            if ($bYearAll) {
                $to_char = 'YYYY';
            }
            $select[] = "to_char(ac.op_date,'{$to_char}') as _day";
            $group = " GROUP BY to_char(op_date,'{$to_char}') ORDER BY to_char(op_date,'{$to_char}')";
        } else {
            $select[] = "extract(day from ac.op_date) as _day";
            $group = " GROUP BY _day ORDER BY  _day";
        }
    } else {
        if ($is_bonus) {
            $select[] = " SUM(round(ac.bonus_ammount,2)) as sum, COUNT(ac.*) as ammount";
        } else {
            $select[] = " SUM(round(ac.ammount,2)) as sum, COUNT(*) as ammount";
        }
        if ($bYear) {
            $to_char = 'MM';
            if ($bYearAll) {
                $to_char = 'YYYY';
            }
            $select[] = "to_char(op_date,'{$to_char}') as _day";
            $group = " GROUP BY to_char(op_date,'{$to_char}') ORDER BY to_char(op_date,'{$to_char}')";
        } else {
            $select[] = "extract(day from op_date) as _day";
            $group = " GROUP BY _day ORDER BY  _day";
        }
    }
    if ($is_konkurs) {
        $contestOpCodes = new_projects::getContestOpCodes();
        $contestOpCodesSql = implode(',', $contestOpCodes);
        $query[] = "ac.op_code IN ({$contestOpCodesSql}) ";
        if ($is_bonus) {
            $query[] = "ac.bonus_ammount <> 0";
        } else {
            $query[] = "ac.bonus_ammount = 0";
        }
    } else {
        if ($is_bonus) {
            $query[] = "ac.op_code = 54";
        } else {
            $query[] = "ac.op_code IN (8,53)";
        }
    }
    $select_str = implode(", ", $select);
    $query_str = implode(" AND ", $query);
    if ($type === '') {
        $sql = "SELECT \n                    {$select_str}\n                FROM \n                    account_operations as ac \n                    INNER JOIN account ON account.id=ac.billing_id AND NOT (op_date >= '2011-01-01' AND account.uid IN (SELECT uid FROM users WHERE ignore_in_stats = TRUE))\n                WHERE \n                    op_date >= '{$from_date}'::date AND op_date < '{$to_date}'::date+'1 day'::interval AND {$query_str} {$group};";
    } else {
        $sql = "SELECT \n                    {$select_str}\n                FROM projects_payments as p \n                    INNER JOIN projects prj ON prj.id = p.project_id\n                    INNER JOIN account_operations as ac ON p.opid=ac.id \n                    {$ignore_str}\n                    WHERE ac.op_date >= '{$from_date}'::date AND ac.op_date < '{$to_date}'::date+'1 day'::interval AND {$query_str} {$group};";
    }
    return $DB->rows($sql);
}
Exemplo n.º 3
0
 /**
  * Взять данные для истории по периоду (новый личный счет)
  *
  * @see  class page_bill
  * 
  * @param string  $sdate 	Дата начало периода
  * @param string  $edate 	Дата окончание периода
  * @param integer $sort  	Тип сортировки (1,2 - сортировка по дате; 3,4 - сортировка по коду операции (op_codes); 5,6 - сортировка по сумме) по умолчанию сортировка по дате
  * @param string  $type  	Доп переменная для фильтровки результатов, по умолчанию false @see page_bill::historyAction() 
  * @param integer $page  	Страница выборки
  * @param integer $pages 	Возвращает количество страниц 
  * @param integer $total 	Возвращает количество данных выборки
  * @param integer $count 	Число показа данных на странице
  * @return array 			Данные выборки
  */
 function searchBillHistory($sdate, $edate, $sort, $type = false, $page = 1, &$pages, &$total, $count = 10)
 {
     global $DB;
     $uid = get_uid(false);
     switch ($sort) {
         case 1:
             $sort = "op_date DESC";
             break;
         case 2:
             $sort = "op_date ASC";
             break;
         case 3:
             $sort = "op_code DESC";
             break;
         case 4:
             $sort = "op_code ASC";
         case 5:
             $sort = "ammount DESC";
             break;
         case 6:
             $sort = "ammount ASC";
             break;
         default:
             $sort = "op_date DESC";
             break;
     }
     $page--;
     if ($page < 0) {
         $page = 0;
     }
     $page_sql = $page * $count;
     $limit = $count ? "LIMIT {$count} OFFSET {$page_sql}" : '';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/sbr.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php';
     $opCodes = new_projects::getContestOpCodes();
     $opCodesSql = implode(',', $opCodes);
     // op_code <> 77 СБР не выводим тк деньги через ЛС не проходят #0020554
     $sql = "SELECT op_date, op_name, ammount, comments, op_code, account_operations.id, round(balance,2) as balance, trs_sum, payment_sys, p.id as project_id\n                FROM account_operations\n\t\t\t\tLEFT JOIN account ON account.id=account_operations.billing_id\n\t\t\t\tLEFT JOIN op_codes on op_code=op_codes.id LEFT JOIN account_operations_blocked ob ON ob.operation_id = account_operations.id \n                LEFT JOIN projects p\n                    ON op_code IN ({$opCodesSql}) AND account_operations.id = p.billing_id\n                WHERE ( op_code IN (" . sbr::OP_RESERVE . ", " . sbr::OP_CREDIT . ", " . sbr::OP_DEBIT . ") AND ammount = 0 ) = false AND  ob.id IS NULL AND uid='{$uid}' AND op_date <= '" . date('c', $edate) . "' AND op_date >= '" . date('c', $sdate) . "' " . ($type != false ? $type : '') . " ORDER BY {$sort} {$limit}";
     $sql_total_page = "SELECT COUNT(*) as total FROM account_operations LEFT JOIN account ON account.id=account_operations.billing_id LEFT JOIN op_codes on op_code=op_codes.id \n                            WHERE ( op_code IN (" . sbr::OP_RESERVE . ", " . sbr::OP_CREDIT . ", " . sbr::OP_DEBIT . ") AND ammount = 0 ) = false AND uid='{$uid}' AND op_date <= '" . date('c', $edate) . "' AND op_date >= '" . date('c', $sdate) . "' " . ($type != false ? $type : '');
     $total = $DB->val($sql_total_page);
     $pages = $count ? ceil($total / $count) : 1;
     /*} else {
     			$sql = "SELECT op_date, op_name, ammount, comments, op_code, account_operations.id FROM account_operations
     				LEFT JOIN account ON account.id=account_operations.billing_id
     				LEFT JOIN op_codes on op_code=op_codes.id WHERE uid='$uid' AND op_date <= '".date('c', $edate)."' AND op_date >= '".date('c', $sdate)."' AND op_code IN(".implode(",", $type).") ORDER BY $sort";
     		}*/
     //echo $sql;
     return $DB->rows($sql);
 }