| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
require '../include/ispcp-lib.php'; |
|---|
| 23 |
|
|---|
| 24 |
check_login(__FILE__); |
|---|
| 25 |
|
|---|
| 26 |
$tpl = new pTemplate(); |
|---|
| 27 |
$tpl->define_dynamic('page', Config::get('RESELLER_TEMPLATE_PATH') . '/orders.tpl'); |
|---|
| 28 |
$tpl->define_dynamic('logged_from', 'page'); |
|---|
| 29 |
$tpl->define_dynamic('page_message', 'page'); |
|---|
| 30 |
|
|---|
| 31 |
$tpl->define_dynamic('orders_table', 'page'); |
|---|
| 32 |
$tpl->define_dynamic('order', 'orders_table'); |
|---|
| 33 |
|
|---|
| 34 |
$tpl->define_dynamic('scroll_prev_gray', 'page'); |
|---|
| 35 |
$tpl->define_dynamic('scroll_prev', 'page'); |
|---|
| 36 |
$tpl->define_dynamic('scroll_next_gray', 'page'); |
|---|
| 37 |
$tpl->define_dynamic('scroll_next', 'page'); |
|---|
| 38 |
|
|---|
| 39 |
$theme_color = Config::get('USER_INITIAL_THEME'); |
|---|
| 40 |
|
|---|
| 41 |
$tpl->assign(array('TR_RESELLER_MAIN_INDEX_PAGE_TITLE' => tr('ispCP - Reseller/Order management'), |
|---|
| 42 |
'THEME_COLOR_PATH' => "../themes/$theme_color", |
|---|
| 43 |
'THEME_CHARSET' => tr('encoding'), |
|---|
| 44 |
'ISP_LOGO' => get_logo($_SESSION['user_id']))); |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
function gen_order_page (&$tpl, &$sql, $user_id) { |
|---|
| 49 |
$start_index = 0; |
|---|
| 50 |
$current_psi = 0; |
|---|
| 51 |
|
|---|
| 52 |
if (isset($_GET['psi']) && is_numeric($_GET['psi'])) { |
|---|
| 53 |
$start_index = $_GET['psi']; |
|---|
| 54 |
$current_psi = $_GET['psi']; |
|---|
| 55 |
} |
|---|
| 56 |
|
|---|
| 57 |
$rows_per_page = Config::get('DOMAIN_ROWS_PER_PAGE'); |
|---|
| 58 |
|
|---|
| 59 |
$count_query = <<<SQL_QUERY |
|---|
| 60 |
select |
|---|
| 61 |
count(id) as cnt |
|---|
| 62 |
from |
|---|
| 63 |
orders |
|---|
| 64 |
where |
|---|
| 65 |
user_id = ? |
|---|
| 66 |
and |
|---|
| 67 |
status != ? |
|---|
| 68 |
SQL_QUERY; |
|---|
| 69 |
|
|---|
| 70 |
$rs = exec_query($sql, $count_query, array($user_id, 'added')); |
|---|
| 71 |
$records_count = $rs->fields['cnt']; |
|---|
| 72 |
|
|---|
| 73 |
$query = <<<SQL_QUERY |
|---|
| 74 |
SELECT |
|---|
| 75 |
* |
|---|
| 76 |
FROM |
|---|
| 77 |
orders |
|---|
| 78 |
WHERE |
|---|
| 79 |
user_id = ? |
|---|
| 80 |
AND |
|---|
| 81 |
status != ? |
|---|
| 82 |
ORDER BY |
|---|
| 83 |
date DESC |
|---|
| 84 |
LIMIT |
|---|
| 85 |
$start_index, $rows_per_page |
|---|
| 86 |
SQL_QUERY; |
|---|
| 87 |
$rs = exec_query($sql, $query, array($user_id, 'added')); |
|---|
| 88 |
|
|---|
| 89 |
$prev_si = $start_index - $rows_per_page; |
|---|
| 90 |
|
|---|
| 91 |
if ($start_index == 0) { |
|---|
| 92 |
$tpl->assign('SCROLL_PREV', ''); |
|---|
| 93 |
} else { |
|---|
| 94 |
$tpl->assign( |
|---|
| 95 |
array('SCROLL_PREV_GRAY' => '', |
|---|
| 96 |
'PREV_PSI' => $prev_si |
|---|
| 97 |
) |
|---|
| 98 |
); |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
$next_si = $start_index + $rows_per_page; |
|---|
| 102 |
|
|---|
| 103 |
if ($next_si + 1 > $records_count) { |
|---|
| 104 |
$tpl->assign('SCROLL_NEXT', ''); |
|---|
| 105 |
} else { |
|---|
| 106 |
$tpl->assign( |
|---|
| 107 |
array('SCROLL_NEXT_GRAY' => '', |
|---|
| 108 |
'NEXT_PSI' => $next_si |
|---|
| 109 |
) |
|---|
| 110 |
); |
|---|
| 111 |
} |
|---|
| 112 |
|
|---|
| 113 |
if ($rs->RecordCount() == 0) { |
|---|
| 114 |
set_page_message(tr('You do not have new orders!')); |
|---|
| 115 |
$tpl->assign('ORDERS_TABLE', ''); |
|---|
| 116 |
$tpl->assign('SCROLL_NEXT_GRAY', ''); |
|---|
| 117 |
$tpl->assign('SCROLL_PREV_GRAY', ''); |
|---|
| 118 |
} else { |
|---|
| 119 |
$counter = 0; |
|---|
| 120 |
while (!$rs->EOF) { |
|---|
| 121 |
$plan_id = $rs->fields['plan_id']; |
|---|
| 122 |
$order_status = tr('New order'); |
|---|
| 123 |
|
|---|
| 124 |
$planname_query = <<<SQL_QUERY |
|---|
| 125 |
select |
|---|
| 126 |
name |
|---|
| 127 |
from |
|---|
| 128 |
hosting_plans |
|---|
| 129 |
where |
|---|
| 130 |
id = ? |
|---|
| 131 |
SQL_QUERY; |
|---|
| 132 |
$rs_planname = exec_query($sql, $planname_query, array($plan_id)); |
|---|
| 133 |
$plan_name = $rs_planname->fields['name']; |
|---|
| 134 |
|
|---|
| 135 |
if ($counter % 2 == 0) { |
|---|
| 136 |
$tpl->assign('ITEM_CLASS', 'content'); |
|---|
| 137 |
} else { |
|---|
| 138 |
$tpl->assign('ITEM_CLASS', 'content2'); |
|---|
| 139 |
} |
|---|
| 140 |
$status = $rs->fields['status']; |
|---|
| 141 |
if ($status === 'update') { |
|---|
| 142 |
$customer_id = $rs->fields['customer_id']; |
|---|
| 143 |
$cusrtomer_query = <<<SQL_QUERY |
|---|
| 144 |
select |
|---|
| 145 |
* |
|---|
| 146 |
from |
|---|
| 147 |
admin |
|---|
| 148 |
where |
|---|
| 149 |
admin_id = ? |
|---|
| 150 |
SQL_QUERY; |
|---|
| 151 |
$rs_customer = exec_query($sql, $cusrtomer_query, array($customer_id)); |
|---|
| 152 |
|
|---|
| 153 |
$user_details = $rs_customer->fields['fname'] . " " . $rs_customer->fields['lname'] . "<br><a href=\"mailto:" . $rs_customer->fields['email'] . "\" class=\"link\">" . $rs_customer->fields['email'] . "</a><br>" . $rs_customer->fields['zip'] . " " . $rs_customer->fields['city'] . " " . $rs_customer->fields['country']; |
|---|
| 154 |
$order_status = tr('Update order'); |
|---|
| 155 |
$tpl->assign('LINK', 'orders_update.php?order_id=' . $rs->fields['id']); |
|---|
| 156 |
} else { |
|---|
| 157 |
$user_details = $rs->fields['fname'] . " " . $rs->fields['lname'] . "<br><a href=\"mailto:" . $rs->fields['email'] . "\" class=\"link\">" . $rs->fields['email'] . "</a><br>" . $rs->fields['zip'] . " " . $rs->fields['city'] . " " . $rs->fields['country']; |
|---|
| 158 |
$tpl->assign('LINK', 'orders_detailst.php?order_id=' . $rs->fields['id']); |
|---|
| 159 |
} |
|---|
| 160 |
$tpl->assign( |
|---|
| 161 |
array('ID' => $rs->fields['id'], |
|---|
| 162 |
'HP' => $plan_name, |
|---|
| 163 |
'DOMAIN' => $rs->fields['domain_name'], |
|---|
| 164 |
'USER' => $user_details, |
|---|
| 165 |
'STATUS' => $order_status, |
|---|
| 166 |
) |
|---|
| 167 |
); |
|---|
| 168 |
|
|---|
| 169 |
$tpl->parse('ORDER', '.order'); |
|---|
| 170 |
|
|---|
| 171 |
$rs->MoveNext(); |
|---|
| 172 |
$counter ++; |
|---|
| 173 |
} |
|---|
| 174 |
} |
|---|
| 175 |
} |
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
gen_order_page($tpl, $sql, $_SESSION['user_id']); |
|---|
| 186 |
|
|---|
| 187 |
gen_reseller_mainmenu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/main_menu_orders.tpl'); |
|---|
| 188 |
gen_reseller_menu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/menu_orders.tpl'); |
|---|
| 189 |
|
|---|
| 190 |
gen_logged_from($tpl); |
|---|
| 191 |
|
|---|
| 192 |
$tpl->assign(array('TR_MANAGE_ORDERS' => tr('Manage Orders'), |
|---|
| 193 |
'TR_ID' => tr('ID'), |
|---|
| 194 |
'TR_DOMAIN' => tr('Domain'), |
|---|
| 195 |
'TR_USER' => tr('Customer data'), |
|---|
| 196 |
'TR_ACTION' => tr('Action'), |
|---|
| 197 |
'TR_STATUS' => tr('Order'), |
|---|
| 198 |
'TR_EDIT' => tr('Edit'), |
|---|
| 199 |
'TR_DELETE' => tr('Delete'), |
|---|
| 200 |
'TR_DETAILS' => tr('Details'), |
|---|
| 201 |
'TR_HP' => tr('Hosting plan'), |
|---|
| 202 |
'TR_MESSAGE_DELETE_ACCOUNT' => tr('Are you sure you want to delete this order?', true), |
|---|
| 203 |
'TR_ADD' => tr('Add/Details'))); |
|---|
| 204 |
|
|---|
| 205 |
gen_page_message($tpl); |
|---|
| 206 |
|
|---|
| 207 |
$tpl->parse('PAGE', 'page'); |
|---|
| 208 |
$tpl->prnt(); |
|---|
| 209 |
|
|---|
| 210 |
if (Config::get('DUMP_GUI_DEBUG')) |
|---|
| 211 |
dump_gui_debug(); |
|---|
| 212 |
|
|---|
| 213 |
unset_messages(); |
|---|
| 214 |
|
|---|
| 215 |
?> |
|---|
| 216 |
|
|---|