<?php
/*
  $Id: $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

$popup = false;
if (mh_get('popup')) {
    mh_define('MH_POPUP', true);
    $popup = true;
}

$back_url = mh_href_link(FILENAME_MAILBEEZ, 'module=' . mh_get('module'));

$app_action = mh_get('app_action', '');
$msg = '';

if (mh_not_null($app_action)) {
    switch ($app_action) {
        case 'save':
            break;
    }
}

?>

<?php
// back to sequence page
if (!$popup) {
    echo mb_admin_button($back_url, mh_lng('MH_BUTTON_BACK_REPORTS'), '', 'link') . '<br /><br />';
}
?>
<?php if ($msg != ''): ?>
    <?php echo $msg; ?>
<?php endif; ?>

<table border="0" width="100%" cellspacing="0" cellpadding="0">
    <tr>
        <td>
            <table border="0" width="100%" cellspacing="0" cellpadding="0">
                <tr>
                    <td class="pageTitle"><?php echo mh_lng('MAILBEEZ_REPORT_BLOCK_TEXT_TITLE'); ?></td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <table border="0" width="100%" cellspacing="0" cellpadding="0">
                <tr>
                    <td valign="top">
                        <table border="0" width="100%" cellspacing="0" cellpadding="2">
                            <tr class="dataTableHeadingRow">
                                <td class="dataTableHeadingContent"><?php echo mh_lng('TABLE_HEADING_ID'); ?></td>
                                <td class="dataTableHeadingContent"><?php echo mh_lng('TABLE_HEADING_DATE'); ?></td>
                                <td class="dataTableHeadingContent"><?php echo mh_lng('TABLE_HEADING_MODULE'); ?></td>
                                <td class="dataTableHeadingContent"><?php echo mh_lng('TABLE_HEADING_CUSTOMER_ID'); ?></td>
                                <td class="dataTableHeadingContent"><?php echo mh_lng('TABLE_HEADING_CUSTOMER_EMAIL'); ?></td>
                                <td class="dataTableHeadingContent"><?php echo mh_lng('TABLE_HEADING_SOURCE'); ?></td>
                                <td class="dataTableHeadingContent"><?php echo mh_lng('TABLE_HEADING_MODE'); ?></td>
                            </tr>
                            <?php

                            //$report_query_numrows = 25;

                            if (mh_get(MH_PAGE_NAME) > 1) $rows = mh_get(MH_PAGE_NAME) * mh_cfg('MH_SPLITPAGE_NUM') - mh_cfg('MH_SPLITPAGE_NUM');

                            $report_query_raw = "select *, c.customers_email_address from " . TABLE_MAILBEEZ_BLOCK . " b, " . TABLE_CUSTOMERS . " c where b.customers_id = c.customers_id order by autoemail_id DESC";
                            $page_val = mh_get(MH_PAGE_NAME);
                            $report_split = new splitPageResults($page_val, mh_cfg('MH_SPLITPAGE_NUM'), $report_query_raw, $report_query_numrows);
                            $report_query = mh_db_query($report_query_raw);
                            while ($report = mh_db_fetch_array($report_query)) {
                                $rows++;

                                if (strlen($rows) < 2) {
                                    $rows = '0' . $rows;
                                }
                                ?>
                                <tr class="dataTableRow"
                                    onmouseover="this.className='dataTableRowOver';this.style.cursor='pointer'"
                                    onmouseout="this.className='dataTableRow'">
                                    <td class="dataTableContent"><?php echo $report['autoemail_id']; ?></td>
                                    <td class="dataTableContent"><?php echo $report['date_block']; ?>&nbsp;</td>
                                    <td class="dataTableContent"><?php echo $report['module']; ?></td>
                                    <td class="dataTableContent"><?php echo $report['customers_id']; ?>&nbsp;</td>
                                    <td class="dataTableContent"><?php echo $report['customers_email_address']; ?>
                                        &nbsp;</td>
                                    <td class="dataTableContent"><?php echo mh_lng('BLOCK_SOURCE_' . $report['source']); ?>
                                        &nbsp;</td>
                                    <td class="dataTableContent"><?php echo ($report['simulation'] > 0) ? MAILBEEZ_SIMULATION_TAG : 'PROD'; ?>
                                        &nbsp;</td>
                                </tr>
                            <?php
                            }
                            ?>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="3">
                        <table border="0" width="100%" cellspacing="0" cellpadding="2">
                            <tr>
                                <td class="smallText"
                                    valign="top"><?php echo $report_split->display_count($report_query_numrows, mh_cfg('MH_SPLITPAGE_NUM'), mh_get(MH_PAGE_NAME), mh_lng('MAILBEEZ_TEXT_DISPLAY_NUMBER_OF_ITEMS')); ?></td>
                                <td class="smallText"
                                    align="right"><?php echo $report_split->display_links($report_query_numrows, mh_cfg('MH_SPLITPAGE_NUM'), mh_cfg('MAX_DISPLAY_PAGE_LINKS'), mh_get(MH_PAGE_NAME), mh_get_all_get_params(array(MH_PAGE_NAME))); ?></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
			