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({
98 _this.form.findField('bodytext').setValue(data);
109 click : function (_self, e)
111 Pman.Dialog.Image.show({
112 _url : baseURL + '/Crm/ImportHtml.php'
115 _this.form.findField('bodytext').setValue(data);
128 text : "Use template",
137 click : function (_self, e)
140 var l = document.location;
143 url : baseURL + '/Crm/ImportHtml.php',
148 importUrl : l.protocol +'//' + l.host + rootURL + '/Pman/Crm/mail_templates/responsive1.html',
150 success : function (res) {
152 _this.form.findField('bodytext').setValue(res.data);
158 text : "Responsive Email (1)"
171 click : function (_self, e)
173 var el = _this.dialog.layout.getRegion('east');
183 text : "Images / Attachments >>"
188 xtype: 'BorderLayout',
192 xtype: 'ContentPanel',
195 render : function (_self, width, height)
198 Roo.log("RESIZE, " + width + ',' + height);
200 var ew = Math.max(250, width-50);
201 var eh = Math.max(250,height-50) ;
206 resize : function (_self, width, height)
\r
208 var ew = Math.max(250, width-50);
\r
209 var eh = Math.max(250,height-50) ;
214 var bdtext = _this.form.findField('bodytext');
\r
215 var ptext = _this.form.findField('plaintext');
\r
216 if(bdtext.resizeEl){
\r
217 bdtext.width = ew-50;
\r
218 bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height ] );
\r
219 ptext.setSize(bdtext.width , bdtext.height);
\r
235 actioncomplete : function(_self,action)
238 if (action.type == 'setdata') {
239 // _this.loaded_data = _this.form.getValues();
241 if(_this.data.id*1 > 0){
242 _this.dialog.el.mask("Loading");
243 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
244 _this.html_preview.show();
245 _this.preview_btn.show();
247 _this.html_preview.hide();
248 _this.preview_btn.hide();
249 _this.form.setValues({
250 'from_name' : Pman.Login.authUser.name,
251 'from_email' : Pman.Login.authUser.email
256 if (action.type == 'load') {
257 _this.dialog.el.unmask();
260 if (action.type =='submit') {
262 _this.dialog.el.unmask();
265 if (_this.callback) {
266 _this.callback.call(_this, action.result.data);
272 rendered : function (form)
277 labelAlign : 'right',
280 style : 'margin:10px',
281 preValidate : function(done_callback) {
283 Roo.MessageBox.progress("Uploading Images", "Uploading");
284 var html = _this.form.findField('bodytext').getValue();
286 var s = Roo.get(_this.form.findField('bodytext').doc.documentElement);
289 s.select('img[src]').each(function(i) {
292 var total = nodes.length;
293 var mkimg = function() {
296 Roo.MessageBox.hide();
297 _this.form.findField('bodytext').syncValue();
299 // _this.form.doAction("submit");
303 var n = i.getAttribute('src').match(/^http(.*)/);
310 url : baseURL + '/Roo/Images.php',
313 onid : _this.form.findField('id').getValue(),
314 ontable : 'crm_mailing_list_message' ,
315 _remote_upload : i.src
317 success : function(res){
318 if(res.success == true){
319 i.setAttribute('src', res.data);
320 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
329 url : baseURL + '/Roo/Core_mailing_list_message.php',
339 fieldLabel : 'Mailout Name',
361 fieldLabel : 'Email address',
371 fieldLabel : 'Subject',
384 legend : "Html Editor",
385 style : 'text-align:center;',
433 xtype: 'ToolbarContext',
434 xns: Roo.form.HtmlEditor
437 xtype: 'ToolbarStandard',
438 xns: Roo.form.HtmlEditor,
444 render : function (_self)
446 _this.extendimgselect = _self;
448 select : function (combo, record, index)
454 var editor = _this.form.findField('bodytext');
455 editor.insertAtCursor(
456 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
457 baseURL, record.data.id, record.data.filename
463 beforequery : function (combo, query, forceAll, cancel, e)
465 var id = _this.form.findField('id').getValue() * 1;
467 Roo.MessageBox.alert("Error", "Save email template first");
473 displayField : 'name',
475 emptyText : "Add Image",
476 fieldLabel : 'Images',
477 forceSelection : true,
479 loadingText : "Searching...",
482 qtip : "Select Images",
483 selectOnFocus : true,
484 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>',
485 triggerAction : 'all',
493 beforeload : function (_self, o){
494 o.params = o.params || {};
496 var id = _this.form.findField('id').getValue() * 1;
498 Roo.MessageBox.alert("Error", "Save press release first");
502 o.params.ontable = 'crm_mailing_list_message';
504 // o.params.imgtype = 'PressRelease';
505 //o.params['query[imagesize]'] = '150x150';
510 sortInfo : { direction : 'ASC', field: 'id' },
515 url : baseURL + '/Roo/Images.php'
522 totalProperty : 'total',
523 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
531 render : function (_self)
533 _this.unsubscribeselect = _self;
535 select : function (combo, record, index)
541 var editor = _this.form.findField('bodytext');
543 if(record.data.name == 'Unsubscribe'){
544 editor.insertAtCursor(
545 String.format('<a href="{0}">{1}</a>',
546 record.data.type, record.data.name
552 editor.insertAtCursor(
561 displayField : 'name',
563 emptyText : "Insert Field",
564 fieldLabel : 'Field',
565 forceSelection : true,
567 loadingText : "Searching...",
570 qtip : "Insert Field",
571 selectOnFocus : true,
572 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
573 triggerAction : 'all',
578 xtype: 'SimpleStore',
581 [ '{person.firstname}', "First Name"],
582 [ '{person.lastname}' , "Last Name"],
583 [ '{person.name}', "Full Name"],
584 [ '#unsubscribe', "Unsubscribe"]
586 fields : [ 'type', 'name']
606 click : function (_self, e)
608 var h = _this.form.findField('bodytext').getValue();
609 var p = _this.form.findField('plaintext');
612 url : baseURL + '/Crm/ImportHtml.php',
\r
616 _convertToPlain : true,
617 _check_unsubscribe : true
\r
619 success : function(res) {
\r
620 if(res.success == true){
621 p.setValue(res.data);
628 text : "Convert Html to Text"
641 legend : "Plain Text",
642 style : 'text-align:center;',
665 xtype: 'LayoutRegion',
675 activate : function() {
678 _this.igrid.ds.load({});
687 tableName : 'Images',
688 title : "Images / Attachments",
696 //_this.dialog = Pman.Dialog.FILL_IN
697 if (_this.ipanel.active) {
698 // _this.igrid.ds.load({});
702 autoExpandColumn : 'filename',
708 beforeload : function (_self, options)
710 options.params = options.params || {};
711 if (typeof(_this.data) == 'undefined') {
714 if(_this.data.id * 1 >= 0)
716 options.params.onid = _this.data.id;
717 options.params.ontable = 'Core_mailing_list_message';
722 sortInfo : { field : 'filename', direction: 'ASC' },
727 url : baseURL + '/Roo/Images.php'
734 totalProperty : 'total',
769 'name': 'displayorder',
777 'name': 'parent_image_id',
783 'dateFormat': 'Y-m-d'
802 'name': 'parent_image_id_id',
806 'name': 'parent_image_id_filename',
810 'name': 'parent_image_id_ontable',
814 'name': 'parent_image_id_onid',
818 'name': 'parent_image_id_mimetype',
822 'name': 'parent_image_id_width',
826 'name': 'parent_image_id_height',
830 'name': 'parent_image_id_filesize',
834 'name': 'parent_image_id_displayorder',
838 'name': 'parent_image_id_language',
842 'name': 'parent_image_id_parent_image_id',
846 'name': 'parent_image_id_created',
850 'name': 'parent_image_id_imgtype',
854 'name': 'parent_image_id_linkurl',
858 'name': 'parent_image_id_descript',
862 'name': 'parent_image_id_title',
878 Pman.Dialog.Image.show( { id : 0, onid: _this.data.id, ontable: 'core_mailing_list_message' }, function() {
879 _this.igrid.getDataSource().load({});
883 cls : 'x-btn-text-icon',
885 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
893 var s = _this.igrid.getSelectionModel().getSelected();
894 if (!s || isNaN(s.id *1)) {
895 Roo.MessageBox.alert("Error", "Select a image");
898 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
904 url : baseURL + '/Roo/Images.php',
911 Roo.log('Got Success!!');
912 _this.igrid.ds.load({});
918 cls : 'x-btn-text-icon',
920 icon : rootURL + '/Pman/templates/images/trash.gif'
926 xtype: 'ColumnModel',
928 dataIndex : 'filename',
931 renderer : function(v,x,r)
933 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
937 xtype: 'ColumnModel',
939 header : 'Displayorder',
941 dataIndex : 'displayorder',
942 renderer : function(v) { return String.format('{0}', v); }
945 xtype: 'ColumnModel',
950 renderer : function(v) { return String.format('{0}', v); }
957 xtype: 'LayoutRegion',
962 xtype: 'LayoutRegion',
966 title : "Images / Attachments",
975 click : function (_self, e)
977 //_this.dialog.hide();
979 Pman.Dialog.CrmMailingListMessagePreview.show({ id : _this.form.findField('id').getValue() });
981 render : function (_self)
983 _this.preview_btn = _self;
992 click : function (_self, e)
994 //_this.dialog.hide();
996 var id = _this.form.findField('id').getValue();
999 Roo.MessageBox.alert('Error', 'Please select a queue to send');
1004 url : baseURL + '/Crm/MessagePreview',
1011 success : function(res) {
1012 if(res.data == 'SUCCESS'){
1013 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1018 render : function (_self)
1020 _this.html_preview = _self;
1023 text : "Send me a test copy"
1029 click : function (_self, e)
1031 _this.dialog.hide();
1040 click : function (_self, e)
1043 _this.form.preValidate(function(res) {
1047 _this.form.doAction("submit");