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
|
<?php
/**
* Template für das Anlegen/Bearbeiten einer Produktgruppe
*/
/** @var wpsg_productgroup|null $oProductgroup */
$oProductgroup = null;
if (intval($_REQUEST['edit_id']??0) > 0) {
$oProductgroup = wpsg_productgroup::getInstance(intval($_REQUEST['edit_id']));
}
?>
<div class="wpsg_productgroups" id="wpsg-bs">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><?php echo __('wpShopGermany', 'wpsg'); ?></a>
</div>
<div class="collapse navbar-collapse" id="bs-customer-navbar-collapse-1">
<ul class="nav navbar-nav">
<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>
<li role="presentation" class="active"><a href="<?php
echo wpsg_admin_url('Productgroups', '', ['wpsg_mod_action' => 'add']);
?>"><span class="glyphicon glyphicon-plus"></span><?php echo __("Produktgruppe anlegen/bearbeiten", "wpsg"); ?></a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div>
</div>
</nav>
<div class="wpsg_msg_wrap"><hr class="wp-header-end wpsg-wp-header-end"/></div>
<div class="wpsg_clear"></div>
<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">
<?php echo \wp_nonce_field('wpsg-productgroup-save-'.wpsg_getInt($_REQUEST['edit_id'])); ?>
<div class="content form-horizontal">
<div class="row">
<div class="col-md-8 col-lg-8">
<?php echo wpsg_drawForm_AdminboxStart(__('Allgemein', 'wpsg')); ?>
<?php echo wpsg_drawForm_Input('name', __('Produktgruppenname', 'wpsg'), $this->view['data']['name']); ?>
<?php if (wpsg_isSizedArray($this->view['languages'])) { ?>
<?php foreach ($this->view['languages'] as $l) { if ($l['locale'] != $this->getDefaultLanguageLocale()) { ?>
<?php echo wpsg_drawForm_Input(
'lang['.$l['locale'].'][name]',
__('Produktgruppenname', 'wpsg').' ('.$l['name'].' <img src="'.$this->getFlagURL().$l['flag'].'" alt="'.$l['Name'].'" />)',
$this->view['data']['lang'][$l['locale']]['name']
); ?>
<?php } } ?>
<?php } ?>
<?php echo wpsg_drawForm_Select('template_file', __('Template', 'wpsg'), $this->view['templates'], $this->view['data']['template_file']); ?>
<?php echo wpsg_drawForm_Select('infopage', __('Info Seite', 'wpsg'), $this->view['pages'], $this->view['data']['infopage']); ?>
<?php echo wpsg_drawForm_Input('pos', __('Positionsnummer (Sortierung, aufsteigend)', 'wpsg'), $this->view['data']['pos']); ?>
<div class="form-group form-group-sm ">
<label class="col-sm-6 control-label"><?php echo __('Produktgruppenbild', 'wpsg'); ?></label>
<div class="col-sm-6">
<div class="wpsg_field_wrap">
<div id="imageBox"><?php
if ($oProductgroup !== null) {
if ($oProductgroup->getImage() > 0) {
echo wp_get_attachment_image($oProductgroup->getImage(), 'full', false, [
'style' => 'max-width:100%; height:auto; margin-bottom:8px;'
]);
}
}
?></div>
<input value="Mediathek" class="button" type="button" style="text-align:center;" size="10" id="btnAddImgLink" />
<input type="hidden" name="image" value="<?php echo (($oProductgroup !== null)?$oProductgroup->getImage():0); ?>" id="image_input" />
<script>
let wpframe = undefined;
let imageBox = document.getElementById('imageBox');
let elImageInput = document.getElementById('image_input');
document.getElementById('btnAddImgLink').addEventListener('click', (event) => {
event.preventDefault();
if (wpframe !== undefined) { wpframe.open(); return; }
wpframe = wp.media.frames.file_frame = wp.media({
title: "<?php echo __('Auswählen oder Hochladen von Medien', 'wpsg'); ?>",
button: { text: "<?php echo __('Medien benutzen', 'wpsg'); ?>" },
multiple: false
});
wpframe.on('select', () => {
let attachments = wpframe.state().get('selection').map((attachment) => {
attachment.toJSON();
return attachment;
});
for (let i = 0; i < attachments.length; ++i) {
let attachment = attachments[i];
imageBox.innerHTML = '<img src="' + attachment.attributes.url + '" alt="" style="max-width:100%; margin-bottom:8px;"/>';
elImageInput.value = attachment.attributes.id;
}
});
wpframe.open();
});
</script>
</div>
</div>
<div class="clearfix wpsg_clear"></div>
</div>
<?php echo wpsg_drawForm_AdminboxEnd(); ?>
</div>
<div class="col-md-4 col-lg-4">
<?php $this->callMods('wpsg_mod_productgroups_addedit_sidebar', array(&$this->view['data'])); ?>
</div>
</div>
<input type="submit" value="<?php echo __('Produktgruppe speichern', 'wpsg'); ?>" class="button-primary" id="submit" name="submit" />
<input type="submit" value="<?php echo __('Produktgruppe speichern und zur Übersicht', 'wpsg'); ?>" class="button-primary" id="submit_index" name="submit_index" />
</div>
<?php if (isset($this->view['data']['id']) && $this->view['data']['id'] > 0) { ?>
<input type="hidden" name="edit_id" value="<?php echo $this->view['data']['id']; ?>" />
<?php } ?>
</form>
</div>
|