You are here

function _commerce_reports_patterns_view in Commerce Reporting 7.3

Same name and namespace in other branches
  1. 7.4 modules/patterns/commerce_reports_patterns.admin.inc \_commerce_reports_patterns_view()
1 call to _commerce_reports_patterns_view()
commerce_reports_patterns_view in modules/patterns/commerce_reports_patterns.admin.inc

File

modules/patterns/commerce_reports_patterns.admin.inc, line 73

Code

function _commerce_reports_patterns_view($size) {
  $query = db_query("SELECT if_clause, then_clause, confidence FROM {commerce_reports_patterns} WHERE size = :size ORDER BY confidence DESC LIMIT 10", array(
    ':size' => $size,
  ));
  $rules = array();
  while ($result = $query
    ->fetchAssoc()) {
    $rules[] = array(
      theme('item_list', array(
        'items' => unserialize($result['if_clause']),
      )),
      theme('item_list', array(
        'items' => unserialize($result['then_clause']),
      )),
      round($result['confidence'] * 100) . '%',
    );
  }
  return array(
    '#theme' => 'table',
    '#rows' => $rules,
    '#header' => array(
      t('Antecedent'),
      t('Consequent'),
      t('Chance'),
    ),
  );
}