{include file="$admingentemplates/admin_top.tpl"}

<div class="cur_v">
    &nbsp;
</div>
<div>

</div>

<div class="page_header">
	<div class="fl">{$welcome_str}</div>
</div>
<div class="cr">&nbsp;</div>
<div class="cr">&nbsp;</div>
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="help_text fl" style="">
	 <div class="close_help">
		<img src="{$site_root}{$template_root}/images/close_help.png" alt="">
	</div>		
	<div class="help_body">
		<p class="page_header_help">{$lang.admin_index.manage_tips}</p>
		<p style="color:#000000;margin-left:10px;">{$lang.admin_index.notice}</p>
		<div style="margin-left:30px;margin-top:-10px;">
			<div style="float:left;width:50%;">
				{foreach from=$lang.admin_index.first_steps key=key item=item name=help}
				{if $key eq ($smarty.foreach.help.total/2|ceil)+1}
				</div>
				<div style="float:left;width:50%;">
				{/if}			
				<p>{$item}</p>
				
				{/foreach}
			</div>
		</div>
	</div>
	<div class="cr"></div>
</div>
<div class="cr"></div>
<div class="hp_box">
    <!--general stats-->
    <table width="100%" cellspacing="0" cellpadding="8" border="0">
        <tr class="hp_table_title">
            <td colspan="2">{$lang.index.list}</td>
	</tr>
	<tr class="hp_table_subtitle">
            <td class="border_top">{$lang.index.stat_all}</td>
            <td class="border_top" align="right">{$form.stat_all}</td>
	</tr>
	{foreach from=$form.stat_gender item=item name=statgender}
	<tr class="{if $smarty.foreach.statgender.index % 2 == 1}odd{else}even{/if}">
            <td class="border_top"><strong>{$item.gender}</strong>&nbsp;{$header.gender_stat}:</td>
            <td class="border_top" align="right">{$item.count}</td>
	</tr>
	{/foreach}
	<tr class="odd">
            <td class="border_top">{$lang.index.stat_active}</td>
            <td class="border_top" align="right">{$form.stat_active}</td>
	</tr>
	<tr class="even">
            <td class="border_top">{$lang.index.stat_chat}</td>
            <td class="border_top" align="right">{$form.stat_chat}</td>
	</tr>
	<tr class="odd">
            <td class="border_top">{$lang.index.stat_reg_today}</td>
            <td class="border_top" align="right">{$form.stat_reg_today}</td>
	</tr>
	<tr class="even">
            <td class="border_top">{$lang.index.stat_last_week}</td>
            <td class="border_top" align="right">{$form.stat_last_week}</td>
	</tr>
        <tr class="odd">
            <td class="border_top">{$lang.index.stat_last_month}</td>
            <td class="border_top" align="right">{$form.stat_last_month}</td>
	</tr>
	<tr class="even">
            <td class="border_top">{$lang.index.stat_most_active}</td>
            <td class="border_top" align="right">{$form.stat_most_active}</td>
	</tr>
	<tr class="odd">
            <td class="border_top">{$lang.index.stat_most_popular}</td>
            <td class="border_top" align="right">{$form.stat_most_popular}</td>
	</tr>
	<tr class="even">
            <td class="border_top">{$lang.index.stat_most_popular_module}</td>
            <td class="border_top" align="right">{$form.stat_most_popular_module}</td>
	</tr>
	<tr class="odd">
            <td class="border_top">{$lang.index.stat_not_seen_module}</td>
            <td class="border_top" align="right">{$form.stat_not_seen_module}</td>
	</tr>
    </table>
		<!--/general stats-->
</div>
<div class="hp_box">
	<!--Object moderation-->
{*	{if $approove_items}*}
    <table width="100%" cellspacing="0" cellpadding="8" border="0">
        <tr class="hp_table_title">
            <td colspan="2">{$lang.admin_menu.object_moderation}</td>
	</tr>
	{foreach from=$approove_items item=item name=foor}
	<tr class="{if $smarty.foreach.foor.iteration % 2 == 1}odd{else}even{/if}">
            <td class="border_top">{$item.name}:</td>
            <td class="border_top" align="right">{if $item.count!=0}<a href="{$item.link}">{$item.count}</a>{else}{$item.count}{/if}</td>
	</tr>
	{/foreach}
    </table> 
{*	{/if}*}
	<!--/Object moderation-->	
</div>
<div class="cr"> &nbsp; </div>
<div class="hp_box">
    <!--payment_stats-->
    <table width="100%" cellspacing="0" cellpadding="8" border="0">
        <tr class="hp_table_title">
            <td class="border_top" style="padding-top: 6px; padding-bottom: 6px;">
                {$lang.admin_index.payment_stats}&nbsp;
				<select name="entry_period" onchange="countPayments();">
                    <option value="year">{$lang.button.all}</option>
                    {foreach from=$payment_stat_period item=_period key=name_period}
                        <option value="{$_period}" {if $select_payment_stat_period eq $_period} selected {/if}> {$header[$_period]} </option>
                    {/foreach}
                </select>
            </td>
		</tr>
    </table>
    <div id="payment_stats">
    </div>
    <!--/payment_stats-->
</div>
<div class="hp_box">
    <!--plot-->
    <table width="100%" cellspacing="0" cellpadding="8" border="0">
        <tr class="hp_table_title">
            <td class="border_top">{$lang.admin_index.plot}</td>
        </tr>
        <tr>
            <td class="border_top" style="padding:10px; text-align: left;">
            <div id="diagramm" style="height:320px; width:370px;"></div>
            </td>
        </tr>
    </table>
    <!--/plot-->
</div>
<div class="cr">&nbsp;</div>
<link href="{$site_root}{$template_root}/css/alert.css" rel="stylesheet" type="text/css"/>
<div id="boxes">
	<div id="close" class="close" onclick="Close()"></div>
	<div id="dialog" class="window">
	</div>
</div>
<div id="mask"></div>
{if $first_in_admin}
<script type="text/javascript">
{literal}
$(document).ready(function(){
    //Get the screen height and width
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();

	//Set heigth and width to mask to fill up the whole screen
	$('#mask').css({'width':maskWidth,'height':maskHeight});
	
	//Get the window height and width
	var winH = $(window).height();
	var winW = $(window).width();
		  
	//Set the popup window to center
	$('#dialog').css('top',  winH/2-$('#dialog').height()/2);
	$('#dialog').css('left', winW/2-$('#dialog').width()/2);
	$('#close').css('top',  winH/2-$('#dialog').height()/2+9);
	$('#close').css('left', winW/2+$('#dialog').width()/2-25);        

	//transition effect		
	$('#mask').fadeIn(500);	
	$('#mask').fadeTo("fast",0.8);
	$('#dialog').html("<div style=\"width: 380px; margin-left: 30px; margin-top: 30px;\">{/literal}{$lang.admin_settings.smtp_settings}{literal}</div>");
	$('#dialog').fadeIn(500);
	$('#close').fadeIn(500); 
    
})

function Close(){
    $('#mask').fadeOut(500);
    $('#close').fadeOut(500)
    $('#dialog').fadeOut(500)	
}
{/literal}
</script>
{/if}

<script language="JavaScript" type="text/javascript">
	{if $articles}
	{literal}
	rC = new DHTMLgoodies_roundedCorners();
	rC.addTarget('pilot_content',10,10,'#eeeeee','#FFFFFF',0,false,'top_right,top_left,bottom_right,bottom_left');
	rC.init();
	{/literal}
	{/if}
	{literal}
	$(document).ready(function(){
		getPilotContent();
	});
		countPayments();
		//countUsers();
	function getPilotContent(){
		//ajaxLoadingImage(1,'pilot_content');
		var str = "sel=pilotContent";
		var filename = "index.php?language_code={/literal}{$lang_code}{literal}";
		$.post(filename,str,function(resp){
			//ajaxLoadingImage(0,'pilot_content');
			$("#pilot_content").html(resp);
		});
	}

	function countPayments(){
		var id_container = "payment_stats";
		ajaxLoadingImage(1, id_container);
		period = $("select[name=entry_period]").val();
		service = $("select[name=service]").val();
		str = "ajax=1&sel=get_payment_stats&period="+period+"&service="+service;
		$.post("../backend.php?language_code={/literal}{$lang_code}{literal}",str,function(data){
			ajaxLoadingImage(0, id_container);
			$("#"+id_container).html(data);
			getPaymentDiagrammData();
		});
	}

	function countUsers(){
		var id_container = 'result';
		ajaxLoadingImage(1, id_container);
		str='ajax=1&sel=get_users_ids'
		$("#search_form select").each(function(i){
			if ($(this).val()>0){
				str+='&'+$(this).attr('name')+'='+$(this).val();
			}
		});

		zip_code1 = $("#search_form input[name=zip_code]").val();

		if (zip_code1 != ''){
			str+="&zip_code="+zip_code1;
		}
		reg_period1 = $("select[name=reg_period]").val();
		if (reg_period1!=0){
			str+='&reg_period='+reg_period1;
		}
		$.post("../backend.php?language_code={/literal}{$lang_code}{literal}",str,function(data){
			ajaxLoadingImage(0, id_container);
			$("#"+id_container).html(data);
		});
	}

        function getPaymentServiceStats(){
            var id_container = "payment_service_stats";
            ajaxLoadingImage(1, id_container);
            period = $("select[name=entry_period]").val();
            service1 = $("select[name=service]").val();
            str = "ajax=1&sel=get_payment_service_stats&period="+period+"&service="+service1;
            $.post("../backend.php?language_code={/literal}{$lang_code}{literal}", str, function(data){
            	ajaxLoadingImage(0, id_container);
				$("#"+id_container).text(data);
                getPaymentDiagrammData();
            })
        }

	function getPaymentDiagrammData(){
		var id_container = "diagramm";
		ajaxLoadingImage(1, id_container);
		period = $("select[name=entry_period]").val();
		service = $("select[name=service]").val();
		str = "ajax=1&sel=get_payment_diagramm_data&period="+period+"&service="+service;
		$.post("../backend.php?language_code={/literal}{$lang_code}{literal}",str,function(data){
			$('#'+id_container).html('');
			ajaxLoadingImage(0, id_container);
			resp = getJQData(data);
			drawDiagramm(id_container, resp['title'], [resp['data']], resp['x_label'], resp['y_label'], resp['x_ticks']);
		});

	}

function drawDiagramm(id_continer, title, data, x_label, y_label, x_ticks){
    opts = {
        title: title,
        series:[{showMarker:true}],
	axes:{
            xaxis:{
                label:x_label,
		ticks: x_ticks,
		autoscale: false,
		labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
                    labelOptions: {
						  enableFontSupport: true,
						  fontFamily: 'Georgia',
						  fontSize: '12pt'
						}
					},
					yaxis:{
						min:0,
						label:y_label,
						autoscale: false,
						labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
						labelOptions: {
						  enableFontSupport: true,
						  fontFamily: 'Georgia',
						  fontSize: '12pt'
						}
					}
				}
			   };
		  $.jqplot(id_continer, data, opts);
}
	
</script>

{/literal}
{include file="$admingentemplates/admin_bottom.tpl"}