public function balancetransferAction()
 {
     $amount = $this->getRequest()->getParam('transferAmount');
     $targetUserEmail = $this->getRequest()->getParam('targetEmail');
     $message = $this->getRequest()->getParam('message');
     if ($this->getRequest()->isPost()) {
         if ($amount < $this->userObject->accountBalanceSummary->available_balance) {
             //$targetUser = new DatabaseObject_User($this->db);
             //if($targetUser->loadByEmail($targetUserEmail)){
             $userAccountBalanceAndRewardPointProcessor = new AccountBalanceAndRewardPointProcessor($this->db, $this->userObject);
             if ($userAccountBalanceAndRewardPointProcessor->transferBalance($amount, $targetUserEmail, $message)) {
                 echo 'processed';
             } else {
                 echo 'NOT processed. ERROR occured';
             }
             //}
         }
     } else {
         //not posted
     }
     $this->view->accountBalance = $this->userObject->accountBalanceSummary;
     $transfers = DatabaseObject_Helper_UserManager::loadUserTransferes($this->db, $this->userObject->getId());
     Zend_Debug::dump($transfers);
     $this->view->transfers = $transfers;
 }
 public function rewardpointsAction()
 {
     $this->view->user = $this->signedInUserSessionInfoHolder;
     $this->view->userRewardPoint = $this->userObject->reward_point;
     if (isset($this->signedInUserSessionInfoHolder->generalInfo->defaultShippingAddress->address_id)) {
         $this->view->defaultShippingKey = $this->signedInUserSessionInfoHolder->generalInfo->defaultShippingAddress->address_id;
     } else {
         echo "there is no default shipping key set in session variable";
     }
     $rewardTracking = DatabaseObject_Helper_UserManager::loadRewardPointTracking($this->db, $this->signedInUserSessionInfoHolder->generalInfo->referee_id);
     $this->view->rewardPointTracking = $rewardTracking;
     $this->breadcrumbs->addStep('Details', $this->getUrl('details', 'account'));
     if ($this->signedInUserSessionInfoHolder->generalInfo->user_type == 'generalSeller' || $this->signedInUserSessionInfoHolder->generalInfo->user_type == 'storeSeller') {
         $userReviews = DatabaseObject_Helper_UserManager::loadUserReviews($this->db, $this->signedInUserSessionInfoHolder->generalInfo->userID);
         //Zend_Debug::dump($userReviews);
         $this->view->userReviews = $userReviews;
         $this->view->numberOfReview = $this->userObject->review_count;
         $this->view->averageRating = $this->userObject->review_average_score;
     }
     $ip = $_SERVER['REMOTE_ADDR'];
     echo "ip is: " . $ip;
 }
 protected function postInsert()
 {
     DatabaseObject_Helper_UserManager::addRewardPointToUser($this->_db, $this->User_referee_id, '16', 'addition of user measurement', $_SERVER['REMOTE_ADDR'], $this->username, $this->User_referee_id, $this->User_referee_id);
     return true;
 }
 public function writereviewAction()
 {
     $request = $this->getRequest();
     $productId = $request->getParam('productId');
     $rating = $request->getParam('starRating');
     $productReview = $request->getParam('productReview');
     if ($productId == '' || $productReview == '') {
         $this->messenger->addMessage('Oops, there is an error with this request');
         echo 'badd stuff1';
         $this->_redirect($_SERVER['HTTP_REFERER']);
     } else {
         $product = new DatabaseObject_OrderProfile($this->db);
         if ($product->load($productId)) {
             if ($product->buyer_UserID == $this->signedInUserSessionInfoHolder->generalInfo->userID && $product->product_order_status == 'order completed' && $product->product_returned == 0 && $product->seller_review_written != 1) {
                 $product_user = new DatabaseObject_User($this->db);
                 $product_user->load($product->product_UserId);
                 $review = new DatabaseObject_UserReview($this->db);
                 $review->rating = $rating;
                 $review->description = $productReview;
                 $review->order_profile_id = $productId;
                 $review->order_unique_id = $product->order_unique_id;
                 $review->order_product_name = $product->product_name;
                 $review->User_id = $product->product_UserId;
                 $product_user->review_count = $product_user->review_count + 1;
                 $product_user->review_total_score = $product_user->review_total_score + $rating;
                 $product_user->review_average_score = $product_user->review_total_score / ($product_user->review_count + 1);
                 $product_user->save();
                 $review->save();
                 $product->seller_review_written = 1;
                 $product->save();
                 echo 'here';
                 //add reward points.
                 DatabaseObject_Helper_UserManager::addRewardPointToUser($this->db, $this->signedInUserSessionInfoHolder->generalInfo->referee_id, '8', 'review written for product: ' . $product->product_name . 'from order: ' . $product->order_unique_id, $_SERVER['REMOTE_ADDR'], $this->signedInUserSessionInfoHolder->generalInfo->username, $this->signedInUserSessionInfoHolder->generalInfo->userID, $this->signedInUserSessionInfoHolder->generalInfo->referee_id);
                 echo 'here2';
                 //$this->messenger->addMessage('thank you for your review. you have been rewarded the the appropriate reward points: '.$review->rating);
                 $this->_redirect($_SERVER['HTTP_REFERER']);
             } else {
                 $this->messenger->addMessage('We are sorry, but you are not able to write a review for this product order');
                 echo 'sorry, bad stuff';
                 $this->_redirect($_SERVER['HTTP_REFERER']);
             }
         }
     }
 }
示例#5
0
 public function process(Zend_Controller_Request_Abstract $request)
 {
     $this->receiver_User_id = $request->getParam('receiver_User_id');
     $this->receiver_Username = $request->getParam('receiver_Username');
     $this->product_id = $request->getParam('product_id');
     $this->receiver_name = $request->getParam('receiver_name');
     $this->sender_name = $request->getParam('sender_name');
     //find out receiver_email from ID and not from getParam;
     if ($this->receiver_User_id != '') {
         $this->receiver_email = DatabaseObject_Helper_UserManager::loadUserEmail($this->db, $this->receiver_User_id);
     } else {
         $this->receiver_email = $request->getParam('receiver_email');
     }
     if (strlen($this->receiver_email) == 0) {
         $this->addError('receiver_email', 'Internal error.');
     }
     if (strlen($this->sender_name) == 0) {
         $this->addError('sender_name', 'Please enter a valid message name');
     }
     $this->sender_email = $request->getParam('sender_email');
     $validator = new Zend_Validate_EmailAddress();
     if (strlen($this->sender_email) == 0) {
         $this->addError('sender_email', 'Please enter you email address');
     } elseif (!$validator->isValid($this->sender_email)) {
         $this->addError('sender_email', 'Please enter a valid email address');
     } else {
         $this->removeError('sender_email');
     }
     $this->sender_subject = $request->getParam('sender_subject');
     if (strlen($this->sender_subject) == 0) {
         $this->addError('sender_subject', 'Please enter a valid message subject');
     }
     //$this->sender_user_receive_notification = 1;
     //$this->sender_user_id = $request->getParam('sender_user_id');
     $this->sender_message = $request->getParam('sender_message');
     if (strlen($this->sender_message) == 0) {
         $this->addError('sender_message', 'Please enter a valid message');
     }
     if (!$this->hasError()) {
         $this->sender->receiver_User_id = $this->receiver_User_id;
         $this->sender->receiver_username = $this->receiver_Username;
         $this->sender->receiver_email = $this->receiver_email;
         $this->sender->receiver_name = $this->receiver_name;
         $this->sender->product_id = $this->product_id;
         $this->sender->sender_name = $this->sender_name;
         $this->sender->sender_email = $this->sender_email;
         $this->sender->sender_subject = $this->sender_subject;
         if ($this->loggedInUser) {
             //echo 'here at loggedInUser isset';
             $this->sender->sender_username = $this->sender_username;
             $this->sender->sender_user_id = $this->sender_user_id;
             //echo 'USER_ID IS:'.$this->sender_user_id;
         }
         $this->sender->sender_message = $this->sender_message;
         $this->sender->save();
         $this->receiver->receiver_User_id = $this->receiver_User_id;
         $this->receiver->receiver_username = $this->receiver_Username;
         $this->receiver->receiver_email = $this->receiver_email;
         $this->receiver->receiver_name = $this->receiver_name;
         $this->receiver->product_id = $this->product_id;
         $this->receiver->sender_name = $this->sender_name;
         $this->receiver->sender_email = $this->sender_email;
         $this->receiver->sender_subject = $this->sender_subject;
         if ($this->loggedInUser) {
             //echo 'here at loggedInUser isset';
             $this->receiver->sender_username = $this->sender_username;
             $this->receiver->sender_user_id = $this->sender_user_id;
             //echo 'USER_ID IS:'.$this->sender_user_id;
         }
         $this->receiver->sender_message = $this->sender_message;
         $this->receiver->save();
     }
     return !$this->hasError();
 }