tally() public static method

returns mailing tally (int)
public static tally ( )
Beispiel #1
0
/**********************************
	OUTPUT FORMATTING
*********************************/
$records = array();
foreach ($mailings as $o) {
    //	If the mailing is not beeing tracked show "not tracked" instead of 0
    if (0 == $o['track']) {
        $o['hits'] = Pommo::_T('Not tracked');
    }
    $row = array('id' => $o['id'], 'subject' => $o['subject'], 'group' => $o['group'] . ' (' . $o['tally'] . ')', 'sent' => $o['sent'], 'start' => $o['start'], 'end' => $o['end'], 'hits' => $o['hits']);
    if ($o['status'] == 0) {
        $o['status'] = Pommo::_T('Complete');
    } elseif ($o['status'] == 1) {
        $o['status'] = Pommo::_T('Processing');
    } else {
        $o['status'] = Pommo::_T('Cancelled');
    }
    $row['status'] = $o['status'];
    // calculate mails per hour
    if (!empty($o['end']) && !empty($o['sent'])) {
        $runtime = strtotime($o['end']) - strtotime($o['start']);
        $mph = $runtime == 0 ? $o['sent'] * 3600 : round($o['sent'] / $runtime * 3600);
    } else {
        $mph = 0;
    }
    $row['end'] .= '<br />' . $mph . ' ' . Pommo::_T('Mails/Hour');
    array_push($records, $row);
}
// format for JSON output to jqGrid
$json->add(array('page' => $state['page'], 'total' => $state['pages'], 'records' => Pommo_Mailing::tally(), 'rows' => $records));
$json->serve();
Beispiel #2
0
$view = new Pommo_Template();
$view->assign('returnStr', Pommo::_T('Mailings Page'));
/** SET PAGE STATE
 * limit	- # of mailings per page
 * sort		- Sorting of Mailings [subject, mailgroup, subscriberCount, started, etc.]
 * order	- Order Type (ascending - ASC /descending - DESC)
 */
// Initialize page state with default values overriden by those held in $_REQUEST
$state =& Pommo_Api::stateInit('mailings_history', array('limit' => 10, 'sort' => 'end', 'order' => 'desc', 'page' => 1), $_REQUEST);
/**********************************
	VALIDATION ROUTINES
*********************************/
if (!is_numeric($state['limit']) || $state['limit'] < 1 || $state['limit'] > 1000) {
    $state['limit'] = 10;
}
if ($state['order'] != 'asc' && $state['order'] != 'desc') {
    $state['order'] = 'asc';
}
if ($state['sort'] != 'start' && $state['sort'] != 'end' && $state['sort'] != 'subject' && $state['sort'] != 'sent' && $state['sort'] != 'status' && $state['sort'] != 'group') {
    $state['sort'] = 'end';
}
/**********************************
	DISPLAY METHODS
*********************************/
// Calculate and Remember number of pages
$tally = Pommo_Mailing::tally();
$state['pages'] = is_numeric($tally) && $tally > 0 ? ceil($tally / $state['limit']) : 0;
$view->assign('state', $state);
$view->assign('tally', $tally);
$view->assign('mailings', $mailings);
$view->display('admin/mailings/mailings_history');