1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Dialog.CoreEmail = {
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)
179 _this.form.findField('bodytext').setValue(record.data.content);
185 displayField : 'file',
187 emptyText : "Select Template",
188 fieldLabel : 'Template',
189 forceSelection : true,
190 hiddenName : 'template',
192 loadingText : "Searching...",
196 qtip : "Select Template",
197 selectOnFocus : true,
198 tpl : '<div class="x-grid-cell-text x-btn button"><b>{file}</b> </div>',
199 triggerAction : 'all',
207 beforeload : function (_self, o){
208 o.params = o.params || {};
214 sortInfo : { direction : 'DESC', field: 'file' },
219 url : baseURL + '/Core/MailTemplateList.php'
226 totalProperty : 'total',
227 fields : [{"name":"file","type":"string"},{"name":"content","type":"string"}]
239 click : function (_self, e)
241 var el = _this.dialog.layout.getRegion('east');
251 text : "Images / Attachments >>"
256 xtype: 'BorderLayout',
260 xtype: 'ContentPanel',
263 render : function (_self, width, height)
266 Roo.log("RESIZE, " + width + ',' + height);
268 var ew = Math.max(250, width-50);
269 var eh = Math.max(250,height-50) ;
274 resize : function (_self, width, height)
\r
276 var ew = Math.max(250, width-50);
\r
277 var eh = Math.max(250,height-50) ;
282 var bdtext = _this.form.findField('bodytext');
\r
283 var ptext = _this.form.findField('plaintext');
\r
284 if(bdtext.resizeEl){
\r
285 bdtext.width = ew-50;
\r
286 bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height ] );
\r
287 ptext.setSize(bdtext.width , bdtext.height);
\r
303 actioncomplete : function(_self,action)
306 if (action.type == 'setdata') {
308 _this.data.module = _this.data.module || 'crm_mailing_list_message';
310 _this.form.url = baseURL + '/Roo/' + _this.data.module;
312 _this.html_preview.hide();
313 _this.preview_btn.hide();
315 if(_this.data.id*1 > 0){
316 _this.dialog.el.mask("Loading");
317 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
318 _this.html_preview.show();
319 _this.preview_btn.show();
322 _this.form.setValues({
323 'from_name' : Pman.Login.authUser.name,
324 'from_email' : Pman.Login.authUser.email
329 if (action.type == 'load') {
330 _this.dialog.el.unmask();
333 if (action.type =='submit') {
335 _this.dialog.el.unmask();
338 if (_this.callback) {
339 _this.callback.call(_this, action.result.data);
345 rendered : function (form)
350 labelAlign : 'right',
353 style : 'margin:10px',
354 preValidate : function(done_callback) {
356 Roo.MessageBox.progress("Uploading Images", "Uploading");
357 var html = _this.form.findField('bodytext').getValue();
359 var s = Roo.get(_this.form.findField('bodytext').editorcore.doc.documentElement);
361 var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
364 s.select('img[src]').each(function(i) {
367 var total = nodes.length;
368 var mkimg = function() {
371 Roo.MessageBox.hide();
372 _this.form.findField('bodytext').syncValue();
374 // _this.form.doAction("submit");
378 var n = i.getAttribute('src').match(/^http(.*)/) && i.getAttribute('src').match(/baseURL/);
385 url : baseURL + '/Roo/Images.php',
388 onid : _this.form.findField('id').getValue(),
390 _remote_upload : i.src
392 success : function(res){
393 if(res.success == true){
394 i.setAttribute('src', res.data);
395 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
404 url : baseURL + '/Roo/crm_mailing_list_message.php',
414 fieldLabel : 'Mailout Name',
436 fieldLabel : 'Email address',
446 fieldLabel : 'Subject',
459 legend : "Html Editor",
460 style : 'text-align:center;',
509 xtype: 'ToolbarContext',
510 xns: Roo.form.HtmlEditor
513 xtype: 'ToolbarStandard',
514 xns: Roo.form.HtmlEditor,
520 render : function (_self)
522 _this.extendimgselect = _self;
524 select : function (combo, record, index)
530 var editor = _this.form.findField('bodytext');
531 editor.insertAtCursor(
532 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
533 baseURL, record.data.id, record.data.filename
539 beforequery : function (combo, query, forceAll, cancel, e)
541 var id = _this.form.findField('id').getValue() * 1;
543 Roo.MessageBox.alert("Error", "Save message first");
549 displayField : 'name',
551 emptyText : "Add Image",
552 fieldLabel : 'Images',
553 forceSelection : true,
555 loadingText : "Searching...",
558 qtip : "Select Images",
559 selectOnFocus : true,
560 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>',
561 triggerAction : 'all',
569 beforeload : function (_self, o){
570 o.params = o.params || {};
572 var id = _this.form.findField('id').getValue() * 1;
574 Roo.MessageBox.alert("Error", "Save email template first");
578 o.params.ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
580 // o.params.imgtype = 'PressRelease';
581 //o.params['query[imagesize]'] = '150x150';
586 sortInfo : { direction : 'ASC', field: 'id' },
591 url : baseURL + '/Roo/Images.php'
598 totalProperty : 'total',
599 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
607 render : function (_self)
609 _this.unsubscribeselect = _self;
611 select : function (combo, record, index)
617 var editor = _this.form.findField('bodytext');
619 if(record.data.name == 'Unsubscribe'){
620 editor.insertAtCursor(
621 String.format('<a href="{0}">{1}</a>',
622 record.data.type, record.data.name
628 editor.insertAtCursor(
637 displayField : 'name',
639 emptyText : "Insert Field",
640 fieldLabel : 'Field',
641 forceSelection : true,
643 loadingText : "Searching...",
646 qtip : "Insert Field",
647 selectOnFocus : true,
648 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
649 triggerAction : 'all',
654 xtype: 'SimpleStore',
657 [ '{person.firstname}', "First Name"],
658 [ '{person.lastname}' , "Last Name"],
659 [ '{person.name}', "Full Name"],
660 [ '#unsubscribe', "Unsubscribe"]
662 fields : [ 'type', 'name']
682 click : function (_self, e)
684 var h = _this.form.findField('bodytext').getValue();
685 var p = _this.form.findField('plaintext');
688 url : baseURL + '/Core/ImportMailMessage.php',
\r
692 _convertToPlain : true,
693 _check_unsubscribe : true
\r
695 success : function(res) {
\r
696 if(res.success == true){
697 p.setValue(res.data);
704 text : "Convert Html to Text"
717 legend : "Plain Text",
718 style : 'text-align:center;',
741 xtype: 'LayoutRegion',
751 activate : function() {
754 _this.igrid.ds.load({});
763 tableName : 'Images',
764 title : "Images / Attachments",
772 //_this.dialog = Pman.Dialog.FILL_IN
773 if (_this.ipanel.active) {
774 // _this.igrid.ds.load({});
778 autoExpandColumn : 'filename',
784 beforeload : function (_self, options)
786 options.params = options.params || {};
787 if (typeof(_this.data) == 'undefined') {
790 if(_this.data.id * 1 >= 0)
792 options.params.onid = _this.data.id;
794 options.params.ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
799 sortInfo : { field : 'filename', direction: 'ASC' },
804 url : baseURL + '/Roo/Images.php'
811 totalProperty : 'total',
846 'name': 'displayorder',
854 'name': 'parent_image_id',
860 'dateFormat': 'Y-m-d'
879 'name': 'parent_image_id_id',
883 'name': 'parent_image_id_filename',
887 'name': 'parent_image_id_ontable',
891 'name': 'parent_image_id_onid',
895 'name': 'parent_image_id_mimetype',
899 'name': 'parent_image_id_width',
903 'name': 'parent_image_id_height',
907 'name': 'parent_image_id_filesize',
911 'name': 'parent_image_id_displayorder',
915 'name': 'parent_image_id_language',
919 'name': 'parent_image_id_parent_image_id',
923 'name': 'parent_image_id_created',
927 'name': 'parent_image_id_imgtype',
931 'name': 'parent_image_id_linkurl',
935 'name': 'parent_image_id_descript',
939 'name': 'parent_image_id_title',
955 var id = _this.form.findField('id').getValue();
958 Roo.MessageBox.alert('Error', 'Please save the email template first');
962 var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
964 Pman.Dialog.Image.show( { id : 0, onid: id, ontable: ontable }, function() {
965 _this.igrid.getDataSource().load({});
969 cls : 'x-btn-text-icon',
971 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
979 var s = _this.igrid.getSelectionModel().getSelected();
980 if (!s || isNaN(s.id *1)) {
981 Roo.MessageBox.alert("Error", "Select a image");
984 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
990 url : baseURL + '/Roo/Images.php',
997 Roo.log('Got Success!!');
998 _this.igrid.ds.load({});
1004 cls : 'x-btn-text-icon',
1006 icon : rootURL + '/Pman/templates/images/trash.gif'
1012 xtype: 'ColumnModel',
1014 dataIndex : 'filename',
1015 header : 'Filename',
1017 renderer : function(v,x,r)
1019 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
1023 xtype: 'ColumnModel',
1025 header : 'Displayorder',
1027 dataIndex : 'displayorder',
1028 renderer : function(v) { return String.format('{0}', v); }
1031 xtype: 'ColumnModel',
1033 dataIndex : 'title',
1036 renderer : function(v) { return String.format('{0}', v); }
1043 xtype: 'LayoutRegion',
1048 xtype: 'LayoutRegion',
1052 title : "Images / Attachments",
1061 click : function (_self, e)
1063 //_this.dialog.hide();
1064 Roo.log(_this.data.module);
1065 Pman.Dialog.CoreEmailPreview.show({ id : _this.form.findField('id').getValue(), module : _this.data.module });
1067 render : function (_self)
1069 _this.preview_btn = _self;
1078 click : function (_self, e)
1080 //_this.dialog.hide();
1082 var id = _this.form.findField('id').getValue();
1085 Roo.MessageBox.alert('Error', 'Please save the message frist!');
1090 url : baseURL + '/Core/MessagePreview',
1095 _table : _this.data.module
1097 success : function(res) {
1098 if(res.data == 'SUCCESS'){
1099 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1104 render : function (_self)
1106 _this.html_preview = _self;
1109 text : "Send me a test copy"
1115 click : function (_self, e)
1117 _this.dialog.hide();
1126 click : function (_self, e)
1130 _this.form.preValidate(function(res) {
1134 _this.form.doAction("submit");