function show_activate_form($timestamp, $data, $errors) { global $l; // TODO translations $package = get_package_info($timestamp); $redistrib_pack = get_redistrib_package_info($timestamp); echo '<h3>Package ' . $package['NAME'] . ' (' . $package['FILEID'] . ')</h3>'; echo '<a href="#" target="_blank">Download</a>'; if ($redistrib_pack) { echo ' - <a href="#" target="_blank">Download redistribution package</a>'; } echo ' - <a href="#" target="_blank">View info file</a>'; echo open_form('activate_pack'); echo '<div class="form-frame">'; show_form_field($data, $errors, 'select', 'METHOD', 'Activation method', array('type' => 'radio', 'options' => array(''))); echo '</div>'; echo close_form(); }
/** * 添加礼包到购物车 * * @access public * @param integer $package_id 礼包编号 * @param integer $num 礼包数量 * @return boolean */ function add_package_to_cart($package_id, $num = 1) { $GLOBALS['err']->clean(); /* 取得礼包信息 */ $package = get_package_info($package_id); if (empty($package)) { $GLOBALS['err']->add($GLOBALS['_LANG']['goods_not_exists'], ERR_NOT_EXISTS); return false; } /* 是否正在销售 */ if ($package['is_on_sale'] == 0) { $GLOBALS['err']->add($GLOBALS['_LANG']['not_on_sale'], ERR_NOT_ON_SALE); return false; } /* 现有库存是否还能凑齐一个礼包 */ if ($GLOBALS['_CFG']['use_storage'] == '1' && judge_package_stock($package_id)) { $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['shortage'], 1), ERR_OUT_OF_STOCK); return false; } /* 检查库存 */ // if ($GLOBALS['_CFG']['use_storage'] == 1 && $num > $package['goods_number']) // { // $num = $goods['goods_number']; // $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['shortage'], $num), ERR_OUT_OF_STOCK); // // return false; // } /* 初始化要插入购物车的基本件数据 */ $parent = array('user_id' => $_SESSION['user_id'], 'session_id' => SESS_ID, 'goods_id' => $package_id, 'goods_sn' => '', 'goods_name' => addslashes($package['package_name']), 'market_price' => $package['market_package'], 'goods_price' => $package['package_price'], 'goods_number' => $num, 'goods_attr' => '', 'goods_attr_id' => '', 'is_real' => $package['is_real'], 'extension_code' => 'package_buy', 'is_gift' => 0, 'rec_type' => CART_GENERAL_GOODS); /* 如果数量不为0,作为基本件插入 */ if ($num > 0) { /* 检查该商品是否已经存在在购物车中 */ $sql = "SELECT goods_number FROM " . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' AND goods_id = '" . $package_id . "' " . " AND parent_id = 0 AND extension_code = 'package_buy' " . " AND rec_type = '" . CART_GENERAL_GOODS . "'"; $row = $GLOBALS['db']->getRow($sql); if ($row) { $num += $row['goods_number']; if ($GLOBALS['_CFG']['use_storage'] == 0 || $num > 0) { $sql = "UPDATE " . $GLOBALS['ecs']->table('cart') . " SET goods_number = '" . $num . "'" . " WHERE session_id = '" . SESS_ID . "' AND goods_id = '{$package_id}' " . " AND parent_id = 0 AND extension_code = 'package_buy' " . " AND rec_type = '" . CART_GENERAL_GOODS . "'"; $GLOBALS['db']->query($sql); } else { $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['shortage'], $num), ERR_OUT_OF_STOCK); return false; } } else { $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('cart'), $parent, 'INSERT'); } } /* 把赠品删除 */ $sql = "DELETE FROM " . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' AND is_gift <> 0"; $GLOBALS['db']->query($sql); return true; }
} $info = array('package_price' => $_POST['package_price']); /* 插入数据 */ $record = array('act_name' => $_POST['package_name'], 'act_desc' => $_POST['desc'], 'act_type' => GAT_PACKAGE, 'start_time' => $_POST['start_time'], 'end_time' => $_POST['end_time'], 'is_finished' => 0, 'ext_info' => serialize($info)); $db->AutoExecute($hhs->table('goods_activity'), $record, 'INSERT'); /* 礼包编号 */ $package_id = $db->insert_id(); handle_packagep_goods($package_id); admin_log($_POST['package_name'], 'add', 'package'); $link[] = array('text' => $_LANG['back_list'], 'href' => 'package.php?act=list'); $link[] = array('text' => $_LANG['continue_add'], 'href' => 'package.php?act=add'); sys_msg($_LANG['add_succeed'], 0, $link); } elseif ($_REQUEST['act'] == 'edit') { /* 权限判断 */ admin_priv('package_manage'); $package = get_package_info($_REQUEST['id']); $package_goods_list = get_package_goods($_REQUEST['id']); // 礼包商品 $smarty->assign('package', $package); $smarty->assign('ur_here', $_LANG['package_edit']); $smarty->assign('action_link', array('text' => $_LANG['14_package_list'], 'href' => 'package.php?act=list&' . list_link_postfix())); $smarty->assign('cat_list', cat_list()); $smarty->assign('brand_list', get_brand_list()); $smarty->assign('form_action', 'update'); $smarty->assign('package_goods_list', $package_goods_list); assign_query_info(); $smarty->display('package_info.htm'); } elseif ($_REQUEST['act'] == 'update') { /* 权限判断 */ admin_priv('package_manage'); /* 将时间转换成整数 */
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here <http://www.gnu.org/licenses/gpl-3.0.html>. ***********************************************************************/ $page_security = 'SA_OPEN'; $path_to_root = "../.."; include_once $path_to_root . "/includes/session.inc"; include_once $path_to_root . "/includes/packages.inc"; page(_($help_context = "Package Details"), true); include_once $path_to_root . "/includes/ui.inc"; if (!isset($_GET['id'])) { /*Script was not passed the correct parameters */ display_note(_("The script must be called with a valid package id to review the info for.")); end_page(); } $filter = array('Version' => _('Available version'), 'Type' => _('Package type'), 'Name' => _('Package content'), 'Description' => _('Description'), 'Author' => _('Author'), 'Homepage' => _('Home page'), 'Maintenance' => _('Package maintainer'), 'InstallPath' => _('Installation path'), 'Depends' => _('Minimal software versions'), 'RTLDir' => _('Right to left'), 'Encoding' => _('Charset encoding')); $pkg = get_package_info($_GET['id'], null, $filter); display_heading(sprintf(_("Content information for package '%s'"), $_GET['id'])); br(); start_table(TABLESTYLE2, "width='80%'"); $th = array(_("Property"), _("Value")); table_header($th); foreach ($pkg as $field => $value) { if ($value == '') { continue; } start_row(); label_cells($field, nl2br(htmlentities(is_array($value) ? implode("\n", $value) : $value)), "class='tableheader2'"); end_row(); } end_table(1); end_page(true);
/** * 添加礼包到购物车 * * @access public * @param integer $package_id 礼包编号 * @param integer $num 礼包数量 * @return boolean */ function add_package_to_cart($package_id, $num = 1) { ECTouch::err()->clean(); /* 取得礼包信息 */ $package = get_package_info($package_id); if (empty($package)) { ECTouch::err()->add(L('goods_not_exists'), ERR_NOT_EXISTS); return false; } /* 是否正在销售 */ if ($package['is_on_sale'] == 0) { ECTouch::err()->add(L('not_on_sale'), ERR_NOT_ON_SALE); return false; } /* 现有库存是否还能凑齐一个礼包 */ if (C('use_storage') == '1' && model('Order')->judge_package_stock($package_id)) { ECTouch::err()->add(sprintf(L('shortage'), 1), ERR_OUT_OF_STOCK); return false; } /* 检查库存 */ // if (C('use_storage') == 1 && $num > $package['goods_number']) // { // $num = $goods['goods_number']; // ECTouch::err()->add(sprintf(L('shortage'), $num), ERR_OUT_OF_STOCK); // // return false; // } /* 初始化要插入购物车的基本件数据 */ $parent = array( 'user_id' => $_SESSION['user_id'], 'session_id' => SESS_ID, 'goods_id' => $package_id, 'goods_sn' => '', 'goods_name' => addslashes($package['package_name']), 'market_price' => $package['market_package'], 'goods_price' => $package['package_price'], 'goods_number' => $num, 'goods_attr' => '', 'goods_attr_id' => '', 'is_real' => $package['is_real'], 'extension_code' => 'package_buy', 'is_gift' => 0, 'rec_type' => CART_GENERAL_GOODS ); /* 如果数量不为0,作为基本件插入 */ if ($num > 0) { /* 检查该商品是否已经存在在购物车中 */ $sql = "SELECT goods_number FROM " . $this->pre . "cart WHERE session_id = '" . SESS_ID . "' AND goods_id = '" . $package_id . "' " . " AND parent_id = 0 AND extension_code = 'package_buy' " . " AND rec_type = '" . CART_GENERAL_GOODS . "'"; $row = $this->row($sql); if ($row) { //如果购物车已经有此物品,则更新 $num += $row['goods_number']; if (C('use_storage') == 0 || $num > 0) { $sql = "UPDATE " . $this->pre . "cart SET goods_number = '" . $num . "'" . " WHERE session_id = '" . SESS_ID . "' AND goods_id = '$package_id' " . " AND parent_id = 0 AND extension_code = 'package_buy' " . " AND rec_type = '" . CART_GENERAL_GOODS . "'"; $this->query($sql); } else { ECTouch::err()->add(sprintf(L('shortage'), $num), ERR_OUT_OF_STOCK); return false; } } else { //购物车没有此物品,则插入 $this->table = 'cart'; $this->insert($parent); } } /* 把赠品删除 */ $sql = "DELETE FROM " . $this->pre . "cart WHERE session_id = '" . SESS_ID . "' AND is_gift <> 0"; $this->query($sql); return true; }