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)"
165 click : function (_self, e)
168 var l = document.location;
171 url : baseURL + '/Crm/ImportHtml.php',
176 importUrl : l.protocol +'//' + l.host + rootURL + '/Pman/Crm/mail_templates/responsive1.html',
178 success : function (res) {
180 _this.form.findField('bodytext').setValue(res.data);
186 text : "Email Template"
199 click : function (_self, e)
201 var el = _this.dialog.layout.getRegion('east');
211 text : "Images / Attachments >>"
216 xtype: 'BorderLayout',
220 xtype: 'ContentPanel',
223 render : function (_self, width, height)
226 Roo.log("RESIZE, " + width + ',' + height);
228 var ew = Math.max(250, width-50);
229 var eh = Math.max(250,height-50) ;
234 resize : function (_self, width, height)
\r
236 var ew = Math.max(250, width-50);
\r
237 var eh = Math.max(250,height-50) ;
242 var bdtext = _this.form.findField('bodytext');
\r
243 var ptext = _this.form.findField('plaintext');
\r
244 if(bdtext.resizeEl){
\r
245 bdtext.width = ew-50;
\r
246 bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height ] );
\r
247 ptext.setSize(bdtext.width , bdtext.height);
\r
263 actioncomplete : function(_self,action)
266 if (action.type == 'setdata') {
267 // _this.loaded_data = _this.form.getValues();
269 if(_this.data.id*1 > 0){
270 _this.dialog.el.mask("Loading");
271 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
272 _this.html_preview.show();
273 _this.preview_btn.show();
275 _this.html_preview.hide();
276 _this.preview_btn.hide();
277 _this.form.setValues({
278 'from_name' : Pman.Login.authUser.name,
279 'from_email' : Pman.Login.authUser.email
284 if (action.type == 'load') {
285 _this.dialog.el.unmask();
288 if (action.type =='submit') {
290 _this.dialog.el.unmask();
293 if (_this.callback) {
294 _this.callback.call(_this, action.result.data);
300 rendered : function (form)
305 labelAlign : 'right',
308 style : 'margin:10px',
309 preValidate : function(done_callback) {
311 Roo.MessageBox.progress("Uploading Images", "Uploading");
312 var html = _this.form.findField('bodytext').getValue();
314 var s = Roo.get(_this.form.findField('bodytext').doc.documentElement);
317 s.select('img[src]').each(function(i) {
320 var total = nodes.length;
321 var mkimg = function() {
324 Roo.MessageBox.hide();
325 _this.form.findField('bodytext').syncValue();
327 // _this.form.doAction("submit");
331 var n = i.getAttribute('src').match(/^http(.*)/);
338 url : baseURL + '/Roo/Images.php',
341 onid : _this.form.findField('id').getValue(),
342 ontable : 'core_mailing_list_message' ,
343 _remote_upload : i.src
345 success : function(res){
346 if(res.success == true){
347 i.setAttribute('src', res.data);
348 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
357 url : baseURL + '/Roo/Core_mailing_list_message.php',
367 fieldLabel : 'Mailout Name',
389 fieldLabel : 'Email address',
399 fieldLabel : 'Subject',
412 legend : "Html Editor",
413 style : 'text-align:center;',
461 xtype: 'ToolbarContext',
462 xns: Roo.form.HtmlEditor
465 xtype: 'ToolbarStandard',
466 xns: Roo.form.HtmlEditor,
472 render : function (_self)
474 _this.extendimgselect = _self;
476 select : function (combo, record, index)
482 var editor = _this.form.findField('bodytext');
483 editor.insertAtCursor(
484 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
485 baseURL, record.data.id, record.data.filename
491 beforequery : function (combo, query, forceAll, cancel, e)
493 var id = _this.form.findField('id').getValue() * 1;
495 Roo.MessageBox.alert("Error", "Save email template first");
501 displayField : 'name',
503 emptyText : "Add Image",
504 fieldLabel : 'Images',
505 forceSelection : true,
507 loadingText : "Searching...",
510 qtip : "Select Images",
511 selectOnFocus : true,
512 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>',
513 triggerAction : 'all',
521 beforeload : function (_self, o){
522 o.params = o.params || {};
524 var id = _this.form.findField('id').getValue() * 1;
526 Roo.MessageBox.alert("Error", "Save press release first");
530 o.params.ontable = 'crm_mailing_list_message';
532 // o.params.imgtype = 'PressRelease';
533 //o.params['query[imagesize]'] = '150x150';
538 sortInfo : { direction : 'ASC', field: 'id' },
543 url : baseURL + '/Roo/Images.php'
550 totalProperty : 'total',
551 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
559 render : function (_self)
561 _this.unsubscribeselect = _self;
563 select : function (combo, record, index)
569 var editor = _this.form.findField('bodytext');
571 if(record.data.name == 'Unsubscribe'){
572 editor.insertAtCursor(
573 String.format('<a href="{0}">{1}</a>',
574 record.data.type, record.data.name
580 editor.insertAtCursor(
589 displayField : 'name',
591 emptyText : "Insert Field",
592 fieldLabel : 'Field',
593 forceSelection : true,
595 loadingText : "Searching...",
598 qtip : "Insert Field",
599 selectOnFocus : true,
600 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
601 triggerAction : 'all',
606 xtype: 'SimpleStore',
609 [ '{person.firstname}', "First Name"],
610 [ '{person.lastname}' , "Last Name"],
611 [ '{person.name}', "Full Name"],
612 [ '#unsubscribe', "Unsubscribe"]
614 fields : [ 'type', 'name']
634 click : function (_self, e)
636 var h = _this.form.findField('bodytext').getValue();
637 var p = _this.form.findField('plaintext');
640 url : baseURL + '/Crm/ImportHtml.php',
\r
644 _convertToPlain : true,
645 _check_unsubscribe : true
\r
647 success : function(res) {
\r
648 if(res.success == true){
649 p.setValue(res.data);
656 text : "Convert Html to Text"
669 legend : "Plain Text",
670 style : 'text-align:center;',
693 xtype: 'LayoutRegion',
703 activate : function() {
706 _this.igrid.ds.load({});
715 tableName : 'Images',
716 title : "Images / Attachments",
724 //_this.dialog = Pman.Dialog.FILL_IN
725 if (_this.ipanel.active) {
726 // _this.igrid.ds.load({});
730 autoExpandColumn : 'filename',
736 beforeload : function (_self, options)
738 options.params = options.params || {};
739 if (typeof(_this.data) == 'undefined') {
742 if(_this.data.id * 1 >= 0)
744 options.params.onid = _this.data.id;
745 options.params.ontable = 'core_mailing_list_message';
750 sortInfo : { field : 'filename', direction: 'ASC' },
755 url : baseURL + '/Roo/Images.php'
762 totalProperty : 'total',
797 'name': 'displayorder',
805 'name': 'parent_image_id',
811 'dateFormat': 'Y-m-d'
830 'name': 'parent_image_id_id',
834 'name': 'parent_image_id_filename',
838 'name': 'parent_image_id_ontable',
842 'name': 'parent_image_id_onid',
846 'name': 'parent_image_id_mimetype',
850 'name': 'parent_image_id_width',
854 'name': 'parent_image_id_height',
858 'name': 'parent_image_id_filesize',
862 'name': 'parent_image_id_displayorder',
866 'name': 'parent_image_id_language',
870 'name': 'parent_image_id_parent_image_id',
874 'name': 'parent_image_id_created',
878 'name': 'parent_image_id_imgtype',
882 'name': 'parent_image_id_linkurl',
886 'name': 'parent_image_id_descript',
890 'name': 'parent_image_id_title',
906 var id = _this.form.findField('id').getValue();
909 Roo.MessageBox.alert('Error', 'Please save the email template first');
913 Pman.Dialog.Image.show( { id : 0, onid: _this.data.id, ontable: 'core_mailing_list_message' }, function() {
914 _this.igrid.getDataSource().load({});
918 cls : 'x-btn-text-icon',
920 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
928 var s = _this.igrid.getSelectionModel().getSelected();
929 if (!s || isNaN(s.id *1)) {
930 Roo.MessageBox.alert("Error", "Select a image");
933 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
939 url : baseURL + '/Roo/Images.php',
946 Roo.log('Got Success!!');
947 _this.igrid.ds.load({});
953 cls : 'x-btn-text-icon',
955 icon : rootURL + '/Pman/templates/images/trash.gif'
961 xtype: 'ColumnModel',
963 dataIndex : 'filename',
966 renderer : function(v,x,r)
968 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
972 xtype: 'ColumnModel',
974 header : 'Displayorder',
976 dataIndex : 'displayorder',
977 renderer : function(v) { return String.format('{0}', v); }
980 xtype: 'ColumnModel',
985 renderer : function(v) { return String.format('{0}', v); }
992 xtype: 'LayoutRegion',
997 xtype: 'LayoutRegion',
1001 title : "Images / Attachments",
1010 click : function (_self, e)
1012 //_this.dialog.hide();
1014 Pman.Dialog.CrmMailingListMessagePreview.show({ id : _this.form.findField('id').getValue() });
1016 render : function (_self)
1018 _this.preview_btn = _self;
1027 click : function (_self, e)
1029 //_this.dialog.hide();
1031 var id = _this.form.findField('id').getValue();
1034 Roo.MessageBox.alert('Error', 'Please select a queue to send');
1039 url : baseURL + '/Crm/MessagePreview',
1046 success : function(res) {
1047 if(res.data == 'SUCCESS'){
1048 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1053 render : function (_self)
1055 _this.html_preview = _self;
1058 text : "Send me a test copy"
1064 click : function (_self, e)
1066 _this.dialog.hide();
1075 click : function (_self, e)
1078 _this.form.preValidate(function(res) {
1082 _this.form.doAction("submit");