Ejemplo n.º 1
0
function action_act_add_booking()
{
    $user = $GLOBALS['user'];
    $_CFG = $GLOBALS['_CFG'];
    $_LANG = $GLOBALS['_LANG'];
    $smarty = $GLOBALS['smarty'];
    $db = $GLOBALS['db'];
    $ecs = $GLOBALS['ecs'];
    $user_id = $_SESSION['user_id'];
    include_once ROOT_PATH . 'includes/lib_clips.php';
    $booking = array('goods_id' => isset($_POST['id']) ? intval($_POST['id']) : 0, 'goods_amount' => isset($_POST['number']) ? intval($_POST['number']) : 0, 'desc' => isset($_POST['desc']) ? trim($_POST['desc']) : '', 'linkman' => isset($_POST['linkman']) ? trim($_POST['linkman']) : '', 'email' => isset($_POST['email']) ? trim($_POST['email']) : '', 'tel' => isset($_POST['tel']) ? trim($_POST['tel']) : '', 'booking_id' => isset($_POST['rec_id']) ? intval($_POST['rec_id']) : 0);
    // 查看此商品是否已经登记过
    $rec_id = get_booking_rec($user_id, $booking['goods_id']);
    if ($rec_id > 0) {
        show_message($_LANG['booking_rec_exist'], $_LANG['back_page_up'], '', 'error');
    }
    if (add_booking($booking)) {
        show_message($_LANG['booking_success'], $_LANG['back_booking_list'], 'user.php?act=booking_list', 'info');
    } else {
        $err->show($_LANG['booking_list_lnk'], 'user.php?act=booking_list');
    }
}
Ejemplo n.º 2
0
    include_once ROOT_PATH . 'includes/lib_clips.php';
    $goods_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
    if ($goods_id == 0) {
        show_message($_LANG['no_goods_id'], $_LANG['back_page_up'], '', 'error');
    }
    $smarty->assign('info', get_goodsinfo($goods_id));
    $smarty->display('user_clips.dwt');
} elseif ($action == 'act_add_booking') {
    include_once ROOT_PATH . 'includes/lib_clips.php';
    $booking = array('goods_id' => isset($_POST['id']) ? intval($_POST['id']) : 0, 'goods_amount' => isset($_POST['number']) ? intval($_POST['number']) : 0, 'desc' => isset($_POST['desc']) ? trim($_POST['desc']) : '', 'linkman' => isset($_POST['linkman']) ? trim($_POST['linkman']) : '', 'email' => isset($_POST['email']) ? trim($_POST['email']) : '', 'tel' => isset($_POST['tel']) ? trim($_POST['tel']) : '', 'booking_id' => isset($_POST['rec_id']) ? intval($_POST['rec_id']) : 0);
    // 查看此商品是否已经登记过
    $rec_id = get_booking_rec($user_id, $booking['goods_id']);
    if ($rec_id > 0) {
        show_message($_LANG['booking_rec_exist'], $_LANG['back_page_up'], '', 'error');
    }
    if (add_booking($booking)) {
        show_message($_LANG['booking_success'], $_LANG['back_booking_list'], 'user.php?act=booking_list', 'info');
    } else {
        $err->show($_LANG['booking_list_lnk'], 'user.php?act=booking_list');
    }
} elseif ($action == 'act_del_booking') {
    include_once ROOT_PATH . 'includes/lib_clips.php';
    $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
    if ($id == 0 || $user_id == 0) {
        ecs_header("Location: user.php?act=booking_list\n");
        exit;
    }
    $result = delete_booking($id, $user_id);
    if ($result) {
        ecs_header("Location: user.php?act=booking_list\n");
        exit;
Ejemplo n.º 3
0
/**
 * Take details posted about a booking, and save to the database.
 *
 * @param  array		Booking details structure.
 * @param  array		Existing bookings to ignore (presumably the booking we're trying to make - if this is an edit).
 * @param  ?MEMBER	The member ID we are saving as (NULL: current user).
 * @return ?array		Booking details structure (NULL: error -- reshow form).
 */
function save_booking_form_to_db($request, $ignore_bookings, $member_id = NULL)
{
    if (is_null($member_id)) {
        $member_id = get_member();
    }
    if (is_guest($member_id)) {
        fatal_exit(do_lang_tempcode('INTERNAL_ERROR'));
    }
    $test = check_booking_dates_available($request, $ignore_bookings);
    if (!is_null($test)) {
        attach_message($test, 'warn');
        return NULL;
    }
    $request = add_booking($request, $member_id);
    return $request;
}