function _webform_analysis_phone in Webform Phone Number 7.2
Same name and namespace in other branches
- 7 webform_phone.components.inc \_webform_analysis_phone()
Calculate and returns statistics about results for this component. This takes into account all submissions 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.
$sids: An optional array of submission IDs (sid). If supplied, the analysis will be limited to these sids.
$single: Boolean flag determining if the details about a single component are being shown. May be used to provided detailed information about a single component's analysis, such as showing "Other" options within a select list.
Return value
An array of data rows, each containing a statistic for this component's submissions.
File
- ./
webform_phone.components.inc, line 294 - Webform Component information for a phone number field type
Code
function _webform_analysis_phone($component, $sids = array(), $single = FALSE) {
// Generate the list of options and questions.
$query = db_select('webform_submitted_data', 'wsd', array(
'fetch' => PDO::FETCH_ASSOC,
))
->fields('wsd', array(
'data',
))
->condition('nid', $component['nid'])
->condition('cid', $component['cid']);
if (count($sids)) {
$query
->condition('sid', $sids, 'IN');
}
$non_blanks = 0;
$submissions = 0;
$result = $query
->execute();
foreach ($result as $data) {
if (drupal_strlen(trim($data['data'])) > 0) {
$non_blanks++;
}
$submissions++;
}
$rows[0] = array(
t('Left Blank'),
$submissions - $non_blanks,
);
$rows[1] = array(
t('User entered value'),
$non_blanks,
);
return $rows;
}