summaryrefslogtreecommitdiff
path: root/views/order/backendEdit/addProduct_product_selected.phtml
blob: e33f28b3ee683eb3460b46d4658428e6a514395b (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
<?php
    
    /**
     * Template für das hinzufügen eines Produktes wenn das Produkt ausgewählt wurde
     * @version 4.6.1
     */
             
    /** @var wpsg_product $oProduct */
    $oProduct = $this->view['oProduct'];

    /** @var wpsg_order_product $oOrderProduct */
    $oOrderProduct = $this->view['oOrderProduct'];
        
?>

<style>
    
    .wpsg_product_add { position:relative; min-height:150px; }
    .wpsg_product_add .image { position:absolute; left:0px; top:10px; }
    
</style>

<strong><?php echo $oProduct->getProductName(); ?></strong>

<div class="wpsg_product_add">

    <input type="hidden" name="product_id" value="<?php echo $oProduct->id; ?>" />
    
    <?php if ($oOrderProduct !== false) { ?>
    <input type="hidden" name="order_product_id" value="<?php echo $oOrderProduct->id; ?>" />
    <?php } ?>
    
    <?php

        $attachment_id = wpsg_ShopController::getShop()->imagehandler->getAttachmentID($oProduct->id);
        
    ?>
    
    <?php if (wpsg_isSizedInt($attachment_id)) { ?>
    <div class="image"><?php echo wp_get_attachment_image($attachment_id, [100, 100]); ?></div>
    <?php } ?>
    
    <?php echo wpsg_drawForm_Input('add_price', __('Produktpreis', 'wpsg').' '.(($this->getBackendTaxView() === WPSG_BRUTTO)?'(BRUTTO)':'(NETTO'), wpsg_ff((($oOrderProduct !== false)?$oOrderProduct->getPrice($this->getBackendTaxView()):$oProduct->getPrice($this->getBackendTaxView())), $this->get_option('wpsg_currency'))); ?>
    <?php echo wpsg_drawForm_Input('add_amount', __('Menge', 'wpsg'), (($oOrderProduct !== false)?$oOrderProduct->getCount():'1')); ?>
    <?php echo wpsg_drawForm_Checkbox('add_eu',__('EU-Leistungsortregel anwenden', 'wpsg'),(($oOrderProduct !== false)?$oOrderProduct->euleistungsortregel:'0')) ?>
	
    <?php if ($this->hasMod('wpsg_mod_scaleprice')) { ?>
        <?php if ($this->callMod('wpsg_mod_scaleprice', 'product_has_scaleprice', [$oProduct->getId()])) { ?>
            
            <?php echo wpsg_drawForm_Checkbox('set_scaleprice', __('Produktpreis anhand Preisstaffel ermitteln', 'wpsg'), false); ?>
            
            <script>
                
                document.getElementById('set_scaleprice').addEventListener('change', (event) => {
					
					if (event.target.checked) {
						
						document.getElementById('add_price').setAttribute('disabled', 'disabled');
						
                    } else {
						
						document.getElementById('add_price').removeAttribute('disabled');
						
                    }
					
                });
                
            </script>
            
        <?php } ?>
    <?php } ?>
    
    <?php if ($this->callMod('wpsg_mod_productvariants', 'isVariantsProduct', [$oProduct->id])) { 
    	
    	$arVariants = $this->callMod('wpsg_mod_productvariants', 'getVariants', [$oProduct->id, true, true, true]); 
    	
    	if ($oOrderProduct !== false) $arVariantenInfoArray = $this->callMod('wpsg_mod_productvariants', 'getVariantenInfoArray', [$oOrderProduct->getProductKey()]);
    	else $arVariantenInfoArray = [];
    	 
    	?> 
        
        <?php if (wpsg_isSizedArray($arVariants)) { ?>
                
            <br />
            
            <?php foreach ($arVariants as $var_id => $var_data) { 
                
                    $arVariSelect = [];
                    foreach ($var_data['arVariation'] as $vari_id => $vari_data) $arVariSelect[$vari_id] = $vari_data['name'];
                
                ?>
            
                <?php echo wpsg_drawForm_Select('wpsg_vp['.$var_id.']', $var_data['name'], $arVariSelect,$arVariantenInfoArray[$var_data['id']]['vari_id'], ['field_class' => 'varichange']); ?>
                
            <?php } ?>
        
        <?php } ?>
		
		<script>
			
			jQuery('.varichange').on('change', function() {

				jQuery('#add_price').val('..');
				
				jQuery.ajax( {
					url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=view&subaction=addProduct&do=updatePrice&noheader=1&product_id=<?php echo $oProduct->id; ?>',
					data: {
						form_data: jQuery('#wpsg_product_add_form').serialize()
					},
					success: function(data) {

						jQuery('#add_price').val(data);

					}
				} );
				
			} );
			
		</script>
        
    <?php } ?> 
    
    <script>

        jQuery('#wpsg_product_dialog .btn-primary').prop('disabled', false);
        
    </script>

</div>