You are here

function theme_merci_current_inventory in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.2

Same name and namespace in other branches
  1. 6.2 theme/theme.inc \theme_merci_current_inventory()

returns the number of items currently checked out for each content type TODO: change this to a views view.

File

theme/theme.inc, line 206
MERCI - Managed Equipment Reservation Checkout and Inventory

Code

function theme_merci_current_inventory() {
  $header = array(
    t('Item'),
    t('On Hand'),
    t('Unavailable'),
    t('Checked Out'),
    t('Total'),
    t('Operations'),
  );
  $merci_types = merci_content_types();
  $rows = array();
  foreach ($merci_types as $merci_type) {
    $info = node_type_get_type($merci_type['type']);
    $info = (array) $info;
    $info['url_str'] = str_replace('_', '-', $info['type']);
    $operations = l(t('Edit'), 'admin/structure/types/manage/' . $info['url_str'], array(
      'query' => array(
        'destination' => 'admin/merci/manage/current_inventory',
      ),
    ));
    $operations .= " | ";
    $operations .= l(t('Add Item'), 'node/add/' . $info['url_str'], array(
      'query' => array(
        'destination' => 'admin/merci/manage/current_inventory',
      ),
    ));
    $checked_out = merci_get_reservation_count($merci_type['type']);
    $available = merci_get_count($merci_type, MERCI_AVA_F);
    $onhand = $available - $checked_out;
    $unavailable = merci_get_count($merci_type, MERCI_UNA_F);
    $total = $onhand + $unavailable + $checked_out;
    $available = l($onhand, 'admin/merci/manage/current_inventory/' . $info['type'] . '/Available');
    $checked_out = l($checked_out, 'admin/merci/manage/current_inventory/' . $info['type'] . '/checked-out');
    $unavailable = l($unavailable, 'admin/merci/manage/current_inventory/' . $info['type'] . '/Unavailable');
    $title = views_get_view('merci_inventory_view') ? l($info['name'], 'admin/merci/manage/inventory/view', array(
      'html' => TRUE,
      'query' => array(
        'merci_content_type' => $merci_type['type'],
      ),
    )) : $info['name'];
    $rows[] = array(
      $title,
      $available,
      $unavailable,
      $checked_out,
      $total,
      $operations,
    );
  }
  $output = theme('status_messages');
  $output .= theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
  $output .= '» ' . l(t('Add a new content type'), 'admin/structure/types/add', array(
    'query' => array(
      'destination' => 'admin/merci/manage/current_inventory',
    ),
  ));
  return $output;
}