|
| 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 | +$page_title = $lang_module['school_info']; |
| 16 | + |
| 17 | + |
| 18 | +// Gọi csdl để lấy dữ liệu |
| 19 | +$query = $db->query('SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_school_info'); |
| 20 | +$data = $query->fetch(); |
| 21 | + |
| 22 | +$xtpl = new XTemplate('school_info.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file); |
| 23 | +$xtpl->assign('LANG', $lang_module); |
| 24 | +$row = []; |
| 25 | + |
| 26 | +if ($nv_Request->isset_request('btnsubmit', 'post')) { |
| 27 | + $row['ten_so'] = nv_substr($nv_Request->get_title('ten_so', 'post', ''), 0, 250); |
| 28 | + $row['ten_phong'] = nv_substr($nv_Request->get_title('ten_phong', 'post', ''), 0, 250); |
| 29 | + $row['ten_truong'] = nv_substr($nv_Request->get_title('ten_truong', 'post', ''), 0, 250); |
| 30 | + $row['tu_nam'] = $nv_Request->get_int('tu_nam', 'post', ''); |
| 31 | + $row['den_nam'] = $nv_Request->get_int('den_nam', 'post', ''); |
| 32 | + |
| 33 | + if (!$data) { |
| 34 | + //them moi |
| 35 | + $_sql = 'INSERT INTO ' . NV_PREFIXLANG . '_' . $module_data . '_school_info ( |
| 36 | + ten_so, ten_phong, ten_truong, tu_nam, den_nam) VALUES ( |
| 37 | + :ten_so, :ten_phong, :ten_truong, :tu_nam, :den_nam)'; |
| 38 | + |
| 39 | + $sth = $db->prepare($_sql); |
| 40 | + $sth->bindParam(':ten_so', $row['ten_so'], PDO::PARAM_STR); |
| 41 | + $sth->bindParam(':ten_phong', $row['ten_phong'], PDO::PARAM_STR); |
| 42 | + $sth->bindParam(':ten_truong', $row['ten_truong'], PDO::PARAM_STR); |
| 43 | + $sth->bindParam(':tu_nam', $row['tu_nam'], PDO::PARAM_STR); |
| 44 | + $sth->bindParam(':den_nam', $row['den_nam'], PDO::PARAM_STR); |
| 45 | + $exe = $sth->execute(); |
| 46 | + |
| 47 | + if ($exe) { |
| 48 | + nv_redirect_location(NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op); |
| 49 | + } |
| 50 | + } else { |
| 51 | + $_sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_school_info |
| 52 | + SET ten_so = :ten_so, ten_phong = :ten_phong, ten_truong = :ten_truong, tu_nam = :tu_nam, den_nam = :den_nam |
| 53 | + WHERE id = '. $data['id']; |
| 54 | + |
| 55 | + // die($_sql); |
| 56 | + $sth = $db->prepare($_sql); |
| 57 | + $sth->bindParam(':ten_so', $row['ten_so'], PDO::PARAM_STR); |
| 58 | + $sth->bindParam(':ten_phong', $row['ten_phong'], PDO::PARAM_STR); |
| 59 | + $sth->bindParam(':ten_truong', $row['ten_truong'], PDO::PARAM_STR); |
| 60 | + $sth->bindParam(':tu_nam', $row['tu_nam'], PDO::PARAM_STR); |
| 61 | + $sth->bindParam(':den_nam', $row['den_nam'], PDO::PARAM_STR); |
| 62 | + $exe = $sth->execute(); |
| 63 | + |
| 64 | + if ($exe) { |
| 65 | + nv_redirect_location(NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op); |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | +} |
| 70 | +if($data){ |
| 71 | + $xtpl->assign('DATA', $data); |
| 72 | +} |
| 73 | + |
| 74 | + |
| 75 | +$xtpl->parse('school_info'); |
| 76 | +$contents = $xtpl->text('school_info'); |
| 77 | +include NV_ROOTDIR . '/includes/header.php'; |
| 78 | +echo nv_admin_theme($contents); |
| 79 | +include NV_ROOTDIR . '/includes/footer.php'; |
0 commit comments