1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Dialog.CoreEmail = {
10 show : function(data, cb)
18 this.dialog.show(this.data._el);
21 this.form.setValues(data);
22 this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });
30 this.dialog = Roo.factory({
31 xtype: 'LayoutDialog',
34 show : function (_self)
37 _self.layout.getRegion('center').showPanel(0);
38 var w = Roo.lib.Dom.getViewWidth();
\r
39 var h = Roo.lib.Dom.getViewHeight();
\r this.resizeTo(w-50, h-50);
\r
41 var ew = Math.max(250, w-320);
\r
42 var eh = Math.max(250, h-350) ;
\r
43 var e = _this.dialog.layout.getRegion('east');
48 var el = _self.getEl();
49 var elw = el.dom.clientWidth;
51 var bdtext = _this.form.findField('bodytext');
52 var ptext = _this.form.findField('plaintext');
54 bdtext.width = elw-100;
55 bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height ] );
56 ptext.setSize(bdtext.width , bdtext.height);
66 title : "Edit / Create Message",
70 xtype: 'NestedLayoutPanel',
92 click : function (_self, e)
94 Pman.Dialog.CoreImportUrl.show({
95 target : '/Core/ImportMailMessage.php'
99 _this.form.findField('bodytext').setValue(data);
110 click : function (_self, e)
112 Pman.Dialog.Image.show({
113 _url : baseURL + '/Core/ImportMailMessage.php'
116 _this.form.findField('bodytext').setValue(data);
129 text : "Use template",
138 click : function (_self, e)
141 var l = document.location;
144 url : baseURL + '/Core/ImportMailMessage.php',
149 importUrl : l.protocol +'//' + l.host + rootURL + '/Pman/Crm/mail_templates/responsive1.html',
151 success : function (res) {
153 _this.form.findField('bodytext').setValue(res.data);
159 text : "Responsive Email (1)"
168 select : function (combo, record, index)
179 _this.form.findField('bodytext').setValue(record.data.content);
185 displayField : 'file',
187 emptyText : "Select Template",
188 fieldLabel : 'Template',
189 forceSelection : true,
190 hiddenName : 'template',
192 loadingText : "Searching...",
196 qtip : "Select Template",
197 selectOnFocus : true,
198 tpl : '<div class="x-grid-cell-text x-btn button"><b>{file}</b> </div>',
199 triggerAction : 'all',
207 beforeload : function (_self, o){
208 o.params = o.params || {};
214 sortInfo : { direction : 'DESC', field: 'file' },
219 url : baseURL + '/Core/MailTemplateList.php'
226 totalProperty : 'total',
227 fields : [{"name":"file","type":"string"},{"name":"content","type":"string"}]
239 click : function (_self, e)
241 var el = _this.dialog.layout.getRegion('east');
251 text : "Images / Attachments >>"
256 xtype: 'BorderLayout',
260 xtype: 'ContentPanel',
263 render : function (_self, width, height)
266 Roo.log("RESIZE, " + width + ',' + height);
268 var ew = Math.max(250, width-50);
269 var eh = Math.max(250,height-50) ;
274 resize : function (_self, width, height)
\r
276 var ew = Math.max(250, width-50);
\r
277 var eh = Math.max(250,height-50) ;
282 var bdtext = _this.form.findField('bodytext');
\r
283 var ptext = _this.form.findField('plaintext');
\r
284 if(bdtext.resizeEl){
\r
285 bdtext.width = ew-50;
\r
286 bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height ] );
\r
287 ptext.setSize(bdtext.width , bdtext.height);
\r
303 actioncomplete : function(_self,action)
306 if (action.type == 'setdata') {
308 _this.data.module = _this.data.module || 'crm_mailing_list_message';
310 _this.form.url = baseURL + '/Roo/' + _this.data.module;
312 _this.html_preview.hide();
313 _this.preview_btn.hide();
315 if(_this.data.id*1 > 0){
316 _this.dialog.el.mask("Loading");
317 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
318 _this.html_preview.show();
319 _this.preview_btn.show();
322 _this.form.setValues({
323 'from_name' : Pman.Login.authUser.name,
324 'from_email' : Pman.Login.authUser.email
329 if (action.type == 'load') {
330 _this.dialog.el.unmask();
333 if (action.type =='submit') {
335 _this.dialog.el.unmask();
338 if (_this.callback) {
339 _this.callback.call(_this, action.result.data);
345 rendered : function (form)
350 labelAlign : 'right',
353 style : 'margin:10px',
354 preValidate : function(done_callback) {
356 Roo.MessageBox.progress("Uploading Images", "Uploading");
357 var html = _this.form.findField('bodytext').getValue();
359 var s = Roo.get(_this.form.findField('bodytext').editorcore.doc.documentElement);
361 var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
364 s.select('img[src]').each(function(i) {
367 var total = nodes.length;
368 var mkimg = function() {
371 Roo.MessageBox.hide();
372 _this.form.findField('bodytext').syncValue();
374 // _this.form.doAction("submit");
379 var n = i.getAttribute('src').match(/(baseURL|server_baseurl)/);
386 n = i.getAttribute('src').match(/^http(.*)/)
394 url : baseURL + '/Roo/Images.php',
397 onid : _this.form.findField('id').getValue(),
399 _remote_upload : i.src
401 success : function(res){
402 if(res.success == true){
403 i.setAttribute('src', res.data);
404 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
413 url : baseURL + '/Roo/crm_mailing_list_message.php',
423 fieldLabel : 'Mailout Name',
445 fieldLabel : 'Email address',
455 fieldLabel : 'Subject',
468 legend : "Html Editor",
469 style : 'text-align:center;',
518 xtype: 'ToolbarContext',
519 xns: Roo.form.HtmlEditor
522 xtype: 'ToolbarStandard',
523 xns: Roo.form.HtmlEditor,
529 render : function (_self)
531 _this.extendimgselect = _self;
533 select : function (combo, record, index)
539 var editor = _this.form.findField('bodytext');
540 editor.insertAtCursor(
541 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
542 baseURL, record.data.id, record.data.filename
548 beforequery : function (combo, query, forceAll, cancel, e)
550 var id = _this.form.findField('id').getValue() * 1;
552 Roo.MessageBox.alert("Error", "Save message first");
558 displayField : 'name',
560 emptyText : "Add Image",
561 fieldLabel : 'Images',
562 forceSelection : true,
564 loadingText : "Searching...",
567 qtip : "Select Images",
568 selectOnFocus : true,
569 tpl : '<div class="x-grid-cell-text x-btn button"><img src="{public_baseURL}/Core/Images/Thumb/150x150/{id}.jpg" height="150" width="150"><b>{filename}</b> </div>',
570 triggerAction : 'all',
578 beforeload : function (_self, o){
579 o.params = o.params || {};
581 var id = _this.form.findField('id').getValue() * 1;
583 Roo.MessageBox.alert("Error", "Save email template first");
587 o.params.ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
589 // o.params.imgtype = 'PressRelease';
590 //o.params['query[imagesize]'] = '150x150';
595 sortInfo : { direction : 'ASC', field: 'id' },
600 url : baseURL + '/Roo/Images.php'
607 totalProperty : 'total',
608 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
616 render : function (_self)
618 _this.unsubscribeselect = _self;
620 select : function (combo, record, index)
626 var editor = _this.form.findField('bodytext');
628 if(record.data.name == 'Unsubscribe'){
629 editor.insertAtCursor(
630 String.format('<a href="{0}">{1}</a>',
631 record.data.type, record.data.name
637 editor.insertAtCursor(
646 displayField : 'name',
648 emptyText : "Insert Field",
649 fieldLabel : 'Field',
650 forceSelection : true,
652 loadingText : "Searching...",
655 qtip : "Insert Field",
656 selectOnFocus : true,
657 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
658 triggerAction : 'all',
663 xtype: 'SimpleStore',
666 [ '{person.firstname}', "First Name"],
667 [ '{person.lastname}' , "Last Name"],
668 [ '{person.name}', "Full Name"],
669 [ '#unsubscribe', "Unsubscribe"]
671 fields : [ 'type', 'name']
691 click : function (_self, e)
693 var h = _this.form.findField('bodytext').getValue();
694 var p = _this.form.findField('plaintext');
697 url : baseURL + '/Core/ImportMailMessage.php',
\r
701 _convertToPlain : true,
702 _check_unsubscribe : true
\r
704 success : function(res) {
\r
705 if(res.success == true){
706 p.setValue(res.data);
713 text : "Convert Html to Text"
726 legend : "Plain Text",
727 style : 'text-align:center;',
750 xtype: 'LayoutRegion',
760 activate : function() {
763 _this.igrid.ds.load({});
772 tableName : 'Images',
773 title : "Images / Attachments",
781 //_this.dialog = Pman.Dialog.FILL_IN
782 if (_this.ipanel.active) {
783 // _this.igrid.ds.load({});
787 autoExpandColumn : 'filename',
793 beforeload : function (_self, options)
795 options.params = options.params || {};
796 if (typeof(_this.data) == 'undefined') {
799 if(_this.data.id * 1 >= 0)
801 options.params.onid = _this.data.id;
803 options.params.ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
808 sortInfo : { field : 'filename', direction: 'ASC' },
813 url : baseURL + '/Roo/Images.php'
820 totalProperty : 'total',
855 'name': 'displayorder',
863 'name': 'parent_image_id',
869 'dateFormat': 'Y-m-d'
888 'name': 'parent_image_id_id',
892 'name': 'parent_image_id_filename',
896 'name': 'parent_image_id_ontable',
900 'name': 'parent_image_id_onid',
904 'name': 'parent_image_id_mimetype',
908 'name': 'parent_image_id_width',
912 'name': 'parent_image_id_height',
916 'name': 'parent_image_id_filesize',
920 'name': 'parent_image_id_displayorder',
924 'name': 'parent_image_id_language',
928 'name': 'parent_image_id_parent_image_id',
932 'name': 'parent_image_id_created',
936 'name': 'parent_image_id_imgtype',
940 'name': 'parent_image_id_linkurl',
944 'name': 'parent_image_id_descript',
948 'name': 'parent_image_id_title',
964 var id = _this.form.findField('id').getValue();
967 Roo.MessageBox.alert('Error', 'Please save the email template first');
971 var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
973 Pman.Dialog.Image.show( { id : 0, onid: id, ontable: ontable }, function() {
974 _this.igrid.getDataSource().load({});
978 cls : 'x-btn-text-icon',
980 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
988 var s = _this.igrid.getSelectionModel().getSelected();
989 if (!s || isNaN(s.id *1)) {
990 Roo.MessageBox.alert("Error", "Select a image");
993 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
999 url : baseURL + '/Roo/Images.php',
1004 success : function()
1006 Roo.log('Got Success!!');
1007 _this.igrid.ds.load({});
1013 cls : 'x-btn-text-icon',
1015 icon : rootURL + '/Pman/templates/images/trash.gif'
1021 xtype: 'ColumnModel',
1023 dataIndex : 'filename',
1024 header : 'Filename',
1026 renderer : function(v,x,r)
1028 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
1032 xtype: 'ColumnModel',
1034 header : 'Displayorder',
1036 dataIndex : 'displayorder',
1037 renderer : function(v) { return String.format('{0}', v); }
1040 xtype: 'ColumnModel',
1042 dataIndex : 'title',
1045 renderer : function(v) { return String.format('{0}', v); }
1052 xtype: 'LayoutRegion',
1057 xtype: 'LayoutRegion',
1061 title : "Images / Attachments",
1070 click : function (_self, e)
1072 //_this.dialog.hide();
1073 Roo.log(_this.data.module);
1074 Pman.Dialog.CoreEmailPreview.show({ id : _this.form.findField('id').getValue(), module : _this.data.module });
1076 render : function (_self)
1078 _this.preview_btn = _self;
1087 click : function (_self, e)
1089 //_this.dialog.hide();
1091 var id = _this.form.findField('id').getValue();
1094 Roo.MessageBox.alert('Error', 'Please save the message frist!');
1099 url : baseURL + '/Core/MessagePreview',
1104 _table : _this.data.module
1106 success : function(res) {
1107 if(res.data == 'SUCCESS'){
1108 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1113 render : function (_self)
1115 _this.html_preview = _self;
1118 text : "Send me a test copy"
1124 click : function (_self, e)
1126 _this.dialog.hide();
1135 click : function (_self, e)
1139 _this.form.preValidate(function(res) {
1143 _this.form.doAction("submit");