blob: 2465bd45319b4ae85add579ea7fab8422b38abd3 (
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
|
<?
// condense regular dates by room
if (is_array($dates['regular']['turnus_data'])) foreach ($dates['regular']['turnus_data'] as $cycle) :
if (is_array($cycle['assigned_rooms'])) foreach ($cycle['assigned_rooms'] as $room_id => $count) :
$room_object = Room::find($room_id);
$output[$room_object->name][] = $cycle['tostring_short'] .' ('. $count .'x)';
endforeach;
if (is_array($cycle['freetext_rooms'])) foreach ($cycle['freetext_rooms'] as $room => $count) :
if ($room) :
$output['('. $room .')'][] = $cycle['tostring_short'] .' ('. $count .'x)';
endif;
endforeach;
endforeach;
// condense irregular dates by room
if (is_array($dates['irregular'])) foreach ($dates['irregular'] as $date) :
if ($date['resource_id']) :
$output_dates[$date['resource_id']][] = $date;
elseif ($date['raum']) :
$output_dates[$date['raum']][] = $date;
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 ($dates[0]['resource_id']) :
$room_object = Room::find($dates[0]['resource_id']);
$output[$room_object->name][] = implode(", ", shrink_dates($dates));
elseif ($dates[0]['raum']) :
$output['('. $dates[0]['raum'] .')'][] = implode(", ", shrink_dates($dates));
endif;
endforeach;
if (!is_array($output) || count($output) === 0) :
echo _('nicht angegeben');
elseif (count($output) === 1) :
echo array_pop(array_keys($output));
else :
$pos = 1;
foreach ($output as $room => $dates) :
echo $room .': '. implode("\n", $dates) . (count($output) > $pos ? ', ' : '') . "\n";
$pos++;
endforeach;
endif;
|