include_once($path_to_root . "/gl/includes/gl_db.inc");
$js = "";
-if ($use_date_picker)
+if (user_use_date_picker())
$js = get_js_date_picker();
page(_($help_context = "Profit & Loss Drilldown"), false, false, "", $js);
+$compare_types = array(
+ _("Accumulated"),
+ _("Period Y-1"),
+ _("Budget")
+);
//----------------------------------------------------------------------------------------------------
// Ajax updates
//Get Accounts directly under this group/type
$result = get_gl_accounts(null, null, $type);
-
+
while ($account=db_fetch($result))
{
$per_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2);
function inquiry_controls()
{
+ global $compare_types;
+
$dim = get_company_pref('use_dimension');
start_table(TABLESTYLE_NOBORDER);
- date_cells(_("From:"), 'TransFromDate', '', null, -$_SESSION["wa_current_user"]->prefs->transaction_days());
+ $date = today();
+ if (!isset($_POST['TransToDate']))
+ $_POST['TransToDate'] = end_month($date);
+ if (!isset($_POST['TransFromDate']))
+ $_POST['TransFromDate'] = add_days(end_month($date), -user_transaction_days());
+ date_cells(_("From:"), 'TransFromDate');
date_cells(_("To:"), 'TransToDate');
- //Compare Combo
- global $sel;
- $sel = array(_("Accumulated"), _("Period Y-1"), _("Budget"));
echo "<td>"._("Compare to").":</td>\n";
echo "<td>";
- echo array_selector('Compare', null, $sel);
+ echo array_selector('Compare', null, $compare_types);
echo "</td>\n";
+
if ($dim >= 1)
dimensions_list_cells(_("Dimension")." 1:", 'Dimension', null, true, " ", false, 1);
if ($dim > 1)
//----------------------------------------------------------------------------------------------------
-function display_profit_and_loss()
+function display_profit_and_loss($compare)
{
- global $path_to_root, $sel;
+ global $path_to_root, $compare_types;
if (!isset($_POST['Dimension']))
$_POST['Dimension'] = 0;
$from = $_POST['TransFromDate'];
$to = $_POST['TransToDate'];
- $compare = $_POST['Compare'];
if (isset($_POST["AccGrp"]) && (strlen($_POST['AccGrp']) > 0))
$drilldown = 1; // Deeper Level
div_start('pl_tbl');
- start_table(TABLESTYLE, "width=50%");
+ start_table(TABLESTYLE, "width='50%'");
$tableheader = "<tr>
<td class='tableheader'>" . _("Group/Account Name") . "</td>
<td class='tableheader'>" . _("Period") . "</td>
- <td class='tableheader'>" . $sel[$compare] . "</td>
+ <td class='tableheader'>" . $compare_types[$compare] . "</td>
<td class='tableheader'>" . _("Achieved %") . "</td>
</tr>";
inquiry_controls();
-display_profit_and_loss();
+display_profit_and_loss(get_post('Compare'));
end_form();
end_page();
-?>
\ No newline at end of file