You are here

function merci_line_item_ui_types_overview in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

Menu callback: display an overview of available types.

File

merci_line_item/includes/merci_line_item_ui.types.inc, line 6

Code

function merci_line_item_ui_types_overview() {
  drupal_add_css(drupal_get_path('module', 'merci_line_item') . '/theme/merci_line_item.admin.css');
  $header = array(
    t('Name'),
    t('Operations'),
  );
  $rows = array();

  // Loop through all defined line item types.
  foreach (merci_line_item_types() as $type => $line_item_type) {

    // Build the operation links for the current line item type.
    $type_arg = strtr($type, '_', '-');
    $links = menu_contextual_links('merci-line-item-type', MERCI_LINE_ITEM_TYPE_PATH, array(
      $type_arg,
    ));

    // Add the line item type's row to the table's rows array.
    $rows[] = array(
      theme('merci_line_item_type_admin_overview', array(
        'line_item_type' => $line_item_type,
      )),
      theme('links', array(
        'links' => $links,
        'attributes' => array(
          'class' => 'links inline operations',
        ),
      )),
    );
  }

  // If no line item types are defined...
  if (empty($rows)) {

    // Add a standard empty row with a link to add a new line item type.
    $rows[] = array(
      array(
        'data' => t('There are no line item types defined by enabled modules.'),
        'colspan' => 2,
      ),
    );
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
}