Skip to content

Commit d111c3a

Browse files
authored
Merge branch 'master' into program_distribution
2 parents 2a5e15e + 4ca6082 commit d111c3a

File tree

13 files changed

+1018
-6
lines changed

13 files changed

+1018
-6
lines changed

modules/manageheadbook/action_mysql.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
$sql_drop_module[] = 'DROP TABLE IF EXISTS ' . $db_config['prefix'] . '_' . $lang . '_' . $module_data . '_school_year;';
2222
$sql_drop_module[] = 'DROP TABLE IF EXISTS ' . $db_config['prefix'] . '_' . $lang . '_' . $module_data . '_week;';
2323
$sql_drop_module[] = 'DROP TABLE IF EXISTS ' . $db_config['prefix'] . '_' . $lang . '_' . $module_data . '_program;';
24+
$sql_drop_module[] = 'DROP TABLE IF EXISTS ' . $db_config['prefix'] . '_' . $lang . '_' . $module_data . '_headbook;';
2425

2526
$sql_create_module = $sql_drop_module;
2627

@@ -68,7 +69,32 @@
6869
thoi_gian_bat_dau int(11) NOT NULL,
6970
thoi_gian_ket_thuc int(11) NOT NULL,
7071
PRIMARY KEY (ma_nam_hoc)
71-
) ENGINE=MyISAM;";
72+
) ENGINE=MyISAM;";
73+
74+
75+
$sql_create_module[] = "CREATE TABLE " . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "_headbook (
76+
ma_so int(11) NOT NULL AUTO_INCREMENT,
77+
ma_tuan int(11) NOT NULL,
78+
ma_lop int(11) NOT NULL,
79+
ma_buoi int(1) NOT NULL,
80+
thu varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
81+
tiet int(1) NOT NULL,
82+
ma_mon int(11) NOT NULL,
83+
tiet_ppct int(11) NOT NULL,
84+
co_phep varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT 0,
85+
khong_phep varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT 0,
86+
di_muon varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT 0,
87+
ten_bai_hoc varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
88+
nhan_xet varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
89+
hoc_tap float NOT NULL,
90+
ky_luat float NOT NULL,
91+
ve_sinh float NOT NULL,
92+
tong_diem float NOT NULL,
93+
ki_ten varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
94+
ngay int(11) NOT NULL DEFAULT 0,
95+
PRIMARY KEY (ma_so)
96+
) ENGINE=MyISAM;";
97+
7298

7399
$sql_create_module[] = "CREATE TABLE " . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "_week (
74100
ma_tuan int(11) NOT NULL AUTO_INCREMENT,
@@ -81,6 +107,7 @@
81107
PRIMARY KEY (ma_tuan)
82108
) ENGINE=MyISAM;";
83109

110+
84111
$sql_create_module[] = "CREATE TABLE " . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "_program (
85112
ma_chuong_trinh int(11) NOT NULL AUTO_INCREMENT,
86113
ma_nam_hoc int(11) DEFAULT NULL,

modules/manageheadbook/admin.functions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
'schoolyearlist',
2727
'addyear',
2828
'addstudent',
29-
'program'
29+
'program',
30+
'headbook'
3031
];
3132

3233
define('NV_IS_FILE_ADMIN', true);

modules/manageheadbook/admin.menu.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@
2020

2121
$submenu['schoolyearlist'] = $lang_module['school_year_list'];
2222

23-
$submenu['program'] = $lang_module['program'];
23+
$submenu['program'] = $lang_module['program'];
24+
25+
$submenu['headbook'] = $lang_module['head_book'];
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
<?php
2+
3+
/**
4+
* Headbook Management System
5+
* @version 4.x
6+
* @author Group DNTU
7+
* @license GNU/GPL version 3
8+
* @see https://github.com/phapdev/manage_headbook.git The Manage headbook GitHub project
9+
*/
10+
11+
if (!defined('NV_IS_FILE_ADMIN')) {
12+
exit('Stop!!!');
13+
}
14+
15+
if (!defined('NV_IS_FILE_ADMIN')) {
16+
die('Stop!!!');
17+
}
18+
19+
20+
$studentid = $nv_Request->get_int('studentid', 'post,get');
21+
22+
$xtpl = new XTemplate('addstudent.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
23+
$xtpl->assign('LANG', $lang_module);
24+
$xtpl->assign('GLANG', $lang_global);
25+
$xtpl->assign('NV_UPLOADS_DIR', NV_UPLOADS_DIR);
26+
$xtpl->assign('UPLOAD_CURRENT', NV_UPLOADS_DIR . '/' . $module_upload . '/' . date("Y_m"));
27+
$xtpl->assign('module_name', $module_name);
28+
29+
if ($studentid) {
30+
// chinh sua
31+
$page_title = $lang_module['edit_student'];
32+
33+
$querystudent = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_student WHERE ma_hoc_sinh = ' . $studentid);
34+
35+
$student = $querystudent->fetch();
36+
37+
$arrayclass=[];
38+
// Gọi csdl để lấy dữ liệu
39+
$queryclass = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_class');
40+
41+
42+
// đổ dữ liệu
43+
$selectedclass = $student['ma_lop'];
44+
while ($row = $queryclass->fetch()) {
45+
$arrayclass[$row['ma_lop']] = $row;
46+
}
47+
48+
// hien thi du lieu class drop down
49+
if(!empty($arrayclass)) {
50+
foreach ($arrayclass as $value) {
51+
$value['key'] = $value['ma_lop'];
52+
$value['title'] = $value['ten_lop'];
53+
$value['selected'] = $selectedclass == $value['ma_lop'] ? "selected" : "";
54+
55+
$xtpl->assign('DATA_CLASS', $value);
56+
$xtpl->parse('addstudent.loopclass');
57+
}
58+
}
59+
// hien thi du lieu sex drop down
60+
$selectedsex = $student['gioi_tinh'];
61+
for ($i = 0; $i <= 1; ++$i) {
62+
$value = [
63+
'key' => $i,
64+
'title' => $lang_module['sex' . $i],
65+
'selected' => $selectedsex == $lang_module['sex' . $i] ? ' selected="selected"' : ''
66+
];
67+
$xtpl->assign('DATA_SEX', $value);
68+
$xtpl->parse('addstudent.loopsex');
69+
}
70+
71+
//hien thi du lieu form con lai
72+
if($student) {
73+
$student['ngay_sinh'] = nv_date('d/m/Y', $student['ngay_sinh']);
74+
$xtpl->assign('DATA', $student);
75+
}
76+
77+
$row = [];
78+
if ($nv_Request->isset_request('btnsubmit', 'post')) {
79+
80+
$row['ho_ten'] = nv_substr($nv_Request->get_title('ho_ten', 'post', ''), 0, 250);
81+
// truy vấn mã giáo viên
82+
83+
$ngay_sinh = $nv_Request->get_string('ngay_sinh', 'post', '');
84+
if (!empty($ngay_sinh) and !preg_match("/^([0-9]{1,2})\\/([0-9]{1,2})\/([0-9]{4})$/", $ngay_sinh))
85+
$ngay_sinh = "";
86+
if (empty($ngay_sinh)) {
87+
$row['ngay_sinh'] = 0;
88+
} else {
89+
$phour = date('H');
90+
$pmin = date('i');
91+
unset($m);
92+
preg_match("/^([0-9]{1,2})\\/([0-9]{1,2})\/([0-9]{4})$/", $ngay_sinh, $m);
93+
$row['ngay_sinh'] = mktime($phour, $pmin, 0, $m[2], $m[1], $m[3]);
94+
}
95+
96+
if(!empty($arrayclass)) {
97+
98+
foreach ($arrayclass as $value) {
99+
$row['ma_lop'] = $nv_Request->get_int('class_' . $value['ma_lop'], 'post', '');
100+
}
101+
for ($i = 0; $i <= 1; ++$i) {
102+
$row['gioi_tinh'] = nv_substr($nv_Request->get_title('sex_' . $i, 'post', ''), 0, 250);
103+
}
104+
$row['gioi_tinh'] = $lang_module['sex' . $row['gioi_tinh']];
105+
}
106+
107+
$row['so_tiet_nghi'] = $nv_Request->get_int('so_tiet_nghi', 'post', '');
108+
$row['anh_dai_dien'] = nv_substr($nv_Request->get_title('anh_dai_dien', 'post', ''), 0, 250);
109+
$row['dia_chi'] = nv_substr($nv_Request->get_title('dia_chi', 'post', ''), 0, 250);
110+
111+
//Xu ly luu du lieu
112+
$_sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_student SET ho_ten=:ho_ten, ngay_sinh=:ngay_sinh
113+
, gioi_tinh=:gioi_tinh, ma_lop=:ma_lop, dia_chi=:dia_chi, so_tiet_nghi=:so_tiet_nghi, anh_dai_dien=:anh_dai_dien WHERE ma_hoc_sinh=' . $studentid;
114+
$sth = $db->prepare($_sql);
115+
$sth->bindParam(':ho_ten', $row['ho_ten'], PDO::PARAM_STR);
116+
$sth->bindParam(':ngay_sinh', $row['ngay_sinh'], PDO::PARAM_STR);
117+
$sth->bindParam(':gioi_tinh', $row['gioi_tinh'], PDO::PARAM_STR);
118+
$sth->bindParam(':ma_lop', $row['ma_lop'], PDO::PARAM_STR);
119+
$sth->bindParam(':dia_chi', $row['dia_chi'], PDO::PARAM_STR);
120+
$sth->bindParam(':so_tiet_nghi', $row['so_tiet_nghi'], PDO::PARAM_STR);
121+
$sth->bindParam(':anh_dai_dien', $row['anh_dai_dien'], PDO::PARAM_STR);
122+
$exe = $sth->execute();
123+
124+
if ($exe) {
125+
nv_redirect_location(NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=student&classid=' . $row['ma_lop']);
126+
}
127+
}
128+
} else {
129+
// them moi
130+
$page_title = $lang_module['add_student'];
131+
132+
$arrayclass=[];
133+
// Gọi csdl để lấy dữ liệu
134+
$queryclass = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_class');
135+
136+
// đổ dữ liệu
137+
$i =0;
138+
$selectedclass;
139+
while ($row = $queryclass->fetch()) {
140+
$arrayclass[$row['ma_lop']] = $row;
141+
if($i ==0)
142+
{
143+
$selectedclass = $row['ma_lop'];
144+
}
145+
$i++;
146+
}
147+
148+
// hien thi du lieu class drop down
149+
if(!empty($arrayclass)) {
150+
foreach ($arrayclass as $value) {
151+
$value['key'] = $value['ma_lop'];
152+
$value['title'] = $value['ten_lop'];
153+
$value['selected'] = $selectedclass == $value['ma_lop'] ? "selected" : "";
154+
155+
$xtpl->assign('DATA_CLASS', $value);
156+
$xtpl->parse('addstudent.loopclass');
157+
}
158+
}
159+
// hien thi du lieu sex drop down
160+
$selectedsex = $lang_module['sex0'];
161+
for ($i = 0; $i <= 1; ++$i) {
162+
$value = [
163+
'key' => $i,
164+
'title' => $lang_module['sex' . $i],
165+
'selected' => $selectedsex == $lang_module['sex' . $i] ? ' selected="selected"' : ''
166+
];
167+
$xtpl->assign('DATA_SEX', $value);
168+
$xtpl->parse('addstudent.loopsex');
169+
}
170+
171+
$row = [];
172+
if ($nv_Request->isset_request('btnsubmit', 'post')) {
173+
174+
$row['ho_ten'] = nv_substr($nv_Request->get_title('ho_ten', 'post', ''), 0, 250);
175+
// truy vấn mã giáo viên
176+
177+
$ngay_sinh = $nv_Request->get_string('ngay_sinh', 'post', '');
178+
if (!empty($ngay_sinh) and !preg_match("/^([0-9]{1,2})\\/([0-9]{1,2})\/([0-9]{4})$/", $ngay_sinh))
179+
$ngay_sinh = "";
180+
if (empty($ngay_sinh)) {
181+
$row['ngay_sinh'] = 0;
182+
} else {
183+
$phour = date('H');
184+
$pmin = date('i');
185+
unset($m);
186+
preg_match("/^([0-9]{1,2})\\/([0-9]{1,2})\/([0-9]{4})$/", $ngay_sinh, $m);
187+
$row['ngay_sinh'] = mktime($phour, $pmin, 0, $m[2], $m[1], $m[3]);
188+
}
189+
190+
if(!empty($arrayclass)) {
191+
192+
foreach ($arrayclass as $value) {
193+
$row['ma_lop'] = $nv_Request->get_int('class_' . $value['ma_lop'], 'post', '');
194+
}
195+
for ($i = 0; $i <= 1; ++$i) {
196+
$row['gioi_tinh'] = nv_substr($nv_Request->get_title('sex_' . $i, 'post', ''), 0, 250);
197+
}
198+
$row['gioi_tinh'] = $lang_module['sex' . $row['gioi_tinh']];
199+
}
200+
201+
$row['so_tiet_nghi'] = $nv_Request->get_int('so_tiet_nghi', 'post', '');
202+
$row['anh_dai_dien'] = nv_substr($nv_Request->get_title('anh_dai_dien', 'post', ''), 0, 250);
203+
$row['dia_chi'] = nv_substr($nv_Request->get_title('dia_chi', 'post', ''), 0, 250);
204+
205+
//Xu ly luu du lieu
206+
$_sql = 'INSERT INTO ' . NV_PREFIXLANG . '_' . $module_data . '_student (
207+
ho_ten, ngay_sinh, gioi_tinh, ma_lop, dia_chi, so_tiet_nghi, anh_dai_dien) VALUES (
208+
:ho_ten, :ngay_sinh, :gioi_tinh, :ma_lop, :dia_chi, :so_tiet_nghi, :anh_dai_dien)';
209+
$sth = $db->prepare($_sql);
210+
$sth->bindParam(':ho_ten', $row['ho_ten'], PDO::PARAM_STR);
211+
$sth->bindParam(':ngay_sinh', $row['ngay_sinh'], PDO::PARAM_STR);
212+
$sth->bindParam(':gioi_tinh', $row['gioi_tinh'], PDO::PARAM_STR);
213+
$sth->bindParam(':ma_lop', $row['ma_lop'], PDO::PARAM_STR);
214+
$sth->bindParam(':dia_chi', $row['dia_chi'], PDO::PARAM_STR);
215+
$sth->bindParam(':so_tiet_nghi', $row['so_tiet_nghi'], PDO::PARAM_STR);
216+
$sth->bindParam(':anh_dai_dien', $row['anh_dai_dien'], PDO::PARAM_STR);
217+
$exe = $sth->execute();
218+
219+
if ($exe) {
220+
nv_redirect_location(NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=student&classid=' . $row['ma_lop']);
221+
}
222+
}
223+
224+
}
225+
226+
227+
$xtpl->parse('addstudent');
228+
$contents = $xtpl->text('addstudent');
229+
230+
231+
include NV_ROOTDIR . '/includes/header.php';
232+
echo nv_admin_theme($contents);
233+
include NV_ROOTDIR . '/includes/footer.php';

0 commit comments

Comments
 (0)