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') {
304 // _this.loaded_data = _this.form.getValues();
306 if(_this.data.id*1 > 0){
307 _this.dialog.el.mask("Loading");
308 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
309 _this.html_preview.show();
310 _this.preview_btn.show();
312 _this.html_preview.hide();
313 _this.preview_btn.hide();
314 _this.form.setValues({
315 'from_name' : Pman.Login.authUser.name,
316 'from_email' : Pman.Login.authUser.email
321 if (action.type == 'load') {
322 _this.dialog.el.unmask();
325 if (action.type =='submit') {
327 _this.dialog.el.unmask();
330 if (_this.callback) {
331 _this.callback.call(_this, action.result.data);
337 rendered : function (form)
342 labelAlign : 'right',
345 style : 'margin:10px',
346 preValidate : function(done_callback) {
348 Roo.MessageBox.progress("Uploading Images", "Uploading");
349 var html = _this.form.findField('bodytext').getValue();
351 var s = Roo.get(_this.form.findField('bodytext').doc.documentElement);
354 s.select('img[src]').each(function(i) {
357 var total = nodes.length;
358 var mkimg = function() {
361 Roo.MessageBox.hide();
362 _this.form.findField('bodytext').syncValue();
364 // _this.form.doAction("submit");
368 var n = i.getAttribute('src').match(/^http(.*)/);
375 url : baseURL + '/Roo/Images.php',
378 onid : _this.form.findField('id').getValue(),
379 ontable : 'core_mailing_list_message' ,
380 _remote_upload : i.src
382 success : function(res){
383 if(res.success == true){
384 i.setAttribute('src', res.data);
385 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
394 url : baseURL + '/Roo/Core_mailing_list_message.php',
404 fieldLabel : 'Mailout Name',
426 fieldLabel : 'Email address',
436 fieldLabel : 'Subject',
449 legend : "Html Editor",
450 style : 'text-align:center;',
498 xtype: 'ToolbarContext',
499 xns: Roo.form.HtmlEditor
502 xtype: 'ToolbarStandard',
503 xns: Roo.form.HtmlEditor,
509 render : function (_self)
511 _this.extendimgselect = _self;
513 select : function (combo, record, index)
519 var editor = _this.form.findField('bodytext');
520 editor.insertAtCursor(
521 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
522 baseURL, record.data.id, record.data.filename
528 beforequery : function (combo, query, forceAll, cancel, e)
530 var id = _this.form.findField('id').getValue() * 1;
532 Roo.MessageBox.alert("Error", "Save email template first");
538 displayField : 'name',
540 emptyText : "Add Image",
541 fieldLabel : 'Images',
542 forceSelection : true,
544 loadingText : "Searching...",
547 qtip : "Select Images",
548 selectOnFocus : true,
549 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>',
550 triggerAction : 'all',
558 beforeload : function (_self, o){
559 o.params = o.params || {};
561 var id = _this.form.findField('id').getValue() * 1;
563 Roo.MessageBox.alert("Error", "Save email template first");
567 o.params.ontable = 'core_mailing_list_message';
569 // o.params.imgtype = 'PressRelease';
570 //o.params['query[imagesize]'] = '150x150';
575 sortInfo : { direction : 'ASC', field: 'id' },
580 url : baseURL + '/Roo/Images.php'
587 totalProperty : 'total',
588 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
596 render : function (_self)
598 _this.unsubscribeselect = _self;
600 select : function (combo, record, index)
606 var editor = _this.form.findField('bodytext');
608 if(record.data.name == 'Unsubscribe'){
609 editor.insertAtCursor(
610 String.format('<a href="{0}">{1}</a>',
611 record.data.type, record.data.name
617 editor.insertAtCursor(
626 displayField : 'name',
628 emptyText : "Insert Field",
629 fieldLabel : 'Field',
630 forceSelection : true,
632 loadingText : "Searching...",
635 qtip : "Insert Field",
636 selectOnFocus : true,
637 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
638 triggerAction : 'all',
643 xtype: 'SimpleStore',
646 [ '{person.firstname}', "First Name"],
647 [ '{person.lastname}' , "Last Name"],
648 [ '{person.name}', "Full Name"],
649 [ '#unsubscribe', "Unsubscribe"]
651 fields : [ 'type', 'name']
671 click : function (_self, e)
673 var h = _this.form.findField('bodytext').getValue();
674 var p = _this.form.findField('plaintext');
677 url : baseURL + '/Crm/ImportHtml.php',
\r
681 _convertToPlain : true,
682 _check_unsubscribe : true
\r
684 success : function(res) {
\r
685 if(res.success == true){
686 p.setValue(res.data);
693 text : "Convert Html to Text"
706 legend : "Plain Text",
707 style : 'text-align:center;',
730 xtype: 'LayoutRegion',
740 activate : function() {
743 _this.igrid.ds.load({});
752 tableName : 'Images',
753 title : "Images / Attachments",
761 //_this.dialog = Pman.Dialog.FILL_IN
762 if (_this.ipanel.active) {
763 // _this.igrid.ds.load({});
767 autoExpandColumn : 'filename',
773 beforeload : function (_self, options)
775 options.params = options.params || {};
776 if (typeof(_this.data) == 'undefined') {
779 if(_this.data.id * 1 >= 0)
781 options.params.onid = _this.data.id;
782 options.params.ontable = 'core_mailing_list_message';
787 sortInfo : { field : 'filename', direction: 'ASC' },
792 url : baseURL + '/Roo/Images.php'
799 totalProperty : 'total',
834 'name': 'displayorder',
842 'name': 'parent_image_id',
848 'dateFormat': 'Y-m-d'
867 'name': 'parent_image_id_id',
871 'name': 'parent_image_id_filename',
875 'name': 'parent_image_id_ontable',
879 'name': 'parent_image_id_onid',
883 'name': 'parent_image_id_mimetype',
887 'name': 'parent_image_id_width',
891 'name': 'parent_image_id_height',
895 'name': 'parent_image_id_filesize',
899 'name': 'parent_image_id_displayorder',
903 'name': 'parent_image_id_language',
907 'name': 'parent_image_id_parent_image_id',
911 'name': 'parent_image_id_created',
915 'name': 'parent_image_id_imgtype',
919 'name': 'parent_image_id_linkurl',
923 'name': 'parent_image_id_descript',
927 'name': 'parent_image_id_title',
943 var id = _this.form.findField('id').getValue();
946 Roo.MessageBox.alert('Error', 'Please save the email template first');
950 Pman.Dialog.Image.show( { id : 0, onid: _this.data.id, ontable: 'core_mailing_list_message' }, function() {
951 _this.igrid.getDataSource().load({});
955 cls : 'x-btn-text-icon',
957 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
965 var s = _this.igrid.getSelectionModel().getSelected();
966 if (!s || isNaN(s.id *1)) {
967 Roo.MessageBox.alert("Error", "Select a image");
970 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
976 url : baseURL + '/Roo/Images.php',
983 Roo.log('Got Success!!');
984 _this.igrid.ds.load({});
990 cls : 'x-btn-text-icon',
992 icon : rootURL + '/Pman/templates/images/trash.gif'
998 xtype: 'ColumnModel',
1000 dataIndex : 'filename',
1001 header : 'Filename',
1003 renderer : function(v,x,r)
1005 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
1009 xtype: 'ColumnModel',
1011 header : 'Displayorder',
1013 dataIndex : 'displayorder',
1014 renderer : function(v) { return String.format('{0}', v); }
1017 xtype: 'ColumnModel',
1019 dataIndex : 'title',
1022 renderer : function(v) { return String.format('{0}', v); }
1029 xtype: 'LayoutRegion',
1034 xtype: 'LayoutRegion',
1038 title : "Images / Attachments",
1047 click : function (_self, e)
1049 //_this.dialog.hide();
1051 Pman.Dialog.CrmMailingListMessagePreview.show({ id : _this.form.findField('id').getValue() });
1053 render : function (_self)
1055 _this.preview_btn = _self;
1064 click : function (_self, e)
1066 //_this.dialog.hide();
1068 var id = _this.form.findField('id').getValue();
1071 Roo.MessageBox.alert('Error', 'Please select a queue to send');
1076 url : baseURL + '/Crm/MessagePreview',
1083 success : function(res) {
1084 if(res.data == 'SUCCESS'){
1085 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1090 render : function (_self)
1092 _this.html_preview = _self;
1095 text : "Send me a test copy"
1101 click : function (_self, e)
1103 _this.dialog.hide();
1112 click : function (_self, e)
1115 _this.form.preValidate(function(res) {
1119 _this.form.doAction("submit");