function calculate_leave_hours($start_date, $start_time, $end_date, $end_time, $work_profile) { $leave = array('from' => $start_date . ' ' . $start_time, 'to' => $end_date . ' ' . $end_time); $net_leave = 0; $work_plans = array(); for ($to_date = strtotime($leave['to']), $i = 0, $x = strtotime($leave['from']); $x <= $to_date; $i++, $x = strtotime($leave['from'] . "+{$i} minute")) { $day = date('Y-m-d H:i:s', $x); $week_type = even_or_odd($work_profile->profile_start_date, $work_profile->start_as, $day); $week_index = date('N', $x); if (isset($work_profile->time[$week_type][$week_index])) { $current_work_plan = $work_profile->time[$week_type][$week_index]; if (falls_in_interval($day, $current_work_plan) and strtotime($leave['from']) != strtotime($day)) { $net_leave++; } } } $net_leave = $net_leave / 60; return $net_leave; }
function download_list_template($array) { global $post; $count = 0; $output = ''; foreach ($array as $post) { setup_postdata($post); $output .= "<li class='wp-pubarch-download " . even_or_odd($count) . "'><a href='" . get_permalink($post->ID) . "'>" . $post->post_title . "</a></li>"; $count++; } wp_reset_postdata(); return $output; }