So, I’m trying to iterate through a foreach loop of all the entries to a gravity forms form. I have it sort of working in a template, but I need to put it in a class (creating a calendar and need to pull in entry information) and now it is just iterating over the last entry a bunch of times. Not sure where I went wrong:
$form_id = 9; //Enter the form ID here. The PTO form ID is 9;
$search_criteria = array();
$sorting = array();
$paging = array( 'offset' => 0, 'page_size' => 25 );
$total_count = 0;
$entry = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging, $total_count );
foreach ( $entry as $entries ) {
$entry_id = rgar( $entries, 'id' );
$fname = rgar( $entries, '13.3' );
$lname = rgar( $entries, '13.6' );
$pto_start = rgar( $entries, '1' );
$pto_end = rgar( $entries, '3' );
$e_location = rgar( $entries, '16' );
$pto_approval = rgar( $entries, '15' );
$supervisor_location = um_user('employee_location');
if ( ($supervisor_location === 'Elk City, OK') && ($e_location === 'Elk City, OK' ) ) {
if ( $pto_start != $this->currentDate ) {
return '<div id="'.$this->currentDate.'" class="day '.($cellNumber%7==1?' start ':($cellNumber%7==0?' end ':' ')).
($cellContent==null?'mask':'').'">'.$cellContent.'</div>';
}
elseif ( $pto_start == $this->currentDate ) {
return '<div id="'.$this->currentDate.'" class="day has-pto '.($cellNumber%7==1?' start ':($cellNumber%7==0?' end ':' ')).
($cellContent==null?'mask':'').'">'.$cellContent.'<div class="inner-pto-cal '.lcfirst($pto_approval).'">'.$fname. ' '.$lname.'</div></div>';
}
}
}