Skip to content

Commit 3bd31a4

Browse files
authored
Merge branch 'master' into display_headbook
2 parents 23a5f74 + f1c9f2e commit 3bd31a4

File tree

503 files changed

+138624
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

503 files changed

+138624
-17
lines changed

modules/manageheadbook/action_mysql.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
$sql_drop_module[] = 'DROP TABLE IF EXISTS ' . $db_config['prefix'] . '_' . $lang . '_' . $module_data . '_student;';
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;';
23+
$sql_drop_module[] = 'DROP TABLE IF EXISTS ' . $db_config['prefix'] . '_' . $lang . '_' . $module_data . '_program;';
2324
$sql_drop_module[] = 'DROP TABLE IF EXISTS ' . $db_config['prefix'] . '_' . $lang . '_' . $module_data . '_headbook;';
2425

2526
$sql_create_module = $sql_drop_module;
@@ -94,6 +95,7 @@
9495
PRIMARY KEY (ma_so)
9596
) ENGINE=MyISAM;";
9697

98+
9799
$sql_create_module[] = "CREATE TABLE " . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "_week (
98100
ma_tuan int(11) NOT NULL AUTO_INCREMENT,
99101
ma_nam_hoc int(11) NOT NULL,
@@ -104,3 +106,15 @@
104106
trang_thai tinyint(1) NOT NULL DEFAULT 1,
105107
PRIMARY KEY (ma_tuan)
106108
) ENGINE=MyISAM;";
109+
110+
111+
$sql_create_module[] = "CREATE TABLE " . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "_program (
112+
ma_chuong_trinh int(11) NOT NULL AUTO_INCREMENT,
113+
ma_nam_hoc int(11) DEFAULT NULL,
114+
ma_mon_hoc int(11) DEFAULT NULL,
115+
khoi int(2) NOT NULL,
116+
tiet int(5) NOT NULL,
117+
ten_bai_hoc varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
118+
PRIMARY KEY (ma_chuong_trinh)
119+
) ENGINE=MyISAM;";
120+

modules/manageheadbook/admin.functions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
'subject',
2424
'addsubject',
2525
'delsubject',
26-
'addstudent',
27-
'headbook',
2826
'schoolyearlist',
2927
'addyear',
30-
'addstudent'
28+
'addstudent',
29+
'program',
30+
'headbook'
3131
];
3232

3333
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
@@ -18,6 +18,8 @@
1818

1919
$submenu['subject'] = $lang_module['subject'];
2020

21-
$submenu['headbook'] = $lang_module['head_book'];
2221
$submenu['schoolyearlist'] = $lang_module['school_year_list'];
2322

23+
$submenu['program'] = $lang_module['program'];
24+
25+
$submenu['headbook'] = $lang_module['head_book'];

modules/manageheadbook/admin/addsubject.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22

33
/**
4-
* @Project NUKEVIET 4.x
5-
* @Author VINADES.,JSC <contact@vinades.vn>
6-
* @Copyright (C) 2014 VINADES.,JSC. All rights reserved
7-
* @License GNU/GPL version 2 or any later version
8-
* @Createdate 24-06-2011 10:35
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
99
*/
1010

11+
1112
if (!defined('NV_IS_FILE_ADMIN')) {
1213
die('Stop!!!');
1314
}
Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
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+
include dirname(__FILE__) . '/../plugins/PHPExcel/Classes/PHPExcel/IOFactory.php';
16+
17+
$page_title = $lang_module['program'];
18+
$error = '';
19+
$success = '';
20+
21+
$action = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&amp;' . NV_NAME_VARIABLE . '=' . $module_name . '&amp;' . NV_OP_VARIABLE . '=' . $op;
22+
23+
// Hiển thị
24+
$xtpl = new XTemplate('program.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
25+
$xtpl->assign('LANG', $lang_module);
26+
$xtpl->assign('GLANG', $lang_global);
27+
$xtpl->assign('FORM_ACTION', $action);
28+
29+
// Subject
30+
$querysubject = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_subject');
31+
$i = 0;
32+
$selectedsubject;
33+
while ($row = $querysubject->fetch()) {
34+
$arraysubject[$row['ma_mon_hoc']] = $row;
35+
if($i ==0)
36+
{
37+
$selectedsubject = $row['ma_mon_hoc'];
38+
}
39+
$i++;
40+
}
41+
// hien thi du lieu subject drop down
42+
if(!empty($arraysubject)) {
43+
foreach ($arraysubject as $value) {
44+
$value['key'] = $value['ma_mon_hoc'];
45+
$value['title'] = $value['ten_mon_hoc'];
46+
$value['selected'] = $selectedsubject == $value['ma_mon_hoc'] ? "selected" : "";
47+
48+
$xtpl->assign('DATA_SUBJECT', $value);
49+
$xtpl->parse('main.loopsubject');
50+
}
51+
}
52+
53+
$queryschoolyear = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_school_years');
54+
$i = 0;
55+
$selectedschoolyear;
56+
while ($row = $queryschoolyear->fetch()) {
57+
$arrayschoolyear[$row['ma_nam_hoc']] = $row;
58+
if($i ==0)
59+
{
60+
$selectedschoolyear = $row['ma_nam_hoc'];
61+
}
62+
$i++;
63+
}
64+
65+
if(!empty($arrayschoolyear)) {
66+
foreach ($arrayschoolyear as $value) {
67+
$value['key'] = $value['ma_nam_hoc'];
68+
$value['title'] = $value['tu_nam'] . ' - ' . $value['den_nam'];
69+
$value['selected'] = $selectedschoolyear == $value['ma_nam_hoc'] ? "selected" : "";
70+
$xtpl->assign('DATA_SCHOOL_YEARs', $value);
71+
$xtpl->parse('main.loopschoolyear');
72+
}
73+
}
74+
75+
$selectedkhoi = $lang_module['khoi'];
76+
for ($i = 1; $i <= 12; ++$i) {
77+
$value = [
78+
'key' => $i,
79+
'title' => $lang_module['khoi' . $i],
80+
'selected' => $selectedkhoi == $lang_module['khoi' . $i] ? ' selected="selected"' : ''
81+
];
82+
$xtpl->assign('DATA_KHOI', $value);
83+
$xtpl->parse('main.loopkhoi');
84+
}
85+
86+
for ($i = 1; $i <= 12; ++$i) {
87+
$khoi = nv_substr($nv_Request->get_title('khoi_' . $i, 'post', ''), 0, 250);
88+
}
89+
$khoi = $lang_module['khoi' . $khoi];
90+
91+
if(!empty($arraysubject)) {
92+
foreach ($arraysubject as $value) {
93+
$ma_mon_hoc = $nv_Request->get_int('subject_' . $value['ma_mon_hoc'], 'post', '');
94+
}
95+
}
96+
97+
if(!empty($arrayschoolyear)) {
98+
foreach ($arrayschoolyear as $value) {
99+
$ma_nam_hoc = $nv_Request->get_int('schoolyear_' . $value['ma_nam_hoc'], 'post', '');
100+
}
101+
}
102+
103+
// Khi nhấn Import
104+
if ($nv_Request->isset_request('do', 'post')) {
105+
if (isset($_FILES['ufile']) && is_uploaded_file($_FILES['ufile']['tmp_name'])) {
106+
$filename = nv_string_to_filename($_FILES['ufile']['name']);
107+
$file = NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename;
108+
if(file_exists($file)){
109+
unlink($file);
110+
}
111+
if (move_uploaded_file($_FILES['ufile']['tmp_name'], $file)) {
112+
if (file_exists($file)) {
113+
try {
114+
$fileType = PHPExcel_IOFactory::identify($file);
115+
$objReader = PHPExcel_IOFactory::createReader($fileType);
116+
$objPHPExcel = $objReader->load($file);
117+
} catch(Exception $e) {
118+
$error = $lang_module['error_cannot_read_file'].' '.pathinfo($file,PATHINFO_BASENAME).'": '.$e->getMessage();
119+
}
120+
121+
if (empty($error)) {
122+
$sheet = $objPHPExcel->getSheet(0);
123+
$highestRow = $sheet->getHighestRow();
124+
$highestColumn = $sheet->getHighestColumn();
125+
126+
for ($row = 1; $row <= $highestRow; $row++){
127+
$dataRow = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE);
128+
$data[] = $dataRow;
129+
}
130+
131+
// Bắt đầu import vào database
132+
$db->query('DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . '_program WHERE ma_mon_hoc = ' . $ma_mon_hoc . ' AND ma_nam_hoc = ' . $ma_nam_hoc . ' AND khoi = ' . $khoi);
133+
for($i = 1; $i <= $highestRow - 1; $i++) {
134+
$tiet = $data[$i][0][0];
135+
$ten_bai_hoc = $data[$i][0][1];
136+
$_sql = 'INSERT INTO ' . NV_PREFIXLANG . '_' . $module_data . '_program
137+
(ma_nam_hoc, khoi, ma_mon_hoc, tiet, ten_bai_hoc) VALUES
138+
(:ma_nam_hoc, :khoi, :ma_mon_hoc, :tiet, :ten_bai_hoc)';
139+
$sth = $db->prepare($_sql);
140+
$sth->bindParam(':ma_nam_hoc', $ma_nam_hoc, PDO::PARAM_INT);
141+
$sth->bindParam(':khoi', $khoi, PDO::PARAM_INT);
142+
$sth->bindParam(':ma_mon_hoc', $ma_mon_hoc, PDO::PARAM_INT);
143+
$sth->bindParam(':tiet', $tiet, PDO::PARAM_INT);
144+
$sth->bindParam(':ten_bai_hoc', $ten_bai_hoc, PDO::PARAM_INT);
145+
$sth->execute();
146+
// die($sth);
147+
}
148+
$success = $lang_module['import_success'];
149+
unlink($file);
150+
}
151+
} else {
152+
$error = $lang_module['error_upload_file'];
153+
}
154+
} else {
155+
$error = $lang_module['error_upload_file'];
156+
}
157+
} else {
158+
$error = $lang_module['error_dont_have_file'];
159+
}
160+
}
161+
162+
// Xem tất cả
163+
if ($nv_Request->isset_request('showall', 'post')) {
164+
// Gọi csdl để lấy dữ liệu
165+
$query = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_program');
166+
// Đổ dữ liệu
167+
while ($row = $query->fetch()) {
168+
$array[$row['id']] = $row;
169+
}
170+
// hien thi du lieu
171+
if($array) {
172+
$i = 1;
173+
foreach ($array as $value) {
174+
$value['stt'] = $i++;
175+
$query_selected_subject = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_subject WHERE ma_mon_hoc = ' . $value['ma_mon_hoc'] );
176+
$row_selected_subject = $query_selected_subject->fetch();
177+
$value['mon_hoc'] = $row_selected_subject['ten_mon_hoc'];
178+
179+
$query_school_years = $db->query("SELECT * FROM " . NV_PREFIXLANG . "_" . $module_data . "_school_years WHERE ma_nam_hoc=". $value['ma_nam_hoc']);
180+
$data_school_years = $query_school_years->fetch();
181+
$value['nam_hoc'] = $data_school_years['tu_nam'] . ' - ' . $data_school_years['den_nam'];
182+
183+
$xtpl->assign('DATA', $value);
184+
$xtpl->parse('main.show.loop');
185+
}
186+
}
187+
$xtpl->parse('main.show');
188+
}
189+
190+
// Khi nhấn Xem
191+
if ($nv_Request->isset_request('show', 'post')) {
192+
// Gọi csdl để lấy dữ liệu
193+
$query = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_program WHERE ma_mon_hoc = ' . $ma_mon_hoc . ' AND ma_nam_hoc = "' . $ma_nam_hoc . '" AND khoi = ' . $khoi);
194+
// Đổ dữ liệu
195+
while ($row = $query->fetch()) {
196+
$array[$row['id']] = $row;
197+
}
198+
// hien thi du lieu
199+
if($array) {
200+
$i = 1;
201+
foreach ($array as $value) {
202+
$value['stt'] = $i++;
203+
$query_selected_subject = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_subject WHERE ma_mon_hoc = ' . $value['ma_mon_hoc']);
204+
$row_selected_subject = $query_selected_subject->fetch();
205+
$value['mon_hoc'] = $row_selected_subject['ten_mon_hoc'];
206+
207+
$query_school_years = $db->query("SELECT * FROM " . NV_PREFIXLANG . "_" . $module_data . "_school_years WHERE ma_nam_hoc=". $value['ma_nam_hoc']);
208+
$data_school_years = $query_school_years->fetch();
209+
$value['nam_hoc'] = $data_school_years['tu_nam'] . ' - ' . $data_school_years['den_nam'];
210+
211+
$xtpl->assign('DATA', $value);
212+
$xtpl->parse('main.show.loop');
213+
}
214+
}
215+
$xtpl->parse('main.show');
216+
}
217+
218+
if ($nv_Request->isset_request('del', 'post')) {
219+
if($ma_mon_hoc && $ma_nam_hoc && $khoi) {
220+
$query = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_program WHERE ma_mon_hoc = ' . $ma_mon_hoc . ' AND ma_nam_hoc = "' . $ma_nam_hoc . '" AND khoi = ' . $khoi);
221+
if($query) {
222+
while ($row = $query->fetch()) {
223+
$array[$row['malop']] = $row;
224+
}
225+
if($array) {
226+
$db->query('DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . '_program WHERE ma_mon_hoc = ' . $ma_mon_hoc . ' AND ma_nam_hoc = "' . $ma_nam_hoc . '" AND khoi = ' . $khoi);
227+
$success = $lang_module['delete_success'];
228+
}
229+
else
230+
$error = $lang_module['error_delete_null'];
231+
}
232+
}
233+
else
234+
$error = $lang_module['error_delete_null'];
235+
}
236+
237+
if ($nv_Request->isset_request('delall', 'post')) {
238+
$query = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_program');
239+
if($query) {
240+
while ($row = $query->fetch()) {
241+
$array[$row['malop']] = $row;
242+
}
243+
if($array) {
244+
$db->query('DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . '_program');
245+
$success = $lang_module['delete_success'];
246+
}
247+
else
248+
$error = $lang_module['error_delete_null'];
249+
}
250+
251+
}
252+
253+
if ($error) {
254+
$xtpl->assign('ERROR', $error);
255+
$xtpl->parse('main.error');
256+
}
257+
258+
if ($success) {
259+
$xtpl->assign('SUCCESS', $success);
260+
$xtpl->parse('main.success');
261+
}
262+
263+
$xtpl->parse('main');
264+
$contents = $xtpl->text('main');
265+
266+
include (NV_ROOTDIR . "/includes/header.php");
267+
echo nv_admin_theme($contents);
268+
include (NV_ROOTDIR . "/includes/footer.php");

modules/manageheadbook/admin/subject.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

33
/**
4-
* @Project NUKEVIET 4.x
5-
* @Author VINADES.,JSC <contact@vinades.vn>
6-
* @Copyright (C) 2014 VINADES.,JSC. All rights reserved
7-
* @License GNU/GPL version 2 or any later version
8-
* @Createdate 24-06-2011 10:35
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
99
*/
1010

1111
if (!defined('NV_IS_FILE_ADMIN')) {
@@ -29,7 +29,7 @@
2929
$xtpl->assign('GLANG', $lang_global);
3030
$xtpl->assign('PAGE_ADDSUBJECT', $page_addsubject);
3131

32-
// hien thi du lieu
32+
// Hiển thị dữ liệu
3333
if($array) {
3434
foreach ($array as $value) {
3535
$value['url_edit'] = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=addsubject&subjectid=' . $value['ma_mon_hoc'];

0 commit comments

Comments
 (0)