function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array())
{
    $first_of_month = gmmktime(0, 0, 0, $month, 1, $year);
    #remember that mktime will automatically correct if invalid dates are entered
    # for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
    # this provides a built in "rounding" feature to generate_calendar()
    $day_names = array();
    #generate all the day names according to the current locale
    for ($n = 0, $t = (3 + $first_day) * 86400; $n < 7; $n++, $t += 86400) {
        #January 4, 1970 was a Sunday
        $day_names[$n] = ucfirst(gmstrftime('%A', $t));
    }
    #%A means full textual day name
    list($month, $year, $month_name, $weekday) = explode(',', gmstrftime('%m,%Y,%B,%w', $first_of_month));
    $weekday = ($weekday + 7 - $first_day) % 7;
    #adjust for $first_day
    $title = strtoupper(htmlentities(ucfirst($month_name))) . '&nbsp;' . $year;
    #note that some locales don't capitalize month and day names
    #Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
    @(list($p, $pl) = each($pn));
    @(list($n, $nl) = each($pn));
    #previous and next links, if applicable
    if ($p) {
        $p = '<span class="calendar-prev">' . ($pl ? '<a href="' . htmlspecialchars($pl) . '">' . $p . '</a>' : $p) . '</span>&nbsp;';
    }
    if ($n) {
        $n = '&nbsp;<span class="calendar-next">' . ($nl ? '<a href="' . htmlspecialchars($nl) . '">' . $n . '</a>' : $n) . '</span>';
    }
    $calendar = '<table style="padding: 0px; margin: 0px auto;" class="calendar"><tr>';
    if ($day_name_length) {
        #if the day names should be shown ($day_name_length > 0)
        #if day_name_length is >3, the full name of the day will be printed
        foreach ($day_names as $d) {
            $calendar .= '<th abbr="' . htmlentities($d) . '">' . htmlentities($day_name_length < 4 ? substr($d, 0, $day_name_length) : $d) . '</th>';
        }
        $calendar .= "</tr>\n<tr>";
    }
    if ($weekday > 0) {
        $calendar .= '<td style="font-size: 8px" colspan="' . $weekday . '">&nbsp;</td>';
    }
    #initial 'empty' days
    for ($day = 1, $days_in_month = gmdate('t', $first_of_month); $day <= $days_in_month; $day++, $weekday++) {
        if ($weekday == 7) {
            $weekday = 0;
            #start a new week
            $calendar .= "</tr>\n<tr>";
        }
        $content = $day;
        $my_classes = "";
        $mysql_date = "{$year}-{$month}-{$day}";
        if (!is_working_day("{$year}-{$month}-{$day}")) {
            $days[$day][1] = "day_holiday";
            $days[$day][2] = "{$day}";
        }
        $agenda_eventt = get_event_date($mysql_date);
        foreach ($agenda_eventt as $agenda_event) {
            list($timestamp, $event) = explode("|", $agenda_event);
            $days[$day][1] = "agenda";
            $days[$day][2] = "{$day}";
            $days[$day][0] = "index.php?sec=agenda&sec2=operation/agenda/agenda&month={$month}&year={$year}";
            $days[$day][3] = $event;
        }
        $agenda_wo = get_wo_end_date($mysql_date);
        foreach ($agenda_wo as $agenda_woitem) {
            list($idwo, $woname) = explode("|", $agenda_woitem);
            $days[$day][1] = "workorder";
            $days[$day][2] = "{$day}";
            $days[$day][0] = "index.php?sec=projects&sec2=operation/workorders/wo&operation=view&id={$idwo}";
            $days[$day][3] = $woname;
        }
        $agenda_task = get_task_end_date($mysql_date);
        foreach ($agenda_task as $agenda_titem) {
            list($tname, $idt, $tend, $pname) = explode("|", $agenda_titem);
            $days[$day][1] = "task";
            $days[$day][2] = "{$day}";
            $days[$day][0] = "index.php?sec=projects&sec2=operation/projects/task_detail&id_task={$idt}&operation=view";
            $days[$day][3] = $pname . " / " . $tname;
        }
        $agenda_project = get_project_end_date($mysql_date);
        foreach ($agenda_project as $agenda_pitem) {
            list($pname, $idp, $pend) = explode("|", $agenda_pitem);
            $days[$day][1] = "project";
            $days[$day][2] = "{$day}";
            $days[$day][0] = "index.php?sec=projects&sec2=operation/projects/task&id_project={$idp}";
            $days[$day][3] = $pname;
        }
        $time = time();
        $today = date('j', $time);
        $today_m = date('n', $time);
        $today_style = "";
        if ($today == $day && $today_m == $month) {
            $today_style .= " style='border: 1px solid #FF9933; color: #FF9933;'";
        }
        if (isset($days[$day]) and is_array($days[$day])) {
            @(list($link, $classes, $content, $tooltip) = $days[$day]);
            $calendar .= '<td ' . $today_style . ' class="' . htmlspecialchars($classes) . '">';
            if ($link) {
                $calendar .= '<a title="' . $tooltip . '" href="' . htmlspecialchars($link) . '">' . $content . '</a></td>';
            } else {
                $calendar .= $content . '</td>';
            }
        } else {
            $calendar .= "<td {$today_style}>{$content}</td>";
        }
    }
    if ($weekday != 7) {
        $calendar .= '<td colspan="' . (7 - $weekday) . '">&nbsp;</td>';
    }
    #remaining "empty" days
    $calendar_outer = '<table style="padding: 0px; margin: 0px auto;" class="calendar_outer_orange"><tr>';
    $calendar_outer .= '<th colspan=7 class="calendar-month"><center><b>' . $title . '</b></center></th></tr><tr>';
    $calendar_outer .= '<td>' . $calendar . '</td></tr></table>';
    return $calendar_outer . "</tr>\n</table>\n";
}
Exemple #2
0
/**
 * Checks and notify user by mail if in current day there agenda items 
 */
function run_calendar_check()
{
    global $config;
    $now = date("Y-m-d");
    $events = get_event_date($now, 1, "_ANY_");
    foreach ($events as $event) {
        list($timestamp, $event_data, $user_event) = split("\\|", $event);
        $user = get_db_row("tusuario", "id_usuario", $user_event);
        $nombre = $user['nombre_real'];
        $email = $user['direccion'];
        $mail_description = "There is an Integria agenda event planned for today at ({$timestamp}): \n\n{$event_data}\n\n";
        integria_sendmail($email, "[" . $config["sitename"] . "] Calendar event for today ", $mail_description);
    }
}
        echo get_sponsors($resident_id, $i);
        echo '</div>';
    }
    echo '</div>';
}
if ($events) {
    echo '<div class="events list">';
    echo '<h3 class="title">Events &amp; Exhibitions</h3>';
    foreach ($events as $event) {
        $event_id = $event->ID;
        $event_name = get_the_title($event_id);
        $event_url = get_the_permalink($event_id);
        $event_status = get_event_status($event_id);
        echo '<a class="' . $event_status . ' event" href="' . $event_url . '">';
        echo '<div class="name">' . $event_name . '</div>';
        echo '<div class="date">' . get_event_date($event_id) . '</div>';
        echo '</a>';
    }
    echo '</div>';
}
?>
		</div>

		<?php 
if (have_rows('gallery')) {
    echo '<div class="gallery stack">';
    echo '<div class="cursor"></div>';
    echo '<div class="images slides">';
    while (have_rows('gallery')) {
        the_row();
        $media_type = get_sub_field('media_type', $home_id);
        echo site_url("events-category/{$cat_2->slug}");
        ?>
'>
							<?php 
        echo $cat_2->name;
        ?>
 <i class="fa fa-arrow-circle-right"></i>
						</a>
					</h3>

					<?php 
        foreach ($cat_2_posts as $post) {
            setup_postdata($post);
            $rows = get_field('events_dates');
            $event_dates = $rows[explode('_', $post->start_date_key)[2]];
            $time = get_event_date($event_dates['event_start_time'], $event_dates['event_end_time']);
            ?>

						<?php 
            $all_events = get_field('events_dates');
            ?>

						<div class="calendar-event">
							<a href="<?php 
            the_permalink();
            ?>
">
								<p class="calendar-event-date">
									<?php 
            echo $time;
            ?>
Exemple #5
0
function get_newsletter($multipart_boundary = null)
{
    require_once __DIR__ . '/../vendor/autoload.php';
    $loader = new Twig_Loader_Filesystem(get_template_directory() . '/inc/newsletter');
    $twig = new Twig_Environment($loader, array());
    $twig->addExtension(new Twig_Extensions_Extension_Intl());
    $twig->addExtension(new Twig_Extensions_Extension_Text());
    $twig->getExtension('Twig_Extension_Core')->setTimezone('Europe/Paris');
    if (have_rows('tb_newsletter_sections', 'option')) {
        $categories = [];
        $subcategories = [];
        $posts = [];
        while (have_rows('tb_newsletter_sections', 'option')) {
            the_row();
            foreach (get_sub_field('tb_newsletter_sections_items') as $post) {
                $category = get_post_top_category($post->ID);
                if ($category) {
                    $subcategory = get_sub_field('tb_newsletter_sections_title');
                    $categories[$category->term_id] = ['slug' => $category->slug, 'name' => $category->name, 'url' => get_category_link($category)];
                    $subcategories[$category->term_id][$subcategory->term_id] = $subcategory->name;
                    $posts[$category->term_id][$subcategory->term_id][] = ['post' => $post, 'author' => get_the_author_meta('display_name', $post->post_author), 'link' => get_post_permalink($post->ID), 'thumbnail' => wp_get_attachment_url(get_post_thumbnail_id($post->ID)), 'date_post' => format_post_date($post->post_date), 'event' => get_event_date($post->ID), 'place' => get_event_place($post->ID)];
                }
            }
        }
    }
    $params = ['intro' => get_field('tb_newsletter_introduction', 'option'), 'categories' => $categories, 'subcategories' => $subcategories, 'posts' => $posts, 'outro' => get_field('tb_newsletter_footer', 'option')];
    if ($multipart_boundary) {
        $params['boundary'] = $multipart_boundary;
        return $twig->render('newsletter-multipart.html', $params);
    } else {
        return $twig->render('newsletter-html.html', $params);
    }
}
function custom_get_events()
{
    global $post;
    $events = [];
    $events_raw = get_swra_events($_POST["category"], $_POST["month"]);
    foreach ($events_raw as $index => $post) {
        setup_postdata($post);
        $rows = get_field('events_dates');
        $event_dates = $rows[explode('_', $post->start_date_key)[2]];
        $events[$index]['link'] = get_permalink();
        $events[$index]['time'] = get_event_date($event_dates['event_start_time'], $event_dates['event_end_time']);
        $events[$index]['title'] = get_the_title();
        $events[$index]['excerpt'] = get_field('event_description') ? get_field('event_description') : '';
        $events[$index]['categories'] = get_event_categories(get_the_ID());
        $events[$index]['sold_out'] = $event_dates['sold_out'];
        wp_reset_postdata();
    }
    echo json_encode($events);
    wp_die();
}
Exemple #7
0
<?php

global $post;
setup_postdata($post);
$event_id = $post->ID;
$event_status = get_event_status($event_id);
$event_title = get_the_title($event_id);
$event_url = get_permalink();
$event_type = get_field('event_type');
$event_type_name = pretty($event_type);
$event_status = get_event_status($event_id);
$event_date_format = get_event_date($event_id);
$event_thumb = get_thumb($event_id, 'thumb');
$today = date('Ymd');
if (get_field('opening_reception', $event_id) >= $today) {
    $opening = new DateTime(get_field('opening_reception', $event_id));
    $opening = $opening->format('M d, Y');
    $opening_hours = get_field('opening_reception_hours', $event_id);
    if ($opening_hours) {
        $opening .= ', ' . $opening_hours;
    }
}
echo '<div class="event item shelf-item border-bottom ' . $event_status . '" data-id="' . $event_id . '">';
echo '<div class="inner">';
echo '<a class="wrap value date" href="' . $event_url . '">';
echo '<h2 class="link name title">' . $event_title . '</h2>';
echo '<div class="image">';
echo '<img src="' . $event_thumb . '"/>';
echo '</div>';
if ($opening) {
    echo '<div class="value date link">Opening Reception:&nbsp;' . $opening . '</div>';
Exemple #8
0
<?php

global $post;
$title = $post->post_title;
$slug = $post->post_name;
$id = $post->ID;
$permalink = get_the_permalink($id);
$description = get_field('description', $id);
$footnote = get_field('footnote', $id);
$event_type = get_field('event_type', $id);
$event_type_name = pretty($event_type);
$date = get_event_date($id);
$event_classes = 'event single ' . get_event_status($id);
$page_columns = get_field('page_columns', $id);
$contributors = get_field('contributors', $id);
$credits = get_field('credits', $id);
$attachments = get_field('attachments', $id);
$rsvp = get_field('rsvp', $id);
$venue = get_field('venue_name', $id);
$location = get_field('venue_location', $id);
$time = get_field('time', $id);
$open_hours = get_field('open_hours', $id);
$opening_reception = new DateTime(get_field('opening_reception', $id));
$opening_reception = $opening_reception->format('M d, Y');
$opening_reception_hours = get_field('opening_reception_hours', $id);
$logos = get_field('logos', $id);
if ($page_columns) {
    $event_classes .= ' ' . $page_columns;
} else {
    if (have_rows('gallery')) {
        $event_classes .= ' cols_2';