PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/accounts.php

https://github.com/intelliants/elitius
PHP | 308 lines | 262 code | 26 blank | 20 comment | 9 complexity | 3b46e36cb18d89bd7d973f0aa49db580 MD5 | raw file
  1<?php
  2/***************************************************************************
  3 *
  4 *	 PROJECT: eLitius Open Source Affiliate Software
  5 *	 VERSION: 1.0
  6 *	 LISENSE: GNU GPL (http://www.opensource.org/licenses/gpl-license.html)
  7 *
  8 *   This program is free software; you can redistribute it and/or modify
  9 *   it under the terms of the GNU General Public License as published by
 10 *   the Free Software Foundation.
 11 *
 12 *   Link to eLitius.com can not be removed from the software pages without
 13 *	 permission of the eLitius respective owners. It is the only requirement
 14 *	 for using this software.
 15 *
 16 *   Copyright 2009 Intelliants LLC
 17 *   http://www.intelliants.com/
 18 *
 19 ***************************************************************************/
 20
 21require_once('./init.php');
 22
 23$gPage = $gXpLang['account_manager'];
 24$gPath = 'account-manager';
 25$gDesc = $gXpLang['manage_accounts'];
 26
 27$buttons = array(0 => array('name'=>'create','img'=> $gXpConfig['xpurl'].'admin/images/new_f2.gif', 'text' => $gXpLang['create']));
 28
 29require_once('header.php');
 30
 31switch($_GET['sgn'])
 32{
 33	case 1:
 34		$msg = $gXpLang['msg_new_account_created'];
 35		break;
 36	case 2:
 37		$msg = $gXpLang['msg_cannot_modify'];
 38		break;
 39	case 3:
 40		$msg = $gXpLang['msg_select_account'];
 41		break;
 42	case 4:
 43		$msg = $gXpLang['msg_select_account2delete'];
 44		break;
 45	case 5:
 46		$msg = $gXpLang['msg_account_success_delete'];
 47		break;
 48	case 6:
 49		$msg = $gXpLang['msg_account_success_modify'];
 50		break;
 51	case 7:
 52		$msg = $gXpLang['msg_account_success_disapproved'];
 53		break;
 54	case 8:
 55		$msg = $gXpLang['msg_account_success_approved'];
 56		break;
 57	case 9:
 58		$msg = $gXpLang['msg_account_success_pending'];
 59		break;
 60	case 10:
 61		$msg = $gXpLang['msg_accounts_success_delete'];
 62		break;
 63	case 11:
 64		$msg = $gXpLang['msg_accounts_success_modify'];
 65		break;
 66	case 12:
 67		$msg = $gXpLang['msg_accounts_success_disapproved'];
 68		break;
 69	case 13:
 70		$msg = $gXpLang['msg_accounts_success_approved'];
 71		break;
 72	case 14:
 73		$msg = $gXpLang['msg_accounts_success_pending'];
 74		break;
 75	default: ;
 76}
 77
 78$items = (int)$_GET['items'];
 79$items = $items ? $items : 5 ;
 80
 81$query_items = '';
 82if ((INT)$_GET['items']>0)
 83{
 84	$query_items = '&items='.(INT)$_GET['items'];
 85}
 86
 87define(ITEMS_PER_PAGE, $items);
 88
 89$page = (int)$_GET['page'];
 90$page = ($page < 1) ? 1 : $page;
 91$start = ($page - 1) * ITEMS_PER_PAGE;
 92
 93$suser = addslashes(htmlentities(strip_tags($_GET['su'])));
 94$smail = addslashes(htmlentities(strip_tags($_GET['sm'])));
 95
 96$accounts_num =& $gXpAdmin->getNumAccounts();
 97$accounts =& $gXpAdmin->getAllAccounts($start, ITEMS_PER_PAGE, $suser, $smail);
 98
 99?>
100
101<br />
102
103<?php
104print_box($error, $msg);
105?>	
106<form id="form_affiliate" action="manage-account.php<?php echo str_replace("&","?",$query_items)?>" method="post" name="adminForm">
107
108	<table class="adminlist" style="text-align: left;">
109		<tr>
110			<th style="text-align: right; border-bottom: 1px solid #fff;" colspan="3"><?php echo $gXpLang['filter_accounts']; ?>: </th>
111			<th style="border-bottom: 1px solid #fff;">
112				<input id="search_user" type="text" name="user" value="<?php echo $suser;?>" style="margin:0" /> 				
113			</th>
114			<th style="border-bottom: 1px solid #fff;">
115				<input id="search_mail" type="text" name="email" value="<?php echo $smail;?>" style="margin:0" /> 				
116			</th>
117			<th style="border-bottom: 1px solid #fff;" colspan="6">
118				<input type="button" value="Search in Accounts" onclick="setAction();" />
119			</th>
120			
121		</tr>
122		<tr>
123			<th width="20"><input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count($accounts);?>);" /></th>
124			<th>ID</th>
125			<th><?php echo $gXpLang['tier_tree']; ?></th>
126			<th><?php echo $gXpLang['username']; ?></th>
127			<th><?php echo $gXpLang['email']; ?></th>
128			<th><?php echo $gXpLang['hits']; ?></th>
129			<th><?php echo $gXpLang['level']; ?></th>
130			<th><?php echo $gXpLang['sales']; ?></th>
131			<th class="empty"><?php echo $gXpLang['status']; ?></th>
132			<th></th>
133			<th><?php echo $gXpLang['action']; ?></th>
134		</tr>
135<?php
136for($i=0; $i<count($accounts); $i++)
137{
138	if($accounts[$i]['aff_tier']>0)
139	{
140		$tier = '<img alt="" src="img/user_go.gif" style="cursor: pointer" border="0" align="top" onclick="viewModal(this, '.$accounts[$i]['id'].', \''.$accounts[$i]['username'].'\')" />';
141	}
142	else
143	{
144		$tier = '<img alt="" src="img/user_gray.gif" border="0" align="top" />';
145	}
146?>	
147		<tr class="row<?php echo ($i%2) ? '0' : '1' ;?>">
148			<td><input id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $accounts[$i]['id'];?>" onclick="isChecked(this.checked);" type="checkbox" /></td>
149			<td><?php echo $accounts[$i]['id'];?></td>
150			<td><?php echo $tier;?></td>
151			<td><a href="view-account.php?id=<?php echo $accounts[$i]['id'];?>" title="<?php echo $gXpLang['view_account_details']; ?>"><?php echo $accounts[$i]['username'];?></a></td>
152			<td><?php echo $accounts[$i]['email'];?></td>
153			<td><?php echo $accounts[$i]['hits'];?></td>
154			<td><?php echo ($accounts[$i]['level']>0? $gXpLang['level'].' - '.$accounts[$i]['level'] : $gXpLang['default_level']); ?></td>
155			<td><?php echo $accounts[$i]['sales'];?></td>
156			<?php
157			$tierContent.='<div id="tier_'.$accounts[$i]['id'].'" style="display: none"><img src="img/spinner2.gif" border="0" align="top" /><font style="padding: 4px;"> Loading...</font></div>';
158			switch ($accounts[$i]['approved'])
159			{
160				case 0:
161					$bgcolor = "bgcolor='#FFBBBB'";
162					$status = $gXpLang['status_disapproved'];
163					break;
164				case 1:
165					$bgcolor = "bgcolor='#FFF4CD'";
166					$status = $gXpLang['status_pending'];
167					break;
168				case 2:
169					$bgcolor = "bgcolor='#BBFFBB'";
170					$status = $gXpLang['status_approved'];
171					break;
172			}
173			?>
174			<td width="50" <?php echo $bgcolor; ?>><?php echo $status;?></td>
175			<td></td>
176			<td><a href="manage-account.php?id=<?php echo $accounts[$i]['id'];?>" title="<?php echo $gXpLang['edit_account']; ?>"><img src="images/edit.gif" border="0" /></a></td>
177		</tr>
178<?php
179}
180if(count($accounts)==0)
181	{ ?>
182		<tr class="row0">
183			<td colspan="9" align="center">No Items</td>
184		</tr>
185	<?php
186	}
187?>
188	</table>
189	<div class="bottom-controls" style="margin-top: 10px; display:none">
190	<select name="action" id="action">
191		<option value="">-- select --</option>
192		<option value="approve"><?php echo $gXpLang['approve'];?></option>
193		<option value="pending"><?php echo $gXpLang['pending'];?></option>
194		<option value="disapprove"><?php echo $gXpLang['disapprove'];?></option>
195		<option value="delete"><?php echo $gXpLang['delete'];?></option>
196	</select>
197	
198	<input type="submit" value=" Go " />
199	</div>
200	<input type="hidden" id="boxchecked" name="boxchecked" value="0" />
201	<input type="hidden" name="task" value="" />
202</form>
203<div style="height: 5px;"></div>
204
205<?php
206$url = "accounts.php?items=".ITEMS_PER_PAGE.(($smail or $suser)? "&su=".$suser."&sm=".$sm:"");
207navigation($accounts_num, $start, count($accounts), $url, ITEMS_PER_PAGE);
208?>
209		
210	<!--main part ends-->
211<div id="modal" style="z-index:999; position: absolute; top: 0px; left:0px; width: 250px; display: none;" class="jqDnR">
212	<img class="close" alt="" src="img/close.gif" border="0" style="position: absolute; right: 3px; top:3px; cursor:pointer" />
213	<div style="cursor: move;height: 27px; background: url('img/box-caption-bg.gif') top left repeat-x;" class="jqHandle jqDrag">
214		<div class="box-top-right">
215			<img alt="" border="0" src="img/box-caption-left.gif" align="left" />
216			<div style="padding: 6px 4px 2px 0px; font-weight: bold"><?php echo $gXpLang['tier_tree']; ?>				
217			</div>			
218		</div>		
219	</div>
220	<div class="box-content" style="overflow:auto; clear: both; height:250px; background: #fff;">
221	      <div id="treePanel">
222		  
223		  </div>
224	</div>
225	<div style="background: url('img/box-bottom-left.gif') #fff bottom left no-repeat; border-top: 1px solid #A7A7A9">
226		<div style="background: url('img/box-bottom-right.gif') bottom right no-repeat; margin-left: 5px;">
227			<img class="jqHandle jqResize" alt="" src="img/resize.gif" border="0" style="position: absolute; right:0px; bottom:1px; margin: 1px 2px; cursor: e-resize;" />&nbsp;
228		</div>
229	</div>
230</div>
231<?php echo $tierContent;?>
232<script type="text/javascript">
233
234function setAction()
235{
236	var suser = $("#search_user").val();
237	var smail = $("#search_mail").val();
238	var link = 'accounts.php';
239	link += suser? "?su="+suser :"";
240	link += smail? (suser? "&":"?")+"sm="+smail : "";
241	document.location.href = link;
242}
243function viewModal(obj, data, username)
244{
245	var pos = $(obj).getElementDimensions();
246	$("#modal").css({top:pos.top+"px", left:pos.left+20+"px"}).show();
247	$("#treePanel").empty();
248
249	var code = $("#tier_"+data).html()||"";
250	$("#treePanel").html(code);
251	$("#treePanel ul, #treePanel li").unbind();
252	if(code.indexOf('spinner2.gif')>0)
253	{
254		$.ajax({
255			type: "POST",
256			url: "get-tier-tree.php",
257			data: "id="+data,
258			async: false,
259			success: function(tree){
260				tree = '<img src="img/user.gif" border="0" align="top" style="margin-left: 4px;" \/> '+username+tree;
261				$("#tier_"+data).html(tree);
262				$("#treePanel").html(tree);				
263			}
264		});
265	}
266	$("#treePanel > ul:first").addClass("dir").Treeview({ speed: "normal", collapsed: true});
267}
268$().require('css/tree.css');
269$().require('js/jquery.treeview.js');
270$(document).ready(function(){
271	jQuery.fn.enterEscape = function()
272	{
273		this.keypress(
274		function(e)
275		{
276			// get key pressed (charCode from Mozilla/Firefox and Opera / keyCode in IE)
277			var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
278
279			if(key == 13)
280			{
281				setAction();
282				return false;
283			}
284		});
285		return this;
286	}
287	$(document).enterEscape();
288
289	if (jQuery.browser.msie) {
290		// we put a styled iframe behind the modal so HTML SELECT elements don't show through
291		var iframe = [	'<iframe class="bgiframe" tabindex="-1" src="about:blank" ',
292		'style="display:block; position:absolute;',
293		'top: 0;',
294		'left:0;',
295		'z-index:-1; filter:Alpha(Opacity=\'0\');',
296		'width:100%;',
297		'height:313px" frameborder="0" \/>'].join('');
298		$("#modal").prepend(iframe);
299	}
300	$('#modal').jqDrag('.jqDrag').jqResize('.jqResize').jqClose('.close');
301	$("#modal").prependTo("body:first");
302});
303
304
305</script>
306<?php
307require_once('footer.php');
308?>