Bekijk de beoordelingen

Hier ziet u hoe onze klanten over ons denken

[insert_php]
$form_id = 5;
$subs = Ninja_Forms()->subs()->get( array(‘form_id’ => $form_id ));
$fields = ninja_forms_get_fields_by_form_id($form_id);

$star_fields = array();

foreach ( $fields as $field ) {
if($field[‘type’] == ‘_rating’) $star_fields[$field[‘id’]] = array(‘type’ => ‘star’, ‘label’ => $field[‘data’][‘label’]);
if($field[‘type’] == ‘_desc’ && $field[‘id’] != “10” && $field[‘id’] != “31” ) $star_fields[$field[‘id’]] = array(‘type’ => ‘heading’, ‘label’ => $field[‘data’][‘default_value’]);

}

$all_subs = array();

foreach ( $subs as $sub ) {
$form_id = $sub->form_id;
$user_id = $sub->user_id;
// Returns an array of [field_id] => [user_value] pairs
$all_fields = $sub->get_all_fields();

$this_result = array();
foreach($star_fields as $fid => $field) {
if($field[‘type’] == ‘star’) {
if(!isset($star_fields[$fid][‘subs’])) {
$star_fields[$fid][‘subs’] = array(‘total_rating’ => 0, ‘number_of_ratings’ => 0);
}
if($all_fields[$fid] != NULL) {
$star_fields[$fid][‘subs’][‘number_of_ratings’] += 1;
$star_fields[$fid][‘subs’][‘total_rating’] += (int) $all_fields[$fid];
}
}
}
}
foreach($star_fields as $item) {
if($item[‘type’] == ‘heading’) echo ‘

‘ . $item[‘label’] . ‘

‘;
elseif($item[‘type’] == ‘star’) {

if($item[‘subs’][‘number_of_ratings’] > 0) {
echo ‘

‘;
$rating = round( ($item[‘subs’][‘total_rating’] / $item[‘subs’][‘number_of_ratings’]) * 10, 2);
echo “

“. $item[‘label’] . “

“;
echo ‘

(‘. round($rating/10,1).’ / 10)

‘;

} else {
echo ‘

Er zijn nog geen antwoorden voor “‘.$item[‘label’].'”

‘;
}
}
}
echo ‘

Toelichtingen

‘;
foreach ( $subs as $sub ) {
$all_fields = $sub->get_all_fields();

$name = $all_fields[7] . ‘ ‘ . $all_fields[9];
$message = $all_fields[33];
if(trim($message) != “Uw toelichting”) {
echo “

$name
“;

if(gettype( $all_fields[32]) == ‘string’) {
echo “Betreft: “.$all_fields[32].”
“;
}
elseif(isset($all_fields[32]) && count($all_fields[32])) {
echo “Betreft: “;
echo join(‘, ‘, $all_fields[32]);
echo ‘

‘;
}
echo ” $message

“;
}
}
[/insert_php]