Exemple #1
0
 protected function postInsert()
 {
     $this->profile->setUserId($this->getId());
     $this->profile->save(false);
     /*$this->sendEmail('user-register.tpl');*/
     if ($this->user_type == 'admin') {
         DatabaseObject_StaticUtility::addClubNumber($this->_db, $this->university_id);
         DatabaseObject_StaticUtility::addTypeClubNumber($this->_db, $this->type_id);
     }
     /*****creat account balance now.*/
     if (!$this->accountbalanceExists()) {
         $this->accountBalanceSummary->user_id = $this->getId();
         $this->accountBalanceSummary->save(false);
     }
     unset($_SESSION['referral']);
     //remove the current referral session
     //echo "at post insert person: ".$this->referral_id;
     if ($this->referral_id != '') {
         $referralUser = new DatabaseObject_User($this->_db);
         if ($referralUser->loadByRefereeId($this->referral_id)) {
             $referralAccountAndRewardPointProcessor = new AccountBalanceAndRewardPointProcessor($this->_db, $referralUser);
             $trackingId = $referralAccountAndRewardPointProcessor->updatePendingRewardPointsAndBalanceForUser('REWARD_ADDITION', 4, 'caused_by_user_id', $this->getId(), 'Reward points awarded for the referral of user ' . $this->first_name . ' ' . $this->last_name);
             $referralAccountAndRewardPointProcessor->postPendingRewardPointsAndBalanceForUser($trackingId);
         }
         //DatabaseObject_Helper_UserManager::addRewardPointToUser($this->_db, $this->referral_id, '4', 'from referred new member registration', $_SERVER['REMOTE_ADDR'], $this->username, $this->getId(), $this->referee_id);
     }
     $userAccountBalanceAndRewardPointProcessor = new AccountBalanceAndRewardPointProcessor($this->_db, $this);
     $trackingId = $userAccountBalanceAndRewardPointProcessor->updatePendingRewardPointsAndBalanceForUser('REWARD_ADDITION', 8, 'caused_by_user_id', $this->getId(), 'Reward points awarded for registration');
     $userAccountBalanceAndRewardPointProcessor->postPendingRewardPointsAndBalanceForUser($trackingId);
     return true;
 }
 public function process(Zend_Controller_Request_Abstract $request)
 {
     // validate the username
     $this->username = trim($request->getPost('username'));
     if (strlen($this->username) == 0) {
         $this->addError('username', 'Please enter a username');
     } else {
         if (!DatabaseObject_User::IsValidUsername($this->username)) {
             $this->addError('username', 'Please enter a valid username');
         } else {
             if ($this->user->usernameExists($this->username)) {
                 $this->addError('username', 'The selected username already exists');
             } else {
                 $this->user->username = $this->username;
             }
         }
     }
     // validate first and last name
     $this->first_name = $this->sanitize($request->getPost('first_name'));
     if (strlen($this->first_name) == 0) {
         $this->addError('first_name', 'Please enter your first name');
     } else {
         $this->user->profile->first_name = $this->first_name;
     }
     $this->last_name = $this->sanitize($request->getPost('last_name'));
     if (strlen($this->last_name) == 0) {
         $this->addError('last_name', 'Please enter your last name');
     } else {
         $this->user->profile->last_name = $this->last_name;
     }
     // validate the e-mail address
     $this->email = $this->sanitize($request->getPost('email'));
     $validator = new Zend_Validate_EmailAddress();
     if (strlen($this->email) == 0) {
         $this->addError('email', 'Please enter your e-mail address');
     } else {
         if (!$validator->isValid($this->email)) {
             $this->addError('email', 'Please enter a valid e-mail address');
         } else {
             $this->user->profile->email = $this->email;
         }
     }
     // validate CAPTCHA phrase
     $session = new Zend_Session_Namespace('captcha');
     $this->captcha = $this->sanitize($request->getPost('captcha'));
     if ($this->captcha != $session->phrase) {
         $this->addError('captcha', 'Please enter the correct phrase');
     }
     if (!$this->_validateOnly && !$this->hasError()) {
         $this->user->save();
         unset($session->phrase);
     }
     return !$this->hasError();
 }
 public function indexAction()
 {
     $request = $this->getRequest();
     $q = trim($request->getQuery('q'));
     $search = array('performed' => false, 'limit' => 5, 'total' => 0, 'start' => 0, 'finish' => 0, 'page' => (int) $request->getQuery('p'), 'pages' => 1, 'result' => array());
     try {
         if (strlen($q) == 0) {
             throw new Exception('No search term specified');
         }
         $path = DatabaseObject_BlogPost::getIndexFullpath();
         $index = Zend_Search_Lucene::open($path);
         $hits = $index->find($q);
         $search['performed'] = true;
         $search['total'] = count($hits);
         $search['pages'] = ceil($search['total'] / $search['limit']);
         $search['page'] = max(1, min($search['pages'], $search['page']));
         $offset = ($search['page'] - 1) * $search['limit'];
         $search['start'] = $offset + 1;
         $search['finish'] = min($search['total'], $search['start'] + $search['limit'] - 1);
         $hits = array_slice($hits, $offset, $search['limit']);
         $post_ids = array();
         foreach ($hits as $hit) {
             $post_ids[] = (int) $hit->post_id;
         }
         $options = array('status' => DatabaseObject_BlogPost::STATUS_LIVE, 'post_id' => $post_ids);
         $posts = DatabaseObject_BlogPost::GetPosts($this->db, $options);
         foreach ($post_ids as $post_id) {
             if (array_key_exists($post_id, $posts)) {
                 $search['results'][$post_id] = $posts[$post_id];
             }
         }
         $user_ids = array();
         foreach ($posts as $post) {
             $user_ids[$post->user_id] = $post->user_id;
         }
         if (count($user_ids) > 0) {
             $options = array('user_id' => $user_ids);
             $users = DatabaseObject_User::GetUsers($this->db, $options);
         } else {
             $users = array();
         }
     } catch (Exception $ex) {
         $users = array();
     }
     if ($search['performed']) {
         $this->breadcrumbs->addStep('Search Results for ' . $q);
     } else {
         $this->breadcrumbs->addStep('Search');
     }
     $this->view->q = $q;
     $this->view->search = $search;
     $this->view->users = $users;
 }
Exemple #4
0
 /**	
  *	fetch forgotten password page: Users can request a password reset by givin their username, a new password is created and sent
  *	to user email address. Users must also activate the new password on this page by clicking the activation link in the email.
  *
  *	@param	String		$action		Defines wheather the user is asking for reset or activating the new password
  *	@param	String		$username		Username whose password will be changed
  *	@param	int			$id			Used in password activation, this is the id of user whose new password wil l be activated
  *	@param	int			$key			Md5 hash to confirm that user is following the link in activation email
  */
 public function fetchpasswordAction()
 {
     // if a user's already logged in, send them to their account home page
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_redirect('/account');
     }
     // initialize the error array
     $errors = array();
     $action = $this->getRequest()->getQuery('action');
     if ($this->getRequest()->isPost()) {
         $action = 'submit';
     }
     // check is the user requesting password reset or activating new password
     switch ($action) {
         case 'submit':
             // request new password
             // get username form post
             $username = trim($this->getRequest()->getPost('username'));
             // check that username is not empty
             if (strlen($username) == 0) {
                 $errors['username'] = '******';
             } else {
                 $user = new DatabaseObject_User($this->db);
                 // load user data
                 if ($user->load($username, 'username')) {
                     // create the new password and send email to user
                     $user->fetchPassword($this->view->language);
                     // redirect user
                     $url = '/account/fetchpassword?action=complete';
                     $this->_redirect($url);
                 } else {
                     $errors['username'] = '******';
                 }
             }
             break;
         case 'complete':
             // if user submitted the request password form
             // nothing to do, show message in view
             break;
             // activate new password
             // activate new password
         // activate new password
         // activate new password
         case 'confirm':
             $id = $this->getRequest()->getQuery('id');
             $key = $this->getRequest()->getQuery('key');
             $user = new DatabaseObject_User($this->db);
             // load user data
             if (!$user->load($id)) {
                 $errors['confirm'] = 'Error confirming new password';
             } else {
                 if (!$user->confirmNewPassword($key)) {
                     $errors['confirm'] = 'Error confirming new password';
                 }
             }
             break;
     }
     // inject the possible errors and the action to view
     $this->view->errors = $errors;
     $this->view->action = $action;
 }
 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 process(Zend_Controller_Request_Abstract $request)
 {
     $this->affiliation = $request->getPost('affiliation');
     if ($this->affiliation == '0') {
         //echo "uni name is: ".$this->university_id;
         $this->addError('university', 'Please select an university from the above list');
     } else {
         //echo "uni name is: ".$this->university_id;
         $this->user->profile->affiliation = $this->affiliation;
     }
     //validate the username
     $this->username = trim($request->getPost('username'));
     //contraint the post item from request
     //echo $this->username;
     //echo "the existance fo the user name: ".$this->user->usernameExists($this->username);
     if (strlen($this->username) == 0) {
         $this->addError('username', 'Please enter a username');
     } else {
         if (!DatabaseObject_User::IsValidUsername($this->username)) {
             $this->addError('username', 'Please enter a valid username');
         } else {
             if ($this->user->usernameExists($this->username)) {
                 $this->addError('username', 'The selected username is already taken');
             } else {
                 $this->user->username = $this->username;
                 //echo "<br/> and the current name is: ".$this->user->username;
             }
         }
     }
     //validate the user's name
     $this->first_name = $this->sanitize($request->getPost('first_name'));
     //sanitize uses FormProcessor's zend_filter funciton to clean strings.
     if (strlen($this->first_name) == 0) {
         $this->addError('first_name', 'Please enter your first name');
     } else {
         $this->user->first_name = $this->first_name;
     }
     $this->last_name = $this->sanitize($request->getPost('last_name'));
     if (strlen($this->last_name) == 0) {
         $this->addError('last_name', 'Please enter your last name');
     } else {
         $this->user->last_name = $this->last_name;
     }
     $this->email = $this->sanitize($request->getPost('email'));
     $validator = new Zend_Validate_EmailAddress();
     if (strlen($this->email) == 0) {
         $this->addError('email', 'Please enter you email address');
     } elseif (!$validator->isValid($this->email)) {
         $this->addError('email', 'Please enter a valid email address');
     } elseif ($this->user->emailExists($this->email)) {
         $this->addError('email', 'this email address is already taken, please use another email address');
     } else {
         $this->user->email = $this->email;
     }
     $this->experience = $this->sanitize($request->getPost('experience'));
     if (strlen($this->experience) == 0) {
         $this->addError('experience', 'Please enter your country');
     } else {
         $this->user->profile->experience = strtolower($this->experience);
     }
     $this->hear_about_us = $this->sanitize($request->getPost('hear_about_us'));
     if (strlen($this->hear_about_us) == 0) {
         $this->addError('hear_about_us', 'let us know how you heared about us');
     } else {
         $this->user->profile->hear_about_us = strtolower($this->hear_about_us);
     }
     $this->sex = $this->sanitize($request->getPost('sex'));
     if (strlen($this->sex) == 0) {
         $this->addError('sex', 'let us know how your gender');
     } else {
         $this->user->sex = strtolower($this->sex);
     }
     $this->password = $this->sanitize($request->getPost('password'));
     $this->confirm_password = $this->sanitize($request->getPost('confirm_password'));
     if (empty($this->password) && !empty($this->confirm_password)) {
         $this->addError('password', 'please enter the password');
     } elseif (!empty($this->password) && empty($this->confirm_password)) {
         $this->addError('confirm_password', 'please ReEnter your password above');
     } elseif ($this->password != $this->confirm_password) {
         $this->addError('confirm_password', 'the ReEntered password does not match the above passowrd');
     } elseif ($this->password == '' && $this->confirm_password == '') {
         $this->addError('password', 'please enter the password');
     } else {
         //echo "password changed";
         $this->user->password = $this->password;
     }
     if (isset($_SESSION['referral'])) {
         $this->user->referral_id = $_SESSION['referral'];
     }
     //echo $request->getPost('clubAdmin');
     //$this->user->user_type = $request->getPost('clubAdmin');
     $this->user->status = 'L';
     $this->user->type_id = 0;
     //if no erros have occured, save the user
     if (!$this->_validateOnly && !$this->hasError()) {
         //echo 'here';
         $this->user->profile->registrationIP = $_SERVER['REMOTE_ADDR'];
         $this->user->save();
         //unset($session->phrase);
     }
     //echo 'here at error';
     //echo 'has error: '.$this->hasError();
     //echo 'not has error: '.!$this->hasError();
     return !$this->hasError();
 }
 public function processtransfersAction()
 {
     $transferId = $this->getRequest()->getParam('transferId');
     $transferTracking = new DatabaseObject_Account_UserAccountBalanceTransferTracking($this->db);
     if ($transferTracking->load($transferId)) {
         echo 'here at loaded<br/>';
         if ($transferTracking->status == 'PENDING') {
             echo 'here at pending<br/>';
             $user = new DatabaseObject_User($this->db);
             $user->load($transferTracking->from_user_id);
             $userPendingBalanceProcessor = new AccountBalanceAndRewardPointProcessor($this->db, $user);
             $toUser = new DatabaseObject_User($this->db);
             $toUser->load($transferTracking->to_user_id);
             $toUserPendingBalanceProcessor = new AccountBalanceAndRewardPointProcessor($this->db, $toUser);
             if ($userPendingBalanceProcessor->postPendingRewardPointsAndBalanceForUser($transferTracking->sender_pending_tracking_id) && $toUserPendingBalanceProcessor->postPendingRewardPointsAndBalanceForUser($transferTracking->receiver_pending_tracking_id)) {
                 echo 'here at processed';
                 $transferTracking->status = 'PROCESSED';
                 $transferTracking->date_processed = date('Y-m-d G:i:s');
                 $transferTracking->save();
             }
         } else {
             echo 'not pending, can not be done';
             echo $transferTracking->status;
         }
     } else {
         echo 'here at not loaded';
     }
 }
 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 detailscompleteAction()
 {
     $user = new DatabaseObject_User($this->db);
     $user->load(Zend_Auth::getInstance()->getIdentity()->user_id);
     $this->breadcrumbs->addStep('Your Account Details', $this->getUrl('details'));
     $this->breadcrumbs->addStep('Details Updated');
     $this->view->user = $user;
 }
 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']);
 }
Exemple #11
0
 public function sendEmail($tpl, $secondUser = '', $invoiceID = '')
 {
     $templater = new Templater();
     $templater->user = $this;
     if ($secondUser != '') {
         $templater->member = $secondUser;
     }
     if ($invoiceID != '') {
         $order = new DatabaseObject_Order($this->_db);
         if ($order->loadOrderByUrl($invoiceID)) {
             if ($order->promotion_code == '') {
                 $templater->addPromo = 'true';
             } else {
                 $templater->promoCode = $order->promotion_code;
                 $templater->discount = $order->total_after_p - $order->total_before_p;
                 $templater->finalTotal = $order->total_after_p;
             }
             //echo "promotion code: ";
             $orderProfile = new Profile_Order($this->_db);
             $result = $orderProfile->loadProifleByOrderID($order->getId());
             if ($order->buyer_id > 30000000) {
                 $member = new DatabaseObject_Guest($this->_db);
                 $member->loadByID($order->buyer_id - 30000000);
                 $templater->guest = 'true';
             } else {
                 $member = new DatabaseObject_User($this->_db);
                 if ($type == 'buyer') {
                     $member->loadByUserId($order->user_id);
                     ////echo "here at odertype buyer";
                 }
             }
             echo "order status: " . $order->url . "<br/>";
             echo "count of order in that order: " . count($result) . "<br/>";
             echo $result[0]['profile_id'];
             echo $result[0]['product_name'];
             $templater->member = $member;
             $productProfile = array();
             foreach ($result as $k => $v) {
                 //echo "<br/>here0<br/>";
                 $productProfile[$result[$k]['profile_id']] = new Profile_Order($this->_db);
                 $productProfile[$result[$k]['profile_id']]->loadOrder($result[$k]['profile_id'], $order->url);
                 //echo "<br/>heels are for profile_id: ".$result[$k]['profile_id']." and heels are: ".$productProfileArray[$result[$k]['profile_id']]->orderAttribute->heel."<br/>";
                 //echo "<br/>name: ".$productProfileArray[1]->product_name;
             }
             $templater->productsProfile = $productProfile;
             $templater->invoice = $invoiceID;
             $templater->dateTime = date(date("F j, Y, g:i a"), $order->ts_created);
             $templater->finalTotal = $order->total_after_p;
             //////////////////////////////////////////////////////////////////////////////////
             /*
             					$this->orderShoppingCart = new DatabaseObject_Order($this->_db);
             					
             					$this->orderCartObject=$this->orderShoppingCart->loadOrderByUrl($invoiceID);
             					
             					if($this->orderShoppingCart->promotion_code == '')
             					{
             						$templater->addPromo = 'true';
             						$templater->total = $this->orderShoppingCart->total_before_p;
             	
             					}
             					else
             					{
             						$templater->promoCode = $this->orderShoppingCart->promotion_code;
             						$templater->total = $this->orderShoppingCart->total_before_p;
             						$templater->discount = $this->orderShoppingCart->total_after_p-$this->orderShoppingCart->total_before_p;
             						$templater->finalTotal = $this->orderShoppingCart->total_after_p;
             					}
             					
             					
             					$product = $this->orderCartObject;
             					
             					echo "count product: ".count($product);
             					$templater->shoppingCart = $this->orderShoppingCart;
             					$templater->dateTime= date(date("F j, Y, g:i a"), $this->orderShoppingCart->ts_created);
             					$templater->products = $product;
             					
             					
             					$productProfile=array();
             					
             					foreach($product as $k => $v)
             					{
             						echo $product[$k]->getId();
             						
             						$productProfile[$product[$k]['profile_id']] = new Profile_Order($this->db);
             						
             						$productProfile[$product[$k]['profile_id']]->loadOrder($product[$k]['profile_id'], $order->url);
             						
             						
             						
             															
             					}
             				
             					$templater->productsProfile=$productProfile;*/
         }
     }
     //fetch teh e-amil body
     $body = $templater->render('email/' . $tpl);
     //extract the subject from the first line
     list($subject, $body) = preg_split('/\\r|\\n/', $body, 2);
     //now set up and send teh email
     echo "here at mail" . "<br/>";
     $mail = new Zend_Mail();
     //set the to address and the user's full name in the 'to' line
     echo "the email sent out is: " . $this->email . "<br />";
     $mail->addTo($this->email, trim($this->first_name . ' ' . $this->last_name));
     //get the admin 'from details form teh config
     $mail->setFrom('*****@*****.**', 've-no-reply');
     //set the subject and boy and send the mail
     $mail->setSubject(trim($subject));
     $mail->setBodyText(trim($body));
     $mail->send();
 }
 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);
     }
 }
 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']);
             }
         }
     }
 }