Esempio n. 1
1
 public function deactivate($contractor_id)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "user_type='contractor' AND userid=" . $contractor_id;
     Affiliates::model()->deleteAll($criteria);
     Referral::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "owner_user_type='contractor' AND owner_id=" . $contractor_id;
     Answers::model()->deleteAll($criteria);
     Questions::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "user_type='contractor' AND deleted_by=" . $contractor_id;
     Messagedeleted::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "from_user_type='contractor' AND from_id=" . $contractor_id;
     Messages::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "to_user_type='contractor' AND to_id=" . $contractor_id;
     Messages::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "viewed_user_type='contractor' AND viewed_by=" . $contractor_id;
     QuestionViews::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "referred_by_type='contractor' AND referred_by=" . $contractor_id;
     Referral::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "invited_id=" . $contractor_id;
     ContractorTeam::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "contractor_id=" . $contractor_id;
     ContractorBond::model()->deleteAll($criteria);
     ContractorLicense::model()->deleteAll($criteria);
     ContractorPoints::model()->deleteAll($criteria);
     ContractorSocials::model()->deleteAll($criteria);
     ContractorTeam::model()->deleteAll($criteria);
     ContractorViews::model()->deleteAll($criteria);
     Contractorphotos::model()->deleteAll($criteria);
     Feedback::model()->deleteAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "ContractorId=" . $contractor_id;
     self::model()->deleteAll($criteria);
     return true;
 }
 public function actionTeam()
 {
     if (!Yii::app()->user->isGuest) {
         $keyword = Yii::app()->Ini->v('keyword');
         $userid = Yii::app()->user->getId();
         $limit = 6;
         $criteria = new CDbCriteria();
         $criteria->condition = "contractor_id={$userid} AND confirmed = 1";
         $criteria->order = "member_id ASC";
         $count = ContractorTeam::model()->count($criteria);
         $pages = new CPagination($count);
         $pages->pageSize = $limit;
         $pages->applyLimit($criteria);
         $result = ContractorTeam::model()->findAll($criteria);
         $param['result'] = $result;
         $param['pages'] = $pages;
         $this->render('contractor-team', $param);
     } else {
         $this->redirect(Yii::app()->homeUrl);
     }
 }
 public function accepttoteam()
 {
     $contractor_id = Yii::app()->Ini->v('contractor_id');
     $invited_id = Yii::app()->user->getId();
     $contractor_team = ContractorTeam::model()->findByAttributes(array('contractor_id' => $contractor_id, 'invited_id' => $invited_id));
     if (count($contractor_team) > 0) {
         $contractor_team->confirmed = 1;
         if ($contractor_team->save()) {
             $team2 = new ContractorTeam();
             $team2->contractor_id = $invited_id;
             $team2->invited_id = $contractor_id;
             $team2->confirmed = 1;
             $team2->save();
             $return = array('success' => true);
         } else {
             $return = array('success' => false, 'error_message' => $contractor_team->getErrors());
         }
     } else {
         $return = array('success' => false, 'error_message' => 'Not invited.');
     }
     $this->renderJSON($return);
 }
 public function actionMy_profile()
 {
     if (!Yii::app()->user->isGuest) {
         if (Yii::app()->user->role == 'contractor') {
             $contractor_id = Yii::app()->user->getId();
             $profile_details = Contractors::model()->findByAttributes(array('ContractorId' => $contractor_id));
             $criteria = new CDbCriteria();
             $criteria->condition = "contractor_id = '{$contractor_id}'";
             $feedback = Feedback::model()->findAll($criteria);
             $criteria_social = new CDbCriteria();
             $criteria_social->condition = "contractor_id = '{$contractor_id}'";
             $social_accounts = ContractorSocials::model()->findAll($criteria_social);
             $contractor_license = ContractorLicense::model()->findByAttributes(array('contractor_id' => $contractor_id));
             $contractor_bond = ContractorBond::model()->findByAttributes(array('contractor_id' => $contractor_id));
             $contractor_points = Contractors::model()->updatePoints($contractor_id);
             $team_members = new CDbCriteria();
             $team_members->condition = "contractor_id = '{$contractor_id}' AND confirmed = '1' ORDER BY RAND() LIMIT 0,5";
             $contractor_team = ContractorTeam::model()->findAll($team_members);
             if (count($profile_details) > 0) {
                 $company = $profile_details->Name;
                 $contact_name = $profile_details->ContactName;
                 $phone = $profile_details->Phone;
                 $fax = $profile_details->Fax;
                 $address1 = $profile_details->Address1;
                 $address2 = $profile_details->Address2;
                 $city = $profile_details->City;
                 $state = $profile_details->State;
                 $zipcode = $profile_details->Zip;
                 $email = $profile_details->Email;
                 $website = $profile_details->Website;
                 $about = $profile_details->AboutBusiness;
                 $services = $profile_details->Services;
                 $date_created = $profile_details->Created;
                 $username = $profile_details->Username;
                 $project_type = $this->getProjectTypeName($profile_details->ProjectTypeId);
                 $profile_pic = $this->getContractorProfilePic($contractor_id);
                 $current_userid = $profile_details->ContractorId;
                 $photo_cover = $this->getProfileCover($contractor_id);
             }
             $this->pageTitle = 'Handyman.com - ' . $contact_name . ' Profile';
             $is_my_profile = false;
             if ($contractor_id == $current_userid) {
                 $is_my_profile = true;
             }
             $this->render('my-profile', array('company' => $company, 'contact_name' => $contact_name, 'phone' => $phone, 'address1' => $address1, 'address2' => $address2, 'city' => $city, 'state' => $state, 'zipcode' => $zipcode, 'email' => $email, 'website' => $website, 'about' => $about, 'services' => $services, 'date_created' => date('F j, Y', strtotime($date_created)), 'username' => $username, 'project_type' => $project_type, 'page' => 'profile', 'param' => "", 'profile_pic' => $profile_pic, 'feedback' => $feedback, 'is_my_profile' => $is_my_profile, 'contractor_license' => $contractor_license, 'contractor_bond' => $contractor_bond, 'social_accounts' => $social_accounts, 'contractor_points' => $contractor_points, 'photo_cover' => $photo_cover, 'contractor_team' => $contractor_team, 'my_gallery' => Contractorphotos::model()->findAllByAttributes(array('contractor_id' => $contractor_id, 'is_profile' => '0'), array('limit' => '6'))));
         } else {
             $this->redirect(Yii::app()->homeUrl);
         }
     } else {
         $this->redirect(Yii::app()->homeUrl);
     }
 }