noalyss Version-9
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 */
24if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
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//-----------------------------------------------------
38if ($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}
53else
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);
67if (count($ret) < 1) NoAccess();
68
69$all = array('value' => 0, 'label' => _('Tous les journaux disponibles'));
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
80{
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//-----------------------------------------------------
90echo '<div class="content">';
91/*
92 * Let you change the exercice
93 */
94echo '<form method="GET" onsubmit="waiting_box();return true;">';
95echo '<fieldset><legend>' . _('Exercice') . '</legend>';
96;
97echo _('Choisissez un autre exercice').' :';
99$wex = $ex->select('exercice', $exercice, ' onchange="waiting_box();submit(this)"');
100echo $wex->input();
101echo dossier::hidden();
102echo HtmlInput::get_to_hidden(array('ac', 'type'));
103echo '</fieldset>';
104echo '</form>';
105?>
106<?php
107
108echo '<FORM METHOD="GET" onsubmit="waiting_box();return true;">' . dossier::hidden();
109echo HtmlInput::get_to_hidden(array('ac', 'type'));
110echo HtmlInput::hidden('type', 'jrn');
111echo HtmlInput::get_to_hidden(array('exercice'));
112echo '<TABLE ><TR>';
113$w = new ISelect();
114$w->table = 1;
115$label = _("Choisissez le journal");
116$w->selected = $http->get('jrn_id',"number",0);
117print td($label) . $w->input("jrn_id", $ret);
118print '</TR>';
119print '<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
125print td(_('Depuis')) . $w->input('from_periode', $periode_start);
126print '</TR>';
127print '<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
133if ($w->selected== '' ){
134 $w->selected=$per_max->p_id;
135}
136print td(_('Jusque')). $w->input('to_periode', $periode_end);
137print "</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;
145print '</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");
154echo "<tr>";
155echo td(_("Uniquement pour journaux vente et achat").Icon_Action::infobulle(75));
156echo td($s_operation->input());
157echo '</tr>';
158
159/// Type of printing
160print '<TR>';
161$simple=$http->get("p_simple","string","L");
162$w->selected = $simple;
163echo '<td>'._("Style d'impression")." ".Icon_Action::infobulle(32).'</td>' . $w->input('p_simple', $a);
164print "</TR>";
165
166echo '</TABLE>';
167print HtmlInput::submit('bt_html', _('Visualisation'));
168
169echo '</FORM>';
170echo '<hr>';
171
172
173//-----------------------------------------------------
174// If print is asked
175// First time in html
176// after in pdf or cvs
177//-----------------------------------------------------
178if (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">';
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
234
235 $ledger_history->export_html();
236
237
238}
239
240echo '</div>';
241?>
NoAccess($js=1)
Echo no access and stop.
Definition: ac_common.php:480
sql_string($p_string)
Fix the problem with the quote char for the database.
Definition: ac_common.php:511
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
$_REQUEST['ac']
$input_from id
Definition: balance.inc.php:63
static factory(Database $cn, $pa_ledger, $p_from, $p_to, $p_mode, $p_paid)
Build the right object.
about the accountancy period (usually 1 year starting in January until december) = exercice
static print_window()
Javascript to print the current window.
static hidden($p_name, $p_value, $p_id="")
static get_to_hidden($array)
transform $_GET data to hidden
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
Html Input.
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
For the periode tables parm_periode and jrn_periode.
$t_periode
$gDossier
print
Type of printing.
global $http
global $g_user
$filter_year
$periode_start
$user_exercice
Get exercice.
$s_operation
All operation.
$from_periode
$ret[$a]
$to_periode
$exercice
$periode_end