Rerun of last commit. A minor bug was detected.
[fa-stable.git] / includes / dashboard.inc
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU General Public License, GPL, 
5         as published by the Free Software Foundation, either version 3 
6         of the License, or (at your option) any later version.
7     This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
10     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12
13 function dashboard($sel_app)
14 {
15         $selected_app = $sel_app;
16
17
18         if (!$_SESSION["wa_current_user"]->check_application_access($selected_app))
19                 return;
20         // first have a look through the directory, 
21         // and remove old temporary pdfs and pngs
22         $dir = company_path(). '/pdf_files';
23
24         if ($d = @opendir($dir)) {
25                 while (($file = readdir($d)) !== false) {
26                         if (!is_file($dir.'/'.$file) || $file == 'index.php') continue;
27                 // then check to see if this one is too old
28                         $ftime = filemtime($dir.'/'.$file);
29                  // seems 3 min is enough for any report download, isn't it?
30                         if (time()-$ftime > 180){
31                                 unlink($dir.'/'.$file);
32                         }
33                 }
34                 closedir($d);
35         }
36
37         //check_for_overdue_recurrent_invoices();
38         if ($selected_app == "orders")
39                 display_customer_topten();
40         elseif ($selected_app == "AP")
41                 display_supplier_topten();
42         elseif ($selected_app == "stock")
43                 display_stock_topten();
44         elseif ($selected_app == "manuf")
45                 display_stock_topten(1);
46         elseif ($selected_app == "assets")
47                 display_stock_topten(2);
48         elseif ($selected_app == "proj")
49                 display_dimension_topten();
50         elseif ($selected_app == "GL")
51                 display_gl_info();
52         else    
53                 display_all();
54 }
55
56 function display_title($title, $colspan=2)
57 {
58         echo "<tr><td colspan=$colspan class='headingtext' style='text-align:center;border:0;height:40px;'>$title</td></tr>\n";
59 }       
60
61 function table_one()
62 {
63         echo "<table width='100%'>";
64         echo "<tr valign=top><td style='width:50%'>\n"; // outer table
65 }
66
67 function table_two()
68 {
69         echo "</td><td style='width:50%'>\n";
70 }
71
72 function table_end()
73 {
74         echo "</td></tr></table>\n";
75 }
76
77 function display_customer_topten()
78 {
79         $pg = new graph();
80
81         table_one();
82         $today = Today();
83         $title = customer_top($today, 10, 66, $pg);
84         customer_trans($today);
85         table_two();
86         source_graphic($today, $title, _("Customer"), $pg, _("Sales"));
87         customer_recurrent_invoices($today);
88         table_end();
89 }
90
91 function display_supplier_topten()
92 {
93         $pg = new graph();
94
95         $today = Today();
96         table_one();
97         $title = supplier_top($today, 10, 66, $pg);
98         supplier_trans($today);
99         table_two();
100         source_graphic($today, $title, _("Supplier"), $pg, _("Purchase"));
101         table_end();
102 }
103
104 function display_stock_topten($type=0)
105 {
106         $pg = new graph();
107
108         table_one();
109         $today = Today();
110         $title = stock_top($today, 10, 66, $type, $pg);
111         table_two();
112         if ($type == 2)
113                 $source = _("Fixed Assets");
114         elseif ($type == 1)
115                 $source = _("Manufacturing");
116         else    
117                 $source = _("Items");
118         source_graphic($today, $title, $source, $pg, ($type == 0 ? _("Sales") : _("Value")));
119         table_end();
120 }
121
122 function display_dimension_topten()
123 {
124         $pg = new graph();
125
126         table_one();
127         $today = Today();
128         $title = dimension_top($today, 10, 66, $pg);
129         table_two();
130         source_graphic($today, $title, _("Dimension"), $pg, _("Performance"), null, 5);
131         table_end();
132 }       
133
134 function display_gl_info()
135 {
136         $pg = new graph();
137
138         table_one();
139         $today = Today();
140         $title = gl_top($today, 66, $pg);
141         bank_balance($today, 66);
142         table_two();
143         source_graphic($today, $title, _("Class"), $pg, _("Amount"), null, 5);
144         gl_performance($today, 66, 5);
145         table_end();
146 }       
147
148 function display_all()
149 {
150         $today = Today();
151         $pg = new graph();
152
153         table_one();
154         $title = customer_top($today, 3, 66, $pg);
155         source_graphic($today, $title, _("Customer"), $pg, _("Sales"));
156         $title = supplier_top($today, 3, 66, $pg);
157         source_graphic($today, $title, _("Supplier"), $pg, _("Purchases"));
158         $title = stock_top($today, 3, 66, 0, $pg);
159         source_graphic($today, $title, _("Stock"), $pg, _("Sales"));
160         table_two();
161         dimension_top($today, 3, 66);
162         $title = gl_top($today, 66, $pg);
163         source_graphic($today, $title, _("Class"), $pg, _("Amount"), null, 5);
164         stock_top($today, 3, 66, 2);
165         stock_top($today, 3, 66, 1);
166         table_end();
167 }
168
169 function customer_top($today, $limit=10, $width="33", &$pg=null)
170 {
171         $begin = begin_fiscalyear();
172         $begin1 = date2sql($begin);
173         $today1 = date2sql($today);
174         $sql = "SELECT SUM((ov_amount + ov_discount) * rate * IF(trans.type = ".ST_CUSTCREDIT.", -1, 1)) AS total,d.debtor_no, d.name FROM
175                 ".TB_PREF."debtor_trans AS trans, ".TB_PREF."debtors_master AS d WHERE trans.debtor_no=d.debtor_no
176                 AND (trans.type = ".ST_SALESINVOICE." OR trans.type = ".ST_CUSTCREDIT.")
177                 AND tran_date >= '$begin1' AND tran_date <= '$today1' GROUP by d.debtor_no ORDER BY total DESC, d.debtor_no 
178                 LIMIT $limit";
179         $result = db_query($sql);
180         $title = _("Top $limit customers in fiscal year");
181         $th = array(_("Customer"), _("Amount"));
182         start_table(TABLESTYLE, "width='$width%'");
183         display_title($title, count($th));
184         table_header($th);
185         check_page_security('SA_SALESTRANSVIEW');
186         $k = 0; //row colour counter
187         $i = 0;
188         while ($myrow = db_fetch($result))
189         {
190                 alt_table_row_color($k);
191                 $name = $myrow["debtor_no"]." ".$myrow["name"];
192                 label_cell($name);
193                 amount_cell($myrow['total']);
194                 if ($pg != null)
195                 {
196                         $pg->x[$i] = $name; 
197                         $pg->y[$i] = $myrow['total'];
198                 }       
199                 $i++;
200                 end_row();
201         }
202         end_table(2);
203         return $title;
204 }
205
206 function supplier_top($today, $limit=10, $width="33", &$pg=null)
207 {
208         $begin = begin_fiscalyear();
209         $begin1 = date2sql($begin);
210         $today1 = date2sql($today);
211         $sql = "SELECT SUM((trans.ov_amount + trans.ov_discount) * rate) AS total, s.supplier_id, s.supp_name FROM
212                 ".TB_PREF."supp_trans AS trans, ".TB_PREF."suppliers AS s WHERE trans.supplier_id=s.supplier_id
213                 AND (trans.type = ".ST_SUPPINVOICE." OR trans.type = ".ST_SUPPCREDIT.")
214                 AND tran_date >= '$begin1' AND tran_date <= '$today1' GROUP by s.supplier_id ORDER BY total DESC, s.supplier_id 
215                 LIMIT $limit";
216         $result = db_query($sql);
217         $title = _("Top $limit suppliers in fiscal year");
218         $th = array(_("Supplier"), _("Amount"));
219         start_table(TABLESTYLE, "width='$width%'");
220         display_title($title, count($th));
221         table_header($th);
222         check_page_security('SA_SUPPTRANSVIEW');
223         $k = 0; //row colour counter
224         $i = 0;
225         while ($myrow = db_fetch($result))
226         {
227                 alt_table_row_color($k);
228                 $name = $myrow["supplier_id"]." ".$myrow["supp_name"];
229                 label_cell($name);
230                 amount_cell($myrow['total']);
231                 if ($pg != null)
232                 {
233                         $pg->x[$i] = $name; 
234                         $pg->y[$i] = $myrow['total'];
235                 }       
236                 $i++;
237                 end_row();
238         }
239         end_table(2);
240         return $title;
241 }
242
243 function stock_top($today, $limit=10, $width="33", $type=0, &$pg=null)
244 {
245         if ($type == 2)
246                 $sec = 'SA_ASSETSANALYTIC';
247         elseif ($type == 1)
248                 $sec = 'SA_WORKORDERANALYTIC';
249         else
250                 $sec = 'SA_ITEMSTRANSVIEW';
251         $begin = begin_fiscalyear();
252         $begin1 = date2sql($begin);
253         $today1 = date2sql($today);
254         if ($type == 0)
255         {
256                 $sql = "SELECT SUM((trans.unit_price * trans.quantity) * d.rate) AS total, s.stock_id, s.description, 
257                         SUM(trans.quantity) AS qty FROM
258                         ".TB_PREF."debtor_trans_details AS trans, ".TB_PREF."stock_master AS s, ".TB_PREF."debtor_trans AS d 
259                         WHERE trans.stock_id=s.stock_id AND trans.debtor_trans_type=d.type AND trans.debtor_trans_no=d.trans_no
260                         AND (d.type = ".ST_SALESINVOICE." OR d.type = ".ST_CUSTCREDIT.") ";
261         }
262         else
263         {
264                 $sql = "SELECT SUM(m.qty * (s.material_cost + s.labour_cost + s.overhead_cost)) AS total, s.stock_id, s.description, 
265                         SUM(qty) AS qty FROM ".TB_PREF."stock_master AS s, ".TB_PREF."stock_moves AS m 
266                         WHERE s.stock_id=m.stock_id ";
267                 if ($type == 1)
268                         $sql .= "AND s.mb_flag='M' ";
269                 elseif ($type == 2)     
270                         $sql .= "AND s.mb_flag='F' ";
271         }
272         $sql .= "AND tran_date >= '$begin1' AND tran_date <= '$today1' GROUP by s.stock_id ORDER BY total DESC, s.stock_id 
273                 LIMIT $limit";
274         $result = db_query($sql);
275         if ($type == 1)
276                 $title = _("Top $limit Manufactured Items in fiscal year");
277         elseif ($type == 2)
278                 $title = _("Top $limit Fixed Assets in fiscal year");
279         else    
280                 $title = _("Top $limit Sold Items in fiscal year");
281         $th = array(_("Item"), _("Amount"), _("Quantity"));
282         start_table(TABLESTYLE, "width='$width%'");
283         display_title($title, count($th));      
284         table_header($th);
285         check_page_security($sec);
286         $k = 0; //row colour counter
287         $i = 0;
288         while ($myrow = db_fetch($result))
289         {
290                 alt_table_row_color($k);
291                 $name = $myrow["description"];
292                 label_cell($name);
293                 amount_cell($myrow['total']);
294                 qty_cell($myrow['qty']);
295                 if ($pg != NULL)
296                 {
297                         $pg->x[$i] = $name; 
298                         $pg->y[$i] = $myrow['total'];
299                 }       
300                 $i++;
301                 end_row();
302         }
303         end_table(2);
304         return $title;
305 }
306
307 function dimension_top($today, $limit=10, $width="33", &$pg=null)
308 {
309
310         $begin = begin_fiscalyear();
311         $begin1 = date2sql($begin);
312         $today1 = date2sql($today);
313         $sql = "SELECT SUM(-t.amount) AS total, d.reference, d.name FROM
314                 ".TB_PREF."gl_trans AS t,".TB_PREF."dimensions AS d WHERE
315                 (t.dimension_id = d.id OR t.dimension2_id = d.id) AND
316                 t.tran_date >= '$begin1' AND t.tran_date <= '$today1' GROUP BY d.id ORDER BY total DESC LIMIT $limit";
317         $result = db_query($sql, "Transactions could not be calculated");
318         $title = _("Top $limit Dimensions in fiscal year");
319         $th = array(_("Dimension"), _("Amount"));
320         start_table(TABLESTYLE, "width='$width%'");
321         display_title($title, count($th));
322         table_header($th);
323         check_page_security('SA_DIMTRANSVIEW');
324         $k = 0; //row colour counter
325         $i = 0;
326         while ($myrow = db_fetch($result))
327         {
328                 alt_table_row_color($k);
329                 $name = $myrow['reference']." ".$myrow["name"];
330                 label_cell($name);
331                 amount_cell($myrow['total']);
332                 if ($pg != null)
333                 {
334                         $pg->x[$i] = $name; 
335                         $pg->y[$i] = abs($myrow['total']);
336                 }       
337                 $i++;
338                 end_row();
339         }
340         end_table(2);
341         return $title;
342 }
343
344 function gl_top($today, $width="33", &$pg=null)
345 {
346         $begin = begin_fiscalyear();
347         $begin1 = date2sql($begin);
348         $today1 = date2sql($today);
349         $sql = "SELECT SUM(amount) AS total, c.class_name, c.ctype FROM
350                 ".TB_PREF."gl_trans,".TB_PREF."chart_master AS a, ".TB_PREF."chart_types AS t, 
351                 ".TB_PREF."chart_class AS c WHERE
352                 account = a.account_code AND a.account_type = t.id AND t.class_id = c.cid
353                 AND IF(c.ctype > 3, tran_date >= '$begin1', tran_date >= '0000-00-00') 
354                 AND tran_date <= '$today1' GROUP BY c.cid ORDER BY c.cid"; 
355         $result = db_query($sql, "Transactions could not be calculated");
356         $title = _("Class Balances");
357         start_table(TABLESTYLE2, "width='$width%'");
358         display_title($title);
359         check_page_security('SA_GLANALYTIC');
360         $i = 0;
361         $total = 0;
362         while ($myrow = db_fetch($result))
363         {
364                 if ($myrow['ctype'] > 3)
365                 {
366                         $total += $myrow['total'];
367                         $myrow['total'] = -$myrow['total'];
368                         if ($pg != null)
369                         {
370                                 $pg->x[$i] = $myrow['class_name']; 
371                                 $pg->y[$i] = abs($myrow['total']);
372                         }       
373                         $i++;
374                 }       
375                 label_row($myrow['class_name'], number_format2($myrow['total'], user_price_dec()), 
376                         "class='label' style='font-weight:bold;'", "style='font-weight:bold;' align=right");
377         }
378         $calculated = _("Calculated Return");
379         label_row("&nbsp;", "");
380         label_row($calculated, number_format2(-$total, user_price_dec()), 
381                 "class='label' style='font-weight:bold;'", "style='font-weight:bold;' align=right");
382         if ($pg != null)
383         {
384                 $pg->x[$i] = $calculated; 
385                 $pg->y[$i] = -$total;
386         }
387         end_table(2);
388         return $title;
389 }
390
391 function gl_performance($today, $width="33", $weeks=5)
392 {
393         $pg = new graph();
394
395         $begin = begin_fiscalyear();
396         $begin1 = date2sql($begin);
397         $today1 = date2sql($today);
398         $sql = "SELECT CONCAT(YEAR(tran_date), '/', WEEK(tran_date)) AS week_name, 
399                         SUM(IF (c.ctype = 4, amount * -1, 0)) AS sales, 
400                         SUM(IF (c.ctype = 6, amount, 0)) AS costs 
401                 FROM
402                         ".TB_PREF."gl_trans, ".TB_PREF."chart_master AS a, ".TB_PREF."chart_types AS t, 
403                         ".TB_PREF."chart_class AS c WHERE (c.ctype = 4 OR c.ctype = 6)
404                         AND account = a.account_code AND a.account_type = t.id AND t.class_id = c.cid
405                         AND IF(c.ctype > 3, tran_date >= '$begin1', tran_date >= '0000-00-00') 
406                         AND tran_date <= '$today1' 
407                 GROUP BY week_name 
408                 ORDER BY YEAR(tran_date) DESC, WEEK(tran_date) DESC limit 0, $weeks";
409         $result = db_query($sql, "Transactions could not be calculated");
410         $title = _("Last $weeks weeks Performance");
411         check_page_security('SA_GLANALYTIC');
412         $i = 0;
413         while ($myrow = db_fetch($result))
414         {
415                 $pg->x[$i] = $myrow['week_name']; 
416                 $pg->y[$i] = $myrow['sales'];
417                 $pg->z[$i] = $myrow['costs'];
418                 $i++;
419         }       
420         $pg->x = array_reverse($pg->x);
421         $pg->y = array_reverse($pg->y);
422         $pg->z = array_reverse($pg->z);
423         
424         source_graphic($today, $title, _("Week"), $pg, _("Sales"), _("Costs"), 1);
425 }
426
427 function source_graphic($today, $title, $x_axis, $pg, $graphic1, $graphic2=null, $type=2)
428 {
429         $pg->title     = $title . " - " . $today;
430         $pg->axis_x    = $x_axis;
431         $pg->axis_y    = _("Amount");
432         $pg->graphic_1 = $graphic1;
433         if ($graphic2 != null)
434                 $pg->graphic_2 = $graphic2;
435         $pg->type      = $type;
436         $pg->skin      = 1;
437         $pg->built_in  = false;
438         $filename = company_path(). "/pdf_files/". uniqid("").".png";
439         $pg->display($filename, true);
440         start_table(TABLESTYLE);
441         start_row();
442         echo "<td>";
443         echo "<img src='$filename' border='0' alt='$title'>";
444         echo "</td>";
445         end_row();
446         end_table(1);
447 }
448
449 function customer_trans($today)
450 {
451         $today = date2sql($today);
452
453         $sql = "SELECT trans.trans_no, trans.reference, trans.tran_date, trans.due_date, debtor.debtor_no, 
454                 debtor.name, branch.br_name, debtor.curr_code,
455                 (trans.ov_amount + trans.ov_gst + trans.ov_freight 
456                         + trans.ov_freight_tax + trans.ov_discount)     AS total,  
457                 (trans.ov_amount + trans.ov_gst + trans.ov_freight 
458                         + trans.ov_freight_tax + trans.ov_discount - trans.alloc) AS remainder,
459                 DATEDIFF('$today', trans.due_date) AS days      
460                 FROM ".TB_PREF."debtor_trans as trans, ".TB_PREF."debtors_master as debtor, 
461                         ".TB_PREF."cust_branch as branch
462                 WHERE debtor.debtor_no = trans.debtor_no AND trans.branch_code = branch.branch_code
463                         AND trans.type = ".ST_SALESINVOICE." AND (trans.ov_amount + trans.ov_gst + trans.ov_freight 
464                         + trans.ov_freight_tax + trans.ov_discount - trans.alloc) > ".FLOAT_COMP_DELTA." 
465                         AND DATEDIFF('$today', trans.due_date) > 0 ORDER BY days DESC";
466         $result = db_query($sql);
467         $title = db_num_rows($result) . _(" overdue Sales Invoices");
468         br(1);
469         display_heading($title);
470         br();
471         $th = array("#", _("Ref."), _("Date"), _("Due Date"), _("Customer"), _("Branch"), _("Currency"), 
472                 _("Total"), _("Remainder"),     _("Days"));
473         start_table(TABLESTYLE);
474         table_header($th);
475         $k = 0; //row colour counter
476         while ($myrow = db_fetch($result))
477         {
478                 alt_table_row_color($k);
479                 label_cell(get_trans_view_str(ST_SALESINVOICE, $myrow["trans_no"]));
480                 label_cell($myrow['reference']);
481                 label_cell(sql2date($myrow['tran_date']));
482                 label_cell(sql2date($myrow['due_date']));
483                 $name = $myrow["debtor_no"]." ".$myrow["name"];
484                 label_cell($name);
485                 label_cell($myrow['br_name']);
486                 label_cell($myrow['curr_code']);
487                 amount_cell($myrow['total']);
488                 amount_cell($myrow['remainder']);
489                 label_cell($myrow['days'], "align='right'");
490                 end_row();
491         }
492         end_table(2);
493 }
494
495 function calculate_next_invoice($myrow)
496 {
497         if ($myrow["last_sent"] == '0000-00-00')
498                 $next = sql2date($myrow["begin"]);
499         else
500                 $next = sql2date($myrow["last_sent"]);
501         $next = add_months($next, $myrow['monthly']);
502         $next = add_days($next, $myrow['days']);
503         return add_days($next,-1);
504 }
505
506 function customer_recurrent_invoices($today)
507 {
508         $result = get_recurrent_invoices($today);
509         $title = _("Overdue Recurrent Invoices");
510         br(1);
511         display_heading($title);
512         br();
513         $th = array(_("Description"), _("Template No"),_("Customer"),_("Branch")."/"._("Group"),_("Next invoice"));
514         start_table(TABLESTYLE, "width=70%");
515         table_header($th);
516         $k = 0;
517         while ($myrow = db_fetch($result)) 
518         {
519                 if (!$myrow['overdue'])
520                         continue;
521                 alt_table_row_color($k);
522
523                 label_cell($myrow["description"]);
524                 label_cell(get_customer_trans_view_str(ST_SALESORDER, $myrow["order_no"]));
525                 if ($myrow["debtor_no"] == 0)
526                 {
527                         label_cell("");
528
529                         label_cell(get_sales_group_name($myrow["group_no"]));
530                 }
531                 else
532                 {
533                         label_cell(get_customer_name($myrow["debtor_no"]));
534                         label_cell(get_branch_name($myrow['group_no']));
535                 }
536                 label_cell(calculate_next_invoice($myrow),  "align='center'");
537                 end_row();
538         }
539         end_table(2);
540 }
541
542 function supplier_trans($today)
543 {
544         $today = date2sql($today);
545         $sql = "SELECT trans.trans_no, trans.reference, trans.tran_date, trans.due_date, s.supplier_id, 
546                 s.supp_name, s.curr_code,
547                 (trans.ov_amount + trans.ov_gst + trans.ov_discount) AS total,  
548                 (trans.ov_amount + trans.ov_gst + trans.ov_discount - trans.alloc) AS remainder,
549                 DATEDIFF('$today', trans.due_date) AS days      
550                 FROM ".TB_PREF."supp_trans as trans, ".TB_PREF."suppliers as s 
551                 WHERE s.supplier_id = trans.supplier_id
552                         AND trans.type = ".ST_SUPPINVOICE." AND (ABS(trans.ov_amount + trans.ov_gst + 
553                                 trans.ov_discount) - trans.alloc) > ".FLOAT_COMP_DELTA."
554                         AND DATEDIFF('$today', trans.due_date) > 0 ORDER BY days DESC";
555         $result = db_query($sql);
556         $title = db_num_rows($result) . _(" overdue Purchase Invoices");
557         br(1);
558         display_heading($title);
559         br();
560         $th = array("#", _("Ref."), _("Date"), _("Due Date"), _("Supplier"), _("Currency"), _("Total"), 
561                 _("Remainder"), _("Days"));
562         start_table(TABLESTYLE);
563         table_header($th);
564         $k = 0; //row colour counter
565         while ($myrow = db_fetch($result))
566         {
567                 alt_table_row_color($k);
568                 label_cell(get_trans_view_str(ST_SUPPINVOICE, $myrow["trans_no"]));
569                 label_cell($myrow['reference']);
570                 label_cell(sql2date($myrow['tran_date']));
571                 label_cell(sql2date($myrow['due_date']));
572                 $name = $myrow["supplier_id"]." ".$myrow["supp_name"];
573                 label_cell($name);
574                 label_cell($myrow['curr_code']);
575                 amount_cell($myrow['total']);
576                 amount_cell($myrow['remainder']);
577                 label_cell($myrow['days'], "align='right'");
578                 end_row();
579         }
580         end_table(2);
581 }
582
583 function bank_balance($today, $width)
584 {
585         $today = date2sql($today);
586         $sql = "SELECT bank_act, bank_account_name, SUM(amount) balance FROM ".TB_PREF."bank_trans bt 
587                     INNER JOIN ".TB_PREF."bank_accounts ba ON bt.bank_act = ba.id
588                     WHERE trans_date <= '$today'
589                     AND inactive <> 1
590                     GROUP BY bank_act, bank_account_name
591                                 ORDER BY bank_account_name";
592         $result = db_query($sql);
593         $title = _("Bank Account Balances");
594         br(1);
595         display_heading($title);
596         br();
597         $th = array(_("Account"), _("Balance"));
598         start_table(TABLESTYLE, "width='$width%'");
599         table_header($th);
600         $k = 0; //row colour counter
601         while ($myrow = db_fetch($result))
602         {
603                 alt_table_row_color($k);
604                 label_cell(viewer_link($myrow["bank_account_name"], 'gl/inquiry/bank_inquiry.php?bank_account='.$myrow["bank_act"]));
605                 amount_cell($myrow['balance']);
606                 end_row();
607         }
608         end_table(1);
609 }