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)"
168 displayField : 'name',
170 emptyText : "Select Template",
171 fieldLabel : 'Template',
172 forceSelection : true,
173 hiddenName : 'template',
175 loadingText : "Searching...",
179 qtip : "Select Template",
180 selectOnFocus : true,
181 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
182 triggerAction : 'all',
190 beforeload : function (_self, o){
191 o.params = o.params || {};
197 sortInfo : { direction : 'DESC', field: 'name' },
202 url : baseURL + '/Core/MailTemplateList.php'
209 totalProperty : 'total',
210 fields : [{"name":"name","type":"string"},{"name":"body","type":"string"}]
222 click : function (_self, e)
224 var el = _this.dialog.layout.getRegion('east');
234 text : "Images / Attachments >>"
239 xtype: 'BorderLayout',
243 xtype: 'ContentPanel',
246 render : function (_self, width, height)
249 Roo.log("RESIZE, " + width + ',' + height);
251 var ew = Math.max(250, width-50);
252 var eh = Math.max(250,height-50) ;
257 resize : function (_self, width, height)
\r
259 var ew = Math.max(250, width-50);
\r
260 var eh = Math.max(250,height-50) ;
265 var bdtext = _this.form.findField('bodytext');
\r
266 var ptext = _this.form.findField('plaintext');
\r
267 if(bdtext.resizeEl){
\r
268 bdtext.width = ew-50;
\r
269 bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height ] );
\r
270 ptext.setSize(bdtext.width , bdtext.height);
\r
286 actioncomplete : function(_self,action)
289 if (action.type == 'setdata') {
290 // _this.loaded_data = _this.form.getValues();
292 if(_this.data.id*1 > 0){
293 _this.dialog.el.mask("Loading");
294 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
295 _this.html_preview.show();
296 _this.preview_btn.show();
298 _this.html_preview.hide();
299 _this.preview_btn.hide();
300 _this.form.setValues({
301 'from_name' : Pman.Login.authUser.name,
302 'from_email' : Pman.Login.authUser.email
307 if (action.type == 'load') {
308 _this.dialog.el.unmask();
311 if (action.type =='submit') {
313 _this.dialog.el.unmask();
316 if (_this.callback) {
317 _this.callback.call(_this, action.result.data);
323 rendered : function (form)
328 labelAlign : 'right',
331 style : 'margin:10px',
332 preValidate : function(done_callback) {
334 Roo.MessageBox.progress("Uploading Images", "Uploading");
335 var html = _this.form.findField('bodytext').getValue();
337 var s = Roo.get(_this.form.findField('bodytext').doc.documentElement);
340 s.select('img[src]').each(function(i) {
343 var total = nodes.length;
344 var mkimg = function() {
347 Roo.MessageBox.hide();
348 _this.form.findField('bodytext').syncValue();
350 // _this.form.doAction("submit");
354 var n = i.getAttribute('src').match(/^http(.*)/);
361 url : baseURL + '/Roo/Images.php',
364 onid : _this.form.findField('id').getValue(),
365 ontable : 'core_mailing_list_message' ,
366 _remote_upload : i.src
368 success : function(res){
369 if(res.success == true){
370 i.setAttribute('src', res.data);
371 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
380 url : baseURL + '/Roo/Core_mailing_list_message.php',
390 fieldLabel : 'Mailout Name',
412 fieldLabel : 'Email address',
422 fieldLabel : 'Subject',
435 legend : "Html Editor",
436 style : 'text-align:center;',
484 xtype: 'ToolbarContext',
485 xns: Roo.form.HtmlEditor
488 xtype: 'ToolbarStandard',
489 xns: Roo.form.HtmlEditor,
495 render : function (_self)
497 _this.extendimgselect = _self;
499 select : function (combo, record, index)
505 var editor = _this.form.findField('bodytext');
506 editor.insertAtCursor(
507 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
508 baseURL, record.data.id, record.data.filename
514 beforequery : function (combo, query, forceAll, cancel, e)
516 var id = _this.form.findField('id').getValue() * 1;
518 Roo.MessageBox.alert("Error", "Save email template first");
524 displayField : 'name',
526 emptyText : "Add Image",
527 fieldLabel : 'Images',
528 forceSelection : true,
530 loadingText : "Searching...",
533 qtip : "Select Images",
534 selectOnFocus : true,
535 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>',
536 triggerAction : 'all',
544 beforeload : function (_self, o){
545 o.params = o.params || {};
547 var id = _this.form.findField('id').getValue() * 1;
549 Roo.MessageBox.alert("Error", "Save press release first");
553 o.params.ontable = 'crm_mailing_list_message';
555 // o.params.imgtype = 'PressRelease';
556 //o.params['query[imagesize]'] = '150x150';
561 sortInfo : { direction : 'ASC', field: 'id' },
566 url : baseURL + '/Roo/Images.php'
573 totalProperty : 'total',
574 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
582 render : function (_self)
584 _this.unsubscribeselect = _self;
586 select : function (combo, record, index)
592 var editor = _this.form.findField('bodytext');
594 if(record.data.name == 'Unsubscribe'){
595 editor.insertAtCursor(
596 String.format('<a href="{0}">{1}</a>',
597 record.data.type, record.data.name
603 editor.insertAtCursor(
612 displayField : 'name',
614 emptyText : "Insert Field",
615 fieldLabel : 'Field',
616 forceSelection : true,
618 loadingText : "Searching...",
621 qtip : "Insert Field",
622 selectOnFocus : true,
623 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
624 triggerAction : 'all',
629 xtype: 'SimpleStore',
632 [ '{person.firstname}', "First Name"],
633 [ '{person.lastname}' , "Last Name"],
634 [ '{person.name}', "Full Name"],
635 [ '#unsubscribe', "Unsubscribe"]
637 fields : [ 'type', 'name']
657 click : function (_self, e)
659 var h = _this.form.findField('bodytext').getValue();
660 var p = _this.form.findField('plaintext');
663 url : baseURL + '/Crm/ImportHtml.php',
\r
667 _convertToPlain : true,
668 _check_unsubscribe : true
\r
670 success : function(res) {
\r
671 if(res.success == true){
672 p.setValue(res.data);
679 text : "Convert Html to Text"
692 legend : "Plain Text",
693 style : 'text-align:center;',
716 xtype: 'LayoutRegion',
726 activate : function() {
729 _this.igrid.ds.load({});
738 tableName : 'Images',
739 title : "Images / Attachments",
747 //_this.dialog = Pman.Dialog.FILL_IN
748 if (_this.ipanel.active) {
749 // _this.igrid.ds.load({});
753 autoExpandColumn : 'filename',
759 beforeload : function (_self, options)
761 options.params = options.params || {};
762 if (typeof(_this.data) == 'undefined') {
765 if(_this.data.id * 1 >= 0)
767 options.params.onid = _this.data.id;
768 options.params.ontable = 'core_mailing_list_message';
773 sortInfo : { field : 'filename', direction: 'ASC' },
778 url : baseURL + '/Roo/Images.php'
785 totalProperty : 'total',
820 'name': 'displayorder',
828 'name': 'parent_image_id',
834 'dateFormat': 'Y-m-d'
853 'name': 'parent_image_id_id',
857 'name': 'parent_image_id_filename',
861 'name': 'parent_image_id_ontable',
865 'name': 'parent_image_id_onid',
869 'name': 'parent_image_id_mimetype',
873 'name': 'parent_image_id_width',
877 'name': 'parent_image_id_height',
881 'name': 'parent_image_id_filesize',
885 'name': 'parent_image_id_displayorder',
889 'name': 'parent_image_id_language',
893 'name': 'parent_image_id_parent_image_id',
897 'name': 'parent_image_id_created',
901 'name': 'parent_image_id_imgtype',
905 'name': 'parent_image_id_linkurl',
909 'name': 'parent_image_id_descript',
913 'name': 'parent_image_id_title',
929 var id = _this.form.findField('id').getValue();
932 Roo.MessageBox.alert('Error', 'Please save the email template first');
936 Pman.Dialog.Image.show( { id : 0, onid: _this.data.id, ontable: 'core_mailing_list_message' }, function() {
937 _this.igrid.getDataSource().load({});
941 cls : 'x-btn-text-icon',
943 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
951 var s = _this.igrid.getSelectionModel().getSelected();
952 if (!s || isNaN(s.id *1)) {
953 Roo.MessageBox.alert("Error", "Select a image");
956 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
962 url : baseURL + '/Roo/Images.php',
969 Roo.log('Got Success!!');
970 _this.igrid.ds.load({});
976 cls : 'x-btn-text-icon',
978 icon : rootURL + '/Pman/templates/images/trash.gif'
984 xtype: 'ColumnModel',
986 dataIndex : 'filename',
989 renderer : function(v,x,r)
991 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
995 xtype: 'ColumnModel',
997 header : 'Displayorder',
999 dataIndex : 'displayorder',
1000 renderer : function(v) { return String.format('{0}', v); }
1003 xtype: 'ColumnModel',
1005 dataIndex : 'title',
1008 renderer : function(v) { return String.format('{0}', v); }
1015 xtype: 'LayoutRegion',
1020 xtype: 'LayoutRegion',
1024 title : "Images / Attachments",
1033 click : function (_self, e)
1035 //_this.dialog.hide();
1037 Pman.Dialog.CrmMailingListMessagePreview.show({ id : _this.form.findField('id').getValue() });
1039 render : function (_self)
1041 _this.preview_btn = _self;
1050 click : function (_self, e)
1052 //_this.dialog.hide();
1054 var id = _this.form.findField('id').getValue();
1057 Roo.MessageBox.alert('Error', 'Please select a queue to send');
1062 url : baseURL + '/Crm/MessagePreview',
1069 success : function(res) {
1070 if(res.data == 'SUCCESS'){
1071 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1076 render : function (_self)
1078 _this.html_preview = _self;
1081 text : "Send me a test copy"
1087 click : function (_self, e)
1089 _this.dialog.hide();
1098 click : function (_self, e)
1101 _this.form.preValidate(function(res) {
1105 _this.form.doAction("submit");