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 if(_this.data.id*1 > 0){
308 _this.dialog.el.mask("Loading");
309 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
310 _this.html_preview.show();
311 _this.preview_btn.show();
313 _this.html_preview.hide();
314 _this.preview_btn.hide();
315 _this.form.setValues({
316 'from_name' : Pman.Login.authUser.name,
317 'from_email' : Pman.Login.authUser.email
322 if (action.type == 'load') {
323 _this.dialog.el.unmask();
326 if (action.type =='submit') {
328 _this.dialog.el.unmask();
331 if (_this.callback) {
332 _this.callback.call(_this, action.result.data);
338 rendered : function (form)
343 labelAlign : 'right',
346 style : 'margin:10px',
347 preValidate : function(done_callback) {
349 Roo.MessageBox.progress("Uploading Images", "Uploading");
350 var html = _this.form.findField('bodytext').getValue();
352 var s = Roo.get(_this.form.findField('bodytext').doc.documentElement);
355 s.select('img[src]').each(function(i) {
358 var total = nodes.length;
359 var mkimg = function() {
362 Roo.MessageBox.hide();
363 _this.form.findField('bodytext').syncValue();
365 // _this.form.doAction("submit");
369 var n = i.getAttribute('src').match(/^http(.*)/);
376 url : baseURL + '/Roo/Images.php',
379 onid : _this.form.findField('id').getValue(),
380 ontable : 'core_mailing_list_message' ,
381 _remote_upload : i.src
383 success : function(res){
384 if(res.success == true){
385 i.setAttribute('src', res.data);
386 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
395 url : baseURL + '/Roo/Core_mailing_list_message.php',
405 fieldLabel : 'Mailout Name',
427 fieldLabel : 'Email address',
437 fieldLabel : 'Subject',
450 legend : "Html Editor",
451 style : 'text-align:center;',
499 xtype: 'ToolbarContext',
500 xns: Roo.form.HtmlEditor
503 xtype: 'ToolbarStandard',
504 xns: Roo.form.HtmlEditor,
510 render : function (_self)
512 _this.extendimgselect = _self;
514 select : function (combo, record, index)
520 var editor = _this.form.findField('bodytext');
521 editor.insertAtCursor(
522 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
523 baseURL, record.data.id, record.data.filename
529 beforequery : function (combo, query, forceAll, cancel, e)
531 var id = _this.form.findField('id').getValue() * 1;
533 Roo.MessageBox.alert("Error", "Save email template first");
539 displayField : 'name',
541 emptyText : "Add Image",
542 fieldLabel : 'Images',
543 forceSelection : true,
545 loadingText : "Searching...",
548 qtip : "Select Images",
549 selectOnFocus : true,
550 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>',
551 triggerAction : 'all',
559 beforeload : function (_self, o){
560 o.params = o.params || {};
562 var id = _this.form.findField('id').getValue() * 1;
564 Roo.MessageBox.alert("Error", "Save email template first");
568 o.params.ontable = 'core_mailing_list_message';
570 // o.params.imgtype = 'PressRelease';
571 //o.params['query[imagesize]'] = '150x150';
576 sortInfo : { direction : 'ASC', field: 'id' },
581 url : baseURL + '/Roo/Images.php'
588 totalProperty : 'total',
589 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
597 render : function (_self)
599 _this.unsubscribeselect = _self;
601 select : function (combo, record, index)
607 var editor = _this.form.findField('bodytext');
609 if(record.data.name == 'Unsubscribe'){
610 editor.insertAtCursor(
611 String.format('<a href="{0}">{1}</a>',
612 record.data.type, record.data.name
618 editor.insertAtCursor(
627 displayField : 'name',
629 emptyText : "Insert Field",
630 fieldLabel : 'Field',
631 forceSelection : true,
633 loadingText : "Searching...",
636 qtip : "Insert Field",
637 selectOnFocus : true,
638 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
639 triggerAction : 'all',
644 xtype: 'SimpleStore',
647 [ '{person.firstname}', "First Name"],
648 [ '{person.lastname}' , "Last Name"],
649 [ '{person.name}', "Full Name"],
650 [ '#unsubscribe', "Unsubscribe"]
652 fields : [ 'type', 'name']
672 click : function (_self, e)
674 var h = _this.form.findField('bodytext').getValue();
675 var p = _this.form.findField('plaintext');
678 url : baseURL + '/Crm/ImportHtml.php',
\r
682 _convertToPlain : true,
683 _check_unsubscribe : true
\r
685 success : function(res) {
\r
686 if(res.success == true){
687 p.setValue(res.data);
694 text : "Convert Html to Text"
707 legend : "Plain Text",
708 style : 'text-align:center;',
731 xtype: 'LayoutRegion',
741 activate : function() {
744 _this.igrid.ds.load({});
753 tableName : 'Images',
754 title : "Images / Attachments",
762 //_this.dialog = Pman.Dialog.FILL_IN
763 if (_this.ipanel.active) {
764 // _this.igrid.ds.load({});
768 autoExpandColumn : 'filename',
774 beforeload : function (_self, options)
776 options.params = options.params || {};
777 if (typeof(_this.data) == 'undefined') {
780 if(_this.data.id * 1 >= 0)
782 options.params.onid = _this.data.id;
783 options.params.ontable = 'core_mailing_list_message';
788 sortInfo : { field : 'filename', direction: 'ASC' },
793 url : baseURL + '/Roo/Images.php'
800 totalProperty : 'total',
835 'name': 'displayorder',
843 'name': 'parent_image_id',
849 'dateFormat': 'Y-m-d'
868 'name': 'parent_image_id_id',
872 'name': 'parent_image_id_filename',
876 'name': 'parent_image_id_ontable',
880 'name': 'parent_image_id_onid',
884 'name': 'parent_image_id_mimetype',
888 'name': 'parent_image_id_width',
892 'name': 'parent_image_id_height',
896 'name': 'parent_image_id_filesize',
900 'name': 'parent_image_id_displayorder',
904 'name': 'parent_image_id_language',
908 'name': 'parent_image_id_parent_image_id',
912 'name': 'parent_image_id_created',
916 'name': 'parent_image_id_imgtype',
920 'name': 'parent_image_id_linkurl',
924 'name': 'parent_image_id_descript',
928 'name': 'parent_image_id_title',
944 var id = _this.form.findField('id').getValue();
947 Roo.MessageBox.alert('Error', 'Please save the email template first');
951 Pman.Dialog.Image.show( { id : 0, onid: _this.data.id, ontable: 'core_mailing_list_message' }, function() {
952 _this.igrid.getDataSource().load({});
956 cls : 'x-btn-text-icon',
958 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
966 var s = _this.igrid.getSelectionModel().getSelected();
967 if (!s || isNaN(s.id *1)) {
968 Roo.MessageBox.alert("Error", "Select a image");
971 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
977 url : baseURL + '/Roo/Images.php',
984 Roo.log('Got Success!!');
985 _this.igrid.ds.load({});
991 cls : 'x-btn-text-icon',
993 icon : rootURL + '/Pman/templates/images/trash.gif'
999 xtype: 'ColumnModel',
1001 dataIndex : 'filename',
1002 header : 'Filename',
1004 renderer : function(v,x,r)
1006 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
1010 xtype: 'ColumnModel',
1012 header : 'Displayorder',
1014 dataIndex : 'displayorder',
1015 renderer : function(v) { return String.format('{0}', v); }
1018 xtype: 'ColumnModel',
1020 dataIndex : 'title',
1023 renderer : function(v) { return String.format('{0}', v); }
1030 xtype: 'LayoutRegion',
1035 xtype: 'LayoutRegion',
1039 title : "Images / Attachments",
1048 click : function (_self, e)
1050 //_this.dialog.hide();
1052 Pman.Dialog.CrmMailingListMessagePreview.show({ id : _this.form.findField('id').getValue() });
1054 render : function (_self)
1056 _this.preview_btn = _self;
1065 click : function (_self, e)
1067 //_this.dialog.hide();
1069 var id = _this.form.findField('id').getValue();
1072 Roo.MessageBox.alert('Error', 'Please select a queue to send');
1077 url : baseURL + '/Crm/MessagePreview',
1084 success : function(res) {
1085 if(res.data == 'SUCCESS'){
1086 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1091 render : function (_self)
1093 _this.html_preview = _self;
1096 text : "Send me a test copy"
1102 click : function (_self, e)
1104 _this.dialog.hide();
1113 click : function (_self, e)
1116 _this.form.preValidate(function(res) {
1120 _this.form.doAction("submit");