function adminindexAction()
 {
     $this->view->title = "All Participations";
     $this->view->activeTab = "List Participations";
     $this->campaign_id = $this->_request->getParam('id');
     $this->tag = $this->_request->getParam('tag');
     $db = Zend_Registry::get('db');
     $select = $db->select();
     $select->from('campaign', null);
     $select->join('campaign_invitation', 'campaign.id = campaign_invitation.campaign_id', 'state');
     if ($this->tag) {
         $select->join('consumer', "consumer.id = campaign_invitation.consumer_id and tags like '%{$this->tag},%'");
     } else {
         $select->join('consumer', "consumer.id = campaign_invitation.consumer_id ");
     }
     $select->join('campaign_participation', 'campaign_invitation.id = campaign_participation.campaign_invitation_id', array('accept_date', 'state'));
     $select->where('campaign_invitation.campaign_id = ?', $this->campaign_id)->where('consumer.pest is null or consumer.pest != 1');
     $this->view->campaignParticipations = $db->fetchAll($select);
     $this->view->campaign_id = $this->campaign_id;
     $this->view->tag = $this->tag;
     //		$this->_helper->layout->disableLayout();
     //print_r($this->view->campaignParticipations);die;
     $this->_helper->layout->setLayout("layout_admin");
     //extract the profile survey
     $profileSurvey = new ProfileSurvey();
     $this->view->profilesurvey = $profileSurvey->fetchAll('id !=12');
 }
 function admincreategroupAction()
 {
     $request = $this->getRequest();
     //1.get all campaign
     $campaign = new Campaign();
     $order = "expire_date desc";
     $this->view->campaigns = $campaign->fetchAll(null, $order, null, null);
     //2.get all profile_survey
     $profileSurveyModel = new ProfileSurvey();
     $this->view->profilesurveys = $profileSurveyModel->find_by_condition();
     //3.execute sql
     $profileSurveyGroupModel = new ProfileSurveyGroup();
     if ($request->isPost()) {
         $formData = $request->getPost();
         $sql = $formData['sql'];
         if ($sql == null || $sql == '') {
             return;
         } else {
             $sql = 'select consumer.id ' . $sql;
         }
         $campaignId = $formData['campaign_id'];
         $profileSurveyId = $formData['profile_survey_id'];
         $comment = $formData['comment'];
         $currentTime = date("Y-m-d H:i:s");
         //get all consumer id
         $db = Zend_Registry::get('db');
         $result = $db->query($sql);
         $consumers = $result->fetchAll();
         //4.save ProfileSurveyGroup
         $newProfileSurveyGroupId = $profileSurveyGroupModel->createRecord(count($consumers), $campaignId, $profileSurveyId, $currentTime, $comment);
         //5.insert profile survey group consumer
         $profileSurveyGroupConsumerModel = new ProfileSurveyGroupConsumer();
         foreach ($consumers as $row) {
             $profileSurveyGroupConsumerModel->createRecord($newProfileSurveyGroupId, $row['id']);
         }
     }
     //4.get all profile survey group
     $this->view->profilesurveygroups = $profileSurveyGroupModel->find_by_condition('id asc');
     //Zend_Debug::dump($this->view->profilesurveygroups);
     $this->_helper->layout->setLayout("layout_admin");
 }
Esempio n. 3
0
 public function admindownloadindexAction()
 {
     $this->view->title = 'Reports';
     $this->view->activeTab = 'Reports';
     $this->_helper->layout->setLayout("layout_admin");
     $profileSurveyModel = new ProfileSurvey();
     $this->view->profileSurvey = $profileSurveyModel->fetchAll();
     $campaignModel = new Campaign();
     $this->view->campaigns = $campaignModel->fetchAll();
 }