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)
167 Pman.Dialog.MailTemplateList.show({}, function(data){
171 var l = document.location;
174 url : baseURL + '/Crm/ImportHtml.php',
179 importUrl : l.protocol +'//' + l.host + rootURL + '/Pman/Crm/mail_templates/responsive1.html',
181 success : function (res) {
183 _this.form.findField('bodytext').setValue(res.data);
191 text : "Email Template"
204 click : function (_self, e)
206 var el = _this.dialog.layout.getRegion('east');
216 text : "Images / Attachments >>"
221 xtype: 'BorderLayout',
225 xtype: 'ContentPanel',
228 render : function (_self, width, height)
231 Roo.log("RESIZE, " + width + ',' + height);
233 var ew = Math.max(250, width-50);
234 var eh = Math.max(250,height-50) ;
239 resize : function (_self, width, height)
\r
241 var ew = Math.max(250, width-50);
\r
242 var eh = Math.max(250,height-50) ;
247 var bdtext = _this.form.findField('bodytext');
\r
248 var ptext = _this.form.findField('plaintext');
\r
249 if(bdtext.resizeEl){
\r
250 bdtext.width = ew-50;
\r
251 bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height ] );
\r
252 ptext.setSize(bdtext.width , bdtext.height);
\r
268 actioncomplete : function(_self,action)
271 if (action.type == 'setdata') {
272 // _this.loaded_data = _this.form.getValues();
274 if(_this.data.id*1 > 0){
275 _this.dialog.el.mask("Loading");
276 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
277 _this.html_preview.show();
278 _this.preview_btn.show();
280 _this.html_preview.hide();
281 _this.preview_btn.hide();
282 _this.form.setValues({
283 'from_name' : Pman.Login.authUser.name,
284 'from_email' : Pman.Login.authUser.email
289 if (action.type == 'load') {
290 _this.dialog.el.unmask();
293 if (action.type =='submit') {
295 _this.dialog.el.unmask();
298 if (_this.callback) {
299 _this.callback.call(_this, action.result.data);
305 rendered : function (form)
310 labelAlign : 'right',
313 style : 'margin:10px',
314 preValidate : function(done_callback) {
316 Roo.MessageBox.progress("Uploading Images", "Uploading");
317 var html = _this.form.findField('bodytext').getValue();
319 var s = Roo.get(_this.form.findField('bodytext').doc.documentElement);
322 s.select('img[src]').each(function(i) {
325 var total = nodes.length;
326 var mkimg = function() {
329 Roo.MessageBox.hide();
330 _this.form.findField('bodytext').syncValue();
332 // _this.form.doAction("submit");
336 var n = i.getAttribute('src').match(/^http(.*)/);
343 url : baseURL + '/Roo/Images.php',
346 onid : _this.form.findField('id').getValue(),
347 ontable : 'core_mailing_list_message' ,
348 _remote_upload : i.src
350 success : function(res){
351 if(res.success == true){
352 i.setAttribute('src', res.data);
353 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
362 url : baseURL + '/Roo/Core_mailing_list_message.php',
372 fieldLabel : 'Mailout Name',
394 fieldLabel : 'Email address',
404 fieldLabel : 'Subject',
417 legend : "Html Editor",
418 style : 'text-align:center;',
466 xtype: 'ToolbarContext',
467 xns: Roo.form.HtmlEditor
470 xtype: 'ToolbarStandard',
471 xns: Roo.form.HtmlEditor,
477 render : function (_self)
479 _this.extendimgselect = _self;
481 select : function (combo, record, index)
487 var editor = _this.form.findField('bodytext');
488 editor.insertAtCursor(
489 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
490 baseURL, record.data.id, record.data.filename
496 beforequery : function (combo, query, forceAll, cancel, e)
498 var id = _this.form.findField('id').getValue() * 1;
500 Roo.MessageBox.alert("Error", "Save email template first");
506 displayField : 'name',
508 emptyText : "Add Image",
509 fieldLabel : 'Images',
510 forceSelection : true,
512 loadingText : "Searching...",
515 qtip : "Select Images",
516 selectOnFocus : true,
517 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>',
518 triggerAction : 'all',
526 beforeload : function (_self, o){
527 o.params = o.params || {};
529 var id = _this.form.findField('id').getValue() * 1;
531 Roo.MessageBox.alert("Error", "Save press release first");
535 o.params.ontable = 'crm_mailing_list_message';
537 // o.params.imgtype = 'PressRelease';
538 //o.params['query[imagesize]'] = '150x150';
543 sortInfo : { direction : 'ASC', field: 'id' },
548 url : baseURL + '/Roo/Images.php'
555 totalProperty : 'total',
556 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
564 render : function (_self)
566 _this.unsubscribeselect = _self;
568 select : function (combo, record, index)
574 var editor = _this.form.findField('bodytext');
576 if(record.data.name == 'Unsubscribe'){
577 editor.insertAtCursor(
578 String.format('<a href="{0}">{1}</a>',
579 record.data.type, record.data.name
585 editor.insertAtCursor(
594 displayField : 'name',
596 emptyText : "Insert Field",
597 fieldLabel : 'Field',
598 forceSelection : true,
600 loadingText : "Searching...",
603 qtip : "Insert Field",
604 selectOnFocus : true,
605 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
606 triggerAction : 'all',
611 xtype: 'SimpleStore',
614 [ '{person.firstname}', "First Name"],
615 [ '{person.lastname}' , "Last Name"],
616 [ '{person.name}', "Full Name"],
617 [ '#unsubscribe', "Unsubscribe"]
619 fields : [ 'type', 'name']
639 click : function (_self, e)
641 var h = _this.form.findField('bodytext').getValue();
642 var p = _this.form.findField('plaintext');
645 url : baseURL + '/Crm/ImportHtml.php',
\r
649 _convertToPlain : true,
650 _check_unsubscribe : true
\r
652 success : function(res) {
\r
653 if(res.success == true){
654 p.setValue(res.data);
661 text : "Convert Html to Text"
674 legend : "Plain Text",
675 style : 'text-align:center;',
698 xtype: 'LayoutRegion',
708 activate : function() {
711 _this.igrid.ds.load({});
720 tableName : 'Images',
721 title : "Images / Attachments",
729 //_this.dialog = Pman.Dialog.FILL_IN
730 if (_this.ipanel.active) {
731 // _this.igrid.ds.load({});
735 autoExpandColumn : 'filename',
741 beforeload : function (_self, options)
743 options.params = options.params || {};
744 if (typeof(_this.data) == 'undefined') {
747 if(_this.data.id * 1 >= 0)
749 options.params.onid = _this.data.id;
750 options.params.ontable = 'core_mailing_list_message';
755 sortInfo : { field : 'filename', direction: 'ASC' },
760 url : baseURL + '/Roo/Images.php'
767 totalProperty : 'total',
802 'name': 'displayorder',
810 'name': 'parent_image_id',
816 'dateFormat': 'Y-m-d'
835 'name': 'parent_image_id_id',
839 'name': 'parent_image_id_filename',
843 'name': 'parent_image_id_ontable',
847 'name': 'parent_image_id_onid',
851 'name': 'parent_image_id_mimetype',
855 'name': 'parent_image_id_width',
859 'name': 'parent_image_id_height',
863 'name': 'parent_image_id_filesize',
867 'name': 'parent_image_id_displayorder',
871 'name': 'parent_image_id_language',
875 'name': 'parent_image_id_parent_image_id',
879 'name': 'parent_image_id_created',
883 'name': 'parent_image_id_imgtype',
887 'name': 'parent_image_id_linkurl',
891 'name': 'parent_image_id_descript',
895 'name': 'parent_image_id_title',
911 var id = _this.form.findField('id').getValue();
914 Roo.MessageBox.alert('Error', 'Please save the email template first');
918 Pman.Dialog.Image.show( { id : 0, onid: _this.data.id, ontable: 'core_mailing_list_message' }, function() {
919 _this.igrid.getDataSource().load({});
923 cls : 'x-btn-text-icon',
925 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
933 var s = _this.igrid.getSelectionModel().getSelected();
934 if (!s || isNaN(s.id *1)) {
935 Roo.MessageBox.alert("Error", "Select a image");
938 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
944 url : baseURL + '/Roo/Images.php',
951 Roo.log('Got Success!!');
952 _this.igrid.ds.load({});
958 cls : 'x-btn-text-icon',
960 icon : rootURL + '/Pman/templates/images/trash.gif'
966 xtype: 'ColumnModel',
968 dataIndex : 'filename',
971 renderer : function(v,x,r)
973 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
977 xtype: 'ColumnModel',
979 header : 'Displayorder',
981 dataIndex : 'displayorder',
982 renderer : function(v) { return String.format('{0}', v); }
985 xtype: 'ColumnModel',
990 renderer : function(v) { return String.format('{0}', v); }
997 xtype: 'LayoutRegion',
1002 xtype: 'LayoutRegion',
1006 title : "Images / Attachments",
1015 click : function (_self, e)
1017 //_this.dialog.hide();
1019 Pman.Dialog.CrmMailingListMessagePreview.show({ id : _this.form.findField('id').getValue() });
1021 render : function (_self)
1023 _this.preview_btn = _self;
1032 click : function (_self, e)
1034 //_this.dialog.hide();
1036 var id = _this.form.findField('id').getValue();
1039 Roo.MessageBox.alert('Error', 'Please select a queue to send');
1044 url : baseURL + '/Crm/MessagePreview',
1051 success : function(res) {
1052 if(res.data == 'SUCCESS'){
1053 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1058 render : function (_self)
1060 _this.html_preview = _self;
1063 text : "Send me a test copy"
1069 click : function (_self, e)
1071 _this.dialog.hide();
1080 click : function (_self, e)
1083 _this.form.preValidate(function(res) {
1087 _this.form.doAction("submit");