+ $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
+ ".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";
+ $result = db_query($sql, "Transactions could not be calculated");
+ $title = _("Last $weeks weeks Performance");
+ check_page_security('SA_GLANALYTIC');
+ $i = 0;
+ while ($myrow = db_fetch($result))
+ {
+ $pg->x[$i] = $myrow['week_name'];
+ $pg->y[$i] = $myrow['sales'];
+ $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);
+}
+
+function source_graphic($today, $title, $x_axis, $pg, $graphic1, $graphic2=null, $type=2)
+{
+ if (count($pg->y) ==0 || (count($pg->y) == 1 && $pg->y[0] == 0))
+ return;
+ display_title("$title ($today)");
+ //$pg->title = $title . " - " . $today;
+ $pg->axis_x = $x_axis;