Skip to content

Commit 4971af5

Browse files
committed
show and delete class
1 parent 3d56a5f commit 4971af5

File tree

8 files changed

+190
-5
lines changed

8 files changed

+190
-5
lines changed

modules/manageheadbook/action_mysql.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,16 @@
2424
ten_lop varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
2525
khoi int(2) NOT NULL,
2626
PRIMARY KEY (ma_lop)
27-
) ENGINE=MyISAM;";
27+
) ENGINE=MyISAM;";
28+
29+
$sql_create_module[] = "CREATE TABLE " . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "_student (
30+
ma_hoc_sinh int(11) NOT NULL AUTO_INCREMENT,
31+
ma_lop int(11) DEFAULT NULL,
32+
ho_ten varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
33+
ngay_sinh int(11) NOT NULL,
34+
gioi_tinh varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
35+
dia_chi varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
36+
so_tiet_nghi float(11) NOT NULL DEFAULT 0,
37+
anh_dai_dien varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
38+
PRIMARY KEY (ma_hoc_sinh)
39+
) ENGINE=MyISAM;";

modules/manageheadbook/admin.functions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
'main',
1717
'addclass',
1818
'class',
19-
'delclass'
19+
'delclass',
20+
'student',
21+
// 'addstudent',
22+
'delstudent'
2023
];
2124

2225
define('NV_IS_FILE_ADMIN', true);

modules/manageheadbook/admin/class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@
3232
if(!empty($arr_class)) {
3333
foreach ($arr_class as $value) {
3434
$value['url_edit'] = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=addclass&id=' . $value['ma_lop'];
35-
$value['url_studentlist'] = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE .'=studentlist&classlistid=' . $value['ma_lop'] ;
35+
$value['url_studentlist'] = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE .'=student&classid=' . $value['ma_lop'] ;
3636
$value['checksess'] = md5($value['ma_lop'] . NV_CHECK_SESSION);
3737

3838
// gọi đến csdl để lấy tên giáo viên
3939
$queryteacher = $db->query('SELECT * FROM nv4_users WHERE userid = ' . $value['ma_gvcn'] );
4040
$rowteacher = $queryteacher->fetch();
4141

4242
$value['ten_gvcn'] = $rowteacher['last_name'] . ' ' . $rowteacher['first_name'];
43-
43+
4444
$xtpl->assign('DATA_CLASS', $value);
4545
$xtpl->parse('class.loop');
4646
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
<?php
3+
4+
/**
5+
* Headbook Management System
6+
* @version 4.x
7+
* @author Group DNTU
8+
* @license GNU/GPL version 3
9+
* @see https://github.com/phapdev/manage_headbook.git The Manage headbook GitHub project
10+
*/
11+
12+
if (! defined('NV_IS_FILE_ADMIN')) {
13+
die('Stop!!!');
14+
}
15+
16+
if (! defined('NV_IS_AJAX')) {
17+
die('Wrong URL');
18+
}
19+
20+
$checkss = $nv_Request->get_string('checkss', 'post');
21+
$ma_hoc_sinh = $nv_Request->get_int('ma_hoc_sinh', 'post', 0);
22+
$contents = '';
23+
24+
if ($ma_hoc_sinh > 0) {
25+
nv_insert_logs(NV_LANG_DATA, $module_name, 'log_delstudent', "ma_hoc_sinh " . $ma_hoc_sinh, $admin_info['userid']);
26+
$sql ='DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . '_student WHERE ma_hoc_sinh =' . $ma_hoc_sinh;
27+
$success = $db->exec($sql);
28+
if ($success) {
29+
$contents = "OK_" . $ma_hoc_sinh;
30+
} else {
31+
$contents = "ERR_" . $lang_module['student_delete_unsuccess'];
32+
}
33+
}
34+
35+
include NV_ROOTDIR . '/includes/header.php';
36+
echo $contents;
37+
include NV_ROOTDIR . '/includes/footer.php';
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
12+
if (!defined('NV_IS_FILE_ADMIN')) {
13+
die('Stop!!!');
14+
}
15+
16+
$page_title = $lang_module['student_list'];
17+
18+
$classid = $nv_Request->get_int('classid', 'post,get');
19+
20+
$page_addstudent = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=addstudent';
21+
$array = [];
22+
23+
// Gọi csdl để lấy dữ liệu
24+
$querystudent = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_student WHERE ma_lop = '. $classid .' ORDER BY ho_ten ASC');
25+
// đổ dữ liệu
26+
while ($row = $querystudent->fetch()) {
27+
$array[$row['ma_hoc_sinh']] = $row;
28+
}
29+
30+
$queryclass = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_class WHERE ma_lop = ' . $classid);
31+
$dataclass = $queryclass->fetch();
32+
33+
$xtpl = new XTemplate('student.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
34+
$xtpl->assign('LANG', $lang_module);
35+
$xtpl->assign('GLANG', $lang_global);
36+
$xtpl->assign('PAGE_ADDSTUDENT', $page_addstudent);
37+
38+
39+
// hien thi du lieu
40+
if(!empty($array)) {
41+
$i = 1;
42+
foreach ($array as $value) {
43+
$value['checksess'] = md5($value['ma_hoc_sinh'] . NV_CHECK_SESSION);
44+
$value['stt'] = $i++;
45+
$value['ten_lop'] = $dataclass['ten_lop'];
46+
$value['ngay_sinh'] = nv_date('d/m/Y', $value['ngay_sinh']);
47+
$value['url_edit'] = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=addstudent&studentid=' . $value['ma_hoc_sinh'];
48+
$xtpl->assign('DATA_STUDENT', $value);
49+
$xtpl->parse('student.loop');
50+
}
51+
}
52+
53+
54+
$xtpl->parse('student');
55+
$contents = $xtpl->text('student');
56+
57+
include NV_ROOTDIR . '/includes/header.php';
58+
echo nv_admin_theme($contents);
59+
include NV_ROOTDIR . '/includes/footer.php';

modules/manageheadbook/language/admin_vi.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,21 @@
3131
$lang_module['class_delete_unsuccess'] = 'Xóa lớp không thành công!';
3232
$lang_module['choose_teacher'] = 'Chọn giáo viên chủ nhiệm';
3333

34+
$lang_module['student_list'] = 'Danh sách học sinh';
35+
36+
$lang_module['stt'] = 'Số thứ tự';
37+
$lang_module['full_name'] = 'Họ tên';
38+
$lang_module['birthday'] = 'Ngày sinh';
39+
$lang_module['sex'] = 'Giới tính';
40+
$lang_module['class'] = 'Lớp';
41+
$lang_module['number_absent'] = 'Số tiết vắng';
42+
$lang_module['avatar'] = 'Ảnh đại diện';
43+
$lang_module['address'] = 'Địa chỉ';
44+
45+
$lang_module['add_student'] = 'Thêm mới học sinh';
46+
47+
48+
3449

35-
// $lang_module['class'] = '';
3650

3751

themes/admin_default/js/manageheadbook.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,21 @@ function nv_del_class(ma_lop, checkss) {
1313
}
1414
return false;
1515
}
16+
17+
function nv_del_student(ma_hoc_sinh, ma_lop, checkss) {
18+
if (confirm(nv_is_del_confirm[0])) {
19+
$.post(script_name + '?' + nv_lang_variable + '=' + nv_lang_data + '&' + nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=delstudent&nocache=' + new Date().getTime(), 'ma_hoc_sinh=' + ma_hoc_sinh + '&checkss=' + checkss, function(res) {
20+
var r_split = res.split("_");
21+
if (r_split[0] == 'OK') {
22+
window.location.href = script_name + '?' + nv_lang_variable + '=' + nv_lang_data + '&' + nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=studentlist&classlistid=' + ma_lop;
23+
} else if (r_split[0] == 'ERR') {
24+
alert(r_split[1]);
25+
} else {
26+
alert(nv_is_del_confirm[2]);
27+
}
28+
});
29+
}
30+
return false;
31+
}
32+
33+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!-- BEGIN: student -->
2+
<div class="table-responsive">
3+
<table class="table table-striped table-bordered table-hover">
4+
<thead>
5+
<tr>
6+
<th class="w100">{LANG.stt}</th>
7+
<th>{LANG.full_name}</th>
8+
<th class="w100">{LANG.birthday}</th>
9+
<th class="w100">{LANG.sex}</th>
10+
<th class="w100">{LANG.class}</th>
11+
<th class="w200">{LANG.address}</th>
12+
<th class="w100">{LANG.number_absent}</th>
13+
<th class="w150">{LANG.avatar}</th>
14+
<th class="w150 text-center">{LANG.func}</th>
15+
</tr>
16+
</thead>
17+
<tbody>
18+
<!-- BEGIN: loop -->
19+
<tr>
20+
<td>{DATA_STUDENT.stt}</td>
21+
<td class="text-center">{DATA_STUDENT.ho_ten}</td>
22+
<td>{DATA_STUDENT.ngay_sinh}</td>
23+
<td>{DATA_STUDENT.gioi_tinh}</td>
24+
<td>{DATA_STUDENT.ten_lop}</td>
25+
<td>{DATA_STUDENT.dia_chi}</td>
26+
<td>{DATA_STUDENT.so_tiet_nghi}</td>
27+
<td class="text-center">
28+
<img src="{DATA_STUDENT.anh_dai_dien}" class="content-image" height="100" width="75">
29+
</td>
30+
<td class="text-center">
31+
<a href="{DATA_STUDENT.url_edit}" class="btn btn-default btn-xs"><i class="fa fa-fw fa-edit"></i>{GLANG.edit}</a>
32+
<a class="btn btn-danger btn-xs" href="javascript:void(0);" onclick="nv_del_student({DATA_STUDENT.ma_hoc_sinh}, {DATA_STUDENT.ma_lop}, '{DATA_STUDENT.checksess}')"><i class="fa fa-fw fa-trash"></i>{GLANG.delete}</a>
33+
</td>
34+
</tr>
35+
<!-- END: loop -->
36+
</tbody>
37+
</table>
38+
<div class="form-group">
39+
<a href="{PAGE_ADDSTUDENT}" class="btn btn-primary">{LANG.add_student}</a>
40+
</div>
41+
</div>
42+
<!-- END: student -->

0 commit comments

Comments
 (0)