<? require_once($_SERVER['DOCUMENT_ROOT'].'/block/head.php');?>
<style>
#chartdiv {
	width	: 100%;
	height	: 400px;
}	
</style>

<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="panel-title-box">
<h3>График платежей нашего сайта</h3>
<span>график предоставлен за последний год работы проекта</span>
</div>
<ul class="panel-controls" style="margin-top: 2px;">
<li data-toggle="tooltip" title='Обновить'><a href="#" class="panel-refresh"><span class="fa fa-refresh"></span></a></li>
<li data-toggle="tooltip" title='Свернуть блок'><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
<li data-toggle="tooltip" title='Скрыть блок'><a href="#" class="panel-remove"><span class="fa fa-times"></span></a></li>
</ul>
</div>
<div class="panel-body">
<div id="chartdiv"></div>
</div>
</div>
</div>

<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="panel-title-box">
<h3>Направления выплат</h3>
<span>последние 20 выплат проекта и их направления</span>
</div>
</div>
<table class="table table-bordered">
<tbody>
<?
$sql = mysql_query("SELECT `id_user`,`ps`,`koshel`,`summa`,`time` FROM `nano_out_money` WHERE `status`='2' ORDER BY `id` DESC LIMIT 20"); 
while ($res = mysql_fetch_array($sql)){
$user_out = get_us_name($res["id_user"]);
$login_out = $res["id_user"];
$ps_out = $res["ps"];
$koshel_out = $res["koshel"];
$summa_out = $res["summa"];
$time_out = date_get($res["time"]);
$id_user = prof_url($login_out, $id_login);
switch($ps_out){
case 'wm': $ps = "<span style='color:#067BC1;'>WebMoney</span>";break;
case 'ym': $ps = "<span><font color='#FA1B0E'>Y</font>andexMoney</span>";break;
case 'pr': $ps = "<span>Pay<font color='#2795D1'>eer</font></span>";break;
}
?>
<tr>
<td style="width: 15%"><center><?=$time_out;?></center></td>
<td><?=$user_out;?>  [ id: <a href='/profil<?=$id_user;?>' style="text-decoration: none; cursor: pointer;"><?=$login_out;?></a> ]</td>
<td style="width: 10%"><center><?=$summa_out;?> Руб.</center></td>
<td style="width: 18%"><center><?=$ps;?></center></td>
</tr>
<?}?>
</tbody>
</table>
<div class="panel-footer">
<a <?if(!isset($_SESSION["login"]) && !isset($_SESSION["pass"])) {?>href="/register"<?}else{?>href="/money"<?}?> class="btn btn-primary btn-block">Получить выплату</a>
</div>
</div>
</div>
</div>

<script>
var chart = AmCharts.makeChart("chartdiv", {
    "type": "serial",
    "theme": "light",
    "marginRight": 10,
    "marginLeft": 40,
    "autoMarginOffset": 20,
    "dataDateFormat": "YYYY-MM-DD",
    "valueAxes": [{
        "id": "v1",
        "axisAlpha": 0,
        "position": "left",
        "ignoreAxisWidth":true
    }],
    "balloon": {
        "borderThickness": 1,
        "shadowAlpha": 0
    },
    "graphs": [{
        "id": "g1",
        "balloon":{
          "drop":true,
          "adjustBorderColor":false,
          "color":"#ffffff"
        },
        "bullet": "round",
        "bulletBorderAlpha": 1,
        "bulletColor": "#FFFFFF",
        "bulletSize": 5,
        "hideBulletsCount": 50,
        "lineThickness": 2,
        "title": "red line",
        "useLineColorForBulletBorder": true,
        "valueField": "value",
        "balloonText": "<span style='font-size:18px;'>[[value]] руб.</span>"
    }],
    "chartScrollbar": {
        "graph": "g1",
        "oppositeAxis":false,
        "offset":30,
        "scrollbarHeight": 80,
        "backgroundAlpha": 0,
        "selectedBackgroundAlpha": 0.1,
        "selectedBackgroundColor": "#888888",
        "graphFillAlpha": 0,
        "graphLineAlpha": 0.5,
        "selectedGraphFillAlpha": 0,
        "selectedGraphLineAlpha": 1,
        "autoGridCount":true,
        "color":"#AAAAAA"
    },
    "chartCursor": {
        "pan": true,
        "valueLineEnabled": true,
        "valueLineBalloonEnabled": true,
        "cursorAlpha":1,
        "cursorColor":"#258cbb",
        "limitToGraph":"g1",
        "valueLineAlpha":0.2
    },
    "valueScrollbar":{
      "oppositeAxis":false,
      "offset":50,
      "scrollbarHeight":10
    },
    "categoryField": "date",
    "categoryAxis": {
        "parseDates": true,
        "dashLength": 1,
        "minorGridEnabled": true
    },
    "export": {
        "enabled": true
    },
    "dataProvider": [
<?
$sql = mysql_query("SELECT `summ`,`time` FROM `nano_out_money_all` ORDER BY `id` ASC LIMIT 365"); 
while ($res = mysql_fetch_array($sql)){
$summ_outs = $res["summ"];
$time_outs = $res["time"];
?>
	{
        "date": "<?=$time_outs;?>",
        "value": <?=$summ_outs;?>
    },
<?}?>
	]
});

chart.addListener("rendered", zoomChart);

zoomChart();

function zoomChart() {
    chart.zoomToIndexes(chart.dataProvider.length - 40, chart.dataProvider.length - 1);
}
</script>
<?require_once($_SERVER['DOCUMENT_ROOT'].'/block/foot.php'); ?>