$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);
        $ajaxResult = array();
        $ajaxResult['period'] = $period;
        $ajaxResult['paid_amount'] = $bkdata['manual_input_paid_amount'];
        $ajaxResult['paid_amount_formatted'] = displayCurrency('EUR', $bkdata['manual_input_paid_amount'], false);
        $ajaxResult['refund_amount'] = $bkdata['manual_input_refund_amount'];
        $ajaxResult['refund_amount_formatted'] = displayCurrency('EUR', $bkdata['manual_input_refund_amount'], false);
        ajaxReturn($ajaxResult);
    } else {
        if ($_POST['me_action'] == 'LOADPERIOD') {
            $period = $_POST['period'];
            $period_year = substr($period, 0, 4);
            $period_month = intval(substr($period, -2));
            $period_prev_month = $period_month - 1;
            $period_prev = $period_prev_month <= 0 ? $period_year - 1 . '12' : $period_year . str_pad($period_prev_month, 2, '0', STR_PAD_LEFT);