summaryrefslogtreecommitdiff
path: root/views/admin/laender.phtml
blob: 41c5fdd26a55a50c274d42cf5ee68f3a913b7153 (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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
<?php

	/**
	 * Template für die Länderverwaltung
	 */

?>
<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>

<div class="modal fade" id="Modal_wpsg_country_edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" id="myModalLabel"><?php echo __('Land anlegen/bearbeiten', 'wpsg'); ?></h4>
			</div>
			<div class="modal-body">

			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" onclick="return wpsg_country_save();" data-dismiss="modal"><?php echo __('Speichern und schließen', 'wpsg'); ?></button>
			</div>
		</div>
	</div>
</div>

<div class="wpsg_admin_content">

	<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=laender&noheader=1'); ?>">

		<?php echo wpsg_drawForm_AdminboxStart(__('Länderverwaltung', 'wpsg')); ?>

		<div id="wpsg_country_list">

			<?php if (wpsg_isSizedArray($this->view['data'])) { ?>
			<table class="table wpsg_table_country">

				<tr>
					<th class="col_check"><input type="checkbox" onclick="return wpsg_country_check_all();" style="margin-top:-2px;" /></th>
					<th class="col_name"><?php echo __('Ländername', 'wpsg'); ?></th>
					<th class="col_vz"><?php echo __('Versandzone', 'wpsg'); ?></th>
					<th class="col_mwstsetting"><?php echo __('MwSt.', 'wpsg'); ?></th>
					<th class="col_mwst"><?php echo __('MwSt. A', 'wpsg'); ?></th>
					<th class="col_mwst"><?php echo __('MwSt. B', 'wpsg'); ?></th>
					<th class="col_mwst"><?php echo __('MwSt. C', 'wpsg'); ?></th>
					<th class="col_mwst"><?php echo __('MwSt. D', 'wpsg'); ?></th>
					<th class="col_action"></th>
				</tr>

				<?php foreach ($this->view['data'] as $l) { ?>
				<tr id="<?php echo $l['id']; ?>">
					<td class="col_check"><input type="checkbox" value="1" name="arDelete[<?php echo $l['id']; ?>]" /></td>
					<td class="col_name"><?php echo wpsg_hspc($l['name'].((wpsg_isSizedString($l['kuerzel']))?' ('.$l['kuerzel'].')':'')); ?></td>
					<td class="col_vz">
						<?php if (wpsg_isSizedInt($l['vz']) && wpsg_isSizedString($this->view['vz'][$l['vz']])) { ?>
						<?php echo wpsg_hspc($this->view['vz'][$l['vz']]); ?>
						<?php } ?>
					</td>
					<td class="col_mwstsetting">
						<?php if ($l['mwst'] == '2') { ?>
						<?php echo __('keine MwSt. bei USt.IdNr.', 'wpsg'); ?>
						<?php } else if ($l['mwst'] == '1') { ?>
						<?php echo __('keine MwSt.', 'wpsg'); ?>
						<?php } else { ?>
						<?php echo __('mit MwSt.', 'wpsg'); ?>
						<?php } ?>
					</td>
					<td class="col_mwst"><?php if (wpsg_tf($l['mwst_a']) != NULL) { ?>
						<?php echo wpsg_ff(wpsg_tf($l['mwst_a']), '%'); ?>
					<?php } ?></td>
					<td class="col_mwst"><?php if (wpsg_tf($l['mwst_b']) != NULL) { ?>
						<?php echo wpsg_ff(wpsg_tf($l['mwst_b']), '%'); ?>
					<?php } ?></td>
					<td class="col_mwst"><?php if (wpsg_tf($l['mwst_c']) != NULL) { ?>
						<?php echo wpsg_ff(wpsg_tf($l['mwst_c']), '%'); ?>
					<?php } ?></td>
					<td class="col_mwst"><?php if (wpsg_tf($l['mwst_d']) != NULL) { ?>
						<?php echo wpsg_ff(wpsg_tf($l['mwst_d']), '%'); ?>
					<?php } ?></td>
					<td class="col_action">

						<a href="#" onclick="return wpsg_country_edit('<?php echo $l['id']; ?>');" class="glyphicon glyphicon-pencil"></a>
						<a href="#" class="glyphicon glyphicon-trash"></a>

					</td>
				</tr>
				<?php } ?>

				<tr>

					<td class="col_check"><span class="glyphicon glyphicon-trash"></span></td>
					<td colspan="8">

						<input type="submit" name="submit" onclick="return confirm('<?php echo __('Sind Sie sich sicher?', 'wpsg'); ?>');" class="button btn-xs" value="<?php echo __('Markierte Länder löschen', 'wpsg'); ?>" />

					</td>

				</tr>

			</table>
			<?php } else { ?>
			<p><?php echo __('Noch keine Länder angelegt.', 'wpsg'); ?></p>
			<?php } ?>

		</div>

		<br />

	</form>

	<a href="#" onclick="return wpsg_country_add();"><span class="wpsg-glyphicon glyphicon glyphicon-plus"></span><?php echo __('Neues Land anlegen.', 'wpsg'); ?></a><br /><br />
	<a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=vz"><span class="wpsg-glyphicon glyphicon glyphicon-wrench"></span><?php echo __('Zur Versandzonenverwaltung', 'wpsg'); ?></a>
	
	<?php echo wpsg_drawForm_AdminboxEnd(); ?>

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

	    function wpsg_country_check_all() { jQuery('td.col_check input').each(function() { jQuery(this).prop('checked', !jQuery(this).prop('checked')); } ); }

		function wpsg_country_add()
		{

			jQuery('#Modal_wpsg_country_edit .modal-body').html('<img src="<?php echo $this->getRessourceURL('gfx/ajax-loader.gif'); ?>" alt="" />');
			jQuery('#Modal_wpsg_country_edit').modal('show');

			jQuery.ajax( {
				url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=laender&do=add&noheader=1',				
				success: function(data) { jQuery('#Modal_wpsg_country_edit .modal-body').html(data); }
			} );
			
			return false;

		} // function wpsg_country_add()

		function wpsg_country_save()
		{

			jQuery('#wpsg_country_list').html('<img src="<?php echo $this->getRessourceURL('gfx/ajax-loader.gif'); ?>" alt="" />');

			jQuery.ajax( {
				url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=laender&do=save&noheader=1',
				data: {
					form_data: jQuery('#wpsg_land_edit_form_edit').serialize()
				},
				success: function(data) {

					jQuery('#wpsg_country_list').html(data);

				}
			} );

		} // function wpsg_country_save()

		function wpsg_country_edit(land_id)
		{

			jQuery('#Modal_wpsg_country_edit .modal-body').html('<img src="<?php echo $this->getRessourceURL('gfx/ajax-loader.gif'); ?>" alt="" />');
			jQuery('#Modal_wpsg_country_edit').modal('show');

			jQuery.ajax( {
				url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=laender&do=edit&noheader=1&land_id' + land_id,
				success: function(data) { jQuery('#Modal_wpsg_country_edit .modal-body').html(data); }
			} );

			return false;

		} // function wpsg_country_edit(edit_id)

	/* ]]> */</script>





	<div class="wpsg_admin_box">	
		
		<h3>
			<?php echo __('Neues Land hinzufügen', 'wpsg'); ?>
			<a target="_blank" href="http://wpshopgermany.maennchen1.de/?p=839037" class="wpsg_form_help_notip"></a>	
		</h3>
		
		<?php echo $this->render(WPSG_PATH_VIEW.'/admin/laender_edit.phtml'); ?>
		
		<h3><?php echo __('Bestehende Länder', 'wpsg'); ?></h3>
	
		<?php if (wpsg_isSizedArray($this->view['data'])) { ?>
		<table class="wpsg_admin_laender_list wpsg_admin_table" cellpadding="0" cellspacing="0">
			<tr>
				<th class="col_name"><?php echo __('Ländername', 'wpsg'); ?></th>
				<th class="col_vz"><?php echo __('Versandzone', 'wpsg'); ?></th>
				<th class="col_mwstsetting"><?php echo __('MwSt.', 'wpsg'); ?></th>
				<th class="col_mwst"><?php echo __('MwSt. A', 'wpsg'); ?></th>
				<th class="col_mwst"><?php echo __('MwSt. B', 'wpsg'); ?></th>
				<th class="col_mwst"><?php echo __('MwSt. C', 'wpsg'); ?></th>
				<th class="col_mwst"><?php echo __('MwSt. D', 'wpsg'); ?></th>				
				<th class="col_action"></th>
			</tr>
			<?php $i = 0; foreach ($this->view['data'] as $l) { $i ++; ?>
			<tr id="wpsg_laenderrow_<?php echo $l['id']; ?>" class="<?php echo (($i % 2 == 0)?'odd':'even'); ?>">
				<td class="col_name data_name"><?php echo wpsg_hspc($l['name'].((wpsg_isSizedString($l['kuerzel']))?' ('.$l['kuerzel'].')':'')); ?></td>
				<td class="col_vz data_vz">
					<?php if (wpsg_isSizedInt($l['vz']) && wpsg_isSizedString($this->view['vz'][$l['vz']])) { ?>
					<?php echo wpsg_hspc($this->view['vz'][$l['vz']]); ?>
					<?php } ?>
				</td>
				<td class="col_mwstsetting data_mwst">
					<?php if ($l['mwst'] == '2') { ?>
					<?php echo __('keine MwSt. bei USt.IdNr.', 'wpsg'); ?>
					<?php } else if ($l['mwst'] == '1') { ?>
					<?php echo __('keine MwSt.', 'wpsg'); ?>
					<?php } else { ?>
					<?php echo __('mit MwSt.', 'wpsg'); ?>
					<?php } ?>
				</td>
				<td class="col_mwst data_mwst_a">
					<?php if (wpsg_tf($l['mwst_a']) != NULL) { ?>
						<?php echo wpsg_ff(wpsg_tf($l['mwst_a']), '%'); ?>
					<?php } ?>					
				</td>
				<td class="col_mwst data_mwst_b">
					<?php if (wpsg_tf($l['mwst_b']) != NULL) { ?>
						<?php echo wpsg_ff(wpsg_tf($l['mwst_b']), '%'); ?>
					<?php } ?>					
				</td>
				<td class="col_mwst data_mwst_c">
					<?php if (wpsg_tf($l['mwst_c']) != NULL) { ?>
						<?php echo wpsg_ff(wpsg_tf($l['mwst_c']), '%'); ?>
					<?php } ?>					
				</td>
				<td class="col_mwst data_mwst_d">
					<?php if (wpsg_tf($l['mwst_d']) != NULL) { ?>
						<?php echo wpsg_ff(wpsg_tf($l['mwst_d']), '%'); ?>
					<?php } ?>					
				</td>
				<td class="col_action">
					
					<a class="wpsg_icon wpsg_icon_edit" href="#" onclick="return wpsg_laender_edit(<?php echo $l['id']; ?>);"></a> 
					<a class="wpsg_icon wpsg_icon_remove" href="#" onclick="return wpsg_laender_remove(<?php echo $l['id']; ?>);"></a>
					
				</td>
			</tr>
			<?php } ?>
		</table>
		<?php } else { ?>
		<p><?php echo __('Noch keine Länder angelegt.', 'wpsg'); ?>
		<?php } ?>
		
		<br /><br />
		
		<input type="button" onclick="return wpsg_laender_import();" value="<?php echo __('Standardländer importieren', 'wpsg'); ?>" class="button" />
		<input type="button" onclick="return wpsg_eu_laender_import();" value="<?php echo __('Standard EU-Länder importieren', 'wpsg'); ?>" class="button" />
	
		<script type="text/javascript">/* <![CDATA[ */

			var land_load = false;

			function wpsg_laender_import()
			{

				if (!confirm('<?php echo __('Sind sie sich sicher ?', 'wpsg'); ?>')) return false;

				location.href = "<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=laender&do=import&noheader=1";
				
				return false;
				
			}

			function wpsg_eu_laender_import()
			{

				if (!confirm('<?php echo __('Sind sie sich sicher ?', 'wpsg'); ?>')) return false;

				location.href = "<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=laender&do=eu_import&noheader=1";
				
				return false;
				
			}

			function wpsg_laender_save()
			{

				jQuery.ajax( {
					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=laender&do=saveEdit&noheader=1',
					data: {
						form_data: jQuery('#wpsg_land_edit_form_edit').serialize()
					},
					success: function(data) {
 
						if (typeof data === 'object')
						{

							land_load = true;
 
							for (var i in data)
							{
 
								jQuery('#wpsg_laenderrow_' + data['id']).find('.data_' + i).html(data[i]);
								
							}
							
							jQuery('#wpsg_laenderrow_edit > td > div').slideUp(100, function() {

								jQuery('#wpsg_laenderrow_edit').remove();
								land_load = false;
								
							} );
							 
						}
						else alert(data);
						
					}
				} );

				return false;
				
			}
	        
			function wpsg_laender_edit(land_id)
			{

				if (land_load == true) return; land_load = true;

				var edit_timeout = 0;
 				
				if (jQuery('#wpsg_laenderrow_edit > td > div').is(':visible'))
				{

					edit_timeout = 150;
 					
					jQuery('#wpsg_laenderrow_edit > td > div').slideUp(100, function() {

						jQuery('#wpsg_laenderrow_edit').remove();
						
					} );
					
				}

				window.setTimeout(function() {
 
					jQuery('#wpsg_laenderrow_' + land_id).after('<tr id="wpsg_laenderrow_edit"><td colspan="8"><img src="<?php echo $this->getRessourceURL('gfx/ajax-loader.gif'); ?>" alt="" /><div style="display:none;"></div></td></tr>');
				
					jQuery.ajax( {
						url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=laender&do=edit&noheader=1',
						data: {
							land_id: land_id
						},
						success: function(data) {
													
							jQuery('#wpsg_laenderrow_edit > td > div').html(data);
							jQuery('#wpsg_laenderrow_edit > td > img').hide();
							jQuery('#wpsg_laenderrow_edit > td > div').slideDown(300, function() { land_load = false; } );
							
						}
					} );

				}, edit_timeout);

				return false;
				
			}

			function wpsg_laender_remove(land_id)
			{

				if (!confirm('<?php echo __('Sind Sie sich sicher?', 'wpsg'); ?>')) return false;

				jQuery.ajax( {
					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=laender&do=remove&noheader=1',
					data: {
						land_id: land_id
					},
					success: function(data) {
												 
						if (data === "1") jQuery('#wpsg_laenderrow_' + land_id).remove();
						else alert(data);
						
					}
				} );
				
				return false;

			}
        
		/* ]]> */</script>
	
	</div>

</div>