DataObjects/pman.links.ini
[Pman.Core] / Pman.Dialog.CoreMailingListMessage.js
index c2cdf88..c39c5bc 100644 (file)
@@ -167,12 +167,15 @@ Pman.Dialog.CoreMailingListMessage = {
                                 listeners : {
                                     select : function (combo, record, index)
                                     {
-                                        Roo.log(record);
+                                       
                                     /*
                                         (function() { 
                                             combo.setValue('');
                                         }).defer(100);
                                     */    
+                                        if(!record){
+                                            return;
+                                        }
                                         _this.form.findField('bodytext').setValue(record.data.content);
                                     
                                     }
@@ -306,17 +309,18 @@ Pman.Dialog.CoreMailingListMessage = {
                                                     
                                                     _this.form.url = baseURL + '/Roo/' + _this.data.module + '_mailing_list_message.php';
                                                     
+                                                    _this.html_preview.hide();
+                                                    _this.preview_btn.hide();
+                                                        
                                                     if(_this.data.id*1 > 0){
                                                         _this.dialog.el.mask("Loading");
                                                         this.load({ method: 'GET', params: { '_id' : _this.data.id }});
                                                         if(_this.data.module == 'crm'){
-                                                            _this.preview_btn.show();
+                                                            _this.html_preview.show();
                                                         }
-                                                        _this.html_preview.show();
+                                                        _this.preview_btn.show();
                                                         
                                                     } else {
-                                                        _this.html_preview.hide();
-                                                        _this.preview_btn.hide();
                                                         _this.form.setValues({
                                                             'from_name' : Pman.Login.authUser.name,
                                                             'from_email' : Pman.Login.authUser.email
@@ -356,6 +360,8 @@ Pman.Dialog.CoreMailingListMessage = {
                                             
                                             var s = Roo.get(_this.form.findField('bodytext').doc.documentElement);
                                             
+                                            var ontable = (_this.data.module) ? _this.data.module + '_mailing_list_message' : 'crm_mailing_list_message';
+                                            
                                             var nodes = [];
                                             s.select('img[src]').each(function(i) {
                                                 nodes.push(i.dom);
@@ -382,7 +388,7 @@ Pman.Dialog.CoreMailingListMessage = {
                                                     method : 'POST',
                                                     params : {
                                                         onid : _this.form.findField('id').getValue(),
-                                                        ontable : 'core_mailing_list_message' ,
+                                                        ontable : ontable ,
                                                         _remote_upload : i.src
                                                     },
                                                     success : function(res){
@@ -535,7 +541,7 @@ Pman.Dialog.CoreMailingListMessage = {
                                                                                     {
                                                                                         var id = _this.form.findField('id').getValue() * 1;    
                                                                                         if (!id) {
-                                                                                            Roo.MessageBox.alert("Error", "Save email template first");
+                                                                                            Roo.MessageBox.alert("Error", "Save message first");
                                                                                             return false;
                                                                                         }
                                                                                     }
@@ -1056,8 +1062,8 @@ Pman.Dialog.CoreMailingListMessage = {
                         click : function (_self, e)
                         {
                             //_this.dialog.hide();
-                            
-                            Pman.Dialog.CoreMailingListMessagePreview.show({ id : _this.form.findField('id').getValue() });
+                            Roo.log(_this.data.module);
+                            Pman.Dialog.CoreMailingListMessagePreview.show({ id : _this.form.findField('id').getValue(), module : _this.data.module });
                         },
                         render : function (_self)
                         {
@@ -1086,8 +1092,7 @@ Pman.Dialog.CoreMailingListMessage = {
                                 method : 'POST',
                                 mask: 'Sending',
                                 params : {
-                                    _id : id,
-                                    _action : 'html'
+                                    _id : id
                                 }, 
                                 success : function(res) { 
                                     if(res.data == 'SUCCESS'){