noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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');
25$gDossier = dossier::id();
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 a 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 ) and jr_def_id=a.jrn_def_id))
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 a
57 join jrn_type on jrn_def_type=jrn_type_id
58 where
59 jrn_enable=1 or exists(select 1
60 from jrn
61 where
62 jr_tech_per in (select p_id from parm_periode where p_exercice=$1)
63 and jr_def_id=a.jrn_def_id)
64 order by jrn_def_name
65 ",0,[$exercice]);
66}
67
68/*
69 * Show all the available ledgers
70 */
71$a = count($ret);
72if (count($ret) < 1) NoAccess();
73
74$all = array('value' => 0, 'label' => _('Tous les journaux disponibles'));
76
77// Get the from_periode and to_periode
78$from_periode=$http->get("from_periode","number","");
79$to_periode=$http->get("to_periode","number","");
80
81// if from_periode empty, then set to first and last
82// periode of the exercice (from preference)
83
85{
86 $t_periode=new Periode($cn);
87 list($per_min,$per_max)=$t_periode->get_limit($exercice);
88 $from_periode=$per_min->p_id;
89 $to_periode=$per_max->p_id;
90}
91
92//-----------------------------------------------------
93// Form
94//-----------------------------------------------------
95echo '<div class="content">';
96/*
97 * Let you change the exercice
98 */
99echo '<form method="GET" onsubmit="waiting_box();return true;">';
100echo '<fieldset>' ;
101;
102echo _('Choisissez un exercice').' :';
104$wex = $ex->select('exercice', $exercice, ' onchange="waiting_box();submit(this)"');
105echo $wex->input();
106echo dossier::hidden();
107echo HtmlInput::get_to_hidden(array('ac', 'type'));
108echo '</fieldset>';
109echo '</form>';
110?>
111<?php
112
113echo '<FORM METHOD="GET" onsubmit="waiting_box();return true;">' . dossier::hidden();
114echo HtmlInput::get_to_hidden(array('ac', 'type'));
115echo HtmlInput::hidden('type', 'jrn');
116echo HtmlInput::get_to_hidden(array('exercice'));
117echo '<TABLE ><TR>';
118$w = new ISelect();
119$w->table = 1;
120$label = _("Choisissez le journal");
121$w->selected = $http->get('jrn_id',"number",0);
122print td($label) . $w->input("jrn_id", $ret);
123print '</TR>';
124print '<TR>';
125// filter on the current year
126$filter_year = " where p_exercice='" . sql_string($exercice) . "'";
127$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");
128$w->selected = $from_periode ;
129
130print td(_('Depuis')) . $w->input('from_periode', $periode_start);
131print '</TR>';
132print '<TR>';
133
134$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");
135$w->selected = $to_periode ;
136
137// By default , show last day of exercice
138if ($w->selected== '' ){
139 $w->selected=$per_max->p_id;
140}
141print td(_('Jusque')). $w->input('to_periode', $periode_end);
142print "</TR><TR>";
143$a = array(
144 array('value' => 'L', 'label' => _('Liste opérations')),
145 array('value' => 'E', 'label' => _('Liste détaillées opérations ')),
146 array('value' => 'A', 'label' => _('Ecriture comptable')),
147 array('value' => 'D', 'label' => _('Détails TVA'))
148);
149$w->selected = 1;
150print '</TR>';
151/// All operation
152$s_operation = new ISelect("operation_type");
153$s_operation->value=array(
154 array("label"=>_("Toutes les opérations"),"value"=>"all"),
155 array("label"=>_("Uniquement payées"),"value"=>"paid"),
156 array("label"=>_("Uniquement non payées"),"value"=>"unpaid")
157 );
158$s_operation->selected=$http->get("operation_type","string","all");
159echo "<tr>";
160echo td(_("Uniquement pour journaux vente et achat").Icon_Action::infobulle(75));
161echo td($s_operation->input());
162echo '</tr>';
163
164/// Type of printing
165print '<TR>';
166$simple=$http->get("p_simple","string","L");
167$w->selected = $simple;
168echo '<td>'._("Style d'impression")." ".Icon_Action::infobulle(32).'</td>' . $w->input('p_simple', $a);
169print "</TR>";
170
171echo '</TABLE>';
172print HtmlInput::submit('bt_html', _('Visualisation'));
173
174echo '</FORM>';
175echo '<hr>';
176
177
178//-----------------------------------------------------
179// If print is asked
180// First time in html
181// after in pdf or cvs
182//-----------------------------------------------------
183if (isset($_REQUEST['bt_html']))
184{
185 // Type of report : listing=1 , Accounting writing=0, detail =2
186 $hid=new IHidden();
187 $jrn_id=$http->get("jrn_id","number");
188 echo '<table>';
189 echo '<td>';
190 echo '<form method="GET" ACTION="export.php" id="export_pdf_frm" onsubmit="download_document_form(\'export_pdf_frm\')">' . dossier::hidden() .
191 HtmlInput::submit('bt_pdf', "Export PDF") .
192 HtmlInput::hidden('act', 'PDF:ledger') .
193 $hid->input("type", "jrn") .
194 $hid->input("jrn_id", $jrn_id) .
195 $hid->input("from_periode", $from_periode) .
196 $hid->input("to_periode", $to_periode);
197 echo $hid->input("operation_type", $s_operation->selected);
198 echo $hid->input("p_simple", $simple);
199 echo HtmlInput::get_to_hidden(array('ac', 'type'));
200 echo "</form>";
201 echo '</td>';
202
203 echo '<TD><form method="GET" ACTION="export.php" id="export_csv_frm" onsubmit="download_document_form(\'export_csv_frm\')">'
204 . dossier::hidden() .
205 HtmlInput::submit('bt_csv', "Export CSV") .
206 HtmlInput::hidden('act', 'CSV:ledger') .
207 $hid->input("type", "jrn") .
208 $hid->input("jrn_id", $jrn_id) .
209 $hid->input("from_periode", $from_periode) .
210 $hid->input("to_periode", $to_periode);
211 echo $hid->input("p_simple", $simple);
212 echo $hid->input("operation_type", $s_operation->selected);
213 echo HtmlInput::get_to_hidden(array('ac', 'type'));
214 echo "</form></TD>";
215
216 echo '<td style="vertical-align:top">';
217 echo HtmlInput::print_window();
218 echo '</td>';
219
220 echo "</TR>";
221
222 echo "</table>";
223
224 /*
225 * Compute an array with all the usable ledger
226 */
227 $a_ledger=[];
228 if ( $jrn_id == 0) {
229 $nb_ret=count($ret);
230 for ($i=0;$i<$nb_ret;$i++) {
231 if ($ret[$i]['value']!=0)
232 $a_ledger[$i]=$ret[$i]['value'];
233 }
234 } else {
236 }
237
239
240 $ledger_history->export_html();
241
242
243}
244
245echo '</div>';
246?>
NoAccess($js=1)
Echo no access and stop.
sql_string($p_string)
Fix the problem with the quote char for the database.
td($p_string='', $p_extra='')
surround the string with td
Definition ac_common.php:83
global $g_user
if no group available , then stop
catch(Exception $e) $exercice
$_REQUEST['ac']
foreach($array as $idx=> $m) $w
$wex
_("actif, passif,charge,...")
$ex
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
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.
$periode_start
Definition fiche.inc.php:60
$periode_end
Definition fiche.inc.php:61
$t_periode
print
Type of printing.
$user_exercice
Get exercice.
$s_operation
All operation.