Skip to content

Commit

Permalink
Merge pull request #533 from mynukeviet/develop
Browse files Browse the repository at this point in the history
Update block bxproduct center
  • Loading branch information
vuthao committed Jan 3, 2017
2 parents 4a33e37 + 525be9f commit 1428019
Show file tree
Hide file tree
Showing 18 changed files with 256 additions and 142 deletions.
1 change: 1 addition & 0 deletions modules/shops/action_mysql.php
Expand Up @@ -757,6 +757,7 @@ class varchar(25) NOT NULL DEFAULT '',
$data['template_active'] = '0';
$data['download_active'] = '0';
$data['download_groups'] = '6';
$data['sortdefault'] = 0;

foreach ($data as $config_name => $config_value) {
$sql_create_module[] = "INSERT INTO " . NV_CONFIG_GLOBALTABLE . " (lang, module, config_name, config_value) VALUES ('" . $lang . "', " . $db->quote($module_name) . ", " . $db->quote($config_name) . ", " . $db->quote($config_value) . ")";
Expand Down
41 changes: 31 additions & 10 deletions modules/shops/admin/blockcat.php
Expand Up @@ -21,12 +21,18 @@
'title' => '',
'alias' => '',
'description' => '',
'keywords' => ''
'keywords' => '',
'image' => ''
);

$table_name = $db_config['prefix'] . '_' . $module_data . '_block_cat';
$savecat = $nv_Request->get_int('savecat', 'post', 0);

$currentpath = NV_UPLOADS_DIR . '/' . $module_upload . '/' . date('Y_m');
if (!file_exists($currentpath)) {
nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module_upload, date('Y_m'), true);
}

if (! empty($savecat)) {
$field_lang = nv_file_table($table_name);

Expand All @@ -37,6 +43,14 @@
$data['description'] = $nv_Request->get_string('description', 'post', '');
$data['description'] = nv_nl2br(nv_htmlspecialchars(strip_tags($data['description'])), '<br />');

$image = $nv_Request->get_string('image', 'post', '');
if (is_file(NV_DOCUMENT_ROOT . $image)) {
$lu = strlen(NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/');
$data['image'] = substr($image, $lu);
} else {
$data['image'] = '';
}

// Cat mo ta cho chinh xac
if (strlen($data['description']) > 255) {
$data['description'] = nv_clean60($data['description'], 250);
Expand Down Expand Up @@ -66,9 +80,10 @@
$listvalue .= ', :' . $flang . '_' . $fname;
}

$sql = "INSERT INTO " . $db_config['prefix'] . "_" . $module_data . "_block_cat (bid, adddefault,image, weight, add_time, edit_time " . $listfield . ") VALUES (NULL, 0, '', " . $weight . ", " . NV_CURRENTTIME . ", " . NV_CURRENTTIME . " " . $listvalue . ")";
$sql = "INSERT INTO " . $db_config['prefix'] . "_" . $module_data . "_block_cat (bid, adddefault,image, weight, add_time, edit_time " . $listfield . ") VALUES (NULL, 0, :image, " . $weight . ", " . NV_CURRENTTIME . ", " . NV_CURRENTTIME . " " . $listvalue . ")";

$data_insert = array();
$data_insert['image'] = $data['image'];
foreach ($field_lang as $field_lang_i) {
list($flang, $fname) = $field_lang_i;
$data_insert[$flang . '_' . $fname] = $data[$fname];
Expand All @@ -89,11 +104,12 @@
if ($stmt->rowCount()) {
$error = $lang_module['block_error_alias'];
} else {
$stmt = $db->prepare('UPDATE ' . $db_config['prefix'] . '_' . $module_data . '_block_cat SET ' . NV_LANG_DATA . '_title= :title, ' . NV_LANG_DATA . '_alias = :alias, ' . NV_LANG_DATA . '_description= :description, ' . NV_LANG_DATA . '_keywords= :keywords, edit_time=' . NV_CURRENTTIME . ' WHERE bid =' . $data['bid']);
$stmt = $db->prepare('UPDATE ' . $db_config['prefix'] . '_' . $module_data . '_block_cat SET ' . NV_LANG_DATA . '_title= :title, ' . NV_LANG_DATA . '_alias = :alias, ' . NV_LANG_DATA . '_description= :description, ' . NV_LANG_DATA . '_keywords= :keywords, image = :image, edit_time=' . NV_CURRENTTIME . ' WHERE bid =' . $data['bid']);
$stmt->bindParam(':title', $data['title'], PDO::PARAM_STR);
$stmt->bindParam(':alias', $data['alias'], PDO::PARAM_STR);
$stmt->bindParam(':description', $data['description'], PDO::PARAM_STR);
$stmt->bindParam(':keywords', $data['keywords'], PDO::PARAM_STR);
$stmt->bindParam(':image', $data['image'], PDO::PARAM_STR);
if ($stmt->execute()) {
$error = $lang_module['saveok'];
$nv_Cache->delMod($module_name);
Expand All @@ -107,6 +123,17 @@
}
}

$data['bid'] = $nv_Request->get_int('bid', 'get', 0);
if ($data['bid'] > 0) {
list($data['bid'], $data['title'], $data['alias'], $data['description'], $data['keywords'], $data['image']) = $db->query('SELECT bid, ' . NV_LANG_DATA . '_title, ' . NV_LANG_DATA . '_alias, ' . NV_LANG_DATA . '_description, ' . NV_LANG_DATA . '_keywords, image FROM ' . $db_config['prefix'] . '_' . $module_data . '_block_cat where bid=' . $data['bid'])->fetch(3);
$lang_module['add_block_cat'] = $lang_module['edit_block_cat'];
}

if (! empty($data['image']) and file_exists(NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $data['image'])) {
$data['image'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $data['image'];
$currentpath = dirname($data['image']);
}

$xtpl = new XTemplate('blockcat.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
$xtpl->assign('LANG', $lang_module);
$xtpl->assign('GLANG', $lang_global);
Expand All @@ -115,15 +142,9 @@
$xtpl->assign('NV_OP_VARIABLE', NV_OP_VARIABLE);
$xtpl->assign('MODULE_NAME', $module_name);
$xtpl->assign('OP', $op);

$xtpl->assign('UPLOAD_CURRENT', $currentpath);
$xtpl->assign('BLOCK_CAT_LIST', nv_show_block_cat_list());

$data['bid'] = $nv_Request->get_int('bid', 'get', 0);
if ($data['bid'] > 0) {
list($data['bid'], $data['title'], $data['alias'], $data['description'], $data['keywords']) = $db->query('SELECT bid, ' . NV_LANG_DATA . '_title, ' . NV_LANG_DATA . '_alias, ' . NV_LANG_DATA . '_description, ' . NV_LANG_DATA . '_keywords FROM ' . $db_config['prefix'] . '_' . $module_data . '_block_cat where bid=' . $data['bid'])->fetch(3);
$lang_module['add_block_cat'] = $lang_module['edit_block_cat'];
}

$xtpl->assign('DATA', $data);

if ($error != '') {
Expand Down
2 changes: 1 addition & 1 deletion modules/shops/admin/or_view.php
Expand Up @@ -58,7 +58,7 @@
$listnum[] = $row['num'];
$listprice[] = $row['price'];

$result_group = $db->query('SELECT group_id FROM ' . $db_config['prefix'] . '_' . $module_data . '_orders_id_group WHERE order_i=' . $row['id']);
$result_group = $db->query('SELECT group_id FROM ' . $db_config['prefix'] . '_' . $module_data . '_orders_id_group WHERE order_i=' . $row['order_id']);
$group = array();
while (list($group_id) = $result_group->fetch(3)) {
$group[] = $group_id;
Expand Down
46 changes: 32 additions & 14 deletions modules/shops/admin/setting.php
Expand Up @@ -7,7 +7,6 @@
* @License GNU/GPL version 2 or any later version
* @Createdate 2-9-2010 14:43
*/

if (! defined('NV_IS_FILE_ADMIN')) {
die('Stop!!!');
}
Expand Down Expand Up @@ -71,6 +70,7 @@
$data['groups_notify'] = ! empty($_groups_notify) ? implode(',', array_intersect($_groups_notify, array_keys($groups_list))) : '';
$data['active_tooltip'] = $nv_Request->get_int('active_tooltip', 'post', 0);
$data['show_product_code'] = $nv_Request->get_int('show_product_code', 'post', 0);
$data['sortdefault'] = $nv_Request->get_int('sortdefault', 'post', 0);
$data['show_compare'] = $nv_Request->get_int('show_compare', 'post', 0);
$data['show_displays'] = $nv_Request->get_int('show_displays', 'post', 0);
$data['use_shipping'] = $nv_Request->get_int('use_shipping', 'post', 0);
Expand All @@ -93,7 +93,7 @@
$data['download_active'] = $nv_Request->get_int('download_active', 'post', 0);
$_dowload_groups = $nv_Request->get_array('download_groups', 'post', array());
$data['download_groups'] = ! empty($_dowload_groups) ? implode(',', nv_groups_post(array_intersect($_dowload_groups, array_keys($groups_list_default)))) : '';

if ($error == '') {
$sth = $db->prepare("UPDATE " . NV_CONFIG_GLOBALTABLE . " SET config_value = :config_value WHERE lang = '" . NV_LANG_DATA . "' AND module = :module_name AND config_name = :config_name");
$sth->bindParam(':module_name', $module_name, PDO::PARAM_STR);
Expand All @@ -102,16 +102,16 @@
$sth->bindParam(':config_value', $config_value, PDO::PARAM_STR);
$sth->execute();
}

$mid = intval($currencies_array[$data['money_unit']]['numeric']);

$sql = "UPDATE " . $db_config['prefix'] . "_" . $module_data . "_money_" . NV_LANG_DATA . " SET exchange = '1' WHERE id = " . $mid;
$db->query($sql);

nv_insert_logs(NV_LANG_DATA, $module_name, $lang_module['setting'], "Setting", $admin_info['userid']);
$nv_Cache->delMod('settings');
$nv_Cache->delMod($module_name);

Header("Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . '=setting');
die();
}
Expand All @@ -123,7 +123,7 @@
$sql = "SELECT * FROM " . $db_config['prefix'] . "_" . $module_data . "_payment ORDER BY weight ASC";
$result = $db->query($sql);
$num_items = $result->rowCount();

while ($row = $result->fetch()) {
$array_setting_payment[$row['payment']] = $row;
}
Expand All @@ -135,9 +135,12 @@
$xtpl->assign('MODULE_NAME', $module_name);

// Số sản phẩm hiển thị trên một dòng
for ($i = 1; $i <= 10; $i++) {
for ($i = 1; $i <= 10; $i ++) {
if (24 % $i == 0) {
$xtpl->assign('PER_ROW', array( 'value' => $i, 'selected' => $data['per_row'] == $i ? 'selected="selected"' : '' ));
$xtpl->assign('PER_ROW', array(
'value' => $i,
'selected' => $data['per_row'] == $i ? 'selected="selected"' : ''
));
$xtpl->parse('main.per_row');
}
}
Expand Down Expand Up @@ -256,7 +259,7 @@

// Tien te
$result = $db->query("SELECT code, currency FROM " . $db_config['prefix'] . "_" . $module_data . "_money_" . NV_LANG_DATA . " ORDER BY code DESC");
while (list($code, $currency) = $result->fetch(3)) {
while (list ($code, $currency) = $result->fetch(3)) {
$array_temp = array();
$array_temp['value'] = $code;
$array_temp['title'] = $code . " - " . $currency;
Expand All @@ -267,7 +270,7 @@

// Don vi khoi luong
$result = $db->query("SELECT code, title FROM " . $db_config['prefix'] . "_" . $module_data . "_weight_" . NV_LANG_DATA . " ORDER BY code DESC");
while (list($code, $title) = $result->fetch(3)) {
while (list ($code, $title) = $result->fetch(3)) {
$array_temp = array();
$array_temp['value'] = $code;
$array_temp['title'] = $code . " - " . $title;
Expand All @@ -285,7 +288,7 @@
));
$xtpl->parse('main.download_groups');
}
if (!$data['download_active']) {
if (! $data['download_active']) {
$xtpl->parse('main.download_groups_none');
}

Expand All @@ -300,7 +303,7 @@
$a = 0;
$all_page = sizeof($array_setting_payment);
$payment = $nv_Request->get_string('payment', 'get', 0);

foreach ($array_setting_payment as $value) {
$value['titleactive'] = (! empty($value['active'])) ? $lang_global['yes'] : $lang_global['no'];
$value['link_edit'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=payport&amp;payment=" . $value['payment'];
Expand All @@ -311,14 +314,29 @@
$value['slect_weight'] = drawselect_number($value['payment'], 1, $all_page + 1, $value['weight'], "nv_chang_pays('" . $value['payment'] . "',this,url_change_weight,url_back);");
$xtpl->assign('DATA_PM', $value);
$xtpl->parse('main.payment.paymentloop');
++$a;
++ $a;
}
$xtpl->assign('url_back', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $op);
$xtpl->assign('url_change', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=changepay");
$xtpl->assign('url_active', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=actpay");
$xtpl->parse('main.payment');
}

$array_sortdefault = array(
0 => $lang_module['setting_sortdefault_0'],
1 => $lang_module['setting_sortdefault_1'],
2 => $lang_module['setting_sortdefault_2']
);
foreach ($array_sortdefault as $index => $value) {
$sl = $data['sortdefault'] == $index ? 'selected="selected"' : '';
$xtpl->assign('SORTDEFAULT', array(
'index' => $index,
'value' => $value,
'selected' => $sl
));
$xtpl->parse('main.sortdefault');
}

$xtpl->parse('main');

$contents .= $xtpl->text('main');
Expand Down

0 comments on commit 1428019

Please sign in to comment.