function entrylist_invoice_tobemade($SQL, $tamed_booking, $area_spesific = false)
{
    $Q = mysql_query($SQL . ' order by `time_start`');
    if (!$tamed_booking || !mysql_num_rows($Q)) {
        echo __('No entries found.');
    } else {
        echo '<font color="red">' . mysql_num_rows($Q) . '</font> ' . __('entries found.');
        echo '<br>' . chr(10) . chr(10);
        echo '<table style="border-collapse: collapse;">' . chr(10);
        echo ' <tr>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>Arrangementsdato</b></td>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>' . __('Name') . '</b></td>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>' . __('Area') . '</b></td>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>Sum</b></td>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>&nbsp;</b></td>' . chr(10);
        echo ' </tr>' . chr(10);
        while ($R = mysql_fetch_assoc($Q)) {
            $entry = getEntry($R['entry_id']);
            echo ' <tr>' . chr(10);
            // Starts
            echo '  <td style="border: 1px solid black;">';
            echo '<a href="day.php?year=' . date('Y', $entry['time_start']) . '&amp;month=' . date('m', $entry['time_start']) . '&amp;day=' . date('d', $entry['time_start']) . '&amp;area=' . $entry['area_id'] . '">' . date('d', $entry['time_start']) . '</a>-';
            echo '<a href="month.php?year=' . date('Y', $entry['time_start']) . '&amp;month=' . date('m', $entry['time_start']) . '&amp;day=' . date('d', $entry['time_start']) . '&amp;area=' . $entry['area_id'] . '">' . __(date('m', $entry['time_start'])) . '</a>-';
            echo date('Y', $entry['time_start']);
            echo '</td>' . chr(10);
            // Name
            echo '  <td style="border: 1px solid black;"><a href="entry.php?entry_id=' . $entry['entry_id'] . '">' . $entry['entry_name'] . '</a>';
            $checkInvoice = checkInvoicedata($entry);
            if (count($checkInvoice[0])) {
                echo '<br /><br /><b>Feil med fakturagrunnlag:</b><br />';
                echo '<div class="error"><ul style="padding-left: 20px; margin: 0px;">';
                foreach ($checkInvoice[0] as $error) {
                    echo '<li>' . $error . '</li>';
                }
                echo '</ul></div>';
            }
            if (count($checkInvoice[1])) {
                if (!count($checkInvoice[0])) {
                    echo '<br /><br />';
                }
                echo '<b>Advarsler p&aring; fakturagrunnlag:</b><br />';
                echo '<div class="notice"><ul style="padding-left: 20px; margin: 0px;">';
                foreach ($checkInvoice[1] as $warnings) {
                    echo '<li>' . $warnings . '</li>';
                }
                echo '</ul></div>';
            }
            echo '</td>' . chr(10);
            // Area
            echo '  <td style="border: 1px solid black;">';
            $area = getArea($entry['area_id']);
            if (count($area)) {
                echo $area['area_name'];
            }
            echo '</td>' . chr(10);
            // Invoice
            echo '  <td style="border: 1px solid black; text-align: right;">kr&nbsp;' . smarty_modifier_commify($entry['faktura_belop_sum'], 2, ",", "&nbsp;") . '</td>' . chr(10);
            // Set ready
            echo '  <td style="border: 1px solid black;">';
            echo '<a href="invoice_setready.php?entry_id=' . $entry['entry_id'];
            if ($area_spesific) {
                echo '&amp;return=invoice_tobemade_area';
            } else {
                echo '&amp;return=invoice_tobemade';
            }
            echo '">' . 'Sett&nbsp;faktureringsklar&nbsp;';
            if (count($checkInvoice[0])) {
                // Errors
                echo iconHTML('arrow_right_red');
            } elseif (count($checkInvoice[1])) {
                // Warnings
                echo iconHTML('arrow_right_yellow');
            } else {
                // None
                echo iconHTML('arrow_right');
            }
            echo '</a>';
            echo '</td>' . chr(10);
            echo ' </tr>' . chr(10);
        }
        echo '</table>';
    }
}
    echo '<div class="error">Du forsøker å sende mer enn 50 bookinger til regnskap på likt. ' . 'Dette blir sannsynligvis for mye for bookingsystemet (klarer ikke så mange i en PDF), så forsøket er blitt stoppet.<br /><br />' . 'Velg et mindre antall og forsøk igjen.</div>';
    exit;
}
$ignore_errors = false;
if (isset($_GET['ignore_errors']) && $_GET['ignore_errors'] == '1') {
    $ignore_errors = true;
}
$entry_errors = false;
$entries = array();
$entry_ids_url = array();
foreach ($_GET['entry_id'] as $id) {
    $tmp_entry = getEntry($id);
    $id = $tmp_entry['entry_id'];
    $entries[$id] = $tmp_entry;
    $entry_ids_url[] = 'entry_id[]=' . $id;
    $checkInvoice = checkInvoicedata($tmp_entry);
    if (count($checkInvoice[0]) && !$ignore_errors) {
        if (!$entry_errors) {
            $section = 'tobemade_ready';
            include "include/invoice_menu.php";
            $entry_errors = true;
            echo '<span class="hiddenprint">';
            $Q_area = mysql_query("select id as area_id, area_name from mrbs_area order by area_name");
            $num_area = mysql_num_rows($Q_area);
            $counter_area = 0;
            echo '<span style="font-size: 0.8em;">Filtrer p&aring; anlegg: ';
            while ($R = mysql_fetch_assoc($Q_area)) {
                $counter_area++;
                if ($area_spesific && $area_invoice['area_id'] == $R['area_id']) {
                    echo '<b>';
                }
        $return = $_GET['return'];
    } else {
        $return_to = 'entry.php?entry_id=' . $entry['entry_id'];
        $return = '';
    }
} else {
    $return_to = 'entry.php?entry_id=' . $entry['entry_id'];
    $return = '';
}
if (isset($_GET['set_okey'])) {
    // Do the changes...
    if (!entrySetReady($entry)) {
        echo 'Feil oppsto. Kontakt systemansvarlig.';
        exit;
    }
    header('Location: ' . $return_to);
    exit;
}
$checkInvoice = checkInvoicedata($entry);
$day = date('d', $entry['time_start']);
$month = date('m', $entry['time_start']);
$year = date('Y', $entry['time_start']);
$area = $entry['area_id'];
print_header($day, $month, $year, $area);
$smarty = new Smarty();
templateAssignEntry('smarty', $entry);
templateAssignSystemvars('smarty');
$smarty->assign('return', $return);
$smarty->assign('return_to', $return_to);
$smarty->assign('checkInvoice', $checkInvoice);
$smarty->display('file:invoice_setready.tpl');