aboutsummaryrefslogtreecommitdiff
path: root/muamba.theme.inc
blob: c2cc38f8f5d21c585255ef777660e30f9be26171 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

/**
 * @file
 * Misc theme functions.
 */

/**
 * Theme callback.
 */
function theme_muamba_transactions($variables) {
  $path = drupal_get_path('module', 'muamba');
  drupal_add_js($path  .'/muamba.js');

  $rows         = array();
  $type         = $variables['type'];
  $transactions = $variables['transactions'];

  $output = '<div class="muamba-transactions">';

  if ($type == 'sent') {
    $title = t('Items I requested from people');
  }
  else {
    $title = t('My items that people requested');
  }

  $output .= '<h2>'. $title .'</h2>';

  if (empty($transactions)) {
    $output .= t('There are no transactions.');
    $output .= '</div>';
    return $output;
  }

  foreach($transactions as $transaction) {
    foreach (muamba_actions_available($type, $transaction['status']) as $action) {
      $callback  = muamba_actions($action);
      $actions[] = l(t($callback), $callback);
    }

    $rows[] = array(
      'asset'   => $transaction['node']->title,
      'user'    => $transaction['user']->name,
      'status'  => t(muamba_statuses($transaction['status'])),
      'actions' => implode($actions, ' | '),
      'thread'  => l(
        t('view messages'),
        'messages/view/'. $transaction['thread_id'],
        array(
          'attributes' => array(
            'class' => array('colorbox-ajax', 'colorbox-load')
          )
        )
      )
    );
  }

  // Make a table for them.
  $header = array(t('Item'), t('User'), t('Status'), t('Actions'), t('Negotiation'));
  $output .= theme('table', array('header' => $header, 'rows' => $rows));  
  $output .= '</div>';

  return $output;
}