Файл: _rootadmin/_editbill.inc.php
Строк: 297
<?
$r=@mysql_query("select * from bills where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($r) > 0) {
$r=mysql_fetch_object($r);
print menu_admin_client($r->uid);
if ($sub == 'edit') {
checkAdminAccess('billsEdit',1);
@mysql_query("update bills set remark='$remark' where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if ($r->host_id and !$r->newaddons) {
@mysql_query("update bills set host_srok='$host_srok',money_host='$money_host',money_addons='$money_addons' where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
else if ($r->host_id and $r->newaddons) {
@mysql_query("update bills set money_addons='$money_addons' where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
if ($r->domain_id) {
@mysql_query("update bills set domain_srok='$domain_srok',money_domain='$money_domain' where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
if ($r->addfunds or $r->money) {
@mysql_query("update bills set money='$money' where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
if ($r->shop_id) {
@mysql_query("update bills set shop_srok='$shop_srok',money_shop='$money_shop' where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
$oldStatus = $r->status;
if ($status != $oldStatus) {
if ($status) {
MakeBillPayed($id, $status, 'Administrator');
}
else if (!$status) {
@mysql_query("update bills set payed='0000-00-00',payeddt='0000-00-00 00:00:00',status='$status' where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if ($r->host_id) {
@mysql_query("update orders set todate=DATE_SUB(todate,INTERVAL ".($host_srok*30)." DAY) where id='$r->host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$q=@mysql_query("select * from orders where startdate>=todate and id='$r->host_id' and archived=0") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($q) > 0) {
@mysql_query("update orders set startdate='0000-00-00',todate='0000-00-00' where id='$r->host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
if ($r->domain_id) {
@mysql_query("update orders_domains set todate=DATE_SUB(todate,INTERVAL $domain_srok MONTH) where id='$r->domain_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$q=@mysql_query("select * from orders_domains where startdate>=todate and id='$r->domain_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($q) > 0) {
@mysql_query("update orders_domains set startdate='0000-00-00',todate='0000-00-00' where id='$r->domain_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
if ($r->shop_id) {
$orderShop = GetOrderShopById($r->shop_id);
$shopItem = GetShopItemById($orderShop->item);
if ($shopItem->costtype != "one") {
@mysql_query("update orders_shop set todate=DATE_SUB(todate,INTERVAL $shop_srok MONTH) where id='$r->shop_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$q=@mysql_query("select * from orders_shop where startdate>=todate and id='$r->shop_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($q) > 0) {
@mysql_query("update orders_shop set startdate='0000-00-00',todate='0000-00-00' where id='$r->shop_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
} else {
@mysql_query("update orders_shop set startdate='0000-00-00',todate='0000-00-00' where id='$r->shop_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
if ($r->addfunds) {
@mysql_query("update users set money=money-$r->money where id='$r->uid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
}
writeAdminLog("Изменен статус счета ID # $id c ".$_statusBill[$oldStatus]." на ".$_statusBill[$status]);
}
writeAdminLog("Изменен счет ID # $id");
print "Данные успешно изменены.<BR><BR>";
$r=@mysql_query("select * from bills where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$r=mysql_fetch_object($r);
}
checkAdminAccess('billsRead',1);
?>
<form method=post>
<input type=hidden name=do value=<? print $do?>>
<input type=hidden name=sub value=edit>
<input type=hidden name=id value=<? print $id?>>
<input type=hidden name=mitem_id value=<? print $mitem_id?>>
<table width=400>
<tr><td colspan=2 align=center bgcolor=<? print $font_head?>><B>Редактирование счета</b></td></tr>
<tr><Td>Номер счета:</td><Td><input type=text size=30 value='<? print sprintf("%04d", $r->id)?>' readonly></td></tr>
<tr><td>Дата создания:</td><Td><input type=text size=30 value='<? print $r->created?>' readonly></td></tr>
<? if ($r->host_id and !$r->newaddons) {?><tr><Td>Срок (хостинг):</td><Td><input type=text name=host_srok size=3 value='<? print $r->host_srok?>'> мес.</td></tr><?}?>
<? if ($r->domain_id and !$r->privacy) {?><tr><Td>Срок (домен):</td><Td><input type=text name=domain_srok size=3 value='<? print $r->domain_srok?>'> мес.</td></tr><?}?>
<? if ($r->shop_id) {
$orderShop = GetOrderShopById($r->shop_id);
$shopItem = GetShopItemById($orderShop->item);
if ($shopItem->costtype != "one") {
?><tr><Td>Срок (товар):</td><Td><input type=text name=shop_srok size=3 value='<? print $r->shop_srok?>'> мес.</td></tr><?
}?>
<?}?>
<? if ($r->host_id) {
if (!$r->newaddons) { ?><tr><Td>Цена (хостинг), <? print CURAS?>:</td><Td><input type=text name=money_host size=3 value='<? print $r->money_host?>'> <? if ($r->newtarif) { print "(<b>смена тарифного плана</b>)"; } else if ($r->newserver) { print "(<b>смена сервера</b>)"; } else if ($r->newslots) { print "(<b>смена кол-ва слотов</b>)"; }?></td></tr><? }
?><tr><Td>Цена (доп. услуги), <? print CURAS?>:</td><Td><input type=text name=money_addons size=3 value='<? print $r->money_addons?>'></td></tr><?
}
if ($r->domain_id) {
if ($r->privacy) {
?><tr><Td>Цена (Privacy Protection), <? print CURAS?>:</td><Td><input type=text name=money_addons size=3 value='<? print $r->money_addons?>'></td></tr><?
} else {
?><tr><Td>Цена (домен), <? print CURAS?>:</td><Td><input type=text name=money_domain size=3 value='<? print $r->money_domain?>'></td></tr><?
}
}?>
<? if ($r->shop_id) {?><tr><Td>Цена (товар), <? print CURAS?>:</td><Td><input type=text name=money_shop size=3 value='<? print $r->money_shop?>'></td></tr><?}?>
<? if ($r->addfunds or $r->money) {?><tr><Td>Сумма, <? print CURAS?>:</td><td><input type=text name=money size=3 value='<? print $r->money?>'></td></tr><?}?>
<tr><td>Статус:</td><TD><select name=status>
<?
reset($_statusBill);
while (list($k,$v) = each($_statusBill)) {
if ($k == $r->status) {$addon='selected';} else {$addon='';}
print "<option value=$k $addon>$v</option>";
}
?>
</select>
</td></tr>
<tr><td>Дата оплаты:</td><Td><input type=text size=30 value='<? print $r->payed?>' readonly></td></tr>
<?
if ($r->promocode) { print "<tr><Td>Промокод:</td><td><input type=text name=promocode value='$r->promocode' readonly></td></tr>"; }
if ($r->comment or $r->newaddons or $r->deleteaddons) {
?> <tr><td valign=top><BR>Комментарий:</td><Td><BR> <?
if ($r->newaddons) {
print "Заказанные доп. услуги:<BR>";
$newaddons = GetAddonsIdsByTxt($r->newaddons);
while (list($k,$v) = each($newaddons)) {
$oneAddon = GetAddonById($v);
if ($oneAddon->id) {
if ($oneAddon->addonsgroup) { $addonGroup = GetAddonsGroupById($oneAddon->addonsgroup); $addonGroup = $addonGroup->name." / "; } else { $addonGroup = ""; }
print "- $addonGroup$oneAddon->name<BR>";
}
}
}
if ($r->deleteaddons) {
print "Удаленные доп. услуги:<BR>";
$deleteaddons = GetAddonsIdsByTxt($r->deleteaddons);
while (list($k,$v) = each($deleteaddons)) {
$oneAddon = GetAddonById($v);
if ($oneAddon->id) {
if ($oneAddon->addonsgroup) { $addonGroup = GetAddonsGroupById($oneAddon->addonsgroup); $addonGroup = $addonGroup->name." / "; } else { $addonGroup = ""; }
print "- $addonGroup$oneAddon->name<BR>";
}
}
}
if ($r->comment) {
print $r->comment;
}
?> </td></tr> <?
}
print "<tr><td colspan=2 align=center bgcolor=$font_head><B>Заметки (видны только администратору)</b></td></tr>";
print "<tr><Td colspan=2 align=center><textarea cols=53 rows=4 name=remark>".$r->remark."</textarea></td></tr>";
?>
<tr><td colspan=2 align=center><BR><input type=submit value="Изменить"></td></tr>
</table><BR>
<?
if ($r->isMainAttach) {
$as = @mysql_query("select * from bills where attachTo='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($as) > 0) {
print "Внимание! К данному счету прикреплены счета № ";
while ($ass = @mysql_fetch_object($as)) {
$rrr++;
if ($rrr != 1) { print ", ";}
print "<a href=?do=editbill&id=$ass->id>".sprintf("%04d", $ass->id)."</a>";
}
print "<BR><BR>";
}
}
else if ($r->attachTo) { print "Внимание! Данный счет прикреплен к счету № <a href=?do=editbill&id=$r->attachTo>".sprintf("%04d", $r->attachTo)."</a><BR><BR>"; }
?>
<? if (!$r->addfunds and !$r->money and !$r->isMainAttach) {?>
<A href=?do=editorder&<? if ($r->shop_id) {print "shop_id=$r->shop_id";} else if ($r->host_id) {print "host_id=$r->host_id";} else {print "domain_id=$r->domain_id";} ?>><img src=./_rootimages/edit.gif border=0>перейти к редактированию заказа</a>
<? } ?>
<?
} else {
print "Счет № ".sprintf("%04d", $id)." не найден.";
}
?>