Skip to content

Commit

Permalink
Merge remote-tracking branch 'laws/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
VINADES.,JSC committed Oct 27, 2017
2 parents 192d2df + 0c963ed commit 4982be9
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 35 deletions.
19 changes: 16 additions & 3 deletions modules/laws/admin/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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=''");
Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -575,7 +587,7 @@

if ($nv_Request->isset_request('list', 'get')) {
$base_url = NV_BASE_ADMINURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $op . "&list";
$join = "";
$join = 'INNER JOIN ' . NV_USERS_GLOBALTABLE . ' u1 ON t1.admin_add=u1.userid';
$where = array();
if ($nv_Request->isset_request('cat', 'get')) {
$keywords = $nv_Request->get_title('keywords', 'get', '');
Expand Down Expand Up @@ -626,10 +638,11 @@
$per_page = 30;

if ($all_page) {
$sql = "SELECT * FROM " . NV_PREFIXLANG . "_" . $module_data . "_row t1 " . $join . ($where ? " WHERE " . implode(" AND ", $where) : "") . " ORDER BY t1.addtime DESC LIMIT " . (($page - 1) * $per_page) . "," . $per_page;
$sql = "SELECT t1.*, u1.username FROM " . NV_PREFIXLANG . "_" . $module_data . "_row t1 " . $join . ($where ? " WHERE " . implode(" AND ", $where) : "") . " ORDER BY t1.addtime DESC LIMIT " . (($page - 1) * $per_page) . "," . $per_page;
$result = $db->query($sql);
$a = 0;
while ($row = $result->fetch()) {
$row['admin_add'] = $row['username'];
$row['publtime'] = date("d-m-Y", $row['publtime']);
$row['exptime'] = $row['exptime'] ? date("d-m-Y", $row['exptime']) : "N/A";
$row['start_comm_time'] = $row['start_comm_time'] ? date("d/m/Y", $row['start_comm_time']) : "";
Expand Down
47 changes: 24 additions & 23 deletions modules/laws/blocks/global.block_new_law.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/**
* nv_block_config_new_laws()
*
*
* @param mixed $module
* @param mixed $data_block
* @param mixed $lang_block
Expand Down Expand Up @@ -61,7 +61,7 @@ function nv_block_config_new_laws($module, $data_block, $lang_block)
$ck = $data_block['duplicated'] ? 'checked="checked"' : '';
$html .= '<td><input type="checkbox" name="config_duplicated" value="1" ' . $ck . ' /></td>';
$html .= '</tr>';

$html .= '<tr>';
$html .= '<td>' . $lang_block['order'] . '</td>';
$html .= '<td><select name="config_order" class="form-control">';
Expand All @@ -80,7 +80,7 @@ function nv_block_config_new_laws($module, $data_block, $lang_block)

/**
* nv_block_config_new_laws_submit()
*
*
* @param mixed $module
* @param mixed $lang_block
* @return
Expand All @@ -104,42 +104,42 @@ function nv_block_config_new_laws_submit($module, $lang_block)

/**
* nv_law_block_newg()
*
*
* @param mixed $block_config
* @return
*/
function nv_law_block_newg($block_config)
{
global $module_info, $lang_module, $global_config, $site_mods, $db, $my_head, $module_name, $nv_laws_listcat, $nv_Cache;

$module = $block_config['module'];
$data = $site_mods[$module]['module_data'];
$modfile = $site_mods[$module]['module_file'];

$numrow = (isset($block_config['numrow'])) ? $block_config['numrow'] : 10;
$title_length = (isset($block_config['title_length'])) ? $block_config['title_length'] : 0;
$show_code = (isset($block_config['show_code'])) ? $block_config['show_code'] : 1;

$order = ($block_config['order'] == 2 or $block_config['order'] == 4) ? "ASC" : "DESC";
$order_param = ($block_config['order'] == 1 or $block_config['order'] == 2) ? "publtime" : "addtime";

$sql = 'SELECT * FROM ' . NV_PREFIXLANG . '_' . $data . '_row WHERE status=1 ORDER BY ' . $order_param . ' ' . $order . ' LIMIT 0,' . $numrow;
$result = $db->query($sql);
$numrow = $result->rowCount();

if (!empty($numrow)) {
if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $modfile . '/block_new_law.tpl')) {
$block_theme = $global_config['module_theme'];
} else {
$block_theme = 'default';
}

if ($module_name != $module) {
$sql = "SELECT id, parentid, alias, title, introduction, keywords, newday FROM " . NV_PREFIXLANG . "_" . $data . "_cat ORDER BY parentid,weight ASC";
$nv_laws_listcat = $nv_Cache->db($sql, 'id', $module);

$my_head .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . NV_BASE_SITEURL . "themes/" . $block_theme . "/css/laws.css\" />";

$temp_lang_module = $lang_module;
$lang_module = array();
include NV_ROOTDIR . '/modules/' . $site_mods[$module]['module_file'] . '/language/' . NV_LANG_INTERFACE . '.php';
Expand All @@ -148,46 +148,47 @@ function nv_law_block_newg($block_config)
} else {
$lang_block_module = $lang_module;
}

$xtpl = new XTemplate('block_new_law.tpl', NV_ROOTDIR . '/themes/' . $block_theme . '/modules/' . $modfile);
$xtpl->assign('LANG', $lang_block_module);
$xtpl->assign('TEMPLATE', $block_theme);

while ($row = $result->fetch()) {
$newday = $row['publtime'] + (86400 * $nv_laws_listcat[$row['cid']]['newday']);

$link = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&amp;' . NV_NAME_VARIABLE . '=' . $module . '&amp;' . NV_OP_VARIABLE . '=' . $site_mods[$module]['alias']['detail'] . '/' . $row['alias'];
$row['link'] = $link;

if ($title_length > 0) {
$row['stitle'] = nv_clean60($row['title'], $title_length);
} else {
$row['stitle'] = $row['title'];
}

$row['publtime'] = nv_date('d/m/Y', $row['publtime']);

$row['addtime'] = nv_date('d/m/Y', $row['addtime']);

$xtpl->assign('ROW', $row);

if ($show_code) {
$xtpl->parse('main.loop.code');
}

if ($newday >= NV_CURRENTTIME) {
$xtpl->parse('main.loop.newday');
}

$xtpl->parse('main.loop');
}

if ($block_config['direction'] != 'none') {
$block_config['pauseOnHover'] = $block_config['pauseOnHover'] ? 'true' : 'false';
$block_config['duplicated'] = $block_config['duplicated'] ? 'true' : 'false';
$xtpl->assign('DATA', $block_config);
$xtpl->parse('main.marquee_data');
$xtpl->parse('main.marquee_js');
}

$xtpl->parse('main');
return $xtpl->text('main');
}
Expand Down
3 changes: 3 additions & 0 deletions modules/laws/funcs/detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=main&amp;edit=1&amp;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)) {
Expand Down
32 changes: 31 additions & 1 deletion modules/laws/funcs/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=main&amp;edit=1&amp;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
Expand Down Expand Up @@ -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 . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=main&amp;edit=1&amp;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']);
Expand Down Expand Up @@ -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';
1 change: 1 addition & 0 deletions modules/laws/language/admin_en.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,4 @@
$lang_module['type_view_1'] = 'Oldest on top';
$lang_module['wait'] = 'Please wait....';
$lang_module['search_error'] = 'Choose at least one search terms';
$lang_module['admin_add'] = "Admin add";
7 changes: 5 additions & 2 deletions modules/laws/language/admin_vi.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,8 @@
$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";
$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.';
$lang_module['admin_add'] = "Người đăng";
4 changes: 3 additions & 1 deletion modules/laws/language/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
$lang_module['click_to_download'] = "Click here to download";
$lang_module['edit'] = "Edit";
$lang_module['delete'] = "Delete";
3 changes: 3 additions & 0 deletions modules/laws/language/vi.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@
$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";
$lang_module['addtime'] = "Thời gian đăng";
23 changes: 21 additions & 2 deletions modules/laws/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']){
Expand All @@ -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');
}
Expand Down Expand Up @@ -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']){
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -586,7 +605,7 @@ function nv_theme_laws_list_other($array_data)
$xtpl->parse('main.loop');
$i++;
}
if(isset($site_mods['comment']) and isset($module_config[$module_name]['activecomm'])){
if(isset($site_mods['comment']) && $module_config[$module_name]['activecomm']==1){
$xtpl->parse('main.comm_time');
}else{
$xtpl->parse('main.publtime_title');
Expand Down
9 changes: 6 additions & 3 deletions themes/admin_default/modules/laws/main.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<colgroup>
<col />
<col class="w100" />
<col span="4" class="w150" />
<col span="5" class="w150" />

</colgroup>
<thead>
<tr>
Expand All @@ -25,6 +26,7 @@
<th>{LANG.start_comm_time}</th>
<th>{LANG.end_comm_time}</th>
<!-- END: view_comm_time_title -->
<th class="text-center">{LANG.admin_add}</th>
<th class="text-center">{LANG.status}</th>
<th class="text-center">{LANG.feature}</th>
</tr>
Expand All @@ -42,6 +44,7 @@
<td>{DATA.start_comm_time}</td>
<td>{DATA.end_comm_time}</td>
<!-- END: view_comm_time -->
<td>{DATA.admin_add}</td>
<td class="text-center">
<select class="form-control" id="status_{DATA.id}" name="status[]" onchange="nv_change_status({DATA.id});">
<option value="0">{LANG.status0}</option>
Expand Down Expand Up @@ -252,7 +255,7 @@
</select>
<div id="exptimearea" style="display:{DATA.display}">
<input class="form-control" name="exptime" id="exptime" value="{DATA.exptime}" style="width: 110px;" maxlength="10" type="text" />
<img src="{NV_BASE_SITEURL}{NV_ASSETS_DIR}/images/calendar.jpg" style="cursor: pointer; vertical-align: middle;" onclick="popCalendar.show(this, 'exptime', 'dd.mm.yyyy', true);" alt="" height="17" /> ({LANG.prm})
({LANG.prm})
</div>
<script type="text/javascript">
$(document).ready(function() {
Expand Down Expand Up @@ -396,7 +399,7 @@
</div>
<script type="text/javascript">
//<![CDATA[
$("#publtime,#startvalid,#end_comm_time,#start_comm_time").datepicker({
$("#publtime,#startvalid,#end_comm_time,#start_comm_time,#exptime").datepicker({
showOn : "both",
yearRange: "2000:2025",
dateFormat : "dd.mm.yy",
Expand Down
Loading

0 comments on commit 4982be9

Please sign in to comment.