$event_data = cw_query_first("select * from {$tables['giftreg_events']} where customer_id='{$customer_id}' AND event_id='{$event_id}'");
    $event_data['allow_to_send'] = cw_query_first_cell("select count(*) from {$tables['giftreg_maillist']} where event_id='{$event_id}' AND status=1");
    $smarty->assign('event_id', $event_id);
    $search_condition = "event_id='{$event_id}'";
    $total_items_in_search = cw_query_first_cell("select count(*) from {$tables['giftreg_guestbooks']} where {$search_condition}");
    $navigation = cw_core_get_navigation($target, $total_items_in_search, $page);
    $navigation['script'] = "index.php?target=gifts&mode=events&event_id={$event_id}&js_tab=guestbook";
    $smarty->assign('navigation', $navigation);
    $guestbook = cw_query("select * from {$tables['giftreg_guestbooks']} where {$search_condition} order by date DESC LIMIT {$navigation['first_page']}, {$navigation['objects_per_page']}");
    $smarty->assign('guestbook', $guestbook);
    $mailing_list = cw_query("select * from {$tables['giftreg_maillist']} where event_id='{$event_id}' order by recipient_name, recipient_email");
    $recipients_count = cw_query_first_cell("select count(*) from {$tables['giftreg_maillist']} where event_id='{$event_id}'");
    if ($recipients_count >= $config['estore_gift']['recipients_limit']) {
        $smarty->assign('recipients_limit_reached', 1);
    }
    $smarty->assign('mailing_list', $mailing_list);
    $wl_products = cw_gift_get_giftreg_wishlist($customer_id, $event_id);
    $smarty->assign('wl_products', $wl_products);
    $location[] = array($event_data['title'], '');
} else {
    $location[] = array(cw_get_langvar_by_name('lbl_giftreg_new_event', ''));
}
$event_details_sess =& cw_session_register('event_details_sess');
if ($event_details_sess) {
    $event_data = cw_array_map('stripslashes', $event_details_sess);
    cw_session_unregister('event_details_sess');
}
$smarty->assign('event_data', $event_data);
$smarty->assign('allow_edit', 1);
$smarty->assign('js_tab', $js_tab);
$smarty->assign('main', 'event');
            $cart['giftcerts'] = array();
        }
        $cart['giftcerts'][] = cw_array_merge($giftcert, array('wishlistid' => $wlitem));
        $top_message = array('type' => 'I', 'content' => 'Wishlist item has been added to cart');
        $products = cw_call('cw_products_in_cart', array($cart, $userinfo));
        $cart = cw_func_call('cw_cart_calc', array('cart' => $cart, 'products' => $products, 'userinfo' => $userinfo));
    }
}
// Redirect
if (!empty($action)) {
    cw_header_location("index.php?target={$target}&mode={$redirect_mode}&event_id={$event_id}&js_tab={$js_tab}");
}
if ($mode == 'friends') {
    $wishlist = cw_gift_get_wishlist($wlid, true);
} else {
    $wishlist = cw_gift_get_giftreg_wishlist($customer_id, $event_id);
}
if ($mode != 'friends') {
    $events_list = cw_call('cw_gift_get_events', array($customer_id));
    $smarty->assign('events_list', $events_list);
}
$smarty->assign('event_id', $event_id);
$wl_giftcerts = cw_gift_get_giftcert_wishlist($customer_id);
if (!empty($wl_giftcerts)) {
    $smarty->assign('wl_giftcerts', $wl_giftcerts);
}
$smarty->assign('from_quote', !empty($cart['info']['quote_doc_id']) ? 1 : 0);
$smarty->assign('wl_products', $wishlist);
$smarty->assign('allow_edit', 1);
$location[] = array(cw_get_langvar_by_name('lbl_wish_list'), '');
$smarty->assign('main', 'wishlist');