Файл: _rootadmin/_orders.inc.php
Строк: 398
<?
checkAdminAccess('ordersRead',1);
if ($param == "uid" and $search) { print menu_admin_client($search); }
if ($param and $search) {$linkAddon = "param=$param&search=$search";}
if ($sub == 'deletearchived') {
checkAdminAccess('ordersDelete',1);
if (!$mass) { $elementsToCheck = array(); $elementsToCheck[] = $id; }
if (count($elementsToCheck) > 0) {
while (list($k,$v) = @each($elementsToCheck)) {
@mysql_query("delete from orders 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>";
}
}
if ($sub == 'delete') {
checkAdminAccess('ordersDelete',1);
if ($id) { $elementsToCheck = array(); $elementsToCheck[] = $id; }
if (count($elementsToCheck) > 0) {
while (list($k,$v) = @each($elementsToCheck)) {
$order = GetOrderById($v);
if ($order->id) {
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>";
}
if ($order->domain_reg == "1" or $order->domain_reg == "3") {
$dm = GetDomainByDomain($order->domain);
if ($dm->status) {
@mysql_query("update orders_domains set host_id='0' where id='$dm->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("update bills set host_id='0', host_srok='0', money_host='0', money_addons='0' where host_id='$order->id' and domain_id='$dm->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
} else {
@mysql_query("delete from orders_domains where host_id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
@mysql_query("delete from orders_domainscert where domain_id='$dm->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
} else {
@mysql_query("delete from orders_domains where host_id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
@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 host_id='$order->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());
}
}
if (!$order->status) {
@mysql_query("delete from orders where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
writeAdminLog("Удален заказ ID # $order->id, $order->domain");
print "Заказ <B>ID # $order->id ($order->domain)</b> и все счета, относящиеся к нему, успешно удалены.<BR>";
} else {
@mysql_query("update orders set archived=1 where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
writeAdminLog("Заказ ID # $order->id, $order->domain успешно перемещен в архив.");
print "Заказ <B>ID # $order->id ($order->domain)</B> успешно перемещен в архив.<BR>";
}
}
}
print "<BR>";
}
}
$myShow = $_SESSION["orderShow"]; if (!$myShow) { $myShow="all"; }
if ($show and $show != $myShow) { $myShow = $show; $_SESSION["orderShow"] = $myShow; }
$mySort = $_SESSION["orderSort"];
$myShowVid = $_SESSION["orderShowVid"];
if ($showVid and $showVid != $myShowVid) { $myShowVid = $showVid; $_SESSION["orderShowVid"] = $myShowVid; }
if ($myShow == "all") {
if ($search) { $where = "where (o.archived=0 or o.archived=1)"; $myShowVid = "all"; }
else { $where = "where o.archived=0"; }
} else if ($myShow == "vobrab") {
$where = "where o.archived=0 and o.status=3";
} else if ($myShow == "obrab") {
$where = "where o.archived=0 and o.status=1";
} else if ($myShow == "noobrab") {
$where = "where o.archived=0 and o.status=0";
} else if ($myShow == "suspended") {
$where = "where o.archived=0 and o.status=2";
} else if ($myShow == "toexpire") {
$where = "where o.archived=0 and TO_DAYS(o.todate)-TO_DAYS(NOW())>=0 and TO_DAYS(o.todate)-TO_DAYS(NOW())<=10";
} else if ($myShow == "expired") {
$where = "where o.archived=0 and TO_DAYS(o.todate)-TO_DAYS(NOW())<0";
} else if ($myShow == "archive") {
$where = "where o.archived=1";
}
if ($myShowVid and $myShowVid != "all") { $where .= " and t.id=o.tarif and t.vid='$myShowVid'"; }
else {$where .= " and t.id=o.tarif";}
if ($param == 'uid' or $param == "serverlogin") { $operat = "o.$param = '$search'"; } else { $operat = "o.$param LIKE '%$search%'"; }
if ($search) { $where .= " and $operat"; }
if (!$mySort) { $mySort = "id"; } # установка поля для сортировки по умолчанию, если не указано
if ($sort and $sort != $mySort) { $mySort = $sort; } # установка нового типа сортировки, если клиент выбрал другой
$_SESSION["orderSort"] = $mySort;
if (!$_SESSION["orderDesc"]) { $_SESSION["orderDesc"] = "desc"; } # получение направления сортировки или установка по умолчанию
if ($desc and $desc != $_SESSION["orderDesc"]) { $_SESSION["orderDesc"] = $desc; } # установка нового направления сортировки, если клиент выбрал другое
if (!$desc and $_SESSION["orderDesc"]) { $desc = $_SESSION["orderDesc"]; }
if ($desc == "desc") { $desc = "asc"; } else { $desc = "desc"; }
$myDesc = $_SESSION["orderDesc"];
getfont();
?>
<table width=99%>
<tr>
<Td valign=top>
<table width=270>
<tr><td align=center bgcolor=<? print $font_head?>><B>Фильтр</b></td></tr>
<tr><td bgcolor=<? print $font_row?>>
<form method=post>
Тип заказов: <select name=showVid>
<option value="all" <? if ($myShowVid == "all") {print "selected";} ?>>Все типы</option>
<?
while (list($k,$v) = each($_lang[OrderType])) {
if ($myShowVid == $k) { $selectedVid = "selected"; } else { $selectedVid = ""; }
print "<option value=$k $selectedVid>$v</option>";
}
?>
</select><BR>
Статус заказов: <select name=show>
<option value=all <? if ($myShow == 'all') {print "selected";} ?>>Все заказы</option>
<option value=vobrab <? if ($myShow == 'vobrab') {print "selected";} ?>>В обработке</option>
<option value=obrab <? if ($myShow == 'obrab') {print "selected";} ?>>Обработанные</option>
<option value=noobrab <? if ($myShow == 'noobrab') {print "selected";} ?>>Не обработанные</option>
<option value=suspended <? if ($myShow == 'suspended') {print "selected";} ?>>Приостановленные</option>
<option value=toexpire <? if ($myShow == 'toexpire') {print "selected";} ?>>Заканчивающиеся</option>
<option value=expired <? if ($myShow == 'expired') {print "selected";} ?>>Закончившиеся</option>
<option value=archive <? if ($myShow == 'archive') {print "selected";} ?>>Архив</option>
</select><BR>
<center><input type=submit value=Показать></center>
</form>
</td></tr>
</table>
</td>
<td width=50> </td>
<Td valign=top>
<table width=400>
<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=show value=all><select name=param><option value=domain selected>Домен:</option><option value=comment>Комментарий клиента:</option><option value=remark>Заметки для админа:</option><option value=remarkUser>Заметки для клиента:</option><option value=ipaddr>IP-адрес:</option><option value=serverlogin>Логин на сервере:</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>
<?
$r=@mysql_query("select o.*,TO_DAYS(o.todate)-TO_DAYS(NOW()) as leftdays,t.vid$select from orders as o, tarifs as t $where order by o.$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["orderShow"] == "archive") { print "deletearchived"; } else { print "delete"; } ?>>
<input type=hidden name=mass value=1>
<table cellpadding=3 width=99%>
<tr><td colspan=14 align=right><? print $txt?></td></tr>
<tr><td colspan=14 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><a href=?do=<? print $do?>&sort=id&desc=<? print $desc?>>ID <? if ($mySort == "id") { print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."'>"; } ?></a></td>
<td><a href=?do=<? print $do?>&sort=orderdate&desc=<? print $desc?>>Дата <? if ($mySort == "orderdate") { print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."'>"; } ?></a></td>
<Td>Логин</Td>
<td><a href=?do=<? print $do?>&sort=domain&desc=<? print $desc?>>Домен <? if ($mySort == "domain") { print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."'>"; } ?></a></td>
<td><a href=?do=<? print $do?>&sort=tarif&desc=<? print $desc?>>Тариф <? if ($mySort == "tarif") { print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."'>"; } ?></a></td>
<td><a href=?do=<? print $do?>&sort=todate&desc=<? print $desc?>><img src=./_rootimages/hosting.gif border=0 alt='Хостинг'> Конец <? if ($mySort == "todate") { print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."'>"; } ?></a></td>
<td>moneyBack</td>
<td><img src=./_rootimages/domain.gif border=0 alt='Домен'> Конец</td>
<td><img src=./_rootimages/hosting.gif border=0 alt='Хостинг'> Статус</td>
<td><img src=./_rootimages/domain.gif border=0 alt='Домен'> Статус</td>
<td></td>
</tr>
<?
$r=@mysql_query("select o.*,TO_DAYS(o.todate)-TO_DAYS(NOW()) as leftdays,t.vid$select from orders as o, tarifs as t $where order by o.$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)) {
getfont();
$u=mysql_query("select * from users where id = '$rr->uid'");
$u=mysql_fetch_object($u);
$t=mysql_query("select * from tarifs where id = '$rr->tarif'");
$t=mysql_fetch_object($t);
$b=mysql_query("select * from bills where archived=0 and host_id = '$rr->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$bills=mysql_num_rows($b);
$b=mysql_fetch_object($b);
if ($rr->leftdays > 0 and ($t->vid == "hosting" or $t->vid == "reseller" or $t->vid == "vds") and !$rr->testPeriod) {
$moneyBack = GetMoneyBackByOrderId($rr->id)." ".CURAS;
} else {
$moneyBack = "-";
}
if ($rr->leftdays == "") {$rr->leftdays=0;}
if ($rr->leftdays <= 10 and $rr->startdate != "0000-00-00") {$rr->leftdays = "<font color=red>".$rr->leftdays."</font>";}
$statusHosting="<img src=./_rootimages/obrabotan_".$rr->status."_small.gif border=0 alt='".$_status[$rr->status]."'>";
if ($rr->testPeriod) { $statusHosting = $statusHosting." <img src=./_rootimages/test_small.gif border=0 alt='Тестовый период'>"; }
$toDateHosting=mydate($rr->todate);
$leftDaysHosting="<label alt='осталось дней'>[$rr->leftdays]</label>";
if ($rr->startdate != "0000-00-00" or ($rr->testPeriod and $rr->serverlogin)) { $toDateHostingTxt = "$toDateHosting $leftDaysHosting"; } else { $toDateHostingTxt = "-"; }
$statusDomain = "";
$toDateDomain = "";
$leftDaysDomain = "";
$toDateDomainTxt = "";
$cert = "";
if ($rr->domain_reg == "1" or $rr->domain_reg == "3") {
$d=@mysql_query("select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays from orders_domains where host_id='$rr->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$d=mysql_fetch_object($d);
$cert=mysql_query("select * from orders_domainscert where domain_id = '$d->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$cert=mysql_num_rows($cert);
if ($cert) { $cert = " [<a href=?do=domainscerts&show=all¶m=d.domain&search=$d->domain>сертификат</a>]"; } else { $cert = "";}
if ($d->leftdays == "") {$d->leftdays=0;}
if ($d->leftdays <= 30 and $d->startdate != "0000-00-00") {$d->leftdays = "<font color=red>".$d->leftdays."</font>";}
$statusDomain = "<img src=./_rootimages/obrabotan_".$d->status."_small.gif border=0 alt='".$_status[$d->status]."'>";
$toDateDomain = mydate($d->todate);
$leftDaysDomain = "<label alt='осталось дней'>[$d->leftdays]</label>";
if ($d->startdate != "0000-00-00") { $toDateDomainTxt = "$toDateDomain $leftDaysDomain"; } else { $toDateDomainTxt = "-";}
}
if ($rr->domain) { $domainTxt = "<B>$rr->domain</b><BR>"; }
else { $domainTxt = ""; }
$orderAddons = mb_split(":x:", $rr->addons);
sort($orderAddons);
$lastaddon='';
$orderAddonsTxt='';
while (list($k,$v) = @each($orderAddons)) {
if ($v) {
$oneAddon=GetAddonById($v);
if ($oneAddon->id) {
if ($lastaddon) {$orderAddonsTxt .= "<BR>";}
$orderAddonsTxt .= "- $oneAddon->name";
$lastaddon=$oneAddon->textid;
}
}
}
if ($orderAddonsTxt) {
$addons=" <img src=./_rootimages/addons2.gif alt='<B>".$_lang[OrderAddons].":</b><BR>$orderAddonsTxt'>";
} else {
$addons="";
}
if ($rr->archived and $rr->history) {
$orderHistoryTxt = $rr->history;
} else if ($rr->archived) {
$orderHistoryTxt = "<B>Тариф:</b> $t->name";
if ($rr->domain) { $orderHistoryTxt .= ", <B>домен:</b> $rr->domain"; }
}
$remarkTxt = "";
if ($rr->comment) { $orderHistoryTxt .= "<BR><B>Комментарий клиента:</b> $rr->comment"; $remarkTxt .= "<B>Комментарий клиента:</b> $rr->comment<BR>"; }
if ($rr->remark) { $orderHistoryTxt .= "<BR><B>Заметки для админа:</b> $rr->remark"; $remarkTxt .= "<B>Заметки для админа:</b> $rr->remark<BR>"; }
if ($rr->remarkUser) { $orderHistoryTxt .= "<BR><B>Заметки для клиента:</b> $rr->remark"; $remarkTxt .= "<B>Заметки для клиента:</b> $rr->remarkUser<BR>"; }
if ($remarkTxt) { $remarkTxt = preg_replace("/rn/ui","<BR>",$remarkTxt); $remarkTxt = " <img src=./_rootimages/question.gif alt="$remarkTxt">"; }
print "<tr bgcolor=$font_row height=30>";
print "<td align=center width=20><input type=checkbox name=elementsToCheck[] value=$rr->id>";
print "<td align=center width=20>";
if (!$rr->archived) {
print "<a href=?do=$do&sub=delete&id=$rr->id onclick="javascript: return confirm('Будет удален заказ, а так же все счета, относящиесу к нему. Вы уверены, что хотите удалить заказ?');"><img src=./_rootimages/del.gif border=0 alt='Удалить заказ'></a>";
} else {
print "<a href=?do=$do&sub=deletearchived&id=$rr->id onclick="javascript: return confirm('Вы уверены, что хотите удалить заказ?');"><img src=./_rootimages/del.gif border=0 alt='Удалить заказ'></a>";
}
print "</td>";
print "
<td align=center>$rr->id</td>
<td align=center>".mydate($rr->orderdate)."</td>
<td align=center><a href=?do=fullinfo&id=$u->id>$u->login</a></td>
";
if (!$rr->archived) {
print "
<td>".$domainTxt."[".$_newregmin[$rr->domain_reg]."]$cert</td>
<td align=center>$t->name$addons$remarkTxt</td>
<td align=center nowrap>$toDateHostingTxt</td>
<td align=center>$moneyBack</td>
<td align=center nowrap>$toDateDomainTxt</td>
<td align=center>$statusHosting</font></td>
<td align=center>$statusDomain</font></td>
";
} else {
print "<td colspan=7>$orderHistoryTxt</td>";
}
print "<td align=center>";
if (!$rr->archived) {
print "<a href=?do=editorder&host_id=$rr->id><img src=./_rootimages/edit.gif border=0 alt='Редактировать заказ'></a>";
print "<A href=?do=bills¶m=host_id&search=$rr->id><img src=./_rootimages/bills.gif border=0 alt='Счета по данному заказу: $bills'></a>";
}
print "</td>";
print "</tr>";
$cnt++;
}
?>
<tr bgcolor=<? print $font_head?>><Td colspan=14>Всего заказов: <? print $rows?>, заказов на странице: <? print $cnt?></td></tr>
<tr><td colspan=14 align=right><? print $txt?></td></tr>
</table>
Отмеченные заказы: <input type=submit value=Удалить>
</form>
<?
?>