X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fdashboard.inc;h=493a70730078256be109412b7f56bf1f946142ae;hb=247a958cc67f9479eb746984b23a660ff9334563;hp=962152b24f816a8826ec0164b24c6c3176a014f2;hpb=4ae7b93fee1e59e639b39833f1437bcbc35685ea;p=fa-stable.git diff --git a/includes/dashboard.inc b/includes/dashboard.inc index 962152b2..493a7073 100644 --- a/includes/dashboard.inc +++ b/includes/dashboard.inc @@ -181,7 +181,7 @@ function customer_top($today, $limit=10, $width="33", &$pg=null) AND tran_date >= '$begin1' AND tran_date <= '$today1' GROUP by d.debtor_no ORDER BY total DESC, d.debtor_no LIMIT $limit"; $result = db_query($sql); - $title = _("Top $limit customers in fiscal year"); + $title = sprintf(_("Top %s customers in fiscal year"), $limit); display_title($title); $th = array(_("Customer"), _("Amount")); start_table(TABLESTYLE, "width='$width%'"); @@ -218,7 +218,7 @@ function supplier_top($today, $limit=10, $width="33", &$pg=null) AND tran_date >= '$begin1' AND tran_date <= '$today1' GROUP by s.supplier_id ORDER BY total DESC, s.supplier_id LIMIT $limit"; $result = db_query($sql); - $title = _("Top $limit suppliers in fiscal year"); + $title = sprintf(_("Top %s suppliers in fiscal year"), $limit); display_title($title); $th = array(_("Supplier"), _("Amount")); start_table(TABLESTYLE, "width='$width%'"); @@ -279,11 +279,11 @@ function stock_top($today, $limit=10, $width="33", $type=0, &$pg=null) LIMIT $limit"; $result = db_query($sql); if ($type == 1) - $title = _("Top $limit Manufactured Items in fiscal year"); + $title = sprintf(_("Top %s Manufactured Items in fiscal year"), $limit); elseif ($type == 2) - $title = _("Top $limit Fixed Assets"); + $title = sprintf(_("Top %s Fixed Assets"), $limit); else - $title = _("Top $limit Sold Items in fiscal year"); + $title = sprintf(_("Top %s Sold Items in fiscal year"), $limit); display_title($title); if ($type == 0) $th = array(_("Item"), _("Sales"), _("Costs"), _("Quantity")); @@ -328,7 +328,7 @@ function dimension_top($today, $limit=10, $width="33", &$pg=null) (t.dimension_id = d.id OR t.dimension2_id = d.id) AND t.tran_date >= '$begin1' AND t.tran_date <= '$today1' GROUP BY d.id ORDER BY total DESC LIMIT $limit"; $result = db_query($sql, "Transactions could not be calculated"); - $title = _("Top $limit Dimensions in fiscal year"); + $title = sprintf(_("Top %s Dimensions in fiscal year"), $limit); display_title($title); $th = array(_("Dimension"), _("Amount")); start_table(TABLESTYLE, "width='$width%'"); @@ -403,22 +403,23 @@ function gl_top($today, $width="33", &$pg=null) function gl_performance($today, $width="33", $weeks=5) { + global $SysPrefs; $pg = new graph(); $begin = begin_fiscalyear(); $begin1 = date2sql($begin); $today1 = date2sql($today); - $sql = "SELECT CONCAT(YEAR(tran_date), '/', WEEK(tran_date)) AS week_name, - SUM(IF (c.ctype = 4, amount * -1, 0)) AS sales, - SUM(IF (c.ctype = 6, amount, 0)) AS costs - FROM + $sep = $SysPrefs->dateseps[user_date_sep()]; + $sql = "SELECT week_name, sales, costs + FROM(SELECT DATE_FORMAT(tran_date, '%Y{$sep}%u') AS week_name, + SUM(IF(c.ctype = 4, amount * -1, 0)) AS sales, + SUM(IF(c.ctype = 6, amount, 0)) AS costs FROM ".TB_PREF."gl_trans, ".TB_PREF."chart_master AS a, ".TB_PREF."chart_types AS t, - ".TB_PREF."chart_class AS c WHERE (c.ctype = 4 OR c.ctype = 6) - AND account = a.account_code AND a.account_type = t.id AND t.class_id = c.cid - AND IF(c.ctype > 3, tran_date >= '$begin1', tran_date >= '0000-00-00') - AND tran_date <= '$today1' - GROUP BY week_name - ORDER BY YEAR(tran_date) DESC, WEEK(tran_date) DESC limit 0, $weeks"; + ".TB_PREF."chart_class AS c WHERE(c.ctype = 4 OR c.ctype = 6) + AND account = a.account_code AND a.account_type = t.id AND t.class_id = c.cid + AND tran_date >= '$begin1' AND tran_date <= '$today1' + GROUP BY week_name ORDER BY week_name DESC LIMIT 0, $weeks) b + GROUP BY week_name ORDER BY week_name ASC"; $result = db_query($sql, "Transactions could not be calculated"); $title = _("Last $weeks weeks Performance"); check_page_security('SA_GLANALYTIC'); @@ -430,9 +431,6 @@ function gl_performance($today, $width="33", $weeks=5) $pg->z[$i] = $myrow['costs']; $i++; } - $pg->x = array_reverse($pg->x); - $pg->y = array_reverse($pg->y); - $pg->z = array_reverse($pg->z); source_graphic($today, $title, _("Week"), $pg, _("Sales"), _("Costs"), 1); } @@ -451,7 +449,7 @@ function source_graphic($today, $title, $x_axis, $pg, $graphic1, $graphic2=null, $pg->type = $type; $pg->skin = 1; $pg->built_in = false; - $filename = company_path(). "/pdf_files/". uniqid("").".png"; + $filename = company_path(). "/pdf_files/". random_id().".png"; $pg->display($filename, true); start_table(TABLESTYLE); start_row();