'Order settings',
'description' => 'Configure the order settings.',
'page callback' => 'uc_order_settings_overview',
'access arguments' => array('administer store'),
'type' => MENU_NORMAL_ITEM,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/settings/orders/overview'] = array(
'title' => 'Overview',
'description' => 'View the order settings.',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items['admin/store/settings/orders/edit'] = array(
'title' => 'Edit',
'description' => 'Edit the order settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_order_settings_form'),
'access arguments' => array('administer store'),
'type' => MENU_LOCAL_TASK,
'weight' => -5,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/settings/orders/edit/basic'] = array(
'title' => 'Order settings',
'description' => 'Edit the basic order settings.',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items['admin/store/settings/orders/edit/workflow'] = array(
'title' => 'Order workflow',
'description' => 'Modify and configure order states and statuses.',
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_order_workflow_form'),
'access arguments' => array('administer order workflow'),
'type' => MENU_LOCAL_TASK,
'weight' => -5,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/settings/orders/edit/panes'] = array(
'title' => 'Order panes',
'description' => 'Edit the pane settings for order pages.',
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_order_panes_form'),
'access arguments' => array('administer store'),
'type' => MENU_LOCAL_TASK,
'weight' => 0,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/settings/orders/edit/workflow/create'] = array(
'title' => 'Create an order status',
'description' => 'Create a custom order status for your store.',
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_order_status_create_form'),
'access arguments' => array('administer order workflow'),
'type' => MENU_CALLBACK,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders'] = array(
'title' => 'Orders',
'description' => 'View and process orders.',
'page callback' => 'uc_order_admin',
'page arguments' => array(NULL, NULL, FALSE),
'access arguments' => array('view all orders'),
'type' => MENU_NORMAL_ITEM,
'weight' => -10,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/view'] = array(
'title' => 'View orders',
'description' => 'View and process the orders received through your website.',
'page arguments' => array(NULL, NULL, FALSE),
'access arguments' => array('view all orders'),
'type' => MENU_NORMAL_ITEM,
'weight' => -10,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/sort/%'] = array(
'title' => 'Orders',
'description' => 'View orders with a particular order status.',
'page arguments' => array(NULL, NULL, FALSE),
'access arguments' => array('view all orders'),
'type' => MENU_CALLBACK,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/create'] = array(
'title' => 'Create order',
'description' => 'Create an empty new order.',
'page callback' => 'uc_order_create',
'access arguments' => array('create orders'),
'type' => MENU_NORMAL_ITEM,
'weight' => -5,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/search'] = array(
'title' => 'Search orders',
'description' => 'Search existing orders.',
'page callback' => 'uc_order_usearch',
'access arguments' => array('view all orders'),
'type' => MENU_NORMAL_ITEM,
'weight' => 0,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/address_book'] = array(
'title' => 'Select address',
'page callback' => 'uc_order_address_book',
'access arguments' => array('edit orders'),
'type' => MENU_CALLBACK,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/customer'] = array(
'title' => 'Select customer',
'page callback' => 'uc_order_select_customer',
'page arguments' => array(NULL),
'access arguments' => array('edit orders'),
'type' => MENU_CALLBACK,
'file' => 'uc_order.admin.inc',
);
$items['user/%user/orders'] = array(
'title' => 'Orders',
'description' => 'View your order history.',
'page callback' => 'uc_order_history',
'page arguments' => array(1),
'access callback' => 'uc_order_can_view_order',
'access arguments' => array(1),
'type' => MENU_LOCAL_TASK,
'file' => 'uc_order.admin.inc',
);
$items['user/%user/order/%uc_order'] = array(
'title callback' => 'uc_order_page_title',
'title arguments' => array(3),
'description' => 'View order.',
'page callback' => 'uc_order_view',
'page arguments' => array(3, 'customer'),
'access callback' => 'uc_order_can_view_order',
'access arguments' => array(1, 3),
'type' => MENU_CALLBACK,
'file' => 'uc_order.admin.inc',
);
$items['user/%user/order/%uc_order/invoice'] = array(
'title' => 'View invoice',
'description' => 'View order invoice.',
'page callback' => 'uc_order_view',
'page arguments' => array(3, 'invoice'),
'access callback' => 'uc_order_can_view_order',
'access arguments' => array(1, 3),
'type' => MENU_CALLBACK,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/%uc_order'] = array(
'title callback' => 'uc_order_page_title',
'title arguments' => array(3),
'description' => 'View order',
'page callback' => 'uc_order_view',
'page arguments' => array(3, 'view'),
'access arguments' => array('view all orders'),
'type' => MENU_CALLBACK,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/%uc_order/view'] = array(
'title' => 'View',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10
);
$items['admin/store/orders/%uc_order/edit'] = array(
'title' => 'Edit',
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_order_edit_form', 3),
'access arguments' => array('edit orders'),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/%uc_order/add_line_item/%'] = array(
'title' => 'Add a line item',
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_order_add_line_item_form', 3, 5),
'access arguments' => array('edit orders'),
'type' => MENU_CALLBACK,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/%uc_order/products'] = array(
'title' => 'Products',
'page callback' => 'uc_order_edit_products',
'page arguments' => array(3),
'access arguments' => array('edit orders'),
'type' => MENU_CALLBACK,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/%uc_order/product_select'] = array(
'title' => 'Product select',
'page callback' => 'uc_order_load_product_select',
'page arguments' => array(3),
'access arguments' => array('edit orders'),
'type' => MENU_CALLBACK,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/%uc_order/add_product/%node'] = array(
'title' => 'Add product',
'page callback' => 'uc_order_add_product',
'page arguments' => array(3, 5),
'access arguments' => array('edit orders'),
'type' => MENU_CALLBACK,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/%uc_order/invoice'] = array(
'title' => 'Invoice',
'page callback' => 'uc_order_invoice',
'page arguments' => array(3),
'access arguments' => array('view all orders'),
'type' => MENU_LOCAL_TASK,
'weight' => 3,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/%uc_order/invoice/view'] = array(
'title' => 'View invoice',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items['admin/store/orders/%uc_order/invoice/print'] = array(
'title' => 'Printable invoice',
'page arguments' => array(3, 'print'),
'access arguments' => array('view all orders'),
'type' => MENU_LOCAL_TASK,
'weight' => -5,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/%uc_order/invoice/mail'] = array(
'title' => 'Mail invoice',
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_order_mail_invoice_form', 3),
'access arguments' => array('view all orders'),
'type' => MENU_LOCAL_TASK,
'weight' => 0,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/%uc_order/log'] = array(
'title' => 'Log',
'page callback' => 'uc_order_log',
'page arguments' => array(3),
'access callback' => 'uc_order_access_order_log',
'type' => MENU_LOCAL_TASK,
'weight' => 10,
'file' => 'uc_order.admin.inc',
);
$items['admin/store/orders/%uc_order/delete'] = array(
'title' => 'Delete an order',
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_order_delete_confirm_form', 3),
'access callback' => 'uc_order_can_delete',
'access arguments' => array(3),
'type' => MENU_CALLBACK,
'file' => 'uc_order.admin.inc',
);
return $items;
}
/**
* Title callback for admin/store/orders/%uc_order.
*/
function uc_order_page_title($order) {
return t('Order @order_id', array('@order_id' => $order->order_id));
}
/**
* Implementation of hook_init().
*/
function uc_order_init() {
drupal_add_css(drupal_get_path('module', 'uc_order') .'/uc_order.css');
if (arg(0) == 'admin' && arg(1) == 'store' && arg(2) == 'orders' && is_numeric(arg(3)) && arg(4) == 'edit') {
drupal_add_js(array(
'ucURL' => array(
'adminOrders' => url('admin/store/orders/'),
),
), 'setting');
drupal_add_js(drupal_get_path('module', 'uc_order') .'/uc_order.js');
}
}
/**
* Implementation of hook_theme().
*/
function uc_order_theme() {
return array(
'uc_order' => array(
'template' => 'uc_order',
'path' => drupal_get_path('module', 'uc_order') .'/templates',
'arguments' => array('order' => NULL, 'op' => 'view', 'template' => 'customer'),
),
'uc_order_state_table' => array(
'arguments' => array('form' => NULL),
),
'uc_order_status_table' => array(
'arguments' => array('form' => NULL),
),
'uc_order_edit_form' => array(
'arguments' => array('form' => NULL),
'file' => 'uc_order.admin.inc',
),
'uc_order_edit_products_form' => array(
'arguments' => array('form' => NULL),
'file' => 'uc_order.admin.inc',
),
'uc_order_remove_product' => array(
'arguments' => array('form' => NULL),
'file' => 'uc_order.admin.inc',
),
'uc_order_view_update_controls' => array(
'arguments' => array('form' => NULL),
),
);
}
/**
* Implementation of hook_token_values(). (token.module)
*/
function uc_order_token_values($type, $object = NULL) {
$values = array();
switch ($type) {
case 'order':
$order = $object;
if (isset($_SESSION['new_user']) && is_array($_SESSION['new_user'])) {
$values['new-username'] = check_plain($_SESSION['new_user']['name']);
$values['new-password'] = check_plain($_SESSION['new_user']['pass']);
}
else {
$values['new-username'] = '';
$values['new-password'] = '';
}
$values['order-id'] = $order->order_id;
$values['order-uid'] = $order->uid;
$values['order-url'] = url('user/'. $order->uid .'/order/'. $order->order_id, array('absolute' => TRUE));
$values['order-link'] = l($order->order_id, $values['order-url']);
$values['order-admin-url'] = url('admin/store/orders/'. $order->order_id, array('absolute' => TRUE));
$admin_url = url('admin/store/orders/'. $order->order_id, array('absolute' => TRUE));
$values['order-admin-link'] = l($order->order_id, $admin_url);
if (is_array($order->line_items)) {
foreach ($order->line_items as $key => $value) {
if ($value['type'] == 'subtotal') {
$context = array(
'revision' => 'formatted',
'type' => 'line_item',
'subject' => array(
'order' => $order,
'line_item' => $order->line_items[$key],
),
);
$subtotal = uc_price($order->line_items[$key]['amount'], $context);
}
if ($value['type'] == 'shipping' && is_null($ship_method)) {
$ship_method = $value['title'];
}
}
}
$values['order-subtotal'] = $subtotal;
$context = array(
'revision' => 'formatted-original',
'type' => 'order_total',
'subject' => array(
'order' => $order,
),
);
$values['order-total'] = uc_price($order->order_total, $context);
$values['order-email'] = check_plain($order->primary_email);
$values['order-shipping-address'] = uc_order_address($order, 'delivery');
$values['order-shipping-phone'] = check_plain($order->delivery_phone);
$values['order-shipping-method'] = is_null($ship_method) ? t('Standard delivery') : $ship_method;
$values['order-billing-address'] = uc_order_address($order, 'billing');
$values['order-billing-phone'] = check_plain($order->billing_phone);
if (variable_get('uc_customer_list_address', 'billing') == 'shipping') {
$values['order-first-name'] = check_plain($order->delivery_first_name);
$values['order-last-name'] = check_plain($order->delivery_last_name);
}
else {
$values['order-first-name'] = check_plain($order->billing_first_name);
$values['order-last-name'] = check_plain($order->billing_last_name);
}
$result = db_result(db_query_range("SELECT message FROM {uc_order_comments} WHERE order_id = %d AND uid = 0 ORDER BY created DESC", $order->order_id, 0, 1));
$values['order-comments'] = empty($result) ? t('No comments left.') : check_plain($result);
$result = db_result(db_query_range("SELECT message FROM {uc_order_comments} WHERE order_id = %d AND uid > 0 ORDER BY created DESC", $order->order_id, 0, 1));
$values['order-last-comment'] = empty($result) ? t('No comment found.') : check_plain($result);
$values['order-last-comment-raw'] = empty($result) ? t('No comment found.') : $result;
$values['order-status'] = uc_order_status_data($order->order_status, 'title');
$values['order-date-created'] = format_date($order->created, 'small');
$values['order-date-modified'] = format_date($order->modified, 'small');
break;
}
return $values;
}
/**
* Implementation of hook_token_list(). (token.module)
*/
function uc_order_token_list($type = 'all') {
$tokens = array();
if ($type == 'order' || $type == 'ubercart' || $type == 'all') {
$tokens['order']['new-username'] = t('New username associated with an order if applicable.');
$tokens['order']['new-password'] = t('New password associated with an order if applicable.');
$tokens['order']['order-id'] = t('The order ID.');
$tokens['order']['order-uid'] = t('The user ID of the order.');
$tokens['order']['order-url'] = t('The URL to the order');
$tokens['order']['order-link'] = t('A link to the order using the order ID.');
$tokens['order']['order-admin-url'] = t('The URL to the admin view page using the order ID.');
$tokens['order']['order-admin-link'] = t('A link to the order admin view page using the order ID.');
$tokens['order']['order-subtotal'] = t('The subtotal of products on an order.');
$tokens['order']['order-total'] = t('The order total.');
$tokens['order']['order-email'] = t('The primary e-mail address of the order.');
$tokens['order']['order-shipping-address'] = t('The order shipping address.');
$tokens['order']['order-shipping-phone'] = t('The phone number for the shipping address.');
$tokens['order']['order-billing-address'] = t('The order billing address.');
$tokens['order']['order-billing-phone'] = t('The phone number for the billing address.');
$tokens['order']['order-shipping-method'] = t('The title of the first shipping line item.');
$tokens['order']['order-first-name'] = t('The first name associated with the order.');
$tokens['order']['order-last-name'] = t('The last name associated with the order.');
$tokens['order']['order-comments'] = t('Comments left by the customer.');
$tokens['order']['order-last-comment'] = t('Last order comment left by an administrator (not counting the order admin comments).');
$tokens['order']['order-last-comment-raw'] = t('Last order comment left by an administrator (not counting the order admin comments). Use with caution: this is unescaped raw input.');
$tokens['order']['order-status'] = t('The current order status.');
$tokens['order']['order-date-created'] = t('The date and time when the order was created.');
$tokens['order']['order-date-modified'] = t('The date and time when the order was last modified.');
}
return $tokens;
}
/**
* Implementation of hook_perm().
*/
function uc_order_perm() {
return array('view own orders', 'view all orders', 'create orders', 'edit orders', 'delete orders', 'unconditionally delete orders', 'administer order workflow');
}
/**
* Access callback for user/%user/orders*.
*/
function uc_order_can_view_order($order_user, $order = NULL) {
global $user;
$access = user_access('view all orders') || ($user->uid && user_access('view own orders') && $user->uid == $order_user->uid);
if (!is_null($order)) {
$access = $access && $order_user->uid == $order->uid;
}
return $access;
}
/**
* Access callback for admin/store/orders/%uc_order/log.
*/
function uc_order_access_order_log() {
return user_access('view all orders') && variable_get('uc_order_logging', TRUE);
}
/**
* Implementation of hook_user().
*/
function uc_order_user($op, &$edit, &$account, $category = NULL) {
global $user;
switch ($op) {
case 'view':
if ($user->uid && (($user->uid == $account->uid && user_access('view own orders')) || user_access('view all orders'))) {
$account->content['orders'] = array(
'#type' => 'user_profile_category',
'#weight' => -5,
'#title' => t('Orders'),
'link' => array(
'#type' => 'user_profile_item',
'#value' => l(t('Click here to view your order history.'), 'user/'. $account->uid .'/orders'),
),
);
}
break;
}
}
/**
* Implementation of hook_mail().
*/
function uc_order_mail($key, &$message, $params) {
$langcode = isset($message['language']) ? $message['language']->language : NULL;
// Build the appropriate message paramaters based on the e-mail key.
switch ($key) {
// Setup an e-mailed invoice.
case 'invoice':
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
$message['subject'] = t('Your Order Invoice', array(), $langcode);
$message['from'] = uc_store_email_from();
$message['body'][] = theme('uc_order', $params['order'], 'admin-mail', variable_get('uc_cust_order_invoice_template', 'customer'));
break;
// Setup a custom e-mail defined by an action on a predicate.
case 'action-mail':
// Assemble an email message from the conditional actions settings.
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
$message['from'] = $params['from'];
// Perform token replacement on the subject and body.
$subject = token_replace_multiple($params['subject'], $params['replacements']);
$body = token_replace_multiple($params['message'], $params['replacements']);
// Strip newline characters from e-mail subjects.
// TODO: Maybe drupal_mail_send() should do this? -LM
$message['subject'] = str_replace(array("\r\n", "\r", "\n"), ' ', $subject);
// Apply an input format to the message body if specified.
if (isset($params['format'])) {
$message['body'] = check_markup($body, $params['format'], FALSE);
}
else {
$message['body'] = $body;
}
break;
}
}
/*******************************************************************************
* Hook Functions (Ubercart)
******************************************************************************/
/**
* Implementation of hook_order_pane().
*/
function uc_order_order_pane() {
$panes[] = array(
'id' => 'ship_to',
'callback' => 'uc_order_pane_ship_to',
'title' => t('Ship to'),
'desc' => t("Manage the order's shipping address and contact information."),
'class' => 'pos-left',
'weight' => 1,
'show' => array('view', 'edit', 'invoice', 'customer'),
);
$panes[] = array(
'id' => 'bill_to',
'callback' => 'uc_order_pane_bill_to',
'title' => t('Bill to'),
'desc' => t("Manage the order's billing address and contact information."),
'class' => 'pos-left',
'weight' => 2,
'show' => array('view', 'edit', 'invoice', 'customer'),
);
$panes[] = array(
'id' => 'customer',
'callback' => 'uc_order_pane_customer',
'title' => t('Customer info'),
'desc' => t("Manage the information for the customer's user account."),
'class' => 'pos-left',
'weight' => 3,
'show' => array('view', 'edit'),
);
$panes[] = array(
'id' => 'products',
'callback' => 'uc_order_pane_products',
'title' => t('Products'),
'desc' => t('Manage the products an order contains.'),
'class' => 'abs-left',
'weight' => 5,
'show' => array('view', 'edit', 'invoice', 'customer'),
);
$panes[] = array(
'id' => 'line_items',
'callback' => 'uc_order_pane_line_items',
'title' => t('Line items'),
'desc' => t("View and modify an order's line items."),
'class' => 'abs-left',
'weight' => 6,
'show' => array('view', 'edit', 'invoice', 'customer'),
);
$panes[] = array(
'id' => 'order_comments',
'callback' => 'uc_order_pane_order_comments',
'title' => t('Order comments'),
'desc' => t('View the order comments, used for communicating with customers.'),
'class' => 'abs-left',
'weight' => 8,
'show' => array('view', 'invoice', 'customer'),
);
$panes[] = array(
'id' => 'admin_comments',
'callback' => 'uc_order_pane_admin_comments',
'title' => t('Admin comments'),
'desc' => t('View the admin comments, used for administrative notes and instructions.'),
'class' => 'abs-left',
'weight' => 9,
'show' => array('view', 'edit'),
);
$panes[] = array(
'id' => 'update',
'callback' => 'uc_order_pane_update',
'title' => t('Update order'),
'desc' => t("Update an order's status or add comments to an order."),
'class' => 'abs-left',
'weight' => 10,
'show' => array('view'),
);
return $panes;
}
/**
* Implementation of hook_order_state().
*/
function uc_order_order_state() {
$states[] = array(
'id' => 'canceled',
'title' => t('Canceled'),
'weight' => -20,
'scope' => 'specific',
);
$states[] = array(
'id' => 'in_checkout',
'title' => t('In checkout'),
'weight' => -10,
'scope' => 'specific',
);
$states[] = array(
'id' => 'post_checkout',
'title' => t('Post checkout'),
'weight' => 0,
'scope' => 'general',
);
$states[] = array(
'id' => 'completed',
'title' => t('Completed'),
'weight' => 20,
'scope' => 'general',
);
return $states;
}
/**
* Implementation of hook_line_item().
*/
function uc_order_line_item() {
$items[] = array(
'id' => 'subtotal',
'title' => t('Subtotal'),
'weight' => 0,
'stored' => FALSE,
'calculated' => FALSE,
'callback' => 'uc_line_item_subtotal',
);
$items[] = array(
'id' => 'generic',
'title' => t('Empty line'),
'weight' => 2,
'stored' => TRUE,
'add_list' => TRUE,
'calculated' => TRUE,
'callback' => 'uc_line_item_generic',
);
$items[] = array(
'id' => 'total',
'title' => t('Total'),
'weight' => 15,
'stored' => FALSE,
'calculated' => FALSE,
'display_only' => TRUE,
'callback' => 'uc_line_item_total',
);
return $items;
}
/**
* Implementation of hook_uc_message().
*/
function uc_order_uc_message() {
$messages['order_update_email'] = t("[order-first-name] [order-last-name],\n\nYour order number [order-link] at [store-name] has been updated.\n\nOrder status: [order-status]\n\nOrder comment:\n[order-last-comment]\n\nBrowse to the following page to login to your account and view your order details:\n[site-login]\n\n\nThanks again,\n\n[store-name]\n[site-slogan]");
return $messages;
}
/**
* Implementation of hook_uc_invoice_templates().
*/
function uc_order_uc_invoice_templates() {
return array('admin', 'customer');
}
/*******************************************************************************
* Callback Functions, Forms, and Tables
******************************************************************************/
/**
* Theme the order state table in the order workflow settings.
*
* @ingroup themeable
*/
function theme_uc_order_state_table($form) {
$header = array(t('State'), t('Default order status'));
foreach (element_children($form) as $state_id) {
$rows[] = array(
drupal_render($form[$state_id]['title']),
drupal_render($form[$state_id]['default']),
);
}
return theme('table', $header, $rows);
}
/**
* Theme the order state table in the order workflow settings.
*/
function theme_uc_order_status_table($form) {
$header = array(t('ID'), t('Title'), t('List position'), t('State'), t('Remove'));
foreach (element_children($form) as $state_id) {
if ($state_id == 'create') {
$create = '
'. t('Use this button to create a custom order status: !create_form', array('!create_form' => drupal_render($form['create'])));
}
else {
$rows[] = array(
drupal_render($form[$state_id]['id']),
drupal_render($form[$state_id]['title']),
drupal_render($form[$state_id]['weight']),
drupal_render($form[$state_id]['state']),
array('data' => drupal_render($form[$state_id]['remove']), 'align' => 'center'),
);
}
}
return theme('table', $header, $rows) . $create;
}
/**
* Summarizes the order panes settings.
*
* @param $form
* The form passed from the summarizer
* @param $panes
* An array of order panes
* @param $parent_name
* The parent's displayed name
* @param $parent_id
* The parent's machine-readable ID
* @return
* An array of summary information
*
* This function summarizes the order panes that have been defined for each screen.
* Everything is then organized under a series of parent nodes correlating with the
* different screens, and specifying which panes are enabled on which screen.
*/
function _uc_order_panes_summarize($form, $panes, $parent_name, $parent_id) {
$items = array();
foreach ($panes as $name => $pane) {
$item[] = t('!title is !enabled.', array('!title' => $pane['title']['#value'], '!enabled' => $pane['uc_order_pane_'. $name .'_show_'. $parent_id]['#default_value'] ? t('enabled') : t('disabled')));
}
$items[] = array(
'data' => t('Order panes on %screen screen:', array('%screen' => $parent_name)),
'children' => $item,
);
return $items;
}
/**
* Form to input search parameters for orders.
*
* @ingroup forms
* @see uc_order_search_form_submit()
*/
function uc_order_search_form() {
$form['search'] = array(
'#type' => 'fieldset',
'#title' => t('Search options'),
'#collapsible' => TRUE,
'#collapsed' => arg(4) == 'results' ? TRUE : FALSE,
);
$form['search']['table1'] = array('#value' => '
');
$form['search']['desc'] = array(
'#value' => ' '. t("Search for customers based on any of the following fields. Use * as a wildcard to match any character. ',
);
$form['search']['table2'] = array('#value' => 'For example, searching by last name for 's*' will return all customers whose last name starts with an s. (Leave a field empty to ignore it in the search.)") .' | |||
'); $form['search']['billing_first_name'] = array( '#type' => 'textfield', '#title' => t('Billing first name'), '#default_value' => arg(5) != '0' ? arg(5) : '', '#size' => 24, '#maxlength' => 32, ); $form['search']['table3'] = array('#value' => ' | '); $form['search']['billing_last_name'] = array( '#type' => 'textfield', '#title' => t('Billing last name'), '#default_value' => arg(6) != '0' ? arg(6) : '', '#size' => 24, '#maxlength' => 32, ); $form['search']['table4'] = array('#value' => ' | '); $form['search']['billing_company'] = array( '#type' => 'textfield', '#title' => t('Billing company'), '#default_value' => arg(7) != '0' ? arg(7) : '', '#size' => 24, '#maxlength' => 96, ); $form['search']['table5'] = array('#value' => ' | |
'); $form['search']['shipping_first_name'] = array( '#type' => 'textfield', '#title' => t('Shipping first name'), '#default_value' => arg(8) != '0' ? arg(8) : '', '#size' => 24, '#maxlength' => 32, ); $form['search']['table6'] = array('#value' => ' | '); $form['search']['shipping_last_name'] = array( '#type' => 'textfield', '#title' => t('Shipping last name'), '#default_value' => arg(9) != '0' ? arg(9) : '', '#size' => 24, '#maxlength' => 32, ); $form['search']['table7'] = array('#value' => ' | '); $form['search']['shipping_company'] = array( '#type' => 'textfield', '#title' => t('Shipping company'), '#default_value' => arg(10) != '0' ? arg(10) : '', '#size' => 24, '#maxlength' => 96, ); $form['search']['table8'] = array('#value' => ' | |
'); $form['search']['use_dates'] = array( '#type' => 'checkbox', '#title' => t('Search using date range.'), '#description' => t('Specify dates to the right if checked.'), '#default_value' => arg(11) != 0 ? 1 : 0, ); $form['search']['table9'] = array('#value' => ' | '); $timestamp = arg(11) == 0 ? time() : arg(11); $form['search']['start_date'] = array( '#type' => 'date', '#title' => t('Start date'), '#default_value' => array('year' => format_date($timestamp, 'custom', 'Y'), 'month' => format_date($timestamp, 'custom', 'n'), 'day' => format_date($timestamp, 'custom', 'j')) ); $form['search']['table10'] = array('#value' => ' | '); $timestamp = arg(12) == 0 ? time() : arg(12); $form['search']['end_date'] = array( '#type' => 'date', '#title' => t('End date'), '#default_value' => array('year' => format_date($timestamp, 'custom', 'Y'), 'month' => format_date($timestamp, 'custom', 'n'), 'day' => format_date($timestamp, 'custom', 'j')), ); $form['search']['table11'] = array('#value' => ' | |
'); $form['search']['submit'] = array( '#type' => 'submit', '#value' => t('Search'), ); $form['search']['table12'] = array('#value' => ' |