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 : '/Crm/ImportHtml.php'
99 _this.form.findField('bodytext').setValue(data);
110 click : function (_self, e)
112 Pman.Dialog.Image.show({
113 _url : baseURL + '/Crm/ImportHtml.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 + '/Crm/ImportHtml.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)"
169 displayField : 'file',
171 emptyText : "Select Template",
172 fieldLabel : 'Template',
173 forceSelection : true,
174 hiddenName : 'template',
176 loadingText : "Searching...",
180 qtip : "Select Template",
181 selectOnFocus : true,
182 tpl : '<div class="x-grid-cell-text x-btn button"><b>{file}</b> </div>',
183 triggerAction : 'all',
191 beforeload : function (_self, o){
192 o.params = o.params || {};
198 sortInfo : { direction : 'DESC', field: 'file' },
203 url : baseURL + '/Core/MailTemplateList.php'
210 totalProperty : 'total',
211 fields : [{"name":"file","type":"string"},{"name":"content","type":"string"}]
223 click : function (_self, e)
225 var el = _this.dialog.layout.getRegion('east');
235 text : "Images / Attachments >>"
240 xtype: 'BorderLayout',
244 xtype: 'ContentPanel',
247 render : function (_self, width, height)
250 Roo.log("RESIZE, " + width + ',' + height);
252 var ew = Math.max(250, width-50);
253 var eh = Math.max(250,height-50) ;
258 resize : function (_self, width, height)
\r
260 var ew = Math.max(250, width-50);
\r
261 var eh = Math.max(250,height-50) ;
266 var bdtext = _this.form.findField('bodytext');
\r
267 var ptext = _this.form.findField('plaintext');
\r
268 if(bdtext.resizeEl){
\r
269 bdtext.width = ew-50;
\r
270 bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height ] );
\r
271 ptext.setSize(bdtext.width , bdtext.height);
\r
287 actioncomplete : function(_self,action)
290 if (action.type == 'setdata') {
291 // _this.loaded_data = _this.form.getValues();
293 if(_this.data.id*1 > 0){
294 _this.dialog.el.mask("Loading");
295 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
296 _this.html_preview.show();
297 _this.preview_btn.show();
299 _this.html_preview.hide();
300 _this.preview_btn.hide();
301 _this.form.setValues({
302 'from_name' : Pman.Login.authUser.name,
303 'from_email' : Pman.Login.authUser.email
308 if (action.type == 'load') {
309 _this.dialog.el.unmask();
312 if (action.type =='submit') {
314 _this.dialog.el.unmask();
317 if (_this.callback) {
318 _this.callback.call(_this, action.result.data);
324 rendered : function (form)
329 labelAlign : 'right',
332 style : 'margin:10px',
333 preValidate : function(done_callback) {
335 Roo.MessageBox.progress("Uploading Images", "Uploading");
336 var html = _this.form.findField('bodytext').getValue();
338 var s = Roo.get(_this.form.findField('bodytext').doc.documentElement);
341 s.select('img[src]').each(function(i) {
344 var total = nodes.length;
345 var mkimg = function() {
348 Roo.MessageBox.hide();
349 _this.form.findField('bodytext').syncValue();
351 // _this.form.doAction("submit");
355 var n = i.getAttribute('src').match(/^http(.*)/);
362 url : baseURL + '/Roo/Images.php',
365 onid : _this.form.findField('id').getValue(),
366 ontable : 'core_mailing_list_message' ,
367 _remote_upload : i.src
369 success : function(res){
370 if(res.success == true){
371 i.setAttribute('src', res.data);
372 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
381 url : baseURL + '/Roo/Core_mailing_list_message.php',
391 fieldLabel : 'Mailout Name',
413 fieldLabel : 'Email address',
423 fieldLabel : 'Subject',
436 legend : "Html Editor",
437 style : 'text-align:center;',
485 xtype: 'ToolbarContext',
486 xns: Roo.form.HtmlEditor
489 xtype: 'ToolbarStandard',
490 xns: Roo.form.HtmlEditor,
496 render : function (_self)
498 _this.extendimgselect = _self;
500 select : function (combo, record, index)
506 var editor = _this.form.findField('bodytext');
507 editor.insertAtCursor(
508 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
509 baseURL, record.data.id, record.data.filename
515 beforequery : function (combo, query, forceAll, cancel, e)
517 var id = _this.form.findField('id').getValue() * 1;
519 Roo.MessageBox.alert("Error", "Save email template first");
525 displayField : 'name',
527 emptyText : "Add Image",
528 fieldLabel : 'Images',
529 forceSelection : true,
531 loadingText : "Searching...",
534 qtip : "Select Images",
535 selectOnFocus : true,
536 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>',
537 triggerAction : 'all',
545 beforeload : function (_self, o){
546 o.params = o.params || {};
548 var id = _this.form.findField('id').getValue() * 1;
550 Roo.MessageBox.alert("Error", "Save email template first");
554 o.params.ontable = 'core_mailing_list_message';
556 // o.params.imgtype = 'PressRelease';
557 //o.params['query[imagesize]'] = '150x150';
562 sortInfo : { direction : 'ASC', field: 'id' },
567 url : baseURL + '/Roo/Images.php'
574 totalProperty : 'total',
575 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
583 render : function (_self)
585 _this.unsubscribeselect = _self;
587 select : function (combo, record, index)
593 var editor = _this.form.findField('bodytext');
595 if(record.data.name == 'Unsubscribe'){
596 editor.insertAtCursor(
597 String.format('<a href="{0}">{1}</a>',
598 record.data.type, record.data.name
604 editor.insertAtCursor(
613 displayField : 'name',
615 emptyText : "Insert Field",
616 fieldLabel : 'Field',
617 forceSelection : true,
619 loadingText : "Searching...",
622 qtip : "Insert Field",
623 selectOnFocus : true,
624 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
625 triggerAction : 'all',
630 xtype: 'SimpleStore',
633 [ '{person.firstname}', "First Name"],
634 [ '{person.lastname}' , "Last Name"],
635 [ '{person.name}', "Full Name"],
636 [ '#unsubscribe', "Unsubscribe"]
638 fields : [ 'type', 'name']
658 click : function (_self, e)
660 var h = _this.form.findField('bodytext').getValue();
661 var p = _this.form.findField('plaintext');
664 url : baseURL + '/Crm/ImportHtml.php',
\r
668 _convertToPlain : true,
669 _check_unsubscribe : true
\r
671 success : function(res) {
\r
672 if(res.success == true){
673 p.setValue(res.data);
680 text : "Convert Html to Text"
693 legend : "Plain Text",
694 style : 'text-align:center;',
717 xtype: 'LayoutRegion',
727 activate : function() {
730 _this.igrid.ds.load({});
739 tableName : 'Images',
740 title : "Images / Attachments",
748 //_this.dialog = Pman.Dialog.FILL_IN
749 if (_this.ipanel.active) {
750 // _this.igrid.ds.load({});
754 autoExpandColumn : 'filename',
760 beforeload : function (_self, options)
762 options.params = options.params || {};
763 if (typeof(_this.data) == 'undefined') {
766 if(_this.data.id * 1 >= 0)
768 options.params.onid = _this.data.id;
769 options.params.ontable = 'core_mailing_list_message';
774 sortInfo : { field : 'filename', direction: 'ASC' },
779 url : baseURL + '/Roo/Images.php'
786 totalProperty : 'total',
821 'name': 'displayorder',
829 'name': 'parent_image_id',
835 'dateFormat': 'Y-m-d'
854 'name': 'parent_image_id_id',
858 'name': 'parent_image_id_filename',
862 'name': 'parent_image_id_ontable',
866 'name': 'parent_image_id_onid',
870 'name': 'parent_image_id_mimetype',
874 'name': 'parent_image_id_width',
878 'name': 'parent_image_id_height',
882 'name': 'parent_image_id_filesize',
886 'name': 'parent_image_id_displayorder',
890 'name': 'parent_image_id_language',
894 'name': 'parent_image_id_parent_image_id',
898 'name': 'parent_image_id_created',
902 'name': 'parent_image_id_imgtype',
906 'name': 'parent_image_id_linkurl',
910 'name': 'parent_image_id_descript',
914 'name': 'parent_image_id_title',
930 var id = _this.form.findField('id').getValue();
933 Roo.MessageBox.alert('Error', 'Please save the email template first');
937 Pman.Dialog.Image.show( { id : 0, onid: _this.data.id, ontable: 'core_mailing_list_message' }, function() {
938 _this.igrid.getDataSource().load({});
942 cls : 'x-btn-text-icon',
944 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
952 var s = _this.igrid.getSelectionModel().getSelected();
953 if (!s || isNaN(s.id *1)) {
954 Roo.MessageBox.alert("Error", "Select a image");
957 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
963 url : baseURL + '/Roo/Images.php',
970 Roo.log('Got Success!!');
971 _this.igrid.ds.load({});
977 cls : 'x-btn-text-icon',
979 icon : rootURL + '/Pman/templates/images/trash.gif'
985 xtype: 'ColumnModel',
987 dataIndex : 'filename',
990 renderer : function(v,x,r)
992 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
996 xtype: 'ColumnModel',
998 header : 'Displayorder',
1000 dataIndex : 'displayorder',
1001 renderer : function(v) { return String.format('{0}', v); }
1004 xtype: 'ColumnModel',
1006 dataIndex : 'title',
1009 renderer : function(v) { return String.format('{0}', v); }
1016 xtype: 'LayoutRegion',
1021 xtype: 'LayoutRegion',
1025 title : "Images / Attachments",
1034 click : function (_self, e)
1036 //_this.dialog.hide();
1038 Pman.Dialog.CrmMailingListMessagePreview.show({ id : _this.form.findField('id').getValue() });
1040 render : function (_self)
1042 _this.preview_btn = _self;
1051 click : function (_self, e)
1053 //_this.dialog.hide();
1055 var id = _this.form.findField('id').getValue();
1058 Roo.MessageBox.alert('Error', 'Please select a queue to send');
1063 url : baseURL + '/Crm/MessagePreview',
1070 success : function(res) {
1071 if(res.data == 'SUCCESS'){
1072 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1077 render : function (_self)
1079 _this.html_preview = _self;
1082 text : "Send me a test copy"
1088 click : function (_self, e)
1090 _this.dialog.hide();
1099 click : function (_self, e)
1102 _this.form.preValidate(function(res) {
1106 _this.form.doAction("submit");