From 561fa06536924aec0da500a375171a325f406c62 Mon Sep 17 00:00:00 2001 From: "VINADES.,JSC" Date: Thu, 26 Oct 2017 10:25:16 +0700 Subject: [PATCH 1/5] add link delete,edit at adminmod --- modules/laws/funcs/detail.php | 3 ++ modules/laws/funcs/main.php | 32 +++++++++++++++++++- modules/laws/language/vi.php | 2 ++ modules/laws/theme.php | 21 ++++++++++++- themes/default/js/laws.js | 16 ++++++++++ themes/default/modules/laws/detail.tpl | 7 +++++ themes/default/modules/laws/main.tpl | 8 +++++ themes/default/modules/laws/main_subject.tpl | 8 +++++ 8 files changed, 95 insertions(+), 2 deletions(-) diff --git a/modules/laws/funcs/detail.php b/modules/laws/funcs/detail.php index efa183373..d7f685ddc 100644 --- a/modules/laws/funcs/detail.php +++ b/modules/laws/funcs/detail.php @@ -25,6 +25,9 @@ nv_redirect_location(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name, true); } +$row['edit_link'] = NV_BASE_ADMINURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=main&edit=1&id=" . $row['id']; +$row['delete_link'] = 'nv_delete_law(' . $row['id'] . ', \'' . md5($row['id'] . session_id()) . '\')'; + $row['aid'] = array(); $result = $db->query('SELECT area_id FROM ' . NV_PREFIXLANG . '_' . $module_data . '_row_area WHERE row_id=' . $row['id']); while (list ($area_id) = $result->fetch(3)) { diff --git a/modules/laws/funcs/main.php b/modules/laws/funcs/main.php index e5c554089..df05b4853 100644 --- a/modules/laws/funcs/main.php +++ b/modules/laws/funcs/main.php @@ -81,6 +81,8 @@ $row['number_comm'] = sprintf($lang_module['number_comm'],$num_comm); $row['comm_time'] = $row['start_comm_time'] . '-' . $row['end_comm_time']; $row['stt'] = $stt++; + $row['edit_link'] = NV_BASE_ADMINURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=main&edit=1&id=" . $row['id']; + $row['delete_link'] = 'nv_delete_law(' . $row['id'] . ', \'' . md5($row['id'] . session_id()) . '\')'; if ($nv_laws_setting['down_in_home']) { // File download @@ -135,7 +137,9 @@ $row['end_comm_time'] = ($row['end_comm_time']>0) ? sprintf($lang_module['end_comm_time'], nv_date('d/m/Y', $row['end_comm_time'])) : ''; $row['comm_time'] = $row['start_comm_time'] . '-' . $row['end_comm_time']; $row['number_comm'] = sprintf($lang_module['number_comm'],$num_comm); - if ($nv_laws_setting['down_in_home']) { + $row['edit_link'] = NV_BASE_ADMINURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=main&edit=1&id=" . $row['id']; + $row['delete_link'] = 'nv_delete_law(' . $row['id'] . ', \'' . md5($row['id'] . session_id()) . '\')'; + if ($nv_laws_setting['down_in_home']) { // File download if (!empty($row['files'])) { $row['files'] = explode(",", $row['files']); @@ -164,6 +168,32 @@ } } +if ($nv_Request->isset_request('id', 'get, post') and $nv_Request->isset_request('checkss', 'get, post')) { + $contents = 'NO_' . $id; + + $id = $nv_Request->get_int('id', 'get, post', 0); + $checkss = $nv_Request->get_string('checkss', 'get, post', ''); + if ($id > 0 and md5($id . session_id()) == $checkss) { + $data = $db->query('SELECT sid FROM ' . NV_PREFIXLANG . '_' . $module_data . '_row WHERE id=' . $id)->fetch(); + if(!empty($data)){ + $query = "DELETE FROM " . NV_PREFIXLANG . "_" . $module_data . "_row WHERE id = " . $id; + $db->query($query); + + $query = "DELETE FROM " . NV_PREFIXLANG . "_" . $module_data . "_set_replace WHERE oid = " . $id; + $db->query($query); + + // Cap nhat lai so luong van ban o chu de + $db->query('UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_subject SET numcount=(SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_row WHERE sid=' . $data['sid'] . ') WHERE id=' . $data['sid']); + + + $nv_Cache->delMod($module_name); + $contents = 'OK_' . $id; + } + } + + die($contents); +} + include NV_ROOTDIR . '/includes/header.php'; echo nv_site_theme($contents); include NV_ROOTDIR . '/includes/footer.php'; \ No newline at end of file diff --git a/modules/laws/language/vi.php b/modules/laws/language/vi.php index bbd1169c5..db320ab6c 100644 --- a/modules/laws/language/vi.php +++ b/modules/laws/language/vi.php @@ -91,3 +91,5 @@ $lang_module['e1'] = "Đã thông qua"; $lang_module['approval'] = "Trạng thái"; $lang_module['examine'] = "Ủy ban thẩm tra"; +$lang_module['edit'] = "Sửa"; +$lang_module['delete'] = "Xóa"; diff --git a/modules/laws/theme.php b/modules/laws/theme.php index 44671e585..17035dcf9 100644 --- a/modules/laws/theme.php +++ b/modules/laws/theme.php @@ -43,6 +43,9 @@ function nv_theme_laws_main($array_data, $generate_page) } $xtpl->parse('main.loop.down_in_home'); } + if (defined('NV_IS_MODADMIN')) { + $xtpl->parse('main.loop.admin_link'); + } if($module_config[$module_name]['activecomm']){ $xtpl->parse('main.loop.comm'); if($row['allow_comm']){ @@ -69,7 +72,10 @@ function nv_theme_laws_main($array_data, $generate_page) $xtpl->parse('main.down_in_home'); $xtpl->parse('main.down_in_home_col'); } - + if (defined('NV_IS_MODADMIN')) { + $xtpl->parse('main.admin_link_col'); + $xtpl->parse('main.admin_link_title'); + } $xtpl->parse('main'); return $xtpl->text('main'); } @@ -110,6 +116,10 @@ function nv_theme_laws_maincat($mod, $array_data) } $xtpl->parse('main.loop.row.down_in_home'); } + + if (defined('NV_IS_MODADMIN')) { + $xtpl->parse('main.loop.row.admin_link'); + } if($module_config[$module_name]['activecomm']){ $xtpl->parse('main.loop.row.comm'); if($rows['allow_comm']){ @@ -146,6 +156,10 @@ function nv_theme_laws_maincat($mod, $array_data) if ($nv_laws_setting['down_in_home']) { $xtpl->parse('main.down_in_home'); } + if (defined('NV_IS_MODADMIN')) { + $xtpl->parse('main.admin_link_col'); + $xtpl->parse('main.admin_link_title'); + } $xtpl->parse('main'); return $xtpl->text('main'); @@ -315,6 +329,11 @@ function nv_theme_laws_detail($array_data, $other_cat = array(), $other_area = a $xtpl->parse('main.nodownload'); } + if (defined('NV_IS_MODADMIN')) { + $xtpl->parse('main.admin_link'); + $xtpl->parse('main.admin_link_title'); + } + if (!empty($other_cat)) { $xtpl->assign('OTHER_CAT', nv_theme_laws_list_other($other_cat)); $xtpl->parse('main.other_cat'); diff --git a/themes/default/js/laws.js b/themes/default/js/laws.js index b93bd2384..3bc3d8cdf 100644 --- a/themes/default/js/laws.js +++ b/themes/default/js/laws.js @@ -15,3 +15,19 @@ $(function() { }); }); }); +function nv_delete_law(id, checkss) { + if (confirm(nv_is_del_confirm[0])) { + $.post(nv_base_siteurl + 'index.php?' + nv_lang_variable + '=' + nv_lang_data + '&' + nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=main&nocache=' + new Date().getTime(), 'id=' + id + '&checkss=' + checkss, function(res) { + var r_split = res.split('_'); + if (r_split[0] == 'OK') { + + window.location.href = window.location.href; + } else if (r_split[0] == 'NO') { + alert(r_split[1]); + } else { + alert(nv_is_del_confirm[2]); + } + }); + } + return false; +} \ No newline at end of file diff --git a/themes/default/modules/laws/detail.tpl b/themes/default/modules/laws/detail.tpl index 6f42aa25b..5eee6d47c 100644 --- a/themes/default/modules/laws/detail.tpl +++ b/themes/default/modules/laws/detail.tpl @@ -161,6 +161,13 @@

{LANG.info_download_no}

+ +
+ {LANG.edit} + {LANG.delete} +
+ +
diff --git a/themes/default/modules/laws/main.tpl b/themes/default/modules/laws/main.tpl index 7074f4b18..72c42ff4d 100644 --- a/themes/default/modules/laws/main.tpl +++ b/themes/default/modules/laws/main.tpl @@ -13,6 +13,7 @@ + @@ -28,6 +29,7 @@ {LANG.comm_time} + @@ -69,6 +71,12 @@
+ + + {LANG.edit} + {LANG.delete} + + diff --git a/themes/default/modules/laws/main_subject.tpl b/themes/default/modules/laws/main_subject.tpl index 8b360d32e..22db30a54 100644 --- a/themes/default/modules/laws/main_subject.tpl +++ b/themes/default/modules/laws/main_subject.tpl @@ -6,6 +6,7 @@ + @@ -20,6 +21,7 @@ {LANG.comm_time} + @@ -64,6 +66,12 @@
+ + + {LANG.edit} + {LANG.delete} + + From 8445589beea765f0a78f98f1ec76bcda6117c485 Mon Sep 17 00:00:00 2001 From: "VINADES.,JSC" Date: Thu, 26 Oct 2017 11:15:42 +0700 Subject: [PATCH 2/5] =?UTF-8?q?fix=20l=E1=BB=97i=20th=C3=AAm=20v=C4=83n=20?= =?UTF-8?q?b=E1=BA=A3n:=20b=E1=BA=AFt=20l=E1=BB=97i=20nh=E1=BA=ADp=20ng?= =?UTF-8?q?=C3=A0y=20ban=20h=C3=A0nh,=20ng=C3=A0y=20b=E1=BA=AFt=20=C4=91?= =?UTF-8?q?=E1=BA=A7u=20hi=E1=BB=87u=20l=E1=BB=B1c=20v=C3=A0=20h=E1=BA=BFt?= =?UTF-8?q?=20hi=E1=BB=87u=20l=E1=BB=B1c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/laws/admin/main.php | 14 +++++++++++++- modules/laws/language/admin_vi.php | 6 ++++-- modules/laws/language/en.php | 4 +++- themes/admin_default/modules/laws/main.tpl | 4 ++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/modules/laws/admin/main.php b/modules/laws/admin/main.php index 9798bbd4b..48a041df1 100644 --- a/modules/laws/admin/main.php +++ b/modules/laws/admin/main.php @@ -255,6 +255,17 @@ $post['startvalid'] = 0; } + //Nếu là module văn bản bình thường(k cho góp ý) thì bắt lỗi ngày ban hành <= Ngày có hiệu lực <=ngày hết hiệu lực + if($module_config[$module_name]['activecomm']==0){ + if($post['startvalid']>0){ + if($post['startvalid'] < $post['publtime']){ + die($lang_module['erroStartvalid']); + }elseif($post['exptime']>0 && ($post['exptime'] <= $post['publtime'] || $post['exptime'] <= $post['startvalid'])){ + die($lang_module['erroExptime']); + } + } + } + $post['sgid'] = $nv_Request->get_title('sgid', 'post', ''); if (!is_numeric($post['sgid']) and !empty($post['sgid'])) { $result = $db->query("SELECT id FROM " . NV_PREFIXLANG . "_" . $module_data . "_signer WHERE title=" . $db->quote($post['title']) . " AND offices='' AND positions=''"); @@ -405,7 +416,8 @@ $post['ptitle'] = $lang_module['editRow']; $post['action_url'] = NV_BASE_ADMINURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=main&edit&id=" . $post['id']; } else { - $post['relatement'] = $post['replacement'] = $post['title'] = $post['code'] = $post['introtext'] = $post['bodytext'] = $post['keywords'] = $post['author'] = $post['publtime'] = $post['exptime'] = ""; + $post['publtime'] = date("d.m.Y", NV_CURRENTTIME); + $post['relatement'] = $post['replacement'] = $post['title'] = $post['code'] = $post['introtext'] = $post['bodytext'] = $post['keywords'] = $post['author'] = $post['exptime'] = ""; $post['groups_view'] = $post['groups_download'] = array( 6 ); diff --git a/modules/laws/language/admin_vi.php b/modules/laws/language/admin_vi.php index d50182923..e84d4e611 100644 --- a/modules/laws/language/admin_vi.php +++ b/modules/laws/language/admin_vi.php @@ -185,5 +185,7 @@ $lang_module['editExamine'] = 'Sửa Ủy ban thẩm tra'; $lang_module['logDelExamine'] = "Xóa Ủy ban thẩm tra"; $lang_module['ExamineSel'] = "Chọn Ủy ban thẩm tra"; -$lang_module['erroNotSelectExamine'] = 'Lỗi! Bạn chưa chọn Ủy ban thẩm tra'; -$lang_module['approval'] = "Trang thái"; \ No newline at end of file +$lang_module['erroNotSelectExamine'] = 'Lỗi! Bạn chưa chọn Ủy ban thẩm tra.'; +$lang_module['approval'] = "Trang thái"; +$lang_module['erroStartvalid'] = 'Lỗi! Ngày bắt đầu hiệu lực không thể trước ngày ban hành.'; +$lang_module['erroExptime'] = 'Lỗi! Ngày hết hiệu lực phải sau ngày ban hành và ngày bắt đầu hiệu lực.'; diff --git a/modules/laws/language/en.php b/modules/laws/language/en.php index a486f870c..1f095923c 100644 --- a/modules/laws/language/en.php +++ b/modules/laws/language/en.php @@ -72,4 +72,6 @@ $lang_module['s_result'] = 'Search result'; $lang_module['s_noresult'] = 'There are no results that match your requirements'; $lang_module['s_result_num'] = '%d laws'; -$lang_module['click_to_download'] = "Click here to download"; \ No newline at end of file +$lang_module['click_to_download'] = "Click here to download"; +$lang_module['edit'] = "Edit"; +$lang_module['delete'] = "Delete"; diff --git a/themes/admin_default/modules/laws/main.tpl b/themes/admin_default/modules/laws/main.tpl index 5cf37636f..fa0de339e 100644 --- a/themes/admin_default/modules/laws/main.tpl +++ b/themes/admin_default/modules/laws/main.tpl @@ -252,7 +252,7 @@
- ({LANG.prm}) + ({LANG.prm})