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({
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)"
172 click : function (_self, e)
174 var el = _this.dialog.layout.getRegion('east');
184 text : "Images / Attachments >>"
189 xtype: 'BorderLayout',
193 xtype: 'ContentPanel',
196 render : function (_self, width, height)
199 Roo.log("RESIZE, " + width + ',' + height);
201 var ew = Math.max(250, width-50);
202 var eh = Math.max(250,height-50) ;
207 resize : function (_self, width, height)
\r
209 var ew = Math.max(250, width-50);
\r
210 var eh = Math.max(250,height-50) ;
215 var bdtext = _this.form.findField('bodytext');
\r
216 var ptext = _this.form.findField('plaintext');
\r
217 if(bdtext.resizeEl){
\r
218 bdtext.width = ew-50;
\r
219 bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height ] );
\r
220 ptext.setSize(bdtext.width , bdtext.height);
\r
236 actioncomplete : function(_self,action)
239 if (action.type == 'setdata') {
240 // _this.loaded_data = _this.form.getValues();
242 if(_this.data.id*1 > 0){
243 _this.dialog.el.mask("Loading");
244 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
245 _this.html_preview.show();
246 _this.preview_btn.show();
248 _this.html_preview.hide();
249 _this.preview_btn.hide();
250 _this.form.setValues({
251 'from_name' : Pman.Login.authUser.name,
252 'from_email' : Pman.Login.authUser.email
257 if (action.type == 'load') {
258 _this.dialog.el.unmask();
261 if (action.type =='submit') {
263 _this.dialog.el.unmask();
266 if (_this.callback) {
267 _this.callback.call(_this, action.result.data);
273 rendered : function (form)
278 labelAlign : 'right',
281 style : 'margin:10px',
282 preValidate : function(done_callback) {
284 Roo.MessageBox.progress("Uploading Images", "Uploading");
285 var html = _this.form.findField('bodytext').getValue();
287 var s = Roo.get(_this.form.findField('bodytext').doc.documentElement);
290 s.select('img[src]').each(function(i) {
293 var total = nodes.length;
294 var mkimg = function() {
297 Roo.MessageBox.hide();
298 _this.form.findField('bodytext').syncValue();
300 // _this.form.doAction("submit");
304 var n = i.getAttribute('src').match(/^http(.*)/);
311 url : baseURL + '/Roo/Images.php',
314 onid : _this.form.findField('id').getValue(),
315 ontable : 'crm_mailing_list_message' ,
316 _remote_upload : i.src
318 success : function(res){
319 if(res.success == true){
320 i.setAttribute('src', res.data);
321 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
330 url : baseURL + '/Roo/Core_mailing_list_message.php',
340 fieldLabel : 'Mailout Name',
362 fieldLabel : 'Email address',
372 fieldLabel : 'Subject',
385 legend : "Html Editor",
386 style : 'text-align:center;',
434 xtype: 'ToolbarContext',
435 xns: Roo.form.HtmlEditor
438 xtype: 'ToolbarStandard',
439 xns: Roo.form.HtmlEditor,
445 render : function (_self)
447 _this.extendimgselect = _self;
449 select : function (combo, record, index)
455 var editor = _this.form.findField('bodytext');
456 editor.insertAtCursor(
457 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
458 baseURL, record.data.id, record.data.filename
464 beforequery : function (combo, query, forceAll, cancel, e)
466 var id = _this.form.findField('id').getValue() * 1;
468 Roo.MessageBox.alert("Error", "Save email template first");
474 displayField : 'name',
476 emptyText : "Add Image",
477 fieldLabel : 'Images',
478 forceSelection : true,
480 loadingText : "Searching...",
483 qtip : "Select Images",
484 selectOnFocus : true,
485 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>',
486 triggerAction : 'all',
494 beforeload : function (_self, o){
495 o.params = o.params || {};
497 var id = _this.form.findField('id').getValue() * 1;
499 Roo.MessageBox.alert("Error", "Save press release first");
503 o.params.ontable = 'crm_mailing_list_message';
505 // o.params.imgtype = 'PressRelease';
506 //o.params['query[imagesize]'] = '150x150';
511 sortInfo : { direction : 'ASC', field: 'id' },
516 url : baseURL + '/Roo/Images.php'
523 totalProperty : 'total',
524 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
532 render : function (_self)
534 _this.unsubscribeselect = _self;
536 select : function (combo, record, index)
542 var editor = _this.form.findField('bodytext');
544 if(record.data.name == 'Unsubscribe'){
545 editor.insertAtCursor(
546 String.format('<a href="{0}">{1}</a>',
547 record.data.type, record.data.name
553 editor.insertAtCursor(
562 displayField : 'name',
564 emptyText : "Insert Field",
565 fieldLabel : 'Field',
566 forceSelection : true,
568 loadingText : "Searching...",
571 qtip : "Insert Field",
572 selectOnFocus : true,
573 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
574 triggerAction : 'all',
579 xtype: 'SimpleStore',
582 [ '{person.firstname}', "First Name"],
583 [ '{person.lastname}' , "Last Name"],
584 [ '{person.name}', "Full Name"],
585 [ '#unsubscribe', "Unsubscribe"]
587 fields : [ 'type', 'name']
607 click : function (_self, e)
609 var h = _this.form.findField('bodytext').getValue();
610 var p = _this.form.findField('plaintext');
613 url : baseURL + '/Crm/ImportHtml.php',
\r
617 _convertToPlain : true,
618 _check_unsubscribe : true
\r
620 success : function(res) {
\r
621 if(res.success == true){
622 p.setValue(res.data);
629 text : "Convert Html to Text"
642 legend : "Plain Text",
643 style : 'text-align:center;',
666 xtype: 'LayoutRegion',
676 activate : function() {
679 _this.igrid.ds.load({});
688 tableName : 'Images',
689 title : "Images / Attachments",
697 //_this.dialog = Pman.Dialog.FILL_IN
698 if (_this.ipanel.active) {
699 // _this.igrid.ds.load({});
703 autoExpandColumn : 'filename',
709 beforeload : function (_self, options)
711 options.params = options.params || {};
712 if (typeof(_this.data) == 'undefined') {
715 if(_this.data.id * 1 >= 0)
717 options.params.onid = _this.data.id;
718 options.params.ontable = 'Core_mailing_list_message';
723 sortInfo : { field : 'filename', direction: 'ASC' },
728 url : baseURL + '/Roo/Images.php'
735 totalProperty : 'total',
770 'name': 'displayorder',
778 'name': 'parent_image_id',
784 'dateFormat': 'Y-m-d'
803 'name': 'parent_image_id_id',
807 'name': 'parent_image_id_filename',
811 'name': 'parent_image_id_ontable',
815 'name': 'parent_image_id_onid',
819 'name': 'parent_image_id_mimetype',
823 'name': 'parent_image_id_width',
827 'name': 'parent_image_id_height',
831 'name': 'parent_image_id_filesize',
835 'name': 'parent_image_id_displayorder',
839 'name': 'parent_image_id_language',
843 'name': 'parent_image_id_parent_image_id',
847 'name': 'parent_image_id_created',
851 'name': 'parent_image_id_imgtype',
855 'name': 'parent_image_id_linkurl',
859 'name': 'parent_image_id_descript',
863 'name': 'parent_image_id_title',
879 Pman.Dialog.Image.show( { id : 0, onid: _this.data.id, ontable: 'core_mailing_list_message' }, function() {
880 _this.igrid.getDataSource().load({});
884 cls : 'x-btn-text-icon',
886 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
894 var s = _this.igrid.getSelectionModel().getSelected();
895 if (!s || isNaN(s.id *1)) {
896 Roo.MessageBox.alert("Error", "Select a image");
899 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
905 url : baseURL + '/Roo/Images.php',
912 Roo.log('Got Success!!');
913 _this.igrid.ds.load({});
919 cls : 'x-btn-text-icon',
921 icon : rootURL + '/Pman/templates/images/trash.gif'
927 xtype: 'ColumnModel',
929 dataIndex : 'filename',
932 renderer : function(v,x,r)
934 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
938 xtype: 'ColumnModel',
940 header : 'Displayorder',
942 dataIndex : 'displayorder',
943 renderer : function(v) { return String.format('{0}', v); }
946 xtype: 'ColumnModel',
951 renderer : function(v) { return String.format('{0}', v); }
958 xtype: 'LayoutRegion',
963 xtype: 'LayoutRegion',
967 title : "Images / Attachments",
976 click : function (_self, e)
978 //_this.dialog.hide();
980 Pman.Dialog.CrmMailingListMessagePreview.show({ id : _this.form.findField('id').getValue() });
982 render : function (_self)
984 _this.preview_btn = _self;
993 click : function (_self, e)
995 //_this.dialog.hide();
997 var id = _this.form.findField('id').getValue();
1000 Roo.MessageBox.alert('Error', 'Please select a queue to send');
1005 url : baseURL + '/Crm/MessagePreview',
1012 success : function(res) {
1013 if(res.data == 'SUCCESS'){
1014 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1019 render : function (_self)
1021 _this.html_preview = _self;
1024 text : "Send me a test copy"
1030 click : function (_self, e)
1032 _this.dialog.hide();
1041 click : function (_self, e)
1044 _this.form.preValidate(function(res) {
1048 _this.form.doAction("submit");