Файл: RootPanel 1.7.0 FreeCode/RootPanel 1.7.0 FreeCode/_rootadmin/_utils.inc.php
Строк: 911
<?
if ($sub == "adddays") {
checkAdminAccess('addDaysAllow',1);
if ($act == "save") {
$types = array();
reset($_lang[OrderType]);
while (list($k,$v) = each($_lang[OrderType])) {
if ($$k) {$types[] = $k;}
}
if (count($types) == 0) { $error = "Не указан тип заказов."; }
else if ($days == "0" or $days == "") { $error = "Не указано количество дней."; }
else {
if ($serverid) {$where = "and serverid='$serverid'";} else {$where = "";}
$r = @mysql_query("select * from orders where status=1 and todate>NOW() $where") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$cnt=0;
if (mysql_num_rows($r) > 0) {
while ($rr = mysql_fetch_object($r)) {
$tarif = GetTarifById($rr->tarif);
if ($tarif->id) {
if (in_array($tarif->vid, $types)) {
$cnt++;
@mysql_query("update orders set todate=DATE_ADD(todate,INTERVAL $days DAY) where id='$rr->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
writeAdminLog("Добавлено $days дней к заказу ID # $rr->id, $rr->domain");
}
}
}
}
if ($cnt > 0) {
print "Дни успешно добавлены. Обработано заказов: $cnt<BR><BR>";
} else {
print "Не найдено ни одного заказа, удовлетворящего условиям.<BR><BR>";
}
}
}
if ($error) { print "<font color=red>Ошибка: $error</font><BR><BR>";}
if (!$days) { $days = 0; }
?>
<form method=post>
<input type=hidden name=do value=<?=$do?>>
<input type=hidden name=sub value=adddays>
<input type=hidden name=act value=save>
<table border=0>
<tr><td colspan=2 bgcolor=<?=$font_head?> align=center><B>Добавление дней к заказам *</b></td></tr>
<tr><td valign=top><BR>Тип заказов:</td><td><BR>
<?
reset($_lang[OrderType]);
while (list($k,$v) = each($_lang[OrderType])) {
if ($$k) {$addon = "checked";} else {$addon = "";}
print "<input type=checkbox name=$k value=1 $addon> $v<BR>";
}
?>
</td></tr>
<tr><td><BR>Сервер:</td><td><BR><select name=serverid><option>Все сервера</option>
<?
$servers = GetServers();
while ($server = @mysql_fetch_object($servers)) {
if ($serverid == $server->id) {$addon='selected';} else {$addon='';}
print "<option value=$server->id $addon>$parenttop$server->name [$server->ip] [$server->type]</option>";
}
?>
</td></tr>
<tr><td><BR>Кол-во дней:</td><td><BR><input type=text name=days value="<?=$days?>" size=4></td></tr>
<tr><td align=center colspan=2><BR><input type=submit value=Добавить></td></tr>
<tr><td align=center colspan=2><BR>* - дни будут добавлены только к тем заказам, которые имеют статус Обработан и у которых не истек срок.</td></tr>
</table>
<?
}
if ($sub == "saveorder") {
checkAdminAccess('addOrderAllow',1);
if ($newUser and !$newLogin) { $error = "Не указан логин."; }
else if ($newUser and preg_match("/^[0-9]/ui",$newLogin)) { $error="Логин должен начинаться с a-z"; }
else if ($newUser and preg_match("/[^a-z,0-9]/ui",$newLogin)) { $error="Логин должен состоять из сиволов a-z,0-9"; }
else if ($newUser and (strlen($newLogin) < 3 or strlen($newLogin) > 10)) { $error="Длина логина должна быть от 3 до 10 символов."; }
else if ($newUser and IsLoginExists($newLogin)) { $error = "Указанный логин уже существует."; }
else if ($newUser and !$newPassword) { $error="Не указан пароль."; }
else if ($newUser and strlen($newPassword) < 6) { $error="Длина пароля не должна быть менее 6 символов."; }
else if ($newUser and !valid_email($newEmail)) { $error="Указан неправильный e-mail адрес."; }
else if (!$newUser and !$userName) { $error = "Не указан логин."; }
else if (($domain_reg == "0" or $domain_reg == "1" or $domain_reg == "3") and !$tarif_id) { $error = "Не выбран тарифный план."; }
else if ((!$domain or !$zone_id) and !$otherdomain and $domain_reg != "3" ) {$error="Не указано доменное имя.";}
else if (!$orderDate) { $error = "Не указана дата оформления заказа."; }
else if (($domain_reg == "0" or $domain_reg == "1" or $domain_reg == "3") and !$payType and !$hostToDate) { $error = "Не указано до когда оплачен хостинг."; }
else if (($domain_reg == "1" or $domain_reg == "2") and !$payType and !$domainToDate) { $error = "Не указано до когда оплачен домен."; }
else if (($domain_reg == "0" or $domain_reg == "1" or $domain_reg == "3") and $payType and !$hostMonths) { $error = "Не указано на какой срок нужно выставить счет за хостинг."; }
else if (($domain_reg == "1" or $domain_reg == "2") and $payType and !$domainMonths) { $error = "Не указано на какой срок нужно выставить счет за домен."; }
else if ($payType and $sendEmail and $attachPDF == "2" and ($orgName == "" or $orgPhone == "")) { $error = "Не указано наименование или телефон организации."; }
else {
if ($domain and $zone_id) {
$zone = GetZoneById($zone_id);
$fulldomain=$domain.".".$zone->zone;
} else {
$fulldomain=$otherdomain;
}
if ($fulldomain and $domain_reg != "2") { $r=@mysql_query("select * from orders where domain='$fulldomain' and domain_reg='0' and todate>NOW()") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error()); }
$k=@mysql_query("select * from orders_domains where domain='$fulldomain' and todate>NOW()") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (@mysql_num_rows($r) > 0) {$error="Тарифный план для указанного доменного имени уже заказан другим клиентом."; $do='';}
else if (mysql_num_rows($k) > 0) {$error="Указанное доменное имя уже заказано другим клиентом."; $do='';}
else {
if ($newUser) {
mysql_query("insert into users (login,password,email,datareg) values('$newLogin','".crypt($newPassword)."','$newEmail',NOW())") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$userId = mysql_insert_id();
mysql_query("insert into users_profile (uid,email) values('$userId','$newEmail')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$profile_id=mysql_insert_id();
@mysql_query("update users SET defaultProfileId='$profile_id' where id='$userId'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$user = GetUserById($userId);
writeAdminLog("Добавлен новый клиент ID # $userId, $newLogin");
} else {
$r = @mysql_query("select * from users where login='$userName'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$r = mysql_fetch_object($r);
$user = $r;
$userId = $r->id;
$profile_id = $r->defaultProfileId;
}
$host_id = 0;
if ($domain_reg == "0" or $domain_reg == "1" or $domain_reg == "3") {
$addonsToSave="";
while (list($k,$v) = @each($addons)) {
if ($v) {
$selectedAddon = GetAddonById($v);
$addonsToSave = $addonsToSave.":x:$selectedAddon->id";
}
}
if ( $domain_reg == "3") { $domain_reg_todb = "2"; } else { $domain_reg_todb = $domain_reg; }
if (!$payType) {
$startDate = fromMyDate($orderDate);
$toDate = fromMyDate($hostToDate);
$status = "1";
} else {
$startDate = "0000-00-00";
$toDate = "0000-00-00";
$status = "0";
}
@mysql_query("insert into orders (uid,tarif,domain,domain_reg,addons,orderdate,startdate,todate,status) values('$userId','$tarif_id','$fulldomain','$domain_reg_todb','$addonsToSave','".fromMyDate($orderDate)."','$startDate','$toDate','$status')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$host_id=mysql_insert_id();
writeAdminLog("Добавлен новый заказ ID # $host_id, $fulldomain");
}
if ($domain_reg == "1" or $domain_reg == "2") {
if (!$payType) {
$startDate = fromMyDate($orderDate);
$toDate = fromMyDate($domainToDate);
$status = "1";
} else {
$startDate = "0000-00-00";
$toDate = "0000-00-00";
$status = "0";
}
$zid=$zone->id;
@mysql_query("insert into orders_domains (uid,zone_id,host_id,domain,orderdate,startdate,todate,status,profileId) values ('$userId','$zid','$host_id','$fulldomain','".fromMyDate($orderDate)."','$startDate','$toDate','$status','$profile_id')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$domain_id=mysql_insert_id();
writeAdminLog("Добавлен новый домен ID # $domain_id, $fulldomain");
}
if ($payType) {
$host = 0;
$addonsCost = 0;
$addonsToSaveText="";
if ($domain_reg == "0" or $domain_reg == "1" or $domain_reg == "3") {
$t = GetTarifById($tarif_id);
$tarifSpecCost = GetSpecialCost($_SESSION['userId'],"tarif",$t->id);
if ($tarifSpecCost) {
$t->cost_setup = $tarifSpecCost["cost1"];
$t->cost = $tarifSpecCost["cost2"];
}
$host_setup = $t->cost_setup;
$hostcost = $t->cost;
$tsroki=@mysql_query("select discount from tarifs_sroki where tarif_id='$tarif_id' and months='$hostMonths'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (@mysql_num_rows($tsroki) > 0) {
$tsroki=mysql_fetch_object($tsroki);
$srokDiscount=$tsroki->discount;
} else {
$srokDiscount=0;
}
$host=$hostcost*$hostMonths; $host=$host-($host/100)*$srokDiscount+$host_setup;
$host=round($host,2);
@reset($addons);
while (list($k,$v) = @each($addons)) {
if ($v) {
$selectedAddon = GetAddonById($v);
if ($addonsToSaveText) {
$addonsToSaveText = $addonsToSaveText.", ".$selectedAddon->name;
} else {
$addonsToSaveText = $selectedAddon->name;
}
#Устанавливаем спец. цену, если она указана для данной доп. услуги и данного пользователя
#
$addonSpecCost = GetSpecialCost($userId,"addon",$selectedAddon->id);
if ($addonSpecCost) {
$addonsCost += $addonSpecCost["cost1"];
$addonsCost += $addonSpecCost["cost2"]*$hostMonths;
} else {
$addonsCost += $selectedAddon->cost_start;
$addonsCost += $selectedAddon->cost_monthly*$hostMonths;
}
}
}
if (!$addonsToSaveText) { $addonsToSaveText="-"; }
$addonsCost=round($addonsCost,2);
}
$dom=0;
if ($domain_reg == "1" or $domain_reg == "2") {
if ($domain_reg == "1") { $withhost = "1"; } else if ($domain_reg == "2") { $withhost = "0"; }
$domaincost = GetDomainCostForUserByZoneId($userId,$zone->id,$withhost);
$dom=$domaincost*($domainMonths/12);
$dom=round($dom,2);
if ($domain_reg == "1") {
$allsumm = $host+$dom+$addonsCost;
$domainfree = 0;
$tfreedomains=@mysql_query("select * from tarifs_freedomains where tarif_id='$tarif_id' and zone='$zone->zone' and hostmonths='$hostMonths'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (@mysql_num_rows($tfreedomains) > 0) {$domainfree=1;}
$tfreedomains=@mysql_query("select * from tarifs_freedomains where tarif_id='$tarif_id' and zone='$zone->zone' and ordersum > 0 and ordersum <= $allsumm") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (@mysql_num_rows($tfreedomains) > 0) {$domainfree=1;}
if ($domainfree) {$dom=0; $bonus=$_lang[OrderFreeDomainInZone]." .$zone";}
}
}
$allsumm = $host+$dom+$addonsCost;
@mysql_query("insert into bills (uid,host_id,domain_id,host_srok,domain_srok,money_host,money_domain,money_addons,created) values('$userId','$host_id','$domain_id','$hostMonths','$domainMonths','$host','$dom','$addonsCost',NOW())") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$bill_id=mysql_insert_id();
$sid=sprintf("%04d", $bill_id);
if ($domain_reg == "0" or $domain_reg == "1" or $domain_reg == "3") {
$tpl = GetTpl('email_touser_'.$t->vid.'_order', $user->lang);
} else if ($domain_reg == "2") {
$tpl = GetTpl('email_touser_domain_order', $user->lang);
}
$subject = $tpl[subject]; $template = $tpl[template];
if ($subject and $template and $sendEmail) {
$curr = LoadCurrencyToVariable($user->currency);
$company_name=GetSetting('company_name');
$company_url=GetSetting('company_url');
$billing_url=GetSetting('billing_url');
$support_url=GetSetting('support_url');
$manager_email=GetSetting('manager_email');
if ($userName and !$newUser) {$tl=strtolower($userName); $tp="******";}
else if ($newLogin and $newPassword and $newUser) {$tl=strtolower($newLogin); $tp=$newPassword;}
$template = str_replace('{company_name}',$company_name,$template);
$template = str_replace('{company_url}',$company_url,$template);
$template = str_replace('{billing_url}',$billing_url,$template);
$template = str_replace('{support_url}',$support_url,$template);
if ($domain_reg == "0" or $domain_reg == "1" or $domain_reg == "3") {
$template = str_replace('{tarif}',$t->name,$template);
$template = str_replace('{srok}',$hostMonths,$template);
$template = str_replace('{domain}',$fulldomain,$template);
$template = str_replace('{bonus}',$bonus,$template);
$template = str_replace('{addons}',$addonsToSaveText,$template);
$template = str_replace('{newreg}',$_newreg[$domain_reg],$template);
$template = str_replace('{login}',$tl,$template);
$template = str_replace('{password}',$tp,$template);
$template = str_replace('{schet}',$sid,$template);
$template = str_replace('{hostcost}',round($host*$curr["CURK"],2)." ".$curr["CURS"],$template);
$template = str_replace('{domaincost}',round($dom*$curr["CURK"],2)." ".$curr["CURS"],$template);
$template = str_replace('{addonscost}',round($addonsCost*$curr["CURK"],2)." ".$curr["CURS"],$template);
$template = str_replace('{cost}',round($allsumm*$curr["CURK"],2)." ".$curr["CURS"],$template);
$template = str_replace('{paymethod}','',$template);
$template = str_replace('{comment}',"",$template);
$template = str_replace('{userid}',$userId,$template);
} else if ($domain_reg == "2") {
$template = str_replace('{domain}',$fulldomain,$template);
$template = str_replace('{login}',$tl,$template);
$template = str_replace('{password}',$tp,$template);
$template = str_replace('{schet}',$sid,$template);
$template = str_replace('{domaincost}',round($dom*$curr["CURK"],2)." ".$curr["CURS"],$template);
$template = str_replace('{cost}',round($dom*$curr["CURK"],2)." ".$curr["CURS"],$template);
$template = str_replace('{srok}',($domainMonths/12),$template);
$template = str_replace('{paymethod}','',$template);
$template = str_replace('{comment}',"",$template);
$template = str_replace('{ns}',"",$template);
$template = str_replace('{userid}',$userId,$template);
}
if ($attachPDF == "1") {
$attachFile = createKvitanciya('', $bill_id, 2);
} else if ($attachPDF == "2") {
$attachFile = createFaktura('', $bill_id, 2, $orgName, $orgPhone);
}
if (!$attachFile) {$attachFile="";}
WriteMailLog($subject,$template,$userId);
sendmail($user->email,$company_name,$manager_email,$subject,$template,$attachFile);
$subject = "Duplicate: ".$subject;
$admEmails=GetAdminEmailsWhereTrueParam("sendneworder");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
sendmail($user->email,'',$user->email,$subject,$template,$attachFile);
@unlink($attachFile);
}
}
print "Данные успешно добавлены.<BR><BR><A href=?do=utils&sub=addorder>Добавить ещё</a>";
}
}
if ($error) { $sub = "addorder"; }
}
if ($sub == "addorder") {
checkAdminAccess('addOrderAllow',1);
if ($error) { print "<font color=red><B>Ошибка:</b> $error</font><BR><BR>"; }
if (!$domain_reg) { $domain_reg = 0; }
?>
<form method=post name=reg>
<input type=hidden name=do value=<?=$do?>>
<input type=hidden name=sub value=saveorder>
<table border=0>
<tr><td colspan=2 bgcolor=<?=$font_head?> align=center><B>Добавление заказа</b></td></tr>
<tr><td width=130>Клиент:</td><td nowrap><input type=radio name=newUser value=0 <? if (!$newUser) { print "checked"; } ?> onclick="hidediv('newuserdiv'); showdiv('olduserdiv');"> существующий клиент <input type=radio name=newUser value=1 <? if ($newUser) { print "checked"; } ?> onclick="hidediv('olduserdiv'); showdiv('newuserdiv');"> новый клиент</td></tr>
<tr>
<td> </td>
<td>
<div id="olduserdiv" style="display: <? if (!$newUser) { print "block;"; } else { print "none;"; } ?>">логин:
<?
$usersLogins = GetUsersLogins();
if (count($usersLogins) > 0) {
print "<select name=userName><option></option>";
while (list($key,$value) = each($usersLogins)) {
if ($userName == $value) { $userSelected = "selected"; } else { $userSelected = ""; }
print "<option value=$value $userSelected>$value</option>";
}
print "</select>";
} else {
print "нет зарегистрированных клиентов";
}
?>
</div>
<div id="newuserdiv" style="display: <? if ($newUser) { print "block;"; } else { print "none;"; } ?>">
<table>
<tr><td>логин:</td><td><input type=text name=newLogin value="<?=$newLogin?>" size=30></td></tr>
<tr><td>пароль:</td><td><input type=text name=newPassword value="<?=$newPassword?>" size=30></td></tr>
<tr><td>e-mail:</td><td><input type=text name=newEmail value="<?=$newEmail?>" size=30></td></tr>
</table>
</div>
</td>
</tr>
<tr><td colspan=2 bgcolor=<?=$font_head?> align=center><B>Параметры заказа</b></td></tr>
<tr>
<td valign=top>Тип заказа:</td>
<Td>
<input type=radio onclick="showdiv('addonsdiv'); this.form.domain.disabled=0; this.form.zone_id.disabled=0; this.form.otherdomain.disabled=0; this.form.tarif_id.disabled=0; this.form.hostToDate.disabled=0; this.form.domainToDate.disabled=1; this.form.hostMonths.disabled=0; this.form.domainMonths.disabled=1;" name=domain_reg value=0 <? if ($domain_reg == "0") { print "checked"; } ?>>домен уже зарегистрирован<BR>
<input type=radio onclick="showdiv('addonsdiv'); this.form.domain.disabled=0; this.form.zone_id.disabled=0; this.form.otherdomain.disabled=1; this.form.tarif_id.disabled=0; this.form.hostToDate.disabled=0; this.form.domainToDate.disabled=0; this.form.hostMonths.disabled=0; this.form.domainMonths.disabled=0;" name=domain_reg value=1 <? if ($domain_reg == "1") { print "checked"; } ?>>с регистрацией нового домена<BR>
<input type=radio onclick="hidediv('addonsdiv'); this.form.domain.disabled=0; this.form.zone_id.disabled=0; this.form.otherdomain.disabled=1; this.form.tarif_id.disabled=1; this.form.hostToDate.disabled=1; this.form.domainToDate.disabled=0; this.form.hostMonths.disabled=1; this.form.domainMonths.disabled=0;" name=domain_reg value=2 <? if ($domain_reg == "2") { print "checked"; } ?>>только регистрация домена<BR>
<input type=radio onclick="showdiv('addonsdiv'); this.form.domain.disabled=1; this.form.zone_id.disabled=1; this.form.otherdomain.disabled=1; this.form.tarif_id.disabled=0; this.form.hostToDate.disabled=0; this.form.domainToDate.disabled=1; this.form.hostMonths.disabled=0; this.form.domainMonths.disabled=1;" name=domain_reg value=3 <? if ($domain_reg == "3") { print "checked"; } ?>>без домена<BR>
</td>
</tr>
<tr>
<td valign=top><BR>Тарифный план:</td>
<td>
<BR><select name=tarif_id><option></option>
<?
$r=@mysql_query("select * from tarifs where NOT(vid = 'mail') order by vid,cost") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
while ($rr = mysql_fetch_object($r)) {
if ($tarif_id == $rr->id) { $tarifSelected = "selected"; } else { $tarifSelected = ""; }
if ($rr->vid == "vds" or $rr->vid == "dedicated" or $rr->vid == "vpn") { $onselect = "this.form.domain_reg[3].disabled=0"; } else { $onselect = "this.form.domain_reg[3].disabled=1;this.form.domain_reg[3].checked=0"; }
print "<option value=$rr->id $tarifSelected onclick="$onselect">$rr->name</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td><BR>Домен:</td>
<td>
<BR><input type="text" name="domain" value="<?=$domain?>"> <select name="zone_id"><option></option>
<?
$r=@mysql_query("select * from zones order by zone") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
while ($rr=mysql_fetch_object($r)) {
if ($rr->zone == $zone) {$zoneSelected='selected';} else {$zoneSelected='';}
if ($rr->autoreg) {$nAddon=" [".GetRegistratorNameById($rr->autoreg)."]";} else { $nAddon = "";}
print "<option value=$rr->id $zoneSelected>.$rr->zone$nAddon</option>";
}
?>
</select>
</td>
</tr>
<tr id="otherdomaindiv"><td> </td><td>домен в другой зоне (example.com):<BR><input type="text" name="otherdomain" value="<?=$otherdomain?>" size=30></td></tr>
<tr><td colspan="2">
<div id="addonsdiv" style="display: <? if ($domain_reg != "2") { print "block;"; } else { print "none;"; } ?>">
<table>
<tr><td width="130" valign=top><BR>Доп. услуги:</td><Td><BR>
<?
$alladdons = GetAddons();
if (@mysql_num_rows($alladdons) > 0) {
$i = 0;
while ($addon = mysql_fetch_object($alladdons)) {
if ($addons[$i] == $addon->id) { $addonSelected = "checked"; } else { $addonSelected = ""; }
print "<input type=checkbox name=addons[] value=$addon->id $addonSelected>$addon->name<BR>";
$i++;
}
} else {
print "нет";
}
?>
</td></tr>
</table>
</div>
</td></tr>
<tr><td colspan=2 bgcolor=<?=$font_head?> align=center><B>Дополнительные параметры</b></td></tr>
<tr><td>Дата заказа:</td><td><input type=text name=orderDate size=10 value="<? if (!$orderDate) { print dateNow(); } else { print $orderDate; } ?>"></td></tr>
<tr><td>Оплата:</td><td nowrap><input type=radio name=payType value=0 <? if (!$payType) { print "checked"; } ?> onclick="hidediv('payType1'); showdiv('payType0');"> заказ уже оплачен <input type=radio name=payType value=1 <? if ($payType) { print "checked"; } ?> onclick="hidediv('payType0'); showdiv('payType1');"> заказ не оплачен</td></tr>
<tr><td colspan=2>
<div id="payType0" style="display: <? if (!$payType) { print "block;"; } else { print "none;"; } ?>">
<table>
<tr><td width="130">Хостинг оплачен до:</td><td><input type=text name=hostToDate size=10 value="<? if (!$hostToDate) { print dateNow(); } else { print $hostToDate; } ?>"></td></tr>
<tr><td>Домен оплачен до:</td><td><input type=text name=domainToDate size=10 value="<? if (!$domainToDate) { print dateNow(); } else { print $domainToDate; } ?>" disabled></td></tr>
</table>
</div>
<div id="payType1" style="display: <? if ($payType) { print "block;"; } else { print "none;"; } ?>">
<table>
<tr><td width="130">Счет:</td><td>выставить клиенту счет за:</td></tr>
<tr><td></td><td>хостинг: <input type=text name=hostMonths size=1 value="<? if (!$hostMonths) { print "1"; } else { print $hostMonths; } ?>"> мес.</td></tr>
<tr><td></td><td> домен: <input type=text name=domainMonths size=1 value="<? if (!$domainMonths) { print "12"; } else { print $domainMonths; } ?>"> мес.</td></tr>
<tr><td>Письмо:</td><td><input type=checkbox name=sendEmail value=1 <? if ($sendEmail) { print "checked"; }?>> отправить email об оформлении заказа и</td></tr>
<tr><td></td><td>
<input onclick="hidediv('organization');" type=radio name=attachPDF value=0 <? if (!$attachPDF) { print "checked"; }?>> ничего не делать<BR>
<input onclick="hidediv('organization');" type=radio name=attachPDF value=1 <? if ($attachPDF == "1") { print "checked"; }?>> прикрепить квитанцию (PDF)<BR>
<input onclick="showdiv('organization');" type=radio name=attachPDF value=2 <? if ($attachPDF == "2") { print "checked"; }?>> прикрепить счет-фактуру (PDF)<BR>
<div id="organization" style="display: <? if ($attachPDF == "2") { print "block;"; } else { print "none;"; } ?>">
Плательщик: <input type=text name=orgName size=15 value="<?=$orgName?>"><BR>
Телефон: <input type=text name=orgPhone size=15 value="<?=$orgPhone?>"><BR>
</div>
</td></tr>
</table>
</div>
</td></tr>
<tr><td colspan=2 align=center><BR><input type=submit value=Добавить></td></tr>
</table>
</form>
<script>
eval(document.forms[0].domain_reg[<?=$domain_reg?>].onclick());
</script>
<?
}
if ($sub == "saveshoporder") {
checkAdminAccess('addOrderAllow',1);
if ($newUser and !$newLogin) { $error = "Не указан логин."; }
else if ($newUser and preg_match("/^[0-9]/ui",$newLogin)) { $error="Логин должен начинаться с a-z"; }
else if ($newUser and preg_match("/[^a-z0-9]/ui",$newLogin)) { $error="Логин должен состоять из сиволов a-z,0-9"; }
else if ($newUser and (strlen($newLogin) < 3 or strlen($newLogin) > 10)) { $error="Длина логина должна быть от 3 до 10 символов."; }
else if ($newUser and IsLoginExists($newLogin)) { $error = "Указанный логин уже существует."; }
else if ($newUser and !$newPassword) { $error="Не указан пароль."; }
else if ($newUser and strlen($newPassword) < 6) { $error="Длина пароля не должна быть менее 6 символов."; }
else if ($newUser and !valid_email($newEmail)) { $error="Указан неправильный e-mail адрес."; }
else if (!$newUser and !$userName) { $error = "Не указан логин."; }
else if (!$shop_id) { $error = "Не выбран товар."; }
else if (!$orderDate) { $error = "Не указана дата оформления заказа."; }
else if (!$orderToDate) { $error = "Не указано до когда оплачен товар."; }
else {
if ($newUser) {
mysql_query("insert into users (login,password,email,datareg) values('$newLogin','".crypt($newPassword)."','$newEmail',NOW())") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$userId = mysql_insert_id();
mysql_query("insert into users_profile (uid,email) values('$userId','$newEmail')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$profile_id=mysql_insert_id();
@mysql_query("update users SET defaultProfileId='$profile_id' where id='$userId'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
writeAdminLog("Добавлен новый клиент ID # $userId, $newLogin");
} else {
$r = @mysql_query("select * from users where login='$userName'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$r = mysql_fetch_object($r);
$userId = $r->id;
}
$shopItem = GetShopItemById($shop_id);
if ($shopItem->costtype == "one") { $orderToDate = "00.00.0000"; }
@mysql_query("insert into orders_shop (uid,item,orderdate,startdate,todate,status) values('$userId','$shop_id','".fromMyDate($orderDate)."','".fromMyDate($orderDate)."','".fromMyDate($orderToDate)."','1')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$shop_id=mysql_insert_id();
writeAdminLog("Добавлен новый заказ на товр ID # $shop_id, $shopItem->name");
print "Данные успешно добавлены.<BR><BR><A href=?do=utils&sub=addshoporder>Добавить ещё</a>";
}
if ($error) { $sub = "addshoporder"; }
}
if ($sub == "addshoporder") {
checkAdminAccess('addOrderAllow',1);
if ($error) { print "<font color=red><B>Ошибка:</b> $error</font><BR><BR>"; }
?>
<form method=post name=reg>
<input type=hidden name=do value=<?=$do?>>
<input type=hidden name=sub value=saveshoporder>
<table border=0>
<tr><td colspan=2 bgcolor=<?=$font_head?> align=center><B>Добавление заказа на товар</b></td></tr>
<tr><td width=130>Клиент:</td><td nowrap><input type=radio name=newUser value=0 <? if (!$newUser) { print "checked"; } ?> onclick="hidediv('newuserdiv'); showdiv('olduserdiv');"> существующий клиент <input type=radio name=newUser value=1 <? if ($newUser) { print "checked"; } ?> onclick="hidediv('olduserdiv'); showdiv('newuserdiv');"> новый клиент</td></tr>
<tr>
<td> </td>
<td>
<div id="olduserdiv" style="display: <? if (!$newUser) { print "block;"; } else { print "none;"; } ?>">логин:
<?
$usersLogins = GetUsersLogins();
if (count($usersLogins) > 0) {
print "<select name=userName><option></option>";
while (list($key,$value) = each($usersLogins)) {
if ($userName == $value) { $userSelected = "selected"; } else { $userSelected = ""; }
print "<option value=$value $userSelected>$value</option>";
}
print "</select>";
} else {
print "нет зарегистрированных клиентов";
}
?>
</div>
<div id="newuserdiv" style="display: <? if ($newUser) { print "block;"; } else { print "none;"; } ?>">
<table>
<tr><td>логин:</td><td><input type=text name=newLogin value="<?=$newLogin?>" size=30></td></tr>
<tr><td>пароль:</td><td><input type=text name=newPassword value="<?=$newPassword?>" size=30></td></tr>
<tr><td>e-mail:</td><td><input type=text name=newEmail value="<?=$newEmail?>" size=30></td></tr>
</table>
</div>
</td>
</tr>
<tr>
<td valign=top><BR>Товар:</td>
<td>
<BR><select name=shop_id><option></option>
<?
$r=GetShopItems();
while ($rr = mysql_fetch_object($r)) {
if ($shop_id == $rr->id) { $tarifSelected = "selected"; } else { $tarifSelected = ""; }
print "<option value=$rr->id $tarifSelected>$rr->name</option>";
}
?>
</select>
</td>
</tr>
<tr><td><BR>Дата заказа:</td><td><BR><input type=text name=orderDate size=10 value="<? if (!$orderDate) { print dateNow(); } else { print $orderDate; } ?>"></td></tr>
<tr><td>Товар оплачен до:</td><td><input type=text name=orderToDate size=10 value="<? if (!$orderToDate) { print dateNow(); } else { print $orderToDate; } ?>"></td></tr>
<tr><td colspan=2 align=center><BR><input type=submit value=Добавить></td></tr>
</table>
</form>
<?
}
?>