/** * nv_product_center() * * @return */ function nv_product_center($block_config) { global $module_name, $lang_module, $module_info, $module_file, $global_array_shops_cat, $db, $module_data, $db_config, $pro_config, $global_config, $site_mods; $module = $block_config['module']; $num_view = 5; $num = 30; $array = array(); $xtpl = new XTemplate('block.product_center.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file); $xtpl->assign('LANG', $lang_module); $xtpl->assign('THEME_TEM', NV_BASE_SITEURL . 'themes/' . $module_info['template']); $xtpl->assign('WIDTH', $pro_config['homewidth']); $xtpl->assign('NUMVIEW', $num_view); $cache_file = NV_LANG_DATA . '_block_module_product_center_' . NV_CACHE_PREFIX . '.cache'; if (($cache = nv_get_cache($module_name, $cache_file)) != false) { $array = unserialize($cache); } else { $db->sqlreset()->select('bid')->from($db_config['prefix'] . '_' . $module_data . '_block_cat')->order('weight ASC')->limit(1); $result = $db->query($db->sql()); $bid = $result->fetchColumn(); $db->sqlreset()->select('t1.id, t1.listcatid, t1.' . NV_LANG_DATA . '_title AS title, t1.' . NV_LANG_DATA . '_alias AS alias, t1.homeimgfile, t1.homeimgthumb , t1.homeimgalt, t1.showprice, t1.discount_id')->from($db_config['prefix'] . '_' . $module_data . '_rows t1')->join('INNER JOIN ' . $db_config['prefix'] . '_' . $module_data . '_block t2 ON t1.id = t2.id')->where('t2.bid= ' . $bid . ' AND t1.status =1')->order('t1.id DESC')->limit($num); $array = nv_db_cache($db->sql(), 'id', $module_name); $cache = serialize($array); nv_set_cache($module_name, $cache_file, $cache); } foreach ($array as $row) { $link = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $global_array_shops_cat[$row['listcatid']]['alias'] . '/' . $row['alias'] . $global_config['rewrite_exturl']; if ($row['homeimgthumb'] == 1) { $src_img = NV_BASE_SITEURL . NV_FILES_DIR . '/' . $site_mods[$module]['module_upload'] . '/' . $row['homeimgfile']; } elseif ($row['homeimgthumb'] == 2) { $src_img = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $site_mods[$module]['module_upload'] . '/' . $row['homeimgfile']; } elseif ($row['homeimgthumb'] == 3) { $src_img = $row['homeimgfile']; } else { $src_img = NV_BASE_SITEURL . 'themes/' . $global_config['site_theme'] . '/images/shops/no-image.jpg'; } $xtpl->assign('LINK', $link); $xtpl->assign('TITLE', $row['title']); $xtpl->assign('TITLE0', nv_clean60($row['title'], 30)); $xtpl->assign('SRC_IMG', $src_img); if ($pro_config['active_price'] == '1') { if ($row['showprice'] == '1') { $price = nv_get_price($row['id'], $pro_config['money_unit']); $xtpl->assign('PRICE', $price); if ($row['discount_id'] and $price['discount_percent'] > 0) { $xtpl->parse('main.items.price.discounts'); } else { $xtpl->parse('main.items.price.no_discounts'); } $xtpl->parse('main.items.price'); } else { $xtpl->parse('main.items.contact'); } } $xtpl->parse('main.items'); } $xtpl->parse('main'); return $xtpl->text('main'); }
function nv_get_price_tmp($module_name, $module_data, $module_file, $pro_id) { global $db, $db_config, $module_config, $discounts_config; $price = array(); $pro_config = $module_config[$module_name]; if (file_exists(NV_ROOTDIR . '/modules/' . $module_file . '/site.functions.php')) { require_once NV_ROOTDIR . '/modules/' . $module_file . '/site.functions.php'; $price = nv_get_price($pro_id, $pro_config['money_unit'], 1, false, $module_name); } return $price; }
/** * nv_others_product() * * @return */ function nv_others_product($block_config) { global $op, $global_config, $pro_config; $module = $block_config['module']; if ($op == 'detail') { global $module_name, $lang_module, $module_info, $module_file, $global_array_shops_cat, $db, $module_data, $db_config, $id, $catid, $pro_config, $global_config; $xtpl = new XTemplate('block.others_product.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file); $xtpl->assign('LANG', $lang_module); $xtpl->assign('THEME_TEM', NV_BASE_SITEURL . 'themes/' . $module_info['template']); $xtpl->assign('WIDTH', $pro_config['blockwidth']); $db->sqlreset()->select('id, listcatid, ' . NV_LANG_DATA . '_title, ' . NV_LANG_DATA . '_alias ,addtime, homeimgfile, homeimgthumb, product_price, money_unit, discount_id, showprice')->from($db_config['prefix'] . '_' . $module_data . '_rows')->where('status =1 AND listcatid = ' . $catid . ' AND id < ' . $id)->order('id DESC')->limit(20); $result = $db->query($db->sql()); $i = 1; while (list($id_i, $listcatid_i, $title_i, $alias_i, $addtime_i, $homeimgfile_i, $homeimgthumb_i, $product_price_i, $money_unit_i, $discount_id_i, $showprice_i) = $result->fetch(3)) { if ($homeimgthumb_i == 1) { $src_img = NV_BASE_SITEURL . NV_FILES_DIR . '/' . $site_mods[$module]['module_upload'] . '/' . $homeimgfile_i; } elseif ($homeimgthumb_i == 2) { $src_img = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $site_mods[$module]['module_upload'] . '/' . $homeimgfile_i; } elseif ($homeimgthumb_i == 3) { $src_img = $homeimgfile_i; } else { $src_img = NV_BASE_SITEURL . 'themes/' . $global_config['site_theme'] . '/images/shops/no-image.jpg'; } $xtpl->assign('link', NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $global_array_shops_cat[$listcatid_i]['alias'] . '/' . $alias_i . $global_config['rewrite_exturl']); $xtpl->assign('title', $title_i); $xtpl->assign('src_img', $src_img); $xtpl->assign('time', nv_date('d-m-Y h:i:s A', $addtime_i)); if ($pro_config['active_price'] == '1') { if ($showprice_i == '1') { $price = nv_get_price($id_i, $money_unit_i); $xtpl->assign('PRICE', $price); if ($discount_id_i and $price['discount_percent'] > 0) { $xtpl->parse('main.loop.price.discounts'); } else { $xtpl->parse('main.loop.price.no_discounts'); } $xtpl->parse('main.loop.price'); } else { $xtpl->parse('main.loop.contact'); } } $bg = $i % 2 == 0 ? 'bg' : ''; $xtpl->assign('bg', $bg); $xtpl->parse('main.loop'); ++$i; } $xtpl->parse('main'); return $xtpl->text('main'); } }
/** * wishlist() * * @param mixed $data_content * @param string $html_pages * @return */ function wishlist($data_content, $compare_id, $html_pages = '') { global $module_info, $lang_module, $module_file, $pro_config, $op, $array_displays, $array_wishlist_id, $module_name, $global_array_shops_cat, $global_array_group, $my_head; $xtpl = new XTemplate('wishlist.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file); $xtpl->assign('TEMPLATE', $module_info['template']); $xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL); $xtpl->assign('LANG', $lang_module); $xtpl->assign('CSS_PRODUCT_CODE', !empty($pro_config['show_product_code']) ? ' show-product-code' : ''); $xtpl->assign('num', 24 / $pro_config['per_row']); if (!empty($data_content)) { foreach ($data_content as $data_row) { $xtpl->assign('ID', $data_row['id']); $xtpl->assign('LINK', $data_row['link_pro']); $xtpl->assign('TITLE', $data_row['title']); $xtpl->assign('TITLE0', nv_clean60($data_row['title'], 40)); $xtpl->assign('IMG_SRC', $data_row['homeimgthumb']); $xtpl->assign('LINK_ORDER', $data_row['link_order']); $xtpl->assign('height', $pro_config['homeheight']); $xtpl->assign('width', $pro_config['homewidth']); $xtpl->assign('hometext', $data_row['hometext']); $xtpl->assign('PRODUCT_CODE', $data_row['product_code']); $newday = $data_row['publtime'] + 86400 * $data_row['newday']; if ($newday >= NV_CURRENTTIME) { $xtpl->parse('main.items.new'); } if ($pro_config['active_order'] == '1' and $pro_config['active_order_non_detail'] == '1') { if ($data_row['showprice'] == '1') { if ($data_row['product_number'] > 0) { // Kiem tra nhom bat buoc chon khi dat hang $listgroupid = GetGroupID($data_row['id']); $group_requie = 0; if (!empty($listgroupid) and !empty($global_array_group)) { foreach ($global_array_group as $groupinfo) { if ($groupinfo['in_order']) { $group_requie = 1; break; } } } $group_requie = $pro_config['active_order_popup'] ? 1 : $group_requie; $xtpl->assign('GROUP_REQUIE', $group_requie); $xtpl->parse('main.items.order'); } else { $xtpl->parse('main.items.product_empty'); } } } if ($pro_config['active_price'] == '1') { if ($data_row['showprice'] == '1') { $price = nv_get_price($data_row['id'], $pro_config['money_unit']); $xtpl->assign('PRICE', $price); if ($data_row['discount_id'] and $price['discount_percent'] > 0) { $xtpl->parse('main.items.price.discounts'); $xtpl->parse('main.items.price.discounts.standard'); } else { $xtpl->parse('main.items.price.no_discounts'); } $xtpl->parse('main.items.price'); } else { $xtpl->parse('main.items.contact'); } } if ($pro_config['active_tooltip'] == 1) { $xtpl->parse('main.items.tooltip'); } if (!empty($pro_config['show_product_code']) and !empty($data_row['product_code'])) { $xtpl->parse('main.items.product_code'); } if (defined('NV_IS_MODADMIN')) { $xtpl->assign('ADMINLINK', nv_link_edit_page($data_row['id']) . ' - ' . nv_link_delete_page($data_row['id'])); $xtpl->parse('main.items.adminlink'); } // Qua tang if ($pro_config['active_gift'] and !empty($data_row['gift_content']) and NV_CURRENTTIME >= $data_row['gift_from'] and NV_CURRENTTIME <= $data_row['gift_to']) { $xtpl->parse('main.items.gift'); } // So sanh san pham if ($pro_config['show_compare'] == 1) { if (!empty($compare_id)) { $ch = in_array($data_row['id'], $compare_id) ? ' checked="checked"' : ''; $xtpl->assign('ch', $ch); } $xtpl->parse('main.items.compare'); } if ($data_row['discount_id'] and $price['discount_percent'] > 0 and $data_row['showprice']) { $xtpl->parse('main.items.discounts'); } // Hien thi bieu tuong tich luy diem if ($pro_config['point_active'] and $global_array_shops_cat[$data_row['listcatid']]['cat_allow_point'] and !empty($global_array_shops_cat[$data_row['listcatid']]['cat_number_point'])) { $xtpl->assign('point', $global_array_shops_cat[$data_row['listcatid']]['cat_number_point']); $xtpl->assign('point_note', sprintf($lang_module['point_product_note'], $global_array_shops_cat[$data_row['listcatid']]['cat_number_point'])); $xtpl->parse('main.items.point'); } $xtpl->parse('main.items'); } if (!defined('MODAL_LOADED')) { $xtpl->parse('main.modal_loaded'); define('MODAL_LOADED', true); } if (!empty($html_pages)) { $xtpl->assign('generate_page', $html_pages); $xtpl->parse('main.pages'); } } $xtpl->parse('main'); return $xtpl->text('main'); }
} // Xoa cac ban ghi san pham don hang cu $db->query('DELETE FROM ' . $db_config['prefix'] . '_' . $module_data . '_orders_id WHERE order_id=' . $order_info['order_id']); // Neu khong tat chuc nang dat hang vo han thi tru so sp trong kho if ($pro_config['active_order_number'] == '0') { product_number_order($listid_old, $listnum_old, '+'); } product_number_sell($listid_old, $listnum_old, '-'); } //Them chi tiet don hang foreach ($_SESSION[$module_data . '_cart'] as $pro_id => $info) { if ($pro_config['active_price'] == '0') { $info['price'] = 0; } if ($_SESSION[$module_data . '_cart'][$pro_id]['order'] == 1 and $i > 0) { $price = nv_get_price($pro_id, $pro_config['money_unit'], $info['num'], true); $info['price'] = $price['sale']; $sql = 'INSERT INTO ' . $db_config['prefix'] . '_' . $module_data . '_orders_id( order_id, proid, num, price, discount_id ) VALUES ( :order_id, :proid, :num, :price, :discount_id )'; $data_insert = array(); $data_insert['order_id'] = $order_id; $data_insert['proid'] = $pro_id; $data_insert['num'] = $info['num']; $data_insert['price'] = $info['price']; $data_insert['discount_id'] = $info['discount_id']; $order_i = $db->insert_id($sql, 'id', $data_insert); if ($order_i > 0 and !empty($info['group'])) { $sth = $db->prepare('INSERT INTO ' . $db_config['prefix'] . '_' . $module_data . '_orders_id_group(order_i, group_id) VALUES( :order_i, :group_id )'); $info['group'] = explode(',', $info['group']); foreach ($info['group'] as $group_i) { $sth->bindParam(':order_i', $order_i, PDO::PARAM_INT); $sth->bindParam(':group_id', $group_i, PDO::PARAM_INT);
if (empty($listnum[$i])) { $listnum[$i] = 0; } if (!isset($listgroup[$i])) { $listgroup[$i] = ''; } $temppro[$proid] = array('price' => $listprice[$i], 'num' => $listnum[$i], 'group' => $listgroup[$i]); $arrayid[] = $proid; $i++; } if (!empty($arrayid)) { $templistid = implode(',', $arrayid); $sql = 'SELECT t1.id, t1.listcatid, t1.publtime, t1.' . NV_LANG_DATA . '_title, t1.' . NV_LANG_DATA . '_alias, t1.' . NV_LANG_DATA . '_hometext, t2.' . NV_LANG_DATA . '_title, t1.money_unit, t1.discount_id FROM ' . $db_config['prefix'] . '_' . $module_data . '_rows AS t1 LEFT JOIN ' . $db_config['prefix'] . '_' . $module_data . '_units AS t2 ON t1.product_unit = t2.id WHERE t1.id IN (' . $templistid . ') AND t1.status =1'; $result = $db->query($sql); while (list($id, $listcatid, $publtime, $title, $alias, $hometext, $unit, $money_unit, $discount_id) = $result->fetch(3)) { $price = nv_get_price($id, $pro_config['money_unit'], $temppro[$id]['num'], true); $data_pro[] = array('id' => $id, 'publtime' => $publtime, 'title' => $title, 'alias' => $alias, 'hometext' => $hometext, 'product_price' => $price['sale'], 'product_unit' => $unit, 'money_unit' => $money_unit, 'discount_id' => $discount_id, 'product_group' => $temppro[$id]['group'], 'link_pro' => $link . $global_array_shops_cat[$listcatid]['alias'] . '/' . $alias . $global_config['rewrite_exturl'], 'product_number' => $temppro[$id]['num']); } } // Xay dung cac url thanh toan truc tuyen $url_checkout = array(); $intro_pay = ''; if (intval($data['transaction_status']) == -1) { $intro_pay = $lang_module['payment_none_pay']; } elseif ($data['transaction_status'] == 0) { $sql = 'SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_payment WHERE active=1 ORDER BY weight ASC'; $result = $db->query($sql); while ($row = $result->fetch()) { if (file_exists(NV_ROOTDIR . '/modules/' . $module_file . '/payment/' . $row['payment'] . '.checkout_url.php')) { $payment_config = unserialize(nv_base64_decode($row['config'])); $payment_config['paymentname'] = $row['paymentname'];