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').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");
378 var n = i.getAttribute('src').match(/^http(.*)/);
385 url : baseURL + '/Roo/Images.php',
388 onid : _this.form.findField('id').getValue(),
390 _remote_upload : i.src
392 success : function(res){
393 if(res.success == true){
394 i.setAttribute('src', res.data);
395 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
404 url : baseURL + '/Roo/crm_mailing_list_message.php',
414 fieldLabel : 'Mailout Name',
436 fieldLabel : 'Email address',
446 fieldLabel : 'Subject',
459 legend : "Html Editor",
460 style : 'text-align:center;',
508 xtype: 'ToolbarContext',
509 xns: Roo.form.HtmlEditor
512 xtype: 'ToolbarStandard',
513 xns: Roo.form.HtmlEditor,
519 render : function (_self)
521 _this.extendimgselect = _self;
523 select : function (combo, record, index)
529 var editor = _this.form.findField('bodytext');
530 editor.insertAtCursor(
531 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
532 baseURL, record.data.id, record.data.filename
538 beforequery : function (combo, query, forceAll, cancel, e)
540 var id = _this.form.findField('id').getValue() * 1;
542 Roo.MessageBox.alert("Error", "Save message first");
548 displayField : 'name',
550 emptyText : "Add Image",
551 fieldLabel : 'Images',
552 forceSelection : true,
554 loadingText : "Searching...",
557 qtip : "Select Images",
558 selectOnFocus : true,
559 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>',
560 triggerAction : 'all',
568 beforeload : function (_self, o){
569 o.params = o.params || {};
571 var id = _this.form.findField('id').getValue() * 1;
573 Roo.MessageBox.alert("Error", "Save email template first");
577 o.params.ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
579 // o.params.imgtype = 'PressRelease';
580 //o.params['query[imagesize]'] = '150x150';
585 sortInfo : { direction : 'ASC', field: 'id' },
590 url : baseURL + '/Roo/Images.php'
597 totalProperty : 'total',
598 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
606 render : function (_self)
608 _this.unsubscribeselect = _self;
610 select : function (combo, record, index)
616 var editor = _this.form.findField('bodytext');
618 if(record.data.name == 'Unsubscribe'){
619 editor.insertAtCursor(
620 String.format('<a href="{0}">{1}</a>',
621 record.data.type, record.data.name
627 editor.insertAtCursor(
636 displayField : 'name',
638 emptyText : "Insert Field",
639 fieldLabel : 'Field',
640 forceSelection : true,
642 loadingText : "Searching...",
645 qtip : "Insert Field",
646 selectOnFocus : true,
647 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
648 triggerAction : 'all',
653 xtype: 'SimpleStore',
656 [ '{person.firstname}', "First Name"],
657 [ '{person.lastname}' , "Last Name"],
658 [ '{person.name}', "Full Name"],
659 [ '#unsubscribe', "Unsubscribe"]
661 fields : [ 'type', 'name']
681 click : function (_self, e)
683 var h = _this.form.findField('bodytext').getValue();
684 var p = _this.form.findField('plaintext');
687 url : baseURL + '/Core/ImportMailMessage.php',
\r
691 _convertToPlain : true,
692 _check_unsubscribe : true
\r
694 success : function(res) {
\r
695 if(res.success == true){
696 p.setValue(res.data);
703 text : "Convert Html to Text"
716 legend : "Plain Text",
717 style : 'text-align:center;',
740 xtype: 'LayoutRegion',
750 activate : function() {
753 _this.igrid.ds.load({});
762 tableName : 'Images',
763 title : "Images / Attachments",
771 //_this.dialog = Pman.Dialog.FILL_IN
772 if (_this.ipanel.active) {
773 // _this.igrid.ds.load({});
777 autoExpandColumn : 'filename',
783 beforeload : function (_self, options)
785 options.params = options.params || {};
786 if (typeof(_this.data) == 'undefined') {
789 if(_this.data.id * 1 >= 0)
791 options.params.onid = _this.data.id;
793 options.params.ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
798 sortInfo : { field : 'filename', direction: 'ASC' },
803 url : baseURL + '/Roo/Images.php'
810 totalProperty : 'total',
845 'name': 'displayorder',
853 'name': 'parent_image_id',
859 'dateFormat': 'Y-m-d'
878 'name': 'parent_image_id_id',
882 'name': 'parent_image_id_filename',
886 'name': 'parent_image_id_ontable',
890 'name': 'parent_image_id_onid',
894 'name': 'parent_image_id_mimetype',
898 'name': 'parent_image_id_width',
902 'name': 'parent_image_id_height',
906 'name': 'parent_image_id_filesize',
910 'name': 'parent_image_id_displayorder',
914 'name': 'parent_image_id_language',
918 'name': 'parent_image_id_parent_image_id',
922 'name': 'parent_image_id_created',
926 'name': 'parent_image_id_imgtype',
930 'name': 'parent_image_id_linkurl',
934 'name': 'parent_image_id_descript',
938 'name': 'parent_image_id_title',
954 var id = _this.form.findField('id').getValue();
957 Roo.MessageBox.alert('Error', 'Please save the email template first');
961 var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
963 Pman.Dialog.Image.show( { id : 0, onid: id, ontable: ontable }, function() {
964 _this.igrid.getDataSource().load({});
968 cls : 'x-btn-text-icon',
970 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
978 var s = _this.igrid.getSelectionModel().getSelected();
979 if (!s || isNaN(s.id *1)) {
980 Roo.MessageBox.alert("Error", "Select a image");
983 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
989 url : baseURL + '/Roo/Images.php',
996 Roo.log('Got Success!!');
997 _this.igrid.ds.load({});
1003 cls : 'x-btn-text-icon',
1005 icon : rootURL + '/Pman/templates/images/trash.gif'
1011 xtype: 'ColumnModel',
1013 dataIndex : 'filename',
1014 header : 'Filename',
1016 renderer : function(v,x,r)
1018 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
1022 xtype: 'ColumnModel',
1024 header : 'Displayorder',
1026 dataIndex : 'displayorder',
1027 renderer : function(v) { return String.format('{0}', v); }
1030 xtype: 'ColumnModel',
1032 dataIndex : 'title',
1035 renderer : function(v) { return String.format('{0}', v); }
1042 xtype: 'LayoutRegion',
1047 xtype: 'LayoutRegion',
1051 title : "Images / Attachments",
1060 click : function (_self, e)
1062 //_this.dialog.hide();
1063 Roo.log(_this.data.module);
1064 Pman.Dialog.CoreEmailPreview.show({ id : _this.form.findField('id').getValue(), module : _this.data.module });
1066 render : function (_self)
1068 _this.preview_btn = _self;
1077 click : function (_self, e)
1079 //_this.dialog.hide();
1081 var id = _this.form.findField('id').getValue();
1084 Roo.MessageBox.alert('Error', 'Please save the message frist!');
1089 url : baseURL + '/Core/MessagePreview',
1094 _table : _this.data.module
1096 success : function(res) {
1097 if(res.data == 'SUCCESS'){
1098 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1103 render : function (_self)
1105 _this.html_preview = _self;
1108 text : "Send me a test copy"
1114 click : function (_self, e)
1116 _this.dialog.hide();
1125 click : function (_self, e)
1128 _this.form.preValidate(function(res) {
1132 _this.form.doAction("submit");