public function markbuyerarbitrationstatusbysellerAction() { $request = $this->getRequest(); $this->adminOrders = new Zend_Session_Namespace('adminOrders'); $orderItemId = $this->getRequest()->getParam('id'); $decision = $this->getRequest()->getParam('decision'); if ($orderItemId != '' && is_numeric($orderItemId) && isset($orderItemId)) { $product = new DatabaseObject_OrderProfile($this->db); //must check to see if the person is seller. because a seller can approve them selves as buyers if they are not the seller. if ($product->load($orderItemId) && $this->signedInUserSessionInfoHolder->generalInfo->userID == $product->uploader_id) { if ($decision == 'APPROVED') { $product->return_allowed = true; $product->orderStatus->buyer_return_claim_approved = true; $product->orderStatus->order_status = 'HELD_BY_BUYER_FOR_ARBITRATION_APPROVED'; $product->orderStatus->buyer_return_claim_approval_date = date('Y-m-d G:i:s'); $product->orderStatus->buyer_return_claim_approved_by = 'SELLER'; $product->orderStatus->buyer_return_claim_approved_warning_shipping_date = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"))); $product->orderStatus->buyer_return_claim_approved_latest_shipping_date = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") + 4, date("Y"))); if ($product->orderStatus->save()) { DatabaseObject_Helper_Admin_OrderManager::updateStatusTracking($this->db, $orderItemId, 'HELD_BY_BUYER_FOR_ARBITRATION_APPROVED'); } $product->save(); } elseif ($decision == 'DENIED') { //$product->return_allowed= false; //$product->buyer_return_claim_approved=false; $product->orderStatus->order_status = 'HELD_BY_BUYER_FOR_ARBITRATION_DENIED_BY_SELLER'; if ($product->orderStatus->save()) { DatabaseObject_Helper_Admin_OrderManager::updateStatusTracking($this->db, $orderItemId, 'HELD_BY_BUYER_FOR_ARBITRATION_DENIED_BY_SELLER'); } //$product->save(); } } else { //logg error } } else { //logg error } }
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 ordercancellationbybuyerAction() { $request = $this->getRequest(); $cancellation_reason = $request->getParam('cancellationReason'); $productId = $request->getParam('productId'); $product = new DatabaseObject_OrderProfile($this->db); if ($product->load($productId)) { if ($product->buyer_UserID == $this->signedInUserSessionInfoHolder->generalInfo->userID && $product->product_order_status == 'unshipped' && strtotime($product->product_absolute_latest_delivery_date) < time()) { echo 'here'; $product->product_order_status = 'Cancelled by buyer'; $product->cancellation_reason = $cancellation_reason; $product->save(); $this->messenger->addMessage('You have successfully cancelled this order. The seller will be notified'); $this->_redirect($_SERVER['HTTP_REFERER']); } else { echo 'sorry but you are not able to cancel this order'; } } }