X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fdashboard.inc;h=69654c88e39f9ba6e4624c6e55e1c663dead245d;hb=cf776631b028241405a5b2c41d0c03da456880f7;hp=13a94629f8c3b6a55fe95251bf8a08d36dcf5b63;hpb=366b3bf5f94581c40515216cf1da5254a1890c6d;p=fa-stable.git diff --git a/includes/dashboard.inc b/includes/dashboard.inc index 13a94629..69654c88 100644 --- a/includes/dashboard.inc +++ b/includes/dashboard.inc @@ -53,20 +53,13 @@ function dashboard($sel_app) display_all(); } -function display_customer_topten() +function display_title($title) { - $pg = new graph(); - - echo ""; - echo "
\n"; // outer table - $today = Today(); - $title = customer_top($today, 10, 66, $pg); - customer_trans($today); - echo "\n"; - source_graphic($today, $title, _("Customer"), $pg); - customer_recurrent_invoices($today); - echo "
\n"; -} + br(); + display_heading($title); + br(); + //echo "$title\n"; +} function table_one() { @@ -84,6 +77,20 @@ function table_end() echo "\n"; } +function display_customer_topten() +{ + $pg = new graph(); + + table_one(); + $today = Today(); + $title = customer_top($today, 10, 66, $pg); + customer_trans($today); + table_two(); + source_graphic($today, $title, _("Customer"), $pg, _("Sales")); + customer_recurrent_invoices($today); + table_end(); +} + function display_supplier_topten() { $pg = new graph(); @@ -93,7 +100,7 @@ function display_supplier_topten() $title = supplier_top($today, 10, 66, $pg); supplier_trans($today); table_two(); - source_graphic($today, $title, _("Supplier"), $pg); + source_graphic($today, $title, _("Supplier"), $pg, _("Purchase")); table_end(); } @@ -111,7 +118,8 @@ function display_stock_topten($type=0) $source = _("Manufacturing"); else $source = _("Items"); - source_graphic($today, $title, $source, $pg); + source_graphic($today, $title, $source, $pg, ($type == 0 ? _("Sales") : _("Amount")), + ($type == 0 ? _("Costs") : null)); table_end(); } @@ -123,7 +131,7 @@ function display_dimension_topten() $today = Today(); $title = dimension_top($today, 10, 66, $pg); table_two(); - source_graphic($today, $title, _("Dimension"), $pg, 5); + source_graphic($today, $title, _("Dimension"), $pg, _("Performance"), null, 5); table_end(); } @@ -136,7 +144,8 @@ function display_gl_info() $title = gl_top($today, 66, $pg); bank_balance($today, 66); table_two(); - source_graphic($today, $title, _("Class"), $pg, 5); + source_graphic($today, $title, _("Class"), $pg, _("Amount"), null, 5); + gl_performance($today, 66, 5); table_end(); } @@ -147,25 +156,20 @@ function display_all() table_one(); $title = customer_top($today, 3, 66, $pg); - source_graphic($today, $title, _("Customer"), $pg); + source_graphic($today, $title, _("Customer"), $pg, _("Sales")); $title = supplier_top($today, 3, 66, $pg); - source_graphic($today, $title, _("Supplier"), $pg); + source_graphic($today, $title, _("Supplier"), $pg, _("Purchases")); $title = stock_top($today, 3, 66, 0, $pg); - source_graphic($today, $title, _("Stock"), $pg); + source_graphic($today, $title, _("Stock"), $pg, _("Sales")); table_two(); dimension_top($today, 3, 66); $title = gl_top($today, 66, $pg); - source_graphic($today, $title, _("Class"), $pg, 5); + source_graphic($today, $title, _("Class"), $pg, _("Amount"), null, 5); stock_top($today, 3, 66, 2); stock_top($today, 3, 66, 1); table_end(); } -function display_title($title, $colspan=2) -{ - echo "$title\n"; -} - function customer_top($today, $limit=10, $width="33", &$pg=null) { $begin = begin_fiscalyear(); @@ -178,9 +182,9 @@ function customer_top($today, $limit=10, $width="33", &$pg=null) LIMIT $limit"; $result = db_query($sql); $title = _("Top $limit customers in fiscal year"); + display_title($title); $th = array(_("Customer"), _("Amount")); start_table(TABLESTYLE, "width='$width%'"); - display_title($title, count($th)); table_header($th); check_page_security('SA_SALESTRANSVIEW'); $k = 0; //row colour counter @@ -215,9 +219,9 @@ function supplier_top($today, $limit=10, $width="33", &$pg=null) LIMIT $limit"; $result = db_query($sql); $title = _("Top $limit suppliers in fiscal year"); + display_title($title); $th = array(_("Supplier"), _("Amount")); start_table(TABLESTYLE, "width='$width%'"); - display_title($title, count($th)); table_header($th); check_page_security('SA_SUPPTRANSVIEW'); $k = 0; //row colour counter @@ -254,7 +258,7 @@ function stock_top($today, $limit=10, $width="33", $type=0, &$pg=null) if ($type == 0) { $sql = "SELECT SUM((trans.unit_price * trans.quantity) * d.rate) AS total, s.stock_id, s.description, - SUM(trans.quantity) AS qty FROM + SUM(trans.quantity) AS qty, SUM((s.material_cost + s.overhead_cost + s.labour_cost) * trans.quantity) AS costs FROM ".TB_PREF."debtor_trans_details AS trans, ".TB_PREF."stock_master AS s, ".TB_PREF."debtor_trans AS d WHERE trans.stock_id=s.stock_id AND trans.debtor_trans_type=d.type AND trans.debtor_trans_no=d.trans_no AND (d.type = ".ST_SALESINVOICE." OR d.type = ".ST_CUSTCREDIT.") "; @@ -278,9 +282,12 @@ function stock_top($today, $limit=10, $width="33", $type=0, &$pg=null) $title = _("Top $limit Fixed Assets in fiscal year"); else $title = _("Top $limit Sold Items in fiscal year"); - $th = array(_("Item"), _("Amount"), _("Quantity")); + display_title($title); + if ($type == 0) + $th = array(_("Item"), _("Sales"), _("Costs"), _("Quantity")); + else + $th = array(_("Item"), _("Amount"), _("Quantity")); start_table(TABLESTYLE, "width='$width%'"); - display_title($title, count($th)); table_header($th); check_page_security($sec); $k = 0; //row colour counter @@ -291,16 +298,21 @@ function stock_top($today, $limit=10, $width="33", $type=0, &$pg=null) $name = $myrow["description"]; label_cell($name); amount_cell($myrow['total']); + if ($type == 0) + amount_cell($myrow['costs']); qty_cell($myrow['qty']); if ($pg != NULL) { $pg->x[$i] = $name; $pg->y[$i] = $myrow['total']; + if ($type == 0) + $pg->z[$i] = $myrow['costs']; } $i++; end_row(); } end_table(2); + return $title; } function dimension_top($today, $limit=10, $width="33", &$pg=null) @@ -315,9 +327,9 @@ function dimension_top($today, $limit=10, $width="33", &$pg=null) 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"); + display_title($title); $th = array(_("Dimension"), _("Amount")); start_table(TABLESTYLE, "width='$width%'"); - display_title($title, count($th)); table_header($th); check_page_security('SA_DIMTRANSVIEW'); $k = 0; //row colour counter @@ -337,6 +349,7 @@ function dimension_top($today, $limit=10, $width="33", &$pg=null) end_row(); } end_table(2); + return $title; } function gl_top($today, $width="33", &$pg=null) @@ -352,8 +365,8 @@ function gl_top($today, $width="33", &$pg=null) AND tran_date <= '$today1' GROUP BY c.cid ORDER BY c.cid"; $result = db_query($sql, "Transactions could not be calculated"); $title = _("Class Balances"); - start_table(TABLESTYLE2, "width='$width%'"); display_title($title); + start_table(TABLESTYLE2, "width='$width%'"); check_page_security('SA_GLANALYTIC'); $i = 0; $total = 0; @@ -383,14 +396,56 @@ function gl_top($today, $width="33", &$pg=null) $pg->y[$i] = -$total; } end_table(2); + return $title; +} + +function gl_performance($today, $width="33", $weeks=5) +{ + $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, $source, $pg, $type=2) +function source_graphic($today, $title, $x_axis, $pg, $graphic1, $graphic2=null, $type=2) { - $pg->title = $title; - $pg->axis_x = $source; + 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; $pg->axis_y = _("Amount"); - $pg->graphic_1 = $today; + $pg->graphic_1 = $graphic1; + if ($graphic2 != null) + $pg->graphic_2 = $graphic2; $pg->type = $type; $pg->skin = 1; $pg->built_in = false; @@ -424,14 +479,12 @@ function customer_trans($today) AND DATEDIFF('$today', trans.due_date) > 0 ORDER BY days DESC"; $result = db_query($sql); $title = db_num_rows($result) . _(" overdue Sales Invoices"); - br(1); - display_heading($title); - br(); + display_title($title); $th = array("#", _("Ref."), _("Date"), _("Due Date"), _("Customer"), _("Branch"), _("Currency"), _("Total"), _("Remainder"), _("Days")); start_table(TABLESTYLE); table_header($th); - $k = 0; //row colour counter + $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); @@ -466,12 +519,10 @@ function customer_recurrent_invoices($today) { $result = get_recurrent_invoices($today); $title = _("Overdue Recurrent Invoices"); - br(1); - display_heading($title); - br(); + display_title($title); $th = array(_("Description"), _("Template No"),_("Customer"),_("Branch")."/"._("Group"),_("Next invoice")); start_table(TABLESTYLE, "width=70%"); - table_header($th); + table_header($th); $k = 0; while ($myrow = db_fetch($result)) { @@ -513,9 +564,7 @@ function supplier_trans($today) AND DATEDIFF('$today', trans.due_date) > 0 ORDER BY days DESC"; $result = db_query($sql); $title = db_num_rows($result) . _(" overdue Purchase Invoices"); - br(1); - display_heading($title); - br(); + display_title($title); $th = array("#", _("Ref."), _("Date"), _("Due Date"), _("Supplier"), _("Currency"), _("Total"), _("Remainder"), _("Days")); start_table(TABLESTYLE); @@ -550,9 +599,7 @@ function bank_balance($today, $width) ORDER BY bank_account_name"; $result = db_query($sql); $title = _("Bank Account Balances"); - br(1); - display_heading($title); - br(); + display_title($title); $th = array(_("Account"), _("Balance")); start_table(TABLESTYLE, "width='$width%'"); table_header($th);