You are here

function _webform_analysis_time in Webform 7.3

Same name and namespace in other branches
  1. 6.3 components/time.inc \_webform_analysis_time()
  2. 7.4 components/time.inc \_webform_analysis_time()

Implements _webform_analysis_component().

File

components/time.inc, line 332
Webform module time component.

Code

function _webform_analysis_time($component, $sids = array()) {
  $query = db_select('webform_submitted_data', 'wsd', array(
    'fetch' => PDO::FETCH_ASSOC,
  ))
    ->fields('wsd', array(
    'no',
    'data',
  ))
    ->condition('nid', $component['nid'])
    ->condition('cid', $component['cid'])
    ->orderBy('sid');
  if (count($sids)) {
    $query
      ->condition('sid', $sids, 'IN');
  }
  $result = $query
    ->execute();
  $times = array();
  $submissions = 0;
  foreach ($result as $row) {
    $submissions++;
    if ($row['data']) {
      $times[] = webform_date_array($row['data']);
    }
  }

  // Display stats.
  $nonblanks = count($times);
  $rows[0] = array(
    t('Left Blank'),
    $submissions - $nonblanks,
  );
  $rows[1] = array(
    t('User entered value'),
    $nonblanks,
  );
  return $rows;
}