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);
     }
 }
 public function actionTest()
 {
     $this->pageTitle = 'Handyman.com - My Profile';
     $contractor_id = Yii::app()->user->getId();
     $profile_details = Contractors::model()->findByAttributes(array('ContractorId' => $contractor_id));
     $this->render('test', array());
 }
 private function sendEmailNotification($subject, $message, $contractor_id, $domain_name)
 {
     $receiver_details = Contractors::model()->findByPk($contractor_id);
     $receiver_name = $receiver_details->Name;
     $receiver_email = $receiver_details->Email;
     $subject = Yii::app()->name . " - " . $subject;
     $content = $this->renderPartial('message_notif_template', array('domain_name' => $domain_name, 'message' => $message, 'receiver_name' => $receiver_name), true);
     $headers = "From: admin <admin@>" . Yii::app()->name . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8";
     $receiver_email = "*****@*****.**";
     mail($receiver_email, $subject, $content, $headers);
 }
Example #4
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     if ($this->role == "homeowner") {
         $user = Homeowners::model()->findByAttributes(array('email' => $this->username));
         if ($user === null) {
             // No user found!
             $this->errorMessage = self::ERROR_USERNAME_INVALID;
         } else {
             if ($user->password !== $this->password) {
                 // Invalid password!
                 $this->errorMessage = self::ERROR_PASSWORD_INVALID;
             } else {
                 // Okay!
                 $this->errorMessage = self::ERROR_NONE;
                 // Store the role in a session:
                 $this->setState('role', $this->role);
                 $this->setState('loginname', $user->firstname);
                 $this->_id = $user->homeowner_id;
                 $this->_username = $user->username;
             }
         }
     } else {
         $user = Contractors::model()->findByAttributes(array('Email' => $this->username));
         if ($user === null) {
             // No user found!
             $this->errorMessage = self::ERROR_USERNAME_INVALID;
         } else {
             if ($user->Password !== $this->password) {
                 // Invalid password!
                 $this->errorMessage = self::ERROR_PASSWORD_INVALID;
             } else {
                 // Okay!
                 $this->errorMessage = self::ERROR_NONE;
                 // Store the role in a session:
                 $this->setState('role', $this->role);
                 $this->setState('loginname', $user->ContactName);
                 $this->_id = $user->ContractorId;
                 $this->_username = $user->Username;
             }
         }
     }
     return !$this->errorMessage;
 }
 public function actionIndex()
 {
     //Yii::app()->name
     if (Yii::app()->user->isGuest || Yii::app()->user->role == 'homeowner') {
         $domain_name = 'handyman.com';
         $domainid = 10231;
         $banner_redirect = "http://handyman.com";
         $banners = array('http://referrals.contrib.com/banners/badge-handyman-1.png', 'http://referrals.contrib.com/banners/handyman-badge-1.png', 'http://referrals.contrib.com/banners/handyman-badge-3.png', 'http://referrals.contrib.com/banners/handyman-badge-9.png', 'http://referrals.contrib.com/banners/handyman-badge-12.png');
         $data = array('domain' => 'handyman.com', 'logo' => 'http://d2qcctj8epnr7y.cloudfront.net/images/2013/logo-handyman-1.png', 'domain_affiliate_link' => 'http://referrals.contrib.com/idevaffiliate.php?id=' . $domainid . '&url=http://www.contrib.com/signup/firststep?domain=' . $domain_name, 'title' => 'Handyman', 'domainid' => $domainid, 'banners' => $banners, 'redirect' => $banner_redirect);
         $this->render('referral', $data);
     } else {
         $contractor_id = Yii::app()->user->getId();
         $contractor = Contractors::model()->findbyPk($contractor_id);
         $data['username'] = $contractor->Username;
         $data['base_url'] = Yii::app()->request->baseUrl;
         $ContractorId = $contractor->ContractorId;
         $affiliate = Affiliates::model()->findByAttributes(array('userid' => $ContractorId, 'user_type' => 'contractor'));
         $data['aff_id'] = $affiliate->affiliate_id;
         $data['url'] = Yii::app()->Ini->getaffiliatelogin(Yii::app()->user->role, Yii::app()->user->getId());
         $this->render('referral_login', $data);
     }
 }
 public function actionPhotos()
 {
     $username = Yii::app()->Ini->v('user');
     $profile_details = Contractors::model()->findByAttributes(array('Username' => $username));
     $current_userid = Yii::app()->user->getId();
     $contractor_id = $profile_details->ContractorId;
     $company = $profile_details->Name;
     $is_my_profile = false;
     if (!Yii::app()->user->isGuest) {
         if ($contractor_id == $current_userid) {
             $is_my_profile = true;
         }
     }
     $this->render('contractor-photos', array('is_my_profile' => $is_my_profile, 'company' => $company, 'my_gallery' => Contractorphotos::model()->findAllByAttributes(array('contractor_id' => $contractor_id, 'is_profile' => '0'))));
 }
Example #7
0
 public function actionAddusername()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "Username IS NULL";
     $criteria->order = 'ContractorId ASC';
     $users = Contractors::model()->findAll($criteria);
     foreach ($users as $k => $v) {
         $model = Contractors::model()->findByPk($v->ContractorId);
         $username = strtolower(str_replace(' ', '', $v->ContactName));
         $username = substr($username, 0, 8) . "-" . $v->ContractorId;
         $model->Username = $username;
         $model->save();
         echo 'saved ' . $v->Email . "<br>";
     }
 }
 public function actionSearchcontractor()
 {
     $zipcode = Yii::app()->Ini->v('zipcode');
     $projecttype = Yii::app()->Ini->v('projecttype');
     $home_advisor_results = false;
     if (!empty($projecttype)) {
         $details = Projecttypes::model()->findByAttributes(array('ProjectTypeId' => $projecttype));
         if (count($details) > 0) {
             $oid = $details->OID;
             $city_name = $details->Name;
             $home_advisor = Yii::app()->Ini->searchhomeadvisor($zipcode, $oid);
             if ($home_advisor == false) {
                 $home_advisor_results = false;
             } else {
                 $home_advisor_results = $home_advisor['serviceProvider'];
             }
         }
     }
     $criteria = new CDbCriteria();
     if ($zipcode > 0 && empty($projecttype)) {
         //no project type
         $criteria->condition = "Zip=" . $zipcode;
         $title = "In zipcode " . $zipcode;
     }
     if (empty($zipcode) && !empty($projecttype)) {
         //no zipcode
         $criteria->condition = "ProjectTypeId=" . $projecttype;
         $title = $this->getProjectTypeName($projecttype);
     } else {
         if ($zipcode > 0 && !empty($projecttype)) {
             //both are provided
             $criteria->condition = "ProjectTypeId=" . $projecttype . " AND Zip=" . $zipcode;
             $title = $this->getProjectTypeName($projecttype) . " In zipcode " . $zipcode;
         } else {
             if (empty($zipcode) && empty($projecttype)) {
                 //both are missing
                 $criteria->order = 'RAND()';
                 $title = "";
             }
         }
     }
     $criteria->limit = 10;
     $criteria->order = 'ContractorId DESC';
     $models = Contractors::model()->findAll($criteria);
     $param = array();
     $param['home_advisor_results'] = $home_advisor_results;
     $param['contractors'] = $models;
     $param['title'] = $title;
     $this->render('/refer/refer-find-result', $param);
 }
?>
				   
				   	<?php 
if (count($contractor_team) > 0) {
    ?>
					
					
                    <div class="panel panel-default panel-style1">
                        <div class="panel-heading">Team</div>
                        <div class="panel-body">
						
						<?php 
    foreach ($contractor_team as $k => $v) {
        ?>
						<?php 
        $team_name = Contractors::model()->findByAttributes(array('ContractorId' => $v->invited_id));
        $contractorphotos = Contractorphotos::model()->findByAttributes(array('contractor_id' => $v->invited_id, 'is_profile' => '1'));
        if (count($contractorphotos) > 0) {
            $profile_pic = Yii::app()->request->baseUrl . "/uploads/profile/" . $contractorphotos->filename;
        } else {
            $profile_pic = 'http://www.justmail.in/platinum/images/clapper.png';
        }
        ?>
                            <div class="row team-member">
                                <div class="col-lg-3 col-lg-12 team-img">
                                    <img src="<?php 
        echo $profile_pic;
        ?>
" class="img-circle" alt="team member image">
                                </div>
                                <div class="col-lg-9 col-lg-12 description">
Example #10
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['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 deactivateaccount($post)
 {
     $role = Yii::app()->user->role;
     $password = $post['password'];
     $reason = $post['reason'];
     if ($role == 'homeowner') {
         $homeowner_id = Yii::app()->user->getId();
         $hmodel = Homeowners::model()->findByPk($homeowner_id);
         if ($hmodel->password == $password) {
             $subject = 'Handyman Homeowner Deactivated Account';
             $content = $hmodel->firstname . ' ' . $hmodel->lastname . ' ' . $hmodel->email . ' has deactivated his/her account.<br>';
             $content .= 'Reason:<br>';
             $content .= $reason;
             $headers = "From: admin <admin@>" . Yii::app()->name . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8";
             mail('*****@*****.**', $subject, $content, $headers);
             Homeowners::model()->deactivate($homeowner_id);
             $status = true;
         } else {
             $status = false;
             $return['message'] = 'Invalid password.';
         }
     } else {
         $contractor_id = Yii::app()->user->getId();
         $cmodel = Contractors::model()->findByPk($contractor_id);
         if ($cmodel->Password == $password) {
             $subject = 'Handyman Contractor Deactivated Account';
             $content = $cmodel->Name . ' - ' . $cmodel->Email . ' has deactivated his/her account.<br>';
             $content .= 'Reason:<br>';
             $content .= $reason;
             $headers = "From: admin <admin@>" . Yii::app()->name . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8";
             mail('*****@*****.**', $subject, $content, $headers);
             Contractors::model()->deactivate($contractor_id);
             $status = true;
         } else {
             $status = false;
             $return['message'] = 'Invalid password.';
         }
     }
     $return['status'] = $status;
     $this->renderJSON($return, $status);
 }
Example #12
0
		<li><a href="<?php 
        echo Yii::app()->request->baseUrl;
        ?>
/logout">Logout</a></li>
		</ul>
	</li>
	<?php 
    }
    ?>
	<?php 
    if (Yii::app()->user->role == 'contractor') {
        ?>
		<li class="dropdown"><a href="#"  class="dropdown-toggle" data-toggle="dropdown" >Referral <b class="caret"></b></a>
			<ul class="dropdown-menu">
			  <?php 
        $model = Contractors::model()->findByPk(Yii::app()->user->id);
        ?>
				<li><a href="<?php 
        echo Yii::app()->request->baseUrl;
        ?>
/refer/<?php 
        echo $model->Username;
        ?>
">Badges</a></li>
				<li><a href="<?php 
        echo Yii::app()->request->baseUrl;
        ?>
/referral">Widgets</a></li>
			</ul>
		</li>
		<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Hi <?php 
 public function actionPost()
 {
     $project_type_id = Yii::app()->Ini->v('project');
     $zipcode = Yii::app()->Ini->v('zipcode');
     $refer = Yii::app()->Ini->v('refer');
     $from_index = false;
     if ($project_type_id && $zipcode) {
         $from_index = true;
     }
     $project_id = Yii::app()->Ini->v('pid');
     $this->pageTitle = 'Handyman.com - Post Project';
     $param['projects'] = Projecttypes::model()->findAll(array('order' => 'Name ASC'));
     $param['state'] = States::model()->findAll(array('order' => 'Name ASC'));
     $param['default_project'] = $project_id;
     $param['from_index'] = $from_index;
     $param['project_type_id'] = $project_type_id;
     $param['zipcode'] = $zipcode;
     if ($refer != '') {
         $details = Contractors::model()->findByAttributes(array('Username' => $refer));
         if (count($details) > 0) {
             $refer_id = $details->ContractorId;
         } else {
             $refer_id = '';
         }
     } else {
         $refer_id = '';
     }
     $param['refer_id'] = $refer_id;
     $this->render('postproject', $param);
 }
Example #14
0
 public function savetoaffiliate($userid, $user_type)
 {
     $domain = "handyman.com";
     $url = "http://www.api.contrib.com/forms/addaffiliate";
     $headers = array('Accept: application/json');
     if ($user_type == "homeowner") {
         $model = Homeowners::model()->findByPk($userid);
         $param = array('domain' => $domain, 'email' => $model->email, 'username' => $model->username, 'password' => $model->password, 'firstname' => $model->firstname, 'lastname' => $model->lastname);
     } else {
         $model = Contractors::model()->findByPk($userid);
         $param = array('domain' => $domain, 'email' => $model->Email, 'username' => $model->Username, 'password' => $model->Password, 'firstname' => $model->ContactName, 'lastname' => "");
     }
     $affiliate_id = Yii::app()->Ini->createApiCall($url, 'POST', $headers, $param);
     if ($affiliate_id != "") {
         $details = Affiliates::model()->findByAttributes(array('userid' => $userid, 'user_type' => $user_type));
         if (count($details) > 0) {
             $details->affiliate_id = $affiliate_id;
             $details->save();
         } else {
             $details = new Affiliates();
             $details->userid = $userid;
             $details->user_type = $user_type;
             $details->affiliate_id = $affiliate_id;
             $details->save();
         }
     }
 }
 private function sendEmailNotifAddTeam($invited_id)
 {
     $contractor_id = Yii::app()->user->getId();
     $contractor_details = Contractors::model()->findbyPk($contractor_id);
     $invited_details = Contractors::model()->findbyPk($invited_id);
     $receiver_name = $invited_details->Name;
     $receiver_email = $invited_details->Email;
     //$receiver_email = '*****@*****.**';
     $message = "\r\n\t\t\t<a href='http://handyman.com/contractor/profile/user/" . $contractor_details->Username . "'>" . $contractor_details->Name . "</a> requested to add you to their handyman team.\r\n\t\t\tTo confirm, login to your account and hit &lsquo;Accept&rsquo; in your dashboard invites page.<br><br>\r\n\t\t\tHandyman\r\n\t\t";
     $subject = Yii::app()->name . " - You have been added in a contractor team";
     $domain_name = "Handyman.com";
     $content = $this->renderPartial('message_notif_template', array('domain_name' => $domain_name, 'message' => $message, 'receiver_name' => $receiver_name), true);
     $headers = "From: admin <*****@*****.**>" . Yii::app()->name . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8";
     mail($receiver_email, $subject, $content, $headers);
 }
Example #16
0
 public function logincontractor($post)
 {
     $identity = new UserIdentity($post['contractor_email'], $post['contractor_password'], 'contractor');
     if ($identity->authenticate()) {
         Yii::app()->user->login($identity);
         $owner_id = Yii::app()->user->getId();
         $user = Contractors::model()->findByPk($owner_id);
         $status = true;
         $return['code'] = $this->encrypt_decrypt('encrypt', json_encode(array('name' => $user->firstname, 'contact_name' => $user->lastname, 'username' => $user->Username, 'password' => $user->Password, 'email' => $user->Email)));
     } else {
         $status = false;
         $return['message'] = $identity->errorMessage;
     }
     $return['status'] = $status;
     $this->renderJSON($return, $status);
 }
 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);
     }
 }
Example #18
0
 public function actionSitemap()
 {
     header('Content-Type: application/xml');
     $cities = Cities::model()->findAll(array('order' => 'Name ASC'));
     $projects = Projecttypes::model()->findAll(array('order' => 'Name ASC'));
     $contractors = Contractors::model()->findAll(array('order' => 'Name ASC'));
     $this->renderPartial('sitemapxml', array('cities' => $cities, 'projects' => $projects, 'contractors' => $contractors));
 }
 private function SendMailAfterAnswer($question_id, $answer_id)
 {
     $question = Questions::model()->findByPk($question_id);
     $answer = Answers::model()->findByPk($answer_id);
     if ($answer->owner_user_type == 'homeowner') {
         $euser = Homeowners::model()->findByPk($answer->owner_id);
         $answered_by = $euser->firstname . " " . $euser->lastname;
     } else {
         $euser = Contractors::model()->findByPk($answer->owner_id);
         $answered_by = $euser->Name;
     }
     if ($question->owner_user_type == 'homeowner') {
         $euser = Homeowners::model()->findByPk($question->owner_id);
         $to_email = $euser->email;
         $receiver_name = $euser->firstname;
     } else {
         $euser = Contractors::model()->findByPk($question->owner_id);
         $to_email = $euser->Email;
         $receiver_name = $euser->Name;
     }
     $subject = Yii::app()->name . ' Question & Answer';
     $content = $this->renderPartial('email-answer', array('question' => $question, 'answer' => $answer, 'answered_by' => $answered_by, 'receiver_name' => $receiver_name), true);
     $headers = "From: admin <admin@>" . Yii::app()->name . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8";
     mail($to_email, $subject, $content, $headers);
 }