summaryrefslogtreecommitdiff
path: root/views/mods/mod_abo/settings_edit.phtml
blob: fc418d172214829a878d7ab73a65d4cfc52106e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php

	/**
	 * Template für die Einstellungen des Abo Moduls
	 */
	
	$arPaymentSelect = [
		'origin' => __('Wie ursprüngliche Zahlungsart', 'wpsg')
	];
	
	foreach ($this->arPayment as $p) { $arPaymentSelect[$p['id']] = $p['name']; }
	
?>
<?php echo wpsg_drawForm_Input('wpsg_mod_abo_url', __('Standard URL für Ablauf/Verlängerung', 'wpsg'), $this->get_option('wpsg_mod_abo_url'), array ('help' => 'wpsg_mod_abo_url')); ?>
<br />
<?php echo wpsg_drawForm_Checkbox('wpsg_mod_abo_wpsgmodabofirstbuy', __('Mail bei erstem Kauf eines Abos', 'wpsg'), $this->get_option('wpsg_mod_abo_wpsgmodabofirstbuy'), array('hint' => wpsg_translate(__('Mail wird bei Bezahlung der Abo Bestellung zusätzlich versendet. (mail_firstbuy.phtml) -> <a href="#1#">Konfiguration</a>', 'wpsg'), WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction=emailconf#wpsgmodabofirstbuy'), 'help' => 'wpsg_mod_abo_wpsgmodabofirstbuy')); ?>
<?php echo wpsg_drawForm_Checkbox('wpsg_mod_abo_wpsgmodabrebuy', __('Mail bei Kauf einer Verlängerung', 'wpsg'), $this->get_option('wpsg_mod_abo_wpsgmodabrebuy'), array('hint' => wpsg_translate(__('Mail wird bei Bezahlung einer Abo Verlängerung versendet. (mail_rebuy.phtml) -> <a href="#1#">Konfiguration</a>', 'wpsg'), WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction=emailconf#wpsgmodabrebuy'), 'help' => 'wpsg_mod_abo_wpsgmodabrebuy')); ?>

<br />

<?php echo wpsg_drawForm_Input('wpsg_mod_abo_perpage', __('Abos pro Seite (Backend)', 'wpsg'), $this->get_option('wpsg_mod_abo_perpage'), array('help' => 'wpsg_mod_abo_perpage')); ?>

<br />
 
<?php echo wpsg_drawForm_Select('wpsg_mod_abo_expiremode', __('Bei Ablauf des Abos', 'wpsg'), Array(
    wpsg_mod_abo::EXPIRE_NONE => __('Nichts', 'wpsg'),
	wpsg_mod_abo::EXPIRE_MAIL => __('Mail versenden', 'wpsg'),
	wpsg_mod_abo::EXPIRE_AUTO => __('Automatisch verlängern', 'wpsg')
), $this->get_option('wpsg_mod_abo_expiremode'), array('help' => 'wpsg_mod_abo_expiremode')); ?>

<?php echo wpsg_drawForm_Select('wpsg_mod_abo_premode', __('X - Tage vor Ablauf des Abos', 'wpsg'), [
    wpsg_mod_abo::EXPIRE_NONE => __('Nichts', 'wpsg'),
    wpsg_mod_abo::EXPIRE_MAIL => __('Mail versenden', 'wpsg'),
    wpsg_mod_abo::EXPIRE_AUTO => __('Automatisch verlängern', 'wpsg')
], $this->get_option('wpsg_mod_abo_premode'), ['help' => 'wpsg_mod_abo_premode']); ?>

<div id="wpsg_mod_abo_premode_greater0" style="display:none;">

    <?php echo wpsg_drawForm_Input('wpsg_mod_abo_autoexpire_informationtime', __('Zeitspanne zum Versenden der Informationsmail in Tagen', 'wpsg'), $this->get_option('wpsg_mod_abo_autoexpire_informationtime'), [
        'help' => 'wpsg_mod_abo_autoexpire_informationtime'
    ]); ?>

</div>

<script>

    let wpsg_mod_abo_premodeSELECT = document.getElementById('wpsg_mod_abo_premode');
    let wpsg_mod_abo_premode_greater0DIV = document.getElementById('wpsg_mod_abo_premode_greater0');

    wpsg_mod_abo_premodeSELECT.addEventListener('change', () => {

        console.log(parseInt(wpsg_mod_abo_premodeSELECT.value));

        if (parseInt(wpsg_mod_abo_premodeSELECT.value) > 0 || (parseInt(wpsg_mod_abo_premodeSELECT.value) === -1 && <?php echo ((intval($this->get_option('wpsg_mod_abo_premode')) > 0)?'true':'false'); ?>)) {

            wpsg_mod_abo_premode_greater0DIV.style.display = 'block';

        } else {

            wpsg_mod_abo_premode_greater0DIV.style.display = 'none';

        }

    });

    wpsg_mod_abo_premodeSELECT.dispatchEvent(new Event('change'));

</script>

<br />

<div id="wpsg_mod_abo_expiremode_auto_layer" style="display:none;">
	
	<?php /* TODO: Mehrfachauswahl von Zahlungsarten */ ?>
	<?php echo wpsg_drawForm_Select('wpsg_mod_abo_autoexpire_payment', __('Zahlungsart für automatische Verlängerung', 'wpsg'), $arPaymentSelect, $this->get_option('wpsg_mod_abo_autoexpire_payment'), array('help' => 'wpsg_mod_abo_autoexpire_payment')); ?>

	<?php echo wpsg_drawForm_Select('wpsg_mod_abo_autoexpire_customermail', __('Mail an Kunden', 'wpsg'), [
        '0' => __('Nein', 'wpsg'),
        '1' => __('Ja', 'wpsg')
    ], $this->get_option('wpsg_mod_abo_autoexpire_customermail'), ['help' => 'wpsg_mod_abo_autoexpire_customermail']); ?>

    <?php echo wpsg_drawForm_Select('wpsg_mod_abo_autoexpire_adminmail', __('Mail an Administrator', 'wpsg'), [
        '0' => __('Nein', 'wpsg'),
        '1' => __('Ja', 'wpsg')
    ], $this->get_option('wpsg_mod_abo_autoexpire_adminmail'), ['help' => 'wpsg_mod_abo_autoexpire_adminmail']); ?>

	<br />

</div>

<script>

    let wpsg_mod_abo_expiremode_auto_layer = document.getElementById('wpsg_mod_abo_expiremode_auto_layer');
    let wpsg_mod_abo_expiremode = document.getElementById('wpsg_mod_abo_expiremode');
    let wpsg_mod_abo_premode = document.getElementById('wpsg_mod_abo_premode');

    function displayAutoRenewOptions() {

    	if (wpsg_mod_abo_expiremode.value === '<?php echo wpsg_mod_abo::EXPIRE_AUTO; ?>' || wpsg_mod_abo_premode.value === '<?php echo wpsg_mod_abo::EXPIRE_AUTO; ?>') {

    		wpsg_mod_abo_expiremode_auto_layer.style.display = 'block';

        } else {

    		wpsg_mod_abo_expiremode_auto_layer.style.display = 'none';

        }

    }

    wpsg_mod_abo_expiremode.addEventListener('change', displayAutoRenewOptions);
    wpsg_mod_abo_premode.addEventListener('change', displayAutoRenewOptions);

    displayAutoRenewOptions();

</script>

<?php echo wpsg_drawForm_Select('wpsg_mod_abo_autoexpire_customer', __('Kunde kann im Frontend', 'wpsg'), Array(
    wpsg_mod_abo::CUSTOMER_AUTO_NOTHING => __('Nichts', 'wpsg'),
    wpsg_mod_abo::CUSTOMER_AUTO_DIRECT => __('Verlängerung direkt stoppen', 'wpsg'),
    wpsg_mod_abo::CUSTOMER_AUTO_MAIL => __('Verlängerung über Mail an Administrator stoppen', 'wpsg')
), $this->get_option('wpsg_mod_abo_autoexpire_customer'), array('help' => 'wpsg_mod_abo_autoexpire_customer')); ?>

<?php echo wpsg_drawForm_Input(false, __('CRON URL', 'wpsg'), site_url().'/?wpsg_cron=1', ['readonly' => true]); ?>

<?php echo wpsg_drawForm_TextStart(); ?>

    <span><?php echo __('Letzter Lauf: ', 'wpsg'); ?><?php echo wpsg_formatTimestamp($this->get_option('wpsg_mod_abo_cron_lastrun'), false, true); ?></span><br />
    <span>
        <?php
            
            $upload_dir = \wp_upload_dir();
            $pid_file = $upload_dir['basedir'].'/wpsg_cron_abo';
            
            echo __('Status: ', 'wpsg'); 
            
        ?><?php echo (($this->get_option('wpsg_mod_abo_cron_run') === '1')?_('Läuft gerade'):_('Wartend')); ?> 
        <?php if ($this->get_option('wpsg_mod_abo_cron_run') === '1' || file_exists($pid_file)) { ?>
            (<?php echo __('Start: ', 'wpsg'); ?><?php echo wpsg_formatTimestamp($this->get_option('wpsg_mod_abo_cron_start'), false, true); ?>)
            <a href="<?php echo WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_abo&subaction=resetCron&noheader=1'; ?>"><?php echo __('Zurücksetzen', 'wpsg'); ?></a>
        <?php } ?>
    </span>

<?php echo wpsg_drawForm_TextEnd(__('Cron Status')); ?>

<br /> 

<script>

    jQuery(document).ready(function() {
    	
    	jQuery('#wpsg_mod_abo_expiremode').on('change', function() {
    		
    		jQuery('.wpsg_mod_expiremode').hide();
			jQuery('.wpsg_mod_expiremode_' + jQuery(this).val()).show();
    		
		} ); 

	} );

</script>