noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
mini_report.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19*/
20// Copyright Author Dany De Bontridder danydb@aevalys.eu 10/08/24
21/*!
22 * \file
23 * \brief manage mini report
24 * \note this widget is included in Noalyss Core and a part of the code (javascript + css + ajax)
25 * are still included in NOALYSS Code, this code should move here and will be part of a "cleansing code" process
26 */
27namespace Noalyss\Widget;
28
29use HtmlInput;
30use Periode;
31/*!
32 * \class
33 * \brief display simple report in a widget on the DASHBOARD
34 * \note this widget is included in Noalyss Core and a part of the code (javascript + css + ajax)
35 * are still included in NOALYSS Code, this code should move here and will be part of a "cleansing code" process
36 */
37class Mini_Report extends Widget
38{
39 /**
40 * @brief show the simple report from USER_WIDGET.WD_PARAMETER
41 * @return void
42 * @throws \Exception
43 */
44 function display()
45 {
46 global $g_user, $cn;
47
48 $param = $this->db->get_value("select uw_parameter from user_widget where uw_id=$1",[$this->user_widget_id]);
49 parse_str($param, $aReport);
50 $report=$aReport['simple_report'];
51 $rapport = new \Acc_Report($cn, $report);
52
53 if ($rapport->exist() == false) {
54 $report = 0;
55 }
56 $this->open_div();
57 if ($report != 0) {
58 $report_id=$this->get_div_domid();
59 ?>
60 <?php echo $this->title($rapport->get_name()) ;?>
61
62 <?php
63 $exercice = $g_user->get_exercice();
64 if ($exercice == 0) {
65 alert(_('Aucune periode par defaut'));
66 } else {
67 $a=$g_user->get_periode();
68 $result = $rapport->get_row($a, $a, 'periode');
69 $ix = 0;
70 if (!empty ($result) && count($result) > 0) {
71 echo '<table class="result">';
72 foreach ($result as $row) {
73 $ix++;
74 $class = ($ix % 2 == 0) ? ' class="even" ' : ' class="odd" ';
75 echo '<tr ' . $class . '>';
76
77 echo '<td> ' . $row['desc'] . '</td>';
78 $style = 'style="text-align:right;"';
79 if ($row['montant'] < 0) {
80 $style = 'style="color:red;text-align:right;"';
81 }
82 echo "<td $style>" . nbm($row['montant']) . "</td>";
83 echo '</tr>';
84 }
85 echo '</table>';
86 } else {
87 echo _('Aucun résultat');
88 }
89 }
90 }
91 $this->close_div();
92 }
93
94 /**
95 * @brief select the simple report (FORM_DEFINITION) to display
96 * @see Widget::make_form()
97 * @return void
98 */
99 function input_parameter() {
100
101 $select=new \ISelect('simple_report');
102 $select->value=$this->db->make_array("select fr_id, fr_label from form_definition order by 2");
103
104 $this->make_form($select->input());
105 }
106
107 /**
108 * @brief Display the parameter of the form
109 * @return void
110 */
111 function display_parameter() {
112 $aParam= $this->get_parameter();
113 $name = $this->db->get_value("select fr_label from form_definition where fr_id=$1",[$aParam['simple_report']]);
114 echo " ";
115 echo span(_("Rapport") ." ".h($name),'class="widget_param"');
116
117
118 }
119
120}
span($p_string, $p_extra='')
Definition ac_common.php:43
nbm($p_number, $p_dec=2)
format the number with a sep.
alert($p_msg, $buffer=false)
alert in javascript
global $g_user
if no group available , then stop
h( $row[ 'oa_description'])
catch(Exception $e) $exercice
_("actif, passif,charge,...")
display simple report in a widget on the DASHBOARD
display_parameter()
Display the parameter of the form.
display()
show the simple report from USER_WIDGET.WD_PARAMETER
input_parameter()
select the simple report (FORM_DEFINITION) to display
Main class for widget.
Definition widget.php:32
get_parameter()
get the parameter of the widget and returns an array
Definition widget.php:345
open_div()
output the DIV HTML with class and id for the widget
Definition widget.php:157
make_form($html_input)
open a form with the DOMID "widget_code"_param, it appears once only for each widget in the dialog bo...
Definition widget.php:287
get_div_domid()
compute the DIV ID
Definition widget.php:165
$anc_filter title
$report
$SecUser db