Subversion Repositories wpShopGermany4

Rev

Rev 7932 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

        declare(strict_types=1);

        /**
         * User: Daschmi (daschmi@daschmi.de)
         * Date: 03.08.2021
         * Time: 07:17
         */

        namespace wpsg;
        
        $arTemplateSelect = ['0' => __('Bitte auswählen', 'wpsg')];
        
        foreach ($this->view['arTemplates'] as $t) $arTemplateSelect[$t['filename']] = $t['name'];
        
?>

<fieldset id="wpsg_mod_kundenkontakt_layer" style="display:none;">
    <legend><?php echo __('Kundenkontakt', 'wpsg'); ?></legend>
    <div>
        
        <?php echo wpsg_drawForm_Select('wpsg_mod_kundenkontakt_template', __('Template', 'wpsg'), $arTemplateSelect, '0'); ?>
        <?php echo wpsg_drawForm_Input('wpsg_mod_kundenkontakt_subject', __('Betreff', 'wpsg'), '', ['wrap_id' => 'wpsg_mod_kundenkontakt_subject_wrap']); ?>
        
        <?php /* echo wpsg_drawForm_Textarea('wpsg_mod_kundenkontakt_text', __('Text', 'wpsg'), '', ['wrap_id' => 'wpsg_mod_kundenkontakt_text_wrap']); */ ?>
                                
        <div class="form-group form-group-sm form-textarea" id="wpsg_mod_kundenkontakt_text_wrap">      
                <label class="col-sm-6 control-label" for="wpsg_mod_kundenkontakt_text">Text</label>                
                <div class="col-sm-6">                    
                    <div class="wpsg_field_wrap">
            
                        <?php if ($this->get_option('wpsg_htmlmail') === '1') { ?>
                            
                            <?php wp_editor('', 'wpsg_mod_kundenkontakt_text'); ?>
                            
                        <?php } else { ?>
                        
                            <textarea class="form-control" id="wpsg_mod_kundenkontakt_text" name="wpsg_mod_kundenkontakt_text"></textarea>
                    
                        <?php } ?>
                        
                    </div>
                        
            </div>
            
            <div class="clearfix wpsg_clear"></div>
            
        </div> 
            
        <?php echo wpsg_drawForm_Button(__('Kunden informieren', 'wpsg'), '', ['wrap_id' => 'wpsg_mod_kundenkontakt_submit_wrap', 'field_id' => 'wpsg_mod_kundenkontakt_submit']); ?>
        
        <?php echo wpsg_drawForm_Text('', __('Bitte warten ...', 'wpsg'), 'wpsg_mod_kundenverwaltung_loading', ['wrap_id' => 'wpsg_mod_kundenkontakt_loading_wrap']); ?>
        
    </div>
</fieldset>

<script>
            
    let el_wpsg_mod_kundenkontakt_layer = document.getElementById('wpsg_mod_kundenkontakt_layer');
    
    let el_wpsg_mod_kundenkontakt_subject = document.getElementById('wpsg_mod_kundenkontakt_subject');
    let el_wpsg_mod_kundenkontakt_subject_wrap = document.getElementById('wpsg_mod_kundenkontakt_subject_wrap');
    
    let el_wpsg_mod_kundenkontakt_text = document.getElementById('wpsg_mod_kundenkontakt_text');
    let el_wpsg_mod_kundenkontakt_text_wrap = document.getElementById('wpsg_mod_kundenkontakt_text_wrap');
    
    let el_wpsg_mod_kundenkontakt_submit = document.getElementById('wpsg_mod_kundenkontakt_submit');
    let el_wpsg_mod_kundenkontakt_submit_wrap = document.getElementById('wpsg_mod_kundenkontakt_submit_wrap');
    
    let el_wpsg_mod_kundenkontakt_loading_wrap = document.getElementById('wpsg_mod_kundenkontakt_loading_wrap');
    
    let el_doaction = document.getElementById('doaction');
    
    document.getElementById('wpsg_mod_kundenkontakt_template').addEventListener('change', (event) => {
            
        if (event.target.value !== '0') {
            
                el_wpsg_mod_kundenkontakt_loading_wrap.style.display = 'block';
                
            jQuery.ajax({ 
                url: "<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_kundenkontakt&noheader=1&do=kk_switchTemplate",
                dataType: 'json',
                data: {                                 
                    template_file: event.target.value
                },
                success: function(data) {
            
                        el_wpsg_mod_kundenkontakt_loading_wrap.style.display = 'none';
                        
                        el_wpsg_mod_kundenkontakt_subject_wrap.style.display = 'block';
                        el_wpsg_mod_kundenkontakt_text_wrap.style.display = 'block';  
                        el_wpsg_mod_kundenkontakt_submit_wrap.style.display = 'block';  
                        
                    el_wpsg_mod_kundenkontakt_subject.value = data.subject;
                    
                    <?php if ($this->get_option('wpsg_htmlmail') === '1') { ?>
                    tinyMCE.get('wpsg_mod_kundenkontakt_text').setContent(data.content);
                    <?php } else { ?>
                    el_wpsg_mod_kundenkontakt_text.value = data.content;
                    <?php } ?>
                    
                }
            });

            } else {
                                
                el_wpsg_mod_kundenkontakt_subject_wrap.style.display = 'none';
                el_wpsg_mod_kundenkontakt_text_wrap.style.display = 'none';
                el_wpsg_mod_kundenkontakt_submit_wrap.style.display = 'none';
                el_wpsg_mod_kundenkontakt_loading_wrap.style.display = 'none';
                                
        }
        
    });
    
    el_wpsg_mod_kundenkontakt_submit.addEventListener('click', (event) => {
        
        event.preventDefault();
        
        let arOrderID = [];
        
        for (let el of document.querySelectorAll('.col_set_checkbox')) {
                
                if (el.checked) arOrderID.push(el.getAttribute('data-order_id'));
                
        }
                
        if (arOrderID.length <= 0) {
                
                alert('<?php echo __('Bitte mindestens eine Bestellung auswählen.', 'wpsg'); ?>');
                return;
        }       
        
        el_wpsg_mod_kundenkontakt_submit.setAttribute("disabled", "disabled");
        el_wpsg_mod_kundenkontakt_subject.setAttribute("disabled", "disabled");
        el_wpsg_mod_kundenkontakt_text.setAttribute("disabled", "disabled");
          
        el_wpsg_mod_kundenkontakt_loading_wrap.style.display = 'block';
        
        jQuery.ajax({ 
            url: "<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_kundenkontakt&noheader=1&do=kk_sendMail",
            data: {                                     
                arOrderID: arOrderID,
                text: el_wpsg_mod_kundenkontakt_text.value,
                el_wpsg_mod_kundenkontakt_subject: el_wpsg_mod_kundenkontakt_subject.value
            },
            success: function(data) {
                                        
                document.getElementById('wpsg_mod_kundenkontakt_template').selectedIndex = 0;
                
                for (let el of document.querySelectorAll('.col_set_checkbox')) {
                        
                        el.checked = false;
                        
                    }
                
                el_wpsg_mod_kundenkontakt_loading_wrap.style.display = 'none';
                
                el_wpsg_mod_kundenkontakt_subject_wrap.style.display = 'none';
                el_wpsg_mod_kundenkontakt_subject.value = '';
                
                el_wpsg_mod_kundenkontakt_text_wrap.style.display = 'none';
                el_wpsg_mod_kundenkontakt_text.value = '';
                        
                el_wpsg_mod_kundenkontakt_submit.removeAttribute("disabled");
                el_wpsg_mod_kundenkontakt_subject.removeAttribute("disabled");
                el_wpsg_mod_kundenkontakt_text.removeAttribute("disabled");
                
                el_wpsg_mod_kundenkontakt_submit_wrap.style.display = 'none';
                
                alert(data);
                
            }
        });
        
    });
    
    document.getElementById('wpsg_action').addEventListener('change', (event) => {
        
        if (event.target.value === 'customercontact') {
            
                el_doaction.style.display = 'none';
            el_wpsg_mod_kundenkontakt_layer.style.display = 'block';
            
        } else {
        
                el_doaction.style.display = 'inline-block';
                el_wpsg_mod_kundenkontakt_layer.style.display = 'none';
                
        }
        
    });
    
</script>

<style>
    
    #wpsg_mod_kundenkontakt_text { height:300px; }
    #wpsg_mod_kundenkontakt_subject_wrap { display:none; }
    #wpsg_mod_kundenkontakt_text_wrap { display:none; }
    #wpsg_mod_kundenkontakt_submit_wrap { display:none; }
    #wpsg_mod_kundenkontakt_loading_wrap { display:none; }
    #wpsg_mod_kundenkontakt_layer .form-group > label { width:15% !important; }
    #wpsg_mod_kundenkontakt_layer .wpsg_form_field > .wpsg_form_left { width:15% !important; }
    #wpsg_mod_kundenkontakt_layer .form-group > div:nth-child(2),
    #wpsg_mod_kundenkontakt_layer .wpsg_form_field > .wpsg_form_right { width:85% !important; }
    
</style>