summaryrefslogtreecommitdiff
path: root/views/admin/emailconf.phtml
blob: 8aade00dd16ea4ed257e79927f017da0f4eea3b1 (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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<?php

	/**
	 * Template für die E-Mail Konfiguration
	 */

?>
<div class="wpsg_admin_submenu">
	
	<div class="list-group">
		<span class="list-group-head list-group-item"><?php echo __('Konfiguration'); ?></span>
		<?php foreach ($this->view['arSubAction'] as $k => $v) { ?>
			<a class="list-group-item <?php echo (($k == $this->view['subAction'])?'active':''); ?>" href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&amp;subaction=<?php echo $k; ?>"><?php echo $v['Menutext']; ?></a>
		<?php } ?>
	</div>

</div>

<script>

    var uploadData = {};
    
</script>

<div class="wpsg_admin_content form-horizontal">
	<form name="form1" method="post" enctype="multipart/form-data" action="<?php echo wpsg_hspc(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction=emailconf&noheader=1'); ?>">

		<?php wp_nonce_field('wpsg-admin-emailconf'); ?>
		
		<?php echo wpsg_drawForm_AdminboxStart('Allgemeine Einstellungen', 'wpsg'); ?>
		<?php $logoPath = wpsg_getUploadDir('wpsg_mailconf').'wpsg_email_logo.jpg'; ?>

		<?php echo wpsg_drawForm_Checkbox(
			'wpsg_htmlmail',
			__('HTML Mails versenden', 'wpsg'),
			$this->get_option('wpsg_htmlmail')
		); ?>


		<div class="col-emaillogo">

			<?php if(file_exists($logoPath)) { ?>
                
				<?php echo wpsg_drawForm_Checkbox(
					'wpsg_email_logo_activated',
					__("E-Maillogo anzeigen"),
					$this->get_option('wpsg_email_logo_activated')
				); ?>

				<?php echo wpsg_drawForm_Checkbox(
					'wpsg_email_logo_watermark',
					__("E-Maillogo als Wasserzeichen anzeigen"),
					$this->get_option('wpsg_email_logo_watermark')
				); ?>
                
			<?php } ?>

			<br />
			
			<div class="form-group">
				<div class="col-sm-6 control-label control-label-email-conf">
					<label><?php echo __("E-Maillogo (JPG)"); ?></label>
				</div>
				<div class="col-sm-6">
					<?php if(file_exists($logoPath)) { ?>
						<a href="<?php echo WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction=emailconf&getEmailLogo=1&noheader=1'; ?>" target="_blank"><?php echo __('Derzeitiges Logo', 'wpsg'); ?></a><br>
					<?php } ?>
					<input type="file" name="wpsg_email_logo">
				</div>

				<?php if(file_exists($logoPath)) { ?>
					<?php echo wpsg_drawForm_Checkbox(
						'wpsg_email_logo_del',
						__("Logo Löschen"),
						0
					); ?>
				<?php } ?>

			</div> <!-- .form-group -->
			
			<br />
			
			<?php if(file_exists($logoPath)) { ?>

				<div class="form-group col-logo-alignment">
					<div class="col-sm-6 control-label control-label-email-conf">
						<label><?php echo __("Ausrichtung des Maillogos"); ?></label>
					</div>
					<div class="col-sm-6 email-logo-alignment">
						<?php $logoAlignment = $this->get_option('wpsg_email_logo_alignment'); ?>
						<?php $standardAlignment = false; ?>
						<?php if(!wpsg_isSizedString($logoAlignment)) $standardAlignment = true; ?>
						<input type="radio" name="wpsg_email_logo_alignment" value="left" <?php if($logoAlignment === "left"):?>checked<?php endif;?>> <span>&#xf036 <?php echo __("Linksbündig"); ?></span> <br>
						<input type="radio" name="wpsg_email_logo_alignment" value="center" <?php if($logoAlignment === "center"):?>checked<?php endif;?>> <span>&#xf037 <?php echo __("Zentriert"); ?></span> <br>
						<input type="radio" name="wpsg_email_logo_alignment" value="right" <?php if($logoAlignment === "right" || $standardAlignment):?>checked<?php endif;?>> <span>&#xf038 <?php echo __("Rechtsbündig"); ?></span>
					</div>
				</div>
				
				<br />
				
				<?php $logoTransparency = $this->get_option('wpsg_email_logo_transparency'); ?>
				<?php if(!wpsg_isSized($logoTransparency)) $logoTransparency = "100%"; ?>
				<?php echo wpsg_drawForm_Input(
					'wpsg_email_logo_transparency',
					__("Deckkraft des Logos"),
					strpos($logoTransparency, "%") !== false ? $logoTransparency : $logoTransparency."%"
				); ?>

			<?php } ?>

		</div>
		<?php echo wpsg_drawForm_AdminboxEnd(); ?>

		<?php echo wpsg_drawEMailConfig(
			'global',
			__('Globale Vorgaben', 'wpsg'),
			__('Werden keine Angaben für die folgenden E-Mails gemacht, so gelten die globalen Angaben.', 'wpsg')); ?>

		<?php echo wpsg_drawEMailConfig(
			'adminmail',
			__('Bestellbestätigung (Admin)', 'wpsg'),
			__('Diese Mail bekommt der Admin beim Eingang einer neuen Bestellung.', 'wpsg'),
			true); ?>

		<?php echo wpsg_drawEMailConfig(
			'kundenmail',
			__('Bestellbestätigung (Kunde)', 'wpsg'),
			__('Diese Mail bekommt der Kunde nach Durchführung der Bestellung.', 'wpsg'),
			false,
			true); ?>

		<?php echo wpsg_drawEMailConfig(
			'status',
			__('Statusänderung (Kunde)', 'wpsg'),
			__('Diese Mail bekommt der Kunde bei der Änderung des Bestellstatus.', 'wpsg')); ?>

        <?php echo wpsg_drawEMailConfig(
            'reminder',
            __('Erinnerung bei Nichtabschluss', 'wpsg'),
            __('Diese Mail bekommen Kunden die eine Bestellung nicht abgeschlossen haben.', 'wpsg'),
			false,
			false,
			'mailtemplates/reminder.phtml'
		); ?>

		<?php $this->callMods('admin_emailconf'); ?>

		<div class="wpsg_hinweis"><?php echo __('Klicken Sie auf die jeweilige Mail um die Einstellungen angezeigt zu bekommen bzw. zu ändern.', 'wpsg'); ?></div>

		<p class="submit"><input type="submit" value="<?php echo __('Einstellungen speichern', 'wpsg'); ?>" class="button-primary" id="submit" name="submit" /></p>

	</form>
</div>

<script type="text/javascript">/* <![CDATA[ */

	/**
	 * Speichert die Informationen ob die Mailboxen auf oder zugeklappt sind in dem Cookie
	 */
	function wpsg_mail_save_cookie()
	{

		var wpsg_mail_open = Array();

		jQuery('.wpsg_email_box .panel-body:visible').each(function() {

			wpsg_mail_open.push(jQuery(this).prev().attr("id"));

		} );

		jQuery.cookie('wpsg_mail', wpsg_mail_open.join(','));

	} // function wpsg_mail_save_cookie()
    
    function wpsg_removeAttachemnt(a) {
	     
	    var id = parseInt(a.getAttribute('data-id'));
	    var key = a.getAttribute('data-key');
 
        uploadData[key].forEach(function(item, index, object) {

            if (parseInt(item.id) === id) {
 
                object.splice(index, 1);
                
            }
            
        } ); 
                
        return false;
	    
    }
    
    var wpframe;
	
	jQuery(document).ready(function() {
	    
        jQuery(".btnAddAttachment").click(function(event) {

            var source = event.target || event.srcElement;
            var key = jQuery(source).attr("data-key");
            
            event.preventDefault();

            if (wpframe) { wpframe.open(); return; }
 
            wpframe = wp.media.frames.file_frame = wp.media({
                title: "<?php echo __('Auswählen oder Hochladen von Medien', 'wpsg'); ?>",
                button: { text: "<?php echo __('Medien benutzen', 'wpsg'); ?>" },
                multiple: true  
            });
 
            wpframe.on('select', function() {

                var attachments = wpframe.state().get('selection').map( function(attachment) {

                    attachment.toJSON();
 
                    var bDrin = false;
                
                    for (var i in uploadData[key]) {
                        
                        if (uploadData[key][i].id === attachment.id) {
                            
                            bDrin = true;
                            
                            break;
                            
                        }
                        
                    }
                    
                    if (!bDrin) {
                    
                        uploadData[key].push( {
                            id: attachment.id, 
                            filename: attachment.attributes.filename,
                            url: attachment.attributes.url
                        } );
                        
                    }
                    
                    return attachment;
                    
                } ); 
                
            } );
 
            wpframe.open();

        } );
	    
		jQuery('.wpsg_email_box .panel-heading').bind('click', function() {

			jQuery(this).next().toggle();

			wpsg_mail_save_cookie();

		} ).css( { 'cursor': 'pointer' } ).disableSelection().next().hide();

		if (jQuery.cookie('wpsg_mail') != null)
		{

			var arOpen = jQuery.cookie('wpsg_mail').split(',');

			for (var i = 0; i < arOpen.length; i ++)
			{

				jQuery('#' + arOpen[i]).next().show();
				jQuery('#' + arOpen[i]).css('border-bottom', '0px');

			}

		}

		jQuery("#wpsg_htmlmail").click(function() {

			if(jQuery("#wpsg_htmlmail")[0].checked == false) jQuery(".col-emaillogo").css("display", "none");
			else $(".col-emaillogo").css("display", "block");

		});
		if(jQuery("#wpsg_htmlmail")[0].checked == false) jQuery(".col-emaillogo").css("display", "none");

		jQuery("#wpsg_email_logo_watermark").click(function() {

			if(jQuery("#wpsg_email_logo_watermark")[0].checked == true) jQuery(".col-logo-alignment").hide();
			else jQuery(".col-logo-alignment").show()

		});
		
		if(jQuery("#wpsg_email_logo_watermark").first().checked == true) jQuery(".col-logo-alignment").hide();

	} );

	/* ]]> */</script>