Файл: _rootadmin/_clients.inc.php
Строк: 266
<?
if ($sub == 'delete') {
checkAdminAccess('clientsDelete',1);
if (!$mass) { $elementsToCheck = array(); $elementsToCheck[] = $uid; }
if (count($elementsToCheck) > 0) {
while (list($k,$v) = @each($elementsToCheck)) {
$user = GetUserById($v);
if ($user->id) {
$orders = @mysql_query("select * from orders where uid='$user->id' and archived=0") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
while ($order = @mysql_fetch_object($orders)) {
if ($order->serverlogin) {
$tarif = GetTarifById($order->tarif);
if ($tarif->autodelete) {
if (deleteUser($order->id)) {
print "Аккаунт <b>$order->serverlogin</b> автоматически удален на сервере.<BR>";
} else {
print "Аккаунт <b>$order->serverlogin</b> не удален на сервере ($GLOBALerror).<BR>";
}
} else {
print "Аккаунт <b>$order->serverlogin</b> не удалён на сервере (эта возможность отключена для тарифного плана).<BR>";
}
} else {
print "Аккаунт для заказа <B>ID #$order->id ($order->domain)</b> не был удалён на сервере (не указан логин на сервере или не выбран сервер для заказа).<BR>";
}
@mysql_query("update servers_ips set order_id='0',isMain='0' where order_id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
$bs = @mysql_query("select * from bills where uid='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
while ($b = @mysql_fetch_object($bs)) {
if (!$b->status) {
@mysql_query("delete from bills where id='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
} else {
@mysql_query("update bills set archived=1 where id='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
@mysql_query("delete from catalog where uid='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("delete from mail_logs where uid='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("delete from orders where uid='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$orders = @mysql_query("select * from orders_domains where uid='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
while ($order = @mysql_fetch_object($orders)) {
if ($order->dnsServerId) {
if (deleteDomainZoneAtServer($order->id)) {
print "Доменная зона для <b>$order->domain</b> автоматически удалена на сервере.<BR>";
} else {
print "Доменная зона для <b>$order->domain</b> не удалена на сервере ($GLOBALerror).<BR>";
}
}
}
@mysql_query("delete from orders_domains where uid='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("delete from orders_domainscert where uid='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("delete from specialcosts where uid='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("delete from users where id='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("delete from users_profile where uid='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("delete from users_logs where uid='$user->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$tickets = @mysql_query("select * from tickets where userid='$user->id' and parentid='0'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
while ($ticket = @mysql_fetch_object($tickets)) {
@mysql_query("delete from tickets where id='$ticket->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("delete from tickets where parentid='$ticket->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
writeAdminLog("Удален клиент ID # $user->id, $user->login");
print "Клиент ID # $user->id, $user->login, а так же все его заказы и счета успешно удалены.<BR>";
}
}
print "<BR>";
}
}
checkAdminAccess('clientsRead',1);
if ($search) {
if ($param == 'u.id') { $where = "and $param = '$search'"; } else { $where = "and $param LIKE '%$search%'"; }
}
if ($mitem_id) {
$sql = "SELECT u.*,p.surname,p.name,p.otchestvo,p.org,p.firma,p.country FROM users_profile AS p, users AS u, orders_shop as o WHERE u.id=p.uid AND u.defaultProfileId=p.id and o.uid=u.id and o.item='$mitem_id' GROUP BY o.uid ORDER BY u.id desc";
}
else if ($partners) {
$sql = "SELECT u.*,p.surname,p.name,p.otchestvo,p.org,p.firma,p.country FROM users_profile AS p, users AS u WHERE u.id=p.uid AND u.defaultProfileId=p.id AND u.isPartner='1' $where ORDER BY u.id desc";
} else {
$sql = "SELECT u.*,p.surname,p.name,p.otchestvo,p.org,p.firma,p.country FROM users_profile AS p, users AS u WHERE u.id=p.uid AND u.defaultProfileId=p.id $where ORDER BY u.id desc";
}
$r = @mysql_query("$sql") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$rows = mysql_num_rows($r);
list($start, $perPage, $txt) = MakePages($page, $rows, "partners=$partners");
if ($partners) { $pageTitle = "Партнеры"; $pageFootTxt = "партнеров";}
else {$pageTitle = "Клиенты"; $pageFootTxt = "клиентов";}
getfont();
if (!$mitem_id) {
?>
<table>
<tr><td align=center bgcolor=<? print $font_head?>><B>Поиск</b></td></tr>
<tr><td bgcolor=<? print $font_row?>><form method=post><input type=hidden name=partners value="<? print $partners?>"><select name=param><option value=u.id>ID:</option><option value=u.login selected>Логин:</option><option value=u.email>E-Mail:</option><option value=p.surname>Фамилия:</option><option value=u.remark>Заметки:</option></select> <input type=text name=search size=20> <input type=submit value=Найти></form></td></tr>
</table><br>
<? } ?>
<form method=post>
<input type=hidden name=do value=<? print $do?>>
<input type=hidden name=sub value=delete>
<input type=hidden name=mass value=1>
<input type=hidden name=partners value=<? print $partners?>>
<table cellpadding=3 width=99%>
<tr><td colspan=8 align=right><? print $txt?></td></tr>
<tr><td colspan=8 align=center bgcolor=<? print $font_head?>><B><? print $pageTitle?></b></td></tr>
<tr bgcolor=<? print $font_head?>><td><input type=checkbox onclick='setChecked(this,0)'></td><td></td><td align=center>ID</td><td align=center>Логин</td><td align=center>E-mail</td><td align=center>Клиент</td><td align=center>Зарегистрирован</td><td align=center></td></tr>
<?
$weSalesTypes = GetSetting("weSalesTypes");
$weSalesTypes = @mb_split("::",$weSalesTypes);
$sql .= " LIMIT $start,$perPage";
$r = @mysql_query("$sql") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$cnt=0;
while ($rr = @mysql_fetch_object($r)) {
$billsAll=mysql_query("select * from bills where uid = '$rr->id'");
$billsAll=@mysql_num_rows($billsAll);
getfont();getfont();
$orders=mysql_query("select * from orders where uid = $rr->id and archived=0");
$orders=@mysql_num_rows($orders);
$ordersShop=mysql_query("select * from orders_shop where uid = $rr->id");
$ordersShop=@mysql_num_rows($ordersShop);
$domains=mysql_query("select * from orders_domains where uid = $rr->id");
$domains=@mysql_num_rows($domains);
$bills=mysql_query("select * from bills where archived=0 and uid = $rr->id");
$bills=@mysql_num_rows($bills);
if ($rr->org == "3" and $rr->country) {
$namePrint = "$rr->firma<BR><font color=#CECECE>[организация]</font>";
} else if ($rr->org == "2" and $rr->country) {
$namePrint = "$rr->surname $rr->name $rr->otchestvo<BR><font color=#CECECE>[частный предприниматель]</font>";
} else if ($rr->org == "1" and $rr->country) {
$namePrint = "$rr->surname $rr->name $rr->otchestvo<BR><font color=#CECECE>[физическое лицо]</font>";
} else {
$namePrint = "";
}
$info = "Счета: $bills;"; $infoUrl = "<a href=?do=bills¶m=uid&search=$rr->id><img src=./_rootimages/bills.gif alt='Счета: $bills' border=0></a>";
if (@in_array("hosting",$weSalesTypes) or @in_array("reseller",$weSalesTypes) or @in_array("vds",$weSalesTypes) or @in_array("dedicated",$weSalesTypes) or @in_array("vpn",$weSalesTypes) or @in_array("ssh",$weSalesTypes)) { $info .= " Заказы: $orders;"; $infoUrl .= " <a href=?do=orders¶m=uid&search=$rr->id><img src=./_rootimages/orders.gif border=0 alt='Заказы: $orders'></a>"; }
if (@in_array("domains",$weSalesTypes)) { $info .= " Домены: $domains;"; $infoUrl .= " <a href=?do=domains¶m=uid&search=$rr->id><img src=./_rootimages/domain.gif border=0 alt='Домены: $domains'></a>"; }
if (@in_array("shop",$weSalesTypes)) { $info .= " Товары: $ordersShop"; $infoUrl .= " <a href=?do=shop¶m=uid&search=$rr->id><img src=./_rootimages/shop.gif border=0 alt='Товары: $ordersShop'></a>"; }
$info = "<font color=#CECECE>".$info."</font>"; if ($namePrint) { $info = "<BR>".$info; }
$emailPrint = "<a href=?do=mailsend&userid=$rr->id>$rr->email</a>";
if ($rr->email2) { $emailPrint = $emailPrint."<BR><a href=?do=mailsend&userid=$rr->id&alt=1>$rr->email2</a>"; }
print "
<tr bgcolor=$font_row>
<td align=center width=20><input type=checkbox name=elementsToCheck[] value=$rr->id>
<td align=center><a href=?do=$do&partners=$partners&sub=delete&uid=$rr->id onclick="javascript: return confirm('Будет удален клиент, а так же все заказы и счета, относящиесу к нему. Вы уверены, что хотите удалить клиента?');"><img src=./_rootimages/del.gif border=0 alt='Удалить клиента'></a></td>
<td align=center>$rr->id</td>
<td><A href=?do=fullinfo&id=$rr->id>$rr->login</a></td>
<td>$emailPrint</td>
<td>$namePrint$info</td>
<td align=center>".mydate($rr->datareg)."</td>
<td align=center width=130>$infoUrl<a href=?do=profile&id=$rr->id><img src=./_rootimages/profile.gif border=0 alt='Профайл'> <a href=?do=history&uid=$rr->id><img src=./_rootimages/history.gif border=0 alt='История'></a> <a href=?do=gotobilling&id=$rr->id target=_blank><img src=./_rootimages/goto.gif border=0 alt='Войти в биллинг клиента'></a></a></td>
</tr>";
$cnt++;
}
?>
<tr bgcolor=<? print $font_head?>><td colspan=8>Всего <? print $pageFootTxt?>: <? print $rows?>, <? print $pageFootTxt?> на странице: <? print $cnt?></td></tr>
<tr><td colspan=8 align=right><? print $txt?></td></tr>
</table>
Отмеченные клиенты: <input type=submit value=Удалить>
</form>
<?
?>