From: Joe Hunt Date: Fri, 12 May 2017 16:02:36 +0000 (+0200) Subject: Added a small Arabic font file and improved the builtin DashBoard. X-Git-Tag: v2.4.2~19^2~15 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=af9e628479b38b0cd7972044ab02902b020211e9 Added a small Arabic font file and improved the builtin DashBoard. --- diff --git a/config.default.php b/config.default.php index cdbb2d44..ba6eadcb 100644 --- a/config.default.php +++ b/config.default.php @@ -154,6 +154,7 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ /* UTF-8 font for Business Graphics. Copy it to /reporting/fonts/ folder. */ $UTF8_fontfile = "FreeSans.ttf"; + //$UTF8_fontfile = "zarnormal.ttf"; // for Arabic Dashboard /* Display a dropdown select box for choosing Company to login if false. diff --git a/includes/dashboard.inc b/includes/dashboard.inc index d5c5b17d..af8219a9 100644 --- a/includes/dashboard.inc +++ b/includes/dashboard.inc @@ -408,17 +408,16 @@ function gl_performance($today, $width="33", $weeks=5) $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 + $sql = "SELECT week_name, sales, costs + FROM(SELECT DATE_FORMAT(tran_date, '%Y-%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, 5) 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 +429,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); } diff --git a/reporting/fonts/zarnormal.ttf b/reporting/fonts/zarnormal.ttf new file mode 100644 index 00000000..0542a5c7 Binary files /dev/null and b/reporting/fonts/zarnormal.ttf differ diff --git a/reporting/includes/class.graphic.inc b/reporting/includes/class.graphic.inc index 7b7d32e9..da537dd5 100644 --- a/reporting/includes/class.graphic.inc +++ b/reporting/includes/class.graphic.inc @@ -160,7 +160,7 @@ class graph // You can also use another UTF-8 font and put it in config.php with the name in $UTF8_fontfile $this->fontfile = $this->encoding == 'UTF-8' ? (isset($SysPrefs->UTF8_fontfile) && $SysPrefs->UTF8_fontfile != "" ? $path.$SysPrefs->UTF8_fontfile : $path.'FreeSans.ttf') : $path.'LiberationSans-Regular.ttf'; - + $this->x = $this->y = $this->z = array(); $this->biggest_x = NULL; $this->biggest_y = NULL; @@ -1000,6 +1000,12 @@ class graph $size = 12; $y += $size + 3; $angle = 0; + + if ($this->encoding == 'UTF-8' && is_arabic($string)) + { + $size += 2; + $string = str_replace(" ", " ", $string); + } imagettftext($img, $size, $angle, $x, $y + $alt, $col, $this->fontfile, $string); }