-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
223 lines (181 loc) · 7.95 KB
/
functions.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php
define("DEBUG", TRUE);
function cancel_button()
{
if (isset($_POST['cancel_button']))
{
header("Location: ".$_SERVER['SCRIPT_NAME']);
}
}
//---------show_modal_form()---------------
function show_modal_form($title, $field_array, $action_button, $warning='')
{
?>
<!-- Модальное окно -->
<div class="myoverlayer"><!-- теперь нельзя кликать под формой --></div>
<div id="modal_form" class="modal" tabindex="-1" role="dialog"><!-- modal hide -->
<div class="modal-header">
<div align="center">
<?php if($warning !='') echo '<div align="center" class="well well-small alert-error">'.$warning.'</div>';?>
<h4><?php echo $title; ?></h4>
</div>
</div>
<!-- body -->
<div class="modal-body" align="center">
<!-- Содержимое модального окна -->
<table border="0" cellspacing="3" cellpadding="3" class="mytable">
<?php
for ($i = 0; $i < count($field_array); ++$i)
{
echo '<tr>'; //начали строку
echo '<td>' .$field_array[$i][0]. '</td>';//строка-пояснение перед элементом формы
echo '<td>' .$field_array[$i][1]. '</td>';//тип инпута(прописывать руками!): <input ...>
echo '<td>'; //открыли столбик
if(trim($field_array[$i][2]) != '') //если строка-предупреждение не пустая, то
echo '<span class="label label-important">'.$field_array[$i][2].'</span>'; //выведем ее
echo '</td>'; //закрыли столбик
echo '</tr>'; //закончили строку
}
/* образец
<tr>
<td align="right">Дисциплина</td>
<td><input name="new_subject" type="text" size="50"></td>
</tr>
<tr>
<td align="right">Активность</td>
<td align="left"><input name="new_subject_activity" type="checkbox" checked></td>
</tr>
*/
?>
</table>
</div>
<!-- нижние кнопки модального окна добавления -->
<div class="modal-footer">
<?php
//не забудь прочистку данных формы сделать!
if($action_button == 'add')
echo '<input class="btn btn-primary" type="submit" name="add_button" id="save_button" value="Сохранить">';
if($action_button == 'update')
echo '<input class="btn btn-primary" type="submit" name="update_button" id="save_button" value="Сохранить">';
if($action_button == 'add_office')
echo '<input class="btn btn-primary" type="submit" name="add_office" id="save_button" value="Сохранить">';
if($action_button == 'add_physic')
echo '<input class="btn btn-primary" type="submit" name="add_physic" id="save_button" value="Сохранить">';
if($action_button == 'add_student')
echo '<input class="btn btn-primary" type="submit" name="add_student" id="save_button" value="Сохранить">';
if($action_button == 'add_group')
echo '<input class="btn btn-primary" type="submit" name="add_group" id="save_button" value="Сохранить">';
if($action_button == 'add_new_course_in_plan')
echo '<input class="btn btn-primary" type="submit" name="add_new_course_in_plan_button" value="Сохранить">';
if($action_button == 'add_new_office_people')
echo '<input class="btn btn-primary" type="submit" name="add_new_office_people_button" value="Сохранить">';
?>
<input class="btn" type="reset" name="reset_button" value="Очистить" id="reset_button">
<input class="btn" type="submit" name="cancel_button" value="Отменить">
</div>
</div>
<?php
}
?>
<?php
//генератор таблицы
function tablebodygenerator($link)
{
while ($row = mysql_fetch_row($link)) {
echo '<tr>';
for ($i = 0; $i < count($row); $i++)
{
if ($i == 0)
{
echo "<td><input type=\"checkbox\" name=\"checkbox$row[0]\"></td>";
echo "<td>$row[$i]</td>";
continue;
}
if ($i == count($row) - 1)
{
echo "<td>$row[$i]</td>";
echo "<td><input class=\"btn btn-primary\" type=\"submit\" value=\"...\" name=\"x-key-edit$row[0]\"><input type=\"hidden\" name=\"edit_flag\"></td>";
continue;
}
echo "<td>$row[$i]</td>";
}
echo '</tr>';
}
}
function tablebodygenerator2($link)
{
while ($row = mysql_fetch_row($link)) {
echo '<tr>';
for ($i = 0; $i < count($row); $i++)
{
if ($i == 0)
{
echo "<td><input type=\"checkbox\" name=\"checkbox$row[0]\"></td>";
echo "<td>$row[$i]</td>";
continue;
}
if ($i == count($row) - 1)
{
echo "<td>$row[$i]</td>";
echo "<td><input class=\"btn btn-primary\" type=\"submit\" value=\"...\" name=\"x-key-edit$row[0]\"><input type=\"hidden\" name=\"edit_flag\"></td>";
continue;
}
echo "<td><pre>$row[$i]</pre></td>";
}
echo '</tr>';
}
}
//логотип и название
function echo_product_name()
{
echo '<div align="center"><img src="/images/logo.png"></div>';
echo '<div align="center">'.PRODUCT_NAME.'</div>';
}
//футер
function footer()
{
echo '<br><div class="well well-small" align="right">'.PRODUCT_NAME.' '. date('Y').'</div>';
}
//Вывод сотрудника:
function whoareyou($coockiename)
{
$querystring = 'SELECT `lastname`,`firstname`,`patronymic`,`position` FROM `users` WHERE `login`=\'' . $coockiename . '\' LIMIT 1';
$usertitlequery = mysql_query($querystring);
$usertitlerow = mysql_fetch_row($usertitlequery);
echo "Вы: $usertitlerow[0] $usertitlerow[1] $usertitlerow[2], $usertitlerow[3]";
}
//меню
function left_menu()
{
echo ' <ul class="nav nav-pills nav-stacked">';
$menu=array();
$menu[0][0]='/desktop.php';
$menu[0][1]='Главная';
$menu[1][0]='/groups.php';
$menu[1][1]='Слушатели';
$menu[2][0]='/courses.php';
$menu[2][1]='Программы ДО';//курсы
$menu[3][0]='/teachers.php';
$menu[3][1]='Преподаватели';
$menu[4][0]='/subjects.php';
$menu[4][1]='Дисциплины';
$menu[5][0]='/reports.php';
$menu[5][1]='Отчеты';
$menu[6][0]='/orders.php';
$menu[6][1]='Заявки';
$menu[7][0]='/settings.php';
$menu[7][1]='Настройки';
$menu[8][0]='/logout.php';
$menu[8][1]='Выход';
for($i=0; $i<count($menu); ++$i)
if($menu[$i][0] == $_SERVER['SCRIPT_NAME'])
echo ' <li class="active"> <a>'.$menu[$i][1].'</a></li>';
else
echo ' <li> <a href="'.$menu[$i][0].'">'.$menu[$i][1].'</a></li>';
echo ' </ul>';
}
function df()//debug
{
//if (DEBUG) { echo'<pre>'; if($_SERVER['SERVER_NAME'] == "localhost") print_r($_POST); echo'</pre>'; }
}
?>