function _webform_analysis_rows_time in Webform 5
Same name and namespace in other branches
- 5.2 components/time.inc \_webform_analysis_rows_time()
- 6.2 components/time.inc \_webform_analysis_rows_time()
Calculate and returns statistics about results for this component from all submission to this webform. The output of this function will be displayed under the "results" tab then "analysis".
Parameters
$component: An array of information describing the component, directly correlating to the webform_component database schema.
Return value
An array of data rows, each containing a statistic for this component's submissions.
File
- components/
time.inc, line 221
Code
function _webform_analysis_rows_time($component) {
$query = 'SELECT no,data ' . ' FROM {webform_submitted_data} ' . ' WHERE nid = %d ' . ' AND cid = %d ' . ' ORDER BY sid,no ASC ';
$result = db_query($query, $component['nid'], $component['cid']);
// build an array of timestamps from entered values.
$timestamps = array();
$submissions = 1;
while ($row = db_fetch_array($result)) {
if ($row['no'] == '0') {
$submissions++;
$hour = $row['data'];
if ($row = db_fetch_array($result)) {
if ($row['no'] == '1') {
$minute = $row['data'];
if ($row = db_fetch_array($result)) {
if ($row['no'] == '2') {
$ampm = $row['data'];
// Build the full timestamp.
if (strlen($hour) > 0 && strlen($minute) > 0) {
$timestamps[] = strtotime($hour . ":" . $minute . ' ' . $ampm);
}
}
else {
// Build military time.
$timestamps[] = strtotime($hour . ":" . $minute);
}
}
}
}
}
}
// Display stats.
// TODO: display date statistics in javascript tabs.
$nonblanks = count($timestamps);
$rows[0] = array(
t('Left Blank'),
$submissions - $nonblanks,
);
$rows[1] = array(
t('User entered value'),
$nonblanks,
);
return $rows;
}