Ejemplo 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;
 }
Ejemplo n.º 2
0
 public function actionProfile($username)
 {
     $details = Contractors::model()->findByAttributes(array('Username' => $username));
     $pic = '';
     $bg = '';
     $zipcode = Yii::app()->Ini->v('zipcode');
     $projecttype = Yii::app()->Ini->v('projecttype');
     $project = Projecttypes::model()->findAll(array('order' => 'Name ASC'));
     if (count($details) > 0) {
         $this->pageTitle = 'Handyman.com - Refer ' . $details->Name;
         $criteria = new CDbCriteria();
         $criteria->condition = "contractor_id = " . $details->ContractorId;
         $photo = Contractorphotos::model()->findAll($criteria);
         $socials = ContractorSocials::model()->findAll($criteria);
         $bonds = ContractorBond::model()->findByAttributes(array('contractor_id' => $details->ContractorId));
         $license = ContractorLicense::model()->findByAttributes(array('contractor_id' => $details->ContractorId));
         if (count($photo) > 0) {
             foreach ($photo as $k => $v) {
                 if ($v->is_profile == 1) {
                     $pic = $v->filename;
                 } else {
                     if ($v->is_bg == 1) {
                         $bg = $v->filename;
                     }
                 }
             }
         }
         $this->render('refer', array('profile' => $details, 'logo' => $pic, 'bg' => $bg, 'socials' => $socials, 'bonds' => $bonds, 'license' => $license, 'zipcode' => $zipcode, 'projecttype' => $projecttype, 'project' => $project));
     } else {
         $this->redirect(Yii::app()->homeUrl);
     }
 }
Ejemplo n.º 3
0
 public function actionProfile()
 {
     $username = Yii::app()->Ini->v('user');
     $profile_details = Contractors::model()->findByAttributes(array('Username' => $username));
     $current_userid = Yii::app()->user->getId();
     $con_id = $profile_details->ContractorId;
     $criteria = new CDbCriteria();
     $criteria->condition = "contractor_id = '{$con_id}'";
     $feedback = Feedback::model()->findAll($criteria);
     $criteria_social = new CDbCriteria();
     $criteria_social->condition = "contractor_id = '{$con_id}'";
     $social_accounts = ContractorSocials::model()->findAll($criteria_social);
     $contractor_license = ContractorLicense::model()->findByAttributes(array('contractor_id' => $con_id));
     $contractor_bond = ContractorBond::model()->findByAttributes(array('contractor_id' => $con_id));
     $contractor_points = Contractors::model()->updatePoints($con_id);
     $team_members = new CDbCriteria();
     $team_members->condition = "contractor_id = '{$con_id}' AND confirmed = '1' ORDER BY RAND() LIMIT 0,5";
     $contractor_team = ContractorTeam::model()->findAll($team_members);
     if (count($profile_details) > 0) {
         $profile_details->updatePoints($profile_details->ContractorId);
         $contractor_id = $con_id;
         $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);
         $photo_cover = $this->getProfileCover($profile_details->ContractorId);
         $is_my_profile = false;
         $homeowner_projects = array();
         if (!Yii::app()->user->isGuest) {
             if ($contractor_id == $current_userid) {
                 $is_my_profile = true;
             } else {
                 /*
                 	if homeowner
                 	can send message and attach project
                 */
                 if (Yii::app()->user->role == 'homeowner') {
                     $criteria = new CDbCriteria();
                     $criteria->condition = "homeowner_id = " . $current_userid;
                     $homeowner_projects = Projects::model()->findAll($criteria);
                 }
             }
         }
         //get map location
         $address = urlencode($address1 . ',' . $city . ',' . $state . "," . $zipcode . ",USA");
         $l = explode(",", Yii::app()->Ini->GetMapLocation($address));
         $point = array($address1 . ',' . $city . ',' . $state, floatval($l[0]), floatval($l[1]), 0);
         $this->pageTitle = 'Handyman.com - Contractor - ' . $company . ' Profile';
         $this->render('contractor-profile', array('profile_exists' => true, 'contractor_id' => $contractor_id, 'company' => $company, 'contact_name' => $contact_name, 'phone' => $phone, 'fax' => $fax, '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' => "", 'logo' => $this->getContractorProfilePic($profile_details->ContractorId), 'is_my_profile' => $is_my_profile, 'contractor_license' => $contractor_license, 'contractor_bond' => $contractor_bond, 'social_accounts' => $social_accounts, 'contractor_points' => $contractor_points, 'feedback' => $feedback, 'photo_cover' => $photo_cover, 'my_gallery' => Contractorphotos::model()->findAllByAttributes(array('contractor_id' => $contractor_id, 'is_profile' => '0'), array('limit' => '6', 'order' => 'RAND()')), 'homeowner_projects' => $homeowner_projects, 'point' => $point, 'contractor_team' => $contractor_team, 'map_location' => $l));
         //update views
         if (!Yii::app()->user->isGuest) {
             $userid = Yii::app()->user->getId();
             $role = Yii::app()->user->role;
             $views = ContractorViews::model()->findByAttributes(array('viewed_by' => $userid, 'contractor_id' => $contractor_id, 'viewed_user_type' => $role));
             if (count($views) > 0) {
             } else {
                 $views = new ContractorViews();
                 $views->contractor_id = $contractor_id;
                 $views->viewed_by = $userid;
                 $views->viewed_user_type = $role;
                 $views->save();
             }
         }
     } else {
         $this->redirect(Yii::app()->homeUrl . 'home/error');
     }
 }
Ejemplo n.º 4
0
 public function actionMy_account()
 {
     if (!Yii::app()->user->isGuest) {
         if (Yii::app()->user->role == 'contractor') {
             $contractor_id = Yii::app()->user->getId();
             $this->pageTitle = 'Handyman.com - My Account';
             $param['city'] = Cities::model()->findAll(array('order' => 'Name ASC'));
             $param['state'] = States::model()->findAll(array('order' => 'Name ASC'));
             $param['page'] = "account";
             $param['cmodel'] = Contractors::model()->findByPk($contractor_id);
             //$param['csocials'] = ContractorSocials::model()->findbyAttributes(array('contractor_id' => $contractor_id));
             $socials = Socials::model()->findAll(array('order' => 'social ASC'));
             $user_socials = array();
             foreach ($socials as $k => $v) {
                 $value = ContractorSocials::model()->findbyAttributes(array('contractor_id' => $contractor_id, 'social_id' => $v->social_id));
                 if (count($value) > 0) {
                     $user_socials[$v->social_id] = $value->value;
                 } else {
                     $user_socials[$v->social_id] = "";
                 }
             }
             $param['socials'] = $socials;
             $param['user_socials'] = $user_socials;
             $param['clicense'] = ContractorLicense::model()->findbyAttributes(array('contractor_id' => $contractor_id));
             $param['cbond'] = ContractorBond::model()->findbyAttributes(array('contractor_id' => $contractor_id));
             $param['projects'] = Projecttypes::model()->findAll(array('order' => 'Name ASC'));
             $param['logo'] = $this->getContractorProfilePic($contractor_id);
             $this->render('my-account', $param);
         } else {
             $this->redirect(Yii::app()->homeUrl);
         }
     } else {
         $this->redirect(Yii::app()->homeUrl);
     }
 }
 public function updatecontractorlicense($post)
 {
     $contractor_id = Yii::app()->user->getId();
     $license_num = $post['license_num'];
     $license_status = $post['license_status'];
     $license_type = $post['license_type'];
     $license_dateissued = $post['license_dateissued'];
     $license_info = $post['license_info'];
     $clicense = ContractorLicense::model()->findbyAttributes(array('contractor_id' => $contractor_id));
     $return['error_message'] = "";
     $status = false;
     if (count($clicense) > 0) {
         $clicense->license_no = $license_num;
         $clicense->status = $license_status;
         $clicense->type = $license_type;
         $clicense->date_issued = $license_dateissued;
         $clicense->info = $license_info;
     } else {
         $clicense = new ContractorLicense();
         $clicense->contractor_id = $contractor_id;
         $clicense->license_no = $license_num;
         $clicense->status = $license_status;
         $clicense->type = $license_type;
         $clicense->date_issued = $license_dateissued;
         $clicense->info = $license_info;
     }
     if ($clicense->save()) {
         $status = true;
     } else {
         $return['error_message'] = "unable to save license update.";
     }
     $return['status'] = $status;
     $this->renderJSON($return, $status);
 }