function calccarttotals ($checkout = '')
{
global $CONFIG;
global $_LANG;
$total_setup = '0';
$total_onetime = '0';
$total_recurring = '0';
$total_recurringmonthly = '0';
$total_recurringquarterly = '0';
$total_recurringsemiannually = '0';
$total_recurringannually = '0';
$total_biennially = '0';
$total_tax = '0';
$freedomains = array ();
if ($checkout)
{
if (!$_SESSION['cart'])
{
return false;
}
$order_number = generateuniqueid ();
$paymentmethod = $_SESSION['cart']['paymentmethod'];
$userid = $_SESSION['uid'];
$query = '' . 'INSERT INTO tblorders (ordernum,userid,contactid,date,status,paymentmethod,ipaddress) VALUES (\'' . $order_number . '\',\'' . $userid . '\',\'' . $_SESSION['cart']['contact'] . ('' . '\',now(),\'Pending\',\'' . $paymentmethod . '\',\'') . $_SERVER['REMOTE_ADDR'] . '\')';
$result = mysql_query ($query);
$orderid = mysql_insert_id ();
logactivity ('' . 'New Order Placed (Order ID: ' . $orderid . ')');
}
$promotioncode = $_SESSION['cart']['promo'];
if ($promotioncode)
{
$query = '' . 'SELECT * FROM tblpromotions WHERE code=\'' . $promotioncode . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$promo_item = $data['item'];
$promo_type = $data['type'];
$promo_discount = $data['discount'];
$promo_value = $data['value'];
$promo_packages = $data['packages'];
$promo_addons = $data['addons'];
$promo_applies = $data['appliesto'];
$promo_packages = explode (',', $promo_packages);
$promo_addons = explode (',', $promo_addons);
$query = '' . 'UPDATE tblorders SET promocode=\'' . $promotioncode . '\',promotype=\'' . $promo_type . ' (' . $promo_item . ')\',promovalue=\'' . $promo_value . '\' WHERE id=\'' . $orderid . '\'';
$result = mysql_query ($query);
if ($checkout)
{
$query = '' . 'UPDATE tblpromotions SET uses=uses+1 WHERE code=\'' . $promotioncode . '\'';
$result = mysql_query ($query);
}
}
if (($_SESSION['cart']['user']['state'] OR $_SESSION['cart']['user']['country']))
{
$state = $_SESSION['cart']['user']['state'];
$country = $_SESSION['cart']['user']['country'];
}
else
{
$clientsdetails = getclientsdetails ($userid);
$state = $clientsdetails['state'];
$country = $clientsdetails['country'];
}
$query = '' . 'SELECT * FROM tbltax WHERE state=\'' . $state . '\' AND country=\'' . $country . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$taxname = $data['name'];
if (!$taxname)
{
$query = '' . 'SELECT * FROM tbltax WHERE state=\'\' AND country=\'' . $country . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$taxname = $data['name'];
}
if (!$taxname)
{
$query = 'SELECT * FROM tbltax WHERE state=\'\' AND country=\'\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$taxname = $data['name'];
}
if (!$taxname)
{
$taxname = $_LANG['invoicestax'];
}
$taxrate = gettaxrate ($state, $country);
$rawtaxrate = $taxrate;
$inctaxrate = $taxrate / 100 + 1;
$taxrate /= 100;
if ($_SESSION['cart']['products'])
{
foreach ($_SESSION['cart']['products'] as $key => $productdata)
{
$productinfo = getproductinfo ($productdata['pid']);
$productdata['productinfo'] = $productinfo;
$customfields = getcustomfields ('product', $productdata['pid'], '', '', 'on', $productdata['customfields']);
$productdata['customfields'] = $customfields;
$query = 'SELECT * FROM tblproducts WHERE id=\'' . $productdata['pid'] . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$productname = $data['name'];
$paytype = $data['paytype'];
$msetupfee = $data['msetupfee'];
$qsetupfee = $data['qsetupfee'];
$ssetupfee = $data['ssetupfee'];
$asetupfee = $data['asetupfee'];
$bsetupfee = $data['bsetupfee'];
$monthly = $data['monthly'];
$quarterly = $data['quarterly'];
$semiannual = $data['semiannual'];
$annual = $data['annual'];
$biennial = $data['biennial'];
$proratabilling = $data['proratabilling'];
$proratadate = $data['proratadate'];
$proratachargenextmonth = $data['proratachargenextmonth'];
$tax = $data['tax'];
$servertype = $data['servertype'];
$defaultserver = $data['defaultserver'];
$autosetup = $data['autosetup'];
$stockcontrol = $data['stockcontrol'];
$freedomain = $data['freedomain'];
$freedomainpaymentterms = $data['freedomainpaymentterms'];
$freedomaintlds = $data['freedomaintlds'];
$freedomainpaymentterms = explode (',', $freedomainpaymentterms);
$freedomaintlds = explode (',', $freedomaintlds);
if (!$CONFIG['TaxEnabled'])
{
$tax = '';
}
if ($paytype == 'recurring')
{
$billingcycle = $productdata['billingcycle'];
if ((((($billingcycle == 'monthly' OR $billingcycle == 'quarterly') OR $billingcycle == 'semiannually') OR $billingcycle == 'annually') OR $billingcycle == 'biennially'))
{
}
else
{
if ($monthly != '0.00')
{
$billingcycle = 'monthly';
}
else
{
if ($quarterly != '0.00')
{
$billingcycle = 'quarterly';
}
else
{
if ($semiannual != '0.00')
{
$billingcycle = 'semiannually';
}
else
{
if ($annual != '0.00')
{
$billingcycle = 'annually';
}
else
{
if ($biennial != '0.00')
{
$billingcycle = 'biennially';
}
}
}
}
}
}
}
else
{
if ($paytype == 'onetime')
{
$billingcycle = 'onetime';
}
else
{
$billingcycle = 'free';
}
}
$productdata['billingcycle'] = $billingcycle;
if ($billingcycle == 'free')
{
$product_setup = '0';
$product_onetime = '0';
$product_recurring = '0';
$databasecycle = 'Free Account';
}
else
{
if ($billingcycle == 'onetime')
{
$product_setup = $msetupfee;
$product_onetime = $monthly;
$product_recurring = 0;
$databasecycle = 'One Time';
}
else
{
if ($billingcycle == 'monthly')
{
$product_setup = $msetupfee;
$product_onetime = $monthly;
$product_recurring = $monthly;
$databasecycle = 'Monthly';
}
else
{
if ($billingcycle == 'quarterly')
{
$product_setup = $qsetupfee;
$product_onetime = $quarterly;
$product_recurring = $quarterly;
$databasecycle = 'Quarterly';
}
else
{
if ($billingcycle == 'semiannually')
{
$product_setup = $ssetupfee;
$product_onetime = $semiannual;
$product_recurring = $semiannual;
$databasecycle = 'Semi-Annually';
}
else
{
if ($billingcycle == 'annually')
{
$product_setup = $asetupfee;
$product_onetime = $annual;
$product_recurring = $annual;
$databasecycle = 'Annually';
}
else
{
if ($billingcycle == 'biennially')
{
$product_setup = $bsetupfee;
$product_onetime = $biennial;
$product_recurring = $biennial;
$databasecycle = 'Biennially';
}
}
}
}
}
}
}
$configurableoptions = array ();
$configurableoptions = getconfigurableproductoptions ($productdata['pid'], $productdata['configoptions'], $billingcycle);
$configoptions = '';
if ($configurableoptions)
{
foreach ($configurableoptions as $confkey => $value)
{
$configoptions[] = array ('name' => $value['optionname'], 'option' => $value['selectedoption']);
$configoptionsdb[$value['id']] = $value['selectedvalue'];
$product_setup += $value['selectedsetup'];
$product_onetime += $value['selectedrecurring'];
$product_recurring += $value['selectedrecurring'];
}
}
$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;
}
}
if ($proratabilling)
{
if ($billingcycle == 'monthly')
{
$proratamonths = 1;
}
else
{
if ($billingcycle == 'quarterly')
{
$proratamonths = 3;
}
else
{
if ($billingcycle == 'semiannually')
{
$proratamonths = 6;
}
else
{
if ($billingcycle == 'annually')
{
$proratamonths = 12;
}
else
{
if ($billingcycle == 'biennially')
{
$proratamonths = 24;
}
}
}
}
}
if ($billingcycle != 'monthly')
{
$proratachargenextmonth = 0;
}
$prorataamount = $product_onetime / $proratamonths;
if (date ('d') < $proratadate)
{
$proratamonth = date ('m');
}
else
{
$proratamonth = date ('m') + 1;
}
$days = (strtotime (date ('Y-m-d', mktime (0, 0, 0, $proratamonth, $proratadate, date ('Y')))) - strtotime (date ('Y-m-d'))) / (60 * 60 * 24);
$totaldays = 30;
$product_onetime = $prorataamount * ($days / $totaldays);
$product_onetime = format_as_currency ($product_onetime);
$proratadateuntil = date ('Y-m-d', mktime (0, 0, 0, $proratamonth, $proratadate, date ('Y')));
if (($proratachargenextmonth <= date ('d') AND $days < 31))
{
$product_onetime += $product_recurring;
$proratadateuntil = date ('Y-m-d', mktime (0, 0, 0, $proratamonth + $proratamonths, $proratadate, date ('Y')));
}
$productdata['proratadate'] = frommysqldate ($proratadateuntil);
}
if (($product_onetime == '0' AND $product_recurring == '0'))
{
$pricing_text = $_LANG['orderfree'];
}
else
{
$pricing_text = $CONFIG['CurrencySymbol'] . format_as_currency ($product_onetime) . ' ' . $CONFIG['Currency'];
if ($product_setup != '0.00')
{
$pricing_text .= ' + ' . $CONFIG['CurrencySymbol'] . format_as_currency ($product_setup) . ' ' . $CONFIG['Currency'] . ' ' . $_LANG['ordersetupfee'];
}
}
$productdata['pricingtext'] = $pricing_text;
$thisproductfirstpaymentamount = $product_setup + $product_onetime;
$thisproductrecurringamount = $product_recurring;
$total_onetime += $thisproductfirstpaymentamount;
$total_recurring += $thisproductrecurringamount;
if (((($promo_item == 'Product' AND !$promo_used) AND in_array ($productdata['pid'], $promo_packages)) AND (($promo_applies AND $databasecycle == $promo_applies) OR !$promo_applies)))
{
if ($promo_discount == 'Money Value')
{
if ($thisproductfirstpaymentamount < $promo_value)
{
$discount = $thisproductfirstpaymentamount;
}
else
{
$discount = $promo_value;
}
}
else
{
$percent = $promo_value / 100;
$discount = $thisproductfirstpaymentamount * $percent;
}
$thisproductfirstpaymentamount -= $discount;
$total_onetime -= $discount;
if ($promo_type == 'Recurring')
{
if ($promo_discount == 'Money Value')
{
if ($thisproductrecurringamount < $promo_value)
{
$recdiscount = $thisproductrecurringamount;
}
else
{
$recdiscount = $promo_value;
}
}
else
{
$percent = $promo_value / 100;
$recdiscount = $thisproductrecurringamount * $percent;
}
$thisproductrecurringamount -= $recdiscount;
$total_recurring -= $recdiscount;
}
$promo_used = true;
}
if ($tax)
{
$total_tax = $total_onetime;
if ($CONFIG['TaxType'] == 'Exclusive')
{
$total_recurring += $thisproductrecurringamount * $taxrate;
}
}
if ($billingcycle == 'monthly')
{
$total_recurringmonthly += $thisproductrecurringamount;
}
else
{
if ($billingcycle == 'quarterly')
{
$total_recurringquarterly += $thisproductrecurringamount;
}
else
{
if ($billingcycle == 'semiannually')
{
$total_recurringsemiannually += $thisproductrecurringamount;
}
else
{
if ($billingcycle == 'annually')
{
$total_recurringannually += $thisproductrecurringamount;
}
else
{
if ($billingcycle == 'biennially')
{
$total_recurringbiennially += $thisproductrecurringamount;
}
}
}
}
}
if ($checkout)
{
if ($servertype)
{
if ($defaultserver == '0')
{
$query = '' . 'SELECT id,maxaccounts FROM tblservers WHERE type=\'' . $servertype . '\' AND active=\'1\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$serverid = $data['id'];
$maxaccounts = $data['maxaccounts'];
$query = '' . 'SELECT COUNT(id) FROM tblhosting WHERE server=\'' . $serverid . '\' AND (domainstatus=\'Active\' OR domainstatus=\'Suspended\')';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$usagecount = $data[0];
if ($usagecount == $maxaccounts)
{
$query = '' . 'SELECT id FROM tblservers WHERE type=\'' . $servertype . '\' AND id!=\'' . $serverid . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$newserverid = $data['id'];
$query = '' . 'UPDATE tblservers SET active=\'\' WHERE type=\'' . $servertype . '\'';
$result = mysql_query ($query);
$query = '' . 'UPDATE tblservers SET active=\'1\' WHERE type=\'' . $servertype . '\' AND id=\'' . $newserverid . '\'';
$result = mysql_query ($query);
}
if ($newserverid != '')
{
$serverid = $newserverid;
}
}
else
{
$serverid = $defaultserver;
}
}
if ($databasecycle == 'Free Account')
{
$hostingquerydates = '00000000,00000000';
}
else
{
$hostingquerydates = 'now(),now()';
}
$productid = $productdata['pid'];
$domain = $productdata['domain'];
$serverhostname = $productdata['server']['hostname'];
$serverns1prefix = $productdata['server']['ns1prefix'];
$serverns2prefix = $productdata['server']['ns2prefix'];
$serverrootpw = encrypt ($productdata['server']['rootpw']);
if ($serverhostname)
{
$domain = $serverhostname . '.' . $domain;
}
if ($serverns1prefix)
{
$serverns1prefix = $serverns1prefix . '.' . $domain;
}
if ($serverns2prefix)
{
$serverns2prefix = $serverns2prefix . '.' . $domain;
}
$query = '' . 'INSERT INTO tblhosting (userid,orderid,regdate,server,domain,paymentmethod,firstpaymentamount,amount,billingcycle,nextduedate,nextinvoicedate,domainstatus,packageid,ns1,ns2,rootpassword) VALUES (\'' . $userid . '\',\'' . $orderid . '\',now(),\'' . $serverid . '\',\'' . $domain . '\',\'' . $paymentmethod . '\',\'' . $thisproductfirstpaymentamount . '\',\'' . $thisproductrecurringamount . '\',\'' . $databasecycle . '\',' . $hostingquerydates . ',\'Pending\',\'' . $productid . '\',\'' . $serverns1prefix . '\',\'' . $serverns2prefix . '\',\'' . $serverrootpw . '\')';
$result = mysql_query ($query);
$clientproductid = mysql_insert_id ();
$orderproductids[] = $clientproductid;
$adminemailitems .= $_LANG['orderproduct'] . ('' . ': ' . $productname . '
') . $_LANG['orderdomain'] . ('' . ': ' . $domain . '
') . $_LANG['firstpaymentamount'] . ': ' . $CONFIG['CurrencySymbol'] . ('' . $thisproductfirstpaymentamount . '
') . $_LANG['recurringamount'] . ': ' . $CONFIG['CurrencySymbol'] . ('' . $thisproductrecurringamount . '
') . $_LANG['orderbillingcycle'] . ': ' . $_LANG['orderpaymentterm' . str_replace ('-', '', strtolower ($databasecycle))] . '
';
if ($stockcontrol == 'on')
{
$query = '' . 'UPDATE tblproducts SET qty=qty-1 WHERE id=\'' . $productid . '\'';
$result = mysql_query ($query);
}
if ($configoptionsdb)
{
foreach ($configoptionsdb as $key => $value)
{
$query = '' . 'INSERT INTO tblhostingconfigoptions (relid,configid,optionid) VALUES (\'' . $clientproductid . '\',\'' . $key . '\',\'' . $value . '\')';
$result = mysql_query ($query);
}
}
foreach ($productdata['customfields'] as $key => $value)
{
$query = 'INSERT INTO tblcustomfieldsvalues (fieldid,relid,value) VALUES (\'' . $value['id'] . ('' . '\',\'' . $clientproductid . '\',\'') . $value['rawvalue'] . '\')';
$result = mysql_query ($query);
}
if ($autosetup == 'order')
{
$servertype = getservertype ($serverid);
include_once dirname (__FILE__) . ('' . '/modules/servers/' . $servertype . '/' . $servertype . '.php');
$result = servercreateaccount ($clientproductid);
if ($result == 'success')
{
sendmessage ('defaultnewacc', $clientproductid);
logactivity ('Automatic Setup of Account on Order Successful');
}
else
{
logactivity ('' . 'Automatic Setup of Account on Order Failed (' . $result . ')');
}
}
}
if ($CONFIG['TaxAddons'])
{
$tax = '1';
}
unset ($addonsarray);
$addons = $productdata['addons'];
if ($addons)
{
foreach ($addons as $addonid)
{
$query = '' . 'SELECT * FROM tbladdons WHERE id=\'' . $addonid . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$addon_name = $data['name'];
$addon_description = $data['description'];
$addon_recurring = $data['recurring'];
$addon_setupfee = $data['setupfee'];
$addon_billingcycle = $data['billingcycle'];
$total_onetime += $addon_setupfee + $addon_recurring;
$rawaddononetime = $addon_setupfee + $addon_recurring;
$rawaddonrecurring = $addon_recurring;
if ((($promo_item == 'Addon' AND !$promo_used) AND in_array ($addonid, $promo_addons)))
{
if ($promo_discount == 'Money Value')
{
if ($rawaddononetime < $promo_value)
{
$discount = $rawaddononetime;
}
else
{
$discount = $promo_value;
}
}
else
{
$percent = $promo_value / 100;
$discount = $rawaddononetime * $percent;
}
$rawaddononetime -= $discount;
if ($promo_type == 'Recurring')
{
if ($promo_discount == 'Money Value')
{
if ($rawaddonrecurring < $promo_value)
{
$recdiscount = $rawaddonrecurring;
}
else
{
$recdiscount = $promo_value;
}
}
else
{
$percent = $promo_value / 100;
$recdiscount = $rawaddonrecurring * $percent;
}
$rawaddonrecurring -= $recdiscount;
}
$promo_used = true;
}
if ($checkout)
{
if ($addon_billingcycle == 'Free')
{
$querydates = '00000000,00000000';
}
else
{
$querydates = 'now(),now()';
}
$addonsetupfee = $rawaddononetime - $rawaddonrecurring;
$query = '' . 'INSERT INTO tblhostingaddons (hostingid,orderid,regdate,name,setupfee,recurring,billingcycle,status,nextduedate,nextinvoicedate,paymentmethod) VALUES (\'' . $clientproductid . '\',\'' . $orderid . '\',now(),\'' . $addon_name . '\',\'' . $addonsetupfee . '\',\'' . $rawaddonrecurring . '\',\'' . $addon_billingcycle . '\',\'Pending\',' . $querydates . ',\'' . $paymentmethod . '\')';
$result = mysql_query ($query);
$addonid = mysql_insert_id ();
$orderaddonids[] = $addonid;
$adminemailitems .= $_LANG['clientareaaddon'] . ('' . ': ' . $addon_name . '
') . $_LANG['ordersetupfee'] . ': ' . $CONFIG['CurrencySymbol'] . ('' . $addonsetupfee . '
') . $_LANG['recurringamount'] . ': ' . $CONFIG['CurrencySymbol'] . ('' . $rawaddonrecurring . '
') . $_LANG['orderbillingcycle'] . ': ' . $_LANG['orderpaymentterm' . str_replace ('-', '', strtolower ($addon_billingcycle))] . '
';
}
if ($tax)
{
$total_tax += $addon_setupfee + $addon_recurring;
if ($CONFIG['TaxType'] == 'Exclusive')
{
$rawaddonrecurring = $rawaddonrecurring + $rawaddonrecurring * $taxrate;
}
}
if ($addon_billingcycle == 'Monthly')
{
$total_recurringmonthly += $rawaddonrecurring;
}
else
{
if ($addon_billingcycle == 'Quarterly')
{
$total_recurringquarterly += $rawaddonrecurring;
}
else
{
if ($addon_billingcycle == 'Semi-Annually')
{
$total_recurringsemiannually += $rawaddonrecurring;
}
else
{
if ($addon_billingcycle == 'Annually')
{
$total_recurringannually += $rawaddonrecurring;
}
else
{
if ($addon_billingcycle == 'Biennially')
{
$total_recurringbiennially += $rawaddonrecurring;
}
}
}
}
}
if (($addon_setupfee == '0' AND $addon_recurring == '0'))
{
$pricing_text = $_LANG['orderfree'];
}
else
{
$pricing_text = $CONFIG['CurrencySymbol'] . format_as_currency ($addon_recurring) . ' ' . $CONFIG['Currency'];
if ($addon_setupfee != '0.00')
{
$pricing_text .= ' + ' . $CONFIG['CurrencySymbol'] . format_as_currency ($addon_setupfee) . ' ' . $CONFIG['Currency'] . ' ' . $_LANG['ordersetupfee'];
}
}
$addonsarray[] = array ('name' => $addon_name, 'pricingtext' => $pricing_text);
}
}
$productdata['addons'] = $addonsarray;
$productsarray[$key] = $productdata;
}
}
$cartdata['products'] = $productsarray;
if ($_SESSION['cart']['addons'])
{
if ($CONFIG['TaxAddons'])
{
$tax = '1';
}
foreach ($_SESSION['cart']['addons'] as $key => $addon)
{
$addonid = $addon['id'];
$productid = $addon['productid'];
$query = '' . 'SELECT * FROM tbladdons WHERE id=\'' . $addonid . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$addon_name = $data['name'];
$addon_description = $data['description'];
$addon_recurring = $data['recurring'];
$addon_setupfee = $data['setupfee'];
$addon_billingcycle = $data['billingcycle'];
$total_onetime += $addon_setupfee + $addon_recurring;
$rawaddononetime = $addon_setupfee + $addon_recurring;
$rawaddonrecurring = $addon_recurring;
if ((($promo_item == 'Addon' AND !$promo_used) AND in_array ($addonid, $promo_addons)))
{
if ($promo_discount == 'Money Value')
{
if ($rawaddononetime < $promo_value)
{
$discount = $rawaddononetime;
}
else
{
$discount = $promo_value;
}
}
else
{
$percent = $promo_value / 100;
$discount = $rawaddononetime * $percent;
}
$rawaddononetime -= $discount;
if ($promo_type == 'Recurring')
{
if ($promo_discount == 'Money Value')
{
if ($rawaddonrecurring < $promo_value)
{
$recdiscount = $rawaddonrecurring;
}
else
{
$recdiscount = $promo_value;
}
}
else
{
$percent = $promo_value / 100;
$recdiscount = $rawaddonrecurring * $percent;
}
$rawaddonrecurring -= $recdiscount;
}
$promo_used = true;
}
if ($checkout)
{
if ($addon_billingcycle == 'Free')
{
$querydates = '00000000,00000000';
}
else
{
$querydates = 'now(),now()';
}
$addonsetupfee = $rawaddononetime - $rawaddonrecurring;
$query = '' . 'INSERT INTO tblhostingaddons (hostingid,orderid,regdate,name,setupfee,recurring,billingcycle,status,nextduedate,nextinvoicedate,paymentmethod) VALUES (\'' . $productid . '\',\'' . $orderid . '\',now(),\'' . $addon_name . '\',\'' . $addonsetupfee . '\',\'' . $rawaddonrecurring . '\',\'' . $addon_billingcycle . '\',\'Pending\',' . $querydates . ',\'' . $paymentmethod . '\')';
$result = mysql_query ($query);
$addonid = mysql_insert_id ();
$orderaddonids[] = $addonid;
$adminemailitems .= $_LANG['clientareaaddon'] . ('' . ': ' . $addon_name . '
') . $_LANG['ordersetupfee'] . ': ' . $CONFIG['CurrencySymbol'] . ('' . $addonsetupfee . '
') . $_LANG['recurringamount'] . ': ' . $CONFIG['CurrencySymbol'] . ('' . $rawaddonrecurring . '
') . $_LANG['orderbillingcycle'] . ': ' . $_LANG['orderpaymentterm' . str_replace ('-', '', strtolower ($addon_billingcycle))] . '
';
}
if ($tax)
{
$total_tax += $addon_setupfee + $addon_recurring;
if ($CONFIG['TaxType'] == 'Exclusive')
{
$rawaddonrecurring = $rawaddonrecurring + $rawaddonrecurring * $taxrate;
}
}
if ($addon_billingcycle == 'Monthly')
{
$total_recurringmonthly += $rawaddonrecurring;
}
else
{
if ($addon_billingcycle == 'Quarterly')
{
$total_recurringquarterly += $rawaddonrecurring;
}
else
{
if ($addon_billingcycle == 'Semi-Annually')
{
$total_recurringsemiannually += $rawaddonrecurring;
}
else
{
if ($addon_billingcycle == 'Annually')
{
$total_recurringannually += $rawaddonrecurring;
}
else
{
if ($addon_billingcycle == 'Biennially')
{
$total_recurringbiennially += $rawaddonrecurring;
}
}
}
}
}
if (($addon_setupfee == '0' AND $addon_recurring == '0'))
{
$pricing_text = $_LANG['orderfree'];
}
else
{
$pricing_text = $CONFIG['CurrencySymbol'] . format_as_currency ($addon_recurring) . ' ' . $CONFIG['Currency'];
if ($addon_setupfee != '0.00')
{
$pricing_text .= ' + ' . $CONFIG['CurrencySymbol'] . format_as_currency ($addon_setupfee) . ' ' . $CONFIG['Currency'] . ' ' . $_LANG['ordersetupfee'];
}
}
$query = '' . 'SELECT domain,name FROM tblhosting INNER JOIN tblproducts ON tblproducts.id=tblhosting.packageid WHERE tblhosting.id=\'' . $productid . '\'';
$result = mysql_query ($query);
$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 'includes/additionaldomainfields.php';
if ($_SESSION['cart']['domains'])
{
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];
if (in_array ($domainname, $freedomains))
{
$temppricelist = gettldpricelist ('.' . $tld);
$regperiod = $temppricelist[0]['period'];
$domainprice = '0.00';
$renewprice = '0.00';
}
else
{
$domainprice = getregprice ('.' . $tld, $regperiod, $domaintype);
$renewprice = getregprice ('.' . $tld, $regperiod, 'renew');
}
if ($domain['dnsmanagement'])
{
$dnsmanagement = true;
$domainprice += $CONFIG['DomainDNSManagement'] * $regperiod;
$renewprice += $CONFIG['DomainDNSManagement'] * $regperiod;
}
else
{
$dnsmanagement = false;
}
if ($domain['emailforwarding'])
{
$emailforwarding = true;
$domainprice += $CONFIG['DomainEmailForwarding'] * $regperiod;
$renewprice += $CONFIG['DomainEmailForwarding'] * $regperiod;
}
else
{
$emailforwarding = false;
}
if ($domain['idprotection'])
{
$idprotection = true;
$domainprice += $CONFIG['DomainIDProtection'] * $regperiod;
$renewprice += $CONFIG['DomainIDProtection'] * $regperiod;
}
else
{
$idprotection = false;
}
$rawdomainprice = $domainprice;
$rawrenewprice = $renewprice;
if (((($promo_item == 'Domain' AND !$promo_used) AND $domainprice != '0') AND $renewprice != '0'))
{
if ($promo_discount == 'Money Value')
{
if ($rawdomainprice < $promo_value)
{
$discount = $rawdomainprice;
}
else
{
$discount = $promo_value;
}
}
else
{
$percent = $promo_value / 100;
$discount = $rawdomainprice * $percent;
}
$rawdomainprice -= $discount;
$totaldomainprice -= $discount;
if ($promo_type == 'Recurring')
{
if ($promo_discount == 'Money Value')
{
if ($rawrenewprice < $promo_value)
{
$recdiscount = $rawrenewprice;
}
else
{
$recdiscount = $promo_value;
}
}
else
{
$percent = $promo_value / 100;
$recdiscount = $rawrenewprice * $percent;
}
$rawrenewprice -= $recdiscount;
}
$promo_used = true;
}
if ($checkout)
{
$query = '' . 'INSERT INTO tbldomains (userid,orderid,type,registrationdate,domain,firstpaymentamount,recurringamount,registrationperiod,status,paymentmethod,expirydate,nextduedate,nextinvoicedate,dnsmanagement,emailforwarding,idprotection) VALUES (\'' . $userid . '\',\'' . $orderid . '\',\'' . $domaintype . '\',now(),\'' . $domainname . '\',\'' . $rawdomainprice . '\',\'' . $rawrenewprice . '\',\'' . $regperiod . '\',\'Pending\',\'' . $paymentmethod . '\',\'00000000\',now(),now(),\'' . $dnsmanagement . '\',\'' . $emailforwarding . '\',\'' . $idprotection . '\')';
$result = mysql_query ($query);
$domainid = mysql_insert_id ();
$orderdomainids[] = $domainid;
$adminemailitems .= $_LANG['orderdomainregistration'] . ': ' . ucfirst ($domaintype) . '
' . $_LANG['orderdomain'] . ('' . ': ' . $domainname . '
') . $_LANG['firstpaymentamount'] . ': ' . $CONFIG['CurrencySymbol'] . ('' . $rawdomainprice . '
') . $_LANG['recurringamount'] . ': ' . $CONFIG['CurrencySymbol'] . ('' . $rawrenewprice . '
') . $_LANG['orderregperiod'] . ('' . ': ' . $regperiod . ' ') . $_LANG['orderyears'] . '
';
if ($dnsmanagement)
{
$adminemailitems .= ' + DNS Management
';
}
if ($emailforwarding)
{
$adminemailitems .= ' + Email Forwarding
';
}
if ($idprotection)
{
$adminemailitems .= ' + ID Protection
';
}
$adminemailitems .= '
';
if ($domaintype == 'register')
{
unset ($tempdomainfields);
$tempdomainfields = $additionaldomainfields['.' . $tld];
if ($tempdomainfields)
{
foreach ($tempdomainfields as $fieldkey => $value)
{
$storedvalue = $domain['fields'][$fieldkey];
$query = '' . 'INSERT INTO tbldomainsadditionalfields (domainid,name,value) VALUES (\'' . $domainid . '\',\'' . $value['Name'] . ('' . '\',\'' . $storedvalue . '\')');
$result = mysql_query ($query);
}
}
}
if ($domaintype == 'transfer')
{
$ordertransfersecrets .= $domainname . '=' . $domain['eppcode'] . ',';
}
}
$tempdomains[$key] = array ('type' => $domaintype, 'domain' => $domainname, 'regperiod' => $regperiod, 'price' => $CONFIG['CurrencySymbol'] . format_as_currency ($domainprice) . ' ' . $CONFIG['Currency'], 'renewprice' => $CONFIG['CurrencySymbol'] . format_as_currency ($renewprice) . ' ' . $CONFIG['Currency'], 'dnsmanagement' => $dnsmanagement, 'emailforwarding' => $emailforwarding, 'idprotection' => $idprotection, 'eppvalue' => $domain['eppcode']);
$totaldomainprice += $domainprice;
}
}
$cartdata['domains'] = $tempdomains;
$total_onetime += $totaldomainprice;
if ($CONFIG['TaxDomains'])
{
$total_tax += $totaldomainprice;
}
if ($CONFIG['TaxEnabled'])
{
if ($CONFIG['TaxType'] == 'Inclusive')
{
$total_without_tax = $total_tax / $inctaxrate;
$total_tax -= $total_without_tax;
$total_onetime -= $total_tax;
}
else
{
$total_tax *= $taxrate;
}
}
else
{
$total_tax = 0;
}
$subtotal = $total_onetime + $discount;
$total_onetime += $total_tax;
$subtotal = format_as_currency ($subtotal);
$discount = format_as_currency ($discount);
$total_tax = format_as_currency ($total_tax);
$total_onetime = format_as_currency ($total_onetime);
$total_recurring = format_as_currency ($total_recurring);
$total_recurringmonthly = format_as_currency ($total_recurringmonthly);
$total_recurringquarterly = format_as_currency ($total_recurringquarterly);
$total_recurringsemiannually = format_as_currency ($total_recurringsemiannually);
$total_recurringannually = format_as_currency ($total_recurringannually);
$total_recurringbiennially = format_as_currency ($total_recurringbiennially);
if ($checkout)
{
$adminemailitems .= $_LANG['ordertotalduetoday'] . ': ' . $CONFIG['CurrencySymbol'] . ('' . $total_onetime . ' ') . $CONFIG['Currency'] . '';
include dirname (__FILE__) . '/includes/processinvoices.php';
$invoiceid = createinvoices ($userid);
if ($CONFIG['OrderDaysGrace'])
{
$new_time = mktime (0, 0, 0, date ('m'), date ('d') + $CONFIG['OrderDaysGrace'], date ('Y'));
$duedate = date ('Y-m-d', $new_time);
$query = '' . 'UPDATE tblinvoices SET duedate=\'' . $duedate . '\' WHERE id=\'' . $invoiceid . '\'';
$result = mysql_query ($query);
}
$ordernameservers = $_SESSION['cart']['ns1'] . ',' . $_SESSION['cart']['ns2'];
if ($_SESSION['cart']['ns3'])
{
$ordernameservers .= ',' . $_SESSION['cart']['ns3'];
}
if ($_SESSION['cart']['ns4'])
{
$ordernameservers .= ',' . $_SESSION['cart']['ns4'];
}
$query = '' . 'UPDATE tblorders SET amount=\'' . $total_onetime . '\',invoiceid=\'' . $invoiceid . '\',nameservers=\'' . $ordernameservers . '\',transfersecret=\'' . $ordertransfersecrets . '\' WHERE id=\'' . $orderid . '\'';
$result = mysql_query ($query);
if ($invoiceid)
{
$query = '' . 'SELECT status FROM tblinvoices WHERE id=\'' . $invoiceid . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$status = $data['status'];
if ($status == 'Paid')
{
$invoiceid = '';
}
}
$query = 'SELECT clientid FROM tblaffiliates WHERE id=\'' . $_COOKIE['WHMCSAffiliateID'] . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$clientid = $data['clientid'];
if (((isset ($_COOKIE['WHMCSAffiliateID']) AND !$_SESSION['adminloggedinstatus']) AND $_SESSION['uid'] != $clientid))
{
foreach ($orderproductids as $orderproductid)
{
$query = '' . 'SELECT name,domain,billingcycle,amount FROM tblhosting INNER JOIN tblproducts ON tblproducts.id=tblhosting.packageid WHERE id=\'' . $orderproductid . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$package = $data['name'];
$domain = $data['domain'];
$productbillingcycle = $data['billingcycle'];
$rawproductrecurring = $data['amount'];
$query = 'INSERT INTO tblaffiliatesaccounts (affiliateid,domain,package,billingcycle,regdate,amount,commission,relid) VALUES (\'' . $_COOKIE['WHMCSAffiliateID'] . '\',\'' . $domain . '\',\'' . $package . '\',\'' . $productbillingcycle . '\',now(),\'' . $rawproductrecurring . '\',\'' . calculateaffiliatecommission ($_COOKIE['WHMCSAffiliateID'], $orderproductid) . ('' . '\',\'' . $orderproductid . '\')');
$result = mysql_query ($query);
}
}
$query = '' . 'SELECT firstname, lastname, companyname, email, address1, address2, city, state, postcode, country, phonenumber, ip, host FROM tblclients WHERE id=\'' . $userid . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
list ($firstname, $lastname, $companyname, $email, $address1, $address2, $city, $state, $postcode, $country, $phonenumber, $ip, $host) = $data;
$query = '' . 'SELECT value FROM tblpaymentgateways WHERE gateway=\'' . $paymentmethod . '\' AND setting=\'Name\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$nicegatewayname = $data['value'];
$orderinfo = '' . 'Order Information
Order ID: ' . $orderid . '
Order Number: ' . $order_number . '
Date/Time: ' . date ('d/m/Y H:i:s') . ('' . '
Invoice Number: ' . $invoiceid . '
Payment Method: ' . $nicegatewayname . '
Customer Information
Customer ID: ' . $userid . '
Name: ' . $firstname . ' ' . $lastname . '
Email: ' . $email . '
Company: ' . $companyname . '
Address 1: ' . $address1 . '
Address 2: ' . $address2 . '
City: ' . $city . '
State: ' . $state . '
Postcode: ' . $postcode . '
Country: ' . $country . '
Phone Number: ' . $phonenumber . '
Order Items
' . $adminemailitems . '
ISP Information
IP: ' . $ip . '
Host: ' . $host);
sendmessage ('Order Confirmation', $userid, array ('OrderID' => $orderid, 'OrderNumber' => $order_number, 'OrderDetails' => $adminemailitems));
sendadminnotification ('sales', 'WHMCS New Order Notification', $orderinfo);
$_SESSION['orderdetails']['OrderID'] = $orderid;
$_SESSION['orderdetails']['OrderNumber'] = $order_number;
$_SESSION['orderdetails']['Products'] = $orderproductids;
$_SESSION['orderdetails']['Domains'] = $orderdomainids;
$_SESSION['orderdetails']['Addons'] = $orderaddonids;
$_SESSION['orderdetails']['PaymentMethod'] = $paymentmethod;
$_SESSION['orderdetails']['InvoiceID'] = $invoiceid;
unset ($_SESSION[cart]);
if (!defined ('ACTIONHOOKSINC'))
{
require dirname (__FILE__) . '/includes/actionhooks.php';
}
actionhook_shoppingcartcheckout (array ('OrderID' => $_SESSION['orderdetails']['OrderID'], 'OrderNumber' => $_SESSION['orderdetails']['OrderNumber'], 'InvoiceID' => $_SESSION['orderdetails']['InvoiceID'], 'Products' => $_SESSION['orderdetails']['Products'], 'Addons' => $_SESSION['orderdetails']['Addons'], 'Domains' => $_SESSION['orderdetails']['Domains']));
}
if ($total_recurringmonthly == '0.00')
{
$total_recurringmonthly = '';
}
else
{
$total_recurringmonthly = $CONFIG['CurrencySymbol'] . $total_recurringmonthly . ' ' . $CONFIG['Currency'];
}
if ($total_recurringquarterly == '0.00')
{
$total_recurringquarterly = '';
}
else
{
$total_recurringquarterly = $CONFIG['CurrencySymbol'] . $total_recurringquarterly . ' ' . $CONFIG['Currency'];
}
if ($total_recurringsemiannually == '0.00')
{
$total_recurringsemiannually = '';
}
else
{
$total_recurringsemiannually = $CONFIG['CurrencySymbol'] . $total_recurringsemiannually . ' ' . $CONFIG['Currency'];
}
if ($total_recurringannually == '0.00')
{
$total_recurringannually = '';
}
else
{
$total_recurringannually = $CONFIG['CurrencySymbol'] . $total_recurringannually . ' ' . $CONFIG['Currency'];
}
if ($total_recurringbiennially == '0.00')
{
$total_recurringbiennially = '';
}
else
{
$total_recurringbiennially = $CONFIG['CurrencySymbol'] . $total_recurringbiennially . ' ' . $CONFIG['Currency'];
}
$subtotal = $CONFIG['CurrencySymbol'] . $subtotal . ' ' . $CONFIG['Currency'];
$discount = '-' . $CONFIG['CurrencySymbol'] . $discount . ' ' . $CONFIG['Currency'];
$total_tax = $CONFIG['CurrencySymbol'] . $total_tax . ' ' . $CONFIG['Currency'];
$total_onetime = $CONFIG['CurrencySymbol'] . $total_onetime . ' ' . $CONFIG['Currency'];
$cartdata['subtotal'] = $subtotal;
$cartdata['discount'] = $discount;
$cartdata['promodiscount'] = $promo_discount;
$cartdata['promovalue'] = $promo_value;
$cartdata['promotype'] = $promo_type;
$cartdata['taxrate'] = $rawtaxrate;
$cartdata['taxname'] = $taxname;
$cartdata['totaltax'] = $total_tax;
$cartdata['totalonetime'] = $total_onetime;
$cartdata['totalrecurringmonthly'] = $total_recurringmonthly;
$cartdata['totalrecurringquarterly'] = $total_recurringquarterly;
$cartdata['totalrecurringsemiannually'] = $total_recurringsemiannually;
$cartdata['totalrecurringannually'] = $total_recurringannually;
$cartdata['totalrecurringbiennially'] = $total_recurringbiennially;
return $cartdata;
}
function setpromocode ($promotioncode)
{
global $_LANG;
$_SESSION['cart']['promo'] = '';
$query = '' . 'SELECT * FROM tblpromotions WHERE code=\'' . $promotioncode . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$id = $data['id'];
$maxuses = $data['maxuses'];
$uses = $data['uses'];
$expiredate = $data['expirationdate'];
if (!$id)
{
$promoerrormessage = $_LANG['ordercodenotfound'];
return $promoerrormessage;
}
if ($maxuses != '0')
{
if ($maxuses <= $uses)
{
$promoerrormessage = $_LANG['orderpromomaxusesreached'];
return $promoerrormessage;
}
}
if ($expiredate != '0000-00-00')
{
$year = substr ($expiredate, 0, 4);
$month = substr ($expiredate, 5, 2);
$day = substr ($expiredate, 8, 2);
$validuntil = $year . $month . $day;
$dayofmonth = date ('d');
$monthnum = date ('m');
$yearnum = date ('Y');
$todaysdate = $yearnum . $monthnum . $dayofmonth;
if ($validuntil < $todaysdate)
{
$promoerrormessage = $_LANG['orderpromoexpired'];
return $promoerrormessage;
}
}
$_SESSION['cart']['promo'] = $promotioncode;
}
define ('CLIENTAREA', true);
require 'dbconnect.php';
require 'includes/functions.php';
require 'includes/orderfunctions.php';
require 'includes/domainfunctions.php';
require 'includes/whoisfunctions.php';
require 'includes/configoptionsfunctions.php';
require 'includes/customfieldfunctions.php';
require 'includes/clientfunctions.php';
require 'includes/invoicefunctions.php';
require 'includes/gatewayfunctions.php';
require 'includes/fraudfunctions.php';
require 'includes/serverfunctions.php';
$frontendaccess = 'true';
$orderform = 'true';
$errormessage = '';
$CONFIG['OrderFormTemplate'] = 'cart';
$pagetitle = $_LANG['carttitle'];
$breadcrumbnav = '' . $_LANG['carttitle'] . '';
$pageicon = 'images/support/order.gif';
require 'init.php';
if ($step == 'fraudcheck')
{
$a = 'fraudcheck';
}
if ($a == 'empty')
{
unset ($_SESSION[cart]);
header ('Location: cart.php?a=view');
exit ();
}
if ($a == 'remove')
{
if ($r == 'p')
{
unset ($_SESSION['cart']['products'][$i]);
}
else
{
if ($r == 'a')
{
unset ($_SESSION['cart']['addons'][$i]);
}
else
{
if ($r == 'd')
{
unset ($_SESSION['cart']['domains'][$i]);
}
}
}
header ('Location: cart.php?a=view');
exit ();
}
if (!$a)
{
if ($gid == 'addons')
{
$templatefile = 'addons';
$productgroups = getproductgroups ();
$smarty->assign ('productgroups', $productgroups);
$productids = array ();
$query = 'SELECT tblhosting.id,domain,packageid,name FROM tblhosting INNER JOIN tblproducts ON tblproducts.id=tblhosting.packageid WHERE userid=\'' . $_SESSION['uid'] . '\'';
$result = mysql_query ($query);
while ($data = mysql_fetch_array ($result))
{
$productstoids[$data['packageid']][] = array ('id' => $data['id'], 'product' => $data['name'], 'domain' => $data['domain']);
if (!in_array ($data['packageid'], $productids))
{
$productids[] = $data['packageid'];
continue;
}
}
$addonids = array ();
$query = 'SELECT id,packages FROM tbladdons ORDER BY name ASC';
$result = mysql_query ($query);
while ($data = mysql_fetch_array ($result))
{
$id = $data['id'];
$packages = $data['packages'];
$packages = explode (',', $packages);
foreach ($productids as $productid)
{
if (in_array ($productid, $productids))
{
if (!in_array ($id, $addonids))
{
$addonids[] = $id;
continue;
}
continue;
}
}
}
$addons = array ();
foreach ($addonids as $addonid)
{
$query = '' . 'SELECT * FROM tbladdons WHERE id=\'' . $addonid . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$packages = $data['packages'];
$packages = explode (',', $packages);
$name = $data['name'];
$description = $data['description'];
$recurring = $data['recurring'];
$setupfee = $data['setupfee'];
if ($setupfee == '0.00')
{
$setupfee = '';
}
$billingcycle = $data['billingcycle'];
$newproductbillingcycle = strtolower ($billingcycle);
$newproductbillingcycle = str_replace ('-', '', $newproductbillingcycle);
$billingcycle = $_LANG['orderpaymentterm' . $newproductbillingcycle];
$free = $data['free'];
$packageids = array ();
foreach ($packages as $packageid)
{
$thisaddonspackages = '';
$thisaddonspackages = $productstoids[$packageid];
if ($thisaddonspackages)
{
$packageids = array_merge ($packageids, $thisaddonspackages);
continue;
}
}
if (count ($packageids))
{
$addons[] = array ('id' => $addonid, 'name' => $name, 'description' => $description, 'free' => $free, 'setupfee' => $setupfee, 'recurringamount' => $recurring, 'billingcycle' => $billingcycle, 'productids' => $packageids);
continue;
}
}
$smarty->assign ('addons', $addons);
if (!count ($addons))
{
$smarty->assign ('noaddons', true);
}
}
else
{
$templatefile = 'products';
$productgroups = getproductgroups ();
$products = getproducts ($gid);
if (!$gid)
{
$query = 'SELECT * FROM tblproductgroups WHERE hidden!=\'on\' ORDER BY `order` ASC';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$gid = $data['id'];
}
$smarty->assign ('gid', $gid);
$smarty->assign ('productgroups', $productgroups);
$smarty->assign ('products', $products);
}
}
if ($a == 'add')
{
if ($pid)
{
$templatefile = 'configureproductdomain';
$smartyvalues['pid'] = $pid;
$query = '' . 'SELECT * FROM tblproducts WHERE id=\'' . $pid . '\'';
$result = mysql_query ($query);
$data = mysql_fetch_array ($result);
$type = $data['type'];
$subdomain = $data['subdomain'];
$freedomain = $data['freedomain'];
$freedomaintlds = $data['freedomaintlds'];
$showdomainoptions = $data['showdomainoptions'];
$stockcontrol = $data['stockcontrol'];
$qty = $data['qty'];
if (!$billingcycle)
{
$paytype = $data['paytype'];
$monthly = $data['monthly'];
$quarterly = $data['quarterly'];
$semiannual = $data['semiannual'];
$annual = $data['annual'];
$biennial = $data['biennial'];
if ($paytype == 'free')
{
$billingcycle = 'free';
}
else
{
if ($paytype == 'onetime')
{
$billingcycle = 'onetime';
}
else
{
if ($paytype == 'recurring')
{
if ($monthly != '0.00')
{
$billingcycle = 'monthly';
}
else
{
if ($quarterly != '0.00')
{
$billingcycle = 'quarterly';
}
else
{
if ($semiannual != '0.00')
{
$billingcycle = 'semiannually';
}
else
{
if ($annual != '0.00')
{
$billingcycle = 'annually';
}
else
{
if ($biennial != '0.00')
{
$billingcycle = 'biennially';
}
}
}
}
}
}
}
}
}
if (($configure AND $previousbillingcycle == $billingcycle))
{
$errormessage = '';
if ($type == 'server')
{
if (!$hostname)
{
$errormessage .= '