customer_shownctextform.phtml
12.5 KB
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<!--
/**
* Anc_Text_CustomerController::shownctextformAction() template
* @var $this anc_text/galleriesmanager (Anc_Text_Block_Galleriesmanager)
*
* @package anc_text
* @anc_text_eingabetyp -- Formular bzw ansicht im Frontend im Warenkorb beim Produkt konfigurieren
* @copy Grundlage: Magento18/app/design/frontend/base/default/template/catalog/product/view/options/type/text.phtml
* @since 20140416
* @author netz.coop eG*
*/ /home/dev/git/Magento/AncText/app/design/frontend/template/customer_shownctextform.phtml
-->
<script type="text/javascript">
// function ajax_gettextinfo(ncinput_id) {
// var ajax_edittext_data = {
// url: "<?php echo Mage::getUrl('anctext/customer/getcustomertextdata'); ?>",
// method: 'Post',
// data: {entity_id: ncinput_id},
// success: function(data, textStatus, jqXhr) {
// console.log(data);
// var parseddata = jQuery.parseJSON(data);
// console.log(parseddata);
// jQuery("#<?php echo $input_id; ?>").attr('value', parseddata.entity_id);
// jQuery("#anc_text_id").attr('value', parseddata.entity_id);
// jQuery("#anc_customer_id").attr('value', parseddata.customer_id);
// jQuery("#anc_admin_id").attr('value', parseddata.admin_user_id);
// jQuery("#ncalbum_id").attr('value', parseddata.ncalbum_id);
// jQuery("#used_byitem_id").attr('value', parseddata.used_byitem_id);
// jQuery("#ordered").attr('value', parseddata.ordered);
//// tinyMCE.activeEditor.setContent(parseddata.content);
// loadNcTextIntoForm('<?php echo $this->getUrl('anctext/customer/shownctextform', array()) ?>id/'+parseddata.entity_id+'/');
// }
// };
// console.log('data');
// jQuery.ajax(ajax_edittext_data);
// }
function ajax_gettextinfo(ncinput_id) {
var ajax_edittext_data = {
url: "<?php echo Mage::getUrl('anctext/customer/getcustomertextdata'); ?>",
method: 'Post',
data: {entity_id: ncinput_id},
success: function(data, textStatus, jqXhr) {
console.log('succes');
var parseddata = jQuery.parseJSON(data);
console.log(parseddata);
jQuery("#<?php // echo $input_id; ?>").attr('value', parseddata.entity_id);
jQuery("#anc_text_id").attr('value', parseddata.entity_id);
jQuery("#anc_customer_id").attr('value', parseddata.customer_id);
jQuery("#anc_admin_id").attr('value', parseddata.admin_user_id);
jQuery("#ncalbum_id").attr('value', parseddata.ncalbum_id);
jQuery("#used_byitem_id").attr('value', parseddata.used_byitem_id);
jQuery("#ordered").attr('value', parseddata.ordered);
// tinymce.execCommand('mceRemoveControl',true,'anctext-texteditorarea-id');
// tinymce.EditorManager.execCommand('mceRemoveEditor', true, "#anctext-texteditorarea-id");
// tinymce.EditorManager.execCommand('mceAddEditor', true, "#anctext-texteditorarea-id");
// tinymce.execCommand('mceAddControl',true,'anctext-texteditorarea-id');
if (typeof parseddata.content === "undefined"||parseddata.content === null) {
parseddata.content=' ';
}else{
tinyMCE.activeEditor.setContent(parseddata.content);
}
// loadNcTextIntoForm('<?php // echo $this->getUrl('anctext/customer/shownctextform', array()) ?>id/'+parseddata.entity_id+'/');
}
};
// console.log('ncinput_id');
// console.log('ncinput_id'+ncinput_id);
jQuery.ajax(ajax_edittext_data);
}
</script>
<?php
$nctext = $this->getCallNcText();
// $path = Mage::helper('anc_text/nctext')->getNcTextPath($nctext->getId(), 'relative', 'original');
// $nctext_data = mcImagick::getData(Mage::getBaseDir().$path);
// $nctext_data = mcImagick::getData(Mage::helper('anc_lib/ncfilepath')->getThisMagentoInstallationPath().$path);
$dropzone_id = 'anctext-dropzone-id';
$ancnote_id = '#ancnote';
?>
<div id="ancnote"></div>
<form action="<?php echo $this->getUrl('anctext/customer/showNcTextForm', array('id' => $nctext->getId())); ?>" id="anctext-customer_showNcTextForm">
<div class="anctext" >
<div id="<?php // echo $dropzone_id; ?>" class="dropzone anctext-dropzone">
<div class="preview-database-text">
<input type="hidden" onchange="opConfig.reloadPrice()" id="anc_text_id" data-info="toll" class="data-anc_text_id" name="data-anc_text_id_options" value="<?php echo ''; ?>" />
<input type="hidden" onchange="opConfig.reloadPrice()" id="anc_customer_id" class="data-anc_customer_id" name="data-anc_customer_id_options" value="<?php echo ''; ?>" />
<input type="hidden" onchange="opConfig.reloadPrice()" id="anc_admin_id" class="data-anc_admin_id" name="data-anc_admin_id_options" value="<?php echo ''; ?>" />
<input type="hidden" onchange="opConfig.reloadPrice()" id="ncalbum_id" class="data-ncalbum_id" name="data-anc_admin_id_options" value="<?php echo ''; ?>" />
<input type="hidden" onchange="opConfig.reloadPrice()" id="used_byitem_id" class="data-used_byitem_id" name="data-used_byitem_id_options" value="<?php echo ''; ?>" />
<input type="hidden" onchange="opConfig.reloadPrice()" id="ordered" class="data-ordered" name="data-ordered_options" value="<?php echo ''; ?>" />
<textarea class="<?php echo 'textareatinymce'; ?>" id="anctext-texteditorarea-id" rows='10' cols="40"></textarea>
<?php if($path):?>
<img src="<?php // echo DS.$path; ?>" />
<?php endif; ?>
</div>
</div>
</div>
<div class="fileinfos tablerow">
<!--<div class="label">Dateiinfos:</div>-->
<!-- <div class="value">Breite: <?php // echo $nctext_data['width']?> px - Höhe: <?php // echo $nctext_data['height']; ?> px - Dateigröße: <?php // echo mcFile::binary_multiples($nctext_data['size']); ?> </div>-->
</div>
<div class="name tablerow">
<div class="label">Name:</div>
<div class="value"><input name="name" id='text_name' type="text" size="30" maxlength="30" value="<?php echo $nctext->getName(); ?>" /></div>
</div>
<div class="comment tablerow">
<div class="label">Kommentar:</div>
<div class="value"><textarea name="comment" id='text_comment' cols="50" rows="5" ><?php echo $nctext->getComment(); ?></textarea></div>
</div>
<div class="tablerow buttons">
<?php $buttonTitle = 'lösche Datei'; ?>
<input class="button delete" title="<?php echo $this->__($buttonTitle) ?>" type="submit" value="<?php echo $this->__($buttonTitle) ?>" />
<?php $buttonTitle = 'speichern'; ?>
<!--<input class="button save" title="<?php // echo $this->__($buttonTitle) ?>" type="submit" value="<?php // echo $this->__($buttonTitle) ?>" />-->
<?php $backurl= $this->getUrl('*/*/galleriesmanager')?>
<button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="redirectAfterSubmitAfterSaveText(this,null,'<?php echo $backurl?>')"><span><span><?php echo $buttonTitle ?></span></span></button>
</div>
<script type="text/javascript">
jQuery('.buttons > .delete').unbind("click").click(function(e){
e.preventDefault();
jQuery.ajax({ // create an AJAX call...
url: '<?php echo $this->getUrl('anctext/customer/deleteNcText', array('id'=>$nctext->getId())); ?>', // the file to call
success: function(rep) { // on success..
var reponse = jQuery.parseJSON( rep );
jQuery('#ancnote').append(reponse.message);
jQuery('#ancnote').addClass('anc-error');
jQuery('#anctext-customer_showNcTextForm').hide();
var gallery_ajaxData = {
url: "<?php echo $this->getUrl('anctext/customer/gallerysimple', array()) ?> ul.gallery",
context: jQuery(".anctext-customer_galleriesown > .anctext-gallerie-content > .anctext-gallerie-content-view"),
success: function(data) {
jQuery(this).html(data);
// damit die gallerie auch klickbar ist
loadNcTextIntoFormThumbnailButton();
Anc_Text_Type.customerGallerysimplePrettyPhoto();
},
};
jQuery.ajax(gallery_ajaxData);
}
});
});
function redirectAfterSubmitAfterSaveText(data, url, backurl) {
var option_id = ''
var ncalbum_id = jQuery('#ncalbum_id').attr('value');
var ncinput_id = jQuery('#anc_text_id').attr('value');
var nccustomerid = jQuery('#anc_customer_id').attr('value');
var ncadmin_id = jQuery('#anc_admin_id').attr('value');
// //used_byitem_id
var used_byitem_id = jQuery('#used_byitem_id').attr('value');
var ordered = jQuery('#ordered').attr('value');
var varcontent = tinymce.get('anctext-texteditorarea-id').getContent();
// var name = jQuery('#text_name').attr('value');
var name = jQuery('#text_name').val();
var comment = jQuery('#text_comment').val();
//// var nctext_id = jQuery("#<?php // echo $AncTextInputId; ?>").attr('value');
console.log(jQuery(this));
console.log('ncalbum_id: ' + ncalbum_id);
console.log('ncinput_id: ' + ncinput_id);
console.log('nccustomerid:' + nccustomerid);
console.log('ncadmin_id: ' + ncadmin_id);
console.log('used_byitem_id: ' + used_byitem_id);
console.log('ordered: ' + ordered);
console.log('option_id: ' + option_id);
console.log('name: ' + name);
console.log('comment: ' + comment);
console.log('tiymce' + varcontent);
ajax_edittexts(ncinput_id, option_id, ncalbum_id, nccustomerid, ncadmin_id, used_byitem_id, ordered, varcontent,name,comment ,true, data, url, backurl);
}
function ajax_edittexts(ncinput_id, option_id, ncalbum_id, nccustomerid, ncadmin_id, used_byitem_id, ordered, varcontent,name,comment, ifredirectAfterSubmit, data, url, backurl) {
var ajax_edittext_data = {
url: "<?php echo Mage::getUrl('anctext/customer/savecustomertext'); ?>",
method: 'Post',
// dataType:"json",
data: {ncinput_id: ncinput_id, option_id: option_id, ncalbum_id: ncalbum_id, nccustomerid: nccustomerid, ncadmin_id: ncadmin_id, used_byitem_id: used_byitem_id, ordered: ordered, varcontent: varcontent,name:name,comment:comment,special:'custemerbe'},
success: function(data, textStatus, jqXhr) {
console.log(data);
var parseddata = jQuery.parseJSON(data);
console.log(parseddata);
jQuery("#<?php echo $input_id; ?>").attr('value', parseddata.id);
if (ifredirectAfterSubmit) {
// ajax_gettextinfo(parseddata.id)
//
redirectAfterSubmit(data, url, backurl);
}
}
};
jQuery.ajax(ajax_edittext_data);
}
function redirectAfterSubmit(data, url, backurl){
jQuery(location).attr('href',backurl);
// this.submit(data, url);
// jquery.ajax(backurl);
}
</script>
</form>
<script type="text/javascript">
jQuery(document).ready(function($) {
// console.log(jQuery(this).data());
//
//
//
//
tinymce.init({
selector: "textarea.textareatinymce",
toolbar: "undo redo | bold italic | fontselect fontsizeselect forecolor | selectall removeformat | code | spellchecker ", //backcolor
menu: {// this is the complete default configuration
platzhalter: {title: 'Platzhalter', items: 'vorname nachname strasse plz ort land anrede titel firma ansprache adresse absender variable1 variable2 variable3 variable4 variable5 variable6'}
},
plugins: "code,textcolor,platzhalter,spellchecker,paste",
paste_as_text: true,
formats: {
},
fontsize_formats: "8 9 10 11 12 13 14 15 20 30 40 50 75",
font_formats: "Arial=arial;Comic Sans MS=comic sans ms;Courier New=courier new,courier;Georgia=georgia;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times;Verdana=verdana,geneva;",
setup: function(editor) {
editor.addButton('platzhalter', {
text: 'Platzhalter',
icon: false,
onclick: function() {
editor.execCommand('mceTableInsertRowAfter', false, editor);
}
});
}
});
var url = jQuery("#anctext-customer_showNcTextForm").attr('action')
url = url.replace(/\/$/, '');
var id = url.substring(url.lastIndexOf('/') +1);
//alert(url +' --- '+id);
ajax_gettextinfo(id);
//
// var dropzone_params = {
// url: "<?php // echo $this->getUrl('anctext/customer/uploadText', array('id'=> $nctext->getId())) ?>",
// dictDefaultMessage: 'Bitte ziehen Sie aus Ihrem Dateiexplorer einfach ein Bild in diesen Bereich!',
// success: function(file, rep) {
// var reponse = jQuery.parseJSON( rep );
// this.removeAllFiles();
// jQuery('#<?php // echo $dropzone_id; ?> > .preview-database-text').append('<img src="'+reponse.path+'" />');
// }
// };
// var gallery_ajaxData = {
// url: "<?php // echo $this->getUrl('anctext/customer/gallerysimple', array()) ?> ul.gallery",
// context: jQuery(".anctext-customer_galleriesown > .anctext-gallerie-content > .anctext-gallerie-content-view"),
// success: function() {
// loadNcTextIntoFormThumbnailButton();
// },
// };
Anc_Text_Type.droppableFile(
jQuery(" #<?php // echo $dropzone_id; ?>"),
dropzone_params,
null,
jQuery(" <?php // echo $ancnote_id; ?>"),
gallery_ajaxData,
false
);
});
</script>