function thankyouAction()
 {
     $this->view->activeTab = 'Polls';
     $this->view->title = $this->view->title = $this->view->translate("Wildfire") . " - " . $this->view->translate("Thanks_For_Poll");
     $consumer = $this->_currentUser;
     $id = (int) $this->_request->getParam('survey', 0);
     $profileSurveyModel = new ProfileSurvey();
     $profileSurvey = $profileSurveyModel->fetchRow("i2_survey_id =" . $id . " or " . "i2_survey_id_en =" . $id);
     // $this->view->point = $profileSurvey->points;
     //check history to prevent multiple participation
     $db = Zend_Registry::get('db');
     $select1 = $db->select();
     $select1->from("poll_participation", "count(*)");
     $select1->where("poll_participation.poll_id = ?", $profileSurvey->id);
     $select1->where("poll_participation.consumer_id = ?", $consumer->id);
     $participationCount = $db->fetchOne($select1);
     if ($participationCount == 0) {
         // check ws
         $indicate2Connect = new Indicate2_Connect();
         $ids = array($id);
         $wsResult = $indicate2Connect->getAnswerSetCount($consumer->email, $ids);
         // Zend_Debug::dump($wsResult."------------".$profileSurvey->points);die;
         if ($wsResult > 0) {
             // add poll participation
             $currentTime = date("Y-m-d H:i:s");
             $pollParticipationModel = new PollParticipation();
             $pollParticipation = $pollParticipationModel->createRow();
             $pollParticipation->poll_id = $profileSurvey->id;
             $pollParticipation->consumer_id = $consumer->id;
             $pollParticipation->date = $currentTime;
             $pollParticipation->save();
             // add points
             $pointRecordModel = new RewardPointTransactionRecord();
             $point = $pointRecordModel->createRow();
             $point->consumer_id = $consumer->id;
             $point->transaction_id = 3;
             $point->date = $currentTime;
             $point->point_amount = $profileSurvey->points;
             $point->save();
             //2011-05-13 change the rank of consumer
             $rankModel = new Rank();
             $rankModel->changeConsumerRank($consumer->id);
             $this->view->point = $point->point_amount;
         } else {
             // add poll participation
             $currentTime = date("Y-m-d H:i:s");
             $pollParticipationModel = new PollParticipation();
             $pollParticipation = $pollParticipationModel->createRow();
             $pollParticipation->poll_id = $profileSurvey->id;
             $pollParticipation->consumer_id = $consumer->id;
             $pollParticipation->date = $currentTime;
             $pollParticipation->save();
             // add points
             $pointRecordModel = new RewardPointTransactionRecord();
             $point = $pointRecordModel->createRow();
             $point->consumer_id = $consumer->id;
             $point->transaction_id = 3;
             $point->date = $currentTime;
             $point->point_amount = $profileSurvey->points;
             $point->save();
             //2011-05-13 change the rank of consumer
             $rankModel = new Rank();
             $rankModel->changeConsumerRank($consumer->id);
             $this->view->point = $point->point_amount;
         }
     }
 }
 function acceptAction()
 {
     $db = Zend_Registry::get('db');
     $request = $this->getRequest();
     $campaignId = (int) $this->_request->getParam('id', 0);
     $consumer = $this->_currentUser;
     if ($campaignId > 0) {
         // check if precampaign poll is finished
         $select1 = $db->select();
         $select1->from('campaign', 'pre_campaign_survey');
         $select1->where('campaign.id = ?', $campaignId);
         $previewCamSurvey = $db->fetchOne($select1);
         $indicate2Connect = new Indicate2_Connect();
         $ids = array($previewCamSurvey);
         $wsResult = $indicate2Connect->getAnswerSetCount($consumer->email, $ids);
         //			Zend_Debug::dump($wsResult);
         if ($wsResult == 0) {
             $this->_redirect('campaign/precampaign/survey/' . $previewCamSurvey);
         } else {
             $campaignInvitationModel = new CampaignInvitation();
             $campaignInvitation = $campaignInvitationModel->fetchRow("campaign_id=" . $campaignId . " and consumer_id=" . $consumer->id);
             $id = $campaignInvitation->id;
             //				Zend_Debug::dump($campaignInvitation);
             $campaignInvitation->state = "ACCEPTED";
             $campaignInvitation->save();
             $result = $db->fetchOne("SELECT COUNT(*) FROM campaign_participation WHERE campaign_invitation_id=:t1", array('t1' => $id));
             if ($result == 0) {
                 //create participation
                 $campaignParticipationModel = new CampaignParticipation();
                 $currentTime = date("Y-m-d H:i:s");
                 $row = $campaignParticipationModel->createRow();
                 $row->campaign_invitation_id = $id;
                 $row->accept_date = $currentTime;
                 $row->save();
             }
             $this->_redirect('campaigninvitation/index');
         }
     }
     $this->_helper->layout->disableLayout();
 }