summaryrefslogtreecommitdiff
path: root/views/order/index.phtml
blob: 0292d90c36eef86c2d63e88b2353d72aa203ed7a (plain)
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
<?php
	
	/**
	 * Template für die Übersicht der Bestellungen
	 * @version 4.6.1
	 */

	$arPaymentKeySelect = [
	    '' => __('Alle Zahlungsarten', 'wpsg')
    ];
	
	foreach ($this->getPaymentArray() as $payment_key => $payment) {
	    
	    $arPaymentKeySelect[$payment_key] = $payment['name'];
	    
    }
    
?>
 
<div class="wpsg_order" id="wpsg-bs">

	<nav class="navbar navbar-default">
		<div class="container-fluid">
			<div class="navbar-header">
                
				<a class="navbar-brand" href="#"><?php echo __('wpShopGermany', 'wpsg'); ?></a>
                <a class="glyphicon glyphicon-menu-hamburger wpsg-bs-toggle-nav visible-xs-block" data-toggle="collapse" data-target="#wpsg-bs-headermenu" href="#"></a>
                
			</div>
			<div class="collapse navbar-collapse" id="wpsg-bs-headermenu">
				<ul class="nav navbar-nav">
					<li role="presentation" class="<?php echo ((!isset($_REQUEST['action']))?'active':''); ?>"><a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order" onclick="return false;"><?php echo __("Bestellübersicht", "wpsg"); ?></a></li>
					<li role="presentation" class="wpsg_showhide_filter wpsg-order-tab-a <?php echo (($this->view['hasFilter'] === true)?'active':''); ?>" id="wpsg-order-tab-0"><a href="#" onclick="return false;"><span class="glyphicon glyphicon-search"></span><?php echo __("Suche", "wpsg"); ?></a></li>
                    <?php foreach ($this->view['tabs']['left'] as $k => $tab) { ?>
                    <li role="presentation" class="wpsg-order-tab-a wpsg-order-tab-mods" id="wpsg-order-tab-<?php echo $k; ?>"><a href="#" onclick="return false;"><span class="<?php echo $tab['tab_icon']; ?>"></span><?php echo $tab['tab_title']; ?></a></li>
                    <?php } ?>
                    <li role="presentation" class="wpsg-order-tab-a wpsg-order-tab-mods" id="wpsg-order-tab-add"><a href="#" onclick="return false;"><span class="glyphicon glyphicon-plus"></span><?php echo __("Neue Bestellung", "wpsg"); ?></a></li>
				</ul>
				<ul class="nav navbar-nav navbar-right">
                    <?php foreach ($this->view['tabs']['right'] as $k => $tab) { ?>
                    <li role="presentation" class="wpsg-order-tab-mods" id="wpsg-order-tab-<?php echo $k; ?>"><a href="#" onclick="return false;"><span class="<?php echo $tab['tab_icon']; ?>"></span><?php echo $tab['tab_title']; ?></a></li>
                    <?php } ?>
				</ul>
			</div>
		</div>

		<div class="wpsg-filter wpsg-order-tab wpsg-order-tab-0 container-fluid form-horizontal" style="display:<?php echo (($this->view['hasFilter'] === true)?'block':'none'); ?>;">
			<div class="row">
				<div class="col-lg-5">
					<form method="post" id="filter_form" >

						<?php echo wp_nonce_field('wpsg-order-search'); ?>
						
						<input id="wpsg_seite" type="hidden" name="seite" value="<?php echo @$this->view['arFilter']['page']; ?>" class="current-page" />
						<input id="wpsg_order" type="hidden" name="filter[order]" value="<?php echo @$this->view['arFilter']['order']; ?>" />
						<input id="wpsg_ascdesc" type="hidden" name="filter[ascdesc]" value="<?php echo @$this->view['arFilter']['ascdesc']; ?>" />

						<input type="hidden" name="filter[voucher_id]" value="<?php echo intval($this->view['arFilter']['voucher_id']??0); ?>" />
						
						<?php echo wpsg_drawForm_Input('filter[s]', __('Suchfeld', 'wpsg'), wpsg_getStr($this->view['arFilter']['s'])); ?>
                        <?php echo wpsg_drawForm_Input('filter[k_id]', __('Kunde (ID)', 'wpsg'), wpsg_getStr($this->view['arFilter']['k_id'])); ?>
                        <?php echo wpsg_drawForm_Select('filter[payment_key]', __('Zahlungsart', 'wpsg'), $arPaymentKeySelect, wpsg_getStr($this->view['arFilter']['payment_key'])); ?>
						<?php echo wpsg_drawForm_Select('filter[status]', __('Bestellstatus', 'wpsg'), wpsg_array_merge(array('-1' => __('Alle', 'wpsg')), $this->arStatus), @$this->view['arFilter']['status']); ?>
						
						<?php /* if ($this->hasMod('wpsg_mod_produktartikel')) { Vorbereitet aber Joins in wpsg_order nach den wp Ktegorien noch nicht umgesetzt! ?>
							
							<?php $arCatSelect = []; $arCat = $this->callMod('wpsg_mod_produktartikel', 'getProductcategorySelect'); foreach ($arCat as $cat) $arCatSelect[$cat['term_id']] = $cat['label']; ?>
							<?php  echo wpsg_drawForm_Select('filter[cat_term_id]', __('Bestellungen mit Produkten aus Kategorie'), ['0' => __('Alle', 'wpsg')] + $arCatSelect, wpsg_getStr($this->view['arFilter']['cat_term_id'])); ?>
						
						<?php } */ ?>
						
						<?php if ($this->hasMod('wpsg_mod_productgroups') && $this->get_option('wpsg_mod_productgroups_order_filter') === '1') { ?>
						
							<?php $arProductgroups = $this->callMod('wpsg_mod_productgroups', 'getAllProductGroups'); ?>
							<?php  echo wpsg_drawForm_Select('filter[productgroup_id]', __('Bestellungen mit Produkten aus Produktgruppe', 'wpsg'), ['0' => __('Alle', 'wpsg')] + $arProductgroups, wpsg_getStr($this->view['arFilter']['productgroup_id'])); ?>
							
						<?php } ?>
						
                        <?php echo wpsg_drawForm_TextStart(); ?>
                        <div class="row">
                            <div class="col-lg-6">
                                <select name="filter[cdate_m]" class="form-control input-sm">
                                    <option value="-1"><?php echo __("Alle", "wpsg"); ?></option>
                                    <?php for ($i = 1; $i <= 12; $i ++) { ?>
                                    <option <?php echo ((wpsg_getStr($this->view['arFilter']['cdate_m']) == $i)?'selected="selected"':''); ?> value="<?php echo str_pad($i, 2, '0', STR_PAD_LEFT); ?>"><?php echo __(date('F', mktime(0, 0, 0, $i, 1, 2000))); ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                            <div class="col-lg-6">
                                <select name="filter[cdate_y]" class="form-control input-sm">
                                    <option value="-1"><?php echo __("Alle", "wpsg"); ?></option>
                                    <?php foreach ($this->view['cdate_years'] as $y) { ?>
                                    <option <?php echo ((wpsg_getStr($this->view['arFilter']['cdate_y']) == $y)?'selected="selected"':''); ?> value="<?php echo $y; ?>"><?php echo $y; ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                        <?php echo wpsg_drawForm_TextEnd(__('Bestelldatum (Monat/Jahr)', 'wpsg'), array('noP' => true)); ?>

						<?php if ($this->hasMod('wpsg_mod_rechnungen')) { ?>
							<?php echo wpsg_drawForm_TextStart(); ?>
							<div class="row">
								<div class="col-lg-6">
									<select name="filter[invoicedate_m]" class="form-control input-sm">
										<option value="-1"><?php echo __("Alle", "wpsg"); ?></option>
										<?php for ($i = 1; $i <= 12; $i ++) { ?>
										<option <?php echo ((wpsg_getStr($this->view['arFilter']['invoicedate_m']) == $i)?'selected="selected"':''); ?> value="<?php echo str_pad($i, 2, '0', STR_PAD_LEFT); ?>"><?php echo esc_html(wp_date('F', mktime(0, 0, 0, $i, 1, 2000))); ?></option>
										<?php } ?>
									</select>
								</div>
								<div class="col-lg-6">
									<select name="filter[invoicedate_y]" class="form-control input-sm">
										<option value="-1"><?php echo __("Alle", "wpsg"); ?></option>
										<?php foreach ($this->view['invoicedate_years'] as $y) { ?>
										<option <?php echo ((wpsg_getStr($this->view['arFilter']['invoicedate_y']) == $y)?'selected="selected"':''); ?> value="<?php echo $y; ?>"><?php echo $y; ?></option>
										<?php } ?>
									</select>
								</div>
							</div>
							<?php echo wpsg_drawForm_TextEnd(__('Rechnungsdatum (Monat/Jahr)', 'wpsg'), array('noP' => true)); ?>
						<?php } ?>

    					<br />
                        
                        <?php echo wpsg_drawForm_SubmitButton(__('Bestellungen suchen', 'wpsg')); ?>

					</form>
				</div>
			</div>
		</div>
	
        <?php foreach ($this->view['tabs'] as $tab_positions) { ?>
        <?php foreach ($tab_positions as $k => $tab) { ?>
        <div class="wpsg-order-tab-mods-content wpsg-filter-tab wpsg-order-tab-<?php echo $k ?>" style="display:none;"><?php echo $tab['tab_content']; ?></div>
        <?php } ?>
        <?php } ?>
        
        <div class="wpsg-order-tab-add-content wpsg-order-tab-add" style="display:none;">

            <div class="container-fluid form-horizontal">
                <div class="row">
                    <div class="col-lg-4">
                        
                        <form method="POST" id="add_form" action="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&subaction=add&noheader=1">
	
							<?php echo wp_nonce_field('wpsg-order-add'); ?>
							                            
                            <br />
                            
                            <?php echo wpsg_drawForm_Input('search_customer',__('Kunde (E-Mail oder Kundennummer)', 'wpsg'), wpsg_getStr($_REQUEST['search_customer'])); ?>
                            
                            <br />
							
                            <?php $arShippingSelect = []; foreach ($this->arShipping as $shipping_id => $shipping) if (!isset($shipping['active']) || $shipping['active'] === '1') $arShippingSelect[$shipping_id] = $shipping['name'].' ('.wpsg_ff(@$shipping['price']).')'; ?>
                            <?php echo wpsg_drawForm_Select('add_shipping', __('Versandart', 'wpsg'), $arShippingSelect, wpsg_getStr($_REQUEST['add_shipping'])); ?>

                            <?php $arPaymentSelect = []; foreach ($this->arPayment as $payment_id => $payment) if (!isset($payment['active']) || $payment['active'] === '1')  $arPaymentSelect[$payment_id] = $payment['name'].' ('.wpsg_ff(wpsg_getStr($payment['price'])).')'; ?>
                            <?php echo wpsg_drawForm_Select('add_payment', __('Zahlungsart', 'wpsg'), $arPaymentSelect, wpsg_getStr($_REQUEST['add_payment'])); ?>
                            
                            <br /><?php echo wpsg_drawForm_SubmitButton(__('Bestellung anlegen', 'wpsg')); ?><br />
                            
                            <script>
                                
                                jQuery(document).ready(function() {
                                
                                    jQuery('#search_customer').autocomplete( {
                                        source: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&subaction=autocomplete&noheader=1',
                                        minLength: 2,
                                        select: function(event, ui) {
                                            
                                            jQuery('#search_customer').val(ui.item.id);
                                            
                                            return false;
                                            
                                        }
                                    } );
                                
                                    jQuery('#add_form').on('submit', function() {
                                        
                                        if (jQuery.trim(jQuery('#search_customer').val()) === '') {                                            
                                            
                                            alert('<?php echo __('Bitte einen Kunden angeben.', 'wpsg'); ?>');
                                            
                                            return false;
                                            
                                        }
                                        
                                    } );
                                    
                                } );
                                
                            </script>
                            
                        </form>
                        
                    </div>
                </div>
            </div>
            
        </div>
    
    </nav>
    
    <div class="wpsg_msg_wrap"><hr class="wp-header-end wpsg-wp-header-end"/></div>
	
	<?php if ($this->hasMod('wpsg_mod_productgroups') && $this->get_option('wpsg_mod_productgroups_order_filter') === '1') { $arPG = $this->callMod('wpsg_mod_productgroups', 'getAllProductGroups', [true]); ?>

		<?php if (wpsg_isSizedArray($arPG)) { ?>
		<div class="container-fluid">
			<div class="row">
				<div class="pagination_wrap wpsg_status_link_wrap">
		
					<ul class="pagination">
						<?php foreach ($arPG as $pg_id => $pg_name) { ?>
							<li class="<?php echo ((wpsg_getStr($this->view['arFilter']['productgroup_id']) == $pg_id)?'active':''); ?>"><a href="#" onclick="return wpsg_setFilterProductgroup('<?php echo $pg_id; ?>');"><?php echo $pg_name; ?></a></li>
						<?php } ?>
					</ul>
		
				</div>
			</div>
		</div>
		<?php } ?>
		
	<?php } ?>
	
	<div class="pagination_wrap wpsg_status_link_wrap">

		<ul class="pagination">
			<?php foreach ($this->view['arStatus'] as $status_key => $status_info) { ?>
			<li class="<?php echo ((wpsg_getStr($this->view['arFilter']['status']) == $status_key)?'active':''); ?>"><a href="#" onclick="return wpsg_setFilterStatus('<?php echo $status_key; ?>');"><?php echo wpsg_translate(__('#1# <span>(#2#)<span>', 'wpsg'), $status_info['label'], $status_info['count']); ?></a></li>
			<?php } ?>
		</ul>

	</div>

	<?php $this->render(WPSG_PATH_VIEW.'/admin/pager.phtml'); ?>

	<div class="wpsg_clear"></div>

	<div class="content">
		<form method="post" action="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&noheader=1" enctype="multipart/form-data" id="order_form">

		<?php if (is_array($this->view['arData']) && sizeof($this->view['arData']) > 0) { ?>

            <table class="table table-bordered table-hover table-striped wpsg-table-order">
                <thead>
                    <tr>
                        <th class="col_checkbox"><input type="checkbox" onclick="return wpsg_order_checkAll();" /></th>
                        <th class="col_nr wpsg_order" data-order="cdate"><?php echo __('Nr', 'wpsg'); ?></th>
                        <th class="col_customer wpsg_order" data-order="customer"><?php echo __('Kunde', 'wpsg'); ?></th>
                        <th class="col_payment wpsg_order" data-order="payment"><?php echo __('Bezahlmethode', 'wpsg'); ?></th>
                        <th class="col_shipping wpsg_order" data-order="shipping"><?php echo __('Versandart', 'wpsg'); ?></th>
                        <th class="col_products wpsg_order" data-order="products"><?php echo __('Produkte', 'wpsg'); ?></th>
                        <?php if ($this->get_option('wpsg_showvalueofgoods')) { ?><th class="col_productsum wpsg_order" data-order="productsum"><?php echo __('Warenwert', 'wpsg'); ?></th><?php } ?>
                        <th class="col_sum wpsg_order" data-order="amount"><?php echo __('Bestellwert', 'wpsg'); ?></th>
                        <th class="col_state wpsg_order" data-order="state"><?php echo __('Status', 'wpsg'); ?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($this->view['arData'] as $oOrder) { ?>
                    <tr>
                        <td class="col_checkbox">

                            <input class="col_set_checkbox" data-order_id="<?php echo $oOrder->id; ?>" name="wpsg_multido[<?php echo $oOrder->id; ?>]" type="checkbox" />

                        </td>
                        <td class="col_nr">

                            <?php echo $oOrder->getNr(); ?> <span class="wpsg_grey"><?php echo wpsg_formatTimestamp(strtotime($oOrder->cdate), false); ?></span><br />

                            <div class="actions">
                                <span class="view"><a title="<?php echo __("Diese Bestellung ansehen", "wpsg"); ?>" href="<?php
		
									echo wpsg_admin_url('Order', 'view', ['edit_id' => $oOrder->getId()]);
	
								?>"><?php echo __("Ansehen", "wpsg"); ?></a></span>
                                |
                                <span class="storno"><a onclick="return confirm('<?php echo __('Sind Sie sich sicher, dass Sie diese Bestellung stornieren möchten?', 'wpsg'); ?>');" title="<?php echo __("Diese Bestellung stornieren", "wpsg"); ?>" href="<?php 
										
									echo wpsg_admin_url('Order', 'storno', ['edit_id' => $oOrder->getId()], ['noheader' => '1']); 
										
								?>"><?php echo __("Stornieren", "wpsg"); ?></a></span>
                                |
                                <span class="delete"><a onclick="return confirm('<?php echo __('Sind Sie sich sicher, dass Sie diese Bestellung löschen möchten?', 'wpsg'); ?>');" title="<?php echo __('Diese Bestellung löschen', 'wpsg'); ?>" href="<?php
									
									echo wpsg_admin_url('Order', 'delete', ['edit_id' => $oOrder->getId()], ['noheader' => '1']);
									
								?>"><?php echo __('Löschen', 'wpsg'); ?></a></span>
                            </div>

                            <?php if (trim($oOrder->admincomment) != "") { ?>
                            <a title="<?php echo __("Kommentar (Admin): ", "wpsg").htmlspecialchars($oOrder->admincomment); ?>" onclick="return false;" class="glyphicon glyphicon-question-sign admincomment" href="#"></a>
                            <?php } ?>

                            <?php if (trim($oOrder->comment) != "") { ?>
                            <a title="<?php echo __("Kommentar (Kunde): ", "wpsg").htmlspecialchars($oOrder->comment); ?>" onclick="return false;" class="glyphicon glyphicon-question-sign customercomment" href="#"></a>
                            <?php } ?>

                            <?php if ($oOrder->hasShippingAdress()) { ?>
                            <a title="<?php echo __("Lieferadresse beachten", "wpsg"); ?>" onclick="return false;" class="glyphicon glyphicon-map-marker shippingadress" href="#"></a>
                            <?php } ?>

                            <?php if ($this->hasMod('wpsg_mod_abo')) { ?>

                                <?php if ($this->callMod('wpsg_mod_abo', 'isAboOrder', array($oOrder->id)) === 1) { ?>
                                    <?php echo __('Abo Bestellung', 'wpsg'); ?>
                                <?php } else if ($this->callMod('wpsg_mod_abo', 'isAboOrder', array($oOrder->id)) === 2) { ?>
                                    
                                    <?php

                                        $origin_order_id = $this->callMod('wpsg_mod_abo', 'getOriginOrder', array($oOrder->id));
                                        $origin_order_data = $this->cache->loadOrder($origin_order_id);

                                        //wpsg_debug($oOrder->id.":".$origin_order_id);
                                        
                                    ?>
                                    <?php echo wpsg_translate(__('Verlängerung zu Bestellung <a href="#1#">#2#</a>', 'wpsg'), WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order&action=view&edit_id='.$origin_order_id, $origin_order_data['onr']); ?>
                                    
                                <?php } ?>
                            
                            <?php } ?>                            

                        </td>
                        <td class="col_customer">
                            <?php $firma = $oOrder->getInvoiceCompany(); if (wpsg_isSizedString($firma)) { ?>
                            <?php echo $firma; ?><br />
                            <?php } ?>
                            <?php echo $oOrder->getInvoiceTitle(); ?> <?php echo $oOrder->getInvoiceFirstname(); ?> <?php echo $oOrder->getInvoiceName(); ?>
                            <br />
                            <span class="wpsg_grey"><?php echo $oOrder->getInvoiceStreet(); ?><br />
                            <?php echo ltrim($oOrder->getInvoiceZip().' '.$oOrder->getInvoiceCity()); ?> <?php echo $oOrder->getInvoiceCountryKuerzel(); ?>
                            </span>
                        </td>
                        <td class="col_payment">

                            <?php /* Bei Crefopay wird die Darstellung der Zahlungsart über das Modul geregelt */ ?>
                            <?php if ($oOrder->getPaymentID() == 4000 && $this->hasMod('wpsg_mod_crefopay')) { ?>
                                <?php echo wpsg_hspc($this->callMod('wpsg_mod_crefopay', 'getOrderPaymentName', array($oOrder->id))); ?>
                            <?php } else { ?>
                                <?php echo $oOrder->getPaymentLabel(); ?>
                            <?php } ?>

                            <?php if ($oOrder->getPaymentAmount() > 0) { ?>
                            &nbsp;-&nbsp;<?php echo wpsg_ff($oOrder->getPaymentAmount(), $this->get_option('wpsg_currency')); ?>
                            <?php } ?>

                        </td>
                        <td class="col_shipping">

                            <?php echo $oOrder->getShippingLabel(); ?>

                            <?php if ($oOrder->getShippingAmount() > 0) { ?>
                            &nbsp;-&nbsp;<?php echo wpsg_ff($oOrder->getShippingAmount(), $this->get_option('wpsg_currency')); ?>
                            <?php } ?>

                            <?php if ($oOrder->hasShippingAdress()) { ?>
                                <br />
                                <?php echo $oOrder->getShippingTitle(); ?> <?php echo $oOrder->getShippingFirstName(); ?> <?php echo $oOrder->getShippingName(); ?><br />
                                <span class="wpsg_grey">
                                    <?php echo $oOrder->getShippingStreet(); ?>
                                    <?php echo $oOrder->getShippingZip(); ?> <?php echo $oOrder->getShippingCity(); ?> <?php echo $oOrder->getShippingCountryKuerzel(); ?><br />
                            </span>
                            <?php } ?>

                        </td>
                        <td class="col_products">

                            <?php $oOrderProducts = $oOrder->getOrderProducts(); ?>
                            
                            <?php foreach ($oOrderProducts as $oOrderProduct) { 
                            	
                            		$product_id = $oOrderProduct->getProductId();
                                	$oAbo = null;
                            		
                            		if ($this->hasMod('wpsg_mod_abo')) {
                            			
                            			try { $oAbo = wpsg_abo::getFromOrderAndOrderProduct($oOrder->getId(), $oOrderProduct->getId()); } catch (\Exception $e) {  }
                            			
                                    }
								
								?>

                                <?php

                                    echo wpsg_translate(__('#1# x <a href="#2#">#3#</a> für je #4#', 'wpsg'),
                                        $oOrderProduct->getCount(),
                                        wp_nonce_url(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Produkt&action=edit&edit_id='.$oOrderProduct->getProductId(), 'wpsg-product-edit-'.wpsg_getInt($product_id)),
                                        $oOrderProduct->getProductName(),
                                        wpsg_ff($oOrderProduct->getOneAmount(), $this->get_option('wpsg_currency'))
                                    );

                                ?><br />
                                
                                <?php if ($oAbo !== null) { ?>
 
									<?php
									 
										$state = $oAbo->getState();
									
										echo __('Abo Laufzeit:', 'wpsg'); 
									
									?>

									<?php if ($state === wpsg_abo::STATE_INEXTENSION) { ?><span style="color:orange;"><?php echo $oAbo->getStateLabel(); ?></span>
									<?php } else if ($state === wpsg_abo::STATE_RUNNING) { ?><span style="color:green;"><?php echo $oAbo->getStateLabel(); ?></span>
									<?php } else if ($state === wpsg_abo::STATE_EXTEND) { ?><span style="color:red;"><?php echo $oAbo->getStateLabel(); ?></span><?php } ?>
									 
									<br />  
                                    
                                <?php } ?>
                            
                            <?php } ?>

                        </td>
                        <?php if ($this->get_option('wpsg_showvalueofgoods')) { ?>
                            <td class="col_productsum">

                                <?php $product_sum = 0; $oOrderProducts = $oOrder->getOrderProducts(); ?>
                                <?php foreach ($oOrderProducts as $oOrderProduct) { ?>
                                    <?php $product_sum = ($product_sum ?? 0) + $oOrderProduct->getPriceSum($this->getBackendTaxview()); ?>
                                <?php } ?>
                                <?php echo wpsg_ff($product_sum, $this->get_option('wpsg_currency')); ?>
                                <?php $product_sum = 0; ?>

                            </td>
                        <?php } ?>
                        <td class="col_sum">
                            <?php echo wpsg_ff($oOrder->getAmount(), $this->get_option('wpsg_currency')); ?>
                        </td>
                        <td class="col_state">
                            <?php echo $oOrder->getStateLabel(); ?>
                        </td>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>

            <div class="alignleft actions">
                <select name="wpsg_action" id="wpsg_action">
                    <option value="-1"><?php echo __('Aktion wählen', 'wpsg'); ?></option>
                    <?php foreach ($this->arStatus as $k => $status) { ?>
                    <option value="<?php echo $k; ?>"><?php echo wpsg_translate(__('Status auf "#1#" setzen.', 'wpsg'), $status); ?></option>
                    <?php } ?>
                    <option value="multiDelete"><?php echo __('Bestellungen löschen', 'wpsg'); ?></option>
                    <?php if ($this->hasMod('wpsg_mod_rechnungen')) { ?>
                    <option value="writeRechnung"><?php echo __('Rechnung schreiben', 'wpsg'); ?></option>
                    <?php if ($this->view['arFilter']['k_id'] != '') { ?>
                    <option value="writeMultiRechnung"><?php echo __('Sammelrechnung schreiben', 'wpsg'); ?></option>
                    <?php } ?>
                    <option value="showRechnung"><?php echo __('Rechnung ansehen', 'wpsg'); ?></option>
                    <?php } ?>
                    <?php if ($this->hasMod('wpsg_mod_kundenkontakt')) { ?>
                    <option value="customercontact"><?php echo __('Kunden informieren', 'wpsg') ;?></option>
                    <?php } ?>
                </select>

                <input onclick="if (jQuery('#wpsg_action').val() == 'multiDelete') { if (!confirm('<?php echo __('Sind Sie sich sicher?', 'wpsg'); ?>')) return false; }" type="submit" value="<?php echo __('Ausführen', 'wpsg'); ?>" class="button-secondary action" id="doaction" name="wpsg_order_doaction" />

                <div id="customer_inform" style="display:none;">
                    <label class="mr-4 font-normal">
                        <input class="mt-0 mr-2" type="checkbox" name="inform" value="1" />&nbsp;<?php echo __('Kunden informieren', 'wpsg'); ?>
                    </label>
                </div>
                
                <script>
                    
                    let el_customer_inform = document.getElementById('customer_inform');
                    
                    document.getElementById('wpsg_action').addEventListener('change', (event) => {
                    	 
                    	if (parseInt(event.target.value) >= 0) {
                    		
                    		el_customer_inform.style.display = 'inline-block';
                    		
                        } else {
                    		
                    		el_customer_inform.style.display = 'none';
                    		
                        }
                    	
						let el_doaction = document.getElementById('doaction');
						
						if (event.target.value === 'writeMultiRechnung') {
							
							el_doaction.style.display = 'none';
							
                        } else {
							
							el_doaction.style.display = 'inline-block';
							
                        }
						
                    });

                    let buttonClicked = false;
                    document.getElementById('doaction').addEventListener('click', (event) => {

                        if (buttonClicked) {

                            event.preventDefault();
                            return false;

                        }

                        // Button deaktivieren und ausgrauen
                        document.getElementById('doaction').style.opacity = '0.5';
                        document.getElementById('doaction').style.pointerEvents = 'none';

                        // Button nach 4 Sekunden wieder aktivieren
                        setTimeout(() => {

                            document.getElementById('doaction').style.opacity = '1';
                            document.getElementById('doaction').style.pointerEvents = 'auto';
                            buttonClicked = false;

                        }, 4000);

                        buttonClicked = true;
                        return true;

                    });

                </script>

                <div class="multiRechnung_tab" id="multiRechnung_inform" style="padding: 15px 0 15px 0; display:none;">
 
						<div class="multiinvoice_form">
							
							<?php $oCustomer = wpsg_customer::getInstance(intval($this->view['arFilter']['k_id'])); ?>

							<div class="row">
								<input type="checkbox" name="wpsg_Multirechnung_sendmail" value="1" id="invoice_sendmail" />
								<label for="invoice_sendmail"><?php echo __('E-Mail an Kunden senden', 'wpsg'); ?></label>
								<input type="email" name="wpsg_Multirechnung_email" value="<?php echo esc_attr($oCustomer->getEMailEInvoice() ?? $oCustomer->email); ?>" />
							</div>
							
							<div class="row">
								<input type="checkbox" name="wpsg_Multirechnung_faelligkeit" value="1" id="invoice_faelligkeit" />
								<label for="invoice_faelligkeit"><?php echo __('Fälligkeit anzeigen', 'wpsg'); ?></label>
								<input type="date" name="wpsg_Multirechnung_faelligkeitsdatum" value="<?php echo date('Y-m-d', strtotime('+'.intval($this->get_option("wpsg_rechnungen_faelligkeit")).' day')); ?>" />
							</div>
							
							<div class="row">
								<input type="checkbox" name="wpsg_Multirechnung_url" value="1" id="invoice_url" />
								<label for="invoice_url"><?php echo __('URL Benachrichtigung', 'wpsg'); ?></label>
								<span></span>
							</div>
							
							<div class="row">
								<span></span>
								<label for="invoice_date"><?php echo __('Rechnungsdatum', 'wpsg') ;?></label>
								<input type="date" value="<?php echo date('Y-m-d'); ?>" name="wpsg_Multirechnung_datum" id="invoice_date" />
							</div>
								
							<span class="row" style="margin-top:0.5rem">
								<input type="hidden" name="preview" id="wpsg_mod_rechnungen_preview" />
								<input type="submit" name="wpsg_order_doaction" value="<?php echo __('Vorschau', 'wpsg'); ?>" id="wpsg_mod_rechnungen_button_preview" class="button" />                    
								<input type="submit" name="wpsg_order_doaction" value="<?php echo __('Erstellen', 'wpsg'); ?>" id="wpsg_mod_rechnungen_button_submit" class="button button-primary" />
							</span>
							
						</div>
						<style>
							
							.multiinvoice_form { border:1px solid #c3c4c7; border-radius:4px; background:#fff; padding:1rem; display:flex; flex-direction:column; gap:1rem; width:500px; user-select:none;
								.row { margin:0; display:flex; justify-content:flex-start; gap:0.5rem; align-items:center; min-height:26px;
								  	& > * { margin:0; }
									& > *:first-child { width:16px; min-width:16px; flex-shrink:0; }
								  input[type="text"], input[type="date"], input[type="email"] { height:26px; min-height:26px; }
								  input[type="email"] { flex:1; }
								}
							}
							
						</style>
						 
						 
                    <div style="width: 100%; padding: 1rem; display: grid; row-gap: 0.5rem; column-gap: 0.5rem; grid-template-columns: 25px 1fr 150px; align-items: center; grid-auto-rows: 30px; padding-bottom: 0.5rem;" >
                        
                       

                    </div>
                    
                    <script>
                        
                        let el_order_form = document.getElementById('order_form'); 
                    
                        document.getElementById('wpsg_mod_rechnungen_button_preview').addEventListener('click', () => {
							
							el_order_form.setAttribute('target', '_blank');
							document.getElementById('wpsg_mod_rechnungen_preview').value = '1'; 
						
						} );
						
                        document.getElementById('wpsg_mod_rechnungen_button_submit').addEventListener('click', () => { 
						
							el_order_form.setAttribute('target', '');
							document.getElementById('wpsg_mod_rechnungen_preview').value = '0'; 
						
						} );
                            
                    </script>
                    
                </div>

                <script>
                    
                    let el_multiRechnung_inform = document.getElementById('multiRechnung_inform');
                    
                    document.getElementById('wpsg_action').addEventListener('change', (event) => {
                    	
                        if (event.target.value === 'writeMultiRechnung') {
                            
                            el_multiRechnung_inform.style.display = 'block';
                            
                        } else {
                    		
                    		el_multiRechnung_inform.style.display = 'none';
                    		
                        }
                    	
                    });

                    // let buttonClicked = false;

                    // document.getElementById('wpsg_mod_rechnungen_button_submit').addEventListener('click', (event) => {

                    //     if (buttonClicked) {

                    //         event.preventDefault();
                    //         return false;

                    //     }

                    //     // Button deaktivieren und ausgrauen
                    //     document.getElementById('wpsg_mod_rechnungen_button_submit').style.opacity = '0.5';
                    //     document.getElementById('wpsg_mod_rechnungen_button_submit').style.pointerEvents = 'none';

                    //     // Button nach 4 Sekunden wieder aktivieren
                    //     setTimeout(() => {

                    //         document.getElementById('wpsg_mod_rechnungen_button_submit').style.opacity = '1';
                    //         document.getElementById('wpsg_mod_rechnungen_button_submit').style.pointerEvents = 'auto';
                    //         buttonClicked = false;

                    //     }, 4000);

                    //     buttonClicked = true;
                    //     return true;

                    // });
                     
                </script>
                
            </div>

            <div style="margin-right:-15px;">
                <?php $this->render(WPSG_PATH_VIEW.'/admin/pager.phtml'); ?>
            </div>

            <div class="wpsg_clear"></div>

            <?php $this->callMod('wpsg_mod_export', 'produkt_index_foot'); ?>

		<?php } else { ?>

            <?php echo wpsg_drawForm_AdminboxStart(); ?>
    		<?php echo __('Keine Bestellungen in der Datenbank.', 'wpsg'); ?>
            <?php echo wpsg_drawForm_AdminboxEnd(); ?>

		<?php } ?>
		<input id="noheader1" type="hidden" name="noheader1" value="1" />
		</form>
	</div>
    
    <?php if ($this->hasMod('wpsg_mod_kundenkontakt')) { $this->callMod('wpsg_mod_kundenkontakt', 'order_index_bottom'); } ?>

<script>

    <?php if (wpsg_isSizedString($this->view['arFilter']['order']) && wpsg_isSizedString($this->view['arFilter']['ascdesc'])) { ?>
    jQuery('th[data-order="<?php echo @$this->view['arFilter']['order']; ?>"]').addClass('wpsg_order_<?php echo strtolower(@$this->view['arFilter']['ascdesc']); ?>');
    <?php } ?>

    function wpsg_order_checkAll()
    {

        jQuery('.col_set_checkbox').each(function() { jQuery(this).prop('checked', !jQuery(this).prop('checked')); } );

    }
	
	<?php if ($this->hasMod('wpsg_mod_productgroups') && $this->get_option('wpsg_mod_productgroups_order_filter') === '1') { ?>
    function wpsg_setFilterProductgroup(pgroup_id) {

		jQuery('#filterproductgroup_id').val(pgroup_id);

		jQuery('#seite').val(1);
		jQuery('#filter_form').trigger('submit');

		return false;
    	
	}
	<?php } ?>
    
	function wpsg_setFilterStatus(state)
	{

		jQuery('#filterstatus').val(state);

		jQuery('#seite').val(1);
		jQuery('#filter_form').trigger('submit');

		return false;

	}

	function goPage(page)
	{

		//if (page <= 0 || page == <?php echo $this->view['arFilter']['page']; ?> || page > <?php echo wpsg_getStr($this->view['pages'], '0'); ?>) return;

		jQuery('#wpsg_seite').val(page);
		jQuery('#filter_form').trigger('submit');

		return false;

	} // function goPage(page)

    jQuery(document).ready(function() {

        jQuery('.wpsg-order-tab-mods').bind('click', function() {

            if (jQuery(this).hasClass('active'))
            {

                jQuery(this).removeClass('active');
                jQuery('.' + jQuery(this).attr("id")).slideUp(250); 
                
            }
            else
            {
                
                jQuery(this).addClass('active');
                jQuery('.' + jQuery(this).attr("id")).slideDown(250);

                if (jQuery(this).attr("id") === 'wpsg-order-tab-add') jQuery('#search_customer').focus(); 
                    
            }

            return false;

        } );

    } );
	
	<?php if ($this->hasMod('wpsg_mod_kundenkontakt')) { ?>
	document.getElementById('wpsg_action').addEventListener('click', (event) => {
		
		console.log('OK');
		
    });
	<?php } ?>

</script>