noalyss
Version-9
include
impress_jrn.inc.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
21
/** \file
22
* \brief ask for Printing the ledger (pdf,html)
23
*/
24
if
( ! defined (
'ALLOWED'
) ) die(
'Appel direct ne sont pas permis'
);
25
$gDossier
=
dossier::id
();
26
global
$g_user
,
$http
;
27
28
/**
29
* Get exercice
30
*/
31
$user_exercice
=
$g_user
->get_exercice();
32
$exercice
=
$http
->get(
"exercice"
,
"string"
,
$user_exercice
);
33
34
35
//-----------------------------------------------------
36
// Show the ledger and date
37
//-----------------------------------------------------
38
if
(
$g_user
->Admin() == 0 &&
$g_user
->is_local_admin() == 0 &&
$g_user
->get_status_security_ledger()==1)
39
{
40
$sql
=
"select jrn_def_id,jrn_def_name
41
from jrn_def join jrn_type on jrn_def_type=jrn_type_id
42
join user_sec_jrn on uj_jrn_id=jrn_def_id
43
where
44
uj_login=$1
45
and uj_priv in ('R','W')
46
and ( jrn_enable=1
47
or
48
exists (select 1 from jrn where jr_tech_per in (select p_id from parm_periode where p_exercice=$2)))
49
order by jrn_def_name
50
"
;
51
$ret
=
$cn
->make_array(
$sql
,0,array(
$g_user
->login,
$exercice
));
52
}
53
else
54
{
55
$ret
=
$cn
->make_array(
"select jrn_def_id,jrn_def_name
56
from jrn_def join jrn_type on jrn_def_type=jrn_type_id
57
where
58
jrn_enable=1 or exists(select 1 from jrn where jr_tech_per in (select p_id from parm_periode where p_exercice=$1))
59
order by jrn_def_name
60
"
,0,[
$exercice
]);
61
}
62
63
/*
64
* Show all the available ledgers
65
*/
66
$a
= count(
$ret
);
67
if
(count(
$ret
) < 1)
NoAccess
();
68
69
$all
= array(
'value'
=> 0,
'label'
=> _(
'Tous les journaux disponibles'
));
70
$ret
[
$a
] =
$all
;
71
72
// Get the from_periode and to_periode
73
$from_periode
=
$http
->get(
"from_periode"
,
"number"
,
""
);
74
$to_periode
=
$http
->get(
"to_periode"
,
"number"
,
""
);
75
76
// if from_periode empty, then set to first and last
77
// periode of the exercice (from preference)
78
79
if
(
$from_periode
==
""
||
$to_periode
==
""
)
80
{
81
$t_periode
=
new
Periode
(
$cn
);
82
list($per_min,$per_max)=
$t_periode
->get_limit(
$exercice
);
83
$from_periode
=$per_min->p_id;
84
$to_periode
=$per_max->p_id;
85
}
86
87
//-----------------------------------------------------
88
// Form
89
//-----------------------------------------------------
90
echo
'<div class="content">'
;
91
/*
92
* Let you change the exercice
93
*/
94
echo
'<form method="GET" onsubmit="waiting_box();return true;">'
;
95
echo
'<fieldset><legend>'
. _(
'Exercice'
) .
'</legend>'
;
96
;
97
echo _(
'Choisissez un autre exercice'
).
' :'
;
98
$ex
=
new
Exercice
(
$cn
);
99
$wex
=
$ex
->select(
'exercice'
,
$exercice
,
' onchange="waiting_box();submit(this)"'
);
100
echo
$wex
->input();
101
echo dossier::hidden();
102
echo
HtmlInput::get_to_hidden
(array(
'ac'
,
'type'
));
103
echo
'</fieldset>'
;
104
echo
'</form>'
;
105
?>
106
<?php
107
108
echo
'<FORM METHOD="GET" onsubmit="waiting_box();return true;">'
. dossier::hidden();
109
echo
HtmlInput::get_to_hidden
(array(
'ac'
,
'type'
));
110
echo
HtmlInput::hidden
(
'type'
,
'jrn'
);
111
echo
HtmlInput::get_to_hidden
(array(
'exercice'
));
112
echo
'<TABLE ><TR>'
;
113
$w
=
new
ISelect
();
114
$w
->table = 1;
115
$label
= _(
"Choisissez le journal"
);
116
$w
->selected =
$http
->get(
'jrn_id'
,
"number"
,0);
117
print
td
(
$label
) .
$w
->input(
"jrn_id"
,
$ret
);
118
print
'</TR>'
;
119
print
'<TR>'
;
120
// filter on the current year
121
$filter_year
=
" where p_exercice='"
.
sql_string
(
$exercice
) .
"'"
;
122
$periode_start
=
$cn
->make_array(
"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end"
);
123
$w
->selected =
$from_periode
;
124
125
print
td
(_(
'Depuis'
)) .
$w
->input(
'from_periode'
,
$periode_start
);
126
print
'</TR>'
;
127
print
'<TR>'
;
128
129
$periode_end
=
$cn
->make_array(
"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end"
);
130
$w
->selected =
$to_periode
;
131
132
// By default , show last day of exercice
133
if
(
$w
->selected==
''
){
134
$w
->selected=$per_max->p_id;
135
}
136
print
td
(_(
'Jusque'
)).
$w
->input(
'to_periode'
,
$periode_end
);
137
print
"</TR><TR>"
;
138
$a
= array(
139
array(
'value'
=>
'L'
,
'label'
=> _(
'Liste opérations'
)),
140
array(
'value'
=>
'E'
,
'label'
=> _(
'Liste détaillées opérations '
)),
141
array(
'value'
=>
'A'
,
'label'
=> _(
'Ecriture comptable'
)),
142
array(
'value'
=>
'D'
,
'label'
=> _(
'Détails TVA'
))
143
);
144
$w
->selected = 1;
145
print
'</TR>'
;
146
/// All operation
147
$s_operation
=
new
ISelect
(
"operation_type"
);
148
$s_operation
->value=array(
149
array(
"label"
=>_(
"Toutes les opérations"
),
"value"
=>
"all"
),
150
array(
"label"
=>_(
"Uniquement payées"
),
"value"
=>
"paid"
),
151
array(
"label"
=>_(
"Uniquement non payées"
),
"value"
=>
"unpaid"
)
152
);
153
$s_operation
->selected=
$http
->get(
"operation_type"
,
"string"
,
"all"
);
154
echo
"<tr>"
;
155
echo
td
(_(
"Uniquement pour journaux vente et achat"
).
Icon_Action::infobulle
(75));
156
echo
td
(
$s_operation
->input());
157
echo
'</tr>'
;
158
159
/// Type of printing
160
print
'<TR>'
;
161
$simple
=
$http
->get(
"p_simple"
,
"string"
,
"L"
);
162
$w
->selected =
$simple
;
163
echo
'<td>'
._(
"Style d'impression"
).
" "
.
Icon_Action::infobulle
(32).
'</td>'
.
$w
->input(
'p_simple'
,
$a
);
164
print
"</TR>"
;
165
166
echo
'</TABLE>'
;
167
print
HtmlInput::submit
(
'bt_html'
, _(
'Visualisation'
));
168
169
echo
'</FORM>'
;
170
echo
'<hr>'
;
171
172
173
//-----------------------------------------------------
174
// If print is asked
175
// First time in html
176
// after in pdf or cvs
177
//-----------------------------------------------------
178
if
(isset(
$_REQUEST
[
'bt_html'
]))
179
{
180
// Type of report : listing=1 , Accounting writing=0, detail =2
181
$hid
=
new
IHidden
();
182
$jrn_id
=
$http
->get(
"jrn_id"
,
"number"
);
183
echo
'<table>'
;
184
echo
'<td>'
;
185
echo
'<form method="GET" ACTION="export.php" id="export_pdf_frm" onsubmit="download_document_form(\'export_pdf_frm\')">'
. dossier::hidden() .
186
HtmlInput::submit
(
'bt_pdf'
,
"Export PDF"
) .
187
HtmlInput::hidden
(
'act'
,
'PDF:ledger'
) .
188
$hid
->input(
"type"
,
"jrn"
) .
189
$hid
->input(
"jrn_id"
,
$jrn_id
) .
190
$hid
->input(
"from_periode"
,
$from_periode
) .
191
$hid
->input(
"to_periode"
,
$to_periode
);
192
echo
$hid
->input(
"operation_type"
,
$s_operation
->selected);
193
echo
$hid
->input(
"p_simple"
,
$simple
);
194
echo
HtmlInput::get_to_hidden
(array(
'ac'
,
'type'
));
195
echo
"</form>"
;
196
echo
'</td>'
;
197
198
echo
'<TD><form method="GET" ACTION="export.php" id="export_csv_frm" onsubmit="download_document_form(\'export_csv_frm\')">'
199
. dossier::hidden() .
200
HtmlInput::submit
(
'bt_csv'
,
"Export CSV"
) .
201
HtmlInput::hidden
(
'act'
,
'CSV:ledger'
) .
202
$hid
->input(
"type"
,
"jrn"
) .
203
$hid
->input(
"jrn_id"
,
$jrn_id
) .
204
$hid
->input(
"from_periode"
,
$from_periode
) .
205
$hid
->input(
"to_periode"
,
$to_periode
);
206
echo
$hid
->input(
"p_simple"
,
$simple
);
207
echo
$hid
->input(
"operation_type"
,
$s_operation
->selected);
208
echo
HtmlInput::get_to_hidden
(array(
'ac'
,
'type'
));
209
echo
"</form></TD>"
;
210
211
echo
'<td style="vertical-align:top">'
;
212
echo
HtmlInput::print_window
();
213
echo
'</td>'
;
214
215
echo
"</TR>"
;
216
217
echo
"</table>"
;
218
219
/*
220
* Compute an array with all the usable ledger
221
*/
222
$a_ledger=[];
223
if
(
$jrn_id
== 0) {
224
$nb_ret=count(
$ret
);
225
for
(
$i
=0;
$i
<$nb_ret;
$i
++) {
226
if
(
$ret
[
$i
][
'value'
]!=0)
227
$a_ledger[
$i
]=
$ret
[
$i
][
'value'
];
228
}
229
}
else
{
230
$a_ledger=[
$jrn_id
];
231
}
232
233
$ledger_history=
Acc_Ledger_History::factory
(
$cn
,$a_ledger,
$from_periode
,
$to_periode
,
$simple
,
$s_operation
->selected);
234
235
$ledger_history->export_html();
236
237
238
}
239
240
echo
'</div>'
;
241
?>
NoAccess
NoAccess($js=1)
Echo no access and stop.
Definition:
ac_common.php:480
sql_string
sql_string($p_string)
Fix the problem with the quote char for the database.
Definition:
ac_common.php:511
td
td($p_string='', $p_extra='')
surround the string with td
Definition:
ac_common.php:83
$i
$i
Definition:
action_document_type_mtable_input.php:83
$sql
$sql
Definition:
ajax_add_concerned_card.php:100
$cn
$cn
Definition:
ajax_anc_accounting.php:30
$hid
$hid
Definition:
ajax_anc_search.php:47
$jrn_id
$jrn_id
Definition:
ajax_operation_tag.php:32
$_REQUEST
$_REQUEST['ac']
Definition:
ajax_search_action.php:26
id
$input_from id
Definition:
balance.inc.php:63
Acc_Ledger_History\factory
static factory(Database $cn, $pa_ledger, $p_from, $p_to, $p_mode, $p_paid)
Build the right object.
Definition:
acc_ledger_history.class.php:161
Exercice
about the accountancy period (usually 1 year starting in January until december) = exercice
Definition:
exercice.class.php:31
HtmlInput\print_window
static print_window()
Javascript to print the current window.
Definition:
html_input.class.php:590
HtmlInput\hidden
static hidden($p_name, $p_value, $p_id="")
Definition:
html_input.class.php:230
HtmlInput\get_to_hidden
static get_to_hidden($array)
transform $_GET data to hidden
Definition:
html_input.class.php:679
HtmlInput\submit
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
Definition:
html_input.class.php:211
IHidden
Html Input.
Definition:
ihidden.class.php:31
ISelect
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Definition:
iselect.class.php:40
Icon_Action\infobulle
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
Definition:
icon_action.class.php:97
Periode
For the periode tables parm_periode and jrn_periode.
Definition:
periode.class.php:33
$t_periode
$t_periode
Definition:
forecast-new.php:31
$label
$label
Definition:
impress_jrn.inc.php:115
$gDossier
$gDossier
Definition:
impress_jrn.inc.php:25
$simple
$simple
Definition:
impress_jrn.inc.php:161
print
print
Type of printing.
Definition:
impress_jrn.inc.php:118
$all
$all
Definition:
impress_jrn.inc.php:69
$wex
$wex
Definition:
impress_jrn.inc.php:99
$http
global $http
Definition:
impress_jrn.inc.php:26
$g_user
global $g_user
Definition:
impress_jrn.inc.php:26
$filter_year
$filter_year
Definition:
impress_jrn.inc.php:121
$periode_start
$periode_start
Definition:
impress_jrn.inc.php:122
$user_exercice
$user_exercice
Get exercice.
Definition:
impress_jrn.inc.php:31
$s_operation
$s_operation
All operation.
Definition:
impress_jrn.inc.php:147
$a
$a
Definition:
impress_jrn.inc.php:66
$from_periode
$from_periode
Definition:
impress_jrn.inc.php:73
$ret
$ret[$a]
Definition:
impress_jrn.inc.php:70
$to_periode
$to_periode
Definition:
impress_jrn.inc.php:74
$exercice
$exercice
Definition:
impress_jrn.inc.php:32
$w
$w
Definition:
impress_jrn.inc.php:113
$ex
$ex
Definition:
impress_jrn.inc.php:98
$periode_end
$periode_end
Definition:
impress_jrn.inc.php:129