コード例 #1
0
ファイル: WheelController.php プロジェクト: romeo14/pow
 public function actionAllwheels()
 {
     $userId = Yii::app()->user->id;
     $userId = 2;
     $wheelDetails = array();
     $allWheels = WheelApi::getWheelsByUserId($userId);
     $i = 0;
     foreach ($allWheels as $allWheel) {
         $wheelArray[$i++] = $allWheel->id;
     }
     $wheelImages = ImagesApi::getPrimaryImageForWheels($wheelArray);
     $wheelDefaultImage = ImageUtils::getDefaultImage('wheel');
     if ($allWheels) {
         foreach ($allWheels as $wheel) {
             $color = ColorApi::getColorById($wheel->color_id);
             $make = MakeApi::getMakeById($wheel->make_id);
             $model = ModelApi::getModelById($wheel->model_id);
             $entityId = EntityApi::getIdByType('WHEEL');
             $wheelRate = FeedbackApi::getRating($wheel->id, $entityId, 'WHEEL');
             $wheelRides = RidesApi::getCountOfWheelRides($wheel->id);
             $wheelPals = WheelApi::getNoOfPalsMetByWheelId($wheel->id);
             $wheelEcoMiles = RidesApi::getEcoMilesDrivenByWheel($wheel->id);
             $wheelRidesCount = 0;
             $wheelNotification = RidesApi::getUpcomingWheelRides($wheel->id);
             if ($wheelNotification) {
                 $wheelRidesCount = count($wheelNotification);
             }
             $wheelDetails[$wheel->id] = array('color' => $color->color, 'make' => $make->make, 'model' => $model->model, 'rate' => round($wheelRate), 'wheelRides' => $wheelRides, 'wheelPals' => $wheelPals[0]['palcnt'], 'wheelEcoMiles' => $wheelEcoMiles, 'wheelRidesCount' => $wheelRidesCount);
         }
     }
     $this->render('allwheels', array('allWheels' => $allWheels, 'wheelDetails' => $wheelDetails, 'wheelImages' => $wheelImages, 'wheelDefaultImage' => $wheelDefaultImage));
 }
コード例 #2
0
ファイル: AccountController.php プロジェクト: romeo14/pow
 public function actionView($id)
 {
     Yii::beginProfile('view_profile');
     //$session = Yii::app()->session;
     $wheelsImages = array();
     $wheelImages = array();
     $lastRide = array();
     $user = UserApi::getUserById($id);
     if (!$user) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $userAge = UserApi::getAge($user->dob);
     $userAddress = "";
     if ($user->city_id) {
         $userAddress = DbUtils::getAddress($user->city_id);
     }
     $imageUserId = array($id);
     $image = ImagesApi::getPrimaryImageForUsers($imageUserId);
     if ($image) {
         $userImage = $image[$id];
     } else {
         $userImage = ImageUtils::getDefaultImage('user');
     }
     $userWheelDefault = ImageUtils::getDefaultImage('wheel');
     $userRides = RidesApi::getCountOfUserRides($id);
     $userEcoMiles = RidesApi::getEcoMilesDrivenByUser($id);
     $userWheel = WheelApi::getWheelsCount($id);
     $userPalsCount = UserPalsApi::getPalsCount($id);
     $entityId = EntityApi::getIdByType("user");
     $driverRating = round(FeedbackApi::getRating($id, $entityId, 'DRIVER'));
     $passengerRating = round(FeedbackApi::getRating($id, $entityId, 'PASSENGER'));
     $userPals = UserPalsApi::getAllPals($id);
     $userPalDefaultImage = ImageUtils::getDefaultImage('user');
     $lastRide = RidesApi::getLastRide($id);
     $lastRideWheel = WheelApi::getWheelById($lastRide[0]['wheel_id']);
     $userWheels = WheelApi::getWheelsByUserId($id);
     $favoriteWheel = WheelApi::getFavouriteWheel($id);
     $userFeedback = FeedbackApi::getAllFeedback($id, $entityId);
     $favWheelDetail = "";
     $wheelMake = "";
     $wheelModel = "";
     $wheelColor = "";
     $wheelRides = "";
     $wheelEcoMiles = "";
     $wheelPals = "";
     $wheelPalCnt = "";
     if ($favoriteWheel) {
         $favWheelDetail = WheelApi::getWheelById($favoriteWheel[0]["wheel_id"]);
         $wheelMake = MakeApi::getMakeById($favWheelDetail->make_id);
         $wheelModel = ModelApi::getModelById($favWheelDetail->model_id);
         $wheelColor = ColorApi::getColorById($favWheelDetail->color_id);
         $wheelRides = RidesApi::getCountOfWheelRides($favWheelDetail->id);
         $wheelImage = ImagesApi::getPrimaryImageForWheels(array($favoriteWheel[0]["wheel_id"]));
         if (!$wheelImage) {
             $wheelImage = $userWheelDefault;
         }
         $wheelEcoMiles = RidesApi::getEcoMilesDrivenByWheel($favWheelDetail->id);
         $wheelPals = WheelApi::getNoOfPalsMetByWheelId($favWheelDetail->id);
         $wheelPalCnt = $wheelPals[0]['palcnt'];
     }
     $i = 0;
     if ($userFeedback) {
         foreach ($userFeedback as $feedback) {
             $fromUserProfile = UserApi::getUserById($feedback->from_user_id);
             $fromUserIds[$i] = $feedback->from_user_id;
             $userName = UserApi::getNameByUserId($fromUserProfile->id);
             $userFeedbackDetails[$i++] = array('from_id' => $feedback->from_user_id, 'userName' => $userName, 'feedback' => $feedback->feedback);
         }
     }
     $i = 0;
     $j = 0;
     $userPalList = "";
     $palScrollLabel = "";
     $mergeArray = array_merge($userPals, $fromUserIds);
     $userIdList = array_unique($mergeArray);
     $userImages = ImagesApi::getPrimaryImageForUsers($userIdList);
     $imageArrayIndex = array_keys($userImages);
     $imageArrayIndexSize = count($imageArrayIndex);
     //var_dump($userPals);
     // var_dump($fromUserIds);die();
     if ($userPals) {
         foreach ($userPals as $userPal) {
             $userPalList[$i++] = userapi::getUserById($userPal);
         }
     }
     if ($userIdList) {
         foreach ($userIdList as $userId) {
             for ($j = 0; $j < $imageArrayIndexSize; $j++) {
                 $palsImages[$userId] = '';
                 if ($imageArrayIndex[$j] == $userId) {
                     $palsImages[$userId] = $userImages[$userId];
                     break;
                 }
             }
             if ($palsImages[$userId] == '') {
                 $palsImages[$userId] = $userPalDefaultImage;
             }
         }
     }
     if ($userWheels) {
         foreach ($userWheels as $wheel) {
             $wheelIds[$wheel->id] = $wheel->id;
         }
         if ($wheelIds) {
             $wheelImages = ImagesApi::getPrimaryImageForWheels($wheelIds);
             if ($wheelImages) {
                 $imageArrayIndex = array_keys($wheelImages);
                 $imageArrayIndexSize = count($imageArrayIndex);
                 foreach ($wheelIds as $wheelId) {
                     for ($j = 0; $j < $imageArrayIndexSize; $j++) {
                         $wheelsImages[$wheelId] = '';
                         if ($imageArrayIndex[$j] == $wheelId) {
                             $wheelsImages[$wheelId] = $wheelImages[$wheelId];
                             break;
                         }
                     }
                     if ($wheelsImages[$wheelId] == '') {
                         $wheelsImages[$wheelId] = $userWheelDefault;
                     }
                 }
             }
         }
     }
     /*$palCntArray=ceil($userPalsCount/3);
         $l=0;
         if($userPalsCount>2){
         
         for($i=0;$i<$palCntArray-1;$i++){
             $palScroll[$i]=array($userPalList[$l],$userPalList[$l+1],$userPalList[$l+2]);
             $l=$l+3;
             }
             
         }
         while($l<$userPalsCount)
         {
         $palScroll[$palCntArray-1]=array($userPalList[$l]);
         $l++;
         }
         $palScrollLabel=$palScroll[0];
         }
         
         
       
        $k=1;
       if (isset($_POST['ajxbtn'])){
               if($k < $palCntArray) 
                $palScrollLabel=$palScroll[$k];
                $k++; 
           }
       */
     $this->render('view', array('user' => $user, 'userAddress' => $userAddress, 'userPalsCount' => $userPalsCount, 'userAge' => $userAge, 'userImage' => $userImage, 'userEcoMiles' => $userEcoMiles, 'userPals' => $userPals, 'userRides' => $userRides, 'userWheel' => $userWheel, 'driverRating' => $driverRating, 'passengerRating' => $passengerRating, 'userPalList' => $userPalList, 'favWheelDetail' => $favWheelDetail, 'wheelMake' => $wheelMake, 'wheelColor' => $wheelColor, 'wheelModel' => $wheelModel, 'wheelRides' => $wheelRides, 'wheelEcoMiles' => $wheelEcoMiles, 'wheelPalCnt' => $wheelPalCnt, 'palScrolls' => $palScrollLabel, 'palImages' => $palsImages, 'userFeedbackDetails' => $userFeedbackDetails, 'wheelsImages' => $wheelsImages, 'userWheels' => $userWheels, 'wheelImage' => $wheelImage, 'lastRide' => $lastRide, 'lastRideWheel' => $lastRideWheel));
     Yii::endProfile('view_profile');
 }