Subversion Repositories wpShopGermany4

Rev

Rev 8197 | 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']); ?>
8280 daniel 72
                        <?php echo wpsg_drawForm_Input('pos', __('Positionsnummer (Sortierung, aufsteigend)', 'wpsg'), $this->view['data']['pos']); ?>
6134 daniel 73
 
8195 daniel 74
                        <div class="form-group form-group-sm ">
75
                            <label class="col-sm-6 control-label"><?php echo __('Produktgruppenbild', 'wpsg'); ?></label>
76
                            <div class="col-sm-6">
77
                                <div class="wpsg_field_wrap">
78
                                    <div id="imageBox"><?php
79
 
80
                                        if ($oProductgroup !== null) {
81
 
82
                                            if ($oProductgroup->getImage() > 0) {
83
 
84
                                                echo wp_get_attachment_image($oProductgroup->getImage(), 'full', false, [
85
                                                    'style' => 'max-width:100%; height:auto; margin-bottom:8px;'
86
                                                ]);
87
 
88
                                            }
89
 
90
                                        }
91
 
92
                                    ?></div>
93
 
94
                                    <input value="Mediathek" class="button" type="button" style="text-align:center;" size="10" id="btnAddImgLink" />
95
                                    <input type="hidden" name="image" value="<?php echo (($oProductgroup !== null)?$oProductgroup->getImage():0); ?>" id="image_input" />
96
 
97
                                    <script>
98
 
99
                                        let wpframe = undefined;
100
                                        let imageBox = document.getElementById('imageBox');
101
                                        let elImageInput = document.getElementById('image_input');
102
 
103
                                        document.getElementById('btnAddImgLink').addEventListener('click', (event) => {
104
 
105
                                            event.preventDefault();
106
 
107
                                            if (wpframe !== undefined) { wpframe.open(); return; }
108
 
109
                                            wpframe = wp.media.frames.file_frame = wp.media({
110
                                                title: "<?php echo __('Auswählen oder Hochladen von Medien', 'wpsg'); ?>",
111
                                                button: { text: "<?php echo __('Medien benutzen', 'wpsg'); ?>" },
112
                                                multiple: false
113
                                            });
114
 
115
                                            wpframe.on('select', () => {
116
 
117
                                                let attachments = wpframe.state().get('selection').map((attachment) => {
118
 
119
                                                    attachment.toJSON();
120
 
121
                                                    return attachment;
122
 
123
                                                });
124
 
125
                                                for (let i = 0; i < attachments.length; ++i) {
126
 
127
                                                    let attachment = attachments[i];
128
 
129
                                                    imageBox.innerHTML = '<img src="' + attachment.attributes.url + '" alt="" style="max-width:100%; margin-bottom:8px;"/>';
130
                                                    elImageInput.value = attachment.attributes.id;
131
 
132
                                                }
133
 
134
                                            });
135
 
136
                                            wpframe.open();
137
 
138
                                        });
139
 
140
                                    </script>
141
                                </div>
142
                            </div>
143
                            <div class="clearfix wpsg_clear"></div>
144
                        </div>
145
 
6134 daniel 146
                    <?php echo wpsg_drawForm_AdminboxEnd(); ?>
147
 
148
                </div>
149
                <div class="col-md-4 col-lg-4">
150
 
151
                    <?php $this->callMods('wpsg_mod_productgroups_addedit_sidebar', array(&$this->view['data'])); ?>
152
 
153
                </div>
154
            </div>
155
 
156
            <input type="submit" value="<?php echo __('Produktgruppe speichern', 'wpsg'); ?>" class="button-primary" id="submit" name="submit" />
157
	        <input type="submit" value="<?php echo __('Produktgruppe speichern und zur Übersicht', 'wpsg'); ?>" class="button-primary" id="submit_index" name="submit_index" />
158
 
159
        </div>
160
 
161
        <?php if (isset($this->view['data']['id']) && $this->view['data']['id'] > 0) { ?>
162
		<input type="hidden" name="edit_id" value="<?php echo $this->view['data']['id']; ?>" />
163
		<?php } ?>
164
 
165
    </form>
166
 
167
</div>