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.CrmImportURL.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.plain_preview.show();
245 _this.html_preview.show();
246 _this.preview_btn.show();
248 _this.plain_preview.hide();
249 _this.html_preview.hide();
250 _this.preview_btn.hide();
251 _this.form.setValues({
252 'from_name' : Pman.Login.authUser.name,
253 'from_email' : Pman.Login.authUser.email
258 if (action.type == 'load') {
259 _this.dialog.el.unmask();
262 if (action.type =='submit') {
264 _this.dialog.el.unmask();
267 if (_this.callback) {
268 _this.callback.call(_this, action.result.data);
274 rendered : function (form)
279 labelAlign : 'right',
282 style : 'margin:10px',
283 preValidate : function(done_callback) {
285 Roo.MessageBox.progress("Uploading Images", "Uploading");
286 var html = _this.form.findField('bodytext').getValue();
288 var s = Roo.get(_this.form.findField('bodytext').doc.documentElement);
291 s.select('img[src]').each(function(i) {
294 var total = nodes.length;
295 var mkimg = function() {
298 Roo.MessageBox.hide();
299 _this.form.findField('bodytext').syncValue();
301 // _this.form.doAction("submit");
305 var n = i.getAttribute('src').match(/^http(.*)/);
312 url : baseURL + '/Roo/Images.php',
315 onid : _this.form.findField('id').getValue(),
316 ontable : 'crm_mailing_list_message' ,
317 _remote_upload : i.src
319 success : function(res){
320 if(res.success == true){
321 i.setAttribute('src', res.data);
322 Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
331 url : baseURL + '/Roo/Crm_mailing_list_message.php',
341 fieldLabel : 'Mailout Name',
363 fieldLabel : 'Email address',
373 fieldLabel : 'Subject',
386 legend : "Html Editor",
387 style : 'text-align:center;',
435 xtype: 'ToolbarContext',
436 xns: Roo.form.HtmlEditor
439 xtype: 'ToolbarStandard',
440 xns: Roo.form.HtmlEditor,
446 render : function (_self)
448 _this.extendimgselect = _self;
450 select : function (combo, record, index)
456 var editor = _this.form.findField('bodytext');
457 editor.insertAtCursor(
458 String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
459 baseURL, record.data.id, record.data.filename
465 beforequery : function (combo, query, forceAll, cancel, e)
467 var id = _this.form.findField('id').getValue() * 1;
469 Roo.MessageBox.alert("Error", "Save press release first");
475 displayField : 'name',
477 emptyText : "Add Image",
478 fieldLabel : 'Images',
479 forceSelection : true,
481 loadingText : "Searching...",
484 qtip : "Select Images",
485 selectOnFocus : true,
486 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>',
487 triggerAction : 'all',
495 beforeload : function (_self, o){
496 o.params = o.params || {};
498 var id = _this.form.findField('id').getValue() * 1;
500 Roo.MessageBox.alert("Error", "Save press release first");
504 o.params.ontable = 'crm_mailing_list_message';
506 // o.params.imgtype = 'PressRelease';
507 //o.params['query[imagesize]'] = '150x150';
512 sortInfo : { direction : 'ASC', field: 'id' },
517 url : baseURL + '/Roo/Images.php'
524 totalProperty : 'total',
525 fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}]
533 render : function (_self)
535 _this.unsubscribeselect = _self;
537 select : function (combo, record, index)
543 var editor = _this.form.findField('bodytext');
545 if(record.data.name == 'Unsubscribe'){
546 editor.insertAtCursor(
547 String.format('<a href="{0}">{1}</a>',
548 record.data.type, record.data.name
554 editor.insertAtCursor(
563 displayField : 'name',
565 emptyText : "Insert Field",
566 fieldLabel : 'Field',
567 forceSelection : true,
569 loadingText : "Searching...",
572 qtip : "Insert Field",
573 selectOnFocus : true,
574 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
575 triggerAction : 'all',
580 xtype: 'SimpleStore',
583 [ '{person.firstname}', "First Name"],
584 [ '{person.lastname}' , "Last Name"],
585 [ '{person.name}', "Full Name"],
586 [ '#unsubscribe', "Unsubscribe"]
588 fields : [ 'type', 'name']
608 click : function (_self, e)
610 var h = _this.form.findField('bodytext').getValue();
611 var p = _this.form.findField('plaintext');
614 url : baseURL + '/Crm/ImportHtml.php',
\r
618 _convertToPlain : true,
619 _check_unsubscribe : true
\r
621 success : function(res) {
\r
622 if(res.success == true){
623 p.setValue(res.data);
630 text : "Convert Html to Text"
643 legend : "Plain Text",
644 style : 'text-align:center;',
667 xtype: 'LayoutRegion',
677 activate : function() {
680 _this.igrid.ds.load({});
689 tableName : 'Images',
690 title : "Images / Attachments",
698 //_this.dialog = Pman.Dialog.FILL_IN
699 if (_this.ipanel.active) {
700 // _this.igrid.ds.load({});
704 autoExpandColumn : 'filename',
710 beforeload : function (_self, options)
712 options.params = options.params || {};
713 if (typeof(_this.data) == 'undefined') {
716 if(_this.data.id * 1 >= 0)
718 options.params.onid = _this.data.id;
719 options.params.ontable = 'Crm_mailing_list_message';
724 sortInfo : { field : 'filename', direction: 'ASC' },
729 url : baseURL + '/Roo/Images.php'
734 totalProperty : 'total',
771 'name': 'displayorder',
779 'name': 'parent_image_id',
785 'dateFormat': 'Y-m-d'
804 'name': 'parent_image_id_id',
808 'name': 'parent_image_id_filename',
812 'name': 'parent_image_id_ontable',
816 'name': 'parent_image_id_onid',
820 'name': 'parent_image_id_mimetype',
824 'name': 'parent_image_id_width',
828 'name': 'parent_image_id_height',
832 'name': 'parent_image_id_filesize',
836 'name': 'parent_image_id_displayorder',
840 'name': 'parent_image_id_language',
844 'name': 'parent_image_id_parent_image_id',
848 'name': 'parent_image_id_created',
852 'name': 'parent_image_id_imgtype',
856 'name': 'parent_image_id_linkurl',
860 'name': 'parent_image_id_descript',
864 'name': 'parent_image_id_title',
880 Pman.Dialog.Image.show( { id : 0, onid: _this.data.id, ontable: 'crm_mailing_list_message' }, function() {
881 _this.igrid.getDataSource().load({});
885 cls : 'x-btn-text-icon',
887 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
895 var s = _this.igrid.getSelectionModel().getSelected();
896 if (!s || isNaN(s.id *1)) {
897 Roo.MessageBox.alert("Error", "Select a image");
900 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
906 url : baseURL + '/Roo/Images.php',
913 Roo.log('Got Success!!');
914 _this.igrid.ds.load({});
920 cls : 'x-btn-text-icon',
922 icon : rootURL + '/Pman/templates/images/trash.gif'
928 xtype: 'ColumnModel',
930 dataIndex : 'filename',
933 renderer : function(v,x,r)
935 return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
939 xtype: 'ColumnModel',
941 header : 'Displayorder',
943 dataIndex : 'displayorder',
944 renderer : function(v) { return String.format('{0}', v); }
947 xtype: 'ColumnModel',
952 renderer : function(v) { return String.format('{0}', v); }
959 xtype: 'LayoutRegion',
964 xtype: 'LayoutRegion',
968 title : "Images / Attachments",
977 click : function (_self, e)
979 //_this.dialog.hide();
981 Pman.Dialog.CrmMailingListMessagePreview.show({ id : _this.form.findField('id').getValue() });
983 render : function (_self)
985 _this.preview_btn = _self;
994 click : function (_self, e)
996 //_this.dialog.hide();
998 var id = _this.form.findField('id').getValue();
1001 Roo.MessageBox.alert('Error', 'Please select a queue to send');
1006 url : baseURL + '/Crm/MessagePreview',
1013 success : function(res) {
1014 if(res.data == 'SUCCESS'){
1015 Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
1020 render : function (_self)
1022 _this.html_preview = _self;
1025 text : "Send me a test copy"
1031 click : function (_self, e)
1033 _this.dialog.hide();
1042 click : function (_self, e)
1045 _this.form.preValidate(function(res) {
1049 _this.form.doAction("submit");