<?php

use_class('ReportBookkeeping');
if (isset($_GET['download'])) {
    ReportBookkeeping::setOptionArchiveQueryAsExcel(true);
    ReportBookkeeping::setOptionDirectDownloadArchiveFile(true);
    if ($_GET['download'] == 'atriga-detail-list') {
        $period = tep_db_prepare_input($_GET['period']);
        ReportBookkeeping::getAtrigaTotal($period);
    }
    exit;
}
$year_now = date('Y');
$year = isset($_POST['year']) ? tep_db_prepare_input($_POST['year']) : $year_now;
$year_options = array();
for ($y = $year_now; $y >= 2013; $y--) {
    $year_options[$y] = $y;
}
$info_icon_open_amount_now = '<span class="ui-icon ui-icon-info help" ' . 'title="Total amount of invoices in this period which are still open ' . ' until now."></span> ';
$info_icon_conf_payment_prev_month = '<span class="ui-icon ui-icon-info help" ' . 'title="Total payment confirmation we have received from Payone<br /> in ' . 'the first workday of the month (excluding Paypal payment).<br />If total ' . 'found is less than 500 Euros it will be summed up<br />with next ' . 'day value."></span>';
$info_icon_sent_to_atriga = '<span class="ui-icon ui-icon-info help" ' . 'title="Total Invoice Amount which was sent to Atriga from this period"></span>';
$info_icon_after_returns = '<span class="ui-icon ui-icon-info help" ' . 'title="Total Invoice Amount after returns from this period"></span>';
$info_icon_stock_value = '<span class="ui-icon ui-icon-info help" ' . 'title="Total value of stock at the end of this period"></span>';
$info_icon_stock_incoming = '<span class="ui-icon ui-icon-info help" ' . 'title="Total value of incoming stock (currently on the way) at the end of this period"></span>';
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'SAVEMANUALINPUT') {
        $period = $_POST['period'];
        $paid_amount = $_POST['paid_amount'];
        $refund_amount = $_POST['refund_amount'];
        ReportBookkeeping::addManualInputValue($period, $paid_amount, $refund_amount);
        $bkdata = ReportBookkeeping::retrieveDetail($period);