-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy patheproosystem.php
2085 lines (1847 loc) · 78.7 KB
/
eproosystem.php
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
<?php
/*
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
*
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
*
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
*
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
* to obtain the text of the corresponding license version.
*
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
*/
?>
<?php
/* Author: Benedikt Sauter <[email protected]> 2013
*
* Hier werden alle Plugins, Widgets usw instanziert die
* fuer die Anwendung benoetigt werden.
* Diese Klasse ist von class.application.php abgleitet.
* Das hat den Vorteil, dass man dort bereits einiges starten kann,
* was man eh in jeder Anwendung braucht.
* - DB Verbindung
* - Template Parser
* - Sicherheitsmodul
* - String Plugin
* - usw....
*/
date_default_timezone_set('Europe/Berlin');
ini_set('default_charset', 'UTF-8');
ini_set('display_errors', 'on');
ini_set('magic_quotes_runtime', 0);
require_once dirname(__DIR__).'/phpwf/class.application.php';
if( WithGUI(true))
{
define('FPDF_FONTPATH',__DIR__.'/lib/pdf/font/');
if(file_exists(__DIR__."/lib/dokumente/class.briefpapier_custom.php"))
{
require_once __DIR__.'/lib/dokumente/class.briefpapier_custom.php';
}else{
require_once __DIR__.'/lib/dokumente/class.briefpapier.php';
}
}
include __DIR__.'/function_exists.php';
class erpooSystem extends Application
{
public $obj;
public $starttime;
public $endtime;
protected $laendercache;
protected $uselaendercache;
/** @var erpAPI $erp
* @var Config $Conf
*/
public function __construct($config,$group='')
{
$this->uselaendercache = false;
parent::__construct($config, $group);
if(WithGUI()){
$module = $this->Secure->GetGET('module');
$action = $this->Secure->GetGET('action');
$this->Tpl->Set('DASHBOARDLINK', 'index.php?module=welcome&action=start');
$this->help = new Help($this);
$companyletter = strtoupper(substr($this->erp->Firmendaten('name'), 0, 1));
$this->Tpl->Set('COMPANYLETTER', ($companyletter != '' ? $companyletter : 'W'));
if($this->erp->Firmendaten('modul_mlm') != '1'){
$this->Tpl->Set('STARTDISABLEMLM', '<!--');
$this->Tpl->Set('ENDEDISABLEMLM', '-->');
}
if($this->erp->Firmendaten('modul_verband') != '1'){
$this->Tpl->Set('STARTDISABLEVERBAND', '<!--');
$this->Tpl->Set('ENDEDISABLEVERBAND', '-->');
}
if($this->erp->Version() === 'stock'){
$this->Tpl->Set('DISABLEOPENSTOCK', '<!--');
$this->Tpl->Set('DISABLECLOSESTOCK', '-->');
}
$icons = array('adresse', 'artikel', 'angebot', 'auftrag', 'lieferschein', 'rechnung');
foreach ($icons as $icon) {
if(!$this->erp->RechteVorhanden($icon, 'list')){
$this->Tpl->Set('ICON' . strtoupper($icon) . 'START', '<!--');
$this->Tpl->Set('ICON' . strtoupper($icon) . 'ENDE', '-->');
}
}
$this->Tpl->Set(strtoupper($module) . 'ACTIVE', 'active');
if(is_file('js/' . $module . '.js')){
$md5 = md5_file('js/' . $module . '.js');
if(!is_file('js/' . $module . $md5 . '.js')) {
@copy('js/' . $module . '.js', 'js/' . $module . $md5 . '.js');
}
if(is_file('js/' . $module . $md5 . '.js')){
$this->Tpl->Set('JSSCRIPTS', '<script type="text/javascript" src="./js/' . $module . $md5 . '.js?v=3"></script>');
}else{
$this->Tpl->Set('JSSCRIPTS', '<script type="text/javascript" src="./js/' . $module . '.js?v=3"></script>');
}
}
$this->erp->PrinterIcon();
$this->Tpl->ReadTemplatesFromPath(__DIR__ . '/widgets/templates/_gen/');
$this->Tpl->ReadTemplatesFromPath(__DIR__ . '/widgets/templates/');
$this->Tpl->ReadTemplatesFromPath(__DIR__ . '/themes/' . $this->Conf->WFconf['defaulttheme'] . '/templates/');
$this->Tpl->ReadTemplatesFromPath(__DIR__ . '/pages/content/_gen/');
$this->Tpl->ReadTemplatesFromPath(__DIR__ . '/pages/content/');
if(is_dir(__DIR__ . '/lib/versandarten/content')) {
$this->Tpl->ReadTemplatesFromPath(__DIR__ . '/lib/versandarten/content/');
}
if(method_exists($this->erp, 'VersionsInfos')){
$ver = $this->erp->VersionsInfos();
if(stripos($ver['Info'], 'Beta') !== false
|| stripos($ver['Info'], 'Alpha') !== false
|| stripos($ver['Info'], 'DEV') !== false
) $this->Tpl->Set('VERSIONINFO', strtoupper($ver['Info']));
}
$this->Tpl->Set('ID', $this->Secure->GetGET('id'));
$this->Tpl->Set('POPUPWIDTH', '1200');
$this->Tpl->Set('POPUPHEIGHT', '800');
$this->Tpl->Set('YEAR', date('Y'));
$this->Tpl->Set('COMMONREADONLYINPUT', '');
$this->Tpl->Set('COMMONREADONLYSELECT', '');
// templates laden
//statisch überladen
$this->Conf->WFconf['defaulttheme'] = 'new';
if(!empty($this->Conf->WFtestmode) && $this->Conf->WFtestmode == true)
$this->Tpl->Set('BODYSTYLE', 'style=background-color:red');
}
if(WithGUI(true)){
$benutzername = $this->erp->Firmendaten('benutzername');
$passwort = $this->erp->Firmendaten('passwort');
$host = $this->erp->Firmendaten('host');
$port = $this->erp->Firmendaten('port');
$mailssl = $this->erp->Firmendaten('mailssl');
$mailanstellesmtp = $this->erp->Firmendaten('mailanstellesmtp');
$noauth = $this->erp->Firmendaten('noauth');
$overviewpage = $this->Secure->GetGET('overviewpage');
$overviewpageAction = $this->Secure->GetGET('overviewpageaction');
$backlinkmodule = $this->Secure->GetGET('backlinkmodule');
$backlinkParameter = $this->Secure->GetGET('backlinkparameter');
// templates
}
if(WithGUI()){
$this->createSidebarNavigation();
$layout_iconbar = $this->erp->Firmendaten('layout_iconbar');
if($this->erp->Version() === 'stock'){
$this->Tpl->Set('STOCKOPEN', '<!--');
$this->Tpl->Set('STOCKCLOSE', '-->');
}
//nur wenn leiste nicht deaktiviert ist
if($layout_iconbar != 1){
if($this->erp->Firmendaten('iconset_dunkel') == '1'){
$this->Tpl->Parse('ICONBAR', 'iconbar_dunkel.tpl');
}
else{
$this->Tpl->Parse('ICONBAR', 'iconbar.tpl');
}
}else{
$this->Tpl->Parse('ICONBAR', 'iconbar_empty.tpl');
}
if($module !== 'kalender' && ($module !== 'welcome' && $action !== 'start')){
$this->Tpl->Add('YUICSS', '.ui-widget-content {}');
}
$overviewLink = null;
if(!empty($overviewpage)) {
$obj = $this->loadModule($overviewpage, false);
if($obj !== null && method_exists($obj, 'getOverViewLink')) {
$overviewLink = $obj->getOverViewLink($overviewpageAction);
}
}
$backlink = null;
if(!empty($backlinkmodule)) {
$obj = $this->loadModule($backlinkmodule, false);
if($obj !== null && method_exists($obj, 'getBackLink')) {
$backlink = $obj->getBackLink($backlinkParameter);
}
}
// back to overview for case apps/einstellungen
if($overviewLink !== null){
$this->Tpl->Set('BACKTOOVERVIEW', '<a href="'. $overviewLink .'" title="Zur Einstellungsübersicht" id="back-to-overview"></a>');
}
$this->Tpl->Set('MODULE', $module);
$this->Tpl->Set('ACTION', $action);
$this->Tpl->Set('THEME', $this->Conf->WFconf['defaulttheme']);
$doc_root = preg_replace("!{$_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME']); # ex: /var/www
$path = preg_replace("!^{$doc_root}!", '', __DIR__);
$this->Tpl->Set('WEBPATH', $path);
if(isset($backlink) && strpos($backlink,"index.php?module=") !== false && strpos($backlink, "&action=") !== false){
$this->Tpl->Set('TABSBACK', $backlink);
} else {
if($action === 'list' || $action == ''){
$this->Tpl->Set('TABSBACK', 'index.php');
}
else{
$this->Tpl->Set('TABSBACK', "index.php?module=$module&action=list");
}
}
$this->Tpl->Set('SAVEBUTTON', '<input type="submit" name="speichern" value="Speichern" class="button-sticky" />');
$this->help->Run();
$this->Tpl->Set('TMPSCRIPT', '');
$msg2 = $this->Secure->GetGET('msg');
$msgid = (int)$this->Secure->GetGET('msgid');
if($msgid && method_exists($this->erp, 'GetTmpMessageOut')){
$msg3 = $this->erp->GetTmpMessageOut($msgid);
$this->Tpl->Set('MESSAGE', $msg3);
}elseif($msg2 != ''){
$msg2 = $this->erp->base64_url_decode($msg2);
$this->Tpl->Set('MESSAGE', $msg2);
}
unset($msg3);
$module = $this->Secure->GetGET('module');
$this->Tpl->Set('MODULE', $module);
if($module == ''){
$module = 'welcome';
}
$this->Tpl->Set('ICON', $module);
$id = $this->Secure->GetGET('id');
$this->Tpl->Set('KID', $id);
// pruefe welche version vorliegt
include dirname(__DIR__).'/version.php';
$this->Tpl->Set('REVISION', $this->erp->Revision() . ' (' . $this->erp->Branch() . ')');
$this->Tpl->Set('REVISIONID', $this->erp->RevisionPlain());
$this->Tpl->Set('BRANCH', $this->erp->Branch());
$this->Tpl->Set('LIZENZHINWEIS', '| <a href="https://www.xentral.biz/lizenzhinweis" target="_blank">Lizenzhinweis</a>');
if($this->erp->Version() === 'OSS'){
$this->Tpl->Set('WAWIVERSION', 'Open-Source Lizenz AGPLv3.0');
}
else if($this->erp->Version() === 'ENT'){
$this->Tpl->Set('WAWIVERSION', 'Enterprise Version');
}
else if($this->erp->Version() === 'PRO'){
$this->Tpl->Set('WAWIVERSION', 'Professional Version');
}
else if($this->erp->Version() === 'PRE'){
$this->Tpl->Set('WAWIVERSION', 'Premium Version');
}
else{
$this->Tpl->Set('WAWIVERSION', 'Nutzungsbedingungen');
}
$this->Tpl->Set('TIMESTAMP', time());
$this->Tpl->Set('THEME', $this->Conf->WFconf['defaulttheme']);
$this->Tpl->Set('AKTIV_GEN_TAB1', 'selected');
if(file_exists(__DIR__ . '/pages/textvorlagen.php') && $this->Secure->GetGET('cmd') !== 'open'){
$showing = true;
if($action === 'edit' && in_array($module, array('auftrag', 'angebot', 'rechnung', 'bestellung', 'lieferschein'))){
$id = (int)$this->Secure->GetGET('id');
if($id && $this->DB->Select("SELECT count(id) FROM " . $module . "_position WHERE $module = '$id'") > 100) {
$showing = false;
}
}
if($showing && $this->erp->RechteVorhanden('textvorlagen', 'show')){
/** @var \Xentral\Widgets\DataTable\Service\DataTableService $service */
$service = $this->Container->get('DataTableService');
$buildConfig = new \Xentral\Widgets\DataTable\DataTableBuildConfig(
'texttemplates',
\Xentral\Modules\TextTemplate\DataTable\TextTemplateDataTable::class,
'index.php?module=textvorlagen&action=show&cmd=table',
false
);
$htmlData = $service->renderHtml($buildConfig);
$this->Tpl->Add('TABTEXTVORLAGEN', $htmlData);
$this->Tpl->Add('TVFILTERHEADER', '<fieldset><legend>Textvorlage suchen und einfügen</legend></fieldset>');
$this->YUI->AutoComplete('textvorlageprojekt', 'projektname', 1);
$this->YUI->CkEditor('textvorlagetext', 'belege');
$this->Tpl->Add('JSSCRIPTS', $this->Tpl->OutputAsString('textvorlagen.tpl'));
}
}
$hooktpl = 'JSSCRIPTS';
$this->erp->RunHook('eproosystem_ende', 1, $hooktpl);
}
}
/**
* @param {String} $path
* @param {String} $category
*
* @return String
*/
public function getSVG($path, $filename){
$filename = str_replace(' ', '', strtolower($filename));
$iconPath = $path . $filename . '.svg';
return file_get_contents($iconPath);
}
protected function getCounterFor(string $type)
{
}
/**
* creates and appends sidebar navigation
*/
public function createSidebarNavigation(){
include dirname(__DIR__).'/version.php';
$appstore = $this->loadModule('appstore');
$svgPath = 'themes/new/images/sidebar/';
$activeModule = $this->Secure->GetGET('module');
$activeAction = $this->Secure->GetGET('action');
$navigation = $this->Page->CreateNavigation($this->erp->Navigation(), true, $activeModule, $activeAction);
$activeCategory = $appstore->GetCategoryByModule($activeModule, $this->Secure->GetGET('id'));
$appointmentCount = (int)$this->DB->Select(
sprintf(
"SELECT COUNT(ke.id)
FROM kalender_event AS ke
LEFT JOIN kalender_user AS ku ON ku.event=ke.id
WHERE DATE_FORMAT(ke.von,'%%Y-%%m-%%d')=DATE_FORMAT(NOW(),'%%Y-%%m-%%d')
AND (
ke.adresse=%d
OR ke.adresseintern=%d
OR ku.userid=%d
)",
$this->User->GetAdresse(),$this->User->GetAdresse(), $this->User->GetID()
)
);
if($appointmentCount <=0) {
$appointmentCount=0;
}
if($this->erp->ModulVorhanden('wiedervorlage') && $this->erp->RechteVorhanden('wiedervorlage','list')) {
$resubmissionCount = (int)$this->DB->Select(
sprintf(
"SELECT count(*)
FROM `wiedervorlage` AS `w`
LEFT JOIN `adresse` AS `a` ON w.adresse = a.id
LEFT JOIN `projekt` AS `p` on p.id = a.projekt
WHERE w.abgeschlossen = 0
AND TIMESTAMP(concat(w.datum_erinnerung,' ',w.zeit_erinnerung)) < TIMESTAMP(now())
AND (w.adresse_mitarbeiter = %d OR (w.adresse_mitarbeiter=0 AND w.bearbeiter=%d)) ",
$this->User->getAdresse(),$this->User->getAdresse()
).$this->erp->ProjektRechte('w.projekt')
);
}
// Creates user specific items
$offene_tickets = $this->erp->AnzahlOffeneTickets(false);
$offene_tickets_user = $this->erp->AnzahlOffeneTickets(true);
$possibleUserItems = [
'Tickets' => [
'link' => 'index.php?module=ticket&action=list',
'counter' => ($offene_tickets+$offene_tickets_user > 0)?$offene_tickets_user."/".$offene_tickets:""
],
'Aufgaben' => [
'link' => 'index.php?module=aufgaben&action=list',
'counter' => $this->erp->AnzahlOffeneAufgaben()
],
/* 'Wiedervorlage' => [
'link' => 'index.php?module=wiedervorlage&action=list',
'counter' => $resubmissionCount,
],*/
'Kalender' => [
'link' => 'index.php?module=kalender&action=list',
'counter' => $appointmentCount
]
];
/* $possibleUserItems['Apps'] = [
'link'=> 'index.php?module=appstore&action=list&cmd=allapps'
];*/
$userItems = '<div class="sidebar-list small-items separator-bottom">';
foreach($possibleUserItems as $title => $data){
$classList = '';
$link = $data['link'];
$counter = isset($data['counter']) && ((is_int($data['counter']) && $data['counter'] >= 1)
|| (is_string($data['counter']) && $data['counter'] !== ''))
? '<div class="item-counter">'. $data['counter'] .'</div>'
: '';
$svg = $this->getSVG($svgPath, $title);
$active = '';
if(strtolower($title) === strtolower($activeModule)){
$active = 'current-module';
}
if(isset($data['type']) && $data['type'] === 'cta'){
$classList .= 'button button-secondary';
}
$userItems .=
'<a href="'. $link .'&top=' .base64_encode($title).'" class="list-item '. $active .' '. $classList .'">'
. $svg
. '<div class="title">'. $this->Tpl->pruefeuebersetzung($title) .'</div>'
. $counter
.'</a>';
}
$userItems .= '</div>';
// Creates main navigation steps
$naviHtml = '<div class="sidebar-list">';
foreach($navigation as $key => $listitem){
if(!empty($listitem)){
if (isset($listitem['original_title'])) {
$svg = $this->getSVG($svgPath, $listitem['original_title']);
} else {
$svg = $this->getSVG($svgPath, $listitem['title']);
}
$active = '';
if($listitem['active']) {
$active = 'current-module';
}
$naviHtml .=
'<div class="list-item '. $active .'">'
. $svg .
'<div class="title">'. $listitem['title'] .'</div>';
if(isset($listitem["sec"])){
$naviHtml .=
'<div class="sidebar-submenu">
<div>';
foreach($listitem["sec"] as $subkey => $subitem){
$naviHtml .= '<a href="'. $subitem['link'].'">'. $subitem['title'] .'</a>';
}
$naviHtml .= '</div>
</div>';
}
$naviHtml .= '</div>';
}
}
$naviHtml .= '</div>';
/** @var Dataprotection $obj */
$obj = $this->loadModule('dataprotection');
$showChat = $obj !== null
&& method_exists($obj, 'isZenDeskActive')
&& $obj->isZenDeskActive();
$possibleFixedItems = [];
if(!$showChat) {
$possibleFixedItems['Hilfe'] = 'id="showinlinehelplink"';
}
// Creates fixed bottom navigation items
// $possibleFixedItems['Datenschutz'] = 'index.php?module=dataprotection&action=list';
$fixedItems = '<div class="sidebar-list bottom">';
foreach($possibleFixedItems as $title => $link){
$svg = $this->getSVG($svgPath, $title);
$active = '';
if(strtolower($title) === strtolower($activeModule)){
$active = 'current-module';
}
if(strpos($link, 'index.php?') !== false){
$fixedItems .=
'<a href="'. $link .'&top=' .base64_encode($title).'" class="list-item '. $active .'">'
. $svg .
'<div class="title">'. $this->Tpl->pruefeuebersetzung($title) .'</div>'
.'</a>';
} elseif(strpos($link, 'id="') !== false) {
$fixedItems .=
'<div ' . $link . ' class="list-item">'
. $svg .
'<div class="title">'. $this->Tpl->pruefeuebersetzung($title) .'</div>'
.'</div>';
}
}
$fixedItems .= '</div>';
$version = '';
if(isset($version_revision) && $version_revision != '') {
$version .= '<div class="sidebar-software-version">OpenXE V.'. $version_revision .'</div>';
}
if($userId = $this->User->GetID()){
/** @var \Xentral\Modules\User\Service\UserConfigService $userConfig */
$userConfig = $this->Container->get('UserConfigService');
$sidebarCollapsed = $userConfig->tryGet('sidebar_collapsed', $userId);
$sidebarClasses = $sidebarCollapsed === true ? 'class="collapsed"' : '';
}else{
$sidebarClasses = '';
}
// set generated HTML to template
$this->Tpl->Set('USERITEMS', $userItems);
$this->Tpl->Set('NAVIGATIONITEMS', $naviHtml);
$this->Tpl->Set('FIXEDITEMS', $fixedItems);
$this->Tpl->Set('XENTRALVERSION', $version);
$this->Tpl->Set('SIDEBAR_CLASSES', $sidebarClasses);
$this->Tpl->Add('SIDEBARLOGO','<div class="sidebar_logo">'.@file_get_contents(__DIR__ . '/themes/new/templates/sidebar_logo.svg').'</div>');
$this->Tpl->Add('SIDEBARLOGO','<div class="sidebar_icon_logo">'.@file_get_contents(__DIR__ . '/themes/new/templates/sidebar_icon_logo.svg').'</div>');
$this->Tpl->Parse('SIDEBAR', 'sidebar.tpl');
$this->Tpl->Parse('PROFILE_MENU', 'profile_menu.tpl');
}
/**
* @return string
*/
public function CheckUserdata()
{
$isSecure = false;
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
$isSecure = true;
}
elseif ((!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') || (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')) {
$isSecure = true;
}
$REQUEST_PROTOCOL = $isSecure ? 'https' : 'http';
if(!empty($_SERVER['SCRIPT_URI']))
{
$weburl = $_SERVER['SCRIPT_URI'];
}elseif(!empty($_SERVER['REQUEST_URI']) && !empty($_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR']!=='::1' && (empty($_SERVER['SERVER_SOFTWARE']) || strpos($_SERVER['SERVER_SOFTWARE'],'nginx')===false))
{
$weburl = (isset($_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR']?$REQUEST_PROTOCOL.'://'.$_SERVER['SERVER_ADDR'].(!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443?':'.$_SERVER['SERVER_PORT']:''):'').$_SERVER['REQUEST_URI'];
} elseif(!empty($_SERVER['SERVER_NAME'])) //MAMP auf macos
{
$weburl = str_replace(array('setup/setup.php?step=5','setup/setup.php'),'',$REQUEST_PROTOCOL.'://'.$_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'].$_SERVER['SCRIPT_NAME']);
}else{
$weburl = '';
}
$userdatadir = $this->Conf->WFuserdata;
$tmpfile = md5(microtime(true)).'.html';
$ret = '';
if(!file_put_contents(rtrim($userdatadir,'/').'/'.$tmpfile,'TEST')){
$ret = 'Das Verzeichnis userdata ist nicht schreibbar (Rechte) oder die Festplatte ist voll';
}
if(!empty($weburl) && stripos($weburl, 'http') !== 0)
{
if(is_file(rtrim($userdatadir,'/').'/'.$tmpfile)){
unlink(rtrim($userdatadir,'/').'/'.$tmpfile);
}
if(method_exists($this->erp, 'setSystemHealth')) {
$this->erp->setSystemHealth('server', 'userdata_writeable',!empty($ret)?'warning':'ok', $ret);
}
return $ret;
}
$pos = strpos($weburl,'index.php');
if($pos){
$weburl = rtrim(substr($weburl, 0 , $pos),'/');
}
$thisfoldera = explode('/',__DIR__);
$userdataa = explode('/',$this->Conf->WFuserdata);
foreach($thisfoldera as $k => $v)
{
if(isset($userdataa[$k]) && $userdataa[$k] == $v)
{
unset($userdataa[$k], $thisfoldera[$k]);
}
}
$userdata = trim(implode('/', $userdataa),'/');
$thisfolder = trim(implode('/', $thisfoldera),'/');
if(substr($weburl, - strlen($thisfolder)) == $thisfolder)
{
$userdata = substr($weburl , 0, strlen($weburl) - strlen($thisfolder)).$userdata.'/';
}else
{
if(is_file(rtrim($userdatadir,'/').'/'.$tmpfile)){
unlink(rtrim($userdatadir,'/').'/'.$tmpfile);
}
if(method_exists($this->erp, 'setSystemHealth')) {
$this->erp->setSystemHealth('server', 'userdata_writeable', 'ok');
}
return $ret;
}
if(is_dir($userdatadir)) {
$content = @file_get_contents($userdata);
if($content != '') {
if(is_file(rtrim($userdatadir, '/') . '/' . $tmpfile)){
unlink(rtrim($userdatadir, '/') . '/' . $tmpfile);
}
$ret = 'Sicherheitswarnung: Verzeichnis userdata ist von extern einsehbar' . ($ret === '' ? '' : ' und nicht beschreibbar') . '!';
if(method_exists($this->erp, 'setSystemHealth')){
$this->erp->setSystemHealth('server', 'userdata_writeable', 'error', $ret);
}
return $ret;
}
if(file_put_contents(rtrim($userdatadir,'/').'/'.$tmpfile,'TEST')) {
if(@file_get_contents($userdata . $tmpfile) === 'TEST') {
unlink(rtrim($userdatadir, '/') . '/' . $tmpfile);
$ret = 'Sicherheitswarnung: Verzeichnis userdata ist von extern einsehbar' . ($ret === '' ? '' : ' und nicht beschreibbar') . '!';
if(method_exists($this->erp, 'setSystemHealth')){
$this->erp->setSystemHealth('server', 'userdata_writeable', 'error', $ret);
}
return $ret;
}
unlink(rtrim($userdatadir,'/').'/'.$tmpfile);
if(method_exists($this->erp, 'setSystemHealth')) {
$this->erp->setSystemHealth('server', 'userdata_writeable', 'ok');
}
return '';
}
}
if(is_file(rtrim($userdatadir,'/').'/'.$tmpfile)){
unlink(rtrim($userdatadir,'/').'/'.$tmpfile);
}
$this->erp->setSystemHealth('server', 'userdata_writeable', 'ok');
return $ret;
}
public function calledBeforeFinish()
{
}
public function Laender($module, $action, $id, $lid)
{
/*********** select field for projekt ***************/
$selectid = $this->Secure->GetPOST('projekt');
if($selectid=='' && $module !== 'projekt') {
/*
Removed because of module tables that have no projekt id
if(!empty($this->Conf->WFdbType) && $this->Conf->WFdbType==='postgre')
{
//POSTGRE --> dringend bei statements wo es die tabelle gibt machen!
$selectid = $this->DB->Select("SELECT projekt FROM `$module` WHERE id='$id' LIMIT 1");
} else {
$selectid = $id > 0?$this->DB->Select("SELECT projekt FROM `$module` WHERE id='$id' LIMIT 1"):NULL;
}*/
}
$color_selected = '';
$options = $this->erp->GetProjektSelect($selectid,'');
$this->Tpl->Set('EPROO_SELECT_PROJEKT',"<select name=\"projekt\"
style=\"background-color:$color_selected;\"
onChange=\"this.style.backgroundColor=this.options[this.selectedIndex].style.backgroundColor\">$options</select>");
$this->Tpl->Set('EPROO_SELECT_UNTERPROJEKT','<div id="selectunterprojekt">
<select name="unterprojekt">
</select>
</div>');
$this->Tpl->Set('LESEZEICHEN','<a title="Angebot" href="index.php?module=angebot&action=search">Angebotssuche</a> ');
$this->Tpl->Add('LESEZEICHEN','<a title="Auftrag" href="index.php?module=auftrag&action=search">Auftragssuche</a> ');
$this->Tpl->Add('LESEZEICHEN','<a title="Rechnung" href="index.php?module=rechnung&action=search">Rechnungssuche</a> ');
$this->Tpl->Add('LESEZEICHEN','<a title="Adresse" href="index.php?module=adresse&action=search">Adressensuche</a> ');
$this->Tpl->Add('LESEZEICHEN','<a title="Adresse" href="index.php?module=wareneingang&action=paketannahme">Paket Annahme</a>');
$this->Tpl->Set('KURZUEBERSCHRIFT',$module);
if($action==='edit'){
$this->Tpl->Add('KURZUEBERSCHRIFT1', 'BEARBEITEN');
}
$this->Tpl->Set('KURZUEBERSCHRIFTFIRSTUPPER',ucfirst($module));
/*********** select field for projekt ***************/
if($this->Secure->GetPOST('land')=='' && $this->Secure->GetGET('land')=='')
{
if(in_array($module, array('adresse', 'adresse_import', 'anfrage', 'angebot', 'ansprechpartner', 'arbeitsnachweis', 'auftrag', 'belege', 'belegegesamt', 'belegeregs', 'bestellung', 'bundesstaaten', 'dokumente', 'gutschrift', 'inventur', 'laendersteuersaetze', 'lieferadressen', 'lieferschein', 'preisanfrage', 'produktion', 'proformarechnung', 'projekt', 'rechnung', 'retoure', 'serviceauftrag', 'shopexport_sprachen', 'shopexport_versandarten', 'spedition', 'spedition_packstuecke', 'steuertexte', 'ustprf', 'verpackungen_details')))
{
$countryField = 'land';
if ($module === 'retoure') {
$countryField = 'lieferland';
}
$sqlCountry = sprintf('SELECT %s FROM `%s` WHERE id = %d LIMIT 1', $countryField, $module, $id);
$selectid = $id ? $this->DB->Select($sqlCountry) : '';
}else{
$selectid = '';
}
if(empty($selectid)) {
$selectid = $lid?$this->DB->Select("SELECT land FROM `lieferadressen` WHERE id='$lid' LIMIT 1"):'';
}
}
else if($this->Secure->GetGET('land')!=''){
$selectid = $this->Secure->GetGET('land');
}
else{
$selectid = $this->Secure->GetPOST('land');
}
/*********** select field for projekt ***************/
if($module==='adresse' && $this->Secure->GetPOST('rechnung_land')=='' && $this->Secure->GetGET('rechnung_land')=='')
{
$selectidrechnung = $id?$this->DB->Select("SELECT rechnung_land FROM adresse WHERE id='$id' LIMIT 1"):'';
}
else{
$selectidrechnung = $this->Secure->GetPOST('rechnung_land');
}
/*********** select field for projekt ***************/
$lid = $this->Secure->GetGET('lid');
if($module==='adresse' && $this->Secure->GetPOST('ansprechpartner_land')=='' && $this->Secure->GetGET('ansprechpartner_land')=='')
{
$selectidansprechpartner = $lid?$this->DB->Select("SELECT ansprechpartner_land FROM ansprechpartner WHERE id='$lid' LIMIT 1"):'';
if(empty($selectidansprechpartner)) {
$selectidansprechpartner = $this->DB->Select("SELECT land FROM adresse WHERE id='$id' LIMIT 1");
}
//if($selectid<=0 && $module=="lieferadressepopup") $this->DB->Select("SELECT land FROM `lieferadressen` WHERE id='$id' LIMIT 1");
}
else{
$selectidansprechpartner = $this->Secure->GetPOST('ansprechpartner_land');
}
if($module==='adresse' && $this->Secure->GetPOST('land')=='' && $this->Secure->GetGET('land')=='')
{
$selectidlieferadresse = $lid?$this->DB->Select("SELECT land FROM lieferadressen WHERE id='$lid' LIMIT 1"):'';
if($selectidlieferadresse =='') {
$selectidlieferadresse = $this->DB->Select("SELECT land FROM adresse WHERE id='$id' LIMIT 1");
}
}
else{
$selectidlieferadresse = $this->Secure->GetPOST('land');
}
if($module==='proformarechnung' && $this->Secure->GetPOST('verzollungland')=='' && $this->Secure->GetGET('verzollungland')=='')
{
$selectidverzollung = $this->DB->Select("SELECT verzollungland FROM proformarechnung WHERE id='$id' LIMIT 1");
}
else{
$selectidverzollung = $this->Secure->GetPOST('land');
}
$this->uselaendercache = true;
$this->Tpl->Set('EPROO_SELECT_LAND',"<select name=\"land\" id=\"land\" [COMMONREADONLYSELECT]>".$this->SelectLaenderliste($selectid)."</select>");
$this->Tpl->Set('EPROO_SELECT_LIEFERLAND',"<select name=\"lieferland\" id=\"lieferland\" [COMMONREADONLYSELECT]>".$this->SelectLaenderliste($selectid)."</select>");
$this->Tpl->Set('EPROO_SELECT_LAND_RECHNUNG',"<select name=\"rechnung_land\" id=\"rechnung_land\" [COMMONREADONLYSELECT]>".$this->SelectLaenderliste($selectidrechnung)."</select>");
$this->Tpl->Set('EPROO_SELECT_LAND_ANSPRECHPARTNER',"<select name=\"ansprechpartner_land\" id=\"ansprechpartner_land\" [COMMONREADONLYSELECT]>".$this->SelectLaenderliste($selectidansprechpartner)."</select>");
$this->Tpl->Set('EPROO_SELECT_LAND_LIEFERADRESSEN',"<select name=\"land\" id=\"land\" [COMMONREADONLYSELECT]>".$this->SelectLaenderliste($selectidlieferadresse)."</select>");
$this->Tpl->Set('EPROO_SELECT_LAND_VERZOLLUNG',"<select name=\"verzollungland\" id=\"land\" [COMMONREADONLYSELECT]>".$this->SelectLaenderliste($selectidverzollung)."</select>");
$this->uselaendercache = false;
if($this->Secure->GetPOST('lieferland')=='')
{
if(in_array($module,array('amazon_inboundshipmentplan', 'angebot', 'auftrag', 'bestellung', 'produktion', 'proformarechnung', 'retoure', 'serviceauftrag', 'spedition')))
{
$selectid = $id?$this->DB->Select("SELECT lieferland FROM `$module` WHERE id='$id' LIMIT 1"):'';
}else {
$selectid = '';
}
}
else{
$selectid = $this->Secure->GetPOST('lieferland');
}
$this->Tpl->Set('EPROO_SELECT_LIEFERLAND','<select name="lieferland" id="lieferland" [COMMONREADONLYSELECT]>'.$this->SelectLaenderliste($selectid).'</select>');
$this->Tpl->Set('VORGAENGELINK',"<a href=\"#\" onclick=\"var ergebnistext=prompt('Lesezeichen:','".ucfirst($module)."'); if(ergebnistext!='' && ergebnistext!=null) window.location.href='index.php?module=welcome&action=vorgang&titel='+ergebnistext;\">*</a>");
if($module==='adresse' || $module==='artikel' || $module==='angebot' || $module==='rechnung' || $module==='auftrag' || $module==='gutschrift' || $module==='lieferschein'
|| $module==='onlineshops' || $module==='geschaeftsbrief_vorlagen' || $module==='emailbackup' || $module==='ticket_vorlage')
{
// module auf richtige tabellen mappen
if($module==='onlineshops') {
$this->erp->Standardprojekt('shopexport',$id);
}
else {
$this->erp->Standardprojekt($module,$id);
}
$bezeichnungaktionscodes = $this->erp->Firmendaten('bezeichnungaktionscodes');
if((String)$bezeichnungaktionscodes === ''){
$bezeichnungaktionscodes = 'Aktionscode';
}
$this->Tpl->Set('BEZEICHNUNGAKTIONSCODE', $bezeichnungaktionscodes);
}
}
/**
* @param string $module
* @param string $action
* @param int $id
*/
public function addPollJs($module, $action, $id)
{
$noTimeoutUserEdit = 0;
$startTime = 3000;
$repeatTime = 5000;
$firmendaten_repeattime = 1000*(int)$this->erp->Firmendaten('poll_repeattime');
if($firmendaten_repeattime > $repeatTime) {
$repeatTime = $firmendaten_repeattime;
if($repeatTime > 25000) {
$repeatTime = 25000;
}
}
$invisibleTime = 25000;
if(empty($id)
|| (
in_array($module, ['auftrag','rechnung','gutschrift','angebot','lieferschein'], false)
&&
$this->DB->Select(
sprintf(
'SELECT schreibschutz FROM `%s` WHERE id = %d',
$module,
$id
)
)
)
) {
$noTimeoutUserEdit = 1;
}
if($action !== 'positionen'){
$pollUid = sha1(uniqid('poll', true));
$this->Tpl->Add('JAVASCRIPT', "
var logErrorCount = 0;
var hidden, visibilityChange;
if (typeof document.hidden !== \"undefined\") { // Opera 12.10 and Firefox 18 and later support
hidden = \"hidden\";
visibilityChange = \"visibilitychange\";
} else if (typeof document.msHidden !== \"undefined\") {
hidden = \"msHidden\";
visibilityChange = \"msvisibilitychange\";
} else if (typeof document.webkitHidden !== \"undefined\") {
hidden = \"webkitHidden\";
visibilityChange = \"webkitvisibilitychange\";
}
function showLockScreen(errorMsg) {
logErrorCount++;
if (typeof errorMsg !== 'undefined' && errorMsg !== null) {
console.error('Polling error: ' + errorMsg);
}
if (typeof LockScreen === 'undefined') {
return;
}
if(logErrorCount <= 2) {
return;
}
LockScreen.show();
}
function hideLockScreen() {
if (typeof LockScreen === 'undefined') { return; }
LockScreen.hide();
}
// Benutzer hat Sperrbildschirm per Button geschlossen
// => Sperrbildschirm schliessen und Counter zurücksetzen
function resetLockScreen() {
if (typeof LockScreen === 'undefined') { return; }
LockScreen.hide();
logErrorCount = 0;
}
var isloggedin = true;
function executeQuery() {
if(typeof generate == 'undefined'){
return;
}
$.ajax({
url: 'index.php?module=welcome&action=poll&smodule=$module&cmd=messages&saction=$action&sid=$id&user=" .
$this->User->GetID().(!empty($noTimeoutUserEdit)?'&nousertimeout=1':'') . "&uid=".$pollUid."',
type: 'POST',
data:{
invisible : typeof document.hidden != 'undefined'?
(document.hidden?1:0):
(typeof document.msHidden !== 'undefined'?
(document.msHidden?1:0):(typeof document.webkitHidden != 'undefined'?(document.webkitHidden?1:0):2))
},
success: function(data) {
if (data === '') {
showLockScreen('Polling result is empty.');
return;
}
// do something with the return value here if you like
try {
var meinelist = JSON.parse(data);
} catch (err) {
showLockScreen('JSON parse error (' + err + ')');
return;
}
logErrorCount = 0;
// Hide lock screen on successful request
hideLockScreen();
for(var i=0;i<meinelist.length;i++)
{
obj = meinelist[i];
if (typeof obj.event !== 'undefined') {
switch(obj.event)
{
case 'logout':
isloggedin = false;
break;
case 'chatbox':
generate('chatbox', obj.message);
break;
case 'notification':
if (typeof Notify === 'undefined') {
console.warn('Notify not found.');
return;
}
// Benachrichtigung erstellen
Notify.create(obj.type, obj.title, obj.message, obj.priority, obj.options);
break;
}
}
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
if (XMLHttpRequest.readyState === 4) {
// HTTP error
var statusCode = XMLHttpRequest.status;
var statusText = XMLHttpRequest.statusText;
showLockScreen('HTTP error (' + statusCode + ' ' + statusText + ')');
} else if (XMLHttpRequest.readyState === 0) {
// Network error (connection refused, connection lost, access denied, ...)
showLockScreen('Network error.');
} else {
// Something weird is happening
showLockScreen('Unknown request error.');
}
}
});
if(isloggedin){
setTimeout(executeQuery, (typeof hidden == 'undefined' || !document[hidden])?".$repeatTime.":".$invisibleTime."); // you could choose not to continue on failure...
}
else {
logErrorCount=3;
showLockScreen('logged out.');
}
}
$(document).ready(function() {
// run the first time; all subsequent calls will take care of themselves
setTimeout(executeQuery, ".$startTime.");
// Benutzer kann Sperrbildschirm per Button schliessen