public function indexAction() { $lang = $this->_request->getParam('lang'); $langNamespace = new Zend_Session_Namespace('Lang'); $langNamespace->lang = $lang; // Zend_Debug::dump($_SERVER["HTTP_REFERER"]); if (isset($this->_currentUser->id)) { $consumerModel = new Consumer(); $consumer = $consumerModel->fetchRow('id = ' . $this->_currentUser->id); if ($consumer != null) { $consumer->language_pref = $lang; $consumer->save(); } else { $adminModel = new Admin(); $admin = $adminModel->fetchRow('id = ' . $this->_currentUser->id); if ($admin != null) { $admin->language_pref = $lang; $admin->save(); } } } $messageArray = $this->_flashMessenger->getMessages(); if ($messageArray != null) { foreach ($messageArray as $message) { $this->_flashMessenger->addMessage($message); } } $this->_helper->redirector->gotoUrl($_SERVER["HTTP_REFERER"]); }
function adminreportbatchreplyAction() { $reportId = $this->_request->getParam('report_id'); $this->view->batchId = $this->_request->getParam('batch_id'); $reportModel = new Report(); $report = $reportModel->find($reportId)->current(); $this->view->report_id = $reportId; $consumerModel = new Consumer(); $this->view->consumer = $consumerModel->find($report['consumer_id'])->current(); $campaignModel = new Campaign(); $campaign = $campaignModel->find($report['campaign_id'])->current(); $this->view->campaign_name = $campaign->name; $this->view->campaign_id = $campaign->id; //get new report $config = Zend_Registry::get('config'); $url = $config->indicate2->home . "/report/showAnswer/accessCode/" . $report['accesscode']; // $contents = file_get_contents($url); // deprecated by ice, for performance reason // $handle = @fopen($url, "r"); // stream_set_timeout($handle, 0, 500);// 500 ms // $contents = stream_get_contents($handle); // $info = stream_get_meta_data($handle); // fclose($handle); $this->view->url = $url; $this->view->title = "Reply Reports"; $this->view->activeTab = "Reply Reports"; $this->view->mailForm = new ReplyReportForm(); $this->view->mailForm->email->setValue($this->view->consumer['email']); $db = Zend_Registry::get('db'); $selectReportSourceAndPoint = $db->select(); $selectReportSourceAndPoint->from('report', array('source', 'campaign_id'))->joinLeft('reward_point_transaction_record', 'report.reward_point_transaction_record_id = reward_point_transaction_record.id', 'point_amount')->where('report.id = ?', $reportId); $reportSourceAndPoint = $db->fetchAll($selectReportSourceAndPoint); // Zend_Debug::dump($reportSourceAndPoint); if (isset($reportSourceAndPoint)) { $this->view->reportSource = $reportSourceAndPoint[0]['source']; if ($this->view->reportSource == 'sms' || empty($this->view->consumer['email'])) { $this->view->reportSource = 'sms'; $this->view->mailForm->email->setLabel($this->view->translate('Phone:')); $this->view->mailForm->email->setValue($this->view->consumer['phone']); $this->view->mailForm->message->setLabel($this->view->translate('Admin_Reply_Message_Sms_Note')); $this->view->mailForm->message->setAttribs(array('rows' => 2, 'cols' => 50)); } } if (isset($reportSourceAndPoint) && $reportSourceAndPoint[0]['point_amount'] != null) { $this->view->mailForm->grade->setValue($reportSourceAndPoint[0]['point_amount']); } //tag for report $selectTags = $db->select(); $selectTags->from('tags', array('name', 'id', 'sort'))->where("module = 'REPORT' and (campaign_id is null or campaign_id=" . $reportSourceAndPoint[0]['campaign_id'] . ")")->order('sort'); $this->view->tags = $db->fetchAll($selectTags); $selectSelectedTags = $db->select(); $selectSelectedTags->from('report_tag', array('tag_id'))->where('report_id = ?', $reportId); $selectedTags = $db->fetchAll($selectSelectedTags); $this->view->selectedTagsArray = array(); foreach ($selectedTags as $tag) { $this->view->selectedTagsArray[$tag['tag_id']] = '1'; } // Zend_Debug::dump($this->view->selectedTagsArray); $replyModel = new Reply(); $reply = $replyModel->fetchRow('report_id = ' . $reportId); if ($reply != null) { $this->view->mailForm->message->setValue($reply['content']); $this->view->status = $reply['status']; } $this->view->usetime = $reply['usetime']; var_dump($reply['usetime']); $this->view->mailForm->subject->setValue($this->view->translate('Admin_Reply_WOM_Report_Subject')); $this->_helper->layout->setLayout("layout_admin"); //organize tag list $tagHash = array(); foreach ($this->view->tags as $tag) { $tagHash[$tag['id']] = $tag['name']; } // get old reports of this campaign $select = $db->select(); $select->from('report', array('id', 'accesscode', 'create_date'))->where('consumer_id = ?', $this->view->consumer['id'])->where('campaign_id = ?', $campaign->id)->order('create_date desc'); $oldreportArray = $db->fetchAll($select); $this->view->oldreports = array(); $i = 1; foreach ($oldreportArray as $oldreport) { $oldTags = ''; if ($report['accesscode'] != $oldreport["accesscode"]) { $this->view->oldreports[$oldreport["accesscode"]]['url'] = $config->indicate2->home . "/report/showAnswer/accessCode/" . $oldreport["accesscode"]; $reply = $replyModel->fetchRow('report_id = ' . $oldreport['id']); if ($reply['admin_id'] != null) { $adminModel = new Admin(); $admin = $adminModel->fetchRow('id = ' . $reply['admin_id']); $adminname = $admin['name']; } else { $adminname = ''; } $this->view->oldreports[$oldreport["accesscode"]]['id'] = $oldreport['id']; $this->view->oldreports[$oldreport["accesscode"]]['create_date'] = $oldreport['create_date']; $this->view->oldreports[$oldreport["accesscode"]]['adminname'] = $adminname; $this->view->oldreports[$oldreport["accesscode"]]['replydate'] = $reply['date']; $this->view->oldreports[$oldreport["accesscode"]]['replycontent'] = $reply['content']; //tag $oldreportTagSelect = $db->select(); $oldreportTagSelect->from('report_tag', 'tag_id')->where('report_tag.report_id = ?', $oldreport['id']); $oldreportTag = $db->fetchAll($oldreportTagSelect); foreach ($oldreportTag as $tag) { $oldTags .= $this->view->translate('Report_Tag_' . $tagHash[$tag['tag_id']]) . " "; } $this->view->oldreports[$oldreport["accesscode"]]['tag'] = $oldTags; } } // get old reports for other campaigns $select = $db->select(); $select->from('report', array('id', 'accesscode', 'create_date'))->where('consumer_id = ?', $this->view->consumer['id'])->where('campaign_id != ?', $campaign->id)->order('create_date desc'); $oldreportArray = $db->fetchAll($select); $this->view->otheroldreports = array(); $i = 1; foreach ($oldreportArray as $oldreport) { $oldTags = ''; if ($report['accesscode'] != $oldreport["accesscode"]) { $this->view->otheroldreports[$oldreport["accesscode"]]['url'] = $config->indicate2->home . "/report/showAnswer/accessCode/" . $oldreport["accesscode"]; $reply = $replyModel->fetchRow('report_id = ' . $oldreport['id']); if ($reply['admin_id'] != null) { $adminModel = new Admin(); $admin = $adminModel->fetchRow('id = ' . $reply['admin_id']); $adminname = $admin['name']; } else { $adminname = ''; } $this->view->otheroldreports[$oldreport["accesscode"]]['id'] = $oldreport['id']; $this->view->otheroldreports[$oldreport["accesscode"]]['create_date'] = $oldreport['create_date']; $this->view->otheroldreports[$oldreport["accesscode"]]['adminname'] = $adminname; $this->view->otheroldreports[$oldreport["accesscode"]]['replydate'] = $reply['date']; $this->view->otheroldreports[$oldreport["accesscode"]]['replycontent'] = $reply['content']; //tag $oldreportTagSelect = $db->select(); $oldreportTagSelect->from('report_tag', 'tag_id')->where('report_tag.report_id = ?', $oldreport['id']); $oldreportTag = $db->fetchAll($oldreportTagSelect); foreach ($oldreportTag as $tag) { $oldTags .= $this->view->translate('Report_Tag_' . $tagHash[$tag['tag_id']]) . " "; } $this->view->otheroldreports[$oldreport["accesscode"]]['tag'] = $oldTags; } } $reportImages = new ReportImages(); $reportImagesData = $reportImages->fetchAll('report=' . $reportId . ' and consumer=' . $report['consumer_id']); $this->view->reportImages = $reportImagesData; }
function clientmessageAction() { $this->view->activeTab = 'clientmessage'; if (!$this->clientdashboardfilter()) { return; } $campaign_id = $this->_request->getParam('id'); $this->_helper->layout->setLayout($this->getCampaignTemplate($campaign_id)); // get current page(default page = 1) if ($this->_request->getParam('page')) { $this->_curPage = $this->_request->getParam('page'); } $clientMessageModel = new ClientMessage(); $where = "client_message.to=" . $this->_currentClient->id . " or client_message.from=" . $this->_currentClient->id; $order = "client_message.id desc"; $messageList = $clientMessageModel->fetchAll($where, $order); $msgMap = array(); foreach ($messageList as $message) { if ($message->parent_id != null) { //reply $key = $message->parent_id; if (!array_key_exists($key, $msgMap)) { $msgMap[$key] = array(); } if (!isset($msgMap[$key]['LASTTIME'])) { //save last time $msgMap[$key]['LASTTIME'] = $message->create_date; } if (!isset($msgMap[$key]['REPLY'])) { $msgMap[$key]['REPLY'] = array(); } array_push($msgMap[$key]['REPLY'], $message); } else { //message $key = $message->id; if (!array_key_exists($key, $msgMap)) { $msgMap[$key] = array(); } $msgMap[$key]['MESSAGE'] = $message; } //get from name depending on from_type if ($message->from_type == "Wildfire") { $adminModel = new Admin(); $admin = $adminModel->fetchRow('id = ' . $message->from); $msgMap[$key]['FROM_NAME'] = $admin->name; } else { if ($message->from_type == "Spark") { $consumerModel = new Consumer(); $consumer = $consumerModel->fetchRow('id = ' . $message->from); $msgMap[$key]['FROM_NAME'] = $consumer->recipients_name; } } } $this->view->msgMap = $msgMap; //Zend_Debug::dump($msgMap); //paging $this->view->controller = $this->_request->getControllerName(); $this->view->action = $this->_request->getActionName(); $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array(array_values($msgMap))); $paginator->setCurrentPageNumber($this->_curPage)->setItemCountPerPage($this->_rowsPerPage); $this->view->paginator = $paginator; //update client message count in session. $clientMessageNamespace = new Zend_Session_Namespace('ClientMessage'); $db = Zend_Registry::get('db'); $messageCount = $db->fetchOne("SELECT count(*) FROM client_message cm WHERE cm.to_type='Client' and cm.to=:clientId and state='NEW'", array('clientId' => $this->_currentClient->id)); if ($messageCount > 0) { $attrName = "count_" . $this->_currentClient->id; $clientMessageNamespace->{$attrName} = $messageCount; $this->view->client_message_count = "(" . $messageCount . ")"; } //get current message for client reply save $request = $this->getRequest(); if (!$request->isPost()) { $message_id = $request->getParam('message_id'); if (isset($message_id)) { $this->view->current_message_id = $message_id; } } $this->view->campaign_id = $request->getParam('id'); $clientCampaignListNamespace = new Zend_Session_Namespace('ClientCampaignList'); }
function ajaxreportAction() { $this->_helper->layout->disableLayout(); $config = Zend_Registry::get('config'); $db = Zend_Registry::get('db'); $select = $db->select(); //tag for report $selectTags = $db->select(); $selectTags->from('tags', array('name', 'id', 'sort'))->where("module = 'REPORT'")->order('sort'); $this->view->tags = $db->fetchAll($selectTags); //organize tag list $tagHash = array(); foreach ($this->view->tags as $tag) { $tagHash[$tag['id']] = $tag['name']; } // get reports $select->from('report', array('id', 'accesscode', 'create_date'))->where('consumer_id = ?', $this->_request->getParam('uid'))->order('create_date desc'); $oldreportArray = $db->fetchAll($select); $replyModel = new Reply(); $this->view->oldreports = array(); $i = 1; foreach ($oldreportArray as $oldreport) { $oldTags = ''; $this->view->oldreports[$oldreport["accesscode"]]['url'] = $config->indicate2->home . "/report/showAnswer/accessCode/" . $oldreport["accesscode"]; $reply = $replyModel->fetchRow('report_id = ' . $oldreport['id']); if ($reply['admin_id'] != null) { $adminModel = new Admin(); $admin = $adminModel->fetchRow('id = ' . $reply['admin_id']); $adminname = $admin['name']; } else { $adminname = ''; } $this->view->oldreports[$oldreport["accesscode"]]['id'] = $oldreport['id']; $this->view->oldreports[$oldreport["accesscode"]]['create_date'] = $oldreport['create_date']; $this->view->oldreports[$oldreport["accesscode"]]['adminname'] = $adminname; $this->view->oldreports[$oldreport["accesscode"]]['replydate'] = $reply['date']; $this->view->oldreports[$oldreport["accesscode"]]['replycontent'] = $reply['content']; //tag $oldreportTagSelect = $db->select(); $oldreportTagSelect->from('report_tag', 'tag_id')->where('report_tag.report_id = ?', $oldreport['id']); $oldreportTag = $db->fetchAll($oldreportTagSelect); foreach ($oldreportTag as $tag) { $oldTags .= $this->view->translate('Report_Tag_' . $tagHash[$tag['tag_id']]) . " "; } $this->view->oldreports[$oldreport["accesscode"]]['tag'] = $oldTags; } }