You are here

function pay_admin_method_overview in Pay 7

1 string reference to 'pay_admin_method_overview'
pay_menu_menu in includes/pay.menu.inc
Implementation of hook_menu().

File

includes/pay.admin.inc, line 181
Administration form settings and related functions.

Code

function pay_admin_method_overview() {
  $header = array(
    t('Name'),
    t('Type'),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  $rows = array();
  $info = pay_handlers('pay_method');
  foreach (pay_form_load()
    ->pay_method_list() as $pmid => $pay_method) {
    if (!($pay_method = pay_method_load($pmid))) {
      continue;
    }
    $row = array();
    $count = $pay_method
      ->transactionCount();

    // Name column.
    $row[] = $pay_method
      ->title();

    // Type/handler column.
    $row[] = $info[$pay_method
      ->handler()]['title'];

    // Edit link.
    $row[] = l(t('edit'), 'admin/config/pay/method/' . $pmid . '/edit');

    // Disable/delete link.
    if ($count == 0) {
      $row[] = l(t('delete'), 'admin/config/pay/method/' . $pmid . '/delete');
    }
    else {
      $row[] = l(t('disable'), 'admin/config/pay/method/' . $pmid . '/delete');
    }
    $rows[] = $row;
  }
  $build['node_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No payment methods available. <a href="@link">Add payment method</a>.', array(
      '@link' => url('admin/config/pay/method/add'),
    )),
  );
  return $build;
}