| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
require '../include/ispcp-lib.php'; |
|---|
| 22 |
|
|---|
| 23 |
$tpl = new pTemplate(); |
|---|
| 24 |
$tpl->define_dynamic('page', Config::get('PURCHASE_TEMPLATE_PATH') . '/chart.tpl'); |
|---|
| 25 |
$tpl->define_dynamic('page_message', 'page'); |
|---|
| 26 |
$tpl->define_dynamic('purchase_header', 'page'); |
|---|
| 27 |
$tpl->define_dynamic('purchase_footer', 'page'); |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
function gen_chart(&$tpl, &$sql, $user_id, $plan_id) { |
|---|
| 34 |
if (Config::exists('HOSTING_PLANS_LEVEL') && Config::get('HOSTING_PLANS_LEVEL') === 'admin') { |
|---|
| 35 |
$query = <<<SQL_QUERY |
|---|
| 36 |
select |
|---|
| 37 |
* |
|---|
| 38 |
from |
|---|
| 39 |
hosting_plans |
|---|
| 40 |
where |
|---|
| 41 |
id = ? |
|---|
| 42 |
SQL_QUERY; |
|---|
| 43 |
|
|---|
| 44 |
$rs = exec_query($sql, $query, array($plan_id)); |
|---|
| 45 |
} else { |
|---|
| 46 |
$query = <<<SQL_QUERY |
|---|
| 47 |
select |
|---|
| 48 |
* |
|---|
| 49 |
from |
|---|
| 50 |
hosting_plans |
|---|
| 51 |
where |
|---|
| 52 |
reseller_id = ? |
|---|
| 53 |
and |
|---|
| 54 |
id = ? |
|---|
| 55 |
SQL_QUERY; |
|---|
| 56 |
|
|---|
| 57 |
$rs = exec_query($sql, $query, array($user_id, $plan_id)); |
|---|
| 58 |
} |
|---|
| 59 |
if ($rs->RecordCount() == 0) { |
|---|
| 60 |
header("Location: index.php"); |
|---|
| 61 |
die(); |
|---|
| 62 |
} else { |
|---|
| 63 |
$price = $rs->fields['price']; |
|---|
| 64 |
$setup_fee = $rs->fields['setup_fee']; |
|---|
| 65 |
$total = $price + $setup_fee; |
|---|
| 66 |
|
|---|
| 67 |
if ($price == 0 || $price == '') { |
|---|
| 68 |
$price = tr('free of charge'); |
|---|
| 69 |
} else { |
|---|
| 70 |
$price = $price . " " . $rs->fields['value'] . " " . $rs->fields['payment']; |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
if ($setup_fee == 0 || $setup_fee == '') { |
|---|
| 74 |
$setup_fee = tr('free of charge'); |
|---|
| 75 |
} else { |
|---|
| 76 |
$setup_fee = $setup_fee . " " . $rs->fields['value']; |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
if ($total == 0) { |
|---|
| 80 |
$total = tr('free of charge'); |
|---|
| 81 |
} else { |
|---|
| 82 |
$total = $total . " " . $rs->fields['value']; |
|---|
| 83 |
} |
|---|
| 84 |
|
|---|
| 85 |
$tpl->assign( |
|---|
| 86 |
array('PRICE' => $price, |
|---|
| 87 |
'SETUP' => $setup_fee, |
|---|
| 88 |
'TOTAL' => $total, |
|---|
| 89 |
'TR_PACKAGE_NAME' => $rs->fields['name'], |
|---|
| 90 |
|
|---|
| 91 |
) |
|---|
| 92 |
); |
|---|
| 93 |
} |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
function gen_personal_data(&$tpl) { |
|---|
| 97 |
if (isset($_SESSION['fname'])) { |
|---|
| 98 |
$first_name = $_SESSION['fname']; |
|---|
| 99 |
} else { |
|---|
| 100 |
$first_name = ''; |
|---|
| 101 |
} |
|---|
| 102 |
|
|---|
| 103 |
if (isset($_SESSION['lname'])) { |
|---|
| 104 |
$last_name = $_SESSION['lname']; |
|---|
| 105 |
} else { |
|---|
| 106 |
$last_name = ''; |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
if (isset($_SESSION['firm'])) { |
|---|
| 110 |
$company = $_SESSION['firm']; |
|---|
| 111 |
} else { |
|---|
| 112 |
$company = ''; |
|---|
| 113 |
} |
|---|
| 114 |
|
|---|
| 115 |
if (isset($_SESSION['zip'])) { |
|---|
| 116 |
$postal_code = $_SESSION['zip']; |
|---|
| 117 |
} else { |
|---|
| 118 |
$postal_code = ''; |
|---|
| 119 |
} |
|---|
| 120 |
|
|---|
| 121 |
if (isset($_SESSION['city'])) { |
|---|
| 122 |
$city = $_SESSION['city']; |
|---|
| 123 |
} else { |
|---|
| 124 |
$city = ''; |
|---|
| 125 |
} |
|---|
| 126 |
|
|---|
| 127 |
if (isset($_SESSION['country'])) { |
|---|
| 128 |
$country = $_SESSION['country']; |
|---|
| 129 |
} else { |
|---|
| 130 |
$country = ''; |
|---|
| 131 |
} |
|---|
| 132 |
|
|---|
| 133 |
if (isset($_SESSION['street1'])) { |
|---|
| 134 |
$street1 = $_SESSION['street1']; |
|---|
| 135 |
} else { |
|---|
| 136 |
$street1 = ''; |
|---|
| 137 |
} |
|---|
| 138 |
|
|---|
| 139 |
if (isset($_SESSION['street2'])) { |
|---|
| 140 |
$street2 = $_SESSION['street2']; |
|---|
| 141 |
} else { |
|---|
| 142 |
$street2 = ''; |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
if (isset($_SESSION['phone'])) { |
|---|
| 146 |
$phone = $_SESSION['phone']; |
|---|
| 147 |
} else { |
|---|
| 148 |
$phone = ''; |
|---|
| 149 |
} |
|---|
| 150 |
|
|---|
| 151 |
if (isset($_SESSION['fax'])) { |
|---|
| 152 |
$fax = $_SESSION['fax']; |
|---|
| 153 |
} else { |
|---|
| 154 |
$fax = ''; |
|---|
| 155 |
} |
|---|
| 156 |
if (isset($_SESSION['email'])) { |
|---|
| 157 |
$email = $_SESSION['email']; |
|---|
| 158 |
} else { |
|---|
| 159 |
$email = ''; |
|---|
| 160 |
} |
|---|
| 161 |
if (isset($_SESSION['gender'])) { |
|---|
| 162 |
$gender = get_gender_by_code($_SESSION['gender']); |
|---|
| 163 |
} else { |
|---|
| 164 |
$gender = get_gender_by_code(''); |
|---|
| 165 |
} |
|---|
| 166 |
|
|---|
| 167 |
$tpl->assign( |
|---|
| 168 |
array('VL_USR_NAME' => $first_name, |
|---|
| 169 |
'VL_LAST_USRNAME' => $last_name, |
|---|
| 170 |
'VL_USR_FIRM' => $company, |
|---|
| 171 |
'VL_USR_POSTCODE' => $postal_code, |
|---|
| 172 |
'VL_USR_GENDER' => $gender, |
|---|
| 173 |
'VL_USRCITY' => $city, |
|---|
| 174 |
'VL_COUNTRY' => $country, |
|---|
| 175 |
'VL_STREET1' => $street1, |
|---|
| 176 |
'VL_STREET2' => $street2, |
|---|
| 177 |
'VL_PHONE' => $phone, |
|---|
| 178 |
'VL_FAX' => $fax, |
|---|
| 179 |
'VL_EMAIL' => $email, |
|---|
| 180 |
|
|---|
| 181 |
) |
|---|
| 182 |
); |
|---|
| 183 |
} |
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
if (isset($_SESSION['user_id']) && $_SESSION['plan_id']) { |
|---|
| 196 |
$user_id = $_SESSION['user_id']; |
|---|
| 197 |
$plan_id = $_SESSION['plan_id']; |
|---|
| 198 |
} else { |
|---|
| 199 |
system_message(tr('You do not have permission to access this interface!')); |
|---|
| 200 |
} |
|---|
| 201 |
|
|---|
| 202 |
gen_purchase_haf($tpl, $sql, $user_id); |
|---|
| 203 |
gen_chart($tpl, $sql, $user_id, $plan_id); |
|---|
| 204 |
gen_personal_data($tpl); |
|---|
| 205 |
|
|---|
| 206 |
gen_page_message($tpl); |
|---|
| 207 |
|
|---|
| 208 |
$tpl->assign( |
|---|
| 209 |
array('YOUR_CHART' => tr('Your Chart'), |
|---|
| 210 |
'TR_COSTS' => tr('Costs'), |
|---|
| 211 |
'TR_PACKAGE_PRICE' => tr('Price'), |
|---|
| 212 |
'TR_PACKAGE_SETUPFEE' => tr('Setup fee'), |
|---|
| 213 |
'TR_TOTAL' => tr('Total'), |
|---|
| 214 |
'TR_CONTINUE' => tr('Purchase'), |
|---|
| 215 |
'TR_CHANGE' => tr('Change'), |
|---|
| 216 |
'TR_FIRSTNAME' => tr('First name'), |
|---|
| 217 |
'TR_LASTNAME' => tr('Last name'), |
|---|
| 218 |
'TR_GENDER' => tr('Gender'), |
|---|
| 219 |
'TR_COMPANY' => tr('Company'), |
|---|
| 220 |
'TR_POST_CODE' => tr('Zip/Postal code'), |
|---|
| 221 |
'TR_CITY' => tr('City'), |
|---|
| 222 |
'TR_COUNTRY' => tr('Country'), |
|---|
| 223 |
'TR_STREET1' => tr('Street 1'), |
|---|
| 224 |
'TR_STREET2' => tr('Street 2'), |
|---|
| 225 |
'TR_EMAIL' => tr('Email'), |
|---|
| 226 |
'TR_PHONE' => tr('Phone'), |
|---|
| 227 |
'TR_FAX' => tr('Fax'), |
|---|
| 228 |
'TR_EMAIL' => tr('Email'), |
|---|
| 229 |
'TR_PERSONAL_DATA' => tr('Personal Data'), |
|---|
| 230 |
'THEME_CHARSET' => tr('encoding') |
|---|
| 231 |
) |
|---|
| 232 |
); |
|---|
| 233 |
|
|---|
| 234 |
$tpl->parse('PAGE', 'page'); |
|---|
| 235 |
$tpl->prnt(); |
|---|
| 236 |
|
|---|
| 237 |
if (Config::get('DUMP_GUI_DEBUG')) |
|---|
| 238 |
dump_gui_debug(); |
|---|
| 239 |
|
|---|
| 240 |
unset_messages(); |
|---|
| 241 |
|
|---|
| 242 |
?> |
|---|