function customer_admin_email_generate_invoice_list($invoices, $customer_id)
            {
                ob_start();
                $colspan = 9;
                $colspan2 = 0;
                $invoice_total = array();
                $invoice_total_due = array();
                foreach ($invoices as $invoice) {
                    if (!isset($invoice_total[$invoice['currency_id']])) {
                        $invoice_total[$invoice['currency_id']] = 0;
                    }
                    if ($invoice['c_total_amount'] == 0) {
                        $invoice = module_invoice::get_invoice($invoice['invoice_id']);
                    }
                    $invoice_total[$invoice['currency_id']] += $invoice['c_total_amount'];
                    if (!isset($invoice_total_due[$invoice['currency_id']])) {
                        $invoice_total_due[$invoice['currency_id']] = 0;
                    }
                    $invoice_total_due[$invoice['currency_id']] += $invoice['c_total_amount_due'];
                }
                $table_manager = module_theme::new_table_manager();
                $columns = array();
                $columns['invoice_number'] = array('title' => 'Invoice Number', 'callback' => function ($invoice) {
                    //echo module_invoice::link_open($invoice['invoice_id'],true,$invoice);
                    echo '<a href="' . module_invoice::link_public($invoice['invoice_id']) . '">' . htmlspecialchars($invoice['name']) . '</a>';
                }, 'cell_class' => 'row_action');
                $columns['invoice_status'] = array('title' => 'Status', 'callback' => function ($invoice) {
                    echo htmlspecialchars($invoice['status']);
                });
                $columns['invoice_create_date'] = array('title' => 'Create Date', 'callback' => function ($invoice) {
                    if (!$invoice['date_create'] || $invoice['date_create'] == '0000-00-00') {
                        //echo print_date($invoice['date_created']);
                    } else {
                        echo print_date($invoice['date_create']);
                    }
                });
                $columns['invoice_due_date'] = array('title' => 'Due Date', 'callback' => function ($invoice) {
                    if ((!$invoice['date_paid'] || $invoice['date_paid'] == '0000-00-00') && strtotime($invoice['date_due']) < time()) {
                        echo '<span class="error_text">';
                        echo print_date($invoice['date_due']);
                        echo '</span>';
                    } else {
                        echo print_date($invoice['date_due']);
                    }
                });
                $columns['invoice_sent_date'] = array('title' => 'Sent Date', 'callback' => function ($invoice) {
                    if ($invoice['date_sent'] && $invoice['date_sent'] != '0000-00-00') {
                        ?>

				            <?php 
                        echo print_date($invoice['date_sent']);
                        ?>

				        <?php 
                    } else {
                        ?>

				            <span class="error_text"><?php 
                        _e('Not sent');
                        ?>
</span>
				        <?php 
                    }
                });
                $columns['invoice_paid_date'] = array('title' => 'Paid Date', 'callback' => function ($invoice) {
                    if ($invoice['date_paid'] && $invoice['date_paid'] != '0000-00-00') {
                        ?>

				            <?php 
                        echo print_date($invoice['date_paid']);
                        ?>

				        <?php 
                    } else {
                        if ($invoice['date_cancel'] && $invoice['date_cancel'] != '0000-00-00') {
                            ?>

				            <span class="error_text"><?php 
                            _e('Cancelled');
                            ?>
</span>
				        <?php 
                        } else {
                            if ($invoice['overdue']) {
                                ?>

				            <span class="error_text" style="font-weight: bold; text-decoration: underline;"><?php 
                                _e('Overdue');
                                ?>
</span>
				        <?php 
                            } else {
                                ?>

				            <span class="error_text"><?php 
                                _e('Not paid');
                                ?>
</span>
				        <?php 
                            }
                        }
                    }
                });
                if (class_exists('module_website', false) && module_website::is_plugin_enabled() && module_website::can_i('view', module_config::c('project_name_plural', 'Websites'))) {
                    $colspan++;
                    $columns['invoice_website'] = array('title' => module_config::c('project_name_single', 'Website'), 'callback' => function ($invoice) {
                        if (isset($invoice['website_ids'])) {
                            foreach ($invoice['website_ids'] as $website_id) {
                                if ((int) $website_id > 0) {
                                    echo module_website::link_open($website_id, true);
                                    echo '<br/>';
                                }
                            }
                        }
                    });
                }
                $columns['invoice_job'] = array('title' => 'Job', 'callback' => function ($invoice) {
                    foreach ($invoice['job_ids'] as $job_id) {
                        if ((int) $job_id > 0) {
                            //echo module_job::link_open($job_id,true);
                            $job_data = module_job::get_job($job_id);
                            echo '<a href="' . module_job::link_public($job_id) . '">' . htmlspecialchars($job_data['name']) . '</a>';
                            if ($job_data['date_start'] && $job_data['date_start'] != '0000-00-00' && $job_data['date_renew'] && $job_data['date_renew'] != '0000-00-00') {
                                _e(' (%s to %s)', print_date($job_data['date_start']), print_date(strtotime("-1 day", strtotime($job_data['date_renew']))));
                            }
                            echo "<br/>\n";
                        }
                    }
                    hook_handle_callback('invoice_admin_list_job', $invoice['invoice_id']);
                });
                if (!isset($_REQUEST['customer_id']) && module_customer::can_i('view', 'Customers')) {
                    $colspan++;
                    $columns['invoice_customer'] = array('title' => 'Customer', 'callback' => function ($invoice) {
                        echo module_customer::link_open($invoice['customer_id'], true);
                    });
                }
                $columns['c_invoice_total'] = array('title' => 'Invoice Total', 'callback' => function ($invoice) {
                    echo dollar($invoice['total_amount'], true, $invoice['currency_id']);
                });
                $columns['c_invoice_total_due'] = array('title' => 'Amount Due', 'callback' => function ($invoice) {
                    echo dollar($invoice['total_amount_due'], true, $invoice['currency_id']);
                    ?>

				        <?php 
                    if ($invoice['total_amount_credit'] > 0) {
                        ?>

				        <span class="success_text"><?php 
                        echo _l('Credit: %s', dollar($invoice['total_amount_credit'], true, $invoice['currency_id']));
                        ?>
</span>
				            <?php 
                    }
                });
                if (class_exists('module_extra', false)) {
                    ob_start();
                    $colspan2 += module_extra::print_table_header('invoice');
                    // used in the footer calc.
                    ob_end_clean();
                    $table_manager->display_extra('invoice', function ($invoice) {
                        module_extra::print_table_data('invoice', $invoice['invoice_id']);
                    });
                }
                $table_manager->set_columns($columns);
                $table_manager->row_callback = function ($row_data) {
                    // load the full vendor data before displaying each row so we have access to more details
                    if (isset($row_data['invoice_id']) && (int) $row_data['invoice_id'] > 0) {
                        return module_invoice::get_invoice($row_data['invoice_id']);
                    }
                    return array();
                };
                $table_manager->set_rows($invoices);
                if (module_config::c('invoice_list_show_totals', 1)) {
                    $footer_rows = array();
                    foreach ($invoice_total + $invoice_total_due as $currency_id => $foo) {
                        $currency = get_single('currency', 'currency_id', $currency_id);
                        $footer_rows[] = array('invoice_number' => array('data' => '<strong>' . _l('%s Totals:', $currency && isset($currency['code']) ? $currency['code'] : '') . '</strong>', 'cell_colspan' => $colspan - 2, 'cell_class' => 'text-right'), 'c_invoice_total' => array('data' => '<strong>' . dollar(isset($invoice_total[$currency_id]) ? $invoice_total[$currency_id] : 0, true, $currency_id) . '</strong>'), 'c_invoice_total_due' => array('data' => '<strong>' . dollar(isset($invoice_total_due[$currency_id]) ? $invoice_total_due[$currency_id] : 0, true, $currency_id) . '</strong>'), 'row_bulk_action' => array('data' => ' ', 'cell_colspan' => $colspan2));
                    }
                    $table_manager->set_footer_rows($footer_rows);
                }
                $table_manager->pagination = false;
                $table_manager->print_table();
                return ob_get_clean();
            }
    ?>

        <?php 
    if ($invoice['total_amount_credit'] > 0) {
        ?>

        <span class="success_text"><?php 
        echo _l('Credit: %s', dollar($invoice['total_amount_credit'], true, $invoice['currency_id']));
        ?>
</span>
            <?php 
    }
});
if (class_exists('module_extra', false)) {
    ob_start();
    $colspan2 += module_extra::print_table_header('invoice');
    // used in the footer calc.
    ob_end_clean();
    $table_manager->display_extra('invoice', function ($invoice) {
        module_extra::print_table_data('invoice', $invoice['invoice_id']);
    });
}
if (module_invoice::can_i('edit', 'Invoices')) {
    $colspan2++;
    // used in the footer
    $columns['row_bulk_action'] = array('title' => ' ', 'callback' => function ($invoice) {
        echo '<input type="checkbox" name="invoice_bulk_operation[' . $invoice['invoice_id'] . ']" value="yes">';
    });
}
$table_manager->set_columns($columns);
$table_manager->row_callback = function ($row_data) {
    public function print_table()
    {
        $this->process_data();
        $colspan = 0;
        if (!$this->inline_table) {
            ?>
        <div class="box <?php 
            echo module_theme::get_config('adminlte_boxstyle', 'box-solid');
            ?>
">
            <?php 
            /*if($this->pagination){
                        ?>
                        <div class="box-header clearfix">
                            <div class="row"><div class="col-xs-6">
            
                            </div><div class="col-xs-6 text-right">
                            <?php  echo $this->rows['summary']; ?>
                            </div></div>
                        </div>
                        <?php
                        }*/
            ?>
        <div class="box-body table-responsive <?php 
            echo module_theme::get_config('adminlte_tablefullwidth', 1) ? 'no-padding' : '';
            ?>
">
            <?php 
        }
        ?>
            <table class="<?php 
        echo $this->table_class;
        echo module_theme::get_config('adminlte_tablestripe', '1') ? ' table-striped' : '';
        echo module_theme::get_config('adminlte_tableborder', '0') ? ' table-bordered' : '';
        ?>
"<?php 
        echo $this->table_id ? ' id="' . $this->table_id . '"' : '';
        ?>
>
            <thead>
            <tr class="title">
                <?php 
        foreach ($this->columns as $column_id => $column_data) {
            $title = is_array($column_data) ? $column_data['title'] : $column_data;
            $colspan++;
            ?>
                    <th id="<?php 
            echo $column_id;
            ?>
"><?php 
            echo _l($title);
            ?>
</th>
                <?php 
        }
        if (class_exists('module_extra', false) && count($this->extra_fields)) {
            foreach ($this->extra_fields as $extra_field) {
                $colspan += module_extra::print_table_header($extra_field['type']);
            }
        }
        if (class_exists('module_subscription', false) && count($this->subscription_fields)) {
            foreach ($this->subscription_fields as $extra_field) {
                module_subscription::print_table_header($extra_field['type']);
                $colspan++;
            }
        }
        ?>
            </tr>
            </thead>
	        <?php 
        if (count($this->header_rows)) {
            ?>
            <thead class="summary">
            <?php 
            foreach ($this->header_rows as $row) {
                $this->print_footer_row($row);
            }
            ?>
            </thead>
            <?php 
        }
        ?>
            <tbody>
            <?php 
        if (!count($this->rows['rows'])) {
            if ($this->blank_message) {
                ?>
	                <tr>
		                <td colspan="<?php 
                echo $colspan;
                ?>
" class="blank_message" style="text-align: center"><?php 
                _e($this->blank_message);
                ?>
</td>
	                </tr>
	                <?php 
            }
        } else {
            foreach ($this->rows['rows'] as $row) {
                $this->print_row($row);
            }
        }
        ?>
            </tbody>
            <?php 
        if (count($this->footer_rows)) {
            ?>
            <tfoot class="summary">
            <?php 
            foreach ($this->footer_rows as $row) {
                $this->print_footer_row($row);
            }
            ?>
            </tfoot>
            <?php 
        }
        ?>
        </table>
        <?php 
        if (!$this->inline_table) {
            ?>
        </div>
        <?php 
        }
        if ($this->pagination && (!$this->pagination_hide_single_page || $this->pagination_hide_single_page && $this->rows['page_numbers'] > 1)) {
            ?>
            <div class="box-footer clearfix">
                <div class="row"><div class="col-xs-6">
                <?php 
            // regex and change the default pagination html output to something nicer, default is:
            /* <div class="pagination_links"><span>			    « Prev |
               </span>					<span><a href="/ucm/demo/customer.customer_admin_list/?leads=1&amp;pgtable=0#t_table" rel="0" class="current">1</a></span>
                                           <span><a href="/ucm/demo/customer.customer_admin_list/?leads=1&amp;pgtable=1#t_table" rel="1" class="">2</a></span>
                                           <span><a href="/ucm/demo/customer.customer_admin_list/?leads=1&amp;pgtable=2#t_table" rel="2" class="">3</a></span>
                                           <span><a href="/ucm/demo/customer.customer_admin_list/?leads=1&amp;pgtable=3#t_table" rel="3" class="">4</a></span>
                                       | <span><a href="/ucm/demo/customer.customer_admin_list/?leads=1&amp;pgtable=1#t_table" rel="1">Next »</a><span>
               </span></span></div> */
            $this->rows['links'] = str_replace('<div class="pagination_links">', '<div class="pagination_links paging_bootstrap pagination-sm no-margin"><ul class="pagination pagination-sm">', $this->rows['links']);
            $this->rows['links'] = str_replace('</div>', '</ul></div>', $this->rows['links']);
            //$this->rows['links'] = str_replace('pagination_links','pagination_links paging_bootstrap',$this->rows['links']);
            $this->rows['links'] = str_replace('|', '', $this->rows['links']);
            $this->rows['links'] = str_replace('...', '<li class="disabled"><a href="#">...</a></li>', $this->rows['links']);
            if (preg_match_all('#<span>(.*)</span>#imsU', $this->rows['links'], $matches)) {
                foreach ($matches[0] as $key => $val) {
                    $li_class = strpos($val, 'current') ? 'active' : '';
                    if (strpos($matches[1][$key], '<a') === false) {
                        $li_class = 'disabled';
                        $matches[1][$key] = '<a href="#">' . $matches[1][$key] . '</a>';
                    }
                    $this->rows['links'] = str_replace($val, '<li class="' . $li_class . '">' . $matches[1][$key] . '</li>', $this->rows['links']);
                }
            }
            echo $this->rows['links'];
            ?>
                </div><div class="col-xs-6 text-right">
                <?php 
            echo $this->rows['summary'];
            ?>
                </div></div>
            </div>
            <?php 
        }
        if (!$this->inline_table) {
            ?>
        </div>
        <?php 
        }
    }
    public function print_table()
    {
        $this->process_data();
        if ($this->pagination && isset($this->rows['summary']) && (!$this->pagination_hide_single_page || $this->pagination_hide_single_page && $this->rows['page_numbers'] > 1)) {
            echo $this->rows['summary'];
        }
        $colspan = 0;
        $this->print_table_before();
        ?>

        <table class="<?php 
        echo $this->table_class;
        ?>
"<?php 
        echo $this->table_id ? ' id="' . $this->table_id . '"' : '';
        ?>
>
            <thead>
            <tr class="title">
                <?php 
        foreach ($this->columns as $column_id => $column_data) {
            $title = is_array($column_data) ? $column_data['title'] : $column_data;
            $colspan++;
            ?>
                    <th id="<?php 
            echo $column_id;
            ?>
"><?php 
            echo _l($title);
            ?>
</th>
                <?php 
        }
        if (class_exists('module_extra', false) && count($this->extra_fields)) {
            foreach ($this->extra_fields as $extra_field) {
                $colspan += module_extra::print_table_header($extra_field['type']);
            }
        }
        if (class_exists('module_subscription', false) && count($this->subscription_fields)) {
            foreach ($this->subscription_fields as $extra_field) {
                module_subscription::print_table_header($extra_field['type']);
                $colspan++;
            }
        }
        ?>
            </tr>
            </thead>
	        <?php 
        if (count($this->header_rows)) {
            ?>
            <thead class="summary">
            <?php 
            foreach ($this->header_rows as $row) {
                $this->print_footer_row($row);
            }
            ?>
            </thead>
            <?php 
        }
        ?>
            <tbody>
            <?php 
        $c = 0;
        if (!count($this->rows['rows'])) {
            if ($this->blank_message) {
                ?>
	                <tr>
		                <td colspan="<?php 
                echo $colspan;
                ?>
" class="blank_message" style="text-align: center"><?php 
                _e($this->blank_message);
                ?>
</td>
	                </tr>
	                <?php 
            }
        } else {
            foreach ($this->rows['rows'] as $row) {
                $this->print_row($row);
            }
        }
        ?>
            </tbody>
            <?php 
        if (count($this->footer_rows)) {
            ?>
            <tfoot class="summary">
            <?php 
            foreach ($this->footer_rows as $row) {
                $this->print_footer_row($row);
            }
            ?>
            </tfoot>
            <?php 
        }
        ?>
        </table>
        <?php 
        $this->print_table_after();
        if ($this->pagination && isset($this->rows['links']) && (!$this->pagination_hide_single_page || $this->pagination_hide_single_page && $this->rows['page_numbers'] > 1)) {
            echo $this->rows['links'];
        }
    }