Commit 9c8c2ff4 authored by Aram Boyajyan's avatar Aram Boyajyan Committed by Aram Boyajyan
Browse files

Issue #2690597 by aramboyajyan: code formatting and some minor things

parent 8dee333e
Loading
Loading
Loading
Loading
+26 −31
Original line number Diff line number Diff line
@@ -9,8 +9,6 @@
 * Implements hook_menu().
 */
function commerce_invoice_receipt_menu() {
  $items = array();

  $items['admin/commerce/orders/%commerce_order/view/details'] = array(
    'title' => 'Order details',
    'page callback' => 'commerce_order_ui_order_view',
@@ -21,7 +19,6 @@ function commerce_invoice_receipt_menu() {
    'weight' => -10,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  );

  $items['admin/commerce/orders/%commerce_order/view/print'] = array(
    'title' => 'Printable invoice',
    'page callback' => 'commerce_invoice_receipt_view_print',
@@ -32,7 +29,6 @@ function commerce_invoice_receipt_menu() {
    'weight' => 1,
    'parent' => 'admin/commerce/orders/%commerce_order',
  );

  $items['admin/commerce/orders/%commerce_order/view/mail'] = array(
    'title' => 'Email the invoice',
    'page callback' => 'drupal_get_form',
@@ -43,7 +39,6 @@ function commerce_invoice_receipt_menu() {
    'weight' => 2,
    'parent' => 'admin/commerce/orders/%commerce_order',
  );

  $items['admin/commerce/orders/%commerce_order/edit/edit'] = array(
    'title' => 'Edit order',
    'page callback' => 'commerce_order_ui_order_form_wrapper',
@@ -56,7 +51,6 @@ function commerce_invoice_receipt_menu() {
    'file path' => drupal_get_path('module', 'commerce_order_ui'),
    'file' => 'includes/commerce_order_ui.orders.inc',
  );

  $items['admin/commerce/orders/%commerce_order/edit/print'] = array(
    'title' => 'Printable Invoice',
    'page callback' => 'commerce_invoice_receipt_view_print',
@@ -67,7 +61,6 @@ function commerce_invoice_receipt_menu() {
    'weight' => 1,
    'parent' => 'admin/commerce/orders/%commerce_order',
  );

  $items['admin/commerce/orders/%commerce_order/edit/mail'] = array(
    'title' => 'Email the invoice',
    'page callback' => 'drupal_get_form',
@@ -78,7 +71,6 @@ function commerce_invoice_receipt_menu() {
    'weight' => 2,
    'parent' => 'admin/commerce/orders/%commerce_order',
  );

  $items['user/%user/orders/%commerce_order/print'] = array(
    'title' => 'Printable Invoice',
    'page callback' => 'commerce_invoice_receipt_view_print',
@@ -88,7 +80,6 @@ function commerce_invoice_receipt_menu() {
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
  );

  $items['user/%user/orders/%commerce_order/view'] = array(
    'title' => 'View',
    'type' => MENU_DEFAULT_LOCAL_TASK,
@@ -106,7 +97,7 @@ function commerce_invoice_receipt_preprocess_commerce_order_invoice_view(&$vars)
  $styles[] = array(
    'type' => 'file',
    'media' => 'all',
    'data' => commerce_invoice_receipt_css_path(),
    'data' => _commerce_invoice_receipt_css_path(),
    'group' => CSS_DEFAULT,
    'every_page' => FALSE,
    'weight' => 0,
@@ -117,23 +108,6 @@ function commerce_invoice_receipt_preprocess_commerce_order_invoice_view(&$vars)
  $vars['styles'] = $styles;
}

/**
 * Locate default CSS path.
 */
function commerce_invoice_receipt_css_path() {
  // Get current default theme
  $default_theme_path = drupal_get_path('theme', variable_get('theme_default', NULL));
  $default_template_css = drupal_get_path('module', 'commerce_invoice_receipt') . '/theme/commerce_invoice_receipt.css';

  // Check if the default theme wants to override the invoice stylesheet.
  $files = file_scan_directory($default_theme_path, '/commerce_invoice_receipt.css$/');
  if (count($files)) {
    $default_template_css = key($files);
  }

  return $default_template_css;
}

/**
 * Menu callback, render invoice.
 */
@@ -242,18 +216,22 @@ function commerce_invoice_receipt_mail($key, &$message, $params) {
 *   commerce_invoice_receipt_mail_form_submit()
 */
function commerce_invoice_receipt_mail_form($form_state, $order) {
  // Store the order ID.
  $form['order_id'] = array(
    '#type' => 'hidden',
    '#value' => $order['build_info']['args'][0]->order_id,
  );

  // Recipient email address.
  $form['email'] = array(
    '#type' => 'textfield',
    '#title' => t('Recipient e-mail address'),
    '#default_value' => $order['build_info']['args'][0]->mail,
  );

  $form['submit' ] = array(
  // Form actions.
  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit' ] = array(
    '#type' => 'submit',
    '#value' => t('Email invoice'),
  );
@@ -292,7 +270,7 @@ function commerce_invoice_receipt_mail_form_submit($form, &$form_state) {
}

/**
 * Generate an array for rendering all the invoice info.
 * Helper function - generate an array for rendering all the invoice info.
 */
function _commerce_invoice_receipt_get_invoice_info($order, $build) {
  $info = array(
@@ -327,3 +305,20 @@ function _commerce_invoice_receipt_get_invoice_info($order, $build) {

  return $info;
}

/**
 * Locate default CSS path.
 */
function _commerce_invoice_receipt_css_path() {
  // Get current default theme
  $default_theme_path = drupal_get_path('theme', variable_get('theme_default', NULL));
  $default_template_css = drupal_get_path('module', 'commerce_invoice_receipt') . '/theme/commerce_invoice_receipt.css';

  // Check if the default theme wants to override the invoice stylesheet.
  $files = file_scan_directory($default_theme_path, '/commerce_invoice_receipt.css$/');
  if (count($files)) {
    $default_template_css = key($files);
  }

  return $default_template_css;
}