Skip to content

Commit f2c7ddd

Browse files
committed
create school year and week
1 parent 6bbacb3 commit f2c7ddd

File tree

8 files changed

+289
-3
lines changed

8 files changed

+289
-3
lines changed

modules/manageheadbook/action_mysql.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
$sql_drop_module[] = 'DROP TABLE IF EXISTS ' . $db_config['prefix'] . '_' . $lang . '_' . $module_data . '_class;';
1919
$sql_drop_module[] = 'DROP TABLE IF EXISTS ' . $db_config['prefix'] . '_' . $lang . '_' . $module_data . '_subject;';
2020
$sql_drop_module[] = 'DROP TABLE IF EXISTS ' . $db_config['prefix'] . '_' . $lang . '_' . $module_data . '_student;';
21+
$sql_drop_module[] = 'DROP TABLE IF EXISTS ' . $db_config['prefix'] . '_' . $lang . '_' . $module_data . '_school_year;';
22+
$sql_drop_module[] = 'DROP TABLE IF EXISTS ' . $db_config['prefix'] . '_' . $lang . '_' . $module_data . '_week;';
2123

2224
$sql_create_module = $sql_drop_module;
2325

@@ -57,3 +59,23 @@
5759
ten_mon_hoc varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
5860
PRIMARY KEY (ma_mon_hoc)
5961
) ENGINE=MyISAM";
62+
63+
$sql_create_module[] = "CREATE TABLE " . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "_school_year (
64+
ma_nam_hoc int(11) NOT NULL AUTO_INCREMENT,
65+
tu_nam int(11) NOT NULL,
66+
den_nam int(11) NOT NULL,
67+
thoi_gian_bat_dau int(11) NOT NULL,
68+
thoi_gian_ket_thuc int(11) NOT NULL,
69+
PRIMARY KEY (ma_nam_hoc)
70+
) ENGINE=MyISAM;";
71+
72+
$sql_create_module[] = "CREATE TABLE " . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "_week (
73+
ma_tuan int(11) NOT NULL AUTO_INCREMENT,
74+
ma_nam_hoc int(11) NOT NULL,
75+
tu_ngay int(11) NOT NULL,
76+
den_ngay int(11) NOT NULL,
77+
ten_tuan varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
78+
mo_ta varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
79+
trang_thai tinyint(1) NOT NULL DEFAULT 1,
80+
PRIMARY KEY (ma_tuan)
81+
) ENGINE=MyISAM;";

modules/manageheadbook/admin.functions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
'delstudent',
2323
'subject',
2424
'addsubject',
25-
'delsubject'
25+
'delsubject',
26+
'schoolyearlist',
27+
'addyear'
2628
// 'addstudent',
2729
];
2830

modules/manageheadbook/admin.menu.php

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

1717
$submenu['class'] = $lang_module['class'];
1818

19-
$submenu['subject'] = $lang_module['subject'];
19+
$submenu['subject'] = $lang_module['subject'];
20+
21+
$submenu['schoolyearlist'] = $lang_module['school_year_list'];
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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+
die('Stop!!!');
13+
}
14+
15+
16+
// them nam hoc moi
17+
$page_title = $lang_module['add_year_title'];
18+
$row = [];
19+
20+
if ($nv_Request->isset_request('btnsubmit', 'post')) {
21+
22+
$thoi_gian_bat_dau = $nv_Request->get_string('thoi_gian_bat_dau', 'post', '');
23+
if (!empty($thoi_gian_bat_dau) and !preg_match("/^([0-9]{1,2})\\/([0-9]{1,2})\/([0-9]{4})$/", $thoi_gian_bat_dau))
24+
$thoi_gian_bat_dau = "";
25+
if (empty($thoi_gian_bat_dau)) {
26+
$row['thoi_gian_bat_dau'] = 0;
27+
} else {
28+
$phour = date('H');
29+
$pmin = date('i');
30+
unset($m);
31+
preg_match("/^([0-9]{1,2})\\/([0-9]{1,2})\/([0-9]{4})$/", $thoi_gian_bat_dau, $m);
32+
$row['thoi_gian_bat_dau'] = mktime($phour, $pmin, 0, $m[2], $m[1], $m[3]);
33+
}
34+
35+
$thoi_gian_ket_thuc = $nv_Request->get_string('thoi_gian_ket_thuc', 'post', '');
36+
if (!empty($thoi_gian_ket_thuc) and !preg_match("/^([0-9]{1,2})\\/([0-9]{1,2})\/([0-9]{4})$/", $thoi_gian_ket_thuc))
37+
$thoi_gian_ket_thuc = "";
38+
if (empty($thoi_gian_ket_thuc)) {
39+
$row['thoi_gian_ket_thuc'] = 0;
40+
} else {
41+
$phour = date('H');
42+
$pmin = date('i');
43+
unset($m);
44+
preg_match("/^([0-9]{1,2})\\/([0-9]{1,2})\/([0-9]{4})$/", $thoi_gian_ket_thuc, $m);
45+
$row['thoi_gian_ket_thuc'] = mktime($phour, $pmin, 0, $m[2], $m[1], $m[3]);
46+
}
47+
48+
$row['tu_nam'] = $nv_Request->get_int('tu_nam', 'post', '');
49+
$row['den_nam'] = $nv_Request->get_int('den_nam', 'post', '');
50+
51+
//Xu ly luu du lieu
52+
$_sql = 'INSERT INTO ' . NV_PREFIXLANG . '_' . $module_data . '_school_year (
53+
tu_nam, den_nam, thoi_gian_bat_dau, thoi_gian_ket_thuc) VALUES (
54+
:tu_nam, :den_nam, :thoi_gian_bat_dau, :thoi_gian_ket_thuc)';
55+
$sth = $db->prepare($_sql);
56+
$sth->bindParam(':tu_nam', $row['tu_nam'], PDO::PARAM_STR);
57+
$sth->bindParam(':den_nam', $row['den_nam'], PDO::PARAM_STR);
58+
$sth->bindParam(':thoi_gian_bat_dau', $row['thoi_gian_bat_dau'], PDO::PARAM_STR);
59+
$sth->bindParam(':thoi_gian_ket_thuc', $row['thoi_gian_ket_thuc'], PDO::PARAM_STR);
60+
$sth->execute();
61+
62+
// tiep tuc goi thang moi them vao de lay id
63+
$query = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_school_year WHERE tu_nam='. $row['tu_nam'] .' AND den_nam=' . $row['den_nam'].' AND thoi_gian_bat_dau=' . $row['thoi_gian_bat_dau'] .' AND thoi_gian_ket_thuc=' . $row['thoi_gian_ket_thuc']);
64+
65+
// đổ dữ liệu
66+
$dataschoolyear = $query->fetch();
67+
68+
69+
$time_per_week = 86400 * 7;
70+
$time_per_1day = 86400;
71+
72+
$time_from_day = $row['thoi_gian_bat_dau'] ;
73+
$time_to_day = $row['thoi_gian_ket_thuc'];
74+
75+
$sum_time = 0;
76+
77+
if (date('w',$time_from_day) != 1) {
78+
for($i = 0; date('w',$time_from_day) != 1; ++$i) {
79+
$time_from_day -= $time_per_1day;
80+
}
81+
}
82+
83+
$_sqlweek = "INSERT INTO " . NV_PREFIXLANG . "_" . $module_data . "_week (ma_nam_hoc, tu_ngay, den_ngay, ten_tuan) VALUES";
84+
for ($i = 0; $sum_time <= $time_to_day; $i++) {
85+
$sum_time = $time_from_day + $i * $time_per_week + $time_per_week - $time_per_1day;
86+
$tu_ngay = $time_from_day + $i * $time_per_week;
87+
$den_ngay = $time_from_day + $i * $time_per_week + $time_per_week - $time_per_1day;
88+
$ten_tuan ='Tuần ' . ($i+1);
89+
if ($sum_time > $time_to_day)
90+
$_sqlweek = $_sqlweek . " (". $dataschoolyear['ma_nam_hoc'].", ".$tu_ngay.", ".$den_ngay.", '".$ten_tuan."');";
91+
else
92+
$_sqlweek = $_sqlweek . " (". $dataschoolyear['ma_nam_hoc'].", ".$tu_ngay.", ".$den_ngay.", '".$ten_tuan."'),";
93+
}
94+
// die($_sqlweek);
95+
$db->query($_sqlweek);
96+
97+
98+
if ($db) {
99+
nv_redirect_location(NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=schoolyearlist');
100+
}
101+
}
102+
103+
$xtpl = new XTemplate('addyear.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
104+
$xtpl->assign('LANG', $lang_module);
105+
$xtpl->assign('GLANG', $lang_global);
106+
107+
108+
109+
110+
$xtpl->parse('addyear');
111+
$contents = $xtpl->text('addyear');
112+
113+
include NV_ROOTDIR . '/includes/header.php';
114+
echo nv_admin_theme($contents);
115+
include NV_ROOTDIR . '/includes/footer.php';
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Headbook Management System
4+
* @version 4.x
5+
* @author Group DNTU
6+
* @license GNU/GPL version 3
7+
* @see https://github.com/phapdev/manage_headbook.git The Manage headbook GitHub project
8+
*/
9+
if (!defined('NV_IS_FILE_ADMIN')) {
10+
die('Stop!!!');
11+
}
12+
13+
$page_title = $lang_module['school_year_list'];
14+
$page_addschoolyear = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=addyear';
15+
$page_studentlist = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=studentlist';
16+
$array = [];
17+
18+
//get data
19+
$query = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_school_year ORDER BY thoi_gian_bat_dau ASC');
20+
21+
while ($row = $query->fetch()) {
22+
$array[$row['ma_nam_hoc']] = $row;
23+
}
24+
25+
$xtpl = new XTemplate('schoolyearlist.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
26+
$xtpl->assign('LANG', $lang_module);
27+
$xtpl->assign('GLANG', $lang_global);
28+
$xtpl->assign('PAGE_ADDSCHOOLYEAR', $page_addschoolyear);
29+
$xtpl->assign('PAGE_STUDENTLIST', $page_studentlist);
30+
31+
// hien thi du lieu
32+
if(!empty($array)) {
33+
foreach ($array as $value) {
34+
$value['url_week_list'] = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE .'=weeklist&id=' . $value['ma_nam_hoc'] ;
35+
$value['checksess'] = md5($value['ma_nam_hoc'] . NV_CHECK_SESSION);
36+
$value['thoi_gian_bat_dau'] = nv_date('d/m/Y', $value['thoi_gian_bat_dau']);
37+
$value['thoi_gian_ket_thuc'] = nv_date('d/m/Y', $value['thoi_gian_ket_thuc']);
38+
$value['nam_hoc'] = $value['tu_nam'] . ' - ' . $value['den_nam'] ;
39+
$xtpl->assign('DATA', $value);
40+
$xtpl->parse('schoolyearlist.loop');
41+
}
42+
}
43+
44+
$xtpl->parse('schoolyearlist');
45+
$contents = $xtpl->text('schoolyearlist');
46+
47+
include NV_ROOTDIR . '/includes/header.php';
48+
echo nv_admin_theme($contents);
49+
include NV_ROOTDIR . '/includes/footer.php';

modules/manageheadbook/language/admin_vi.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
$lang_translator['author'] = 'Group DNTU';
1616

1717
$lang_module['func'] = 'Chức năng';
18-
18+
$lang_module['add'] = 'Thêm mới';
1919

2020
$lang_module['addclass'] = 'Thêm lớp';
2121
$lang_module['class'] = 'Lớp học';
@@ -62,3 +62,12 @@
6262
$lang_module['edit_subject'] = 'Sửa môn học';
6363
$lang_module['subject_id'] = 'Mã môn học';
6464
$lang_module['subject_name'] = 'Tên môn học';
65+
66+
67+
$lang_module['add_week'] = 'Thêm tuần';
68+
$lang_module['edit_week'] = 'Chỉnh sửa tuần';
69+
$lang_module['school_year_list'] = 'Danh sách năm học';
70+
$lang_module['week_list'] = 'Danh sách tuần';
71+
$lang_module['start_time'] = 'Thời gian bắt đầu (dự kiến)';
72+
$lang_module['finish_time'] = 'Thời gian kết thúc (dự kiến)';
73+
$lang_module['add_year_title'] = 'Thêm năm học';
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!-- BEGIN: addyear -->
2+
<link rel="stylesheet" type="text/css" href="{NV_BASE_SITEURL}{NV_ASSETS_DIR}/js/jquery-ui/jquery-ui.min.css">
3+
4+
<form action="" method="post" class="form-inline">
5+
<div class="table-responsive">
6+
<table class="table table-striped table-bordered table-hover">
7+
<colgroup>
8+
<col style="width: 260px" />
9+
<col/>
10+
</colgroup>
11+
<tbody>
12+
<tr>
13+
<td>{LANG.school_year} <span class="red">*</span></td>
14+
<td>
15+
<input class="form-control w100" name="tu_nam" value="{DATA.tu_nam}" />
16+
<span class="ml-10 mr-10"> - </span>
17+
<input class="form-control w100" name="den_nam" value="{DATA.den_nam}" />
18+
</td>
19+
</tr>
20+
<tr>
21+
<td>{LANG.start_time} <span class="red">*</span></td>
22+
<td>
23+
<span class="text-middle">
24+
<input class="form-control" name="thoi_gian_batdau" id="starttime" value="{DATA.thoi_gian_bat_dau}" style="width: 100px;" maxlength="10" type="text" />
25+
</span>
26+
</td>
27+
</tr>
28+
<tr>
29+
<td>{LANG.finish_time} <span class="red">*</span></td>
30+
<td>
31+
<span class="text-middle">
32+
<input class="form-control" name="thoi_gian_ket_thuc" id="finishtime" value="{DATA.thoi_gian_ket_thuc}" style="width: 100px;" maxlength="10" type="text" />
33+
</span>
34+
</td>
35+
</tr>
36+
</tbody>
37+
</table>
38+
</div>
39+
<div class="text-center">
40+
<input class="btn btn-primary" type="submit" name="btnsubmit" value="{LANG.save}">
41+
</div>
42+
</form>
43+
<script type="text/javascript" src="{NV_BASE_SITEURL}{NV_ASSETS_DIR}/js/jquery-ui/jquery-ui.min.js"></script>
44+
<script type="text/javascript" src="{NV_BASE_SITEURL}{NV_ASSETS_DIR}/js/language/jquery.ui.datepicker-{NV_LANG_INTERFACE}.js"></script>
45+
<script type="text/javascript">
46+
$("#starttime,#finishtime").datepicker({
47+
showOn : "both",
48+
dateFormat : "dd/mm/yy",
49+
changeMonth : true,
50+
changeYear : true,
51+
showOtherMonths : true,
52+
buttonImage : nv_base_siteurl + "assets/images/calendar.gif",
53+
buttonImageOnly : true,
54+
yearRange: "-10:+10"
55+
});
56+
</script>
57+
<!-- END: addyear -->
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!-- BEGIN: schoolyearlist -->
2+
<div class="table-responsive">
3+
<table class="table table-striped table-bordered table-hover">
4+
<thead>
5+
<tr>
6+
<th class="w200">{LANG.school_year}</th>
7+
<th>{LANG.start_time}</th>
8+
<th>{LANG.finish_time}</th>
9+
<th class="w300 text-center">{LANG.func}</th>
10+
</tr>
11+
</thead>
12+
<tbody>
13+
<!-- BEGIN: loop -->
14+
<tr>
15+
<td>{DATA.nam_hoc}</td>
16+
<td>{DATA.thoi_gian_bat_dau}</td>
17+
<td>{DATA.thoi_gian_ket_thuc}</td>
18+
<td class="text-center">
19+
<a href="{DATA.url_week_list}" class="btn btn-default btn-xs"><i class="fa fa-fw fa-list"></i>{LANG.week_list}</a>
20+
<a class="btn btn-danger btn-xs" href="javascript:void(0);" onclick="nv_del_schoolyear({DATA.ma_nam_hoc}, '{DATA.checksess}')"><i class="fa fa-fw fa-trash"></i>{GLANG.delete}</a>
21+
</td>
22+
</tr>
23+
<!-- END: loop -->
24+
</tbody>
25+
</table>
26+
<div class="form-group">
27+
<a href="{PAGE_ADDSCHOOLYEAR}" class="btn btn-primary">{LANG.add}</a>
28+
</div>
29+
</div>
30+
<!-- END: schoolyearlist -->

0 commit comments

Comments
 (0)