/**
  * Create Order by array
  *
  * @param mixed $data
  * @return bool|int|null|string
  */
 public function createOrder($data)
 {
     global $db;
     $newID = $db->insertFromArray(TABLE_SHOP_ORDERS, $data);
     if ($newID) {
         //Create bitcoin transaction
         BuckysBitcoinTransaction::addTransaction($data['sellerID'], $data['buyerID'], BuckysBitcoinTransaction::ACTIVITY_TYPE_PRODUCT_PURCHASE, $newID, $data['totalPrice']);
         $shopProdIns = new BuckysShopProduct();
         $product = $shopProdIns->getProductById($data['productID']);
         if (!$product['isDownloadable']) {
             $shopProdIns->updateProduct($data['productID'], ['status' => BuckysShopProduct::STATUS_SOLD]);
         }
         //Send notification if the seller wants to get notification
         $notificationIns = new BuckysShopNotification();
         $notificationIns->createNotification($data['sellerID'], $data['buyerID'], BuckysShopNotification::ACTION_TYPE_PRODUCT_SOLD, $newID);
         return $newID;
     }
     return false;
 }
Esempio n. 2
0
<?php

require dirname(dirname(__FILE__)) . '/includes/bootstrap.php';
if (!($userID = buckys_is_logged_in())) {
    buckys_redirect('/index.php', MSG_NOT_LOGGED_IN_USER, MSG_TYPE_ERROR);
}
buckys_enqueue_stylesheet('shop.css');
buckys_enqueue_javascript('shop.js');
$TNB_GLOBALS['content'] = 'shop/sold';
$TNB_GLOBALS['headerType'] = 'shop';
//Update sold notification as read
$notificationIns = new BuckysShopNotification();
$notificationIns->markAsRead($userID, BuckysShopNotification::ACTION_TYPE_PRODUCT_SOLD);
$paramCurrentPage = get_secure_integer(isset($_REQUEST['page']) ? $_REQUEST['page'] : null);
$paramType = get_secure_string(isset($_REQUEST['type']) ? $_REQUEST['type'] : "");
$view = [];
$orderIns = new BuckysShopOrder();
$view['sold'] = $orderIns->getSold($userID);
//Update Sold product as read
$orderIns->updateSoldAsRead($userID);
$view['sold'] = fn_buckys_pagination($view['sold'], '/shop/sold.php', $paramCurrentPage, COMMON_ROWS_PER_PAGE);
$TNB_GLOBALS['title'] = 'My Sold Items - BuckysRoomShop';
require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
        ?>
" id="trade-notify-icon">
                        <span class="dropDownNotificationList">
                            <?php 
        render_footer_link_content('trade', $newTradeNotify);
        ?>
                        </span>
                    </span>
                <?php 
    } else {
        echo '<span class="notificationLinks inactive-notify no-data" id="trade-notify-icon"><span class="dropDownNotificationList"><span class="nodata">Nothing to see here</span></span></span>';
    }
    ?>

                <?php 
    $shopNotiIns = new BuckysShopNotification();
    $newMsgFlag = 1;
    $newMsgNum = $shopNotiIns->getNumOfNewMessages($userID, null, $newMsgFlag);
    if ($newMsgNum == 0) {
        $newMsgFlag = 0;
        $newMsgNum = $shopNotiIns->getNumOfNewMessages($userID, null, $newMsgFlag);
    }
    if ($newMsgNum && $newMsgNum > 0) {
        $newShopNotify = $shopNotiIns->getReceivedMessages($userID, null, $newMsgFlag, $notificationLimit);
        ?>
                    <span class="notificationLinks <?php 
        if ($newMsgFlag == 0) {
            echo 'inactive-notify';
        }
        ?>
" id="shop-notify-icon">
$type = isset($_REQUEST['type']) ? strtolower($_REQUEST['type']) : null;
if (isset($_POST['action']) && $_POST['action'] == 'read') {
    switch ($type) {
        case 'my':
            BuckysActivity::markReadNotifications($userID);
            $notiData = BuckysActivity::getNotifications($userID, $notificationLimit, 0);
            $result['content'] = render_footer_link_content($type, $notiData, false);
            break;
        case 'forum':
            BuckysForumNotification::makeNotificationsToRead($userID);
            $notiData = BuckysForumNotification::getNewNotifications($userID, 0, $notificationLimit);
            $result['content'] = render_footer_link_content($type, $notiData, false);
            break;
        case 'trade':
            $tradeNotiIns = new BuckysTradeNotification();
            $tradeNotiIns->markAsRead($userID);
            $notiData = $tradeNotiIns->getReceivedMessages($userID, null, 0, $notificationLimit);
            $result['content'] = render_footer_link_content($type, $notiData, false);
            break;
        case 'shop':
            $shopNotiIns = new BuckysShopNotification();
            $shopNotiIns->markAsRead($userID);
            $notiData = $shopNotiIns->getReceivedMessages($userID, null, 0, $notificationLimit);
            $result['content'] = render_footer_link_content($type, $notiData, false);
            break;
    }
    echo json_encode($result);
    exit;
}
echo MSG_INVALID_REQUEST;
exit;