summaryrefslogtreecommitdiff
path: root/views/mods/mod_coverletter/order_view.phtml
blob: 33b5f86ad420341842aca90c00333e5d36fe09c5 (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
<?php

	/**
	 * Template für die Integration des Anschreiben Moduls in die Bestellverwaltung
	 * @version 4.6.1
	 */

	if (!defined('ABSPATH')) exit;

	$order_id = (int)($this->view['data']['id']??0);
	$arCoverLetter = (array)($this->view['mod_coverletter']['arCoverLetter']??[]);

	$arShopLocations = $this->getShopLocations();
	$arShopLocationLabels = [];

	foreach ($arShopLocations as $l_id => $l) {

		$arShopLocationLabels[$l_id] = $l['label'];
	}

?>

<?php echo wpsg_drawForm_AdminboxStart(__('Anschreiben', 'wpsg')); ?>

	<?php if (sizeof($arCoverLetter) === 0) { ?>

		<p><?php echo esc_html__('Bisher kein Anschreiben für diese Bestellung geschrieben.', 'wpsg'); ?></p>

	<?php } else { ?>

		<?php foreach ($arCoverLetter as $a) { ?>

			<div class="wpsg_flex wpsg_flex_justify_content_space_between">
				<span>
					<?php echo wpsg_hspc(wpsg_translate(__('#2#: Anschreiben ##1#', 'wpsg'), $a['id'], wpsg_formatTimestamp(strtotime($a['cdate'])))); ?>: <?php echo wpsg_hspc(((strlen($a['text']) > 50)?substr($a['text'], 0, 50).' ...':$a['text'])); ?>
				</span>
				<a href="<?php echo esc_url(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order&mod=wpsg_mod_coverletter&noheader=1&action=ajax&order_id='.intval($a['order_id']).'&cl_id='.intval($a['id']).'&wpsg_mod_coverletter_get'); ?>" target="_new">
					<?php echo esc_html__('Ansehen', 'wpsg'); ?>
				</a>
			</div>

		<?php } ?>

	<?php } ?>

	<br />

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

	<hr />

	<div class="inside">
		<div>

			<form target="_blank" method="post" action="<?php echo esc_url(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order&mod=wpsg_mod_coverletter&edit_id='.$order_id.'&action=ajax&noheader=1'); ?>" id="wpsg_mod_coverletter_form">

				<?php wp_nonce_field('wpsg-coverletter-order_ajax-write-'.$order_id); ?>

				<?php if (sizeof($arShopLocations) > 1) { ?>

					<?php echo wpsg_drawForm_Select('target', __('Shop Adresse', 'wpsg'), $arShopLocationLabels, '1'); ?>

				<?php } else { ?>

					<input type="hidden" name="target" value="1" />

				<?php } ?>

				<?php echo wpsg_drawForm_Textarea('text', __('Text', 'wpsg'), $this->replaceUniversalPlatzhalter($this->get_option('wpsg_mod_coverletter_text'), $order_id), ['noLabel' => true, 'fullLabel' => __('Text für das Anschreiben', 'wpsg'), 'style' => 'height:200px']); ?>

				<br />

				<input type="submit" name="wpsg_mod_coverletter_write" value="<?php echo esc_attr__('Speichern & Drucken', 'wpsg'); ?>" style="float:left;" class="button button-primary" />
				<input type="submit" name="wpsg_mod_coverletter_preview" onclick="wpsg_form_refresh = false;" value="<?php echo esc_attr__('Vorschau', 'wpsg'); ?>" style="float:left; margin-left:15px;" class="button" />

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

			</form>

		</div>
	</div>

<?php echo wpsg_drawForm_AdminboxEnd(); ?>

<script>

	var wpsg_form_refresh = true;

	jQuery('#wpsg_mod_coverletter_form').on('submit', function() {

		if (wpsg_form_refresh) {

			setTimeout(function() {

				location.reload();

			}, 1000);

		}

		wpsg_form_refresh = true;

	});

</script>