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)
179 _this.form.findField('bodytext').setValue(record.data.content);
185 displayField : 'file',
187 emptyText : "Select Template",
188 fieldLabel : 'Template',
189 forceSelection : true,
190 hiddenName : 'template',
192 loadingText : "Searching...",
196 qtip : "Select Template",
197 selectOnFocus : true,
198 tpl : '<div class="x-grid-cell-text x-btn button"><b>{file}</b> </div>',
199 triggerAction : 'all',
207 beforeload : function (_self, o){
208 o.params = o.params || {};
214 sortInfo : { direction : 'DESC', field: 'file' },
219 url : baseURL + '/Core/MailTemplateList.php'
226 totalProperty : 'total',
227 fields : [{"name":"file","type":"string"},{"name":"content","type":"string"}]
239 click : function (_self, e)
241 var el = _this.dialog.layout.getRegion('east');
251 text : "Images / Attachments >>"
256 xtype: 'BorderLayout',
260 xtype: 'ContentPanel',
263 render : function (_self, width, height)
266 Roo.log("RESIZE, " + width + ',' + height);
268 var ew = Math.max(250, width-50);
269 var eh = Math.max(250,height-50) ;
274 resize : function (_self, width, height)
\r
276 var ew = Math.max(250, width-50);
\r
277 var eh = Math.max(250,height-50) ;
282 var bdtext = _this.form.findField('bodytext');
\r
283 var ptext = _this.form.findField('plaintext');
\r
284 if(bdtext.resizeEl){
\r
285 bdtext.width = ew-50;
\r
286 bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height ] );
\r
287 ptext.setSize(bdtext.width , bdtext.height);
\r
303 actioncomplete : function(_self,action)
306 if (action.type == 'setdata') {
308 _this.data.module = _this.data.module || 'crm';
310 _this.form.url = baseURL + '/Roo/' + _this.data.module + '_mailing_list_message.php';
312 _this.html_preview.hide();
313 _this.preview_btn.hide();
315 if(_this.data.id*1 > 0){
316 _this.dialog.el.mask("Loading");
317 this.load({ method: 'GET', params: { '_id' : _this.data.id }});
318 if(_this.data.module == 'crm'){
319 _this.html_preview.show();
321 _this.preview_btn.show();
324 _this.form.setValues({
325 'from_name' : Pman.Login.authUser.name,
326 'from_email' : Pman.Login.authUser.email
331 if (action.type == 'load') {
332 _this.dialog.el.unmask();
335 if (action.type =='submit') {
337 _this.dialog.el.unmask();
340 if (_this.callback) {
341 _this.callback.call(_this, action.result.data);
347 rendered : function (form)
352 labelAlign : 'right',
355 style : 'margin:10px',
356 preValidate : function(done_callback) {
358 Roo.MessageBox.progress("Uploading Images", "Uploading");
359 var html = _this.form.findField('bodytext').getValue();
361 var s = Roo.get(_this.form.findField('bodytext').doc.documentElement);
363 var ontable = (_this.data.module) ? _this.data.module + '_mailing_list_message' : 'crm_mailing_list_message';
366 s.select('img[src]').each(function(i) {
369 var total = nodes.length;
370 var mkimg = function() {
373 Roo.MessageBox.hide();
374 _this.form.findField('bodytext').syncValue();
376 // _this.form.doAction("submit");
380 var n = i.getAttribute('src').match(/^http(.*)/);
387 url : baseURL + '/Roo/Images.php',
390 onid : _this.form.findField('id').getValue(),
392 _remote_upload : i.src
394 success : function(res){
395 if(res.success == true){
396 i.setAttribute('src', res.data);
397 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
406 url : baseURL + '/Roo/Core_mailing_list_message.php',
416 fieldLabel : 'Mailout Name',
438 fieldLabel : 'Email address',
448 fieldLabel : 'Subject',
461 legend : "Html Editor",
462 style : 'text-align:center;',
510 xtype: 'ToolbarContext',
511 xns: Roo.form.HtmlEditor
514 xtype: 'ToolbarStandard',
515 xns: Roo.form.HtmlEditor,
521 render : function (_self)
523 _this.extendimgselect = _self;
525 select : function (combo, record, index)
531 var editor = _this.form.findField('bodytext');
532 editor.insertAtCursor(
533 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
534 baseURL, record.data.id, record.data.filename
540 beforequery : function (combo, query, forceAll, cancel, e)
542 var id = _this.form.findField('id').getValue() * 1;
544 Roo.MessageBox.alert("Error", "Save message first");
550 displayField : 'name',
552 emptyText : "Add Image",
553 fieldLabel : 'Images',
554 forceSelection : true,
556 loadingText : "Searching...",
559 qtip : "Select Images",
560 selectOnFocus : true,
561 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>',
562 triggerAction : 'all',
570 beforeload : function (_self, o){
571 o.params = o.params || {};
573 var id = _this.form.findField('id').getValue() * 1;
575 Roo.MessageBox.alert("Error", "Save email template first");
579 o.params.ontable = 'core_mailing_list_message';
581 // o.params.imgtype = 'PressRelease';
582 //o.params['query[imagesize]'] = '150x150';
587 sortInfo : { direction : 'ASC', field: 'id' },
592 url : baseURL + '/Roo/Images.php'
599 totalProperty : 'total',
600 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
608 render : function (_self)
610 _this.unsubscribeselect = _self;
612 select : function (combo, record, index)
618 var editor = _this.form.findField('bodytext');
620 if(record.data.name == 'Unsubscribe'){
621 editor.insertAtCursor(
622 String.format('<a href="{0}">{1}</a>',
623 record.data.type, record.data.name
629 editor.insertAtCursor(
638 displayField : 'name',
640 emptyText : "Insert Field",
641 fieldLabel : 'Field',
642 forceSelection : true,
644 loadingText : "Searching...",
647 qtip : "Insert Field",
648 selectOnFocus : true,
649 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
650 triggerAction : 'all',
655 xtype: 'SimpleStore',
658 [ '{person.firstname}', "First Name"],
659 [ '{person.lastname}' , "Last Name"],
660 [ '{person.name}', "Full Name"],
661 [ '#unsubscribe', "Unsubscribe"]
663 fields : [ 'type', 'name']
683 click : function (_self, e)
685 var h = _this.form.findField('bodytext').getValue();
686 var p = _this.form.findField('plaintext');
689 url : baseURL + '/Core/ImportMailMessage.php',
\r
693 _convertToPlain : true,
694 _check_unsubscribe : true
\r
696 success : function(res) {
\r
697 if(res.success == true){
698 p.setValue(res.data);
705 text : "Convert Html to Text"
718 legend : "Plain Text",
719 style : 'text-align:center;',
742 xtype: 'LayoutRegion',
752 activate : function() {
755 _this.igrid.ds.load({});
764 tableName : 'Images',
765 title : "Images / Attachments",
773 //_this.dialog = Pman.Dialog.FILL_IN
774 if (_this.ipanel.active) {
775 // _this.igrid.ds.load({});
779 autoExpandColumn : 'filename',
785 beforeload : function (_self, options)
787 options.params = options.params || {};
788 if (typeof(_this.data) == 'undefined') {
791 if(_this.data.id * 1 >= 0)
793 options.params.onid = _this.data.id;
795 options.params.ontable = (_this.data.module) ? _this.data.module + '_mailing_list_message' : 'crm_mailing_list_message';
800 sortInfo : { field : 'filename', direction: 'ASC' },
805 url : baseURL + '/Roo/Images.php'
812 totalProperty : 'total',
847 'name': 'displayorder',
855 'name': 'parent_image_id',
861 'dateFormat': 'Y-m-d'
880 'name': 'parent_image_id_id',
884 'name': 'parent_image_id_filename',
888 'name': 'parent_image_id_ontable',
892 'name': 'parent_image_id_onid',
896 'name': 'parent_image_id_mimetype',
900 'name': 'parent_image_id_width',
904 'name': 'parent_image_id_height',
908 'name': 'parent_image_id_filesize',
912 'name': 'parent_image_id_displayorder',
916 'name': 'parent_image_id_language',
920 'name': 'parent_image_id_parent_image_id',
924 'name': 'parent_image_id_created',
928 'name': 'parent_image_id_imgtype',
932 'name': 'parent_image_id_linkurl',
936 'name': 'parent_image_id_descript',
940 'name': 'parent_image_id_title',
956 var id = _this.form.findField('id').getValue();
959 Roo.MessageBox.alert('Error', 'Please save the email template first');
963 var ontable = (_this.data.module) ? _this.data.module + '_mailing_list_message' : 'crm_mailing_list_message';
965 Pman.Dialog.Image.show( { id : 0, onid: id, ontable: ontable }, function() {
966 _this.igrid.getDataSource().load({});
970 cls : 'x-btn-text-icon',
972 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
980 var s = _this.igrid.getSelectionModel().getSelected();
981 if (!s || isNaN(s.id *1)) {
982 Roo.MessageBox.alert("Error", "Select a image");
985 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
991 url : baseURL + '/Roo/Images.php',
998 Roo.log('Got Success!!');
999 _this.igrid.ds.load({});
1005 cls : 'x-btn-text-icon',
1007 icon : rootURL + '/Pman/templates/images/trash.gif'
1013 xtype: 'ColumnModel',
1015 dataIndex : 'filename',
1016 header : 'Filename',
1018 renderer : function(v,x,r)
1020 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
1024 xtype: 'ColumnModel',
1026 header : 'Displayorder',
1028 dataIndex : 'displayorder',
1029 renderer : function(v) { return String.format('{0}', v); }
1032 xtype: 'ColumnModel',
1034 dataIndex : 'title',
1037 renderer : function(v) { return String.format('{0}', v); }
1044 xtype: 'LayoutRegion',
1049 xtype: 'LayoutRegion',
1053 title : "Images / Attachments",
1062 click : function (_self, e)
1064 //_this.dialog.hide();
1065 Roo.log(_this.data.module);
1066 Pman.Dialog.CoreMailingListMessagePreview.show({ id : _this.form.findField('id').getValue(), module : _this.data.module });
1068 render : function (_self)
1070 _this.preview_btn = _self;
1079 click : function (_self, e)
1081 //_this.dialog.hide();
1083 var id = _this.form.findField('id').getValue();
1086 Roo.MessageBox.alert('Error', 'Please save the message frist!');
1091 url : baseURL + '/Crm/MessagePreview',
1097 success : function(res) {
1098 if(res.data == 'SUCCESS'){
1099 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1104 render : function (_self)
1106 _this.html_preview = _self;
1109 text : "Send me a test copy"
1115 click : function (_self, e)
1117 _this.dialog.hide();
1126 click : function (_self, e)
1129 _this.form.preValidate(function(res) {
1133 _this.form.doAction("submit");