forked from f4b10/X4GA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xframe.py
1999 lines (1646 loc) · 75.3 KB
/
xframe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/env python
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
# Name: xframe.py
# Author: Fabio Cassini <fabio.cassini@gmail.com>
# Copyright: (C) 2011 Astra S.r.l. C.so Cavallotti, 122 18038 Sanremo (IM)
# ------------------------------------------------------------------------------
# This file is part of X4GA
#
# X4GA is free software: you can redistribute it and/or modify
# it under the terms of the Affero GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# X4GA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with X4GA. If not, see <http://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------------
import sys
import wx
import wx.richtext
import lib
import stormdb as adb
import rss
import strumenti
appl = wx.GetApp()
__app__ = (appl is not None)
import xml.dom.minidom
if __app__:
def up():
if appl.splash:
appl.splash.UpdateProgress()
wx.SafeYield(onlyIfNeeded=True)
def setjob(x):
if appl:
if appl.splash:
appl.splash.SetJob(x)
else:
def up():
pass
def setjob(x):
pass
#setjob("Caricamento moduli di base")
import erman
up()
from version import __version__, __modversion__, MODVERSION_NAME
up()
import versionchanges
up()
import cfg.tabsetup as tabsetup
up()
import os
def opj(x, y):
return os.path.join(x, y).replace('\\', '/')
up()
import awc.controls.windows as aw
up()
import awc.util as awu
up()
import promem
up()
from X_wdr import *
up()
# ------------------------------------------------------------------------------
ID_TB_CLIENT = wx.NewId()
ID_TB_FORNIT = wx.NewId()
ID_TB_EMIDOC = wx.NewId()
ID_TB_INCPAG = wx.NewId()
ID_TB_INTSOTT = wx.NewId()
ID_TB_INTART = wx.NewId()
ID_TB_SCADCF = wx.NewId()
_evtSTATUSBAR_TEXTCHANGE_EVENT = wx.NewEventType()
EVT_STATUSBAR_TEXTCHANGE_EVENT = wx.PyEventBinder(_evtSTATUSBAR_TEXTCHANGE_EVENT, 0)
class StatusBarTextChangeEvent(wx.PyCommandEvent):
def __init__(self, text=''):
wx.PyCommandEvent.__init__(self, _evtSTATUSBAR_TEXTCHANGE_EVENT)
self.text = text
def SetText(self, text):
self.text = text
def GetText(self):
return self.text
# ------------------------------------------------------------------------------
class AutoCheckUpdates_Thread(object):
def __init__(self, parent):
object.__init__(self)
self.parent = parent
def Start(self):
import thread
self.keepGoing = self.running = True
thread.start_new_thread(self.Run, ())
def Stop(self):
self.keepGoing = False
def IsRunning(self):
return self.running
def Run(self):
self.TrigTextEvent('Controllo presenza aggiornamenti in corso...')
from prgup import VersionsDb
db = VersionsDb()
try:
downloads = db.CheckUpdates()
if downloads:
self.TrigTextEvent('Aggiornamenti disponibili!')
else:
self.TrigTextEvent('Nessun aggiornamento trovato.')
wx.Sleep(3)
self.TrigTextEvent('')
except Exception, e:
self.TrigTextEvent(repr(e.args))
self.running = False
def TrigTextEvent(self, msg):
try:
e = StatusBarTextChangeEvent(msg)
self.parent.GetEventHandler().AddPendingEvent(e)
except:
pass
# ------------------------------------------------------------------------------
class XFrame(aw.Frame):
def __init__(self, parent=None, id=-1, title="X4",
pos=(0,0), size=(600, 160),
style = wx.DEFAULT_FRAME_STYLE ):
aw.Frame.__init__(self, parent, id, title, pos, size, style)
show_promem = show_feeds = True
show_pages = []
self.custom_info = None
ci = self.GetFrameCustomInfo()
if ci and len(ci.getElementsByTagName('execute'))>0:
_Import, _Function, _Parameters = self.GetExecuteInfo(ci)
try:
m = __import__(_Import, {}, {}, False)
except:
m=None
print 'impossibile importare modulo %s' % _Import
aw.awu.MsgDialog(None, 'impossibile importare modulo %s' % _Import)
if m:
try:
function_to_call = getattr(m.lib, _Function)
function_to_call(_Parameters)
except:
print 'Funzione %s non trovata nel modulo %s' % (_Function, _Import )
aw.awu.MsgDialog(None, 'Funzione %s non trovata nel modulo %s' % (_Function, _Import ))
if ci and len(ci.getElementsByTagName('execute'))==0:
try:
f = ci.getElementsByTagName('customize_frame')[0]
def _int(n, d):
try:
return int(n)
except:
return d
show_promem = _int(f.getAttribute('promemoria'), 1)
show_feeds = _int(f.getAttribute('feeds'), 1)
frame_width = _int(f.getAttribute('width'), 0)
frame_height = _int(f.getAttribute('height'), 0)
if frame_width and frame_height:
def set_size():
self.SetSize((frame_width, frame_height))
wx.CallAfter(set_size)
except:
pass
for pages in ci.getElementsByTagName('pages'):
for page in pages.getElementsByTagName('page'):
pt = page.getAttribute('title')
pp = page.getAttribute('panel')
if pp and pt:
n = pp.rindex('.')
pm, pc = pp[:n], pp[n+1:]
m = __import__(pm, fromlist=True)
if hasattr(m, pc):
show_pages.append((pt, getattr(m, pc)))
self.menuext = []
self.ftdif = []
self.menupers = {}
self.toolpers = {}
self.toollist = []
self.CreateMenuBar()
self.CreateXToolBar()
self.CreateStatusBar(2)
self.SetStatusText("Welcome!")
self.DisplayUserStatusBar()
sizer = wx.FlexGridSizer(0, 1, 0, 0)
sizer.AddGrowableCol(0)
sizer.AddGrowableRow(0)
if show_promem or show_feeds or show_pages:
self.workzone = nb = wx.Notebook(self, -1)
sizer.Add(nb, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 0)
if show_promem:
try:
rp = promem.PromemPanel(nb, -1)
nb.AddPage(rp, 'Promemoria')
except:
show_promem = False
pass
if show_feeds:
feeds = [['Notizie (beta)', "http://www.ilsole24ore.com/rss/norme-e-tributi/fisco.xml"]]
i = self.custom_info
if i:
for ff in i.getElementsByTagName('feeds'):
for f in ff.getElementsByTagName('feed'):
try:
feeds.append([f.getAttribute('title'), f.getAttribute('url')])
except:
pass
for title, url in feeds:
rss.AddNotebookFeedPage(nb, title, url)
for title, Panel in show_pages:
nb.AddPage(Panel(nb), title)
self.SetSizer(sizer)
sizer.SetSizeHints(self)
self.Fit()
if len(self.MenuBar.GetMenus())>10:
n=len(self.MenuBar.GetMenus())-10
x,y=self.Size
self.Size=(x+(n*50), y)
self.Layout()
if show_promem:
rp.populate()
self.promem = rp
if hasattr(sys, 'frozen') or True:
rp.autoUpdate(5)
rp.startReminder(1)
self.Bind(lib.EVT_CHANGEMENU, self.OnChangeMenu)
self.Bind(EVT_STATUSBAR_TEXTCHANGE_EVENT, self.OnStatusBarTextChange)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
def GetExecuteInfo(self, ci):
f = ci.getElementsByTagName('execute')[0]
_Import = f.getElementsByTagName('import')[0].getAttribute('module')
_Function = f.getElementsByTagName('function')[0].getAttribute('name')
_Parameters={}
for n in f.getElementsByTagName('parameters')[0].childNodes:
if n.nodeType==xml.dom.minidom.Node.ELEMENT_NODE:
_Parameters[n.tagName]= n.firstChild.nodeValue
return _Import, _Function, _Parameters
def DisplayUserStatusBar(self):
import Env
v = Env.version
l = Env.Azienda.Login
sb = self.GetStatusBar()
msg = 'X4 v.%s' % v.VERSION_STRING
if v.MODVERSION_NAME:
msg += ' mod %s v.%s' % (v.MODVERSION_NAME, v.MODVERSION_STRING)
msg += ' - Op.: %s - %s' % (l.usercode, l.username)
self.SetStatusText(msg, sb.GetFieldsCount()-1)
def Show(self, *args, **kwargs):
aw.Frame.Show(self, *args, **kwargs)
cfg = Env.Azienda.config
if cfg.get('Updates', 'user') and cfg.get('Updates', 'pswd'):
if cfg.get('Updates', 'autocheck') == '2':
msg =\
"""E' possibile impostare questa workstation in modo che effettui\n"""\
"""automaticamente il controllo della presenza di nuove versioni\n"""\
"""all'avvio.\n\n"""\
"""Desideri attivare questa possibilità?"""
r = aw.awu.MsgDialog(self, msg, 'Aggornamenti automatici',
style=wx.ICON_QUESTION|wx.YES_NO|wx.YES_DEFAULT)
if r == wx.ID_YES:
v = '1'
else:
v = '0'
cfg.set('Updates', 'autocheck', v)
cfg.write()
self.AutoCheckUpdates()
def AutoCheckUpdates(self):
cfg = Env.Azienda.config
if cfg.get('Updates', 'user') and cfg.get('Updates', 'pswd'):
if cfg.get('Updates', 'autocheck') == '1':
t = AutoCheckUpdates_Thread(self)
t.Start()
def OnStatusBarTextChange(self, event):
sb = self.GetStatusBar()
text = event.GetText()
if text:
sb.SetStatusText(text, sb.GetFieldsCount()-1)
else:
self.DisplayUserStatusBar()
event.Skip()
def OnChangeMenu(self, event):
self.CreateMenuBar()
self.CreateXToolBar()
event.Skip()
def GetFrameCustomInfo(self):
if not hasattr(self, 'custom_info'):
self.custom_info = None
if self.custom_info is None:
ua = adb.DbTable('x4.diritti', 'ua')
ua.Reset()
if hasattr(ua, 'customize_frame'):
aa = adb.DbTable('x4.aziende', 'aa')
if aa.Retrieve('aa.codice=%s', Env.Azienda.codice) and aa.OneRow():
if ua.Retrieve('ua.id_azienda=%s AND ua.id_utente=%s AND ua.attivo=1',
aa.id, Env.Azienda.Login.userid) and ua.OneRow():
if ua.customize_frame:
try:
self.custom_info = xml.dom.minidom.parseString(ua.customize_frame)
return self.custom_info
except:
pass
p = None
try:
p = Env.Azienda.config.get('Site', 'folder')
except:
pass
if not p:
p = Env.config_base_path
p = opj(p, 'cust')
p = opj(p, 'frame')
p = opj(p, Env.Azienda.codice)
names = []
if Env.Azienda.params['execute']:
file=opj(p, Env.Azienda.params['execute'])
self.custom_info = xml.dom.minidom.parse(file)
else:
if Env.Azienda.params['custom-menu']:
names.append(Env.Azienda.params['custom-menu'])
names.append(Env.Azienda.Login.username)
names.append('__allusers__')
for f in names:
f = opj(p, f)
if not f.endswith('.x4f'):
f += '.x4f'
if os.path.exists(f):
try:
self.custom_info = xml.dom.minidom.parse(f)
break
except Exception, e:
aw.awu.MsgDialog(self, repr(e.args), style=wx.ICON_ERROR)
return self.custom_info
def GetMenuPers(self):
i = self.GetFrameCustomInfo()
if i:
try:
return i.getElementsByTagName('menu')[0]
except:
pass
return None
def GetFrameInfo(self):
i = self.GetFrameCustomInfo()
if i:
try:
f = i.getElementsByTagName('customize_frame')[0]
o = {}
for name in f.attributes.keys():
o[name] = f.getAttribute(name)
return o
except:
pass
return None
def CreateXMenuBar(self):
menubar = None
c = self.GetMenuPers()
if c:
err = False
menubar = wx.MenuBar()
for g in c.getElementsByTagName("group"):
menu = wx.Menu()
for v in g.getElementsByTagName("voice"):
keys = v.attributes.keys()
if 'menu' in keys:
mid = wx.NewId()
menu.Append(mid, v.getAttribute('menu'))
err = None
try:
sf, mv, md, fx = map(lambda x: v.getAttribute(x),
'frame menu desc function'.split())
if len(sf)>0:
isFrame=True
n = sf.rindex('.')
sm, sf = sf[:n], sf[n+1:]
else:
isFrame=False
n = fx.rindex('.')
sm, sf = fx[:n], fx[n+1:]
cm = __import__(sm, fromlist=True)
if not isFrame:
n=sf.index('(')
sf=sf[:n]
if isFrame and hasattr(cm, sf):
fc = getattr(cm, sf)
self.menupers[mid] = {'frame': fc,
'voice': mv,
'desc': md,}
for key in keys:
if key.startswith('frame_'):
self.menupers[mid][key] = v.getAttribute(key)
elif not isFrame and getattr(cm, sf, None):
fc = getattr(cm, sf)
self.menupers[mid] = {'function': fc,
'voice': mv,
'desc': md,}
else:
err = "Frame non trovato: %s" % sf
if not err:
tb = v.getAttribute('toolbar')
if tb:
n = tb.rindex('.')
tm, ti = tb[:n], tb[n+1:]
im = __import__(tm, fromlist=True)
if not hasattr(im, ti):
err = "Immagine toolbar non trovata: %s" % ti
else:
tid = wx.NewId()
if isFrame:
self.toolpers[tid] = {'image': getattr(im, ti),
'frame': fc,
'voice': mv,
'desc': md,}
else:
self.toolpers[tid] = {'image': getattr(im, ti),
'function': fc,
'voice': mv,
'desc': md,}
self.toollist.append(tid)
except Exception, e:
err = "Configurazione voce menu errata: %s" % repr(e.args)
except ImportError, e:
err = "Modulo non trovato: %s" % sm
if err:
aw.awu.MsgDialog(self, err, style=wx.ICON_ERROR)
else:
self.Bind(wx.EVT_MENU, self.OnMenuPers, id=mid)
elif 'separator' in keys:
if 'menu' in v.getAttribute('separator'):
menu.AppendSeparator()
if 'toolbar' in v.getAttribute('separator'):
if not -1 in self.toolpers:
self.toolpers[-1] = {'separator': True,}
self.toollist.append(-1)
if err:
break
menubar.Append(menu, g.getAttribute('name'))
if menubar is None and not self.menupers:
menubar = XMenuBarFunc()
return menubar
def CreateMenuBar(self):
menubar = self.CreateXMenuBar()
menubar = self.AdaptMenuBar_CheckSetup(menubar)
menubar = self.AdaptMenuBar_CheckUtente(menubar)
menubar = self.AdaptMenuBar_Clean(menubar)
self.SetMenuBar(menubar)
#costruzione menu fatturazione differita
mod = menubar.FindItemById(ID_MAGOPEDIF)
del self.menuext[:]
if mod:
mod = mod.GetSubMenu()
if mod:
fd = adb.DbTable(Env.Azienda.BaseTab.TABNAME_CFGFTDIF,
writable=False)
if fd.Retrieve():
def RunFtDif(fdid):
from magazz.ftdif import FtDifFrame
dlg = self.LaunchFrame(FtDifFrame, show=False)
dlg.SetRaggr(fdid)
dlg.Show()
for f in fd:
mid = wx.NewId()
mod.Append(mid, f.descriz)
self.menuext.append((mid, RunFtDif))
self.Bind(wx.EVT_MENU, self.OnMenuExt, id=mid)
self.ftdif.append((mid, f.id, f.codice, f.descriz))
#handlers menu
for func, cid in (
#gestione tabelle di base
(self.OnQuit, ID_QUIT),
(self.OnGestCasse, ID_GESCASSE),
(self.OnGestBanche, ID_GESBANCHE),
(self.OnGestEffetti, ID_GESEFFETT),
(self.OnGestCatCli, ID_GESCLIENT_CATEGO),
(self.OnGestStatCli, ID_GESCLIENT_STATUS),
(self.OnGestClienti, ID_GESCLIENT),
(self.OnGestCatFor, ID_GESFORNIT_CATEGO),
(self.OnGestStatFor, ID_GESFORNIT_STATUS),
(self.OnGestFornit, ID_GESFORNIT),
(self.OnGestProd, ID_GESPROD),
(self.OnGestProdPromo, ID_GESPRODPROMO),
(self.OnGestCatArt, ID_GESPROD_CATART),
(self.OnGestGruArt, ID_GESPROD_GRUART),
(self.OnGestInvStru, ID_GESINVSTR),
(self.OnGestStatArt, ID_GESPROD_STATUS),
(self.OnGestTipArt, ID_GESPROD_TIPART),
(self.OnGestMarArt, ID_GESPROD_MARART),
(self.OnGestTipList, ID_GESPROD_TIPLIST),
(self.OnGestGruPrez, ID_GESPROD_GRUPREZ),
(self.OnGestTesti, ID_GESTESTI),
(self.OnGestPdc, ID_GESBILPDC),
(self.OnGestPdcCee, ID_GESPDCCEE),
(self.OnGestStatPdc, ID_GESSTATPDC),
(self.OnGestPdcStru, ID_GESBILSTR),
(self.OnGestPdcRiclStru, ID_GESBILRICLSTR),
(self.OnGestBilMas, ID_GESBILMAS),
(self.OnGestBilCon, ID_GESBILCON),
(self.OnGestBriMas, ID_GESBRIMAS),
(self.OnGestBilCee, ID_GESBILCEE),
(self.OnGestBriCon, ID_GESBRICON),
(self.OnGestModPag, ID_GESMODPAG),
(self.OnGestAliqIva, ID_GESALQIVA),
(self.OnGestStati, ID_CFGSTATI),
(self.OnGestPdcTip, ID_GESTIPANA),
(self.OnGestScadGrp, ID_GESGRUSCA),
(self.OnGestListini, ID_GESLISVEN),
(self.OnGestStampaListino, ID_GESSTALIS),
(self.OnGestGrpCli, ID_GESGRPCLI),
(self.OnGestGrpFor, ID_GESGRPFOR),
(self.OnPrintGrpCli, ID_STAGRPCLI),
(self.OnPrintGrpFor, ID_STAGRPFOR),
(self.OnGestDatiFiscaliClienti, ID_GESDATIFISC_CLI),
(self.OnGestDatiFiscaliFornitori, ID_GESDATIFISC_FOR),
#gestione tabelle organizzazione maazzino/vendite
(self.OnGestZone, ID_GESTZONE),
(self.OnGestAgenti, ID_GESTAGENTI),
(self.OnGestSpeInc, ID_GESTSPEINC),
(self.OnGestMagazz, ID_CFGMAGAZZ),
#gestione tabelle dati trasporto x agazzino
(self.OnGestTraCau, ID_GESTRACAU),
(self.OnGestTraCur, ID_GESTRACUR),
(self.OnGestTraAsp, ID_GESTRAASP),
(self.OnGestTraPor, ID_GESTRAPOR),
(self.OnGestTraCon, ID_GESTRACON),
(self.OnGestTraVet, ID_GESTRAVET),
#interrogazioni contabili sottoconti/movimenti
(self.OnPdcInterrCli, ID_INTCONCLI),
(self.OnPdcInterrFor, ID_INTCONFOR),
(self.OnPdcInterrCas, ID_INTCONCAS),
(self.OnQuadRegCont, ID_CTR_QUADCON),
(self.OnPdcInterrBan, ID_INTCONBAN),
(self.OnPdcInterrEff, ID_INTCONEFF),
(self.OnPdcInterrPdc, ID_INTCONPDC),
(self.OnPcfInterrCli, ID_INTPCFCLI),
(self.OnPcfInterrFor, ID_INTPCFFOR),
#bilanci
(self.OnBilVerif, ID_CONTABIL_VERIF),
(self.OnBilGest, ID_CONTABIL_GEST),
(self.OnBilContr, ID_CONTABIL_CONTR),
(self.OnBilVerifRicl, ID_CONTABRI_VERIF),
(self.OnBilGestRicl, ID_CONTABRI_GEST),
(self.OnBilContrRicl, ID_CONTABRI_CONTR),
(self.OnBilCee, ID_CONTABIL_CEE),
#interrogazioni contabili
(self.OnScadenzario, ID_SCAD_SCAD),
(self.OnScadenzarioGruppo, ID_SCAD_SCADGRP),
(self.OnScadGlobal, ID_SCAD_GLOBAL),
(self.OnScadGlobalIncassi, ID_SCAD_GLOBAL_INCASSI),
(self.OnScadGlobalPagamenti, ID_SCAD_GLOBAL_PAGAMENTI),
(self.OnScadGlobalEffettiDaEm, ID_SCAD_GLOBAL_EFFETTIDAEMETTERE),
(self.OnScadGlobalEffettiEmessi, ID_SCAD_GLOBAL_EFFETTIEMESSI),
(self.OnScadGlobalEffettiInsoluti, ID_SCAD_GLOBAL_EFFETTIINSOLUTI),
(self.OnQuadPcfCont, ID_SCAD_CTRQUAD),
(self.OnCalcIntPcf, ID_SCAD_CALCINT),
(self.OnSituazioneFidiClienti, ID_SCAD_SITFIDO),
(self.OnCtrCassa, ID_CTR_CASSA),
(self.OnIntRegCon, ID_INTREGCON),
(self.OnEmiEffetti, ID_EMIEFF),
(self.OnAccorpaEffetti, ID_RAGGRPCF),
(self.OnMastriSottoconto, ID_CONTAB_MASTRI),
(self.OnGiornaleGenerale, ID_CONTAB_GIORNALE),
(self.OnFatturatoAcqVen, ID_FATCONACQVEN),
(self.OnVendAziPriv, ID_VENDAZIPRIV),
(self.OnVenditeXAliqIVA, ID_VENDXALIQIVA),
(self.OnSpesometro, ID_CONTAB_SPESOM),
#interrogazioni iva
(self.OnIntRegIva, ID_INTREGIVA),
(self.OnAliqRegIva, ID_INTALIQIVA),
(self.OnRegIva, ID_REGIVA),
(self.OnLiqIva, ID_LIQIVA),
#(self.OnAllegati, ID_ALLEGCF),
(self.OnCtrIvaSeq, ID_IVASEQ),
#interrogazioni magazzino prodotto/movimenti
(self.OnInterrProdotto, ID_INTPROD),
(self.OnIntDocMag, ID_INTDOCMAG),
(self.OnIntDocVet, ID_INTDOCVET),
(self.OnIntMovMag, ID_INTMOVMAG),
(self.OnIntEvaMag, ID_INTEVAMAG),
(self.OnIntInvPres, ID_INTGIAPRE),
(self.OnIntInvent, ID_INTINVENT),
(self.OnIntSottoSc, ID_INTSOTTOSC),
(self.OnIntMagSrcDes, ID_INTMAGSRCDES),
(self.OnIntMagProvAge, ID_PROVAGE),
(self.OnProdRiPro, ID_MAGPRODPRORIC),
(self.OnProdRiCos, ID_MAGPRODCOSTIZERO),
(self.OnPdcIntMagCli, ID_INTMAGCLI),
(self.OnPdcSituazioneAcconti, ID_INTMAGACC),
(self.OnPdcIntMagFor, ID_INTMAGFOR),
(self.OnBarCodesSpot, ID_BARCODESPOT),
#statistiche magazzino
(self.OnPdcFtProd, ID_PDCSINTART),
(self.OnStatFatCli, ID_STATFATCLI),
(self.OnStatFatCliCatArt, ID_STATFATCLICAT),
(self.OnStatFatFor, ID_STATFATFOR),
(self.OnStatFatForCatArt, ID_STATFATFORCAT),
(self.OnStatFatPro, ID_STATFATPRO),
(self.OnStatFatProCli, ID_STATFATPROCLI),
(self.OnStatFatAge, ID_STATFATAGE),
(self.OnStatFatCatArt, ID_STATFATCATART),
(self.OnStatValCosAcq, ID_STATCOSACQ),
(self.OnStatValPreApp, ID_STATPREAPP),
(self.OnStatReddVend, ID_STATREDDVEND),
#setup
(self.OnCfgLicense, ID_CFGLICENSE),
(self.OnCfgActivationCodes, ID_CFGACTIVATIONCODES),
(self.OnCfgAzienda, ID_CFGAZIENDA),
(self.OnCfgEmail, ID_CFGEMAIL),
(self.OnCfgXmpp, ID_CFGXMPP),
(self.OnCfgDocsEmail, ID_CFGDOCSEMAIL),
(self.OnCfgTipiEvento, ID_CFGTIPEVENT),
(self.OnCfgEventManager, ID_CFGEVENTMGR),
(self.OnCfgCauContab, ID_CFGCONCAU),
(self.OnCfgProgrContab, ID_CFGPROGRCON),
(self.OnCfgRegIva, ID_CFGREGIVA),
(self.OnCfgProgrIva, ID_CFGLIQIVA),
(self.OnCfgAutoContab, ID_CFGAUTCON),
(self.OnCfgCauMagazz, ID_CFGMAGCAU),
(self.OnCfgFtDif, ID_CFGFTDIF),
(self.OnCfgAutoMagazz, ID_CFGAUTMAG),
(self.OnCfgWorkstation, ID_CFGWKS),
(self.OnCfgUpdates, ID_CFGUPDATES),
(self.OnCfgPdcRange, ID_CFGPDCRANGE),
(self.OnCfgMassimaliSpesometro, ID_CFGSPESOM),
#dataentry contabili
(self.OnDataEntryContabIva, ID_CONTABGES_ACQVEN),
(self.OnDataEntryContabSaldaConto, ID_CONTABGES_INCPAG),
(self.OnDataEntryContabComposto, ID_CONTABGES_ALTRO),
(self.OnDataEntryContabSolaIva, ID_CONTABGES_SOLIVA),
(self.OnPcfNew, ID_SCADINS),
#dataentry magazzino
(self.OnDataEntryMagazz, ID_MAGAZZINS),
(self.OnStaDif, ID_STADIFF),
#chiusure contabili
(self.OnChiusContabGenMov, ID_CHIUSCONT_GENMOV),
(self.OnChiusContabSovrapp, ID_CHIUSCONT_SOVRAPP),
(self.OnChiusContabAnnuale, ID_CHIUSCONT_ANNUALE),
(self.OnChiusContabIVA, ID_CHIUSIVA_CHIUSIVA),
#chiusure magazzino
(self.OnChiusMagazzConsCosti, ID_CHIUSMAGAZZ_CREACOSTI),
(self.OnChiusMagazzEditGiacenze, ID_CHIUSMAGAZZ_EDITGIAC),
(self.OnChiusMagazzGenMoviIni, ID_CHIUSMAGAZZ_GENMOVINI),
(self.OnBackupExplorer, ID_BACKUPEXPLORER),
(self.OnChangeIva, ID_CHANGEIVA),
(self.OnSyncSede, ID_RUNSYNC),
(self.OnRepair, ID_REPAIRTABLE),
(self.OnHelp, ID_HELP),
(self.OnAbout, ID_ABOUT),
(self.OnProgramUpdate, ID_UPDATES),
(self.OnCatalogo, ID_CATALOGO),
):
self.Bind(wx.EVT_MENU, func, id=cid)
#menu specifici della mod
return menubar
def AdaptMenuBar_CheckSetup(self, menubar):
bt = Env.Azienda.BaseTab
#rimozione voci x bilanci riclassificati se non gestiti
if not bt.CONBILRICL:
for cid in (ID_GESTBILRICL, ID_BILRICL):
item = menubar.FindItemById(cid)
if item:
item.GetMenu().Remove(cid)
#rimozione voci x bilancio cee se non gestito
if not bt.CONBILRCEE:
for cid in (ID_GESTBILCEE, ID_BILCEE):
item = menubar.FindItemById(cid)
if item:
item.GetMenu().Remove(cid)
#rimozione voci x griglie prezzi se non gestite
for flag, cid in ((bt.MAGATTGRIP, ID_GRIPCLI),
(bt.MAGATTGRIF, ID_GRIPFOR)):
if not flag:
item = menubar.FindItemById(cid)
if item:
item.GetMenu().Remove(cid)
#rimozione voce x gestione acconti se non gestito
if bt.MAGGESACC != 1:
cid = ID_INTMAGACC
item = menubar.FindItemById(cid)
if item:
item.GetMenu().Remove(cid)
#rimozione voce x situazione fidi clienti
if bt.GESFIDICLI != '1':
cid = ID_SCAD_SITFIDO
item = menubar.FindItemById(cid)
if item:
item.GetMenu().Remove(cid)
#adeguamento voci di chiusura contabile in funzione della sovrapposizione
#gestita o meno e dello stato di esecuzione delle procedure di generazione
#movimenti di chiusura/apertura
from cfg.dbtables import ProgrEsercizio
pe = ProgrEsercizio()
try:
#menu attivazione sovrapposizione di esercizio
item = menubar.FindItemById(ID_CHIUSCONT_SOVRAPP)
if bt.CONSOVGES == 1:
#chiusure in sovrapposizione
if pe.GetSovrapposizione():
#sovrapposizione eseguita, disabilito voce di attivazione
item.GetMenu().Enable(ID_CHIUSCONT_SOVRAPP, False)
else:
#sovrapposizione non ancora attivata, disabilito voce generazione
item.GetMenu().Enable(ID_CHIUSCONT_GENMOV, False)
else:
#chiusure senza sovrapposizione, elimino voce di attivazione
item.GetMenu().Remove(ID_CHIUSCONT_SOVRAPP)
#menu generazione movimenti di chiusura/apertura
item = menubar.FindItemById(ID_CHIUSCONT_GENMOV)
if pe.GetMovimentiGenerati():
#movimenti già generati, disabilito voce generazione
item.GetMenu().Enable(ID_CHIUSCONT_GENMOV, False)
else:
#movimenti non acora generati, disabilito voce chiusura
item.GetMenu().Enable(ID_CHIUSCONT_ANNUALE, False)
#rimozione voci x listino attuale se non gestito o non x data
if bt.MAGNUMLIS == 0 or not bt.MAGDATLIS:
item = menubar.FindItemById(ID_GESSTALIS)
if item:
item.GetMenu().Remove(ID_GESSTALIS)
#rimozione voci x promozioni se non gestito
if not bt.MAGPPROMO:
item = menubar.FindItemById(ID_GESPRODPROMO)
if item:
item.GetMenu().Remove(ID_GESPRODPROMO)
#rimozione voci x provvigioni agenti se non gestite
if not bt.MAGPROVATT:
item = menubar.FindItemById(ID_MENUPROVAGE)
if item:
item.GetMenu().Remove(ID_MENUPROVAGE)
except:
pass
return menubar
def AdaptMenuBar_CheckUtente(self, menubar):
#inizio sequenza di controlli per rimozioni menu in base ai permessi dell'utente
datute = Env.Azienda.Login.userdata
#controllo permessi contabilità: tolgo tendina se non posso inserire, interrogare, gestire
try:
if datute.can_contabins != 1 and datute.can_contabint != 1 and datute.can_contabges != 1:
n = menubar.FindMenu('Contabilità')
if n >= 0:
menubar.Remove(n)
except Exception, e:
pass
#controllo permesso contabilità: inserimento
try:
if datute.can_contabins != 1:
item = menubar.FindItemById(ID_MENUCONTINS)
if item:
item.GetMenu().Delete(ID_MENUCONTINS)
except Exception, e:
pass
#controllo permesso contabilità: interrogazioni
try:
if datute.can_contabint != 1:
item = menubar.FindItemById(ID_MENUCONTINT)
if item:
item.GetMenu().Delete(ID_MENUCONTINT)
except Exception, e:
pass
#controllo permesso contabilità: stampe fiscali ed iva
try:
if datute.can_contabfis != 1:
for cid in (ID_MENUSTAFIS, ID_MENUIVA):
item = menubar.FindItemById(cid)
if item:
item.GetMenu().Delete(cid)
except Exception, e:
pass
#controllo permesso contabilità: bilanci
try:
if datute.can_contabbil != 1:
for cid in (ID_MENUBIL, ID_BILRICL, ID_BILCEE):
item = menubar.FindItemById(cid)
if item:
item.GetMenu().Delete(cid)
except Exception, e:
pass
#controllo permesso contabilità: gestione
try:
if datute.can_contabges != 1:
item = menubar.FindItemById(ID_MENUCONTGES)
if item:
item.GetMenu().Delete(ID_MENUCONTGES)
except Exception, e:
pass
#controllo permesso contabilità: scadenzari
try:
if datute.can_contabsca != 1:
n = menubar.FindMenu('Scadenzari')
if n >= 0:
menubar.Remove(n)
except Exception, e:
pass
#controllo permesso contabilità: effetti
try:
if datute.can_contabeff != 1:
n = menubar.FindMenu('Effetti')
if n >= 0:
menubar.Remove(n)
except Exception, e:
pass
#controllo permessi magazzino: tolgo tendina se non posso inserire, interrogare, fare op.differite, elaborare
try:
if datute.can_magazzins != 1 and datute.can_magazzint != 1 and datute.can_magazzdif != 1 and datute.can_magazzela != 1:
n = menubar.FindMenu('Magazzino')
if n >= 0:
menubar.Remove(n)
except Exception, e:
pass
#controllo permesso magazzino: inserimento
try:
if datute.can_magazzins != 1:
item = menubar.FindItemById(ID_MAGAZZINS)
if item:
item.GetMenu().Delete(ID_MAGAZZINS)
except Exception, e:
pass
#controllo permesso magazzino: inserimento
try:
if datute.can_magazzint != 1:
item = menubar.FindItemById(ID_MAGAZZINT)
if item:
item.GetMenu().Delete(ID_MAGAZZINT)
except Exception, e:
pass
#controllo permesso magazzino: inserimento
try:
if datute.can_magazzdif != 1:
item = menubar.FindItemById(ID_MAGOPEDIF)
if item:
item.GetMenu().Delete(ID_MAGOPEDIF)
except Exception, e:
pass
#controllo permesso magazzino: inserimento
try:
if datute.can_magazzela != 1:
item = menubar.FindItemById(ID_MENUMAGELAB)
if item:
item.GetMenu().Delete(ID_MENUMAGELAB)
except Exception, e:
pass
#controllo permessi setup impostazioni: tolgo tendina se non ho accesso a setup contab, magazz, impostaz, opzioni, altre impostazioni da esterno, altre opzioni da esterno
try:
if datute.can_setupcontab != 1 and datute.can_setupmagazz != 1 and datute.can_setupsetup != 1 and datute.can_setupoption != 1 and datute.can_setupother != 1 and datute.can_setupoptoth != 1:
item = menubar.FindItemById(ID_MENUSETUP)
if item:
item.GetMenu().Delete(ID_MENUSETUP)
except Exception, e:
pass
#controllo permesso setup: contabilità
try:
if datute.can_setupcontab != 1:
item = menubar.FindItemById(ID_MENUSETUP_CONTAB)
if item:
item.GetMenu().Delete(ID_MENUSETUP_CONTAB)
except Exception, e:
pass
#controllo permesso setup: magazzino
try:
if datute.can_setupmagazz != 1: