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

<div class="back">
    <a href="{$site_url}{$site_root}/admin/affiliate/aff_summary.php">{$lang.button.back}</a>
</div>
<div class="cr"></div>
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{$lang.affiliate.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.aff_affiliates}
    </div>
</div>
<div class="cr">&nbsp;</div>

<ul class="tabs" style="width: 100.5%;">
    <li>
        <a href="aff_summary.php">{$lang.aff.tab_1}</a>
    </li>
    <li>
        <a href="aff_sales.php">{$lang.aff.tab_2}</a>
    </li>
	<li>
        <a class="current" href="#">{$lang.aff.tab_3}</a>
    </li>
	<li>
        <a href="aff_ads.php">{$lang.aff.tab_4}</a>
    </li>
	<li>
        <a href="aff_stats.php">{$lang.aff.tab_5}</a>
    </li>
	<li>
        <a href="aff_editsettings.php">{$lang.aff.tab_6}</a>
    </li>
</ul>*}
<div id="aff_affiliates_div">
{literal}

<SCRIPT LANGUAGE="JavaScript">
<!-- //hide
function Profile(id){
   window.open('affiliate/aff_profile.php?id=' + id, 'blank_', 'resizable=yes,scrollbars=yes,location=no,directories=no,status=no,toolbar=no,menubar=no,width=700,height=550,left=0,top=0');
}
//-->
</SCRIPT>

{/literal}

<div class="panel">
	<div class="panel_section">
		<div class="panel_content" style="width:100%;margin:0;padding:0;">

<form method="GET" action="admin_affilate.php" style="margin:0px" name="form1">
	<input type="hidden" name="ref" value="6">
<table border="0" cellspacing="0" cellpadding="5">
<input type="hidden" name="ShowByIp" value="">
<tr>
  <td>
    <a href="affiliate/aff_affiliates_create_new.php">{$lang.affiliate.new_affiliate}</a> | 
	<a href="affiliate/aff_affiliates_send_email.php">{$lang.affiliate.send_email}</a> | 
	{$lang.affiliate.search_ip} <input type="text" name="IP" size="17" style="padding: 1px 4px;">
  </td>
  <td>
	<div class="fl" style="text-align:left;">
		<a href="#" class="admin_button" style="margin:0px;" id="" onclick="javascript:document.form1.submit();">{$lang.button.select}<span>&nbsp;</span></a>
	</div>
  </td>
</tr>
</table>
</form>

<br>

<form action='admin_affilate.php' method='GET' style="margin:0px" name="form2">
	<input type="hidden" name="ref" value="6">
<input type="hidden" name="ShowAffiliates" value="">
<table border="0" cellspacing="0" cellpadding="5">
<tr>
  <td>
    <b>{$lang.affiliate.select_affiliates}</b><br>
	{$lang.affiliate.from} <select name='date1_year'>
		{section name=num loop=$dates_year}
		<option value='{$dates_year[num].values}' {if ($dates_year[num].values == $date1_year)}selected{/if}>{$dates_year[num].names}</option>
		{/section}
	</select> <select name='date1_month'>
		{section name=num loop=$dates_month}
		<option value='{$dates_month[num].values}' {if ($dates_month[num].values == $date1_month)}selected{/if}>{$dates_month[num].names}</option>
		{/section}
	</select> <select name='date1_day'>
		{section name=num loop=$dates_day}
		<option value='{$dates_day[num].values}' {if ($dates_day[num].values == $date1_day)}selected{/if}>{$dates_day[num].names}</option>
		{/section}
	</select>
	{$lang.affiliate.to} <select name='date2_year'>
		{section name=num loop=$dates_year}
		<option value='{$dates_year[num].values}' {if ($dates_year[num].values == $date2_year)}selected{/if}>{$dates_year[num].names}</option>
		{/section}
	</select> <select name='date2_month'>
		{section name=num loop=$dates_month}
		<option value='{$dates_month[num].values}' {if ($dates_month[num].values == $date2_month)}selected{/if}>{$dates_month[num].names}</option>
		{/section}
	</select> <select name='date2_day'>
		{section name=num loop=$dates_day}
		<option value='{$dates_day[num].values}' {if ($dates_day[num].values == $date2_day)}selected{/if}>{$dates_day[num].names}</option>
		{/section}
	</select>
	{$lang.affiliate.order} <select name="orderby">
		<option value="DateAscending">{$lang.affiliate.date} {$lang.affiliate.asc}
		<option value="DateDescending">{$lang.affiliate.date} {$lang.affiliate.desc}
		<option value="Username">{$lang.affiliate.username}
		<option value="FullName">{$lang.affiliate.full_name}
	</select>
  </td>
  <td valign="bottom">
	<div class="fl" style="text-align:left;">
		<a href="#" class="admin_button" style="margin:0px;" id="" onclick="javascript:document.form2.submit();">{$lang.button.select}<span>&nbsp;</span></a>
	</div>
  </td>
</tr>
</table>
</form>

{if ($affiliates)}

<br>

{if $page_links}
<b>{$lang.affiliate.pages}:</b>
{section name=c loop=$page_links}
	<a href={$page_links[c].url}>{$page_links[c].text}</a>&nbsp;
{/section}
<br><br>
{/if}
<div id="tooltip" onclick="hideToolTip()" style="text-align:center; background-color: #FFFFFF; border: 1px dotted; text-align: {$default_left}; position:absolute; display:none; padding:5px;"></div>
{literal}
<script type="text/javascript">
$(function() {
$('#tool_tip_4 *').tooltip();
});
</script>
{/literal}

<table border="0" cellspacing="0" cellpadding="5" width="100%">
<tr class="table_header">
  <td width="5%">#</td>
  <td width="10%" onclick="document.location.href='admin_affilate.php?ref=6&ShowAffiliates=&date1_year={$date1_year}&date1_month={$date1_month}&date1_day={$date1_day}&date2_year={$date2_year}&date2_month={$date2_month}&date2_day={$date2_day}&orderby=Username&asc={if $asc eq '1'}2{elseif $asc ne '1'}1{/if}'">{$lang.affiliate.username}</td>
  <td width="15%" nowrap="nowrap" onclick="document.location.href='admin_affilate.php?ref=6&ShowAffiliates=&date1_year={$date1_year}&date1_month={$date1_month}&date1_day={$date1_day}&date2_year={$date2_year}&date2_month={$date2_month}&date2_day={$date2_day}&orderby=FullName&asc={if $asc eq '1'}2{elseif $asc ne '1'}1{/if}'">{$lang.affiliate.full_name}</td>
  <td width="10%" nowrap="nowrap">{$lang.affiliate.signup_date}</td>
  <!--<td width="10%" nowrap="nowrap">{$lang.affiliate.due}</td> -->
  <td width="10%" nowrap="nowrap">{$lang.affiliate.paid_out}</td>
  <td width="15%" nowrap="nowrap">{$lang.affiliate.last_payout}</td>
  <td width="9%" nowrap="nowrap">{$lang.affiliate.to_be_paid}</td>
  <td width="14%" nowrap="nowrap">{$lang.affiliate.last_payment_date}</td>
  <td width="12%" align="right">{$lang.button.action}</td>
</tr>

{section name=num loop=$affiliates}
<tr {if $smarty.section.num.index mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if} height="27px">
  <td valign="top">{$smarty.section.num.iteration}</td>
  <td valign="top"><a href="javascript:Profile('{$affiliates[num].id}')">{$affiliates[num].login}</a>&nbsp;</td>
  <td valign="top">{$affiliates[num].fullname}&nbsp;</td>
  <td valign="top">{$affiliates[num].date}</td>
  <!--<td valign="top">{$affiliates[num].due} {$costunit}</td> -->
  <td valign="top">{$affiliates[num].out} {$costunit}</td>
  <td valign="top">{$affiliates[num].last}</td>
  <td id="to_be_paid_td{$affiliates[num].id}" valign="top">{$affiliates[num].to_be_paid} {$costunit}</td>
  <td id="last_payment_date_td{$affiliates[num].id}" valign="top">{$affiliates[num].last_payment_date}</td>
  <td nowrap="nowrap">
  	{if $affiliates[num].to_be_paid > 0}
		<a class="fl" id="paid_link{$affiliates[num].id}" href="#" onclick="javascript: paidOfAction({$affiliates[num].id});">{$lang.affiliate.paid_of}</a>
	{/if}
	<div class="block_action fr" style="display: none;padding-left:10px;">
		<!-- subscr_form -->
		<div class="action_edit" style="display: block;float:left;">
			<img width="16" alt="" src="{$site_root}{$template_root}/images/edit.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.edit}');return false" onclick="document.location='affiliate/aff_affiliates_create_new.php?which={$affiliates[num].id}'">
		</div>
		<div style="width:10px;" class="fl">&nbsp;</div>
		<div class="action_edit" style="display: block;float:left;">
			<img width="16" alt="" src="{$site_root}{$template_root}/images/photo_delete.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.delete}');return false" onclick="document.location='affiliate/aff_affiliates.php?action=Delete&which={$affiliates[num].id}&QueryString=ShowAffiliates%3DSelect%26date1_year%3D1993%26date1_month%3D1%26date1_day%3D1%26date2_year%3D2003%26date2_month%3D4%26date2_day%3D16%26orderby%3DDateAscending%26status%3Dall'">
		</div>
	</div>
	<div id="data_div{$affiliates[num].id}" style="display:none;"></div>
	</td>
</tr>
{sectionelse}

<tr>
    <td align=center colspan="10">{$lang.affiliate.no_affiliates}</td>
</tr>

{/section}
                    <tr class="table_header">
                        <td colspan="10">
                            &nbsp;&nbsp;
                            {if $links}
                            {foreach item=item from=$links.pages}
                                &nbsp;<a onclick="PageList('aff_affiliates_div', '{$item.link}');" class="page_link" {if $item.selected} style=" font-weight: bold; text-decoration: none;" {/if}>{$item.name}</a>&nbsp;
                            {/foreach}
                            {/if}
                            <div class="page_navigation">
                            {if $links.previous}
                                <a onclick="PageList('aff_affiliates_div', '{$links.previous}');">< {$lang.content.previous} {$per_page}</a>
                            {/if}
                            {if $links.next}
                                <a onclick="PageList('aff_affiliates_div', '{$links.next}');">{$lang.content.next} {$per_page} ></a>
                            {/if}
                            </div>
                        </td>
                    </tr>

</table>
<script type="text/javascript">
{literal}
		function showToolTip(e,text){
			if(document.all)e = event;
			var obj = document.getElementById('tooltip');
			obj.innerHTML = text;
			obj.style.display = 'block';
			var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
			if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0;
			var leftPos = e.clientX - $('#tooltip').width()-10;
			if(leftPos<0)leftPos = 0;
			obj.style.left = leftPos + 'px';
			obj.style.top = e.clientY - obj.offsetHeight -10 + st + 'px';
		}
		function hideToolTip(){
			document.getElementById('tooltip').style.display = 'none';
		}
{/literal}		
</script>

{/if}

		</div>
	</div>
</div>

<script type="text/javascript">
{literal}
function paidOfAction(id_aff){
	to_be_paid_obj = getById('to_be_paid_td'+id_aff);
	last_payment_date_obj = getById('last_payment_date_td'+id_aff);
	paid_link_obj = getById('paid_link'+id_aff);
	
	old_to_be_paid_value = to_be_paid_obj.innerHTML;
	old_last_payment_date_value = last_payment_date_obj.innerHTML;
	
	data_div_obj = getById('data_div'+id_aff);
	
	to_be_paid_obj.innerHTML = '0.00 {/literal}{$costunit}{literal}';
	last_payment_date_obj.innerHTML = '...';
	
	//file_name = '{/literal}{$file_name}{literal}';
	file_name = 'admin_affilate.php';
	str = 'ref=6&sel=reset_to_be_paid&id_aff='+id_aff;
	
	destination_odj = data_div_obj;
	tmp_text = '..';
	anisochronous = false;
	runJS = false;
	
	ajaxRequest(file_name, str, destination_odj, tmp_text, anisochronous, runJS);
	
	error_obj = getById('id_error');
	error = error_obj.innerHTML;
	
	last_payment_date_data_obj = getById('last_payment_date_data');
	text_data_obj = getById('text_data');
	if (error == '0'){
		last_payment_date_obj.innerHTML = last_payment_date_data_obj.innerHTML;
		paid_link_obj.style.display = 'none';
	}else{
		to_be_paid_obj.innerHTML = old_to_be_paid_value
		last_payment_date_obj.innerHTML = old_last_payment_date_value;
	}
//	to_be_paid_obj.innerHTML = text_data_obj.innerHTML+'<br />'+old_to_be_paid_obj.innerHTML;
	alert(text_data_obj.innerHTML);
}
function getById(name){
	return document.getElementById(name);
}
    function PageList(id_div, par) {
        ajaxLoadingImage(1, 'aff_affiliates_div');
        $.post("affilate/aff_affiliates.php", par, function(data){
            ajaxLoadingImage(0, 'aff_affiliates_div');
            $('#aff_affiliates_div').html(data);
        });
    }

{/literal}
</script>
</div>
{*{include file="$admingentemplates/admin_bottom.tpl"}*}
