Файл: _rootadmin/_bills.inc.php
Строк: 476
<?
if ($sub == 'delete') {
checkAdminAccess('billsDelete',1);
if (!$mass) { $elementsToCheck = array(); $elementsToCheck[] = $id; }
if (count($elementsToCheck) > 0) {
while (list($k,$v) = @each($elementsToCheck)) {
$b = GetBillById($v);
if ($b->id) {
if ($b->isMainAttach) {
@mysql_query("update bills set attachTo='' where attachTo='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("delete from bills where id='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
writeAdminLog("Удален счет ID # $b->id");
print "Счет <B># ID $b->id</b> успешно удален.<BR>";
}
else if (!$b->status) {
@mysql_query("delete from bills where id='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
writeAdminLog("Удален счет ID # $b->id");
print "Счет <B>ID # $b->id</B> успешно удален.<BR>";
}
else {
@mysql_query("update bills set archived='1' where id='$b->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
writeAdminLog("Счет ID # $b->id перемещён в архив.");
print "Счет <B>ID # $b->id</B> успешно перемещён в архив.<BR>";
}
}
}
print "<BR>";
}
}
if ($sub == 'deletearchived') {
checkAdminAccess('billsDelete',1);
if (!$mass) { $elementsToCheck = array(); $elementsToCheck[] = $id; }
if (count($elementsToCheck) > 0) {
while (list($k,$v) = @each($elementsToCheck)) {
@mysql_query("delete from bills where id='$v'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
writeAdminLog("Из архива удален счет ID # $v");
print "Счет <B>ID # $v</B> успешно удален из архива.<BR>";
}
print "<BR>";
}
}
checkAdminAccess('billsRead',1);
if ($param == "uid" and $search) { print menu_admin_client($search); }
if ($param and $search) {$linkAddon = "param=$param&search=$search";}
if ($mitem_id) {
$linkAddon .= "&mitem_id=$mitem_id";
# if (!$sort and !$desc) { $sort = "payeddt"; $desc = "desc"; }
}
if ($mitem_id) { $show = "all"; }
$mySort = $_SESSION["billsSort"];
$myShow = $_SESSION["billsShow"]; if (!$myShow) { $myShow="all"; }
if ($show and $show != $myShow) { $myShow = $show; $_SESSION["billsShow"] = $myShow; }
if ($myShow == "all") {
$where = "where archived=0";
} else if ($myShow == "payed") {
$where = "where archived=0 and status=1";
} else if ($myShow == "nonpayed") {
$where = "where archived=0 and status=0";
} else if ($myShow == "nonpayed20") {
$where = "where archived=0 and status=0 and (TO_DAYS(NOW())-TO_DAYS(created))>20";
} else if ($myShow == "uslpayed") {
$where = "where archived=0 and status=2";
} else if ($myShow == "archive") {
$where = "where archived=1";
}
if ($search) {
if ($param == "id" or $param == "uid" or $param == "host_id" or $param == "domain_id" or $param == "shop_id") {
$where .= " and $param='$search'";
} else {
$where .= " and $param LIKE '%$search%'";
}
}
if (!$mySort) { $mySort = "id"; } # установка поля для сортировки по умолчанию, если не указано
if ($sort and $sort != $mySort) { $mySort = $sort; } # установка нового типа сортировки, если клиент выбрал другой
$_SESSION["billsSort"] = $mySort;
if (!$_SESSION["billsDesc"]) { $_SESSION["billsDesc"] = "desc"; } # получение направления сортировки или установка по умолчанию
if ($desc and $desc != $_SESSION["billsDesc"]) { $_SESSION["billsDesc"] = $desc; } # установка нового направления сортировки, если клиент выбрал другое
if (!$desc and $_SESSION["billsDesc"]) { $desc = $_SESSION["billsDesc"]; }
if ($desc == "desc") { $desc = "asc"; } else { $desc = "desc"; }
$myDesc = $_SESSION["billsDesc"];
getfont();
if (!$mitem_id) {
?>
<table width=99%>
<tr>
<Td valign=top>
<table width=330>
<tr><td align=center bgcolor=<? print $font_head?>><B>Фильтр</b></td></tr>
<tr><td bgcolor=<? print $font_row?> align=center>
<form method=post>
<select name=show>
<option value=all <? if ($myShow == 'all') {print "selected";} ?>>Все счета</option>
<option value=payed <? if ($myShow == 'payed') {print "selected";} ?>>Оплаченные</option>
<option value=uslpayed <? if ($myShow == 'uslpayed') {print "selected";} ?>>Условно опплаченные</option>
<option value=nonpayed <? if ($myShow == 'nonpayed') {print "selected";} ?>>Не оплаченные</option>
<option value=nonpayed20 <? if ($myShow == 'nonpayed20') {print "selected";} ?>>Не оплаченные более 20 дней</option>
<option value=archive <? if ($myShow == 'archive') {print "selected";} ?>>Архив</option>
</select>
<input type=submit value=Показать>
</form>
</td></tr>
</table>
</td>
<td width=50> </td>
<Td valign=top>
<table width=320>
<tr><td align=center bgcolor=<? print $font_head?>><B>Поиск</b></td></tr>
<tr><td bgcolor=<? print $font_row?>><form method=post><select name=param><option value=id selected>№ счета:</option></select> <input type=text name=search size=20> <input type=submit value=Найти></form></td></tr>
</table>
</td>
<td width=100%></td>
</tr>
</table><BR>
<?
}
if ($mitem_id) {
$r=@mysql_query("select b.* from bills as b, orders_shop as o, shop_items as i where i.id=o.item and o.id=b.shop_id and i.id='$mitem_id' and b.archived=0 order by $mySort $myDesc") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
} else {
$r=@mysql_query("select * from bills $where order by $mySort $myDesc") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
$rows = mysql_num_rows($r);
list($start, $perPage, $txt) = MakePages($page, $rows, $linkAddon);
?>
<form method=post>
<input type=hidden name=do value=<? print $do?>>
<input type=hidden name=sub value=<? if ($_SESSION["billsShow"] == "archive") { print "deletearchived"; } else { print "delete"; } ?>>
<input type=hidden name=mass value=1>
<table cellpadding=3 width=99%>
<tr><td colspan=11 align=right><? print $txt?></td></tr>
<tr><td colspan=11 align=center bgcolor=<? print $font_head?>><B>Счета</b></td></tr>
<tr bgcolor=<? print $font_head?> align=center><td><input type=checkbox onclick='setChecked(this,0)'></td><td></td><td>Дата</td><td><a href=?do=<? print $do?>&sort=id&desc=<? print $desc?>&mitem_id=<? print $mitem_id?>>№ счета <? if ($mySort == "id") { print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."'>"; } ?></a></td><td>Логин</td><td>Тариф</td><td>Домен</td><td>Стоимость, <? print CURAS?></td><td>Сумма, <? print CURAS?></td><td><a href=?do=<? print $do?>&sort=payeddt&desc=<? print $desc?>&mitem_id=<? print $mitem_id?>>Оплата <? if ($mySort == "payeddt") { print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."'>"; } ?></a></td><td></td></tr>
<?
if ($mitem_id) {
$r=@mysql_query("select b.* from bills as b, orders_shop as o, shop_items as i where i.id=o.item and o.id=b.shop_id and i.id='$mitem_id' and b.archived='0' order by $mySort $myDesc LIMIT $start,$perPage") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
} else {
$r=@mysql_query("select * from bills $where order by $mySort $myDesc LIMIT $start,$perPage") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
$cnt=0;
getfont();
while ($rr = mysql_fetch_object($r)) {
$tarifTxt = "";
$domainTxt = "";
$cost = "";
if ($rr->host_id) {
$t=@mysql_query("select t1.*, t2.name from orders as t1, tarifs as t2 where t1.id='$rr->host_id' and t1.tarif=t2.id");
$t=@mysql_fetch_object($t);
if (!$rr->newaddons) { $cost = "<img src=./_rootimages/hosting.gif border=0 alt='Хостинг'> $rr->money_host"; }
$newreg='';
$domain_srok='';
if ($rr->tarif) {
$curTarif = GetTarifById($rr->tarif);
if ($curTarif->id) {
$t->name = $curTarif->name;
} else {
$t->name = "UNKNOWN";
}
}
if ($rr->server) {
$curServer = GetServers($rr->server);
if ($curServer->id) {
$curServer->place = $curServer->place;
} else {
$curServer->place = "UNKNOWN";
}
}
if ($rr->newtarif) {
$newTarif=GetTarifById($rr->newtarif);
if ($rr->history) { $tarifTxt = "$rr->history<BR>[смена тарифа]"; } else { $tarifTxt = "<B>$t->name</B> => <B>$newTarif->name</b><BR>[смена тарифа]"; }
$tarifHistoryTxt = $tarifTxt;
} else if ($rr->newserver) {
$newServer=GetServers($rr->newserver);
if ($rr->history) { $tarifTxt = htmlDecode($rr->history)."<BR>[смена сервера]"; } else { $tarifTxt = "<B>$t->name</B><BR><B>$curServer->place</b> => <B>$newServer->place</b><BR>[смена сервера]"; }
$tarifHistoryTxt = $tarifTxt;
} else if ($rr->newslots) {
if ($rr->history) { $tarifTxt = htmlDecode($rr->history)."<BR>[смена кол-ва слотов]"; } else { $tarifTxt = "<B>$t->name</B><BR><B>$t->slots</b> => <B>$rr->newslots</b><BR>[смена кол-ва слотов]"; }
$tarifHistoryTxt = $tarifTxt;
} else if ($rr->newaddons) {
$tarifTxt = "<b>$t->name</b><BR>[заказ доп.услуг]";
if ($rr->archived and $rr->history) { $tarifHistoryTxt = $rr->history; }
else if ($rr->archived and !$rr->history) { $tarifHistoryTxt = "Тариф: <B>$t->name</B><BR>[заказ доп.услуг]"; }
} else {
$tarifTxt = "<b>$t->name</b><BR>[".$rr->host_srok." мес]";
if ($rr->archived and $rr->history) { $tarifHistoryTxt = $rr->history; }
else if ($rr->archived and !$rr->history) { $tarifHistoryTxt = "Тариф: <B>$t->name</B>, $rr->host_srok мес."; }
}
if ($t->domain_reg == "1" or $t->domain_reg == "3") {
if ($rr->renew) {
if ($rr->domain_id) {
$newreg=$_renewmin[1];
$domain_srok=" [$rr->domain_srok мес]";
} else {
$newreg=$_renewmin[0];
}
} else if ($rr->transfer) {
$newreg=$_newregmin[3];
$domain_srok=" [$rr->domain_srok мес]";
} else {
$newreg=$_newregmin[1];
$domain_srok=" [$rr->domain_srok мес]";
}
if ($rr->archived and !$rr->history) { $tarifHistoryTxt .= " + домен <B>$t->domain</b>, ".($rr->domain_srok/12)." г."; }
if (!$rr->newaddons) { $cost .= " <img src=./_rootimages/domain.gif border=0 alt='Домен'> $rr->money_domain"; }
} else if ($t->domain_reg == "2") {
$newreg='';
} else if ($t->domain_reg == "0") {
if ($rr->renew or $rr->newtarif or $rr->newserver or $rr->newslots) {
$newreg='';
} else {
$newreg=$_newregmin[0];
}
}
if ($newreg) {$newreg="[".$newreg."]";}
if (!$rr->newtarif and !$rr->newaddons and !$rr->newserver and !$rr->newslots) {
if ($rr->renew) {
$tarifHistoryTxt .= "<BR>[продление]";
} else {
$tarifHistoryTxt .= "<BR>[новый]";
}
}
if ($t->domain and !$rr->newaddons) { $domainTxt = "<B>$t->domain</b><BR>".$newreg.$domain_srok; }
else if ($t->domain and $rr->newaddons) { $domainTxt = "<B>$t->domain</b><BR> "; }
else { $domainTxt = ""; }
} else {
$tarifHistoryTxt = "";
$t = "";
}
if ($rr->domain_id and !$rr->host_id) {
$d=@mysql_query("select * from orders_domains domains where id='$rr->domain_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$d=@mysql_fetch_object($d);
if (!$rr->privacy) { $cost=$cost." <img src=./_rootimages/domain.gif border=0 alt='Домен'> $rr->money_domain"; }
if ($rr->privacy) {
$domainTxt = "<B>".$d->domain."</b><BR>[заказ Privacy Protection]";
} else {
$domainTxt = "<B>".$d->domain."</b><BR>";
if ($rr->renew) { $domainTxt .= "[продление] "; } else { $domainTxt .= "[новый] "; }
$domainTxt .= "[$rr->domain_srok мес]";
}
if ($rr->archived and $rr->history) { $tarifHistoryTxt = $rr->history; }
else if ($rr->archived and !$rr->history) { if ($rr->privacy) { $tarifHistoryTxt = "Домен: <B>$d->domain</b><BR>[заказ Privacy Protection]"; } else { $tarifHistoryTxt = "Домен: <B>$d->domain</b>, ".($rr->domain_srok/12)." г."; }}
if ($rr->renew) {
$tarifHistoryTxt .= "<BR>[продление]";
} else {
$tarifHistoryTxt .= "<BR>[новый]";
}
} else {
$d = "";
}
if ($rr->money_addons > 0 or $rr->deleteaddons) {
if ($rr->deleteaddons) { $addonsFile = "addonsdeleted.gif"; } else { $addonsFile = "addons.gif"; }
$cost=$cost." <img src=./_rootimages/$addonsFile border=0 alt='Доп. услуги'> $rr->money_addons";
}
if ($rr->shop_id) {
$s=@mysql_query("select * from orders_shop where id='$rr->shop_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$s = @mysql_fetch_object($s);
$cost = $cost." <img src=./_rootimages/shop.gif border=0 alt='Товар'> ".$rr->money_shop;
$tshop=GetShopItemById($s->item);
$shopTxt = "<B>".$tshop->name."</b><BR>";
if ($rr->renew) { $shopTxt .= "[продление] "; } else { $shopTxt .= "[новый] "; }
if ($tshop->costtype != "one") { $shopTxt .= "[$rr->shop_srok мес]"; }
if ($rr->archived and $rr->history) { $shopHistoryTxt = $rr->history; }
else if ($rr->archived and !$rr->history) {
$shopHistoryTxt = "Товар: <B>$tshop->name</b>";
if ($tshop->costtype != "one") { $shopHistoryTxt .= ", $rr->shop_srok мес."; }
}
if ($rr->renew) { $shopHistoryTxt .= "<BR>[продление]"; } else { $shopHistoryTxt .= "<BR>[новый]"; }
} else {
$tshop = "";
$s = "";
$shopHistoryTxt = "";
}
$u=@mysql_query("select * from users where id='$rr->uid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$u=mysql_fetch_object($u);
if ($rr->status != 0) {$rr->payeddt = @mb_split(" ",$rr->payeddt); $statusAddOn=" ".mydate($rr->payeddt[0])." ".$rr->payeddt[1];}
else {$statusAddOn="";}
getfont();
?>
<tr bgcolor="<? print $font_row?>" height=30>
<td align=center width=20><input type=checkbox name=elementsToCheck[] value=<? print $rr->id?>>
<td align=center width=20>
<? if (!$rr->archived) { ?>
<a href=?do=<? print $do?>&sub=delete&id=<? print $rr->id?> onclick="javascript: return confirm('Вы уверены, что хотите удалить счет?');"><img src=./_rootimages/del.gif border=0 alt="Удалить счет"></a>
<? } else { ?>
<a href=?do=<? print $do?>&sub=deletearchived&id=<? print $rr->id?> onclick="javascript: return confirm('Вы уверены, что хотите удалить счет?');"><img src=./_rootimages/del.gif border=0 alt="Удалить счет"></a>
<? } ?>
</td>
</td>
<td align=center><? print mydate($rr->created)?></td>
<td align=center><B><? print sprintf("%04d", $rr->id)?></b></td>
<td align=center><a href=?do=fullinfo&id=<? print $u->id?>><? print $u->login?></a></td>
<? if ($rr->isMainAttach and !$rr->host_id and !$rr->domain_id and !$rr->shop_id and !$rr->money and !$rr->addfunds) { ?>
<td align=center colspan=3><? print $_lang[BillsBillByAttach]?></td>
<?
$attbs = @mysql_query("select * from bills where attachTo='$rr->id' and uid='$rr->uid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
while ($attb = @mysql_fetch_object($attbs)) {
$rr->money_host = $rr->money_host + $attb->money_host;
$rr->money_domain = $rr->money_domain + $attb->money_domain;
$rr->money_addons = $rr->money_addons + $attb->money_addons;
$rr->money = $rr->money + $attb->money;
$rr->money_shop = $rr->money_shop + $attb->money_shop;
}
?>
<? } else if (!$rr->archived and !$rr->addfunds and !$rr->money and !$rr->shop_id) { ?>
<td align=center><? print $tarifTxt?></td>
<td><? print $domainTxt?></td>
<td align=center><? print $cost?></td>
<? } else if ($rr->archived and !$rr->addfunds and !$rr->money and !$rr->shop_id) { ?>
<td colspan=2><? print $tarifHistoryTxt?></td>
<td align=center><? print $cost?></td>
<? } else if (!$rr->addfunds and $rr->money) { ?>
<td colspan=3 align=center>счет выставлен администратором <img src="./_rootimages/question.gif" alt="<B>Комментарий:</b><BR><? print $rr->comment?>"></td>
<? } else if (!$rr->archived and $rr->shop_id) { ?>
<td colspan=2>Товар: <? print $shopTxt?></td>
<td align=center><? print $cost?></td>
<? } else if ($rr->archived and $rr->shop_id) { ?>
<td colspan=2><? print $shopHistoryTxt?></td>
<td align=center><? print $cost?></td>
<? } else {?>
<td colspan=3 align=center>пополнение внутреннего баланса<? if ($rr->archived and $rr->history) { print " (пользователь <B>$rr->history</b>)"; } ?></td>
<? } ?>
<td align=center><B><? print ($rr->money_host+$rr->money_domain+$rr->money_addons+$rr->money+$rr->money_shop)?></b></td>
<td align=center><img src=./_rootimages/payed_<? print $rr->status?>_small.gif border=0 alt="<? print $_statusBill[$rr->status].$statusAddOn?>"></td>
<td align=left width=50>
<? if (!$rr->archived) { ?>
<a href=?do=editbill&id=<? print $rr->id?>&mitem_id=<? print $mitem_id?>><img src=./_rootimages/edit.gif border=0 alt="Редактировать счет"></a>
<? } ?>
<? if (!$rr->addfunds and !$rr->money and !$rr->archived) { ?>
<a href=?do=editorder&<? if ($s->id) { print "shop_id=$s->id"; } else if ($t->id) { print "host_id=$t->id"; } else { print "domain_id=$d->id"; } ?>><img src=./_rootimages/orders.gif border=0 alt='Редактировать заказ'></a>
<? } ?>
</td>
</tr>
<?
$cnt++;
}
?>
<tr bgcolor=<? print $font_head?>><Td colspan=11>Всего счетов: <? print $rows?>, счетов на странице: <? print $cnt?></td></tr>
<tr><td colspan=11 align=right><? print $txt?></td></tr>
</table>
Отмеченные счета: <input type=submit value=Удалить>
</form>
<?
?>