DataObjects/core.sql
[Pman.Core] / Pman.Dialog.CoreMailingListMessage.js
index 164b0d9..c9091d4 100644 (file)
@@ -33,7 +33,7 @@ Pman.Dialog.CoreMailingListMessage = {
             listeners : {
                 show : function (_self)
                 {
-                     
+                    
                     _self.layout.getRegion('center').showPanel(0);
                     var w = Roo.lib.Dom.getViewWidth();\r
                     var h = Roo.lib.Dom.getViewHeight();    \r    this.resizeTo(w-50, h-50);\r
@@ -91,7 +91,8 @@ Pman.Dialog.CoreMailingListMessage = {
                                             listeners : {
                                                 click : function (_self, e)
                                                 {
-                                                    Pman.Dialog.CrmImportURL.show({
+                                                    Pman.Dialog.CoreImportUrl.show({
+                                                        target : '/Crm/ImportHtml.php'
                                                     }, function(data) {
                                                         if  (data) {
                                                           //  Roo.log(data);
@@ -117,7 +118,7 @@ Pman.Dialog.CoreMailingListMessage = {
                                                     });
                                                 }
                                             },
-                                            text : "File"
+                                            text : "Html File"
                                         }
                                     ]
                                 }
@@ -160,6 +161,70 @@ Pman.Dialog.CoreMailingListMessage = {
                                     ]
                                 }
                             },
+                            {
+                                xtype: 'ComboBox',
+                                xns: Roo.form,
+                                listeners : {
+                                    select : function (combo, record, index)
+                                    {
+                                        Roo.log(record);
+                                    /*
+                                        (function() { 
+                                            combo.setValue('');
+                                        }).defer(100);
+                                    */    
+                                        _this.form.findField('bodytext').setValue(record.data.content);
+                                    
+                                    }
+                                },
+                                allowBlank : true,
+                                alwaysQuery : true,
+                                displayField : 'file',
+                                editable : false,
+                                emptyText : "Select Template",
+                                fieldLabel : 'Template',
+                                forceSelection : true,
+                                hiddenName : 'template',
+                                listWidth : 400,
+                                loadingText : "Searching...",
+                                minChars : 2,
+                                name : 'template',
+                                pageSize : 20,
+                                qtip : "Select Template",
+                                selectOnFocus : true,
+                                tpl : '<div class="x-grid-cell-text x-btn button"><b>{file}</b> </div>',
+                                triggerAction : 'all',
+                                typeAhead : true,
+                                valueField : 'file',
+                                width : 200,
+                                store : {
+                                    xtype: 'Store',
+                                    xns: Roo.data,
+                                    listeners : {
+                                        beforeload : function (_self, o){
+                                            o.params = o.params || {};
+                                            // set more here
+                                           
+                                        }
+                                    },
+                                    remoteSort : true,
+                                    sortInfo : { direction : 'DESC', field: 'file' },
+                                    proxy : {
+                                        xtype: 'HttpProxy',
+                                        xns: Roo.data,
+                                        method : 'GET',
+                                        url : baseURL + '/Core/MailTemplateList.php'
+                                    },
+                                    reader : {
+                                        xtype: 'JsonReader',
+                                        xns: Roo.data,
+                                        id : 'name',
+                                        root : 'data',
+                                        totalProperty : 'total',
+                                        fields : [{"name":"file","type":"string"},{"name":"content","type":"string"}]
+                                    }
+                                }
+                            },
                             {
                                 xtype: 'Fill',
                                 xns: Roo.Toolbar
@@ -311,7 +376,7 @@ Pman.Dialog.CoreMailingListMessage = {
                                                     method : 'POST',
                                                     params : {
                                                         onid : _this.form.findField('id').getValue(),
-                                                        ontable : 'crm_mailing_list_message' ,
+                                                        ontable : 'core_mailing_list_message' ,
                                                         _remote_upload : i.src
                                                     },
                                                     success : function(res){
@@ -495,11 +560,11 @@ Pman.Dialog.CoreMailingListMessage = {
                                                                                         
                                                                                             var id = _this.form.findField('id').getValue() * 1;    
                                                                                             if (!id) {
-                                                                                                Roo.MessageBox.alert("Error", "Save press release first");
+                                                                                                Roo.MessageBox.alert("Error", "Save email template first");
                                                                                                 return false;
                                                                                             }
                                                                                             o.params.onid = id
-                                                                                            o.params.ontable = 'crm_mailing_list_message';
+                                                                                            o.params.ontable = 'core_mailing_list_message';
                                                                                             
                                                                                            // o.params.imgtype = 'PressRelease';
                                                                                             //o.params['query[imagesize]'] = '150x150';
@@ -644,7 +709,7 @@ Pman.Dialog.CoreMailingListMessage = {
                                                             {
                                                                 xtype: 'TextArea',
                                                                 xns: Roo.form,
-                                                                height : 150,
+                                                                height : 50,
                                                                 name : 'plaintext'
                                                             }
                                                         ]
@@ -714,7 +779,7 @@ Pman.Dialog.CoreMailingListMessage = {
                                     if(_this.data.id * 1 >= 0)
                                     {
                                         options.params.onid = _this.data.id;
-                                        options.params.ontable = 'Core_mailing_list_message';
+                                        options.params.ontable = 'core_mailing_list_message';
                                     }
                                 }
                             },
@@ -729,9 +794,9 @@ Pman.Dialog.CoreMailingListMessage = {
                             reader : {
                                 xtype: 'JsonReader',
                                 xns: Roo.data,
-                                totalProperty : 'total',
-                                root : 'data',
                                 id : 'id',
+                                root : 'data',
+                                totalProperty : 'total',
                                 fields : [
                                     {
                                         'name': 'id',
@@ -875,7 +940,14 @@ Pman.Dialog.CoreMailingListMessage = {
                                     listeners : {
                                         click : function()
                                         {
-                                            Pman.Dialog.Image.show( { id : 0, onid: _this.data.id, ontable: 'crm_mailing_list_message' }, function() {
+                                            var id = _this.form.findField('id').getValue();
+                                            
+                                            if(id*1 < 1){
+                                                Roo.MessageBox.alert('Error', 'Please save the email template first');
+                                                return;
+                                            }
+                                            
+                                            Pman.Dialog.Image.show( { id : 0, onid: _this.data.id, ontable: 'core_mailing_list_message' }, function() {
                                                 _this.igrid.getDataSource().load({});
                                             }); 
                                         }