aboutsummaryrefslogtreecommitdiff
path: root/templates/dates/seminar_html_location.php
blob: 72a5fc33ba1d35095ea701998e56abdc35ef8107 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?
if (!isset($link)) $link = true;

$output = [];
$output_dates = [];

// condense regular dates by room
if (is_array($dates['regular']['turnus_data'])) foreach ($dates['regular']['turnus_data'] as $cycle) :
    $first_date   = sprintf(_("ab %s"), strftime('%x', $cycle['first_date']['date']));
    $cycle_output = $cycle['tostring'] . ' (' . $first_date . ')';
    if ($cycle['desc'])
        $cycle_output .= ', <i>' . htmlReady($cycle['desc']) . '</i>';

    if (!empty($show_room)) :
        $cycle_output .= $this->render_partial('dates/_seminar_rooms', ['assigned' => $cycle['assigned_rooms'],
                                                                        'freetext' => $cycle['freetext_rooms'],
                                                                        'link'     => $link
        ]);
    endif;

    if (is_array($cycle['assigned_rooms'])) foreach ($cycle['assigned_rooms'] as $room_id => $count) :
        $room_obj = Room::find($room_id);
        if ($link) {
            $output[
                '<a href="' . $room_obj->getActionLink('show') . '" data-dialog="1">'
                . htmlReady($room_obj->name)
                . '</a>'
                ][] = $cycle['tostring'] .' ('. $count .'x)';
        } else {
            $output[htmlReady($room_obj->name)][] = $cycle['tostring_short'] .' ('. $count .'x)';
        }
    endforeach;
    if (is_array($cycle['freetext_rooms'])) foreach ($cycle['freetext_rooms'] as $room => $count) :
        if ($room) :
            $output['(' . htmlReady($room) . ')'][] = $cycle['tostring'] . ' (' . $count . 'x)';
        elseif ($cycle['tostring']) :
            $without_location = $cycle['tostring'];
            if($count) :
                $without_location .=  '(' . $count . 'x)';
            endif;
            $output[_('Keine Raumangabe')][] = $without_location;
        endif;
    endforeach;
endforeach;


// condense irregular dates by room
if (isset($dates['irregular']) && is_array($dates['irregular'])) {
    foreach ($dates['irregular'] as $date) :
        if (isset($date['resource_id'])) :
            $output_dates[$date['resource_id']][] = $date;
        elseif (!empty($date['raum'])) :
            $output_dates[$date['raum']][] = $date;
        else :
            $output_dates[_('Keine Raumangabe')][]  = $date['tostring'];
        endif;
    endforeach;
}

// now shrink the dates for each room/freetext and add them to the output
foreach ($output_dates as $dates) :
    if (isset($dates[0]['resource_id'])) :
        $room_obj = Room::find($dates[0]['resource_id']);
        if ($link) {
            $output[
                '<a href="' . $room_obj->getActionLink('show') . '" data-dialog="1">'
                . htmlReady($room_obj->name)
                . '</a>'
                ][] = implode('<br>', shrink_dates($dates));
        } else {
            $output[htmlReady($room_obj->name)][] = implode('<br>', shrink_dates($dates));
        }
    elseif (isset($dates[0]['raum'])) :
        $output['(' . htmlReady($dates[0]['raum']) . ')'][] = implode('<br>', shrink_dates($dates));
    else :
        $output[_('Keine Raumangabe')][] = implode('<br>', $dates);
    endif;
endforeach;
?>


<? if (count($output) === 0) : ?>
    <?= empty($ort) ? _('Keine Raumangabe') : htmlReady($ort) ?>
<? else: ?>
    <dl>
        <? foreach ($output as $room_html => $dates) : ?>
            <dt><?= $room_html ?></dt>
            <? foreach ($dates as $date) : ?>
                <dd>
                    <?= $date ?>
                </dd>
            <? endforeach ?>
        <? endforeach ?>
    </dl>
<? endif ?>