Exemplo n.º 1
0
{
    return date("Y-m-d", strtotime('01-' . date('m') . '-' . date('Y') . ' 00:00:00'));
}
function lastOfMonth()
{
    return date("Y-m-d", strtotime('-1 second', strtotime('+1 month', strtotime('01-' . date('m') . '-' . date('Y') . ' 00:00:00'))));
}
isset($_POST['start_date']) ? $start_date = $_POST['start_date'] : ($start_date = firstOfMonth());
isset($_POST['end_date']) ? $end_date = $_POST['end_date'] : ($end_date = lastOfMonth());
$sql = "select \n        e.amount as expense, \n        e.status as status, \n        ea.name as account,\n        (select sum(tax_amount) from si_expense_item_tax where expense_id = e.id) as tax,\n        (select tax + e.amount) as total,\n        (CASE WHEN status = 1 THEN '" . $LANG['paid'] . "'\n              WHEN status = 0 THEN '" . $LANG['not_paid'] . "'\n         END) AS status_wording\n    from \n        si_expense e, \n        si_expense_account ea \n    where \n        e.expense_account_id = ea.id \n        and \n        e.date between '{$start_date}' and '{$end_date}'";
$sth = $db->query($sql);
$accounts = $sth->fetchAll();
$payment = new payment();
$payment->start_date = $start_date;
$payment->end_date = $end_date;
$payment->filter = "date";
$payments = $payment->select_all();
$invoice = new invoice();
$invoice->start_date = $start_date;
$invoice->end_date = $end_date;
$invoice->having = "date_between";
$invoice->sort = "preference";
$invoice_all = $invoice->select_all();
$invoices = $invoice_all->fetchAll();
$smarty->assign('accounts', $accounts);
$smarty->assign('payments', $payments);
$smarty->assign('invoices', $invoices);
$smarty->assign('start_date', $start_date);
$smarty->assign('end_date', $end_date);
$smarty->assign('pageActive', 'report');
$smarty->assign('active_tab', '#home');