Subversion Repositories wpShopGermany4

Rev

Rev 7932 | Go to most recent revision | Details | Compare with Previous | 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']); ?>
7934 daniel 25
 
26
        <?php /* echo wpsg_drawForm_Textarea('wpsg_mod_kundenkontakt_text', __('Text', 'wpsg'), '', ['wrap_id' => 'wpsg_mod_kundenkontakt_text_wrap']); */ ?>
27
 
28
        <div class="form-group form-group-sm form-textarea" id="wpsg_mod_kundenkontakt_text_wrap">
29
                <label class="col-sm-6 control-label" for="wpsg_mod_kundenkontakt_text">Text</label>
30
                <div class="col-sm-6">
31
                    <div class="wpsg_field_wrap">
32
 
33
                        <?php if ($this->get_option('wpsg_htmlmail') === '1') { ?>
34
 
35
                            <?php wp_editor('', 'wpsg_mod_kundenkontakt_text'); ?>
36
 
37
                        <?php } else { ?>
38
 
39
                            <textarea class="form-control" id="wpsg_mod_kundenkontakt_text" name="wpsg_mod_kundenkontakt_text"></textarea>
40
 
41
                        <?php } ?>
42
 
43
                    </div>
44
 
45
            </div>
46
 
47
            <div class="clearfix wpsg_clear"></div>
48
 
49
        </div>
50
 
7932 daniel 51
        <?php echo wpsg_drawForm_Button(__('Kunden informieren', 'wpsg'), '', ['wrap_id' => 'wpsg_mod_kundenkontakt_submit_wrap', 'field_id' => 'wpsg_mod_kundenkontakt_submit']); ?>
52
 
7934 daniel 53
        <?php echo wpsg_drawForm_Text('', __('Bitte warten ...', 'wpsg'), 'wpsg_mod_kundenverwaltung_loading', ['wrap_id' => 'wpsg_mod_kundenkontakt_loading_wrap']); ?>
54
 
7932 daniel 55
    </div>
56
</fieldset>
57
 
58
<script>
59
 
60
    let el_wpsg_mod_kundenkontakt_layer = document.getElementById('wpsg_mod_kundenkontakt_layer');
61
 
62
    let el_wpsg_mod_kundenkontakt_subject = document.getElementById('wpsg_mod_kundenkontakt_subject');
63
    let el_wpsg_mod_kundenkontakt_subject_wrap = document.getElementById('wpsg_mod_kundenkontakt_subject_wrap');
64
 
65
    let el_wpsg_mod_kundenkontakt_text = document.getElementById('wpsg_mod_kundenkontakt_text');
66
    let el_wpsg_mod_kundenkontakt_text_wrap = document.getElementById('wpsg_mod_kundenkontakt_text_wrap');
67
 
68
    let el_wpsg_mod_kundenkontakt_submit = document.getElementById('wpsg_mod_kundenkontakt_submit');
69
    let el_wpsg_mod_kundenkontakt_submit_wrap = document.getElementById('wpsg_mod_kundenkontakt_submit_wrap');
70
 
7934 daniel 71
    let el_wpsg_mod_kundenkontakt_loading_wrap = document.getElementById('wpsg_mod_kundenkontakt_loading_wrap');
72
 
7932 daniel 73
    let el_doaction = document.getElementById('doaction');
74
 
75
    document.getElementById('wpsg_mod_kundenkontakt_template').addEventListener('change', (event) => {
76
 
77
    	if (event.target.value !== '0') {
7934 daniel 78
 
79
    		el_wpsg_mod_kundenkontakt_loading_wrap.style.display = 'block';
80
 
7932 daniel 81
            jQuery.ajax({
82
                url: "<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_kundenkontakt&noheader=1&do=kk_switchTemplate",
83
                dataType: 'json',
84
                data: {
85
                    template_file: event.target.value
86
                },
87
                success: function(data) {
88
 
7934 daniel 89
                	el_wpsg_mod_kundenkontakt_loading_wrap.style.display = 'none';
90
 
7932 daniel 91
                	el_wpsg_mod_kundenkontakt_subject_wrap.style.display = 'block';
92
    		        el_wpsg_mod_kundenkontakt_text_wrap.style.display = 'block';
93
    		        el_wpsg_mod_kundenkontakt_submit_wrap.style.display = 'block';
94
 
95
                    el_wpsg_mod_kundenkontakt_subject.value = data.subject;
7934 daniel 96
 
97
                    <?php if ($this->get_option('wpsg_htmlmail') === '1') { ?>
98
                    tinyMCE.get('wpsg_mod_kundenkontakt_text').setContent(data.content);
99
                    <?php } else { ?>
7932 daniel 100
                    el_wpsg_mod_kundenkontakt_text.value = data.content;
7934 daniel 101
                    <?php } ?>
7932 daniel 102
 
103
                }
104
            });
105
 
106
	    } else {
107
 
108
    		el_wpsg_mod_kundenkontakt_subject_wrap.style.display = 'none';
109
    		el_wpsg_mod_kundenkontakt_text_wrap.style.display = 'none';
110
    		el_wpsg_mod_kundenkontakt_submit_wrap.style.display = 'none';
7934 daniel 111
    		el_wpsg_mod_kundenkontakt_loading_wrap.style.display = 'none';
7932 daniel 112
 
113
        }
114
 
115
    });
116
 
117
    el_wpsg_mod_kundenkontakt_submit.addEventListener('click', (event) => {
118
 
119
    	event.preventDefault();
120
 
121
    	let arOrderID = [];
122
 
123
    	for (let el of document.querySelectorAll('.col_set_checkbox')) {
124
 
125
    		if (el.checked) arOrderID.push(el.getAttribute('data-order_id'));
126
 
127
        }
128
 
129
    	if (arOrderID.length <= 0) {
130
 
131
    		alert('<?php echo __('Bitte mindestens eine Bestellung auswählen.', 'wpsg'); ?>');
132
    		return;
133
        }
134
 
135
    	el_wpsg_mod_kundenkontakt_submit.setAttribute("disabled", "disabled");
7934 daniel 136
    	el_wpsg_mod_kundenkontakt_subject.setAttribute("disabled", "disabled");
137
        el_wpsg_mod_kundenkontakt_text.setAttribute("disabled", "disabled");
138
 
139
    	el_wpsg_mod_kundenkontakt_loading_wrap.style.display = 'block';
7932 daniel 140
 
141
    	jQuery.ajax({
142
            url: "<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_kundenkontakt&noheader=1&do=kk_sendMail",
143
            data: {
144
                arOrderID: arOrderID,
145
                text: el_wpsg_mod_kundenkontakt_text.value,
146
                el_wpsg_mod_kundenkontakt_subject: el_wpsg_mod_kundenkontakt_subject.value
147
            },
148
            success: function(data) {
7934 daniel 149
 
150
            	document.getElementById('wpsg_mod_kundenkontakt_template').selectedIndex = 0;
151
 
152
            	for (let el of document.querySelectorAll('.col_set_checkbox')) {
153
 
154
            		el.checked = false;
155
 
156
	            }
157
 
158
            	el_wpsg_mod_kundenkontakt_loading_wrap.style.display = 'none';
159
 
160
            	el_wpsg_mod_kundenkontakt_subject_wrap.style.display = 'none';
161
            	el_wpsg_mod_kundenkontakt_subject.value = '';
162
 
163
            	el_wpsg_mod_kundenkontakt_text_wrap.style.display = 'none';
164
            	el_wpsg_mod_kundenkontakt_text.value = '';
165
 
7932 daniel 166
            	el_wpsg_mod_kundenkontakt_submit.removeAttribute("disabled");
7934 daniel 167
            	el_wpsg_mod_kundenkontakt_subject.removeAttribute("disabled");
168
                el_wpsg_mod_kundenkontakt_text.removeAttribute("disabled");
7932 daniel 169
 
7934 daniel 170
            	el_wpsg_mod_kundenkontakt_submit_wrap.style.display = 'none';
171
 
7932 daniel 172
            	alert(data);
173
 
174
            }
175
        });
176
 
177
    });
178
 
179
    document.getElementById('wpsg_action').addEventListener('change', (event) => {
180
 
181
        if (event.target.value === 'customercontact') {
182
 
183
        	el_doaction.style.display = 'none';
184
            el_wpsg_mod_kundenkontakt_layer.style.display = 'block';
185
 
186
        } else {
187
 
188
        	el_doaction.style.display = 'inline-block';
189
        	el_wpsg_mod_kundenkontakt_layer.style.display = 'none';
190
 
191
        }
192
 
193
    });
194
 
195
</script>
196
 
197
<style>
198
 
199
    #wpsg_mod_kundenkontakt_text { height:300px; }
200
    #wpsg_mod_kundenkontakt_subject_wrap { display:none; }
201
    #wpsg_mod_kundenkontakt_text_wrap { display:none; }
202
    #wpsg_mod_kundenkontakt_submit_wrap { display:none; }
7934 daniel 203
    #wpsg_mod_kundenkontakt_loading_wrap { display:none; }
204
    #wpsg_mod_kundenkontakt_layer .form-group > label { width:15% !important; }
205
    #wpsg_mod_kundenkontakt_layer .wpsg_form_field > .wpsg_form_left { width:15% !important; }
206
    #wpsg_mod_kundenkontakt_layer .form-group > div:nth-child(2),
207
    #wpsg_mod_kundenkontakt_layer .wpsg_form_field > .wpsg_form_right { width:85% !important; }
7932 daniel 208
 
209
</style>