Subversion Repositories wpShopGermany4

Rev

Rev 8195 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6134 daniel 1
<?php
2
 
3
	/**
4
	 * Template für das Anlegen/Bearbeiten einer Produktgruppe
5
	 */
6
 
8197 daniel 7
    /** @var wpsg_productgroup|null $oProductgroup */
8195 daniel 8
    $oProductgroup = null;
9
 
10
    if (intval($_REQUEST['edit_id']??0) > 0) {
11
 
8197 daniel 12
        $oProductgroup = wpsg_productgroup::getInstance(intval($_REQUEST['edit_id']));
8195 daniel 13
 
14
    }
15
 
6134 daniel 16
?>
17
 
18
<div class="wpsg_productgroups" id="wpsg-bs">
19
 
20
    <nav class="navbar navbar-default">
21
 
22
		<div class="container-fluid">
23
			<div class="navbar-header">
24
				<a class="navbar-brand" href="#"><?php echo __('wpShopGermany', 'wpsg'); ?></a>
25
			</div>
26
			<div class="collapse navbar-collapse" id="bs-customer-navbar-collapse-1">
27
				<ul class="nav navbar-nav">
28
					<li role="presentation" class="wpsg-customer-tab-a active"><a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=index"><?php echo __("Produktgruppenverwaltung", "wpsg"); ?></a></li>
7774 daniel 29
                    <li role="presentation" class="active"><a href="<?php
30
 
31
                        echo wpsg_admin_url('Productgroups', '', ['wpsg_mod_action' => 'add']);
32
 
33
                    ?>"><span class="glyphicon glyphicon-plus"></span><?php echo __("Produktgruppe anlegen/bearbeiten", "wpsg"); ?></a></li>
6134 daniel 34
				</ul>
35
				<ul class="nav navbar-nav navbar-right">
36
				</ul>
37
			</div>
38
		</div>
39
 
40
    </nav>
41
 
7549 daniel 42
	<div class="wpsg_msg_wrap"><hr class="wp-header-end wpsg-wp-header-end"/></div>
43
	<div class="wpsg_clear"></div>
6134 daniel 44
 
45
    <form method="POST" action="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Productgroups&wpsg_mod_action=save&noheader=1" enctype="multipart/form-data">
7549 daniel 46
 
47
		<?php echo \wp_nonce_field('wpsg-productgroup-save-'.wpsg_getInt($_REQUEST['edit_id'])); ?>
48
 
6134 daniel 49
        <div class="content form-horizontal">
50
 
51
            <div class="row">
52
                <div class="col-md-8 col-lg-8">
53
 
54
                    <?php echo wpsg_drawForm_AdminboxStart(__('Allgemein', 'wpsg')); ?>
55
 
7549 daniel 56
                        <?php echo wpsg_drawForm_Input('name', __('Produktgruppenname', 'wpsg'), $this->view['data']['name']); ?>
6134 daniel 57
 
58
                        <?php if (wpsg_isSizedArray($this->view['languages'])) { ?>
6494 hartmut 59
                            <?php foreach ($this->view['languages'] as $l) { if ($l['locale'] != $this->getDefaultLanguageLocale()) { ?>
6134 daniel 60
 
61
                                <?php echo wpsg_drawForm_Input(
62
                                    'lang['.$l['locale'].'][name]',
6655 daniel 63
                                    __('Produktgruppenname', 'wpsg').'&nbsp;('.$l['name'].'&nbsp;<img src="'.$this->getFlagURL().$l['flag'].'" alt="'.$l['Name'].'" />)',
6134 daniel 64
                                    $this->view['data']['lang'][$l['locale']]['name']
65
                                ); ?>
66
 
67
                            <?php } } ?>
68
                        <?php } ?>
69
 
7549 daniel 70
                        <?php echo wpsg_drawForm_Select('template_file', __('Template', 'wpsg'), $this->view['templates'], $this->view['data']['template_file']); ?>
71
                        <?php echo wpsg_drawForm_Select('infopage', __('Info Seite', 'wpsg'), $this->view['pages'], $this->view['data']['infopage']); ?>
6134 daniel 72
 
8195 daniel 73
                        <div class="form-group form-group-sm ">
74
                            <label class="col-sm-6 control-label"><?php echo __('Produktgruppenbild', 'wpsg'); ?></label>
75
                            <div class="col-sm-6">
76
                                <div class="wpsg_field_wrap">
77
                                    <div id="imageBox"><?php
78
 
79
                                        if ($oProductgroup !== null) {
80
 
81
                                            if ($oProductgroup->getImage() > 0) {
82
 
83
                                                echo wp_get_attachment_image($oProductgroup->getImage(), 'full', false, [
84
                                                    'style' => 'max-width:100%; height:auto; margin-bottom:8px;'
85
                                                ]);
86
 
87
                                            }
88
 
89
                                        }
90
 
91
                                    ?></div>
92
 
93
                                    <input value="Mediathek" class="button" type="button" style="text-align:center;" size="10" id="btnAddImgLink" />
94
                                    <input type="hidden" name="image" value="<?php echo (($oProductgroup !== null)?$oProductgroup->getImage():0); ?>" id="image_input" />
95
 
96
                                    <script>
97
 
98
                                        let wpframe = undefined;
99
                                        let imageBox = document.getElementById('imageBox');
100
                                        let elImageInput = document.getElementById('image_input');
101
 
102
                                        document.getElementById('btnAddImgLink').addEventListener('click', (event) => {
103
 
104
                                            event.preventDefault();
105
 
106
                                            if (wpframe !== undefined) { wpframe.open(); return; }
107
 
108
                                            wpframe = wp.media.frames.file_frame = wp.media({
109
                                                title: "<?php echo __('Auswählen oder Hochladen von Medien', 'wpsg'); ?>",
110
                                                button: { text: "<?php echo __('Medien benutzen', 'wpsg'); ?>" },
111
                                                multiple: false
112
                                            });
113
 
114
                                            wpframe.on('select', () => {
115
 
116
                                                let attachments = wpframe.state().get('selection').map((attachment) => {
117
 
118
                                                    attachment.toJSON();
119
 
120
                                                    return attachment;
121
 
122
                                                });
123
 
124
                                                for (let i = 0; i < attachments.length; ++i) {
125
 
126
                                                    let attachment = attachments[i];
127
 
128
                                                    imageBox.innerHTML = '<img src="' + attachment.attributes.url + '" alt="" style="max-width:100%; margin-bottom:8px;"/>';
129
                                                    elImageInput.value = attachment.attributes.id;
130
 
131
                                                }
132
 
133
                                            });
134
 
135
                                            wpframe.open();
136
 
137
                                        });
138
 
139
                                    </script>
140
                                </div>
141
                            </div>
142
                            <div class="clearfix wpsg_clear"></div>
143
                        </div>
144
 
6134 daniel 145
                    <?php echo wpsg_drawForm_AdminboxEnd(); ?>
146
 
147
                </div>
148
                <div class="col-md-4 col-lg-4">
149
 
150
                    <?php $this->callMods('wpsg_mod_productgroups_addedit_sidebar', array(&$this->view['data'])); ?>
151
 
152
                </div>
153
            </div>
154
 
155
            <input type="submit" value="<?php echo __('Produktgruppe speichern', 'wpsg'); ?>" class="button-primary" id="submit" name="submit" />
156
	        <input type="submit" value="<?php echo __('Produktgruppe speichern und zur Übersicht', 'wpsg'); ?>" class="button-primary" id="submit_index" name="submit_index" />
157
 
158
        </div>
159
 
160
        <?php if (isset($this->view['data']['id']) && $this->view['data']['id'] > 0) { ?>
161
		<input type="hidden" name="edit_id" value="<?php echo $this->view['data']['id']; ?>" />
162
		<?php } ?>
163
 
164
    </form>
165
 
166
</div>