Beispiel #1
0
 public function userstatsAction()
 {
     $fitnessPromotion = new FitnessPromotionCodes();
     $fitnessUser = new FitnessUserGeneral();
     $promotionUsers = new FitnessPromotionUsers();
     //get the number of users registered through iphone and android
     $usersIphone = $fitnessUser->getIphoneUserCount();
     $usersAndroid = $fitnessUser->getAndroidUserCount();
     //get the users from website
     $usersWeb = $fitnessUser->getUserCount();
     foreach ($usersWeb as $web) {
         $usersweb[] = $web['user_id'];
     }
     //get users who have used promotion codes
     $userspromo = array();
     $usersPromotion = $promotionUsers->getPromotionUsers();
     foreach ($usersPromotion as $promo) {
         $userspromo[] = $promo['user_id'];
     }
     $usersWebFinal = array_diff($usersweb, $userspromo);
     //get all promotion ids
     $promotionsIds = $fitnessPromotion->getCodes();
     $i = 0;
     foreach ($promotionsIds as $ids) {
         $promotionsUsers[$i]['promotion_name'] = $ids['promotion_code'];
         $promoUsers = $promotionUsers->getUsersByCode($ids['id']);
         $promotionsUsers[$i]['promotion_users'] = $promoUsers[0]['count'];
         $i = $i + 1;
     }
     $this->view->usersIphone = $usersIphone['count'];
     $this->view->usersAndroid = $usersAndroid['count'];
     $this->view->usersWeb = count($usersWebFinal);
     $this->view->promotionData = $promotionsUsers;
 }
Beispiel #2
0
 /**
  * function that handles the paypal payment method
  * @params amount, userid,workout id
  * @author lekha
  * @date 3/22/2012
  * 
  */
 public function paymentpaypalAction()
 {
     $this->view->loginStatus = $this->isLoggedIn();
     //if($this->view->loginStatus == 1)
     //$this->view->memberStatus = $this->checkUserMembership();
     if ($this->isLoggedIn() == 0) {
         $this->_redirect('/index/login');
     }
     $fitnessUser = new FitnessUserGeneral();
     $fitnessWorkout = new FitnessWorkouts();
     $fitnessworkoutRate = new FitnessWorkoutRates();
     $fitnessPromotion = new FitnessPromotionCodes();
     $promotionUsers = new FitnessPromotionUsers();
     $fitnessUserSettings = new FitnessUserSettings();
     $sess = new Zend_Session_Namespace('UserSession');
     $userDetails = $fitnessUser->getUserbyUsername($sess->username);
     $workout_id = $this->_request->getParam('workout_id');
     $purchaseType = $this->_request->getParam('type');
     //get workout rate
     $workoutDetails = $fitnessWorkout->getWorkout($workout_id);
     $workoutrate = $fitnessworkoutRate->getRateByVersion(1);
     $userSettings = $fitnessUserSettings->getUserSettings($userDetails['user_id']);
     if ($userSettings['address_check'] != 1) {
         $this->_redirect('user/settings/details/1');
     }
     $this->view->loginStatus = $this->isLoggedIn();
     $this->view->siteurl = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $this->view->baseUrl();
     $this->view->user_id = $userDetails['user_id'];
     $this->view->workout_id = $workout_id;
     $this->view->purchaseType = $purchaseType;
     if ($this->_request->getPost('promotion_code') != "") {
         //check if user has used this promotion code
         //check if promotion code is active
         $checkStatus = $fitnessPromotion->checkStatus($this->_request->getPost('promotion_code'));
         if ($checkStatus['status'] == 1) {
             $checkUser = $promotionUsers->checkUser($userDetails['user_id'], $this->_request->getPost('promotion_code'));
             if ($checkUser['count'] < 1) {
                 //get the reduction in price for this promotion
                 $promoDetails = $fitnessPromotion->getpromoByCode($this->_request->getPost('promotion_code'));
                 //insert user in promo table
                 $promouserArray = array();
                 $promouserArray['promotion_id'] = $promoDetails['id'];
                 $promouserArray['promotion_code'] = $promoDetails['promotion_code'];
                 $promouserArray['user_id'] = $userDetails['user_id'];
                 $promotionUsers->addData($promouserArray);
                 $this->view->reduction = $promoDetails['price_reduction'];
                 $this->view->message = "Your discount has been applied.";
             } else {
                 $this->view->message = "You have used a promotion code previously.";
             }
         } else {
             $this->view->message = "This promotion code is not active anymore.";
         }
     }
     if ($purchaseType == 1) {
         $this->view->workout_rate = $workoutrate['rate_single_workout'];
     } else {
         $this->view->workout_rate = $workoutrate['rate_total_workout'];
     }
     $this->view->lang = $this->getDefaultLanguage();
 }