{include file="$admingentemplates/admin_top.tpl"}
<div class="error_message"></div>
<div class="cr"></div>
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{$lang.pays.razdel_name}</div>
<div class="cr">&nbsp;</div>
<div class="cr">&nbsp;</div>
<div class="help_text" style="display:block;">
    <div class="close_help">
        <img src="{$site_root}{$template_root}/images/close_help.png" alt="">
    </div>
    <div class="help_body">
        <span class="help_title">{$lang.help}:</span>{$lang.admin_help.billing}
    </div>
</div>
<ul class="tabs">
    <li>
        <a {if $info.active == "history"} class="current" {else} href="admin_pays.php"  {/if}>{$lang.pays.history} </a>
    </li>
    <li>
        <a {if $info.active == "offline"} class="current" {else} href="admin_pays.php?sel=approve" {/if}>{$lang.pays.offline}</a>
    </li>    
</ul>
<div class="user_operation_line">
            <div class="uol_item" >
				<div class="uol_in_item" onclick="AddFunds()">{$lang.voip.add_founds}</div>
            </div>
            <div class="uol_item" onclick="SendMessage()">
                <div class="uol_in_item">{$lang.pays.send_message}</div>
            </div>                             
</div>
<div class="cr"></div>

<div style="overflow:hidden;float:left;width:100%;">
<div style="float: right;"  width="100%">
<input type=hidden name="sorter" value="{$sorter}">
					<table><tr>
					<form name="search_form" action="{$form.action}" method="post">
					<td class="main_content_text" ><input type="text" name="search" value="{$search}"></td>
					<td class="main_content_text" ><select name="s_type" style="">
					{section name=s loop=$types}
					<option value="{$smarty.section.s.index_next}" {if $types[s].sel}selected{/if}>{$types[s].value}</option>
					{/section}
					</select></td>
					<td class="main_content_text"><a class="admin_button btn_upload" onclick="javascript: document.search_form.submit();" name="search_submit">{$lang.button.search}<span>&nbsp;</span></a></td>
					</form>
					</tr></table>
</div>	
</div>	
<div>
<div style="float: left;">
    <b>{$lang.pays.total_payments}:&nbsp;<font>{$payment_stat.total_payment}</font>&nbsp;{$form.costunits}</b><br />    
    <b>{$lang.pays.user_accounts}:&nbsp;<font>{$payment_stat.users_accounts}</font>&nbsp;{$form.costunits}</b>
</div>
<div style="margin-top: 10px;float:right;" align="right">
    <select name="pays_numpage" onchange="NumUsers(); return false;">                        
                        <option value="10" {if $pays_numpage eq 10} selected {/if}>10 {$lang.button.users}</option>
                        <option value="30" {if $pays_numpage eq 30} selected {/if}>30 {$lang.button.users}</option>
                        <option value="50" {if $pays_numpage eq 50} selected {/if}>50 {$lang.button.users}</option>
                        <option value="100" {if $pays_numpage eq 100} selected {/if}>100 {$lang.button.users}</option>
                    </select>
</div>	
</div>	

<div id="pays" style="float: left; width: 100%; margin-top: 20px;">
			{include file = "$admingentemplates/admin_billing_users_content_table.tpl"}
</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>
{include file="$admingentemplates/admin_bottom.tpl"}

<script type="text/javascript">       
{literal}
function AddFunds(){
    var mas=[]
    var i=0
    $('input[name=delete]:checked').each(function(){
        mas[i] = $(this).val()   
        i++    
    });
    if (mas == ""){
        $(".error_message").html("{/literal}{$lang.pays.add_users_for_add_funds}{literal}");
        $(".error_message").fadeIn(500);
        setTimeout('$(".error_message").fadeOut(500);', 5000);  
    }else{
        WindowShow(mas);
    }
}

function WindowShow(par) {
	//var id = '#dialog';
	
		//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});
		
		//transition effect		
		$('#mask').fadeIn(500);	
		$('#mask').fadeTo("fast",0.8);	
	
		//Get the window height and width
		var winH = $(document).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);
        $('#close').fadeIn(500);
                
        var par = 'sel=add_billing&id='+par
	
	$.ajax({
  		type: "POST",
  		url: "admin_pays.php",        
		data: (par),
		success: function(data){
			$('#dialog').html(data);
            $('#dialog').fadeIn(500); 
		}
	});
	//transition effect
}

function Close(){
    $('#mask').fadeOut(500);
    $('#close').fadeOut(500)
    $('#dialog').fadeOut(500)	
}

function PutAll() {
         var o=document.getElementsByName('select_all')	
         var i
         if (o[0].checked){                    
            o=document.getElementsByName('delete')
            for (i=0; i<o.length; i++){                
                o[i].checked = true
            }            
         }
         else{
            o=document.getElementsByName('delete')
            for (i=0; i<o.length; i++){                
                o[i].checked = false
            }            
         }             
}
function PageList(id_div, par) {
        ajaxLoadingImage(1, 'pays');
        $.post("admin_pays.php", par, function(data){
            ajaxLoadingImage(0, 'pays');
            $('#pays').html(data);
        });
    }

function NumUsers(){
    num_users = $("select[name=pays_numpage]").val();    
    ajaxLoadingImage(1, 'pays');
    $.ajax({
        type: "POST",
        dataType: "text",
        data: 'pays_numpage='+num_users+'&ajax=1',
        url: "admin_pays.php",
        success: function(data){
            ajaxLoadingImage(0, 'pays');
            $('#pays').html(data);
        }
    })
}
function SendMessage(){
    var i=0
    var mas_id = []
    $('input[name=delete]:checked').each(function(){
        mas_id[i] = $(this).val()   
        i++       
     });   
    if (mas_id.length >0){
        var NewWindows = window.open('{/literal}{$info.comunicate}?id={literal}'+mas_id+'&commit=1','comunicate', 'height=800, resizable=yes, scrollbars=yes,width=600, menubar=no,status=no');   
    } 
    
}
{/literal}
</script>