-
Notifications
You must be signed in to change notification settings - Fork 0
/
single_section.php
77 lines (71 loc) · 3.32 KB
/
single_section.php
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
<?php
/*
* One row (section) of single consultation
*
* expected variables:
* - $one_user - one row of result of database selection from joined tables kon_signed & kon_user
* - $start_time - timestamp of starting time of consultation
* - $section_time - timestamp of duration of single section
* - $disabled - array of disabled sections
* - $occupied - array of occupied sections
* - $si - section index
* - $is_current_author - true in case this consultation is shown for its author
* - $section_edit_num - result of function kon_editable_section()
*
* sets variable:
* - $logged - is true if someone is logged in current section, false otherwise
* - $help_dis_var - stores DB time of currently processed section and eventually stores if section is disabled
*
*/
$help_dis_var = date(TIME_DB_FULL, timezone_adjustment($si * $section_time + $start_time));
if (!isset($current_user))
$current_user = get_logged_user();
if ($section_edit_num > 0 && $section_edit_num <= $si + 1)
$section_is_editable = true;
else
$section_is_editable = false;
if (!isset($is_current_author))
$is_current_author = false;
if ($one_user == null || $one_user['section'] != $help_dis_var) {
// noone is logged
$logged = false;
// check if section is disabled or occupied
if (in_array($help_dis_var, $disabled))
$help_dis_var = 'd';
else if (!array_key_exists(substr($help_dis_var, 0, -3), $occupied))
$help_dis_var = '';
?>
<div class="kon-row<?php
if ($help_dis_var == 'd')
echo ' disabled';
else if ($help_dis_var != '')
echo ' occupied';
if (!$section_is_editable) echo ' is_past'; ?>">
<div class="sel-checkbox"><label></label><input type="checkbox"></div>
<div class="cas"><?php echo date(TIME_S, timezone_adjustment($start_time + $section_time * $si)); ?></div>
<div class="jmeno"><?php if ($current_user && ($current_user['level'] < KANTOR_LEVEL || $current_user['stud_show'] > 0) && !$is_current_author && empty($help_dis_var) && $section_is_editable) echo '<span class="glyphicon glyphicon-copy"></span> ' . $GLOBALS['lang']->consultation->signIn ?></div>
<div class="pozn"><?php if ($help_dis_var && $help_dis_var != 'd') echo $occupied[substr($help_dis_var, 0, -3)]; ?></div>
<?php if ($help_dis_var == 'd') echo '<div class="dis_row_label">' . $GLOBALS['lang']->consultation->disabled . '</div>'; ?>
</div>
<?php
} else {
// section is equal, someone is logged
$logged = true;
if ($current_user['login'] == $one_user['login'])
$is_this_user = ' logged';
else
$is_this_user = '';
?>
<div class="kon-row user_present<?php echo $is_this_user; ?>" data-login="<?php echo $one_user['login']; ?>" data-email="<?php echo $one_user['email']; ?>">
<div class="sel-checkbox"><label></label><input type="checkbox"></div>
<div class="cas"><?php echo date(TIME_S, timezone_adjustment($start_time + $section_time * $si)); ?></div>
<?php if ($is_this_user != '' && $section_is_editable) { ?>
<div class="sign_out"><span class="glyphicon glyphicon-remove"></span></div>
<?php } ?>
<div class="jmeno"><?php echo $one_user['first_name'] . ' ' . $one_user['last_name']; ?></div>
<?php if ($is_this_user != '' && $section_is_editable) { ?>
<div class="edit_pozn"><span class="glyphicon glyphicon-pencil"></span></div>
<?php } ?>
<div class="pozn"><?php echo $one_user['note']; ?></div>
</div>
<?php } // else ?>