[svn-upgrade] Integrating new upstream version, eekboek (1.05.05)
Joost van Baal
14 years ago
0 | 0 | # CHANGES -*- coding: utf-8 -*- |
1 | 1 | |
2 | 1.05.03 | |
2 | 1.05.05 | |
3 | ||
4 | * Integratie met EB WxShell. | |
5 | ||
6 | * Verwijder (tijdelijk) GUI voor ombouw tot browser. | |
7 | ||
8 | * (Wizard) Config 'admdir' in sectie '[general]' kan worden | |
9 | gebruikt om te bepalen waar de administraties (moeten komen | |
10 | te) staan. | |
11 | ||
12 | * (Wizard) Voorkom dat de verkeerde ebshell wordt opgestart. | |
13 | ||
14 | * (Wizard) Gebruik de voorbeeldadministratie als default. | |
15 | ||
16 | * Bugfix (regressie) BTW werd niet afgeboekt in de volgjaren | |
17 | van een meerjarige boekhouding. | |
18 | ||
19 | * Bugfix: meervoudige definitie van 'min' in | |
20 | EB/Tools/Einde.pm. | |
21 | ||
22 | * Bugfix: ebgui kende --[no]wizard niet. | |
23 | ||
24 | * (Wizard): Defaults voor adm code en database naam. | |
25 | ||
26 | 1.05.04 2009-10-28 23:47 | |
27 | ||
28 | * Many internal changes for GUI integration. | |
29 | ||
30 | * Consistent gedrag gui/wizard. | |
31 | ||
32 | 1.05.03 2009-10-27 16:15 | |
3 | 33 | |
4 | 34 | * !!! SNAPSHOT !!! SNAPSHOT !!! SNAPSHOT !!! |
5 | 35 |
13 | 13 | Summary: Bookkeeping software for small and medium-size businesses |
14 | 14 | License: GPL+ or Artistic |
15 | 15 | Group: Applications/Productivity |
16 | Version: 1.05.04 | |
16 | Version: 1.05.05 | |
17 | 17 | Release: 1%{?dist} |
18 | 18 | Source: http://www.eekboek.nl/dl/%{name}-%{version}.tar.gz |
19 | 19 | URL: http://www.eekboek.nl |
116 | 116 | lib/EB/CPAN/File/HomeDir/MacOS9.pm |
117 | 117 | lib/EB/CPAN/File/HomeDir/Unix.pm |
118 | 118 | lib/EB/CPAN/File/HomeDir/Windows.pm |
119 | lib/EB/CPAN/Wx/Perl/ProcessStream.pm | |
119 | 120 | lib/EB/Config.pm |
120 | 121 | lib/EB/Config/Data.pm |
121 | 122 | lib/EB/DB.pm |
126 | 127 | lib/EB/Format.pm |
127 | 128 | lib/EB/Globals.pm |
128 | 129 | lib/EB/Import.pm |
130 | lib/EB/IniWiz.pm | |
129 | 131 | lib/EB/Locale.pm |
130 | 132 | lib/EB/Main.pm |
131 | 133 | lib/EB/Relation.pm |
159 | 161 | lib/EB/Tools/SQLEngine.pm |
160 | 162 | lib/EB/Tools/Schema.pm |
161 | 163 | lib/EB/Utils.pm |
162 | lib/EB/Wx/Booking/BKMPanel.pm | |
163 | lib/EB/Wx/Booking/IVPanel.pm | |
164 | lib/EB/Wx/Booking/IVPanel/BskPanel.pm | |
165 | lib/EB/Wx/Booking/IVPanel/BsrPanel.pm | |
166 | lib/EB/Wx/Export/EekBoek.pm | |
167 | lib/EB/Wx/Export/XAF.pm | |
168 | 164 | lib/EB/Wx/FakeApp.pm |
169 | 165 | lib/EB/Wx/IniWiz.pm |
170 | 166 | lib/EB/Wx/IniWiz/OpenDialog.pm |
171 | 167 | lib/EB/Wx/Locale.pm |
172 | lib/EB/Wx/Main.pm | |
173 | lib/EB/Wx/MainFrame.pm | |
174 | lib/EB/Wx/Maint/Accounts.pm | |
175 | lib/EB/Wx/Maint/Accounts/TreeCtrl.pm | |
176 | lib/EB/Wx/Maint/BTWTarieven.pm | |
177 | lib/EB/Wx/Maint/Dagboeken.pm | |
178 | lib/EB/Wx/Maint/Relaties.pm | |
179 | lib/EB/Wx/Maint/StdAccounts.pm | |
180 | lib/EB/Wx/Report/BTWAangifte.pm | |
181 | lib/EB/Wx/Report/BTWAangifte/Preferences.pm | |
182 | lib/EB/Wx/Report/BalResProof.pm | |
183 | lib/EB/Wx/Report/DebCrd.pm | |
184 | lib/EB/Wx/Report/DebCrd/Preferences.pm | |
185 | lib/EB/Wx/Report/GenBase.pm | |
186 | lib/EB/Wx/Report/GenBase/Preferences.pm | |
187 | lib/EB/Wx/Report/Grootboek.pm | |
188 | lib/EB/Wx/Report/Grootboek/Preferences.pm | |
189 | lib/EB/Wx/Report/Journaal.pm | |
190 | lib/EB/Wx/Report/Journaal/Preferences.pm | |
191 | lib/EB/Wx/Report/Openstaand.pm | |
192 | lib/EB/Wx/State.pm | |
193 | lib/EB/Wx/Tools/AboutDialog.pm | |
194 | lib/EB/Wx/Tools/PreferencesDialog.pm | |
195 | lib/EB/Wx/Tools/PropertiesDialog.pm | |
196 | lib/EB/Wx/UI/AccInput.pm | |
197 | lib/EB/Wx/UI/AmountCtrl.pm | |
198 | lib/EB/Wx/UI/BalAccInput.pm | |
199 | lib/EB/Wx/UI/BTWInput.pm | |
200 | lib/EB/Wx/UI/HvdInput.pm | |
201 | lib/EB/Wx/UI/ListInput.pm | |
202 | lib/EB/Wx/UI/ListInput/ListDialog.pm | |
203 | lib/EB/Wx/UI/NumericCtrl.pm | |
204 | lib/EB/Wx/UI/PeriodPanel.pm | |
205 | lib/EB/Wx/UI/StdAccPanel.pm | |
206 | lib/EB/Wx/UI/VdiInput.pm | |
207 | lib/EB/Wx/Window.pm | |
208 | lib/EB/Wx/icons/calendar.png | |
209 | lib/EB/Wx/icons/credit.png | |
210 | lib/EB/Wx/icons/debet.png | |
211 | lib/EB/Wx/icons/eb.jpg | |
212 | lib/EB/Wx/icons/ebicon.png | |
168 | lib/EB/Wx/Shell/HtmlViewer.pm | |
169 | lib/EB/Wx/Shell/Main.pm | |
170 | lib/EB/Wx/Shell/MainFrame.pm | |
171 | lib/EB/Wx/Shell/PreferencesDialog.pm | |
213 | 172 | lib/EB/Wx/icons/ebwiz.jpg |
214 | lib/EB/Wx/icons/ebsplash.jpg | |
215 | lib/EB/Wx/icons/edit_add.png | |
216 | lib/EB/Wx/icons/edit_remove.png | |
217 | lib/EB/Wx/icons/edittrash.png | |
218 | lib/EB/Wx/icons/perl_powered.png | |
219 | lib/EB/Wx/tips.txt | |
220 | 173 | lib/EB/css/balans.css |
221 | 174 | lib/EB/css/balres.css |
222 | 175 | lib/EB/css/btwaangifte.css |
247 | 200 | lib/EB/migrate/001000011001000012.sql |
248 | 201 | lib/EB/migrate/001000012001000013.sql |
249 | 202 | lib/EB/migrate/001000013001000014.sql |
203 | lib/EB/mo/nl/ebwxshell.mo | |
250 | 204 | lib/EB/schema/eekboek.sql |
205 | lib/EB/schema/eenmanszaak.ebz | |
206 | lib/EB/schema/nvbv.ebz | |
207 | lib/EB/schema/ondernemer.ebz | |
251 | 208 | lib/EB/schema/sampledb.ebz |
209 | lib/EB/schema/vereniging.ebz | |
252 | 210 | lib/EB/schema/sample.conf |
253 | 211 | lib/EekBoek.pm |
254 | 212 | script/ebshell |
255 | 213 | script/ebgui |
214 | script/ebwxshell | |
256 | 215 | t/10_basic.t |
257 | 216 | t/20_dates.t |
258 | 217 | t/30_amounts.t |
0 | 0 | --- |
1 | 1 | name: EekBoek |
2 | version: 1.05.04 | |
2 | version: 1.05.05 | |
3 | 3 | author: |
4 | 4 | - Johan Vromans (jvromans@squirrel.nl) |
5 | 5 | abstract: Elementary Bookkeeping (for the Dutch/European market) |
25 | 25 | provides: |
26 | 26 | EekBoek: |
27 | 27 | file: lib/EekBoek.pm |
28 | version: 1.05.04 | |
28 | version: 1.05.05 | |
29 | 29 | generated_by: Module::Build version 0.28 |
30 | 30 | meta-spec: |
31 | 31 | url: http://module-build.sourceforge.net/META-spec-v1.2.html |
0 | ############################################################################# | |
1 | ## Name: Wx/Perl/ProcessStream.pm | |
2 | ## Purpose: capture async process STDOUT/STDERR | |
3 | ## Author: Mark Dootson | |
4 | ## Modified by: | |
5 | ## Created: 11/05/2007 | |
6 | ## Copyright: (c) 2007 Mark Dootson | |
7 | ## Licence: This program is free software; you can redistribute it and/or | |
8 | ## modify it under the same terms as Perl itself | |
9 | ############################################################################# | |
10 | ||
11 | package Wx::Perl::ProcessStream; | |
12 | ||
13 | our $VERSION = '0.11'; | |
14 | ||
15 | =head1 NAME | |
16 | ||
17 | Wx::Perl::ProcessStream - access IO of external processes via events | |
18 | ||
19 | =head1 VERSION | |
20 | ||
21 | Version 0.11 | |
22 | ||
23 | =head1 SYNOPSYS | |
24 | ||
25 | use Wx::Perl::ProcessStream qw( :everything ); | |
26 | ||
27 | EVT_WXP_PROCESS_STREAM_STDOUT( $self, \&evt_process_stdout); | |
28 | EVT_WXP_PROCESS_STREAM_STDERR( $self, \&evt_process_stderr); | |
29 | EVT_WXP_PROCESS_STREAM_EXIT( $self, \&evt_process_exit); | |
30 | ||
31 | my $proc1 = Wx::Perl::ProcessStream->OpenProcess('perl -e"print qq($_\n) for(@INC);"', 'MyName1', $self); | |
32 | my $command = 'executable.exe parm1 parm2 parm3' | |
33 | my $proc2 = Wx::Perl::ProcessStream->OpenProcess($command, 'MyName2', $self); | |
34 | my @args = qw( executable.exe parm1 parm2 parm3 ); | |
35 | my $proc3 = Wx::Perl::ProcessStream->OpenProcess(\@args, 'MyName2', $self); | |
36 | my $proc4 = Wx::Perl::ProcessStream->OpenProcess(\@args, 'MyName2', $self, 'readline'); | |
37 | ||
38 | sub evt_process_stdout { | |
39 | my ($self, $event) = @_; | |
40 | $event->Skip(1); | |
41 | my $process = $event->GetProcess; | |
42 | my $line = $event->GetLine; | |
43 | ||
44 | if($line eq 'something we are waiting for') { | |
45 | $process->WriteProcess('a message to stdin'); | |
46 | ||
47 | $process->CloseInput() if($finishedwriting); | |
48 | } | |
49 | ............ | |
50 | } | |
51 | ||
52 | sub evt_process_exit { | |
53 | my ($self, $event) = @_; | |
54 | $event->Skip(1); | |
55 | my $process = $event->GetProcess; | |
56 | my $line = $event->GetLine; | |
57 | my @buffers = @{ $process->GetStdOutBuffer }; | |
58 | my @errors = @{ $process->GetStdOutBuffer }; | |
59 | my $exitcode = $process->GetExitCode; | |
60 | ............ | |
61 | $process->Destroy; | |
62 | } | |
63 | ||
64 | ||
65 | =head1 DESCRIPTION | |
66 | ||
67 | This module provides the STDOUT, STDERR and exit codes of asynchronously running processes via events. | |
68 | It may be used for long running or blocking processes that provide periodic updates on state via STDOUT. Simple IPC is possible via STDIN. | |
69 | ||
70 | Do not use this module simply to collect the output of another process. For that, it is much simpler to do: | |
71 | ||
72 | my ($status, $output) = Wx::ExecuteStdout( 'perl -e"print qq($_\n) for(@INC);"' ); | |
73 | ||
74 | ||
75 | =head2 Wx::Perl::ProcessStream | |
76 | ||
77 | ||
78 | =head3 Methods | |
79 | ||
80 | ||
81 | =over 12 | |
82 | ||
83 | =item OpenProcess | |
84 | ||
85 | Run an external process. | |
86 | If the process is launched successfully, returns a Wx::Perl::ProcessStream::Process object. | |
87 | If the process could not be launched, returns undef; | |
88 | ||
89 | my $process = Wx::Perl::ProcessStream->OpenProcess($command, $name, $eventhandler, $readmethod); | |
90 | ||
91 | $command = command text (and parameters) you wish to run. You may also pass a | |
92 | reference to an array containing the command and parameters. | |
93 | $name = an arbitray name for the process. | |
94 | $eventhandler = the Wx object that will handle events for this process. | |
95 | $process = Wx::Perl::ProcessStream::Process object | |
96 | $readmethod = 'getc' or 'readline' (default = 'getc') an optional param. From Wx version | |
97 | 0.75 you can specifiy the method you wish to use to read the output of an | |
98 | external process. The default is 'getc' which uses the Wx::InputStream->GetC method | |
99 | to read bytes. If you specify 'readline', then the wxPerl implementation of | |
100 | Wx::InputStream->READLINE() will be used. From Wx version 0.75 onwards there should | |
101 | be no difference between output from the two implementations. | |
102 | ||
103 | If the process could not be started then zero is returned. | |
104 | You should destroy each process after it has completed. You can do this after receiving the exit event. | |
105 | ||
106 | ||
107 | =item GetDefaultAppCloseAction | |
108 | ||
109 | Returns the default on application close action that will be given to new processes. | |
110 | When your application exits, any remaining Wx::Perl::ProcessStream::Process objects will be signalled to close. | |
111 | The default signal is wxpSIGTERM but you can change this to wxpSIGKILL if you are sure this is what you want. | |
112 | Whenever a mew process is opened, it is given the application close action returned by GetDefaultAppCloseAction. | |
113 | You can also set the application close action at an individual process level. | |
114 | ||
115 | my $def-action = Wx::Perl::ProcessStream->SetDefaultAppCloseAction(); | |
116 | ||
117 | $def-action will be one of wxpSIGTERM or wxpSIGKILL; (default wxpSIGTERM) | |
118 | ||
119 | ||
120 | =item SetDefaultAppCloseAction | |
121 | ||
122 | Sets the default on application close action that will be given to new processes. | |
123 | See GetDefaultAppCloseAction. | |
124 | ||
125 | Wx::Perl::ProcessStream->SetDefaultAppCloseAction( $newdefaction ); | |
126 | ||
127 | $newdefaction = one of wxpSIGTERM or wxpSIGKILL | |
128 | ||
129 | =item GetPollInterval | |
130 | ||
131 | Get the current polling interval. See SetPollInterval. | |
132 | ||
133 | $milliseconds = Wx::Perl::ProcessStream->GetPollInterval(); | |
134 | ||
135 | =item SetPollInterval | |
136 | ||
137 | When all buffers are empty but there are still running external process, the module will pause before polling the processes again for output. | |
138 | By default, the module waits for 500 milliseconds. You can set the value of this polling intrval with this method. | |
139 | Internally, a Wx::Timer object is used to handle polling and the value you set here is passed directly to that. | |
140 | The precision of the intervals is OS dependent. | |
141 | ||
142 | Wx::Perl::ProcessStream->SetPollInterval( $milliseconds ); | |
143 | ||
144 | $milliseconds = number of milliseconds to wait when no buffer activity | |
145 | ||
146 | =back | |
147 | ||
148 | =head2 Wx::Perl::ProcessStream::Process | |
149 | ||
150 | Returned from a call to Wx::Perl::ProcessStream->OpenProcess. | |
151 | It is also available in event handlers using $event->GetProcess. | |
152 | ||
153 | =head3 Methods | |
154 | ||
155 | =over 12 | |
156 | ||
157 | =item CloseInput | |
158 | ||
159 | Close the STDIN stream of the external process. (Some processes may not close until STDIN is closed.) | |
160 | ||
161 | $process->CloseInput(); | |
162 | ||
163 | =item GetAppCloseAction | |
164 | ||
165 | Returns the current process signal that will used on application exit. Either wxpSIGTERM or wxpSIGKILL. | |
166 | See SetAppCloseAction. | |
167 | ||
168 | my $action = $process->GetAppCloseAction(); | |
169 | ||
170 | =item GetExitCode | |
171 | ||
172 | Returns the process exit code. It is undefined until a wxpEVT_PROCESS_STREAM_EXIT event has been received. | |
173 | ||
174 | my $exitcode = $process->GetExitCode(); | |
175 | ||
176 | =item GetProcessName | |
177 | ||
178 | Returns the process name as passed to the OpenProcess constructor. | |
179 | ||
180 | my $processname = $process->GetProcessName(); | |
181 | ||
182 | =item GetStdErrBuffer | |
183 | ||
184 | This returns a reference to an array containing all the lines sent by the process to stderr. | |
185 | Calling this clears the process object internal stderr buffer. | |
186 | (This has no effect on the actual process I/O buffers.) | |
187 | ||
188 | my $arryref = $process->GetStdErrBuffer(); | |
189 | ||
190 | =item GetStdOutBuffer | |
191 | ||
192 | This returns a reference to an array containing all the lines sent by the process to stdout. | |
193 | Calling this clears the process object internal stdout buffer. | |
194 | (This has no effect on the actual process I/O buffers.) | |
195 | ||
196 | my $arryref = $process->GetStdOutBuffer(); | |
197 | ||
198 | =item GetProcessId | |
199 | ||
200 | Returns the process id assigned by the system. | |
201 | ||
202 | my $processid = $process->GetProcessId(); | |
203 | ||
204 | =item IsAlive | |
205 | ||
206 | Check if the process still exists in the system. | |
207 | Returns 1 if process exists, 0 if process does not exist, and undefined if there was some problem in signaling the process. | |
208 | ||
209 | my $isalive = $process->IsAlive(); | |
210 | ||
211 | =item KillProcess | |
212 | ||
213 | Send a SIGKILL signal to the external process. | |
214 | ||
215 | $process->KillProcess(); | |
216 | ||
217 | =item SetAppCloseAction | |
218 | ||
219 | When your application exits, any remaining Wx::Perl::ProcessStream::Process objects will be signaled to close. | |
220 | The default signal is wxpSIGTERM but you can change this to wxpSIGKILL if you are sure this is what you want. | |
221 | ||
222 | $process->SetAppCloseAction( $newaction ); | |
223 | ||
224 | $newaction = one of wxpSIGTERM, wxpSIGKILL | |
225 | ||
226 | =item TerminateProcess | |
227 | ||
228 | Send a SIGTERM signal to the external process. | |
229 | ||
230 | $process->TerminateProcess(); | |
231 | ||
232 | =item WriteProcess | |
233 | ||
234 | Write to the STDIN of process. | |
235 | ||
236 | $process->WriteProcess( $writedata . "\n" ); | |
237 | ||
238 | $writedata = The data you wish to write. Remember to add any appropriate line endings your external process may expect. | |
239 | ||
240 | =back | |
241 | ||
242 | =head2 Wx::Perl::ProcessStream::ProcessEvent | |
243 | ||
244 | A Wx::Perl::ProcessStream::ProcessEvent is sent whenever an external process started with OpenProcess writes to STDOUT, STDERR or when the process exits. | |
245 | ||
246 | ||
247 | =head3 Event Connectors | |
248 | ||
249 | =over 12 | |
250 | ||
251 | =item EVT_WXP_PROCESS_STREAM_STDOUT | |
252 | ||
253 | Install an event handler for an event of type wxpEVT_PROCESS_STREAM_STDOUT exported on request by this module. | |
254 | The event subroutine will receive a Wx::Perl::ProcessStream::ProcessEvent for every line written to STDOUT by the external process. | |
255 | ||
256 | EVT_WXP_PROCESS_STREAM_STDOUT( $eventhandler, $codref ); | |
257 | ||
258 | =item EVT_WXP_PROCESS_STREAM_STDERR | |
259 | ||
260 | Install an event handler for an event of type wxpEVT_PROCESS_STREAM_STDERR exported on request by this module. | |
261 | The event subroutine will receive a Wx::Perl::ProcessStream::ProcessEvent for every line written to STDERR by the external process. | |
262 | ||
263 | EVT_WXP_PROCESS_STREAM_STDERR( $eventhandler, $codref ); | |
264 | ||
265 | =item EVT_WXP_PROCESS_STREAM_EXIT | |
266 | ||
267 | Install an event handler for an event of type wxpEVT_PROCESS_STREAM_EXIT exported on request by this module. | |
268 | The event subroutine will receive a Wx::Perl::ProcessStream::ProcessEvent when the external process exits. | |
269 | ||
270 | EVT_WXP_PROCESS_STREAM_EXIT( $eventhandler, $codref ); | |
271 | ||
272 | =back | |
273 | ||
274 | =head3 Methods | |
275 | ||
276 | =over 12 | |
277 | ||
278 | =item GetLine | |
279 | ||
280 | For events of type wxpEVT_PROCESS_STREAM_STDOUT and wxpEVT_PROCESS_STREAM_STDERR this will return the line written by the process. | |
281 | ||
282 | =item GetProcess | |
283 | ||
284 | This returns the process that raised the event. If this is a wxpEVT_PROCESS_STREAM_EXIT event you should destroy the process with $process->Destroy; | |
285 | ||
286 | =back | |
287 | ||
288 | =head1 COPYRIGHT & LICENSE | |
289 | ||
290 | Copyright (C) 2007 Mark Dootson, all rights reserved. | |
291 | ||
292 | This program is free software; you can redistribute it and/or modify it | |
293 | under the same terms as Perl itself. | |
294 | ||
295 | =head1 ACKNOWLEDGEMENTS | |
296 | ||
297 | Thanks to Johan Vromans for testing and suggesting a better interface. | |
298 | ||
299 | =head1 AUTHOR | |
300 | ||
301 | Mark Dootson, C<< <mdootson at cpan.org> >> | |
302 | ||
303 | =head1 SEE ALSO | |
304 | ||
305 | The distribution includes examples in the 'example' folder. | |
306 | From the source root, run | |
307 | ||
308 | perl -Ilib example/psexample.pl | |
309 | ||
310 | You can enter commands, execute them and view results. | |
311 | ||
312 | You may also wish to consult the wxWidgets manuals for: | |
313 | ||
314 | Wx::Process | |
315 | ||
316 | Wx::Execute | |
317 | ||
318 | Wx::ExecuteArgs | |
319 | ||
320 | Wx::ExecuteCommand | |
321 | ||
322 | Wx::ExecuteStdout | |
323 | ||
324 | Wx::ExecuteStdoutStderr | |
325 | ||
326 | ||
327 | ||
328 | =cut | |
329 | ||
330 | #----------------------------------------------------- | |
331 | # PACKAGE Wx::Perl::ProcessStream | |
332 | #----------------------------------------------------- | |
333 | ||
334 | package Wx::Perl::ProcessStream; | |
335 | use strict; | |
336 | use Wx 0.50 qw( wxEXEC_ASYNC wxSIGTERM wxSIGKILL); | |
337 | require Exporter; | |
338 | use base qw(Exporter); | |
339 | use Wx::Perl::Carp; | |
340 | ||
341 | #----------------------------------------------------- | |
342 | # check wxWidgets version | |
343 | #----------------------------------------------------- | |
344 | if( Wx::wxVERSION() < 2.0060025) { | |
345 | croak qq(Wx $Wx::VERSION compiled with $Wx::wxVERSION_STRING.\n\nMinimum wxWidgets version 2.6.3 required for Wx::Perl::ProcessStream $VERSION); | |
346 | } | |
347 | ||
348 | #----------------------------------------------------- | |
349 | # initialise | |
350 | #----------------------------------------------------- | |
351 | ||
352 | our ($ID_CMD_EXIT, $ID_CMD_STDOUT, $ID_CMD_STDERR, $WXP_DEFAULT_CLOSE_ACTION); | |
353 | ||
354 | $ID_CMD_EXIT = Wx::NewId(); | |
355 | $ID_CMD_STDOUT = Wx::NewId(); | |
356 | $ID_CMD_STDERR = Wx::NewId(); | |
357 | $WXP_DEFAULT_CLOSE_ACTION = wxSIGTERM; | |
358 | ||
359 | our @EXPORT_OK = qw( wxpEVT_PROCESS_STREAM_EXIT | |
360 | wxpEVT_PROCESS_STREAM_STDERR | |
361 | wxpEVT_PROCESS_STREAM_STDOUT | |
362 | EVT_WXP_PROCESS_STREAM_STDOUT | |
363 | EVT_WXP_PROCESS_STREAM_STDERR | |
364 | EVT_WXP_PROCESS_STREAM_EXIT | |
365 | wxpSIGTERM | |
366 | wxpSIGKILL | |
367 | ); | |
368 | our %EXPORT_TAGS = (); | |
369 | $EXPORT_TAGS{'everything'} = \@EXPORT_OK; | |
370 | ||
371 | our $ProcHandler = Wx::Perl::ProcessStream::ProcessHandler->new(); | |
372 | ||
373 | sub wxpEVT_PROCESS_STREAM_EXIT () { $ID_CMD_EXIT } | |
374 | sub wxpEVT_PROCESS_STREAM_STDERR () { $ID_CMD_STDERR } | |
375 | sub wxpEVT_PROCESS_STREAM_STDOUT () { $ID_CMD_STDOUT } | |
376 | sub wxpSIGTERM () { wxSIGTERM } | |
377 | sub wxpSIGKILL () { wxSIGKILL } | |
378 | ||
379 | sub EVT_WXP_PROCESS_STREAM_STDOUT ($$) { $_[0]->Connect(-1,-1,&wxpEVT_PROCESS_STREAM_STDOUT, $_[1] ) }; | |
380 | sub EVT_WXP_PROCESS_STREAM_STDERR ($$) { $_[0]->Connect(-1,-1,&wxpEVT_PROCESS_STREAM_STDERR, $_[1] ) }; | |
381 | sub EVT_WXP_PROCESS_STREAM_EXIT ($$) { $_[0]->Connect(-1,-1,&wxpEVT_PROCESS_STREAM_EXIT, $_[1] ) }; | |
382 | ||
383 | sub OpenProcess { | |
384 | my $class = shift; | |
385 | my( $command, $procname, $handler, $readmethod ) = @_; | |
386 | ||
387 | $procname ||= 'any'; | |
388 | $readmethod ||= 'getc'; | |
389 | ||
390 | my $process = Wx::Perl::ProcessStream::Process->new( $procname, $handler, $readmethod ); | |
391 | $process->Redirect(); | |
392 | $process->SetAppCloseAction($WXP_DEFAULT_CLOSE_ACTION); | |
393 | my $procid = (ref $command eq 'ARRAY') ? Wx::ExecuteArgs( $command, wxEXEC_ASYNC, $process ) | |
394 | : Wx::ExecuteCommand( $command, wxEXEC_ASYNC, $process ); | |
395 | if($procid) { | |
396 | $process->__set_process_id( $procid ); | |
397 | $ProcHandler->AddProc( $process ); | |
398 | return $process; | |
399 | } else { | |
400 | return undef; | |
401 | } | |
402 | } | |
403 | ||
404 | sub SetDefaultAppCloseAction { | |
405 | my $class = shift; | |
406 | my $newaction = shift; | |
407 | $WXP_DEFAULT_CLOSE_ACTION = ($newaction == wxSIGTERM||wxSIGKILL) ? $newaction : $WXP_DEFAULT_CLOSE_ACTION; | |
408 | } | |
409 | ||
410 | sub GetDefaultAppCloseAction { | |
411 | $WXP_DEFAULT_CLOSE_ACTION; | |
412 | } | |
413 | ||
414 | sub GetPollInterval { | |
415 | $ProcHandler->GetInterval(); | |
416 | } | |
417 | ||
418 | sub SetPollInterval { | |
419 | my ($class, $interval) = @_; | |
420 | $ProcHandler->_set_poll_interval($interval); | |
421 | } | |
422 | ||
423 | ||
424 | #----------------------------------------------------- | |
425 | # PACKAGE Wx::Perl::ProcessStream::ProcessHandler; | |
426 | # | |
427 | # Inherits from timer and cycles througn running | |
428 | # processes raising events for STDOUT/STDERR/EXIT | |
429 | #----------------------------------------------------- | |
430 | ||
431 | package Wx::Perl::ProcessStream::ProcessHandler; | |
432 | use Wx qw( wxSIGTERM wxSIGKILL); | |
433 | use base qw( Wx::Timer ); | |
434 | use Wx::Perl::Carp; | |
435 | ||
436 | sub DESTROY { | |
437 | my $self = shift; | |
438 | ||
439 | ## clear any live procs | |
440 | for my $process (@{ $self->{_procs} }) { | |
441 | next unless $process; # JV | |
442 | my $procid = $process->GetProcessId() if($process->IsAlive()); | |
443 | $process->Detach; | |
444 | Wx::Process::Kill($procid, $process->GetAppCloseAction()); | |
445 | } | |
446 | $self->SUPER::DESTROY if $self->can("SUPER::DESTROY"); | |
447 | ||
448 | } | |
449 | ||
450 | sub new { | |
451 | my $self = shift->SUPER::new(@_); | |
452 | $self->{_procs} = []; | |
453 | $self->{_pollinterval} = 500; | |
454 | return $self; | |
455 | } | |
456 | ||
457 | sub _set_poll_interval { | |
458 | my $self = shift; | |
459 | $self->{_pollinterval} = shift; | |
460 | if($self->IsRunning()) { | |
461 | $self->Stop(); | |
462 | $self->Start( $self->{_pollinterval} ); | |
463 | } | |
464 | } | |
465 | ||
466 | sub Notify { | |
467 | my ($self ) = @_; | |
468 | return 1 if($self->{_notify_in_progress}); # do not re-enter notify proc | |
469 | $self->{_notify_in_progress} = 1; | |
470 | ||
471 | my @checkprocs = @{ $self->{_procs} }; # get the current list of procs | |
472 | $self->{_procs} = []; # clear permanent list | |
473 | ||
474 | my $continue = 1; | |
475 | ||
476 | my $oldpollinterval = $self->{_pollinterval}; # handle poll interval changes | |
477 | ||
478 | while( $continue ) { | |
479 | my @procsleft = (); | |
480 | my $blockreadlines = 0; | |
481 | for my $process (@checkprocs) { | |
482 | ||
483 | # process inout actions | |
484 | while( my $action = shift( @{ $process->{_await_actions} }) ) { | |
485 | ||
486 | if( $action->{action} eq 'terminate' ) { | |
487 | $process->CloseOutput() if( defined(my $handle = $process->GetOutputStream() ) ); | |
488 | Wx::Process::Kill($process->GetProcessId(), wxSIGTERM); | |
489 | }elsif( $action->{action} eq 'kill' ) { | |
490 | $process->CloseOutput() if( defined(my $handle = $process->GetOutputStream() ) ); | |
491 | Wx::Process::Kill($process->GetProcessId(), wxSIGKILL); | |
492 | }elsif( $action->{action} eq 'closeinput') { | |
493 | $process->CloseOutput() if( defined(my $handle = $process->GetOutputStream() ) ); | |
494 | } elsif( $action->{action} eq 'write') { | |
495 | if(defined( my $fh = $process->GetOutputStream() )) { | |
496 | print $fh $action->{writedata}; | |
497 | } | |
498 | } | |
499 | } | |
500 | ||
501 | my $procexitcode = $process->GetExitCode(); | |
502 | my $linedataread = 0; | |
503 | ||
504 | # STDERR | |
505 | if( my $linebuffer = $process->__read_error_line ){ | |
506 | $linedataread = 1; | |
507 | $blockreadlines++; | |
508 | $linebuffer =~ s/(\r\n|\n)$//; | |
509 | my $event = Wx::Perl::ProcessStream::ProcessEvent->new( &Wx::Perl::ProcessStream::wxpEVT_PROCESS_STREAM_STDERR, -1 ); | |
510 | push(@{ $process->{_stderr_buffer} }, $linebuffer); | |
511 | $event->SetLine( $linebuffer ); | |
512 | $event->SetProcess( $process ); | |
513 | $process->__get_handler()->AddPendingEvent($event); | |
514 | } | |
515 | ||
516 | # STDOUT | |
517 | if( my $linebuffer = $process->__read_input_line ){ | |
518 | $linedataread = 1; | |
519 | $blockreadlines++; | |
520 | $linebuffer =~ s/(\r\n|\n)$//; | |
521 | my $event = Wx::Perl::ProcessStream::ProcessEvent->new( &Wx::Perl::ProcessStream::wxpEVT_PROCESS_STREAM_STDOUT, -1 ); | |
522 | push(@{ $process->{_stdout_buffer} }, $linebuffer); | |
523 | $event->SetLine( $linebuffer ); | |
524 | $event->SetProcess( $process ); | |
525 | $process->__get_handler()->AddPendingEvent($event); | |
526 | } | |
527 | ||
528 | if(defined($procexitcode) && !$linedataread) { | |
529 | my $event = Wx::Perl::ProcessStream::ProcessEvent->new( &Wx::Perl::ProcessStream::wxpEVT_PROCESS_STREAM_EXIT, -1); | |
530 | $event->SetLine( undef ); | |
531 | $event->SetProcess( $process ); | |
532 | $process->__get_handler()->AddPendingEvent($event); | |
533 | ||
534 | } else { | |
535 | push( @procsleft, $process ); | |
536 | } | |
537 | ||
538 | } # for my $process (@checkprocs) { | |
539 | ||
540 | my $procsadded = 0; | |
541 | ||
542 | # add any newly created procs | |
543 | my @newprocs = @{ $self->{_procs} }; | |
544 | if( @newprocs ) { | |
545 | push(@procsleft, @newprocs); | |
546 | $self->{_procs} = []; | |
547 | $procsadded = 1 | |
548 | } | |
549 | @checkprocs = @procsleft; | |
550 | ||
551 | # loop if we have new procs or read data | |
552 | if( $procsadded || $blockreadlines ) { | |
553 | $continue = 1; | |
554 | } else { | |
555 | $continue = 0; | |
556 | } | |
557 | #-------------------------------------------------- | |
558 | # yield whilst $self->{_procs} is populated | |
559 | #-------------------------------------------------- | |
560 | $self->{_procs} = \@checkprocs; | |
561 | Wx::wxTheApp->Yield(); | |
562 | @checkprocs = @{ $self->{_procs} }; | |
563 | $self->{_procs} = []; | |
564 | ||
565 | } # while( $continue ) { | |
566 | ||
567 | $self->{_procs} = \@checkprocs; | |
568 | $self->{_notify_in_progress} = 0; | |
569 | ||
570 | $self->Stop() unless( @checkprocs ); | |
571 | } | |
572 | ||
573 | sub Start { | |
574 | my $self = shift; | |
575 | my @args = @_; | |
576 | $self->SUPER::Start(@args); | |
577 | } | |
578 | ||
579 | sub Stop { | |
580 | my $self = shift; | |
581 | ||
582 | $self->SUPER::Stop(); | |
583 | } | |
584 | ||
585 | sub AddProc { | |
586 | my $self = shift; | |
587 | my $newproc = shift; | |
588 | push(@{ $self->{_procs} }, $newproc ); | |
589 | $self->Start($self->{_pollinterval}) if(!$self->IsRunning()); | |
590 | } | |
591 | ||
592 | #----------------------------------------------------- | |
593 | # PACKAGE Wx::Perl::ProcessStream::Process | |
594 | # | |
595 | # Adds some extra methods to Wx::Process | |
596 | #----------------------------------------------------- | |
597 | ||
598 | package Wx::Perl::ProcessStream::Process; | |
599 | use Wx qw(wxSIGTERM | |
600 | wxSIGKILL | |
601 | wxSIGNONE | |
602 | wxKILL_OK | |
603 | wxKILL_BAD_SIGNAL | |
604 | wxKILL_ACCESS_DENIED | |
605 | wxKILL_NO_PROCESS | |
606 | wxKILL_ERROR); | |
607 | ||
608 | use base qw( Wx::Process ); | |
609 | use Wx::Perl::Carp; | |
610 | ||
611 | sub new { | |
612 | my $class = shift; | |
613 | my $procname = shift; | |
614 | my $handler = shift; | |
615 | my $readmethod = shift || 'getc'; | |
616 | my $self = $class->SUPER::new(@_); | |
617 | ||
618 | $self->{__readlinemethod} = ( lc($readmethod) eq 'readline' ) ? 1 : 0; | |
619 | if($self->{__readlinemethod} && ($Wx::VERSION < 0.75)) { | |
620 | carp('A read method of "readline" cannot be used with Wx versions < 0.75. Reverting to default "getc" method'); | |
621 | } | |
622 | ||
623 | $self->__set_process_name($procname); | |
624 | $self->__set_handler($handler); | |
625 | $self->{_await_actions} = []; | |
626 | $self->{_stderr_buffer} = []; | |
627 | $self->{_stdout_buffer} = []; | |
628 | return $self; | |
629 | } | |
630 | ||
631 | sub __read_input_line { | |
632 | my $self = shift; | |
633 | my $linebuffer; | |
634 | my $charbuffer = '0'; | |
635 | use bytes; | |
636 | if($self->{__readlinebytes}) { | |
637 | if( $self->IsInputAvailable() && defined( my $tempbuffer = readline( $self->GetInputStream() ) ) ){ | |
638 | $linebuffer = $tempbuffer; | |
639 | } | |
640 | } else { | |
641 | while($self->IsInputAvailable() && ( my $chars = read($self->GetInputStream(),$charbuffer,1 ) ) ) { | |
642 | last if(!$chars); | |
643 | $linebuffer .= $charbuffer; | |
644 | last if($charbuffer eq "\n"); | |
645 | } | |
646 | } | |
647 | no bytes; | |
648 | return $linebuffer; | |
649 | } | |
650 | ||
651 | sub __read_error_line { | |
652 | my $self = shift; | |
653 | my $linebuffer; | |
654 | my $charbuffer = '0'; | |
655 | use bytes; | |
656 | if($self->{__readlinebytes}) { | |
657 | if( $self->IsErrorAvailable() && defined( my $tempbuffer = readline( $self->GetErrorStream() ) ) ){ | |
658 | $linebuffer = $tempbuffer; | |
659 | } | |
660 | } else { | |
661 | while($self->IsErrorAvailable() && ( my $chars = read($self->GetErrorStream(),$charbuffer,1 ) ) ) { | |
662 | last if(!$chars); | |
663 | $linebuffer .= $charbuffer; | |
664 | last if($charbuffer eq "\n"); | |
665 | } | |
666 | } | |
667 | no bytes; | |
668 | return $linebuffer; | |
669 | } | |
670 | ||
671 | sub OnTerminate { | |
672 | my($self, $pid, $status) = @_; | |
673 | $self->__set_exit_code($status); | |
674 | } | |
675 | ||
676 | sub __get_handler { | |
677 | my $self = shift; | |
678 | return $self->{_handler}; | |
679 | } | |
680 | ||
681 | sub __set_handler { | |
682 | my $self = shift; | |
683 | $self->{_handler} = shift; | |
684 | } | |
685 | ||
686 | sub GetAppCloseAction { | |
687 | my $self = shift; | |
688 | return $self->{_closeaction}; | |
689 | } | |
690 | ||
691 | sub SetAppCloseAction { | |
692 | my $self = shift; | |
693 | my $newaction = shift; | |
694 | $self->{_closeaction} = ($newaction == wxSIGTERM||wxSIGKILL) ? $newaction : $self->{_closeaction}; | |
695 | } | |
696 | ||
697 | sub GetProcessName { | |
698 | my $self = shift; | |
699 | return $self->{_procname}; | |
700 | } | |
701 | ||
702 | sub __set_process_name { | |
703 | my $self = shift; | |
704 | $self->{_procname} = shift; | |
705 | } | |
706 | ||
707 | sub GetExitCode { | |
708 | my $self = shift; | |
709 | return $self->{_exitcode}; | |
710 | } | |
711 | ||
712 | sub __set_exit_code { | |
713 | my $self = shift; | |
714 | $self->{_exitcode} = shift; | |
715 | } | |
716 | ||
717 | sub GetStdOutBuffer { | |
718 | my $self = shift; | |
719 | my @buffers = @{ $self->{_stdout_buffer} }; | |
720 | $self->{_stdout_buffer} = []; | |
721 | return \@buffers; | |
722 | } | |
723 | ||
724 | sub GetStdErrBuffer { | |
725 | my $self = shift; | |
726 | my @buffers = @{ $self->{_stderr_buffer} }; | |
727 | $self->{_stderr_buffer} = []; | |
728 | return \@buffers; | |
729 | } | |
730 | ||
731 | sub GetProcessId { | |
732 | my $self = shift; | |
733 | return $self->{_processpid}; | |
734 | } | |
735 | ||
736 | sub __set_process_id { | |
737 | my $self = shift; | |
738 | $self->{_processpid} = shift; | |
739 | } | |
740 | ||
741 | sub TerminateProcess { | |
742 | my $self = shift; | |
743 | push(@{ $self->{_await_actions} }, { action => 'terminate', } ); | |
744 | } | |
745 | ||
746 | sub KillProcess { | |
747 | my $self = shift; | |
748 | push(@{ $self->{_await_actions} }, { action => 'kill', } ); | |
749 | } | |
750 | ||
751 | sub WriteProcess { | |
752 | my ($self, $writedata) = @_; | |
753 | push(@{ $self->{_await_actions} }, { action => 'write', writedata => $writedata } ); | |
754 | } | |
755 | ||
756 | sub CloseInput { | |
757 | my $self = shift; | |
758 | push(@{ $self->{_await_actions} }, { action => 'closeinput', } ); | |
759 | } | |
760 | ||
761 | sub IsAlive { | |
762 | my $self = shift; | |
763 | my $alive = Wx::Process::Kill( $self->GetProcessId(), wxSIGNONE ); | |
764 | if($alive == wxKILL_NO_PROCESS) { | |
765 | return 0; | |
766 | } elsif( $alive == wxKILL_OK ) { | |
767 | return 1; | |
768 | } else { | |
769 | return undef; | |
770 | } | |
771 | } | |
772 | ||
773 | #----------------------------------------------------- | |
774 | # PACKAGE Wx::Perl::ProcessStream::ProcessEvent | |
775 | # | |
776 | # STDOUT, STDERR, EXIT events | |
777 | #----------------------------------------------------- | |
778 | ||
779 | package Wx::Perl::ProcessStream::ProcessEvent; | |
780 | use Wx; | |
781 | use base qw( Wx::PlCommandEvent ); | |
782 | ||
783 | sub new { | |
784 | my( $class, $type, $id ) = @_; | |
785 | my $self = $class->SUPER::new( $type, $id ); | |
786 | return $self; | |
787 | } | |
788 | ||
789 | sub GetLine { | |
790 | my $self = shift; | |
791 | return $self->{_outputline}; | |
792 | } | |
793 | ||
794 | sub SetLine { | |
795 | my $self = shift; | |
796 | $self->{_outputline} = shift; | |
797 | } | |
798 | ||
799 | sub GetProcess { | |
800 | my $self = shift; | |
801 | return $self->{_process}; | |
802 | } | |
803 | ||
804 | sub SetProcess { | |
805 | my $self = shift; | |
806 | $self->{_process} = shift; | |
807 | } | |
808 | ||
809 | sub Clone { | |
810 | my $self = shift; | |
811 | my $class = ref $self; | |
812 | my $clone = $class->new( $self->GetEventType(), $self->GetId() ); | |
813 | $clone->SetLine( $self->GetLine ); | |
814 | $clone->SetProcess( $self->GetProcess() ); | |
815 | return $clone; | |
816 | } | |
817 | ||
818 | 1; | |
819 | __END__ | |
820 | ||
821 |
2 | 2 | use utf8; |
3 | 3 | |
4 | 4 | # Config.pm -- Configuration files. |
5 | # RCS Info : $Id: Config.pm,v 1.24 2009/10/28 22:08:50 jv Exp $ | |
5 | # RCS Info : $Id: Config.pm,v 1.25 2009/12/15 13:39:17 jv Exp $ | |
6 | 6 | # Author : Johan Vromans |
7 | 7 | # Created On : Fri Jan 20 17:57:13 2006 |
8 | 8 | # Last Modified By: Johan Vromans |
0 | 0 | #! perl |
1 | 1 | |
2 | 2 | # Sqlite.pm -- EekBoek driver for SQLite database |
3 | # RCS Info : $Id: Sqlite.pm,v 1.10 2009/10/16 18:22:19 jv Exp $ | |
3 | # RCS Info : $Id: Sqlite.pm,v 1.11 2009/12/18 21:56:03 jv Exp $ | |
4 | 4 | # Author : Johan Vromans |
5 | 5 | # Created On : Sat Oct 7 10:10:36 2006 |
6 | 6 | # Last Modified By: Johan Vromans |
7 | # Last Modified On: Fri Oct 16 12:30:30 2009 | |
8 | # Update Count : 157 | |
7 | # Last Modified On: Fri Dec 18 20:07:56 2009 | |
8 | # Update Count : 158 | |
9 | 9 | # Status : Unknown, Use with caution! |
10 | 10 | |
11 | 11 | package main; |
17 | 17 | use strict; |
18 | 18 | use warnings; |
19 | 19 | |
20 | our $VERSION = sprintf "%d.%03d", q$Revision: 1.10 $ =~ /(\d+)/g; | |
20 | our $VERSION = sprintf "%d.%03d", q$Revision: 1.11 $ =~ /(\d+)/g; | |
21 | 21 | |
22 | 22 | use EB; |
23 | 23 | use DBI; |
104 | 104 | } |
105 | 105 | |
106 | 106 | # Our database is UTF8, so deal with it properly. |
107 | $dbh->{unicode} = 1; | |
107 | if ( $DBD::SQLite::VERSION ge "1.26_06" ) { | |
108 | $dbh->{sqlite_unicode} = 1; | |
109 | } | |
110 | else { | |
111 | $dbh->{unicode} = 1; | |
112 | } | |
108 | 113 | |
109 | 114 | # Create some missing functions. |
110 | 115 | register_functions(); |
0 | #! perl -- -*- coding: utf-8 -*- | |
1 | ||
2 | use utf8; | |
3 | ||
4 | package main; | |
5 | ||
6 | use strict; | |
7 | use warnings; | |
8 | ||
9 | use EekBoek; | |
10 | use EB; | |
11 | ||
12 | our $cfg; | |
13 | ||
14 | our @configs = qw( .eekboek.conf schema.dat | |
15 | mutaties.eb relaties.eb opening.eb ); | |
16 | ||
17 | package EB::IniWiz; | |
18 | ||
19 | use EB; | |
20 | use File::Basename; | |
21 | ||
22 | my @adm_dirs; | |
23 | my $runeb; | |
24 | ||
25 | sub getadm { # STATIC | |
26 | my ( $pkg, $opts ) = @_; | |
27 | chdir($opts->{admdir}); | |
28 | my @files = glob( "*/" . $cfg->std_config ); | |
29 | foreach ( sort @files ) { | |
30 | push( @adm_dirs, dirname($_) ); | |
31 | } | |
32 | ||
33 | my $ret = -1; | |
34 | ||
35 | if ( @adm_dirs ) { | |
36 | ||
37 | print STDERR (__x("Beschikbare administraties in {dir}:", | |
38 | dir => $opts->{admdir}), "\n\n"); | |
39 | for ( my $i = 0; $i < @adm_dirs; $i++ ) { | |
40 | my $desc = $adm_dirs[$i]; | |
41 | if ( open( my $fd, '<:utf8', $adm_dirs[$i]."/opening.eb" ) ) { | |
42 | while ( <$fd> ) { | |
43 | next unless /adm_naam\s+"(.+)"/; | |
44 | $desc = $1; | |
45 | last; | |
46 | } | |
47 | close($fd); | |
48 | } | |
49 | printf STDERR ("%3d: %s\n", $i+1, $desc); | |
50 | } | |
51 | print STDERR ("\n"); | |
52 | while ( 1 ) { | |
53 | print STDERR (_T("Uw keuze: ")); | |
54 | chomp( my $ans = <STDIN> ); | |
55 | next unless $ans =~ /^\d+$/; | |
56 | next unless $ans && $ans <= @adm_dirs; | |
57 | $ret = $ans; | |
58 | chdir( $adm_dirs[ $ret-1 ] ) || die("chdir"); | |
59 | last; | |
60 | } | |
61 | } | |
62 | return $ret; | |
63 | ||
64 | } | |
65 | ||
66 | sub run { | |
67 | my ( $self, $opts ) = @_; | |
68 | my $admdir = $opts->{admdir} || $cfg->val(qw(general admdir), $cfg->user_dir("admdir")); | |
69 | $runeb = 1; | |
70 | $admdir =~ s/\$([A-Z_]+)/$ENV{$1}/ge; | |
71 | if ( $admdir ) { | |
72 | mkdir($admdir) unless -d $admdir; | |
73 | die("No admdir $admdir: $!") unless -d $admdir; | |
74 | } | |
75 | $opts->{admdir} = $admdir; | |
76 | $runeb = 0; | |
77 | ||
78 | my $ret = EB::IniWiz->getadm($opts) if $admdir; | |
79 | $opts->{runeb} = $ret >= 0; | |
80 | ||
81 | } | |
82 | ||
83 | 1; |
1 | 1 | |
2 | 2 | use utf8; |
3 | 3 | |
4 | # RCS Id : $Id: Main.pm,v 1.8 2009/10/28 22:09:45 jv Exp $ | |
4 | # RCS Id : $Id: Main.pm,v 1.9 2009/12/15 13:41:14 jv Exp $ | |
5 | 5 | # Author : Johan Vromans |
6 | 6 | # Created On : Thu Jul 7 15:53:48 2005 |
7 | 7 | # Last Modified By: Johan Vromans |
8 | # Last Modified On: Wed Oct 28 23:36:39 2009 | |
9 | # Update Count : 969 | |
8 | # Last Modified On: Sat Dec 19 15:23:25 2009 | |
9 | # Update Count : 975 | |
10 | 10 | # Status : Unknown, Use with caution! |
11 | 11 | |
12 | 12 | ################ Common stuff ################ |
79 | 79 | |
80 | 80 | my $userdir = $cfg->user_dir; |
81 | 81 | mkdir($userdir) unless -d $userdir; |
82 | ||
83 | if ( $opts->{wizard} | |
84 | or | |
85 | !$opts->{config} | |
86 | && ( -e ".eekboek.conf" ? $cfg->val( qw(general wizard), 0 ) : 1 ) | |
87 | ) { | |
88 | require EB::IniWiz; | |
89 | EB::IniWiz->run($opts); # sets $opts->{runeb} | |
90 | return unless $opts->{runeb}; | |
91 | undef $cfg; | |
92 | EB::Config->init_config( { app => $EekBoek::PACKAGE, %$opts } ); | |
93 | } | |
82 | 94 | |
83 | 95 | if ( $opts->{createsampleconfig} ) { |
84 | 96 | $opts->{command} = 1; |
242 | 254 | 'dir=s', |
243 | 255 | 'file=s', |
244 | 256 | 'interactive!', |
257 | 'wizard', | |
245 | 258 | 'errexit', |
246 | 259 | 'trace', |
247 | 260 | 'help|?' => $help, |
2 | 2 | use utf8; |
3 | 3 | |
4 | 4 | # Einde.pm -- Eindejaarsverwerking |
5 | # RCS Info : $Id: Einde.pm,v 1.20 2009/10/17 22:02:54 jv Exp $ | |
5 | # RCS Info : $Id: Einde.pm,v 1.22 2009/11/04 22:24:03 jv Exp $ | |
6 | 6 | # Author : Johan Vromans |
7 | 7 | # Created On : Sun Oct 16 21:27:40 2005 |
8 | 8 | # Last Modified By: Johan Vromans |
9 | # Last Modified On: Sat Oct 17 12:50:26 2009 | |
10 | # Update Count : 241 | |
9 | # Last Modified On: Wed Nov 4 23:21:55 2009 | |
10 | # Update Count : 246 | |
11 | 11 | # Status : Unknown, Use with caution! |
12 | 12 | |
13 | 13 | package main; |
20 | 20 | use strict; |
21 | 21 | use warnings; |
22 | 22 | |
23 | our $VERSION = sprintf "%d.%03d", q$Revision: 1.20 $ =~ /(\d+)/g; | |
23 | our $VERSION = sprintf "%d.%03d", q$Revision: 1.22 $ =~ /(\d+)/g; | |
24 | 24 | |
25 | 25 | use EB; |
26 | 26 | use EB::Format; |
34 | 34 | $class = ref($class) || $class; |
35 | 35 | return bless {} => $class; |
36 | 36 | } |
37 | ||
38 | sub min($$) { $_[0] lt $_[1] ? $_[0] : $_[1] } | |
39 | 37 | |
40 | 38 | sub perform { |
41 | 39 | my ($self, $args, $opts) = @_; |
175 | 173 | |
176 | 174 | ## Afboeken BTW |
177 | 175 | |
178 | foreach my $stdacc ( @{ $dbh->std_accs } ) { | |
176 | foreach ( @{ $dbh->std_accs } ) { | |
177 | my $stdacc = $_; # copy for mod | |
179 | 178 | next unless $stdacc =~ /^btw_[iv].$/; |
180 | 179 | next unless defined( $stdacc = $dbh->std_acc($stdacc, undef) ); |
181 | 180 | ($acc_id, $acc_desc, $acc_balance) = |
0 | #! perl | |
1 | ||
2 | # $Id: BKMPanel.pm,v 1.9 2008/03/25 23:03:51 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $dbh; | |
8 | our $app; | |
9 | ||
10 | package EB::Wx::Booking::BKMPanel; | |
11 | ||
12 | use Wx qw[:everything]; | |
13 | use base qw(Wx::Dialog); | |
14 | use base qw(EB::Wx::Window); | |
15 | use strict; | |
16 | use EB; | |
17 | use EB::Format; | |
18 | ||
19 | # begin wxGlade: ::dependencies | |
20 | use Wx::Grid; | |
21 | # end wxGlade | |
22 | ||
23 | my $dbk_type; | |
24 | ||
25 | sub new { | |
26 | my( $self, $parent, $id, $title, $pos, $size, $type ) = @_; | |
27 | $parent = undef unless defined $parent; | |
28 | $id = -1 unless defined $id; | |
29 | $title = "" unless defined $title; | |
30 | $pos = wxDefaultPosition unless defined $pos; | |
31 | $size = wxDefaultSize unless defined $size; | |
32 | my $style; | |
33 | my $name = ""; | |
34 | $dbk_type = $type; | |
35 | ||
36 | # begin wxGlade: EB::Wx::Booking::BKMPanel::new | |
37 | ||
38 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTHICK_FRAME | |
39 | unless defined $style; | |
40 | ||
41 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
42 | $self->{sz_staticbox} = Wx::StaticBox->new($self, -1, _T("Dagboek") ); | |
43 | $self->{gr_main} = Wx::Grid->new($self, -1); | |
44 | $self->{b_close} = Wx::Button->new($self, wxID_CLOSE, ""); | |
45 | ||
46 | $self->__set_properties(); | |
47 | $self->__do_layout(); | |
48 | ||
49 | Wx::Event::EVT_BUTTON($self, $self->{b_close}->GetId, \&OnClose); | |
50 | ||
51 | # end wxGlade | |
52 | ||
53 | Wx::Event::EVT_MENU($self, wxID_CLOSE, \&OnClose); | |
54 | Wx::Event::EVT_GRID_CELL_LEFT_DCLICK($self->{gr_main}, \&OnDClick); | |
55 | ||
56 | $self->SetTitle($title); | |
57 | return $self; | |
58 | ||
59 | } | |
60 | ||
61 | ||
62 | sub __set_properties { | |
63 | my $self = shift; | |
64 | ||
65 | $self->{dbk_type} = $dbk_type; | |
66 | ||
67 | # begin wxGlade: EB::Wx::Booking::BKMPanel::__set_properties | |
68 | ||
69 | $self->SetTitle(_T("Bank/Kas/Memoriaal Boeking")); | |
70 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(300, 168))); | |
71 | $self->{gr_main}->CreateGrid(0, | |
72 | $self->{dbk_type} == DBKTYPE_MEMORIAAL ? 3 : 4); | |
73 | $self->{gr_main}->SetRowLabelSize(3); | |
74 | $self->{gr_main}->SetColLabelSize(22); | |
75 | $self->{gr_main}->EnableEditing(0); | |
76 | $self->{gr_main}->EnableDragRowSize(0); | |
77 | $self->{gr_main}->SetSelectionMode(wxGridSelectRows); | |
78 | $self->{gr_main}->SetColLabelValue(0, _T("Nr")); | |
79 | $self->{gr_main}->SetColLabelValue(1, _T("Datum")); | |
80 | $self->{gr_main}->SetColLabelValue(2, _T("Omschrijving")); | |
81 | $self->{gr_main}->SetColLabelValue(3, _T("Bedrag")) | |
82 | if $self->{dbk_type} != DBKTYPE_MEMORIAAL; | |
83 | $self->{b_close}->SetFocus(); | |
84 | ||
85 | # end wxGlade | |
86 | } | |
87 | ||
88 | sub __do_layout { | |
89 | my $self = shift; | |
90 | ||
91 | # begin wxGlade: EB::Wx::Booking::BKMPanel::__do_layout | |
92 | ||
93 | $self->{sz_outer} = Wx::BoxSizer->new(wxHORIZONTAL); | |
94 | $self->{sz_main} = Wx::BoxSizer->new(wxVERTICAL); | |
95 | $self->{sz_buttons} = Wx::BoxSizer->new(wxHORIZONTAL); | |
96 | $self->{sz}= Wx::StaticBoxSizer->new($self->{sz_staticbox}, wxHORIZONTAL); | |
97 | $self->{sz}->Add($self->{gr_main}, 1, wxALL|wxEXPAND, 5); | |
98 | $self->{sz_main}->Add($self->{sz}, 1, wxEXPAND, 0); | |
99 | $self->{sz_buttons}->Add(5, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
100 | $self->{sz_buttons}->Add($self->{b_close}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
101 | $self->{sz_main}->Add($self->{sz_buttons}, 0, wxTOP|wxEXPAND, 5); | |
102 | $self->{sz_outer}->Add($self->{sz_main}, 1, wxALL|wxEXPAND, 5); | |
103 | $self->SetSizer($self->{sz_outer}); | |
104 | $self->Layout(); | |
105 | ||
106 | # end wxGlade | |
107 | } | |
108 | ||
109 | sub init { | |
110 | my ($self, $id, $desc, $type) = @_; | |
111 | $self->SetTitle(__x("Dagboek: {dbk}", dbk => $desc)); | |
112 | $self->{dbk_id} = $id; | |
113 | $self->{dbk_desc} = $desc; | |
114 | $self->{dbk_type} = $type; | |
115 | $self->refresh; | |
116 | } | |
117 | ||
118 | sub refresh { | |
119 | my ($self) = @_; | |
120 | ||
121 | my $sth = $dbh->sql_exec("SELECT bsk_id, bsk_nr, bsk_desc,". | |
122 | " bsk_date, bsk_amount". | |
123 | " From Boekstukken". | |
124 | " WHERE bsk_dbk_id = ?". | |
125 | " ORDER BY bsk_date, bsk_id", | |
126 | $self->{dbk_id}); | |
127 | ||
128 | my $gr = $self->{gr_main}; | |
129 | $gr->DeleteRows(0, $gr->GetNumberRows); | |
130 | ||
131 | my $row = 0; | |
132 | while ( my $rr = $sth->fetchrow_arrayref ) { | |
133 | my ($bsk_id, $bsk_nr, $bsk_desc, $bsk_date, $bsk_amount) = @$rr; | |
134 | $bsk_nr =~ s/\s+$//; | |
135 | ||
136 | my $col = 0; | |
137 | $gr->AppendRows(1); | |
138 | $gr->SetCellValue($row, $col, $bsk_nr); | |
139 | $gr->SetCellAlignment($row, $col, wxALIGN_RIGHT, wxALIGN_CENTER); | |
140 | $col++; | |
141 | $gr->SetCellValue($row, $col, $bsk_date); | |
142 | $gr->SetCellAlignment($row, $col, wxALIGN_LEFT, wxALIGN_CENTER); | |
143 | $col++; | |
144 | $gr->SetCellValue($row, $col, $bsk_desc); | |
145 | $gr->SetCellAlignment($row, $col, wxALIGN_LEFT, wxALIGN_CENTER); | |
146 | if ( $self->{dbk_type} != DBKTYPE_MEMORIAAL ) { | |
147 | $col++; | |
148 | $gr->SetCellValue($row, $col, numfmt($bsk_amount)); | |
149 | $gr->SetCellAlignment($row, $col, wxALIGN_RIGHT, wxALIGN_CENTER); | |
150 | } | |
151 | $row++; | |
152 | } | |
153 | ||
154 | $self->{_curr_row} = 0; | |
155 | $self->resize_grid($self->{gr_main}); | |
156 | } | |
157 | ||
158 | # wxGlade: EB::Wx::Booking::BKMPanel::OnClose <event_handler> | |
159 | sub OnClose { | |
160 | my ($self, $event) = @_; | |
161 | # Remember position and size. | |
162 | $self->sizepos_save; | |
163 | # Disappear. | |
164 | $self->Show(0); | |
165 | } | |
166 | ||
167 | # wxGlade: EB::Wx::Booking::BKMPanel::OnDClick <event_handler> | |
168 | sub OnDClick { | |
169 | my ($self, $event) = @_; | |
170 | my $row = $event->GetRow; | |
171 | warn("row = $row\n"); | |
172 | } | |
173 | ||
174 | # end of class EB::Wx::Booking::BKMPanel | |
175 | ||
176 | 1; | |
177 |
0 | #! perl | |
1 | ||
2 | package main; | |
3 | ||
4 | our $cfg; | |
5 | our $dbh; | |
6 | our $state; | |
7 | ||
8 | package Wx::DatePickerCtrl; | |
9 | ||
10 | package EB::Wx::Booking::IVPanel::BskPanel; | |
11 | ||
12 | use Wx qw[:everything :datepicker]; | |
13 | use Wx::Calendar; | |
14 | use base qw(Wx::Dialog); | |
15 | use base qw(EB::Wx::Window); | |
16 | use strict; | |
17 | use EB; | |
18 | use EB::Format; | |
19 | use EB::Booking; | |
20 | use EB::Wx::UI::AmountCtrl; | |
21 | use EB::Wx::UI::BTWInput; | |
22 | use EB::Wx::UI::AccInput; | |
23 | use Wx::Grid; | |
24 | ||
25 | sub new { | |
26 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
27 | $parent = undef unless defined $parent; | |
28 | $id = -1 unless defined $id; | |
29 | $title = "" unless defined $title; | |
30 | $pos = wxDefaultPosition unless defined $pos; | |
31 | $size = wxDefaultSize unless defined $size; | |
32 | $name = "" unless defined $name; | |
33 | ||
34 | # begin wxGlade: EB::Wx::Booking::IVPanel::BskPanel::new | |
35 | ||
36 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTHICK_FRAME | |
37 | unless defined $style; | |
38 | ||
39 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
40 | $self->{sz_bsrs_staticbox} = Wx::StaticBox->new($self, -1, _T("Boekstukregels") ); | |
41 | $self->{sz_bsr_staticbox} = Wx::StaticBox->new($self, -1, _T("Details boekstukregel") ); | |
42 | $self->{sz_bsk_staticbox} = Wx::StaticBox->new($self, -1, _T("Boekstuk") ); | |
43 | $self->{label_4} = Wx::StaticText->new($self, -1, _T("Volgnr."), wxDefaultPosition, wxDefaultSize, ); | |
44 | $self->{label_6} = Wx::StaticText->new($self, -1, _T("Omschrijving"), wxDefaultPosition, wxDefaultSize, ); | |
45 | $self->{t_bsknr} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_RIGHT); | |
46 | $self->{t_desc} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
47 | $self->{label_1} = Wx::StaticText->new($self, -1, _T("Relatie"), wxDefaultPosition, wxDefaultSize, ); | |
48 | $self->{t_rel_code} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
49 | $self->{t_rel_desc} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_READONLY); | |
50 | $self->{label_5} = Wx::StaticText->new($self, -1, _T("Datum"), wxDefaultPosition, wxDefaultSize, ); | |
51 | $self->{dt_date} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
52 | $self->{b_date} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("calendar.png", wxBITMAP_TYPE_ANY)); | |
53 | $self->{label_2} = Wx::StaticText->new($self, -1, _T("Bedrag"), wxDefaultPosition, wxDefaultSize, ); | |
54 | $self->{label_3} = Wx::StaticText->new($self, -1, _T("Referentie"), wxDefaultPosition, wxDefaultSize, ); | |
55 | $self->{t_amount} = EB::Wx::UI::AmountCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_RIGHT); | |
56 | $self->{t_ref} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
57 | $self->{static_line_1} = Wx::StaticLine->new($self, -1, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL); | |
58 | $self->{b_apply} = Wx::Button->new($self, -1, _T("Toepassen")); | |
59 | $self->{b_cancel} = Wx::Button->new($self, -1, _T("Annuleren")); | |
60 | $self->{b_forward} = Wx::Button->new($self, -1, _T("Volgende")); | |
61 | $self->{b_backward} = Wx::Button->new($self, -1, _T("Vorige")); | |
62 | $self->{gr_bsr} = Wx::Grid->new($self, -1); | |
63 | $self->{b_add} = Wx::Button->new($self, -1, _T("Toevoegen")); | |
64 | $self->{b_dupl} = Wx::Button->new($self, -1, _T("Dupliceren")); | |
65 | $self->{b_change} = Wx::Button->new($self, -1, _T("Wijzigen")); | |
66 | $self->{b_remove} = Wx::Button->new($self, -1, _T("Verwijderen")); | |
67 | $self->{l_bsr_total} = Wx::StaticText->new($self, -1, _T("Totaal boekstukregels: "), wxDefaultPosition, wxDefaultSize, ); | |
68 | $self->{label_12} = Wx::StaticText->new($self, -1, _T("Datum"), wxDefaultPosition, wxDefaultSize, ); | |
69 | $self->{label_13} = Wx::StaticText->new($self, -1, _T("Omschrijving"), wxDefaultPosition, wxDefaultSize, ); | |
70 | $self->{td_r_date} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
71 | $self->{b_r_date} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("calendar.png", wxBITMAP_TYPE_ANY)); | |
72 | $self->{t_r_desc} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
73 | $self->{l_amount1} = Wx::StaticText->new($self, -1, _T("Bedrag"), wxDefaultPosition, wxDefaultSize, ); | |
74 | $self->{t_r_amount} = EB::Wx::UI::AmountCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_RIGHT); | |
75 | $self->{label_14} = Wx::StaticText->new($self, -1, _T("BTW"), wxDefaultPosition, wxDefaultSize, ); | |
76 | $self->{label_15} = Wx::StaticText->new($self, -1, _T("Soort"), wxDefaultPosition, wxDefaultSize, ); | |
77 | $self->{c_r_btw} = EB::Wx::UI::BTWInput->new($self, -1, wxDefaultPosition, wxDefaultSize, [], ); | |
78 | $self->{t_r_btw} = EB::Wx::UI::AmountCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_RIGHT); | |
79 | $self->{c_r_kstomz} = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, [_T("Kosten"), _T("Neutraal"), _T("Omzet")], ); | |
80 | $self->{l_amount2} = Wx::StaticText->new($self, -1, _T("Bedrag"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); | |
81 | $self->{label_10} = Wx::StaticText->new($self, -1, _T("Rekening"), wxDefaultPosition, wxDefaultSize, ); | |
82 | $self->{t_r_amount2} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_RIGHT); | |
83 | $self->{t_r_acct} = EB::Wx::UI::AccInput->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
84 | $self->{static_line_2} = Wx::StaticLine->new($self, -1, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL); | |
85 | $self->{b_r_accept} = Wx::Button->new($self, -1, _T("Toepassen")); | |
86 | $self->{b_r_cancel} = Wx::Button->new($self, -1, _T("Annuleren")); | |
87 | $self->{b_r_forward} = Wx::Button->new($self, -1, _T("Volgende")); | |
88 | $self->{b_r_backward} = Wx::Button->new($self, -1, _T("Vorige")); | |
89 | $self->{cb_pin} = Wx::CheckBox->new($self, -1, _T("Toon details tegelijk met boekstukregels"), wxDefaultPosition, wxDefaultSize, ); | |
90 | ||
91 | $self->__set_properties(); | |
92 | $self->__do_layout(); | |
93 | ||
94 | Wx::Event::EVT_BUTTON($self, $self->{b_date}->GetId, \&OnDate); | |
95 | Wx::Event::EVT_BUTTON($self, $self->{b_apply}->GetId, \&OnApply); | |
96 | Wx::Event::EVT_BUTTON($self, $self->{b_cancel}->GetId, \&OnCancel); | |
97 | Wx::Event::EVT_BUTTON($self, $self->{b_forward}->GetId, \&OnForward); | |
98 | Wx::Event::EVT_BUTTON($self, $self->{b_backward}->GetId, \&OnBackward); | |
99 | Wx::Event::EVT_BUTTON($self, $self->{b_add}->GetId, \&OnAdd); | |
100 | Wx::Event::EVT_BUTTON($self, $self->{b_dupl}->GetId, \&OnDupl); | |
101 | Wx::Event::EVT_BUTTON($self, $self->{b_change}->GetId, \&OnChange); | |
102 | Wx::Event::EVT_BUTTON($self, $self->{b_remove}->GetId, \&OnRemove); | |
103 | Wx::Event::EVT_BUTTON($self, $self->{b_r_date}->GetId, \&OnRDate); | |
104 | Wx::Event::EVT_CHOICE($self, $self->{c_r_btw}->GetId, \&OnRBTW); | |
105 | Wx::Event::EVT_CHOICE($self, $self->{c_r_kstomz}->GetId, \&OnRKstOmz); | |
106 | Wx::Event::EVT_BUTTON($self, $self->{b_r_accept}->GetId, \&OnRApply); | |
107 | Wx::Event::EVT_BUTTON($self, $self->{b_r_cancel}->GetId, \&OnRCancel); | |
108 | Wx::Event::EVT_BUTTON($self, $self->{b_r_forward}->GetId, \&OnRForward); | |
109 | Wx::Event::EVT_BUTTON($self, $self->{b_r_backward}->GetId, \&OnRBackward); | |
110 | Wx::Event::EVT_CHECKBOX($self, $self->{cb_pin}->GetId, \&OnPin); | |
111 | ||
112 | # end wxGlade | |
113 | ||
114 | Wx::Event::EVT_GRID_CELL_LEFT_CLICK($self->{gr_bsr}, \&OnClick); | |
115 | Wx::Event::EVT_GRID_CELL_LEFT_DCLICK($self->{gr_bsr}, \&OnDClick); | |
116 | ||
117 | return $self; | |
118 | ||
119 | } | |
120 | ||
121 | ||
122 | sub __set_properties { | |
123 | my $self = shift; | |
124 | ||
125 | $self->{td_r_date}->SetMinSize($self->{td_r_date}->ConvertDialogSizeToPixels(Wx::Size->new(44, -1))); | |
126 | $self->{t_r_amount}->SetMinSize($self->{t_r_amount}->ConvertDialogSizeToPixels(Wx::Size->new(60, -1))); | |
127 | $self->{t_r_btw}->SetMinSize($self->{t_r_btw}->ConvertDialogSizeToPixels(Wx::Size->new(60, -1))); | |
128 | ||
129 | # begin wxGlade: EB::Wx::Booking::IVPanel::BskPanel::__set_properties | |
130 | ||
131 | $self->SetTitle(_T("Boekstuk")); | |
132 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(352, 300))); | |
133 | $self->{dt_date}->SetMinSize($self->{dt_date}->ConvertDialogSizeToPixels(Wx::Size->new(44, -1))); | |
134 | $self->{b_date}->SetSize($self->{b_date}->GetBestSize()); | |
135 | $self->{t_amount}->SetMinSize($self->{t_amount}->ConvertDialogSizeToPixels(Wx::Size->new(60, -1))); | |
136 | $self->{gr_bsr}->CreateGrid(0, 6); | |
137 | $self->{gr_bsr}->SetRowLabelSize(0); | |
138 | $self->{gr_bsr}->EnableEditing(0); | |
139 | $self->{gr_bsr}->EnableDragRowSize(0); | |
140 | $self->{gr_bsr}->SetSelectionMode(wxGridSelectRows); | |
141 | $self->{gr_bsr}->SetColLabelValue(0, _T("Nr")); | |
142 | $self->{gr_bsr}->SetColLabelValue(1, _T("Datum")); | |
143 | $self->{gr_bsr}->SetColLabelValue(2, _T("Omschrijving")); | |
144 | $self->{gr_bsr}->SetColLabelValue(3, _T("Bedrag")); | |
145 | $self->{gr_bsr}->SetColLabelValue(4, _T("BTW")); | |
146 | $self->{gr_bsr}->SetColLabelValue(5, _T("Rekening")); | |
147 | $self->{b_r_date}->SetSize($self->{b_r_date}->GetBestSize()); | |
148 | $self->{c_r_btw}->SetSelection(0); | |
149 | $self->{c_r_kstomz}->SetSelection(0); | |
150 | $self->{l_amount2}->Enable(0); | |
151 | $self->{t_r_amount2}->Enable(0); | |
152 | ||
153 | # end wxGlade | |
154 | } | |
155 | ||
156 | sub __do_layout { | |
157 | my $self = shift; | |
158 | ||
159 | # begin wxGlade: EB::Wx::Booking::IVPanel::BskPanel::__do_layout | |
160 | ||
161 | $self->{sizer_1} = Wx::BoxSizer->new(wxHORIZONTAL); | |
162 | $self->{sz_main} = Wx::BoxSizer->new(wxVERTICAL); | |
163 | $self->{sz_pin} = Wx::BoxSizer->new(wxHORIZONTAL); | |
164 | $self->{sz_bsr}= Wx::StaticBoxSizer->new($self->{sz_bsr_staticbox}, wxHORIZONTAL); | |
165 | $self->{sizer_19} = Wx::BoxSizer->new(wxVERTICAL); | |
166 | $self->{sizer_12} = Wx::BoxSizer->new(wxVERTICAL); | |
167 | $self->{sizer_13} = Wx::BoxSizer->new(wxHORIZONTAL); | |
168 | $self->{sizer_9} = Wx::BoxSizer->new(wxVERTICAL); | |
169 | $self->{grid_sizer_11} = Wx::FlexGridSizer->new(6, 2, 2, 5); | |
170 | $self->{grid_sizer_12} = Wx::FlexGridSizer->new(2, 3, 0, 5); | |
171 | $self->{sizer_14} = Wx::BoxSizer->new(wxVERTICAL); | |
172 | $self->{sizer_11} = Wx::BoxSizer->new(wxHORIZONTAL); | |
173 | $self->{sz_bsrs}= Wx::StaticBoxSizer->new($self->{sz_bsrs_staticbox}, wxVERTICAL); | |
174 | $self->{sizer_6} = Wx::BoxSizer->new(wxHORIZONTAL); | |
175 | $self->{sz_bsk}= Wx::StaticBoxSizer->new($self->{sz_bsk_staticbox}, wxHORIZONTAL); | |
176 | $self->{sizer_7} = Wx::BoxSizer->new(wxVERTICAL); | |
177 | $self->{grid_sizer_2} = Wx::FlexGridSizer->new(6, 2, 2, 5); | |
178 | $self->{sizer_3} = Wx::FlexGridSizer->new(2, 2, 0, 5); | |
179 | $self->{sizer_2} = Wx::FlexGridSizer->new(2, 2, 0, 5); | |
180 | $self->{grid_sizer_2}->Add($self->{label_4}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
181 | $self->{grid_sizer_2}->Add($self->{label_6}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
182 | $self->{grid_sizer_2}->Add($self->{t_bsknr}, 0, wxRIGHT|wxTOP|wxEXPAND|wxADJUST_MINSIZE, 0); | |
183 | $self->{grid_sizer_2}->Add($self->{t_desc}, 1, wxRIGHT|wxTOP|wxEXPAND|wxADJUST_MINSIZE, 0); | |
184 | $self->{grid_sizer_2}->Add($self->{label_1}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
185 | $self->{grid_sizer_2}->Add(2, 2, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
186 | $self->{grid_sizer_2}->Add($self->{t_rel_code}, 0, wxLEFT|wxEXPAND|wxADJUST_MINSIZE, 0); | |
187 | $self->{grid_sizer_2}->Add($self->{t_rel_desc}, 1, wxLEFT|wxRIGHT|wxEXPAND|wxADJUST_MINSIZE, 0); | |
188 | $self->{sizer_2}->Add($self->{label_5}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
189 | $self->{sizer_2}->Add(1, 1, 0, wxADJUST_MINSIZE, 0); | |
190 | $self->{sizer_2}->Add($self->{dt_date}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
191 | $self->{sizer_2}->Add($self->{b_date}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
192 | $self->{sizer_2}->AddGrowableCol(1); | |
193 | $self->{grid_sizer_2}->Add($self->{sizer_2}, 1, wxEXPAND, 0); | |
194 | $self->{sizer_3}->Add($self->{label_2}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
195 | $self->{sizer_3}->Add($self->{label_3}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
196 | $self->{sizer_3}->Add($self->{t_amount}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
197 | $self->{sizer_3}->Add($self->{t_ref}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
198 | $self->{sizer_3}->AddGrowableCol(1); | |
199 | $self->{grid_sizer_2}->Add($self->{sizer_3}, 1, wxEXPAND, 0); | |
200 | $self->{grid_sizer_2}->AddGrowableCol(1); | |
201 | $self->{sz_bsk}->Add($self->{grid_sizer_2}, 1, wxALL|wxEXPAND, 5); | |
202 | $self->{sz_bsk}->Add($self->{static_line_1}, 0, wxRIGHT|wxBOTTOM|wxEXPAND, 5); | |
203 | $self->{sizer_7}->Add($self->{b_apply}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
204 | $self->{sizer_7}->Add($self->{b_cancel}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
205 | $self->{sizer_7}->Add($self->{b_forward}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
206 | $self->{sizer_7}->Add($self->{b_backward}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
207 | $self->{sz_bsk}->Add($self->{sizer_7}, 0, wxRIGHT|wxEXPAND, 5); | |
208 | $self->{sz_main}->Add($self->{sz_bsk}, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 5); | |
209 | $self->{sz_bsrs}->Add($self->{gr_bsr}, 1, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
210 | $self->{sizer_6}->Add($self->{b_add}, 0, wxLEFT|wxTOP|wxADJUST_MINSIZE, 5); | |
211 | $self->{sizer_6}->Add($self->{b_dupl}, 0, wxLEFT|wxTOP|wxADJUST_MINSIZE, 5); | |
212 | $self->{sizer_6}->Add($self->{b_change}, 0, wxLEFT|wxTOP|wxADJUST_MINSIZE, 5); | |
213 | $self->{sizer_6}->Add($self->{b_remove}, 0, wxLEFT|wxTOP|wxADJUST_MINSIZE, 5); | |
214 | $self->{sizer_6}->Add($self->{l_bsr_total}, 1, wxLEFT|wxTOP|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
215 | $self->{sz_bsrs}->Add($self->{sizer_6}, 0, wxBOTTOM|wxEXPAND, 5); | |
216 | $self->{sz_main}->Add($self->{sz_bsrs}, 1, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 5); | |
217 | $self->{grid_sizer_11}->Add($self->{label_12}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
218 | $self->{grid_sizer_11}->Add($self->{label_13}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
219 | $self->{sizer_11}->Add($self->{td_r_date}, 1, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
220 | $self->{sizer_11}->Add($self->{b_r_date}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
221 | $self->{grid_sizer_11}->Add($self->{sizer_11}, 1, wxEXPAND, 0); | |
222 | $self->{grid_sizer_11}->Add($self->{t_r_desc}, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
223 | $self->{sizer_14}->Add($self->{l_amount1}, 0, wxADJUST_MINSIZE, 0); | |
224 | $self->{sizer_14}->Add($self->{t_r_amount}, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
225 | $self->{grid_sizer_11}->Add($self->{sizer_14}, 1, wxEXPAND, 0); | |
226 | $self->{grid_sizer_12}->Add(1, 1, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
227 | $self->{grid_sizer_12}->Add($self->{label_14}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
228 | $self->{grid_sizer_12}->Add($self->{label_15}, 0, wxADJUST_MINSIZE, 0); | |
229 | $self->{grid_sizer_12}->Add($self->{c_r_btw}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
230 | $self->{grid_sizer_12}->Add($self->{t_r_btw}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
231 | $self->{grid_sizer_12}->Add($self->{c_r_kstomz}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
232 | $self->{grid_sizer_11}->Add($self->{grid_sizer_12}, 1, wxEXPAND, 0); | |
233 | $self->{grid_sizer_11}->Add($self->{l_amount2}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
234 | $self->{grid_sizer_11}->Add($self->{label_10}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
235 | $self->{grid_sizer_11}->Add($self->{t_r_amount2}, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
236 | $self->{grid_sizer_11}->Add($self->{t_r_acct}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
237 | $self->{grid_sizer_11}->AddGrowableCol(1); | |
238 | $self->{sizer_13}->Add($self->{grid_sizer_11}, 1, wxALL|wxEXPAND, 5); | |
239 | $self->{sizer_13}->Add($self->{static_line_2}, 0, wxRIGHT|wxBOTTOM|wxEXPAND, 5); | |
240 | $self->{sizer_9}->Add($self->{b_r_accept}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
241 | $self->{sizer_9}->Add($self->{b_r_cancel}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
242 | $self->{sizer_9}->Add($self->{b_r_forward}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
243 | $self->{sizer_9}->Add($self->{b_r_backward}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
244 | $self->{sizer_13}->Add($self->{sizer_9}, 0, wxRIGHT|wxEXPAND, 5); | |
245 | $self->{sizer_12}->Add($self->{sizer_13}, 0, wxEXPAND, 0); | |
246 | $self->{sizer_19}->Add($self->{sizer_12}, 0, wxEXPAND, 0); | |
247 | $self->{sz_bsr}->Add($self->{sizer_19}, 1, wxEXPAND, 0); | |
248 | $self->{sz_main}->Add($self->{sz_bsr}, 0, wxLEFT|wxRIGHT|wxEXPAND|wxADJUST_MINSIZE, 5); | |
249 | $self->{sz_pin}->Add($self->{cb_pin}, 0, wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); | |
250 | $self->{sz_pin}->Add(1, 1, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
251 | $self->{sz_main}->Add($self->{sz_pin}, 0, wxEXPAND, 0); | |
252 | $self->{sizer_1}->Add($self->{sz_main}, 1, wxEXPAND, 0); | |
253 | $self->SetSizer($self->{sizer_1}); | |
254 | $self->Layout(); | |
255 | ||
256 | # end wxGlade | |
257 | } | |
258 | ||
259 | sub _ISOtoWxD { | |
260 | return unless shift =~ /^(\d{4})-(\d\d)-(\d\d)$/; | |
261 | Wx::DateTime->newFromDMY($3,$2-1,$1,1,1,1,1); | |
262 | } | |
263 | ||
264 | sub init { | |
265 | my ($self, $id) = @_; | |
266 | $self->{bsk_id} = $id; | |
267 | #$self->{gr_bsr}->SetColLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTER); | |
268 | } | |
269 | ||
270 | my @bsrmap; | |
271 | ||
272 | sub refresh { | |
273 | my ($self) = @_; | |
274 | my $id = $self->{bsk_id}; | |
275 | my $rr = $dbh->do("SELECT bsk_nr, bsk_desc, rel_code, rel_desc, bsk_date, bsk_amount, bsk_ref". | |
276 | " FROM Boekstukken, Boekstukregels, Relaties". | |
277 | " WHERE bsr_bsk_id = bsk_id". | |
278 | " AND bsr_rel_code = rel_code". | |
279 | " AND bsk_id = ?", | |
280 | $id); | |
281 | ||
282 | $self->{t_bsknr}->SetValue($rr->[0]); | |
283 | $self->{t_desc}->SetValue($rr->[1]); | |
284 | $self->{t_rel_code}->SetValue($rr->[2]); | |
285 | $self->{t_rel_desc}->SetValue($rr->[3]); | |
286 | $self->{dt_date}->SetValue($rr->[4]); | |
287 | # $self->{dt_date}->SetValue(_ISOtoWxD($rr->[4])); | |
288 | # $self->{dt_date}->SetRange(_ISOtoWxD($dbh->adm("begin")), _ISOtoWxD($dbh->adm("end"))); | |
289 | $self->{t_amount}->SetValue | |
290 | ($self->GetParent->{dbk_type} == DBKTYPE_INKOOP ? -$rr->[5] : $rr->[5]); | |
291 | $self->{t_ref}->SetValue($rr->[6]||""); | |
292 | ||
293 | my $sth = $dbh->sql_exec("SELECT bsr_nr, bsr_date, bsr_desc, bsr_amount, bsr_btw_id, bsr_acc_id". | |
294 | " FROM Boekstukregels". | |
295 | " WHERE bsr_bsk_id = ?". | |
296 | " ORDER BY bsr_nr", $self->{bsk_id}); | |
297 | ||
298 | my $gr = $self->{gr_bsr}; | |
299 | @bsrmap = (); | |
300 | my $row = 0; | |
301 | $gr->DeleteRows(0, $gr->GetNumberRows); | |
302 | my $tot = 0; | |
303 | ||
304 | while ( my $rr = $sth->fetch ) { | |
305 | my ($nr, $date, $desc, $amt, $btw, $acct) = @$rr; | |
306 | $nr =~ s/\s+$//; | |
307 | $amt = -$amt if $self->GetParent->{dbk_type} == DBKTYPE_VERKOOP; | |
308 | ||
309 | my $col = 0; | |
310 | my ($a, $b) = @{EB::Booking->norm_btw($amt, $btw)}; | |
311 | $gr->AppendRows(1); | |
312 | $gr->SetCellValue($row, $col, $nr); | |
313 | $gr->SetCellAlignment($row, $col, wxALIGN_RIGHT, wxALIGN_CENTER); | |
314 | $col++; | |
315 | $gr->SetCellValue($row, $col, $date); | |
316 | $gr->SetCellAlignment($row, $col, wxALIGN_LEFT, wxALIGN_CENTER); | |
317 | $col++; | |
318 | $gr->SetCellValue($row, $col, $desc); | |
319 | $gr->SetCellAlignment($row, $col, wxALIGN_LEFT, wxALIGN_CENTER); | |
320 | $col++; | |
321 | $gr->SetCellValue($row, $col, numfmt($a)); | |
322 | $gr->SetCellAlignment($row, $col, wxALIGN_RIGHT, wxALIGN_CENTER); | |
323 | $col++; | |
324 | $gr->SetCellValue($row, $col, numfmt($b)); | |
325 | $gr->SetCellAlignment($row, $col, wxALIGN_RIGHT, wxALIGN_CENTER); | |
326 | $col++; | |
327 | $gr->SetCellValue($row, $col, $acct . " " . $dbh->accts->{$acct}); | |
328 | $gr->SetCellAlignment($row, $col, wxALIGN_LEFT, wxALIGN_CENTER); | |
329 | ||
330 | $tot += $a; | |
331 | $row++; | |
332 | push(@bsrmap, $nr); | |
333 | } | |
334 | ||
335 | $self->resize_grid($gr); | |
336 | $self->{l_bsr_total}->SetLabel(__x("Totaal boekstukregels: {tot}", | |
337 | tot => numfmt($tot))); | |
338 | if ( $state->bsr_pin ) { | |
339 | $self->{cb_pin}->SetValue(1); | |
340 | } | |
341 | if ( $self->{bsr_shown} || $self->{cb_pin}->IsChecked ) { | |
342 | $self->{sz_main}->Show(1, $self->{cb_pin}->IsChecked); | |
343 | $self->{sz_main}->Show(2, 1); | |
344 | $self->{sz_main}->Layout; | |
345 | $self->{bsr_show} = 1; | |
346 | $self->advance($self->{_curr_row} = 0); | |
347 | } | |
348 | else { | |
349 | $self->{sz_main}->Show(1, 1); | |
350 | $self->{sz_main}->Show(2, 0); | |
351 | $self->{bsr_shown} = 0; | |
352 | $self->{sz_main}->Layout; | |
353 | } | |
354 | ||
355 | $self->{_sel_row} = 0; | |
356 | $self->{_curr_row} = 0; | |
357 | } | |
358 | ||
359 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnCancel <event_handler> | |
360 | sub OnCancel { | |
361 | my ($self, $event) = @_; | |
362 | $self->sizepos_save; | |
363 | warn "Event handler (OnCancel) not implemented"; | |
364 | $event->Skip; | |
365 | } | |
366 | ||
367 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnApply <event_handler> | |
368 | sub OnApply { | |
369 | my ($self, $event) = @_; | |
370 | $self->sizepos_save; | |
371 | warn "Event handler (OnApply) not implemented"; | |
372 | $event->Skip; | |
373 | } | |
374 | ||
375 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnDClick <event_handler> | |
376 | sub OnClick { | |
377 | my ($self, $event) = @_; | |
378 | $self = $self->GetParent; | |
379 | $self->{_sel_row} = $event->GetRow; | |
380 | $event->Skip; | |
381 | } | |
382 | ||
383 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnDClick <event_handler> | |
384 | sub OnDClick { | |
385 | my ($self, $event) = @_; | |
386 | # This event is delivered at the Grid. | |
387 | $self = $self->GetParent; | |
388 | my $row = $self->{_curr_row} = $event->GetRow; | |
389 | $self->advance($row); | |
390 | return if $self->{cb_pin}->IsChecked; | |
391 | $self->{sz_main}->Show(1, 0); | |
392 | $self->{sz_main}->Show(2, 1); | |
393 | $self->{bsr_shown} = 1; | |
394 | $self->{sz_main}->Layout; | |
395 | } | |
396 | ||
397 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnDate <event_handler> | |
398 | sub OnDate { | |
399 | my ($self, $event) = @_; | |
400 | ||
401 | warn "Event handler (OnDate) not implemented"; | |
402 | $event->Skip; | |
403 | } | |
404 | ||
405 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnForward <event_handler> | |
406 | sub OnForward { | |
407 | my ($self, $event) = @_; | |
408 | my $parent = $self->GetParent; | |
409 | $parent->advance(++$parent->{_curr_row}); | |
410 | if ( !$self->{cb_pin}->IsChecked && $self->{bsr_shown} ) { | |
411 | $self->{sz_main}->Show(1, 0); | |
412 | $self->{sz_main}->Show(2, 1); | |
413 | $self->{sz_main}->Layout; | |
414 | $self->advance($self->{_curr_row} = 0); | |
415 | } | |
416 | } | |
417 | ||
418 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnBackward <event_handler> | |
419 | sub OnBackward { | |
420 | my ($self, $event) = @_; | |
421 | my $parent = $self->GetParent; | |
422 | $parent->advance(--$parent->{_curr_row}); | |
423 | if ( !$self->{cb_pin}->IsChecked && $self->{bsr_shown} ) { | |
424 | $self->{sz_main}->Show(1, 0); | |
425 | $self->{sz_main}->Show(2, 1); | |
426 | $self->{sz_main}->Layout; | |
427 | $self->advance($self->{_curr_row} = 0); | |
428 | } | |
429 | } | |
430 | ||
431 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnAdd <event_handler> | |
432 | sub OnAdd { | |
433 | my ($self, $event) = @_; | |
434 | warn "Event handler (OnAdd) not implemented"; | |
435 | $event->Skip; | |
436 | } | |
437 | ||
438 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnDupl <event_handler> | |
439 | sub OnDupl { | |
440 | my ($self, $event) = @_; | |
441 | warn "Event handler (OnDupl) not implemented"; | |
442 | $event->Skip; | |
443 | } | |
444 | ||
445 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnChange <event_handler> | |
446 | sub OnChange { | |
447 | my ($self, $event) = @_; | |
448 | $self->advance($self->{_sel_row}); | |
449 | return if $self->{cb_pin}->IsChecked; | |
450 | $self->{sz_main}->Show(1, 0); | |
451 | $self->{sz_main}->Show(2, 1); | |
452 | $self->{bsr_shown} = 1; | |
453 | $self->{sz_main}->Layout; | |
454 | } | |
455 | ||
456 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnRemove <event_handler> | |
457 | sub OnRemove { | |
458 | my ($self, $event) = @_; | |
459 | warn "Event handler (OnRemove) not implemented"; | |
460 | $event->Skip; | |
461 | } | |
462 | ||
463 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnPin <event_handler> | |
464 | sub OnPin { | |
465 | my ($self, $event) = @_; | |
466 | if ( $self->{cb_pin}->IsChecked ) { | |
467 | $self->advance($self->{_curr_row}); | |
468 | $self->{sz_main}->Show(1,1); | |
469 | $self->{sz_main}->Show(2,1); | |
470 | $self->{bsr_shown} = 1; | |
471 | $self->{sz_main}->Layout; | |
472 | $state->bsr_pin(1); | |
473 | } | |
474 | else { | |
475 | $self->{sz_main}->Show(1,1); | |
476 | $self->{sz_main}->Show(2,0); | |
477 | $self->{bsr_shown} = 0; | |
478 | $self->{sz_main}->Layout; | |
479 | $state->bsr_pin(0); | |
480 | } | |
481 | ||
482 | } | |
483 | ||
484 | sub advance { | |
485 | my ($self, $row) = @_; | |
486 | $self->{b_r_backward}->Enable($row > 0); | |
487 | $self->{b_r_forward}->Enable($row < $self->{gr_bsr}->GetNumberRows-1); | |
488 | $self->{gr_bsr}->SelectRow($row); | |
489 | $self->_upd_bsr($self->{gr_bsr}->GetCellValue($row, 0), $self->{bsk_id}); | |
490 | } | |
491 | ||
492 | sub _upd_bsr { | |
493 | my ($self, $bsr_nr, $bsk_id) = @_; | |
494 | my @v = @{$dbh->do("SELECT bsr_date, bsr_desc, bsr_amount, bsr_btw_id, bsr_acc_id, bsr_btw_class". | |
495 | " FROM Boekstukregels". | |
496 | " WHERE bsr_nr = ?". | |
497 | " AND bsr_bsk_id = ?", | |
498 | $bsr_nr, $bsk_id)}; | |
499 | $self->{td_r_date}->SetValue(shift(@v)); | |
500 | $self->{t_r_desc}->SetValue(shift(@v)); | |
501 | ||
502 | $v[0] = -$v[0] if $self->GetParent->{dbk_type} == DBKTYPE_VERKOOP; | |
503 | my ($a, $b) = @{EB::Booking->norm_btw($v[0], $v[1])}; | |
504 | $self->{t_r_amount}->SetValue(shift(@v)); | |
505 | $self->{c_r_btw}->SetValue(shift(@v)); | |
506 | $self->_show_amount($a, $b); | |
507 | $self->{t_r_acct}->SetValue(shift(@v)); | |
508 | $self->{c_r_kstomz}->SetSelection | |
509 | ($v[0] & BTWKLASSE_BTW_BIT | |
510 | ? $v[0] & BTWKLASSE_KO_BIT | |
511 | ? 0 : 2 | |
512 | : 1); | |
513 | $self->{sz_bsr_staticbox}->SetLabel | |
514 | (__x("Details boekstukregel {bsr}", bsr => $bsr_nr)); | |
515 | } | |
516 | ||
517 | sub _show_amount { | |
518 | my ($self, $incl, $btw) = @_; | |
519 | if ( $self->{c_r_btw}->IsInclusive ) { | |
520 | $self->{l_amount1}->SetLabel(_T("Bedrag (incl.)")); | |
521 | $self->{l_amount2}->SetLabel(_T("Bedrag (excl.)")); | |
522 | $self->{t_r_amount2}->SetValue(numfmt($incl - $btw)); | |
523 | } | |
524 | else { | |
525 | $self->{l_amount1}->SetLabel(_T("Bedrag (excl.)")); | |
526 | $self->{l_amount2}->SetLabel(_T("Bedrag (incl.)")); | |
527 | $self->{t_r_amount2}->SetValue(numfmt($incl)); | |
528 | } | |
529 | $self->{t_r_btw}->SetValue($btw); | |
530 | } | |
531 | ||
532 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnRDate <event_handler> | |
533 | sub OnRDate { | |
534 | my ($self, $event) = @_; | |
535 | warn "Event handler (OnRDate) not implemented"; | |
536 | $event->Skip; | |
537 | } | |
538 | ||
539 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnRBTW <event_handler> | |
540 | sub OnRBTW { | |
541 | my ($self, $event) = @_; | |
542 | ||
543 | my $btw = $self->{c_r_btw}->GetValue; | |
544 | my $amt = $self->{t_r_amount}->GetValue; | |
545 | my ($a, $b) = @{EB::Booking->norm_btw($amt, $btw)}; | |
546 | $self->_show_amount($a, $b); | |
547 | } | |
548 | ||
549 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnRKstOmz <event_handler> | |
550 | sub OnRKstOmz { | |
551 | my ($self, $event) = @_; | |
552 | warn "Event handler (OnKstOmz) not implemented"; | |
553 | $event->Skip; | |
554 | } | |
555 | ||
556 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnRApply <event_handler> | |
557 | sub OnRApply { | |
558 | my ($self, $event) = @_; | |
559 | return if $self->{cb_pin}->IsChecked; | |
560 | $self->{sz_main}->Show(2,0); | |
561 | $self->{sz_main}->Show(1,1); | |
562 | $self->{bsr_shown} = 0; | |
563 | $self->{sz_main}->Layout; | |
564 | } | |
565 | ||
566 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnRCancel <event_handler> | |
567 | sub OnRCancel { | |
568 | my ($self, $event) = @_; | |
569 | return if $self->{cb_pin}->IsChecked; | |
570 | $self->{sz_main}->Show(2,0); | |
571 | $self->{sz_main}->Show(1,1); | |
572 | $self->{bsr_shown} = 0; | |
573 | $self->{sz_main}->Layout; | |
574 | } | |
575 | ||
576 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnRForward <event_handler> | |
577 | sub OnRForward { | |
578 | my ($self, $event) = @_; | |
579 | $self->advance(++$self->{_curr_row}); | |
580 | } | |
581 | ||
582 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnRBackward <event_handler> | |
583 | sub OnRBackward { | |
584 | my ($self, $event) = @_; | |
585 | $self->advance(--$self->{_curr_row}); | |
586 | } | |
587 | ||
588 | # end of class EB::Wx::Booking::IVPanel::BskPanel | |
589 | ||
590 | 1; |
0 | # perl | |
1 | ||
2 | package main; | |
3 | ||
4 | our $dbh; | |
5 | our $state; | |
6 | ||
7 | package EB::Wx::Booking::IVPanel::BskPanel; | |
8 | ||
9 | use Wx qw[:everything]; | |
10 | use base qw(Wx::Panel); | |
11 | use strict; | |
12 | ||
13 | use EB; | |
14 | use EB::Wx::UI::BTWInput; | |
15 | use EB::Wx::UI::AccInput; | |
16 | use EB::Wx::UI::AmountCtrl; | |
17 | use EB::Format; | |
18 | ||
19 | sub new { | |
20 | my( $self, $parent, $id) = @_; | |
21 | my ($title, $pos, $size, $style, $name); | |
22 | $parent = undef unless defined $parent; | |
23 | $id = -1 unless defined $id; | |
24 | my $title = ""; | |
25 | $pos = wxDefaultPosition unless defined $pos; | |
26 | $size = wxDefaultSize unless defined $size; | |
27 | ||
28 | # begin wxGlade: EB::Wx::Booking::IVPanel::BskPanel::new | |
29 | ||
30 | $style = wxTAB_TRAVERSAL | |
31 | unless defined $style; | |
32 | ||
33 | $self = $self->SUPER::new( $parent, $id, $pos, $size, $style, $name ); | |
34 | $self->{sz_bsr_staticbox} = Wx::StaticBox->new($self, -1, _T("Details boekstukregel") ); | |
35 | $self->{label_2} = Wx::StaticText->new($self, -1, _T("Datum"), wxDefaultPosition, wxDefaultSize, ); | |
36 | $self->{label_3} = Wx::StaticText->new($self, -1, _T("Omschrijving"), wxDefaultPosition, wxDefaultSize, ); | |
37 | $self->{td_r_date} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
38 | $self->{b_r_date} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("calendar.png", wxBITMAP_TYPE_ANY)); | |
39 | $self->{t_r_desc} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
40 | $self->{l_amount1} = Wx::StaticText->new($self, -1, _T("Bedrag"), wxDefaultPosition, wxDefaultSize, ); | |
41 | $self->{t_r_amount} = EB::Wx::UI::AmountCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_RIGHT); | |
42 | $self->{label_4} = Wx::StaticText->new($self, -1, _T("BTW"), wxDefaultPosition, wxDefaultSize, ); | |
43 | $self->{label_5} = Wx::StaticText->new($self, -1, _T("Soort"), wxDefaultPosition, wxDefaultSize, ); | |
44 | $self->{c_r_btw} = EB::Wx::UI::BTWInput->new($self, -1, wxDefaultPosition, wxDefaultSize, [], ); | |
45 | $self->{t_r_btw} = EB::Wx::UI::AmountCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_RIGHT); | |
46 | $self->{c_r_kstomz} = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, [_T("Kosten"), _T("Neutraal"), _T("Omzet")], ); | |
47 | $self->{l_amount2} = Wx::StaticText->new($self, -1, _T("Bedrag"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); | |
48 | $self->{label_10} = Wx::StaticText->new($self, -1, _T("Rekening"), wxDefaultPosition, wxDefaultSize, ); | |
49 | $self->{t_r_amount2} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_RIGHT); | |
50 | $self->{t_r_acct} = EB::Wx::UI::AccInput->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
51 | $self->{static_line_1} = Wx::StaticLine->new($self, -1, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL); | |
52 | $self->{b_r_accept} = Wx::Button->new($self, -1, _T("Toepassen")); | |
53 | $self->{b_r_cancel} = Wx::Button->new($self, -1, _T("Annuleren")); | |
54 | $self->{b_r_forward} = Wx::Button->new($self, -1, _T("Volgende")); | |
55 | $self->{b_r_backward} = Wx::Button->new($self, -1, _T("Vorige")); | |
56 | ||
57 | $self->__set_properties(); | |
58 | $self->__do_layout(); | |
59 | ||
60 | Wx::Event::EVT_BUTTON($self, $self->{b_r_date}->GetId, \&OnDate); | |
61 | Wx::Event::EVT_CHOICE($self, $self->{c_r_btw}->GetId, \&OnBTW); | |
62 | Wx::Event::EVT_CHOICE($self, $self->{c_r_kstomz}->GetId, \&OnKstOmz); | |
63 | Wx::Event::EVT_BUTTON($self, $self->{b_r_accept}->GetId, \&OnApply); | |
64 | Wx::Event::EVT_BUTTON($self, $self->{b_r_cancel}->GetId, \&OnCancel); | |
65 | Wx::Event::EVT_BUTTON($self, $self->{b_r_forward}->GetId, \&OnForward); | |
66 | Wx::Event::EVT_BUTTON($self, $self->{b_r_backward}->GetId, \&OnBackward); | |
67 | ||
68 | # end wxGlade | |
69 | return $self; | |
70 | ||
71 | } | |
72 | ||
73 | ||
74 | sub __set_properties { | |
75 | my $self = shift; | |
76 | ||
77 | # $self->{c_r_btw}->Destroy; | |
78 | # $self->{c_r_btw} = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, $btwchoices, ); | |
79 | ||
80 | $self->{td_r_date}->SetMinSize($self->{td_r_date}->ConvertDialogSizeToPixels(Wx::Size->new(44, -1))); | |
81 | $self->{t_r_amount}->SetMinSize($self->{t_r_amount}->ConvertDialogSizeToPixels(Wx::Size->new(60, -1))); | |
82 | $self->{t_r_btw}->SetMinSize($self->{t_r_btw}->ConvertDialogSizeToPixels(Wx::Size->new(60, -1))); | |
83 | ||
84 | # begin wxGlade: EB::Wx::Booking::IVPanel::BskPanel::__set_properties | |
85 | ||
86 | $self->{b_r_date}->SetSize($self->{b_r_date}->GetBestSize()); | |
87 | $self->{c_r_btw}->SetSelection(0); | |
88 | $self->{c_r_kstomz}->SetSelection(0); | |
89 | $self->{l_amount2}->Enable(0); | |
90 | $self->{t_r_amount2}->Enable(0); | |
91 | ||
92 | # end wxGlade | |
93 | ||
94 | ||
95 | } | |
96 | ||
97 | sub __do_layout { | |
98 | my $self = shift; | |
99 | ||
100 | # begin wxGlade: EB::Wx::Booking::IVPanel::BskPanel::__do_layout | |
101 | ||
102 | $self->{sizer_1} = Wx::BoxSizer->new(wxHORIZONTAL); | |
103 | $self->{sz_bsr}= Wx::StaticBoxSizer->new($self->{sz_bsr_staticbox}, wxHORIZONTAL); | |
104 | $self->{sz_main} = Wx::BoxSizer->new(wxVERTICAL); | |
105 | $self->{sizer_12} = Wx::BoxSizer->new(wxVERTICAL); | |
106 | $self->{sizer_13} = Wx::BoxSizer->new(wxHORIZONTAL); | |
107 | $self->{sizer_9} = Wx::BoxSizer->new(wxVERTICAL); | |
108 | $self->{grid_sizer_1} = Wx::FlexGridSizer->new(6, 2, 2, 5); | |
109 | $self->{grid_sizer_2} = Wx::FlexGridSizer->new(2, 3, 0, 5); | |
110 | $self->{sizer_2} = Wx::BoxSizer->new(wxVERTICAL); | |
111 | $self->{sizer_11} = Wx::BoxSizer->new(wxHORIZONTAL); | |
112 | $self->{grid_sizer_1}->Add($self->{label_2}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
113 | $self->{grid_sizer_1}->Add($self->{label_3}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
114 | $self->{sizer_11}->Add($self->{td_r_date}, 1, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
115 | $self->{sizer_11}->Add($self->{b_r_date}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
116 | $self->{grid_sizer_1}->Add($self->{sizer_11}, 1, wxEXPAND, 0); | |
117 | $self->{grid_sizer_1}->Add($self->{t_r_desc}, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
118 | $self->{sizer_2}->Add($self->{l_amount1}, 0, wxADJUST_MINSIZE, 0); | |
119 | $self->{sizer_2}->Add($self->{t_r_amount}, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
120 | $self->{grid_sizer_1}->Add($self->{sizer_2}, 1, wxEXPAND, 0); | |
121 | $self->{grid_sizer_2}->Add(1, 1, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
122 | $self->{grid_sizer_2}->Add($self->{label_4}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
123 | $self->{grid_sizer_2}->Add($self->{label_5}, 0, wxADJUST_MINSIZE, 0); | |
124 | $self->{grid_sizer_2}->Add($self->{c_r_btw}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
125 | $self->{grid_sizer_2}->Add($self->{t_r_btw}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
126 | $self->{grid_sizer_2}->Add($self->{c_r_kstomz}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
127 | $self->{grid_sizer_1}->Add($self->{grid_sizer_2}, 1, wxEXPAND, 0); | |
128 | $self->{grid_sizer_1}->Add($self->{l_amount2}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
129 | $self->{grid_sizer_1}->Add($self->{label_10}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
130 | $self->{grid_sizer_1}->Add($self->{t_r_amount2}, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
131 | $self->{grid_sizer_1}->Add($self->{t_r_acct}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
132 | $self->{grid_sizer_1}->AddGrowableCol(1); | |
133 | $self->{sizer_13}->Add($self->{grid_sizer_1}, 1, wxALL|wxEXPAND, 5); | |
134 | $self->{sizer_13}->Add($self->{static_line_1}, 0, wxRIGHT|wxBOTTOM|wxEXPAND, 5); | |
135 | $self->{sizer_9}->Add($self->{b_r_accept}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
136 | $self->{sizer_9}->Add($self->{b_r_cancel}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
137 | $self->{sizer_9}->Add($self->{b_r_forward}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
138 | $self->{sizer_9}->Add($self->{b_r_backward}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
139 | $self->{sizer_13}->Add($self->{sizer_9}, 0, wxEXPAND, 0); | |
140 | $self->{sizer_12}->Add($self->{sizer_13}, 0, wxEXPAND, 0); | |
141 | $self->{sz_main}->Add($self->{sizer_12}, 0, wxEXPAND, 0); | |
142 | $self->{sz_bsr}->Add($self->{sz_main}, 1, wxEXPAND, 0); | |
143 | $self->{sizer_1}->Add($self->{sz_bsr}, 1, wxEXPAND, 0); | |
144 | $self->SetSizer($self->{sizer_1}); | |
145 | $self->{sizer_1}->Fit($self); | |
146 | ||
147 | # end wxGlade | |
148 | } | |
149 | ||
150 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnDate <event_handler> | |
151 | sub OnDate { | |
152 | my ($self, $event) = @_; | |
153 | ||
154 | warn "Event handler (OnDate) not implemented"; | |
155 | $event->Skip; | |
156 | } | |
157 | ||
158 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnBTW <event_handler> | |
159 | sub OnBTW { | |
160 | my ($self, $event) = @_; | |
161 | ||
162 | my $btw = $self->{c_r_btw}->GetValue; | |
163 | my $amt = $self->{t_r_amount}->GetValue; | |
164 | my ($a, $b) = @{EB::Booking->norm_btw($amt, $btw)}; | |
165 | $self->_show_amount($a, $b); | |
166 | } | |
167 | ||
168 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnApply <event_handler> | |
169 | sub OnApply { | |
170 | my ($self, $event) = @_; | |
171 | return if $self->GetParent->{cb_pin}->IsChecked; | |
172 | $self->GetParent->{sz_main}->Show(2,0); | |
173 | $self->GetParent->{sz_main}->Show(1,1); | |
174 | $self->GetParent->{sz_main}->Layout; | |
175 | } | |
176 | ||
177 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnCancel <event_handler> | |
178 | sub OnCancel { | |
179 | my ($self, $event) = @_; | |
180 | return if $self->GetParent->{cb_pin}->IsChecked; | |
181 | $self->GetParent->{sz_main}->Show(2,0); | |
182 | $self->GetParent->{sz_main}->Show(1,1); | |
183 | $self->GetParent->{sz_main}->Layout; | |
184 | } | |
185 | ||
186 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnForward <event_handler> | |
187 | sub OnForward { | |
188 | my ($self, $event) = @_; | |
189 | $self->advance(++$self->GetParent->{_curr_row}); | |
190 | } | |
191 | ||
192 | sub advance { | |
193 | my ($self, $row) = @_; | |
194 | $self->{b_r_backward}->Enable($row > 0); | |
195 | $self->{b_r_forward}->Enable($row < $self->GetParent->{gr_bsr}->GetNumberRows-1); | |
196 | $self->GetParent->{gr_bsr}->SelectRow($row); | |
197 | $self->_upd_bsr($self->GetParent->{gr_bsr}->GetCellValue($row, 0), $self->GetParent->{bsk_id}); | |
198 | } | |
199 | ||
200 | sub _upd_bsr { | |
201 | my ($self, $bsr_nr, $bsk_id) = @_; | |
202 | my @v = @{$dbh->do("SELECT bsr_date, bsr_desc, bsr_amount, bsr_btw_id, bsr_acc_id, bsr_btw_class". | |
203 | " FROM Boekstukregels". | |
204 | " WHERE bsr_nr = ?". | |
205 | " AND bsr_bsk_id = ?", | |
206 | $bsr_nr, $bsk_id)}; | |
207 | $self->{td_r_date}->SetValue(shift(@v)); | |
208 | $self->{t_r_desc}->SetValue(shift(@v)); | |
209 | ||
210 | $v[0] = -$v[0] if $self->GetParent->GetParent->{dbk_type} == DBKTYPE_VERKOOP; | |
211 | my ($a, $b) = @{EB::Booking->norm_btw($v[0], $v[1])}; | |
212 | $self->{t_r_amount}->SetValue(shift(@v)); | |
213 | $self->{c_r_btw}->SetValue(shift(@v)); | |
214 | $self->_show_amount($a, $b); | |
215 | $self->{t_r_acct}->SetValue(shift(@v)); | |
216 | $self->{c_r_kstomz}->SetSelection | |
217 | ($v[0] & BTWKLASSE_BTW_BIT | |
218 | ? $v[0] & BTWKLASSE_KO_BIT | |
219 | ? 0 : 2 | |
220 | : 1); | |
221 | $self->{sz_bsr_staticbox}->SetLabel | |
222 | (__x("Details boekstukregel {bsr}", bsr => $bsr_nr)); | |
223 | } | |
224 | ||
225 | sub _show_amount { | |
226 | my ($self, $incl, $btw) = @_; | |
227 | if ( $self->{c_r_btw}->IsInclusive ) { | |
228 | $self->{l_amount1}->SetLabel(_T("Bedrag (incl.)")); | |
229 | $self->{l_amount2}->SetLabel(_T("Bedrag (excl.)")); | |
230 | $self->{t_r_amount2}->SetValue(numfmt($incl - $btw)); | |
231 | } | |
232 | else { | |
233 | $self->{l_amount1}->SetLabel(_T("Bedrag (excl.)")); | |
234 | $self->{l_amount2}->SetLabel(_T("Bedrag (incl.)")); | |
235 | $self->{t_r_amount2}->SetValue(numfmt($incl)); | |
236 | } | |
237 | $self->{t_r_btw}->SetValue($btw); | |
238 | } | |
239 | ||
240 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnBackward <event_handler> | |
241 | sub OnBackward { | |
242 | my ($self, $event) = @_; | |
243 | $self->advance(--$self->GetParent->{_curr_row}); | |
244 | } | |
245 | ||
246 | ||
247 | sub OnKstOmz { | |
248 | my ($self, $event) = @_; | |
249 | # wxGlade: EB::Wx::Booking::IVPanel::BskPanel::OnKstOmz <event_handler> | |
250 | ||
251 | warn "Event handler (OnKstOmz) not implemented"; | |
252 | $event->Skip; | |
253 | ||
254 | # end wxGlade | |
255 | } | |
256 | ||
257 | # end of class EB::Wx::Booking::IVPanel::BskPanel | |
258 | ||
259 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: IVPanel.pm,v 1.8 2009/10/19 10:28:23 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $dbh; | |
8 | our $app; | |
9 | ||
10 | use strict; | |
11 | ||
12 | package EB::Wx::Booking::IVPanel; | |
13 | ||
14 | use EB; | |
15 | use EB::Format; | |
16 | ||
17 | use Wx qw[:everything]; | |
18 | use base qw(Wx::Dialog); | |
19 | use base qw(EB::Wx::Window); | |
20 | use strict; | |
21 | ||
22 | # begin wxGlade: ::dependencies | |
23 | use Wx::Grid; | |
24 | # end wxGlade | |
25 | ||
26 | sub new { | |
27 | my( $self, $parent, $id, $title, $pos, $size, $type ) = @_; | |
28 | $parent = undef unless defined $parent; | |
29 | $id = -1 unless defined $id; | |
30 | $title = "" unless defined $title; | |
31 | $pos = wxDefaultPosition unless defined $pos; | |
32 | $size = wxDefaultSize unless defined $size; | |
33 | my $style; | |
34 | my $name = ""; | |
35 | ||
36 | # begin wxGlade: EB::Wx::Booking::IVPanel::new | |
37 | ||
38 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTHICK_FRAME | |
39 | unless defined $style; | |
40 | ||
41 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
42 | $self->{sz_staticbox} = Wx::StaticBox->new($self, -1, _T("Dagboek") ); | |
43 | $self->{gr_main} = Wx::Grid->new($self, -1); | |
44 | $self->{b_close} = Wx::Button->new($self, wxID_CLOSE, ""); | |
45 | ||
46 | $self->__set_properties(); | |
47 | $self->__do_layout(); | |
48 | ||
49 | Wx::Event::EVT_BUTTON($self, $self->{b_close}->GetId, \&OnClose); | |
50 | ||
51 | # end wxGlade | |
52 | ||
53 | Wx::Event::EVT_MENU($self, wxID_CLOSE, \&OnClose); | |
54 | Wx::Event::EVT_GRID_CELL_LEFT_DCLICK($self->{gr_main}, \&OnDClick); | |
55 | ||
56 | $self->SetTitle($title); | |
57 | return $self; | |
58 | ||
59 | } | |
60 | ||
61 | ||
62 | sub __set_properties { | |
63 | my $self = shift; | |
64 | ||
65 | # begin wxGlade: EB::Wx::Booking::IVPanel::__set_properties | |
66 | ||
67 | $self->SetTitle(_T("Inkoop/Verkoop Boeking")); | |
68 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(300, 168))); | |
69 | $self->{gr_main}->CreateGrid(0, 6); | |
70 | $self->{gr_main}->SetRowLabelSize(0); | |
71 | $self->{gr_main}->SetColLabelSize(22); | |
72 | $self->{gr_main}->EnableEditing(0); | |
73 | $self->{gr_main}->EnableDragRowSize(0); | |
74 | $self->{gr_main}->SetSelectionMode(wxGridSelectRows); | |
75 | $self->{gr_main}->SetColLabelValue(0, _T("Nr")); | |
76 | $self->{gr_main}->SetColLabelValue(1, _T("Datum")); | |
77 | $self->{gr_main}->SetColLabelValue(2, _T("Relatie")); | |
78 | $self->{gr_main}->SetColLabelValue(3, _T("Omschrijving")); | |
79 | $self->{gr_main}->SetColLabelValue(4, _T("Bedrag")); | |
80 | $self->{gr_main}->SetColLabelValue(5, _T("Voldaan")); | |
81 | $self->{b_close}->SetFocus(); | |
82 | ||
83 | # end wxGlade | |
84 | } | |
85 | ||
86 | sub __do_layout { | |
87 | my $self = shift; | |
88 | ||
89 | # begin wxGlade: EB::Wx::Booking::IVPanel::__do_layout | |
90 | ||
91 | $self->{sz_outer} = Wx::BoxSizer->new(wxHORIZONTAL); | |
92 | $self->{sz_main} = Wx::BoxSizer->new(wxVERTICAL); | |
93 | $self->{sz_buttons} = Wx::BoxSizer->new(wxHORIZONTAL); | |
94 | $self->{sz}= Wx::StaticBoxSizer->new($self->{sz_staticbox}, wxHORIZONTAL); | |
95 | $self->{sz}->Add($self->{gr_main}, 1, wxALL|wxEXPAND, 5); | |
96 | $self->{sz_main}->Add($self->{sz}, 1, wxEXPAND, 0); | |
97 | $self->{sz_buttons}->Add(5, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
98 | $self->{sz_buttons}->Add($self->{b_close}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
99 | $self->{sz_main}->Add($self->{sz_buttons}, 0, wxTOP|wxEXPAND, 5); | |
100 | $self->{sz_outer}->Add($self->{sz_main}, 1, wxALL|wxEXPAND, 5); | |
101 | $self->SetSizer($self->{sz_outer}); | |
102 | $self->Layout(); | |
103 | ||
104 | # end wxGlade | |
105 | } | |
106 | ||
107 | sub init { | |
108 | my ($self, $id, $desc, $type) = @_; | |
109 | $self->SetTitle(__x("Dagboek: {dbk}", dbk => $desc)); | |
110 | $self->{sz_staticbox}->SetLabel(__x("Dagboek: {dbk}", dbk => $desc)); | |
111 | $self->{dbk_id} = $id; | |
112 | $self->{dbk_desc} = $desc; | |
113 | $self->{dbk_type} = $type; | |
114 | $self->refresh; | |
115 | } | |
116 | ||
117 | my @bskmap; | |
118 | ||
119 | sub refresh { | |
120 | my ($self) = @_; | |
121 | ||
122 | my ($begin, $end) = @{$dbh->do("SELECT bky_begin, bky_end". | |
123 | " FROM Boekjaren". | |
124 | " WHERE bky_code = ?", | |
125 | $state->bky || | |
126 | $state->set("bky", $dbh->adm("bky")))}; | |
127 | ||
128 | my $sth = $dbh->sql_exec("SELECT bsk_id, bsk_nr, bsk_desc,". | |
129 | " bsk_date, bsk_amount, bsk_open, bsr_rel_code". | |
130 | " From Boekstukken, Boekstukregels". | |
131 | " WHERE bsk_dbk_id = ?". | |
132 | " AND bsr_bsk_id = bsk_id AND bsr_nr = 1". | |
133 | " AND bsk_date >= ? AND bsk_date <= ?". | |
134 | " ORDER BY bsk_date, bsk_id", | |
135 | $self->{dbk_id}, $begin, $end); | |
136 | ||
137 | my $gr = $self->{gr_main}; | |
138 | $gr->DeleteRows(0, $gr->GetNumberRows); | |
139 | ||
140 | @bskmap = (); | |
141 | my $row = 0; | |
142 | ||
143 | while ( my $rr = $sth->fetchrow_arrayref ) { | |
144 | my ($bsk_id, $bsk_nr, $bsk_desc, $bsk_date, $bsk_amount, $bsk_open, $bsr_rel) = @$rr; | |
145 | $bsk_nr =~ s/\s+$//; | |
146 | $bsr_rel =~ s/\s+$//; | |
147 | $bsk_amount = -$bsk_amount if $self->{dbk_type} == DBKTYPE_INKOOP; | |
148 | ||
149 | my $col = 0; | |
150 | $gr->AppendRows(1); | |
151 | $gr->SetCellValue($row, $col, $bsk_nr); | |
152 | $gr->SetCellAlignment($row, $col, wxALIGN_RIGHT, wxALIGN_CENTER); | |
153 | $col++; | |
154 | $gr->SetCellValue($row, $col, $bsk_date); | |
155 | $gr->SetCellAlignment($row, $col, wxALIGN_LEFT, wxALIGN_CENTER); | |
156 | $col++; | |
157 | $gr->SetCellValue($row, $col, $bsr_rel); | |
158 | $gr->SetCellAlignment($row, $col, wxALIGN_LEFT, wxALIGN_CENTER); | |
159 | $col++; | |
160 | $gr->SetCellValue($row, $col, $bsk_desc); | |
161 | $gr->SetCellAlignment($row, $col, wxALIGN_LEFT, wxALIGN_CENTER); | |
162 | $col++; | |
163 | $gr->SetCellValue($row, $col, numfmt($bsk_amount)); | |
164 | $gr->SetCellAlignment($row, $col, wxALIGN_RIGHT, wxALIGN_CENTER); | |
165 | $col++; | |
166 | $gr->SetCellValue($row, $col, $bsk_open ? _T("Nee") : _T("Ja")); | |
167 | $gr->SetCellAlignment($row, $col, wxALIGN_CENTER, wxALIGN_CENTER); | |
168 | $row++; | |
169 | push(@bskmap, $bsk_id); | |
170 | } | |
171 | ||
172 | $self->{_curr_row} = 0; | |
173 | $self->resize_grid($self->{gr_main}); | |
174 | } | |
175 | ||
176 | # wxGlade: EB::Wx::Booking::IVPanel::OnClose <event_handler> | |
177 | sub OnClose { | |
178 | my ($self, $event) = @_; | |
179 | # Remember position and size. | |
180 | $self->sizepos_save; | |
181 | # Disappear. | |
182 | $self->Show(0); | |
183 | } | |
184 | ||
185 | # wxGlade: EB::Wx::Booking::IVPanel::OnDClick <event_handler> | |
186 | sub OnDClick { | |
187 | my ($self, $event) = @_; | |
188 | my $row = $event->GetRow; | |
189 | $self = $self->GetParent; | |
190 | $self->{_curr_row} = $row; | |
191 | ||
192 | require EB::Wx::Booking::IVPanel::BskPanel; | |
193 | $self->{d_bskpanel} ||= EB::Wx::Booking::IVPanel::BskPanel->new | |
194 | ($self, -1, | |
195 | _T("Boekstuk"), | |
196 | wxDefaultPosition, | |
197 | wxDefaultSize, | |
198 | ); | |
199 | $self->{d_bskpanel}->sizepos_restore($self->{mew}."kw"); | |
200 | $self->advance($row); | |
201 | $self->{d_bskpanel}->Show(1); | |
202 | ||
203 | } | |
204 | ||
205 | sub advance { | |
206 | my ($self, $row) = @_; | |
207 | $self->{_curr_row} = $row; | |
208 | $self->{d_bskpanel}->init($bskmap[$row]); | |
209 | $self->{d_bskpanel}->refresh; | |
210 | $self->{d_bskpanel}->{b_forward}->Enable($row < $self->{gr_main}->GetNumberRows-1); | |
211 | $self->{d_bskpanel}->{b_backward}->Enable($row > 0); | |
212 | $self->{gr_main}->SelectRow($row); | |
213 | } | |
214 | ||
215 | # end of class EB::Wx::Booking::IVPanel | |
216 | ||
217 | 1; |
0 | #! perl -- -*- coding: utf-8 -*- | |
1 | ||
2 | use utf8; | |
3 | ||
4 | # $Id: EekBoek.pm,v 1.8 2009/10/15 10:05:03 jv Exp $ | |
5 | ||
6 | package main; | |
7 | ||
8 | our $state; | |
9 | ||
10 | package EB::Wx::Export::EekBoek; | |
11 | ||
12 | use Wx qw[:everything]; | |
13 | use base qw(Wx::Dialog); | |
14 | use strict; | |
15 | use EB::Wx::Window; | |
16 | use EB::Wx::UI::PeriodPanel; | |
17 | use File::Spec; | |
18 | ||
19 | sub new { | |
20 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
21 | $parent = undef unless defined $parent; | |
22 | $id = -1 unless defined $id; | |
23 | $title = "" unless defined $title; | |
24 | $pos = wxDefaultPosition unless defined $pos; | |
25 | $size = wxDefaultSize unless defined $size; | |
26 | $name = "" unless defined $name; | |
27 | ||
28 | # begin wxGlade: EB::Wx::Export::EekBoek::new | |
29 | ||
30 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTHICK_FRAME | |
31 | unless defined $style; | |
32 | ||
33 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
34 | $self->{sizer_4_staticbox} = Wx::StaticBox->new($self, -1, "Uitvoeropties" ); | |
35 | $self->{sizer_6_staticbox} = Wx::StaticBox->new($self, -1, "" ); | |
36 | $self->{p_period} = EB::Wx::UI::PeriodPanel->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
37 | $self->{label_1} = Wx::StaticText->new($self, -1, "Omschrijving", wxDefaultPosition, wxDefaultSize, ); | |
38 | $self->{t_desc} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
39 | $self->{cb_single} = Wx::CheckBox->new($self, -1, "Eén regel per boekstuk", wxDefaultPosition, wxDefaultSize, ); | |
40 | $self->{cb_bsknr} = Wx::CheckBox->new($self, -1, "Expliciteer boekstuknummers", wxDefaultPosition, wxDefaultSize, ); | |
41 | $self->{cb_explicit} = Wx::CheckBox->new($self, -1, "Expliciteer BTW", wxDefaultPosition, wxDefaultSize, ); | |
42 | $self->{cb_totals} = Wx::CheckBox->new($self, -1, "Totaalbedragen opnemen", wxDefaultPosition, wxDefaultSize, ); | |
43 | $self->{b_dir} = Wx::Button->new($self, -1, "Export naar Folder"); | |
44 | $self->{b_expfile} = Wx::Button->new($self, -1, "Export naar Bestand"); | |
45 | $self->{b_cancel} = Wx::Button->new($self, wxID_CANCEL, ""); | |
46 | ||
47 | $self->__set_properties(); | |
48 | $self->__do_layout(); | |
49 | ||
50 | Wx::Event::EVT_BUTTON($self, $self->{b_dir}->GetId, \&OnExpDir); | |
51 | Wx::Event::EVT_BUTTON($self, $self->{b_expfile}->GetId, \&OnExpFile); | |
52 | ||
53 | # end wxGlade | |
54 | ||
55 | $self->{p_period}->allow_all(2); | |
56 | $self->{p_period}->Enable(0); | |
57 | return $self; | |
58 | ||
59 | } | |
60 | ||
61 | ||
62 | sub __set_properties { | |
63 | my $self = shift; | |
64 | ||
65 | # begin wxGlade: EB::Wx::Export::EekBoek::__set_properties | |
66 | ||
67 | $self->SetTitle("Administratie exporteren"); | |
68 | $self->{cb_bsknr}->SetValue(1); | |
69 | $self->{cb_totals}->SetValue(1); | |
70 | ||
71 | # end wxGlade | |
72 | } | |
73 | ||
74 | sub __do_layout { | |
75 | my $self = shift; | |
76 | ||
77 | # begin wxGlade: EB::Wx::Export::EekBoek::__do_layout | |
78 | ||
79 | $self->{sizer_1} = Wx::BoxSizer->new(wxHORIZONTAL); | |
80 | $self->{sizer_2} = Wx::BoxSizer->new(wxVERTICAL); | |
81 | $self->{sizer_3} = Wx::BoxSizer->new(wxHORIZONTAL); | |
82 | $self->{sizer_4}= Wx::StaticBoxSizer->new($self->{sizer_4_staticbox}, wxHORIZONTAL); | |
83 | $self->{sizer_5} = Wx::BoxSizer->new(wxVERTICAL); | |
84 | $self->{sizer_7} = Wx::BoxSizer->new(wxHORIZONTAL); | |
85 | $self->{sizer_6}= Wx::StaticBoxSizer->new($self->{sizer_6_staticbox}, wxHORIZONTAL); | |
86 | $self->{sizer_6}->Add($self->{p_period}, 1, wxEXPAND, 0); | |
87 | $self->{sizer_2}->Add($self->{sizer_6}, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
88 | $self->{sizer_7}->Add($self->{label_1}, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
89 | $self->{sizer_7}->Add($self->{t_desc}, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
90 | $self->{sizer_5}->Add($self->{sizer_7}, 1, wxEXPAND, 0); | |
91 | $self->{sizer_5}->Add($self->{cb_single}, 0, wxADJUST_MINSIZE, 0); | |
92 | $self->{sizer_5}->Add($self->{cb_bsknr}, 0, wxADJUST_MINSIZE, 0); | |
93 | $self->{sizer_5}->Add($self->{cb_explicit}, 0, wxADJUST_MINSIZE, 0); | |
94 | $self->{sizer_5}->Add($self->{cb_totals}, 0, wxADJUST_MINSIZE, 0); | |
95 | $self->{sizer_4}->Add($self->{sizer_5}, 1, wxTOP|wxEXPAND, 2); | |
96 | $self->{sizer_2}->Add($self->{sizer_4}, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 5); | |
97 | $self->{sizer_2}->Add(2, 2, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
98 | $self->{sizer_3}->Add(2, 2, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
99 | $self->{sizer_3}->Add($self->{b_dir}, 0, wxLEFT|wxTOP|wxBOTTOM|wxEXPAND|wxADJUST_MINSIZE, 5); | |
100 | $self->{sizer_3}->Add($self->{b_expfile}, 0, wxLEFT|wxTOP|wxBOTTOM|wxEXPAND|wxADJUST_MINSIZE, 5); | |
101 | $self->{sizer_3}->Add($self->{b_cancel}, 0, wxALL|wxEXPAND|wxADJUST_MINSIZE, 5); | |
102 | $self->{sizer_2}->Add($self->{sizer_3}, 0, wxEXPAND, 0); | |
103 | $self->{sizer_1}->Add($self->{sizer_2}, 1, wxEXPAND, 0); | |
104 | $self->SetSizer($self->{sizer_1}); | |
105 | $self->{sizer_1}->Fit($self); | |
106 | $self->Layout(); | |
107 | ||
108 | # end wxGlade | |
109 | } | |
110 | ||
111 | sub init { | |
112 | } | |
113 | ||
114 | sub refresh { | |
115 | my ($self) = @_; | |
116 | $self->{p_period}->refresh; | |
117 | } | |
118 | ||
119 | sub DoExport { | |
120 | my ($self, $path, $file) = @_; | |
121 | ||
122 | my $sel = $self->{p_period}->GetValues; | |
123 | ||
124 | my $opts = {}; | |
125 | ||
126 | $opts->{boekjaar} = $sel->{period_panel_bky} | |
127 | if $sel->{period_panel_bky} && ! $sel->{period_panel_all}; | |
128 | ||
129 | if ( defined($path) ) { | |
130 | if ( -d $path ) { | |
131 | my $inuse = 0; | |
132 | for ( qw(schema.dat opening.eb muaties.eb relaties.eb) ) { | |
133 | $inuse++ if -e File::Spec->catfile($path, $_); | |
134 | } | |
135 | if ( $inuse ) { | |
136 | my $ret = EB::Wx::MessageDialog | |
137 | ($self, | |
138 | "De opgegeven folder bevat al exportinformatie.\n". | |
139 | "Moet deze worden overschreven?", | |
140 | "Folder in gebruik", | |
141 | wxICON_ERROR|wxYES_NO|wxNO_DEFAULT); | |
142 | return unless $ret == wxID_YES; | |
143 | } | |
144 | } | |
145 | else { | |
146 | mkdir($path); | |
147 | } | |
148 | $opts->{dir} = $path; | |
149 | } | |
150 | else { | |
151 | $opts->{file} = $path = $file; | |
152 | } | |
153 | ||
154 | # $opts->{boekjaar} = ; | |
155 | $opts->{desc} = $self->{t_desc}->GetValue; | |
156 | $opts->{single} = $self->{cb_single}->GetValue; | |
157 | $opts->{bsknr} = $self->{cb_bsknr}->GetValue; | |
158 | $opts->{explicit} = $self->{cb_explicit}->GetValue; | |
159 | $opts->{totals} = $self->{cb_totals}->GetValue; | |
160 | ||
161 | require EB::Export; | |
162 | eval { EB::Export->export($opts) }; | |
163 | if ( $@ ) { | |
164 | Wx::LogMessage($@); | |
165 | EB::Wx::MessageDialog | |
166 | ($self, | |
167 | "Fout tijdens het exporteren:\n".$@, | |
168 | "Fout tijdens het exporteren", | |
169 | wxICON_ERROR|wxOK); | |
170 | return; | |
171 | } | |
172 | else { | |
173 | Wx::LogMessage("Export: $path"); | |
174 | EB::Wx::MessageDialog | |
175 | ($self, | |
176 | "De administratie is succesvol geëxporteerd.", | |
177 | "Succes", | |
178 | wxICON_INFORMATION|wxOK, | |
179 | ); | |
180 | if ( $opts->{dir} ) { | |
181 | $state->expdir($path); | |
182 | } | |
183 | else { | |
184 | $state->expfile($path); | |
185 | } | |
186 | } | |
187 | return 1; | |
188 | } | |
189 | ||
190 | # wxGlade: EB::Wx::Export::EekBoek::OnExpDir <event_handler> | |
191 | sub OnExpDir { | |
192 | my ($self, $event) = @_; | |
193 | ||
194 | my $dd = Wx::DirDialog->new | |
195 | ($self, | |
196 | "Exporteer naar folder", | |
197 | $state->expdir || "", | |
198 | wxDD_DEFAULT_STYLE, | |
199 | wxDefaultPosition, | |
200 | ); | |
201 | my $res = $dd->ShowModal; | |
202 | if ( $res == wxID_OK && $self->DoExport($dd->GetPath, undef) ) { | |
203 | $dd->Destroy; | |
204 | $self->Destroy; | |
205 | } | |
206 | } | |
207 | ||
208 | # wxGlade: EB::Wx::Export::EekBoek::OnExpFile <event_handler> | |
209 | sub OnExpFile { | |
210 | my ($self, $event) = @_; | |
211 | ||
212 | my $dd = Wx::FileDialog->new | |
213 | ($self, | |
214 | "Exporteer naar bestand", | |
215 | "", | |
216 | $state->expfile || "", | |
217 | "EekBoek export files (*.ebz)|*.ebz", | |
218 | wxFD_SAVE|wxFD_OVERWRITE_PROMPT, | |
219 | wxDefaultPosition, | |
220 | ); | |
221 | my $res = $dd->ShowModal; | |
222 | if ( $res == wxID_OK && $self->DoExport(undef, $dd->GetPath) ) { | |
223 | $dd->Destroy; | |
224 | $self->Destroy; | |
225 | } | |
226 | ||
227 | } | |
228 | ||
229 | # end of class EB::Wx::Export::EekBoek | |
230 | ||
231 | 1; |
0 | #! perl -- -*- coding: utf-8 -*- | |
1 | ||
2 | use utf8; | |
3 | ||
4 | # $Id: XAF.pm,v 1.2 2009/10/14 21:14:02 jv Exp $ | |
5 | ||
6 | package main; | |
7 | ||
8 | our $state; | |
9 | ||
10 | package EB::Wx::Export::XAF; | |
11 | ||
12 | use Wx qw[:everything]; | |
13 | use base qw(Wx::Dialog); | |
14 | use strict; | |
15 | use EB::Wx::Window; | |
16 | use EB::Wx::UI::PeriodPanel; | |
17 | ||
18 | sub new { | |
19 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
20 | $parent = undef unless defined $parent; | |
21 | $id = -1 unless defined $id; | |
22 | $title = "" unless defined $title; | |
23 | $pos = wxDefaultPosition unless defined $pos; | |
24 | $size = wxDefaultSize unless defined $size; | |
25 | $name = "" unless defined $name; | |
26 | ||
27 | # begin wxGlade: EB::Wx::Export::XAF::new | |
28 | ||
29 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTHICK_FRAME | |
30 | unless defined $style; | |
31 | ||
32 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
33 | $self->{sz_opts_staticbox} = Wx::StaticBox->new($self, -1, "Uitvoeropties" ); | |
34 | $self->{sizer_6_staticbox} = Wx::StaticBox->new($self, -1, "" ); | |
35 | $self->{p_period} = EB::Wx::UI::PeriodPanel->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
36 | $self->{cb_single} = Wx::CheckBox->new($self, -1, "Eén regel per boekstuk", wxDefaultPosition, wxDefaultSize, ); | |
37 | $self->{cb_bsknr} = Wx::CheckBox->new($self, -1, "Expliciteer boekstuknummers", wxDefaultPosition, wxDefaultSize, ); | |
38 | $self->{cb_explicit} = Wx::CheckBox->new($self, -1, "Expliciteer BTW", wxDefaultPosition, wxDefaultSize, ); | |
39 | $self->{cb_totals} = Wx::CheckBox->new($self, -1, "Totaalbedragen opnemen", wxDefaultPosition, wxDefaultSize, ); | |
40 | $self->{b_expfile} = Wx::Button->new($self, wxID_SAVE, ""); | |
41 | $self->{b_cancel} = Wx::Button->new($self, wxID_CANCEL, ""); | |
42 | ||
43 | $self->__set_properties(); | |
44 | $self->__do_layout(); | |
45 | ||
46 | Wx::Event::EVT_BUTTON($self, $self->{b_expfile}->GetId, \&OnExpFile); | |
47 | ||
48 | # end wxGlade | |
49 | ||
50 | $self->{p_period}->allow_all(0); | |
51 | $self->{p_period}->allow_fromto(0); | |
52 | # $self->{p_period}->Enable(0); | |
53 | return $self; | |
54 | ||
55 | } | |
56 | ||
57 | ||
58 | sub __set_properties { | |
59 | my $self = shift; | |
60 | ||
61 | # begin wxGlade: EB::Wx::Export::XAF::__set_properties | |
62 | ||
63 | $self->SetTitle("Aanmaken XML Audit File"); | |
64 | $self->{cb_bsknr}->SetValue(1); | |
65 | $self->{cb_totals}->SetValue(1); | |
66 | ||
67 | # end wxGlade | |
68 | } | |
69 | ||
70 | sub __do_layout { | |
71 | my $self = shift; | |
72 | ||
73 | # begin wxGlade: EB::Wx::Export::XAF::__do_layout | |
74 | ||
75 | $self->{sizer_1} = Wx::BoxSizer->new(wxHORIZONTAL); | |
76 | $self->{sz_main} = Wx::BoxSizer->new(wxVERTICAL); | |
77 | $self->{sizer_3} = Wx::BoxSizer->new(wxHORIZONTAL); | |
78 | $self->{sz_opts}= Wx::StaticBoxSizer->new($self->{sz_opts_staticbox}, wxHORIZONTAL); | |
79 | $self->{sizer_5} = Wx::BoxSizer->new(wxVERTICAL); | |
80 | $self->{sizer_6}= Wx::StaticBoxSizer->new($self->{sizer_6_staticbox}, wxHORIZONTAL); | |
81 | $self->{sizer_6}->Add($self->{p_period}, 1, wxEXPAND, 0); | |
82 | $self->{sz_main}->Add($self->{sizer_6}, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
83 | $self->{sizer_5}->Add($self->{cb_single}, 0, wxADJUST_MINSIZE, 0); | |
84 | $self->{sizer_5}->Add($self->{cb_bsknr}, 0, wxADJUST_MINSIZE, 0); | |
85 | $self->{sizer_5}->Add($self->{cb_explicit}, 0, wxADJUST_MINSIZE, 0); | |
86 | $self->{sizer_5}->Add($self->{cb_totals}, 0, wxADJUST_MINSIZE, 0); | |
87 | $self->{sz_opts}->Add($self->{sizer_5}, 0, wxTOP|wxEXPAND, 2); | |
88 | $self->{sz_main}->Add($self->{sz_opts}, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 5); | |
89 | $self->{sz_main}->Add(2, 2, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
90 | $self->{sizer_3}->Add(2, 2, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
91 | $self->{sizer_3}->Add($self->{b_expfile}, 0, wxLEFT|wxTOP|wxBOTTOM|wxEXPAND|wxADJUST_MINSIZE, 5); | |
92 | $self->{sizer_3}->Add($self->{b_cancel}, 0, wxALL|wxEXPAND|wxADJUST_MINSIZE, 5); | |
93 | $self->{sz_main}->Add($self->{sizer_3}, 0, wxEXPAND, 0); | |
94 | $self->{sizer_1}->Add($self->{sz_main}, 1, wxEXPAND, 0); | |
95 | $self->SetSizer($self->{sizer_1}); | |
96 | $self->{sizer_1}->Fit($self); | |
97 | $self->Layout(); | |
98 | ||
99 | # end wxGlade | |
100 | ||
101 | $self->{sz_main}->Show($self->{sz_opts}, 0); | |
102 | $self->Layout; | |
103 | ||
104 | } | |
105 | ||
106 | sub init { | |
107 | } | |
108 | ||
109 | sub refresh { | |
110 | my ($self) = @_; | |
111 | $self->{p_period}->refresh; | |
112 | } | |
113 | ||
114 | sub DoExport { | |
115 | my ($self, $path) = @_; | |
116 | ||
117 | my $sel = $self->{p_period}->GetValues; | |
118 | ||
119 | my $opts = {}; | |
120 | ||
121 | $opts->{boekjaar} = $sel->{period_panel_bky} | |
122 | if $sel->{period_panel_bky} && ! $sel->{period_panel_all}; | |
123 | ||
124 | $opts->{xaf} = $path; | |
125 | ||
126 | require EB::Export::XAF; | |
127 | eval { EB::Export::XAF->export($opts) }; | |
128 | if ( $@ ) { | |
129 | Wx::LogMessage($@); | |
130 | EB::Wx::MessageDialog | |
131 | ($self, | |
132 | "Fout tijdens het exporteren:\n".$@, | |
133 | "Fout tijdens het exporteren", | |
134 | wxICON_ERROR|wxOK); | |
135 | return; | |
136 | } | |
137 | else { | |
138 | Wx::LogMessage("Export: $path"); | |
139 | EB::Wx::MessageDialog | |
140 | ($self, | |
141 | "De XML Audit File is succesvol aangemaakt.", | |
142 | "Succes", | |
143 | wxICON_INFORMATION|wxOK, | |
144 | ); | |
145 | $state->expxaf($path); | |
146 | } | |
147 | return 1; | |
148 | } | |
149 | ||
150 | # wxGlade: EB::Wx::Export::XAF::OnExpFile <event_handler> | |
151 | sub OnExpFile { | |
152 | my ($self, $event) = @_; | |
153 | ||
154 | my $dd = Wx::FileDialog->new | |
155 | ($self, | |
156 | "Aanmaken XML Audit File", | |
157 | "", | |
158 | $state->expxaf || "", | |
159 | "XML Audit files (*.xaf)|*.xaf", | |
160 | wxFD_SAVE|wxFD_OVERWRITE_PROMPT, | |
161 | wxDefaultPosition, | |
162 | ); | |
163 | my $res = $dd->ShowModal; | |
164 | if ( $res == wxID_OK && $self->DoExport($dd->GetPath) ) { | |
165 | $dd->Destroy; | |
166 | $self->Destroy; | |
167 | } | |
168 | ||
169 | } | |
170 | ||
171 | # end of class EB::Wx::Export::XAF | |
172 | ||
173 | 1; |
9 | 9 | use EekBoek; |
10 | 10 | use EB; |
11 | 11 | use EB::Tools::MiniAdm; |
12 | use EB::Wx::Main; | |
13 | 12 | use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); |
14 | 13 | |
15 | 14 | our $app; |
98 | 97 | |
99 | 98 | # end wxGlade |
100 | 99 | |
100 | # Set defaults for code and db name. | |
101 | OnSelectAdmName( $self->{wiz} ); | |
102 | ||
101 | 103 | my $prev; |
102 | 104 | for ( my $i = 0; ; $i++ ) { |
103 | 105 | my $page = sprintf("wiz_p%02d", $i); |
110 | 112 | |
111 | 113 | @ebz = glob( libfile("schema/*.ebz") ); |
112 | 114 | |
115 | my $i = 0; | |
113 | 116 | foreach my $ebz ( @ebz ) { |
114 | 117 | require Archive::Zip; |
115 | 118 | my $zip = Archive::Zip->new(); |
125 | 128 | $desc = $1 if $ebz =~ m/([^\\\/]+)\.ebz$/i; |
126 | 129 | } |
127 | 130 | $self->{ch_template}->Append($desc); |
131 | $i++; | |
132 | if ( $ebz =~ /\/sample(db)?\.ebz$/ ) { | |
133 | $self->{ch_template}->SetSelection($i); | |
134 | } | |
128 | 135 | } |
129 | 136 | unshift (@ebz, undef ); # skeleton |
130 | 137 | |
131 | 138 | # Enumerate DB drivers. |
132 | 139 | my $drivers = find_db_drivers(); |
133 | my $def = 0; | |
134 | 140 | $self->{ch_db_driver}->Delete(0) while $self->{ch_db_driver}->GetCount; |
135 | 141 | foreach ( sort keys %$drivers ) { |
136 | 142 | push( @db_drivers, $_ ); |
174 | 180 | my ( $pkg, $opts ) = @_; |
175 | 181 | chdir($opts->{admdir}); |
176 | 182 | my @files = glob( "*/" . $cfg->std_config ); |
183 | my @adm_desc; | |
177 | 184 | foreach ( sort @files ) { |
178 | 185 | push( @adm_dirs, dirname($_) ); |
186 | my $desc = $adm_dirs[-1]; | |
187 | if ( open( my $fd, '<:utf8', $adm_dirs[-1]."/opening.eb" ) ) { | |
188 | while ( <$fd> ) { | |
189 | next unless /adm_naam\s+"(.+)"/; | |
190 | $desc = $1; | |
191 | last; | |
192 | } | |
193 | close($fd); | |
194 | } | |
195 | push( @adm_desc, $desc); | |
179 | 196 | } |
180 | 197 | |
181 | 198 | my $ret = wxID_NEW; |
184 | 201 | my $d = EB::Wx::IniWiz::OpenDialog->new( undef, -1, |
185 | 202 | _T("Kies"), |
186 | 203 | wxDefaultPosition, wxDefaultSize, ); |
187 | $d->init( \@adm_dirs ); | |
204 | $d->init( \@adm_desc ); | |
188 | 205 | if ( ($ret = $d->ShowModal) == wxID_OK ) { |
189 | 206 | chdir( $adm_dirs[ $d->GetSelection ] ) || die("chdir"); |
190 | 207 | } |
497 | 514 | # Using EB::Main->run crashes ... |
498 | 515 | # Need to run ebshell externally. |
499 | 516 | |
500 | my @cmd = ( "ebshell", "--init" ); | |
517 | my @cmd = ( $^X, "-S", "ebshell", "--init" ); | |
501 | 518 | my $ret = system(@cmd); |
502 | 519 | $self->{t_main}->AppendText(_T( $ret ? "Mislukt" : "Gereed")."\n"); |
503 | 520 | } |
593 | 610 | |
594 | 611 | sub run { |
595 | 612 | my ( $self, $opts ) = @_; |
596 | my $admdir = $opts->{admdir} ||= $cfg->user_dir("admdir"); | |
613 | my $admdir = $opts->{admdir} || $cfg->val(qw(general admdir), $cfg->user_dir("admdir")); | |
597 | 614 | $runeb = 1; |
598 | ||
615 | $admdir =~ s/\$([A-Z_]+)/$ENV{$1}/ge; | |
599 | 616 | if ( $admdir ) { |
600 | 617 | mkdir($admdir) unless -d $admdir; |
601 | 618 | die("No admdir $admdir: $!") unless -d $admdir; |
602 | 619 | } |
603 | ||
620 | $opts->{admdir} = $admdir; | |
604 | 621 | $runeb = 0; |
605 | 622 | |
606 | 623 | no warnings 'redefine'; |
0 | #! perl -- -*- coding: utf-8 -*- | |
1 | ||
2 | use utf8; | |
3 | ||
4 | # RCS Id : $Id: Main.pm,v 1.11 2009/10/28 22:10:44 jv Exp $ | |
5 | # Author : Johan Vromans | |
6 | # Created On : Sun Jul 31 23:35:10 2005 | |
7 | # Last Modified By: Johan Vromans | |
8 | # Last Modified On: Wed Oct 28 23:36:58 2009 | |
9 | # Update Count : 364 | |
10 | # Status : Unknown, Use with caution! | |
11 | ||
12 | ################ Common stuff ################ | |
13 | ||
14 | package main; | |
15 | ||
16 | our $cfg; | |
17 | our $state; | |
18 | our $dbh; | |
19 | our $app; | |
20 | use EB::Wx::FakeApp; | |
21 | ||
22 | package EB::Wx::Main; | |
23 | ||
24 | use strict; | |
25 | use warnings; | |
26 | ||
27 | # Save options array (for restart). | |
28 | my @opts; BEGIN { @opts = @ARGV } | |
29 | ||
30 | use EekBoek; | |
31 | use EB; | |
32 | use EB::Config (); | |
33 | use EB::DB; | |
34 | use Getopt::Long 2.13; | |
35 | ||
36 | ################ The Process ################ | |
37 | ||
38 | use Wx 0.74 qw[:everything]; | |
39 | sub Wx::wxTHICK_FRAME() { 0 } | |
40 | use EB::Wx::Window; | |
41 | use POSIX qw(locale_h); | |
42 | use Wx::Locale; # WHY? | |
43 | use File::Basename (); | |
44 | use File::Spec (); | |
45 | use File::HomeDir (); | |
46 | ||
47 | my $app_dir; | |
48 | my $app_state; | |
49 | ||
50 | our $restart = 0; | |
51 | ||
52 | use base qw(Wx::App); | |
53 | ||
54 | sub OnInit { | |
55 | my( $self ) = shift; | |
56 | ||
57 | my $locale = Wx::Locale->new( Wx::Locale::GetSystemLanguage ); | |
58 | ||
59 | Wx::InitAllImageHandlers(); | |
60 | ||
61 | require EB::Wx::MainFrame; | |
62 | my $frame = EB::Wx::MainFrame->new | |
63 | (undef, undef, $EekBoek::PACKAGE, | |
64 | wxDefaultPosition, wxDefaultSize, | |
65 | undef, | |
66 | $EekBoek::PACKAGE); | |
67 | ||
68 | $self->SetTopWindow($frame); | |
69 | $app->{TOP} = $frame; | |
70 | $frame->sizepos_restore("mainw"); | |
71 | $frame->Show(1); | |
72 | showtips($state->showtips); | |
73 | ||
74 | # $frame->command($precmd) if $precmd; | |
75 | ||
76 | return 1; | |
77 | } | |
78 | ||
79 | sub OnClose { | |
80 | goto &OnExit; | |
81 | } | |
82 | ||
83 | sub OnExit { | |
84 | my ($self) = @_; | |
85 | app_exit(); | |
86 | } | |
87 | ||
88 | sub app_exit { | |
89 | store_state(); | |
90 | if ( $restart ) { # for development | |
91 | warn("=== restarting ===\n"); | |
92 | exec($^X, $0, @opts); | |
93 | } | |
94 | } | |
95 | ||
96 | sub showtips { | |
97 | if ( shift ) { | |
98 | # require EB::Wx::Tools::TipProvider; | |
99 | # my $t = EB::Wx::Tools::TipProvider->new($state->lasttip); | |
100 | my $t = Wx::CreateFileTipProvider(EB::findlib("Wx/tips.txt"), $state->lasttip); | |
101 | $state->showtips(Wx::ShowTip($app->{TOP}, $t, $state->showtips) || 0); | |
102 | $state->lasttip($t->GetCurrentTip); | |
103 | } | |
104 | } | |
105 | ||
106 | ################ State ################ | |
107 | ||
108 | sub init_state { | |
109 | use EB::Wx::State; | |
110 | $state = EB::Wx::State->new; | |
111 | $state->load($app_state) if -f $app_state; | |
112 | } | |
113 | ||
114 | sub store_state { | |
115 | $state->store($app_state); | |
116 | } | |
117 | ||
118 | ################ Run ################ | |
119 | ||
120 | sub run { | |
121 | ||
122 | my ( $pkg, $opts ) = @_; | |
123 | $opts = {} unless defined $opts; | |
124 | ||
125 | binmode(STDOUT, ":encoding(utf8)"); | |
126 | binmode(STDERR, ":encoding(utf8)"); | |
127 | ||
128 | # Command line options. | |
129 | $opts = | |
130 | { | |
131 | #config, # config file | |
132 | #nostdconf, # skip standard configs | |
133 | #define, # config overrides | |
134 | ||
135 | verbose => 0, # verbose processing | |
136 | ||
137 | # Development options (not shown with -help). | |
138 | debug => 0, # debugging | |
139 | trace => 0, # trace (show process) | |
140 | test => 0, # test mode. | |
141 | ||
142 | # Let supplied options override. | |
143 | %$opts, | |
144 | }; | |
145 | ||
146 | # Process command line options. | |
147 | app_options($opts); | |
148 | ||
149 | # Post-processing. | |
150 | $opts->{trace} |= ($opts->{debug} || $opts->{test}); | |
151 | ||
152 | # Initialize config. | |
153 | EB::Config->init_config( { app => $EekBoek::PACKAGE, %$opts } ); | |
154 | ||
155 | if ( $opts->{printconfig} ) { | |
156 | $cfg->printconf( \@ARGV ); | |
157 | exit; | |
158 | } | |
159 | ||
160 | $app_dir = $cfg->user_dir; | |
161 | mkdir($app_dir) unless -d $app_dir; | |
162 | $app_state = $cfg->user_dir("ebgui_state"); | |
163 | init_state(); | |
164 | ||
165 | Wx::InitAllImageHandlers(); | |
166 | ||
167 | if ( $state->showsplash ) { | |
168 | require Wx::Perl::SplashFast; | |
169 | Wx::Perl::SplashFast->new(EB::findlib("Wx/icons/ebsplash.jpg"), 3000); | |
170 | sleep(2); | |
171 | } | |
172 | ||
173 | $state->set(verbose => $opts->{verbose}); | |
174 | $state->set(trace => $opts->{trace}); | |
175 | $state->set(debug => $opts->{debug}); | |
176 | ||
177 | #### WHAT THE ***** IS GOING ON HERE???? | |
178 | *Fcntl::O_NOINHERIT = sub() { 0 }; | |
179 | *Fcntl::O_EXLOCK = sub() { 0 }; | |
180 | *Fcntl::O_TEMPORARY = sub() { 0 }; | |
181 | ||
182 | unless ( $opts->{nowizard} || $opts->{config} ) { | |
183 | require EB::Wx::IniWiz; | |
184 | EB::Wx::IniWiz->run($opts); # sets $opts->{runeb} | |
185 | return unless $opts->{runeb}; | |
186 | undef $cfg; | |
187 | EB::Config->init_config( { app => $EekBoek::PACKAGE, %$opts } ); | |
188 | } | |
189 | ||
190 | my $dataset = $cfg->val(qw(database name)); | |
191 | if ( !$dataset ) { | |
192 | die(_T("Geen dataset opgegeven.". | |
193 | " Specificeer een dataset in de configuratiefile."). | |
194 | "\n"); | |
195 | } | |
196 | $cfg->newval(qw(database name), $dataset); | |
197 | ||
198 | $dbh = EB::DB->new(trace => $opts->{trace} || $ENV{EB_SQL_TRACE}); | |
199 | ||
200 | if ( $state->lastdb ne $dataset ) { | |
201 | $state->set(lastdb => $dataset); | |
202 | $state->set(bky => $dbh->adm("bky")); | |
203 | } | |
204 | ||
205 | my $app = EB::Wx::Main->new(); | |
206 | $dbh->dbh->{HandleError} = sub { my $a = shift; | |
207 | $a =~ s/\n+$//; | |
208 | Wx::LogMessage($a); | |
209 | return 0; | |
210 | }; | |
211 | $app->MainLoop(); | |
212 | } | |
213 | ||
214 | # Since Wx::Bitmap cannot be convinced to use a search path, we | |
215 | # need a stronger method... | |
216 | my $wxbitmapnew = \&Wx::Bitmap::new; | |
217 | no warnings 'redefine'; | |
218 | *Wx::Bitmap::new = sub { | |
219 | # Only handle Wx::Bitmap->new(file, type) case. | |
220 | goto &$wxbitmapnew if @_ != 3 || -f $_[1]; | |
221 | my ($self, @rest) = @_; | |
222 | $rest[0] = EB::findlib("Wx/icons/".File::Basename::basename($rest[0])); | |
223 | $wxbitmapnew->($self, @rest); | |
224 | }; | |
225 | use warnings 'redefine'; | |
226 | ||
227 | ||
228 | ################ Subroutines ################ | |
229 | ||
230 | sub app_options { | |
231 | my ( $opts ) = @_; | |
232 | my $help = 0; # handled locally | |
233 | my $ident = 0; # handled locally | |
234 | ||
235 | # Process options, if any. | |
236 | # Make sure defaults are set before returning! | |
237 | return unless @ARGV > 0; | |
238 | ||
239 | Getopt::Long::Configure(qw(no_ignore_case)); | |
240 | ||
241 | if ( !GetOptions( $opts, | |
242 | 'define|D=s%', | |
243 | 'nostdconf|X', | |
244 | 'config|f=s', | |
245 | 'admdir=s', | |
246 | 'open=s', | |
247 | 'printconfig|P', | |
248 | 'ident' => \$ident, | |
249 | 'verbose', | |
250 | 'trace!', | |
251 | 'help|?', | |
252 | 'debug', | |
253 | ) or $help ) | |
254 | { | |
255 | app_usage(2); | |
256 | } | |
257 | app_usage(2) if @ARGV && !$opts->{printconfig}; | |
258 | app_ident() if $ident; | |
259 | } | |
260 | ||
261 | sub app_ident { | |
262 | return; | |
263 | print STDERR (__x("Dit is {pkg} [{name} {version}]", | |
264 | pkg => $EekBoek::PACKAGE, | |
265 | name => "GUI", | |
266 | version => $EekBoek::VERSION) . "\n"); | |
267 | } | |
268 | ||
269 | sub app_usage { | |
270 | my ($exit) = @_; | |
271 | app_ident(); | |
272 | warn <<EndOfUsage; | |
273 | Gebruik: {prog} [options] [file ...] | |
274 | ||
275 | --config=XXX -f specificeer configuratiebestand | |
276 | --nostdconf -X gebruik uitsluitend dit configuratiebestand | |
277 | --define=XXX -D definieer configuratiesetting | |
278 | --printconfig -P print config waarden | |
279 | --admdir=XXX directory voor de config files | |
280 | --help deze hulpboodschap | |
281 | --ident toon identificatie | |
282 | --verbose geef meer uitgebreide information | |
283 | EndOfUsage | |
284 | CORE::exit $exit if defined $exit && $exit != 0; | |
285 | } | |
286 |
0 | #! perl -- -*- coding: utf-8 -*- | |
1 | ||
2 | use utf8; | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $dbh; | |
8 | ||
9 | package EB::Wx::MainFrame; | |
10 | ||
11 | use strict; | |
12 | use warnings; | |
13 | ||
14 | use Wx qw[:everything]; | |
15 | use base qw(Wx::Frame); | |
16 | use EB; | |
17 | use base qw(EB::Wx::Window); | |
18 | ||
19 | my %cmds; | |
20 | ||
21 | sub new { | |
22 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
23 | $parent = undef unless defined $parent; | |
24 | $id = -1 unless defined $id; | |
25 | $title = "" unless defined $title; | |
26 | $pos = wxDefaultPosition unless defined $pos; | |
27 | $size = wxDefaultSize unless defined $size; | |
28 | $name = "" unless defined $name; | |
29 | ||
30 | # begin wxGlade: EB::Wx::MainFrame::new | |
31 | ||
32 | $style = wxDEFAULT_FRAME_STYLE | |
33 | unless defined $style; | |
34 | ||
35 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
36 | ||
37 | ||
38 | # Menu Bar | |
39 | ||
40 | $self->{mainframe_menubar} = Wx::MenuBar->new(); | |
41 | use constant MENU_XAF => Wx::NewId(); | |
42 | use constant MENU_SHELL => Wx::NewId(); | |
43 | use constant MENU_GBK => Wx::NewId(); | |
44 | use constant MENU_DBK => Wx::NewId(); | |
45 | use constant MENU_BTW => Wx::NewId(); | |
46 | use constant MENU_STD => Wx::NewId(); | |
47 | use constant MENU_REL => Wx::NewId(); | |
48 | use constant MENU_R_PRF => Wx::NewId(); | |
49 | use constant MENU_R_BAL => Wx::NewId(); | |
50 | use constant MENU_R_RES => Wx::NewId(); | |
51 | use constant MENU_R_GBK => Wx::NewId(); | |
52 | use constant MENU_R_JNL => Wx::NewId(); | |
53 | use constant MENU_R_BTW => Wx::NewId(); | |
54 | use constant MENU_R_OP => Wx::NewId(); | |
55 | use constant MENU_R_DEB => Wx::NewId(); | |
56 | use constant MENU_R_CRD => Wx::NewId(); | |
57 | use constant MENU_R_OBAL => Wx::NewId(); | |
58 | my $wxglade_tmp_menu; | |
59 | $wxglade_tmp_menu = Wx::Menu->new(); | |
60 | $wxglade_tmp_menu->Append(wxID_CLOSE, _T("Verberg log venster"), _T("Toon of verberg het log venster")); | |
61 | $wxglade_tmp_menu->Append(wxID_CLEAR, _T("Log venster schoonmaken"), ""); | |
62 | $wxglade_tmp_menu->AppendSeparator(); | |
63 | $wxglade_tmp_menu->Append(wxID_SAVE, _T("Exporteer EekBoek..."), _T("Exporteer administratie")); | |
64 | $wxglade_tmp_menu->Append(MENU_XAF, _T("Aanmaken XML Audit File..."), _T("Exporteer administratie")); | |
65 | $wxglade_tmp_menu->AppendSeparator(); | |
66 | $wxglade_tmp_menu->Append(wxID_PROPERTIES, _T("Eigenschappen...\tAlt+Enter"), _T("Toon administratiegegevens")); | |
67 | $wxglade_tmp_menu->AppendSeparator(); | |
68 | $wxglade_tmp_menu->Append(MENU_SHELL, _T("EekBoek Shell\tAlt-!"), _T("EekBoek Shell")); | |
69 | $wxglade_tmp_menu->AppendSeparator(); | |
70 | $wxglade_tmp_menu->Append(wxID_REFRESH, _T("Opnieuw starten\tAlt-R"), _T("Herstart (voor testen)")); | |
71 | $wxglade_tmp_menu->Append(wxID_EXIT, _T("Beëindigen\tAlt-x"), _T("Beëindig het programma")); | |
72 | $self->{mainframe_menubar}->Append($wxglade_tmp_menu, _T("&Bestand")); | |
73 | $wxglade_tmp_menu = Wx::Menu->new(); | |
74 | $wxglade_tmp_menu->Append(wxID_CUT, _T("Knip"), ""); | |
75 | $wxglade_tmp_menu->Append(wxID_PASTE, _T("Plak"), ""); | |
76 | $wxglade_tmp_menu->Append(wxID_COPY, _T("Kopiëer"), ""); | |
77 | $wxglade_tmp_menu->AppendSeparator(); | |
78 | $wxglade_tmp_menu->Append(wxID_PREFERENCES, _T("Instellingen..."), _T("Instellingen")); | |
79 | $self->{mainframe_menubar}->Append($wxglade_tmp_menu, _T("&Edit")); | |
80 | $wxglade_tmp_menu = Wx::Menu->new(); | |
81 | $wxglade_tmp_menu->Append(MENU_GBK, _T("Grootboekrekeningen"), _T("Onderhoud rekeningschema en grootboekrekeningen")); | |
82 | $wxglade_tmp_menu->Append(MENU_DBK, _T("Dagboeken"), _T("Onderhoud dagboeken")); | |
83 | $wxglade_tmp_menu->Append(MENU_BTW, _T("BTW Tarieven"), _T("Onderhoud BTW tarieven")); | |
84 | $wxglade_tmp_menu->Append(MENU_STD, _T("Koppelingen"), _T("Onderhoud Standaardrekeningen (koppelingen)")); | |
85 | $wxglade_tmp_menu->Append(MENU_REL, _T("Relaties"), _T("Onderhoud debiteuren en crediteuren")); | |
86 | $self->{mainframe_menubar}->Append($wxglade_tmp_menu, _T("&Onderhoud")); | |
87 | $wxglade_tmp_menu = Wx::Menu->new(); | |
88 | $self->{mainframe_menubar}->Append($wxglade_tmp_menu, _T("&Dagboeken")); | |
89 | $wxglade_tmp_menu = Wx::Menu->new(); | |
90 | $wxglade_tmp_menu->Append(MENU_R_PRF, _T("Proef- en Saldibalans"), _T("Opmaken Proef- en Saldibalans")); | |
91 | $wxglade_tmp_menu->Append(MENU_R_BAL, _T("Balans"), _T("Opmaken Balans")); | |
92 | $wxglade_tmp_menu->Append(MENU_R_RES, _T("Resultaatrekening"), _T("Opmaken Resultaatrekening")); | |
93 | $wxglade_tmp_menu->AppendSeparator(); | |
94 | $wxglade_tmp_menu->Append(MENU_R_GBK, _T("Grootboek"), _T("Opmaken Grootboekrapportage")); | |
95 | $wxglade_tmp_menu->Append(MENU_R_JNL, _T("Journaal"), _T("Opmaken Journaal")); | |
96 | $wxglade_tmp_menu->Append(MENU_R_BTW, _T("BTW aangifte"), _T("Opmaken BTW aangifte")); | |
97 | $wxglade_tmp_menu->AppendSeparator(); | |
98 | $wxglade_tmp_menu->Append(MENU_R_OP, _T("Openstaande posten"), _T("Opmaken overzicht openstaande posten")); | |
99 | $wxglade_tmp_menu->Append(MENU_R_DEB, _T("Debiteuren"), _T("Opmaken Debiteurenoverzicht")); | |
100 | $wxglade_tmp_menu->Append(MENU_R_CRD, _T("Crediteuren"), _T("Opmaken Crediteurenoverzicht")); | |
101 | $wxglade_tmp_menu->AppendSeparator(); | |
102 | $wxglade_tmp_menu->Append(MENU_R_OBAL, _T("Openingsbalans"), _T("Toon openingsbalans")); | |
103 | $self->{mainframe_menubar}->Append($wxglade_tmp_menu, _T("Ra&pportages")); | |
104 | $wxglade_tmp_menu = Wx::Menu->new(); | |
105 | $wxglade_tmp_menu->Append(wxID_HELP, _T("Documentatie\tF1"), _T("Toon de EekBoek documentatie")); | |
106 | $wxglade_tmp_menu->Append(wxID_ABOUT, _T("&Info..."), _T("Informatie")); | |
107 | $self->{mainframe_menubar}->Append($wxglade_tmp_menu, _T("&Hulp")); | |
108 | $self->SetMenuBar($self->{mainframe_menubar}); | |
109 | ||
110 | # Menu Bar end | |
111 | ||
112 | $self->{mainframe_statusbar} = $self->CreateStatusBar(0, 0); | |
113 | $self->{eb_logo} = Wx::StaticBitmap->new($self, -1, Wx::Bitmap->new("eb.jpg", wxBITMAP_TYPE_ANY), wxDefaultPosition, wxDefaultSize, wxDOUBLE_BORDER); | |
114 | $self->{pp_logo} = Wx::StaticBitmap->new($self, -1, Wx::Bitmap->new("/home/jv/src/eekboek/src/libgui/EB/Wx/icons/perl_powered.png", wxBITMAP_TYPE_ANY), wxDefaultPosition, wxDefaultSize, ); | |
115 | $self->{tx_log} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL); | |
116 | ||
117 | $self->__set_properties(); | |
118 | $self->__do_layout(); | |
119 | ||
120 | Wx::Event::EVT_MENU($self, wxID_CLOSE, \&OnLogw); | |
121 | Wx::Event::EVT_MENU($self, wxID_CLEAR, \&OnLogClean); | |
122 | Wx::Event::EVT_MENU($self, wxID_SAVE, \&OnExportEB); | |
123 | Wx::Event::EVT_MENU($self, MENU_XAF, \&OnExportXAF); | |
124 | Wx::Event::EVT_MENU($self, wxID_PROPERTIES, \&OnProperties); | |
125 | Wx::Event::EVT_MENU($self, MENU_SHELL, \&OnShell); | |
126 | Wx::Event::EVT_MENU($self, wxID_REFRESH, \&OnRestart); | |
127 | Wx::Event::EVT_MENU($self, wxID_EXIT, \&OnExit); | |
128 | Wx::Event::EVT_MENU($self, wxID_PREFERENCES, \&OnPreferences); | |
129 | Wx::Event::EVT_MENU($self, MENU_GBK, \&OnMGbk); | |
130 | Wx::Event::EVT_MENU($self, MENU_DBK, \&OnMDbk); | |
131 | Wx::Event::EVT_MENU($self, MENU_BTW, \&OnMBtw); | |
132 | Wx::Event::EVT_MENU($self, MENU_STD, \&OnMStdAcc); | |
133 | Wx::Event::EVT_MENU($self, MENU_REL, \&OnMRel); | |
134 | Wx::Event::EVT_MENU($self, MENU_R_PRF, \&OnRPrf); | |
135 | Wx::Event::EVT_MENU($self, MENU_R_BAL, \&OnRBal); | |
136 | Wx::Event::EVT_MENU($self, MENU_R_RES, \&OnRRes); | |
137 | Wx::Event::EVT_MENU($self, MENU_R_GBK, \&OnRGbk); | |
138 | Wx::Event::EVT_MENU($self, MENU_R_JNL, \&OnRJnl); | |
139 | Wx::Event::EVT_MENU($self, MENU_R_BTW, \&OnRBtw); | |
140 | Wx::Event::EVT_MENU($self, MENU_R_OP, \&OnROpen); | |
141 | Wx::Event::EVT_MENU($self, MENU_R_DEB, \&OnRDeb); | |
142 | Wx::Event::EVT_MENU($self, MENU_R_CRD, \&OnRCrd); | |
143 | Wx::Event::EVT_MENU($self, MENU_R_OBAL, \&OnROBal); | |
144 | Wx::Event::EVT_MENU($self, wxID_HELP, \&OnDoc); | |
145 | Wx::Event::EVT_MENU($self, wxID_ABOUT, \&OnAbout); | |
146 | ||
147 | # end wxGlade | |
148 | ||
149 | $self->{OLDLOG} = Wx::Log::SetActiveTarget (Wx::LogTextCtrl->new($self->{tx_log})); | |
150 | #Wx::Log::SetTimestamp("%T"); | |
151 | Wx::LogMessage($EB::imsg); | |
152 | Wx::LogMessage("Huidig boekjaar: " . ($state->bky) . " (" . $dbh->adm("name") . ")"); | |
153 | ||
154 | $self->adapt_menus; | |
155 | ||
156 | # No restart unless we have a program. | |
157 | $self->{mainframe_menubar}->Enable(wxID_REFRESH, $0 ne '-e'); | |
158 | ||
159 | $self->{mainframe_menubar}->Enable(MENU_SHELL, | |
160 | findlib("Wx/Shell.pm")); | |
161 | $self->{mainframe_menubar}->Enable(MENU_XAF, | |
162 | findlib("Wx/Export/XAF.pm")); | |
163 | ||
164 | use Wx::Event qw(EVT_CLOSE); | |
165 | ||
166 | EVT_CLOSE($self, \&OnExit); | |
167 | ||
168 | %cmds = ( props => wxID_PROPERTIES, | |
169 | prefs => wxID_PREFERENCES, | |
170 | exp => wxID_SAVE, | |
171 | gbk => MENU_GBK, | |
172 | dbk => MENU_DBK, | |
173 | rel => MENU_REL, | |
174 | btw => MENU_BTW, | |
175 | std => MENU_STD, | |
176 | rbal => MENU_R_BAL, | |
177 | rres => MENU_R_RES, | |
178 | rprf => MENU_R_PRF, | |
179 | rgbk => MENU_R_GBK, | |
180 | rjnl => MENU_R_JNL, | |
181 | rbtw => MENU_R_BTW, | |
182 | rdeb => MENU_R_DEB, | |
183 | rcrd => MENU_R_CRD, | |
184 | ropn => MENU_R_OP, | |
185 | about => wxID_ABOUT, | |
186 | ); | |
187 | ||
188 | $self; | |
189 | } | |
190 | ||
191 | sub __set_properties { | |
192 | my $self = shift; | |
193 | ||
194 | # begin wxGlade: EB::Wx::MainFrame::__set_properties | |
195 | ||
196 | $self->SetTitle(_T("EekBoek")); | |
197 | my $icon = Wx::Icon->new(); | |
198 | $icon->CopyFromBitmap(Wx::Bitmap->new(_T("/home/jv/src/eekboek/src/libgui/EB/Wx/icons/eb.jpg"), wxBITMAP_TYPE_ANY)); | |
199 | $self->SetIcon($icon); | |
200 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(372, 203))); | |
201 | $self->SetBackgroundColour(Wx::Colour->new(255, 255, 255)); | |
202 | $self->{mainframe_statusbar}->SetStatusWidths(); | |
203 | ||
204 | my( @mainframe_statusbar_fields ) = ( | |
205 | ||
206 | ); | |
207 | ||
208 | if( @mainframe_statusbar_fields ) { | |
209 | $self->{mainframe_statusbar}->SetStatusText($mainframe_statusbar_fields[$_], $_) | |
210 | for 0 .. $#mainframe_statusbar_fields ; | |
211 | } | |
212 | ||
213 | # end wxGlade | |
214 | ||
215 | $self->{mainframe_statusbar}->SetStatusText($EB::imsg, 0); | |
216 | ||
217 | } | |
218 | ||
219 | sub __do_layout { | |
220 | my $self = shift; | |
221 | ||
222 | # begin wxGlade: EB::Wx::MainFrame::__do_layout | |
223 | ||
224 | $self->{sz_main} = Wx::BoxSizer->new(wxVERTICAL); | |
225 | $self->{sizer_4} = Wx::BoxSizer->new(wxHORIZONTAL); | |
226 | $self->{sizer_4}->Add(150, 20, 2, wxADJUST_MINSIZE, 0); | |
227 | $self->{sizer_4}->Add($self->{eb_logo}, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 40); | |
228 | $self->{sizer_4}->Add(20, 20, 1, wxADJUST_MINSIZE, 0); | |
229 | $self->{sizer_4}->Add($self->{pp_logo}, 0, wxRIGHT|wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 40); | |
230 | $self->{sizer_4}->Add(150, 20, 2, wxADJUST_MINSIZE, 0); | |
231 | $self->{sz_main}->Add($self->{sizer_4}, 1, wxEXPAND, 0); | |
232 | $self->{sz_main}->Add($self->{tx_log}, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 5); | |
233 | $self->SetSizer($self->{sz_main}); | |
234 | $self->Layout(); | |
235 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(372, 203))); | |
236 | ||
237 | # end wxGlade | |
238 | } | |
239 | ||
240 | sub closehandler { | |
241 | my ($self) = @_; | |
242 | $self->sizepos_save; | |
243 | # Explicitly destroy the hidden (but still alive!) dialogs. | |
244 | foreach ( qw(opendialog) ) { | |
245 | next unless $self->{"d_$_"}; | |
246 | $self->{"d_$_"}->Destroy; | |
247 | } | |
248 | } | |
249 | ||
250 | sub command { | |
251 | my ($self, $cmd) = @_; | |
252 | use Wx qw(wxEVT_COMMAND_MENU_SELECTED); | |
253 | ||
254 | foreach ( split(":", $cmd) ) { | |
255 | if ( exists($cmds{$_}) ) { | |
256 | Wx::PostEvent($self, | |
257 | Wx::CommandEvent->new(wxEVT_COMMAND_MENU_SELECTED, $cmds{$_})); | |
258 | } | |
259 | else { | |
260 | Wx::LogMessage("Unknown command: $_"); | |
261 | } | |
262 | } | |
263 | ||
264 | } | |
265 | ||
266 | sub adapt_menus { | |
267 | my $self = shift; | |
268 | ||
269 | $self->{mainframe_menubar}->Enable(MENU_BTW, $dbh->does_btw); | |
270 | $self->{mainframe_menubar}->Enable(MENU_R_BTW, $dbh->does_btw); | |
271 | ||
272 | my $sth = $dbh->sql_exec("SELECT dbk_id,dbk_desc,dbk_type". | |
273 | " FROM Dagboeken". | |
274 | " ORDER BY dbk_desc"); | |
275 | ||
276 | use Wx::Event qw(EVT_MENU); | |
277 | ||
278 | my $tmp = Wx::Menu->new; | |
279 | while ( my $rr = $sth->fetchrow_arrayref ) { | |
280 | my ($id, $desc, $type) = @$rr; | |
281 | # This consumes Ids, but we do not expect to do this often. | |
282 | my $m = Wx::NewId(); | |
283 | $tmp->Append($m, "$desc\tAlt-$id", | |
284 | __x("Dagboek {dbk}", dbk => $desc)."\n"); | |
285 | my $tp = qw(X IV IV BKM BKM BKM)[$type]; | |
286 | my $cl = "EB::Wx::Booking::${tp}Panel"; | |
287 | my $p = "d_dbkpanel$tp$id"; | |
288 | undef($self->{$p}); | |
289 | EVT_MENU($self, $m, | |
290 | sub { eval "require $cl"; | |
291 | die($@) if $@; | |
292 | my $pos = wxDefaultPosition; | |
293 | my $width = wxDefaultSize; | |
294 | $self->{$p} ||= | |
295 | $cl->new($self, -1, | |
296 | __x("Dagboek {dbk}", dbk => $desc)."\n", | |
297 | $pos, $width, $type); | |
298 | $self->{$p}->sizepos_restore("dbk$tp${id}w"); | |
299 | $self->{$p}->init($id, $desc, $type); | |
300 | $self->{$p}->refresh; | |
301 | $self->{$p}->Show(1); | |
302 | $self->{dbk_id} = $id; | |
303 | }); | |
304 | } | |
305 | ||
306 | my $ix = $self->{mainframe_menubar}->FindMenu(_T("&Dagboeken")); | |
307 | $tmp = $self->{mainframe_menubar}->Replace | |
308 | ($ix, $tmp, | |
309 | $self->{mainframe_menubar}->GetLabelTop($ix)); | |
310 | $tmp->Destroy if $tmp; | |
311 | $self->{mainframe_menubar}->Refresh; | |
312 | ||
313 | my $t = $::cfg->val(qw(database name)); | |
314 | $t =~ s/^eekboek_//; | |
315 | $t = $dbh->adm("name"); | |
316 | $self->{mainframe_statusbar}->SetStatusText(__x("Administratie: {adm}", | |
317 | adm => $t), 0); | |
318 | $self->SetTitle(__x("EekBoek: {adm}", | |
319 | adm => $dbh->adm("name"))); | |
320 | } | |
321 | ||
322 | sub DESTROY { | |
323 | my $self = shift; | |
324 | Wx::Log::SetActiveTarget($self->{OLDLOG})->Destroy; | |
325 | } | |
326 | ||
327 | ################ Menu: File ################ | |
328 | ||
329 | # wxGlade: EB::Wx::MainFrame::OnExportEB <event_handler> | |
330 | sub OnExportEB { | |
331 | my ($self, $event) = @_; | |
332 | ||
333 | my $c = $state->expdir; | |
334 | $state->expdir("") unless $c && -d $c; | |
335 | require EB::Wx::Export::EekBoek; | |
336 | $self->{d_exporteb} = EB::Wx::Export::EekBoek->new | |
337 | ($self, -1, | |
338 | _T("Exporteren administratie"), | |
339 | wxDefaultPosition, | |
340 | wxDefaultSize, | |
341 | wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER, | |
342 | "", | |
343 | ); | |
344 | $self->{d_exporteb}->refresh; | |
345 | $self->{d_exporteb}->ShowModal; | |
346 | $self->{d_exporteb}->Destroy; | |
347 | } | |
348 | ||
349 | # wxGlade: EB::Wx::MainFrame::OnExportXAF <event_handler> | |
350 | sub OnExportXAF { | |
351 | my ($self, $event) = @_; | |
352 | ||
353 | my $c = $state->expdir; | |
354 | $state->expdir("") unless $c && -d $c; | |
355 | require EB::Wx::Export::XAF; | |
356 | $self->{d_exportxaf} = EB::Wx::Export::XAF->new | |
357 | ($self, -1, | |
358 | _T("Exporteren administratie"), | |
359 | wxDefaultPosition, | |
360 | wxDefaultSize, | |
361 | wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER, | |
362 | "", | |
363 | ); | |
364 | $self->{d_exportxaf}->refresh; | |
365 | $self->{d_exportxaf}->ShowModal; | |
366 | $self->{d_exportxaf}->Destroy; | |
367 | } | |
368 | ||
369 | # wxGlade: EB::Wx::MainFrame::OnProperties <event_handler> | |
370 | sub OnProperties { | |
371 | my ($self, $event) = @_; | |
372 | require EB::Wx::Tools::PropertiesDialog; | |
373 | $self->{d_prpdialog} ||= EB::Wx::Tools::PropertiesDialog->new | |
374 | ($self, -1, | |
375 | _T("Administratiegegevens"), | |
376 | wxDefaultPosition, wxDefaultSize, | |
377 | ); | |
378 | $self->{d_prpdialog}->sizepos_restore("prpw", 1); | |
379 | $self->{d_prpdialog}->refresh; | |
380 | $self->{d_prpdialog}->ShowModal; | |
381 | } | |
382 | ||
383 | # wxGlade: EB::Wx::MainFrame::OnLogw <event_handler> | |
384 | sub OnLogw { | |
385 | my ($self, $event) = @_; | |
386 | if ( $self->{tx_log}->IsShown ) { | |
387 | $self->{tx_log}->Show(0); | |
388 | $self->{mainframe_menubar}->SetLabel(wxID_CLOSE, "Toon log venster"); | |
389 | } | |
390 | else { | |
391 | $self->{tx_log}->Show(1); | |
392 | $self->{mainframe_menubar}->SetLabel(wxID_CLOSE, "Verberg log venster"); | |
393 | } | |
394 | $self->Layout; | |
395 | } | |
396 | ||
397 | # wxGlade: EB::Wx::MainFrame::OnLogClean <event_handler> | |
398 | sub OnLogClean { | |
399 | my ($self, $event) = @_; | |
400 | $self->{tx_log}->Clear; | |
401 | } | |
402 | ||
403 | # wxGlade: EB::Wx::MainFrame::OnShell <event_handler> | |
404 | sub OnShell { | |
405 | my ($self, $event) = @_; | |
406 | warn "Event handler (OnShell) not implemented"; | |
407 | $event->Skip; | |
408 | } | |
409 | ||
410 | # wxGlade: EB::Wx::MainFrame::OnRestart <event_handler> | |
411 | sub OnRestart { | |
412 | my ($self, $event) = @_; | |
413 | $self->closehandler(@_); | |
414 | $EB::Wx::Main::restart++; | |
415 | $self->Close(1); | |
416 | } | |
417 | ||
418 | # wxGlade: EB::Wx::MainFrame::OnExit <event_handler> | |
419 | sub OnExit { | |
420 | my ($self, $event) = @_; | |
421 | $self->closehandler(@_); | |
422 | $self->Destroy; | |
423 | } | |
424 | ||
425 | ################ Menu: Edit ################ | |
426 | ||
427 | # wxGlade: EB::Wx::MainFrame::OnPreferences <event_handler> | |
428 | sub OnPreferences { | |
429 | my ($self, $event) = @_; | |
430 | require EB::Wx::Tools::PreferencesDialog; | |
431 | my $p = "d_mprfpanel"; | |
432 | $self->{$p} ||= EB::Wx::Tools::PreferencesDialog->new | |
433 | ($self, -1, | |
434 | "Voorkeursinstellingen", | |
435 | wxDefaultPosition, wxDefaultSize, | |
436 | ); | |
437 | $self->{$p}->sizepos_restore("prefw", 1); | |
438 | $self->{$p}->refresh; | |
439 | $self->{$p}->Show(1); | |
440 | } | |
441 | ||
442 | ################ Maintenance ################ | |
443 | ||
444 | # wxGlade: EB::Wx::MainFrame::OnMGbk <event_handler> | |
445 | sub OnMGbk { | |
446 | my ($self, $event) = @_; | |
447 | require EB::Wx::Maint::Accounts; | |
448 | my $p = "d_maccpanel"; | |
449 | $self->{$p} ||= EB::Wx::Maint::Accounts->new | |
450 | ($self, -1, | |
451 | "Raadplegen Grootboekrekeningen", | |
452 | wxDefaultPosition, wxDefaultSize, | |
453 | ); | |
454 | $self->{$p}->sizepos_restore("accw"); | |
455 | $self->{$p}->Show(1); | |
456 | } | |
457 | ||
458 | # wxGlade: EB::Wx::MainFrame::OnMDbk <event_handler> | |
459 | sub OnMDbk { | |
460 | my ($self, $event) = @_; | |
461 | require EB::Wx::Maint::Dagboeken; | |
462 | my $p = "d_mdbkpanel"; | |
463 | $self->{$p} ||= EB::Wx::Maint::Dagboeken->new | |
464 | ($self, -1, | |
465 | "Onderhoud Dagboeken", | |
466 | wxDefaultPosition, wxDefaultSize, | |
467 | ); | |
468 | $self->{$p}->sizepos_restore("dbkw"); | |
469 | $self->{$p}->refresh; | |
470 | $self->{$p}->Show(1); | |
471 | } | |
472 | ||
473 | # wxGlade: EB::Wx::MainFrame::OnMRel <event_handler> | |
474 | sub OnMRel { | |
475 | my ($self, $event) = @_; | |
476 | require EB::Wx::Maint::Relaties; | |
477 | my $p = "d_mrelpanel"; | |
478 | $self->{$p} ||= EB::Wx::Maint::Relaties->new | |
479 | ($self, -1, | |
480 | "Onderhoud Relaties", | |
481 | wxDefaultPosition, wxDefaultSize, | |
482 | ); | |
483 | $self->{$p}->sizepos_restore("relw"); | |
484 | $self->{$p}->refresh; | |
485 | $self->{$p}->Show(1); | |
486 | } | |
487 | ||
488 | # wxGlade: EB::Wx::MainFrame::OnMBtw <event_handler> | |
489 | sub OnMBtw { | |
490 | my ($self, $event) = @_; | |
491 | require EB::Wx::Maint::BTWTarieven; | |
492 | my $p = "d_mbtwpanel"; | |
493 | $self->{$p}->Destroy if $self->{$p}; | |
494 | $self->{$p} = EB::Wx::Maint::BTWTarieven->new | |
495 | ($self, -1, | |
496 | "Onderhoud BTW instellingen", | |
497 | wxDefaultPosition, wxDefaultSize, | |
498 | ); | |
499 | $self->{$p}->sizepos_restore("btww"); | |
500 | $self->{$p}->refresh; | |
501 | $self->{$p}->Show(1); | |
502 | } | |
503 | ||
504 | # wxGlade: EB::Wx::MainFrame::OnMStdAcc <event_handler> | |
505 | sub OnMStdAcc { | |
506 | my ($self, $event) = @_; | |
507 | require EB::Wx::Maint::StdAccounts; | |
508 | my $p = "d_mstdpanel"; | |
509 | $self->{$p} ||= EB::Wx::Maint::StdAccounts->new | |
510 | ($self, -1, | |
511 | "Onderhoud Koppelingen", | |
512 | wxDefaultPosition, wxDefaultSize, | |
513 | ); | |
514 | $self->{$p}->sizepos_restore("stdw"); | |
515 | $self->{$p}->Show(1); | |
516 | } | |
517 | ||
518 | ################ Menu: Reports ################ | |
519 | ||
520 | # wxGlade: EB::Wx::MainFrame::OnRPrf <event_handler> | |
521 | sub OnRPrf { | |
522 | my ($self, $event) = @_; | |
523 | require EB::Wx::Report::BalResProof; | |
524 | $self->{d_rprfpanel} ||= EB::Wx::Report::BalResProof->new | |
525 | ($self, -1, | |
526 | "Proef & Saldibalans", | |
527 | wxDefaultPosition, wxDefaultSize, | |
528 | ); | |
529 | $self->{d_rprfpanel}->sizepos_restore("rprfw"); | |
530 | $self->{d_rprfpanel}->init("prf"); | |
531 | $self->{d_rprfpanel}->Show(1); | |
532 | } | |
533 | ||
534 | # wxGlade: EB::Wx::MainFrame::OnRBal <event_handler> | |
535 | sub OnRBal { | |
536 | my ($self, $event) = @_; | |
537 | require EB::Wx::Report::BalResProof; | |
538 | $self->{d_rbalpanel} ||= EB::Wx::Report::BalResProof->new | |
539 | ($self, -1, | |
540 | "Balans", | |
541 | wxDefaultPosition, wxDefaultSize, | |
542 | ); | |
543 | $self->{d_rbalpanel}->sizepos_restore("rbalw"); | |
544 | $self->{d_rbalpanel}->init("bal"); | |
545 | $self->{d_rbalpanel}->Show(1); | |
546 | } | |
547 | ||
548 | # wxGlade: EB::Wx::MainFrame::OnRRes <event_handler> | |
549 | sub OnRRes { | |
550 | my ($self, $event) = @_; | |
551 | require EB::Wx::Report::BalResProof; | |
552 | $self->{d_rrespanel} ||= EB::Wx::Report::BalResProof->new | |
553 | ($self, -1, | |
554 | "Resultaat", | |
555 | wxDefaultPosition, wxDefaultSize, | |
556 | ); | |
557 | $self->{d_rrespanel}->sizepos_restore("rresw"); | |
558 | $self->{d_rrespanel}->init("res"); | |
559 | $self->{d_rrespanel}->Show(1); | |
560 | } | |
561 | ||
562 | # wxGlade: EB::Wx::MainFrame::OnRGbk <event_handler> | |
563 | sub OnRGbk { | |
564 | my ($self, $event) = @_; | |
565 | $self->ShowRGbk; | |
566 | } | |
567 | ||
568 | sub ShowRGbk { | |
569 | my ($self, $args) = @_; | |
570 | require EB::Wx::Report::Grootboek; | |
571 | $self->{d_rgbkpanel} ||= EB::Wx::Report::Grootboek->new | |
572 | ($self, -1, | |
573 | "Grootboek", | |
574 | wxDefaultPosition, wxDefaultSize, | |
575 | ); | |
576 | $self->{d_rgbkpanel}->sizepos_restore("rgbkw"); | |
577 | $self->{d_rgbkpanel}->init("gbk", $args); | |
578 | $self->{d_rgbkpanel}->Show(1); | |
579 | $self->{d_rgbkpanel}->Raise; | |
580 | } | |
581 | ||
582 | # wxGlade: EB::Wx::MainFrame::OnRJnl <event_handler> | |
583 | sub OnRJnl { | |
584 | my ($self, $event) = @_; | |
585 | $self->ShowRJnl; | |
586 | } | |
587 | ||
588 | sub ShowRJnl { | |
589 | my ($self, $args) = @_; | |
590 | require EB::Wx::Report::Journaal; | |
591 | $self->{d_rjnlpanel} ||= EB::Wx::Report::Journaal->new | |
592 | ($self, -1, | |
593 | "Journaal", | |
594 | wxDefaultPosition, wxDefaultSize, | |
595 | ); | |
596 | $self->{d_rjnlpanel}->sizepos_restore("rjnlw"); | |
597 | $self->{d_rjnlpanel}->init("jnl", $args); | |
598 | $self->{d_rjnlpanel}->Show(1); | |
599 | $self->{d_rjnlpanel}->Raise; | |
600 | } | |
601 | ||
602 | # wxGlade: EB::Wx::MainFrame::OnRBtw <event_handler> | |
603 | sub OnRBtw { | |
604 | my ($self, $event) = @_; | |
605 | require EB::Wx::Report::BTWAangifte; | |
606 | $self->{d_rbtwpanel} ||= EB::Wx::Report::BTWAangifte->new | |
607 | ($self, -1, | |
608 | "BTW aangifte", | |
609 | wxDefaultPosition, wxDefaultSize, | |
610 | ); | |
611 | $self->{d_rbtwpanel}->sizepos_restore("rbtww"); | |
612 | $self->{d_rbtwpanel}->init("btw"); | |
613 | $self->{d_rbtwpanel}->Show(1); | |
614 | } | |
615 | ||
616 | # wxGlade: EB::Wx::MainFrame::OnROpen <event_handler> | |
617 | sub OnROpen { | |
618 | my ($self, $event) = @_; | |
619 | require EB::Wx::Report::Openstaand; | |
620 | $self->{d_ropnpanel} ||= EB::Wx::Report::Openstaand->new | |
621 | ($self, -1, | |
622 | "Openstaande posten", | |
623 | wxDefaultPosition, wxDefaultSize, | |
624 | ); | |
625 | $self->{d_ropnpanel}->sizepos_restore("ropnw"); | |
626 | $self->{d_ropnpanel}->init("opn"); | |
627 | $self->{d_ropnpanel}->Show(1); | |
628 | } | |
629 | ||
630 | # wxGlade: EB::Wx::MainFrame::OnRDeb <event_handler> | |
631 | sub OnRDeb { | |
632 | my ($self, $event) = @_; | |
633 | $self->ShowRDeb; | |
634 | } | |
635 | ||
636 | sub ShowRDeb { | |
637 | my ($self, $args) = @_; | |
638 | require EB::Wx::Report::DebCrd; | |
639 | $self->{d_rdebpanel} ||= EB::Wx::Report::DebCrd->new | |
640 | ($self, -1, | |
641 | "Debiteuren", | |
642 | wxDefaultPosition, wxDefaultSize, | |
643 | ); | |
644 | $self->{d_rdebpanel}->sizepos_restore("rdebw"); | |
645 | $self->{d_rdebpanel}->init("deb", $args); | |
646 | $self->{d_rdebpanel}->Show(1); | |
647 | $self->{d_rdebpanel}->Raise; | |
648 | } | |
649 | ||
650 | # wxGlade: EB::Wx::MainFrame::OnRCrd <event_handler> | |
651 | sub OnRCrd { | |
652 | my ($self, $event) = @_; | |
653 | $self->ShowRCrd; | |
654 | } | |
655 | ||
656 | sub ShowRCrd { | |
657 | my ($self, $args) = @_; | |
658 | require EB::Wx::Report::DebCrd; | |
659 | $self->{d_rcrdpanel} ||= EB::Wx::Report::DebCrd->new | |
660 | ($self, -1, | |
661 | "Crediteuren", | |
662 | wxDefaultPosition, wxDefaultSize, | |
663 | ); | |
664 | $self->{d_rcrdpanel}->sizepos_restore("rcrdw"); | |
665 | $self->{d_rcrdpanel}->init("crd", $args); | |
666 | $self->{d_rcrdpanel}->Show(1); | |
667 | $self->{d_rcrdpanel}->Raise; | |
668 | } | |
669 | ||
670 | ||
671 | # wxGlade: EB::Wx::MainFrame::OnROBal <event_handler> | |
672 | sub OnROBal { | |
673 | my ($self, $event) = @_; | |
674 | require EB::Wx::Report::BalResProof; | |
675 | $self->{d_robalpanel} ||= EB::Wx::Report::BalResProof->new | |
676 | ($self, -1, | |
677 | "Openingsbalans", | |
678 | wxDefaultPosition, wxDefaultSize, | |
679 | ); | |
680 | $self->{d_robalpanel}->sizepos_restore("robalw"); | |
681 | $self->{d_robalpanel}->init("obal"); | |
682 | $self->{d_robalpanel}->Show(1); | |
683 | } | |
684 | ||
685 | ################ Menu: Info ################ | |
686 | ||
687 | # wxGlade: EB::Wx::MainFrame::OnDoc <event_handler> | |
688 | sub OnDoc { | |
689 | my ($self, $event) = @_; | |
690 | Wx::LaunchDefaultBrowser("$EB::url/docs/index.html"); | |
691 | } | |
692 | ||
693 | # wxGlade: EB::Wx::MainFrame::OnAbout <event_handler> | |
694 | sub OnAbout { | |
695 | my ($self, $event) = @_; | |
696 | ||
697 | require EB::Wx::Tools::AboutDialog; | |
698 | $self->{d_about} ||= EB::Wx::Tools::AboutDialog->new | |
699 | ($self, -1, | |
700 | "Info ...", | |
701 | wxDefaultPosition, wxDefaultSize, | |
702 | ); | |
703 | $self->{d_about}->init(); | |
704 | $self->{d_about}->refresh(); | |
705 | $self->{d_about}->ShowModal; | |
706 | } | |
707 | ||
708 | ################ End of Menus ################ | |
709 | ||
710 | # end of class EB::Wx::MainFrame | |
711 | ||
712 | 1; | |
713 |
0 | #!/usr/bin/perl | |
1 | ||
2 | # $Id: TreeCtrl.pm,v 1.8 2008/03/25 22:57:42 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $dbh; | |
8 | our $app; | |
9 | ||
10 | package EB::Wx::Maint::Accounts::TreeCtrl; | |
11 | ||
12 | use strict; | |
13 | use base qw(Wx::TreeCtrl); | |
14 | use Wx qw[:everything]; | |
15 | use EB::Wx::Window; | |
16 | ||
17 | sub new { | |
18 | my $class = shift; | |
19 | my $self = $class->SUPER::new(@_); | |
20 | ||
21 | my $root = $self->AddRoot("Gegevens", -1, -1); | |
22 | ||
23 | foreach ( qw(Balans Resultaat) ) { | |
24 | my $handler = "EB::Wx::Maint::Accounts::TreeCtrl::" . $_ . "Handler"; | |
25 | my $text = $handler->description; | |
26 | my $item = $self->AppendItem($root, $text, -1, -1); | |
27 | $handler->populate($self, $item); | |
28 | $self->Expand($item) if $state->accexp->{$text}; | |
29 | } | |
30 | ||
31 | Wx::Event::EVT_TREE_SEL_CHANGED ($self, $self, \&OnSelChange); | |
32 | Wx::Event::EVT_TREE_ITEM_EXPANDED ($self, $self, \&OnExpand); | |
33 | Wx::Event::EVT_TREE_ITEM_COLLAPSED($self, $self, \&OnCollapse); | |
34 | Wx::Event::EVT_TREE_ITEM_ACTIVATED($self, $self, \&OnActivate); | |
35 | ||
36 | Wx::Event::EVT_TREE_BEGIN_DRAG ($self, $self, \&OnBeginDrag); | |
37 | Wx::Event::EVT_TREE_END_DRAG ($self, $self, \&OnEndDrag); | |
38 | ||
39 | =begin ContextMenu | |
40 | ||
41 | Wx::Event::EVT_RIGHT_DOWN ($self, \&OnRightClick); | |
42 | ||
43 | =cut | |
44 | ||
45 | Wx::Event::EVT_IDLE($self, \&OnIdle); | |
46 | ||
47 | $self; | |
48 | } | |
49 | ||
50 | sub OnIdle { | |
51 | my ($self) = @_; | |
52 | # To handle things you cannot do from inside an event. | |
53 | if ( my $fx = $self->{fix} ) { | |
54 | $self->{fix} = 0; | |
55 | $self->SetItemText(@$fx); | |
56 | } | |
57 | if ( my $msg = $self->{msg} ) { | |
58 | $self->{msg} = 0; | |
59 | EB::Wx::MessageDialog($self, @$msg); | |
60 | } | |
61 | } | |
62 | ||
63 | sub OnBeginDrag { | |
64 | my ($self, $event) = @_; | |
65 | if ( $event->GetItem != $self->GetRootItem and | |
66 | $self->GetPlData($event->GetItem) and | |
67 | $self->GetPlData($event->GetItem)->[2] >= 0 ) { | |
68 | $self->{draggeditem} = $event->GetItem; | |
69 | $event->Allow; | |
70 | } | |
71 | else { | |
72 | Wx::LogMessage( "This item can't be dragged" ); | |
73 | } | |
74 | } | |
75 | ||
76 | use Wx qw(wxOK wxICON_HAND); | |
77 | ||
78 | sub OnEndDrag { | |
79 | my ($self, $event) = @_; | |
80 | my ($src, $dst) = ( $self->{draggeditem}, $event->GetItem ); | |
81 | ||
82 | if ( !$dst->IsOk ) { | |
83 | Wx::Bell; | |
84 | return; | |
85 | } | |
86 | ||
87 | if ( $app->{TOP}->{d_maccpanel}->changed ) { | |
88 | EB::Wx::MessageDialog($self, | |
89 | "Er zijn wijzigingen in het rechter paneel. Gelieve deze eerst te verwerken of te annuleren.", | |
90 | "In gebruik", | |
91 | wxOK|wxICON_ERROR); | |
92 | return; | |
93 | } | |
94 | ||
95 | if ( $self->GetParent($src) == $dst || | |
96 | $self->GetParent($src) == $self->GetParent($dst) ) { | |
97 | Wx::LogMessage("Drop skipped"); | |
98 | return; | |
99 | } | |
100 | ||
101 | my $sdata = $self->GetPlData($src); | |
102 | my $ddata = $self->GetPlData($dst) || [0,0,-1]; | |
103 | ||
104 | unless ( $dbh->lookup($sdata->[0], qw(Accounts acc_id acc_balres)) | |
105 | == | |
106 | $dbh->lookup($ddata->[0], qw(Accounts acc_id acc_balres)) ) { | |
107 | Wx::LogMessage("Drop skipped"); | |
108 | return; | |
109 | } | |
110 | ||
111 | my $stype = $sdata->[2]; | |
112 | my $dtype = $ddata->[2]; | |
113 | ||
114 | if ( $dtype == $stype ) { | |
115 | $dst = $self->GetParent($dst); | |
116 | $ddata = $self->GetPlData($dst) || [0,0,-1]; | |
117 | $dtype = $ddata->[2]; | |
118 | } | |
119 | ||
120 | if ( $stype == 2 ) { # Account | |
121 | if ( $dtype == 1 ) { # Verdichting | |
122 | my $text = $self->GetItemText($src); | |
123 | my $it = $self->AppendItem($dst, $text, -1, -1, Wx::TreeItemData->new($sdata)); | |
124 | $self->SortChildren($dst); | |
125 | $self->Delete($src); | |
126 | $dbh->begin_work; | |
127 | $dbh->sql_exec("UPDATE Accounts". | |
128 | " SET acc_struct = ?, acc_balres = ?". | |
129 | " WHERE acc_id = ?", | |
130 | $ddata->[0], | |
131 | $dbh->lookup($ddata->[0], qw(Verdichtingen vdi_id vdi_balres)), | |
132 | $sdata->[0], | |
133 | )->finish; | |
134 | $dbh->commit; | |
135 | $app->{TOP}->{d_maccpanel}->set_item($sdata->[0], $sdata->[2], $self, $dst); | |
136 | $self->SelectItem($it, 1); | |
137 | } | |
138 | else { | |
139 | $self->{msg} = ["Een grootboekrekening kan alleen worden verplaatst naar een verdichting", | |
140 | "Niet hier", | |
141 | wxOK|wxICON_HAND]; | |
142 | return; | |
143 | } | |
144 | } | |
145 | elsif ( $stype == 1 ) { # Verdichting | |
146 | if ( $dtype == 0 ) { # Hoofdverdichting | |
147 | my $text = $self->GetItemText($src); | |
148 | my $new = $self->AppendItem($dst, $text, -1, -1, Wx::TreeItemData->new($sdata)); | |
149 | if ( $self->ItemHasChildren($src) ) { | |
150 | $self->CopyChildren($src, $new); | |
151 | } | |
152 | $self->SortChildren($dst); | |
153 | $self->Delete($src); | |
154 | my $sbalres = $dbh->lookup($sdata->[0], qw(Verdichtingen vdi_id vdi_balres)); | |
155 | my $dbalres = $dbh->lookup($ddata->[0], qw(Verdichtingen vdi_id vdi_balres)); | |
156 | $dbh->begin_work; | |
157 | $dbh->sql_exec("UPDATE Verdichtingen". | |
158 | " SET vdi_struct = ?, vdi_balres = ?". | |
159 | " WHERE vdi_id = ?", | |
160 | $ddata->[0], $dbalres, $sdata->[0], | |
161 | )->finish; | |
162 | $dbh->sql_exec("UPDATE Accounts". | |
163 | " SET acc_balres = ?". | |
164 | " WHERE acc_struct = ?", | |
165 | $dbalres, $sdata->[0], | |
166 | )->finish unless $sbalres == $dbalres; | |
167 | $dbh->commit; | |
168 | $app->{TOP}->{d_maccpanel}->set_item($sdata->[0], $sdata->[2], $self, $dst); | |
169 | $self->SelectItem($new, 1); | |
170 | } | |
171 | else { | |
172 | $self->{msg} = ["Een verdichting kan alleen worden verplaatst naar een hoofdverdichting", | |
173 | "Niet hier", | |
174 | wxOK|wxICON_HAND]; | |
175 | return; | |
176 | } | |
177 | } | |
178 | elsif ( $stype == 0 ) { # Hoofdverdichting | |
179 | if ( $dtype == -1 ) { # Balans/Resultaat | |
180 | my $text = $self->GetItemText($src); | |
181 | my $new = $self->AppendItem($dst, $text, -1, -1, Wx::TreeItemData->new($sdata)); | |
182 | if ( $self->ItemHasChildren($src) ) { | |
183 | $self->CopyChildren($src, $new); | |
184 | } | |
185 | $self->SortChildren($dst); | |
186 | $self->Delete($src); | |
187 | my $sbalres = $dbh->lookup($sdata->[0], qw(Verdichtingen vdi_id vdi_balres)); | |
188 | my $dbalres = $dbh->lookup($ddata->[0], qw(Verdichtingen vdi_id vdi_balres)); | |
189 | $dbh->begin_work; | |
190 | $dbh->sql_exec("UPDATE Verdichtingen". | |
191 | " SET vdi_balres = ?". | |
192 | " WHERE vdi_id = ? OR vdi_struct = ?", | |
193 | $dbalres ? 1 : 0, $sdata->[0], $sdata->[0], | |
194 | )->finish; | |
195 | $dbh->sql_exec("UPDATE Accounts". | |
196 | " SET acc_balres = ?". | |
197 | " WHERE acc_struct IN ( SELECT vdi_id FROM Verdichtingen WHERE vdi_struct = ? )", | |
198 | $dbalres ? 1 : 0, $sdata->[0], | |
199 | )->finish unless $sbalres == $dbalres; | |
200 | $dbh->commit; | |
201 | } | |
202 | else { | |
203 | $self->{msg} = ["Een hoofdverdichting kan alleen worden verplaatst naar de hoofdgroep \"Balansrekeningen\" of \"Resultaatrekeningen\"", | |
204 | "Niet hier", | |
205 | wxOK|wxICON_HAND]; | |
206 | return; | |
207 | } | |
208 | } | |
209 | else { | |
210 | Wx::LogMessage("Cannot Drop $stype -> $dtype"); | |
211 | } | |
212 | } | |
213 | ||
214 | sub CopyChildren { | |
215 | my ($self, $src, $dst) = @_; | |
216 | my ($item, $cookie) = $self->GetFirstChild($src); | |
217 | while ( $item->IsOk ) { | |
218 | my $new = $self->AppendItem($dst, | |
219 | $self->GetItemText($item), | |
220 | -1, -1, | |
221 | Wx::TreeItemData->new($self->GetPlData($item))); | |
222 | if ( $self->ItemHasChildren($item) ) { | |
223 | $self->CopyChildren($item, $new); | |
224 | } | |
225 | ($item, $cookie) = $self->GetNextChild($src, $cookie); | |
226 | } | |
227 | $self->SetItemHasChildren($dst, 1); | |
228 | $self->Expand($dst) if $state->accexp->{$self->GetItemText($dst)}; | |
229 | } | |
230 | ||
231 | sub OnCompareItems { | |
232 | my ($self, $item1, $item2) = @_; | |
233 | $self->GetPlData($item1)->[0] <=> $self->GetPlData($item2)->[0]; | |
234 | } | |
235 | ||
236 | sub OnSelChange { | |
237 | my ($self, $event) = @_; | |
238 | my $item = $event->GetItem; | |
239 | my $data = $self->GetPlData($item); | |
240 | return unless $data && ref($data); | |
241 | return unless UNIVERSAL::can($data, "select"); | |
242 | $data->select($self, $event); | |
243 | } | |
244 | ||
245 | sub OnActivate { | |
246 | my ($self, $event) = @_; | |
247 | my $item = $event->GetItem; | |
248 | my $data = $self->GetPlData($item); | |
249 | return unless $data && ref($data); | |
250 | return unless UNIVERSAL::can($data, "activate"); | |
251 | $data->activate($self, $event); | |
252 | } | |
253 | ||
254 | sub OnExpand { | |
255 | my ($self, $event) = @_; | |
256 | my $item = $event->GetItem; | |
257 | my $text = $self->GetItemText($item); | |
258 | $state->accexp->{$text} = 1; | |
259 | } | |
260 | ||
261 | sub OnCollapse { | |
262 | my ($self, $event) = @_; | |
263 | my $item = $event->GetItem; | |
264 | my $text = $self->GetItemText($item); | |
265 | $state->accexp->{$text} = 0; | |
266 | } | |
267 | ||
268 | =begin ContextMenu | |
269 | ||
270 | use Wx qw(wxTREE_HITTEST_NOWHERE); | |
271 | ||
272 | sub OnRightClick { | |
273 | my ($self, $event) = @_; | |
274 | my ($item, $flags) = $self->HitTest($event->GetPosition); | |
275 | return if $flags & wxTREE_HITTEST_NOWHERE; | |
276 | $self->SelectItem($item); | |
277 | my $data = $self->GetPlData($item); | |
278 | my $ctx = UNIVERSAL::can($data, "ctxmenu"); | |
279 | return unless $ctx; | |
280 | $ctx->($data, $event, $self, $item); | |
281 | } | |
282 | ||
283 | =cut | |
284 | ||
285 | package EB::Wx::Maint::Accounts::TreeCtrl::StandardHandler; | |
286 | ||
287 | use strict; | |
288 | ||
289 | sub new { | |
290 | my ($class, $rr) = @_; | |
291 | $class = ref($class) || $class; | |
292 | bless [@$rr], $class; | |
293 | } | |
294 | ||
295 | sub select { | |
296 | my ($self, $ctrl, $event) = @_; | |
297 | print STDERR ("SEL: ", $self->[1], "\n"); | |
298 | } | |
299 | ||
300 | sub activate { | |
301 | my ($self, $ctrl, $event) = @_; | |
302 | print STDERR ("ACT: ", @_, "\n"); | |
303 | } | |
304 | ||
305 | =begin ContextMenu | |
306 | ||
307 | use constant CTXMENU_DELETE => Wx::NewId(); | |
308 | use constant CTXMENU_NEW => Wx::NewId(); | |
309 | use constant CTXMENU_RENAME => Wx::NewId(); | |
310 | use constant CTXMENU_OPEN => Wx::NewId(); | |
311 | use constant CTXMENU_EXPAND => Wx::NewId(); | |
312 | use constant CTXMENU_COLLAPSE => Wx::NewId(); | |
313 | ||
314 | use Wx qw(wxYES_NO wxYES wxNO_DEFAULT wxICON_QUESTION); | |
315 | ||
316 | use Wx::Event qw(EVT_MENU EVT_TREE_END_LABEL_EDIT); | |
317 | ||
318 | sub ctxmenu { | |
319 | my ($self, $event, $ctl, $item) = @_; # (this instance, click event, tree ctrl, tree item) | |
320 | my $ctxmenu = Wx::Menu->new(""); | |
321 | $ctxmenu->Append(CTXMENU_OPEN, "Details"); | |
322 | if ( $ctl->ItemHasChildren($item) ) { | |
323 | $ctxmenu->Append(CTXMENU_EXPAND, "Uitvouwen"); | |
324 | $ctxmenu->Append(CTXMENU_COLLAPSE, "Dichtvouwen"); | |
325 | } | |
326 | # $ctxmenu->Append(CTXMENU_RENAME, "Omschrijving wijzigen"); | |
327 | $ctxmenu->AppendSeparator; | |
328 | $ctxmenu->Append(CTXMENU_NEW, "Nieuw ..."); | |
329 | # $ctxmenu->AppendSeparator; | |
330 | # $ctxmenu->Append(CTXMENU_DELETE, "Verwijderen"); | |
331 | ||
332 | EVT_MENU($ctl, CTXMENU_OPEN, sub { $self->activate($ctl, $item) }); | |
333 | EVT_MENU($ctl, CTXMENU_EXPAND, sub { $ctl->Expand($item) }); | |
334 | EVT_MENU($ctl, CTXMENU_COLLAPSE, sub { $ctl->Collapse($item) }); | |
335 | ||
336 | EVT_MENU($ctl, CTXMENU_RENAME, | |
337 | sub { | |
338 | my $t = $ctl->GetItemText($item); | |
339 | $t = $1 if $t =~ /^\d+\s+(.*)/; | |
340 | $ctl->SetItemText($item, $t); | |
341 | $ctl->EditLabel($item); | |
342 | }); | |
343 | ||
344 | EVT_TREE_END_LABEL_EDIT($ctl, $ctl, | |
345 | sub { | |
346 | my (undef, $event) = @_; | |
347 | if ( $event->IsEditCancelled ) { | |
348 | my $t = $ctl->GetItemText($item); | |
349 | $ctl->SetItemText($item, $self->[0] . " " . $t); | |
350 | return; | |
351 | } | |
352 | ||
353 | my $t = $event->GetLabel; | |
354 | $self->[1] = $t; | |
355 | Wx::LogMessage("New label for %d: %s", $self->[0], $t); | |
356 | $dbh->begin_work; | |
357 | $dbh->sql_exec("UPDATE Accounts SET acc_desc = ? WHERE acc_id = ?", | |
358 | $self->[1], $self->[0])->finish; | |
359 | $dbh->commit; | |
360 | # The new text is stored upon completion of this event. | |
361 | # Use the IDLE loop to fix the contents. | |
362 | $ctl->{fix} = [ $item, $self->[0] . " " . $t ]; | |
363 | ||
364 | if ( $app->{TOP}->{d_maccpanel}->curr_id == $self->[0] ) { | |
365 | $app->{TOP}->{d_maccpanel}->set_desc($t); | |
366 | } | |
367 | }); | |
368 | ||
369 | EVT_MENU($ctl, CTXMENU_DELETE, | |
370 | sub { | |
371 | # my ($self, $event) = @_; | |
372 | my ($aid) = $self->[0]; | |
373 | my $r = EB::Wx::MessageDialog | |
374 | ($self, | |
375 | "$aid: " . ($self->[1]) . "\n" . | |
376 | "Wilt u deze rekening verwijderen?", | |
377 | "Bevestig", | |
378 | wxYES_NO|wxNO_DEFAULT|wxICON_QUESTION); | |
379 | return unless $r == wxYES; | |
380 | $dbh->begin_work; | |
381 | $dbh->sql_exec("DELETE FROM Accounts WHERE acc_id = ?", | |
382 | $aid)->finish; | |
383 | $dbh->commit; | |
384 | $ctl->Delete($item); | |
385 | }); | |
386 | ||
387 | EVT_MENU($ctl, CTXMENU_NEW, | |
388 | sub { | |
389 | # my ($self, $event) = @_; | |
390 | my $p = $app->{TOP}->{d_maccpanel}; | |
391 | $p->newentry($self->[0]); | |
392 | }); | |
393 | ||
394 | $ctl->PopupMenu($ctxmenu, $event->GetPosition); | |
395 | } | |
396 | ||
397 | =cut | |
398 | ||
399 | package EB::Wx::Maint::Accounts::TreeCtrl::GrootboekHandler; | |
400 | ||
401 | use strict; | |
402 | use base qw(EB::Wx::Maint::Accounts::TreeCtrl::StandardHandler); | |
403 | ||
404 | sub description { "Grootboekrekeningen" } | |
405 | ||
406 | sub populate { | |
407 | my ($self, $ctrl, $parent, $id) = @_; | |
408 | ||
409 | my $sth = $dbh->sql_exec("SELECT vdi_id,vdi_desc FROM Verdichtingen". | |
410 | " WHERE vdi_struct ". | |
411 | (defined($id) ? " = $id" : "IS NULL"). | |
412 | " AND " .($self->type eq "balans" ? "" : "NOT") . " vdi_balres". | |
413 | " ORDER BY vdi_id"); | |
414 | ||
415 | my $rr; | |
416 | my $rows; | |
417 | ||
418 | while ( $rr = $sth->fetchrow_arrayref ) { | |
419 | $rows++; | |
420 | my $text = "$rr->[0] $rr->[1]"; | |
421 | my $item = $ctrl->AppendItem($parent, $text, -1, -1, | |
422 | Wx::TreeItemData->new(__PACKAGE__->new([@$rr,defined($id)]))); | |
423 | $self->populate($ctrl, $item, $rr->[0]); | |
424 | $ctrl->Expand($item) if $state->accexp->{$text}; | |
425 | } | |
426 | unless ( $rows ) { | |
427 | $sth->finish; | |
428 | $sth = $dbh->sql_exec("SELECT acc_id,acc_desc FROM Accounts". | |
429 | " WHERE acc_struct = ?". | |
430 | " ORDER BY acc_id", $id); | |
431 | ||
432 | while ( $rr = $sth->fetchrow_arrayref ) { | |
433 | my $id = $rr->[0]; | |
434 | my $text = $rr->[1]; | |
435 | my $item = $ctrl->AppendItem($parent, "$id $text", -1, -1, | |
436 | Wx::TreeItemData->new(__PACKAGE__->new([@$rr,2]))); | |
437 | } | |
438 | } | |
439 | } | |
440 | ||
441 | sub select { | |
442 | my ($self, $ctrl, $event) = @_; | |
443 | my $item = $event->GetItem; | |
444 | my $data = $ctrl->GetPlData($item); | |
445 | } | |
446 | ||
447 | sub activate { | |
448 | my ($self, $ctrl, $event) = @_; | |
449 | my $item = UNIVERSAL::isa($event, 'Wx::TreeItemId') ? $event : $event->GetItem; | |
450 | my $data = $ctrl->GetPlData($item); | |
451 | $app->{TOP}->{d_maccpanel}->set_item($data->[0], $data->[2], $ctrl, $item); | |
452 | } | |
453 | ||
454 | package EB::Wx::Maint::Accounts::TreeCtrl::BalansHandler; | |
455 | ||
456 | use strict; | |
457 | use base qw(EB::Wx::Maint::Accounts::TreeCtrl::GrootboekHandler); | |
458 | ||
459 | sub description { "Balansrekeningen" } | |
460 | ||
461 | sub type { "balans" }; | |
462 | ||
463 | package EB::Wx::Maint::Accounts::TreeCtrl::ResultaatHandler; | |
464 | ||
465 | use strict; | |
466 | use base qw(EB::Wx::Maint::Accounts::TreeCtrl::GrootboekHandler); | |
467 | ||
468 | sub description { "Resultaatrekeningen" } | |
469 | ||
470 | sub type { "result" }; | |
471 | ||
472 | 1; |
0 | #! perl -- -*- coding: utf-8 -*- | |
1 | ||
2 | use utf8; | |
3 | ||
4 | # $Id: Accounts.pm,v 1.12 2009/10/14 21:14:01 jv Exp $ | |
5 | ||
6 | package main; | |
7 | ||
8 | our $state; | |
9 | our $dbh; | |
10 | our $app; | |
11 | ||
12 | package EB::Wx::Maint::Accounts; | |
13 | ||
14 | use Wx qw[:everything]; | |
15 | use base qw(Wx::Dialog); | |
16 | use base qw(EB::Wx::Window); | |
17 | use strict; | |
18 | ||
19 | use EB; | |
20 | use EB::Format; | |
21 | ||
22 | # begin wxGlade: ::dependencies | |
23 | use EB::Wx::Maint::Accounts::TreeCtrl; | |
24 | use EB::Wx::UI::NumericCtrl; | |
25 | use EB::Wx::UI::HvdInput; | |
26 | use EB::Wx::UI::VdiInput; | |
27 | use EB::Wx::UI::BTWInput; | |
28 | # end wxGlade | |
29 | ||
30 | sub new { | |
31 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
32 | $parent = undef unless defined $parent; | |
33 | $id = -1 unless defined $id; | |
34 | $pos = wxDefaultPosition unless defined $pos; | |
35 | $size = wxDefaultSize unless defined $size; | |
36 | $name = "" unless defined $name; | |
37 | ||
38 | $state->set("accexp", {}) unless $state->accexp; | |
39 | ||
40 | # begin wxGlade: EB::Wx::Maint::Accounts::new | |
41 | ||
42 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTHICK_FRAME | |
43 | unless defined $style; | |
44 | ||
45 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
46 | $self->{w_acc_frame} = Wx::SplitterWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_BORDER); | |
47 | $self->{maint_pane_outer} = Wx::Panel->new($self->{w_acc_frame}, -1, wxDefaultPosition, wxDefaultSize, ); | |
48 | $self->{maint_pane} = Wx::Panel->new($self->{maint_pane_outer}, -1, wxDefaultPosition, wxDefaultSize, ); | |
49 | $self->{sz_acc_staticbox} = Wx::StaticBox->new($self->{maint_pane}, -1, _T("Grootboekrekening") ); | |
50 | $self->{sz_btw_staticbox} = Wx::StaticBox->new($self->{maint_pane}, -1, _T("BTW Tarief") ); | |
51 | $self->{sz_saldo_staticbox} = Wx::StaticBox->new($self->{maint_pane}, -1, _T("Saldo") ); | |
52 | $self->{tree_pane} = Wx::Panel->new($self->{w_acc_frame}, -1, wxDefaultPosition, wxDefaultSize, ); | |
53 | $self->{acc_tree} = EB::Wx::Maint::Accounts::TreeCtrl->new($self->{tree_pane}, -1, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS|wxTR_NO_LINES|wxTR_HIDE_ROOT|wxTR_DEFAULT_STYLE|wxSUNKEN_BORDER); | |
54 | $self->{l_acc_id} = Wx::StaticText->new($self->{maint_pane}, -1, _T("Nr."), wxDefaultPosition, wxDefaultSize, ); | |
55 | $self->{l_acc_desc} = Wx::StaticText->new($self->{maint_pane}, -1, _T("Omschrijving"), wxDefaultPosition, wxDefaultSize, ); | |
56 | $self->{t_acc_id} = EB::Wx::UI::NumericCtrl->new($self->{maint_pane}, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_READONLY); | |
57 | $self->{t_acc_desc} = Wx::TextCtrl->new($self->{maint_pane}, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
58 | $self->{l_vrd} = Wx::StaticText->new($self->{maint_pane}, -1, _T("Indeling"), wxDefaultPosition, wxDefaultSize, ); | |
59 | $self->{ch_vdi} = EB::Wx::UI::VdiInput->new($self->{maint_pane}, -1, wxDefaultPosition, wxDefaultSize, [], ); | |
60 | $self->{ch_hvd} = EB::Wx::UI::HvdInput->new($self->{maint_pane}, -1, wxDefaultPosition, wxDefaultSize, [], ); | |
61 | $self->{ch_balres} = Wx::Choice->new($self->{maint_pane}, -1, wxDefaultPosition, wxDefaultSize, [_T("Resultaatrekeningen"), _T("Balansrekeningen")], ); | |
62 | $self->{rb_debcrd} = Wx::RadioBox->new($self->{maint_pane}, -1, _T("Richting"), wxDefaultPosition, wxDefaultSize, [_T("Debet"), _T("Credit")], 0, wxRA_SPECIFY_ROWS); | |
63 | $self->{rb_kstomz} = Wx::RadioBox->new($self->{maint_pane}, -1, _T("Soort"), wxDefaultPosition, wxDefaultSize, [_T("Neutraal"), _T("Kosten"), _T("Omzet")], 0, wxRA_SPECIFY_ROWS); | |
64 | $self->{ch_btw} = EB::Wx::UI::BTWInput->new($self->{maint_pane}, -1, wxDefaultPosition, wxDefaultSize, [], ); | |
65 | $self->{l_saldo_opening} = Wx::StaticText->new($self->{maint_pane}, -1, _T("Opening"), wxDefaultPosition, wxDefaultSize, ); | |
66 | $self->{t_saldo_opening} = Wx::StaticText->new($self->{maint_pane}, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
67 | $self->{l_saldo_act} = Wx::StaticText->new($self->{maint_pane}, -1, _T("Actueel"), wxDefaultPosition, wxDefaultSize, ); | |
68 | $self->{t_saldo_act} = Wx::StaticText->new($self->{maint_pane}, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
69 | $self->{b_add} = Wx::Button->new($self->{maint_pane}, -1, _T("Dupliceren")); | |
70 | $self->{b_del} = Wx::Button->new($self->{maint_pane}, -1, _T("Verwijderen")); | |
71 | $self->{l_msg} = Wx::StaticText->new($self->{maint_pane_outer}, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
72 | $self->{static_line_2} = Wx::StaticLine->new($self->{maint_pane_outer}, -1, wxDefaultPosition, wxDefaultSize, ); | |
73 | $self->{b_accept} = Wx::Button->new($self->{maint_pane_outer}, wxID_APPLY, ""); | |
74 | $self->{b_reset} = Wx::Button->new($self->{maint_pane_outer}, wxID_REVERT_TO_SAVED, ""); | |
75 | $self->{b_cancel} = Wx::Button->new($self->{maint_pane_outer}, wxID_CANCEL, ""); | |
76 | ||
77 | $self->__set_properties(); | |
78 | $self->__do_layout(); | |
79 | ||
80 | Wx::Event::EVT_TEXT($self, $self->{t_acc_id}->GetId, \&OnAccIdChanged); | |
81 | Wx::Event::EVT_TEXT($self, $self->{t_acc_desc}->GetId, \&OnAccDescChanged); | |
82 | Wx::Event::EVT_CHOICE($self, $self->{ch_vdi}->GetId, \&OnVdiChanged); | |
83 | Wx::Event::EVT_CHOICE($self, $self->{ch_hvd}->GetId, \&OnHvdChanged); | |
84 | Wx::Event::EVT_CHOICE($self, $self->{ch_balres}->GetId, \&OnBalresChanged); | |
85 | Wx::Event::EVT_RADIOBOX($self, $self->{rb_debcrd}->GetId, \&OnDebcrdClicked); | |
86 | Wx::Event::EVT_RADIOBOX($self, $self->{rb_kstomz}->GetId, \&OnKstomzClicked); | |
87 | Wx::Event::EVT_CHOICE($self, $self->{ch_btw}->GetId, \&OnBtwChanged); | |
88 | Wx::Event::EVT_BUTTON($self, $self->{b_add}->GetId, \&OnAdd); | |
89 | Wx::Event::EVT_BUTTON($self, $self->{b_del}->GetId, \&OnDel); | |
90 | Wx::Event::EVT_BUTTON($self, $self->{b_accept}->GetId, \&OnAccept); | |
91 | Wx::Event::EVT_BUTTON($self, $self->{b_reset}->GetId, \&OnReset); | |
92 | Wx::Event::EVT_BUTTON($self, $self->{b_cancel}->GetId, \&OnClose); | |
93 | Wx::Event::EVT_SPLITTER_SASH_POS_CHANGED($self, $self->{w_acc_frame}->GetId, \&OnSashPosChanged); | |
94 | ||
95 | # end wxGlade | |
96 | ||
97 | $self->{busy} = 0; | |
98 | ||
99 | Wx::Event::EVT_MENU($self, wxID_CLOSE, \&OnClose); | |
100 | Wx::Event::EVT_CLOSE($self, \&OnClose); | |
101 | # Wx::Event::EVT_KILL_FOCUS($self->{t_acc_id}, \&OnAccIdLosesFocus); | |
102 | Wx::Event::EVT_IDLE($self, \&OnIdle); | |
103 | ||
104 | $self->{maint_pane}->Enable(0); | |
105 | ||
106 | return $self; | |
107 | ||
108 | } | |
109 | ||
110 | sub __set_properties { | |
111 | my $self = shift; | |
112 | ||
113 | # begin wxGlade: EB::Wx::Maint::Accounts::__set_properties | |
114 | ||
115 | $self->{ch_vdi}->Show(0); | |
116 | $self->{ch_vdi}->SetSelection(0); | |
117 | $self->{ch_hvd}->Show(0); | |
118 | $self->{ch_hvd}->SetSelection(0); | |
119 | $self->{ch_balres}->SetSelection(0); | |
120 | $self->{rb_debcrd}->SetSelection(0); | |
121 | $self->{rb_kstomz}->Show(0); | |
122 | $self->{rb_kstomz}->SetSelection(0); | |
123 | $self->{ch_btw}->SetSelection(0); | |
124 | $self->{b_add}->Enable(0); | |
125 | $self->{b_del}->Enable(0); | |
126 | $self->{maint_pane}->Enable(0); | |
127 | $self->{b_accept}->Enable(0); | |
128 | $self->{b_reset}->Enable(0); | |
129 | $self->{b_cancel}->SetFocus(); | |
130 | $self->{b_cancel}->SetDefault(); | |
131 | $self->{w_acc_frame}->SetMinSize($self->{w_acc_frame}->ConvertDialogSizeToPixels(Wx::Size->new(338, 181))); | |
132 | ||
133 | # end wxGlade | |
134 | } | |
135 | ||
136 | sub __do_layout { | |
137 | my $self = shift; | |
138 | ||
139 | # begin wxGlade: EB::Wx::Maint::Accounts::__do_layout | |
140 | ||
141 | $self->{acc_frame_sizer} = Wx::BoxSizer->new(wxHORIZONTAL); | |
142 | $self->{sz_accx} = Wx::BoxSizer->new(wxVERTICAL); | |
143 | $self->{sz_acccan} = Wx::BoxSizer->new(wxHORIZONTAL); | |
144 | $self->{sz_accy} = Wx::BoxSizer->new(wxVERTICAL); | |
145 | $self->{sz_adddel} = Wx::BoxSizer->new(wxHORIZONTAL); | |
146 | $self->{sz_saldo}= Wx::StaticBoxSizer->new($self->{sz_saldo_staticbox}, wxHORIZONTAL); | |
147 | $self->{gr_saldo} = Wx::FlexGridSizer->new(2, 2, 3, 5); | |
148 | $self->{sz_btw}= Wx::StaticBoxSizer->new($self->{sz_btw_staticbox}, wxHORIZONTAL); | |
149 | $self->{sz_properties} = Wx::BoxSizer->new(wxHORIZONTAL); | |
150 | $self->{sz_acc}= Wx::StaticBoxSizer->new($self->{sz_acc_staticbox}, wxHORIZONTAL); | |
151 | $self->{sz_id} = Wx::FlexGridSizer->new(4, 2, 3, 5); | |
152 | $self->{sz_vrd} = Wx::BoxSizer->new(wxVERTICAL); | |
153 | $self->{sz_addrem} = Wx::BoxSizer->new(wxHORIZONTAL); | |
154 | $self->{sz_tree} = Wx::BoxSizer->new(wxHORIZONTAL); | |
155 | $self->{sz_tree}->Add($self->{acc_tree}, 1, wxEXPAND, 0); | |
156 | $self->{tree_pane}->SetSizer($self->{sz_tree}); | |
157 | $self->{sz_id}->Add($self->{l_acc_id}, 0, wxEXPAND|wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
158 | $self->{sz_id}->Add($self->{l_acc_desc}, 0, wxEXPAND|wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
159 | $self->{sz_id}->Add($self->{t_acc_id}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
160 | $self->{sz_id}->Add($self->{t_acc_desc}, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
161 | $self->{sz_id}->Add(2, 2, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
162 | $self->{sz_id}->Add($self->{l_vrd}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
163 | $self->{sz_addrem}->Add(2, 2, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
164 | $self->{sz_id}->Add($self->{sz_addrem}, 1, wxEXPAND, 0); | |
165 | $self->{sz_vrd}->Add($self->{ch_vdi}, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
166 | $self->{sz_vrd}->Add($self->{ch_hvd}, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
167 | $self->{sz_vrd}->Add($self->{ch_balres}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
168 | $self->{sz_id}->Add($self->{sz_vrd}, 1, wxEXPAND, 0); | |
169 | $self->{sz_id}->AddGrowableCol(1); | |
170 | $self->{sz_acc}->Add($self->{sz_id}, 1, wxEXPAND|wxADJUST_MINSIZE, 5); | |
171 | $self->{sz_accy}->Add($self->{sz_acc}, 0, wxALL|wxEXPAND, 5); | |
172 | $self->{sz_properties}->Add($self->{rb_debcrd}, 1, wxEXPAND|wxADJUST_MINSIZE, 5); | |
173 | $self->{sz_properties}->Add($self->{rb_kstomz}, 1, wxLEFT|wxEXPAND|wxADJUST_MINSIZE, 5); | |
174 | $self->{sz_accy}->Add($self->{sz_properties}, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND|wxADJUST_MINSIZE, 5); | |
175 | $self->{sz_btw}->Add($self->{ch_btw}, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
176 | $self->{sz_accy}->Add($self->{sz_btw}, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND|wxADJUST_MINSIZE, 5); | |
177 | $self->{gr_saldo}->Add($self->{l_saldo_opening}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
178 | $self->{gr_saldo}->Add($self->{t_saldo_opening}, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
179 | $self->{gr_saldo}->Add($self->{l_saldo_act}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
180 | $self->{gr_saldo}->Add($self->{t_saldo_act}, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
181 | $self->{gr_saldo}->AddGrowableCol(1); | |
182 | $self->{sz_saldo}->Add($self->{gr_saldo}, 1, wxEXPAND, 5); | |
183 | $self->{sz_accy}->Add($self->{sz_saldo}, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND|wxADJUST_MINSIZE, 5); | |
184 | $self->{sz_adddel}->Add($self->{b_add}, 0, wxLEFT|wxBOTTOM|wxADJUST_MINSIZE, 5); | |
185 | $self->{sz_adddel}->Add($self->{b_del}, 0, wxLEFT|wxBOTTOM|wxADJUST_MINSIZE, 5); | |
186 | $self->{sz_adddel}->Add(2, 2, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
187 | $self->{sz_accy}->Add($self->{sz_adddel}, 0, wxEXPAND, 0); | |
188 | $self->{maint_pane}->SetSizer($self->{sz_accy}); | |
189 | $self->{sz_accx}->Add($self->{maint_pane}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
190 | $self->{sz_accx}->Add($self->{l_msg}, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
191 | $self->{sz_accx}->Add(1, 5, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
192 | $self->{sz_accx}->Add($self->{static_line_2}, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 5); | |
193 | $self->{sz_acccan}->Add($self->{b_accept}, 0, wxLEFT|wxBOTTOM|wxEXPAND|wxADJUST_MINSIZE, 5); | |
194 | $self->{sz_acccan}->Add($self->{b_reset}, 0, wxLEFT|wxADJUST_MINSIZE, 5); | |
195 | $self->{sz_acccan}->Add(5, 0, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
196 | $self->{sz_acccan}->Add($self->{b_cancel}, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND|wxADJUST_MINSIZE, 5); | |
197 | $self->{sz_accx}->Add($self->{sz_acccan}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
198 | $self->{maint_pane_outer}->SetSizer($self->{sz_accx}); | |
199 | $self->{w_acc_frame}->SplitVertically($self->{tree_pane}, $self->{maint_pane_outer}, 350); | |
200 | $self->{acc_frame_sizer}->Add($self->{w_acc_frame}, 1, wxEXPAND, 0); | |
201 | $self->SetSizer($self->{acc_frame_sizer}); | |
202 | $self->{acc_frame_sizer}->Fit($self); | |
203 | $self->Layout(); | |
204 | ||
205 | # end wxGlade | |
206 | ||
207 | $self->{w_acc_frame}->SetSashPosition($state->accsash); | |
208 | ||
209 | } | |
210 | ||
211 | sub _nf { | |
212 | my ($v, $debcrd) = @_; | |
213 | my $t = numfmt(abs($v)); | |
214 | $t = (" " x (AMTWIDTH - length($t))) . $t; | |
215 | $t . " " . (($debcrd xor ($v < 0)) ? "Credit" : ($v ? "Debet" : "")); | |
216 | } | |
217 | ||
218 | sub _kstomz_code { | |
219 | my ($self, $k) = @_; | |
220 | defined $k ? 0 : $k ? 1 : 2; | |
221 | } | |
222 | ||
223 | sub _code_kstomz { | |
224 | my ($self, $c) = @_; | |
225 | (undef, 0, 1)[$c]; | |
226 | } | |
227 | ||
228 | sub set_item { | |
229 | my ($self, $id, $type, $ctrl, $item) = @_; | |
230 | if ( $type == 2 ) { # Account | |
231 | $self->set_acc($id, $ctrl, $item); | |
232 | } | |
233 | else { | |
234 | $self->set_vrd($id, $type, $ctrl, $item); | |
235 | } | |
236 | } | |
237 | ||
238 | sub set_acc { | |
239 | my ($self, $id, $ctrl, $item) = @_; | |
240 | ||
241 | local($self->{busy}) = 1; | |
242 | my $rr = $dbh->do("SELECT acc_desc, acc_balres, acc_kstomz, acc_debcrd, acc_btw,". | |
243 | " acc_balance, acc_ibalance, acc_struct FROM Accounts". | |
244 | " WHERE acc_id = ?", $id); | |
245 | ||
246 | $self->{_type} = "acc"; | |
247 | $self->{_ctrl} = $ctrl; | |
248 | $self->{_item} = $item; | |
249 | ||
250 | my $l = ($rr->[1] ? "Balans" : "Resultaat")."rekening"; | |
251 | $self->{_what} = $l; | |
252 | $self->{sz_acc}->GetStaticBox->SetLabel($l); | |
253 | $self->{b_add}->SetToolTipString(_T("Maak een nieuwe ".lc($l)." door deze te dupliceren")); | |
254 | $self->{b_del}->SetToolTipString(_T("Deze ".lc($l)." verwijderen")); | |
255 | ||
256 | $self->{t_acc_id}->SetValue($self->{_id} = $id); | |
257 | $self->{t_acc_id}->Enable(0); | |
258 | $self->{t_acc_desc}->SetValue($self->{_desc} = $rr->[0]); | |
259 | $self->{_balres} = $rr->[1]; | |
260 | $self->{_kstomz} = $self->_kstomz_code($rr->[2]); | |
261 | $self->{rb_kstomz}->SetSelection($self->{_kstomz}); | |
262 | $self->{rb_debcrd}->SetSelection(!($self->{_debcrd} = $rr->[3])); | |
263 | $self->{rb_debcrd}->Show($self->{_balres}); | |
264 | $self->{rb_kstomz}->Show(1); | |
265 | $self->{sz_properties}->Layout; | |
266 | $self->{ch_btw}->SetValue($self->{_btw} = $rr->[4]); | |
267 | $self->{ch_vdi}->SetValue($self->{_vdi} = $rr->[7]); | |
268 | $self->{t_saldo_act}->SetLabel(_nf($rr->[5], $rr->[3])); | |
269 | $self->{t_saldo_opening}->SetLabel(_nf($rr->[6], $rr->[3])); | |
270 | ||
271 | $self->{sz_acc}->Show($self->{sz_btw}, 1); | |
272 | $self->{sz_acc}->Show($self->{sz_saldo}, 1); | |
273 | $self->{sz_acc}->Layout; | |
274 | ||
275 | my $inuse = $dbh->acc_inuse($id); | |
276 | foreach ( qw(rb_kstomz rb_debcrd b_del) ) { | |
277 | $self->{$_}->Enable(!$inuse); | |
278 | } | |
279 | $self->{sz_adddel}->Show($self->{b_add}, 1); | |
280 | $self->{sz_adddel}->Show($self->{b_del}, 1); | |
281 | $self->{maint_pane}->Show(1); | |
282 | $self->{l_msg}->Show(0); | |
283 | foreach ( qw(b_add) ) { | |
284 | #$self->{$_}->Enable($rr->[0]); | |
285 | $self->{$_}->Enable(1); | |
286 | } | |
287 | for ( !$rr->[0] && $self->{_kstomz} ) { | |
288 | $self->{ch_btw}->Enable($_); | |
289 | $self->{sz_btw_staticbox}->Enable($_); | |
290 | } | |
291 | ||
292 | $self->{b_accept}->Enable(0); | |
293 | $self->{b_reset}->Enable(0); | |
294 | $self->{maint_pane}->Enable(1); | |
295 | $self->{struct} = 0; | |
296 | $self->{sz_vrd}->Show($self->{ch_balres}, 0); | |
297 | $self->{sz_vrd}->Show($self->{ch_hvd}, 0); | |
298 | $self->{sz_vrd}->Show($self->{ch_vdi}, 1); | |
299 | $self->{l_vrd}->SetLabel("Verdichting"); | |
300 | $self->{sz_accy}->Show($self->{sz_btw}, 1); | |
301 | $self->{sz_accy}->Show($self->{sz_saldo}, 1); | |
302 | $self->Layout; | |
303 | $dbh->trace(1); | |
304 | } | |
305 | ||
306 | sub set_vrd { | |
307 | my ($self, $id, $type, $ctrl, $item) = @_; | |
308 | ||
309 | local($self->{busy}) = 1; | |
310 | my $rr = $dbh->do("SELECT vdi_desc, vdi_balres, vdi_kstomz, vdi_struct". | |
311 | " FROM Verdichtingen". | |
312 | " WHERE vdi_id = ?", $id); | |
313 | ||
314 | $self->{_type} = $rr->[3] ? "vdi" : "hvd"; | |
315 | $self->{_ctrl} = $ctrl; | |
316 | $self->{_item} = $item; | |
317 | ||
318 | my $l = ($rr->[1] ? "Balans" : "Resultaat"). | |
319 | ($rr->[3] ? "" : "hoofd"). | |
320 | "verdichting"; | |
321 | $self->{sz_acc}->GetStaticBox->SetLabel($l); | |
322 | $self->{b_add}->SetToolTipString(_T("$l toevoegen")); | |
323 | $self->{b_del}->SetToolTipString(_T("Deze ".lc($l)." verwijderen")); | |
324 | ||
325 | $self->{t_acc_id}->SetValue($self->{_id} = $id); | |
326 | $self->{t_acc_id}->Enable(0); | |
327 | $self->{t_acc_desc}->SetValue($self->{_desc} = $rr->[0]); | |
328 | $self->{_balres} = $rr->[1]; | |
329 | $self->{_kstomz} = $self->_kstomz_code($rr->[2]); | |
330 | $self->{rb_kstomz}->SetSelection($self->{_kstomz}); | |
331 | $self->{rb_debcrd}->Show(0); | |
332 | $self->{sz_properties}->Layout; | |
333 | ||
334 | $self->{sz_acc}->Show($self->{sz_btw}, 0); | |
335 | $self->{sz_acc}->Show($self->{sz_saldo}, 0); | |
336 | $self->{l_vrd}->SetLabel($rr->[3] ? "Hoofdverdichting" : "Indeling"); | |
337 | if ( $self->{_type} eq "vdi" ) { | |
338 | $self->{sz_vrd}->Show($self->{ch_balres}, 0); | |
339 | $self->{ch_hvd}->SetValue($self->{_vdi} = $rr->[3]); | |
340 | $self->{sz_vrd}->Show($self->{ch_hvd}, 1); | |
341 | $self->{sz_vrd}->Show($self->{ch_vdi}, 0); | |
342 | } | |
343 | else { | |
344 | $self->{ch_balres}->SetSelection($self->{_balres}); | |
345 | $self->{sz_vrd}->Show($self->{ch_balres}, 1); | |
346 | $self->{sz_vrd}->Show($self->{ch_vdi}, 0); | |
347 | $self->{sz_vrd}->Show($self->{ch_hvd}, 0); | |
348 | } | |
349 | $self->{maint_pane}->Show(1); | |
350 | $self->{l_msg}->Show(0); | |
351 | ||
352 | $self->{sz_adddel}->Show($self->{b_add}, 0); | |
353 | $self->{sz_adddel}->Show($self->{b_del}, 0); | |
354 | $self->{b_accept}->Enable(0); | |
355 | $self->{b_reset}->Enable(0); | |
356 | $self->{maint_pane}->Enable(1); | |
357 | $self->{struct} = 0; | |
358 | $self->{sz_accy}->Show($self->{sz_btw}, 0); | |
359 | $self->{sz_accy}->Show($self->{sz_saldo}, 0); | |
360 | $self->Layout; | |
361 | $dbh->trace(1); | |
362 | } | |
363 | ||
364 | sub newentry { | |
365 | my ($self, $pid) = @_; | |
366 | ||
367 | if ( $self->{b_accept}->IsEnabled ) { | |
368 | Wx::Bell; | |
369 | return; | |
370 | } | |
371 | my $rr = $dbh->do("SELECT acc_struct FROM Accounts WHERE acc_id = ?", $pid); | |
372 | $pid = $rr->[0] if $rr; | |
373 | $rr = $dbh->do("SELECT vdi_balres, vdi_kstomz FROM Verdichtingen WHERE vdi_id = ?", $pid); | |
374 | unless ( $rr ) { | |
375 | Wx::Bell; | |
376 | return; | |
377 | } | |
378 | $self->{struct} = $self->{_vdi} = $pid; | |
379 | ||
380 | $self->{_type} = "acc"; | |
381 | $self->{t_acc_id}->SetValue($self->{_id} = ""); | |
382 | $self->{t_acc_id}->Enable(1); | |
383 | $self->{t_acc_desc}->SetValue($self->{_desc}); | |
384 | $self->{_balres} = $rr->[0]; | |
385 | $self->{_kstomz} = $self->_kstomz_code($rr->[1]); | |
386 | $self->{rb_kstomz}->SetSelection($self->{_kstomz}); | |
387 | $self->{rb_debcrd}->SetSelection(!($self->{_debcrd} = 1)); | |
388 | $self->{rb_debcrd}->Show(1); | |
389 | $self->{ch_btw}->SetValue($self->{_btw} = 0); | |
390 | $self->{t_saldo_act}->SetLabel(""); | |
391 | $self->{t_saldo_opening}->SetLabel(""); | |
392 | ||
393 | $self->{sz_acc}->Show($self->{sz_btw}, 1); | |
394 | $self->{sz_acc}->Show($self->{sz_saldo}, 0); | |
395 | ||
396 | $self->{sz_adddel}->Show($self->{b_add}, 0); | |
397 | $self->{sz_adddel}->Show($self->{b_del}, 0); | |
398 | ||
399 | foreach ( qw(rb_kstomz rb_debcrd ch_btw sz_btw_staticbox) ) { | |
400 | $self->{$_}->Enable(1); | |
401 | } | |
402 | $self->{sz_adddel}->Show($self->{b_add}, 0); | |
403 | $self->{sz_adddel}->Show($self->{b_del}, 0); | |
404 | $self->{maint_pane}->Show(1); | |
405 | $self->{l_msg}->Show(1); | |
406 | $self->{l_msg}->SetLabel(__x("Druk op de knop [{apply}] om deze ".lc($self->{sz_acc}->GetStaticBox->GetLabel)." toe te voegen.", | |
407 | apply => _T("Toepassen"))); | |
408 | $self->Layout; | |
409 | ||
410 | $self->{b_accept}->Enable(0); | |
411 | $self->{b_reset}->Enable(0); | |
412 | $self->{maint_pane}->Enable(1); | |
413 | ||
414 | $self->Layout; | |
415 | } | |
416 | ||
417 | sub curr_id { | |
418 | my ($self) = @_; | |
419 | $self->{_id}; | |
420 | } | |
421 | ||
422 | sub set_desc { | |
423 | my ($self, $desc) = @_; | |
424 | $self->{t_acc_desc}->SetValue($self->{_desc} = $desc); | |
425 | } | |
426 | ||
427 | sub changed { | |
428 | my ($self) = @_; | |
429 | $self->{struct} and return 1; | |
430 | $self->{_id} or return 0; | |
431 | $self->{t_acc_id}->GetValue or return 1; | |
432 | $self->{t_acc_id}->GetValue != $self->{_id} and return 1; | |
433 | $self->{t_acc_desc}->GetValue ne $self->{_desc} and return 1; | |
434 | $self->{rb_kstomz}->GetSelection != $self->{_kstomz} and return 1; | |
435 | $self->{_type} eq "acc" and $self->{ch_vdi}->GetValue != $self->{_vdi} and return 1; | |
436 | $self->{_type} eq "vdi" and $self->{ch_hvd}->GetValue != $self->{_vdi} and return 1; | |
437 | $self->{_type} eq "hvd" and $self->{ch_balres}->GetSelection != $self->{_balres} and return 1; | |
438 | $self->{_type} ne "acc" and return 0; | |
439 | $self->{rb_debcrd}->GetSelection == $self->{_debcrd} and return 1; | |
440 | $self->{ch_btw}->GetValue != $self->{_btw} and return 1; | |
441 | } | |
442 | ||
443 | sub check_id { | |
444 | my ($self) = @_; | |
445 | my $obj = $self->{t_acc_id}; | |
446 | return 1 if $obj->GetValue == $self->{_id}; | |
447 | if ( $self->{_id} ) { | |
448 | my $rr = $dbh->do("SELECT COUNT(*) FROM Journal WHERE jnl_acc_id = ?", $self->{_id}); | |
449 | if ( $rr && $rr->[0] ) { | |
450 | EB::Wx::MessageDialog | |
451 | ($self, | |
452 | "Rekeningnummer ". | |
453 | ($self->{_id}). | |
454 | " is in gebruik en kan daarom niet worden gewijzigd.", | |
455 | "In gebruik", | |
456 | wxOK|wxICON_ERROR); | |
457 | local($self->{busy}) = 1; | |
458 | $obj->SetValue($self->{_id}); | |
459 | return 0; | |
460 | } | |
461 | } | |
462 | if ( $obj->GetValue ) { | |
463 | my $rr = $dbh->do("SELECT COUNT(*) FROM Accounts WHERE acc_id = ?", $obj->GetValue); | |
464 | if ( $rr && $rr->[0] ) { | |
465 | EB::Wx::MessageDialog | |
466 | ($self, | |
467 | "Rekeningnummer ". | |
468 | ($obj->GetValue). | |
469 | " bestaat reeds.", | |
470 | "In gebruik", | |
471 | wxOK|wxICON_ERROR); | |
472 | local($self->{busy}) = 1; | |
473 | $obj->SetValue($self->{_id}); | |
474 | return 0; | |
475 | } | |
476 | } | |
477 | 1; | |
478 | } | |
479 | ||
480 | # wxGlade: EB::Wx::Maint::Accounts::OnSashPosChanged <event_handler> | |
481 | sub OnSashPosChanged { | |
482 | my ($self, $event) = @_; | |
483 | $state->set("accsash", $event->GetEventObject->GetSashPosition); | |
484 | } | |
485 | ||
486 | # wxGlade: EB::Wx::Maint::Accounts::OnAccIdChanged <event_handler> | |
487 | sub OnAccIdChanged { | |
488 | my ($self, $event) = @_; | |
489 | return if $self->{busy}; | |
490 | my $ch = $self->changed; | |
491 | $self->{b_accept}->Enable($ch); | |
492 | $self->{b_reset}->Enable($ch); | |
493 | } | |
494 | ||
495 | # wxGlade: EB::Wx::Maint::Accounts::OnAccIdLosesFocus <event_handler> | |
496 | sub OnAccIdLosesFocus { | |
497 | my ($self, $event) = @_; | |
498 | my $obj = $event->GetEventObject; | |
499 | return unless $obj->IsModified; | |
500 | ||
501 | # This event is tied to t_acc_id, but we need the EB::Wx::Maint::Accounts frame. | |
502 | my $p = $self->GetParent; | |
503 | until ( exists($p->{_id}) ) { $p = $p->GetParent } | |
504 | ||
505 | $p->{refocus} = $self unless $p->check_id; | |
506 | ||
507 | my $ch = $p->changed; | |
508 | $p->{b_accept}->Enable($ch); | |
509 | $p->{b_reset}->Enable($ch); | |
510 | } | |
511 | ||
512 | # wxGlade: EB::Wx::Maint::Accounts::OnIdle <event_handler> | |
513 | sub OnIdle { | |
514 | my ($self, $event) = @_; | |
515 | Wx::Window::SetFocus($self->{refocus}), undef $self->{refocus} if $self->{refocus}; | |
516 | my $ch = $self->changed; | |
517 | $self->{b_accept}->Enable($ch); | |
518 | $self->{b_reset}->Enable($ch); | |
519 | } | |
520 | ||
521 | # wxGlade: EB::Wx::Maint::Accounts::OnAccDescChanged <event_handler> | |
522 | sub OnAccDescChanged { | |
523 | my ($self, $event) = @_; | |
524 | return if $self->{busy}; | |
525 | ||
526 | my $ch = $self->changed; | |
527 | $self->{b_accept}->Enable($ch); | |
528 | $self->{b_reset}->Enable($ch); | |
529 | } | |
530 | ||
531 | # wxGlade: EB::Wx::Maint::Accounts::OnDebcrdClicked <event_handler> | |
532 | sub OnDebcrdClicked { | |
533 | my ($self, $event) = @_; | |
534 | my $ch = $self->changed; | |
535 | $self->{b_accept}->Enable($ch); | |
536 | $self->{b_reset}->Enable($ch); | |
537 | } | |
538 | ||
539 | # wxGlade: EB::Wx::Maint::Accounts::OnKstomzClicked <event_handler> | |
540 | sub OnKstomzClicked { | |
541 | my ($self, $event) = @_; | |
542 | my $ch = $self->changed; | |
543 | $self->{b_accept}->Enable($ch); | |
544 | $self->{b_reset}->Enable($ch); | |
545 | } | |
546 | ||
547 | # wxGlade: EB::Wx::Maint::Accounts::OnBtwChanged <event_handler> | |
548 | sub OnBtwChanged { | |
549 | my ($self, $event) = @_; | |
550 | my $ch = $self->changed; | |
551 | $self->{b_accept}->Enable($ch); | |
552 | $self->{b_reset}->Enable($ch); | |
553 | } | |
554 | ||
555 | sub _struct_change { | |
556 | my ($self, $event) = @_; | |
557 | EB::Wx::MessageDialog($self, | |
558 | "Om de ". | |
559 | ($self->{_type} eq "acc" | |
560 | ? "verdichting" | |
561 | : $self->{_type} eq "vdi" | |
562 | ? "hoofdverdichting" | |
563 | : "indeling"). | |
564 | " van een ". | |
565 | ($self->{_type} eq "acc" | |
566 | ? "grootboekrekening" | |
567 | : $self->{_type} eq "vdi" | |
568 | ? "verdichting" | |
569 | : "hoofdverdichting"). | |
570 | " te wijzigen dient u deze in het linker paneel te verslepen", | |
571 | "Niet zo"); | |
572 | } | |
573 | ||
574 | # wxGlade: EB::Wx::Maint::Accounts::OnVdiChanged <event_handler> | |
575 | sub OnVdiChanged { | |
576 | my ($self, $event) = @_; | |
577 | $self->{ch_vdi}->SetValue($self->{_vdi}); | |
578 | $self->_struct_change($event); | |
579 | } | |
580 | ||
581 | # wxGlade: EB::Wx::Maint::Accounts::OnHvdChanged <event_handler> | |
582 | sub OnHvdChanged { | |
583 | my ($self, $event) = @_; | |
584 | $self->{ch_hvd}->SetValue($self->{_vdi}); | |
585 | $self->_struct_change($event); | |
586 | } | |
587 | ||
588 | # wxGlade: EB::Wx::Maint::Accounts::OnBalresChanged <event_handler> | |
589 | sub OnBalresChanged { | |
590 | my ($self, $event) = @_; | |
591 | $self->{ch_balres}->SetSelection($self->{_balres}); | |
592 | $self->_struct_change($event); | |
593 | } | |
594 | ||
595 | # wxGlade: EB::Wx::Maint::Accounts::OnAccept <event_handler> | |
596 | sub OnAccept { | |
597 | my ($self, $event) = @_; | |
598 | ||
599 | return unless $self->check_id; | |
600 | ||
601 | my $type = $self->{_type}; | |
602 | ||
603 | if ( $self->{struct} < 0 ) { | |
604 | $dbh->begin_work; | |
605 | eval { | |
606 | $dbh->sql_exec("DELETE FROM ".($type eq "acc" ? "Accounts" : "Verdichtingen"). | |
607 | " WHERE ${type}_id = ?", | |
608 | $self->{_id})->finish; | |
609 | $dbh->commit; | |
610 | }; | |
611 | if ( $@ ) { | |
612 | my $m = $@; | |
613 | $dbh->rollback; | |
614 | EB::Wx::MessageDialog($self, $m, "Fout tijdens de verwerking", | |
615 | wxOK|wxICON_ERROR); | |
616 | return; | |
617 | } | |
618 | $self->{struct} = 0; | |
619 | $self->{_ctrl}->Delete($self->{_item}); | |
620 | $self->{maint_pane}->Enable(0); | |
621 | } | |
622 | ||
623 | elsif ( $self->{struct} ) { | |
624 | ||
625 | unless ( $self->{t_acc_id}->GetValue && $self->{t_acc_desc}->GetValue ) { | |
626 | EB::Wx::MessageDialog($self, | |
627 | "Niet alle vereiste informatie is ingevuld", | |
628 | "Fout", | |
629 | wxOK|wxICON_ERROR); | |
630 | return; | |
631 | } | |
632 | ||
633 | my $sql = "INSERT INTO ".($type eq "acc" ? "Accounts" : "Verdichtingen"). | |
634 | " (acc_id,acc_desc,acc_balres,acc_kstomz,acc_debcrd,acc_struct,acc_btw,acc_balance,acc_ibalance)". | |
635 | " VALUES(?,?,?,?,?,?,?,0,0)"; | |
636 | my @args = ( $self->{_id} = $self->{t_acc_id}->GetValue, | |
637 | $self->{_desc} = $self->{t_acc_desc}->GetValue, | |
638 | $self->{_balres}, | |
639 | $self->_code_kstomz($self->{_kstomz} = $self->{rb_kstomz}->GetSelection), | |
640 | $self->{_debcrd} = 1 - $self->{rb_debcrd}->GetSelection, | |
641 | $self->{struct}, | |
642 | $self->{_btw} = $self->{ch_btw}->GetValue,); | |
643 | $dbh->begin_work; | |
644 | $dbh->sql_exec($sql, @args)->finish; | |
645 | $dbh->commit; | |
646 | $self->{struct} = 0; | |
647 | my $it = $self->{_ctrl}->AppendItem | |
648 | ($self->{_ctrl}->GetItemParent($self->{_item}), | |
649 | $self->{_id} . " " . $self->{_desc}, | |
650 | -1, -1, | |
651 | Wx::TreeItemData->new | |
652 | (EB::Wx::Maint::Accounts::TreeCtrl::GrootboekHandler->new | |
653 | ([$self->{_id}, $self->{_desc}, 2]))); | |
654 | $self->{_ctrl}->SortChildren | |
655 | ($self->{_ctrl}->GetItemParent($self->{_item})); | |
656 | $self->set_item($self->{_id}, 2, $self->{_ctrl}, $it); | |
657 | $self->{_ctrl}->SelectItem($it); | |
658 | } | |
659 | else { | |
660 | my $t = $type eq "acc" ? "acc" : "vdi"; | |
661 | my $sql = "UPDATE ".($t eq "acc" ? "Accounts" : "Verdichtingen")." SET"; | |
662 | my @args; | |
663 | my $id = $self->curr_id; | |
664 | ||
665 | if ( $self->{t_acc_id}->GetValue ne $self->{_id} ) { | |
666 | $sql .= " ${t}_id = ?,"; | |
667 | push(@args, $self->{_id} = $self->{t_acc_id}->GetValue); | |
668 | } | |
669 | if ( $self->{t_acc_desc}->GetValue ne $self->{_desc} ) { | |
670 | $sql .= " ${t}_desc = ?,"; | |
671 | push(@args, $self->{_desc} = $self->{t_acc_desc}->GetValue); | |
672 | } | |
673 | if ( $self->{rb_kstomz}->GetSelection != $self->{_kstomz} ) { | |
674 | $sql .= " ${t}_kstomz = ?,"; | |
675 | push(@args, $self->_code_kstomz($self->{_kstomz} = $self->{rb_kstomz}->GetSelection)); | |
676 | } | |
677 | if ( $self->{ch_vdi}->GetValue != $self->{_vdi} ) { | |
678 | $sql .= " ${t}_struct = ?,"; | |
679 | push(@args, $self->{_vdi} = $self->{ch_vdi}->GetValue); | |
680 | } | |
681 | if ( $type eq "acc" ) { | |
682 | if ( $self->{rb_debcrd}->GetSelection == $self->{_debcrd} ) { | |
683 | $sql .= " acc_debcrd = ?,"; | |
684 | push(@args, $self->{_debcrd} = 1 - $self->{rb_debcrd}->GetSelection); | |
685 | } | |
686 | if ( $self->{ch_btw}->GetValue != $self->{_btw} ) { | |
687 | $sql .= " acc_btw = ?,"; | |
688 | push(@args, $self->{_btw} = $self->{ch_btw}->GetValue); | |
689 | } | |
690 | } | |
691 | ||
692 | if ( @args ) { | |
693 | chop($sql); | |
694 | $sql .= " WHERE ${t}_id = ?"; | |
695 | push(@args, $id); | |
696 | $dbh->begin_work; | |
697 | eval { $dbh->sql_exec($sql, @args)->finish }; | |
698 | if ( $@ ) { | |
699 | EB::Wx::MessageDialog | |
700 | ($self, | |
701 | "Fout tijdens de verwerking\n$@", | |
702 | "Annuleren", | |
703 | wxOK|wxICON_ERROR); | |
704 | $dbh->rollback; | |
705 | } | |
706 | else { | |
707 | $dbh->commit; | |
708 | } | |
709 | ||
710 | if ( $self->{_ctrl} ) { | |
711 | $self->{_ctrl}->SetItemText($self->{_item}, "$self->{_id} $self->{_desc}"); | |
712 | $self->{_ctrl}->SetPlData($self->{_item}, | |
713 | EB::Wx::Maint::Accounts::TreeCtrl::GrootboekHandler->new | |
714 | ([$self->{_id}, $self->{_desc}, 2])); | |
715 | } | |
716 | ||
717 | } | |
718 | } | |
719 | my $ch = $self->changed; | |
720 | $self->{b_accept}->Enable($ch); | |
721 | $self->{b_reset}->Enable($ch); | |
722 | } | |
723 | ||
724 | # wxGlade: EB::Wx::Maint::Accounts::OnReset <event_handler> | |
725 | sub OnReset { | |
726 | my ($self, $event) = @_; | |
727 | ||
728 | if ( $self->{struct} ) { | |
729 | $self->{struct} = 0; | |
730 | my $data = $self->{_ctrl}->GetPlData($self->{_item}); | |
731 | $self->set_item($data->[0], 2, $self->{_ctrl}, $self->{_item}); | |
732 | } | |
733 | else { | |
734 | $self->{t_acc_id}->SetValue($self->{_id}); | |
735 | $self->{t_acc_desc}->SetValue($self->{_desc}); | |
736 | $self->{rb_debcrd}->SetSelection(!$self->{_debcrd}); | |
737 | $self->{rb_kstomz}->SetSelection($self->{_kstomz}); | |
738 | $self->{ch_btw}->SetValue($self->{_btw}); | |
739 | $self->{_type} eq "acc" && $self->{ch_vdi}->SetValue($self->{_vdi}); | |
740 | $self->{_type} eq "vdi" && $self->{ch_hvd}->SetValue($self->{_vdi}); | |
741 | $self->{_type} eq "hvd" && $self->{ch_balres}->SetSelection($self->{_balres}); | |
742 | } | |
743 | ||
744 | my $ch = $self->changed; | |
745 | $self->{b_accept}->Enable($ch); | |
746 | $self->{b_reset}->Enable($ch); | |
747 | } | |
748 | ||
749 | # wxGlade: EB::Wx::Maint::Accounts::OnClose <event_handler> | |
750 | sub OnClose { | |
751 | my ($self, $event) = @_; | |
752 | if ( $self->changed ) { | |
753 | my $r = EB::Wx::MessageDialog | |
754 | ($self, | |
755 | "Er zijn nog wijzigingen, deze zullen verloren gaan.\n". | |
756 | "Venster toch sluiten?", | |
757 | "Annuleren", | |
758 | wxYES_NO|wxNO_DEFAULT|wxICON_ERROR); | |
759 | return unless $r == wxID_YES; | |
760 | } | |
761 | # Remember position and size. | |
762 | $self->sizepos_save; | |
763 | # Disappear. | |
764 | $self->Show(0); | |
765 | } | |
766 | ||
767 | # wxGlade: EB::Wx::Maint::Accounts::OnAdd <event_handler> | |
768 | sub OnAdd { | |
769 | my ($self, $event) = @_; | |
770 | ||
771 | if ( $self->changed ) { | |
772 | EB::Wx::MessageDialog($self, | |
773 | "Er zijn wijzigingen aangebracht. Gelieve deze eerst te verwerken of te annuleren.", | |
774 | "In gebruik", | |
775 | wxOK|wxICON_ERROR); | |
776 | return; | |
777 | } | |
778 | ||
779 | $self->newentry($self->{_vdi}); | |
780 | } | |
781 | ||
782 | # wxGlade: EB::Wx::Maint::Accounts::OnDel <event_handler> | |
783 | sub OnDel { | |
784 | my ($self, $event) = @_; | |
785 | ||
786 | if ( $self->changed ) { | |
787 | EB::Wx::MessageDialog($self, | |
788 | "Er zijn wijzigingen aangebracht. Gelieve deze eerst te annuleren.", | |
789 | "In gebruik", | |
790 | wxOK|wxICON_ERROR); | |
791 | return; | |
792 | } | |
793 | ||
794 | $self->{struct} = -1; | |
795 | $self->{maint_pane}->Show(0); | |
796 | $self->{l_msg}->Show(1); | |
797 | my $l = lc($self->{sz_acc}->GetStaticBox->GetLabel); | |
798 | $self->{l_msg}->SetLabel(__x("Druk op de knop [{apply}] om deze $l te verwijderen.", | |
799 | apply => _T("Toepassen"))); | |
800 | $self->Layout; | |
801 | ||
802 | } | |
803 | ||
804 | ||
805 | # end of class EB::Wx::Maint::Accounts | |
806 | ||
807 | 1; | |
808 |
0 | #! perl | |
1 | ||
2 | # $Id: BTWTarieven.pm,v 1.14 2008/03/25 22:59:44 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $app; | |
8 | our $dbh; | |
9 | ||
10 | package EB::Wx::Maint::BTWTarieven; | |
11 | ||
12 | use Wx qw[:everything]; | |
13 | use strict; | |
14 | use base qw(Wx::Dialog); | |
15 | use base qw(EB::Wx::Window); | |
16 | use Wx::Grid; | |
17 | use EB; | |
18 | use EB::Format; | |
19 | use EB::Wx::UI::NumericCtrl; | |
20 | use EB::Wx::UI::AmountCtrl; | |
21 | ||
22 | sub new { | |
23 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
24 | $parent = undef unless defined $parent; | |
25 | $id = -1 unless defined $id; | |
26 | $title = "" unless defined $title; | |
27 | $pos = wxDefaultPosition unless defined $pos; | |
28 | $size = wxDefaultSize unless defined $size; | |
29 | $name = "" unless defined $name; | |
30 | ||
31 | # begin wxGlade: EB::Wx::Maint::BTWTarieven::new | |
32 | ||
33 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTHICK_FRAME | |
34 | unless defined $style; | |
35 | ||
36 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
37 | $self->{s_details_staticbox} = Wx::StaticBox->new($self, -1, _T("Details") ); | |
38 | $self->{sz_grid_staticbox} = Wx::StaticBox->new($self, -1, _T("BTW Tarieven") ); | |
39 | $self->{gr_list} = Wx::Grid->new($self, -1); | |
40 | $self->{static_line_2} = Wx::StaticLine->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
41 | $self->{b_add} = Wx::Button->new($self, -1, _T("Toevoegen")); | |
42 | $self->{b_details} = Wx::Button->new($self, -1, _T("Wijzigen")); | |
43 | $self->{b_remove} = Wx::Button->new($self, -1, _T("Verwijderen")); | |
44 | $self->{label_1} = Wx::StaticText->new($self, -1, _T("Code"), wxDefaultPosition, wxDefaultSize, ); | |
45 | $self->{label_2} = Wx::StaticText->new($self, -1, _T("Omschrijving"), wxDefaultPosition, wxDefaultSize, ); | |
46 | $self->{t_code} = EB::Wx::UI::NumericCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize); | |
47 | $self->{t_desc} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
48 | $self->{label_3} = Wx::StaticText->new($self, -1, _T("Percentage"), wxDefaultPosition, wxDefaultSize, ); | |
49 | $self->{t_perc} = EB::Wx::UI::AmountCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize); | |
50 | $self->{label_4} = Wx::StaticText->new($self, -1, _T("Tariefgroep"), wxDefaultPosition, wxDefaultSize, ); | |
51 | $self->{label_5} = Wx::StaticText->new($self, -1, _T("Incl./Excl."), wxDefaultPosition, wxDefaultSize, ); | |
52 | $self->{c_tg} = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, [], ); | |
53 | $self->{c_inex} = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, [], ); | |
54 | $self->{static_line_1} = Wx::StaticLine->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
55 | $self->{b_apply} = Wx::Button->new($self, -1, _T("Toepassen")); | |
56 | $self->{b_cancel} = Wx::Button->new($self, -1, _T("Annuleren")); | |
57 | $self->{l_inuse} = Wx::StaticText->new($self, -1, _T("Sommige gegevens zijn in gebruik en\nkunnen niet meer worden gewijzigd."), wxDefaultPosition, wxDefaultSize, ); | |
58 | $self->{b_close} = Wx::Button->new($self, wxID_CLOSE, ""); | |
59 | ||
60 | $self->__set_properties(); | |
61 | $self->__do_layout(); | |
62 | ||
63 | Wx::Event::EVT_BUTTON($self, $self->{b_add}->GetId, \&OnAdd); | |
64 | Wx::Event::EVT_BUTTON($self, $self->{b_details}->GetId, \&OnDetails); | |
65 | Wx::Event::EVT_BUTTON($self, $self->{b_remove}->GetId, \&OnRemove); | |
66 | Wx::Event::EVT_BUTTON($self, $self->{b_apply}->GetId, \&OnApply); | |
67 | Wx::Event::EVT_BUTTON($self, $self->{b_cancel}->GetId, \&OnCancel); | |
68 | Wx::Event::EVT_BUTTON($self, $self->{b_close}->GetId, \&OnClose); | |
69 | ||
70 | # end wxGlade | |
71 | ||
72 | Wx::Event::EVT_MENU($self, wxID_CLOSE, \&OnClose); | |
73 | Wx::Event::EVT_GRID_SELECT_CELL($self->{gr_list}, sub {}); | |
74 | Wx::Event::EVT_GRID_CELL_LEFT_CLICK($self->{gr_list}, \&OnClick); | |
75 | Wx::Event::EVT_GRID_CELL_LEFT_DCLICK($self->{gr_list}, \&OnSel); | |
76 | Wx::Event::EVT_CLOSE($self, \&OnClose); | |
77 | Wx::Event::EVT_IDLE($self, \&OnIdle); | |
78 | $self->{sz_buttons}->Show(0, 0); | |
79 | $self->{sz_main}->Show(1, 0); | |
80 | $self->Layout; | |
81 | ||
82 | return $self; | |
83 | ||
84 | } | |
85 | ||
86 | sub __set_properties { | |
87 | my $self = shift; | |
88 | ||
89 | $self->set_properties; | |
90 | ||
91 | # begin wxGlade: EB::Wx::Maint::BTWTarieven::__set_properties | |
92 | ||
93 | $self->SetTitle(_T("Onderhoud BTWTarieven")); | |
94 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(268, 164))); | |
95 | $self->{c_tg}->SetSelection(0); | |
96 | $self->{c_inex}->SetSelection(0); | |
97 | $self->{b_close}->SetFocus(); | |
98 | $self->{b_close}->SetDefault(); | |
99 | ||
100 | # end wxGlade | |
101 | } | |
102 | ||
103 | sub __do_layout { | |
104 | my $self = shift; | |
105 | ||
106 | # begin wxGlade: EB::Wx::Maint::BTWTarieven::__do_layout | |
107 | ||
108 | $self->{sz_main} = Wx::BoxSizer->new(wxVERTICAL); | |
109 | $self->{sz_buttons} = Wx::BoxSizer->new(wxHORIZONTAL); | |
110 | $self->{s_details}= Wx::StaticBoxSizer->new($self->{s_details_staticbox}, wxHORIZONTAL); | |
111 | $self->{sizer_4} = Wx::BoxSizer->new(wxVERTICAL); | |
112 | $self->{sizer_6} = Wx::BoxSizer->new(wxHORIZONTAL); | |
113 | $self->{sizer_5} = Wx::BoxSizer->new(wxHORIZONTAL); | |
114 | $self->{grid_sizer_1} = Wx::FlexGridSizer->new(3, 2, 3, 5); | |
115 | $self->{sizer_7} = Wx::BoxSizer->new(wxHORIZONTAL); | |
116 | $self->{grid_sizer_2} = Wx::FlexGridSizer->new(2, 2, 3, 5); | |
117 | $self->{sizer_1} = Wx::BoxSizer->new(wxVERTICAL); | |
118 | $self->{sz_grid}= Wx::StaticBoxSizer->new($self->{sz_grid_staticbox}, wxHORIZONTAL); | |
119 | $self->{sz_dbk} = Wx::BoxSizer->new(wxVERTICAL); | |
120 | $self->{sizer_2} = Wx::BoxSizer->new(wxVERTICAL); | |
121 | $self->{sizer_3} = Wx::BoxSizer->new(wxHORIZONTAL); | |
122 | $self->{sizer_2}->Add($self->{gr_list}, 1, wxEXPAND, 0); | |
123 | $self->{sizer_2}->Add($self->{static_line_2}, 0, wxTOP|wxEXPAND, 5); | |
124 | $self->{sizer_3}->Add($self->{b_add}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
125 | $self->{sizer_3}->Add($self->{b_details}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
126 | $self->{sizer_3}->Add($self->{b_remove}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
127 | $self->{sizer_3}->Add(1, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
128 | $self->{sizer_2}->Add($self->{sizer_3}, 0, wxTOP|wxEXPAND, 5); | |
129 | $self->{sz_dbk}->Add($self->{sizer_2}, 1, wxALL|wxEXPAND, 5); | |
130 | $self->{sz_grid}->Add($self->{sz_dbk}, 1, wxEXPAND, 0); | |
131 | $self->{sz_main}->Add($self->{sz_grid}, 1, wxALL|wxEXPAND, 5); | |
132 | $self->{grid_sizer_1}->Add($self->{label_1}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
133 | $self->{grid_sizer_1}->Add($self->{label_2}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
134 | $self->{grid_sizer_1}->Add($self->{t_code}, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 0); | |
135 | $self->{grid_sizer_1}->Add($self->{t_desc}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
136 | $self->{sizer_1}->Add($self->{label_3}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
137 | $self->{sizer_1}->Add($self->{t_perc}, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 0); | |
138 | $self->{grid_sizer_1}->Add($self->{sizer_1}, 1, wxEXPAND, 0); | |
139 | $self->{grid_sizer_2}->Add($self->{label_4}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
140 | $self->{grid_sizer_2}->Add($self->{label_5}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
141 | $self->{grid_sizer_2}->Add($self->{c_tg}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
142 | $self->{grid_sizer_2}->Add($self->{c_inex}, 0, wxADJUST_MINSIZE, 0); | |
143 | $self->{grid_sizer_1}->Add($self->{grid_sizer_2}, 1, wxEXPAND, 0); | |
144 | $self->{grid_sizer_1}->Add($self->{sizer_7}, 1, wxEXPAND, 0); | |
145 | $self->{grid_sizer_1}->AddGrowableCol(1); | |
146 | $self->{sizer_5}->Add($self->{grid_sizer_1}, 1, wxEXPAND, 0); | |
147 | $self->{sizer_4}->Add($self->{sizer_5}, 1, wxEXPAND, 0); | |
148 | $self->{sizer_4}->Add($self->{static_line_1}, 0, wxTOP|wxEXPAND, 5); | |
149 | $self->{sizer_6}->Add($self->{b_apply}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
150 | $self->{sizer_6}->Add($self->{b_cancel}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
151 | $self->{sizer_6}->Add(1, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
152 | $self->{sizer_4}->Add($self->{sizer_6}, 0, wxTOP|wxEXPAND, 5); | |
153 | $self->{s_details}->Add($self->{sizer_4}, 1, wxALL|wxEXPAND, 5); | |
154 | $self->{sz_main}->Add($self->{s_details}, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
155 | $self->{sz_buttons}->Add($self->{l_inuse}, 0, wxLEFT|wxBOTTOM|wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
156 | $self->{sz_buttons}->Add(20, 20, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
157 | $self->{sz_buttons}->Add($self->{b_close}, 0, wxALL|wxEXPAND|wxADJUST_MINSIZE|wxFIXED_MINSIZE, 5); | |
158 | $self->{sz_main}->Add($self->{sz_buttons}, 0, wxALL|wxEXPAND, 5); | |
159 | $self->SetSizer($self->{sz_main}); | |
160 | $self->Layout(); | |
161 | ||
162 | # end wxGlade | |
163 | } | |
164 | ||
165 | sub INEX() { [ qw(Exclusief Inclusief) ] } | |
166 | ||
167 | sub set_properties { # Specific | |
168 | my $self = shift; | |
169 | ||
170 | $self->{c_tg}->Append($_) foreach @{BTWTARIEVEN()}; | |
171 | $self->{c_inex}->Append($_) foreach @{INEX()}; | |
172 | ||
173 | # $self->{t_perc}->Destroy; | |
174 | # $self->{t_perc} = EB::Wx::UI::AmountCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
175 | ||
176 | $self->{gr_list}->CreateGrid(0, 5); | |
177 | $self->{gr_list}->SetRowLabelSize(0); | |
178 | $self->{gr_list}->EnableEditing(0); | |
179 | $self->{gr_list}->EnableDragColSize(0); | |
180 | $self->{gr_list}->EnableDragRowSize(0); | |
181 | $self->{gr_list}->SetSelectionMode(wxGridSelectRows); | |
182 | $self->{gr_list}->SetColLabelValue(0, _T("Code")); | |
183 | $self->{gr_list}->SetColLabelValue(1, _T("Omschrijving")); | |
184 | $self->{gr_list}->SetColLabelValue(2, _T("Perc.")); | |
185 | $self->{gr_list}->SetColLabelValue(3, _T("Tariefgroep")); | |
186 | $self->{gr_list}->SetColLabelValue(4, _T("Incl./Excl.")); | |
187 | ||
188 | } | |
189 | ||
190 | ################ Task Specific Code ################ | |
191 | ||
192 | sub get_data { | |
193 | my ($self) = @_; | |
194 | $self->{_grid_map} = []; | |
195 | my $sth = $dbh->sql_exec | |
196 | ("SELECT btw_id, btw_desc, btw_perc, btw_tariefgroep, btw_incl". | |
197 | " FROM BTWTabel". | |
198 | " ORDER BY btw_id"); | |
199 | while ( my $rr = $sth->fetchrow_arrayref ) { | |
200 | my $inuse = 0; | |
201 | if ( $rr->[0] == 0 | |
202 | || defined $dbh->do("SELECT bsr_btw_id FROM Boekstukregels". | |
203 | " WHERE bsr_btw_id = ? LIMIT 1", | |
204 | $rr->[0]) | |
205 | || defined $dbh->do("SELECT acc_btw FROM Accounts". | |
206 | " WHERE acc_btw = ? LIMIT 1", | |
207 | $rr->[0]) | |
208 | ) { | |
209 | $inuse = 1; | |
210 | } | |
211 | push(@{$self->{_grid_map}}, [@$rr, $inuse]); | |
212 | } | |
213 | } | |
214 | ||
215 | sub fill_row { | |
216 | my ($self, $row, @values) = @_; | |
217 | my $col = 0; | |
218 | my $p = $self->{gr_list}; | |
219 | $p->SetCellValue($row, $col++, $values[0]); | |
220 | $p->SetCellAlignment($row, $col-1, wxALIGN_RIGHT, wxALIGN_CENTRE); | |
221 | $p->SetCellValue($row, $col++, $values[1]); | |
222 | $p->SetCellValue($row, $col++, numfmt($values[2])); | |
223 | $p->SetCellAlignment($row, $col-1, wxALIGN_RIGHT, wxALIGN_CENTRE); | |
224 | $p->SetCellValue($row, $col++, BTWTARIEVEN->[$values[3]]); | |
225 | $p->SetCellValue($row, $col++, INEX()->[$values[4]]); | |
226 | } | |
227 | ||
228 | sub show_row { | |
229 | my ($self, $row, @v) = @_; | |
230 | $self->{t_code}->SetValue(shift(@v)); | |
231 | $self->{t_desc}->SetValue(shift(@v)); | |
232 | $self->{t_perc}->SetValue(shift(@v)); | |
233 | $self->{c_tg}->SetSelection(shift(@v)); | |
234 | $self->{c_inex}->SetSelection($v[0] ? 1 : 0); | |
235 | } | |
236 | ||
237 | sub details_inuse { | |
238 | my ($self, $row) = @_; | |
239 | $self->{$_}->Enable(!$self->is_inuse($row)) | |
240 | foreach qw(t_code t_perc c_tg c_inex); | |
241 | } | |
242 | ||
243 | sub changed { | |
244 | my ($self) = @_; | |
245 | # my $ch = $self->_changed; | |
246 | # $ch; | |
247 | #} | |
248 | # | |
249 | #sub _changed { | |
250 | # my ($self) = @_; | |
251 | return 0 unless $self->{_details_shown}; | |
252 | my $v = $self->{_grid_map}->[$self->{_curr_row}]; | |
253 | return 1 if $self->{t_code}->GetValue != $v->[0]; | |
254 | return 2 if $self->{t_desc}->GetValue ne $v->[1]; | |
255 | return 3 if $self->{t_perc}->GetValue != $v->[2]; | |
256 | return 4 if $self->{c_tg}->GetSelection != $v->[3]; | |
257 | return 5 if $self->{c_inex}->GetSelection != $v->[4]; | |
258 | return 0; | |
259 | } | |
260 | ||
261 | sub new_row { | |
262 | my ($self) = @_; | |
263 | [ 0, "", 0, 0, 0 ]; | |
264 | } | |
265 | ||
266 | sub delete_row { | |
267 | my ($self, $code) = @_; | |
268 | $dbh->begin_work; | |
269 | eval { | |
270 | $dbh->sql_exec("DELETE FROM BTWTabel". | |
271 | " WHERE btw_id = ?", | |
272 | $code); | |
273 | $dbh->commit; | |
274 | $self->refresh; | |
275 | }; | |
276 | if ( $@ ) { | |
277 | $dbh->rollback; | |
278 | my $msg; | |
279 | $msg = "Fout tijdens het bijwerken van BTW tarief $code:\n". $@; | |
280 | $msg =~ s/\nat .*//s; | |
281 | EB::Wx::MessageDialog | |
282 | ($self, | |
283 | $msg, "Fout tijdens het bijwerken", | |
284 | wxOK|wxICON_ERROR); | |
285 | } | |
286 | } | |
287 | ||
288 | sub apply { | |
289 | my ($self, $row) = @_; | |
290 | ||
291 | $dbh->begin_work; | |
292 | ||
293 | my $error; | |
294 | my @fields = qw(btw_id btw_desc btw_perc btw_tariefgroep btw_incl); | |
295 | my $code; | |
296 | ||
297 | eval { | |
298 | if ( $self->is_new($row) ) { | |
299 | # New... | |
300 | if ( !($code = $self->{t_code}->GetValue) | |
301 | || !$self->{t_desc}->GetValue ) { | |
302 | die("Niet alle verplichte gegevens zijn ingevuld\n"); | |
303 | } | |
304 | $dbh->sql_insert("BTWTabel", | |
305 | \@fields, | |
306 | $code, | |
307 | $self->{t_desc}->GetValue, | |
308 | $self->{t_perc}->GetValue, | |
309 | $self->{c_tg}->GetSelection, | |
310 | $self->{c_inex}->GetSelection, | |
311 | ); | |
312 | $self->{_grid_map}->[$row]->[-1] = 0; | |
313 | } | |
314 | else { | |
315 | # Modified... | |
316 | ||
317 | my @sets; | |
318 | my @values; | |
319 | my @ovalues = @{$self->{_grid_map}->[$row]}; | |
320 | $code = $ovalues[0]; | |
321 | my @nvalues = ( $self->{t_code}->GetValue, | |
322 | $self->{t_desc}->GetValue, | |
323 | $self->{t_perc}->GetValue, | |
324 | $self->{c_tg}->GetSelection, | |
325 | $self->{c_inex}->GetSelection, | |
326 | ); | |
327 | ||
328 | my $i = 0; | |
329 | foreach ( @fields ) { | |
330 | if ( $ovalues[$i] ne $nvalues[$i] ) { | |
331 | push(@sets, $fields[$i]." = ?"); | |
332 | push(@values, $nvalues[$i]); | |
333 | } | |
334 | $i++; | |
335 | } | |
336 | ||
337 | $dbh->sql_exec("UPDATE BTWTabel". | |
338 | " SET ". join(", ", @sets). | |
339 | " WHERE btw_id = ?", | |
340 | @values, $code); | |
341 | } | |
342 | ||
343 | $dbh->commit; | |
344 | $self->hide_details; | |
345 | $self->refresh; | |
346 | ||
347 | }; | |
348 | ||
349 | if ( $@ ) { | |
350 | $dbh->rollback; | |
351 | my $msg; | |
352 | if ( $dbh->dbh->state eq '23505' ) { | |
353 | $msg = "BTW tariefcode $code bestaat al\n"; | |
354 | } | |
355 | else { | |
356 | $msg = "Fout tijdens het bijwerken van BTW tarief $code:\n". $@; | |
357 | } | |
358 | $msg =~ s/\nat .*//s; | |
359 | EB::Wx::MessageDialog | |
360 | ($self, | |
361 | $msg, "Fout tijdens het bijwerken", | |
362 | wxOK|wxICON_ERROR); | |
363 | } | |
364 | } | |
365 | ||
366 | ################ Generic Code ################ | |
367 | ||
368 | sub is_new { | |
369 | my ($self, $row) = @_; | |
370 | $self->{_grid_map}->[$row]->[-1] < 0; | |
371 | } | |
372 | ||
373 | sub is_inuse { | |
374 | my ($self, $row) = @_; | |
375 | $self->{_grid_map}->[$row]->[-1] > 0; | |
376 | } | |
377 | ||
378 | sub refresh { | |
379 | my ($self) = @_; | |
380 | ||
381 | $self->get_data; | |
382 | my $p = $self->{gr_list}; | |
383 | $p->DeleteRows(0, $p->GetNumberRows, 1); | |
384 | $p->AppendRows(scalar(@{$self->{_grid_map}})); | |
385 | my $row = 0; | |
386 | my $inuse = 0; | |
387 | foreach ( @{$self->{_grid_map}} ) { | |
388 | $self->fill_row($row, @$_); | |
389 | $inuse ||= $self->is_inuse($row); | |
390 | $row++; | |
391 | } | |
392 | ||
393 | $self->set_current(0); | |
394 | $self->resize_grid($p); | |
395 | undef $self->{_details_shown}; | |
396 | $self->{sz_buttons}->Show(0, $inuse); | |
397 | } | |
398 | ||
399 | sub set_current { | |
400 | my ($self, $row) = @_; | |
401 | $self->{_curr_row} = $row; | |
402 | $self->{b_remove}->Enable(!$self->is_inuse($row)); | |
403 | } | |
404 | ||
405 | sub show_details { | |
406 | my ($self, $row) = @_; | |
407 | $row = $self->{_curr_row} unless defined $row; | |
408 | ||
409 | $self->show_row($row, @{$self->{_grid_map}->[$row]}); | |
410 | $self->details_inuse($row); | |
411 | ||
412 | $self->{$_}->Enable(0) | |
413 | foreach qw(b_apply gr_list b_add b_details b_remove); | |
414 | ||
415 | $self->{sz_main}->Show(1,1); | |
416 | $self->{sz_main}->Show(2,0); | |
417 | $self->Layout; | |
418 | $self->{_details_shown} = 1; | |
419 | } | |
420 | ||
421 | sub hide_details { | |
422 | my ($self) = @_; | |
423 | $self->{$_}->Enable(1) | |
424 | foreach qw(gr_list b_add b_details); | |
425 | $self->{b_remove}->Enable(1) unless $self->is_inuse($self->{_curr_row}); | |
426 | $self->{sz_main}->Show(1,0); | |
427 | $self->{sz_main}->Show(2,1); | |
428 | $self->Layout; | |
429 | $self->{_details_shown} = 0; | |
430 | } | |
431 | ||
432 | sub OnIdle { | |
433 | my ($self) = @_; | |
434 | return unless $self->{_details_shown}; | |
435 | $self->{b_apply}->Enable($self->changed); | |
436 | } | |
437 | ||
438 | # wxGlade: EB::Wx::Maint::BTWTarieven::OnClose <event_handler> | |
439 | sub OnClose { | |
440 | my ($self, $event) = @_; | |
441 | ||
442 | if ( $self->changed ) { | |
443 | my $r = EB::Wx::MessageDialog | |
444 | ($self, | |
445 | "Er zijn nog wijzigingen, deze zullen verloren gaan.\n". | |
446 | "Venster toch sluiten?", | |
447 | "Annuleren", | |
448 | wxYES_NO|wxNO_DEFAULT|wxICON_ERROR); | |
449 | return unless $r == wxID_YES; | |
450 | } | |
451 | ||
452 | $self->sizepos_save; | |
453 | $self->Show(0); | |
454 | } | |
455 | ||
456 | # wxGlade: EB::Wx::Maint::BTWTarieven::OnAdd <event_handler> | |
457 | sub OnAdd { | |
458 | my ($self, $event) = @_; | |
459 | my $p = $self->{gr_list}; | |
460 | my $row = $p->GetNumberRows; | |
461 | $p->AppendRows(1); | |
462 | my $rr = $self->new_row; | |
463 | $self->fill_row($row, @$rr); | |
464 | push(@{$self->{_grid_map}}, [@$rr, -1]); | |
465 | $self->set_current($row); | |
466 | $self->show_details($row); | |
467 | } | |
468 | ||
469 | # wxGlade: EB::Wx::Maint::BTWTarieven::OnDetails <event_handler> | |
470 | sub OnDetails { | |
471 | my ($self, $event) = @_; | |
472 | $self->show_details($self->{_curr_row}); | |
473 | } | |
474 | ||
475 | # wxGlade: EB::Wx::Maint::BTWTarieven::OnRemove <event_handler> | |
476 | sub OnRemove { | |
477 | my ($self, $event) = @_; | |
478 | my $code = $self->{_grid_map}->[$self->{_curr_row}]->[0]; | |
479 | $self->delete_row($code); | |
480 | } | |
481 | ||
482 | # wxGlade: EB::Wx::Maint::BTWTarieven::OnApply <event_handler> | |
483 | sub OnApply { | |
484 | my ($self, $event) = @_; | |
485 | $self->apply($self->{_curr_row}); | |
486 | } | |
487 | ||
488 | # wxGlade: EB::Wx::Maint::BTWTarieven::OnCancel <event_handler> | |
489 | sub OnCancel { | |
490 | my ($self, $event) = @_; | |
491 | if ( $self->changed ) { | |
492 | my $r = EB::Wx::MessageDialog | |
493 | ($self, | |
494 | "Er zijn nog wijzigingen, deze zullen verloren gaan.\n". | |
495 | "Toch annuleren?", | |
496 | "Annuleren", | |
497 | wxYES_NO|wxNO_DEFAULT|wxICON_ERROR); | |
498 | return unless $r == wxID_YES; | |
499 | } | |
500 | $self->hide_details; | |
501 | if ( $self->{_curr_row} > 0 && $self->is_new($self->{_curr_row}) ) { | |
502 | $self->{gr_list}->DeleteRows($self->{_curr_row}, 1); | |
503 | $self->{_curr_row}--; | |
504 | } | |
505 | # end wxGlade | |
506 | } | |
507 | ||
508 | sub OnClick { | |
509 | my ($self, $event) = @_; | |
510 | $self = $self->GetParent; | |
511 | my $row = $event->GetRow; | |
512 | $self->{gr_list}->SelectRow($row); | |
513 | $self->set_current($row); | |
514 | $event->Skip; | |
515 | } | |
516 | ||
517 | # wxGlade: EB::Wx::Maint::BTWTarieven::OnSel <event_handler> | |
518 | sub OnSel { | |
519 | my ($self, $event) = @_; | |
520 | $self = $self->GetParent; | |
521 | $self->set_current($event->GetRow); | |
522 | $self->show_details; | |
523 | } | |
524 | ||
525 | # end of class EB::Wx::Maint::BTWTarieven | |
526 | ||
527 | 1; | |
528 |
0 | #! perl | |
1 | ||
2 | # $Id: Dagboeken.pm,v 1.6 2008/03/25 22:59:43 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $app; | |
8 | our $dbh; | |
9 | ||
10 | package EB::Wx::Maint::Dagboeken; | |
11 | ||
12 | use Wx qw[:everything]; | |
13 | use strict; | |
14 | use base qw(Wx::Dialog); | |
15 | use base qw(EB::Wx::Window); | |
16 | use Wx::Grid; | |
17 | use EB; | |
18 | use EB::Wx::UI::BalAccInput; | |
19 | ||
20 | sub new { | |
21 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
22 | $parent = undef unless defined $parent; | |
23 | $id = -1 unless defined $id; | |
24 | $title = "" unless defined $title; | |
25 | $pos = wxDefaultPosition unless defined $pos; | |
26 | $size = wxDefaultSize unless defined $size; | |
27 | $name = "" unless defined $name; | |
28 | ||
29 | # begin wxGlade: EB::Wx::Maint::Dagboeken::new | |
30 | ||
31 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTHICK_FRAME | |
32 | unless defined $style; | |
33 | ||
34 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
35 | $self->{s_details_staticbox} = Wx::StaticBox->new($self, -1, _T("Details") ); | |
36 | $self->{sz_grid_staticbox} = Wx::StaticBox->new($self, -1, _T("Dagboeken") ); | |
37 | $self->{gr_list} = Wx::Grid->new($self, -1); | |
38 | $self->{static_line_2} = Wx::StaticLine->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
39 | $self->{b_add} = Wx::Button->new($self, -1, _T("Toevoegen")); | |
40 | $self->{b_details} = Wx::Button->new($self, -1, _T("Wijzigen")); | |
41 | $self->{b_remove} = Wx::Button->new($self, -1, _T("Verwijderen")); | |
42 | $self->{label_1} = Wx::StaticText->new($self, -1, _T("Code"), wxDefaultPosition, wxDefaultSize, ); | |
43 | $self->{label_2} = Wx::StaticText->new($self, -1, _T("Omschrijving"), wxDefaultPosition, wxDefaultSize, ); | |
44 | $self->{label_3} = Wx::StaticText->new($self, -1, _T("Soort"), wxDefaultPosition, wxDefaultSize, ); | |
45 | $self->{t_code} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
46 | $self->{t_desc} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
47 | $self->{c_type} = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, [], ); | |
48 | $self->{label_4} = Wx::StaticText->new($self, -1, _T("Grootboekrekening"), wxDefaultPosition, wxDefaultSize, ); | |
49 | $self->{label_5} = Wx::StaticText->new($self, -1, _T("Debet/Credit"), wxDefaultPosition, wxDefaultSize, ); | |
50 | $self->{cb_acct} = Wx::CheckBox->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
51 | $self->{t_acct} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
52 | $self->{c_dcsplit} = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, [], ); | |
53 | $self->{static_line_1} = Wx::StaticLine->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
54 | $self->{b_apply} = Wx::Button->new($self, -1, _T("Toepassen")); | |
55 | $self->{b_cancel} = Wx::Button->new($self, -1, _T("Annuleren")); | |
56 | $self->{l_inuse} = Wx::StaticText->new($self, -1, _T("Sommige gegevens zijn in gebruik en\nkunnen niet meer worden gewijzigd."), wxDefaultPosition, wxDefaultSize, ); | |
57 | $self->{b_close} = Wx::Button->new($self, wxID_CLOSE, ""); | |
58 | ||
59 | $self->__set_properties(); | |
60 | $self->__do_layout(); | |
61 | ||
62 | Wx::Event::EVT_BUTTON($self, $self->{b_add}->GetId, \&OnAdd); | |
63 | Wx::Event::EVT_BUTTON($self, $self->{b_details}->GetId, \&OnDetails); | |
64 | Wx::Event::EVT_BUTTON($self, $self->{b_remove}->GetId, \&OnRemove); | |
65 | Wx::Event::EVT_CHECKBOX($self, $self->{cb_acct}->GetId, \&OnCBAcct); | |
66 | Wx::Event::EVT_BUTTON($self, $self->{b_apply}->GetId, \&OnApply); | |
67 | Wx::Event::EVT_BUTTON($self, $self->{b_cancel}->GetId, \&OnCancel); | |
68 | Wx::Event::EVT_BUTTON($self, $self->{b_close}->GetId, \&OnClose); | |
69 | ||
70 | # end wxGlade | |
71 | ||
72 | Wx::Event::EVT_MENU($self, wxID_CLOSE, \&OnClose); | |
73 | Wx::Event::EVT_GRID_SELECT_CELL($self->{gr_list}, sub {}); | |
74 | Wx::Event::EVT_GRID_CELL_LEFT_CLICK($self->{gr_list}, \&OnClick); | |
75 | Wx::Event::EVT_GRID_CELL_LEFT_DCLICK($self->{gr_list}, \&OnSel); | |
76 | Wx::Event::EVT_CLOSE($self, \&OnClose); | |
77 | Wx::Event::EVT_IDLE($self, \&OnIdle); | |
78 | $self->{sz_buttons}->Show(0, 0); | |
79 | $self->{sz_main}->Show(1, 0); | |
80 | $self->Layout; | |
81 | ||
82 | return $self; | |
83 | ||
84 | } | |
85 | ||
86 | sub __set_properties { | |
87 | my $self = shift; | |
88 | ||
89 | $self->set_properties; | |
90 | ||
91 | # begin wxGlade: EB::Wx::Maint::Dagboeken::__set_properties | |
92 | ||
93 | $self->SetTitle(_T("Onderhoud Dagboeken")); | |
94 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(368, 316))); | |
95 | $self->{c_type}->SetSelection(0); | |
96 | $self->{c_dcsplit}->SetSelection(0); | |
97 | $self->{b_close}->SetFocus(); | |
98 | $self->{b_close}->SetDefault(); | |
99 | ||
100 | # end wxGlade | |
101 | } | |
102 | ||
103 | sub __do_layout { | |
104 | my $self = shift; | |
105 | ||
106 | # begin wxGlade: EB::Wx::Maint::Dagboeken::__do_layout | |
107 | ||
108 | $self->{sz_main} = Wx::BoxSizer->new(wxVERTICAL); | |
109 | $self->{sz_buttons} = Wx::BoxSizer->new(wxHORIZONTAL); | |
110 | $self->{s_details}= Wx::StaticBoxSizer->new($self->{s_details_staticbox}, wxHORIZONTAL); | |
111 | $self->{sizer_4} = Wx::BoxSizer->new(wxVERTICAL); | |
112 | $self->{sizer_6} = Wx::BoxSizer->new(wxHORIZONTAL); | |
113 | $self->{sizer_5} = Wx::BoxSizer->new(wxHORIZONTAL); | |
114 | $self->{grid_sizer_1} = Wx::FlexGridSizer->new(3, 3, 3, 5); | |
115 | $self->{sizer_7} = Wx::BoxSizer->new(wxHORIZONTAL); | |
116 | $self->{sz_grid}= Wx::StaticBoxSizer->new($self->{sz_grid_staticbox}, wxHORIZONTAL); | |
117 | $self->{sz_dbk} = Wx::BoxSizer->new(wxVERTICAL); | |
118 | $self->{sizer_2} = Wx::BoxSizer->new(wxVERTICAL); | |
119 | $self->{sizer_3} = Wx::BoxSizer->new(wxHORIZONTAL); | |
120 | $self->{sizer_2}->Add($self->{gr_list}, 1, wxEXPAND, 0); | |
121 | $self->{sizer_2}->Add($self->{static_line_2}, 0, wxTOP|wxEXPAND, 5); | |
122 | $self->{sizer_3}->Add($self->{b_add}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
123 | $self->{sizer_3}->Add($self->{b_details}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
124 | $self->{sizer_3}->Add($self->{b_remove}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
125 | $self->{sizer_3}->Add(1, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
126 | $self->{sizer_2}->Add($self->{sizer_3}, 0, wxTOP|wxEXPAND, 5); | |
127 | $self->{sz_dbk}->Add($self->{sizer_2}, 1, wxALL|wxEXPAND, 5); | |
128 | $self->{sz_grid}->Add($self->{sz_dbk}, 1, wxEXPAND, 0); | |
129 | $self->{sz_main}->Add($self->{sz_grid}, 1, wxALL|wxEXPAND, 5); | |
130 | $self->{grid_sizer_1}->Add($self->{label_1}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
131 | $self->{grid_sizer_1}->Add($self->{label_2}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
132 | $self->{grid_sizer_1}->Add($self->{label_3}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
133 | $self->{grid_sizer_1}->Add($self->{t_code}, 0, wxADJUST_MINSIZE, 0); | |
134 | $self->{grid_sizer_1}->Add($self->{t_desc}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
135 | $self->{grid_sizer_1}->Add($self->{c_type}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
136 | $self->{grid_sizer_1}->Add(1, 1, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
137 | $self->{grid_sizer_1}->Add($self->{label_4}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
138 | $self->{grid_sizer_1}->Add($self->{label_5}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
139 | $self->{grid_sizer_1}->Add(2, 2, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
140 | $self->{sizer_7}->Add($self->{cb_acct}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
141 | $self->{sizer_7}->Add($self->{t_acct}, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
142 | $self->{grid_sizer_1}->Add($self->{sizer_7}, 1, wxEXPAND, 0); | |
143 | $self->{grid_sizer_1}->Add($self->{c_dcsplit}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
144 | $self->{grid_sizer_1}->AddGrowableCol(1); | |
145 | $self->{sizer_5}->Add($self->{grid_sizer_1}, 1, wxEXPAND, 0); | |
146 | $self->{sizer_4}->Add($self->{sizer_5}, 1, wxEXPAND, 0); | |
147 | $self->{sizer_4}->Add($self->{static_line_1}, 0, wxTOP|wxEXPAND, 5); | |
148 | $self->{sizer_6}->Add($self->{b_apply}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
149 | $self->{sizer_6}->Add($self->{b_cancel}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
150 | $self->{sizer_6}->Add(1, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
151 | $self->{sizer_4}->Add($self->{sizer_6}, 0, wxTOP|wxEXPAND, 5); | |
152 | $self->{s_details}->Add($self->{sizer_4}, 1, wxALL|wxEXPAND, 5); | |
153 | $self->{sz_main}->Add($self->{s_details}, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
154 | $self->{sz_buttons}->Add($self->{l_inuse}, 0, wxLEFT|wxBOTTOM|wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
155 | $self->{sz_buttons}->Add(20, 20, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
156 | $self->{sz_buttons}->Add($self->{b_close}, 0, wxALL|wxEXPAND|wxADJUST_MINSIZE|wxFIXED_MINSIZE, 5); | |
157 | $self->{sz_main}->Add($self->{sz_buttons}, 0, wxALL|wxEXPAND, 5); | |
158 | $self->SetSizer($self->{sz_main}); | |
159 | $self->Layout(); | |
160 | ||
161 | # end wxGlade | |
162 | } | |
163 | ||
164 | sub set_properties { # Specific | |
165 | my $self = shift; | |
166 | ||
167 | $self->{c_type}->Append($_) foreach grep { !/^-/ } @{DBKTYPES()}; | |
168 | $self->{c_dcsplit}->Append($_) foreach qw(Samen Apart); | |
169 | ||
170 | $self->{t_acct}->Destroy; | |
171 | $self->{t_acct} = EB::Wx::UI::BalAccInput->new($self, -1); | |
172 | ||
173 | $self->{gr_list}->CreateGrid(0, 5); | |
174 | $self->{gr_list}->SetRowLabelSize(0); | |
175 | $self->{gr_list}->EnableEditing(0); | |
176 | $self->{gr_list}->EnableDragColSize(0); | |
177 | $self->{gr_list}->EnableDragRowSize(0); | |
178 | $self->{gr_list}->SetSelectionMode(wxGridSelectRows); | |
179 | $self->{gr_list}->SetColLabelValue(0, _T("Code")); | |
180 | $self->{gr_list}->SetColLabelValue(1, _T("Omschrijving")); | |
181 | $self->{gr_list}->SetColLabelValue(2, _T("Type")); | |
182 | $self->{gr_list}->SetColLabelValue(3, _T("Grootboekrekening")); | |
183 | $self->{gr_list}->SetColLabelValue(4, _T("Debet/Credit")); | |
184 | ||
185 | } | |
186 | ||
187 | ################ Task Specific Code ################ | |
188 | ||
189 | sub get_data { | |
190 | my ($self) = @_; | |
191 | $self->{_grid_map} = []; | |
192 | my $sth = $dbh->sql_exec | |
193 | ("SELECT dbk_id, dbk_desc, dbk_type, dbk_dcsplit, dbk_acc_id". | |
194 | " FROM Dagboeken". | |
195 | " ORDER BY dbk_id"); | |
196 | while ( my $rr = $sth->fetchrow_arrayref ) { | |
197 | push(@{$self->{_grid_map}}, | |
198 | [@$rr, | |
199 | defined($dbh->do | |
200 | ("SELECT jnl_date FROM Journal". | |
201 | " WHERE jnl_dbk_id = ? OR jnl_rel_dbk = ? LIMIT 1", | |
202 | $rr->[0], $rr->[0])) ? 1 : 0]); | |
203 | } | |
204 | } | |
205 | ||
206 | sub fill_row { | |
207 | my ($self, $row, @values) = @_; | |
208 | my $col = 0; | |
209 | my $p = $self->{gr_list}; | |
210 | $p->SetCellValue($row, $col++, $values[0]); | |
211 | $p->SetCellValue($row, $col++, $values[1]); | |
212 | $p->SetCellValue($row, $col++, DBKTYPES->[$values[2]]); | |
213 | $p->SetCellValue($row, $col++, $values[4] . " " . $dbh->accts->{$values[4]}); | |
214 | $p->SetCellValue($row, $col++, $values[3] ? "Apart" : "Samen"); | |
215 | } | |
216 | ||
217 | sub show_row { | |
218 | my ($self, $row, @v) = @_; | |
219 | $self->{t_code}->SetValue(shift(@v)); | |
220 | $self->{t_desc}->SetValue(shift(@v)); | |
221 | $self->{c_type}->SetSelection(shift(@v)-1); | |
222 | $self->{c_dcsplit}->SetSelection(shift(@v)); | |
223 | if ( defined $v[0] ) { | |
224 | $self->{t_acct}->SetValue(shift(@v)); | |
225 | $self->{t_acct}->Enable(1); | |
226 | $self->{cb_acct}->SetValue(1); | |
227 | } | |
228 | else { | |
229 | $self->{t_acct}->SetValue(""); | |
230 | $self->{t_acct}->Enable(0); | |
231 | $self->{cb_acct}->SetValue(0); | |
232 | shift(@v); | |
233 | } | |
234 | } | |
235 | ||
236 | sub details_inuse { | |
237 | my ($self, $row) = @_; | |
238 | $self->{$_}->Enable(!$self->is_inuse($row)) | |
239 | foreach qw(t_code c_type cb_acct t_acct); | |
240 | } | |
241 | ||
242 | sub changed { | |
243 | my ($self) = @_; | |
244 | return 0 unless $self->{_details_shown}; | |
245 | my $v = $self->{_grid_map}->[$self->{_curr_row}]; | |
246 | return 1 if $self->{t_code}->GetValue ne $v->[0]; | |
247 | return 2 if $self->{t_desc}->GetValue ne $v->[1]; | |
248 | return 3 if $self->{c_type}->GetSelection != $v->[2]-1; | |
249 | return 4 if $self->{c_dcsplit}->GetSelection != 0+$v->[3]; | |
250 | return 5 if $self->{t_acct}->GetValue != $v->[4]; | |
251 | return 0; | |
252 | } | |
253 | ||
254 | sub new_row { | |
255 | my ($self) = @_; | |
256 | [ "", "", 1, 0, 0 ]; | |
257 | } | |
258 | ||
259 | sub delete_row { | |
260 | my ($self, $code) = @_; | |
261 | $dbh->begin_work; | |
262 | eval { | |
263 | $dbh->sql_exec("DELETE FROM Dagboeken". | |
264 | " WHERE dbk_id = ?", | |
265 | $code); | |
266 | $dbh->commit; | |
267 | $self->refresh; | |
268 | }; | |
269 | if ( $@ ) { | |
270 | $dbh->rollback; | |
271 | my $msg; | |
272 | $msg = "Fout tijdens het bijwerken van dagboek $code:\n". $@; | |
273 | $msg =~ s/\nat .*//s; | |
274 | EB::Wx::MessageDialog | |
275 | ($self, | |
276 | $msg, "Fout tijdens het bijwerken", | |
277 | wxOK|wxICON_ERROR); | |
278 | } | |
279 | } | |
280 | ||
281 | sub apply { | |
282 | my ($self, $row) = @_; | |
283 | ||
284 | $dbh->begin_work; | |
285 | ||
286 | my $error; | |
287 | my @fields = qw(dbk_id dbk_desc dbk_type dbk_dcsplit dbk_acc_id); | |
288 | my $code; | |
289 | ||
290 | eval { | |
291 | if ( $self->is_new($row) ) { | |
292 | # New... | |
293 | if ( !($code = $self->{t_code}->GetValue) | |
294 | || !$self->{t_desc}->GetValue | |
295 | || ( $self->{c_type}->GetSelection + 1 != DBKTYPE_MEMORIAAL && !$self->{t_acct}->GetValue ) ) { | |
296 | die("Niet alle verplichte gegevens zijn ingevuld\n"); | |
297 | } | |
298 | $dbh->sql_insert("Dagboeken", | |
299 | \@fields, | |
300 | $code, | |
301 | $self->{t_desc}->GetValue, | |
302 | 1 + $self->{c_type}->GetSelection, | |
303 | $self->{c_dcsplit}->GetSelection, | |
304 | $self->{t_acct}->GetValue); | |
305 | $self->{_grid_map}->[$row]->[-1] = 0; | |
306 | } | |
307 | else { | |
308 | # Modified... | |
309 | ||
310 | my @sets; | |
311 | my @values; | |
312 | my @ovalues = @{$self->{_grid_map}->[$row]}; | |
313 | $code = $ovalues[0]; | |
314 | my @nvalues = ( $self->{t_code}->GetValue, | |
315 | $self->{t_desc}->GetValue, | |
316 | $self->{c_type}->GetSelection + 1, | |
317 | $self->{c_dcsplit}->GetSelection, | |
318 | $self->{t_acct}->GetValue ); | |
319 | ||
320 | my $i = 0; | |
321 | foreach ( @fields ) { | |
322 | if ( $ovalues[$i] ne $nvalues[$i] ) { | |
323 | push(@sets, $fields[$i]." = ?"); | |
324 | push(@values, $nvalues[$i]); | |
325 | } | |
326 | $i++; | |
327 | } | |
328 | ||
329 | $dbh->sql_exec("UPDATE Dagboeken". | |
330 | " SET ". join(", ", @sets). | |
331 | " WHERE dbk_id = ?", | |
332 | @values, $code); | |
333 | } | |
334 | ||
335 | $dbh->commit; | |
336 | $self->hide_details; | |
337 | $self->refresh; | |
338 | ||
339 | }; | |
340 | ||
341 | if ( $@ ) { | |
342 | $dbh->rollback; | |
343 | my $msg; | |
344 | if ( $dbh->dbh->state eq '23505' ) { | |
345 | $msg = "Dagboekcode $code bestaat al\n"; | |
346 | } | |
347 | else { | |
348 | $msg = "Fout tijdens het bijwerken van dagboekcode $code:\n". $@; | |
349 | } | |
350 | $msg =~ s/\nat .*//s; | |
351 | EB::Wx::MessageDialog | |
352 | ($self, | |
353 | $msg, "Fout tijdens het bijwerken", | |
354 | wxOK|wxICON_ERROR); | |
355 | } | |
356 | } | |
357 | ||
358 | # wxGlade: EB::Wx::Maint::Dagboeken::OnCBAcct <event_handler> | |
359 | sub OnCBAcct { | |
360 | my ($self, $event) = @_; | |
361 | if ( $self->{cb_acct}->IsChecked ) { | |
362 | $self->{t_acct}->Enable(1); | |
363 | } | |
364 | else { | |
365 | $self->{t_acct}->SetValue(""); | |
366 | $self->{t_acct}->Enable(0); | |
367 | } | |
368 | } | |
369 | ||
370 | ################ Generic Code ################ | |
371 | ||
372 | sub is_new { | |
373 | my ($self, $row) = @_; | |
374 | $self->{_grid_map}->[$row]->[-1] < 0; | |
375 | } | |
376 | ||
377 | sub is_inuse { | |
378 | my ($self, $row) = @_; | |
379 | $self->{_grid_map}->[$row]->[-1] > 0; | |
380 | } | |
381 | ||
382 | sub refresh { | |
383 | my ($self) = @_; | |
384 | ||
385 | $self->get_data; | |
386 | my $p = $self->{gr_list}; | |
387 | $p->DeleteRows(0, $p->GetNumberRows, 1); | |
388 | $p->AppendRows(scalar(@{$self->{_grid_map}})); | |
389 | my $row = 0; | |
390 | my $inuse = 0; | |
391 | foreach ( @{$self->{_grid_map}} ) { | |
392 | $self->fill_row($row, @$_); | |
393 | $inuse ||= $self->is_inuse($row); | |
394 | $row++; | |
395 | } | |
396 | ||
397 | $self->set_current(0); | |
398 | $self->resize_grid($p); | |
399 | undef $self->{_details_shown}; | |
400 | $self->{sz_buttons}->Show(0, $inuse); | |
401 | } | |
402 | ||
403 | sub set_current { | |
404 | my ($self, $row) = @_; | |
405 | $self->{_curr_row} = $row; | |
406 | $self->{b_remove}->Enable(!$self->is_inuse($row)); | |
407 | } | |
408 | ||
409 | sub show_details { | |
410 | my ($self, $row) = @_; | |
411 | $row = $self->{_curr_row} unless defined $row; | |
412 | ||
413 | $self->show_row($row, @{$self->{_grid_map}->[$row]}); | |
414 | $self->details_inuse($row); | |
415 | ||
416 | $self->{$_}->Enable(0) | |
417 | foreach qw(b_apply gr_list b_add b_details b_remove); | |
418 | ||
419 | $self->{sz_main}->Show(1,1); | |
420 | $self->{sz_main}->Show(2,0); | |
421 | $self->Layout; | |
422 | $self->{_details_shown} = 1; | |
423 | } | |
424 | ||
425 | sub hide_details { | |
426 | my ($self) = @_; | |
427 | $self->{$_}->Enable(1) | |
428 | foreach qw(gr_list b_add b_details); | |
429 | $self->{b_remove}->Enable(1) unless $self->is_inuse($self->{_curr_row}); | |
430 | $self->{sz_main}->Show(1,0); | |
431 | $self->{sz_main}->Show(2,1); | |
432 | $self->Layout; | |
433 | $self->{_details_shown} = 0; | |
434 | } | |
435 | ||
436 | sub OnIdle { | |
437 | my ($self) = @_; | |
438 | return unless $self->{_details_shown}; | |
439 | $self->{b_apply}->Enable($self->changed); | |
440 | } | |
441 | ||
442 | # wxGlade: EB::Wx::Maint::Dagboeken::OnClose <event_handler> | |
443 | sub OnClose { | |
444 | my ($self, $event) = @_; | |
445 | ||
446 | if ( $self->changed ) { | |
447 | my $r = EB::Wx::MessageDialog | |
448 | ($self, | |
449 | "Er zijn nog wijzigingen, deze zullen verloren gaan.\n". | |
450 | "Venster toch sluiten?", | |
451 | "Annuleren", | |
452 | wxYES_NO|wxNO_DEFAULT|wxICON_ERROR); | |
453 | return unless $r == wxID_YES; | |
454 | } | |
455 | ||
456 | $self->sizepos_save; | |
457 | $self->Show(0); | |
458 | } | |
459 | ||
460 | # wxGlade: EB::Wx::Maint::Dagboeken::OnAdd <event_handler> | |
461 | sub OnAdd { | |
462 | my ($self, $event) = @_; | |
463 | my $p = $self->{gr_list}; | |
464 | my $row = $p->GetNumberRows; | |
465 | $p->AppendRows(1); | |
466 | my $rr = $self->new_row; | |
467 | $self->fill_row($row, @$rr); | |
468 | push(@{$self->{_grid_map}}, [@$rr, -1]); | |
469 | $self->set_current($row); | |
470 | $self->show_details($row); | |
471 | } | |
472 | ||
473 | # wxGlade: EB::Wx::Maint::Dagboeken::OnDetails <event_handler> | |
474 | sub OnDetails { | |
475 | my ($self, $event) = @_; | |
476 | $self->show_details($self->{_curr_row}); | |
477 | } | |
478 | ||
479 | # wxGlade: EB::Wx::Maint::Dagboeken::OnRemove <event_handler> | |
480 | sub OnRemove { | |
481 | my ($self, $event) = @_; | |
482 | my $code = $self->{_grid_map}->[$self->{_curr_row}]->[0]; | |
483 | $self->delete_row($code); | |
484 | } | |
485 | ||
486 | # wxGlade: EB::Wx::Maint::Dagboeken::OnApply <event_handler> | |
487 | sub OnApply { | |
488 | my ($self, $event) = @_; | |
489 | $self->apply($self->{_curr_row}); | |
490 | } | |
491 | ||
492 | # wxGlade: EB::Wx::Maint::Dagboeken::OnCancel <event_handler> | |
493 | sub OnCancel { | |
494 | my ($self, $event) = @_; | |
495 | if ( $self->changed ) { | |
496 | my $r = EB::Wx::MessageDialog | |
497 | ($self, | |
498 | "Er zijn nog wijzigingen, deze zullen verloren gaan.\n". | |
499 | "Toch annuleren?", | |
500 | "Annuleren", | |
501 | wxYES_NO|wxNO_DEFAULT|wxICON_ERROR); | |
502 | return unless $r == wxID_YES; | |
503 | } | |
504 | $self->hide_details; | |
505 | if ( $self->{_curr_row} > 0 && $self->is_new($self->{_curr_row}) ) { | |
506 | $self->{gr_list}->DeleteRows($self->{_curr_row}, 1); | |
507 | $self->{_curr_row}--; | |
508 | } | |
509 | # end wxGlade | |
510 | } | |
511 | ||
512 | sub OnClick { | |
513 | my ($self, $event) = @_; | |
514 | $self = $self->GetParent; | |
515 | my $row = $event->GetRow; | |
516 | $self->{gr_list}->SelectRow($row); | |
517 | $self->set_current($row); | |
518 | $event->Skip; | |
519 | } | |
520 | ||
521 | # wxGlade: EB::Wx::Maint::Dagboeken::OnSel <event_handler> | |
522 | sub OnSel { | |
523 | my ($self, $event) = @_; | |
524 | $self = $self->GetParent; | |
525 | $self->set_current($event->GetRow); | |
526 | $self->show_details; | |
527 | } | |
528 | ||
529 | # end of class EB::Wx::Maint::Dagboeken | |
530 | ||
531 | 1; | |
532 |
0 | #! perl | |
1 | ||
2 | # $Id: Relaties.pm,v 1.13 2008/03/25 22:59:01 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $app; | |
8 | our $dbh; | |
9 | ||
10 | package EB::Wx::Maint::Relaties; | |
11 | ||
12 | use Wx qw[:everything]; | |
13 | use strict; | |
14 | use base qw(Wx::Dialog); | |
15 | use base qw(EB::Wx::Window); | |
16 | use Wx::Grid; | |
17 | use EB; | |
18 | use EB::Wx::UI::AccInput; | |
19 | ||
20 | sub new { | |
21 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
22 | $parent = undef unless defined $parent; | |
23 | $id = -1 unless defined $id; | |
24 | $title = "" unless defined $title; | |
25 | $pos = wxDefaultPosition unless defined $pos; | |
26 | $size = wxDefaultSize unless defined $size; | |
27 | $name = "" unless defined $name; | |
28 | ||
29 | # begin wxGlade: EB::Wx::Maint::Relaties::new | |
30 | ||
31 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTHICK_FRAME | |
32 | unless defined $style; | |
33 | ||
34 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
35 | $self->{s_details_staticbox} = Wx::StaticBox->new($self, -1, _T("Details") ); | |
36 | $self->{sz_grid_staticbox} = Wx::StaticBox->new($self, -1, _T("Relaties") ); | |
37 | $self->{label_6} = Wx::StaticText->new($self, -1, _T("Selecteer:"), wxDefaultPosition, wxDefaultSize, ); | |
38 | $self->{cb_deb} = Wx::CheckBox->new($self, -1, _T("Debiteuren"), wxDefaultPosition, wxDefaultSize, ); | |
39 | $self->{cb_crd} = Wx::CheckBox->new($self, -1, _T("Crediteuren"), wxDefaultPosition, wxDefaultSize, ); | |
40 | $self->{gr_list} = Wx::Grid->new($self, -1); | |
41 | $self->{static_line_2} = Wx::StaticLine->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
42 | $self->{b_add} = Wx::Button->new($self, -1, _T("Toevoegen")); | |
43 | $self->{b_details} = Wx::Button->new($self, -1, _T("Wijzigen")); | |
44 | $self->{b_remove} = Wx::Button->new($self, -1, _T("Verwijderen")); | |
45 | $self->{label_1} = Wx::StaticText->new($self, -1, _T("Code"), wxDefaultPosition, wxDefaultSize, ); | |
46 | $self->{label_2} = Wx::StaticText->new($self, -1, _T("Omschrijving"), wxDefaultPosition, wxDefaultSize, ); | |
47 | $self->{label_3} = Wx::StaticText->new($self, -1, _T("Dagboek"), wxDefaultPosition, wxDefaultSize, ); | |
48 | $self->{t_code} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
49 | $self->{t_desc} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
50 | $self->{c_dbk} = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, [], ); | |
51 | $self->{label_4} = Wx::StaticText->new($self, -1, _T("Grootboekrekening"), wxDefaultPosition, wxDefaultSize, ); | |
52 | $self->{label_5} = Wx::StaticText->new($self, -1, _T("BTW"), wxDefaultPosition, wxDefaultSize, ); | |
53 | $self->{t_acct} = EB::Wx::UI::AccInput->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
54 | $self->{c_btw} = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, [], ); | |
55 | $self->{static_line_1} = Wx::StaticLine->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
56 | $self->{b_apply} = Wx::Button->new($self, -1, _T("Toepassen")); | |
57 | $self->{b_cancel} = Wx::Button->new($self, -1, _T("Annuleren")); | |
58 | $self->{l_inuse} = Wx::StaticText->new($self, -1, _T("Sommige gegevens zijn in gebruik en\nkunnen niet meer worden gewijzigd."), wxDefaultPosition, wxDefaultSize, ); | |
59 | $self->{b_close} = Wx::Button->new($self, wxID_CLOSE, ""); | |
60 | ||
61 | $self->__set_properties(); | |
62 | $self->__do_layout(); | |
63 | ||
64 | Wx::Event::EVT_CHECKBOX($self, $self->{cb_deb}->GetId, \&OnDeb); | |
65 | Wx::Event::EVT_CHECKBOX($self, $self->{cb_crd}->GetId, \&OnCrd); | |
66 | Wx::Event::EVT_BUTTON($self, $self->{b_add}->GetId, \&OnAdd); | |
67 | Wx::Event::EVT_BUTTON($self, $self->{b_details}->GetId, \&OnDetails); | |
68 | Wx::Event::EVT_BUTTON($self, $self->{b_remove}->GetId, \&OnRemove); | |
69 | Wx::Event::EVT_BUTTON($self, $self->{b_apply}->GetId, \&OnApply); | |
70 | Wx::Event::EVT_BUTTON($self, $self->{b_cancel}->GetId, \&OnCancel); | |
71 | Wx::Event::EVT_BUTTON($self, $self->{b_close}->GetId, \&OnClose); | |
72 | ||
73 | # end wxGlade | |
74 | ||
75 | Wx::Event::EVT_MENU($self, wxID_CLOSE, \&OnClose); | |
76 | Wx::Event::EVT_GRID_SELECT_CELL($self->{gr_list}, sub {}); | |
77 | Wx::Event::EVT_GRID_CELL_LEFT_CLICK($self->{gr_list}, \&OnClick); | |
78 | Wx::Event::EVT_GRID_CELL_LEFT_DCLICK($self->{gr_list}, \&OnSel); | |
79 | Wx::Event::EVT_CLOSE($self, \&OnClose); | |
80 | Wx::Event::EVT_IDLE($self, \&OnIdle); | |
81 | $self->{sz_buttons}->Show(0, 0); | |
82 | $self->{sz_main}->Show(1, 0); | |
83 | $self->Layout; | |
84 | ||
85 | return $self; | |
86 | ||
87 | } | |
88 | ||
89 | sub __set_properties { | |
90 | my $self = shift; | |
91 | ||
92 | $self->set_properties; | |
93 | ||
94 | # begin wxGlade: EB::Wx::Maint::Relaties::__set_properties | |
95 | ||
96 | $self->SetTitle(_T("Onderhoud Relaties")); | |
97 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(368, 316))); | |
98 | $self->{cb_deb}->SetValue(1); | |
99 | $self->{cb_crd}->SetValue(1); | |
100 | $self->{c_dbk}->SetSelection(0); | |
101 | $self->{c_btw}->SetSelection(0); | |
102 | $self->{b_close}->SetFocus(); | |
103 | $self->{b_close}->SetDefault(); | |
104 | ||
105 | # end wxGlade | |
106 | } | |
107 | ||
108 | sub __do_layout { | |
109 | my $self = shift; | |
110 | ||
111 | # begin wxGlade: EB::Wx::Maint::Relaties::__do_layout | |
112 | ||
113 | $self->{sz_main} = Wx::BoxSizer->new(wxVERTICAL); | |
114 | $self->{sz_buttons} = Wx::BoxSizer->new(wxHORIZONTAL); | |
115 | $self->{s_details}= Wx::StaticBoxSizer->new($self->{s_details_staticbox}, wxHORIZONTAL); | |
116 | $self->{sizer_4} = Wx::BoxSizer->new(wxVERTICAL); | |
117 | $self->{sizer_6} = Wx::BoxSizer->new(wxHORIZONTAL); | |
118 | $self->{sizer_5} = Wx::BoxSizer->new(wxHORIZONTAL); | |
119 | $self->{grid_sizer_1} = Wx::FlexGridSizer->new(3, 3, 3, 5); | |
120 | $self->{sz_grid}= Wx::StaticBoxSizer->new($self->{sz_grid_staticbox}, wxHORIZONTAL); | |
121 | $self->{sz_dbk} = Wx::BoxSizer->new(wxVERTICAL); | |
122 | $self->{sizer_2} = Wx::BoxSizer->new(wxVERTICAL); | |
123 | $self->{sizer_3} = Wx::BoxSizer->new(wxHORIZONTAL); | |
124 | $self->{sizer_1} = Wx::BoxSizer->new(wxHORIZONTAL); | |
125 | $self->{sizer_1}->Add($self->{label_6}, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
126 | $self->{sizer_1}->Add($self->{cb_deb}, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
127 | $self->{sizer_1}->Add($self->{cb_crd}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
128 | $self->{sizer_1}->Add(1, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
129 | $self->{sizer_2}->Add($self->{sizer_1}, 0, wxBOTTOM|wxEXPAND, 5); | |
130 | $self->{sizer_2}->Add($self->{gr_list}, 1, wxEXPAND, 0); | |
131 | $self->{sizer_2}->Add($self->{static_line_2}, 0, wxTOP|wxEXPAND, 5); | |
132 | $self->{sizer_3}->Add($self->{b_add}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
133 | $self->{sizer_3}->Add($self->{b_details}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
134 | $self->{sizer_3}->Add($self->{b_remove}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
135 | $self->{sizer_3}->Add(1, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
136 | $self->{sizer_2}->Add($self->{sizer_3}, 0, wxTOP|wxEXPAND, 5); | |
137 | $self->{sz_dbk}->Add($self->{sizer_2}, 1, wxALL|wxEXPAND, 5); | |
138 | $self->{sz_grid}->Add($self->{sz_dbk}, 1, wxEXPAND, 0); | |
139 | $self->{sz_main}->Add($self->{sz_grid}, 1, wxALL|wxEXPAND, 5); | |
140 | $self->{grid_sizer_1}->Add($self->{label_1}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
141 | $self->{grid_sizer_1}->Add($self->{label_2}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
142 | $self->{grid_sizer_1}->Add($self->{label_3}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
143 | $self->{grid_sizer_1}->Add($self->{t_code}, 0, wxADJUST_MINSIZE, 0); | |
144 | $self->{grid_sizer_1}->Add($self->{t_desc}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
145 | $self->{grid_sizer_1}->Add($self->{c_dbk}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
146 | $self->{grid_sizer_1}->Add(1, 1, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
147 | $self->{grid_sizer_1}->Add($self->{label_4}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
148 | $self->{grid_sizer_1}->Add($self->{label_5}, 0, wxALIGN_BOTTOM|wxADJUST_MINSIZE, 0); | |
149 | $self->{grid_sizer_1}->Add(2, 2, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
150 | $self->{grid_sizer_1}->Add($self->{t_acct}, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
151 | $self->{grid_sizer_1}->Add($self->{c_btw}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
152 | $self->{grid_sizer_1}->AddGrowableCol(1); | |
153 | $self->{sizer_5}->Add($self->{grid_sizer_1}, 1, wxEXPAND, 0); | |
154 | $self->{sizer_4}->Add($self->{sizer_5}, 1, wxEXPAND, 0); | |
155 | $self->{sizer_4}->Add($self->{static_line_1}, 0, wxTOP|wxEXPAND, 5); | |
156 | $self->{sizer_6}->Add($self->{b_apply}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
157 | $self->{sizer_6}->Add($self->{b_cancel}, 0, wxRIGHT|wxADJUST_MINSIZE, 5); | |
158 | $self->{sizer_6}->Add(1, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
159 | $self->{sizer_4}->Add($self->{sizer_6}, 0, wxTOP|wxEXPAND, 5); | |
160 | $self->{s_details}->Add($self->{sizer_4}, 1, wxALL|wxEXPAND, 5); | |
161 | $self->{sz_main}->Add($self->{s_details}, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
162 | $self->{sz_buttons}->Add($self->{l_inuse}, 0, wxLEFT|wxBOTTOM|wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
163 | $self->{sz_buttons}->Add(20, 20, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
164 | $self->{sz_buttons}->Add($self->{b_close}, 0, wxALL|wxEXPAND|wxADJUST_MINSIZE|wxFIXED_MINSIZE, 5); | |
165 | $self->{sz_main}->Add($self->{sz_buttons}, 0, wxALL|wxEXPAND, 5); | |
166 | $self->SetSizer($self->{sz_main}); | |
167 | $self->Layout(); | |
168 | ||
169 | # end wxGlade | |
170 | } | |
171 | ||
172 | sub set_properties { # Specific | |
173 | my $self = shift; | |
174 | ||
175 | my $sth = $dbh->sql_exec("SELECT dbk_id, dbk_desc". | |
176 | " FROM Dagboeken". | |
177 | " WHERE dbk_type = ? OR dbk_type = ?". | |
178 | " ORDER BY dbk_id", | |
179 | DBKTYPE_INKOOP, DBKTYPE_VERKOOP); | |
180 | $self->{_dbk_map} = []; | |
181 | $self->{_dbk_ord} = {}; | |
182 | while ( my $rr = $sth->fetch ) { | |
183 | $self->{c_dbk}->Append($rr->[1]); | |
184 | $self->{_dbk_ord}->{$rr->[0]} = scalar(@{$self->{_dbk_map}}); | |
185 | push(@{$self->{_dbk_map}}, [@$rr]); | |
186 | } | |
187 | $self->{c_btw}->Append($_) foreach @{BTWTYPES()}; | |
188 | ||
189 | $self->{gr_list}->CreateGrid(0, 5); | |
190 | $self->{gr_list}->SetRowLabelSize(0); | |
191 | $self->{gr_list}->EnableEditing(0); | |
192 | $self->{gr_list}->EnableDragColSize(0); | |
193 | $self->{gr_list}->EnableDragRowSize(0); | |
194 | $self->{gr_list}->SetSelectionMode(wxGridSelectRows); | |
195 | $self->{gr_list}->SetColLabelValue(0, _T("Code")); | |
196 | $self->{gr_list}->SetColLabelValue(1, _T("Omschrijving")); | |
197 | $self->{gr_list}->SetColLabelValue(2, _T("Grootboekrekening")); | |
198 | $self->{gr_list}->SetColLabelValue(3, _T("Dagboek")); | |
199 | $self->{gr_list}->SetColLabelValue(4, _T("BTW")); | |
200 | ||
201 | } | |
202 | ||
203 | ################ Task Specific Code ################ | |
204 | ||
205 | sub get_data { | |
206 | my ($self) = @_; | |
207 | $self->{_grid_map} = []; | |
208 | ||
209 | my $deb = $self->{cb_deb}->GetValue; | |
210 | my $crd = $self->{cb_crd}->GetValue; | |
211 | my $asel = ""; | |
212 | if ( $deb && !$crd ) { | |
213 | $asel = " WHERE rel_debcrd"; | |
214 | } | |
215 | elsif ( !$deb && $crd ) { | |
216 | $asel = " WHERE NOT rel_debcrd"; | |
217 | } | |
218 | ||
219 | my $sth = $dbh->sql_exec | |
220 | ("SELECT rel_code, rel_desc, rel_acc_id, rel_ledger, rel_btw_status". | |
221 | " FROM Relaties". | |
222 | $asel. | |
223 | " ORDER BY rel_code"); | |
224 | while ( my $rr = $sth->fetch ) { | |
225 | my $inuse = defined $dbh->do("SELECT bsr_nr FROM Boekstukregels". | |
226 | " WHERE bsr_rel_code = ? AND bsr_dbk_id = ? LIMIT 1", | |
227 | $rr->[0], $rr->[3]); | |
228 | push(@{$self->{_grid_map}}, [@$rr, $inuse]); | |
229 | } | |
230 | $self->{l_inuse}->Show(0); | |
231 | } | |
232 | ||
233 | sub fill_row { | |
234 | my ($self, $row, @values) = @_; | |
235 | my $col = 0; | |
236 | my $p = $self->{gr_list}; | |
237 | $p->SetCellValue($row, $col++, $values[0]); | |
238 | $p->SetCellValue($row, $col++, $values[1]); | |
239 | $p->SetCellValue($row, $col++, $values[2] . " " . $dbh->accts->{$values[2]}); | |
240 | $p->SetCellValue($row, $col++, $self->{_dbk_map}->[$self->{_dbk_ord}->{$values[3]}]->[1]); | |
241 | $p->SetCellValue($row, $col++, BTWTYPES->[$values[4]]); | |
242 | } | |
243 | ||
244 | sub show_row { | |
245 | my ($self, $row, @v) = @_; | |
246 | $self->{t_code}->SetValue(shift(@v)); | |
247 | $self->{t_desc}->SetValue(shift(@v)); | |
248 | $self->{t_acct}->SetValue(shift(@v)); | |
249 | $self->{c_dbk}->SetSelection($self->{_dbk_ord}->{shift(@v)}); | |
250 | $self->{c_btw}->SetSelection(shift(@v)); | |
251 | } | |
252 | ||
253 | sub details_inuse { | |
254 | my ($self, $row) = @_; | |
255 | $self->{$_}->Enable(!$self->is_inuse($row)) | |
256 | foreach qw(t_code c_dbk c_btw t_acct); | |
257 | } | |
258 | ||
259 | sub changed { | |
260 | my ($self) = @_; | |
261 | return 0 unless $self->{_details_shown}; | |
262 | my $v = $self->{_grid_map}->[$self->{_curr_row}]; | |
263 | return 1 if $self->{t_code}->GetValue ne $v->[0]; | |
264 | return 2 if $self->{t_desc}->GetValue ne $v->[1]; | |
265 | return 3 if $self->{t_acct}->GetValue != $v->[2]; | |
266 | return 4 if $self->{c_dbk}->GetSelection != $self->{_dbk_ord}->{$v->[3]}; | |
267 | return 5 if $self->{c_btw}->GetSelection != $v->[4]; | |
268 | return 0; | |
269 | } | |
270 | ||
271 | sub new_row { | |
272 | my ($self) = @_; | |
273 | [ "", "", 0, $self->{_dbk_map}->[0]->[0], 0 ]; | |
274 | } | |
275 | ||
276 | sub delete_row { | |
277 | my ($self, $code, undef, undef, $dbk) = @_; | |
278 | $dbh->begin_work; | |
279 | eval { | |
280 | $dbh->sql_exec("DELETE FROM Relaties". | |
281 | " WHERE rel_code = ?". | |
282 | " AND rel_ledger = ?", | |
283 | $code, $dbk); | |
284 | $dbh->commit; | |
285 | my $row = $self->{_curr_row}; | |
286 | $row-- if $row >= $self->{gr_list}->GetNumberRows; | |
287 | $self->refresh; | |
288 | $self->{gr_list}->MakeCellVisible($row, 0); | |
289 | $self->{gr_list}->SelectRow($row); | |
290 | }; | |
291 | if ( $@ ) { | |
292 | $dbh->rollback; | |
293 | my $msg; | |
294 | $msg = "Fout tijdens het bijwerken van dagboek $code:\n". $@; | |
295 | $msg =~ s/\nat .*//s; | |
296 | EB::Wx::MessageDialog | |
297 | ($self, | |
298 | $msg, "Fout tijdens het bijwerken", | |
299 | wxOK|wxICON_ERROR); | |
300 | } | |
301 | } | |
302 | ||
303 | sub apply { | |
304 | my ($self, $row) = @_; | |
305 | ||
306 | $dbh->begin_work; | |
307 | ||
308 | my $error; | |
309 | my @fields = qw(rel_code rel_desc rel_acc_id rel_ledger rel_btw_status); | |
310 | my $code; | |
311 | ||
312 | eval { | |
313 | if ( $self->is_new($row) ) { | |
314 | # New... | |
315 | if ( !($code = $self->{t_code}->GetValue) | |
316 | || !$self->{t_desc}->GetValue | |
317 | || !$self->{t_acct}->GetValue ) { | |
318 | die("Niet alle verplichte gegevens zijn ingevuld\n"); | |
319 | } | |
320 | my $dbk = $self->{_dbk_map}->[$self->{c_dbk}->GetSelection]->[0]; | |
321 | $dbh->sql_insert("Relaties", | |
322 | [@fields, "rel_debcrd"], | |
323 | $code, | |
324 | $self->{t_desc}->GetValue, | |
325 | $self->{t_acct}->GetValue, | |
326 | $dbk, | |
327 | $self->{c_btw}->GetSelection, | |
328 | 0+($dbh->lookup($dbk, | |
329 | qw(Dagboeken dbk_id dbk_type)) == DBKTYPE_VERKOOP), | |
330 | ); | |
331 | $self->{_grid_map}->[$row]->[-1] = 0; | |
332 | } | |
333 | else { | |
334 | # Modified... | |
335 | ||
336 | my @sets; | |
337 | my @values; | |
338 | my @ovalues = @{$self->{_grid_map}->[$row]}; | |
339 | $code = $ovalues[0]; | |
340 | my @nvalues = ( $self->{t_code}->GetValue, | |
341 | $self->{t_desc}->GetValue, | |
342 | $self->{t_acct}->GetValue, | |
343 | $self->{_dbk_map}->[$self->{c_dbk}->GetSelection]->[0], | |
344 | $self->{c_btw}->GetSelection, | |
345 | ); | |
346 | ||
347 | my $i = 0; | |
348 | foreach ( @fields ) { | |
349 | if ( $ovalues[$i] ne $nvalues[$i] ) { | |
350 | push(@sets, $fields[$i]." = ?"); | |
351 | push(@values, $nvalues[$i]); | |
352 | if ( $i == 3 ) { | |
353 | push(@sets, "rel_debcrd = ?"); | |
354 | push(@values, | |
355 | 0+($dbh->lookup($nvalues[3], | |
356 | qw(Dagboeken dbk_id dbk_type)) == DBKTYPE_VERKOOP)); | |
357 | } | |
358 | } | |
359 | $i++; | |
360 | } | |
361 | ||
362 | $dbh->sql_exec("UPDATE Relaties". | |
363 | " SET ". join(", ", @sets). | |
364 | " WHERE rel_code = ?". | |
365 | " AND rel_ledger = ?", | |
366 | @values, $ovalues[0], $ovalues[3]); | |
367 | } | |
368 | ||
369 | $dbh->commit; | |
370 | $self->hide_details; | |
371 | $row-- if $row >= $self->{gr_list}->GetNumberRows; | |
372 | $self->refresh; | |
373 | $self->{gr_list}->MakeCellVisible($row, 0); | |
374 | $self->{gr_list}->SelectRow($row); | |
375 | ||
376 | }; | |
377 | ||
378 | if ( $@ ) { | |
379 | $dbh->rollback; | |
380 | my $msg; | |
381 | if ( $dbh->dbh->state eq '23505' ) { | |
382 | $msg = "Relatie $code bestaat al\n"; | |
383 | } | |
384 | else { | |
385 | $msg = "Fout tijdens het bijwerken van relatie $code:\n". $@; | |
386 | } | |
387 | $msg =~ s/\nat .*//s; | |
388 | EB::Wx::MessageDialog | |
389 | ($self, | |
390 | $msg, "Fout tijdens het bijwerken", | |
391 | wxOK|wxICON_ERROR); | |
392 | } | |
393 | } | |
394 | ||
395 | # wxGlade: EB::Wx::Maint::Relaties::OnDeb <event_handler> | |
396 | sub OnDeb { | |
397 | my ($self, $event) = @_; | |
398 | # If only Deb is selected, and Deb gets deselected, the only | |
399 | # logical action is to implicitly select Crd. | |
400 | ||
401 | unless ( $self->{cb_deb}->GetValue || $self->{cb_crd}->GetValue ) { | |
402 | $self->{cb_crd}->SetValue(1); | |
403 | } | |
404 | $self->refresh; | |
405 | } | |
406 | ||
407 | # wxGlade: EB::Wx::Maint::Relaties::OnCrd <event_handler> | |
408 | sub OnCrd { | |
409 | my ($self, $event) = @_; | |
410 | # See comment at OnDeb. | |
411 | ||
412 | unless ( $self->{cb_deb}->GetValue || $self->{cb_crd}->GetValue ) { | |
413 | $self->{cb_deb}->SetValue(1); | |
414 | } | |
415 | $self->refresh; | |
416 | } | |
417 | ||
418 | ################ Generic Code ################ | |
419 | ||
420 | sub is_new { | |
421 | my ($self, $row) = @_; | |
422 | $self->{_grid_map}->[$row]->[-1] < 0; | |
423 | } | |
424 | ||
425 | sub is_inuse { | |
426 | my ($self, $row) = @_; | |
427 | $self->{_grid_map}->[$row]->[-1] > 0; | |
428 | } | |
429 | ||
430 | sub refresh { | |
431 | my ($self) = @_; | |
432 | ||
433 | $self->get_data; | |
434 | my $p = $self->{gr_list}; | |
435 | $p->DeleteRows(0, $p->GetNumberRows, 1); | |
436 | $p->AppendRows(scalar(@{$self->{_grid_map}})); | |
437 | my $row = 0; | |
438 | my $inuse = 0; | |
439 | foreach ( @{$self->{_grid_map}} ) { | |
440 | $self->fill_row($row, @$_); | |
441 | $inuse ||= $self->is_inuse($row); | |
442 | $row++; | |
443 | } | |
444 | ||
445 | $self->set_current(0); | |
446 | $self->resize_grid($p); | |
447 | undef $self->{_details_shown}; | |
448 | $self->{sz_buttons}->Show(0, $inuse); | |
449 | } | |
450 | ||
451 | sub set_current { | |
452 | my ($self, $row) = @_; | |
453 | $self->{_curr_row} = $row; | |
454 | $self->{b_remove}->Enable(!$self->is_inuse($row)); | |
455 | } | |
456 | ||
457 | sub show_details { | |
458 | my ($self, $row) = @_; | |
459 | $row = $self->{_curr_row} unless defined $row; | |
460 | ||
461 | $self->show_row($row, @{$self->{_grid_map}->[$row]}); | |
462 | $self->details_inuse($row); | |
463 | ||
464 | $self->{$_}->Enable(0) | |
465 | foreach qw(b_apply gr_list b_add b_details b_remove); | |
466 | ||
467 | $self->{sz_main}->Show(1,1); | |
468 | $self->{sz_main}->Show(2,0); | |
469 | $self->Layout; | |
470 | $self->{_details_shown} = 1; | |
471 | } | |
472 | ||
473 | sub hide_details { | |
474 | my ($self) = @_; | |
475 | $self->{$_}->Enable(1) | |
476 | foreach qw(gr_list b_add b_details); | |
477 | $self->{b_remove}->Enable(1) unless $self->is_inuse($self->{_curr_row}); | |
478 | $self->{sz_main}->Show(1,0); | |
479 | $self->{sz_main}->Show(2,1); | |
480 | $self->Layout; | |
481 | $self->{_details_shown} = 0; | |
482 | } | |
483 | ||
484 | sub OnIdle { | |
485 | my ($self) = @_; | |
486 | return unless $self->{_details_shown}; | |
487 | $self->{b_apply}->Enable($self->changed); | |
488 | } | |
489 | ||
490 | # wxGlade: EB::Wx::Maint::Relaties::OnClose <event_handler> | |
491 | sub OnClose { | |
492 | my ($self, $event) = @_; | |
493 | ||
494 | if ( $self->changed ) { | |
495 | my $r = EB::Wx::MessageDialog | |
496 | ($self, | |
497 | "Er zijn nog wijzigingen, deze zullen verloren gaan.\n". | |
498 | "Venster toch sluiten?", | |
499 | "Annuleren", | |
500 | wxYES_NO|wxNO_DEFAULT|wxICON_ERROR); | |
501 | return unless $r == wxID_YES; | |
502 | } | |
503 | ||
504 | $self->sizepos_save; | |
505 | $self->Show(0); | |
506 | } | |
507 | ||
508 | # wxGlade: EB::Wx::Maint::Relaties::OnAdd <event_handler> | |
509 | sub OnAdd { | |
510 | my ($self, $event) = @_; | |
511 | my $p = $self->{gr_list}; | |
512 | my $row = $p->GetNumberRows; | |
513 | $p->AppendRows(1); | |
514 | my $rr = $self->new_row; | |
515 | $self->fill_row($row, @$rr); | |
516 | push(@{$self->{_grid_map}}, [@$rr, -1]); | |
517 | $self->set_current($row); | |
518 | $self->show_details($row); | |
519 | } | |
520 | ||
521 | # wxGlade: EB::Wx::Maint::Relaties::OnDetails <event_handler> | |
522 | sub OnDetails { | |
523 | my ($self, $event) = @_; | |
524 | $self->show_details($self->{_curr_row}); | |
525 | } | |
526 | ||
527 | # wxGlade: EB::Wx::Maint::Relaties::OnRemove <event_handler> | |
528 | sub OnRemove { | |
529 | my ($self, $event) = @_; | |
530 | $self->delete_row(@{$self->{_grid_map}->[$self->{_curr_row}]}); | |
531 | } | |
532 | ||
533 | # wxGlade: EB::Wx::Maint::Relaties::OnApply <event_handler> | |
534 | sub OnApply { | |
535 | my ($self, $event) = @_; | |
536 | $self->apply($self->{_curr_row}); | |
537 | } | |
538 | ||
539 | # wxGlade: EB::Wx::Maint::Relaties::OnCancel <event_handler> | |
540 | sub OnCancel { | |
541 | my ($self, $event) = @_; | |
542 | if ( $self->changed ) { | |
543 | my $r = EB::Wx::MessageDialog | |
544 | ($self, | |
545 | "Er zijn nog wijzigingen, deze zullen verloren gaan.\n". | |
546 | "Toch annuleren?", | |
547 | "Annuleren", | |
548 | wxYES_NO|wxNO_DEFAULT|wxICON_ERROR); | |
549 | return unless $r == wxID_YES; | |
550 | } | |
551 | $self->hide_details; | |
552 | if ( $self->{_curr_row} > 0 && $self->is_new($self->{_curr_row}) ) { | |
553 | $self->{gr_list}->DeleteRows($self->{_curr_row}, 1); | |
554 | $self->{_curr_row}--; | |
555 | } | |
556 | # end wxGlade | |
557 | } | |
558 | ||
559 | sub OnClick { | |
560 | my ($self, $event) = @_; | |
561 | $self = $self->GetParent; | |
562 | my $row = $event->GetRow; | |
563 | $self->{gr_list}->SelectRow($row); | |
564 | $self->set_current($row); | |
565 | $event->Skip; | |
566 | } | |
567 | ||
568 | # wxGlade: EB::Wx::Maint::Relaties::OnSel <event_handler> | |
569 | sub OnSel { | |
570 | my ($self, $event) = @_; | |
571 | $self = $self->GetParent; | |
572 | $self->set_current($event->GetRow); | |
573 | $self->show_details; | |
574 | } | |
575 | ||
576 | # end of class EB::Wx::Maint::Relaties | |
577 | ||
578 | 1; | |
579 |
0 | #! perl | |
1 | ||
2 | # $Id: StdAccounts.pm,v 1.8 2008/03/25 22:58:38 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $dbh; | |
7 | our $state; | |
8 | our $app; | |
9 | ||
10 | package EB::Wx::Maint::StdAccounts; | |
11 | ||
12 | use Wx qw[:everything]; | |
13 | use base qw(Wx::Dialog); | |
14 | use base qw(EB::Wx::Window); | |
15 | use strict; | |
16 | use EB; | |
17 | ||
18 | # begin wxGlade: ::dependencies | |
19 | use EB::Wx::UI::StdAccPanel; | |
20 | # end wxGlade | |
21 | ||
22 | sub new { | |
23 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
24 | $parent = undef unless defined $parent; | |
25 | $id = -1 unless defined $id; | |
26 | $title = "" unless defined $title; | |
27 | $pos = wxDefaultPosition unless defined $pos; | |
28 | $size = wxDefaultSize unless defined $size; | |
29 | $name = "" unless defined $name; | |
30 | ||
31 | # begin wxGlade: EB::Wx::Maint::StdAccounts::new | |
32 | ||
33 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTHICK_FRAME | |
34 | unless defined $style; | |
35 | ||
36 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
37 | $self->{stdacc_title_staticbox} = Wx::StaticBox->new($self, -1, _T("Koppelingen") ); | |
38 | $self->{p_stdacc} = EB::Wx::UI::StdAccPanel->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
39 | $self->{l_inuse} = Wx::StaticText->new($self, -1, _T("Sommige gegevens zijn in gebruik en\nkunnen niet meer worden gewijzigd."), wxDefaultPosition, wxDefaultSize, ); | |
40 | $self->{b_cancel} = Wx::Button->new($self, wxID_CLOSE, ""); | |
41 | ||
42 | $self->__set_properties(); | |
43 | $self->__do_layout(); | |
44 | ||
45 | Wx::Event::EVT_BUTTON($self, $self->{b_cancel}->GetId, \&OnClose); | |
46 | ||
47 | # end wxGlade | |
48 | ||
49 | Wx::Event::EVT_MENU($self, wxID_CLOSE, \&OnClose); | |
50 | ||
51 | return $self; | |
52 | ||
53 | } | |
54 | ||
55 | sub __set_properties { | |
56 | my $self = shift; | |
57 | ||
58 | # begin wxGlade: EB::Wx::Maint::StdAccounts::__set_properties | |
59 | ||
60 | $self->SetTitle(_T("Koppelingen")); | |
61 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(238, 195))); | |
62 | $self->{b_cancel}->SetFocus(); | |
63 | $self->{b_cancel}->SetDefault(); | |
64 | ||
65 | # end wxGlade | |
66 | } | |
67 | ||
68 | sub __do_layout { | |
69 | my $self = shift; | |
70 | ||
71 | # begin wxGlade: EB::Wx::Maint::StdAccounts::__do_layout | |
72 | ||
73 | $self->{stdacc_outer} = Wx::BoxSizer->new(wxVERTICAL); | |
74 | $self->{stdacc_main} = Wx::BoxSizer->new(wxVERTICAL); | |
75 | $self->{sz_buttons} = Wx::BoxSizer->new(wxHORIZONTAL); | |
76 | $self->{stdacc_title}= Wx::StaticBoxSizer->new($self->{stdacc_title_staticbox}, wxHORIZONTAL); | |
77 | $self->{stdacc_title}->Add($self->{p_stdacc}, 1, wxEXPAND, 0); | |
78 | $self->{stdacc_main}->Add($self->{stdacc_title}, 1, wxEXPAND, 0); | |
79 | $self->{sz_buttons}->Add($self->{l_inuse}, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
80 | $self->{sz_buttons}->Add(5, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
81 | $self->{sz_buttons}->Add($self->{b_cancel}, 0, wxEXPAND|wxADJUST_MINSIZE|wxFIXED_MINSIZE, 5); | |
82 | $self->{stdacc_main}->Add($self->{sz_buttons}, 0, wxALL|wxEXPAND, 5); | |
83 | $self->{stdacc_outer}->Add($self->{stdacc_main}, 1, wxALL|wxEXPAND, 5); | |
84 | $self->SetSizer($self->{stdacc_outer}); | |
85 | $self->Layout(); | |
86 | ||
87 | # end wxGlade | |
88 | } | |
89 | ||
90 | # wxGlade: EB::Wx::Maint::StdAccounts::OnClose <event_handler> | |
91 | sub OnClose { | |
92 | my ($self, $event) = @_; | |
93 | if ( $self->{p_stdacc}->changed ) { | |
94 | my $r = EB::Wx::MessageDialog | |
95 | ($self, | |
96 | "Er zijn nog wijzigingen, deze zullen verloren gaan.\n". | |
97 | "Venster toch sluiten?", | |
98 | "Annuleren", | |
99 | wxYES_NO|wxNO_DEFAULT|wxICON_ERROR); | |
100 | return unless $r == wxYES; | |
101 | $self->{p_stdacc}->refresh; | |
102 | } | |
103 | # Remember position and size. | |
104 | $self->sizepos_save; | |
105 | # Disappear. | |
106 | $self->Show(0); | |
107 | } | |
108 | ||
109 | # end of class EB::Wx::Maint::StdAccounts | |
110 | ||
111 | 1; | |
112 |
0 | #! perl | |
1 | ||
2 | # $Id: Preferences.pm,v 1.6 2008/03/25 22:28:18 jv Exp $ | |
3 | ||
4 | package EB::Wx::Report::BTWAangifte::Preferences; | |
5 | ||
6 | use Wx qw[:everything]; | |
7 | use base qw(Wx::Dialog); | |
8 | use strict; | |
9 | use EB; | |
10 | ||
11 | sub new { | |
12 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
13 | $parent = undef unless defined $parent; | |
14 | $id = -1 unless defined $id; | |
15 | $title = "" unless defined $title; | |
16 | $pos = wxDefaultPosition unless defined $pos; | |
17 | $size = wxDefaultSize unless defined $size; | |
18 | $name = "" unless defined $name; | |
19 | ||
20 | # begin wxGlade: EB::Wx::Report::BTWAangifte::Preferences::new | |
21 | ||
22 | $style = wxDEFAULT_DIALOG_STYLE | |
23 | unless defined $style; | |
24 | ||
25 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
26 | $self->{sz_periode_staticbox} = Wx::StaticBox->new($self, -1, _T("Periode") ); | |
27 | $self->{b_jaar} = Wx::ToggleButton->new($self, -1, _T("Jaar")); | |
28 | $self->{b_kw1} = Wx::ToggleButton->new($self, -1, _T("Kwart 1")); | |
29 | $self->{b_m1} = Wx::ToggleButton->new($self, -1, _T("Jan")); | |
30 | $self->{b_m2} = Wx::ToggleButton->new($self, -1, _T("Feb")); | |
31 | $self->{b_m3} = Wx::ToggleButton->new($self, -1, _T("Mar")); | |
32 | $self->{b_kw2} = Wx::ToggleButton->new($self, -1, _T("Kwart 2")); | |
33 | $self->{b_m4} = Wx::ToggleButton->new($self, -1, _T("Apr")); | |
34 | $self->{b_m5} = Wx::ToggleButton->new($self, -1, _T("Mei")); | |
35 | $self->{b_m6} = Wx::ToggleButton->new($self, -1, _T("Jun")); | |
36 | $self->{b_kw3} = Wx::ToggleButton->new($self, -1, _T("Kwart 3")); | |
37 | $self->{b_m7} = Wx::ToggleButton->new($self, -1, _T("Jul")); | |
38 | $self->{b_m8} = Wx::ToggleButton->new($self, -1, _T("Aug")); | |
39 | $self->{b_m9} = Wx::ToggleButton->new($self, -1, _T("Sep")); | |
40 | $self->{b_kw4} = Wx::ToggleButton->new($self, -1, _T("Kwart 4")); | |
41 | $self->{b_m10} = Wx::ToggleButton->new($self, -1, _T("Okt")); | |
42 | $self->{b_m11} = Wx::ToggleButton->new($self, -1, _T("Nov")); | |
43 | $self->{b_m12} = Wx::ToggleButton->new($self, -1, _T("Dec")); | |
44 | $self->{l_default} = Wx::StaticText->new($self, -1, _T("Standaardinstelling"), wxDefaultPosition, wxDefaultSize, ); | |
45 | $self->{b_cancel} = Wx::Button->new($self, wxID_CANCEL, ""); | |
46 | $self->{b_ok} = Wx::Button->new($self, wxID_OK, ""); | |
47 | ||
48 | $self->__set_properties(); | |
49 | $self->__do_layout(); | |
50 | ||
51 | Wx::Event::EVT_BUTTON($self, $self->{b_cancel}->GetId, \&OnCancel); | |
52 | Wx::Event::EVT_BUTTON($self, $self->{b_ok}->GetId, \&OnOk); | |
53 | ||
54 | # end wxGlade | |
55 | ||
56 | Wx::Event::EVT_TOGGLEBUTTON($self, $self->{b_jaar}->GetId, | |
57 | sub { $self->{b_jaar}->SetValue(1); | |
58 | for my $kw ( 1..4 ) { | |
59 | $self->{"b_kw$kw"}->SetValue(0); | |
60 | } | |
61 | for my $m ( 1..12 ) { | |
62 | $self->{"b_m$m"}->SetValue(1); | |
63 | } | |
64 | $self->{periode} = "j"; | |
65 | }); | |
66 | ||
67 | foreach my $kw ( 1 .. 4 ) { | |
68 | Wx::Event::EVT_TOGGLEBUTTON($self, $self->{"b_kw$kw"}->GetId, | |
69 | sub { $self->{b_jaar}->SetValue(0); | |
70 | for my $k ( 1..4 ) { | |
71 | $self->{"b_kw$k"}->SetValue($k == $kw); | |
72 | } | |
73 | for my $m ( 1..12 ) { | |
74 | $self->{"b_m$m"}->SetValue($m > ($kw-1)*3 && $m <= $kw*3); | |
75 | } | |
76 | $self->{periode} = "k$kw"; | |
77 | }); | |
78 | } | |
79 | foreach my $mm ( 1 .. 12 ) { | |
80 | Wx::Event::EVT_TOGGLEBUTTON($self, $self->{"b_m$mm"}->GetId, | |
81 | sub { $self->{b_jaar}->SetValue(0); | |
82 | for my $k ( 1..4 ) { | |
83 | $self->{"b_kw$k"}->SetValue(0); | |
84 | } | |
85 | for my $m ( 1..12 ) { | |
86 | $self->{"b_m$m"}->SetValue($m == $mm); | |
87 | } | |
88 | $self->{periode} = "m$mm"; | |
89 | }); | |
90 | } | |
91 | ||
92 | return $self; | |
93 | ||
94 | } | |
95 | ||
96 | ||
97 | sub __set_properties { | |
98 | my $self = shift; | |
99 | ||
100 | # begin wxGlade: EB::Wx::Report::BTWAangifte::Preferences::__set_properties | |
101 | ||
102 | $self->SetTitle(_T("Instellingen Aangifte BTW")); | |
103 | $self->{b_jaar}->SetToolTipString(_T("Gehele jaar")); | |
104 | $self->{b_kw1}->SetToolTipString(_T("Eerste kwartaal")); | |
105 | $self->{b_m1}->SetToolTipString(_T("Januari")); | |
106 | $self->{b_m2}->SetToolTipString(_T("Februari")); | |
107 | $self->{b_m3}->SetToolTipString(_T("Maart")); | |
108 | $self->{b_kw2}->SetToolTipString(_T("Tweede kwartaal")); | |
109 | $self->{b_m4}->SetToolTipString(_T("April")); | |
110 | $self->{b_m5}->SetToolTipString(_T("Mei")); | |
111 | $self->{b_m6}->SetToolTipString(_T("Juni")); | |
112 | $self->{b_kw3}->SetToolTipString(_T("Derde kwartaal")); | |
113 | $self->{b_m7}->SetToolTipString(_T("Juli")); | |
114 | $self->{b_m8}->SetToolTipString(_T("Augustus")); | |
115 | $self->{b_m9}->SetToolTipString(_T("September")); | |
116 | $self->{b_kw4}->SetToolTipString(_T("Vierde kwartaal")); | |
117 | $self->{b_m10}->SetToolTipString(_T("Oktober")); | |
118 | $self->{b_m11}->SetToolTipString(_T("November")); | |
119 | $self->{b_m12}->SetToolTipString(_T("December")); | |
120 | $self->{b_cancel}->SetFocus(); | |
121 | $self->{b_ok}->SetDefault(); | |
122 | ||
123 | # end wxGlade | |
124 | } | |
125 | ||
126 | sub __do_layout { | |
127 | my $self = shift; | |
128 | ||
129 | # begin wxGlade: EB::Wx::Report::BTWAangifte::Preferences::__do_layout | |
130 | ||
131 | $self->{sz_outer} = Wx::BoxSizer->new(wxHORIZONTAL); | |
132 | $self->{sz_prefs} = Wx::BoxSizer->new(wxVERTICAL); | |
133 | $self->{sz_buttons} = Wx::BoxSizer->new(wxHORIZONTAL); | |
134 | $self->{sz_periode}= Wx::StaticBoxSizer->new($self->{sz_periode_staticbox}, wxVERTICAL); | |
135 | $self->{gr_m} = Wx::FlexGridSizer->new(4, 4, 0, 0); | |
136 | $self->{sz_periode}->Add($self->{b_jaar}, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND|wxADJUST_MINSIZE, 5); | |
137 | $self->{gr_m}->Add($self->{b_kw1}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
138 | $self->{gr_m}->Add($self->{b_m1}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
139 | $self->{gr_m}->Add($self->{b_m2}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
140 | $self->{gr_m}->Add($self->{b_m3}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
141 | $self->{gr_m}->Add($self->{b_kw2}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
142 | $self->{gr_m}->Add($self->{b_m4}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
143 | $self->{gr_m}->Add($self->{b_m5}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
144 | $self->{gr_m}->Add($self->{b_m6}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
145 | $self->{gr_m}->Add($self->{b_kw3}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
146 | $self->{gr_m}->Add($self->{b_m7}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
147 | $self->{gr_m}->Add($self->{b_m8}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
148 | $self->{gr_m}->Add($self->{b_m9}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
149 | $self->{gr_m}->Add($self->{b_kw4}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
150 | $self->{gr_m}->Add($self->{b_m10}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
151 | $self->{gr_m}->Add($self->{b_m11}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
152 | $self->{gr_m}->Add($self->{b_m12}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
153 | $self->{gr_m}->AddGrowableCol(0); | |
154 | $self->{gr_m}->AddGrowableCol(1); | |
155 | $self->{gr_m}->AddGrowableCol(2); | |
156 | $self->{gr_m}->AddGrowableCol(3); | |
157 | $self->{sz_periode}->Add($self->{gr_m}, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 5); | |
158 | $self->{sz_periode}->Add($self->{l_default}, 0, wxALL|wxEXPAND|wxADJUST_MINSIZE, 5); | |
159 | $self->{sz_prefs}->Add($self->{sz_periode}, 0, wxALL|wxEXPAND, 5); | |
160 | $self->{sz_buttons}->Add(5, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
161 | $self->{sz_buttons}->Add($self->{b_cancel}, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND|wxADJUST_MINSIZE, 5); | |
162 | $self->{sz_buttons}->Add($self->{b_ok}, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND|wxADJUST_MINSIZE, 5); | |
163 | $self->{sz_prefs}->Add($self->{sz_buttons}, 0, wxEXPAND, 5); | |
164 | $self->{sz_outer}->Add($self->{sz_prefs}, 1, wxEXPAND, 5); | |
165 | $self->SetSizer($self->{sz_outer}); | |
166 | $self->{sz_outer}->Fit($self); | |
167 | $self->Layout(); | |
168 | ||
169 | # end wxGlade | |
170 | } | |
171 | ||
172 | sub init { | |
173 | my ($self, $args) = @_; | |
174 | $self->{b_jaar}->SetLabel("Gehele jaar ".$args->{year}); | |
175 | my $t = $args->{btwp} == 1 ? "jaar" : | |
176 | $args->{btwp} == 4 ? "kwartaal" : | |
177 | $args->{btwp} == 12 ? "maand" : $args->{btwp}; | |
178 | $self->{l_default}->SetLabel("Standaardinstelling: per $t"); | |
179 | $self->refresh; | |
180 | } | |
181 | ||
182 | sub refresh { | |
183 | } | |
184 | ||
185 | # wxGlade: EB::Wx::Report::BTWAangifte::Preferences::OnOk <event_handler> | |
186 | sub OnOk { | |
187 | my ($self, $event) = @_; | |
188 | $event->Skip; | |
189 | } | |
190 | ||
191 | # wxGlade: EB::Wx::Report::BTWAangifte::Preferences::OnCancel <event_handler> | |
192 | sub OnCancel { | |
193 | my ($self, $event) = @_; | |
194 | $self->EndModal(-1); | |
195 | } | |
196 | ||
197 | sub GetValues { | |
198 | my ($self) = @_; | |
199 | my $r; | |
200 | $r->{pref_periode} = $self->{periode}; | |
201 | $r; | |
202 | } | |
203 | ||
204 | # end of class EB::Wx::Report::BTWAangifte::Preferences | |
205 | ||
206 | 1; | |
207 |
0 | #! perl | |
1 | ||
2 | # $Id: BTWAangifte.pm,v 1.12 2009/10/24 21:27:05 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $dbh; | |
8 | ||
9 | package EB::Wx::Report::BTWAangifte; | |
10 | ||
11 | use base qw(EB::Wx::Report::GenBase); | |
12 | use strict; | |
13 | use EB; | |
14 | use Wx qw(wxICON_ERROR wxOK); | |
15 | ||
16 | #### TODO: BOEKJAAR MEENEMEN #### | |
17 | ||
18 | sub init { | |
19 | my ($self) = @_; | |
20 | $self->SetTitle(_T("BTW aangifte")); | |
21 | $self->SetDetails(0,0,0); | |
22 | $self->{year} = substr($dbh->adm("begin"), 0, 4); | |
23 | $self->{btwp} = $dbh->adm("btwperiod"); | |
24 | ||
25 | $self->{compat_periode} = | |
26 | $self->{btwp} == 1 ? "j" : | |
27 | $self->{btwp} == 4 ? "k1" : | |
28 | $self->{btwp} == 12 ? $EB::Utils::month_names[0] : $self->{btwp}; | |
29 | ||
30 | $self->refresh; | |
31 | } | |
32 | ||
33 | sub refresh { | |
34 | my ($self) = @_; | |
35 | require EB::Report::BTWAangifte; | |
36 | ||
37 | if ( $self->{pref_periode} ) { | |
38 | $self->set_periode($self->{pref_periode}); | |
39 | } | |
40 | ||
41 | my $output; | |
42 | my $save = $self->htmltext; | |
43 | my @msgs; | |
44 | local $SIG{__WARN__} = sub { push(@msgs, "@_") }; | |
45 | eval { | |
46 | ||
47 | EB::Report::BTWAangifte->new->perform | |
48 | ({ generate => 'wxhtml', | |
49 | compat_periode => $self->{compat_periode}, | |
50 | boekjaar => $self->{pref_bky}, | |
51 | output => \$output, | |
52 | detail => $self->{detail} }); | |
53 | ||
54 | $output =~ s/<table border="1" width="100%">/<table>/; | |
55 | }; | |
56 | ||
57 | if ( $@ ) { | |
58 | my $msg = $@; | |
59 | $msg =~ s/^\?+//; | |
60 | EB::Wx::MessageDialog($self, $msg, "Fout", wxICON_ERROR|wxOK); | |
61 | $output = $save; | |
62 | } | |
63 | elsif ( @msgs ) { | |
64 | # Splice in any messages. | |
65 | my $msg = join("<br>", map { s/^\!//; $_ } @msgs); | |
66 | $output =~ s/\ /<font color=\"red\">$msg<\/font><br>\ /; | |
67 | } | |
68 | $self->{w_report}->SetPage($output); | |
69 | $self->{_HTMLTEXT} = $output; | |
70 | } | |
71 | ||
72 | sub set_periode { | |
73 | my ($self, $p) = @_; | |
74 | if ( $p eq "j" ) { | |
75 | $self->{compat_periode} = $p; | |
76 | } | |
77 | elsif ( $p =~ /^k(\d+)$/ ) { | |
78 | $self->{compat_periode} = $p; | |
79 | } | |
80 | elsif ( $p =~ /^m(\d+)$/ ) { | |
81 | $self->{compat_periode} = $EB::Utils::month_names[$1-1]; | |
82 | } | |
83 | } | |
84 | ||
85 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: BalResProof.pm,v 1.7 2008/03/25 22:31:06 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $app; | |
8 | our $dbh; | |
9 | ||
10 | package EB::Wx::Report::BalResProof; | |
11 | ||
12 | use base qw(EB::Wx::Report::GenBase); | |
13 | use strict; | |
14 | use EB; | |
15 | ||
16 | sub init { | |
17 | my ($self, $me) = @_; | |
18 | if ( $me eq "bal" ) { | |
19 | $self->SetTitle(_T("Balans")); | |
20 | $self->{pref_from_to} = 2; | |
21 | } | |
22 | elsif ( $me eq "obal" ) { | |
23 | $self->SetTitle(_T("Openingsbalans")); | |
24 | $self->{pref_from_to} = 0; | |
25 | } | |
26 | elsif ( $me eq "prf" ) { | |
27 | $self->SetTitle(_T("Proef- en Saldibalans")); | |
28 | $self->{pref_from_to} = 2; | |
29 | } | |
30 | else { | |
31 | $self->SetTitle(_T("Resultaatrekening")); | |
32 | $self->{pref_from_to} = 3; | |
33 | } | |
34 | $self->SetDetails(2, -1, 2, | |
35 | [ _T("Op hoofdverdichting"), # 0 | |
36 | _T("Op verdichting"), # 1 | |
37 | _T("Gedetailleerd"), # 2 | |
38 | _T("Op grootboekrekening"), # -1 | |
39 | ]); | |
40 | $self->refresh; | |
41 | } | |
42 | ||
43 | sub refresh { | |
44 | my ($self) = @_; | |
45 | ||
46 | my @period; | |
47 | ||
48 | if ( defined($self->{pref_bky}) ) { | |
49 | @period = ("boekjaar", $self->{pref_bky}); | |
50 | } | |
51 | elsif ( defined($self->{pref_per}->[0]) ) { | |
52 | @period = ("periode", [ @{$self->{pref_per}} ]); | |
53 | } | |
54 | elsif ( defined($self->{pref_per}->[1]) ) { | |
55 | @period = ("per", $self->{pref_per}->[1]); | |
56 | } | |
57 | else { | |
58 | @period = ("boekjaar", $self->{pref_bky} = $state->bky); | |
59 | } | |
60 | ||
61 | my $output; | |
62 | if ( $self->{mew} eq "rprfw" ) { | |
63 | require EB::Report::Proof; | |
64 | EB::Report::Proof->new->perform | |
65 | ({ generate => "wxhtml", | |
66 | @period, | |
67 | saldi => 1, | |
68 | output => \$output, | |
69 | detail => $self->GetDetail }); | |
70 | } | |
71 | else { | |
72 | require EB::Report::Balres; | |
73 | my $fun = $self->{mew} eq "rresw" | |
74 | ? "result" | |
75 | : $self->{mew} eq "robalw" | |
76 | ? "balans" | |
77 | : "balans"; | |
78 | EB::Report::Balres->new->$fun | |
79 | ( { generate => "wxhtml", | |
80 | @period, | |
81 | detail => $self->GetDetail, | |
82 | $self->{mew} eq "robalw" ? ( opening => 1 ) : (), | |
83 | output => \$output, | |
84 | } ); | |
85 | } | |
86 | $self->html->SetPage($output); | |
87 | $self->htmltext = $output; | |
88 | } | |
89 | ||
90 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: Preferences.pm,v 1.4 2008/02/20 15:22:26 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $dbh; | |
8 | ||
9 | use strict; | |
10 | ||
11 | package EB::Wx::Report::DebCrd::Preferences; | |
12 | ||
13 | use Wx qw[:everything]; | |
14 | use base qw(Wx::Dialog); | |
15 | use base qw(EB::Wx::Window); | |
16 | use EB::Wx::UI::PeriodPanel; | |
17 | use EB; | |
18 | ||
19 | use strict; | |
20 | ||
21 | sub new { | |
22 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
23 | $parent = undef unless defined $parent; | |
24 | $id = -1 unless defined $id; | |
25 | $title = "" unless defined $title; | |
26 | $pos = wxDefaultPosition unless defined $pos; | |
27 | $size = wxDefaultSize unless defined $size; | |
28 | $name = "" unless defined $name; | |
29 | ||
30 | # begin wxGlade: EB::Wx::Report::DebCrd::Preferences::new | |
31 | ||
32 | $style = wxDEFAULT_DIALOG_STYLE | |
33 | unless defined $style; | |
34 | ||
35 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
36 | $self->{sizer_2_staticbox} = Wx::StaticBox->new($self, -1, "" ); | |
37 | $self->{sizer_4_staticbox} = Wx::StaticBox->new($self, -1, "" ); | |
38 | $self->{cb_open} = Wx::CheckBox->new($self, -1, "Alleen openstaande posten", wxDefaultPosition, wxDefaultSize, ); | |
39 | $self->{p_period} = EB::Wx::UI::PeriodPanel->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
40 | $self->{b_cancel} = Wx::Button->new($self, wxID_CANCEL, ""); | |
41 | $self->{b_apply} = Wx::Button->new($self, wxID_OK, ""); | |
42 | ||
43 | $self->__set_properties(); | |
44 | $self->__do_layout(); | |
45 | ||
46 | Wx::Event::EVT_CHECKBOX($self, $self->{cb_open}->GetId, \&OnCBOpen); | |
47 | ||
48 | # end wxGlade | |
49 | ||
50 | Wx::Event::EVT_EB_PERIOD($self, $self->{p_period}, \&OnPeriod); | |
51 | ||
52 | return $self; | |
53 | ||
54 | } | |
55 | ||
56 | ||
57 | sub __set_properties { | |
58 | my $self = shift; | |
59 | ||
60 | # begin wxGlade: EB::Wx::Report::DebCrd::Preferences::__set_properties | |
61 | ||
62 | $self->SetTitle("Instellingen"); | |
63 | $self->{b_cancel}->SetFocus(); | |
64 | ||
65 | # end wxGlade | |
66 | ||
67 | } | |
68 | ||
69 | sub __do_layout { | |
70 | my $self = shift; | |
71 | ||
72 | # begin wxGlade: EB::Wx::Report::DebCrd::Preferences::__do_layout | |
73 | ||
74 | $self->{sizer_1} = Wx::BoxSizer->new(wxVERTICAL); | |
75 | $self->{sizer_3} = Wx::BoxSizer->new(wxHORIZONTAL); | |
76 | $self->{sizer_2}= Wx::StaticBoxSizer->new($self->{sizer_2_staticbox}, wxHORIZONTAL); | |
77 | $self->{sizer_4}= Wx::StaticBoxSizer->new($self->{sizer_4_staticbox}, wxVERTICAL); | |
78 | $self->{sizer_4}->Add($self->{cb_open}, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
79 | $self->{sizer_1}->Add($self->{sizer_4}, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
80 | $self->{sizer_2}->Add($self->{p_period}, 1, wxEXPAND, 0); | |
81 | $self->{sizer_1}->Add($self->{sizer_2}, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
82 | $self->{sizer_3}->Add(5, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
83 | $self->{sizer_3}->Add($self->{b_cancel}, 0, wxALL|wxADJUST_MINSIZE, 5); | |
84 | $self->{sizer_3}->Add($self->{b_apply}, 0, wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE, 5); | |
85 | $self->{sizer_1}->Add($self->{sizer_3}, 0, wxEXPAND, 0); | |
86 | $self->SetSizer($self->{sizer_1}); | |
87 | $self->{sizer_1}->Fit($self); | |
88 | $self->Layout(); | |
89 | ||
90 | # end wxGlade | |
91 | } | |
92 | ||
93 | sub init { | |
94 | my ($self, $args) = @_; | |
95 | if ( $args->{pref_from_to} ) { | |
96 | $self->{p_period}->allow_fromto(1) if $args->{pref_from_to} & 1; | |
97 | $self->{p_period}->allow_to(1) if $args->{pref_from_to} & 2; | |
98 | } | |
99 | $self->refresh; | |
100 | $self->{p_period}->set_bky($args->{pref_bky}) if $args->{pref_bky}; | |
101 | } | |
102 | ||
103 | sub refresh { | |
104 | my ($self) = @_; | |
105 | $self->{p_period}->refresh; | |
106 | $self->{b_apply}->Enable(0); | |
107 | } | |
108 | ||
109 | sub OnCBOpen { | |
110 | my ($self, $event) = @_; | |
111 | # wxGlade: EB::Wx::Report::DebCrd::Preferences::OnCBOpen <event_handler> | |
112 | ||
113 | $self->{b_apply}->Enable(1); | |
114 | ||
115 | # end wxGlade | |
116 | } | |
117 | ||
118 | sub OnPeriod { | |
119 | my ($self, $event) = @_; | |
120 | $self->{b_apply}->Enable($self->{p_period}->changed); | |
121 | } | |
122 | ||
123 | sub GetValues { | |
124 | my ($self) = @_; | |
125 | my $r; | |
126 | my $p = $self->{p_period}->GetValues; | |
127 | $r->{pref_open} = $self->{cb_open}->GetValue; | |
128 | $r->{pref_bky} = $p->{period_panel_bky} if exists $p->{period_panel_bky}; | |
129 | $r->{pref_per}->[0] = $p->{period_panel_from} if exists $p->{period_panel_from}; | |
130 | $r->{pref_per}->[1] = $p->{period_panel_to} if exists $p->{period_panel_to}; | |
131 | $r; | |
132 | } | |
133 | ||
134 | # end of class EB::Wx::Report::DebCrd::Preferences | |
135 | ||
136 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: DebCrd.pm,v 1.6 2008/03/25 22:32:01 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | ||
8 | package EB::Wx::Report::DebCrd; | |
9 | ||
10 | use base qw(EB::Wx::Report::GenBase); | |
11 | use strict; | |
12 | use EB; | |
13 | ||
14 | sub init { | |
15 | my ($self, $me, $args) = @_; | |
16 | $self->{pref_from_to} = 3; | |
17 | $self->SetTitle($me eq "deb" ? "Debiteurenoverzicht" : "Crediteurenoverzicht"); | |
18 | $self->SetDetails(0,0,0); | |
19 | if ( $args->{select} ) { | |
20 | $self->{pref_rel} = [ $args->{select} ]; | |
21 | } | |
22 | if ( $args->{periode} ) { | |
23 | my $p = parse_date_range($args->{periode}); | |
24 | delete($self->{pref_bky}); | |
25 | $self->{pref_per} = $p; | |
26 | } | |
27 | ||
28 | $self->refresh; | |
29 | } | |
30 | ||
31 | sub refresh { | |
32 | my ($self) = @_; | |
33 | my $output = ""; | |
34 | ||
35 | delete($self->{pref_rel}) if $self->{prefs_changed}; | |
36 | ||
37 | my @period; | |
38 | ||
39 | if ( defined($self->{pref_bky}) ) { | |
40 | @period = ("boekjaar", $self->{pref_bky}); | |
41 | } | |
42 | elsif ( defined($self->{pref_per}->[0]) ) { | |
43 | @period = ("periode", [ @{$self->{pref_per}} ]); | |
44 | } | |
45 | else { | |
46 | @period = ("boekjaar", $self->{pref_bky} = $state->bky); | |
47 | } | |
48 | ||
49 | require EB::Report::Debcrd; | |
50 | my $fun = $self->{mew} eq "rdebw" ? "debiteuren" : "crediteuren"; | |
51 | ||
52 | eval { | |
53 | EB::Report::Debcrd->new->$fun | |
54 | ($self->{pref_rel}, | |
55 | { generate => "wxhtml", | |
56 | @period, | |
57 | $self->{pref_open} ? ("openstaand" => 1) : (), | |
58 | output => \$output, | |
59 | }); | |
60 | }; | |
61 | if ( $@ ) { | |
62 | $output = $@; | |
63 | } | |
64 | ||
65 | $self->html->SetPage($output); | |
66 | $self->{_HTMLTEXT} = $output; | |
67 | } | |
68 | ||
69 | 1; | |
70 |
0 | #! perl | |
1 | ||
2 | # $Id: Preferences.pm,v 1.5 2008/02/20 15:22:26 jv Exp $ | |
3 | ||
4 | package EB::Wx::Report::GenBase::Preferences; | |
5 | ||
6 | use Wx qw[:everything]; | |
7 | use base qw(Wx::Dialog); | |
8 | use EB::Wx::UI::PeriodPanel; | |
9 | use strict; | |
10 | ||
11 | sub new { | |
12 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
13 | $parent = undef unless defined $parent; | |
14 | $id = -1 unless defined $id; | |
15 | $title = "" unless defined $title; | |
16 | $pos = wxDefaultPosition unless defined $pos; | |
17 | $size = wxDefaultSize unless defined $size; | |
18 | $name = "" unless defined $name; | |
19 | ||
20 | # begin wxGlade: EB::Wx::Report::GenBase::Preferences::new | |
21 | ||
22 | $style = wxDEFAULT_DIALOG_STYLE | |
23 | unless defined $style; | |
24 | ||
25 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
26 | $self->{sizer_2_staticbox} = Wx::StaticBox->new($self, -1, "" ); | |
27 | $self->{p_period} = EB::Wx::UI::PeriodPanel->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
28 | $self->{b_cancel} = Wx::Button->new($self, wxID_CANCEL, ""); | |
29 | $self->{b_apply} = Wx::Button->new($self, wxID_OK, ""); | |
30 | ||
31 | $self->__set_properties(); | |
32 | $self->__do_layout(); | |
33 | ||
34 | # end wxGlade | |
35 | ||
36 | Wx::Event::EVT_EB_PERIOD($self, $self->{p_period}, \&OnPeriod); | |
37 | ||
38 | return $self; | |
39 | ||
40 | } | |
41 | ||
42 | ||
43 | sub __set_properties { | |
44 | my $self = shift; | |
45 | ||
46 | # begin wxGlade: EB::Wx::Report::GenBase::Preferences::__set_properties | |
47 | ||
48 | $self->SetTitle("Instellingen"); | |
49 | $self->{b_cancel}->SetFocus(); | |
50 | ||
51 | # end wxGlade | |
52 | } | |
53 | ||
54 | sub __do_layout { | |
55 | my $self = shift; | |
56 | ||
57 | # begin wxGlade: EB::Wx::Report::GenBase::Preferences::__do_layout | |
58 | ||
59 | $self->{sizer_1} = Wx::BoxSizer->new(wxVERTICAL); | |
60 | $self->{sizer_3} = Wx::BoxSizer->new(wxHORIZONTAL); | |
61 | $self->{sizer_2}= Wx::StaticBoxSizer->new($self->{sizer_2_staticbox}, wxHORIZONTAL); | |
62 | $self->{sizer_2}->Add($self->{p_period}, 1, wxEXPAND, 0); | |
63 | $self->{sizer_1}->Add($self->{sizer_2}, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
64 | $self->{sizer_3}->Add(5, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
65 | $self->{sizer_3}->Add($self->{b_cancel}, 0, wxALL|wxADJUST_MINSIZE, 5); | |
66 | $self->{sizer_3}->Add($self->{b_apply}, 0, wxALL|wxADJUST_MINSIZE, 5); | |
67 | $self->{sizer_1}->Add($self->{sizer_3}, 0, wxEXPAND, 0); | |
68 | $self->SetSizer($self->{sizer_1}); | |
69 | $self->{sizer_1}->Fit($self); | |
70 | $self->Layout(); | |
71 | ||
72 | # end wxGlade | |
73 | } | |
74 | ||
75 | sub init { | |
76 | my ($self, $args) = @_; | |
77 | if ( $args->{pref_from_to} ) { | |
78 | $self->{p_period}->allow_fromto(1) if $args->{pref_from_to} & 1; | |
79 | $self->{p_period}->allow_to(1) if $args->{pref_from_to} & 2; | |
80 | } | |
81 | $self->refresh; | |
82 | $self->{p_period}->set_bky($args->{pref_bky}) if $args->{pref_bky}; | |
83 | } | |
84 | ||
85 | sub refresh { | |
86 | my ($self) = @_; | |
87 | $self->{p_period}->refresh; | |
88 | $self->{b_apply}->Enable(0); | |
89 | } | |
90 | ||
91 | sub GetValues { | |
92 | my ($self) = @_; | |
93 | my $r; | |
94 | my $p = $self->{p_period}->GetValues; | |
95 | $r->{pref_bky} = $p->{period_panel_bky} if exists $p->{period_panel_bky}; | |
96 | $r->{pref_per}->[0] = $p->{period_panel_from} if exists $p->{period_panel_from}; | |
97 | $r->{pref_per}->[1] = $p->{period_panel_to} if exists $p->{period_panel_to}; | |
98 | $r; | |
99 | } | |
100 | ||
101 | sub OnPeriod { | |
102 | my ($self, $event) = @_; | |
103 | $self->{b_apply}->Enable($self->{p_period}->changed); | |
104 | } | |
105 | ||
106 | # end of class EB::Wx::Report::GenBase::Preferences | |
107 | ||
108 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: GenBase.pm,v 1.6 2009/10/09 15:43:07 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $app; | |
8 | our $dbh; | |
9 | ||
10 | package EB::Wx::Report::GenBase; | |
11 | ||
12 | use Wx qw[:everything]; | |
13 | use base qw(Wx::Dialog); | |
14 | use base qw(EB::Wx::Window); | |
15 | use Wx::Html; | |
16 | use strict; | |
17 | use EB; | |
18 | ||
19 | # begin wxGlade: ::dependencies | |
20 | # end wxGlade | |
21 | ||
22 | sub new { | |
23 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
24 | $parent = undef unless defined $parent; | |
25 | $id = -1 unless defined $id; | |
26 | $title = "" unless defined $title; | |
27 | $pos = wxDefaultPosition unless defined $pos; | |
28 | $size = wxDefaultSize unless defined $size; | |
29 | $name = "" unless defined $name; | |
30 | ||
31 | # begin wxGlade: EB::Wx::Report::GenBase::new | |
32 | ||
33 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTHICK_FRAME | |
34 | unless defined $style; | |
35 | ||
36 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
37 | $self->{b_refresh} = Wx::Button->new($self, wxID_REFRESH, ""); | |
38 | $self->{b_props} = Wx::Button->new($self, wxID_PREFERENCES, ""); | |
39 | $self->{l_detail} = Wx::StaticText->new($self, -1, _T("Detail:"), wxDefaultPosition, wxDefaultSize, ); | |
40 | $self->{bd_less} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("edit_remove.png", wxBITMAP_TYPE_ANY)); | |
41 | $self->{bd_more} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("edit_add.png", wxBITMAP_TYPE_ANY)); | |
42 | $self->{b_print} = Wx::Button->new($self, wxID_PRINT, ""); | |
43 | $self->{b_close} = Wx::Button->new($self, wxID_CLOSE, ""); | |
44 | $self->{w_report} = Wx::HtmlWindow::Derived->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
45 | ||
46 | $self->__set_properties(); | |
47 | $self->__do_layout(); | |
48 | ||
49 | Wx::Event::EVT_BUTTON($self, $self->{b_refresh}->GetId, \&OnRefresh); | |
50 | Wx::Event::EVT_BUTTON($self, $self->{b_props}->GetId, \&OnProps); | |
51 | Wx::Event::EVT_BUTTON($self, $self->{bd_less}->GetId, \&OnLess); | |
52 | Wx::Event::EVT_BUTTON($self, $self->{bd_more}->GetId, \&OnMore); | |
53 | Wx::Event::EVT_BUTTON($self, wxID_PRINT, \&OnPrint); | |
54 | Wx::Event::EVT_BUTTON($self, $self->{b_close}->GetId, \&OnClose); | |
55 | ||
56 | # end wxGlade | |
57 | ||
58 | Wx::Event::EVT_MENU($self, wxID_CLOSE, \&OnClose); | |
59 | ||
60 | =begin notneeded | |
61 | ||
62 | # Accelerators do not work with Dialog windows. | |
63 | # Attach one to the inner w_report window. | |
64 | $self->{w_report}->SetAcceleratorTable | |
65 | ( Wx::AcceleratorTable->new | |
66 | ( [ wxACCEL_ALT, WXK_F4, wxID_CLOSE ] ) ); | |
67 | Wx::Event::EVT_MENU($self->{w_report}, wxID_CLOSE, \&OnClose); | |
68 | ||
69 | =cut | |
70 | ||
71 | $self->{_PRINTER} = Wx::HtmlEasyPrinting->new('Print'); | |
72 | ||
73 | return $self; | |
74 | ||
75 | } | |
76 | ||
77 | sub html { $_[0]->{w_report} } | |
78 | sub htmltext :lvalue { $_[0]->{_HTMLTEXT} } | |
79 | sub printer { $_[0]->{_PRINTER} } | |
80 | ||
81 | sub __set_properties { | |
82 | my $self = shift; | |
83 | ||
84 | # begin wxGlade: EB::Wx::Report::GenBase::__set_properties | |
85 | ||
86 | $self->SetTitle(_T("Generiek Rapport")); | |
87 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(360, 220))); | |
88 | $self->{b_refresh}->SetToolTipString(_T("Bijwerken naar laatste gegevens")); | |
89 | $self->{b_props}->SetToolTipString(_T("Instellingsgegevens")); | |
90 | $self->{bd_less}->SetToolTipString(_T("Minder uitgebreid")); | |
91 | $self->{bd_less}->SetSize($self->{bd_less}->GetBestSize()); | |
92 | $self->{bd_more}->SetToolTipString(_T("Meer uitgebreid")); | |
93 | $self->{bd_more}->SetSize($self->{bd_more}->GetBestSize()); | |
94 | $self->{b_print}->SetToolTipString(_T("Overzicht afdrukken")); | |
95 | $self->{b_close}->SetToolTipString(_T("Venster sluiten")); | |
96 | $self->{b_close}->SetFocus(); | |
97 | ||
98 | # end wxGlade | |
99 | } | |
100 | ||
101 | sub __do_layout { | |
102 | my $self = shift; | |
103 | ||
104 | # begin wxGlade: EB::Wx::Report::GenBase::__do_layout | |
105 | ||
106 | $self->{sizer_1} = Wx::BoxSizer->new(wxHORIZONTAL); | |
107 | $self->{sizer_2} = Wx::BoxSizer->new(wxVERTICAL); | |
108 | $self->{sizer_3} = Wx::BoxSizer->new(wxHORIZONTAL); | |
109 | $self->{sizer_3}->Add($self->{b_refresh}, 0, wxLEFT|wxTOP|wxEXPAND|wxADJUST_MINSIZE, 5); | |
110 | $self->{sizer_3}->Add($self->{b_props}, 0, wxLEFT|wxTOP|wxEXPAND|wxADJUST_MINSIZE, 5); | |
111 | $self->{sizer_3}->Add(5, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
112 | $self->{sizer_3}->Add($self->{l_detail}, 0, wxLEFT|wxTOP|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
113 | $self->{sizer_3}->Add($self->{bd_less}, 0, wxTOP|wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
114 | $self->{sizer_3}->Add($self->{bd_more}, 0, wxTOP|wxEXPAND|wxADJUST_MINSIZE, 5); | |
115 | $self->{sizer_3}->Add(5, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
116 | $self->{sizer_3}->Add($self->{b_print}, 0, wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); | |
117 | $self->{sizer_3}->Add($self->{b_close}, 0, wxRIGHT|wxTOP|wxEXPAND|wxADJUST_MINSIZE, 5); | |
118 | $self->{sizer_2}->Add($self->{sizer_3}, 0, wxBOTTOM|wxEXPAND, 5); | |
119 | $self->{sizer_2}->Add($self->{w_report}, 1, wxEXPAND, 0); | |
120 | $self->{sizer_1}->Add($self->{sizer_2}, 1, wxEXPAND, 5); | |
121 | $self->SetSizer($self->{sizer_1}); | |
122 | $self->Layout(); | |
123 | ||
124 | # end wxGlade | |
125 | ||
126 | } | |
127 | ||
128 | sub SetDetails { | |
129 | my ($self, $cur, $min, $max, $tips) = @_; | |
130 | $self->{_maxdetail} = $max; | |
131 | $self->{_mindetail} = $min; | |
132 | $self->{detail} = $cur; | |
133 | $self->{_ml_tips} = $tips if $tips; | |
134 | $self->_MoreLess; | |
135 | } | |
136 | ||
137 | sub GetDetail { | |
138 | my ($self) = @_; | |
139 | $self->{detail}; | |
140 | } | |
141 | ||
142 | sub OnRefresh { | |
143 | my ($self, $event) = @_; | |
144 | # wxGlade: EB::Wx::Report::GenBase::OnRefresh <event_handler> | |
145 | ||
146 | $self->refresh; | |
147 | ||
148 | # end wxGlade | |
149 | } | |
150 | ||
151 | sub OnProps { | |
152 | my ($self, $event) = @_; | |
153 | # wxGlade: EB::Wx::Report::GenBase::OnProps <event_handler> | |
154 | ||
155 | my $this = "d_repprops"; | |
156 | ||
157 | # Try package specific prefs dialog. | |
158 | my $pkg = ref($self)."::Preferences"; | |
159 | eval "require $pkg"; | |
160 | ||
161 | # Otherwise, try generic dialog. | |
162 | if ( $@ ) { | |
163 | Wx::LogMessage($@) unless $@ =~ /Can't locate .*\/Preferences.pm in \@INC/; | |
164 | $pkg = "EB::Wx::Report::GenBase::Preferences"; | |
165 | eval "require $pkg"; | |
166 | die($@) if $@; | |
167 | } | |
168 | ||
169 | $self->{$this} ||= $pkg->new | |
170 | ($self, -1, | |
171 | "Instellingen", | |
172 | wxDefaultPosition, wxDefaultSize, | |
173 | ); | |
174 | ||
175 | # Let it take what it wants... | |
176 | $self->{$this}->init($self); | |
177 | my $ret = $self->{$this}->ShowModal; | |
178 | ||
179 | # Store back (possibly updated) prefs. | |
180 | if ( $ret == wxID_OK ) { | |
181 | my $h = $self->{$this}->GetValues; | |
182 | foreach ( grep { /^pref_/ } keys(%$h) ) { | |
183 | $self->{$_} = $h->{$_}; | |
184 | } | |
185 | $self->{prefs_changed} = 1; | |
186 | $self->refresh; | |
187 | delete $self->{prefs_changed}; | |
188 | } | |
189 | ||
190 | # end wxGlade | |
191 | } | |
192 | ||
193 | # wxGlade: EB::Wx::Report::GenBase::OnMore <event_handler> | |
194 | sub OnMore { | |
195 | my ($self, $event) = @_; | |
196 | ||
197 | if ( $self->{detail} < $self->{_maxdetail} ) { | |
198 | $self->{detail}++; | |
199 | $self->refresh; | |
200 | } | |
201 | $self->_MoreLess; | |
202 | } | |
203 | ||
204 | sub _MoreLess() { | |
205 | my $self = shift; | |
206 | ||
207 | if ( $self->{detail} < $self->{_maxdetail} ) { | |
208 | $self->{bd_more}->Enable(1); | |
209 | $self->{bd_more}->SetToolTipString | |
210 | ( $self->{_ml_tips} | |
211 | ? $self->{_ml_tips}->[$self->{detail}+1] | |
212 | : _T("Meer uitgebreid") ); | |
213 | } | |
214 | else { | |
215 | $self->{bd_more}->Enable(0); | |
216 | } | |
217 | ||
218 | if ( $self->{detail} > $self->{_mindetail} ) { | |
219 | $self->{bd_less}->Enable(1); | |
220 | $self->{bd_less}->SetToolTipString | |
221 | ( $self->{_ml_tips} | |
222 | ? $self->{_ml_tips}->[$self->{detail}-1] | |
223 | : _T("Minder uitgebreid") ); | |
224 | } | |
225 | else { | |
226 | $self->{bd_less}->Enable(0); | |
227 | } | |
228 | } | |
229 | ||
230 | # wxGlade: EB::Wx::Report::GenBase::OnLess <event_handler> | |
231 | sub OnLess { | |
232 | my ($self, $event) = @_; | |
233 | ||
234 | if ( $self->{detail} > $self->{_mindetail} ) { | |
235 | $self->{detail}--; | |
236 | $self->refresh; | |
237 | } | |
238 | $self->_MoreLess; | |
239 | } | |
240 | ||
241 | # wxGlade: EB::Wx::Report::GenBase::OnClose <event_handler> | |
242 | sub OnClose { | |
243 | my ($self, $event) = @_; | |
244 | ||
245 | # OnClose can be triggered from the inner window. | |
246 | while ( ! $self->can("sizepos_save") ) { | |
247 | $self = $self->GetParent; | |
248 | } | |
249 | ||
250 | $self->sizepos_save; | |
251 | $self->Show(0); | |
252 | ||
253 | } | |
254 | ||
255 | # wxGlade: EB::Wx::Report::GenBase::OnPrint <event_handler> | |
256 | sub OnPrint { | |
257 | my ($self, $event) = @_; | |
258 | ||
259 | #$self->printer->SetHeader('@TITLE@'); | |
260 | #$self->printer->SetFooter('@DATE@ @TIME@ '._T("Blad:").' @PAGENUM@'); | |
261 | $self->printer->SetFooter(_T("Blad:").' @PAGENUM@'); | |
262 | my $html = $self->htmltext; | |
263 | $html =~ s;</?a[^>]*>;;gx; | |
264 | $self->printer->PrintText($html); | |
265 | ||
266 | } | |
267 | ||
268 | package Wx::HtmlWindow::Derived; | |
269 | ||
270 | use strict; | |
271 | use warnings; | |
272 | use base qw(Wx::HtmlWindow); | |
273 | ||
274 | sub OnLinkClicked { | |
275 | my ($self, $event) = @_; | |
276 | my $link = $event->GetHref; | |
277 | ||
278 | if ( $link =~ m;^([^:]+)://(.+)$; | |
279 | && (my $rep = EB::Wx::MainFrame->can("ShowR" . ucfirst(lc($1)))) ) { | |
280 | my @a = split(/[?&]/, $2); | |
281 | my $args = { select => shift(@a) }; | |
282 | foreach ( @a ) { | |
283 | if ( /^([^=]+)=(.*)/ ) { | |
284 | $args->{$1} = $2; | |
285 | } | |
286 | else { | |
287 | $args->{$_} = 1; | |
288 | } | |
289 | } | |
290 | $rep->($app->{TOP}, $args); | |
291 | } | |
292 | else { | |
293 | Wx::LogMessage('Link: "%s"', $1); | |
294 | $self->SUPER::OnLinkClicked($event); | |
295 | } | |
296 | } | |
297 | ||
298 | 1; | |
299 |
0 | #! perl | |
1 | ||
2 | # $Id: Preferences.pm,v 1.3 2009/10/09 15:43:33 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $dbh; | |
8 | ||
9 | use strict; | |
10 | ||
11 | package EB::Wx::Report::Grootboek::Preferences; | |
12 | ||
13 | use Wx qw[:everything]; | |
14 | use base qw(Wx::Dialog); | |
15 | use base qw(EB::Wx::Window); | |
16 | use EB::Wx::UI::PeriodPanel; | |
17 | use EB::Wx::UI::AccInput; | |
18 | use EB; | |
19 | ||
20 | use strict; | |
21 | ||
22 | sub new { | |
23 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
24 | $parent = undef unless defined $parent; | |
25 | $id = -1 unless defined $id; | |
26 | $title = "" unless defined $title; | |
27 | $pos = wxDefaultPosition unless defined $pos; | |
28 | $size = wxDefaultSize unless defined $size; | |
29 | $name = "" unless defined $name; | |
30 | ||
31 | # begin wxGlade: EB::Wx::Report::Grootboek::Preferences::new | |
32 | ||
33 | $style = wxDEFAULT_DIALOG_STYLE | |
34 | unless defined $style; | |
35 | ||
36 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
37 | $self->{sizer_2_staticbox} = Wx::StaticBox->new($self, -1, "" ); | |
38 | $self->{sizer_4_staticbox} = Wx::StaticBox->new($self, -1, "" ); | |
39 | $self->{label_1} = Wx::StaticText->new($self, -1, "Selecteer een grootboekrekening", wxDefaultPosition, wxDefaultSize, ); | |
40 | $self->{cb_acct} = Wx::CheckBox->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
41 | $self->{t_acct} = EB::Wx::UI::AccInput->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
42 | $self->{p_period} = EB::Wx::UI::PeriodPanel->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
43 | $self->{b_cancel} = Wx::Button->new($self, wxID_CANCEL, ""); | |
44 | $self->{b_apply} = Wx::Button->new($self, wxID_OK, ""); | |
45 | ||
46 | $self->__set_properties(); | |
47 | $self->__do_layout(); | |
48 | ||
49 | Wx::Event::EVT_CHECKBOX($self, $self->{cb_acct}->GetId, \&OnCBAcct); | |
50 | ||
51 | # end wxGlade | |
52 | ||
53 | Wx::Event::EVT_EB_LISTINPUT($self, $self->{t_acct}, \&OnAcct); | |
54 | Wx::Event::EVT_EB_PERIOD($self, $self->{p_period}, \&OnPeriod); | |
55 | ||
56 | return $self; | |
57 | ||
58 | } | |
59 | ||
60 | ||
61 | sub __set_properties { | |
62 | my $self = shift; | |
63 | ||
64 | # begin wxGlade: EB::Wx::Report::Grootboek::Preferences::__set_properties | |
65 | ||
66 | $self->SetTitle("Instellingen"); | |
67 | $self->{t_acct}->Enable(0); | |
68 | $self->{b_cancel}->SetFocus(); | |
69 | ||
70 | # end wxGlade | |
71 | ||
72 | } | |
73 | ||
74 | sub __do_layout { | |
75 | my $self = shift; | |
76 | ||
77 | ||
78 | # begin wxGlade: EB::Wx::Report::Grootboek::Preferences::__do_layout | |
79 | ||
80 | $self->{sizer_1} = Wx::BoxSizer->new(wxVERTICAL); | |
81 | $self->{sizer_3} = Wx::BoxSizer->new(wxHORIZONTAL); | |
82 | $self->{sizer_2}= Wx::StaticBoxSizer->new($self->{sizer_2_staticbox}, wxHORIZONTAL); | |
83 | $self->{sizer_4}= Wx::StaticBoxSizer->new($self->{sizer_4_staticbox}, wxVERTICAL); | |
84 | $self->{sizer_5} = Wx::BoxSizer->new(wxVERTICAL); | |
85 | $self->{sizer_6} = Wx::BoxSizer->new(wxHORIZONTAL); | |
86 | $self->{sizer_5}->Add($self->{label_1}, 0, wxLEFT|wxRIGHT|wxTOP|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
87 | $self->{sizer_5}->Add(5, 1, 0, wxADJUST_MINSIZE, 0); | |
88 | $self->{sizer_6}->Add($self->{cb_acct}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
89 | $self->{sizer_6}->Add($self->{t_acct}, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
90 | $self->{sizer_5}->Add($self->{sizer_6}, 1, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
91 | $self->{sizer_4}->Add($self->{sizer_5}, 0, wxEXPAND, 0); | |
92 | $self->{sizer_1}->Add($self->{sizer_4}, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
93 | $self->{sizer_2}->Add($self->{p_period}, 1, wxEXPAND, 0); | |
94 | $self->{sizer_1}->Add($self->{sizer_2}, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
95 | $self->{sizer_3}->Add(5, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
96 | $self->{sizer_3}->Add($self->{b_cancel}, 0, wxALL|wxADJUST_MINSIZE, 5); | |
97 | $self->{sizer_3}->Add($self->{b_apply}, 0, wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE, 5); | |
98 | $self->{sizer_1}->Add($self->{sizer_3}, 0, wxEXPAND, 0); | |
99 | $self->SetSizer($self->{sizer_1}); | |
100 | $self->{sizer_1}->Fit($self); | |
101 | $self->Layout(); | |
102 | ||
103 | # end wxGlade | |
104 | } | |
105 | ||
106 | sub init { | |
107 | my ($self, $args) = @_; | |
108 | if ( $args->{pref_from_to} ) { | |
109 | $self->{p_period}->allow_fromto(1) if $args->{pref_from_to} & 1; | |
110 | $self->{p_period}->allow_to(1) if $args->{pref_from_to} & 2; | |
111 | } | |
112 | $self->refresh; | |
113 | $self->{p_period}->set_bky($args->{pref_bky}) if $args->{pref_bky}; | |
114 | } | |
115 | ||
116 | my @choices; | |
117 | sub refresh { | |
118 | my ($self) = @_; | |
119 | ||
120 | $self->{b_apply}->Enable(0); | |
121 | if ( $self->{pref_acct} ) { | |
122 | $self->{t_acct}->SetValue($self->{pref_acct}); | |
123 | $self->{t_acct}->Enable(1); | |
124 | $self->{cb_acct}->SetValue(1); | |
125 | } | |
126 | $self->{p_period}->refresh; | |
127 | } | |
128 | ||
129 | sub GetValues { | |
130 | my ($self) = @_; | |
131 | my $r; | |
132 | my $p = $self->{p_period}->GetValues; | |
133 | $r->{pref_acct} = | |
134 | $self->{cb_acct}->IsChecked | |
135 | ? $self->{t_acct}->GetValue | |
136 | : undef; | |
137 | $r->{pref_bky} = $p->{period_panel_bky} | |
138 | if exists $p->{period_panel_bky}; | |
139 | $r->{pref_per}->[0] = $p->{period_panel_from} | |
140 | if exists $p->{period_panel_from}; | |
141 | $r->{pref_per}->[1] = $p->{period_panel_to} | |
142 | if exists $p->{period_panel_to}; | |
143 | $r; | |
144 | } | |
145 | ||
146 | sub OnPeriod { | |
147 | my ($self, $event) = @_; | |
148 | $self->{b_apply}->Enable($self->{p_period}->changed); | |
149 | } | |
150 | ||
151 | # wxGlade: EB::Wx::Report::Grootboek::Preferences::OnCBAcct <event_handler> | |
152 | sub OnCBAcct { | |
153 | my ($self, $event) = @_; | |
154 | $self->{t_acct}->Enable($self->{cb_acct}->IsChecked); | |
155 | $self->{b_apply}->Enable(1); | |
156 | } | |
157 | ||
158 | sub OnAcct { | |
159 | my ($self, $event) = @_; | |
160 | $self->{b_apply}->Enable(1); | |
161 | } | |
162 | ||
163 | # end of class EB::Wx::Report::Grootboek::Preferences | |
164 | ||
165 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: Grootboek.pm,v 1.7 2009/10/09 15:43:20 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | ||
8 | package EB::Wx::Report::Grootboek; | |
9 | ||
10 | use base qw(EB::Wx::Report::GenBase); | |
11 | use strict; | |
12 | use EB; | |
13 | ||
14 | sub init { | |
15 | my ($self, $me, $args) = @_; | |
16 | $self->SetTitle(_T("Grootboek")); | |
17 | $self->{pref_from_to} = 3; | |
18 | $self->SetDetails(2,0,2); | |
19 | ||
20 | if ( $args->{select} ) { | |
21 | $self->{pref_acct} = $args->{select}; | |
22 | $self->{detail} = 2; | |
23 | } | |
24 | if ( $args->{periode} ) { | |
25 | my $p = parse_date_range($args->{periode}); | |
26 | delete($self->{pref_bky}); | |
27 | $self->{pref_per} = $p; | |
28 | } | |
29 | $self->refresh; | |
30 | } | |
31 | ||
32 | sub refresh { | |
33 | my ($self) = @_; | |
34 | my $output = ""; | |
35 | ||
36 | my @period; | |
37 | ||
38 | if ( defined($self->{pref_bky}) ) { | |
39 | @period = ("boekjaar", $self->{pref_bky}); | |
40 | } | |
41 | elsif ( defined($self->{pref_per}->[0]) ) { | |
42 | @period = ("periode", [ @{$self->{pref_per}} ]); | |
43 | } | |
44 | else { | |
45 | @period = ("boekjaar", $self->{pref_bky} = $state->bky); | |
46 | } | |
47 | ||
48 | require EB::Report::Grootboek; | |
49 | ||
50 | eval { | |
51 | EB::Report::Grootboek->new->perform | |
52 | ({ generate => "wxhtml", | |
53 | @period, | |
54 | detail => $self->GetDetail, | |
55 | $self->{pref_acct} ? ("select" => $self->{pref_acct}) : (), | |
56 | output => \$output, | |
57 | }); | |
58 | }; | |
59 | if ( $@ ) { | |
60 | $output = $@; | |
61 | } | |
62 | ||
63 | $self->html->SetPage($output); | |
64 | $self->{_HTMLTEXT} = $output; | |
65 | } | |
66 | ||
67 | 1; | |
68 |
0 | #! perl | |
1 | ||
2 | # $Id: Preferences.pm,v 1.4 2008/02/20 15:22:26 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $dbh; | |
8 | ||
9 | use strict; | |
10 | ||
11 | package EB::Wx::Report::Journaal::Preferences; | |
12 | ||
13 | use Wx qw[:everything]; | |
14 | use base qw(Wx::Dialog); | |
15 | use base qw(EB::Wx::Window); | |
16 | use EB::Wx::UI::PeriodPanel; | |
17 | use EB; | |
18 | ||
19 | use strict; | |
20 | ||
21 | sub new { | |
22 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
23 | $parent = undef unless defined $parent; | |
24 | $id = -1 unless defined $id; | |
25 | $title = "" unless defined $title; | |
26 | $pos = wxDefaultPosition unless defined $pos; | |
27 | $size = wxDefaultSize unless defined $size; | |
28 | $name = "" unless defined $name; | |
29 | ||
30 | # begin wxGlade: EB::Wx::Report::Journaal::Preferences::new | |
31 | ||
32 | $style = wxDEFAULT_DIALOG_STYLE | |
33 | unless defined $style; | |
34 | ||
35 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
36 | $self->{sizer_2_staticbox} = Wx::StaticBox->new($self, -1, "" ); | |
37 | $self->{sizer_4_staticbox} = Wx::StaticBox->new($self, -1, "" ); | |
38 | $self->{label_1} = Wx::StaticText->new($self, -1, "Dagboek", wxDefaultPosition, wxDefaultSize, ); | |
39 | $self->{ch_dbk} = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, [], ); | |
40 | $self->{p_period} = EB::Wx::UI::PeriodPanel->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
41 | $self->{b_cancel} = Wx::Button->new($self, wxID_CANCEL, ""); | |
42 | $self->{b_apply} = Wx::Button->new($self, wxID_OK, ""); | |
43 | ||
44 | $self->__set_properties(); | |
45 | $self->__do_layout(); | |
46 | ||
47 | Wx::Event::EVT_CHOICE($self, $self->{ch_dbk}->GetId, \&OnDbk); | |
48 | ||
49 | # end wxGlade | |
50 | ||
51 | Wx::Event::EVT_EB_PERIOD($self, $self->{p_period}, \&OnPeriod); | |
52 | ||
53 | return $self; | |
54 | ||
55 | } | |
56 | ||
57 | ||
58 | sub __set_properties { | |
59 | my $self = shift; | |
60 | ||
61 | # begin wxGlade: EB::Wx::Report::Journaal::Preferences::__set_properties | |
62 | ||
63 | $self->SetTitle("Instellingen"); | |
64 | $self->{ch_dbk}->SetSelection(0); | |
65 | $self->{b_cancel}->SetFocus(); | |
66 | ||
67 | # end wxGlade | |
68 | ||
69 | } | |
70 | ||
71 | sub __do_layout { | |
72 | my $self = shift; | |
73 | ||
74 | ||
75 | # begin wxGlade: EB::Wx::Report::Journaal::Preferences::__do_layout | |
76 | ||
77 | $self->{sizer_1} = Wx::BoxSizer->new(wxVERTICAL); | |
78 | $self->{sizer_3} = Wx::BoxSizer->new(wxHORIZONTAL); | |
79 | $self->{sizer_2}= Wx::StaticBoxSizer->new($self->{sizer_2_staticbox}, wxHORIZONTAL); | |
80 | $self->{sizer_4}= Wx::StaticBoxSizer->new($self->{sizer_4_staticbox}, wxVERTICAL); | |
81 | $self->{sizer_5} = Wx::BoxSizer->new(wxVERTICAL); | |
82 | $self->{sizer_5}->Add($self->{label_1}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
83 | $self->{sizer_5}->Add(5, 1, 0, wxADJUST_MINSIZE, 0); | |
84 | $self->{sizer_5}->Add($self->{ch_dbk}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
85 | $self->{sizer_4}->Add($self->{sizer_5}, 0, wxEXPAND, 0); | |
86 | $self->{sizer_1}->Add($self->{sizer_4}, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
87 | $self->{sizer_2}->Add($self->{p_period}, 1, wxEXPAND, 0); | |
88 | $self->{sizer_1}->Add($self->{sizer_2}, 0, wxLEFT|wxRIGHT|wxEXPAND, 5); | |
89 | $self->{sizer_3}->Add(5, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
90 | $self->{sizer_3}->Add($self->{b_cancel}, 0, wxALL|wxADJUST_MINSIZE, 5); | |
91 | $self->{sizer_3}->Add($self->{b_apply}, 0, wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE, 5); | |
92 | $self->{sizer_1}->Add($self->{sizer_3}, 0, wxEXPAND, 0); | |
93 | $self->SetSizer($self->{sizer_1}); | |
94 | $self->{sizer_1}->Fit($self); | |
95 | $self->Layout(); | |
96 | ||
97 | # end wxGlade | |
98 | } | |
99 | ||
100 | sub init { | |
101 | my ($self, $args) = @_; | |
102 | if ( $args->{pref_from_to} ) { | |
103 | $self->{p_period}->allow_fromto(1) if $args->{pref_from_to} & 1; | |
104 | $self->{p_period}->allow_to(1) if $args->{pref_from_to} & 2; | |
105 | } | |
106 | $self->{b_apply}->Enable(0); | |
107 | $self->refresh; | |
108 | $self->{p_period}->set_bky($args->{pref_bky}) if $args->{pref_bky}; | |
109 | } | |
110 | ||
111 | my @choices; | |
112 | sub refresh { | |
113 | my ($self) = @_; | |
114 | ||
115 | my $sth = $dbh->sql_exec("SELECT dbk_desc FROM Dagboeken". | |
116 | " ORDER BY dbk_desc"); | |
117 | ||
118 | @choices = ("Alle dagboeken"); | |
119 | while ( my $rr = $sth->fetch ) { | |
120 | push(@choices, $rr->[0]); | |
121 | } | |
122 | $self->{ch_dbk}->Clear; | |
123 | $self->{ch_dbk}->Append($_) foreach @choices; | |
124 | $self->{ch_dbk}->SetSelection(0); | |
125 | $self->{p_period}->refresh; | |
126 | } | |
127 | ||
128 | sub GetValues { | |
129 | my ($self) = @_; | |
130 | my $r; | |
131 | my $p = $self->{p_period}->GetValues; | |
132 | $r->{pref_dbk} = $choices[$self->{ch_dbk}->GetSelection] | |
133 | if $self->{ch_dbk}->GetSelection; | |
134 | $r->{pref_bky} = $p->{period_panel_bky} | |
135 | if exists $p->{period_panel_bky}; | |
136 | $r->{pref_per}->[0] = $p->{period_panel_from} | |
137 | if exists $p->{period_panel_from}; | |
138 | $r->{pref_per}->[1] = $p->{period_panel_to} | |
139 | if exists $p->{period_panel_to}; | |
140 | $r; | |
141 | } | |
142 | ||
143 | sub OnDbk { | |
144 | my ($self, $event) = @_; | |
145 | # wxGlade: EB::Wx::Report::Journaal::Preferences::OnDbk <event_handler> | |
146 | ||
147 | $self->{b_apply}->Enable(1); | |
148 | ||
149 | # end wxGlade | |
150 | } | |
151 | ||
152 | sub OnPeriod { | |
153 | my ($self, $event) = @_; | |
154 | $self->{b_apply}->Enable($self->{p_period}->changed); | |
155 | } | |
156 | ||
157 | # end of class EB::Wx::Report::Journaal::Preferences | |
158 | ||
159 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: Journaal.pm,v 1.8 2008/03/25 22:32:46 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | ||
8 | package EB::Wx::Report::Journaal; | |
9 | ||
10 | use base qw(EB::Wx::Report::GenBase); | |
11 | use strict; | |
12 | use EB; | |
13 | ||
14 | sub init { | |
15 | my ($self, $me, $args) = @_; | |
16 | $self->SetDetails(1, 0, 1, | |
17 | [ _T("Alleen totaal"), | |
18 | _T("Volledig"), | |
19 | ]); | |
20 | $self->{pref_from_to} = 3; | |
21 | $self->SetTitle("Journaal"); | |
22 | ||
23 | if ( $args->{select} ) { | |
24 | $self->{pref_dbk} = $args->{select}; | |
25 | $self->{detail} = 1; | |
26 | } | |
27 | if ( $args->{periode} ) { | |
28 | my $p = parse_date_range($args->{periode}); | |
29 | delete($self->{pref_bky}); | |
30 | $self->{pref_per} = $p; | |
31 | } | |
32 | $self->refresh; | |
33 | } | |
34 | ||
35 | sub refresh { | |
36 | my ($self) = @_; | |
37 | my $output; | |
38 | ||
39 | delete($self->{pref_dbk}) if $self->{prefs_changed}; | |
40 | ||
41 | my @period; | |
42 | ||
43 | if ( defined($self->{pref_bky}) ) { | |
44 | @period = ("boekjaar", $self->{pref_bky}); | |
45 | } | |
46 | elsif ( defined($self->{pref_per}->[0]) ) { | |
47 | @period = ("periode", [ @{$self->{pref_per}} ]); | |
48 | } | |
49 | else { | |
50 | @period = ("boekjaar", $self->{pref_bky} = $state->bky); | |
51 | } | |
52 | ||
53 | require EB::Report::Journal; | |
54 | eval { | |
55 | EB::Report::Journal->new->journal | |
56 | ({ generate => "wxhtml", | |
57 | @period, | |
58 | $self->{pref_dbk} ? (select => $self->{pref_dbk}) : (), | |
59 | output => \$output, | |
60 | detail => $self->{detail} }); | |
61 | }; | |
62 | if ( $@ ) { | |
63 | $output = $@; | |
64 | } | |
65 | $self->html->SetPage($output); | |
66 | $self->{_HTMLTEXT} = $output; | |
67 | } | |
68 | ||
69 | 1; | |
70 |
0 | #! perl | |
1 | ||
2 | # $Id: Openstaand.pm,v 1.3 2008/03/25 22:33:06 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | ||
8 | package EB::Wx::Report::Openstaand; | |
9 | ||
10 | use base qw(EB::Wx::Report::GenBase); | |
11 | use strict; | |
12 | use EB; | |
13 | ||
14 | sub init { | |
15 | my ($self, $me) = @_; | |
16 | $self->{pref_from_to} = 2; | |
17 | $self->SetTitle("Openstaande posten"); | |
18 | $self->SetDetails(0,0,0); | |
19 | $self->refresh; | |
20 | } | |
21 | ||
22 | sub refresh { | |
23 | my ($self) = @_; | |
24 | ||
25 | my @period; | |
26 | ||
27 | if ( defined($self->{pref_bky}) ) { | |
28 | @period = ("boekjaar", $self->{pref_bky}); | |
29 | } | |
30 | elsif ( defined($self->{pref_per}->[0]) ) { | |
31 | @period = ("periode", [ @{$self->{pref_per}} ]); | |
32 | } | |
33 | elsif ( defined($self->{pref_per}->[1]) ) { | |
34 | @period = ("per", $self->{pref_per}->[1]); | |
35 | } | |
36 | else { | |
37 | @period = ("boekjaar", $self->{pref_bky} = $state->bky); | |
38 | } | |
39 | ||
40 | require EB::Report::Open; | |
41 | my $output; | |
42 | EB::Report::Open->new->perform | |
43 | ({ generate => 'wxhtml', | |
44 | @period, | |
45 | output => \$output, | |
46 | }); | |
47 | $self->{w_report}->SetPage($output); | |
48 | $self->{_HTMLTEXT} = $output; | |
49 | } | |
50 | ||
51 | 1; | |
52 |
0 | # generated by wxGlade 0.5cvs on Fri Aug 3 21:34:29 2007 from /home/jv/src/eekboek/src/wxeb/wxeb.wxg | |
1 | # To get wxPerl visit http://wxPerl.sourceforge.net/ | |
2 | ||
3 | use Wx 0.15 qw[:allclasses]; | |
4 | use strict; | |
5 | package EB::Wx::Shell::HtmlViewer; | |
6 | ||
7 | use Wx qw[:everything]; | |
8 | use base qw(Wx::Dialog); | |
9 | use strict; | |
10 | ||
11 | # begin wxGlade: ::dependencies | |
12 | use Wx::Locale gettext => '_T'; | |
13 | # end wxGlade | |
14 | ||
15 | sub new { | |
16 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
17 | $parent = undef unless defined $parent; | |
18 | $id = -1 unless defined $id; | |
19 | $title = "" unless defined $title; | |
20 | $pos = wxDefaultPosition unless defined $pos; | |
21 | $size = wxDefaultSize unless defined $size; | |
22 | $name = "" unless defined $name; | |
23 | ||
24 | # begin wxGlade: EB::Wx::Shell::HtmlViewer::new | |
25 | ||
26 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxMAXIMIZE_BOX|wxMINIMIZE_BOX | |
27 | unless defined $style; | |
28 | ||
29 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
30 | $self->{b_print} = Wx::Button->new($self, wxID_PRINT, ""); | |
31 | $self->{b_save} = Wx::Button->new($self, wxID_SAVE, ""); | |
32 | $self->{p_close} = Wx::Button->new($self, wxID_CLOSE, ""); | |
33 | $self->{p_htmlview} = Wx::HtmlWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
34 | ||
35 | $self->__set_properties(); | |
36 | $self->__do_layout(); | |
37 | ||
38 | Wx::Event::EVT_BUTTON($self, $self->{b_print}->GetId, \&OnPrint); | |
39 | Wx::Event::EVT_BUTTON($self, $self->{b_save}->GetId, \&OnSave); | |
40 | Wx::Event::EVT_BUTTON($self, $self->{p_close}->GetId, \&OnClose); | |
41 | ||
42 | # end wxGlade | |
43 | ||
44 | $self->{_PRINTER} = Wx::HtmlEasyPrinting->new('Print'); | |
45 | ||
46 | $self->SetAcceleratorTable | |
47 | (Wx::AcceleratorTable->new | |
48 | ( [wxACCEL_CTRL, ord 'w', wxID_CLOSE], | |
49 | [wxACCEL_NORMAL, 27, wxID_CLOSE], | |
50 | )); | |
51 | ||
52 | return $self; | |
53 | ||
54 | } | |
55 | ||
56 | sub html { $_[0]->{p_htmlview} } | |
57 | sub htmltext :lvalue { $_[0]->{_HTMLTEXT} } | |
58 | sub printer { $_[0]->{_PRINTER} } | |
59 | ||
60 | sub __set_properties { | |
61 | my $self = shift; | |
62 | ||
63 | # begin wxGlade: EB::Wx::Shell::HtmlViewer::__set_properties | |
64 | ||
65 | $self->SetTitle(_T("HTML View")); | |
66 | $self->SetSize(Wx::Size->new(618, 522)); | |
67 | $self->{p_close}->SetDefault(); | |
68 | ||
69 | # end wxGlade | |
70 | } | |
71 | ||
72 | sub __do_layout { | |
73 | my $self = shift; | |
74 | ||
75 | # begin wxGlade: EB::Wx::Shell::HtmlViewer::__do_layout | |
76 | ||
77 | $self->{sz_htmlview} = Wx::BoxSizer->new(wxVERTICAL); | |
78 | $self->{sz_htmlviewbuttons} = Wx::BoxSizer->new(wxHORIZONTAL); | |
79 | $self->{sz_htmlviewbuttons}->Add($self->{b_print}, 0, wxADJUST_MINSIZE, 0); | |
80 | $self->{sz_htmlviewbuttons}->Add($self->{b_save}, 0, wxLEFT|wxADJUST_MINSIZE, 5); | |
81 | $self->{sz_htmlviewbuttons}->Add(5, 1, 1, wxADJUST_MINSIZE, 0); | |
82 | $self->{sz_htmlviewbuttons}->Add($self->{p_close}, 0, wxADJUST_MINSIZE, 0); | |
83 | $self->{sz_htmlview}->Add($self->{sz_htmlviewbuttons}, 0, wxALL|wxEXPAND, 5); | |
84 | $self->{sz_htmlview}->Add($self->{p_htmlview}, 1, wxEXPAND, 0); | |
85 | $self->SetSizer($self->{sz_htmlview}); | |
86 | $self->Layout(); | |
87 | ||
88 | # end wxGlade | |
89 | } | |
90 | ||
91 | sub OnPrint { | |
92 | my ($self, $event) = @_; | |
93 | # wxGlade: EB::Wx::Shell::HtmlViewer::OnPrint <event_handler> | |
94 | $self->printer->SetFooter(' - @PAGENUM@ - '); | |
95 | $self->printer->PrintText($self->htmltext); | |
96 | # end wxGlade | |
97 | } | |
98 | ||
99 | ||
100 | sub OnSave { | |
101 | my ($self, $event) = @_; | |
102 | # wxGlade: EB::Wx::Shell::HtmlViewer::OnSave <event_handler> | |
103 | my $d = Wx::FileDialog->new($self, "Save as...", | |
104 | "", "wxeb.html", | |
105 | "HTML files (*.html)|*.html", | |
106 | wxSAVE | wxOVERWRITE_PROMPT); | |
107 | my $result = $d->ShowModal; | |
108 | if ( $result == wxID_OK ) { | |
109 | my $file = $d->GetPath; | |
110 | open(my $fd, ">", $file); | |
111 | print { $fd } $self->htmltext; | |
112 | close($fd); | |
113 | } | |
114 | # end wxGlade | |
115 | } | |
116 | ||
117 | ||
118 | sub OnClose { | |
119 | my ($self, $event) = @_; | |
120 | # wxGlade: EB::Wx::Shell::HtmlViewer::OnClose <event_handler> | |
121 | $self->Show(0); | |
122 | # end wxGlade | |
123 | } | |
124 | ||
125 | ||
126 | # end of class EB::Wx::Shell::HtmlViewer | |
127 | ||
128 | 1; | |
129 |
0 | #! perl -- -*- coding: utf-8 -*- | |
1 | ||
2 | use utf8; | |
3 | ||
4 | # RCS Id : $Id: Main.pm,v 1.2 2009/12/19 14:09:06 jv Exp $ | |
5 | # Author : Johan Vromans | |
6 | # Created On : Sun Jul 31 23:35:10 2005 | |
7 | # Last Modified By: Johan Vromans | |
8 | # Last Modified On: Sat Dec 19 14:19:28 2009 | |
9 | # Update Count : 390 | |
10 | # Status : Unknown, Use with caution! | |
11 | ||
12 | ################ Common stuff ################ | |
13 | ||
14 | package main; | |
15 | ||
16 | our $cfg; | |
17 | our $app; | |
18 | use EB::Wx::FakeApp; | |
19 | ||
20 | package EB::Wx::Shell::Main; | |
21 | ||
22 | use strict; | |
23 | use warnings; | |
24 | ||
25 | use EekBoek; | |
26 | use EB; | |
27 | use EB::Config (); | |
28 | use Getopt::Long 2.13; | |
29 | ||
30 | ################ The Process ################ | |
31 | ||
32 | use Wx 0.74 qw[:everything]; | |
33 | use Wx::Locale; | |
34 | #use File::Basename (); | |
35 | ||
36 | my $app_dir; | |
37 | ||
38 | use base qw(Wx::App); | |
39 | ||
40 | sub OnInit { | |
41 | my( $self ) = shift; | |
42 | ||
43 | ||
44 | return 1; | |
45 | } | |
46 | ||
47 | ################ Run ################ | |
48 | ||
49 | sub run { | |
50 | ||
51 | my ( $pkg, $opts ) = @_; | |
52 | $opts = {} unless defined $opts; | |
53 | ||
54 | binmode(STDOUT, ":encoding(utf8)"); | |
55 | binmode(STDERR, ":encoding(utf8)"); | |
56 | ||
57 | # Command line options. | |
58 | $opts = | |
59 | { | |
60 | #config, # config file | |
61 | #nostdconf, # skip standard configs | |
62 | #define, # config overrides | |
63 | ||
64 | verbose => 0, # verbose processing | |
65 | ||
66 | # Development options (not shown with -help). | |
67 | debug => 0, # debugging | |
68 | trace => 0, # trace (show process) | |
69 | test => 0, # test mode. | |
70 | ||
71 | # Let supplied options override. | |
72 | %$opts, | |
73 | }; | |
74 | ||
75 | # Process command line options. | |
76 | app_options($opts); | |
77 | ||
78 | # Post-processing. | |
79 | $opts->{trace} |= ($opts->{debug} || $opts->{test}); | |
80 | ||
81 | # Initialize config. | |
82 | EB::Config->init_config( { app => $EekBoek::PACKAGE, %$opts } ); | |
83 | ||
84 | if ( $opts->{printconfig} ) { | |
85 | $cfg->printconf( \@ARGV ); | |
86 | exit; | |
87 | } | |
88 | ||
89 | $app_dir = $cfg->user_dir; | |
90 | mkdir($app_dir) unless -d $app_dir; | |
91 | ||
92 | Wx::InitAllImageHandlers(); | |
93 | ||
94 | #### WHAT THE ***** IS GOING ON HERE???? | |
95 | *Fcntl::O_NOINHERIT = sub() { 0 }; | |
96 | *Fcntl::O_EXLOCK = sub() { 0 }; | |
97 | *Fcntl::O_TEMPORARY = sub() { 0 }; | |
98 | ||
99 | if ( !$opts->{nowizard} | |
100 | && !$opts->{config} | |
101 | && ( -e ".eekboek.conf" ? $cfg->val( qw(general wizard), 0 ) : 1 ) | |
102 | ) { | |
103 | require EB::Wx::IniWiz; | |
104 | EB::Wx::IniWiz->run($opts); # sets $opts->{runeb} | |
105 | return unless $opts->{runeb}; | |
106 | undef $cfg; | |
107 | EB::Config->init_config( { app => $EekBoek::PACKAGE, %$opts } ); | |
108 | } | |
109 | ||
110 | my $app = EB::Wx::Shell::Main->new(); | |
111 | ||
112 | my $locale = Wx::Locale->new( Wx::Locale::GetSystemLanguage ); | |
113 | ||
114 | if ( my $prefix = findlib("mo") ) { | |
115 | $locale->AddCatalogLookupPathPrefix($prefix); | |
116 | } | |
117 | $locale->AddCatalog("ebwxshell"); | |
118 | my $histfile = $cfg->user_dir("history"); | |
119 | ||
120 | require EB::Wx::Shell::MainFrame; | |
121 | my $frame = EB::Wx::Shell::MainFrame->new | |
122 | (undef, undef, $EekBoek::PACKAGE, | |
123 | wxDefaultPosition, wxDefaultSize, | |
124 | undef, | |
125 | $EekBoek::PACKAGE); | |
126 | ||
127 | my $config = $opts->{config} || $cfg->std_config; | |
128 | $frame->{_ebcfg} = $config if $config && -s $config; | |
129 | $frame->FillHistory($histfile); | |
130 | ||
131 | $app->SetTopWindow($frame); | |
132 | $frame->Show(1); | |
133 | $frame->RunCommand(undef); | |
134 | $app->MainLoop(); | |
135 | } | |
136 | ||
137 | # Since Wx::Bitmap cannot be convinced to use a search path, we | |
138 | # need a stronger method... | |
139 | my $wxbitmapnew = \&Wx::Bitmap::new; | |
140 | no warnings 'redefine'; | |
141 | *Wx::Bitmap::new = sub { | |
142 | # Only handle Wx::Bitmap->new(file, type) case. | |
143 | goto &$wxbitmapnew if @_ != 3 || -f $_[1]; | |
144 | my ($self, @rest) = @_; | |
145 | $rest[0] = EB::findlib("Wx/icons/".File::Basename::basename($rest[0])); | |
146 | $wxbitmapnew->($self, @rest); | |
147 | }; | |
148 | use warnings 'redefine'; | |
149 | ||
150 | ################ Subroutines ################ | |
151 | ||
152 | sub app_options { | |
153 | my ( $opts ) = @_; | |
154 | my $help = 0; # handled locally | |
155 | my $ident = 0; # handled locally | |
156 | ||
157 | # Process options, if any. | |
158 | # Make sure defaults are set before returning! | |
159 | return unless @ARGV > 0; | |
160 | ||
161 | Getopt::Long::Configure(qw(no_ignore_case)); | |
162 | ||
163 | if ( !GetOptions( $opts, | |
164 | 'define|D=s%', | |
165 | 'nostdconf|X', | |
166 | 'config|f=s', | |
167 | 'admdir=s', | |
168 | 'open=s', | |
169 | 'nowizard|no-wizard|nw', | |
170 | 'printconfig|P', | |
171 | 'ident' => \$ident, | |
172 | 'verbose', | |
173 | 'trace!', | |
174 | 'help|?', | |
175 | 'debug', | |
176 | ) or $help ) | |
177 | { | |
178 | app_usage(2); | |
179 | } | |
180 | app_usage(2) if @ARGV && !$opts->{printconfig}; | |
181 | app_ident() if $ident; | |
182 | } | |
183 | ||
184 | sub app_ident { | |
185 | return; | |
186 | print STDERR (__x("Dit is {pkg} [{name} {version}]", | |
187 | pkg => $EekBoek::PACKAGE, | |
188 | name => "WxShell", | |
189 | version => $EekBoek::VERSION) . "\n"); | |
190 | } | |
191 | ||
192 | sub app_usage { | |
193 | my ($exit) = @_; | |
194 | app_ident(); | |
195 | warn <<EndOfUsage; | |
196 | Gebruik: {prog} [options] [file ...] | |
197 | ||
198 | --config=XXX -f specificeer configuratiebestand | |
199 | --nostdconf -X gebruik uitsluitend dit configuratiebestand | |
200 | --define=XXX -D definieer configuratiesetting | |
201 | --printconfig -P print config waarden | |
202 | --admdir=XXX directory voor de config files | |
203 | --help deze hulpboodschap | |
204 | --ident toon identificatie | |
205 | --verbose geef meer uitgebreide information | |
206 | EndOfUsage | |
207 | CORE::exit $exit if defined $exit && $exit != 0; | |
208 | } | |
209 | ||
210 | 1; |
0 | # generated by wxGlade 0.5cvs on Fri Aug 3 21:56:01 2007 from /home/jv/src/eekboek/src/wxeb/wxeb.wxg | |
1 | # To get wxPerl visit http://wxPerl.sourceforge.net/ | |
2 | ||
3 | use Wx 0.15 qw[:allclasses]; | |
4 | use strict; | |
5 | ||
6 | package EB::Wx::Shell::MainFrame; | |
7 | ||
8 | use EekBoek; | |
9 | use Wx qw[:everything]; | |
10 | use base qw(Wx::Frame); | |
11 | use strict; | |
12 | use utf8; | |
13 | ||
14 | # begin wxGlade: ::dependencies | |
15 | use Wx::Locale gettext => '_T'; | |
16 | # end wxGlade | |
17 | ||
18 | use EB::Wx::Shell::HtmlViewer; | |
19 | use EB::Wx::Shell::PreferencesDialog; | |
20 | use Wx::Perl::ProcessStream qw[:everything]; | |
21 | ||
22 | sub new { | |
23 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
24 | $parent = undef unless defined $parent; | |
25 | $id = -1 unless defined $id; | |
26 | $title = "" unless defined $title; | |
27 | $pos = wxDefaultPosition unless defined $pos; | |
28 | $size = wxDefaultSize unless defined $size; | |
29 | $name = "" unless defined $name; | |
30 | ||
31 | # begin wxGlade: EB::Wx::Shell::MainFrame::new | |
32 | ||
33 | $style = wxDEFAULT_FRAME_STYLE | |
34 | unless defined $style; | |
35 | ||
36 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
37 | $self->{s_input_staticbox} = Wx::StaticBox->new($self, -1, _T("Input") ); | |
38 | ||
39 | ||
40 | # Menu Bar | |
41 | ||
42 | $self->{menubar} = Wx::MenuBar->new(); | |
43 | use constant MENU_REP_TRIAL => Wx::NewId(); | |
44 | use constant MENU_REP_BAL => Wx::NewId(); | |
45 | use constant MENU_REP_RES => Wx::NewId(); | |
46 | use constant MENU_REP_JNL => Wx::NewId(); | |
47 | use constant MENU_REP_UN => Wx::NewId(); | |
48 | use constant MENU_REP_AP => Wx::NewId(); | |
49 | use constant MENU_REP_AR => Wx::NewId(); | |
50 | my $wxglade_tmp_menu; | |
51 | $wxglade_tmp_menu = Wx::Menu->new(); | |
52 | $wxglade_tmp_menu->Append(wxID_OPEN, _T("&Open\tCtrl-O"), ""); | |
53 | $wxglade_tmp_menu->AppendSeparator(); | |
54 | $wxglade_tmp_menu->Append(wxID_PREFERENCES, _T("Prefere&nces..."), ""); | |
55 | $wxglade_tmp_menu->AppendSeparator(); | |
56 | $wxglade_tmp_menu->Append(wxID_EXIT, _T("E&xit\tCtrl-Q"), ""); | |
57 | $self->{_T("menubar")}->Append($wxglade_tmp_menu, _T("&File")); | |
58 | $wxglade_tmp_menu = Wx::Menu->new(); | |
59 | $wxglade_tmp_menu->Append(wxID_CLEAR, _T("&Clear output"), ""); | |
60 | $self->{_T("menubar")}->Append($wxglade_tmp_menu, _T("&Edit")); | |
61 | $self->{_T("Reports")} = Wx::Menu->new(); | |
62 | $self->{_T("Reports")}->Append(MENU_REP_TRIAL, _T("&Trial"), ""); | |
63 | $self->{_T("Reports")}->Append(MENU_REP_BAL, _T("&Balance"), ""); | |
64 | $self->{_T("Reports")}->Append(MENU_REP_RES, _T("&Results"), ""); | |
65 | $self->{_T("Reports")}->AppendSeparator(); | |
66 | $self->{_T("Reports")}->Append(MENU_REP_JNL, _T("&Journal"), ""); | |
67 | $self->{_T("Reports")}->AppendSeparator(); | |
68 | $self->{_T("Reports")}->Append(MENU_REP_UN, _T("&Unsettled Accounts"), ""); | |
69 | $self->{_T("Reports")}->AppendSeparator(); | |
70 | $self->{_T("Reports")}->Append(MENU_REP_AP, _T("Accounts &Payable"), ""); | |
71 | $self->{_T("Reports")}->Append(MENU_REP_AR, _T("Accounts Re&ceivable"), ""); | |
72 | $self->{_T("menubar")}->Append($self->{_T("Reports")}, _T("&Reports")); | |
73 | $wxglade_tmp_menu = Wx::Menu->new(); | |
74 | $wxglade_tmp_menu->Append(wxID_ABOUT, _T("&About..."), ""); | |
75 | $self->{_T("menubar")}->Append($wxglade_tmp_menu, _T("&Help")); | |
76 | $self->SetMenuBar($self->{menubar}); | |
77 | ||
78 | # Menu Bar end | |
79 | ||
80 | $self->{statusbar} = $self->CreateStatusBar(1, wxST_SIZEGRIP); | |
81 | $self->{t_output} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL); | |
82 | $self->{t_input} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_PROCESS_TAB|wxHSCROLL); | |
83 | $self->{b_send} = Wx::Button->new($self, -1, _T("Send")); | |
84 | ||
85 | $self->__set_properties(); | |
86 | $self->__do_layout(); | |
87 | ||
88 | Wx::Event::EVT_MENU($self, wxID_OPEN, \&OnOpen); | |
89 | Wx::Event::EVT_MENU($self, wxID_PREFERENCES, \&OnPrefs); | |
90 | Wx::Event::EVT_MENU($self, wxID_EXIT, \&OnQuit); | |
91 | Wx::Event::EVT_MENU($self, wxID_CLEAR, \&OnClear); | |
92 | Wx::Event::EVT_MENU($self, MENU_REP_TRIAL, \&OnTrial); | |
93 | Wx::Event::EVT_MENU($self, MENU_REP_BAL, \&OnMenuBal); | |
94 | Wx::Event::EVT_MENU($self, MENU_REP_RES, \&OnMenuRes); | |
95 | Wx::Event::EVT_MENU($self, MENU_REP_JNL, \&OnJournal); | |
96 | Wx::Event::EVT_MENU($self, MENU_REP_UN, \&OnMenuUns); | |
97 | Wx::Event::EVT_MENU($self, MENU_REP_AP, \&OnMenuAP); | |
98 | Wx::Event::EVT_MENU($self, MENU_REP_AR, \&OnMenuAR); | |
99 | Wx::Event::EVT_MENU($self, wxID_ABOUT, \&OnAbout); | |
100 | Wx::Event::EVT_TEXT_ENTER($self, $self->{t_input}->GetId, \&OnTextEnter); | |
101 | Wx::Event::EVT_BUTTON($self, $self->{b_send}->GetId, \&OnSend); | |
102 | ||
103 | # end wxGlade | |
104 | ||
105 | Wx::Event::EVT_CHAR($self->{t_input}, sub { $self->OnChar(@_) }); | |
106 | # Wx::Event::EVT_IDLE($self, \&OnIdle); | |
107 | ||
108 | EVT_WXP_PROCESS_STREAM_STDOUT( $self, \&evt_process_stdout); | |
109 | EVT_WXP_PROCESS_STREAM_STDERR( $self, \&evt_process_stderr); | |
110 | EVT_WXP_PROCESS_STREAM_EXIT( $self, \&evt_process_exit); | |
111 | ||
112 | return $self; | |
113 | ||
114 | } | |
115 | ||
116 | ||
117 | sub __set_properties { | |
118 | my $self = shift; | |
119 | ||
120 | # begin wxGlade: EB::Wx::Shell::MainFrame::__set_properties | |
121 | ||
122 | $self->SetTitle(_T("EekBoek")); | |
123 | $self->SetSize(Wx::Size->new(800, 550)); | |
124 | $self->{statusbar}->SetStatusWidths(-1); | |
125 | ||
126 | my( @statusbar_fields ) = ( | |
127 | "" | |
128 | ); | |
129 | ||
130 | if( @statusbar_fields ) { | |
131 | $self->{statusbar}->SetStatusText($statusbar_fields[$_], $_) | |
132 | for 0 .. $#statusbar_fields ; | |
133 | } | |
134 | $self->{t_input}->SetFocus(); | |
135 | ||
136 | # end wxGlade | |
137 | ||
138 | my $f = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); | |
139 | $self->{t_output}->SetFont(Wx::Font->new($f->GetPointSize, wxMODERN, wxNORMAL, wxNORMAL, 0, "")); | |
140 | ||
141 | } | |
142 | ||
143 | sub __do_layout { | |
144 | my $self = shift; | |
145 | ||
146 | # begin wxGlade: EB::Wx::Shell::MainFrame::__do_layout | |
147 | ||
148 | $self->{s_main} = Wx::BoxSizer->new(wxVERTICAL); | |
149 | $self->{s_layout} = Wx::BoxSizer->new(wxVERTICAL); | |
150 | $self->{s_input}= Wx::StaticBoxSizer->new($self->{s_input_staticbox}, wxHORIZONTAL); | |
151 | $self->{s_output} = Wx::BoxSizer->new(wxHORIZONTAL); | |
152 | $self->{s_output}->Add($self->{t_output}, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
153 | $self->{s_layout}->Add($self->{s_output}, 1, wxEXPAND, 0); | |
154 | $self->{s_input}->Add($self->{t_input}, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
155 | $self->{s_input}->Add(5, 1, 0, wxADJUST_MINSIZE, 0); | |
156 | $self->{s_input}->Add($self->{b_send}, 0, wxADJUST_MINSIZE, 0); | |
157 | $self->{s_layout}->Add($self->{s_input}, 0, wxEXPAND, 0); | |
158 | $self->{s_main}->Add($self->{s_layout}, 1, wxALL|wxEXPAND, 5); | |
159 | $self->SetSizer($self->{s_main}); | |
160 | $self->Layout(); | |
161 | $self->SetSize(Wx::Size->new(800, 550)); | |
162 | ||
163 | # end wxGlade | |
164 | } | |
165 | ||
166 | sub RunCommand { | |
167 | my ($self, $cmd) = @_; | |
168 | unless ( defined $self->{_proc} ) { | |
169 | unless ( $self->{_ebcfg} && -s $self->{_ebcfg} ) { | |
170 | my $md = Wx::MessageDialog->new | |
171 | ($self, | |
172 | _T("Please select a valid .eekboek.conf first"), | |
173 | _T("Missing config"), wxOK|wxICON_INFORMATION, | |
174 | wxDefaultPosition); | |
175 | $md->ShowModal; | |
176 | $md->Destroy; | |
177 | $self->OnOpen; | |
178 | return; | |
179 | } | |
180 | my @eb = qw(ebshell --nointeractive); | |
181 | push(@eb, "-f", $self->{_ebcfg}) if $self->{_ebcfg}; | |
182 | $self->{_proc} = | |
183 | Wx::Perl::ProcessStream->OpenProcess(\@eb, 'EekBoek', $self); | |
184 | $self->{_pid} = $self->{_proc}->GetProcessId; | |
185 | warn("STARTED: @eb\n"); | |
186 | } | |
187 | ||
188 | $cmd = "database" unless defined $cmd; | |
189 | $self->{t_output}->AppendText("eb> "); | |
190 | $self->ShowText($cmd, wxBLUE); | |
191 | if ( $cmd =~ /^(balans|result|proefensaldibalans|journaal|openstaand|(?:deb|cred)iteuren)(?:\s|$)/ ) { | |
192 | $cmd .= " --gen-wxhtml"; | |
193 | } | |
194 | $self->{_proc}->WriteProcess($cmd."\n"); | |
195 | } | |
196 | ||
197 | sub ShowText { | |
198 | my ($self, $text, $colour) = @_; | |
199 | if ( $colour ) { | |
200 | my $t = Wx::TextAttr->new; | |
201 | $t->SetTextColour($colour); | |
202 | my $x0 = $self->{t_output}->GetLastPosition; | |
203 | $self->{t_output}->AppendText($text."\n"); | |
204 | $self->{t_output}->SetStyle($x0, $self->{t_output}->GetLastPosition, $t); | |
205 | } | |
206 | else { | |
207 | $self->{t_output}->AppendText($text."\n"); | |
208 | } | |
209 | } | |
210 | ||
211 | my $capturing; | |
212 | sub evt_process_stdout { | |
213 | my ($self, $event) = @_; | |
214 | #$event->Skip(1); | |
215 | my $out = $event->GetLine; | |
216 | # warn("app: $out\n"); | |
217 | if ( $capturing || $out eq "<html>" ) { | |
218 | $capturing .= $out . "\n"; | |
219 | if ( $out eq "</html>" ) { | |
220 | my ($title) = ($capturing =~ m{<title>(.+?)</title>}); | |
221 | #warn("captured $title: ", length($capturing), " characters\n"); | |
222 | my $panel = $self->{pr_repwin} ? "d_htmlpanel" : "d_htmlpanel_$title"; | |
223 | $self->{$panel} ||= EB::Wx::Shell::HtmlViewer->new | |
224 | ($self, -1, $title); | |
225 | $self->{$panel}->html->SetPage($capturing); | |
226 | $self->{$panel}->htmltext = $capturing; | |
227 | $self->{$panel}->SetTitle($title); | |
228 | $self->{$panel}->Show(1); | |
229 | $capturing = ""; | |
230 | } | |
231 | } | |
232 | else { | |
233 | $self->{t_output}->AppendText($out."\n"); | |
234 | } | |
235 | } | |
236 | ||
237 | sub evt_process_stderr { | |
238 | my ($self, $event) = @_; | |
239 | #$event->Skip(1); | |
240 | my $out = $event->GetLine; | |
241 | $self->ProcessMessages($out); | |
242 | } | |
243 | ||
244 | sub evt_process_exit { | |
245 | my ($self, $event) = @_; | |
246 | #$event->Skip(1); | |
247 | my $process = $event->GetProcess; | |
248 | my $pid = $process->GetProcessId; | |
249 | #my $line = $event->GetLine; | |
250 | #my @buffers = @{ $process->GetStdOutBuffer }; | |
251 | #my @errors = @{ $process->GetStdOutBuffer }; | |
252 | #my $exitcode = $process->GetExitCode; | |
253 | return if $self->{_pid} && $self->{_pid} != $pid; | |
254 | $process->Destroy; | |
255 | my $md = Wx::MessageDialog->new | |
256 | ($self, | |
257 | _T("EekBoek program has finished"), | |
258 | _T("Finished"), wxOK|wxICON_INFORMATION, | |
259 | wxDefaultPosition); | |
260 | $md->ShowModal; | |
261 | $md->Destroy; | |
262 | $self->OnQuit; | |
263 | } | |
264 | ||
265 | sub ProcessMessages { | |
266 | my ($self, $err) = @_; | |
267 | return unless $err; | |
268 | my @err = split(/\n+/, $err); | |
269 | while ( @err ) { | |
270 | $err = shift(@err); | |
271 | if ( $err =~ /^(EekBoek\s+([0-9.]+).*)/ ) { | |
272 | $self->{statusbar}->SetStatusText($1, 0); | |
273 | $self->{_eb} = $2; | |
274 | next; | |
275 | } | |
276 | my @i; | |
277 | if ( $err =~ /^\?+(.*)/ ) { | |
278 | $self->ShowText($err, wxRED); | |
279 | @i = ($1, "Error", wxOK|wxICON_ERROR); | |
280 | } | |
281 | elsif ( $err =~ /^\!+(.*)/ ) { | |
282 | $self->ShowText($err, Wx::Colour->new("magenta")); | |
283 | @i = ($1, "Warning", wxOK|wxICON_WARNING); | |
284 | } | |
285 | else { | |
286 | $self->ShowText($err, wxGREEN); | |
287 | @i = ($err, "Information", wxOK|wxICON_INFORMATION); | |
288 | } | |
289 | my $md = Wx::MessageDialog->new($self, @i, wxDefaultPosition); | |
290 | $md->ShowModal; | |
291 | $md->Destroy; | |
292 | } | |
293 | } | |
294 | ||
295 | ||
296 | sub OnTextEnter { | |
297 | my ($self, $event) = @_; | |
298 | # wxGlade: EB::Wx::Shell::MainFrame::OnTextEnter <event_handler> | |
299 | ||
300 | my $cmd = $self->{t_input}->GetValue; | |
301 | return unless $cmd; | |
302 | push(@{$self->{_cmd}}, $cmd) | |
303 | unless $cmd eq $self->{_cmd}->[-1]; | |
304 | $self->{_cmdptr} = $#{$self->{_cmd}} + 1; | |
305 | $self->{t_input}->SetValue(""); | |
306 | $self->RunCommand($cmd); | |
307 | $self->{t_input}->SetFocus(); | |
308 | ||
309 | # end wxGlade | |
310 | } | |
311 | ||
312 | sub OnSend { | |
313 | my ($self, $event) = @_; | |
314 | # wxGlade: EB::Wx::Shell::MainFrame::OnSend <event_handler> | |
315 | ||
316 | &OnTextEnter; | |
317 | ||
318 | # end wxGlade | |
319 | } | |
320 | ||
321 | sub OnOpen { | |
322 | my ($self, $event) = @_; | |
323 | # wxGlade: EB::Wx::Shell::MainFrame::OnOpen <event_handler> | |
324 | ||
325 | my $fd = Wx::FileDialog->new | |
326 | ($self, | |
327 | _T("Choose"), | |
328 | "", "", | |
329 | ".eekboek.conf", | |
330 | 0|wxFD_FILE_MUST_EXIST, | |
331 | wxDefaultPosition); | |
332 | my $ret = $fd->ShowModal; | |
333 | if ( $ret == wxID_OK ) { | |
334 | if ( $self->{_proc} ) { | |
335 | $self->{_proc}->TerminateProcess; | |
336 | undef $self->{_proc}; | |
337 | undef $self->{_pid}; | |
338 | } | |
339 | $self->{_ebcfg} = $fd->GetPath; | |
340 | $self->RunCommand(undef); | |
341 | } | |
342 | $fd->Destroy; | |
343 | ||
344 | # end wxGlade | |
345 | } | |
346 | ||
347 | sub OnQuit { | |
348 | my ($self, $event) = @_; | |
349 | # wxGlade: EB::Wx::Shell::MainFrame::OnQuit <event_handler> | |
350 | $self->SaveHistory; | |
351 | $self->Destroy; | |
352 | ||
353 | # end wxGlade | |
354 | } | |
355 | ||
356 | sub PutOnHistory { | |
357 | my ($self, $cmd) = @_; | |
358 | return if $cmd eq ""; | |
359 | return if @{$self->{_cmd}} && $cmd eq $self->{_cmd}->[-1]; | |
360 | ||
361 | return if exists $self->{_cmd}->[$self->{_cmdptr}] | |
362 | && $cmd eq $self->{_cmd}->[$self->{_cmdptr}]; | |
363 | ||
364 | push(@{$self->{_cmd}}, $cmd); | |
365 | } | |
366 | ||
367 | use Wx qw(:keycode); | |
368 | ||
369 | sub OnChar { | |
370 | my ($self, $ctl, $event) = @_; | |
371 | ||
372 | # Get key code and char, if ordinary. | |
373 | my $k = $event->GetKeyCode; | |
374 | my $c = ($k < WXK_START) ? pack("C", $k) : ""; | |
375 | ||
376 | if ( $k == WXK_UP | |
377 | && $self->{_cmdptr} > 0 ) { | |
378 | $self->PutOnHistory($ctl->GetValue); | |
379 | $ctl->SetValue($self->{_cmd}->[--$self->{_cmdptr}]); | |
380 | $ctl->SetInsertionPointEnd; | |
381 | } | |
382 | elsif ( $k == WXK_DOWN | |
383 | && $self->{_cmdptr} < $#{$self->{_cmd}} ) { | |
384 | $self->PutOnHistory($ctl->GetValue); | |
385 | $ctl->SetValue($self->{_cmd}->[++$self->{_cmdptr}]); | |
386 | $ctl->SetInsertionPointEnd; | |
387 | } | |
388 | elsif ( | |
389 | $k == WXK_TAB || | |
390 | $k == WXK_RETURN || | |
391 | $k >= WXK_START || | |
392 | $event->HasModifiers | |
393 | ) { | |
394 | # Common controls. | |
395 | $event->Skip; | |
396 | return; | |
397 | } | |
398 | else { | |
399 | $event->Skip; | |
400 | } | |
401 | } | |
402 | ||
403 | ||
404 | sub OnAbout { | |
405 | my ($self, $event) = @_; | |
406 | # wxGlade: EB::Wx::Shell::MainFrame::OnAbout <event_handler> | |
407 | ||
408 | my $year = 1900 + (localtime(time))[5]; | |
409 | ||
410 | my $md = Wx::MessageDialog->new | |
411 | ($self, | |
412 | "$EekBoek::PACKAGE WxShell version $EekBoek::VERSION\n". | |
413 | "Copyright 2007-$year Squirrel Consultancy\n\n". | |
414 | "Written by Johan Vromans\n". | |
415 | "<jvromans\@squirrel.nl>\n". | |
416 | "http://www.squirrel.nl\n\n". | |
417 | "GUI design with wxGlade, http://wxglade.sourceforge.net\n\n". | |
418 | "Perl version ".sprintf("%vd",$^V)."\n". | |
419 | "WxPerl version $Wx::VERSION\n". | |
420 | "wxWidgets version ".Wx::wxVERSION."\n", | |
421 | "About EekBoek WxShell", | |
422 | wxOK|wxICON_INFORMATION, | |
423 | wxDefaultPosition); | |
424 | $md->ShowModal; | |
425 | $md->Destroy; | |
426 | ||
427 | # end wxGlade | |
428 | } | |
429 | ||
430 | ||
431 | sub OnClear { | |
432 | my ($self, $event) = @_; | |
433 | # wxGlade: EB::Wx::Shell::MainFrame::OnClear <event_handler> | |
434 | ||
435 | $self->{t_output}->SetValue(""); | |
436 | ||
437 | # end wxGlade | |
438 | } | |
439 | ||
440 | ||
441 | sub OnPrefs { | |
442 | my ($self, $event) = @_; | |
443 | # wxGlade: EB::Wx::Shell::MainFrame::OnPrefs <event_handler> | |
444 | $self->{d_prefs} ||= EB::Wx::Shell::PreferencesDialog->new($self, -1, "Preferences"); | |
445 | $self->{d_prefs}->Show(1); | |
446 | # end wxGlade | |
447 | } | |
448 | ||
449 | ||
450 | sub FillHistory { | |
451 | my ($self, $histfile) = @_; | |
452 | $self->{_histfile} = $histfile; | |
453 | $self->{_cmd} = []; | |
454 | $self->{_cmdptr} = 0; | |
455 | if ( -s $histfile ) { | |
456 | my $fh; | |
457 | return unless open($fh, "<", $histfile); | |
458 | while ( <$fh> ) { | |
459 | chomp; | |
460 | $self->PutOnHistory($_); | |
461 | } | |
462 | close($fh); | |
463 | } | |
464 | $self->{_cmdinit} = $self->{_cmdptr} = $#{$self->{_cmd}} + 1; | |
465 | } | |
466 | ||
467 | ||
468 | sub SaveHistory { | |
469 | my $self = shift; | |
470 | my $fh; | |
471 | my $histfile = $self->{_histfile}; | |
472 | return unless open($fh, ">>", $histfile); | |
473 | while ( $self->{_cmdinit} < $self->{_cmdptr} ) { | |
474 | print { $fh } ($self->{_cmd}->[$self->{_cmdinit}], "\n"); | |
475 | $self->{_cmdinit}++; | |
476 | } | |
477 | close($fh); | |
478 | } | |
479 | ||
480 | ||
481 | sub OnMenuBal { | |
482 | my ($self, $event) = @_; | |
483 | # wxGlade: EB::Wx::Shell::MainFrame::OnMenuBal <event_handler> | |
484 | ||
485 | $self->{_proc}->WriteProcess("balans --gen-wxhtml\n"); | |
486 | ||
487 | # end wxGlade | |
488 | } | |
489 | ||
490 | ||
491 | sub OnMenuRes { | |
492 | my ($self, $event) = @_; | |
493 | # wxGlade: EB::Wx::Shell::MainFrame::OnMenuRes <event_handler> | |
494 | ||
495 | $self->{_proc}->WriteProcess("result --gen-wxhtml\n"); | |
496 | ||
497 | # end wxGlade | |
498 | } | |
499 | ||
500 | ||
501 | sub OnMenuAP { | |
502 | my ($self, $event) = @_; | |
503 | # wxGlade: EB::Wx::Shell::MainFrame::OnMenuAP <event_handler> | |
504 | ||
505 | $self->{_proc}->WriteProcess("crediteuren --gen-wxhtml\n"); | |
506 | ||
507 | # end wxGlade | |
508 | } | |
509 | ||
510 | ||
511 | sub OnMenuAR { | |
512 | my ($self, $event) = @_; | |
513 | # wxGlade: EB::Wx::Shell::MainFrame::OnMenuAR <event_handler> | |
514 | ||
515 | $self->{_proc}->WriteProcess("debiteuren --gen-wxhtml\n"); | |
516 | ||
517 | # end wxGlade | |
518 | } | |
519 | ||
520 | ||
521 | sub OnMenuUns { | |
522 | my ($self, $event) = @_; | |
523 | # wxGlade: EB::Wx::Shell::MainFrame::OnMenuUns <event_handler> | |
524 | ||
525 | $self->{_proc}->WriteProcess("openstaand --gen-wxhtml\n"); | |
526 | ||
527 | # end wxGlade | |
528 | } | |
529 | ||
530 | ||
531 | sub OnTrial { | |
532 | my ($self, $event) = @_; | |
533 | # wxGlade: EB::Wx::Shell::MainFrame::OnTrial <event_handler> | |
534 | ||
535 | $self->{_proc}->WriteProcess("proefensaldibalans --gen-wxhtml\n"); | |
536 | ||
537 | # end wxGlade | |
538 | } | |
539 | ||
540 | ||
541 | sub OnJournal { | |
542 | my ($self, $event) = @_; | |
543 | # wxGlade: EB::Wx::Shell::MainFrame::OnJournal <event_handler> | |
544 | ||
545 | $self->{_proc}->WriteProcess("journaal --gen-wxhtml\n"); | |
546 | ||
547 | # end wxGlade | |
548 | } | |
549 | ||
550 | # end of class EB::Wx::Shell::MainFrame | |
551 | ||
552 | 1; | |
553 |
0 | # generated by wxGlade 0.5.1cvs on Fri Aug 3 23:18:33 2007 from /home/jv/src/eekboek/src/wxeb/wxeb.wxg | |
1 | # To get wxPerl visit http://wxPerl.sourceforge.net/ | |
2 | ||
3 | use Wx 0.15 qw[:allclasses]; | |
4 | use strict; | |
5 | package EB::Wx::Shell::PreferencesDialog; | |
6 | ||
7 | use Wx qw[:everything]; | |
8 | use base qw(Wx::Dialog); | |
9 | use strict; | |
10 | ||
11 | # begin wxGlade: ::dependencies | |
12 | use Wx::Locale gettext => '_T'; | |
13 | # end wxGlade | |
14 | ||
15 | sub new { | |
16 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
17 | $parent = undef unless defined $parent; | |
18 | $id = -1 unless defined $id; | |
19 | $title = "" unless defined $title; | |
20 | $pos = wxDefaultPosition unless defined $pos; | |
21 | $size = wxDefaultSize unless defined $size; | |
22 | $name = "" unless defined $name; | |
23 | ||
24 | # begin wxGlade: EB::Wx::Shell::PreferencesDialog::new | |
25 | ||
26 | $style = wxDEFAULT_DIALOG_STYLE | |
27 | unless defined $style; | |
28 | ||
29 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
30 | $self->{sz_prefs_inner_staticbox} = Wx::StaticBox->new($self, -1, _T("Preferences") ); | |
31 | $self->{cx_repwin} = Wx::CheckBox->new($self, -1, _T("Single window for reports"), wxDefaultPosition, wxDefaultSize, ); | |
32 | $self->{b_prefs_cancel} = Wx::Button->new($self, wxID_CANCEL, ""); | |
33 | $self->{b_prefs_ok} = Wx::Button->new($self, wxID_OK, ""); | |
34 | ||
35 | $self->__set_properties(); | |
36 | $self->__do_layout(); | |
37 | ||
38 | Wx::Event::EVT_BUTTON($self, $self->{b_prefs_cancel}->GetId, \&OnCancel); | |
39 | Wx::Event::EVT_BUTTON($self, $self->{b_prefs_ok}->GetId, \&OnAccept); | |
40 | ||
41 | # end wxGlade | |
42 | return $self; | |
43 | ||
44 | } | |
45 | ||
46 | ||
47 | sub __set_properties { | |
48 | my $self = shift; | |
49 | ||
50 | # begin wxGlade: EB::Wx::Shell::PreferencesDialog::__set_properties | |
51 | ||
52 | $self->SetTitle(_T("Preferences")); | |
53 | $self->{b_prefs_ok}->SetDefault(); | |
54 | ||
55 | # end wxGlade | |
56 | } | |
57 | ||
58 | sub __do_layout { | |
59 | my $self = shift; | |
60 | ||
61 | # begin wxGlade: EB::Wx::Shell::PreferencesDialog::__do_layout | |
62 | ||
63 | $self->{sz_prefs_outer} = Wx::BoxSizer->new(wxVERTICAL); | |
64 | $self->{sz_prefs_buttons} = Wx::BoxSizer->new(wxHORIZONTAL); | |
65 | $self->{sz_prefs_inner}= Wx::StaticBoxSizer->new($self->{sz_prefs_inner_staticbox}, wxVERTICAL); | |
66 | $self->{sz_prefs} = Wx::BoxSizer->new(wxVERTICAL); | |
67 | $self->{sz_prefs}->Add($self->{cx_repwin}, 0, wxADJUST_MINSIZE, 0); | |
68 | $self->{sz_prefs}->Add(1, 5, 0, wxADJUST_MINSIZE, 0); | |
69 | $self->{sz_prefs_inner}->Add($self->{sz_prefs}, 1, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 5); | |
70 | $self->{sz_prefs_outer}->Add($self->{sz_prefs_inner}, 1, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 5); | |
71 | $self->{sz_prefs_buttons}->Add($self->{b_prefs_cancel}, 0, wxADJUST_MINSIZE, 0); | |
72 | $self->{sz_prefs_buttons}->Add(5, 1, 1, wxADJUST_MINSIZE, 0); | |
73 | $self->{sz_prefs_buttons}->Add($self->{b_prefs_ok}, 0, wxADJUST_MINSIZE, 0); | |
74 | $self->{sz_prefs_outer}->Add($self->{sz_prefs_buttons}, 0, wxALL|wxEXPAND, 5); | |
75 | $self->SetSizer($self->{sz_prefs_outer}); | |
76 | $self->{sz_prefs_outer}->Fit($self); | |
77 | $self->Layout(); | |
78 | ||
79 | # end wxGlade | |
80 | } | |
81 | ||
82 | sub OnCancel { | |
83 | my ($self, $event) = @_; | |
84 | # wxGlade: EB::Wx::Shell::PreferencesDialog::OnCancel <event_handler> | |
85 | $event->Skip; | |
86 | ||
87 | # end wxGlade | |
88 | } | |
89 | ||
90 | ||
91 | sub OnAccept { | |
92 | my ($self, $event) = @_; | |
93 | # wxGlade: EB::Wx::Shell::PreferencesDialog::OnAccept <event_handler> | |
94 | $self->GetParent->{pr_repwin} = $self->{cx_repwin}->GetValue; | |
95 | $event->Skip; | |
96 | ||
97 | # end wxGlade | |
98 | } | |
99 | ||
100 | ||
101 | # end of class EB::Wx::Shell::PreferencesDialog | |
102 | ||
103 | 1; | |
104 |
0 | #! perl | |
1 | ||
2 | # State.pm -- State persistency | |
3 | # RCS Info : $Id: State.pm,v 1.2 2009/10/14 21:14:02 jv Exp $ | |
4 | # Author : Johan Vromans | |
5 | # Created On : Fri Feb 15 22:48:51 2008 | |
6 | # Last Modified By: Johan Vromans | |
7 | # Last Modified On: Tue Oct 13 21:35:37 2009 | |
8 | # Update Count : 8 | |
9 | # Status : Unknown, Use with caution! | |
10 | ||
11 | package main; | |
12 | ||
13 | our $state; | |
14 | ||
15 | package EB::Wx::State; | |
16 | ||
17 | our $VERSION = sprintf "%d.%03d", q$Revision: 1.2 $ =~ /(\d+)/g; | |
18 | ||
19 | use strict; | |
20 | use warnings; | |
21 | use Data::Dumper; | |
22 | use Carp; | |
23 | ||
24 | sub new { | |
25 | my ($pkg) = @_; | |
26 | bless { state => {} }, $pkg; | |
27 | } | |
28 | ||
29 | sub set { | |
30 | my ($self, $key, $value) = @_; | |
31 | $self->{state}->{$key} = $value; | |
32 | } | |
33 | ||
34 | sub get { | |
35 | my ($self, $key) = @_; | |
36 | $self->{state}->{$key}; | |
37 | } | |
38 | ||
39 | sub newval { | |
40 | my ($self, $key, $value) = @_; | |
41 | $self->{state}->{$key} = $value; | |
42 | } | |
43 | ||
44 | sub load { | |
45 | my ($self, $file) = @_; | |
46 | my $state; | |
47 | open(my $fh, '<:encoding(utf-8)', $file) | |
48 | or croak("Loading state: $file: $!"); | |
49 | my $data = <$fh>; | |
50 | croak("Invalid state file: $file") | |
51 | unless $data =~ /^# EekBoek Wx State 1.00/; | |
52 | local $/; | |
53 | $data = <$fh>; | |
54 | close($fh); | |
55 | eval $data; | |
56 | croak("Invalid state data: $file\n$@") | |
57 | if $@; | |
58 | $self->{state} = $state; | |
59 | $self->{file} = $file; | |
60 | } | |
61 | ||
62 | sub store { | |
63 | my ($self, $file) = @_; | |
64 | $file = $self->{file} unless defined $file; | |
65 | open(my $fh, '>:encoding(utf-8)', $file) | |
66 | or carp("Saving state: $file: $!"); | |
67 | print { $fh } ("# EekBoek Wx State 1.00 -- DO NOT EDIT / NIET WIJZIGEN!\n\n"); | |
68 | local $Data::Dumper::Purity = 1; | |
69 | print { $fh } Data::Dumper->Dump([$self->{state}], ['state']); | |
70 | close($fh); | |
71 | } | |
72 | ||
73 | our $AUTOLOAD; | |
74 | sub AUTOLOAD { | |
75 | my ($self) = @_; | |
76 | my $key = $AUTOLOAD; | |
77 | ||
78 | # Remove the leading package name. | |
79 | $key =~ s/.*:://; | |
80 | ||
81 | # Ignore destructor. | |
82 | return if $key eq 'DESTROY'; | |
83 | ||
84 | if ( @_ > 1 ) { | |
85 | $self->{state}->{$key} = $_[1]; | |
86 | } | |
87 | else { | |
88 | $self->{state}->{$key}; | |
89 | } | |
90 | } | |
91 | ||
92 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: AboutDialog.pm,v 1.3 2009/10/28 22:11:31 jv Exp $ | |
3 | ||
4 | package EB::Wx::Tools::AboutDialog; | |
5 | ||
6 | use Wx qw[:everything]; | |
7 | use base qw(Wx::Dialog); | |
8 | use strict; | |
9 | ||
10 | sub new { | |
11 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
12 | $parent = undef unless defined $parent; | |
13 | $id = -1 unless defined $id; | |
14 | $title = "" unless defined $title; | |
15 | $pos = wxDefaultPosition unless defined $pos; | |
16 | $size = wxDefaultSize unless defined $size; | |
17 | $name = "" unless defined $name; | |
18 | ||
19 | # begin wxGlade: EB::Wx::Tools::AboutDialog::new | |
20 | ||
21 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTHICK_FRAME | |
22 | unless defined $style; | |
23 | ||
24 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
25 | $self->{bitmap_1} = Wx::StaticBitmap->new($self, -1, Wx::Bitmap->new("eb.jpg", wxBITMAP_TYPE_ANY), wxDefaultPosition, wxDefaultSize, ); | |
26 | $self->{p_html} = EB::Wx::Tools::AboutDialog::HtmlWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | |
27 | $self->{b_ok} = Wx::Button->new($self, wxID_OK, ""); | |
28 | ||
29 | $self->__set_properties(); | |
30 | $self->__do_layout(); | |
31 | ||
32 | # end wxGlade | |
33 | ||
34 | return $self; | |
35 | ||
36 | } | |
37 | ||
38 | sub __set_properties { | |
39 | my $self = shift; | |
40 | ||
41 | # begin wxGlade: EB::Wx::Tools::AboutDialog::__set_properties | |
42 | ||
43 | $self->SetTitle("Info"); | |
44 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(232, 136))); | |
45 | $self->SetBackgroundColour(Wx::Colour->new(255, 255, 255)); | |
46 | $self->{b_ok}->SetFocus(); | |
47 | ||
48 | # end wxGlade | |
49 | } | |
50 | ||
51 | sub __do_layout { | |
52 | my $self = shift; | |
53 | ||
54 | # begin wxGlade: EB::Wx::Tools::AboutDialog::__do_layout | |
55 | ||
56 | $self->{sizer_1} = Wx::BoxSizer->new(wxHORIZONTAL); | |
57 | $self->{sizer_2} = Wx::BoxSizer->new(wxVERTICAL); | |
58 | $self->{sizer_3} = Wx::BoxSizer->new(wxHORIZONTAL); | |
59 | $self->{sizer_4} = Wx::BoxSizer->new(wxHORIZONTAL); | |
60 | $self->{sizer_4}->Add($self->{bitmap_1}, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); | |
61 | $self->{sizer_4}->Add($self->{p_html}, 1, wxALL|wxEXPAND, 5); | |
62 | $self->{sizer_2}->Add($self->{sizer_4}, 1, wxEXPAND, 0); | |
63 | $self->{sizer_3}->Add(1, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
64 | $self->{sizer_3}->Add($self->{b_ok}, 0, wxALL|wxADJUST_MINSIZE, 5); | |
65 | $self->{sizer_3}->Add(1, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
66 | $self->{sizer_2}->Add($self->{sizer_3}, 0, wxEXPAND, 0); | |
67 | $self->{sizer_1}->Add($self->{sizer_2}, 1, wxEXPAND, 0); | |
68 | $self->SetSizer($self->{sizer_1}); | |
69 | $self->Layout(); | |
70 | ||
71 | # end wxGlade | |
72 | } | |
73 | ||
74 | # end of class EB::Wx::Tools::AboutDialog | |
75 | ||
76 | sub init { | |
77 | } | |
78 | ||
79 | sub refresh { | |
80 | my ($self) = @_; | |
81 | ||
82 | my $info = "<p>"; | |
83 | ||
84 | my $msg = $EB::imsg . "\n"; | |
85 | $info .= $msg . "</p>\n"; | |
86 | my $v = $Wx::VERSION; | |
87 | $v =~ s/,/./g; | |
88 | $info .= "<p>wxPerl versie $v<br>\n"; | |
89 | $info .= sprintf("Perl versie %vd<br>\n", $^V); | |
90 | $v = Wx::wxVERSION; | |
91 | $v =~ s/,/./g; | |
92 | $v = sprintf("%d.%d.%d", $1, $2, $3) if $v =~ /^(\d+)\.(\d\d\d)(\d\d\d)$/; | |
93 | $info .= "wxWidgets versie $v</p>\n"; | |
94 | $info .= "<p>Voor meer informatie: <a href='http://www.eekboek.nl'>http://www.eekboek.nl/</a></p>\n"; | |
95 | ||
96 | $self->{p_html}->SetPage($info); | |
97 | ||
98 | } | |
99 | ||
100 | package EB::Wx::Tools::AboutDialog::HtmlWindow; | |
101 | ||
102 | use strict; | |
103 | use Wx::Html; | |
104 | use base qw(Wx::HtmlWindow); | |
105 | ||
106 | sub OnLinkClicked { | |
107 | my ($self, $link ) = @_; | |
108 | ||
109 | Wx::LaunchDefaultBrowser($link->GetHref); | |
110 | ||
111 | } | |
112 | ||
113 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: PreferencesDialog.pm,v 1.3 2008/02/11 15:21:19 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $dbh; | |
8 | ||
9 | package EB::Wx::Tools::PreferencesDialog; | |
10 | ||
11 | use Wx qw[:everything]; | |
12 | use base qw(Wx::Dialog); | |
13 | use base qw(EB::Wx::Window); | |
14 | use strict; | |
15 | ||
16 | use Wx::Locale gettext => '_T'; | |
17 | sub new { | |
18 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
19 | $parent = undef unless defined $parent; | |
20 | $id = -1 unless defined $id; | |
21 | $title = "" unless defined $title; | |
22 | $pos = wxDefaultPosition unless defined $pos; | |
23 | $size = wxDefaultSize unless defined $size; | |
24 | $name = "" unless defined $name; | |
25 | ||
26 | # begin wxGlade: EB::Wx::Tools::PreferencesDialog::new | |
27 | ||
28 | $style = wxDEFAULT_DIALOG_STYLE | |
29 | unless defined $style; | |
30 | ||
31 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
32 | $self->{s_main_staticbox} = Wx::StaticBox->new($self, -1, _T("Voorkeursinstellingen") ); | |
33 | $self->{c_splash} = Wx::CheckBox->new($self, -1, _T("Toon welkom-scherm bij opstarten"), wxDefaultPosition, wxDefaultSize, ); | |
34 | $self->{c_tips} = Wx::CheckBox->new($self, -1, _T("Toon hints bij opstarten"), wxDefaultPosition, wxDefaultSize, ); | |
35 | $self->{c_verbose} = Wx::CheckBox->new($self, -1, _T("Uitgebreide log-informatie"), wxDefaultPosition, wxDefaultSize, ); | |
36 | $self->{c_trace} = Wx::CheckBox->new($self, -1, _T("Trace SQL aanroepen"), wxDefaultPosition, wxDefaultSize, ); | |
37 | $self->{b_cancel} = Wx::Button->new($self, wxID_CANCEL, ""); | |
38 | $self->{b_accept} = Wx::Button->new($self, wxID_APPLY, ""); | |
39 | ||
40 | $self->__set_properties(); | |
41 | $self->__do_layout(); | |
42 | ||
43 | Wx::Event::EVT_CHECKBOX($self, $self->{c_splash}->GetId, \&OnClick); | |
44 | Wx::Event::EVT_CHECKBOX($self, $self->{c_tips}->GetId, \&OnClick); | |
45 | Wx::Event::EVT_CHECKBOX($self, $self->{c_verbose}->GetId, \&OnClick); | |
46 | Wx::Event::EVT_CHECKBOX($self, $self->{c_trace}->GetId, \&OnClick); | |
47 | Wx::Event::EVT_BUTTON($self, $self->{b_cancel}->GetId, \&OnCancel); | |
48 | Wx::Event::EVT_BUTTON($self, $self->{b_accept}->GetId, \&OnApply); | |
49 | ||
50 | # end wxGlade | |
51 | ||
52 | Wx::Event::EVT_IDLE($self, \&OnIdle); | |
53 | ||
54 | return $self; | |
55 | ||
56 | } | |
57 | ||
58 | ||
59 | sub __set_properties { | |
60 | my $self = shift; | |
61 | ||
62 | # begin wxGlade: EB::Wx::Tools::PreferencesDialog::__set_properties | |
63 | ||
64 | $self->SetTitle(_T("Voorkeursinstellingen")); | |
65 | $self->{c_splash}->SetValue(1); | |
66 | $self->{c_tips}->SetValue(1); | |
67 | $self->{c_verbose}->SetValue(1); | |
68 | $self->{b_cancel}->SetFocus(); | |
69 | $self->{b_accept}->Enable(0); | |
70 | $self->{b_accept}->SetDefault(); | |
71 | ||
72 | # end wxGlade | |
73 | } | |
74 | ||
75 | sub __do_layout { | |
76 | my $self = shift; | |
77 | ||
78 | # begin wxGlade: EB::Wx::Tools::PreferencesDialog::__do_layout | |
79 | ||
80 | $self->{s_outer} = Wx::BoxSizer->new(wxVERTICAL); | |
81 | $self->{s_buttons} = Wx::BoxSizer->new(wxHORIZONTAL); | |
82 | $self->{s_main}= Wx::StaticBoxSizer->new($self->{s_main_staticbox}, wxVERTICAL); | |
83 | $self->{s_grid} = Wx::FlexGridSizer->new(4, 1, 3, 3); | |
84 | $self->{s_grid}->Add($self->{c_splash}, 0, wxADJUST_MINSIZE, 0); | |
85 | $self->{s_grid}->Add($self->{c_tips}, 0, wxADJUST_MINSIZE, 0); | |
86 | $self->{s_grid}->Add($self->{c_verbose}, 0, wxADJUST_MINSIZE, 0); | |
87 | $self->{s_grid}->Add($self->{c_trace}, 0, wxADJUST_MINSIZE, 0); | |
88 | $self->{s_grid}->AddGrowableCol(1); | |
89 | $self->{s_main}->Add($self->{s_grid}, 0, wxEXPAND, 0); | |
90 | $self->{s_outer}->Add($self->{s_main}, 0, wxALL|wxEXPAND, 5); | |
91 | $self->{s_buttons}->Add(5, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
92 | $self->{s_buttons}->Add($self->{b_cancel}, 0, wxLEFT|wxADJUST_MINSIZE, 5); | |
93 | $self->{s_buttons}->Add($self->{b_accept}, 0, wxLEFT|wxADJUST_MINSIZE, 5); | |
94 | $self->{s_outer}->Add($self->{s_buttons}, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 5); | |
95 | $self->SetSizer($self->{s_outer}); | |
96 | $self->{s_outer}->Fit($self); | |
97 | $self->Layout(); | |
98 | ||
99 | # end wxGlade | |
100 | } | |
101 | ||
102 | sub refresh { | |
103 | my ($self) = @_; | |
104 | $self->{c_splash }->SetValue($state->showsplash); | |
105 | $self->{c_tips }->SetValue($state->showtips ); | |
106 | $self->{c_verbose}->SetValue($state->verbose ); | |
107 | $self->{c_trace }->SetValue($state->trace ); | |
108 | $self->{b_accept}->Enable(0); | |
109 | $self->{b_accept}->SetDefault(); | |
110 | $self->{b_cancel}->SetFocus(); | |
111 | $self->{_check_changed} = 0; | |
112 | } | |
113 | ||
114 | sub changed { | |
115 | my ($self) = @_; | |
116 | return 1 if $self->{c_splash }->GetValue != $state->showsplash; | |
117 | return 2 if $self->{c_tips }->GetValue != $state->showtips ; | |
118 | return 4 if $self->{c_verbose}->GetValue != $state->verbose ; | |
119 | return 8 if $self->{c_trace }->GetValue != $state->trace ; | |
120 | return; | |
121 | } | |
122 | ||
123 | # wxGlade: EB::Wx::Tools::PreferencesDialog::OnIdle <event_handler> | |
124 | sub OnIdle { | |
125 | my ($self) = @_; | |
126 | return unless $self->{_check_changed}; | |
127 | $self->{b_accept}->Enable(0+$self->changed); | |
128 | $self->{_check_changed} = 0; | |
129 | } | |
130 | ||
131 | # wxGlade: EB::Wx::Tools::PreferencesDialog::OnApply <event_handler> | |
132 | sub OnApply { | |
133 | my ($self, $event) = @_; | |
134 | $state->showsplash(0+$self->{c_splash }->GetValue); | |
135 | $state->showtips( 0+$self->{c_tips }->GetValue); | |
136 | $state->verbose( 0+$self->{c_verbose}->GetValue); | |
137 | $state->trace( 0+$self->{c_trace }->GetValue); | |
138 | $dbh->trace($state->trace); | |
139 | $self->OnClose($event); | |
140 | } | |
141 | ||
142 | # wxGlade: EB::Wx::Tools::PreferencesDialog::OnClick <event_handler> | |
143 | sub OnClick { | |
144 | my ($self, $event) = @_; | |
145 | $self->{_check_changed}++; | |
146 | } | |
147 | ||
148 | # wxGlade: EB::Wx::Tools::PreferencesDialog::OnClose <event_handler> | |
149 | sub OnClose { | |
150 | my ($self, $event) = @_; | |
151 | $self->sizepos_save; | |
152 | $self->Show(0); | |
153 | } | |
154 | ||
155 | # wxGlade: EB::Wx::Tools::PreferencesDialog::OnCancel <event_handler> | |
156 | sub OnCancel { | |
157 | my ($self, $event) = @_; | |
158 | $self->OnClose($event); | |
159 | } | |
160 | ||
161 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: PropertiesDialog.pm,v 1.5 2008/02/11 15:21:48 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $cfg; | |
7 | our $state; | |
8 | our $app; | |
9 | our $dbh; | |
10 | ||
11 | package EB::Wx::Tools::PropertiesDialog; | |
12 | ||
13 | use Wx qw[:everything]; | |
14 | use base qw(Wx::Dialog); | |
15 | use base qw(EB::Wx::Window); | |
16 | use strict; | |
17 | use EB; | |
18 | ||
19 | sub new { | |
20 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
21 | $parent = undef unless defined $parent; | |
22 | $id = -1 unless defined $id; | |
23 | $title = "" unless defined $title; | |
24 | $pos = wxDefaultPosition unless defined $pos; | |
25 | $size = wxDefaultSize unless defined $size; | |
26 | $name = "" unless defined $name; | |
27 | ||
28 | # begin wxGlade: EB::Wx::Tools::PropertiesDialog::new | |
29 | ||
30 | $style = wxDEFAULT_DIALOG_STYLE | |
31 | unless defined $style; | |
32 | ||
33 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
34 | $self->{s_main_staticbox} = Wx::StaticBox->new($self, -1, _T("Administratiegegevens") ); | |
35 | $self->{l_dbname} = Wx::StaticText->new($self, -1, _T("Database"), wxDefaultPosition, wxDefaultSize, ); | |
36 | $self->{t_dbname} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_READONLY); | |
37 | $self->{l_boekjaar} = Wx::StaticText->new($self, -1, _T("Boekjaar"), wxDefaultPosition, wxDefaultSize, ); | |
38 | $self->{c_bky} = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, [], ); | |
39 | $self->{t_adm} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
40 | $self->{l_open} = Wx::StaticText->new($self, -1, _T("Geopend"), wxDefaultPosition, wxDefaultSize, ); | |
41 | $self->{t_open} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_READONLY); | |
42 | $self->{l_btw} = Wx::StaticText->new($self, -1, _T("BTW periode"), wxDefaultPosition, wxDefaultSize, ); | |
43 | $self->{c_btw} = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, [_T("Geen"), _T("Jaar"), _T("Kwartaal"), _T("Maand")], ); | |
44 | $self->{b_cancel} = Wx::Button->new($self, wxID_CANCEL, ""); | |
45 | $self->{b_accept} = Wx::Button->new($self, wxID_APPLY, ""); | |
46 | ||
47 | $self->__set_properties(); | |
48 | $self->__do_layout(); | |
49 | ||
50 | Wx::Event::EVT_CHOICE($self, $self->{c_bky}->GetId, \&OnBkyChanged); | |
51 | Wx::Event::EVT_TEXT($self, $self->{t_adm}->GetId, \&OnAdmChanged); | |
52 | Wx::Event::EVT_CHOICE($self, $self->{c_btw}->GetId, \&OnBTWChanged); | |
53 | Wx::Event::EVT_BUTTON($self, $self->{b_cancel}->GetId, \&OnCancel); | |
54 | Wx::Event::EVT_BUTTON($self, $self->{b_accept}->GetId, \&OnClose); | |
55 | ||
56 | # end wxGlade | |
57 | ||
58 | $self->{_check_changed} = 1; | |
59 | Wx::Event::EVT_IDLE($self, \&OnIdle); | |
60 | return $self; | |
61 | ||
62 | } | |
63 | ||
64 | ||
65 | sub __set_properties { | |
66 | my $self = shift; | |
67 | ||
68 | # begin wxGlade: EB::Wx::Tools::PropertiesDialog::__set_properties | |
69 | ||
70 | $self->SetTitle(_T("Eigenschappen")); | |
71 | $self->{c_bky}->SetSelection(0); | |
72 | $self->{t_adm}->SetMinSize($self->{t_adm}->ConvertDialogSizeToPixels(Wx::Size->new(102, 12))); | |
73 | $self->{c_btw}->SetSelection(0); | |
74 | $self->{b_cancel}->SetFocus(); | |
75 | $self->{b_accept}->Enable(0); | |
76 | $self->{b_accept}->SetDefault(); | |
77 | ||
78 | # end wxGlade | |
79 | } | |
80 | ||
81 | sub __do_layout { | |
82 | my $self = shift; | |
83 | ||
84 | # begin wxGlade: EB::Wx::Tools::PropertiesDialog::__do_layout | |
85 | ||
86 | $self->{s_outer} = Wx::BoxSizer->new(wxVERTICAL); | |
87 | $self->{s_buttons} = Wx::BoxSizer->new(wxHORIZONTAL); | |
88 | $self->{s_main}= Wx::StaticBoxSizer->new($self->{s_main_staticbox}, wxVERTICAL); | |
89 | $self->{s_grid} = Wx::FlexGridSizer->new(5, 2, 3, 3); | |
90 | $self->{sizer_1} = Wx::BoxSizer->new(wxHORIZONTAL); | |
91 | $self->{s_grid}->Add($self->{l_dbname}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
92 | $self->{s_grid}->Add($self->{t_dbname}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
93 | $self->{s_grid}->Add($self->{l_boekjaar}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
94 | $self->{sizer_1}->Add($self->{c_bky}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
95 | $self->{sizer_1}->Add(5, 1, 0, wxADJUST_MINSIZE, 0); | |
96 | $self->{sizer_1}->Add($self->{t_adm}, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
97 | $self->{s_grid}->Add($self->{sizer_1}, 0, wxEXPAND, 0); | |
98 | $self->{s_grid}->Add($self->{l_open}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
99 | $self->{s_grid}->Add($self->{t_open}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
100 | $self->{s_grid}->Add($self->{l_btw}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
101 | $self->{s_grid}->Add($self->{c_btw}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
102 | $self->{s_grid}->AddGrowableCol(1); | |
103 | $self->{s_main}->Add($self->{s_grid}, 0, wxALL|wxEXPAND, 3); | |
104 | $self->{s_outer}->Add($self->{s_main}, 0, wxALL|wxEXPAND, 5); | |
105 | $self->{s_buttons}->Add(5, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
106 | $self->{s_buttons}->Add($self->{b_cancel}, 0, wxLEFT|wxADJUST_MINSIZE, 5); | |
107 | $self->{s_buttons}->Add($self->{b_accept}, 0, wxLEFT|wxADJUST_MINSIZE, 5); | |
108 | $self->{s_outer}->Add($self->{s_buttons}, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 5); | |
109 | $self->SetSizer($self->{s_outer}); | |
110 | $self->{s_outer}->Fit($self); | |
111 | $self->Layout(); | |
112 | ||
113 | # end wxGlade | |
114 | } | |
115 | ||
116 | my $btwmap = [ 0, 1, undef, undef, 2, undef, undef, undef, undef, undef, undef, undef, 3 ]; | |
117 | my $bkymap; | |
118 | ||
119 | sub refresh { | |
120 | my ($self) = @_; | |
121 | my $t = $cfg->val(qw(database name)); | |
122 | $t =~ s/^eekboek_//; | |
123 | $t .= " (" . $dbh->driverdb . ")"; | |
124 | $self->{t_dbname}->SetValue($t); | |
125 | $self->{t_open}->SetValue($dbh->adm("opened")); | |
126 | ||
127 | my $sth = $dbh->sql_exec("SELECT bky_code, bky_name". | |
128 | " FROM Boekjaren". | |
129 | " WHERE bky_begin >= ( SELECT bky_end FROM Boekjaren WHERE bky_code = ?)". | |
130 | " ORDER BY bky_begin", BKY_PREVIOUS); | |
131 | my $this = 0; | |
132 | $self->{c_bky}->Clear; | |
133 | $bkymap = []; | |
134 | while ( my $rr = $sth->fetchrow_arrayref ) { | |
135 | $this = @$bkymap if $rr->[0] eq $state->bky; | |
136 | push(@$bkymap, [ @$rr ]); | |
137 | $self->{c_bky}->Append($rr->[0]); | |
138 | } | |
139 | $self->{c_bky}->SetSelection($self->{o_bky} = $this); | |
140 | $self->{t_adm}->SetValue($self->{o_adm} = $bkymap->[$this]->[1]); | |
141 | ||
142 | $self->{c_btw}->SetSelection($self->{o_btw} = $btwmap->[$dbh->adm("btwperiod")]); | |
143 | } | |
144 | ||
145 | sub changed { | |
146 | my $self = shift; | |
147 | return 1 if $self->{o_bky} != $self->{c_bky}->GetSelection; | |
148 | return 1 if $self->{o_adm} ne $self->{t_adm}->GetValue; | |
149 | return 1 if $self->{o_btw} != $self->{c_btw}->GetSelection; | |
150 | return; | |
151 | } | |
152 | ||
153 | # wxGlade: EB::Wx::Tools::PropertiesDialog::OnClose <event_handler> | |
154 | sub OnClose { | |
155 | my ($self, $event, $cancel) = @_; | |
156 | unless ( $cancel ) { | |
157 | $dbh->begin_work; | |
158 | if ( $self->{o_bky} != $self->{c_bky}->GetSelection ) { | |
159 | $state->set("bky", $bkymap->[$self->{c_bky}->GetSelection]->[0]); | |
160 | $self->{o_adm} = $bkymap->[$self->{c_bky}->GetSelection]->[1]; | |
161 | } | |
162 | eval { | |
163 | if ( $self->{o_adm} ne $self->{t_adm}->GetValue ) { | |
164 | $dbh->sql_exec("UPDATE Boekjaren". | |
165 | " SET bky_name = ?". | |
166 | " WHERE bky_code = ?", | |
167 | $self->{t_adm}->GetValue, | |
168 | $bkymap->[$self->{c_bky}->GetSelection]->[0], | |
169 | )->finish; | |
170 | } | |
171 | if ( $self->{o_btw} != $self->{c_btw}->GetSelection ) { | |
172 | for ( my $i = 0; $i++; ) { | |
173 | next unless $btwmap->[$i] == $self->{c_btw}->GetSelection; | |
174 | $dbh->sql_exec("UPDATE Boekjaren". | |
175 | " SET bky_btwperiod = $i". | |
176 | " WHERE bky_code = ?", | |
177 | $bkymap->[$self->{c_bky}->GetSelection]->[0], | |
178 | )->finish; | |
179 | last; | |
180 | } | |
181 | } | |
182 | }; | |
183 | if ( $@ ) { | |
184 | EB::Wx::MessageDialog | |
185 | ($self, $@, "Fout tijdens het bijwerken", | |
186 | wxOK|wxICON_ERROR); | |
187 | $dbh->rollback; | |
188 | } | |
189 | else { | |
190 | $dbh->commit; | |
191 | $app->{TOP}->SetTitle("EekBoek: " . ($self->{t_adm}->GetValue)); | |
192 | my $t = $state->bky . " (" . $self->{t_adm}->GetValue . ")"; | |
193 | Wx::LogMessage("Huidig boekjaar: $t"); | |
194 | $self->set_status("Boekjaar: $t"); | |
195 | } | |
196 | } | |
197 | #$self->sizepos_save; | |
198 | $self->Show(0); | |
199 | } | |
200 | ||
201 | sub OnIdle { | |
202 | my ($self) = @_; | |
203 | return unless $self->{_check_changed}; | |
204 | $self->{_check_changed} = 0; | |
205 | my $ch = $self->changed; | |
206 | $self->{b_accept}->Enable($ch); | |
207 | } | |
208 | ||
209 | # wxGlade: EB::Wx::Tools::PropertiesDialog::OnBkyChanged <event_handler> | |
210 | sub OnBkyChanged { | |
211 | my ($self, $event) = @_; | |
212 | my $rr = $dbh->do("SELECT bky_name, bky_btwperiod". | |
213 | " FROM Boekjaren". | |
214 | " WHERE bky_code = ?", | |
215 | $bkymap->[$self->{c_bky}->GetSelection]->[0]); | |
216 | ||
217 | $self->{t_adm}->SetValue($self->{o_adm} = $rr->[0]); | |
218 | $self->{c_btw}->SetSelection($self->{o_btw} = $btwmap->[$rr->[1]]); | |
219 | $self->{_check_changed} = 1; | |
220 | } | |
221 | ||
222 | # wxGlade: EB::Wx::Tools::PropertiesDialog::OnBTWChanged <event_handler> | |
223 | sub OnBTWChanged { | |
224 | my ($self, $event) = @_; | |
225 | $self->{_check_changed} = 1; | |
226 | } | |
227 | ||
228 | # wxGlade: EB::Wx::Tools::PropertiesDialog::OnCancel <event_handler> | |
229 | sub OnCancel { | |
230 | my ($self, $event) = @_; | |
231 | $self->OnClose($event, 1); | |
232 | } | |
233 | ||
234 | # wxGlade: EB::Wx::Tools::PropertiesDialog::OnAdmChanged <event_handler> | |
235 | sub OnAdmChanged { | |
236 | my ($self, $event) = @_; | |
237 | $self->{_check_changed} = 1; | |
238 | } | |
239 | ||
240 | # end of class EB::Wx::Tools::PropertiesDialog | |
241 | ||
242 | 1; | |
243 |
0 | #! perl | |
1 | ||
2 | # $Id$ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $dbh; | |
7 | ||
8 | package EB::Wx::UI::AccInput; | |
9 | ||
10 | use Wx qw(wxDefaultPosition wxDefaultSize wxID_OK); | |
11 | use base qw(EB::Wx::UI::ListInput); | |
12 | use strict; | |
13 | ||
14 | sub new { | |
15 | my ($self, $parent, $id, $title, $pos, $size, $style ) = @_; | |
16 | $parent = undef unless defined $parent; | |
17 | $id = -1 unless defined $id; | |
18 | $title = "" unless defined $title; | |
19 | $pos = wxDefaultPosition unless defined $pos; | |
20 | $size = wxDefaultSize unless defined $size; | |
21 | $style = 0 unless defined $style; | |
22 | ||
23 | # Select the list of accounts, depending on the class. | |
24 | my $class = ref($self) || $self; | |
25 | my $accts = $class =~ /\bBalAccInput$/ ? $dbh->accts("acc_balres") | |
26 | : $class =~ /\bResAccInput$/ ? $dbh->accts("not acc_balres") | |
27 | : $dbh->accts; | |
28 | $accts = [ map { $_ . " " . $accts->{$_} } sort { $a <=> $b } keys %$accts ]; | |
29 | ||
30 | $self = $self->SUPER::new($parent, -1, "", $pos, $size, 0, $accts); | |
31 | $self; | |
32 | } | |
33 | ||
34 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: AmountCtrl.pm,v 1.5 2008/03/25 22:24:31 jv Exp $ | |
3 | ||
4 | package EB::Wx::UI::AmountCtrl; | |
5 | ||
6 | use Wx qw[:everything]; | |
7 | use base qw(Wx::TextCtrl); | |
8 | use base qw(Wx::PlWindow); | |
9 | use base qw(Exporter); | |
10 | our @EXPORT_OK = qw(EVT_PL_AMOUNT); | |
11 | our %EXPORT_TAGS = ( 'everything' => \@EXPORT_OK, | |
12 | 'event' => [ qw(EVT_PL_AMOUNT) ], | |
13 | ); | |
14 | ||
15 | use strict; | |
16 | ||
17 | use EB::Format qw(numfmt amount); | |
18 | ||
19 | sub new { | |
20 | my ($class, @args) = @_; | |
21 | $args[5] |= wxTE_RIGHT|wxTE_PROCESS_ENTER; | |
22 | my $self = $class->SUPER::new(@args); | |
23 | Wx::Event::EVT_CHAR($self, \&OnKbdInput); | |
24 | Wx::Event::EVT_KILL_FOCUS($self, \&OnLoseFocus); | |
25 | #Wx::Event::EVT_SET_FOCUS($self, \&OnGetFocus); | |
26 | Wx::Event::EVT_TEXT($self, $self, \&OnChange); | |
27 | Wx::Event::EVT_TEXT_ENTER($self, $self, \&OnChange); | |
28 | $self; | |
29 | } | |
30 | ||
31 | my $evt_change = Wx::NewEventType; | |
32 | ||
33 | sub Wx::Event::EVT_PL_AMOUNT($$$) { | |
34 | $_[0]->Connect($_[1], -1, $evt_change, $_[2]); | |
35 | } | |
36 | ||
37 | sub SetValue { | |
38 | my ($self, $value) = @_; | |
39 | $self->SUPER::SetValue(numfmt($value)); | |
40 | } | |
41 | ||
42 | sub GetValue { | |
43 | my ($self) = @_; | |
44 | amount($self->SUPER::GetValue); | |
45 | } | |
46 | ||
47 | sub OnKbdInput { | |
48 | my ($self, $event) = @_; | |
49 | my $c = $event->GetKeyCode; | |
50 | $self->{prev} = $self->GetValue; | |
51 | $self->{cursor} = $self->GetInsertionPoint; | |
52 | ||
53 | if ( $c == WXK_TAB || | |
54 | $c == WXK_RETURN || | |
55 | $c == WXK_BACK || | |
56 | $c == WXK_DELETE || | |
57 | $c >= WXK_START || | |
58 | $event->HasModifiers | |
59 | ) { | |
60 | $event->Skip; | |
61 | return; | |
62 | } | |
63 | ||
64 | my $chr = pack("C", $c); | |
65 | if ( $chr =~ /^[[:digit:]]$/ ) { | |
66 | $event->Skip; | |
67 | } | |
68 | elsif ( $chr =~ /^[.,]$/ ) { | |
69 | if ( $self->{prev} =~ /[.,]/ ) { | |
70 | Wx::Bell; | |
71 | } | |
72 | else { | |
73 | $event->Skip; | |
74 | } | |
75 | } | |
76 | else { | |
77 | Wx::Bell; | |
78 | } | |
79 | } | |
80 | ||
81 | sub OnChange { | |
82 | my ($self, $event) = @_; | |
83 | my $newval = $self->GetValue; | |
84 | if ( !defined($newval) ) { | |
85 | Wx::Bell; | |
86 | $self->SetValue($self->{prev}); | |
87 | $self->SetInsertionPoint($self->{cursor}); | |
88 | } | |
89 | ||
90 | $self->GetEventHandler->ProcessEvent | |
91 | (EB::Wx::Perl::AmountCtrl::Event->new($evt_change, $self->GetId)); | |
92 | } | |
93 | ||
94 | sub OnLoseFocus { | |
95 | my ($self, $event) = @_; | |
96 | my $newval = $self->GetValue; | |
97 | if ( defined($newval) ) { | |
98 | $self->SetValue($newval); | |
99 | } | |
100 | else { | |
101 | Wx::Bell; | |
102 | } | |
103 | } | |
104 | ||
105 | sub OnGetFocus { | |
106 | my ($self, $event) = @_; | |
107 | # Nothing, yet. | |
108 | } | |
109 | ||
110 | package EB::Wx::Perl::AmountCtrl::Event; | |
111 | use base qw(Wx::PlCommandEvent); | |
112 | ||
113 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: BTWInput.pm,v 1.1 2008/03/25 23:04:10 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $dbh; | |
7 | our $state; | |
8 | our $app; | |
9 | ||
10 | package EB::Wx::UI::BTWInput; | |
11 | ||
12 | use Wx qw(wxDefaultPosition wxDefaultSize wxID_OK); | |
13 | use base qw(Wx::Choice); | |
14 | ||
15 | =begin evt_pl_btwinput | |
16 | ||
17 | # We can use a specialized event, but it is not necessary. | |
18 | ||
19 | use base qw(Wx::PlWindow); | |
20 | use base qw(Exporter); | |
21 | our @EXPORT_OK = qw(EVT_PL_BTWINPUT); | |
22 | our %EXPORT_TAGS = ( 'everything' => \@EXPORT_OK, | |
23 | 'event' => [ qw(EVT_PL_BTWINPUT) ], | |
24 | ); | |
25 | ||
26 | =cut | |
27 | ||
28 | use strict; | |
29 | use EB; | |
30 | ||
31 | sub new { | |
32 | my ($self, $parent, $id, $pos, $size, $list ) = @_; | |
33 | $parent = undef unless defined $parent; | |
34 | $id = -1 unless defined $id; | |
35 | $pos = wxDefaultPosition unless defined $pos; | |
36 | $size = wxDefaultSize unless defined $size; | |
37 | ||
38 | my $class = ref($self) || $self; | |
39 | ||
40 | # Each instance holds its own table. Room for optimization. | |
41 | # Later. | |
42 | ||
43 | my @btwmap; | |
44 | my %btwmap; | |
45 | my $sth = $dbh->sql_exec("SELECT btw_id, btw_desc, btw_perc, btw_tariefgroep, btw_incl". | |
46 | " FROM BTWTabel". | |
47 | " ORDER BY btw_id"); | |
48 | ||
49 | while ( my $rr = $sth->fetch ) { | |
50 | $btwmap{$rr->[0]} = @btwmap; | |
51 | push(@btwmap, [ @$rr ]); | |
52 | } | |
53 | ||
54 | $list = [ map { sprintf("%d %s", $_->[0], $_->[1]) } @btwmap ] | |
55 | unless ref($list) eq 'ARRAY' && scalar(@$list) > 0; | |
56 | ||
57 | $self = $self->SUPER::new($parent, $id, $pos, $size, $list); | |
58 | ||
59 | $self->{_btw_seq_to_data} = \@btwmap; | |
60 | $self->{_btw_code_to_seq} = \%btwmap; | |
61 | ||
62 | =begin evt_pl_btwinput | |
63 | ||
64 | Wx::Event::EVT_CHOICE($self, $self->GetId, \&OnChange); | |
65 | ||
66 | =cut | |
67 | ||
68 | $self; | |
69 | } | |
70 | ||
71 | # Set/GetSelection deal with the ordinal values. | |
72 | ||
73 | # Set/GetValue deal with the logical IDs. | |
74 | ||
75 | sub GetValue { | |
76 | my ($self) = @_; | |
77 | $self->{_btw_seq_to_data}->[$self->GetSelection]->[0]; | |
78 | } | |
79 | ||
80 | sub SetValue { | |
81 | my ($self, $value) = @_; | |
82 | $self->SetSelection($self->{_btw_code_to_seq}->{$value}); | |
83 | } | |
84 | ||
85 | # For convenience, provide the rest of the info as well. | |
86 | ||
87 | sub GetDescription { | |
88 | my ($self) = @_; | |
89 | $self->{_btw_seq_to_data}->[$self->GetSelection]->[1]; | |
90 | } | |
91 | ||
92 | sub GetPercentage { | |
93 | my ($self) = @_; | |
94 | $self->{_btw_seq_to_data}->[$self->GetSelection]->[2]; | |
95 | } | |
96 | ||
97 | sub GetGroup { | |
98 | my ($self) = @_; | |
99 | $self->{_btw_seq_to_data}->[$self->GetSelection]->[3]; | |
100 | } | |
101 | ||
102 | sub IsInclusive { | |
103 | my ($self) = @_; | |
104 | $self->{_btw_seq_to_data}->[$self->GetSelection]->[4]; | |
105 | } | |
106 | ||
107 | =begin evt_pl_btwinput | |
108 | ||
109 | my $evt_change = Wx::NewEventType; | |
110 | ||
111 | sub Wx::Event::EVT_PL_BTWINPUT($$$) { | |
112 | $_[0]->Connect($_[1], -1, $evt_change, $_[2]); | |
113 | } | |
114 | ||
115 | sub OnChange { | |
116 | my ($self, $event) = @_; | |
117 | $self->GetEventHandler->ProcessEvent | |
118 | (EB::Wx::Perl::BTWInput::Event->new($evt_change, $self->GetId)); | |
119 | } | |
120 | ||
121 | package EB::Wx::Perl::BTWInput::Event; | |
122 | use base qw(Wx::PlCommandEvent); | |
123 | ||
124 | =cut | |
125 | ||
126 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id$ | |
3 | ||
4 | package EB::Wx::UI::BalAccInput; | |
5 | ||
6 | # A wrapper around AccInput. | |
7 | ||
8 | # Since we need to specify the selection list at creation time, we | |
9 | # select the desired list based on the class name. | |
10 | ||
11 | use base qw(EB::Wx::UI::AccInput); | |
12 | ||
13 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: HvdInput.pm,v 1.1 2008/03/25 23:04:10 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $dbh; | |
7 | our $state; | |
8 | our $app; | |
9 | ||
10 | package EB::Wx::UI::HvdInput; | |
11 | ||
12 | use Wx qw(wxDefaultPosition wxDefaultSize wxID_OK); | |
13 | use base qw(Wx::Choice); | |
14 | ||
15 | use strict; | |
16 | use EB; | |
17 | ||
18 | sub new { | |
19 | my ($self, $parent, $id, $pos, $size, $list ) = @_; | |
20 | $parent = undef unless defined $parent; | |
21 | $id = -1 unless defined $id; | |
22 | $pos = wxDefaultPosition unless defined $pos; | |
23 | $size = wxDefaultSize unless defined $size; | |
24 | ||
25 | my $class = ref($self) || $self; | |
26 | ||
27 | # Each instance holds its own table. Room for optimization. | |
28 | # Later. | |
29 | ||
30 | my @vdimap; | |
31 | my %vdimap; | |
32 | my $sth = $dbh->sql_exec("SELECT vdi_id, vdi_desc, vdi_balres, vdi_kstomz, vdi_struct". | |
33 | " FROM Verdichtingen". | |
34 | " WHERE vdi_struct IS NULL". | |
35 | " ORDER BY vdi_id"); | |
36 | ||
37 | while ( my $rr = $sth->fetch ) { | |
38 | $vdimap{$rr->[0]} = @vdimap; | |
39 | push(@vdimap, [ @$rr ]); | |
40 | } | |
41 | ||
42 | $list = [ map { sprintf("%d %s", $_->[0], $_->[1]) } @vdimap ] | |
43 | unless ref($list) eq 'ARRAY' && scalar(@$list) > 0; | |
44 | ||
45 | $self = $self->SUPER::new($parent, $id, $pos, $size, $list); | |
46 | ||
47 | $self->{_vdi_seq_to_data} = \@vdimap; | |
48 | $self->{_vdi_code_to_seq} = \%vdimap; | |
49 | ||
50 | $self; | |
51 | } | |
52 | ||
53 | # Set/GetSelection deal with the ordinal values. | |
54 | ||
55 | # Set/GetValue deal with the logical IDs. | |
56 | ||
57 | sub GetValue { | |
58 | my ($self) = @_; | |
59 | $self->{_vdi_seq_to_data}->[$self->GetSelection]->[0]; | |
60 | } | |
61 | ||
62 | sub SetValue { | |
63 | my ($self, $value) = @_; | |
64 | $self->SetSelection($self->{_vdi_code_to_seq}->{$value}); | |
65 | } | |
66 | ||
67 | # For convenience, provide the rest of the info as well. | |
68 | ||
69 | sub GetDescription { | |
70 | my ($self) = @_; | |
71 | $self->{_vdi_seq_to_data}->[$self->GetSelection]->[1]; | |
72 | } | |
73 | ||
74 | sub GetBalRes { | |
75 | my ($self) = @_; | |
76 | $self->{_vdi_seq_to_data}->[$self->GetSelection]->[2]; | |
77 | } | |
78 | ||
79 | sub GetKstOmz { | |
80 | my ($self) = @_; | |
81 | $self->{_vdi_seq_to_data}->[$self->GetSelection]->[3]; | |
82 | } | |
83 | ||
84 | sub GetStruct { | |
85 | my ($self) = @_; | |
86 | $self->{_vdi_seq_to_data}->[$self->GetSelection]->[4]; | |
87 | } | |
88 | ||
89 | 1; |
0 | #! perl | |
1 | ||
2 | # $id$ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | ||
8 | package EB::Wx::UI::ListInput::ListDialog; | |
9 | ||
10 | use Wx qw[:everything]; | |
11 | use base qw(Wx::Dialog); | |
12 | use strict; | |
13 | use EB; | |
14 | ||
15 | # begin wxGlade: ::dependencies | |
16 | # end wxGlade | |
17 | ||
18 | sub new { | |
19 | my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; | |
20 | $parent = undef unless defined $parent; | |
21 | $id = -1 unless defined $id; | |
22 | $title = "" unless defined $title; | |
23 | $pos = wxDefaultPosition unless defined $pos; | |
24 | $size = wxDefaultSize unless defined $size; | |
25 | $name = "" unless defined $name; | |
26 | ||
27 | # begin wxGlade: EB::Wx::UI::ListInput::ListDialog::new | |
28 | ||
29 | $style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTHICK_FRAME|wxSTAY_ON_TOP | |
30 | unless defined $style; | |
31 | ||
32 | $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); | |
33 | $self->{lb_lst} = Wx::ListBox->new($self, -1, wxDefaultPosition, wxDefaultSize, [], wxLB_SINGLE|wxLB_HSCROLL); | |
34 | $self->{b_accept} = Wx::Button->new($self, wxID_OK, ""); | |
35 | $self->{b_cancel} = Wx::Button->new($self, wxID_CANCEL, ""); | |
36 | ||
37 | $self->__set_properties(); | |
38 | $self->__do_layout(); | |
39 | ||
40 | Wx::Event::EVT_LISTBOX($self, $self->{lb_lst}->GetId, \&OnSelect); | |
41 | Wx::Event::EVT_BUTTON($self, wxID_OK, \&OnOk); | |
42 | Wx::Event::EVT_BUTTON($self, wxID_CANCEL, \&OnCancel); | |
43 | ||
44 | # end wxGlade | |
45 | ||
46 | Wx::Event::EVT_CHAR($self, \&OnChar); | |
47 | ||
48 | $self->{ctx} = ""; | |
49 | $self->{ctx_type} = 0; # 0 = alpha, 1 = numeric | |
50 | $self->{default} = ""; | |
51 | ||
52 | return $self; | |
53 | ||
54 | } | |
55 | ||
56 | ||
57 | sub __set_properties { | |
58 | my $self = shift; | |
59 | ||
60 | # begin wxGlade: EB::Wx::UI::ListInput::ListDialog::__set_properties | |
61 | ||
62 | $self->SetTitle(_T("Selecteer")); | |
63 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(161, 107))); | |
64 | $self->{lb_lst}->SetFocus(); | |
65 | $self->{lb_lst}->SetSelection(0); | |
66 | $self->{b_accept}->SetDefault(); | |
67 | ||
68 | # end wxGlade | |
69 | } | |
70 | ||
71 | sub __do_layout { | |
72 | my $self = shift; | |
73 | ||
74 | # begin wxGlade: EB::Wx::UI::ListInput::ListDialog::__do_layout | |
75 | ||
76 | $self->{sz_lstd_outer} = Wx::BoxSizer->new(wxHORIZONTAL); | |
77 | $self->{sz_lstd_main} = Wx::BoxSizer->new(wxVERTICAL); | |
78 | $self->{sz_buttons} = Wx::BoxSizer->new(wxHORIZONTAL); | |
79 | $self->{sz_lstd_main}->Add($self->{lb_lst}, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
80 | $self->{sz_buttons}->Add($self->{b_accept}, 0, wxADJUST_MINSIZE, 0); | |
81 | $self->{sz_buttons}->Add(5, 1, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | |
82 | $self->{sz_buttons}->Add($self->{b_cancel}, 0, wxADJUST_MINSIZE, 0); | |
83 | $self->{sz_lstd_main}->Add($self->{sz_buttons}, 0, wxTOP|wxEXPAND, 5); | |
84 | $self->{sz_lstd_outer}->Add($self->{sz_lstd_main}, 1, wxALL|wxEXPAND, 5); | |
85 | $self->SetSizer($self->{sz_lstd_outer}); | |
86 | $self->Layout(); | |
87 | ||
88 | # end wxGlade | |
89 | } | |
90 | ||
91 | sub setvalue { | |
92 | my ($self, $value) = @_; | |
93 | my $i = $self->{lb_lst}->FindString($value); | |
94 | return if $i < 0; | |
95 | $self->{lb_lst}->SetSelection($i); | |
96 | $self->{lb_lst}->SetFirstItem($i); | |
97 | #$self->{lb_lst}->EnsureVisible($i); | |
98 | } | |
99 | ||
100 | sub value { | |
101 | my ($self) = @_; | |
102 | $self->{lb_lst}->GetSelection; | |
103 | } | |
104 | ||
105 | sub fill { | |
106 | my ($self, $aref) = @_; | |
107 | $self->{lb_lst}->InsertItems($self->{list} = $aref, 0); | |
108 | } | |
109 | ||
110 | # wxGlade: EB::Wx::UI::ListInput::ListDialog::OnOk <event_handler> | |
111 | sub OnOk { | |
112 | my ($self, $event) = @_; | |
113 | my $v = $1 if $self->{lb_lst}->GetString($self->value) =~ /^(\d+)/; | |
114 | $self->closehandler(0+$v); | |
115 | } | |
116 | ||
117 | # wxGlade: EB::Wx::UI::ListInput::ListDialog::OnSelect <event_handler> | |
118 | sub OnSelect { | |
119 | my ($self, $event) = @_; | |
120 | my $v = $1 if $self->{lb_lst}->GetString($self->value) =~ /^(\d+)/; | |
121 | $self->closehandler(0+$v); | |
122 | } | |
123 | ||
124 | # wxGlade: EB::Wx::UI::ListInput::ListDialog::OnCancel <event_handler> | |
125 | sub OnCancel { | |
126 | my ($self, $event) = @_; | |
127 | $self->closehandler(-1); | |
128 | } | |
129 | ||
130 | sub closehandler { | |
131 | my ($self, $retval) = @_; | |
132 | $self->EndModal($retval); | |
133 | } | |
134 | ||
135 | use Wx qw(:keycode); | |
136 | ||
137 | sub OnChar { | |
138 | my ($self, $event) = @_; | |
139 | ||
140 | if ( $event->HasModifiers ) { | |
141 | # Common controls. | |
142 | $event->Skip; | |
143 | return; | |
144 | } | |
145 | ||
146 | # Get key code and char, if ordinary. | |
147 | my $k = $event->GetKeyCode; | |
148 | my $c = ($k < WXK_START) ? pack("C", $k) : ""; | |
149 | ||
150 | # Remember default value. | |
151 | $self->{default} ||= $self->value; | |
152 | ||
153 | if ( $k == WXK_BACK ) { | |
154 | # Remove a char from the search. | |
155 | if ( $self->{ctx} ne "" ) { | |
156 | chop($self->{ctx}); | |
157 | if ( $self->{ctx} eq "" ) { | |
158 | # Exhausted -> reset. | |
159 | $self->setvalue($self->{default}); | |
160 | } | |
161 | } | |
162 | else { | |
163 | Wx::Bell; | |
164 | } | |
165 | } | |
166 | elsif ( $k == WXK_ESCAPE ) { | |
167 | # Reset to orig value. | |
168 | $self->setvalue($self->{default}); | |
169 | $self->{ctx} = ""; | |
170 | } | |
171 | elsif ( $k == WXK_UP ) { | |
172 | my $i = $self->{lb_lst}->GetSelection; | |
173 | $self->{lb_lst}->SetSelection($i-1) if $i >= 1; | |
174 | $self->{ctx} = ""; | |
175 | $self->{lb_lst}->SetFirstItem($i-1); | |
176 | } | |
177 | elsif ( $k == WXK_DOWN ) { | |
178 | my $i = $self->{lb_lst}->GetSelection; | |
179 | $self->{lb_lst}->SetSelection($i+1); | |
180 | $self->{ctx} = ""; | |
181 | $self->{lb_lst}->SetFirstItem($i+1); | |
182 | } | |
183 | elsif ( $k == WXK_RETURN ) { | |
184 | my $v = $1 if $self->{lb_lst}->GetString($self->value) =~ /^(\d+)/; | |
185 | $self->closehandler(0+$v); | |
186 | } | |
187 | elsif ( $c =~ /^[[:alpha:]]$/ ) { | |
188 | # Append to search, or switch search type. | |
189 | if ( $self->{ctx_type} ) { | |
190 | $self->{ctx} = $c; | |
191 | $self->{ctx_type} = 0; | |
192 | } | |
193 | else { | |
194 | $self->{ctx} .= $c; | |
195 | } | |
196 | } | |
197 | elsif ( $c =~ /^[[:digit:]]$/ ) { | |
198 | # Append to search, or switch search type. | |
199 | if ( $self->{ctx_type} ) { | |
200 | $self->{ctx} .= $c; | |
201 | } | |
202 | else { | |
203 | $self->{ctx} = $c; | |
204 | $self->{ctx_type} = 1; | |
205 | } | |
206 | } | |
207 | elsif ( | |
208 | $k == WXK_TAB || | |
209 | $k >= WXK_START | |
210 | ) { | |
211 | # Common controls. | |
212 | $event->Skip; | |
213 | return; | |
214 | } | |
215 | else { | |
216 | # Skip event. | |
217 | } | |
218 | ||
219 | # Try to match. | |
220 | if ( $self->{ctx} ne "" ) { | |
221 | my $lk = $self->{ctx}; | |
222 | my $pat = $self->{ctx_type} ? qr/(^)($lk)/ : qr/^(\S+\s+)($lk)/i; | |
223 | foreach ( @{$self->{list}} ) { | |
224 | next unless /$pat/; | |
225 | $self->setvalue($_); | |
226 | return; | |
227 | } | |
228 | # No match, remove offending character, | |
229 | chop($self->{ctx}); | |
230 | return; | |
231 | } | |
232 | else { | |
233 | } | |
234 | # $event->Skip; | |
235 | } | |
236 | ||
237 | # end of class EB::Wx::UI::ListInput::ListDialog | |
238 | ||
239 | 1; | |
240 |
0 | #! perl | |
1 | ||
2 | # $Id: ListInput.pm,v 1.5 2008/03/25 22:25:36 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $dbh; | |
7 | our $state; | |
8 | our $app; | |
9 | ||
10 | package EB::Wx::UI::ListInput; | |
11 | ||
12 | use Wx qw(wxDefaultPosition wxDefaultSize wxID_OK); | |
13 | use base qw(Wx::TextCtrl); | |
14 | use base qw(Wx::PlWindow); | |
15 | use base qw(Exporter); | |
16 | our @EXPORT_OK = qw(EVT_EB_LISTINPUT); | |
17 | our %EXPORT_TAGS = ( 'everything' => \@EXPORT_OK, | |
18 | 'event' => [ qw(EVT_EB_LISTINPUT) ], | |
19 | ); | |
20 | use strict; | |
21 | use EB; | |
22 | ||
23 | sub new { | |
24 | my ($self, $parent, $id, $title, $pos, $size, $style, $list ) = @_; | |
25 | $parent = undef unless defined $parent; | |
26 | $id = -1 unless defined $id; | |
27 | $title = "" unless defined $title; | |
28 | $pos = wxDefaultPosition unless defined $pos; | |
29 | $size = wxDefaultSize unless defined $size; | |
30 | $style = 0 unless defined $style; | |
31 | ||
32 | my $class = ref($self) || $self; | |
33 | $self = $self->SUPER::new($parent, -1, "", $pos, $size, $style ); | |
34 | ||
35 | $self->{list} = $list; | |
36 | ||
37 | Wx::Event::EVT_CHAR($self, \&OnChar); | |
38 | Wx::Event::EVT_LISTBOX($self, $self->GetId, \&OnSelect); | |
39 | ||
40 | Wx::Event::EVT_IDLE($self, \&OnIdle); | |
41 | ||
42 | $self->{ctx} = ""; | |
43 | $self->{ctx_type} = 0; # 0 = alpha, 1 = numeric | |
44 | $self->{default} = ""; | |
45 | return $self; | |
46 | } | |
47 | ||
48 | my $evt_change = Wx::NewEventType; | |
49 | ||
50 | sub Wx::Event::EVT_EB_LISTINPUT($$$) { | |
51 | $_[0]->Connect($_[1], -1, $evt_change, $_[2]); | |
52 | } | |
53 | ||
54 | use Wx qw(:keycode); | |
55 | ||
56 | sub OnChar { | |
57 | my ($self, $event) = @_; | |
58 | ||
59 | # Get key code and char, if ordinary. | |
60 | my $k = $event->GetKeyCode; | |
61 | my $c = ($k < WXK_START) ? pack("C", $k) : ""; | |
62 | ||
63 | # Remember default value. | |
64 | $self->{default} ||= $self->SUPER::GetValue; | |
65 | ||
66 | if ( $k == WXK_BACK ) { | |
67 | # Remove a char from the search. | |
68 | if ( $self->{ctx} ne "" ) { | |
69 | chop($self->{ctx}); | |
70 | if ( $self->{ctx} eq "" ) { | |
71 | # Exhausted -> reset. | |
72 | $self->SetValue($self->{default}); | |
73 | } | |
74 | } | |
75 | else { | |
76 | Wx::Bell; | |
77 | } | |
78 | } | |
79 | elsif ( $k == WXK_ESCAPE ) { | |
80 | # Reset to orig value. | |
81 | $self->SetValueAsIs($self->{default}); | |
82 | $self->{ctx} = ""; | |
83 | } | |
84 | elsif ( $k == WXK_UP ) { | |
85 | my $v; | |
86 | my $cur = $self->SUPER::GetValue; | |
87 | foreach ( @{$self->{list}} ) { | |
88 | last if $_ eq $cur; | |
89 | $v = $_; | |
90 | } | |
91 | $self->SetValueAsIs($v) if $v; | |
92 | $self->{ctx} = ""; | |
93 | } | |
94 | elsif ( $k == WXK_DOWN ) { | |
95 | my $v = ""; | |
96 | my $cur = $self->SUPER::GetValue; | |
97 | foreach ( @{$self->{list}} ) { | |
98 | if ( $v eq $cur ) { | |
99 | # $self->SetValueAsIs($_); | |
100 | $self->{_pending} = $_; | |
101 | last; | |
102 | } | |
103 | $v = $_; | |
104 | } | |
105 | $self->{ctx} = ""; | |
106 | } | |
107 | elsif ( $c =~ /^[[:alpha:]]$/ ) { | |
108 | # Append to search, or switch search type. | |
109 | if ( $self->{ctx_type} ) { | |
110 | $self->{ctx} = $c; | |
111 | $self->{ctx_type} = 0; | |
112 | } | |
113 | else { | |
114 | $self->{ctx} .= $c; | |
115 | } | |
116 | } | |
117 | elsif ( $c =~ /^[[:digit:]]$/ ) { | |
118 | # Append to search, or switch search type. | |
119 | if ( $self->{ctx_type} ) { | |
120 | $self->{ctx} .= $c; | |
121 | } | |
122 | else { | |
123 | $self->{ctx} = $c; | |
124 | $self->{ctx_type} = 1; | |
125 | } | |
126 | } | |
127 | elsif ( $c eq '?' ) { | |
128 | use EB::Wx::UI::ListInput::ListDialog; | |
129 | my $d = EB::Wx::UI::ListInput::ListDialog->new($self, -1, "Selecteer", wxDefaultPosition, wxDefaultSize,); | |
130 | $d->fill($self->{list}); | |
131 | $d->setvalue($self->SUPER::GetValue); | |
132 | my $ret = $d->ShowModal; | |
133 | $self->SetValue($ret) if $ret >= 0; | |
134 | $d->Destroy; | |
135 | } | |
136 | elsif ( | |
137 | $k == WXK_TAB || | |
138 | $k == WXK_RETURN || | |
139 | $k >= WXK_START || | |
140 | $event->HasModifiers | |
141 | ) { | |
142 | # Common controls. | |
143 | $event->Skip; | |
144 | return; | |
145 | } | |
146 | else { | |
147 | # Skip event. | |
148 | } | |
149 | ||
150 | # Try to match. | |
151 | if ( $self->{ctx} ne "" ) { | |
152 | my $lk = $self->{ctx}; | |
153 | my $pat = $self->{ctx_type} ? qr/(^)($lk)/ : qr/^(\S+\s+)($lk)/i; | |
154 | foreach ( @{$self->{list}} ) { | |
155 | next unless /$pat/; | |
156 | $self->SetValueAsIs($_); | |
157 | $self->SetSelection(length($1), length($1)+length($2)); | |
158 | return; | |
159 | } | |
160 | # No match, remove offendig character, | |
161 | chop($self->{ctx}); | |
162 | return; | |
163 | } | |
164 | else { | |
165 | $self->SetSelection(0,0); | |
166 | } | |
167 | # $event->Skip; | |
168 | } | |
169 | ||
170 | sub OnIdle { | |
171 | my ($self) = @_; | |
172 | return unless defined $self->{_pending}; | |
173 | $self->SetValue(delete $self->{_pending}); | |
174 | } | |
175 | ||
176 | # Value setter/getters. These use the numeric part only. | |
177 | ||
178 | sub SetValue { | |
179 | my ($self, $value) = @_; | |
180 | foreach ( @{$self->{list}} ) { | |
181 | next unless /^(\d+)/ && $1 == $value; | |
182 | $value = $_; | |
183 | last; | |
184 | } | |
185 | $self->SetValueAsIs($value); | |
186 | } | |
187 | ||
188 | sub SetValueAsIs { | |
189 | my ($self, $value) = @_; | |
190 | $self->SUPER::SetValue($value); | |
191 | my $event = | |
192 | EB::Wx::Perl::ListInput::Event->new($evt_change, $self->GetId); | |
193 | $self->GetEventHandler->ProcessEvent($event); | |
194 | ||
195 | } | |
196 | ||
197 | sub GetValue { | |
198 | my ($self) = @_; | |
199 | my $value = $self->SUPER::GetValue; | |
200 | $value =~ /^(\d+)/; | |
201 | $1; # valid or undef | |
202 | } | |
203 | ||
204 | # wxGlade: MyFrame::OnSelect <event_handler> | |
205 | sub OnSelect { | |
206 | my ($self, $event) = @_; | |
207 | $self->{ctx} = ""; | |
208 | $self->{ctx_type} = 0; | |
209 | $event->Skip; | |
210 | } | |
211 | ||
212 | # wxGlade: MyFrame::OnLoseFocus <event_handler> | |
213 | sub OnLoseFocus { | |
214 | my ($self, $event) = @_; | |
215 | my $obj = $event->GetEventObject; | |
216 | #warn("Selected: ", $obj->GetValue); | |
217 | } | |
218 | ||
219 | package EB::Wx::Perl::ListInput::Event; | |
220 | use base qw(Wx::PlCommandEvent); | |
221 | ||
222 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: NumericCtrl.pm,v 1.5 2008/03/25 22:26:01 jv Exp $ | |
3 | ||
4 | package EB::Wx::UI::NumericCtrl; | |
5 | ||
6 | use base qw(Wx::TextCtrl); | |
7 | use Wx qw[:everything]; | |
8 | use Wx::Perl::TextValidator; | |
9 | use strict; | |
10 | use EB; | |
11 | ||
12 | sub new { | |
13 | my ($class, @args) = @_; | |
14 | $args[5] |= wxTE_RIGHT|wxTE_PROCESS_ENTER; | |
15 | my $self = $class->SUPER::new(@args); | |
16 | $self->SetValidator(Wx::Perl::TextValidator->new(qr/^\d*$/)); | |
17 | $self; | |
18 | } | |
19 | ||
20 | 1; | |
21 | ||
22 | __END__ | |
23 | ||
24 | sub OnKbdInput { | |
25 | my ($self, $event) = @_; | |
26 | my $c = $event->GetKeyCode; | |
27 | ||
28 | if ( $c == WXK_BACK || | |
29 | $c == WXK_TAB || | |
30 | $c == WXK_RETURN || | |
31 | $c == WXK_ESCAPE || | |
32 | $c == WXK_DELETE || | |
33 | $c >= WXK_START || | |
34 | $event->HasModifiers | |
35 | ) { | |
36 | $event->Skip; | |
37 | } | |
38 | ||
39 | elsif ( pack("C", $c) =~ /^\d$/ ) { | |
40 | $event->Skip; | |
41 | } | |
42 | else { | |
43 | Wx::Bell; | |
44 | } | |
45 | } | |
46 | ||
47 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: PeriodPanel.pm,v 1.6 2008/03/25 22:26:27 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $state; | |
7 | our $dbh; | |
8 | ||
9 | package EB::Wx::UI::PeriodPanel; | |
10 | ||
11 | use Wx qw[:everything :datepicker]; | |
12 | use Wx::Calendar; | |
13 | use base qw(Wx::Panel); | |
14 | use base qw(EB::Wx::Window); | |
15 | ||
16 | use base qw(Wx::PlWindow); | |
17 | use base qw(Exporter); | |
18 | our @EXPORT_OK = qw(EVT_EB_PERIOD); | |
19 | our %EXPORT_TAGS = ( 'everything' => \@EXPORT_OK, | |
20 | 'event' => [ qw(EVT_EB_PERIOD) ], | |
21 | ); | |
22 | ||
23 | use EB; | |
24 | ||
25 | use strict; | |
26 | ||
27 | sub new { | |
28 | my( $self, $parent, $id, $pos, $size, $style, $name ) = @_; | |
29 | $parent = undef unless defined $parent; | |
30 | $id = -1 unless defined $id; | |
31 | $pos = wxDefaultPosition unless defined $pos; | |
32 | $size = wxDefaultSize unless defined $size; | |
33 | $name = "" unless defined $name; | |
34 | ||
35 | # begin wxGlade: EB::Wx::UI::PeriodPanel::new | |
36 | ||
37 | $style = wxTAB_TRAVERSAL | |
38 | unless defined $style; | |
39 | ||
40 | $self = $self->SUPER::new( $parent, $id, $pos, $size, $style, $name ); | |
41 | $self->{label_1} = Wx::StaticText->new($self, -1, "Specificeer de gewenste periode door een\nboekjaar te kiezen of door handmatig de\ndata in te geven.", wxDefaultPosition, wxDefaultSize, ); | |
42 | $self->{l_bky} = Wx::StaticText->new($self, -1, "Boekjaar:", wxDefaultPosition, wxDefaultSize, ); | |
43 | $self->{c_bky} = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, ["Kies datum"], ); | |
44 | $self->{t_bky} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_READONLY); | |
45 | $self->{l_per_from} = Wx::StaticText->new($self, -1, "Periode vanaf", wxDefaultPosition, wxDefaultSize, ); | |
46 | $self->{dt_from} = Wx::StaticText->new($self, -1, "Placeholder", wxDefaultPosition, wxDefaultSize, ); | |
47 | $self->{l_per_to} = Wx::StaticText->new($self, -1, "Periode t/m", wxDefaultPosition, wxDefaultSize, ); | |
48 | $self->{dt_to} = Wx::StaticText->new($self, -1, "Placeholder", wxDefaultPosition, wxDefaultSize, ); | |
49 | ||
50 | $self->__set_properties(); | |
51 | $self->__do_layout(); | |
52 | ||
53 | Wx::Event::EVT_CHOICE($self, $self->{c_bky}->GetId, \&OnBky); | |
54 | ||
55 | # end wxGlade | |
56 | ||
57 | Wx::Event::EVT_DATE_CHANGED($self, $self->{dt_from}->GetId, \&OnFromChanged); | |
58 | Wx::Event::EVT_DATE_CHANGED($self, $self->{dt_to}->GetId, \&OnToChanged); | |
59 | ||
60 | return $self; | |
61 | ||
62 | } | |
63 | ||
64 | ||
65 | sub __set_properties { | |
66 | my $self = shift; | |
67 | ||
68 | my $date = Wx::DateTime::Now; | |
69 | $self->{dt_from}->Destroy; | |
70 | $self->{dt_from} = Wx::DatePickerCtrl->new($self, -1, $date); | |
71 | $self->{dt_to}->Destroy; | |
72 | $self->{dt_to} = Wx::DatePickerCtrl->new($self, -1, $date); | |
73 | ||
74 | # begin wxGlade: EB::Wx::UI::PeriodPanel::__set_properties | |
75 | ||
76 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(172, 103))); | |
77 | $self->{c_bky}->SetMinSize(Wx::Size->new(150, 30)); | |
78 | $self->{c_bky}->SetSelection(0); | |
79 | $self->{dt_from}->SetMinSize(Wx::Size->new(150, 26)); | |
80 | $self->{dt_to}->SetMinSize(Wx::Size->new(150, 26)); | |
81 | ||
82 | # end wxGlade | |
83 | ||
84 | } | |
85 | ||
86 | sub __do_layout { | |
87 | my $self = shift; | |
88 | ||
89 | # begin wxGlade: EB::Wx::UI::PeriodPanel::__do_layout | |
90 | ||
91 | $self->{sizer_1} = Wx::BoxSizer->new(wxVERTICAL); | |
92 | $self->{sizer_2} = Wx::BoxSizer->new(wxHORIZONTAL); | |
93 | $self->{sizer_4} = Wx::BoxSizer->new(wxVERTICAL); | |
94 | $self->{grid_sizer_1} = Wx::FlexGridSizer->new(5, 2, 5, 5); | |
95 | $self->{sizer_4}->Add($self->{label_1}, 0, wxADJUST_MINSIZE, 0); | |
96 | $self->{sizer_4}->Add(1, 7, 0, wxADJUST_MINSIZE, 0); | |
97 | $self->{grid_sizer_1}->Add($self->{l_bky}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
98 | $self->{grid_sizer_1}->Add($self->{c_bky}, 1, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
99 | $self->{grid_sizer_1}->Add(1, 1, 0, wxADJUST_MINSIZE, 0); | |
100 | $self->{grid_sizer_1}->Add($self->{t_bky}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | |
101 | $self->{grid_sizer_1}->Add($self->{l_per_from}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
102 | $self->{grid_sizer_1}->Add($self->{dt_from}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
103 | $self->{grid_sizer_1}->Add($self->{l_per_to}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
104 | $self->{grid_sizer_1}->Add($self->{dt_to}, 0, wxADJUST_MINSIZE, 0); | |
105 | $self->{grid_sizer_1}->AddGrowableCol(1); | |
106 | $self->{sizer_4}->Add($self->{grid_sizer_1}, 1, wxEXPAND, 0); | |
107 | $self->{sizer_2}->Add($self->{sizer_4}, 1, wxEXPAND, 0); | |
108 | $self->{sizer_1}->Add($self->{sizer_2}, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 5); | |
109 | $self->SetSizer($self->{sizer_1}); | |
110 | ||
111 | # end wxGlade | |
112 | } | |
113 | ||
114 | my $evt_change = Wx::NewEventType; | |
115 | ||
116 | sub Wx::Event::EVT_EB_PERIOD($$$) { | |
117 | $_[0]->Connect($_[1], -1, $evt_change, $_[2]); | |
118 | } | |
119 | ||
120 | sub _ISOtoWxD { | |
121 | return unless shift =~ /^(\d{4})-(\d\d)-(\d\d)$/; | |
122 | Wx::DateTime->newFromDMY($3,$2-1,$1,1,1,1,1); | |
123 | } | |
124 | ||
125 | sub allow_fromto { | |
126 | my ($self, $val) = @_; | |
127 | $self->allow_to($val); | |
128 | $self->allow_from($val); | |
129 | } | |
130 | sub allow_to { | |
131 | my ($self, $val) = @_; | |
132 | $self->{_allow_to} = $val; | |
133 | } | |
134 | sub allow_from { | |
135 | my ($self, $val) = @_; | |
136 | $self->{_allow_from} = $val; | |
137 | ||
138 | } | |
139 | sub allow_all { | |
140 | my ($self, $val) = @_; | |
141 | $self->{_allow_all} = $val; | |
142 | ||
143 | } | |
144 | ||
145 | my @choices; | |
146 | sub refresh { | |
147 | my ($self) = @_; | |
148 | ||
149 | my $sth = $dbh->sql_exec("SELECT bky_code, bky_begin, bky_end, bky_name FROM Boekjaren". | |
150 | " WHERE NOT bky_opened IS NULL". | |
151 | " AND bky_code <> ?". | |
152 | " ORDER BY bky_begin", BKY_PREVIOUS); | |
153 | $self->{c_bky}->Clear; | |
154 | @choices = (); | |
155 | ||
156 | if ( $self->{_allow_all} ) { | |
157 | push(@choices, 0); | |
158 | $self->{c_bky}->Append("Alle"); | |
159 | } | |
160 | ||
161 | my $i = 0; | |
162 | my $sel; | |
163 | my $min; | |
164 | my $max; | |
165 | while ( my $rr = $sth->fetchrow_arrayref ) { | |
166 | push(@choices, [@$rr]); | |
167 | $self->{c_bky}->Append($rr->[0]) unless $self->{_allow_all} > 1; | |
168 | $sel = $i if $state->bky eq $choices[-1]; | |
169 | $i++; | |
170 | $min = $rr->[1] if !defined($min) || $min gt $rr->[1]; | |
171 | $max = $rr->[2] if !defined($max) || $max lt $rr->[2]; | |
172 | } | |
173 | if ( $self->{_allow_from} || $self->{_allow_to} ) { | |
174 | push(@choices, ["Kies datum",$min,$max,""]); | |
175 | $self->{c_bky}->Append($choices[-1]->[0]) unless $self->{_allow_all} > 1; | |
176 | } | |
177 | if ( $self->{_allow_all} ) { | |
178 | $choices[0] = ["Alle", $min, $max, "Gehele administratie"]; | |
179 | $sel = 0; | |
180 | } | |
181 | $self->{_bky} = $choices[$sel]->[0]; | |
182 | my $begin = _ISOtoWxD($min); | |
183 | $min = _ISOtoWxD($choices[$sel]->[1]); | |
184 | $max = _ISOtoWxD($choices[$sel]->[2]); | |
185 | $self->{c_bky}->SetSelection($sel); | |
186 | $self->{t_bky}->SetValue($choices[$sel]->[3]); | |
187 | $self->{dt_from}->SetValue($self->{_fromto} ? $min : $begin); | |
188 | $self->{dt_from}->SetRange($self->{_fromto} ? $min : $begin, $max); | |
189 | $self->{dt_to}->SetValue($max); | |
190 | $self->{dt_to}->SetRange($min, $max); | |
191 | $self->{dt_from}->Enable(0); | |
192 | $self->{l_per_from}->Enable(0); | |
193 | $self->{l_per_to}->Enable(0); | |
194 | $self->{dt_to}->Enable(0); | |
195 | $self->{_changed} = 0; | |
196 | } | |
197 | ||
198 | sub OnBky { | |
199 | my ($self, $event) = @_; | |
200 | # wxGlade: EB::Wx::UI::PeriodPanel::OnBky <event_handler> | |
201 | ||
202 | my $sel = $self->{c_bky}->GetSelection; | |
203 | $self->set_bky(undef, $sel); | |
204 | $self->{_changed}++; | |
205 | $self->GetEventHandler->ProcessEvent | |
206 | (EB::Wx::UI::PeriodPanel::Event->new($evt_change, $self->GetId)); | |
207 | ||
208 | # end wxGlade | |
209 | } | |
210 | ||
211 | sub set_bky { | |
212 | my ($self, $bky, $sel) = @_; | |
213 | unless ( defined($sel) ) { | |
214 | for ( my $s=0; $s < @choices; $s++ ) { | |
215 | $sel = $s, last if $choices[$s]->[0] eq $bky; | |
216 | } | |
217 | } | |
218 | return unless defined $sel; | |
219 | ||
220 | my $min = _ISOtoWxD($choices[$sel]->[1]); | |
221 | my $max = _ISOtoWxD($choices[$sel]->[2]); | |
222 | ||
223 | if ( $self->{_allow_from} ) { | |
224 | $self->{dt_from}->SetValue($min); | |
225 | $self->{dt_from}->SetRange($min, $max); | |
226 | } | |
227 | $self->{dt_to}->SetValue($max); | |
228 | $self->{dt_to}->SetRange($min, $max); | |
229 | $self->{t_bky}->SetValue($choices[$sel]->[3]); | |
230 | if ( ($self->{_allow_from} || $self->{_allow_to}) && $sel == $#choices ) { | |
231 | undef $self->{_bky}; | |
232 | if ( $self->{_allow_from} ) { | |
233 | $self->{dt_from}->Enable(1); | |
234 | $self->{l_per_from}->Enable(1); | |
235 | } | |
236 | if ( $self->{_allow_to} ) { | |
237 | $self->{dt_to}->Enable(1); | |
238 | $self->{l_per_to}->Enable(1); | |
239 | } | |
240 | $self->{_bky} = undef; | |
241 | } | |
242 | else { | |
243 | $self->{c_bky}->SetSelection($sel); | |
244 | $self->{dt_to}->Enable(0); | |
245 | $self->{dt_from}->Enable(0); | |
246 | $self->{l_per_from}->Enable(0); | |
247 | $self->{l_per_to}->Enable(0); | |
248 | $self->{_bky} = $choices[$sel]->[0]; | |
249 | } | |
250 | } | |
251 | ||
252 | sub OnFromChanged { | |
253 | my ($self, $event) = @_; | |
254 | $self->{_changed}++; | |
255 | $self->GetEventHandler->ProcessEvent | |
256 | (EB::Wx::UI::PeriodPanel::Event->new($evt_change, $self->GetId)); | |
257 | } | |
258 | ||
259 | sub OnToChanged { | |
260 | my ($self, $event) = @_; | |
261 | $self->{_changed}++; | |
262 | $self->GetEventHandler->ProcessEvent | |
263 | (EB::Wx::UI::PeriodPanel::Event->new($evt_change, $self->GetId)); | |
264 | } | |
265 | ||
266 | sub changed { | |
267 | my ($self) = @_; | |
268 | $self->{_changed}; | |
269 | } | |
270 | ||
271 | sub GetValues { | |
272 | my ($self) = @_; | |
273 | ||
274 | my $ret = {}; | |
275 | ||
276 | $ret->{period_panel_bky} = $self->{_bky}; | |
277 | $ret->{period_panel_from} = $self->{dt_from}->GetValue->FormatISODate | |
278 | if $self->{_allow_from}; | |
279 | $ret->{period_panel_to} = $self->{dt_to}->GetValue->FormatISODate | |
280 | if $self->{_allow_to}; | |
281 | $ret->{period_panel_all} = $self->{c_bky}->GetSelection == 0 | |
282 | if $self->{_allow_all}; | |
283 | $ret; | |
284 | } | |
285 | ||
286 | # end of class EB::Wx::UI::PeriodPanel | |
287 | ||
288 | package EB::Wx::UI::PeriodPanel::Event; | |
289 | use base qw(Wx::PlCommandEvent); | |
290 | ||
291 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: StdAccPanel.pm,v 1.8 2008/03/11 11:05:34 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $app; | |
7 | our $state; | |
8 | our $dbh; | |
9 | ||
10 | package EB::Wx::UI::StdAccPanel; | |
11 | ||
12 | use Wx qw[:everything]; | |
13 | use base qw(Wx::Panel); | |
14 | use strict; | |
15 | use EB; | |
16 | ||
17 | # begin wxGlade: ::dependencies | |
18 | use EB::Wx::UI::BalAccInput; | |
19 | use EB::Wx::UI::ListInput; | |
20 | use EB::Wx::Window; | |
21 | # end wxGlade | |
22 | ||
23 | sub new { | |
24 | my( $self, $parent, $id, $pos, $size, $style, $name ) = @_; | |
25 | $parent = undef unless defined $parent; | |
26 | $id = -1 unless defined $id; | |
27 | $pos = wxDefaultPosition unless defined $pos; | |
28 | $size = wxDefaultSize unless defined $size; | |
29 | $name = "" unless defined $name; | |
30 | ||
31 | # begin wxGlade: EB::Wx::UI::StdAccPanel::new | |
32 | ||
33 | $self = $self->SUPER::new( $parent, $id, $pos, $size, $style, $name ); | |
34 | $self->{main_panel} = Wx::ScrolledWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxCLIP_CHILDREN); | |
35 | $self->{l_winst} = Wx::StaticText->new($self->{main_panel}, -1, _T("Winst"), wxDefaultPosition, wxDefaultSize, ); | |
36 | $self->{tx_winst} = EB::Wx::UI::BalAccInput->new($self->{main_panel}, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
37 | $self->{b_apply} = Wx::Button->new($self, wxID_APPLY, ""); | |
38 | $self->{b_reset} = Wx::Button->new($self, wxID_REVERT_TO_SAVED, ""); | |
39 | ||
40 | $self->__set_properties(); | |
41 | $self->__do_layout(); | |
42 | ||
43 | Wx::Event::EVT_TEXT($self, $self->{tx_winst}->GetId, \&OnChanged); | |
44 | Wx::Event::EVT_BUTTON($self, $self->{b_apply}->GetId, \&OnApply); | |
45 | Wx::Event::EVT_BUTTON($self, $self->{b_reset}->GetId, \&OnReset); | |
46 | ||
47 | # end wxGlade | |
48 | ||
49 | Wx::Event::EVT_IDLE($self, \&OnIdle); | |
50 | ||
51 | $self->refresh; | |
52 | my $ch = $self->changed; | |
53 | $self->{b_apply}->Enable($ch); | |
54 | $self->{b_reset}->Enable($ch); | |
55 | ||
56 | return $self; | |
57 | ||
58 | } | |
59 | ||
60 | ||
61 | sub __set_properties { | |
62 | my $self = shift; | |
63 | ||
64 | # begin wxGlade: EB::Wx::UI::StdAccPanel::__set_properties | |
65 | ||
66 | $self->SetSize($self->ConvertDialogSizeToPixels(Wx::Size->new(187, 153))); | |
67 | $self->{l_winst}->Enable(0); | |
68 | $self->{tx_winst}->Enable(0); | |
69 | $self->{main_panel}->SetScrollRate(10, 10); | |
70 | ||
71 | # end wxGlade | |
72 | } | |
73 | ||
74 | sub __do_layout { | |
75 | my $self = shift; | |
76 | ||
77 | # begin wxGlade: EB::Wx::UI::StdAccPanel::__do_layout | |
78 | ||
79 | $self->{sz_std} = Wx::BoxSizer->new(wxVERTICAL); | |
80 | $self->{sz_std_buttons} = Wx::BoxSizer->new(wxHORIZONTAL); | |
81 | $self->{sz_stdacc} = Wx::BoxSizer->new(wxVERTICAL); | |
82 | $self->{sz_g_stdacc} = Wx::FlexGridSizer->new(0, 2, 3, 5); | |
83 | $self->{sz_g_stdacc}->Add($self->{l_winst}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
84 | $self->{sz_g_stdacc}->Add($self->{tx_winst}, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
85 | $self->{sz_g_stdacc}->AddGrowableCol(1); | |
86 | $self->{sz_stdacc}->Add($self->{sz_g_stdacc}, 0, wxALL|wxEXPAND, 5); | |
87 | $self->{main_panel}->SetSizer($self->{sz_stdacc}); | |
88 | $self->{sz_std}->Add($self->{main_panel}, 1, wxEXPAND, 0); | |
89 | $self->{sz_std_buttons}->Add($self->{b_apply}, 0, wxADJUST_MINSIZE, 0); | |
90 | $self->{sz_std_buttons}->Add(20, 20, 1, wxADJUST_MINSIZE, 0); | |
91 | $self->{sz_std_buttons}->Add($self->{b_reset}, 0, wxADJUST_MINSIZE, 0); | |
92 | $self->{sz_std}->Add($self->{sz_std_buttons}, 0, wxALL|wxEXPAND, 5); | |
93 | $self->SetSizer($self->{sz_std}); | |
94 | ||
95 | # end wxGlade | |
96 | ||
97 | # Bepaal dynamisch de rest van de koppelingen. | |
98 | foreach my $acc ( sort @{$dbh->std_accs} ) { | |
99 | next if $acc eq 'winst'; | |
100 | my $label = $acc; | |
101 | if ( $acc eq 'deb' ) { | |
102 | $label = "Debiteuren"; | |
103 | } | |
104 | elsif ( $acc eq 'crd' ) { | |
105 | $label = "Crediteuren"; | |
106 | } | |
107 | elsif ( $acc eq 'btw_ok' ) { | |
108 | $label = "BTW Betaald"; | |
109 | } | |
110 | elsif ( $acc =~ /^btw_([iv])(.)$/ ) { | |
111 | $label = "BTW "; | |
112 | $label .= $1 eq 'i' ? "Inkoop " : "Verkoop "; | |
113 | foreach ( @{BTWTARIEVEN()} ) { | |
114 | $label .= $_ if lc(substr($_, 0, 1)) eq $2; | |
115 | } | |
116 | } | |
117 | $self->{"l_$acc"} = Wx::StaticText->new($self->{main_panel}, -1, _T($label), wxDefaultPosition, wxDefaultSize, ); | |
118 | $self->{"tx_$acc"} = EB::Wx::UI::BalAccInput->new($self->{main_panel}, -1, "", wxDefaultPosition, wxDefaultSize, ); | |
119 | $self->{"tx_$acc"}->SetValue($dbh->std_acc($acc)); | |
120 | $self->{sz_g_stdacc}->Add($self->{"l_$acc"}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
121 | $self->{sz_g_stdacc}->Add($self->{"tx_$acc"}, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | |
122 | Wx::Event::EVT_TEXT($self, $self->{"tx_$acc"}->GetId, \&OnChanged); | |
123 | } | |
124 | ||
125 | } | |
126 | ||
127 | sub hide_buttons { | |
128 | my ($self, $hide) = (@_, 1); | |
129 | $self->{sz_std}->Show($self->{sz_std_buttons}, !$hide); | |
130 | $self->Layout; | |
131 | } | |
132 | ||
133 | sub OnIdle { | |
134 | my ($self) = @_; | |
135 | return unless $self->{_check_changed}; | |
136 | $self->{_check_changed} = 0; | |
137 | my $ch = $self->changed; | |
138 | $self->{b_apply}->Enable($ch); | |
139 | $self->{b_reset}->Enable($ch); | |
140 | } | |
141 | ||
142 | sub refresh { | |
143 | my ($self) = @_; | |
144 | local($self->{busy}) = 1; | |
145 | $self->{anyinuse} = 0; | |
146 | foreach my $acc ( @{$dbh->std_accs} ) { | |
147 | my $t = $dbh->std_acc($acc); | |
148 | $self->{"tx_$acc"}->SetValue($t); | |
149 | my $inuse = $dbh->do("SELECT COUNT(*) FROM Journal WHERE jnl_acc_id = ?", | |
150 | $dbh->std_acc($acc))->[0]; | |
151 | if ( $inuse ) { | |
152 | $self->{"tx_$acc"}->Enable(0); | |
153 | $self->{"l_$acc"}->Enable(0); | |
154 | $self->{anyinuse}++; | |
155 | } | |
156 | else { | |
157 | $self->{"tx_$acc"}->Enable(1); | |
158 | $self->{"l_$acc"}->Enable(1); | |
159 | } | |
160 | } | |
161 | } | |
162 | ||
163 | sub anyinuse { | |
164 | my ($self) = @_; | |
165 | $self->{anyinuse}; | |
166 | } | |
167 | ||
168 | sub changed { | |
169 | my ($self) = @_; | |
170 | return 0 if $self->{busy}; | |
171 | foreach my $acc ( @{$dbh->std_accs} ) { | |
172 | eval { | |
173 | return 1 if (split(' ', $self->{"tx_$acc"}->GetValue))[0] != $dbh->std_acc($acc); | |
174 | }; | |
175 | } | |
176 | return 0; | |
177 | } | |
178 | ||
179 | # wxGlade: EB::Wx::UI::StdAccPanel::OnChanged <event_handler> | |
180 | sub OnChanged { | |
181 | my ($self, $event) = @_; | |
182 | $self->{_check_changed}++; | |
183 | } | |
184 | ||
185 | # wxGlade: EB::Wx::UI::StdAccPanel::OnApply <event_handler> | |
186 | sub OnApply { | |
187 | my ($self, $event) = @_; | |
188 | $dbh->begin_work; | |
189 | eval { $self->apply }; | |
190 | if ( $@ ) { | |
191 | $dbh->rollback; | |
192 | EB::Wx::MessageDialog | |
193 | ($self, | |
194 | "Dat ging niet helemaal lekker.\n".$@, | |
195 | "Oeps", | |
196 | wxOK|wxICON_ERROR); | |
197 | } | |
198 | else { | |
199 | #$dbh->commit; | |
200 | } | |
201 | $self->{_check_changed}++; | |
202 | } | |
203 | ||
204 | sub apply { | |
205 | my ($self) = @_; | |
206 | my @set; | |
207 | my $t; | |
208 | foreach my $acc ( @{$dbh->std_accs} ) { | |
209 | if ( ($t = (split(' ', $self->{"tx_$acc"}->GetValue))[0]) != $dbh->std_acc($acc) ) { | |
210 | my $inuse = $dbh->do("SELECT COUNT(*) FROM Journal WHERE jnl_acc_id = ?", | |
211 | $t)->[0]; | |
212 | if ( $inuse ) { | |
213 | EB::Wx::MessageBox | |
214 | ($self, | |
215 | "Rekening $t is in gebruik", "In gebruik", | |
216 | wxOK|wxICON_ERROR); | |
217 | next; | |
218 | } | |
219 | push(@set, "std_acc_$acc = $t"); | |
220 | } | |
221 | } | |
222 | ||
223 | if ( @set ) { | |
224 | $dbh->sql_exec("UPDATE Standaardrekeningen SET ". | |
225 | join(", ", @set))->finish; | |
226 | $dbh->commit; | |
227 | $dbh->std_acc(""); # slush cache | |
228 | $self->refresh; | |
229 | $self->{_check_changed} = 1; | |
230 | } | |
231 | } | |
232 | ||
233 | # wxGlade: EB::Wx::UI::StdAccPanel::OnReset <event_handler> | |
234 | sub OnReset { | |
235 | my ($self, $event) = @_; | |
236 | $self->refresh; | |
237 | } | |
238 | ||
239 | ||
240 | 1; | |
241 |
0 | #! perl | |
1 | ||
2 | # $Id: VdiInput.pm,v 1.1 2008/03/25 23:04:10 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $dbh; | |
7 | our $state; | |
8 | our $app; | |
9 | ||
10 | package EB::Wx::UI::VdiInput; | |
11 | ||
12 | use Wx qw(wxDefaultPosition wxDefaultSize wxID_OK); | |
13 | use base qw(Wx::Choice); | |
14 | ||
15 | use strict; | |
16 | use EB; | |
17 | ||
18 | sub new { | |
19 | my ($self, $parent, $id, $pos, $size, $list ) = @_; | |
20 | $parent = undef unless defined $parent; | |
21 | $id = -1 unless defined $id; | |
22 | $pos = wxDefaultPosition unless defined $pos; | |
23 | $size = wxDefaultSize unless defined $size; | |
24 | ||
25 | my $class = ref($self) || $self; | |
26 | ||
27 | # Each instance holds its own table. Room for optimization. | |
28 | # Later. | |
29 | ||
30 | my @vdimap; | |
31 | my %vdimap; | |
32 | my $sth = $dbh->sql_exec("SELECT vdi_id, vdi_desc, vdi_balres, vdi_kstomz, vdi_struct". | |
33 | " FROM Verdichtingen". | |
34 | " WHERE NOT vdi_struct IS NULL". | |
35 | " ORDER BY vdi_id"); | |
36 | ||
37 | while ( my $rr = $sth->fetch ) { | |
38 | $vdimap{$rr->[0]} = @vdimap; | |
39 | push(@vdimap, [ @$rr ]); | |
40 | } | |
41 | ||
42 | $list = [ map { sprintf("%d %s", $_->[0], $_->[1]) } @vdimap ] | |
43 | unless ref($list) eq 'ARRAY' && scalar(@$list) > 0; | |
44 | ||
45 | $self = $self->SUPER::new($parent, $id, $pos, $size, $list); | |
46 | ||
47 | $self->{_vdi_seq_to_data} = \@vdimap; | |
48 | $self->{_vdi_code_to_seq} = \%vdimap; | |
49 | ||
50 | $self; | |
51 | } | |
52 | ||
53 | # Set/GetSelection deal with the ordinal values. | |
54 | ||
55 | # Set/GetValue deal with the logical IDs. | |
56 | ||
57 | sub GetValue { | |
58 | my ($self) = @_; | |
59 | $self->{_vdi_seq_to_data}->[$self->GetSelection]->[0]; | |
60 | } | |
61 | ||
62 | sub SetValue { | |
63 | my ($self, $value) = @_; | |
64 | $self->SetSelection($self->{_vdi_code_to_seq}->{$value}); | |
65 | } | |
66 | ||
67 | # For convenience, provide the rest of the info as well. | |
68 | ||
69 | sub GetDescription { | |
70 | my ($self) = @_; | |
71 | $self->{_vdi_seq_to_data}->[$self->GetSelection]->[1]; | |
72 | } | |
73 | ||
74 | sub GetBalRes { | |
75 | my ($self) = @_; | |
76 | $self->{_vdi_seq_to_data}->[$self->GetSelection]->[2]; | |
77 | } | |
78 | ||
79 | sub GetKstOmz { | |
80 | my ($self) = @_; | |
81 | $self->{_vdi_seq_to_data}->[$self->GetSelection]->[3]; | |
82 | } | |
83 | ||
84 | sub GetStruct { | |
85 | my ($self) = @_; | |
86 | $self->{_vdi_seq_to_data}->[$self->GetSelection]->[4]; | |
87 | } | |
88 | ||
89 | 1; |
0 | #! perl | |
1 | ||
2 | # $Id: Window.pm,v 1.5 2009/10/24 21:26:53 jv Exp $ | |
3 | ||
4 | package main; | |
5 | ||
6 | our $cfg; | |
7 | our $state; | |
8 | our $app; | |
9 | our $dbh; | |
10 | ||
11 | package EB::Wx::Window; | |
12 | ||
13 | use strict; | |
14 | use warnings; | |
15 | ||
16 | use Wx qw(:everything); | |
17 | ||
18 | sub sizepos_save { | |
19 | my ($self, $posonly) = @_; | |
20 | my $h = $state->get($self->{mew}); | |
21 | @$h{ qw(xpos ypos ) } = $self->GetPositionXY; | |
22 | @$h{ qw(xwidth ywidth) } = $self->GetSizeWH unless $posonly; | |
23 | $state->set($self->{mew}, $h); | |
24 | } | |
25 | ||
26 | sub sizepos_restore { | |
27 | my ($self, $mew, $posonly) = @_; | |
28 | $self->{mew} = $mew if defined $mew; | |
29 | my $h = $state->get($self->{mew}); | |
30 | $self->Move( [ @$h{ qw(xpos ypos ) } ] ) | |
31 | if defined($h->{xpos}) && defined($h->{ypos}); | |
32 | $self->SetSize( [ @$h{ qw(xwidth ywidth) } ] ) | |
33 | if !$posonly && defined($h->{xwidth}) && defined($h->{ywidth}); | |
34 | ||
35 | # For convenience: CLOSE on Ctrl-W and Esc. | |
36 | # (Doesn't work on GTK, yet). | |
37 | $self->SetAcceleratorTable | |
38 | (Wx::AcceleratorTable->new | |
39 | ( [wxACCEL_CTRL, ord 'w', wxID_CLOSE], | |
40 | [wxACCEL_NORMAL, 27, wxID_CLOSE], | |
41 | )); | |
42 | ||
43 | } | |
44 | ||
45 | sub set_status { | |
46 | my ($self, $text, $ix) = @_; | |
47 | return unless $app && $app->{TOP} && $app->{TOP}->{mainframe_statusbar}; | |
48 | $app->{TOP}->{mainframe_statusbar}->SetStatusText($text, $ix||0); | |
49 | } | |
50 | ||
51 | #### Override | |
52 | sub init { | |
53 | shift->refresh(@_); | |
54 | } | |
55 | ||
56 | #### Override | |
57 | sub refresh { | |
58 | } | |
59 | ||
60 | sub resize_grid { | |
61 | my ($self, $gr) = @_; | |
62 | ||
63 | # Calculate minimal fit. | |
64 | $gr->AutoSizeColumns(1); | |
65 | ||
66 | # Get the total minimal width. | |
67 | my $w = 0; | |
68 | my @w; | |
69 | my $cols = $gr->GetNumberCols; | |
70 | for ( 0 .. $cols-1 ) { | |
71 | push(@w, $gr->GetColSize($_)); | |
72 | $w += $w[-1]; | |
73 | } | |
74 | ||
75 | # Get available width. | |
76 | my $width; | |
77 | if ( $gr->can("GetVirtualSizeWH") ) { | |
78 | $width = ($gr->GetVirtualSizeWH)[0]; | |
79 | } | |
80 | else { | |
81 | # Assume scrollbar. | |
82 | $width = ($gr->GetSizeWH)[0] - 16; | |
83 | } | |
84 | ||
85 | # Scale columns if possible. | |
86 | if ( $w < $width ) { | |
87 | my $r = $width / $w; | |
88 | for ( 0 .. $cols-1 ) { | |
89 | $gr->SetColSize($_, int($r*$w[$_])); | |
90 | } | |
91 | } | |
92 | } | |
93 | ||
94 | sub EB::Wx::MessageDialog { | |
95 | my ($parent, $msg, $title, $flags) = @_; | |
96 | ||
97 | $flags ||= wxICON_INFORMATION|wxOK; | |
98 | ||
99 | my $m = Wx::MessageDialog->new($parent, $msg, $title, $flags); | |
100 | my $ret = $m->ShowModal; | |
101 | $m->Destroy; | |
102 | return $ret; | |
103 | } | |
104 | ||
105 | sub EB::Wx::Fatal { | |
106 | my ($msg) = "@_"; | |
107 | ||
108 | my $m = Wx::MessageDialog->new(undef, $msg, | |
109 | "EekBoek afgebroken", | |
110 | wxICON_ERROR|wxOK); | |
111 | my $ret = $m->ShowModal; | |
112 | $m->Destroy; | |
113 | $app->{TOP}->ExitMainLoop if $app && $app->{TOP}; | |
114 | exit(1); | |
115 | } | |
116 | ||
117 | *CORE::GLOBAL::die = sub(@) { | |
118 | goto \&EB::Wx::Fatal; | |
119 | }; | |
120 | ||
121 | 1; |
0 | Squirrel Consultancy, voor al uw Open Source projecten. | |
1 | Squirrel Consultancy, voor al uw Perl trainingen. | |
2 | Open Source -- Het gaat om uw vrijheid! | |
3 | Wist u dat in periode-aanduidingen, het ook mogelijk is om de naam van een maand op te geven, of k1 voor eerste kwartaal, enzovoorts? | |
4 | Vragen kun je het beste stellen op de mailing list: http://lists.sourceforge.net/lists/listinfo/eekboek-users | |
5 |
0 | 0 | BEGIN WORK; |
1 | 1 | |
2 | SELECT * INTO TEMP TAccounts FROM Accounts WHERE acc_id = 0; | |
3 | ||
2 | 4 | ALTER TABLE Accounts |
5 | ADD COLUMN acc_dcfixed boolean; -- fixed d/c | |
6 | ||
7 | ALTER TABLE TAccounts | |
3 | 8 | ADD COLUMN acc_dcfixed boolean; -- fixed d/c |
4 | 9 | |
5 | 10 | UPDATE Accounts SET acc_dcfixed = 'f' WHERE acc_balres; |
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
32 | 32 | |
33 | 33 | [general] |
34 | 34 | |
35 | ; There are currently no General config variables. | |
35 | ; Default location for administrations. | |
36 | ;admdir = $HOME/.eekboek/admdir | |
37 | ||
38 | ; Force use of selection wizard even if a config is present. | |
39 | ;wizard = 1 | |
36 | 40 | |
37 | 41 | [locale] |
38 | 42 |
Binary diff not shown
9 | 9 | # Minimal version to prevent many Unicode bugs. |
10 | 10 | use 5.008003; |
11 | 11 | |
12 | my $RCS_Id = '$Id: EekBoek.pm,v 1.79 2009/10/27 15:22:39 jv Exp $ '; | |
12 | my $RCS_Id = '$Id: EekBoek.pm,v 1.80 2009/10/28 22:55:29 jv Exp $ '; | |
13 | 13 | our $PACKAGE = 'EekBoek'; |
14 | our $VERSION = '1.05.04'; | |
14 | our $VERSION = '1.05.05'; | |
15 | 15 | |
16 | 16 | =head1 NAME |
17 | 17 | |
62 | 62 | |
63 | 63 | 1; |
64 | 64 | |
65 | # $Id: EekBoek.pm,v 1.79 2009/10/27 15:22:39 jv Exp $ | |
65 | # $Id: EekBoek.pm,v 1.80 2009/10/28 22:55:29 jv Exp $ |
0 | 0 | #! perl |
1 | 1 | |
2 | # $Id: ebgui,v 1.10 2009/10/28 22:11:46 jv Exp $ | |
2 | # $Id: ebgui,v 1.11 2009/11/25 09:41:53 jv Exp $ | |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use utf8; |
66 | 66 | |
67 | 67 | sub check_version { |
68 | 68 | my ( $what, $version, $required ) = @_; |
69 | $version =~ s/,/./g; | |
69 | 70 | return if $version ge $required; |
70 | 71 | error( <<END_MSG, "Ontoereikende $what versie" ); |
71 | 72 | De geïnstalleerde versie van $what is niet toereikend. |
0 | #! perl | |
1 | ||
2 | # $Id: ebwxshell,v 1.2 2009/12/19 14:10:59 jv Exp $ | |
3 | ||
4 | use strict; | |
5 | use utf8; | |
6 | # use lib qw(EekBoekLibrary); | |
7 | ||
8 | package main; | |
9 | ||
10 | use strict; | |
11 | use warnings; | |
12 | use File::Spec; | |
13 | use File::Basename; | |
14 | ||
15 | use Wx qw( :everything );; | |
16 | # If we get here, we have Wx :) | |
17 | ||
18 | # Common case when run from unpacked dist. | |
19 | my $script = $0; | |
20 | my $dir = dirname($script); | |
21 | my $lib = File::Spec->catfile( dirname($dir), "lib" ); | |
22 | if ( -s File::Spec->catfile( $lib, "EekBoek.pm" ) ) { | |
23 | # Need abs paths since we're going to chdir later. | |
24 | unshift( @INC, File::Spec->rel2abs($lib) ); | |
25 | my $sep = $ENV{PATH} =~ m?;??q:;::q;:;;;; # just for fun | |
26 | $ENV{PATH} = File::Spec->rel2abs($dir) . $sep . $ENV{PATH}; | |
27 | } | |
28 | ||
29 | check_install( "EekBoek", "EekBoek.pm", "EB.pm", "EB/schema/eekboek.sql" ); | |
30 | ||
31 | require EekBoek; | |
32 | check_version( "EekBoek", $EekBoek::VERSION, "1.05.00" ); | |
33 | ||
34 | check_install( "De EekBoek WxShell", "EB/Wx/Shell/Main.pm", "EB/Wx/IniWiz.pm" ); | |
35 | ||
36 | # Some more version checking. Wx 0.74 is somewhat arbitrary. | |
37 | check_version( "Wx", $Wx::VERSION, "0.74" ); | |
38 | check_version( "wxWidgets", $Wx::wxVERSION, "2.008" ); | |
39 | ||
40 | require EB::Wx::Shell::Main; | |
41 | EB::Wx::Shell::Main->run; | |
42 | ||
43 | ################ Subroutines ################ | |
44 | ||
45 | sub findfile { | |
46 | my ( $file ) = @_; | |
47 | foreach ( @INC ) { | |
48 | my $f = File::Spec->catfile( $_, $file ); | |
49 | return $f if -s $f; | |
50 | } | |
51 | return; | |
52 | } | |
53 | ||
54 | sub check_install { | |
55 | my ( $what, @checks ) = @_; | |
56 | foreach ( @checks ) { | |
57 | next if findfile( $_ ); | |
58 | error( <<END_MSG, "Installatiefout" ); | |
59 | $what is niet geïnstalleerd, of kon niet worden gevonden. | |
60 | ||
61 | Raadplaag uw systeembeheerder. | |
62 | END_MSG | |
63 | return; | |
64 | } | |
65 | } | |
66 | ||
67 | sub check_version { | |
68 | my ( $what, $version, $required ) = @_; | |
69 | $version =~ s/,/./g; | |
70 | return if $version ge $required; | |
71 | error( <<END_MSG, "Ontoereikende $what versie" ); | |
72 | De geïnstalleerde versie van $what is niet toereikend. | |
73 | Versie $version is geïnstalleerd terwijl versie $required of later | |
74 | is vereist. | |
75 | ||
76 | Raadplaag uw systeembeheerder. | |
77 | END_MSG | |
78 | } | |
79 | ||
80 | ################ Messengers ################ | |
81 | ||
82 | sub _msg { | |
83 | my ( $msg, $caption, $style ) = @_; | |
84 | $style |= wxOK; | |
85 | my $d = Wx::MessageDialog->new ( undef, | |
86 | $msg, | |
87 | $caption, | |
88 | $style, wxDefaultPosition ); | |
89 | $d->ShowModal; | |
90 | $d->Destroy; | |
91 | } | |
92 | ||
93 | sub info { | |
94 | push( @_, wxICON_INFORMATION ); | |
95 | goto &_msg; | |
96 | } | |
97 | ||
98 | sub error { | |
99 | push( @_, wxICON_ERROR ); | |
100 | &_msg; | |
101 | exit(1); | |
102 | } | |
103 | ||
104 | sub warning { | |
105 | push( @_, wxICON_EXCLAMATION ); | |
106 | goto &_msg; | |
107 | } | |
108 | ||
109 | 1; | |
110 | ||
111 | =head1 NAME | |
112 | ||
113 | EekBoek - Bookkeeping software for small and medium-size businesses | |
114 | ||
115 | =head1 SYNOPSIS | |
116 | ||
117 | ebgui | |
118 | ||
119 | EekBoek is a bookkeeping package for small and medium-size businesses. | |
120 | Unlike other accounting software, EekBoek has both a command-line | |
121 | interface (CLI) and a graphical user-interface (GUI). Furthermore, it | |
122 | has a complete Perl API to create your own custom applications. | |
123 | ||
124 | EekBoek is designed for the Dutch/European market and currently | |
125 | available in Dutch only. An English translation is in the works (help | |
126 | appreciated). | |
127 | ||
128 | =head1 DESCRIPTION | |
129 | ||
130 | For a description how to use the program, see L<http://www.eekboek.nl/docs/index.html>. | |
131 | ||
132 | =head1 BUGS AND PROBLEMS | |
133 | ||
134 | Please use the eekboek-users mailing list at SourceForge. | |
135 | ||
136 | =head1 AUTHOR AND CREDITS | |
137 | ||
138 | Johan Vromans (jvromans@squirrel.nl) wrote this package. | |
139 | ||
140 | Web site: L<http://www.eekboek.nl>. | |
141 | ||
142 | =head1 COPYRIGHT AND DISCLAIMER | |
143 | ||
144 | This program is Copyright 2005-2009 by Squirrel Consultancy. All | |
145 | rights reserved. | |
146 | ||
147 | This program is free software; you can redistribute it and/or modify | |
148 | it under the terms of either: a) the GNU General Public License as | |
149 | published by the Free Software Foundation; either version 1, or (at | |
150 | your option) any later version, or b) the "Artistic License" which | |
151 | comes with Perl. | |
152 | ||
153 | This program is distributed in the hope that it will be useful, but | |
154 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
155 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the | |
156 | GNU General Public License or the Artistic License for more details. | |
157 | ||
158 | =cut |