public function updateClient() { global $whmcs; $exinfo = getClientsDetails($this->getID()); if (defined("ADMINAREA")) { $updatefieldsarray = array(); } else { $updatefieldsarray = array("firstname" => "First Name", "lastname" => "Last Name", "companyname" => "Company Name", "email" => "Email Address", "address1" => "Address 1", "address2" => "Address 2", "city" => "City", "state" => "State", "postcode" => "Postcode", "country" => "Country", "phonenumber" => "Phone Number", "billingcid" => "Billing Contact"); if ($whmcs->get_config("AllowClientsEmailOptOut")) { $updatefieldsarray['emailoptout'] = "Newsletter Email Opt Out"; } } $changelist = array(); $updateqry = array(); foreach ($updatefieldsarray as $field => $displayname) { if ($this->isEditableField($field)) { $value = $whmcs->get_req_var($field); if ($field == "emailoptout" && !$value) { $value = "0"; } $updateqry[$field] = $value; if ($value != $exinfo[$field]) { $changelist[] = "" . $displayname . ": '" . $exinfo[$field] . "' to '" . $value . "'"; continue; } continue; } } update_query("tblclients", $updateqry, array("id" => $this->getID())); $old_customfieldsarray = getCustomFields("client", "", $this->getID(), "", ""); $customfields = getCustomFields("client", "", $this->getID(), "", ""); foreach ($customfields as $v) { $k = $v['id']; $customfieldsarray[$k] = $_POST['customfield'][$k]; } saveCustomFields($this->getID(), $customfieldsarray); $paymentmethod = $whmcs->get_req_var("paymentmethod"); clientChangeDefaultGateway($this->getID(), $paymentmethod); if ($paymentmethod != $exinfo['defaultgateway']) { $changelist[] = "Default Payment Method: '" . getGatewayName($exinfo['defaultgateway']) . "' to '" . getGatewayName($paymentmethod) . "'<br>\n"; } run_hook("ClientEdit", array_merge(array("userid" => $this->getID(), "olddata" => $exinfo), $updateqry)); if (!defined("ADMINAREA") && $whmcs->get_config("SendEmailNotificationonUserDetailsChange")) { foreach ($old_customfieldsarray as $values) { if ($values['value'] != $_POST['customfield'][$values['id']]) { $changelist[] = $values['name'] . ": '" . $values['value'] . "' to '" . $_POST['customfield'][$values['id']] . "'"; continue; } } if (0 < count($changelist)) { $adminurl = $whmcs->get_config("SystemSSLURL") ? $whmcs->get_config("SystemSSLURL") : $whmcs->get_config("SystemURL"); $adminurl .= "/" . $whmcs->get_admin_folder_name() . "/clientssummary.php?userid=" . $this->getID(); sendAdminNotification("account", "WHMCS User Details Change", "<p>Client ID: <a href=\"" . $adminurl . "\">" . $this->getID() . " - " . $exinfo['firstname'] . " " . $exinfo['lastname'] . "</a> has requested to change his/her details as indicated below:<br><br>" . implode("<br />\n", $changelist) . "<br>If you are unhappy with any of the changes, you need to login and revert them - this is the only record of the old details.</p>"); logActivity("Client Profile Modified - " . implode(", ", $changelist) . " - User ID: " . $this->getID()); } } return true; }
function getFraudParams($fraudmodule, $userid = "", $ip = "") { global $remote_ip; if (!$userid) { $userid = $_SESSION['uid']; } include ROOTDIR . "/includes/countriescallingcodes.php"; $params = getFraudConfigOptions($fraudmodule); $params['ip'] = $ip ? $ip : $remote_ip; $params['forwardedip'] = $_SERVER['HTTP_X_FORWARDED_FOR']; $params['clientsdetails'] = getClientsDetails($userid); $countrycode = $params['clientsdetails']['country']; $params['clientsdetails']['countrycode'] = $countrycallingcodes[$countrycode]; $phonenumber = preg_replace("/[^0-9]/", "", $params['clientsdetails']['phonenumber']); $params['clientsdetails']['phonenumber'] = $phonenumber; return $params; }
/** * @link http://docs.whmcs.com/Hooks:ClientEdit * @param array $vars */ function hook_coza_client_update($vars) { $params = getRegistrarConfigOptions('coza'); $contact = getClientsDetails($vars['userid'], 0); $epp_client = \COZA\Factory::build($params); try { $epp_client->connect(); try { \COZA\Factory::updateContactIfExists($epp_client, \COZA\Factory::getContactHandle($params, (int) $vars['userid']), $contact); } catch (Exception $e) { unset($epp_client); logActivity($e->getMessage(), $vars['userid']); return; } unset($epp_client); return; } catch (Exception $e) { unset($epp_client); logActivity('COZA/ContactUpdate: ' . $e->getMessage(), $vars['userid']); return; } }
public function initPage() { global $whmcs; global $_LANG; global $clientsdetails; $this->startSmartyIfNotStarted(); if ($this->isLoggedIn()) { $this->assign("loggedin", true); if (!function_exists("getClientsDetails")) { require ROOTDIR . "/includes/clientfunctions.php"; } $clientsdetails = getClientsDetails(); $this->assign("clientsdetails", $clientsdetails); $this->assign("clientsstats", getClientsStats($_SESSION['uid'])); if (isset($_SESSION['cid'])) { $result = select_query("tblcontacts", "id,firstname,lastname,email,permissions", array("id" => $_SESSION['cid'], "userid" => $_SESSION['uid'])); $data = mysql_fetch_array($result); $loggedinuser = array("contactid" => $data['id'], "firstname" => $data['firstname'], "lastname" => $data['lastname'], "email" => $data['email']); $contactpermissions = explode(",", $data[4]); } else { $loggedinuser = array("userid" => $_SESSION['uid'], "firstname" => $clientsdetails['firstname'], "lastname" => $clientsdetails['lastname'], "email" => $clientsdetails['email']); $contactpermissions = array("profile", "contacts", "products", "manageproducts", "domains", "managedomains", "invoices", "tickets", "affiliates", "emails", "orders"); } $this->assign("loggedinuser", $loggedinuser); $this->assign("contactpermissions", $contactpermissions); return null; } $this->assign("loggedin", false); }
function RegTransferDomain($paramvars) { global $CONFIG; $domainid = $paramvars['domainid']; $passedepp = $paramvars['transfersecret']; $result = select_query("tbldomains", "", array("id" => $domainid)); $data = mysql_fetch_array($result); $userid = $data['userid']; $domain = $data['domain']; $orderid = $data['orderid']; $registrar = $data['registrar']; $registrationperiod = $data['registrationperiod']; $dnsmanagement = $data['dnsmanagement'] ? true : false; $emailforwarding = $data['emailforwarding'] ? true : false; $idprotection = $data['idprotection'] ? true : false; $domainparts = explode(".", $domain, 2); $result = select_query("tblorders", "contactid,nameservers,transfersecret", array("id" => $orderid)); $data = mysql_fetch_array($result); $contactid = $data['contactid']; $nameservers = $data['nameservers']; $transfersecret = $data['transfersecret']; if (!function_exists("getClientsDetails")) { require dirname(__FILE__) . "/clientfunctions.php"; } $clientsdetails = getClientsDetails($userid, $contactid); $clientsdetails['fullstate'] = $clientsdetails['state']; $clientsdetails['state'] = convertStateToCode($clientsdetails['state'], $clientsdetails['country']); global $params; $params = array_merge($paramvars, $clientsdetails); $params['registrar'] = $registrar; $params['sld'] = $domainparts[0]; $params['tld'] = $domainparts[1]; $params['regperiod'] = $registrationperiod; $params['dnsmanagement'] = $dnsmanagement; $params['emailforwarding'] = $emailforwarding; $params['idprotection'] = $idprotection; if ($CONFIG['RegistrarAdminUseClientDetails'] == "on") { $params['adminfirstname'] = $clientsdetails['firstname']; $params['adminlastname'] = $clientsdetails['lastname']; $params['admincompanyname'] = $clientsdetails['companyname']; $params['adminemail'] = $clientsdetails['email']; $params['adminaddress1'] = $clientsdetails['address1']; $params['adminaddress2'] = $clientsdetails['address2']; $params['admincity'] = $clientsdetails['city']; $params['adminfullstate'] = $clientsdetails['fullstate']; $params['adminstate'] = $clientsdetails['state']; $params['adminpostcode'] = $clientsdetails['postcode']; $params['admincountry'] = $clientsdetails['country']; $params['adminphonenumber'] = $clientsdetails['phonenumber']; } else { $params['adminfirstname'] = $CONFIG['RegistrarAdminFirstName']; $params['adminlastname'] = $CONFIG['RegistrarAdminLastName']; $params['admincompanyname'] = $CONFIG['RegistrarAdminCompanyName']; $params['adminemail'] = $CONFIG['RegistrarAdminEmailAddress']; $params['adminaddress1'] = $CONFIG['RegistrarAdminAddress1']; $params['adminaddress2'] = $CONFIG['RegistrarAdminAddress2']; $params['admincity'] = $CONFIG['RegistrarAdminCity']; $params['adminstate'] = $CONFIG['RegistrarAdminStateProvince']; $params['adminpostcode'] = $CONFIG['RegistrarAdminPostalCode']; $params['admincountry'] = $CONFIG['RegistrarAdminCountry']; $params['adminphonenumber'] = $CONFIG['RegistrarAdminPhone']; } require ROOTDIR . "/includes/countriescallingcodes.php"; $phonenumber = $params['phonenumber']; $adminphonenumber = $params['adminphonenumber']; $phonenumber = preg_replace("/[^0-9]/", "", $phonenumber); $adminphonenumber = preg_replace("/[^0-9]/", "", $adminphonenumber); $countrycode = $params['country']; $admincountrycode = $params['admincountry']; $countrycode = $countrycallingcodes[$countrycode]; $admincountrycode = $countrycallingcodes[$admincountrycode]; $params['fullphonenumber'] = "+" . $countrycode . "." . $phonenumber; $params['adminfullphonenumber'] = "+" . $admincountrycode . "." . $adminphonenumber; if (!$params['ns1'] && !$params['ns2']) { $result = select_query("tblorders", "nameservers", array("id" => $orderid)); $data = mysql_fetch_array($result); $nameservers = $data['nameservers']; $result = select_query("tblhosting", "server", array("domain" => $domain)); $data = mysql_fetch_array($result); $server = $data['server']; if ($server) { $result = select_query("tblservers", "", array("id" => $server)); $data = mysql_fetch_array($result); $i = 1; while ($i <= 5) { $params["ns" . $i] = trim($data["nameserver" . $i]); ++$i; } } else { if ($nameservers && $nameservers != ",") { $nameservers = explode(",", $nameservers); $i = 1; while ($i <= 5) { $params["ns" . $i] = trim($nameservers[$i - 1]); ++$i; } } else { $i = 1; while ($i <= 5) { $params["ns" . $i] = trim($CONFIG["DefaultNameserver" . $i]); ++$i; } } } } else { $i = 1; while ($i <= 5) { $params["ns" . $i] = trim($params["ns" . $i]); ++$i; } } $result = select_query("tbldomainsadditionalfields", "", array("domainid" => $domainid)); while ($data = mysql_fetch_array($result)) { $field_name = $data['name']; $field_value = $data['value']; $params['additionalfields'][$field_name] = $field_value; } $originaldetails = $params; $params = foreignChrReplace($params); $params['original'] = $originaldetails; if (!$params['transfersecret']) { $transfersecret = $transfersecret ? unserialize($transfersecret) : array(); $params['transfersecret'] = $params['eppcode'] = $transfersecret[$domain]; } else { $params['transfersecret'] = $params['eppcode'] = html_entity_decode($passedepp); } run_hook("PreDomainRegister", array("domain" => $domain)); $values = RegCallFunction($params, "TransferDomain"); if (!is_array($values)) { return false; } if ($values['na']) { logActivity("Domain Transfer Not Supported by Module - Domain ID: " . $domainid . " - Domain: " . $domain); return array("error" => "Registrar Function Not Supported"); } if ($values['error']) { logActivity("Domain Transfer Failed - Domain ID: " . $domainid . " - Domain: " . $domain . " - Error: " . $values['error'], $userid); run_hook("AfterRegistrarTransferFailed", array("params" => $params, "error" => $values['error'])); } else { update_query("tbldomains", array("status" => "Pending Transfer"), array("id" => $domainid)); $array = array("date" => "now()", "title" => "Domain Pending Transfer", "description" => "Check the transfer status of the domain " . $params['sld'] . "." . $params['tld'] . "", "admin" => "", "status" => "In Progress", "duedate" => date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 5, date("Y")))); insert_query("tbltodolist", $array); logActivity("Domain Transfer Initiated Successfully - Domain ID: " . $domainid . " - Domain: " . $domain, $userid); run_hook("AfterRegistrarTransfer", array("params" => $params)); } return $values; }
function InvoiceTotal($id) { global $CONFIG; $result = select_query("tblinvoiceitems", "", array("invoiceid" => $id)); while ($data = mysql_fetch_array($result)) { if ($data['taxed'] == "1") { $taxsubtotal += $data['amount']; } else { $nontaxsubtotal += $data['amount']; } } $subtotal = $total = $nontaxsubtotal + $taxsubtotal; $result = select_query("tblinvoices", "userid,credit,taxrate,taxrate2", array("id" => $id)); $data = mysql_fetch_array($result); $userid = $data['userid']; $credit = $data['credit']; $taxrate = $data['taxrate']; $taxrate2 = $data['taxrate2']; if (!function_exists("getClientsDetails")) { require_once dirname(__FILE__) . "/clientfunctions.php"; } $clientsdetails = getClientsDetails($userid); $tax = $tax2 = 0; if ($CONFIG['TaxEnabled'] == "on" && !$clientsdetails['taxexempt']) { if ($taxrate != "0.00") { if ($CONFIG['TaxType'] == "Inclusive") { $taxrate = $taxrate / 100 + 1; $calc1 = $taxsubtotal / $taxrate; $tax = $taxsubtotal - $calc1; } else { $taxrate = $taxrate / 100; $tax = $taxsubtotal * $taxrate; } } if ($taxrate2 != "0.00") { if ($CONFIG['TaxL2Compound']) { $taxsubtotal += $tax; } if ($CONFIG['TaxType'] == "Inclusive") { $taxrate2 = $taxrate2 / 100 + 1; $calc1 = $taxsubtotal / $taxrate2; $tax2 = $taxsubtotal - $calc1; } else { $taxrate2 = $taxrate2 / 100; $tax2 = $taxsubtotal * $taxrate2; } } $tax = round($tax, 2); $tax2 = round($tax2, 2); } if ($CONFIG['TaxType'] == "Inclusive") { $subtotal = $subtotal - $tax - $tax2; } else { $total = $subtotal + $tax + $tax2; } if (0 < $credit) { if ($total < $credit) { $total = 0; $remainingcredit = $total - $credit; } else { $total -= $credit; } } $subtotal = format_as_currency($subtotal); $tax = format_as_currency($tax); $total = format_as_currency($total); return $total; }
$ca->addToBreadCrumb('supporttickets.php', $whmcs->get_lang('supportticketspagetitle')); $ca->addToBreadCrumb('submitticket.php', $whmcs->get_lang('supportticketssubmitticket')); $ca->initPage(); ## Return custom fields if ($action == 'fetchcustomfields') { $sirportlyCustomFields = sirportlyCustomFields($deptid, $customfield); $ca->assign("customfields", $sirportlyCustomFields); echo $smarty->fetch($CONFIG['Template'] . "/supportticketsubmit-customfields.tpl"); exit; } ## Setup the menus Menu::addContext('support_module', 'sirportly'); ## Load the sirportly contact $sirportlyContact = findOrCreateSirportlyContact($_SESSION['uid'], $_SESSION['cid']); # Fetch the WHMCS client $clientDetails = getClientsDetails($_SESSION['uid'], $_SESSION['cid']); $smarty->assign("clientname", $clientDetails['fullname']); $smarty->assign("email", $clientDetails['email']); ## Departments $departments = sirportlyDepartments(); $ca->assign("departments", $departments); $ca->assign("deptid", $deptid); ## Priorities $priorities = sirportly_priorities(); $ca->assign("priorities", $priorities); $ca->assign("priorityid", $_POST['priorities']); ## Custom fields $sirportlyCustomFields = sirportlyCustomFields($deptid, $customfield); $ca->assign("customfields", $sirportlyCustomFields); $ca->assign('errormessage', $validate->getHTMLErrorOutput()); $ca->assign("allowedfiletypes", $CONFIG['TicketAllowedFileTypes']);
public function formatForOutput() { global $whmcs; global $currency; $this->output = $this->data; $array = array("date", "duedate", "datepaid"); foreach ($array as $v) { $this->output[$v] = substr($this->output[$v], 0, 10) != "0000-00-00" ? fromMySQLDate($this->output[$v], $v == "datepaid" ? "1" : "0", 1) : ""; } $this->output['datecreated'] = $this->output['date']; $this->output['datedue'] = $this->output['duedate']; $currency = getCurrency($this->getData("userid")); $array = array("subtotal", "credit", "tax", "tax2", "total", "balance", "amountpaid"); foreach ($array as $v) { $this->output[$v] = formatCurrency($this->output[$v]); } if (!function_exists("getClientsDetails")) { require ROOTDIR . "/includes/clientfunctions.php"; } $clientsdetails = getClientsDetails($this->getData("userid"), "billing"); $clientsdetails['country'] = $clientsdetails['countryname']; $this->output['clientsdetails'] = $clientsdetails; $customfields = array(); $result = select_query("tblcustomfields", "tblcustomfields.id,tblcustomfields.fieldname,(SELECT value FROM tblcustomfieldsvalues WHERE tblcustomfieldsvalues.fieldid=tblcustomfields.id AND tblcustomfieldsvalues.relid=" . (int) $this->getData("userid") . ") AS value", array("type" => "client", "showinvoice" => "on")); while ($data = mysql_fetch_assoc($result)) { if ($data['value']) { $customfields[] = $data; } } $this->output['customfields'] = $customfields; if (0 < $this->getData("taxrate")) { $taxname = getTaxRate(1, $clientsdetails['state'], $clientsdetails['countrycode']); $this->output['taxname'] = $taxname['name']; } else { $this->output['taxrate'] = "0"; } if (0 < $this->getData("taxrate2")) { $taxname = getTaxRate(2, $clientsdetails['state'], $clientsdetails['countrycode']); $this->output['taxname2'] = $taxname['name']; } else { $this->output['taxrate2'] = "0"; } $this->output['statuslocale'] = $whmcs->get_lang("invoices" . strtolower($this->output['status'])); $this->output['pagetitle'] = $whmcs->get_lang("invoicenumber") . $this->getData("invoicenum"); $this->output['payto'] = nl2br($whmcs->get_config("InvoicePayTo")); $this->output['notes'] = nl2br($this->output['notes']); $this->output['subscrid'] = get_query_val("tblinvoiceitems", "tblhosting.subscriptionid", "tblinvoiceitems.type='Hosting' AND tblinvoiceitems.invoiceid=" . $this->getData("id") . " AND tblhosting.subscriptionid!=''", "tblhosting`.`id", "ASC", "", "tblhosting ON tblhosting.id=tblinvoiceitems.relid"); $clienttotals = get_query_vals("tblinvoices", "SUM(credit),SUM(total)", array("userid" => $this->getData("userid"), "status" => "Unpaid")); $alldueinvoicespayments = get_query_val("tblaccounts", "SUM(amountin-amountout)", "invoiceid IN (SELECT id FROM tblinvoices WHERE userid=" . (int) $this->getData("userid") . " AND status='Unpaid')"); $this->output['clienttotaldue'] = formatCurrency($clienttotals[0] + $clienttotals[1]); $this->output['clientpreviousbalance'] = formatCurrency($clienttotals[1] - $this->getData("total")); $this->output['clientbalancedue'] = formatCurrency($clienttotals[1] - $alldueinvoicespayments); $lastpayment = get_query_vals("tblaccounts", "(amountin-amountout),transid", array("invoiceid" => $this->getData("id")), "id", "DESC"); $this->output['lastpaymentamount'] = formatCurrency($lastpayment[0]); $this->output['lastpaymenttransid'] = $lastpayment[1]; }
function getCCVariables($invoiceid) { global $CONFIG; global $cc_encryption_hash; global $clientsdetails; if (!function_exists("paymentMethodsSelection")) { require_once dirname(__FILE__) . "/gatewayfunctions.php"; } $result = select_query("tblinvoices", "userid,total,paymentmethod", array("id" => $invoiceid)); $data = mysql_fetch_array($result); $userid = $data['userid']; $total = $data['total']; $paymentmethod = $data['paymentmethod']; $result = select_query("tblaccounts", "SUM(amountin)-SUM(amountout)", array("invoiceid" => $invoiceid)); $data = mysql_fetch_array($result); $amountpaid = $data[0]; $balance = $total - $amountpaid; if ($balance < 0) { $balance = 0; } $cchash = md5($cc_encryption_hash . $userid); $result = select_query("tblclients", "cardtype,cardlastfour,AES_DECRYPT(cardnum,'" . $cchash . "') as cardnum,AES_DECRYPT(expdate,'" . $cchash . "') as expdate,AES_DECRYPT(issuenumber,'" . $cchash . "') as issuenumber,AES_DECRYPT(startdate,'" . $cchash . "') as startdate,gatewayid", array("id" => $userid)); $data = mysql_fetch_array($result); $cardtype = $data['cardtype']; $cardnum = $data['cardnum']; $cardexp = $data['expdate']; $startdate = $data['startdate']; $issuenumber = $data['issuenumber']; $gatewayid = $data['gatewayid']; $result = select_query("tblclients", "bankname,banktype,AES_DECRYPT(bankcode,'" . $cchash . "') as bankcode,AES_DECRYPT(bankacct,'" . $cchash . "') as bankacct", array("id" => $userid)); $data = mysql_fetch_array($result); $bankname = $data['bankname']; $banktype = $data['banktype']; $bankcode = $data['bankcode']; $bankacct = $data['bankacct']; $clientsdetails = getClientsDetails($userid, "billing"); $params = getGatewayVariables($paymentmethod, $invoiceid, $balance); $params['cardtype'] = $cardtype; $params['cardnum'] = $cardnum; $params['cardexp'] = $cardexp; $params['cardstart'] = $startdate; $params['cardissuenum'] = $issuenumber; if ($banktype) { $params['bankname'] = $bankname; $params['banktype'] = $banktype; $params['bankcode'] = $bankcode; $params['bankacct'] = $bankacct; } $params['disableautocc'] = $clientsdetails['disableautocc']; $params['gatewayid'] = $gatewayid; return $params; }
function calcCartTotals($checkout = "", $ignorenoconfig = "") { global $CONFIG; global $_LANG; global $remote_ip; global $currency; global $promo_data; $cart_total = $cart_discount = $cart_tax = 0; run_hook("PreCalculateCartTotals", $_SESSION['cart']); if (!$ignorenoconfig) { if (array_key_exists("products", $_SESSION['cart'])) { foreach ($_SESSION['cart']['products'] as $key => $productdata) { if ($productdata['noconfig']) { unset($_SESSION['cart']['products'][$key]); continue; } } } $bundlewarnings = bundlesValidateCheckout(); if (array_key_exists("products", $_SESSION['cart'])) { $_SESSION['cart']['products'] = array_values($_SESSION['cart']['products']); } } if ($checkout) { if (!$_SESSION['cart']) { return false; } run_hook("PreShoppingCartCheckout", $_SESSION['cart']); $order_number = generateUniqueID(); $paymentmethod = $_SESSION['cart']['paymentmethod']; $availablegateways = getAvailableOrderPaymentGateways(); if (!array_key_exists($paymentmethod, $availablegateways)) { foreach ($availablegateways as $k => $v) { $paymentmethod = $k; break; } } $userid = $_SESSION['uid']; $ordernotes = ""; if ($_SESSION['cart']['notes'] && $_SESSION['cart']['notes'] != $_LANG['ordernotesdescription']) { $ordernotes = $_SESSION['cart']['notes']; } $cartitems = count($_SESSION['cart']['products']) + count($_SESSION['cart']['addons']) + count($_SESSION['cart']['domains']) + count($_SESSION['cart']['renewals']); if (!$cartitems) { return false; } $orderid = insert_query("tblorders", array("ordernum" => $order_number, "userid" => $userid, "contactid" => $_SESSION['cart']['contact'], "date" => "now()", "status" => "Pending", "paymentmethod" => $paymentmethod, "ipaddress" => $remote_ip, "notes" => $ordernotes)); logActivity("New Order Placed - Order ID: " . $orderid . " - User ID: " . $userid); $domaineppcodes = array(); } $promotioncode = array_key_exists("promo", $_SESSION['cart']) ? $_SESSION['cart']['promo'] : ""; if ($promotioncode) { $result = select_query("tblpromotions", "", array("code" => $promotioncode)); $promo_data = mysql_fetch_array($result); } if (!isset($_SESSION['uid'])) { if (!$_SESSION['cart']['user']['country']) { $_SESSION['cart']['user']['country'] = $CONFIG['DefaultCountry']; } $state = $_SESSION['cart']['user']['state']; $country = $_SESSION['cart']['user']['country']; } else { $clientsdetails = getClientsDetails($_SESSION['uid']); $state = $clientsdetails['state']; $country = $clientsdetails['country']; } if ($CONFIG['TaxEnabled']) { $taxdata = getTaxRate(1, $state, $country); $taxname = $taxdata['name']; $taxrate = $taxdata['rate']; $rawtaxrate = $taxrate; $inctaxrate = $taxrate / 100 + 1; $taxrate /= 100; $taxdata = getTaxRate(2, $state, $country); $taxname2 = $taxdata['name']; $taxrate2 = $taxdata['rate']; $rawtaxrate2 = $taxrate2; $inctaxrate2 = $taxrate2 / 100 + 1; $taxrate2 /= 100; } if ($CONFIG['TaxInclusiveDeduct'] && (!$taxrate && !$taxrate2 || $clientsdetails['taxexempt'])) { $result = select_query("tbltax", "", ""); $data = mysql_fetch_array($result); $excltaxrate = 1 + $data['taxrate'] / 100; } else { $CONFIG['TaxInclusiveDeduct'] = 0; } $cartdata = $productsarray = $tempdomains = $orderproductids = $orderdomainids = $orderaddonids = $orderrenewalids = $freedomains = array(); $recurring_cycles_total = array("monthly" => 0, "quarterly" => 0, "semiannually" => 0, "annually" => 0, "biennially" => 0, "triennially" => 0); if (array_key_exists("products", $_SESSION['cart']) && is_array($_SESSION['cart']['products'])) { foreach ($_SESSION['cart']['products'] as $key => $productdata) { $result = select_query("tblproducts", "tblproducts.id,tblproducts.gid,tblproductgroups.name AS groupname,tblproducts.name,tblproducts.paytype,tblproducts.allowqty,tblproducts.proratabilling,tblproducts.proratadate,tblproducts.proratachargenextmonth,tblproducts.tax,tblproducts.servertype,tblproducts.servergroup,tblproducts.stockcontrol,tblproducts.freedomain,tblproducts.freedomainpaymentterms,tblproducts.freedomaintlds", array("tblproducts.id" => $productdata['pid']), "", "", "", "tblproductgroups ON tblproductgroups.id=tblproducts.gid"); $data = mysql_fetch_array($result); $pid = $data['id']; $gid = $data['gid']; $groupname = $data['groupname']; $productname = $data['name']; $paytype = $data['paytype']; $allowqty = $data['allowqty']; $proratabilling = $data['proratabilling']; $proratadate = $data['proratadate']; $proratachargenextmonth = $data['proratachargenextmonth']; $tax = $data['tax']; $servertype = $data['servertype']; $servergroup = $data['servergroup']; $stockcontrol = $data['stockcontrol']; $freedomain = $data['freedomain']; if ($freedomain) { $freedomainpaymentterms = $data['freedomainpaymentterms']; $freedomaintlds = $data['freedomaintlds']; $freedomainpaymentterms = explode(",", $freedomainpaymentterms); $freedomaintlds = explode(",", $freedomaintlds); } else { $freedomainpaymentterms = $freedomaintlds = array(); } $productinfo = getProductInfo($pid); $productdata['productinfo'] = $productinfo; if (!function_exists("getCustomFields")) { require ROOTDIR . "/includes/customfieldfunctions.php"; } $customfields = getCustomFields("product", $pid, "", true, "", $productdata['customfields']); $productdata['customfields'] = $customfields; $pricing = getPricingInfo($pid); $qty = $productdata['qty']; if (!$allowqty || !$qty) { $qty = 1; } $productdata['allowqty'] = $allowqty; $productdata['qty'] = $qty; if ($pricing['type'] == "recurring") { $billingcycle = strtolower($productdata['billingcycle']); if (!in_array($billingcycle, array("monthly", "quarterly", "semiannually", "annually", "biennially", "triennially"))) { $billingcycle = ""; } if ($pricing['rawpricing'][$billingcycle] < 0) { $billingcycle = ""; } if (!$billingcycle) { if (0 <= $pricing['rawpricing']['monthly']) { $billingcycle = "monthly"; } else { if (0 <= $pricing['rawpricing']['quarterly']) { $billingcycle = "quarterly"; } else { if (0 <= $pricing['rawpricing']['semiannually']) { $billingcycle = "semiannually"; } else { if (0 <= $pricing['rawpricing']['annually']) { $billingcycle = "annually"; } else { if (0 <= $pricing['rawpricing']['biennially']) { $billingcycle = "biennially"; } else { if (0 <= $pricing['rawpricing']['triennially']) { $billingcycle = "triennially"; } } } } } } } } else { if ($pricing['type'] == "onetime") { $billingcycle = "onetime"; } else { $billingcycle = "free"; } } $productdata['billingcycle'] = $billingcycle; if ($billingcycle == "free") { $product_setup = $product_onetime = $product_recurring = "0"; $databasecycle = "Free Account"; } else { if ($billingcycle == "onetime") { $product_setup = $pricing['rawpricing']['msetupfee']; $product_onetime = $pricing['rawpricing']['monthly']; $product_recurring = 0; $databasecycle = "One Time"; } else { $product_setup = $pricing['rawpricing'][substr($billingcycle, 0, 1) . "setupfee"]; $product_onetime = $product_recurring = $pricing['rawpricing'][$billingcycle]; $databasecycle = ucfirst($billingcycle); if ($databasecycle == "Semiannually") { $databasecycle = "Semi-Annually"; } } } $before_priceoverride_value = ""; if ($bundleoverride = bundlesGetProductPriceOverride("product", $key)) { $before_priceoverride_value = $product_setup + $product_onetime; $product_setup = 0; $product_onetime = $product_recurring = $bundleoverride; } $hookret = run_hook("OrderProductPricingOverride", array("key" => $key, "pid" => $pid, "proddata" => $productdata)); foreach ($hookret as $hookret2) { if (is_array($hookret2)) { if ($hookret2['setup']) { $product_setup = $hookret2['setup']; } if ($hookret2['recurring']) { $product_onetime = $product_recurring = $hookret2['recurring']; continue; } continue; } } $productdata['pricing']['baseprice'] = formatCurrency($product_onetime); $configurableoptions = array(); $configurableoptions = getCartConfigOptions($pid, $productdata['configoptions'], $billingcycle); $configoptions = ""; if ($configurableoptions) { foreach ($configurableoptions as $confkey => $value) { $configoptions[] = array("name" => $value['optionname'], "type" => $value['optiontype'], "option" => $value['selectedoption'], "optionname" => $value['selectedname'], "setup" => 0 < $value['selectedsetup'] ? formatCurrency($value['selectedsetup']) : "", "recurring" => formatCurrency($value['selectedrecurring']), "qty" => $value['selectedqty']); $configoptionsdb[$value['id']] = array("value" => $value['selectedvalue'], "qty" => $value['selectedqty']); $product_setup += $value['selectedsetup']; $product_onetime += $value['selectedrecurring']; if (strlen($before_priceoverride_value)) { $before_priceoverride_value += $value['selectedrecurring']; } if ($billingcycle != "onetime") { $product_recurring += $value['selectedrecurring']; continue; } } } $productdata['configoptions'] = $configoptions; if (in_array($billingcycle, $freedomainpaymentterms)) { $domain = $productdata['domain']; $domainparts = explode(".", $domain, 2); $tld = "." . $domainparts[1]; if (in_array($tld, $freedomaintlds)) { $freedomains[$domain] = $freedomain; } } if ($proratabilling) { $proratavalues = getProrataValues($billingcycle, $product_onetime, $proratadate, $proratachargenextmonth, date("d"), date("m"), date("Y"), $_SESSION['uid']); $product_onetime = $proratavalues['amount']; $productdata['proratadate'] = fromMySQLDate($proratavalues['date']); } if ($CONFIG['TaxInclusiveDeduct']) { $product_setup = format_as_currency($product_setup / $excltaxrate); $product_onetime = format_as_currency($product_onetime / $excltaxrate); $product_recurring = format_as_currency($product_recurring / $excltaxrate); } $product_total_today_db = $product_setup + $product_onetime; $product_recurring_db = $product_recurring; $productdata['pricing']['setup'] = $product_setup * $qty; $productdata['pricing']['recurring'][$billingcycle] = $product_recurring * $qty; $productdata['pricing']['totaltoday'] = $product_total_today_db * $qty; if ($product_onetime == 0 && $product_recurring == 0) { $pricing_text = $_LANG['orderfree']; } else { $pricing_text = ""; if (strlen($before_priceoverride_value)) { $pricing_text .= "<strike>" . formatCurrency($before_priceoverride_value) . "</strike> "; } $pricing_text .= formatCurrency($product_onetime); if (0 < $product_setup) { $pricing_text .= " + " . formatCurrency($product_setup) . " " . $_LANG['ordersetupfee']; } if ($allowqty && 1 < $qty) { $pricing_text .= $_LANG['invoiceqtyeach'] . "<br />" . $_LANG['invoicestotal'] . ": " . formatCurrency($productdata['pricing']['totaltoday']); } } $productdata['pricingtext'] = $pricing_text; if ($promotioncode) { $onetimediscount = $recurringdiscount = $promoid = 0; if ($promocalc = CalcPromoDiscount($pid, $databasecycle, $product_total_today_db, $product_recurring_db, $product_setup)) { $onetimediscount = $promocalc['onetimediscount']; $recurringdiscount = $promocalc['recurringdiscount']; $product_total_today_db -= $onetimediscount; $product_recurring_db -= $recurringdiscount; $cart_discount += $onetimediscount * $qty; $promoid = $promo_data['id']; } } if (isset($productdata['priceoverride'])) { $product_total_today_db = $product_recurring_db = $product_onetime = $productdata['priceoverride']; $product_setup = 0; } $cart_total += $product_total_today_db * $qty; $product_total_qty_recurring = $product_recurring_db * $qty; if ($CONFIG['TaxEnabled'] && $tax && !$clientsdetails['taxexempt']) { $cart_tax += $product_total_today_db * $qty; if ($CONFIG['TaxType'] == "Exclusive") { if ($CONFIG['TaxL2Compound']) { $product_total_qty_recurring += $product_total_qty_recurring * $taxrate; $product_total_qty_recurring += $product_total_qty_recurring * $taxrate2; } else { $product_total_qty_recurring += $product_total_qty_recurring * $taxrate + $product_total_qty_recurring * $taxrate2; } } } $recurring_cycles_total[$billingcycle] += $product_total_qty_recurring; $domain = $productdata['domain']; $serverhostname = $productdata['server']['hostname']; $serverns1prefix = $productdata['server']['ns1prefix']; $serverns2prefix = $productdata['server']['ns2prefix']; $serverrootpw = encrypt($productdata['server']['rootpw']); if ($serverns1prefix && $domain) { $serverns1prefix = $serverns1prefix . "." . $domain; } if ($serverns2prefix && $domain) { $serverns2prefix = $serverns2prefix . "." . $domain; } if ($serverhostname) { $domain = $domain ? $serverhostname . "." . $domain : $serverhostname; } $productdata['domain'] = $domain; if ($checkout) { $multiqtyids = array(); $qtycount = 1; while ($qtycount <= $qty) { $serverid = $servertype ? getServerID($servertype, $servergroup) : "0"; $hostingquerydates = $databasecycle == "Free Account" ? "0000-00-00" : date("Y-m-d"); $serviceid = insert_query("tblhosting", array("userid" => $userid, "orderid" => $orderid, "packageid" => $pid, "server" => $serverid, "regdate" => "now()", "domain" => $domain, "paymentmethod" => $paymentmethod, "firstpaymentamount" => $product_total_today_db, "amount" => $product_recurring_db, "billingcycle" => $databasecycle, "nextduedate" => $hostingquerydates, "nextinvoicedate" => $hostingquerydates, "domainstatus" => "Pending", "ns1" => $serverns1prefix, "ns2" => $serverns2prefix, "password" => $serverrootpw, "promoid" => $promoid)); $multiqtyids[$qtycount] = $serviceid; $orderproductids[] = $serviceid; if ($stockcontrol) { full_query("UPDATE tblproducts SET qty=qty-1 WHERE id='" . mysql_real_escape_string($pid) . "'"); } if ($configoptionsdb) { foreach ($configoptionsdb as $key => $value) { insert_query("tblhostingconfigoptions", array("relid" => $serviceid, "configid" => $key, "optionid" => $value['value'], "qty" => $value['qty'])); } } foreach ($productdata['customfields'] as $key => $value) { insert_query("tblcustomfieldsvalues", array("fieldid" => $value['id'], "relid" => $serviceid, "value" => $value['rawvalue'])); } $productdetails = getInvoiceProductDetails($serviceid, $pid, date("Y-m-d"), $hostingquerydates, $databasecycle, $domain); $invoice_description = $productdetails['description']; $invoice_tax = $productdetails['tax']; if (!$_SESSION['cart']['geninvoicedisabled']) { $prodinvoicearray = array(); $prodinvoicearray['userid'] = $userid; $prodinvoicearray['type'] = "Hosting"; $prodinvoicearray['relid'] = $serviceid; $prodinvoicearray['taxed'] = $invoice_tax; $prodinvoicearray['duedate'] = $hostingquerydates; $prodinvoicearray['paymentmethod'] = $paymentmethod; if (0 < $product_setup) { $prodinvoicearray['description'] = $productname . " " . $_LANG['ordersetupfee']; $prodinvoicearray['amount'] = $product_setup; insert_query("tblinvoiceitems", $prodinvoicearray); $prodinvoicearray['type'] = ""; $prodinvoicearray['relid'] = 0; } if (0 < $product_onetime) { $prodinvoicearray['description'] = $invoice_description; $prodinvoicearray['amount'] = $product_onetime; insert_query("tblinvoiceitems", $prodinvoicearray); } $promovals = getInvoiceProductPromo($product_total_today_db, $promoid, $userid, $serviceid, $product_setup + $product_onetime); if ($promovals['description']) { $prodinvoicearray['type'] = "PromoHosting"; $prodinvoicearray['description'] = $promovals['description']; $prodinvoicearray['amount'] = $promovals['amount']; insert_query("tblinvoiceitems", $prodinvoicearray); } } $adminemailitems .= $_LANG['orderproduct'] . (": " . $groupname . " - " . $productname . "<br>\r\n"); if ($domain) { $adminemailitems .= $_LANG['orderdomain'] . (": " . $domain . "<br>\r\n"); } foreach ($configurableoptions as $confkey => $value) { $adminemailitems .= $value['optionname'] . ": " . $value['selectedname'] . "<br />\r\n"; } foreach ($customfields as $customfield) { if (!$customfield['adminonly']) { $adminemailitems .= "" . $customfield['name'] . ": " . $customfield['value'] . "<br />\r\n"; continue; } } $adminemailitems .= $_LANG['firstpaymentamount'] . ": " . formatCurrency($product_total_today_db) . "<br>\r\n"; if ($product_recurring_db) { $adminemailitems .= $_LANG['recurringamount'] . ": " . formatCurrency($product_recurring_db) . "<br>\r\n"; } $adminemailitems .= $_LANG['orderbillingcycle'] . ": " . $_LANG["orderpaymentterm" . str_replace(array("-", " "), "", strtolower($databasecycle))] . "<br>\r\n"; if ($allowqty && 1 < $qty) { $adminemailitems .= $_LANG['quantity'] . (": " . $qty . "<br>\r\n") . $_LANG['invoicestotal'] . ": " . $productdata['pricing']['totaltoday'] . "<br>\r\n"; } $adminemailitems .= "<br>\r\n"; ++$qtycount; } } $addonsarray = array(); $addons = $productdata['addons']; if ($addons) { foreach ($addons as $addonid) { $result = select_query("tbladdons", "name,description,billingcycle,tax", array("id" => $addonid)); $data = mysql_fetch_array($result); $addon_name = $data['name']; $addon_description = $data['description']; $addon_billingcycle = $data['billingcycle']; $addon_tax = $data['tax']; if (!$CONFIG['TaxEnabled']) { $addon_tax = ""; } $result = select_query("tblpricing", "msetupfee,monthly", array("type" => "addon", "currency" => $currency['id'], "relid" => $addonid)); $data = mysql_fetch_array($result); $addon_setupfee = $data['msetupfee']; $addon_recurring = $data['monthly']; $hookret = run_hook("OrderAddonPricingOverride", array("key" => $key, "pid" => $pid, "addonid" => $addonid, "proddata" => $productdata)); foreach ($hookret as $hookret2) { if (is_array($hookret2)) { if ($hookret2['setup']) { $addon_setupfee = $hookret2['setup']; } if ($hookret2['recurring']) { $addon_recurring = $hookret2['recurring']; continue; } continue; } } $addon_total_today_db = $addon_setupfee + $addon_recurring; $addon_recurring_db = $addon_recurring; $addon_total_today = $addon_total_today_db * $qty; if ($CONFIG['TaxInclusiveDeduct']) { $addon_total_today_db = round($addon_total_today_db / $excltaxrate, 2); $addon_recurring_db = round($addon_recurring_db / $excltaxrate, 2); } if ($promotioncode) { $onetimediscount = $recurringdiscount = $promoid = 0; if ($promocalc = CalcPromoDiscount("A" . $addonid, $addon_billingcycle, $addon_total_today_db, $addon_recurring_db, $addon_setupfee)) { $onetimediscount = $promocalc['onetimediscount']; $recurringdiscount = $promocalc['recurringdiscount']; $addon_total_today_db -= $onetimediscount; $addon_recurring_db -= $recurringdiscount; $cart_discount += $onetimediscount * $qty; } } if ($checkout) { $qtycount = 1; while ($qtycount <= $qty) { $serviceid = $multiqtyids[$qtycount]; $addonsetupfee = $addon_total_today_db - $addon_recurring_db; $aid = insert_query("tblhostingaddons", array("hostingid" => $serviceid, "addonid" => $addonid, "orderid" => $orderid, "regdate" => "now()", "name" => "", "setupfee" => $addonsetupfee, "recurring" => $addon_recurring_db, "billingcycle" => $addon_billingcycle, "status" => "Pending", "nextduedate" => "now()", "nextinvoicedate" => "now()", "paymentmethod" => $paymentmethod, "tax" => $addon_tax)); $orderaddonids[] = $aid; $adminemailitems .= $_LANG['clientareaaddon'] . (": " . $addon_name . "<br>\r\n") . $_LANG['ordersetupfee'] . ": " . formatCurrency($addonsetupfee) . "<br>\r\n"; if ($addon_recurring_db) { $adminemailitems .= $_LANG['recurringamount'] . ": " . formatCurrency($addon_recurring_db) . "<br>\r\n"; } $adminemailitems .= $_LANG['orderbillingcycle'] . ": " . $_LANG["orderpaymentterm" . str_replace(array("-", " "), "", strtolower($addon_billingcycle))] . "<br>\r\n<br>\r\n"; ++$qtycount; } } $addon_total_today_db *= $qty; $cart_total += $addon_total_today_db; $addon_recurring_db *= $qty; if ($addon_tax && !$clientsdetails['taxexempt']) { $cart_tax += $addon_total_today_db; if ($CONFIG['TaxType'] == "Exclusive") { if ($CONFIG['TaxL2Compound']) { $addon_recurring_db += $addon_recurring_db * $taxrate; $addon_recurring_db += $addon_recurring_db * $taxrate2; } else { $addon_recurring_db += $addon_recurring_db * $taxrate + $addon_recurring_db * $taxrate2; } } } $addon_billingcycle = str_replace(array("-", " "), "", strtolower($addon_billingcycle)); $recurring_cycles_total[$addon_billingcycle] += $addon_recurring_db; if ($addon_setupfee == "0" && $addon_recurring == "0") { $pricing_text = $_LANG['orderfree']; } else { $pricing_text = formatCurrency($addon_recurring); if ($addon_setupfee != "0.00") { $pricing_text .= " + " . formatCurrency($addon_setupfee) . " " . $_LANG['ordersetupfee']; } if ($allowqty && 1 < $qty) { $pricing_text .= $_LANG['invoiceqtyeach'] . "<br />" . $_LANG['invoicestotal'] . ": " . formatCurrency($addon_total_today); } } $addonsarray[] = array("name" => $addon_name, "pricingtext" => $pricing_text, "setup" => formatCurrency($addon_setupfee), "recurring" => formatCurrency($addon_recurring), "totaltoday" => formatCurrency($addon_total_today)); $productdata['pricing']['setup'] += $addon_setupfee * $qty; $productdata['pricing']['addons'] += $addon_recurring * $qty; $productdata['pricing']['recurring'][$addon_billingcycle] += $addon_recurring * $qty; $productdata['pricing']['totaltoday'] += $addon_total_today; } } $productdata['addons'] = $addonsarray; $totaltaxrates = 1; if ($CONFIG['TaxEnabled'] && $tax && !$clientsdetails['taxexempt']) { $product_tax = $productdata['pricing']['totaltoday']; if ($CONFIG['TaxType'] == "Inclusive") { $totaltaxrates = 1 + ($taxrate + $taxrate2); $total_without_tax = $productdata['pricing']['totaltoday'] = $product_tax / $totaltaxrates; $total_tax_1 = $total_without_tax * $taxrate; $total_tax_2 = $total_without_tax * $taxrate2; } else { $total_tax_1 = $product_tax * $taxrate; if ($CONFIG['TaxL2Compound']) { $total_tax_2 = ($product_tax + $total_tax_1) * $taxrate2; } else { $total_tax_2 = $product_tax * $taxrate2; } } $total_tax_1 = round($total_tax_1, 2); $total_tax_2 = round($total_tax_2, 2); $productdata['pricing']['totaltoday'] += $total_tax_1 + $total_tax_2; if (0 < $total_tax_1) { $productdata['pricing']['tax1'] = formatCurrency($total_tax_1); } if (0 < $total_tax_2) { $productdata['pricing']['tax2'] = formatCurrency($total_tax_2); } } $productdata['pricing']['setup'] = formatCurrency($productdata['pricing']['setup']); foreach ($productdata['pricing']['recurring'] as $cycle => $recurring) { unset($productdata['pricing']['recurring'][$cycle]); if (0 < $recurring) { $recurringwithtax = $recurring; if ($CONFIG['TaxEnabled'] && $tax && !$clientsdetails['taxexempt'] && $CONFIG['TaxType'] == "Exclusive") { $rectax = $recurringwithtax * $taxrate; if ($CONFIG['TaxL2Compound']) { $rectax += ($recurringwithtax + $rectax) * $taxrate2; } else { $rectax += $recurringwithtax * $taxrate2; } $recurringwithtax += $rectax; } $productdata['pricing']['recurring'][$_LANG["orderpaymentterm" . $cycle]] = formatCurrency($recurringwithtax); $productdata['pricing']['recurringexcltax'][$_LANG["orderpaymentterm" . $cycle]] = formatCurrency($recurring / $totaltaxrates); continue; } } if (0 < $productdata['pricing']['addons']) { $productdata['pricing']['addons'] = formatCurrency($productdata['pricing']['addons']); } $productdata['pricing']['totaltoday'] = formatCurrency($productdata['pricing']['totaltoday']); $productsarray[$key] = $productdata; } } $cartdata['products'] = $productsarray; $addonsarray = array(); if (array_key_exists("addons", $_SESSION['cart']) && is_array($_SESSION['cart']['addons'])) { foreach ($_SESSION['cart']['addons'] as $key => $addon) { $addonid = $addon['id']; $serviceid = $addon['productid']; $result = select_query("tbladdons", "name,description,billingcycle,tax", array("id" => $addonid)); $data = mysql_fetch_array($result); $addon_name = $data['name']; $addon_description = $data['description']; $addon_billingcycle = $data['billingcycle']; $addon_tax = $data['tax']; if (!$CONFIG['TaxEnabled']) { $addon_tax = ""; } $result = select_query("tblpricing", "msetupfee,monthly", array("type" => "addon", "currency" => $currency['id'], "relid" => $addonid)); $data = mysql_fetch_array($result); $addon_setupfee = $data['msetupfee']; $addon_recurring = $data['monthly']; $hookret = run_hook("OrderAddonPricingOverride", array("key" => $key, "addonid" => $addonid, "serviceid" => $serviceid)); foreach ($hookret as $hookret2) { if (strlen($hookret2)) { if ($hookret2['setup']) { $addon_setupfee = $hookret2['setup']; } if ($hookret2['recurring']) { $addon_recurring = $hookret2['recurring']; continue; } continue; } } $addon_total_today_db = $addon_setupfee + $addon_recurring; $addon_recurring_db = $addon_recurring; if ($CONFIG['TaxInclusiveDeduct']) { $addon_total_today_db = round($addon_total_today_db / $excltaxrate, 2); $addon_recurring_db = round($addon_recurring_db / $excltaxrate, 2); } if ($promotioncode) { $onetimediscount = $recurringdiscount = $promoid = 0; if ($promocalc = CalcPromoDiscount("A" . $addonid, $addon_billingcycle, $addon_total_today_db, $addon_recurring_db, $addon_setupfee)) { $onetimediscount = $promocalc['onetimediscount']; $recurringdiscount = $promocalc['recurringdiscount']; $addon_total_today_db -= $onetimediscount; $addon_recurring_db -= $recurringdiscount; $cart_discount += $onetimediscount; } } if ($checkout) { $addonsetupfee = $addon_total_today_db - $addon_recurring_db; $aid = insert_query("tblhostingaddons", array("hostingid" => $serviceid, "addonid" => $addonid, "orderid" => $orderid, "regdate" => "now()", "name" => "", "setupfee" => $addonsetupfee, "recurring" => $addon_recurring_db, "billingcycle" => $addon_billingcycle, "status" => "Pending", "nextduedate" => "now()", "nextinvoicedate" => "now()", "paymentmethod" => $paymentmethod, "tax" => $addon_tax)); $orderaddonids[] = $aid; $adminemailitems .= $_LANG['clientareaaddon'] . (": " . $addon_name . "<br>\r\n") . $_LANG['ordersetupfee'] . ": " . formatCurrency($addonsetupfee) . "<br>\r\n"; if ($addon_recurring_db) { $adminemailitems .= $_LANG['recurringamount'] . ": " . formatCurrency($addon_recurring_db) . "<br>\r\n"; } $adminemailitems .= $_LANG['orderbillingcycle'] . ": " . $_LANG["orderpaymentterm" . str_replace(array("-", " "), "", strtolower($addon_billingcycle))] . "<br>\r\n<br>\r\n"; } $cart_total += $addon_total_today_db; if ($addon_tax && !$clientsdetails['taxexempt']) { $cart_tax += $addon_total_today_db; if ($CONFIG['TaxType'] == "Exclusive") { if ($CONFIG['TaxL2Compound']) { $addon_recurring_db += $addon_recurring_db * $taxrate; $addon_recurring_db += $addon_recurring_db * $taxrate2; } else { $addon_recurring_db = $addon_recurring_db + $addon_recurring_db * $taxrate + $addon_recurring_db * $taxrate2; } } } $addon_billingcycle = str_replace(array("-", " "), "", strtolower($addon_billingcycle)); $recurring_cycles_total[$addon_billingcycle] += $addon_recurring_db; if ($addon_setupfee == "0" && $addon_recurring == "0") { $pricing_text = $_LANG['orderfree']; } else { $pricing_text = formatCurrency($addon_recurring); if ($addon_setupfee != "0.00") { $pricing_text .= " + " . formatCurrency($addon_setupfee) . " " . $_LANG['ordersetupfee']; } } $result = select_query("tblhosting", "tblproducts.name,tblhosting.domain", array("tblhosting.id" => $serviceid), "", "", "", "tblproducts ON tblproducts.id=tblhosting.packageid"); $data = mysql_fetch_array($result); $productname = $data['name']; $domainname = $data['domain']; $addonsarray[] = array("name" => $addon_name, "productname" => $productname, "domainname" => $domainname, "pricingtext" => $pricing_text); } $cartdata['addons'] = $addonsarray; } include ROOTDIR . "/includes/additionaldomainfields.php"; $totaldomainprice = 0; if (array_key_exists("domains", $_SESSION['cart']) && is_array($_SESSION['cart']['domains'])) { $result = select_query("tblpricing", "", array("type" => "domainaddons", "currency" => $currency['id'], "relid" => 0)); $data = mysql_fetch_array($result); $domaindnsmanagementprice = $data['msetupfee']; $domainemailforwardingprice = $data['qsetupfee']; $domainidprotectionprice = $data['ssetupfee']; foreach ($_SESSION['cart']['domains'] as $key => $domain) { $domaintype = $domain['type']; $domainname = $domain['domain']; $regperiod = $domain['regperiod']; $domainparts = explode(".", $domainname, 2); $sld = $domainparts[0]; $tld = $domainparts[1]; $temppricelist = getTLDPriceList("." . $tld); if (!isset($temppricelist[$regperiod][$domaintype])) { $tldyears = array_keys($temppricelist); $regperiod = $tldyears[0]; } if (!isset($temppricelist[$regperiod][$domaintype])) { exit("Invalid TLD/Registration Period Supplied for Domain Registration"); } if (array_key_exists($domainname, $freedomains)) { $tldyears = array_keys($temppricelist); $regperiod = $tldyears[0]; $domainprice = "0.00"; $renewprice = $freedomains[$domainname] == "once" ? $temppricelist[$regperiod]['renew'] : ($renewprice = "0.00"); } else { $domainprice = $temppricelist[$regperiod][$domaintype]; $renewprice = $temppricelist[$regperiod]['renew']; } $before_priceoverride_value = ""; if ($bundleoverride = bundlesGetProductPriceOverride("domain", $key)) { $before_priceoverride_value = $domainprice; $domainprice = $renewprice = $bundleoverride; } $hookret = run_hook("OrderDomainPricingOverride", array("type" => $domaintype, "domain" => $domainname, "regperiod" => $regperiod, "dnsmanagement" => $domain['dnsmanagement'], "emailforwarding" => $domain['emailforwarding'], "idprotection" => $domain['idprotection'], "eppcode" => html_entity_decode($domain['eppcode']))); foreach ($hookret as $hookret2) { if (strlen($hookret2)) { $before_priceoverride_value = $domainprice; $domainprice = $hookret2; continue; } } if ($domain['dnsmanagement']) { $dnsmanagement = true; $domainprice += $domaindnsmanagementprice * $regperiod; $renewprice += $domaindnsmanagementprice * $regperiod; if (strlen($before_priceoverride_value)) { $before_priceoverride_value += $domaindnsmanagementprice * $regperiod; } } else { $dnsmanagement = false; } if ($domain['emailforwarding']) { $emailforwarding = true; $domainprice += $domainemailforwardingprice * $regperiod; $renewprice += $domainemailforwardingprice * $regperiod; if (strlen($before_priceoverride_value)) { $before_priceoverride_value += $domainemailforwardingprice * $regperiod; } } else { $emailforwarding = false; } if ($domain['idprotection']) { $idprotection = true; $domainprice += $domainidprotectionprice * $regperiod; $renewprice += $domainidprotectionprice * $regperiod; if (strlen($before_priceoverride_value)) { $before_priceoverride_value += $domainidprotectionprice * $regperiod; } } else { $idprotection = false; } if ($CONFIG['TaxInclusiveDeduct']) { $domainprice = round($domainprice / $excltaxrate, 2); $renewprice = round($renewprice / $excltaxrate, 2); } $domain_price_db = $domainprice; $domain_renew_price_db = $renewprice; if ($promotioncode) { $onetimediscount = $recurringdiscount = $promoid = 0; if ($promocalc = CalcPromoDiscount("D." . $tld, $regperiod . "Years", $domain_price_db, $domain_renew_price_db)) { $onetimediscount = $promocalc['onetimediscount']; $recurringdiscount = $promocalc['recurringdiscount']; $domain_price_db -= $onetimediscount; $domain_renew_price_db -= $recurringdiscount; $cart_discount += $onetimediscount; $promoid = $promo_data['id']; } } if ($regperiod == "1") { $domain_billing_cycle = "annually"; } else { if ($regperiod == "2") { $domain_billing_cycle = "biennially"; } else { if ($regperiod == "3") { $domain_billing_cycle = "triennially"; } } } $recurring_cycles_total[$domain_billing_cycle] += $domain_renew_price_db; if ($CONFIG['TaxEnabled'] && $CONFIG['TaxDomains'] && $CONFIG['TaxType'] == "Exclusive" && !$clientsdetails['taxexempt']) { if ($CONFIG['TaxL2Compound']) { $recurring_cycles_total[$domain_billing_cycle] += $domain_renew_price_db * $taxrate + ($domain_renew_price_db + $domain_renew_price_db * $taxrate) * $taxrate2; } else { $recurring_cycles_total[$domain_billing_cycle] += $domain_renew_price_db * $taxrate + $domain_renew_price_db * $taxrate2; } } if ($checkout) { $donotrenew = $CONFIG['DomainAutoRenewDefault'] ? "" : "on"; $domainid = insert_query("tbldomains", array("userid" => $userid, "orderid" => $orderid, "type" => $domaintype, "registrationdate" => "now()", "domain" => $domainname, "firstpaymentamount" => $domain_price_db, "recurringamount" => $domain_renew_price_db, "registrationperiod" => $regperiod, "status" => "Pending", "paymentmethod" => $paymentmethod, "expirydate" => "00000000", "nextduedate" => "now()", "nextinvoicedate" => "now()", "dnsmanagement" => $dnsmanagement, "emailforwarding" => $emailforwarding, "idprotection" => $idprotection, "donotrenew" => $donotrenew, "promoid" => $promoid)); $orderdomainids[] = $domainid; $adminemailitems .= $_LANG['orderdomainregistration'] . ": " . ucfirst($domaintype) . "<br>\r\n" . $_LANG['orderdomain'] . (": " . $domainname . "<br>\r\n") . $_LANG['firstpaymentamount'] . ": " . formatCurrency($domain_price_db) . "<br>\r\n" . $_LANG['recurringamount'] . ": " . formatCurrency($domain_renew_price_db) . "<br>\r\n" . $_LANG['orderregperiod'] . (": " . $regperiod . " ") . $_LANG['orderyears'] . "<br>\r\n"; if ($dnsmanagement) { $adminemailitems .= " + " . $_LANG['domaindnsmanagement'] . "<br>\r\n"; } if ($emailforwarding) { $adminemailitems .= " + " . $_LANG['domainemailforwarding'] . "<br>\r\n"; } if ($idprotection) { $adminemailitems .= " + " . $_LANG['domainidprotection'] . "<br>\r\n"; } $adminemailitems .= "<br>\r\n"; if ($domaintype == "register") { unset($tempdomainfields); $tempdomainfields = $additionaldomainfields["." . $tld]; if ($tempdomainfields) { foreach ($tempdomainfields as $fieldkey => $value) { $storedvalue = $domain['fields'][$fieldkey]; insert_query("tbldomainsadditionalfields", array("domainid" => $domainid, "name" => $value['Name'], "value" => $storedvalue)); } } } if ($domaintype == "transfer" && $domain['eppcode']) { $domaineppcodes[$domainname] = html_entity_decode($domain['eppcode']); } } $pricing_text = ""; if (strlen($before_priceoverride_value)) { $pricing_text .= "<strike>" . formatCurrency($before_priceoverride_value) . "</strike> "; } $pricing_text .= formatCurrency($domainprice); $tempdomains[$key] = array("type" => $domaintype, "domain" => $domainname, "regperiod" => $regperiod, "price" => $pricing_text, "renewprice" => formatCurrency($renewprice), "dnsmanagement" => $dnsmanagement, "emailforwarding" => $emailforwarding, "idprotection" => $idprotection, "eppvalue" => $domain['eppcode']); $totaldomainprice += $domain_price_db; } } $cartdata['domains'] = $tempdomains; $cart_total += $totaldomainprice; if ($CONFIG['TaxDomains']) { $cart_tax += $totaldomainprice; } $orderrenewals = ""; if (array_key_exists("renewals", $_SESSION['cart']) && is_array($_SESSION['cart']['renewals'])) { $result = select_query("tblpricing", "", array("type" => "domainaddons", "currency" => $currency['id'], "relid" => 0)); $data = mysql_fetch_array($result); $domaindnsmanagementprice = $data['msetupfee']; $domainemailforwardingprice = $data['qsetupfee']; $domainidprotectionprice = $data['ssetupfee']; foreach ($_SESSION['cart']['renewals'] as $domainid => $regperiod) { $result = select_query("tbldomains", "", array("id" => $domainid)); $data = mysql_fetch_array($result); $domainname = $data['domain']; $expirydate = $data['expirydate']; if ($expirydate == "0000-00-00") { $expirydate = $data['nextduedate']; } $dnsmanagement = $data['dnsmanagement']; $emailforwarding = $data['emailforwarding']; $idprotection = $data['idprotection']; $domainparts = explode(".", $domainname, 2); $sld = $domainparts[0]; $tld = "." . $domainparts[1]; $temppricelist = getTLDPriceList($tld, "", true); if (!isset($temppricelist[$regperiod]['renew'])) { exit("Invalid TLD/Registration Period Supplied for Domain Renewal"); } $renewprice = $temppricelist[$regperiod]['renew']; if ($dnsmanagement) { $renewprice += $domaindnsmanagementprice * $regperiod; } if ($emailforwarding) { $renewprice += $domainemailforwardingprice * $regperiod; } if ($idprotection) { $renewprice += $domainidprotectionprice * $regperiod; } if ($CONFIG['TaxInclusiveDeduct']) { $renewprice = round($renewprice / $excltaxrate, 2); } $domain_renew_price_db = $renewprice; if ($promotioncode) { $onetimediscount = $recurringdiscount = $promoid = 0; if ($promocalc = CalcPromoDiscount("D" . $tld, $regperiod . "Years", $domain_renew_price_db, $domain_renew_price_db)) { $onetimediscount = $promocalc['onetimediscount']; $domain_renew_price_db -= $onetimediscount; $cart_discount += $onetimediscount; } } $cart_total += $domain_renew_price_db; if ($CONFIG['TaxDomains']) { $cart_tax += $domain_renew_price_db; } if ($checkout) { $domain_renew_price_db = format_as_currency($domain_renew_price_db); $orderrenewalids[] = $domainid; $orderrenewals .= "" . $domainid . "=" . $regperiod . ","; $adminemailitems .= $_LANG['domainrenewal'] . (": " . $domainname . " - " . $regperiod . " ") . $_LANG['orderyears'] . "<br>\r\n"; $domaindesc = $_LANG['domainrenewal'] . (" - " . $domainname . " - " . $regperiod . " ") . $_LANG['orderyears'] . " (" . fromMySQLDate($expirydate) . " - " . fromMySQLDate(getInvoicePayUntilDate($expirydate, $regperiod)) . ")"; if ($dnsmanagement) { $adminemailitems .= " + " . $_LANG['domaindnsmanagement'] . "<br>\r\n"; $domaindesc .= "\r\n + " . $_LANG['domaindnsmanagement']; } if ($emailforwarding) { $adminemailitems .= " + " . $_LANG['domainemailforwarding'] . "<br>\r\n"; $domaindesc .= "\r\n + " . $_LANG['domainemailforwarding']; } if ($idprotection) { $adminemailitems .= " + " . $_LANG['domainidprotection'] . "<br>\r\n"; $domaindesc .= "\r\n + " . $_LANG['domainidprotection']; } $adminemailitems .= "<br>\r\n"; $tax = $CONFIG['TaxDomains'] ? "1" : "0"; update_query("tbldomains", array("registrationperiod" => $regperiod, "recurringamount" => $domain_renew_price_db), array("id" => $domainid)); insert_query("tblinvoiceitems", array("userid" => $userid, "type" => "Domain", "relid" => $domainid, "description" => $domaindesc, "amount" => $domain_renew_price_db, "taxed" => $tax, "duedate" => "now()", "paymentmethod" => $paymentmethod)); $result = select_query("tblinvoiceitems", "tblinvoiceitems.id,tblinvoiceitems.invoiceid", array("type" => "Domain", "relid" => $domainid, "status" => "Unpaid", "tblinvoices.userid" => $_SESSION['uid']), "", "", "", "tblinvoices ON tblinvoices.id=tblinvoiceitems.invoiceid"); while ($data = mysql_fetch_array($result)) { $itemid = $data['id']; $invoiceid = $data['invoiceid']; $result2 = select_query("tblinvoiceitems", "COUNT(*)", array("invoiceid" => $invoiceid)); $data = mysql_fetch_array($result2); $itemcount = $data[0]; if ($itemcount == 1) { update_query("tblinvoices", array("status" => "Cancelled"), array("id" => $invoiceid)); logActivity("Cancelled Previous Domain Renewal Invoice - Invoice ID: " . $invoiceid . " - Domain: " . $domainname); } delete_query("tblinvoiceitems", array("id" => $itemid)); updateInvoiceTotal($invoiceid); logActivity("Removed Previous Domain Renewal Line Item - Invoice ID: " . $invoiceid . " - Domain: " . $domainname); } } $cartdata['renewals'][$domainid] = array("domain" => $domainname, "regperiod" => $regperiod, "price" => formatCurrency($renewprice), "dnsmanagement" => $dnsmanagement, "emailforwarding" => $emailforwarding, "idprotection" => $idprotection); } } $cart_adjustments = 0; $adjustments = run_hook("CartTotalAdjustment", $_SESSION['cart']); foreach ($adjustments as $k => $adjvals) { if ($checkout) { insert_query("tblinvoiceitems", array("userid" => $userid, "type" => "", "relid" => "", "description" => $adjvals['description'], "amount" => $adjvals['amount'], "taxed" => $adjvals['taxed'], "duedate" => "now()", "paymentmethod" => $paymentmethod)); } $adjustments[$k]['amount'] = formatCurrency($adjvals['amount']); $cart_adjustments += $adjvals['amount']; if ($adjvals['taxed']) { $cart_tax += $adjvals['amount']; continue; } } if ($CONFIG['TaxEnabled'] && !$clientsdetails['taxexempt']) { if ($CONFIG['TaxType'] == "Inclusive") { $totaltaxrates = 1 + ($taxrate + $taxrate2); $total_without_tax = $cart_tax / $totaltaxrates; $total_tax_1 = $total_without_tax * $taxrate; $total_tax_2 = $total_without_tax * $taxrate2; } else { $total_tax_1 = $cart_tax * $taxrate; if ($CONFIG['TaxL2Compound']) { $total_tax_2 = ($cart_tax + $total_tax_1) * $taxrate2; } else { $total_tax_2 = $cart_tax * $taxrate2; } } $total_tax_1 = round($total_tax_1, 2); $total_tax_2 = round($total_tax_2, 2); if ($CONFIG['TaxType'] == "Inclusive") { $cart_total -= $total_tax_1 + $total_tax_2; } } else { $total_tax_1 = $total_tax_2 = 0; } $cart_subtotal = $cart_total + $cart_discount; $cart_total += $total_tax_1 + $total_tax_2 + $cart_adjustments; $cart_subtotal = format_as_currency($cart_subtotal); $cart_discount = format_as_currency($cart_discount); $cart_adjustments = format_as_currency($cart_adjustments); $total_tax_1 = format_as_currency($total_tax_1); $total_tax_2 = format_as_currency($total_tax_2); $cart_total = format_as_currency($cart_total); if ($checkout) { $adminemailitems .= $_LANG['ordertotalduetoday'] . ": " . formatCurrency($cart_total); if ($promotioncode && $promo_data['promoapplied']) { update_query("tblpromotions", array("uses" => "+1"), array("code" => $promotioncode)); $promo_recurring = $promo_data['recurring'] ? "Recurring" : "One Time"; update_query("tblorders", array("promocode" => $promo_data['code'], "promotype" => $promo_recurring . " " . $promo_data['type'], "promovalue" => $promo_data['value']), array("id" => $orderid)); } if ($_SESSION['cart']['ns1'] && $_SESSION['cart']['ns1']) { $ordernameservers = $_SESSION['cart']['ns1'] . "," . $_SESSION['cart']['ns2']; if ($_SESSION['cart']['ns3']) { $ordernameservers .= "," . $_SESSION['cart']['ns3']; } if ($_SESSION['cart']['ns4']) { $ordernameservers .= "," . $_SESSION['cart']['ns4']; } if ($_SESSION['cart']['ns5']) { $ordernameservers .= "," . $_SESSION['cart']['ns5']; } } $domaineppcodes = count($domaineppcodes) ? serialize($domaineppcodes) : ""; $orderdata = array(); if (is_array($_SESSION['cart']['bundle'])) { foreach ($_SESSION['cart']['bundle'] as $bvals) { $orderdata['bundleids'][] = $bvals['bid']; } } update_query("tblorders", array("amount" => $cart_total, "nameservers" => $ordernameservers, "transfersecret" => $domaineppcodes, "renewals" => substr($orderrenewals, 0, 0 - 1), "orderdata" => serialize($orderdata)), array("id" => $orderid)); $invoiceid = 0; if (!$_SESSION['cart']['geninvoicedisabled']) { if (!$userid) { exit("An Error Occurred"); } $invoiceid = createInvoices($userid, true, "", array("products" => $orderproductids, "addons" => $orderaddonids, "domains" => $orderdomainids)); if ($CONFIG['OrderDaysGrace']) { $new_time = mktime(0, 0, 0, date("m"), date("d") + $CONFIG['OrderDaysGrace'], date("Y")); $duedate = date("Y-m-d", $new_time); update_query("tblinvoices", array("duedate" => $duedate), array("id" => $invoiceid)); } if (!$CONFIG['NoInvoiceEmailOnOrder']) { sendMessage("Invoice Created", $invoiceid); } } if ($invoiceid) { update_query("tblorders", array("invoiceid" => $invoiceid), array("id" => $orderid)); $result = select_query("tblinvoices", "status", array("id" => $invoiceid)); $data = mysql_fetch_array($result); $status = $data['status']; if ($status == "Paid") { $invoiceid = ""; } } if (!$_SESSION['adminid']) { if (isset($_COOKIE['WHMCSAffiliateID'])) { $result = select_query("tblaffiliates", "clientid", array("id" => (int) $_COOKIE['WHMCSAffiliateID'])); $data = mysql_fetch_array($result); $clientid = $data['clientid']; if ($clientid && $_SESSION['uid'] != $clientid) { foreach ($orderproductids as $orderproductid) { insert_query("tblaffiliatesaccounts", array("affiliateid" => (int) $_COOKIE['WHMCSAffiliateID'], "relid" => $orderproductid)); } } } if (isset($_COOKIE['WHMCSLinkID'])) { update_query("tbllinks", array("conversions" => "+1"), array("id" => $_COOKIE['WHMCSLinkID'])); } } $result = select_query("tblclients", "firstname, lastname, companyname, email, address1, address2, city, state, postcode, country, phonenumber, ip, host", array("id" => $userid)); $data = mysql_fetch_array($result); list($firstname, $lastname, $companyname, $email, $address1, $address2, $city, $state, $postcode, $country, $phonenumber, $ip, $host) = $data; $customfields = getCustomFields("client", "", $userid, "", true); $clientcustomfields = ""; foreach ($customfields as $customfield) { $clientcustomfields .= "" . $customfield['name'] . ": " . $customfield['value'] . "<br />\r\n"; } $result = select_query("tblpaymentgateways", "value", array("gateway" => $paymentmethod, "setting" => "name")); $data = mysql_fetch_array($result); $nicegatewayname = $data['value']; sendAdminMessage("New Order Notification", array("order_id" => $orderid, "order_number" => $order_number, "order_date" => fromMySQLDate(date("Y-m-d H:i:s"), true), "invoice_id" => $invoiceid, "order_payment_method" => $nicegatewayname, "order_total" => formatCurrency($cart_total), "client_id" => $userid, "client_first_name" => $firstname, "client_last_name" => $lastname, "client_email" => $email, "client_company_name" => $companyname, "client_address1" => $address1, "client_address2" => $address2, "client_city" => $city, "client_state" => $state, "client_postcode" => $postcode, "client_country" => $country, "client_phonenumber" => $phonenumber, "client_customfields" => $clientcustomfields, "order_items" => $adminemailitems, "order_notes" => nl2br($ordernotes), "client_ip" => $ip, "client_hostname" => $host), "account"); if (!$_SESSION['cart']['orderconfdisabled']) { sendMessage("Order Confirmation", $userid, array("order_id" => $orderid, "order_number" => $order_number, "order_details" => $adminemailitems)); } $_SESSION['cart'] = array(); $_SESSION['orderdetails'] = array("OrderID" => $orderid, "OrderNumber" => $order_number, "ServiceIDs" => $orderproductids, "DomainIDs" => $orderdomainids, "AddonIDs" => $orderaddonids, "RenewalIDs" => $orderrenewalids, "PaymentMethod" => $paymentmethod, "InvoiceID" => $invoiceid, "TotalDue" => $cart_total, "Products" => $orderproductids, "Domains" => $orderdomainids, "Addons" => $orderaddonids, "Renewals" => $orderrenewalids); run_hook("AfterShoppingCartCheckout", $_SESSION['orderdetails']); } $total_recurringmonthly = $recurring_cycles_total['monthly'] <= 0 ? "" : formatCurrency($recurring_cycles_total['monthly']); $total_recurringquarterly = $recurring_cycles_total['quarterly'] <= 0 ? "" : formatCurrency($recurring_cycles_total['quarterly']); $total_recurringsemiannually = $recurring_cycles_total['semiannually'] <= 0 ? "" : formatCurrency($recurring_cycles_total['semiannually']); $total_recurringannually = $recurring_cycles_total['annually'] <= 0 ? "" : formatCurrency($recurring_cycles_total['annually']); $total_recurringbiennially = $recurring_cycles_total['biennially'] <= 0 ? "" : formatCurrency($recurring_cycles_total['biennially']); $total_recurringtriennially = $recurring_cycles_total['triennially'] <= 0 ? "" : formatCurrency($recurring_cycles_total['triennially']); $cartdata['bundlewarnings'] = $bundlewarnings; $cartdata['rawdiscount'] = $cart_discount; $cartdata['subtotal'] = formatCurrency($cart_subtotal); $cartdata['discount'] = formatCurrency($cart_discount); $cartdata['promotype'] = $promo_data['type']; $cartdata['promovalue'] = $promo_data['type'] == "Fixed Amount" || $promo_data['type'] == "Price Override" ? formatCurrency($promo_data['value']) : round($promo_data['value'], 2); $cartdata['promorecurring'] = $promo_data['recurring'] ? $_LANG['recurring'] : $_LANG['orderpaymenttermonetime']; $cartdata['taxrate'] = $rawtaxrate; $cartdata['taxrate2'] = $rawtaxrate2; $cartdata['taxname'] = $taxname; $cartdata['taxname2'] = $taxname2; $cartdata['taxtotal'] = formatCurrency($total_tax_1); $cartdata['taxtotal2'] = formatCurrency($total_tax_2); $cartdata['adjustments'] = $adjustments; $cartdata['adjustmentstotal'] = formatCurrency($cart_adjustments); $cartdata['rawtotal'] = $cart_total; $cartdata['total'] = formatCurrency($cart_total); $cartdata['totalrecurringmonthly'] = $total_recurringmonthly; $cartdata['totalrecurringquarterly'] = $total_recurringquarterly; $cartdata['totalrecurringsemiannually'] = $total_recurringsemiannually; $cartdata['totalrecurringannually'] = $total_recurringannually; $cartdata['totalrecurringbiennially'] = $total_recurringbiennially; $cartdata['totalrecurringtriennially'] = $total_recurringtriennially; return $cartdata; }
} $gatewaypath = ROOTDIR . "/modules/gateways/" . $paymentmethod . ".php"; if (file_exists($gatewaypath)) { require_once $gatewaypath; } if (!function_exists($paymentmethod . "_link")) { redir("invoiceid=" . (int) $invoiceid, "creditcard.php"); } } $result = select_query("tblinvoices", "", array("userid" => $client->getID(), "id" => $invoiceid)); $data = mysql_fetch_array($result); $id = $data['id']; $total = $data['total']; $paymentmethod = $data['paymentmethod']; $paymentmethod = WHMCS_Gateways::makesafename($paymentmethod); $clientsdetails = getClientsDetails($client->getID()); $params = getGatewayVariables($paymentmethod, $id, $total); $paymentbutton = call_user_func($paymentmethod . "_link", $params); $ca->setTemplate("forwardpage"); $ca->assign("message", $_LANG['forwardingtogateway']); $ca->assign("code", $paymentbutton); $ca->assign("invoiceid", $id); $ca->output(); exit; } $smartyvalues['subtotal'] = formatCurrency($subtotal); if ($credit) { $smartyvalues['credit'] = formatCurrency($credit); } if ($tax) { $smartyvalues['tax'] = formatCurrency($tax);
if ($CONFIG['AutoRedirectoInvoice'] == "on") { redir("id=" . $invoiceid, "viewinvoice.php"); } if ($CONFIG['AutoRedirectoInvoice'] == "gateway") { if (in_array($paymentmethod, array("mailin", "banktransfer"))) { redir("id=" . $invoiceid, "viewinvoice.php"); } $params = getGatewayVariables($paymentmethod, $invoiceid, $total); $paymentbutton = call_user_func($paymentmethod . "_link", $params); unset($orderform); $templatefile = "forwardpage"; $smarty->assign("message", $_LANG['forwardingtogateway']); $smarty->assign("code", $paymentbutton); $smarty->assign("invoiceid", $invoiceid); outputClientArea($templatefile); exit; } } $amount = get_query_val("tblorders", "amount", array("userid" => $_SESSION['uid'], "id" => $orderid)); $templatefile = "complete"; $smartyvalues = array_merge($smartyvalues, array("orderid" => $orderid, "ordernumber" => $_SESSION['orderdetails']['OrderNumber'], "invoiceid" => $invoiceid, "ispaid" => $_SESSION['orderdetails']['paymentcomplete'], "amount" => $amount, "paymentmethod" => $paymentmethod, "clientdetails" => getClientsDetails($_SESSION['uid']))); $addons_html = run_hook("ShoppingCartCheckoutCompletePage", $smartyvalues); $smartyvalues['addons_html'] = $addons_html; } if (!$templatefile) { redir(); exit; } $nowrapper = isset($_REQUEST['ajax']) ? true : false; $smartyvalues['carttpl'] = $orderfrm->getTemplate(); outputClientArea($templatefile, $nowrapper);
} if (!function_exists("getClientsDetails")) { require ROOTDIR . "/includes/clientfunctions.php"; } $where = array(); if ($clientid) { $where['id'] = $clientid; } else { if ($email) { $where['email'] = $email; } } $result = select_query("tblclients", "id", $where); $data = mysql_fetch_array($result); $clientid = $data['id']; if (!$clientid) { $apiresults = array("result" => "error", "message" => "Client Not Found"); return null; } $clientsdetails = getClientsDetails($clientid); $currency_result = full_query("SELECT code FROM tblcurrencies WHERE id=" . (int) $clientsdetails['currency']); $currency = mysql_fetch_assoc($currency_result); $clientsdetails['currency_code'] = $currency['code']; if ($responsetype == "xml") { $apiresults = array("result" => "success", "client" => $clientsdetails); } else { $apiresults = array_merge(array("result" => "success"), $clientsdetails); } if ($stats || $responsetype == "xml") { $apiresults = array("result" => "success", "client" => $clientsdetails, "stats" => getClientsStats($clientid)); }
public function calcTotals() { global $whmcs; $retarray = array("subtotal" => "0", "taxenabled" => false, "taxname" => "", "taxrate" => 0, "taxname2" => "", "taxrate2" => 0); $subtotal = 11; foreach ($this->lineitems as $vals) { $subtotal += $vals['amount']; } $subtotal = round($subtotal, 2); if ($subtotal < 0 && !$whmcs->get_config("CreditOnDowngrade")) { $subtotal = 11; } if (is_array($this->promodata)) { } else { $promodata = get_query_vals("tblpromotions", "code,type,value", array("lifetimepromo" => 1, "recurring" => 1, "id" => get_query_val("tblhosting", "promoid", array("id" => $serviceid)))); if (is_array($promodata)) { $smartyvalues['promocode'] = $promocode = $promodata['code']; $smartyvalues['promorecurring'] = $smartyvalues['promodesc'] = $promodata['type'] == "Percentage" ? $promodata['value'] . "%" : formatCurrency($promodata['value']); $smartyvalues->promodesc .= " " . $_LANG['orderdiscount']; } } $tax = $tax2 = 0; if ($whmcs->get_config("TaxEnabled") && $this->getProductInfo("tax")) { $clientsdetails = getClientsDetails($this->getProductInfo("userid")); $state = $clientsdetails['state']; $country = $clientsdetails['country']; $taxexempt = $clientsdetails['taxexempt']; if (!$taxexempt) { $retarray['taxenabled'] = true; $taxdata = getTaxRate(1, $state, $country); $retarray['taxname'] = $taxdata['name']; $retarray['taxrate'] = $taxrate = $taxdata['rate']; $taxdata2 = getTaxRate(2, $state, $country); $retarray['taxname2'] = $taxdata2['name']; $retarray['taxrate2'] = $taxrate2 = $taxdata2['rate']; if ($taxrate) { if ($CONFIG['TaxType'] == "Inclusive") { $inctaxrate = 1 + $taxrate / 100; $tempsubtotal = $subtotal; $subtotal = $subtotal / $inctaxrate; $tax = $tempsubtotal - $subtotal; } else { $tax = $subtotal * ($taxrate / 100); } } if ($taxrate2) { $tempsubtotal = $subtotal; if ($CONFIG['TaxL2Compound']) { $tempsubtotal += $tax; } if ($CONFIG['TaxType'] == "Inclusive") { $inctaxrate = 1 + $taxrate / 100; $subtotal = $tempsubtotal / $inctaxrate; $tax2 = $tempsubtotal - $subtotal; } else { $tax2 = $tempsubtotal * ($taxrate2 / 100); } } $tax = round($tax, 2); $tax2 = round($tax2, 2); } } $retarray['subtotal'] = formatCurrency($subtotal); $retarray['tax'] = formatCurrency($tax); $retarray['tax2'] = formatCurrency($tax2); $retarray['total'] = formatCurrency($subtotal + $tax + $tax2); return $retarray; }
public function buildParams($vars = "") { if (count($this->moduleparams)) { $params = $this->moduleparams; if (is_array($vars)) { $params = array_merge($params, $vars); } return $params; } $params = array(); $params['accountid'] = $this->getData("id"); $params['serviceid'] = $this->getData("id"); $params['domain'] = $this->getData("domain"); $params['username'] = $this->getData("username"); $params['password'] = html_entity_decode($this->getData("password")); $params['packageid'] = $this->getData("pid"); $params['pid'] = $this->getData("pid"); $params['serverid'] = $this->getData("server"); $params['type'] = $this->getData("type"); $params['producttype'] = $this->getData("type"); $params['moduletype'] = $this->getModule(); $fields = array(); $counter = 1; while ($counter <= 10) { $fields[] = "configoption" . $counter; $counter += 1; } $moduleconfigops = get_query_vals("tblproducts", implode(",", $fields), array("id" => $this->getData("pid"))); foreach ($fields as $field) { $params[$field] = $moduleconfigops[$field]; } $customfields = array(); $result = full_query("SELECT tblcustomfields.fieldname,tblcustomfieldsvalues.value FROM tblcustomfields,tblcustomfieldsvalues WHERE tblcustomfields.id=tblcustomfieldsvalues.fieldid AND tblcustomfieldsvalues.relid='" . (int) $this->getData("id") . "' AND tblcustomfields.relid='" . (int) $this->getData("pid") . "'"); while ($data = mysql_fetch_array($result)) { $customfieldname = $data[0]; $customfieldvalue = $data[1]; if (strpos($customfieldname, "|")) { $customfieldname = explode("|", $customfieldname); $customfieldname = trim($customfieldname[0]); } if (strpos($customfieldvalue, "|")) { $customfieldvalue = explode("|", $customfieldvalue); $customfieldvalue = trim($customfieldvalue[0]); } $customfields[$customfieldname] = $customfieldvalue; } $params['customfields'] = $customfields; $configoptions = array(); $result = full_query("SELECT tblproductconfigoptions.optionname,tblproductconfigoptions.optiontype,tblproductconfigoptionssub.optionname,tblhostingconfigoptions.qty FROM tblproductconfigoptions,tblproductconfigoptionssub,tblhostingconfigoptions,tblproductconfiglinks WHERE tblhostingconfigoptions.configid=tblproductconfigoptions.id AND tblhostingconfigoptions.optionid=tblproductconfigoptionssub.id AND tblhostingconfigoptions.relid='" . (int) $this->getData("id") . "' AND tblproductconfiglinks.gid=tblproductconfigoptions.gid AND tblproductconfiglinks.pid='" . (int) $this->getData("pid") . "'"); while ($data = mysql_fetch_array($result)) { $configoptionname = $data[0]; $configoptiontype = $data[1]; $configoptionvalue = $data[2]; $configoptionqty = $data[3]; if (strpos($configoptionname, "|")) { $configoptionname = explode("|", $configoptionname); $configoptionname = trim($configoptionname[0]); } if (strpos($configoptionvalue, "|")) { $configoptionvalue = explode("|", $configoptionvalue); $configoptionvalue = trim($configoptionvalue[0]); } if ($configoptiontype == "3" || $configoptiontype == "4") { $configoptionvalue = $configoptionqty; } $configoptions[$configoptionname] = $configoptionvalue; } $params['configoptions'] = $configoptions; if (!function_exists("getClientsDetails")) { require dirname(__FILE__) . "/clientfunctions.php"; } $clientsdetails = getClientsDetails($this->getData("userid")); $clientsdetails['fullstate'] = $clientsdetails['state']; $clientsdetails['state'] = convertStateToCode($clientsdetails['state'], $clientsdetails['country']); $clientsdetails = foreignChrReplace($clientsdetails); $params['clientsdetails'] = $clientsdetails; $data = $this->getServerInfo(); if (count($data)) { $params['server'] = true; $params['serverip'] = $data['ipaddress']; $params['serverhostname'] = $data['hostname']; $params['serverusername'] = html_entity_decode($data['username']); $params['serverpassword'] = html_entity_decode(decrypt($data['password'])); $params['serveraccesshash'] = html_entity_decode($data['accesshash']); $params['serversecure'] = $data['secure']; } else { $params['server'] = false; $params['serverip'] = ""; $params['serverhostname'] = ""; $params['serverusername'] = ""; $params['serverpassword'] = ""; $params['serveraccesshash'] = ""; $params['serversecure'] = ""; } $this->moduleparams = $params; if (is_array($vars)) { $params = array_merge($params, $vars); } return $params; }
/** * * @ WHMCS FULL DECODED & NULLED * * @ Version : 5.2.15 * @ Author : MTIMER * @ Release on : 2013-12-24 * @ Website : http://www.mtimer.cn * **/ function initialiseClientArea($pagetitle, $pageicon, $breadcrumbnav) { global $whmcs; global $CONFIG; global $_LANG; global $templates_compiledir; global $in_ssl; global $clientsdetails; global $smarty; global $smartyvalues; include_once ROOTDIR . "/includes/smarty/Smarty.class.php"; $smarty = new Smarty(); $smarty->caching = 0; $smarty->template_dir = ROOTDIR . "/templates/"; $smarty->compile_dir = $templates_compiledir; $filename = $_SERVER['PHP_SELF']; $filename = substr($filename, strrpos($filename, "/")); $filename = str_replace("/", "", $filename); $filename = explode(".", $filename); $filename = $filename[0]; $breadcrumb = array(); $parts = explode(" > ", $breadcrumbnav); foreach ($parts as $part) { $parts2 = explode("\">", $part, 2); $link = str_replace("<a href=\"", "", $parts2[0]); $breadcrumb[] = array("link" => $link, "label" => strip_tags($parts2[1])); } $smarty->assign("template", $whmcs->get_sys_tpl_name()); $smarty->assign("language", $whmcs->get_client_language()); $smarty->assign("LANG", $_LANG); $smarty->assign("companyname", $CONFIG['CompanyName']); $smarty->assign("logo", $CONFIG['LogoURL']); $smarty->assign("charset", $CONFIG['Charset']); $smarty->assign("pagetitle", $pagetitle); $smarty->assign("pageicon", $pageicon); $smarty->assign("filename", $filename); $smarty->assign("breadcrumb", $breadcrumb); $smarty->assign("breadcrumbnav", $breadcrumbnav); $smarty->assign("todaysdate", date("l, jS F Y")); $smarty->assign("date_day", date("d")); $smarty->assign("date_month", date("m")); $smarty->assign("date_year", date("Y")); $smarty->assign("token", generate_token("plain")); if ($CONFIG['SystemSSLURL']) { $smarty->assign("systemsslurl", $CONFIG['SystemSSLURL'] . "/"); } if ($in_ssl && $CONFIG['SystemSSLURL']) { $smarty->assign("systemurl", $CONFIG['SystemSSLURL'] . "/"); } else { if ($CONFIG['SystemURL'] != "http://www.yourdomain.com/whmcs") { $smarty->assign("systemurl", $CONFIG['SystemURL'] . "/"); } } if (isset($_SESSION['uid'])) { $smarty->assign("loggedin", true); if (!function_exists("getClientsDetails")) { require ROOTDIR . "/includes/clientfunctions.php"; } $clientsdetails = getClientsDetails(); $smarty->assign("clientsdetails", $clientsdetails); $smarty->assign("clientsstats", getClientsStats($_SESSION['uid'])); if (isset($_SESSION['cid'])) { $result = select_query("tblcontacts", "id,firstname,lastname,email,permissions", array("id" => $_SESSION['cid'], "userid" => $_SESSION['uid'])); $data = mysql_fetch_array($result); $loggedinuser = array("contactid" => $data['id'], "firstname" => $data['firstname'], "lastname" => $data['lastname'], "email" => $data['email']); $contactpermissions = explode(",", $data[4]); } else { $loggedinuser = array("userid" => $_SESSION['uid'], "firstname" => $clientsdetails['firstname'], "lastname" => $clientsdetails['lastname'], "email" => $clientsdetails['email']); $contactpermissions = array("profile", "contacts", "products", "manageproducts", "domains", "managedomains", "invoices", "tickets", "affiliates", "emails", "orders"); } $smarty->assign("loggedinuser", $loggedinuser); $smarty->assign("contactpermissions", $contactpermissions); } if ($CONFIG['AllowLanguageChange'] == "on") { $smarty->assign("langchange", "true"); } $setlanguage = "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF']; $count = 0; foreach ($_GET as $k => $v) { $prefix = $count == 0 ? "?" : "&"; $setlanguage .= $prefix . htmlentities($k) . "=" . htmlentities($v); ++$count; } $setlanguage .= "\" name=\"languagefrm\" id=\"languagefrm\"><strong>" . $_LANG['language'] . ":</strong> <select name=\"language\" onchange=\"languagefrm.submit()\">"; foreach ($whmcs->getValidLanguages() as $lang) { $setlanguage .= "<option"; if ($lang == $whmcs->get_client_language()) { $setlanguage .= " selected=\"selected\""; } $setlanguage .= ">" . ucfirst($lang) . "</option>"; } $setlanguage .= "</select></form>"; $smarty->assign("setlanguage", $setlanguage); $currenciesarray = array(); $result = select_query("tblcurrencies", "id,code,`default`", "", "code", "ASC"); while ($data = mysql_fetch_array($result)) { $currenciesarray[] = array("id" => $data['id'], "code" => $data['code'], "default" => $data['default']); } if (count($currenciesarray) == 1) { $currenciesarray = ""; } $smarty->assign("currencies", $currenciesarray); $smarty->assign("twitterusername", $whmcs->get_config("TwitterUsername")); $smarty->assign("condlinks", WHMCS_ClientArea::getconditionallinks()); $smartyvalues = array(); }
function resellerclub_addCustomer($params) { global $CONFIG; require ROOTDIR . "/includes/countriescallingcodes.php"; if (!function_exists("getClientsDetails")) { require ROOTDIR . "/includes/clientfunctions.php"; } $clientdetails = foreignChrReplace(getClientsDetails($params['userid'])); $language = $clientdetails['language'] ? $clientdetails['language'] : $CONFIG['Language']; $language = resellerclub_Language($language); $postfields['auth-userid'] = $params['ResellerID']; $postfields['api-key'] = $params['APIKey']; $postfields['username'] = $clientdetails['email']; $postfields['passwd'] = resellerclub_genLBRandomPW(); $postfields['name'] = $clientdetails['firstname'] . " " . $clientdetails['lastname']; $companyname = $clientdetails['companyname']; if (!$companyname) { $companyname = "N/A"; } $postfields['company'] = $companyname; $postfields['address-line-1'] = substr($clientdetails['address1'], 0, 64); if (64 < $clientdetails['address1']) { $postfields['address-line-2'] = substr($clientdetails['address1'] . ", " . $clientdetails['address2'], 64, 128); } else { $postfields['address-line-2'] = substr($clientdetails['address2'], 0, 64); } $postfields['city'] = $clientdetails['city']; if ($params['country'] != "US") { $postfields['state'] = $clientdetails['state']; } else { $postfields['state'] = convertStateToCode($clientdetails['state'], $clientdetails['country']); } $postfields['zipcode'] = $clientdetails['postcode']; $postfields['country'] = $clientdetails['country']; $phonenumber = $clientdetails['phonenumber']; $phonenumber = preg_replace("/[^0-9]/", "", $phonenumber); $countrycode = $clientdetails['country']; $countrycode = $countrycallingcodes[$countrycode]; $postfields['phone-cc'] = $countrycode; $postfields['phone'] = $phonenumber; $postfields['lang-pref'] = "" . $language; $result = resellerclub_SendCommand("signup", "customers", $postfields, $params, "POST"); unset($postfields); if (strtoupper($result['status']) == "ERROR") { if (!$result['message']) { $result['message'] = $result['error']; } return array("error" => $result['message']); } $customerid = $result; return $customerid; }
public function valUserID($tempuid) { global $userid; global $clientsdetails; $userid = (int) $tempuid; if (!function_exists("getClientsDetails")) { require ROOTDIR . "/includes/clientfunctions.php"; } $clientsdetails = getClientsDetails($userid); $userid = $_REQUEST['userid'] = $_POST['userid'] = $_GET['userid'] = $clientsdetails['userid']; if (!$userid) { $this->gracefulExit($this->lang("clients", "invalidclientid")); } }
$subtotal = $data['subtotal']; $total = $data['total']; $status = $data['status']; $proposal = $data['proposal']; $notes = $data['customernotes']; $currency = $data['currency']; if (!$id) { $smarty->assign("error", "on"); $template_output = $smarty->fetch("viewquote.tpl"); echo $template_output; exit; } $date = fromMySQLDate($date, 0, 1); $validuntil = fromMySQLDate($validuntil, 0, 1); if ($userid) { $clientsdetails = getClientsDetails($userid, "billing"); } else { $clientsdetails = array(); $clientsdetails['firstname'] = $data['firstname']; $clientsdetails['lastname'] = $data['lastname']; $clientsdetails['companyname'] = $data['companyname']; $clientsdetails['email'] = $data['email']; $clientsdetails['address1'] = $data['address1']; $clientsdetails['address2'] = $data['address2']; $clientsdetails['city'] = $data['city']; $clientsdetails['state'] = $data['state']; $clientsdetails['postcode'] = $data['postcode']; $clientsdetails['country'] = $data['country']; $clientsdetails['phonenumber'] = $data['phonenumber']; } if ($CONFIG['TaxEnabled']) {
if (!function_exists("getClientsDetails")) { require ROOTDIR . "/includes/clientfunctions.php"; } if (!function_exists("updateInvoiceTotal")) { require ROOTDIR . "/includes/invoicefunctions.php"; } $result = select_query("tblclients", "id", array("id" => $_POST['userid'])); $data = mysql_fetch_array($result); if (!$data['id']) { $apiresults = array("result" => "error", "message" => "Client ID Not Found"); return null; } $taxrate = $_POST['taxrate']; $taxrate2 = $_POST['taxrate2']; if ($CONFIG['TaxEnabled'] == "on" && !$taxrate && !$taxrate2) { $clientsdetails = getClientsDetails($_POST['userid']); if (!$clientsdetails['taxexempt']) { $state = $clientsdetails['state']; $country = $clientsdetails['country']; $taxdata = getTaxRate(1, $state, $country); $taxdata2 = getTaxRate(2, $state, $country); $taxrate = $taxdata['rate']; $taxrate2 = $taxdata2['rate']; } } $invoiceid = insert_query("tblinvoices", array("date" => $_POST['date'], "duedate" => $_POST['duedate'], "userid" => $_POST['userid'], "status" => "Unpaid", "taxrate" => $taxrate, "taxrate2" => $taxrate2, "paymentmethod" => $_POST['paymentmethod'], "notes" => $_POST['notes'])); foreach ($_POST as $k => $v) { if (substr($k, 0, 10) == "itemamount") { $counter = substr($k, 10); $description = $_POST["itemdescription" . $counter]; $amount = $_POST["itemamount" . $counter];
function tco_reoccuring_request() { global $whmcs; $whmcs->load_function("gateway"); $whmcs->load_function("client"); $whmcs->load_function("invoice"); $GATEWAY = getGatewayVariables("tco"); $invoiceid = $description = (int) $_POST['invoiceid']; $vendorid = $GATEWAY['vendornumber']; $apiusername = $GATEWAY['apiusername']; $apipassword = $GATEWAY['apipassword']; $demomode = $GATEWAY['demomode']; $recurrings = getRecurringBillingValues($invoiceid); if (!$recurrings) { $url = "../../viewinvoice.php?id=" . $invoiceid; header("Location:" . $url); exit; } $primaryserviceid = $recurrings['primaryserviceid']; $first_payment_amount = $recurrings['firstpaymentamount'] ? $recurrings['firstpaymentamount'] : $recurrings['recurringamount']; $recurring_amount = $recurrings['recurringamount']; if ($recurrings['recurringcycleunits'] == "Months") { $billing_cycle = $recurrings['recurringcycleperiod'] . " Month"; } else { if ($recurrings['recurringcycleunits'] == "Years") { $billing_cycle = $recurrings['recurringcycleperiod'] . " Year"; } } $billing_duration = "Forever"; $startup_fee = $first_payment_amount - $recurring_amount; $url = "https://www.2checkout.com/api/products/create_product"; $name = "Recurring Subscription for Invoice #" . $invoiceid; if ($demomode = "on") { $query_string = "name=" . $name . "&price=" . $recurring_amount . "&startup_fee=" . $startup_fee . "&demo=Y&recurring=1&recurrence=" . $billing_cycle . "&duration=" . $billing_duration . "&description=" . $description; } else { $query_string = "name=" . $name . "&price=" . $recurring_amount . "&startup_fee=" . $startup_fee . "&recurring=1&recurrence=" . $billing_cycle . "&duration=" . $billing_duration . "&description=" . $description; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERPWD, $apiusername . ":" . $apipassword); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json")); $response = curl_exec($ch); curl_close($ch); if (!function_exists("json_decode")) { exit("JSON Module Required in PHP Build for 2CheckOut Gateway"); } $response = json_decode($response, true); if (!count($response['errors']) && $response['response_code'] == "OK") { logTransaction("2Checkout Recurring", print_r($response, true), "Ok"); $product_id = $response['product_id']; $assigned_product_id = $response['assigned_product_id']; $purchaseroutine = !$GATEWAY['purchaseroutine'] ? "s" : ""; $result = select_query("tblinvoices", "userid", array("id" => $invoiceid)); $data = mysql_fetch_array($result); $userid = $data[0]; $clientsdetails = getClientsDetails($userid); $currency = getCurrency($userid); global $CONFIG; $lang = $clientsdetails['language']; if (!$lang) { $lang = $CONFIG['Language']; } $lang = strtolower($lang); if ($lang == "chinese") { $lang = "zh"; } else { if ($lang == "danish") { $lang = "da"; } else { if ($lang == "dutch") { $lang = "nl"; } else { if ($lang == "french") { $lang = "fr"; } else { if ($lang == "german") { $lang = "gr"; } else { if ($lang == "greek") { $lang = "el"; } else { if ($lang == "italian") { $lang = "it"; } else { if ($lang == "japanese") { $lang = "jp"; } else { if ($lang == "norwegian") { $lang = "no"; } else { if ($lang == "portuguese") { $lang = "pt"; } else { if ($lang == "slovenian") { $lang = "sl"; } else { if ($lang == "spanish") { $lang = "es_la"; } else { if ($lang == "swedish") { $lang = "sv"; } else { if ($lang == "english") { $lang = "en"; } else { $lang = ""; } } } } } } } } } } } } } } if ($lang) { $lang = "&lang=" . $lang; } if ($clientsdetails['country'] != "US" || $clientsdetails['country'] != "CA") { $clientsdetails['state'] = "XX"; } $url = "https://www.2checkout.com/checkout/" . $purchaseroutine . "purchase?sid=" . $vendorid . "&quantity=1&product_id=" . $assigned_product_id . "&tco_currency=" . $currency['code'] . "&merchant_order_id=" . $primaryserviceid . "&card_holder_name=" . $clientsdetails['firstname'] . " " . $clientsdetails['lastname'] . "&street_address=" . $clientsdetails['address1'] . "&city=" . $clientsdetails['city'] . "&state=" . $clientsdetails['state'] . "&zip=" . $clientsdetails['postcode'] . "&country=" . $clientsdetails['country'] . "&email=" . $clientsdetails['email'] . "&phone=" . $clientsdetails['phonenumber'] . $lang; header("Location:" . $url); exit; return null; } $apierror = "Errors => " . print_r($response, true); logTransaction("2Checkout Recurring", $apierror, "Error"); $url = "../../viewinvoice.php?id=" . $invoiceid . "&paymentfailed=true"; header("Location:" . $url); exit; }
sendAdminNotification("account", "Offline Credit Card Payment Submitted", "<p>An offline credit card payment has just been submitted. Details are below:</p><p>Client ID: " . $_SESSION['uid'] . "<br />Invoice ID: " . $invoiceid . "</p>"); redir("id=" . $invoiceid . "&offlinepaid=true", "viewinvoice.php"); } if ($result == "success") { redir("id=" . $invoiceid . "&paymentsuccess=true", "viewinvoice.php"); exit; } else { $errormessage = "<li>" . $_LANG['creditcarddeclined']; $action = ""; if ($ccinfo == "new") { updateCCDetails($_SESSION['uid'], "", "", "", "", ""); } } } } $clientsdetails = getClientsDetails($_SESSION['uid'], "billing"); $cardtype = $clientsdetails['cctype']; $cardnum = $clientsdetails['cclastfour']; if (!$errormessage || $fromorderform) { $firstname = $clientsdetails['firstname']; $lastname = $clientsdetails['lastname']; $email = $clientsdetails['email']; $address1 = $clientsdetails['address1']; $address2 = $clientsdetails['address2']; $city = $clientsdetails['city']; $state = $clientsdetails['state']; $postcode = $clientsdetails['postcode']; $country = $clientsdetails['country']; $phonenumber = $clientsdetails['phonenumber']; } include "includes/countries.php";
function coza_TransferSync($params) { // currently we can only figure out if a transfer was rejected, by reading // the poll messages. Until I implemented some log-parser and hooks, it is // up to the admin to read the poll messages and do manual action on failed // transfer requests. // https://www.registry.net.za/content.php?wiki=1&contentid=25&title=Transfer%20Cleanup // get our consistent contact-id by getting it from the tblorders <> tbldomains $result = select_query('tblorders', 'tblorders.userid, tblorders.contactid, tblorders.nameservers', ['tbldomains.id' => (int) $params['domainid']], null, null, null, 'tbldomains ON tblorders.id = tbldomains.orderid'); if ($result === false || mysql_num_rows($result) !== 1) { // this should only happen on forged POST-request return ['error' => 'COZA/TransferSync: unknown order']; } $data = mysql_fetch_array($result); $user_id = (int) $data['userid']; $contact_id = (int) $data['contactid']; $nameservers = explode(',', $data['nameservers']); $nameservers = array_flip($nameservers); $contact_handle = \COZA\Factory::getContactHandle($params, $user_id, $contact_id); $epp_client = \COZA\Factory::build($params); try { $epp_client->connect(); // verify if domain is ours $frame = new \AfriCC\EPP\Frame\Command\Info\Domain(); $frame->setDomain(\COZA\Factory::getDomain($params)); $response = $epp_client->request($frame); unset($frame); if (!$response instanceof \AfriCC\EPP\Frame\Response) { unset($epp_client); return ['error' => 'COZA/TransferSync: unable to get response']; } // permanent fail, domain is available // @todo register domain for the client if ($response->code() === 2303) { unset($epp_client); return ['failed' => true, 'reason' => $response->message()]; } // other reasons if (!$response->success()) { unset($epp_client); return ['error' => sprintf('COZA/TransferSync: %s (%d)', $response->message(), $response->code())]; } $data = $response->data(); if (empty($data['infData']['clID']) || empty($data['infData']['exDate'])) { unset($epp_client); return ['error' => 'COZA/TransferSync: unable to parse response']; } // transfer not yet completed (tempfail) if ($data['infData']['clID'] !== \COZA\Factory::getRegistrarId($params)) { unset($epp_client); return ['error' => 'COZA/TransferSync: transfer not yet completed']; } // @todo if the transfer was rejected, the status should be anything else // OTHER than "pendingTransfer" AND have losing registrar as clID // meaning the transfer was then rejected - in this case we also need // to return a permfail $contact = getClientsDetails($user_id, $contact_id); // create contact if not exists try { \COZA\Factory::createContactIfNotExists($epp_client, $contact_handle, $contact); } catch (Exception $e) { unset($epp_client); return ['error' => $e->getMessage()]; } // prepare domain update $frame = new \AfriCC\EPP\Frame\Command\Update\Domain(); $frame->setDomain(\COZA\Factory::getDomain($params)); // override nameservers $ns_add = $ns_rem = []; if (!empty($data['infData']['ns']['hostAttr']) && is_array($data['infData']['ns']['hostAttr'])) { foreach ($data['infData']['ns']['hostAttr'] as $host_attr) { if (!isset($nameservers[$host_attr['hostName']])) { $ns_rem[] = $host_attr['hostName']; } else { $ns_add[] = $host_attr['hostName']; unset($nameservers[$host_attr['hostName']]); } } } $ns_add = array_merge($ns_add, array_keys($nameservers)); if (!empty($ns_add)) { foreach ($ns_add as $host) { $frame->addHostAttr($host); } } if (!empty($ns_rem)) { foreach ($ns_rem as $host) { $frame->removeHostAttr($host); } } // apply new contact if ($data['infData']['registrant'] !== $contact_handle) { $frame->changeRegistrant($contact_handle); } $response = $epp_client->request($frame); unset($frame); if (!$response instanceof \AfriCC\EPP\Frame\Response) { unset($epp_client); return ['error' => 'COZA/TransferSync: unable to get response']; } if (!$response->success()) { unset($epp_client); return ['error' => 'COZA/TransferSync: ' . $response->message()]; } // delete old contact if ($data['infData']['registrant'] !== $contact_handle) { // we can not delete contact handles right away, as it takes 5 days // until the old contact was replaced by the new contact. So lets // put in a queue and let a cronjob handle it insert_query('mod_coza_contact_deletequeue', ['next_due' => date('Y-m-d H:i:s', strtotime('+6 day')), 'contact_handle' => $data['infData']['registrant'], 'deleted' => 0]); } unset($epp_client); return ['completed' => true, 'expirydate' => date('Y-m-d', strtotime($data['infData']['exDate']))]; } catch (Exception $e) { unset($epp_client); return ['error' => sprintf('COZA/TransferSync: %s', $e->getMessage())]; } }
function convertQuotetoInvoice($id, $invoicetype, $invoiceduedate, $depositpercent, $depositduedate, $finalduedate, $sendemail) { global $CONFIG; global $_LANG; $result = select_query("tblquotes", "", array("id" => $id)); $data = mysql_fetch_array($result); $userid = $data['userid']; $firstname = $data['firstname']; $lastname = $data['lastname']; $companyname = $data['companyname']; $email = $data['email']; $address1 = $data['address1']; $address2 = $data['address2']; $city = $data['city']; $state = $data['state']; $postcode = $data['postcode']; $country = $data['country']; $phonenumber = $data['phonenumber']; $currency = $data['currency']; if ($userid) { getUsersLang($userid); $clientsdetails = getClientsDetails($userid); $state = $clientsdetails['state']; $country = $clientsdetails['country']; } else { if (!function_exists("addClient")) { require ROOTDIR . "/clientfunctions.php"; } $_SESSION['currency'] = $currency; $userid = addClient($firstname, $lastname, $companyname, $email, $address1, $address2, $city, $state, $postcode, $country, $phonenumber, substr(md5($id), 0, 10), 0, "", "on"); } if ($CONFIG['TaxEnabled'] == "on") { $taxlevel1 = getTaxRate(1, $state, $country); $taxlevel2 = getTaxRate(2, $state, $country); $taxrate = $taxlevel1['rate']; $taxrate2 = $taxlevel2['rate']; } $subtotal = $data['subtotal']; $tax1 = $data['tax1']; $tax2 = $data['tax2']; $total = $data['total']; $result = select_query("tblpaymentgateways", "gateway", array("setting" => "name"), "order", "ASC"); $data = mysql_fetch_array($result); $gateway = $data['gateway']; $duedate = $finaldate = ""; if ($invoicetype == "deposit") { if ($depositduedate) { $duedate = toMySQLDate($depositduedate); } $finaldate = $finalduedate ? toMySQLDate($finalduedate) : date("Y-m-d"); } else { if ($invoiceduedate) { $duedate = toMySQLDate($invoiceduedate); } } if (!$duedate) { $duedate = date("Y-m-d"); } $invoiceid = insert_query("tblinvoices", array("date" => "now()", "duedate" => $duedate, "userid" => $userid, "status" => "Unpaid", "paymentmethod" => $gateway, "taxrate" => $taxrate, "taxrate2" => $taxrate2, "subtotal" => $subtotal, "tax" => $tax1, "tax2" => $tax2, "total" => $total, "notes" => $_LANG['quoteref'] . $id)); if ($finaldate) { $finalinvoiceid = insert_query("tblinvoices", array("date" => "now()", "duedate" => $finaldate, "userid" => $userid, "status" => "Unpaid", "paymentmethod" => $gateway, "taxrate" => $taxrate, "taxrate2" => $taxrate2, "subtotal" => $subtotal, "tax" => $tax1, "tax2" => $tax2, "total" => $total, "notes" => $_LANG['quoteref'] . $id)); } $result = select_query("tblquoteitems", "", array("quoteid" => $id), "id", "ASC"); while ($data = mysql_fetch_array($result)) { $line_id = $data['id']; $line_desc = $data['description']; $line_qty = $data['quantity']; $line_unitprice = $data['unitprice']; $line_discount = $data['discount']; $line_taxable = $data['taxable']; $line_total = format_as_currency($line_qty * $line_unitprice * (1 - $line_discount / 100)); $lineitemdesc = "" . $line_qty . " x " . $line_desc . " @ " . $line_unitprice; if (0 < $line_discount) { $lineitemdesc .= " - " . $line_discount . "% " . $_LANG['orderdiscount']; } if ($finalinvoiceid) { $originalamount = $line_total; $line_total = $originalamount * ($depositpercent / 100); $final_amount = $originalamount - $line_total; insert_query("tblinvoiceitems", array("invoiceid" => $finalinvoiceid, "userid" => $userid, "description" => $lineitemdesc . " (" . (100 - $depositpercent) . "% " . $_LANG['quotefinalpayment'] . ")", "amount" => $final_amount, "taxed" => $line_taxable)); $lineitemdesc .= " (" . $depositpercent . "% " . $_LANG['quotedeposit'] . ")"; } insert_query("tblinvoiceitems", array("invoiceid" => $invoiceid, "userid" => $userid, "description" => $lineitemdesc, "amount" => $line_total, "taxed" => $line_taxable)); } if (!function_exists("updateInvoiceTotal")) { require ROOTDIR . "/includes/invoicefunctions.php"; } updateInvoiceTotal($invoiceid); if ($finalinvoiceid) { updateInvoiceTotal($finalinvoiceid); } run_hook("InvoiceCreationPreEmail", array("invoiceid" => $invoiceid)); if ($finalinvoiceid) { run_hook("InvoiceCreationPreEmail", array("invoiceid" => $finalinvoiceid)); } if ($sendemail) { sendMessage("Invoice Created", $invoiceid); if ($finalinvoiceid) { sendMessage("Invoice Created", $finalinvoiceid); } } run_hook("InvoiceCreated", array("invoiceid" => $invoiceid)); if ($finalinvoiceid) { run_hook("InvoiceCreated", array("invoiceid" => $finalinvoiceid)); } if (1 < $CONFIG['InvoiceIncrement']) { $invoiceincrement = $CONFIG['InvoiceIncrement'] - 1; $counter = 1; while ($counter <= $invoiceincrement) { $tempinvoiceid = insert_query("tblinvoices", array("date" => "now()")); delete_query("tblinvoices", array("id" => $tempinvoiceid)); $counter += 1; } } update_query("tblquotes", array("userid" => $userid, "stage" => "Accepted"), array("id" => $id)); return $invoiceid; }
function findOrCreateSirportlyContact($uid, $cid) { ## Setup the query $user_query = $uid === null ? 'is NULL' : "= '{$uid}'"; $client_query = $cid === null ? 'is NULL' : "= '{$cid}'"; $query = full_query("SELECT `sirportly_id` FROM `sirportly_contacts` WHERE `user_id` {$user_query} AND `contact_id` {$client_query}"); $result = mysql_fetch_array($query, MYSQL_ASSOC); if (empty($result['sirportly_id'])) { ## Fetch the client details $clientDetails = getClientsDetails($uid, $cid); ## Attempt to search Sirportly for the contact $contactSearch = _doSirportlyAPICall('contacts/search', array('query' => $clientDetails['email'], 'types' => 'email', 'limit' => '1')); ## Check to see if we encountered any errors if (checkForSirportlyErrors($contactSearch)) { die('Unable to create Sirportly contact'); } if (empty($contactSearch)) { ## Attempt to create the contact $createSirportlyContact = _doSirportlyAPICall('contacts/create', array('name' => $clientDetails['fullname'], 'company' => $clientDetails['company'])); ## Check to see if we encountered any errors if (checkForSirportlyErrors($createSirportlyContact)) { die('Unable to create Sirportly contact'); } ## Attempt to create the contact method $createSirportlyContactMethod = _doSirportlyAPICall('contacts/add_contact_method', array('contact' => $createSirportlyContact['id'], 'method_type' => 'email', 'data' => $clientDetails['email'])); ## Check to see if we encountered any errors if (checkForSirportlyErrors($createSirportlyContactMethod)) { die('Unable to create Sirportly contact method'); } ## Store the Sirportly contact ID for future storeSirportlyContact($uid, $cid, $createSirportlyContact['id']); ## Return the contact id return $createSirportlyContact['id']; } else { ## Store the Sirportly contact ID for future storeSirportlyContact($uid, $cid, $contactSearch['0']['contact']['id']); ## Return the contact id return $contactSearch['0']['contact']['id']; } ## If we got here something seriously went wrong die('Contact doesn\'t exist'); } else { ## Return the contact id return $result['sirportly_id']; } }
function ModuleBuildParams($id) { $result = select_query("tblhosting", "", array("id" => $id)); $data = mysql_fetch_array($result); $func_id = $id = $data['id']; $userid = $data['userid']; $domain = $data['domain']; $username = $data['username']; $password = html_entity_decode(decrypt($data['password'])); $pid = $data['packageid']; $server = $data['server']; $params['accountid'] = $id; $params['serviceid'] = $id; $params['domain'] = $domain; $params['username'] = $username; $params['password'] = $password; $params['packageid'] = $pid; $params['pid'] = $pid; $params['serverid'] = $server; $result = select_query("tblproducts", "", array("id" => $pid)); $data = mysql_fetch_array($result); $params['type'] = $data['type']; $params['producttype'] = $data['type']; $params['moduletype'] = $data['servertype']; if (!$params['moduletype']) { return false; } if (!isValidforPath($params['moduletype'])) { exit("Invalid Server Module Name"); } $counter = 1; while ($counter <= 12) { $params["configoption" . $counter] = $data["configoption" . $counter]; $counter += 1; } $customfields = array(); $result = full_query("SELECT tblcustomfields.fieldname,tblcustomfieldsvalues.value FROM tblcustomfields,tblcustomfieldsvalues WHERE tblcustomfields.id=tblcustomfieldsvalues.fieldid AND tblcustomfieldsvalues.relid=" . (int) $id . " AND tblcustomfields.relid=" . (int) $pid); while ($data = mysql_fetch_array($result)) { $customfieldname = $data[0]; $customfieldvalue = $data[1]; if (strpos($customfieldname, "|")) { $customfieldname = explode("|", $customfieldname); $customfieldname = trim($customfieldname[0]); } if (strpos($customfieldvalue, "|")) { $customfieldvalue = explode("|", $customfieldvalue); $customfieldvalue = trim($customfieldvalue[0]); } $customfields[$customfieldname] = $customfieldvalue; } $params['customfields'] = $customfields; $configoptions = array(); $result = full_query("SELECT tblproductconfigoptions.optionname,tblproductconfigoptions.optiontype,tblproductconfigoptionssub.optionname,tblhostingconfigoptions.qty FROM tblproductconfigoptions,tblproductconfigoptionssub,tblhostingconfigoptions,tblproductconfiglinks WHERE tblhostingconfigoptions.configid=tblproductconfigoptions.id AND tblhostingconfigoptions.optionid=tblproductconfigoptionssub.id AND tblhostingconfigoptions.relid=" . (int) $id . " AND tblproductconfiglinks.gid=tblproductconfigoptions.gid AND tblproductconfiglinks.pid=" . (int) $pid); while ($data = mysql_fetch_array($result)) { $configoptionname = $data[0]; $configoptiontype = $data[1]; $configoptionvalue = $data[2]; $configoptionqty = $data[3]; if (strpos($configoptionname, "|")) { $configoptionname = explode("|", $configoptionname); $configoptionname = trim($configoptionname[0]); } if (strpos($configoptionvalue, "|")) { $configoptionvalue = explode("|", $configoptionvalue); $configoptionvalue = trim($configoptionvalue[0]); } if ($configoptiontype == "3" || $configoptiontype == "4") { $configoptionvalue = $configoptionqty; } $configoptions[$configoptionname] = $configoptionvalue; } $params['configoptions'] = $configoptions; if (!function_exists("getClientsDetails")) { require dirname(__FILE__) . "/clientfunctions.php"; } $clientsdetails = getClientsDetails($userid); $clientsdetails['fullstate'] = $clientsdetails['state']; $clientsdetails['state'] = convertStateToCode($clientsdetails['state'], $clientsdetails['country']); $clientsdetails = foreignChrReplace($clientsdetails); $params['clientsdetails'] = $clientsdetails; if ($server) { $result = select_query("tblservers", "", array("id" => $server)); $data = mysql_fetch_array($result); $params['server'] = true; $params['serverip'] = $data['ipaddress']; $params['serverhostname'] = $data['hostname']; $params['serverusername'] = html_entity_decode($data['username']); $params['serverpassword'] = html_entity_decode(decrypt($data['password'])); $params['serveraccesshash'] = html_entity_decode($data['accesshash']); $params['serversecure'] = $data['secure']; } else { $params['server'] = false; $params['serverip'] = $params['serverhostname'] = $params['serverusername'] = $params['serverpassword'] = $params['serveraccesshash'] = $params['serversecure'] = ""; } if (!function_exists($params['moduletype'] . "_ConfigOptions")) { $modulepath = ROOTDIR . "/modules/servers/" . $params['moduletype'] . "/" . $params['moduletype'] . ".php"; if (file_exists($modulepath)) { require $modulepath; } else { logActivity("Required Product Module '" . $params['moduletype'] . "' Missing"); } } $GLOBALS['moduleparams'] = $params; return $params; }
$result = select_query("mod_project", "", "duedate>='" . toMySQLDate($datefrom) . "' AND duedate<='" . toMySQLDate($dateto) . "'" . $adminquery . $statusquery); while ($data = mysql_fetch_array($result)) { $totaltaskstime = 0; $projectid = $data['id']; $projectname = $data['title']; $adminid = $data['adminid']; $userid = $data['userid']; $created = $data['created']; $duedate = $data['duedate']; $ticketids = $data['ticketids']; $projectstatus = $data['status']; $created = fromMySQLDate($created); $duedate = fromMySQLDate($duedate); $admin = $adminid ? getAdminName($adminid) : "None"; if ($userid) { $clientsdetails = getClientsDetails($userid); $client = "<a href=\"clientssummary.php?userid=" . $clientsdetails['userid'] . "\">" . $clientsdetails['firstname'] . " " . $clientsdetails['lastname']; if ($clientsdetails['companyname']) { $client .= " (" . $clientsdetails['companyname'] . ")"; } $client .= "</a>"; $currency = getCurrency(); } else { $client = "None"; } $ticketinvoicelinks = array(); foreach ($ticketids as $i => $ticketnum) { if ($ticketnum) { $ticketnum = get_query_val("tbltickets", "tid", array("tid" => $ticketnum)); $ticketinvoicelinks[] = "description LIKE '%Ticket #" . $ticketnum . "%'"; continue;
if (!isValidforPath($paymentmethod)) { exit("Invalid Payment Gateway Name"); } $gatewaypath = ROOTDIR . "/modules/gateways/" . $paymentmethod . ".php"; if (file_exists($gatewaypath)) { require_once $gatewaypath; } if (!function_exists($paymentmethod . "_link")) { redir("invoiceid=" . (int) $invoiceid, "creditcard.php"); } } if ($CONFIG['AutoRedirectoInvoice'] == "on") { redir("id=" . (int) $invoiceid, "viewinvoice.php"); } if ($CONFIG['AutoRedirectoInvoice'] == "gateway") { $clientsdetails = getClientsDetails($_SESSION['uid']); $params = getGatewayVariables($paymentmethod, $invoiceid, $total); $paymentbutton = call_user_func($paymentmethod . "_link", $params); $templatefile = "forwardpage"; $smarty->assign("message", $_LANG['forwardingtogateway']); $smarty->assign("code", $paymentbutton); $smarty->assign("invoiceid", $invoiceid); outputClientArea($templatefile); exit; } } else { $smarty->assign("ispaid", true); } } $templatefile = "complete"; $smarty->assign("orderid", (int) $orderid);