summaryrefslogtreecommitdiff
path: root/views/mods/mod_ticket/order_view.phtml
blob: 06a16aacab24fd08d24878a0774114ee317d07cc (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
<?php
	
	declare(strict_types=1);
	
	/**
	 * @author: Daniel Schmitzer (daniel@maennchen1.de)
	 * @date: 03.12.23
	 * @time: 15:14
	 */
	
	namespace wpsgTicket;
	
	/** @var \wpsg_order $oOrder */
    $oOrder = \wpsg_order::getInstance(intval($this->view['data']['id']));
	
	$data = [];
	
	foreach ($oOrder->getOrderProducts() as $oOrderProduct) {
		
		if (intval($oOrderProduct->getMeta('ticket_id', false, 0)) > 0) {
		
			for ($amount_index = 0; $amount_index < $oOrderProduct->getAmount(); $amount_index++) {
			
				$oTicketBooking = TicketBooking::getInstanceByBookingKey(TicketBooking::encodeBookingKey($oOrderProduct->getId(), $amount_index));
				
				$data[] = $oTicketBooking->toJSON();
			
			}
		
		}
		
	}
	
?>

<?php echo wpsg_drawForm_AdminboxStart(__('Ticketbuchungen', 'wpsg')); ?>
	<div id="order_view_app">
		
		<table>
			<thead>
				<tr>
					<th class="col_ticket"><?php echo __('Ticket', 'wpsg'); ?></th>
					<th class="col_product"><?php echo __('Ticket Produkt', 'wpsg'); ?></th>
					<th class="col_date"><?php echo __('Datum / Zeitraum', 'wpsg'); ?></th>
					<th class="col_state"><?php echo __('Status', 'wpsg'); ?></th>
				</tr>
			</thead>
			<tbody v-for="(row, i) in data">
				<tr>
					<td class="col_ticket">
						<a :href="row.urls.pdf" target="_blank">{{row.label}}</a>
					</td>
					<td class="col_product">
						<a :href="row.urls.product_edit">{{row.ticket_product_label}}</a>
					</td>
					<td class="col_date">{{row.ticket_data.label}}</td>
					<td class="col_state">
						<span :class="{'text-red': row.state_code === <?php echo TicketBooking::STATUS_UNAVAILABLE; ?>, 'text-green': row.state_code === <?php echo TicketBooking::STATUS_AVAILABLE; ?>}">{{row.state_label}}</span>
						<span v-if="row.is_send" :title="row.is_send_tooltip" class="ml-4 glyphicon glyphicon-send text-green"></span>
					</td>
				</tr>
				<template v-if="row.arProductVars.length > 0">
					<template v-for="(pv_data, pv_id) of row.arProductVars">
						<tr>
							<td colspan="2">
								{{pv_data['name']}}:
							</td>
							<td colspan="2">
								{{pv_data['value']}}
							</td>
						</tr>
					</template>
				</template>
			</tbody>
		</table>
		
		<br />
		
		<div class="flex items-center gap-2">
			
			<a href="<?php echo \add_query_arg([
				'action' => 'wpsg_ticket',
				'ticket_action' => 'export',
				'order_id' => $oOrder->getId()
			], \admin_url('admin-ajax.php')); ?>" target="_blank" class="button"><?php echo __('Terminübersicht exportieren', 'wpsg'); ?></a>
			
			<a href="<?php echo \add_query_arg([
				'action' => 'wpsg_ticket',
				'ticket_action' => 'resend',
				'order_id' => $oOrder->getId()
			], \admin_url('admin-ajax.php')); ?>" class="button"><?php echo __('Tickets per E-Mail an Kunden versenden', 'wpsg'); ?></a>
		
		</div>
		
	</div>
	<style>
		
		#order_view_app table { width:100%; }
		#order_view_app table tr td { padding:0.25rem 0.5rem 0.25rem 0; border-bottom:1px solid #DEDEDE; }
		#order_view_app table tr th { border-bottom:1px solid black; }
		#order_view_app .text-red { color:red; }
		#order_view_app .text-green { color:green; }
		#order_view_app .flex { display:flex; }
		#order_view_app .items-center { align-items:center; }
		#order_view_app .ml-4 { margin-left:1rem; }
		#order_view_app .gap-2 { gap:0.5rem; }
		
	</style>
<?php echo wpsg_drawForm_AdminboxEnd(); ?>

<script type="module">
	
	const wpsgSettings = {
		baseUrl: '<?php echo WPSG_URL; ?>'
	};
	
	import { order_view } from '<?php echo WPSG_URL; ?>mods/mod_ticket/assets/js/wpsg_order_view.js';
	
	order_view(wpsgSettings, <?php echo json_encode([
		'order_id' => $oOrder->getId(),
		'data' => $data,
		'ajax_url' => \admin_url('admin-ajax.php')
	]); ?>);
	
</script>