| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* This file contains the callbacks for the default order panes supplied with
|
| 7 |
* Ubercart and their corresponding helper functions.
|
| 8 |
*
|
| 9 |
* Order panes are defined using hook_order_pane() and use a callback to handle
|
| 10 |
* the different processes involved in order viewing/editing. The default order
|
| 11 |
* panes are defined in uc_order_order_pane() in uc_order.module.
|
| 12 |
*/
|
| 13 |
|
| 14 |
/**
|
| 15 |
* Handle the "Ship to" order pane.
|
| 16 |
*/
|
| 17 |
function uc_order_pane_ship_to($op, $arg1) {
|
| 18 |
switch ($op) {
|
| 19 |
case 'customer':
|
| 20 |
if (!uc_order_is_shippable($arg1)) {
|
| 21 |
return;
|
| 22 |
}
|
| 23 |
case 'view':
|
| 24 |
$output = uc_order_address($arg1, 'delivery') .'<br />'. check_plain($arg1->delivery_phone);
|
| 25 |
return $output;
|
| 26 |
|
| 27 |
case 'edit-form':
|
| 28 |
$form['ship_to'] = array(
|
| 29 |
'#type' => 'fieldset',
|
| 30 |
'#title' => t("Modify 'Ship to' information"),
|
| 31 |
'#collapsible' => TRUE,
|
| 32 |
'#collapsed' => FALSE,
|
| 33 |
);
|
| 34 |
if (uc_address_field_enabled('first_name')) {
|
| 35 |
$form['ship_to']['delivery_first_name'] = uc_textfield(uc_get_field_name('first_name'), $arg1->delivery_first_name, FALSE);
|
| 36 |
}
|
| 37 |
if (uc_address_field_enabled('last_name')) {
|
| 38 |
$form['ship_to']['delivery_last_name'] = uc_textfield(uc_get_field_name('last_name'), $arg1->delivery_last_name, FALSE);
|
| 39 |
}
|
| 40 |
if (uc_address_field_enabled('phone')) {
|
| 41 |
$form['ship_to']['delivery_phone'] = uc_textfield(uc_get_field_name('phone'), $arg1->delivery_phone, FALSE, NULL, 32, 16);
|
| 42 |
}
|
| 43 |
if (uc_address_field_enabled('company')) {
|
| 44 |
$form['ship_to']['delivery_company'] = uc_textfield(uc_get_field_name('company'), $arg1->delivery_company, FALSE, NULL, 64);
|
| 45 |
}
|
| 46 |
if (uc_address_field_enabled('street1')) {
|
| 47 |
$form['ship_to']['delivery_street1'] = uc_textfield(uc_get_field_name('street1'), $arg1->delivery_street1, FALSE, NULL, 64);
|
| 48 |
}
|
| 49 |
if (uc_address_field_enabled('street2')) {
|
| 50 |
$form['ship_to']['delivery_street2'] = uc_textfield(uc_get_field_name('street2'), $arg1->delivery_street2, FALSE, NULL, 64);
|
| 51 |
}
|
| 52 |
if (uc_address_field_enabled('city')) {
|
| 53 |
$form['ship_to']['delivery_city'] = uc_textfield(uc_get_field_name('city'), $arg1->delivery_city, FALSE);
|
| 54 |
}
|
| 55 |
if (uc_address_field_enabled('country')) {
|
| 56 |
$form['ship_to']['delivery_country'] = uc_country_select(uc_get_field_name('country'), $arg1->delivery_country);
|
| 57 |
}
|
| 58 |
if (uc_address_field_enabled('zone')) {
|
| 59 |
if (isset($_POST['delivery_country'])) {
|
| 60 |
$country_id = intval($_POST['delivery_country']);
|
| 61 |
}
|
| 62 |
else {
|
| 63 |
$country_id = $arg1->delivery_country;
|
| 64 |
}
|
| 65 |
$form['ship_to']['delivery_zone'] = uc_zone_select(uc_get_field_name('zone'), $arg1->delivery_zone, NULL, $country_id);
|
| 66 |
}
|
| 67 |
if (uc_address_field_enabled('postal_code')) {
|
| 68 |
$form['ship_to']['delivery_postal_code'] = uc_textfield(uc_get_field_name('postal_code'), $arg1->delivery_postal_code, FALSE, NULL, 10, 10);
|
| 69 |
}
|
| 70 |
return $form;
|
| 71 |
|
| 72 |
case 'edit-title':
|
| 73 |
$output .= ' <img src="'. base_path() . drupal_get_path('module', 'uc_store')
|
| 74 |
.'/images/address_book.gif" alt="Select from address book." '
|
| 75 |
.'title="Select from address book." onclick="load_address_select('. $arg1['order_uid']['#value'] .', \'#delivery_address_select\', \'delivery\');" '
|
| 76 |
.'style="position: relative; top: 2px; cursor: pointer;" />';
|
| 77 |
return $output;
|
| 78 |
|
| 79 |
case 'edit-theme':
|
| 80 |
$output = '<div id="delivery_address_select"></div><table class="order-edit-table">';
|
| 81 |
foreach (element_children($arg1['ship_to']) as $field) {
|
| 82 |
$title = $arg1['ship_to'][$field]['#title'];
|
| 83 |
$arg1['ship_to'][$field]['#title'] = NULL;
|
| 84 |
$output .= '<tr><td class="oet-label">'. $title .':</td><td>'
|
| 85 |
. drupal_render($arg1['ship_to'][$field]) .'</td></tr>';
|
| 86 |
}
|
| 87 |
$output .= '</table>';
|
| 88 |
return $output;
|
| 89 |
|
| 90 |
case 'edit-process':
|
| 91 |
foreach ($arg1 as $key => $value) {
|
| 92 |
if (substr($key, 0, 9) == 'delivery_') {
|
| 93 |
if (uc_address_field_enabled(substr($key, 9))) {
|
| 94 |
$changes[$key] = $value;
|
| 95 |
}
|
| 96 |
}
|
| 97 |
}
|
| 98 |
return $changes;
|
| 99 |
}
|
| 100 |
}
|
| 101 |
|
| 102 |
/**
|
| 103 |
* Handle the "Bill to" order pane.
|
| 104 |
*/
|
| 105 |
function uc_order_pane_bill_to($op, $arg1) {
|
| 106 |
switch ($op) {
|
| 107 |
case 'view':
|
| 108 |
case 'customer':
|
| 109 |
$output = uc_order_address($arg1, 'billing') .'<br />'. check_plain($arg1->billing_phone);
|
| 110 |
return $output;
|
| 111 |
|
| 112 |
case 'edit-form':
|
| 113 |
$form['bill_to'] = array(
|
| 114 |
'#type' => 'fieldset',
|
| 115 |
'#title' => t("Modify 'Bill to' information"),
|
| 116 |
'#collapsible' => TRUE,
|
| 117 |
'#collapsed' => FALSE,
|
| 118 |
);
|
| 119 |
if (uc_address_field_enabled('first_name')) {
|
| 120 |
$form['bill_to']['billing_first_name'] = uc_textfield(uc_get_field_name('first_name'), $arg1->billing_first_name, FALSE);
|
| 121 |
}
|
| 122 |
if (uc_address_field_enabled('last_name')) {
|
| 123 |
$form['bill_to']['billing_last_name'] = uc_textfield(uc_get_field_name('last_name'), $arg1->billing_last_name, FALSE);
|
| 124 |
}
|
| 125 |
if (uc_address_field_enabled('phone')) {
|
| 126 |
$form['bill_to']['billing_phone'] = uc_textfield(uc_get_field_name('phone'), $arg1->billing_phone, FALSE, NULL, 32, 16);
|
| 127 |
}
|
| 128 |
if (uc_address_field_enabled('company')) {
|
| 129 |
$form['bill_to']['billing_company'] = uc_textfield(uc_get_field_name('company'), $arg1->billing_company, FALSE, NULL, 64);
|
| 130 |
}
|
| 131 |
if (uc_address_field_enabled('street1')) {
|
| 132 |
$form['bill_to']['billing_street1'] = uc_textfield(uc_get_field_name('street1'), $arg1->billing_street1, FALSE, NULL, 64);
|
| 133 |
}
|
| 134 |
if (uc_address_field_enabled('street2')) {
|
| 135 |
$form['bill_to']['billing_street2'] = uc_textfield(uc_get_field_name('street2'), $arg1->billing_street2, FALSE, NULL, 64);
|
| 136 |
}
|
| 137 |
if (uc_address_field_enabled('city')) {
|
| 138 |
$form['bill_to']['billing_city'] = uc_textfield(uc_get_field_name('city'), $arg1->billing_city, FALSE);
|
| 139 |
}
|
| 140 |
if (uc_address_field_enabled('country')) {
|
| 141 |
$form['bill_to']['billing_country'] = uc_country_select(uc_get_field_name('country'), $arg1->billing_country);
|
| 142 |
}
|
| 143 |
if (uc_address_field_enabled('zone')) {
|
| 144 |
if (isset($_POST['billing_country'])) {
|
| 145 |
$country_id = intval($_POST['billing_country']);
|
| 146 |
}
|
| 147 |
else {
|
| 148 |
$country_id = $arg1->billing_country;
|
| 149 |
}
|
| 150 |
$form['bill_to']['billing_zone'] = uc_zone_select(uc_get_field_name('zone'), $arg1->billing_zone, NULL, $country_id);
|
| 151 |
}
|
| 152 |
if (uc_address_field_enabled('postal_code')) {
|
| 153 |
$form['bill_to']['billing_postal_code'] = uc_textfield(uc_get_field_name('postal_code'), $arg1->billing_postal_code, FALSE, NULL, 10, 10);
|
| 154 |
}
|
| 155 |
return $form;
|
| 156 |
|
| 157 |
case 'edit-title':
|
| 158 |
$output .= ' <img src="'. base_path() . drupal_get_path('module', 'uc_store')
|
| 159 |
.'/images/address_book.gif" alt="'. t('Select from address book.') .'" '
|
| 160 |
.'title="'. t('Select from address book.') .'" onclick="load_address_select('. $arg1['order_uid']['#value'] .', \'#billing_address_select\', \'billing\');" '
|
| 161 |
.'style="position: relative; top: 2px; cursor: pointer;" />';
|
| 162 |
$output .= ' <img src="'. base_path() . drupal_get_path('module', 'uc_store')
|
| 163 |
.'/images/copy.gif" alt="'. t('Copy shipping information.') .'" title="'
|
| 164 |
. t('Copy shipping information.') .'" onclick="uc_order_copy_shipping_to_billing();" '
|
| 165 |
.'style="position: relative; top: 2px; cursor: pointer;" />';
|
| 166 |
return $output;
|
| 167 |
|
| 168 |
case 'edit-theme':
|
| 169 |
$output = '<div id="billing_address_select"></div><table class="order-edit-table">';
|
| 170 |
foreach (element_children($arg1['bill_to']) as $field) {
|
| 171 |
$title = $arg1['bill_to'][$field]['#title'];
|
| 172 |
$arg1['bill_to'][$field]['#title'] = NULL;
|
| 173 |
$output .= '<tr><td class="oet-label">'. $title .':</td><td>'
|
| 174 |
. drupal_render($arg1['bill_to'][$field]) .'</td></tr>';
|
| 175 |
}
|
| 176 |
$output .= '</table>';
|
| 177 |
return $output;
|
| 178 |
|
| 179 |
case 'edit-process':
|
| 180 |
foreach ($arg1 as $key => $value) {
|
| 181 |
if (substr($key, 0, 8) == 'billing_') {
|
| 182 |
if (uc_address_field_enabled(substr($key, 8))) {
|
| 183 |
$changes[$key] = $value;
|
| 184 |
}
|
| 185 |
}
|
| 186 |
}
|
| 187 |
return $changes;
|
| 188 |
}
|
| 189 |
}
|
| 190 |
|
| 191 |
/**
|
| 192 |
* Handle the "Customer Info" order pane.
|
| 193 |
*/
|
| 194 |
function uc_order_pane_customer($op, $arg1) {
|
| 195 |
switch ($op) {
|
| 196 |
case 'view':
|
| 197 |
$output = t('Customer number: ') . l($arg1->uid, 'user/'. $arg1->uid)
|
| 198 |
.'<br />'. t('Primary e-mail:') .'<br />'
|
| 199 |
. check_plain($arg1->primary_email);
|
| 200 |
return $output;
|
| 201 |
|
| 202 |
case 'edit-form':
|
| 203 |
$form['customer'] = array(
|
| 204 |
'#type' => 'fieldset',
|
| 205 |
'#title' => t("Modify 'Customer info'"),
|
| 206 |
'#collapsible' => TRUE,
|
| 207 |
'#collapsed' => FALSE
|
| 208 |
);
|
| 209 |
$form['customer']['uid'] = array(
|
| 210 |
'#type' => 'hidden',
|
| 211 |
'#default_value' => $arg1->uid,
|
| 212 |
);
|
| 213 |
$form['customer']['text']['uid_text'] = array(
|
| 214 |
'#type' => 'textfield',
|
| 215 |
'#title' => t('Customer number'),
|
| 216 |
'#default_value' => $arg1->uid,
|
| 217 |
'#maxlength' => 10,
|
| 218 |
'#size' => 10,
|
| 219 |
'#disabled' => TRUE,
|
| 220 |
);
|
| 221 |
$form['customer']['primary_email'] = array(
|
| 222 |
'#type' => 'hidden',
|
| 223 |
'#default_value' => $arg1->primary_email,
|
| 224 |
);
|
| 225 |
$form['customer']['text']['primary_email_text'] = array(
|
| 226 |
'#type' => 'textfield',
|
| 227 |
'#title' => t('Primary e-mail'),
|
| 228 |
'#default_value' => $arg1->primary_email,
|
| 229 |
'#maxlength' => 64,
|
| 230 |
'#size' => 32,
|
| 231 |
'#disabled' => TRUE,
|
| 232 |
);
|
| 233 |
return $form;
|
| 234 |
|
| 235 |
case 'edit-title':
|
| 236 |
$output .= ' <img src="'. base_path() . drupal_get_path('module', 'uc_store')
|
| 237 |
.'/images/order_view.gif" alt="'. t('Search for an existing customer.') .'" '
|
| 238 |
.'title="'. t('Search for an existing customer.') .'" onclick="load_customer_search();" '
|
| 239 |
.'style="position: relative; top: 2px; cursor: pointer;" />';
|
| 240 |
$output .= ' <img src="'. base_path() . drupal_get_path('module', 'uc_store')
|
| 241 |
.'/images/menu_customers_small.gif" alt="'. t('Create a new customer.') .'" '
|
| 242 |
.'title="'. t('Create a new customer.') .'" onclick="load_new_customer_form();" '
|
| 243 |
.'style="position: relative; top: 2px; cursor: pointer;" />';
|
| 244 |
return $output;
|
| 245 |
|
| 246 |
case 'edit-theme':
|
| 247 |
$output = '<div id="customer-select"></div><table class="order-edit-table">';
|
| 248 |
foreach (element_children($arg1['customer']['text']) as $field) {
|
| 249 |
$title = $arg1['customer']['text'][$field]['#title'];
|
| 250 |
$arg1['customer']['text'][$field]['#title'] = NULL;
|
| 251 |
$output .= '<tr><td class="oet-label">'. $title .':</td><td>'
|
| 252 |
. drupal_render($arg1['customer']['text'][$field]) .'</td></tr>';
|
| 253 |
}
|
| 254 |
$output .= '</table>'. drupal_render($arg1['customer']['primary_email'])
|
| 255 |
. drupal_render($arg1['customer']['uid']);
|
| 256 |
return $output;
|
| 257 |
|
| 258 |
case 'edit-process':
|
| 259 |
$changes['uid'] = $arg1['uid'];
|
| 260 |
$changes['primary_email'] = $arg1['primary_email'];
|
| 261 |
return $changes;
|
| 262 |
}
|
| 263 |
}
|
| 264 |
|
| 265 |
/**
|
| 266 |
* Handle the "Products" order pane.
|
| 267 |
*/
|
| 268 |
function uc_order_pane_products($op, $arg1) {
|
| 269 |
switch ($op) {
|
| 270 |
case 'view':
|
| 271 |
return tapir_get_table('op_products_view_table', $arg1->products);
|
| 272 |
|
| 273 |
case 'customer':
|
| 274 |
return tapir_get_table('op_products_customer_table', $arg1->products);
|
| 275 |
|
| 276 |
case 'edit-theme':
|
| 277 |
uc_add_js('uc_order_load_product_edit_div('. $arg1['order_id']['#value'] .');', 'inline');
|
| 278 |
|
| 279 |
$output = '<div id="products-selector"></div>'
|
| 280 |
.'<div id="products-container">'. t('Loading product information... (<em>If nothing happens, make sure you have Javascript enabled.</em>)') .'</div>';
|
| 281 |
return $output;
|
| 282 |
|
| 283 |
case 'edit-title':
|
| 284 |
$settings = array(
|
| 285 |
'div' => '#products-selector',
|
| 286 |
'class' => 'product-select-box',
|
| 287 |
'vid' => variable_get('uc_catalog_vid', 0),
|
| 288 |
'filter' => implode(',', module_invoke_all('product_types')),
|
| 289 |
'search' => 'true',
|
| 290 |
'nids' => 'true',
|
| 291 |
'close' => 'true',
|
| 292 |
'nodesg' => 'product',
|
| 293 |
'nodepl' => 'products',
|
| 294 |
'select' => 'add_product_form();',
|
| 295 |
);
|
| 296 |
|
| 297 |
if (module_exists('ubrowser') && module_exists('uc_catalog') && variable_get('uc_ubrowser_product_select', TRUE)) {
|
| 298 |
$output = ubrowser_button(t('Add product'), $settings, NULL, 'add-product-button') .' ';
|
| 299 |
}
|
| 300 |
else {
|
| 301 |
$output = '<input type="button" value="'. t('Add product')
|
| 302 |
.'" onclick="load_product_select('. $arg1['order_id']['#value']
|
| 303 |
.', false);" id="add-product-button" />';
|
| 304 |
}
|
| 305 |
$output .= '<input type="button" value="'. t('Add blank line')
|
| 306 |
.'" onclick="add_blank_line_button('. $arg1['order_id']['#value']
|
| 307 |
.');" />';
|
| 308 |
$output .= ' <span id="product-div-throbber"></span>';
|
| 309 |
return $output;
|
| 310 |
}
|
| 311 |
}
|
| 312 |
|
| 313 |
/**
|
| 314 |
* Handle the "Line Items" order pane.
|
| 315 |
*/
|
| 316 |
function uc_order_pane_line_items($op, $arg1) {
|
| 317 |
switch ($op) {
|
| 318 |
case 'view':
|
| 319 |
case 'customer':
|
| 320 |
$line_items = $arg1->line_items;
|
| 321 |
$items = _line_item_list();
|
| 322 |
foreach ($items as $item) {
|
| 323 |
if (isset($item['display_only']) && $item['display_only'] == TRUE) {
|
| 324 |
$result = $item['callback']('display', $arg1);
|
| 325 |
if (is_array($result)) {
|
| 326 |
foreach ($result as $line) {
|
| 327 |
$line_items[] = array(
|
| 328 |
'title' => $line['title'],
|
| 329 |
'amount' => $line['amount'],
|
| 330 |
'weight' => $item['weight']
|
| 331 |
);
|
| 332 |
}
|
| 333 |
}
|
| 334 |
}
|
| 335 |
}
|
| 336 |
usort($line_items, 'uc_weight_sort');
|
| 337 |
|
| 338 |
$output = '<table class="line-item-table">';
|
| 339 |
foreach ($line_items as $item) {
|
| 340 |
$output .= '<tr><td class="li-title">'. check_plain($item['title']) .':</td>'
|
| 341 |
.'<td class="li-amount" nowrap="nowrap">'
|
| 342 |
. uc_currency_format($item['amount']) .'</td></tr>';
|
| 343 |
}
|
| 344 |
$output .= '</table>';
|
| 345 |
return $output;
|
| 346 |
|
| 347 |
case 'show-title':
|
| 348 |
return FALSE;
|
| 349 |
|
| 350 |
case 'edit-form':
|
| 351 |
$options = array();
|
| 352 |
$items = _line_item_list();
|
| 353 |
$line_items = $arg1->line_items;
|
| 354 |
foreach ($items as $item) {
|
| 355 |
if ($item['add_list'] === TRUE) {
|
| 356 |
$options[$item['id']] = check_plain($item['title']);
|
| 357 |
}
|
| 358 |
if (isset($item['display_only']) && $item['display_only'] == TRUE) {
|
| 359 |
$result = $item['callback']('display', $arg1);
|
| 360 |
if (is_array($result)) {
|
| 361 |
foreach ($result as $line) {
|
| 362 |
$line_items[] = array(
|
| 363 |
'line_item_id' => $line['id'],
|
| 364 |
'title' => $line['title'],
|
| 365 |
'amount' => $line['amount'],
|
| 366 |
'weight' => $item['weight'],
|
| 367 |
);
|
| 368 |
}
|
| 369 |
}
|
| 370 |
}
|
| 371 |
}
|
| 372 |
usort($line_items, 'uc_weight_sort');
|
| 373 |
|
| 374 |
$form['add_line_item'] = array(
|
| 375 |
'#type' => 'fieldset',
|
| 376 |
'#title' => t('Add line item'),
|
| 377 |
'#collapsible' => TRUE,
|
| 378 |
'#collapsed' => FALSE,
|
| 379 |
);
|
| 380 |
$form['add_line_item']['li_type_select'] = array(
|
| 381 |
'#type' => 'select',
|
| 382 |
'#title' => t('Select a type'),
|
| 383 |
'#options' => $options,
|
| 384 |
);
|
| 385 |
$form['add_line_item']['submit'] = array(
|
| 386 |
'#type' => 'submit',
|
| 387 |
'#value' => t('Add line'),
|
| 388 |
'#attributes' => array('class' => 'save-button'),
|
| 389 |
'#disabled' => TRUE,
|
| 390 |
);
|
| 391 |
$form['li_delete_id'] = array(
|
| 392 |
'#type' => 'hidden',
|
| 393 |
);
|
| 394 |
$form['line_items'] = array(
|
| 395 |
'#type' => 'fieldset',
|
| 396 |
'#title' => t("Modify 'line items'"),
|
| 397 |
'#collapsible' => TRUE,
|
| 398 |
'#collapsed' => FALSE,
|
| 399 |
'#tree' => TRUE,
|
| 400 |
);
|
| 401 |
foreach ($line_items as $item) {
|
| 402 |
$form['line_items'][$item['line_item_id']]['li_id'] = array(
|
| 403 |
'#type' => 'hidden',
|
| 404 |
'#value' => $item['line_item_id'],
|
| 405 |
);
|
| 406 |
if (_line_item_data($item['type'], 'stored') == TRUE) {
|
| 407 |
$form['line_items'][$item['line_item_id']]['title'] = array(
|
| 408 |
'#type' => 'textfield',
|
| 409 |
'#title' => t('Title'),
|
| 410 |
'#default_value' => $item['title'],
|
| 411 |
'#size' => 40,
|
| 412 |
'#maxlength' => 128,
|
| 413 |
'#prefix' => '<img id="li-'. $item['line_item_id'] .'" src="'
|
| 414 |
. base_path() . drupal_get_path('module', 'uc_store')
|
| 415 |
.'/images/error.gif" alt="'. t('Remove line item.')
|
| 416 |
.'" title="'. t('Remove line item.') .'" style="'
|
| 417 |
.'cursor: pointer; position: relative; top: 3px;" '
|
| 418 |
.'onclick="confirm_line_item_delete(\''
|
| 419 |
. addslashes(t('Remove this line item?')) .'\', this.id);" />',
|
| 420 |
);
|
| 421 |
$form['line_items'][$item['line_item_id']]['amount'] = array(
|
| 422 |
'#type' => 'textfield',
|
| 423 |
'#title' => t('Amount'),
|
| 424 |
'#default_value' => $item['amount'],
|
| 425 |
'#size' => 6,
|
| 426 |
'#maxlength' => 13,
|
| 427 |
'#field_prefix' => variable_get('uc_sign_after_amount', FALSE) ? '' : variable_get('uc_currency_sign', '$'),
|
| 428 |
'#field_suffix' => variable_get('uc_sign_after_amount', FALSE) ? variable_get('uc_currency_sign', '$') : '',
|
| 429 |
);
|
| 430 |
}
|
| 431 |
else {
|
| 432 |
$form['line_items'][$item['line_item_id']]['title'] = array(
|
| 433 |
'#value' => check_plain($item['title']),
|
| 434 |
);
|
| 435 |
$form['line_items'][$item['line_item_id']]['amount'] = array(
|
| 436 |
'#value' => uc_currency_format($item['amount']),
|
| 437 |
);
|
| 438 |
}
|
| 439 |
}
|
| 440 |
return $form;
|
| 441 |
|
| 442 |
case 'edit-theme':
|
| 443 |
$arg1['add_line_item']['li_type_select']['#title'] = '';
|
| 444 |
$output = '<table class="full-width"><tr><td>';
|
| 445 |
$output .= '<table><tr><td colspan="2"><b>'. t('Add a line item')
|
| 446 |
.': </b></td></tr><tr><td>'. drupal_render($arg1['add_line_item']['li_type_select'])
|
| 447 |
.' </td><td>'. drupal_render($arg1['add_line_item']['submit'])
|
| 448 |
.'</td></tr></table>';
|
| 449 |
$output .= '</td><td>'. drupal_render($arg1['li_delete_id'])
|
| 450 |
.'<table class="line-item-table">';
|
| 451 |
foreach (element_children($arg1['line_items']) as $field) {
|
| 452 |
$arg1['line_items'][$field]['title']['#title'] = '';
|
| 453 |
$arg1['line_items'][$field]['amount']['#title'] = '';
|
| 454 |
$output .= '<tr><td class="li-title">'
|
| 455 |
. drupal_render($arg1['line_items'][$field]['li_id'])
|
| 456 |
. drupal_render($arg1['line_items'][$field]['title'])
|
| 457 |
.':</td><td class="li-amount" nowrap>'
|
| 458 |
. drupal_render($arg1['line_items'][$field]['amount'])
|
| 459 |
.'</td></tr>';
|
| 460 |
}
|
| 461 |
$output .= '</table></td></tr></table>';
|
| 462 |
return $output;
|
| 463 |
|
| 464 |
case 'edit-process':
|
| 465 |
if (is_array($arg1['line_items'])) {
|
| 466 |
foreach ($arg1['line_items'] as $line) {
|
| 467 |
if (is_numeric($line['li_id']) && intval($line['li_id']) > 0) {
|
| 468 |
uc_order_update_line_item($line['li_id'], $line['title'], $line['amount']);
|
| 469 |
}
|
| 470 |
}
|
| 471 |
}
|
| 472 |
if (intval($arg1['li_delete_id']) > 0) {
|
| 473 |
uc_order_delete_line_item($arg1['li_delete_id']);
|
| 474 |
drupal_set_message(t('Line item removed.'));
|
| 475 |
}
|
| 476 |
return;
|
| 477 |
|
| 478 |
case 'edit-ops':
|
| 479 |
return array(t('Add line'));
|
| 480 |
|
| 481 |
case t('Add line'):
|
| 482 |
drupal_goto('admin/store/orders/'. $arg1['order_id']
|
| 483 |
.'/add_line_item/'. $arg1['li_type_select']);
|
| 484 |
}
|
| 485 |
}
|
| 486 |
|
| 487 |
/**
|
| 488 |
* Handle the "Order Comments" order pane.
|
| 489 |
*/
|
| 490 |
function uc_order_pane_order_comments($op, $arg1) {
|
| 491 |
switch ($op) {
|
| 492 |
case 'view':
|
| 493 |
$comments = uc_order_comments_load($arg1->order_id);
|
| 494 |
return tapir_get_table('op_order_comments_view_table', $comments);
|
| 495 |
|
| 496 |
case 'customer':
|
| 497 |
$comments = uc_order_comments_load($arg1->order_id);
|
| 498 |
$header = array(t('Date'), t('Status'), array('data' => t('Message'), 'width' => '100%'));
|
| 499 |
$rows[] = array(
|
| 500 |
format_date($arg1->created, 'custom', variable_get('uc_date_format_default', 'm/d/Y')),
|
| 501 |
array('data' => '-', 'align' => 'center'),
|
| 502 |
t('Order created.')
|
| 503 |
);
|
| 504 |
if (count($comments) > 0) {
|
| 505 |
foreach ($comments as $comment) {
|
| 506 |
$rows[] = array(
|
| 507 |
'data' => array(
|
| 508 |
array('data' => format_date($comment->created, 'custom', variable_get('uc_date_format_default', 'm/d/Y')), 'align' => 'center'),
|
| 509 |
array('data' => $comment->title, 'align' => 'center', 'nowrap' => 'nowrap'),
|
| 510 |
check_plain($comment->message),
|
| 511 |
),
|
| 512 |
'valign' => 'top'
|
| 513 |
);
|
| 514 |
}
|
| 515 |
}
|
| 516 |
$output = theme('table', $header, $rows);
|
| 517 |
|
| 518 |
return $output;
|
| 519 |
}
|
| 520 |
}
|
| 521 |
|
| 522 |
/**
|
| 523 |
* Handle the "Admin Comments" order pane.
|
| 524 |
*/
|
| 525 |
function uc_order_pane_admin_comments($op, $arg1) {
|
| 526 |
switch ($op) {
|
| 527 |
case 'view':
|
| 528 |
$comments = uc_order_comments_load($arg1->order_id, TRUE);
|
| 529 |
return tapir_get_table('op_admin_comments_view_table', $comments);
|
| 530 |
|
| 531 |
case 'edit-form':
|
| 532 |
$form['admin_comment_field'] = array(
|
| 533 |
'#type' => 'fieldset',
|
| 534 |
'#title' => t('Add an admin comment'),
|
| 535 |
'#collapsible' => TRUE,
|
| 536 |
'#collapsed' => TRUE,
|
| 537 |
);
|
| 538 |
$form['admin_comment_field']['admin_comment'] = array(
|
| 539 |
'#type' => 'textarea',
|
| 540 |
'#description' => t('Admin comments are only seen by store administrators.'),
|
| 541 |
);
|
| 542 |
return $form;
|
| 543 |
|
| 544 |
case 'edit-theme':
|
| 545 |
$comments = uc_order_comments_load($arg1['order_id']['#value'], TRUE);
|
| 546 |
if (is_array($comments) && count($comments) > 0) {
|
| 547 |
foreach ($comments as $comment) {
|
| 548 |
$items[] = '['. uc_get_initials($comment->uid) .'] '. filter_xss_admin($comment->message);
|
| 549 |
}
|
| 550 |
}
|
| 551 |
else {
|
| 552 |
$items = array(t('No admin comments have been entered for this order.'));
|
| 553 |
}
|
| 554 |
$output = theme('item_list', $items) . drupal_render($arg1['admin_comment_field']);
|
| 555 |
return $output;
|
| 556 |
|
| 557 |
case 'edit-process':
|
| 558 |
if (!is_null($arg1['admin_comment']) && strlen(trim($arg1['admin_comment'])) > 0) {
|
| 559 |
global $user;
|
| 560 |
uc_order_comment_save($arg1['order_id'], $user->uid, $arg1['admin_comment']);
|
| 561 |
}
|
| 562 |
return;
|
| 563 |
}
|
| 564 |
}
|
| 565 |
|
| 566 |
/**
|
| 567 |
* Handle the "Update" order pane.
|
| 568 |
*/
|
| 569 |
function uc_order_pane_update($op, $arg1) {
|
| 570 |
switch ($op) {
|
| 571 |
case 'view':
|
| 572 |
return drupal_get_form('uc_order_view_update_form', $arg1);
|
| 573 |
}
|
| 574 |
}
|
| 575 |
|
| 576 |
function uc_order_view_update_form($form_state, $order) {
|
| 577 |
$form['order_comment_field'] = array(
|
| 578 |
'#type' => 'fieldset',
|
| 579 |
'#title' => t('Add an order comment'),
|
| 580 |
'#collapsible' => TRUE,
|
| 581 |
'#collapsed' => TRUE,
|
| 582 |
);
|
| 583 |
$form['order_comment_field']['order_comment'] = array(
|
| 584 |
'#type' => 'textarea',
|
| 585 |
'#description' => t('Order comments are used primarily to communicate with the customer.'),
|
| 586 |
);
|
| 587 |
|
| 588 |
$form['admin_comment_field'] = array(
|
| 589 |
'#type' => 'fieldset',
|
| 590 |
'#title' => t('Add an admin comment'),
|
| 591 |
'#collapsible' => TRUE,
|
| 592 |
'#collapsed' => TRUE,
|
| 593 |
);
|
| 594 |
$form['admin_comment_field']['admin_comment'] = array(
|
| 595 |
'#type' => 'textarea',
|
| 596 |
'#description' => t('Admin comments are only seen by store administrators.'),
|
| 597 |
);
|
| 598 |
|
| 599 |
$form['current_status'] = array(
|
| 600 |
'#type' => 'hidden',
|
| 601 |
'#value' => $order->order_status,
|
| 602 |
);
|
| 603 |
|
| 604 |
$form['order_id'] = array(
|
| 605 |
'#type' => 'hidden',
|
| 606 |
'#value' => $order->order_id,
|
| 607 |
);
|
| 608 |
|
| 609 |
$form['controls'] = array(
|
| 610 |
'#theme' => 'uc_order_view_update_controls',
|
| 611 |
'#weight' => 10,
|
| 612 |
);
|
| 613 |
|
| 614 |
foreach (uc_order_status_list('general') as $status) {
|
| 615 |
$options[$status['id']] = $status['title'];
|
| 616 |
}
|
| 617 |
foreach (uc_order_status_list('specific') as $status) {
|
| 618 |
$options[$status['id']] = $status['title'];
|
| 619 |
}
|
| 620 |
$form['controls']['status'] = array(
|
| 621 |
'#type' => 'select',
|
| 622 |
'#title' => t('Order status'),
|
| 623 |
'#default_value' => $order->order_status,
|
| 624 |
'#options' => $options,
|
| 625 |
'#attributes' => array('style' => 'display: inline;'),
|
| 626 |
'#weight' => -10,
|
| 627 |
);
|
| 628 |
|
| 629 |
$form['controls']['submit'] = array(
|
| 630 |
'#type' => 'submit',
|
| 631 |
'#value' => t('Update'),
|
| 632 |
'#weight' => 10,
|
| 633 |
);
|
| 634 |
|
| 635 |
return $form;
|
| 636 |
}
|
| 637 |
|
| 638 |
function theme_uc_order_view_update_controls($form) {
|
| 639 |
return '<div class="update-controls">'. drupal_render($form) .'</div>';
|
| 640 |
}
|
| 641 |
|
| 642 |
function uc_order_view_update_form_submit($form_id, &$form_state) {
|
| 643 |
global $user;
|
| 644 |
|
| 645 |
if ($form_state['values']['status'] != $form_state['values']['current_status']) {
|
| 646 |
if (uc_order_update_status($form_state['values']['order_id'], $form_state['values']['status'])) {
|
| 647 |
if (is_null($form_state['values']['order_comment']) || strlen($form_state['values']['order_comment']) == 0) {
|
| 648 |
uc_order_comment_save($form_state['values']['order_id'], $user->uid, '-', 'order', $form_state['values']['status'], $form_state['values']['notify']);
|
| 649 |
}
|
| 650 |
}
|
| 651 |
}
|
| 652 |
|
| 653 |
if (!is_null($form_state['values']['order_comment']) && strlen(trim($form_state['values']['order_comment'])) > 0) {
|
| 654 |
uc_order_comment_save($form_state['values']['order_id'], $user->uid, $form_state['values']['order_comment'], 'order', $form_state['values']['status'], $form_state['values']['notify']);
|
| 655 |
}
|
| 656 |
|
| 657 |
if (!is_null($form_state['values']['admin_comment']) && strlen(trim($form_state['values']['admin_comment'])) > 0) {
|
| 658 |
uc_order_comment_save($form_state['values']['order_id'], $user->uid, $form_state['values']['admin_comment']);
|
| 659 |
}
|
| 660 |
|
| 661 |
drupal_set_message(t('Order updated.'));
|
| 662 |
}
|
| 663 |
|
| 664 |
/**
|
| 665 |
* Build the order view products table.
|
| 666 |
*/
|
| 667 |
function op_products_view_table($form_state, $products) {
|
| 668 |
$table = array();
|
| 669 |
|
| 670 |
$fields = array();
|
| 671 |
$fields[] = array(
|
| 672 |
'id' => 'qty',
|
| 673 |
'cell' => array(
|
| 674 |
'data' => t('Qty'),
|
| 675 |
'class' => 'text-right',
|
| 676 |
),
|
| 677 |
'weight' => 0,
|
| 678 |
);
|
| 679 |
$fields[] = array(
|
| 680 |
'id' => 'product',
|
| 681 |
'cell' => array(
|
| 682 |
'data' => t('Product'),
|
| 683 |
'width' => '80%',
|
| 684 |
),
|
| 685 |
'weight' => 1,
|
| 686 |
);
|
| 687 |
$fields[] = array(
|
| 688 |
'id' => 'model',
|
| 689 |
'cell' => array(
|
| 690 |
'data' => t('Model'),
|
| 691 |
'class' => 'text-center',
|
| 692 |
'nowrap' => 'nowrap',
|
| 693 |
),
|
| 694 |
'weight' => 2,
|
| 695 |
);
|
| 696 |
if (user_access('administer products')) {
|
| 697 |
$fields[] = array(
|
| 698 |
'id' => 'cost',
|
| 699 |
'cell' => array(
|
| 700 |
'data' => t('Cost'),
|
| 701 |
'class' => 'text-right',
|
| 702 |
),
|
| 703 |
'weight' => 3,
|
| 704 |
);
|
| 705 |
}
|
| 706 |
$fields[] = array(
|
| 707 |
'id' => 'price',
|
| 708 |
'cell' => array(
|
| 709 |
'data' => t('Price'),
|
| 710 |
'class' => 'text-right',
|
| 711 |
),
|
| 712 |
'weight' => 4,
|
| 713 |
);
|
| 714 |
$fields[] = array(
|
| 715 |
'id' => 'total',
|
| 716 |
'cell' => array(
|
| 717 |
'data' => t('Total'),
|
| 718 |
'class' => 'text-right',
|
| 719 |
),
|
| 720 |
'weight' => 5,
|
| 721 |
);
|
| 722 |
|
| 723 |
$table['columns'] = $fields;
|
| 724 |
|
| 725 |
if (is_array($products)) {
|
| 726 |
foreach ($products as $product) {
|
| 727 |
$data = array();
|
| 728 |
$data['qty']['cell'] = array('data' => $product->qty .'x', 'align' => 'right');
|
| 729 |
$options = $product->data['attributes'];
|
| 730 |
$option_rows = array();
|
| 731 |
if (module_exists('uc_attribute') && is_array($options)) {
|
| 732 |
foreach ($options as $attribute => $option) {
|
| 733 |
$option_rows[] = t('@attribute: @option', array('@attribute' => $attribute, '@option' => $option));
|
| 734 |
}
|
| 735 |
}
|
| 736 |
$data['product']['cell'] = check_plain($product->title) . theme('item_list', $option_rows, NULL, 'ul', array('class' => 'product-options'));
|
| 737 |
$data['model']['cell'] = array('data' => check_plain($product->model), 'align' => 'center', 'nowrap' => 'nowrap');
|
| 738 |
if (user_access('administer products')) {
|
| 739 |
$data['cost']['cell'] = array('data' => uc_currency_format($product->cost), 'align' => 'right', 'nowrap' => 'nowrap');
|
| 740 |
}
|
| 741 |
$data['price']['cell'] = array('data' => uc_currency_format($product->price), 'align' => 'right', 'nowrap' => 'nowrap');
|
| 742 |
$data['total']['cell'] = array('data' => uc_currency_format($product->qty * $product->price), 'align' => 'right', 'nowrap' => 'nowrap');
|
| 743 |
$table['rows'][] = array('data' => $data, 'valign' => 'top');
|
| 744 |
}
|
| 745 |
}
|
| 746 |
else {
|
| 747 |
$table['rows'][]['product']['cell'] = array('data' => t('This order contains no products.'), 'colspan' => 10);
|
| 748 |
}
|
| 749 |
|
| 750 |
$attributes = array('class' => 'order-pane-table');
|
| 751 |
|
| 752 |
$form['table'] = array(
|
| 753 |
'#value' => $table,
|
| 754 |
'#theme' => 'tapir_table',
|
| 755 |
'#attributes' => $attributes,
|
| 756 |
);
|
| 757 |
|
| 758 |
return $form;
|
| 759 |
}
|
| 760 |
|
| 761 |
function op_products_customer_table($form_state, $products) {
|
| 762 |
$table = array();
|
| 763 |
|
| 764 |
$fields = array();
|
| 765 |
$fields[] = array(
|
| 766 |
'id' => 'qty',
|
| 767 |
'cell' => array('data' => t('Qty'), 'class' => 'text-right'),
|
| 768 |
'weight' => 0,
|
| 769 |
);
|
| 770 |
$fields[] = array(
|
| 771 |
'id' => 'product',
|
| 772 |
'cell' => array('data' => t('Product'), 'width' => '80%'),
|
| 773 |
'weight' => 1,
|
| 774 |
);
|
| 775 |
$fields[] = array(
|
| 776 |
'id' => 'model',
|
| 777 |
'cell' => array('data' => t('Model'), 'class' => 'text-center', 'nowrap' => 'nowrap'),
|
| 778 |
'weight' => 2,
|
| 779 |
);
|
| 780 |
$fields[] = array(
|
| 781 |
'id' => 'cost',
|
| 782 |
'cell' => array('data' => t('Cost'), 'class' => 'text-right'),
|
| 783 |
'weight' => 3,
|
| 784 |
);
|
| 785 |
$fields[] = array(
|
| 786 |
'id' => 'price',
|
| 787 |
'cell' => array('data' => t('Price'), 'class' => 'text-right'),
|
| 788 |
'weight' => 4,
|
| 789 |
);
|
| 790 |
$fields[] = array(
|
| 791 |
'id' => 'total',
|
| 792 |
'cell' => array('data' => t('Total'), 'class' => 'text-right'),
|
| 793 |
'weight' => 5,
|
| 794 |
);
|
| 795 |
|
| 796 |
$table['columns'] = $fields;
|
| 797 |
|
| 798 |
if (is_array($products)) {
|
| 799 |
foreach ($products as $product) {
|
| 800 |
$data = array();
|
| 801 |
$data['qty']['cell'] = array('data' => $product->qty .'x', 'align' => 'right');
|
| 802 |
$options = $product->data['attributes'];
|
| 803 |
$option_rows = array();
|
| 804 |
if (is_array($options)) {
|
| 805 |
foreach ($options as $attribute => $option) {
|
| 806 |
$option_rows[] = t('@attribute: @option', array('@attribute' => $attribute, '@option' => $option));
|
| 807 |
}
|
| 808 |
}
|
| 809 |
$data['product']['cell'] = check_plain($product->title) . theme('item_list', $option_rows, NULL, 'ul', array('class' => 'product-options'));
|
| 810 |
$data['model']['cell'] = array('data' => check_plain($product->model), 'align' => 'center', 'nowrap' => 'nowrap');
|
| 811 |
$data['cost']['cell'] = array('data' => uc_currency_format($product->cost), 'align' => 'right', 'nowrap' => 'nowrap');
|
| 812 |
$data['price']['cell'] = array('data' => uc_currency_format($product->price), 'align' => 'right', 'nowrap' => 'nowrap');
|
| 813 |
$data['total']['cell'] = array('data' => uc_currency_format($product->qty * $product->price), 'align' => 'right', 'nowrap' => 'nowrap');
|
| 814 |
$table['rows'][] = array('data' => $data, 'valign' => 'top');
|
| 815 |
}
|
| 816 |
}
|
| 817 |
else {
|
| 818 |
$data['product']['cell'] = array('data' => t('This order contains no products.'), 'colspan' => 10);
|
| 819 |
$table['rows'][] = $data;
|
| 820 |
}
|
| 821 |
|
| 822 |
$attributes = array('class' => 'order-pane-table');
|
| 823 |
|
| 824 |
$form['table'] = array(
|
| 825 |
'#value' => $table,
|
| 826 |
'#theme' => 'tapir_table',
|
| 827 |
'#attributes' => $attributes,
|
| 828 |
);
|
| 829 |
|
| 830 |
return $form;
|
| 831 |
}
|
| 832 |
|
| 833 |
function op_order_comments_view_table($form_state, $comments) {
|
| 834 |
$table = array();
|
| 835 |
|
| 836 |
$fields = array();
|
| 837 |
$fields[] = array(
|
| 838 |
'id' => 'date',
|
| 839 |
'cell' => array('data' => t('Date'), 'class' => 'text-center'),
|
| 840 |
'weight' => 0,
|
| 841 |
);
|
| 842 |
$fields[] = array(
|
| 843 |
'id' => 'user',
|
| 844 |
'cell' => t('User'),
|
| 845 |
'weight' => 1,
|
| 846 |
);
|
| 847 |
$fields[] = array(
|
| 848 |
'id' => 'notified',
|
| 849 |
'cell' => t('Notified'),
|
| 850 |
'weight' => 2,
|
| 851 |
);
|
| 852 |
$fields[] = array(
|
| 853 |
'id' => 'status',
|
| 854 |
'cell' => array('data' => t('Status'), 'class' => 'text-center'),
|
| 855 |
'weight' => 3,
|
| 856 |
);
|
| 857 |
$fields[] = array(
|
| 858 |
'id' => 'comment',
|
| 859 |
'cell' => array('data' => t('Comment'), 'width' => '80%'),
|
| 860 |
'weight' => 4,
|
| 861 |
);
|
| 862 |
|
| 863 |
$table['columns'] = $fields;
|
| 864 |
|
| 865 |
if (is_array($comments)) {
|
| 866 |
foreach ($comments as $comment) {
|
| 867 |
$data = array();
|
| 868 |
$data['date']['cell'] = array('data' => format_date($comment->created, 'custom', variable_get('uc_date_format_default', 'm/d/Y') .'<\b\r />g:i:s A'), 'align' => 'center', 'nowrap' => 'true');
|
| 869 |
$data['user']['cell'] = array('data' => uc_get_initials($comment->uid), 'align' => 'center');
|
| 870 |
$data['notified']['cell'] = array('data' => (($comment->notified == 1) ? '<img src="'. base_path() . drupal_get_path('module', 'uc_order') .'/images/true-icon.gif" />': '<img src="'. base_path() . drupal_get_path('module', 'uc_order') .'/images/false-icon.gif" />'), 'align' => 'center');
|
| 871 |
$data['status']['cell'] = array('data' => $comment->title, 'align' => 'center');
|
| 872 |
$data['comment']['cell'] = array('data' => filter_xss_admin($comment->message));
|
| 873 |
$table['rows'][] = $data;
|
| 874 |
}
|
| 875 |
}
|
| 876 |
else {
|
| 877 |
$data['comment']['cell'] = array('data' => t('This order has no comments associated with it.'), 'colspan' => 10);
|
| 878 |
$table['rows'][] = $data;
|
| 879 |
}
|
| 880 |
|
| 881 |
$attributes = array('class' => 'order-pane-table');
|
| 882 |
|
| 883 |
$form['table'] = array(
|
| 884 |
'#value' => $table,
|
| 885 |
'#theme' => 'tapir_table',
|
| 886 |
'#attributes' => $attributes,
|
| 887 |
);
|
| 888 |
|
| 889 |
return $form;
|
| 890 |
}
|
| 891 |
|
| 892 |
function op_admin_comments_view_table($form_state, $comments) {
|
| 893 |
$table = array();
|
| 894 |
|
| 895 |
$fields = array();
|
| 896 |
$fields[] = array(
|
| 897 |
'id' => 'date',
|
| 898 |
'cell' => array('data' => t('Date'), 'class' => 'text-center'),
|
| 899 |
'weight' => 0,
|
| 900 |
);
|
| 901 |
$fields[] = array(
|
| 902 |
'id' => 'user',
|
| 903 |
'cell' => array('data' => t('User'), 'class' => 'text-center'),
|
| 904 |
'weight' => 1,
|
| 905 |
);
|
| 906 |
$fields[] = array(
|
| 907 |
'id' => 'comment',
|
| 908 |
'cell' => array('data' => t('Comment'), 'width' => '80%'),
|
| 909 |
'weight' => 2,
|
| 910 |
);
|
| 911 |
|
| 912 |
$table['columns'] = $fields;
|
| 913 |
|
| 914 |
if (is_array($comments)) {
|
| 915 |
foreach ($comments as $comment) {
|
| 916 |
$data = array();
|
| 917 |
$data['date']['cell'] = array('data' => format_date($comment->created, 'custom', variable_get('uc_date_format_default', 'm/d/Y') .'<\b\r />g:i:s A'), 'align' => 'center', 'nowrap' => 'true', 'valign' => 'top');
|
| 918 |
$data['user']['cell'] = array('data' => uc_get_initials($comment->uid), 'align' => 'center', 'valign' => 'top');
|
| 919 |
$data['comment']['cell'] = array('data' => filter_xss_admin($comment->message), 'valign' => 'top');
|
| 920 |
$table['rows'][] = $data;
|
| 921 |
}
|
| 922 |
}
|
| 923 |
else {
|
| 924 |
$data['comment']['cell'] = array('data' => t('This order has no admin comments associated with it.'), 'colspan' => 10);
|
| 925 |
$table['rows'][] = $data;
|
| 926 |
}
|
| 927 |
|
| 928 |
$attributes = array('class' => 'order-pane-table');
|
| 929 |
|
| 930 |
$form['table'] = array(
|
| 931 |
'#value' => $table,
|
| 932 |
'#theme' => 'tapir_table',
|
| 933 |
'#attributes' => $attributes,
|
| 934 |
);
|
| 935 |
|
| 936 |
return $form;
|
| 937 |
}
|
| 938 |
|
| 939 |
/**
|
| 940 |
* Build a list of order panes defined in the enabled modules.
|
| 941 |
*/
|
| 942 |
function _order_pane_list($view = 'view') {
|
| 943 |
static $panes;
|
| 944 |
|
| 945 |
if (count($panes) > 0 && $action !== 'rebuild') {
|
| 946 |
return $panes;
|
| 947 |
}
|
| 948 |
|
| 949 |
$panes = module_invoke_all('order_pane', NULL);
|
| 950 |
foreach ($panes as $i => $value) {
|
| 951 |
$panes[$i]['enabled'] = variable_get('uc_order_pane_'. $panes[$i]['id'] .'_enabled', (!isset($panes[$i]['enabled']) ? TRUE : $panes[$i]['enabled']));
|
| 952 |
$panes[$i]['weight'] = variable_get('uc_order_pane_'. $panes[$i]['id'] .'_weight_'. $view, (!isset($panes[$i]['weight']) ? 0 : $panes[$i]['weight']));
|
| 953 |
}
|
| 954 |
usort($panes, 'uc_weight_sort');
|
| 955 |
|
| 956 |
return $panes;
|
| 957 |
}
|
| 958 |
|
| 959 |
/**
|
| 960 |
* Return data from an order pane by pane ID and the array key.
|
| 961 |
*/
|
| 962 |
function _order_pane_data($pane_id, $key) {
|
| 963 |
$panes = _order_pane_list();
|
| 964 |
foreach ($panes as $pane) {
|
| 965 |
if ($pane['id'] == $pane_id) {
|
| 966 |
return $pane[$key];
|
| 967 |
}
|
| 968 |
}
|
| 969 |
}
|
| 970 |
|
| 971 |
/**
|
| 972 |
* Call an order pane function with the argument passed by reference.
|
| 973 |
*/
|
| 974 |
function _call_order_pane_byref($func, $op, &$form) {
|
| 975 |
return $func($op, $form);
|
| 976 |
}
|
| 977 |
|