Subversion Repositories wpShopGermany4

Rev

Rev 7486 | Rev 7787 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7179 daniel 1
<?php
2
 
3
	/**
4
	 * User: Daschmi (daschmi@daschmi.de)
5
	 * Date: 05.10.2018
6
	 * Time: 08:24
7
	 */
8
 
9
	namespace wpsg;
10
 
11
	/** @var wpsg_calculation $oCalculation */
12
	$oCalculation = $this->view['oCalculation'];
13
 
14
	if ($this->getBackendTaxView() === WPSG_NETTO) $strBN = 'NETTO';
15
	else $strBN = 'BRUTTO';
16
 
17
	$arCalculation = $oCalculation->getCalculationArray();
7486 daniel 18
	$voucher = [
19
		'code' => '',
20
		'id' => 0,
21
		'set' => 0,
7490 daniel 22
		'type' => 'voucher',
7486 daniel 23
	];
7179 daniel 24
 
7490 daniel 25
	//wpsg_debug(array_merge($arCalculation['voucher'], $arCalculation['coupon']));
26
	//wpsg_Debug($_REQUEST);
27
 
7486 daniel 28
	// Voucher suchen
29
	foreach (array_merge($arCalculation['voucher'], $arCalculation['coupon']) as $v) {
30
 
31
		if ($v['order_voucher_id'] == $_REQUEST['order_voucher_id']) {
7490 daniel 32
 
33
			$order_voucher_db = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_ORDER_VOUCHER."` WHERE `id` = '".wpsg_q($_REQUEST['order_voucher_id'])."' ");
7486 daniel 34
 
35
			$voucher = $v;
36
 
7490 daniel 37
			//if ($order_voucher_db['coupon'] === '1') $voucher['type'] = 'coupon';
38
 
7486 daniel 39
		}
40
 
41
	}
42
 
43
	$strVal = ((isset($voucher['set']))?$voucher['set']:0);
7179 daniel 44
 
7490 daniel 45
	if (strpos($strVal, '%') !== false) $strVal = wpsg_ff(abs(wpsg_tf($strVal)), '%');
46
	else $strVal = wpsg_ff(abs(wpsg_tf($strVal)), $this->get_option('wpsg_currency'));
7486 daniel 47
 
7179 daniel 48
?>
49
 
50
<form id="wpsg_be_voucher_form">
51
 
7486 daniel 52
	<input type="hidden" name="order_voucher_id" value="<?php echo wpsg_getInt($_REQUEST['order_voucher_id']); ?>" />
53
 
7179 daniel 54
	<div class="autocomplete_wrap">
55
		<?php echo wpsg_drawForm_Input('be_voucher_search', __('Gutscheinsuche', 'wpsg'), ''); ?>
56
	</div>
57
 
58
	<br />
59
 
7486 daniel 60
	<?php echo wpsg_drawForm_Input('be_voucher_code', __('Code (Optional)', 'wpsg'), @$voucher['code']); ?>
61
	<?php echo wpsg_drawForm_Input('be_voucher_id', __('Guschein ID', 'wpsg'), @$voucher['id']); ?>
7179 daniel 62
	<?php echo wpsg_drawForm_Input('be_voucher_amount', wpsg_translate(__('Gutscheinwert in #1# (#2#) oder % ', 'wpsg'), $this->get_option('wpsg_currency'), $strBN), $strVal); ?>
7486 daniel 63
	<?php echo wpsg_drawForm_Checkbox('be_voucher_coupon', __('Wertgutschein'), (($voucher['type'] === 'coupon')?'1':'0')); ?>
7179 daniel 64
 
65
</form>
66
 
67
<script>
68
 
69
	jQuery('#wpsg_be_voucher_form').on('submit', function() { return false; } );
70
	jQuery('#be_voucher_search').focus();
71
 
72
	jQuery(document).ready(function() {
73
 
74
		jQuery('#be_voucher_search').autocomplete( {
75
			source: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=editVoucher&do=search&noheader=1&edit_id=<?php echo $_REQUEST['edit_id']; ?>',
76
			minLength: 2,
77
			appendTo: ".autocomplete_wrap",
78
			select: function(event, ui) {
79
 
80
				jQuery('#be_voucher_code').val(ui.item.code);
81
				jQuery('#be_voucher_id').val(ui.item.id);
82
				jQuery('#be_voucher_amount').val(ui.item.gs_value);
83
 
7490 daniel 84
				if (ui.item.coupon === '1') jQuery('#be_voucher_coupon').prop('checked', true);
85
				else jQuery('#be_voucher_coupon').prop('checked', false);
86
 
7179 daniel 87
				jQuery('#be_voucher_search').val('');
88
 
89
				return false;
90
 
91
			}
92
		} );
93
 
94
	} );
95
 
96
</script>