summaryrefslogtreecommitdiff
path: root/views/mods/mod_productvariants/admin_show.phtml
blob: 5908d742c1cbc591c850062cedd98db73401ca33 (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
<?php

	/**
	 * Verwaltung der Produktvarianten im Backend
	 * @version 4.6.1
	 */

?>

<input type="hidden" id="wpsg_mod_productvariants_product_id" value="<?php echo $this->view['product_id']; ?>" />

<?php if (wpsg_isSizedArray($this->view['arVariants'])) { ?>

	<table class="table table-striped wpsg_mod_productvariants_table_variants">
    	<thead>
      		<tr>
      			<th class="col_id"><?php echo __('Id', 'wpsg'); ?></th>
        		<th class="col1"><?php echo __('Name', 'wpsg'); ?></th>
        		<th class="col_type"><?php echo __('Typ', 'wpsg'); ?></th>
        		<th class="col_vari"><?php echo __('Variationen', 'wpsg'); ?></th>
        		
        		<?php if (!wpsg_isSizedInt($this->view['product_id'])) { ?>
        		<th class="col_products"><?php echo __('Produkte', 'wpsg'); ?></th>
        		<?php } ?>
        		
        		<th class="col_action"></th>
      		</tr>
    	</thead>
    	<tbody>
    		<?php foreach ($this->view['arVariants'] as $var) { ?>
    		<tr id="var_<?php echo $var['id']; ?>">
    			<td class="col_id"><?php echo $var['id']; ?></td>
    			<td class="col1">
    				<span class="wpsg_editable" id="productvariants_name_<?php echo $var['id']; ?>"><?php echo wpsg_hspc($var['name']); ?></span>
    				<?php if (wpsg_isSizedInt($var['product_id'])) { ?>
    				&nbsp;<span class="wpsg_mod_productvariants_info"><?php echo __('(Produktbezogen)', 'wpsg'); ?></span>
    				<?php } ?>
    			</td>
    			<td class="col_type"><span class="wpsg_editable" id="productvariants_type_<?php echo $var['id']; ?>"><?php echo $var['type_label']; ?></span></td>
    			<td class="col_vari"><?php 
    			
    				if (wpsg_isSizedInt($this->view['product_id'])) echo $var['count_active'].'/'.$var['count_variation'];
    				else echo $var['count_variation']; 
    			
    			?></td>
    			<?php if (!wpsg_isSizedInt($this->view['product_id'])) { ?>
    			<td class="col_products"><?php echo wpsg_hspc($var['count_produkte']); ?></td>
    			<?php } ?>
    			<td class="col_action">
    			
    				<script>

    					<?php if ((wpsg_isSizedInt($this->view['product_id']) && $this->view['product_id'] == $var['product_id']) || (!wpsg_isSizedInt($var['product_id']) && !wpsg_isSizedInt($this->view['product_id']))) { ?>

						jQuery('#productvariants_name_<?php echo $var['id']; ?>').wpsg_editable('<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_productvariants&subaction=admin_inlineEdit&noheader=1', {
							submitdata: { 
					    		field: 'name',
					    		field_id: '<?php echo $var['id']; ?>'
							}
						});

						jQuery('#productvariants_type_<?php echo $var['id']; ?>').wpsg_editable('<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_productvariants&subaction=admin_inlineEdit&noheader=1', { 
							submitdata: {
								field: 'type',
								field_id: '<?php echo $var['id']; ?>'
							},
							data: <?php echo wpsg_prepare_for_inlineEdit(wpsg_mod_productvariants::$arTypeLabel); ?>,
							type: 'select'							
						});	
						
						<?php } ?>		
		
					</script>
    			
    				<a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Variante bearbeiten', 'wpsg'); ?>" onclick="return wpsg_mod_productvariants_edit(<?php echo $var['id']; ?>);"><span class="glyphicon glyphicon-pencil"></span></a>
    				
    				<?php if ((wpsg_isSizedInt($this->view['product_id']) && $this->view['product_id'] == $var['product_id']) || (!wpsg_isSizedInt($var['product_id']) && !wpsg_isSizedInt($this->view['product_id']))) { ?>    				
    				<a href="#" class="wpsg-glyphlink-td" title="<?php echo __('Variante löschen', 'wpsg'); ?>" onclick="return wpsg_mod_productvariants_del(<?php echo $var['id']; ?>);"><span class="glyphicon glyphicon-trash"></span></a>
					<?php } ?>
			
    			</td>
    		</tr>
    		<?php } ?>
    	</tbody>
    </table>
    
    <p class="wpsg_hinweis"><?php echo __('Reihenfolge kann mittels Drag&Drop verändert werden.', 'wpsg'); ?></p>
    
    <script>

	    jQuery('.wpsg_mod_productvariants_table_variants tbody').sortable( {
			items: 'tr',
			helper: wpsg_Tablefix,  
			update: function(event, ui) {

				var wpsg_reorder = jQuery(this).sortable('toArray');
				var product_id = jQuery('#wpsg_mod_productvariants_product_id').val();

				jQuery.ajax( {
					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_productvariants&subaction=admin_inlineEdit&noheader=1',
					data: {
						'field': 'pos',
						'product_id': product_id,
						'value': jQuery(this).sortable('toArray')
					},
					success: function(data) { }
				} );
																			 
			}			
		} );

    </script>

<?php } else { ?>
<?php echo __('Bisher keine Produktvarianten angelegt.', 'wpsg'); ?>
<?php } ?>