Ejemplo n.º 1
0
 public function getGeneralPercentate($type)
 {
     $temp = 0;
     $val = 0;
     $userID = Yii::app()->user->getId();
     if ($type == 'general') {
         $model = $this->model()->findByPk($userID);
         $list = array('Gender', 'CityOrPostal', 'MobileNumber');
         foreach ($list as $val) {
             if ($model->{$val}) {
                 $temp += 1;
             }
         }
         $val = round(100 / count($list) * $temp);
     } else {
         if ($type == 'basic' || $type == 'desc') {
             if (UserInformation::model()->findByAttributes(array("UserId" => $userID))) {
                 $model = UserInformation::model()->findByAttributes(array("UserId" => $userID));
                 if ($type == 'basic') {
                     $list = array('Orientation', 'LookingFor', 'Children', 'Education', 'Occupation', 'Religion', 'Income', 'Height', 'Weight', 'Eyes', 'HairColour', 'EthnicOrigin', 'Smoke', 'MaritalStatus', 'WantChildren', 'PractisingReligion', 'Build', 'Glasses', 'FacialHair', 'Diet');
                 } else {
                     if ($type == 'desc') {
                         $list = array('UserStatus', 'AboutMe', 'IamLookingFor');
                     }
                 }
                 foreach ($list as $val) {
                     if ($model->{$val}) {
                         $temp += 1;
                     }
                     $val = round(100 / count($list) * $temp);
                 }
             }
         }
     }
     return $val;
 }