Subversion Repositories wpShopGermany4

Rev

Rev 7715 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

        /**
         * Template für die Integration der Kundeneingaben für das Modul "Kreditkarte" in den Checkout2
         */

        if (!isset($this->view['error'])) $this->view['error'] = [];

?>
<br /><br />
<div class="wpsg_mod_creditcard">
        
        <div class="wpsg_mod_creditcard_name wpsg_mod_creditcard_field">
                <label>

            <?php echo __('Typ der Kreditkarte', 'wpsg'); ?><span class="wpsg_required">*</span>:

                        <select name="wpsg_mod_creditcard[typ]" id="wpsg_mod_creditcard_typ" 
                        class="<?php echo ((in_array('mod_creditcard_typ', (array)$this->view['error']))?'wpsg_error':''); ?>" >
                                <option value="VISA" <?php echo (($this->view['wpsg_mod_creditcard']['typ'] === 'VISA')?'selected="selected"':''); ?>>VISA</option>
                                <option value="MasterCard" <?php echo (($this->view['wpsg_mod_creditcard']['typ'] === 'MasterCard')?'selected="selected"':''); ?>>MasterCard</option>
                        </select>
                        
                </label>
        </div>
        <div class="wpsg_clear"></div>

        <div class="wpsg_mod_creditcard_inhaber wpsg_mod_creditcard_field">
                <label>
                        <?php echo __('Inhaber', 'wpsg'); ?><span class="wpsg_required">*</span>:
                        <input class="<?php echo ((in_array("mod_creditcard_inhaber", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" name="wpsg_mod_creditcard[inhaber]" value="<?php echo wpsg_hspc($this->view['wpsg_mod_creditcard']['inhaber']); ?>" />
                </label>
        </div>
        <div class="wpsg_clear"></div>
        
        <div class="wpsg_mod_creditcard_knr wpsg_mod_creditcard_field">
                <label>
                        <?php echo __('Kartennummer', 'wpsg'); ?><span class="wpsg_required">*</span>:
                        <input class="<?php echo ((in_array("mod_creditcard_knr", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" id="wpsg_mod_creditcard_knr" name="wpsg_mod_creditcard[knr]" value="<?php echo wpsg_hspc($this->view['wpsg_mod_creditcard']['knr']); ?>" />
                </label>
        </div>
        <div class="wpsg_clear"></div>

        <div class="wpsg_mod_creditcard_knr wpsg_mod_creditcard_field">
                <label>
                        <?php echo __('Prüfziffer', 'wpsg'); ?><span class="wpsg_required">*</span>:
                        <input class="<?php echo ((in_array("mod_creditcard_pruefz", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" name="wpsg_mod_creditcard[pruefz]" value="<?php echo wpsg_hspc($this->view['wpsg_mod_creditcard']['pruefz']); ?>" />
                </label>
        </div>
        <div class="wpsg_clear"></div>

        <div class="wpsg_mod_creditcard_knr wpsg_mod_creditcard_field">
                <label>
                        <?php echo __('Gültigkeit', 'wpsg'); ?><span class="wpsg_required">*</span>:
                        <!-- <input class="<?php echo ((in_array("mod_creditcard_gueltig", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" name="wpsg_mod_creditcard[gueltig]" value="<?php echo wpsg_hspc(wpsg_getStr($this->view['wpsg_mod_creditcard']['gueltig'])); ?>" /> -->
                        
                        <select name="wpsg_mod_creditcard[gueltigm]" id="wpsg_mod_creditcard_gueltigm" 
                        class="<?php echo ((in_array('mod_creditcard_gueltigm', (array)$this->view['error']))?'wpsg_error':''); ?>" >
                                <option value="01">01</option>
                                <option value="02">02</option>
                                <option value="03">03</option>
                                <option value="04">04</option>
                                <option value="05">05</option>
                                <option value="06">06</option>
                                <option value="07">07</option>
                                <option value="08">08</option>
                                <option value="09">09</option>
                                <option value="10">10</option>
                                <option value="11">11</option>
                                <option value="12" selected="selected">12</option>
                        </select>
                        <select name="wpsg_mod_creditcard[gueltigj]" id="wpsg_mod_creditcard_gueltigj" 
                        class="<?php echo ((in_array('mod_creditcard_gueltigj', (array)$this->view['error']))?'wpsg_error':''); ?>" >

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

        
        <div class="wpsg_mandatoryfield_hint">
                <?php echo wpsg_translate(__('Mit #1# gekennzeichnete Felder sind Pflichtfelder.', 'wpsg'), '<span class="wpsg_required">*</span>'); ?>
        </div>
        
</div>

<script>

jQuery(document).ready(function() { 
        var gm,
                gj,
                sel1,
                i,
                dt,
                garr;

        gm="<?php echo wpsg_hspc($this->view['wpsg_mod_creditcard']['gueltigm']); ?>";
        gj="<?php echo wpsg_hspc($this->view['wpsg_mod_creditcard']['gueltigj']); ?>";

        dt = new Date();
        dt = dt.getFullYear();
    sel1 = document.getElementById("wpsg_mod_creditcard_gueltigj");
    for (i = 0; i < 6; i++) {
        newopt = new Option(dt + i, dt + i, false, false);
        sel1.options[i] = newopt;
    }
    //gm = '06';
    //gj = '2018';
    jQuery('#wpsg_mod_creditcard_gueltigm').val(gm);
    jQuery('#wpsg_mod_creditcard_gueltigj').val(gj);

        
});

//alert(jQuery("#wpsg_mod_creditcard_knr").length);
//$(document).on("input", "#wpsg_mod_creditcard_knr", function () {
jQuery("#wpsg_mod_creditcard_knr").on("input", function () {
        var
                knr,
                typ,
                a1,
                ai,
                isANumber,
                bb = true,
                sum = 0,
                k = 2,
                i;
        //alert("onchange");
        knr = jQuery('#wpsg_mod_creditcard_knr').val();
        typ = jQuery('#wpsg_mod_creditcard_typ').val();
        knr = knr.replace(/ /g, "");
        if (knr.length < 16) { return; }

        isANumber = (isNaN(knr) === false);
        if (isANumber === false) { bb = false; }
        a1 = knr.substr(0, 1);
        ai = parseInt(knr.substr(15, 1), 10);
        if (!(((a1 === "4") && (typ === "VISA")) || ((a1 === "5") && (typ === "MasterCard")))) { bb = false; }
        for (i = 14; i >= 0; i--) {
        dig = k * parseInt(knr.substr(i, 1), 10);
        if (dig > 9) { dig = dig - 9;}
                sum = sum + dig;
                //sum = sum + k * parseInt(knr.substr(i, 1), 10);
                if (k === 2) { k = 1; } else { k = 2; }
        }
        sum = sum % 10;
        if (sum > 0) { sum = 10 - sum; }
        if (sum !== ai) { bb = false; }

        if (bb === false) {
                alert('Kartennummer fehlerhaft');
        }

});


</script>