aboutsummaryrefslogtreecommitdiff
path: root/templates/dates/seminar_html_location.php
blob: 53cdfad26247fb47888d5dbfdf47c63f03be17f7 (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
96
97
98
99
100
<?
if (!isset($link)) $link = true;

// 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 ($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_short'] .' ('. $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[_('k.A.')][] = $without_location;
        endif;
    endforeach;
endforeach;


// condense irregular dates by room
if (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[_('k.A.')][]  = $date['tostring'];
    endif;
endforeach;

// now shrink the dates for each room/freetext and add them to the output
if (is_array($output_dates)) 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[_('k.A.')][] = implode('<br>', $dates);
    endif;
endforeach;
?>


<? if (!is_array($output) || count($output) === 0) : ?>
    <?= htmlReady($ort) ?: _("nicht angegeben") ?>
<? else: ?>
    <table class="default">
        <? foreach ($output as $room => $dates) : ?>
        <tr>
            <td style="vertical-align: top"><?= $room ?></td>
            <td>
                <? $dates = implode('<br>', $dates) ?>

                <? if (mb_strlen($dates) > 222 && !$disable_list_shrinking) : ?>
                    <?= mb_substr($dates, 0, 228) ?>
                    <div class="more-location-dates-infos" style="display:none">
                        <?= $dates ?>
                    </div>
                    <div>
                        <span class='more-location-digits'>...</span>
                        <a class="more-location-dates" style="cursor: pointer; margin-left: 3px">(mehr)</a>
                    </div>
                <? else : ?>
                    <?= $dates ?>
                <? endif ?>
            </td>
            <? endforeach ?>
    </table>
<? endif ?>