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') {
305 _this.data.module = _this.data.module || 'crm';
307 _this.form.url = baseURL + '/Roo/' + _this.data.module + '_mailing_list_message.php';
309 _this.html_preview.hide();
310 _this.preview_btn.hide();
312 if(_this.data.id*1 > 0){
313 _this.dialog.el.mask("Loading");
314 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
315 if(_this.data.module == 'crm'){
316 _this.html_preview.show();
318 _this.preview_btn.show();
321 _this.form.setValues({
322 'from_name' : Pman.Login.authUser.name,
323 'from_email' : Pman.Login.authUser.email
328 if (action.type == 'load') {
329 _this.dialog.el.unmask();
332 if (action.type =='submit') {
334 _this.dialog.el.unmask();
337 if (_this.callback) {
338 _this.callback.call(_this, action.result.data);
344 rendered : function (form)
349 labelAlign : 'right',
352 style : 'margin:10px',
353 preValidate : function(done_callback) {
355 Roo.MessageBox.progress("Uploading Images", "Uploading");
356 var html = _this.form.findField('bodytext').getValue();
358 var s = Roo.get(_this.form.findField('bodytext').doc.documentElement);
360 var ontable = (_this.data.module) ? _this.data.module + '_mailing_list_message' : 'crm_mailing_list_message';
363 s.select('img[src]').each(function(i) {
366 var total = nodes.length;
367 var mkimg = function() {
370 Roo.MessageBox.hide();
371 _this.form.findField('bodytext').syncValue();
373 // _this.form.doAction("submit");
377 var n = i.getAttribute('src').match(/^http(.*)/);
384 url : baseURL + '/Roo/Images.php',
387 onid : _this.form.findField('id').getValue(),
389 _remote_upload : i.src
391 success : function(res){
392 if(res.success == true){
393 i.setAttribute('src', res.data);
394 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
403 url : baseURL + '/Roo/Core_mailing_list_message.php',
413 fieldLabel : 'Mailout Name',
435 fieldLabel : 'Email address',
445 fieldLabel : 'Subject',
458 legend : "Html Editor",
459 style : 'text-align:center;',
507 xtype: 'ToolbarContext',
508 xns: Roo.form.HtmlEditor
511 xtype: 'ToolbarStandard',
512 xns: Roo.form.HtmlEditor,
518 render : function (_self)
520 _this.extendimgselect = _self;
522 select : function (combo, record, index)
528 var editor = _this.form.findField('bodytext');
529 editor.insertAtCursor(
530 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
531 baseURL, record.data.id, record.data.filename
537 beforequery : function (combo, query, forceAll, cancel, e)
539 var id = _this.form.findField('id').getValue() * 1;
541 Roo.MessageBox.alert("Error", "Save message first");
547 displayField : 'name',
549 emptyText : "Add Image",
550 fieldLabel : 'Images',
551 forceSelection : true,
553 loadingText : "Searching...",
556 qtip : "Select Images",
557 selectOnFocus : true,
558 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>',
559 triggerAction : 'all',
567 beforeload : function (_self, o){
568 o.params = o.params || {};
570 var id = _this.form.findField('id').getValue() * 1;
572 Roo.MessageBox.alert("Error", "Save email template first");
576 o.params.ontable = 'core_mailing_list_message';
578 // o.params.imgtype = 'PressRelease';
579 //o.params['query[imagesize]'] = '150x150';
584 sortInfo : { direction : 'ASC', field: 'id' },
589 url : baseURL + '/Roo/Images.php'
596 totalProperty : 'total',
597 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
605 render : function (_self)
607 _this.unsubscribeselect = _self;
609 select : function (combo, record, index)
615 var editor = _this.form.findField('bodytext');
617 if(record.data.name == 'Unsubscribe'){
618 editor.insertAtCursor(
619 String.format('<a href="{0}">{1}</a>',
620 record.data.type, record.data.name
626 editor.insertAtCursor(
635 displayField : 'name',
637 emptyText : "Insert Field",
638 fieldLabel : 'Field',
639 forceSelection : true,
641 loadingText : "Searching...",
644 qtip : "Insert Field",
645 selectOnFocus : true,
646 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
647 triggerAction : 'all',
652 xtype: 'SimpleStore',
655 [ '{person.firstname}', "First Name"],
656 [ '{person.lastname}' , "Last Name"],
657 [ '{person.name}', "Full Name"],
658 [ '#unsubscribe', "Unsubscribe"]
660 fields : [ 'type', 'name']
680 click : function (_self, e)
682 var h = _this.form.findField('bodytext').getValue();
683 var p = _this.form.findField('plaintext');
686 url : baseURL + '/Core/ImportMailMessage.php',
\r
690 _convertToPlain : true,
691 _check_unsubscribe : true
\r
693 success : function(res) {
\r
694 if(res.success == true){
695 p.setValue(res.data);
702 text : "Convert Html to Text"
715 legend : "Plain Text",
716 style : 'text-align:center;',
739 xtype: 'LayoutRegion',
749 activate : function() {
752 _this.igrid.ds.load({});
761 tableName : 'Images',
762 title : "Images / Attachments",
770 //_this.dialog = Pman.Dialog.FILL_IN
771 if (_this.ipanel.active) {
772 // _this.igrid.ds.load({});
776 autoExpandColumn : 'filename',
782 beforeload : function (_self, options)
784 options.params = options.params || {};
785 if (typeof(_this.data) == 'undefined') {
788 if(_this.data.id * 1 >= 0)
790 options.params.onid = _this.data.id;
792 options.params.ontable = (_this.data.module) ? _this.data.module + '_mailing_list_message' : 'crm_mailing_list_message';
797 sortInfo : { field : 'filename', direction: 'ASC' },
802 url : baseURL + '/Roo/Images.php'
809 totalProperty : 'total',
844 'name': 'displayorder',
852 'name': 'parent_image_id',
858 'dateFormat': 'Y-m-d'
877 'name': 'parent_image_id_id',
881 'name': 'parent_image_id_filename',
885 'name': 'parent_image_id_ontable',
889 'name': 'parent_image_id_onid',
893 'name': 'parent_image_id_mimetype',
897 'name': 'parent_image_id_width',
901 'name': 'parent_image_id_height',
905 'name': 'parent_image_id_filesize',
909 'name': 'parent_image_id_displayorder',
913 'name': 'parent_image_id_language',
917 'name': 'parent_image_id_parent_image_id',
921 'name': 'parent_image_id_created',
925 'name': 'parent_image_id_imgtype',
929 'name': 'parent_image_id_linkurl',
933 'name': 'parent_image_id_descript',
937 'name': 'parent_image_id_title',
953 var id = _this.form.findField('id').getValue();
956 Roo.MessageBox.alert('Error', 'Please save the email template first');
960 var ontable = (_this.data.module) ? _this.data.module + '_mailing_list_message' : 'crm_mailing_list_message';
962 Pman.Dialog.Image.show( { id : 0, onid: id, ontable: ontable }, function() {
963 _this.igrid.getDataSource().load({});
967 cls : 'x-btn-text-icon',
969 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
977 var s = _this.igrid.getSelectionModel().getSelected();
978 if (!s || isNaN(s.id *1)) {
979 Roo.MessageBox.alert("Error", "Select a image");
982 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
988 url : baseURL + '/Roo/Images.php',
995 Roo.log('Got Success!!');
996 _this.igrid.ds.load({});
1002 cls : 'x-btn-text-icon',
1004 icon : rootURL + '/Pman/templates/images/trash.gif'
1010 xtype: 'ColumnModel',
1012 dataIndex : 'filename',
1013 header : 'Filename',
1015 renderer : function(v,x,r)
1017 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
1021 xtype: 'ColumnModel',
1023 header : 'Displayorder',
1025 dataIndex : 'displayorder',
1026 renderer : function(v) { return String.format('{0}', v); }
1029 xtype: 'ColumnModel',
1031 dataIndex : 'title',
1034 renderer : function(v) { return String.format('{0}', v); }
1041 xtype: 'LayoutRegion',
1046 xtype: 'LayoutRegion',
1050 title : "Images / Attachments",
1059 click : function (_self, e)
1061 //_this.dialog.hide();
1062 Roo.log(_this.data.module);
1063 Pman.Dialog.CoreMailingListMessagePreview.show({ id : _this.form.findField('id').getValue(), module : _this.data.module });
1065 render : function (_self)
1067 _this.preview_btn = _self;
1076 click : function (_self, e)
1078 //_this.dialog.hide();
1080 var id = _this.form.findField('id').getValue();
1083 Roo.MessageBox.alert('Error', 'Please save the message frist!');
1088 url : baseURL + '/Crm/MessagePreview',
1095 success : function(res) {
1096 if(res.data == 'SUCCESS'){
1097 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1102 render : function (_self)
1104 _this.html_preview = _self;
1107 text : "Send me a test copy"
1113 click : function (_self, e)
1115 _this.dialog.hide();
1124 click : function (_self, e)
1127 _this.form.preValidate(function(res) {
1131 _this.form.doAction("submit");