Exemple #1
0
 /**
  * Load the datagrid for statistics
  */
 private function loadStatistics()
 {
     // fetch the latest mailing
     $mailing = BackendMailmotorModel::getSentMailings(1);
     // check if a mailing was found
     if (empty($mailing)) {
         return false;
     }
     // check if a mailing was set
     if (!isset($mailing[0])) {
         return false;
     }
     // show the sent mailings block
     $this->tpl->assign('oSentMailings', true);
     // fetch the statistics for this mailing
     $stats = BackendMailmotorCMHelper::getStatistics($mailing[0]['id'], true);
     // reformat the send date
     $mailing[0]['sent'] = \SpoonDate::getDate('d-m-Y', $mailing[0]['sent']) . ' ' . BL::lbl('At') . ' ' . \SpoonDate::getDate('H:i', $mailing);
     // get results
     $results[] = array('label' => BL::lbl('MailmotorLatestMailing'), 'value' => $mailing[0]['name']);
     $results[] = array('label' => BL::lbl('MailmotorSendDate'), 'value' => $mailing[0]['sent']);
     $results[] = array('label' => BL::lbl('MailmotorSent'), 'value' => $stats['recipients'] . ' (' . $stats['recipients_percentage'] . ')');
     $results[] = array('label' => BL::lbl('MailmotorOpened'), 'value' => $stats['unique_opens'] . ' (' . $stats['unique_opens_percentage'] . ')');
     $results[] = array('label' => BL::lbl('MailmotorClicks'), 'value' => $stats['clicks_total'] . ' (' . $stats['clicks_percentage'] . ')');
     // there are some results
     if (!empty($results)) {
         // get the datagrid
         $dataGrid = new BackendDataGridArray($results);
         // no pagination
         $dataGrid->setPaging(false);
         // parse the datagrid
         $this->tpl->assign('dgMailmotorStatistics', $dataGrid->getContent());
     }
 }
Exemple #2
0
 /**
  * Gets all data needed for this page
  */
 private function getData()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if (!BackendMailmotorModel::existsMailing($this->id)) {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=mailing-does-not-exist');
     }
     // get mailing
     $this->mailing = BackendMailmotorModel::getMailing($this->id);
     // fetch the statistics
     $this->statistics = BackendMailmotorCMHelper::getStatistics($this->id, true);
     // no stats found
     if ($this->statistics === false) {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=no-statistics-loaded&var=' . str_replace('#', '', $this->mailing['name']));
     }
 }
 /**
  * Gets all data needed for this page
  */
 private function getData()
 {
     // get parameters
     $id = $this->getParameter('mailing_id', 'int');
     $this->linkURL = $this->getParameter('url');
     // does the item exist
     if (!BackendMailmotorModel::existsMailing($id)) {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=mailing-does-not-exist');
     }
     if ($this->linkURL == '') {
         $this->redirect(BackendModel::createURLForAction('Statistics') . '&id=' . $id . '&error=link-does-not-exist');
     }
     // fetch the statistics
     $this->statistics = BackendMailmotorCMHelper::getStatistics($id, true);
     // fetch the mailing
     $this->mailing = BackendMailmotorModel::getMailing($id);
     // no stats found
     if ($this->statistics === false) {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=no-statistics-loaded');
     }
 }
Exemple #4
0
 /**
  * Exports the statistics of a given mailing in CSV format.
  * This function will send headers to download the CSV and exit your script after use.
  *
  * @param int $id The ID of the mailing.
  */
 public static function exportStatistics($id)
 {
     // fetch the addresses by group
     $records = array();
     $records[] = BackendMailmotorCMHelper::getStatistics($id, true);
     // fetch separate arrays
     $statsClickedLinks = isset($records[0]['clicked_links']) ? $records[0]['clicked_links'] : array();
     $statsClickedLinksBy = isset($records[0]['clicked_links_by']) ? $records[0]['clicked_links_by'] : array();
     // unset multi-dimensional arrays
     unset($records[0]['clicked_links'], $records[0]['clicked_links_by'], $records[0]['opens'], $records[0]['clicks'], $records[0]['clicks_percentage'], $records[0]['clicks_total'], $records[0]['recipients_total'], $records[0]['recipients_percentage'], $records[0]['online_version']);
     // set columns
     $columns = array();
     $columns[] = BL::msg('MailingCSVRecipients');
     $columns[] = BL::msg('MailingCSVUniqueOpens');
     $columns[] = BL::msg('MailingCSVUnsubscribes');
     $columns[] = BL::msg('MailingCSVBounces');
     $columns[] = BL::msg('MailingCSVUnopens');
     $columns[] = BL::msg('MailingCSVBouncesPercentage');
     $columns[] = BL::msg('MailingCSVUniqueOpensPercentage');
     $columns[] = BL::msg('MailingCSVUnopensPercentage');
     // set start of the CSV
     $csv = BackendCSV::arrayToString($records, $columns);
     // check set links
     if (!empty($statsClickedLinks)) {
         // urldecode the clicked URLs
         $statsClickedLinks = \SpoonFilter::arrayMapRecursive('urldecode', $statsClickedLinks);
         // fetch CSV strings
         $csv .= PHP_EOL . BackendCSV::arrayToString($statsClickedLinks);
     }
     // set the filename and path
     $filename = 'statistics-' . \SpoonDate::getDate('YmdHi') . '.csv';
     // set headers for download
     header('Content-type: application/octet-stream');
     header('Content-Disposition: attachment; filename="' . $filename . '"');
     // output the CSV string
     echo $csv;
     // exit here
     exit;
 }