public function orderconfirmedAction() { $request = $this->getRequest(); $orderId = $request->getParam('orderId'); $shoppingCart = new DatabaseObject_ShoppingCart($this->db); $shoppingCart->loadCartOnly($orderId); $shoppingCart->loadCartProducts(); Zend_Debug::dump($shoppingCart->products); $buyer = new DatabaseObject_User($this->db); $buyer->load($shoppingCart->buyer_id); $buyerBalanceAccountProcessor = new AccountBalanceAndRewardPointProcessor($this->db, $buyer); $danceRialto = new DatabaseObject_User($this->db); //that is the id of DanceRialto Admin $danceRialto->load(1); $danceRialtoAccountProcessor = new AccountBalanceAndRewardPointProcessor($this->db, $danceRialto); //DanceRialto load; $confirmedOrder = new DatabaseObject_Order($this->db); $confirmedOrder->order_unique_id = $shoppingCart->order_unique_id; $confirmedOrder->buyer_username = $shoppingCart->buyer_username; $confirmedOrder->buyer_id = $shoppingCart->buyer_id; $confirmedOrder->buyer_email = $shoppingCart->buyer_email; $confirmedOrder->buyer_name = $shoppingCart->buyer_name; $confirmedOrder->total_number_items = $shoppingCart->total_number_items; $confirmedOrder->reward_points_awarded = $shoppingCart->reward_points_awarded; $confirmedOrder->cart_costs = $shoppingCart->cart_costs; $confirmedOrder->total_costs = $shoppingCart->total_costs; $confirmedOrder->total_shipping_costs = $shoppingCart->total_shipping_costs; $confirmedOrder->reward_points_used = $shoppingCart->reward_points_used; $confirmedOrder->reward_amount_deducted = $shoppingCart->reward_amount_deducted; $confirmedOrder->promotion_code_used = $shoppingCart->promotion_code_used; $confirmedOrder->promotion_amount_deducted = $shoppingCart->promotion_amount_deducted; $confirmedOrder->final_total_costs = $shoppingCart->final_total_costs; $confirmedOrder->order_shipping_id = $shoppingCart->order_shipping_id; if ($confirmedOrder->save()) { //upate reward points for buyer if ($confirmedOrder->reward_points_used > 0) { $buyerBalanceAccountProcessor->updatePendingRewardPointsAndBalanceForUser('REWARD_DEDUCTION', $confirmedOrder->reward_points_used, 'from_order_id', $confirmedOrder->order_unique_id, 'Reward points used for the purchase of order id: ' . $confirmedOrder->order_unique_id); } } foreach ($shoppingCart->products as $k => $v) { $orderProfile = new DatabaseObject_OrderProfile($this->db); foreach ($v as $key => $value) { if ($key != 'profile' && $key != 'ts_created') { echo 'key is: ' . $key . ' value is:' . $value . '<br />'; $orderProfile->{$key} = $value; } elseif ($key == 'profile') { foreach ($value as $attributeKey => $attributeValue) { //$productProfile->profile->$attributeKey = $attributeValue; $orderProfile->profile->{$attributeValue}['profile_key'] = $attributeValue['profile_value']; echo "attribute key is: " . $attributeValue['profile_key'] . ' '; echo "attribute value is: " . $attributeValue['profile_value'] . '<br />'; } } } $orderProfile->dr_receivable = $orderProfile->product_price * 0.15; $orderProfile->order_id = $confirmedOrder->getId(); if ($orderProfile->save()) { //****update reward points for buyer if ($orderProfile->reward_points_awarded > 0) { $buyerBalanceAccountProcessor->updatePendingRewardPointsAndBalanceForUser('REWARD_ADDITION', $orderProfile->reward_points_awarded, 'from_order_profile_id', $orderProfile->getId(), 'Reward points awarded for the purchase of ' . $orderProfile->product_name . ' in order Id: ' . $confirmedOrder->order_unique_id); } //****update seller account balance $seller = new DatabaseObject_User($this->db); $seller->load($orderProfile->uploader_id); echo 'orderProfile uploader_id is: ' . $seller->getId(); //Zend_Debug::dump($seller); $sellerBalanceAccountProcessor = new AccountBalanceAndRewardPointProcessor($this->db, $seller); echo 'account processor user: '******'BALANCE_ADDITION', $orderProfile->seller_receivable, 'from_order_profile_id', $orderProfile->getId(), 'Balance addition from the sale of ' . $orderProfile->product_name . ' in order Id: ' . $orderProfile->order_unique_id); //update balance for DR. $danceRialtoAccountProcessor->updatePendingRewardPointsAndBalanceForUser('BALANCE_ADDITION', $orderProfile->dr_receivable, 'from_order_profile_id', $orderProfile->getId(), 'Balance addition from the sale of ' . $orderProfile->product_name . ' in order Id: ' . $orderProfile->order_unique_id); } $orderProfileStatusAndDelivery = new DatabaseObject_OrderProfileStatusAndDelivery($this->db); $orderProfileStatusAndDelivery->order_profile_id = $orderProfile->getId(); $orderProfileStatusAndDelivery->save(); } //now at deleting the shopping cart after completion. foreach ($shoppingCart->products as $k => $v) { $shoppingCartProfile = new DatabaseObject_ShoppingCartProfile($this->db); $shoppingCartProfile->load($k); $shoppingCartProfile->delete(); } //echo 'shoppingcart->rewardPointsUsed: '.$shoppingCart->reward_points_used; //$rewardPoints = 0-$shoppingCart->reward_points_used; //echo'shopping cart reward point is: '.$rewardPoints.'<br />'; //DatabaseObject_Helper_UserManager::addRewardPointToUser($this->db, $this->signedInUserSessionInfoHolder->generalInfo->referee_id, $rewardPoints, "Reward points used for the purchase of order: $confirmedOrder->order_unique_id", $_SERVER['REMOTE_ADDR'], $this->signedInUserSessionInfoHolder->generalInfo->username, $this->signedInUserSessionInfoHolder->generalInfo->userID, $this->signedInUserSessionInfoHolder->generalInfo->referee_id); $shoppingCart->delete(); }
public function markorderasupdatedorcancelledAction() { //there are still tracking id problems. $this->adminOrders = new Zend_Session_Namespace('adminOrders'); $orderItemId = $this->getRequest()->getParam('id'); $product = new DatabaseObject_OrderProfile($this->db); if ($product->load($orderItemId)) { //Load dance rialto $danceRialto = new DatabaseObject_User($this->db); //that is the id of DanceRialto Admin $danceRialto->load(1); $danceRialtoAccountProcessor = new AccountBalanceAndRewardPointProcessor($this->db, $danceRialto); //load seller. $seller = new DatabaseObject_User($this->db); $seller->load($product->uploader_id); echo 'orderProfile uploader_id is: ' . $seller->getId(); //Zend_Debug::dump($seller); $sellerBalanceAccountProcessor = new AccountBalanceAndRewardPointProcessor($this->db, $seller); //load buyer $buyer = new DatabaseObject_User($this->db); $buyer->load($product->buyer_id); $buyerAccountBalanceAndRewardPointProcessor = new AccountBalanceAndRewardPointProcessor($this->db, $buyer); if ($product->orderStatus->order_status == 'ORDER_COMPLETED' || $product->orderStatus->order_status == 'HELD_BY_SELLER_FOR_ARBITRATION_APPROVED') { $product->orderStatus->order_status = 'BALANCE_UPDATED'; //$product->orderStatus->product_delivered_date=date('Y-m-d',mktime(0,0,0,date("m"),date("d"),date("Y"))); //$this->messenger->addMessage($product->late_delivery_confirmation_date); //$this->messenger->addMessage('shipped delivered'); if ($product->orderStatus->save()) { //update profile status tracking DatabaseObject_Helper_Admin_OrderManager::updateStatusTracking($this->db, $orderItemId, 'BALANCE_UPDATED'); //buyer reward points gets posted $buyerTrackingId = DatabaseObject_Account_UserPendingRewardPointAndBalanceTracking::loadTrackingIdByColumnId($this->db, $product->buyer_id, 'from_order_profile_id', $orderItemId); foreach ($buyerTrackingId as $k => $v) { $buyerAccountBalanceAndRewardPointProcessor->postPendingRewardPointsAndBalanceForUser($v['user_pending_reward_point_and_balance_tracking_id']); } //***seller balance gets posted $sellerTrackingId = DatabaseObject_Account_UserPendingRewardPointAndBalanceTracking::loadTrackingIdByColumnId($this->db, $product->uploader_id, 'from_order_profile_id', $orderItemId); foreach ($sellerTrackingId as $k => $v) { $sellerBalanceAccountProcessor->postPendingRewardPointsAndBalanceForUser($v['user_pending_reward_point_and_balance_tracking_id']); } //***danceRialto balance gets posted $DRtrackingId = DatabaseObject_Account_UserPendingRewardPointAndBalanceTracking::loadTrackingIdByColumnId($this->db, $danceRialto->getId(), 'from_order_profile_id', $orderItemId); foreach ($DRtrackingId as $k => $v) { $danceRialtoAccountProcessor->postPendingRewardPointsAndBalanceForUser($v['user_pending_reward_point_and_balance_tracking_id']); } echo 'complted'; } $this->adminOrders->orderProfiles->balanceUpdatedOrders[$orderItemId] = $this->adminOrders->orderProfiles->orderCompletedOrders[$orderItemId]; unset($this->adminOrders->orderProfiles->orderCompletedOrders[$orderItemId]); $this->messenger->addMessage('Balance transfered'); } else { if ($product->orderStatus->order_status == 'RETURN_COMPLETED' || $product->orderStatus->order_status == 'CANCELLED_BY_SELLER' || $product->orderStatus->order_status == 'CANCELLED_BY_BUYER' || $product->orderStatus->order_status == 'HELD_BY_SELLER_FOR_ARBITRATION_DENIED') { $product->orderStatus->order_status = 'BALANCE_REFUNDED'; $this->messenger->addMessage($product->late_return_delivery_confirmation_date); if ($product->orderStatus->save()) { //update profile status tracking DatabaseObject_Helper_Admin_OrderManager::updateStatusTracking($this->db, $orderItemId, 'BALANCE_REFUNDED'); //***Buyer balance gets posted and updated. $buyerTrackingId = $buyerAccountBalanceAndRewardPointProcessor->updatePendingRewardPointsAndBalanceForUser('BALANCE_ADDITION', $product->seller_receivable + $product->dr_receivable, 'from_order_profile_id', $product->getId(), 'Balance addition from the refund of ' . $product->product_name . ' in order Id: ' . $product->order_unique_id); $buyerAccountBalanceAndRewardPointProcessor->postPendingRewardPointsAndBalanceForUser($buyerTrackingId); //***Buyer reward points gets cancelled. $buyerTrackingIdArray = DatabaseObject_Account_UserPendingRewardPointAndBalanceTracking::loadTrackingIdByColumnId($this->db, $product->buyer_id, 'from_order_profile_id', $orderItemId); foreach ($buyerTrackingIdArray as $k => $v) { $buyerAccountBalanceAndRewardPointProcessor->cancelPendingRewardPointsAndBalanceForUser($v['user_pending_reward_point_and_balance_tracking_id']); } //***Seller balance gets cancelled. $sellerTrackingIdArray = DatabaseObject_Account_UserPendingRewardPointAndBalanceTracking::loadTrackingIdByColumnId($this->db, $product->uploader_id, 'from_order_profile_id', $orderItemId); foreach ($sellerTrackingIdArray as $k => $v) { $sellerBalanceAccountProcessor->cancelPendingRewardPointsAndBalanceForUser($v['user_pending_reward_point_and_balance_tracking_id']); } //***danceRialto balance gets Cancelled $DRtrackingIdArray = DatabaseObject_Account_UserPendingRewardPointAndBalanceTracking::loadTrackingIdByColumnId($this->db, $danceRialto->getId(), 'from_order_profile_id', $orderItemId); foreach ($DRtrackingIdArray as $k => $v) { $danceRialtoAccountProcessor->cancelPendingRewardPointsAndBalanceForUser($v['user_pending_reward_point_and_balance_tracking_id']); } echo 'return complted'; } $this->messenger->addMessage('Balance refunded'); $this->adminOrders->orderProfiles->balanceRefundedOrders[$orderItemId] = $this->adminOrders->orderProfiles->returnCompletedOrders[$orderItemId]; unset($this->adminOrders->orderProfiles->returnCompletedOrders[$orderItemId]); } } //$this->_redirect($_SERVER['HTTP_REFERER']); //verifying the cart completion $cartCompletion = $buyerAccountBalanceAndRewardPointProcessor->checkCartCompletion($product->order_unique_id); if ($cartCompletion['processed'] == true) { echo 'here'; $buyerCartPendingTrackingIdArray = DatabaseObject_Account_UserPendingRewardPointAndBalanceTracking::loadTrackingIdByColumnId($this->db, $product->buyer_id, 'from_order_id', $product->order_unique_id); if (count($buyerCartPendingTrackingIdArray) > 0) { Zend_Debug::dump($buyerCartPendingTrackingIdArray); if ($cartCompletion['allCancelled'] == true) { echo 'cancel the cart pending info<br />'; $buyerAccountBalanceAndRewardPointProcessor->cancelPendingRewardPointsAndBalanceForUser($buyerCartPendingTrackingIdArray[0]['user_pending_reward_point_and_balance_tracking_id']); } elseif ($cartCompletion['allCancelled'] == false) { echo 'post the cart pending info<br />'; $buyerAccountBalanceAndRewardPointProcessor->postPendingRewardPointsAndBalanceForUser($buyerCartPendingTrackingIdArray[0]['user_pending_reward_point_and_balance_tracking_id']); } } } } else { $this->messenger->addMessage('not even loaded'); } $this->_redirect($_SERVER['HTTP_REFERER']); }
public static function verifiyShoppingInput($db, $username, $productID, $databaseColumn, $productType) { $user = new DatabaseObject_User($db); if (!$user->loadByUsername($username, 'clubAdmin', 'L')) { echo "no such club"; return false; } echo "you are at after loadbyusername"; echo "<br/>userID is: " . $user->getID(); if ($productType == 'product') { $product = new DatabaseObject_Product($db); } elseif ($productType == 'event') { $product = new DatabaseObject_Event($db); } elseif ($productType == 'due') { $product = new DatabaseObject_UniversalDue($db); } elseif ($productType == 'individualDue') { $product = new DatabaseObject_IndividualDue($db); } if (!DatabaseObject_StaticUtility::loadObjectForUser($product, $user->getId(), $productID, $databaseColumn)) { //echo "no such product exist"; return false; } if (empty($_SESSION['shoppingClubID'])) { return $product; } elseif (!empty($_SESSION['shoppingClubID']) && $product->user_id == $_SESSION['shoppingClubID']) { return $product; } else { return false; } }
public function imagesAction() { $request = $this->getRequest(); $json = array(); $user_id = (int) $request->getPost('id'); $user = new DatabaseObject_User($this->db); if (!$user->load(Zend_Auth::getInstance()->getIdentity()->userID)) { $this->_redirect($this->getUrl()); } if ($request->getPost('upload')) { $fp = new FormProcessor_Image($user); if ($fp->process($request)) { $this->messenger->addMessage('Image uploaded'); } else { foreach ($fp->getErrors() as $error) { $this->messenger->addMessage($error); } } } elseif ($request->getPost('reorder')) { $order = $request->getPost('post_images'); $options = array('user_id' => Zend_Auth::getInstance()->getIdentity()->userID); //loading images $images = DatabaseObject_Image::GetImages($this->db, $options, 'user_id', 'users_profiles_images'); $user->images = $images; $user->setImageOrder($order); } elseif ($request->getPost('delete')) { $image_id = (int) $request->getPost('image'); $image = new DatabaseObject_Image($this->db); if ($image->loadForPost($user->getId(), $image_id)) { $image->delete(); //the files are unlinked/deleted at preDelete. //echo "image at delete"; if ($request->isXmlHttpRequest()) { $json = array('deleted' => true, 'image_id' => $image_id); } else { $this->messenger->addMessage('Image deleted'); } } } if ($request->isXmlHttpRequest()) { $this->sendJson($json); } else { $url = $this->getUrl('details'); $this->_redirect($url); } }