Subversion Repositories wpShopGermany4

Rev

Rev 7934 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7932 daniel 1
<?php
2
 
3
	declare(strict_types=1);
4
 
5
	/**
6
	 * User: Daschmi (daschmi@daschmi.de)
7
	 * Date: 03.08.2021
8
	 * Time: 07:17
9
	 */
10
 
11
	namespace wpsg;
12
 
13
	$arTemplateSelect = ['0' => __('Bitte auswählen', 'wpsg')];
14
 
15
	foreach ($this->view['arTemplates'] as $t) $arTemplateSelect[$t['filename']] = $t['name'];
16
 
17
?>
18
 
19
<fieldset id="wpsg_mod_kundenkontakt_layer" style="display:none;">
20
    <legend><?php echo __('Kundenkontakt', 'wpsg'); ?></legend>
21
    <div>
22
 
23
        <?php echo wpsg_drawForm_Select('wpsg_mod_kundenkontakt_template', __('Template', 'wpsg'), $arTemplateSelect, '0'); ?>
24
        <?php echo wpsg_drawForm_Input('wpsg_mod_kundenkontakt_subject', __('Betreff', 'wpsg'), '', ['wrap_id' => 'wpsg_mod_kundenkontakt_subject_wrap']); ?>
25
        <?php echo wpsg_drawForm_Textarea('wpsg_mod_kundenkontakt_text', __('Text', 'wpsg'), '', ['wrap_id' => 'wpsg_mod_kundenkontakt_text_wrap']); ?>
26
 
27
        <?php echo wpsg_drawForm_Button(__('Kunden informieren', 'wpsg'), '', ['wrap_id' => 'wpsg_mod_kundenkontakt_submit_wrap', 'field_id' => 'wpsg_mod_kundenkontakt_submit']); ?>
28
 
29
    </div>
30
</fieldset>
31
 
32
<script>
33
 
34
    let el_wpsg_mod_kundenkontakt_layer = document.getElementById('wpsg_mod_kundenkontakt_layer');
35
 
36
    let el_wpsg_mod_kundenkontakt_subject = document.getElementById('wpsg_mod_kundenkontakt_subject');
37
    let el_wpsg_mod_kundenkontakt_subject_wrap = document.getElementById('wpsg_mod_kundenkontakt_subject_wrap');
38
 
39
    let el_wpsg_mod_kundenkontakt_text = document.getElementById('wpsg_mod_kundenkontakt_text');
40
    let el_wpsg_mod_kundenkontakt_text_wrap = document.getElementById('wpsg_mod_kundenkontakt_text_wrap');
41
 
42
    let el_wpsg_mod_kundenkontakt_submit = document.getElementById('wpsg_mod_kundenkontakt_submit');
43
    let el_wpsg_mod_kundenkontakt_submit_wrap = document.getElementById('wpsg_mod_kundenkontakt_submit_wrap');
44
 
45
    let el_doaction = document.getElementById('doaction');
46
 
47
    document.getElementById('wpsg_mod_kundenkontakt_template').addEventListener('change', (event) => {
48
 
49
    	if (event.target.value !== '0') {
50
 
51
            jQuery.ajax({
52
                url: "<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_kundenkontakt&noheader=1&do=kk_switchTemplate",
53
                dataType: 'json',
54
                data: {
55
                    template_file: event.target.value
56
                },
57
                success: function(data) {
58
 
59
                	el_wpsg_mod_kundenkontakt_subject_wrap.style.display = 'block';
60
    		        el_wpsg_mod_kundenkontakt_text_wrap.style.display = 'block';
61
    		        el_wpsg_mod_kundenkontakt_submit_wrap.style.display = 'block';
62
 
63
                    el_wpsg_mod_kundenkontakt_subject.value = data.subject;
64
                    el_wpsg_mod_kundenkontakt_text.value = data.content;
65
 
66
                }
67
            });
68
 
69
	    } else {
70
 
71
    		el_wpsg_mod_kundenkontakt_subject_wrap.style.display = 'none';
72
    		el_wpsg_mod_kundenkontakt_text_wrap.style.display = 'none';
73
    		el_wpsg_mod_kundenkontakt_submit_wrap.style.display = 'none';
74
 
75
        }
76
 
77
    });
78
 
79
    el_wpsg_mod_kundenkontakt_submit.addEventListener('click', (event) => {
80
 
81
    	event.preventDefault();
82
 
83
    	let arOrderID = [];
84
 
85
    	for (let el of document.querySelectorAll('.col_set_checkbox')) {
86
 
87
    		if (el.checked) arOrderID.push(el.getAttribute('data-order_id'));
88
 
89
        }
90
 
91
    	if (arOrderID.length <= 0) {
92
 
93
    		alert('<?php echo __('Bitte mindestens eine Bestellung auswählen.', 'wpsg'); ?>');
94
    		return;
95
        }
96
 
97
    	el_wpsg_mod_kundenkontakt_submit.setAttribute("disabled", "disabled");
98
 
99
    	jQuery.ajax({
100
            url: "<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_kundenkontakt&noheader=1&do=kk_sendMail",
101
            data: {
102
                arOrderID: arOrderID,
103
                text: el_wpsg_mod_kundenkontakt_text.value,
104
                el_wpsg_mod_kundenkontakt_subject: el_wpsg_mod_kundenkontakt_subject.value
105
            },
106
            success: function(data) {
107
 
108
            	el_wpsg_mod_kundenkontakt_submit.removeAttribute("disabled");
109
 
110
            	alert(data);
111
 
112
            }
113
        });
114
 
115
    });
116
 
117
    document.getElementById('wpsg_action').addEventListener('change', (event) => {
118
 
119
        if (event.target.value === 'customercontact') {
120
 
121
        	el_doaction.style.display = 'none';
122
            el_wpsg_mod_kundenkontakt_layer.style.display = 'block';
123
 
124
        } else {
125
 
126
        	el_doaction.style.display = 'inline-block';
127
        	el_wpsg_mod_kundenkontakt_layer.style.display = 'none';
128
 
129
        }
130
 
131
    });
132
 
133
</script>
134
 
135
<style>
136
 
137
    #wpsg_mod_kundenkontakt_text { height:300px; }
138
    #wpsg_mod_kundenkontakt_subject_wrap { display:none; }
139
    #wpsg_mod_kundenkontakt_text_wrap { display:none; }
140
    #wpsg_mod_kundenkontakt_submit_wrap { display:none; }
141
 
142
</style>