本文整理汇总了PHP中main::uidtopack方法的典型用法代码示例。如果您正苦于以下问题:PHP main::uidtopack方法的具体用法?PHP main::uidtopack怎么用?PHP main::uidtopack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类main
的用法示例。
在下文中一共展示了main::uidtopack方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($serverId = null)
{
global $dbh, $postvar, $getvar, $instance;
if (!is_null($serverId)) {
$this->server = (int) $serverId;
$server_details = $this->serverDetails($this->server);
} elseif ($getvar['do']) {
//Suspend and stuff
$clients_package = main::uidtopack($getvar['do']);
$pid = $clients_package['packages']['id'];
$packages_data = $dbh->select("packages", array("id", "=", $pid), 0, "1");
$this->server = $packages_data['server'];
$server_details = $this->serverDetails($this->server);
}
if ($server_details['dnstemplate']) {
$this->dnstemplate = $server_details['dnstemplate'];
}
$this->welcome_email = $server_details['welcome'];
}
示例2: ChangeClientPackage
private function ChangeClientPackage()
{
global $dbh, $postvar, $getvar, $instance;
$new_pack = $postvar['newpackage'];
$immediately = $postvar['immediately'];
$userid = $getvar['do'];
if (is_numeric($new_pack) && is_numeric($userid)) {
$upack_info = main::uidtopack($userid);
if ($upack_info['packages']['id'] == $new_pack) {
main::errors("The user is already on the package specified. Please choose a different package if you wish to change their package.");
} else {
$new_pack_info = $dbh->select("packages", array("id", "=", $new_pack));
if ($new_pack_info['server'] != $upack_info['packages']['server']) {
$new_server = 1;
}
if (!$immediately || $new_pack_info['type'] == "p2h") {
$response = upgrade::prorate($new_pack, "", $userid, 1);
if ($response == "now") {
$immediately = 1;
}
if (substr_count($response, "check")) {
$no_upgrade = 1;
}
}
if ($immediately) {
if ($new_server) {
$flags = "7";
$message = "The user has been upgraded and is now <font color = '#779500'>on the new server</font>. Please be sure to remove the account on the old server when the user has migrated their website.";
} else {
$flags = "0";
$message = "The user has been upgraded.";
}
} else {
if ($new_server) {
$flags = "4";
$message = "The user has been prepared for their upgrade <font color = '#779500'>on the new server</font> at the end of their current billing cycle.";
} else {
$flags = "1";
$message = "The user has been prepared for their upgrade at the end of their current billing cycle.";
}
}
if ($no_upgrade) {
main::errors("The user cannot be changed to a P2H package until they have entered their credentials. To do this, have the user log in and try to upgrade to the P2H package. If the upgrade fails, the credentials are saved and you'll be able to upgrade them using this method. If the upgrade succeeds, you don't need to do anything. If the upgrade requires your approval, you'll be notified via email.");
} else {
$existing_upgrade = $dbh->select("upgrade", array("uid", "=", $userid));
if ($existing_upgrade) {
$upgrade_update = array("created" => time(), "newpack" => $new_pack, "flags" => $flags);
$dbh->update("upgrade", $upgrade_update, array("id", "=", $existing_upgrade['id']), "1");
} else {
$upgrade_insert = array("created" => time(), "newpack" => $new_pack, "flags" => $flags, "uid" => $userid);
$dbh->insert("upgrade", $upgrade_insert);
}
$existing_upgrade = $dbh->select("upgrade", array("uid", "=", $userid));
$done = upgrade::do_upgrade($existing_upgrade['id'], "Update", 1);
if ($done === false) {
$dbh->delete("upgrade", array("id", "=", $existing_upgrade['id']), "1");
echo "<br><br>";
} else {
main::errors($message);
}
}
}
}
}
示例3: content
public function content()
{
global $dbh, $postvar, $getvar, $instance;
if (main::isint(str_replace("P2H-", "", $getvar['view']))) {
//Display the invoice
if (substr_count($getvar['view'], "P2H-")) {
$p2hid = str_replace("P2H-", "", $getvar['view']);
$userid = $dbh->select("users", array("id", "=", $p2hid));
$userid = $userid['id'];
$userdata = coupons::admin_userdata($userid);
} else {
$invoiceid = $getvar['view'];
$invoice_data_top = $dbh->select("invoices", array("id", "=", $invoiceid));
$pid = $invoice_data_top['pid'];
$userid = $invoice_data_top['uid'];
$uidtopack = main::uidtopack($userid, $pid);
if (!$pid) {
$dbh->update("invoices", array("pid" => $uidtopack['pid']), array("id", "=", $invoice_data_top['id']));
}
$userdata = coupons::admin_userdata($userid);
}
if ($_POST['submitaddcoupon']) {
if (!$postvar['addcoupon']) {
main::errors("Please enter a coupon code.");
} else {
$coupcode = $postvar['addcoupon'];
$user = main::uname($userid);
$pack_data = main::uidtopack($userid, $pid);
$packid = $pack_data['packages']['id'];
$multi_coupons = $dbh->config("multicoupons");
if ($p2hid) {
$monthly = $pack_data['additional']['monthly'];
$monthly = coupons::get_discount("p2hmonthly", $monthly, $userid);
$total_posted = coupons::totalposts($userid);
$amt_owed = max(0, $monthly - $total_posted);
} else {
$invoice_info = $dbh->select("invoices", array("id", "=", $invoiceid));
if ($invoice_info['pid'] != $pack_data['pid']) {
$pack_data = upgrade::pidtobak($invoice_info['pid'], $invoice_info["uid"]);
}
$total_paid = coupons::totalpaid($invoiceid);
$amt_owed = max(0, $invoice_info['amount'] - $total_paid);
}
if ($amt_owed == 0) {
main::errors("The user's balance is already paid in full, so you can't add another coupon.");
} else {
$coupon_info = coupons::coupon_data($coupcode);
$coupid = $coupon_info['id'];
$use_coupon = coupons::use_coupon($coupid, $packid, $invoiceid, $userid);
if (!$use_coupon) {
if (!$multi_coupons) {
main::errors("Coupon code entered was invalid or user is already using a coupon. You can give them a credit instead.");
} else {
main::errors("Coupon code entered was invalid or the user is already using this coupon.");
}
} else {
main::redirect("?page=invoices&view=" . $getvar['view']);
}
}
}
}
if ($_POST['submitcredit']) {
$postvar['credit'] = str_replace(array(" ", ","), array("", "."), $postvar['credit']);
if (!is_numeric($postvar['credit'])) {
main::errors("Please enter the amount to be credited or debited.");
} else {
if ($postvar['creditreason']) {
$creditreason = $postvar['creditreason'];
$creditreason = ' <a title="' . $creditreason . '" class="tooltip"><img src="<URL>themes/icons/information.png"></a>';
$creditreason = str_replace(",", "", $creditreason);
//Can't have commas, no way no how! ;) lol We need to be able to explode(",", $invoice_info['txn']);
}
if ($p2hid) {
$credit_fee = $postvar['credit'];
} else {
$credit_fee = main::addzeros($postvar['credit']);
}
if ($credit_fee != 0) {
if (substr_count($credit_fee, "-")) {
$creditfee_lable = "CHARGE";
} else {
$creditfee_lable = "CREDIT";
}
$packinfo = main::uidtopack($userid, $pid);
if (!$packinfo['user_data']['pid'] && !$p2hid) {
$packinfo = upgrade::pidtobak($pid, $userid);
}
$monthly = $packinfo['additional']['monthly'];
if ($p2hid) {
$amt_owed = max(0, $monthly - coupons::totalposts($userid));
} else {
$amt_owed = max(0, $monthly - coupons::totalpaid($invoiceid));
}
if ($amt_owed == 0 && $creditfee_lable == "CREDIT") {
main::errors("The user's balance is already paid in full, so you can't add a credit.");
} else {
if ($p2hid) {
$p2h_info = $dbh->select("coupons_p2h", array("uid", "=", $userid));
if ($p2h_info['datepaid']) {
$comma = ",";
//.........这里部分代码省略.........
示例4: do_upgrade
public function do_upgrade($upgradeid, $mode, $no_errors_out = 0)
{
global $dbh, $postvar, $getvar, $instance;
//$mode
//
//Init - When the upgrade info is added, we call this function.
//Update - When cron or an admin does something with this function, we check to see if various tasks are ready to be performed.
//Flag meaning:
//
//IMMEDIATE UPGRADE FLAGS
//
//0 - Upgrade is immediate.
//5 - If admin approves the upgrade, then the upgrade will be immediate.
//
//6 - If admin approves the upgrade, then the new account will be created on the new server and the
// admin will know that they are moving to a new server so they can manually close the old account
// when they're ready.
//
//7 - The new account on the new server will be immediately created and the admin will be notified that
// the user is switching servers.
//
//NEXT MONTH UPGRADE FLAGS
//
//1 - Cron will upgrade them next month.
//2 - If admin approves this, then it will be set to 1 for cron to upgrade them next month.
//3 - The admin will be notified that the user wishes to be upgraded and if they approve it,
// then an account on the new server will be created so they can migrate to the new server.
// the admin can opt to switch the account over before next month if they both agree and the
// switch will be made in the admin area manually.
//
//4 - Cron will create a new account on the new server next month and inform the admin that the
// user is changing to the new server.
//
$upgrade_data = $dbh->select("upgrade", array("id", "=", $upgradeid));
$userid = $upgrade_data['uid'];
$newpack = $upgrade_data['newpack'];
$flags = $upgrade_data['flags'];
$created = $upgrade_data['created'];
$coupcode = $upgrade_data['coupcode'];
$user_data = main::uidtopack($userid);
$current_pack_type = $user_data['packages']['type'];
$current_pack_name = $user_data['packages']['name'];
$current_pack_id = $user_data['packages']['id'];
$user_info = $dbh->select("users", array("id", "=", $userid));
$user_email = $user_info['email'];
$username = $user_info['user'];
$new_plan_data = $dbh->select("packages", array("id", "=", $newpack));
$newpack_name = $new_plan_data['name'];
$new_plan_additional = type::additional($newpack);
$new_server_data = $dbh->select("servers", array("id", "=", $new_plan_data['server']));
$new_server_name = $new_server_data['name'];
$old_server_data = $dbh->select("servers", array("id", "=", $user_data['packages']['server']));
$old_server_name = $old_server_data['name'];
switch ($flags) {
case "0":
$upgrade = 1;
break;
case "1":
$upgrade_today = self::upgrade_today($current_pack_type, $userid);
if ($upgrade_today) {
$upgrade = 1;
}
break;
case "2":
if ($mode = "Init") {
$admin_approval = 1;
} else {
//If its already the day for the upgrade, then we can do the upgrade now.
$upgrade_today = self::upgrade_today($current_pack_type, $userid);
if ($upgrade_today) {
$upgrade = 1;
}
if (!$upgrade) {
$dbh->update("upgrade", array("flags" => "1"), array("id", "=", $upgradeid), "1");
}
}
break;
case "3":
if ($mode = "Init") {
$admin_approval = 1;
$new_server = 1;
} else {
//If its already the day for the upgrade, then we can do the upgrade now.
$upgrade_today = self::upgrade_today($current_pack_type, $userid);
if ($upgrade_today) {
$upgrade = 1;
$new_server = 1;
}
if (!$upgrade) {
$dbh->update("upgrade", array("flags", "=", "4"), array("id", "=", $upgradeid), "1");
}
}
break;
case "4":
//If its already the day for the upgrade, then we can do the upgrade now.
$upgrade_today = self::upgrade_today($current_pack_type, $userid);
if ($upgrade_today) {
$upgrade = 1;
$new_server = 1;
$admin_inform = 1;
//.........这里部分代码省略.........
示例5: clientPage
public function clientPage()
{
global $dbh, $postvar, $getvar, $instance;
if (is_numeric($getvar['remove'])) {
coupons::remove_p2h_coupon($getvar['remove']);
main::redirect("?page=type&type=p2h&sub=forums");
exit;
}
if ($_POST['submitaddcoupon']) {
if (!$postvar['addcoupon']) {
main::errors("Please enter a coupon code.");
} else {
$coupcode = $postvar['addcoupon'];
$pack_data = main::uidtopack();
$packid = $pack_data['packages']['id'];
$multi_coupons = $dbh->config("multicoupons");
$coupon_info = coupons::coupon_data($coupcode);
$coupid = $coupon_info['id'];
$use_coupon = coupons::use_coupon($coupid, $packid);
if (!$use_coupon) {
if (!$multi_coupons) {
main::errors("Coupon code entered was invalid or you're already using a coupon.");
} else {
main::errors("Coupon code entered was invalid.");
}
} else {
main::redirect("?page=type&type=p2h&sub=forums");
}
}
}
$userid = $_SESSION['cuser'];
$client = $dbh->client($userid);
$forum = type::additional($client['pid'], 'forum');
$user = type::userAdditional($client['id']);
$fdetails = $this->forumdata($forum);
$this->con = $this->forumCon($forum);
$posts = $this->checkMonthly($fdetails['forumtype'], $user['fuser'], $fdetails['prefix']);
$total_posts = coupons::totalposts($userid);
$p2h_payments = $dbh->select("coupons_p2h", array("uid", "=", $userid));
$package_info = main::uidtopack($userid);
$user_posts = $this->userposts($package_info['packages']['id'], $package_info['user_data']['id']);
$monthly = $this->getMonthly($client['pid']);
if (empty($p2h_payments)) {
$p2h_pay_array = array("uid" => $userid, "amt_paid" => $user_posts, "txn" => $package_info['uadditional']['fuser'], "datepaid" => time(), "gateway" => $package_info['additional']['forum']);
$dbh->insert("coupons_p2h", $p2h_pay_array);
$p2h_payments = $dbh->select("coupons_p2h", array("uid", "=", $userid));
}
$amt_paid = $p2h_payments['amt_paid'];
$txn = $p2h_payments['txn'];
$datepaid = $p2h_payments['datepaid'];
$gateway = $p2h_payments['gateway'];
$amt_paid = explode(",", $amt_paid);
$txn = explode(",", $txn);
$datepaid = explode(",", $datepaid);
$gateway = explode(",", $gateway);
for ($i = 0; $i < count($amt_paid); $i++) {
if ($txn[$i] == $package_info['uadditional']['fuser']) {
if ($amt_paid[$i] != $user_posts) {
$reload = 1;
}
$amt_paid[$i] = $user_posts;
$datepaid[$i] = time();
}
$p2h_data = $dbh->select("p2h", array("id", "=", $gateway[$i]));
$transaction_list_array['PAIDAMOUNT'] = main::s($amt_paid[$i], " Post");
$transaction_list_array['TXN'] = $txn[$i];
$transaction_list_array['PAIDDATE'] = main::convertdate("n/d/Y", $datepaid[$i]);
$transaction_list_array['GATEWAY'] = str_replace(",", "", $p2h_data['forumname']);
$invoice_transactions_array['TXNS'] .= style::replaceVar("tpl/invoices/transaction-list.tpl", $transaction_list_array);
$paidamts = $paidamts . "," . $amt_paid[$i];
$paidtxn = $paidtxn . "," . $txn[$i];
$paiddate = $paiddate . "," . $datepaid[$i];
$paidgateway = $paidgateway . "," . $gateway[$i];
}
$paidamts = substr($paidamts, 1, strlen($paidamts));
$paidtxn = substr($paidtxn, 1, strlen($paidtxn));
$paiddate = substr($paiddate, 1, strlen($paiddate));
$paidgateway = substr($paidgateway, 1, strlen($paidgateway));
$p2h_pay_array = array("amt_paid" => $paidamts, "txn" => $paidtxn, "datepaid" => $paiddate, "gateway" => $paidgateway);
$where[] = array("uid", "=", $userid);
$dbh->update("coupons_p2h", $p2h_pay_array, $where);
if ($reload) {
main::redirect("?page=type&type=p2h&sub=forums");
}
$invoice_transactions_array['TOTALPAID'] = main::s($total_posts, " Post");
$posts_array['TRANSACTIONS'] = style::replaceVar("tpl/invoices/invoice-transactions.tpl", $invoice_transactions_array);
$pack_monthly = $package_info['additional']['monthly'];
$coupon_total = $pack_monthly - coupons::get_discount("p2hmonthly", $pack_monthly, $userid);
$balance = max(0, $monthly - $total_posts);
unset($where);
$where[] = array("user", "=", $_SESSION['cuser'], "AND");
$where[] = array("disabled", "=", "0");
$coupons_used_query = $dbh->select("coupons_used", $where, array("id", "ASC"), 0, 1);
while ($coupons_used_data = $dbh->fetch_array($coupons_used_query)) {
$valid_coupon = coupons::check_expire($coupons_used_data['coupcode']);
if ($valid_coupon) {
$multipost_text = main::s($coupons_used_data['p2hmonthlydisc'], " Post");
$coupons_list_array['COUPONAMOUNT'] = $multipost_text;
$coupons_list_array['COUPCODE'] = $coupons_used_data['coupcode'];
$coupons_list_array['REMOVE'] = $balance == 0 ? "" : '(<a href = "?page=type&type=p2h&sub=forums&remove=' . $coupons_used_data['id'] . '">Remove</a>)';
//.........这里部分代码省略.........
示例6: content
public function content()
{
global $dbh, $postvar, $getvar, $instance;
$upackinfo = main::uidtopack();
$currentpack = $upackinfo['user_data']['pid'];
$packsid = $postvar['packs'];
if (!$packsid) {
$packsid = $getvar['package'];
}
unset($where);
if (is_numeric($packsid)) {
$where[] = array("id", "=", $packsid, "AND");
} else {
$where[] = array("is_hidden", "=", "0", "AND");
}
$where[] = array("is_disabled", "=", "0", "AND");
$where[] = array("id", "!=", $currentpack);
$packages_order[] = array("type", "ASC");
$packages_order[] = array("name", "ASC");
$packages_query = $dbh->select("packages", $where, $packages_order, 0, 1);
$upgrade_array['PACK'] = "";
while ($packages_data = $dbh->fetch_array($packages_query)) {
$additional = type::additional($packages_data['id']);
$monthly = $additional['monthly'];
$signup = $additional['signup'];
unset($info);
if ($packages_data['type'] == "p2h") {
$info = "[Signup Posts: " . $signup . ", Monthly Posts: " . $monthly . "] ";
$contribution = "<strong>Signup Posts:</strong> " . $signup . "<br><strong>Monthly Posts:</strong> " . $monthly;
} elseif ($packages_data['type'] == "paid") {
$info = "[" . main::money($monthly) . "] ";
$contribution = main::money($monthly);
} else {
$contribution = "Free";
}
$packages[] = array("[" . $packages_data['type'] . "] " . $info . $packages_data['name'], $packages_data['id']);
if ($packsid && $packsid == $packages_data['id']) {
$prorate = upgrade::prorate($packages_data['id'], $postvar['coupon']);
$package_array['DISABLED'] = "";
if ($prorate == "inelegible") {
main::errors("You are currently not elegible for the plan selected because you do not have enough posts.<br><br>");
$package_array['DISABLED'] = "disabled";
}
if ($prorate == "owe") {
main::errors("You have outstanding charges on your account and can only upgrade your paid package. Your charges are outstanding! Keep up the good work. lol<br><br>");
$package_array['DISABLED'] = "disabled";
}
if ($prorate == "oweposts") {
main::errors("You still owe your required monthly posts and can only upgrade to a paid plan until you finish your posting quota. Our forum is a lot of fun, so come join us! =)<br><br>");
$package_array['DISABLED'] = "disabled";
}
if ($prorate == "next" || $prorate == "check next") {
main::errors("If you choose this package, you'll be upgraded at the start of your next billing cycle. If you do not wish to wait, please contact us.<br><br>");
$next_month = 1;
}
if (is_numeric($prorate) && $prorate > 0) {
$contribution .= " (You pay only <font color = '#FF0055'>" . main::money($prorate) . "</font> more today to upgrade.)";
}
if ($prorate == "check" || $prorate == "check next" || $prorate == "check now") {
$fuser = $postvar['fuser'];
$fpass = $postvar['fpass'];
$forum_credentials_array['FUSER'] = $fuser;
$forum_credentials_array['FPASS'] = $fpass;
$package_array['FORUMINFO'] = style::replaceVar("tpl/upgrade/forum-credentials.tpl", $forum_credentials_array);
} else {
if ($packages_data['type'] == "p2h") {
$fuser = $upackinfo['uadditional']['fuser'];
$fpass = $upackinfo['uadditional']['fpass'];
$no_fcheck = 1;
}
$package_array['FORUMINFO'] = "";
}
$coupon_entry_array['COUPCODE'] = "";
$coupon_entry_array['COUPTEXT'] = "";
$coupon_entry_array['COUPCODEVALID'] = "";
if ($packages_data['type'] == "p2h" && $prorate != "owe") {
//Paid users can enter them when they pay the invoice and free users don't need coupons.
$coupcode = $postvar['coupon'];
$validcoupon = $postvar['validcoupon'];
if ($postvar['addcoupon']) {
$uname = main::uname($_SESSION['cuser']);
if ($coupcode) {
$response = coupons::validate_coupon($coupcode, "orders", $uname, $packsid);
if ($response) {
$coup_data = coupons::coupon_data($coupcode);
$discount = $coup_data['p2hinitdisc'];
$multi_coupons = $dbh->config("multicoupons");
if ($multi_coupons) {
$discount = $discount + upgrade::get_init_discount();
}
$total_posts = coupons::totalposts($_SESSION['cuser'], $packages_data['id']) + $discount;
if ($total_posts < $signup) {
$error = 1;
main::errors("You are currently not elegible for the plan selected because you do not have enough posts.<br><br>");
$package_array['DISABLED'] = "disabled";
$coupon_entry_array['COUPCODEVALID'] = "";
} else {
$prorate = upgrade::prorate($packages_data['id'], $coupcode);
if ($prorate == "next" || $prorate == "check next" || $prorate == "inelegible") {
//We know they're eligible or they wouldn't be at this stage. It just doesn't check existing coupons.
//.........这里部分代码省略.........
示例7: totalposts
public function totalposts($userid, $packid = 0)
{
global $dbh, $postvar, $getvar, $instance;
$p2h_info = $dbh->select("coupons_p2h", array("uid", "=", $userid));
$amt_paid = $p2h_info['amt_paid'];
$txn = $p2h_info['txn'];
$datepaid = $p2h_info['datepaid'];
$gateway = $p2h_info['gateway'];
$package_info = main::uidtopack($userid);
$p2h = $instance->packtypes["p2h"];
if (!$packid) {
$packid = $package_info['packages']['id'];
}
$total_posts = $p2h->userposts($packid, $package_info['user_data']['id']);
$amt_paid = explode(",", $amt_paid);
$txn = explode(",", $txn);
$datepaid = explode(",", $datepaid);
for ($i = 0; $i < count($amt_paid); $i++) {
if ($txn[$i] == $package_info['uadditional']['fuser']) {
$found_posts = 1;
$amt_paid[$i] = $total_posts;
}
$posted = $posted + $amt_paid[$i];
}
if (!$found_posts) {
$posted = $posted + $total_posts;
}
return $posted;
}
示例8: content
public function content()
{
global $dbh, $postvar, $getvar, $instance;
if (is_numeric($getvar['view'])) {
//Show the invoice
unset($where);
$where[] = array("uid", "=", $_SESSION['cuser'], "AND");
$where[] = array("id", "=", $getvar['view']);
$invoice_info_top = $dbh->select("invoices", $where);
$pack_data_top = main::uidtopack();
if (!$invoice_info_top['pid']) {
$dbh->update("invoices", array("pid" => $pack_data_top['user_data']['pid']), array("id", "=", $invoice_info_top['id']));
$invoice_info_top['pid'] = $pack_data_top['user_data']['pid'];
}
if ($_POST['submitaddcoupon']) {
if (!$postvar['addcoupon']) {
main::errors("Please enter a coupon code or click the checkout button.");
} else {
$coupcode = $postvar['addcoupon'];
$user = main::uname($_SESSION['cuser']);
$pack_data = main::uidtopack();
if ($invoice_info_top['pid'] != $pack_data['user_data']['pid']) {
$pack_data = upgrade::pidtobak($invoice_info_top['pid']);
}
$packid = $pack_data['packages']['id'];
$multi_coupons = $dbh->config("multicoupons");
$coupon_info = coupons::coupon_data($coupcode);
$coupid = $coupon_info['id'];
$use_coupon = coupons::use_coupon($coupid, $packid, $getvar['view']);
if (!$use_coupon) {
if (!$multi_coupons) {
main::errors("Coupon code entered was invalid or you're already using a coupon.");
} else {
main::errors("Coupon code entered was invalid.");
}
} else {
main::redirect("?page=invoices&view=" . $getvar['view']);
}
}
}
unset($where);
$where[] = array("uid", "=", $_SESSION['cuser'], "AND");
$where[] = array("id", "=", $getvar['view']);
$invoice_info = $dbh->select("invoices", $where);
if (empty($invoice_info)) {
main::redirect("?page=invoices");
exit;
}
$package = $dbh->select("packages", array("id", "=", $invoice_info['pid']));
$monthly = type::additional($package['id']);
$subtotal = $monthly['monthly'];
if (is_numeric($getvar['remove'])) {
$remove_id = $getvar['remove'];
$remove = coupons::remove_coupon($remove_id, $package['id'], $invoice_info['id'], $_SESSION['cuser']);
main::redirect("?page=invoices&view=" . $invoice_info['id']);
exit;
}
$total_paid_real = coupons::totalpaid($getvar['view']);
if ($total_paid_real < 0) {
$total_paid = "0.00";
} else {
$total_paid = $total_paid_real;
}
$acct_balance = coupons::get_discount("paid", $subtotal) - $total_paid_real;
if ($acct_balance < 0) {
$acct_balance = "0.00";
}
$acct_balance = main::addzeros($acct_balance);
if ($acct_balance == 0 && $invoice_info['is_paid'] == '0') {
$dbh->update("invoices", array("is_paid" => "1"), array("id", "=", $invoice_info['id']), "1");
main::redirect("?page=invoices&view=" . $invoice_info['id']);
}
if ($acct_balance > 0 && $invoice_info['is_paid'] == '1') {
$dbh->update("invoices", array("is_paid" => "0"), array("id", "=", $invoice_info['id']), "1");
main::redirect("?page=invoices&view=" . $invoice_info['id']);
}
if ($_POST['checkout']) {
$postvar['paythis'] = str_replace(array(" ", ","), array("", "."), $postvar['paythis']);
if (!is_numeric($postvar['paythis'])) {
main::errors("Please enter the amount you wish to pay today.");
} else {
if ($postvar['paythis'] > $acct_balance || $acct_balance <= 0) {
main::errors("You can't pay more than you owe. =)");
} else {
$dbh->update("invoices", array("pay_now" => $postvar['paythis']), array("id", "=", $getvar['view']));
main::redirect("?page=invoices&iid=" . $getvar['view']);
exit;
}
}
}
$created = $invoice_info['created'];
$thirty_days = 30 * 24 * 60 * 60;
$orig_due = $created + $thirty_days;
if (main::convertdate("n/d/Y", $invoice_info['due']) != main::convertdate("n/d/Y", $created + $thirty_days)) {
$due_text = " (Originally " . main::convertdate("n/d/Y", $orig_due) . ")";
}
$due = main::convertdate("n/d/Y", $invoice_info['due']);
$client = $dbh->client($_SESSION['cuser']);
$invoice_transactions_array['TOTALAMOUNT'] = main::money($acct_balance);
$invoice_transactions_array['TOTALPAID'] = main::money($total_paid);
//.........这里部分代码省略.........