1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Dialog.CoreMailingListMessage = {
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)
176 _this.form.findField('bodytext').setValue(record.data.content);
182 displayField : 'file',
184 emptyText : "Select Template",
185 fieldLabel : 'Template',
186 forceSelection : true,
187 hiddenName : 'template',
189 loadingText : "Searching...",
193 qtip : "Select Template",
194 selectOnFocus : true,
195 tpl : '<div class="x-grid-cell-text x-btn button"><b>{file}</b> </div>',
196 triggerAction : 'all',
204 beforeload : function (_self, o){
205 o.params = o.params || {};
211 sortInfo : { direction : 'DESC', field: 'file' },
216 url : baseURL + '/Core/MailTemplateList.php'
223 totalProperty : 'total',
224 fields : [{"name":"file","type":"string"},{"name":"content","type":"string"}]
236 click : function (_self, e)
238 var el = _this.dialog.layout.getRegion('east');
248 text : "Images / Attachments >>"
253 xtype: 'BorderLayout',
257 xtype: 'ContentPanel',
260 render : function (_self, width, height)
263 Roo.log("RESIZE, " + width + ',' + height);
265 var ew = Math.max(250, width-50);
266 var eh = Math.max(250,height-50) ;
271 resize : function (_self, width, height)
\r
273 var ew = Math.max(250, width-50);
\r
274 var eh = Math.max(250,height-50) ;
279 var bdtext = _this.form.findField('bodytext');
\r
280 var ptext = _this.form.findField('plaintext');
\r
281 if(bdtext.resizeEl){
\r
282 bdtext.width = ew-50;
\r
283 bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height ] );
\r
284 ptext.setSize(bdtext.width , bdtext.height);
\r
300 actioncomplete : function(_self,action)
303 if (action.type == 'setdata') {
305 _this.data.module = _this.data.module || 'crm';
307 _this.form.url = baseURL + '/Roo/' + _this.data.module + '_mailing_list_message.php';
309 if(_this.data.id*1 > 0){
310 _this.dialog.el.mask("Loading");
311 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
312 if(_this.data.module == 'crm'){
313 _this.preview_btn.show();
315 _this.html_preview.show();
318 _this.html_preview.hide();
319 _this.preview_btn.hide();
320 _this.form.setValues({
321 'from_name' : Pman.Login.authUser.name,
322 'from_email' : Pman.Login.authUser.email
327 if (action.type == 'load') {
328 _this.dialog.el.unmask();
331 if (action.type =='submit') {
333 _this.dialog.el.unmask();
336 if (_this.callback) {
337 _this.callback.call(_this, action.result.data);
343 rendered : function (form)
348 labelAlign : 'right',
351 style : 'margin:10px',
352 preValidate : function(done_callback) {
354 Roo.MessageBox.progress("Uploading Images", "Uploading");
355 var html = _this.form.findField('bodytext').getValue();
357 var s = Roo.get(_this.form.findField('bodytext').doc.documentElement);
362 s.select('img[src]').each(function(i) {
365 var total = nodes.length;
366 var mkimg = function() {
369 Roo.MessageBox.hide();
370 _this.form.findField('bodytext').syncValue();
372 // _this.form.doAction("submit");
376 var n = i.getAttribute('src').match(/^http(.*)/);
383 url : baseURL + '/Roo/Images.php',
386 onid : _this.form.findField('id').getValue(),
387 ontable : 'core_mailing_list_message' ,
388 _remote_upload : i.src
390 success : function(res){
391 if(res.success == true){
392 i.setAttribute('src', res.data);
393 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
402 url : baseURL + '/Roo/Core_mailing_list_message.php',
412 fieldLabel : 'Mailout Name',
434 fieldLabel : 'Email address',
444 fieldLabel : 'Subject',
457 legend : "Html Editor",
458 style : 'text-align:center;',
506 xtype: 'ToolbarContext',
507 xns: Roo.form.HtmlEditor
510 xtype: 'ToolbarStandard',
511 xns: Roo.form.HtmlEditor,
517 render : function (_self)
519 _this.extendimgselect = _self;
521 select : function (combo, record, index)
527 var editor = _this.form.findField('bodytext');
528 editor.insertAtCursor(
529 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
530 baseURL, record.data.id, record.data.filename
536 beforequery : function (combo, query, forceAll, cancel, e)
538 var id = _this.form.findField('id').getValue() * 1;
540 Roo.MessageBox.alert("Error", "Save email template first");
546 displayField : 'name',
548 emptyText : "Add Image",
549 fieldLabel : 'Images',
550 forceSelection : true,
552 loadingText : "Searching...",
555 qtip : "Select Images",
556 selectOnFocus : true,
557 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>',
558 triggerAction : 'all',
566 beforeload : function (_self, o){
567 o.params = o.params || {};
569 var id = _this.form.findField('id').getValue() * 1;
571 Roo.MessageBox.alert("Error", "Save email template first");
575 o.params.ontable = 'core_mailing_list_message';
577 // o.params.imgtype = 'PressRelease';
578 //o.params['query[imagesize]'] = '150x150';
583 sortInfo : { direction : 'ASC', field: 'id' },
588 url : baseURL + '/Roo/Images.php'
595 totalProperty : 'total',
596 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
604 render : function (_self)
606 _this.unsubscribeselect = _self;
608 select : function (combo, record, index)
614 var editor = _this.form.findField('bodytext');
616 if(record.data.name == 'Unsubscribe'){
617 editor.insertAtCursor(
618 String.format('<a href="{0}">{1}</a>',
619 record.data.type, record.data.name
625 editor.insertAtCursor(
634 displayField : 'name',
636 emptyText : "Insert Field",
637 fieldLabel : 'Field',
638 forceSelection : true,
640 loadingText : "Searching...",
643 qtip : "Insert Field",
644 selectOnFocus : true,
645 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
646 triggerAction : 'all',
651 xtype: 'SimpleStore',
654 [ '{person.firstname}', "First Name"],
655 [ '{person.lastname}' , "Last Name"],
656 [ '{person.name}', "Full Name"],
657 [ '#unsubscribe', "Unsubscribe"]
659 fields : [ 'type', 'name']
679 click : function (_self, e)
681 var h = _this.form.findField('bodytext').getValue();
682 var p = _this.form.findField('plaintext');
685 url : baseURL + '/Core/ImportMailMessage.php',
\r
689 _convertToPlain : true,
690 _check_unsubscribe : true
\r
692 success : function(res) {
\r
693 if(res.success == true){
694 p.setValue(res.data);
701 text : "Convert Html to Text"
714 legend : "Plain Text",
715 style : 'text-align:center;',
738 xtype: 'LayoutRegion',
748 activate : function() {
751 _this.igrid.ds.load({});
760 tableName : 'Images',
761 title : "Images / Attachments",
769 //_this.dialog = Pman.Dialog.FILL_IN
770 if (_this.ipanel.active) {
771 // _this.igrid.ds.load({});
775 autoExpandColumn : 'filename',
781 beforeload : function (_self, options)
783 options.params = options.params || {};
784 if (typeof(_this.data) == 'undefined') {
787 if(_this.data.id * 1 >= 0)
789 options.params.onid = _this.data.id;
791 options.params.ontable = (_this.data.module) ? _this.data.module + '_mailing_list_message' : 'crm_mailing_list_message';
796 sortInfo : { field : 'filename', direction: 'ASC' },
801 url : baseURL + '/Roo/Images.php'
808 totalProperty : 'total',
843 'name': 'displayorder',
851 'name': 'parent_image_id',
857 'dateFormat': 'Y-m-d'
876 'name': 'parent_image_id_id',
880 'name': 'parent_image_id_filename',
884 'name': 'parent_image_id_ontable',
888 'name': 'parent_image_id_onid',
892 'name': 'parent_image_id_mimetype',
896 'name': 'parent_image_id_width',
900 'name': 'parent_image_id_height',
904 'name': 'parent_image_id_filesize',
908 'name': 'parent_image_id_displayorder',
912 'name': 'parent_image_id_language',
916 'name': 'parent_image_id_parent_image_id',
920 'name': 'parent_image_id_created',
924 'name': 'parent_image_id_imgtype',
928 'name': 'parent_image_id_linkurl',
932 'name': 'parent_image_id_descript',
936 'name': 'parent_image_id_title',
952 var id = _this.form.findField('id').getValue();
955 Roo.MessageBox.alert('Error', 'Please save the email template first');
959 var ontable = (_this.data.module) ? _this.data.module + '_mailing_list_message' : 'crm_mailing_list_message';
961 Pman.Dialog.Image.show( { id : 0, onid: id, ontable: ontable }, function() {
962 _this.igrid.getDataSource().load({});
966 cls : 'x-btn-text-icon',
968 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
976 var s = _this.igrid.getSelectionModel().getSelected();
977 if (!s || isNaN(s.id *1)) {
978 Roo.MessageBox.alert("Error", "Select a image");
981 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
987 url : baseURL + '/Roo/Images.php',
994 Roo.log('Got Success!!');
995 _this.igrid.ds.load({});
1001 cls : 'x-btn-text-icon',
1003 icon : rootURL + '/Pman/templates/images/trash.gif'
1009 xtype: 'ColumnModel',
1011 dataIndex : 'filename',
1012 header : 'Filename',
1014 renderer : function(v,x,r)
1016 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
1020 xtype: 'ColumnModel',
1022 header : 'Displayorder',
1024 dataIndex : 'displayorder',
1025 renderer : function(v) { return String.format('{0}', v); }
1028 xtype: 'ColumnModel',
1030 dataIndex : 'title',
1033 renderer : function(v) { return String.format('{0}', v); }
1040 xtype: 'LayoutRegion',
1045 xtype: 'LayoutRegion',
1049 title : "Images / Attachments",
1058 click : function (_self, e)
1060 //_this.dialog.hide();
1062 Pman.Dialog.CoreMailingListMessagePreview.show({ id : _this.form.findField('id').getValue() });
1064 render : function (_self)
1066 _this.preview_btn = _self;
1075 click : function (_self, e)
1077 //_this.dialog.hide();
1079 var id = _this.form.findField('id').getValue();
1082 Roo.MessageBox.alert('Error', 'Please save the message frist!');
1087 url : baseURL + '/Crm/MessagePreview',
1094 success : function(res) {
1095 if(res.data == 'SUCCESS'){
1096 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1101 render : function (_self)
1103 _this.html_preview = _self;
1106 text : "Send me a test copy"
1112 click : function (_self, e)
1114 _this.dialog.hide();
1123 click : function (_self, e)
1126 _this.form.preValidate(function(res) {
1130 _this.form.doAction("submit");