Flexmail.grid.Campaigns = function(config) {
config = config || {};
Ext.applyIf(config,{
id: 'flexmail-grid-campaigns'
,url: Flexmail.config.connectorUrl
,baseParams: { action: 'mgr/campaigns/getList' }
,fields: ['id','jobname','sourcedoc_id','createdon','modifiedon','send_end','msg_subj','msg_from','msg_replyto']
,paging: true
,remoteSort: true
,anchor: '97%'
,autoExpandColumn: 'name'
,columns: [{
header: _('flexmail.campaigns.label_jobname')
,dataIndex: 'jobname'
,sortable: false
,width: 150
,editor: { xtype: 'textfield' }
},{
header: _('flexmail.campaigns.label_sourceid')
,dataIndex: 'sourcedoc_id'
,sortable: true
,width: 90
},{
header: _('flexmail.campaigns.label_createdon')
,dataIndex: 'createdon'
,sortable: true
,width: 90
},{
header: _('flexmail.campaigns.label_modifiedon')
,dataIndex: 'modifiedon'
,sortable: true
,width: 90
},{
header: _('flexmail.campaigns.label_senton')
,dataIndex: 'send_end'
,sortable: true
,width: 90
}]
});
Flexmail.grid.Campaigns.superclass.constructor.call(this,config)
};
Ext.extend(Flexmail.grid.Campaigns,MODx.grid.Grid,{
getMenu: function(){
return [{
text: _('flexmail.campaigns.menu_edit')
,handler: this.editCampaign
},'-',{
text: _('flexmail.campaigns.menu_delete')
,handler: this.deleteCampaign
},'-',{
text: _('flexmail.campaigns.menu_duplicate')
,handler: this.duplicateCampaign
}];
}
,editCampaign: function(btn,e){
if(!this.editCampaignWindow){
this.editCampaignWindow = MODx.load({
xtype: 'flexmail-window-campaign-edit'
,record: this.menu.record
,listeners: {
'success': {fn:this.refresh,scope:this}
}
});
}
this.editCampaignWindow.setValues(this.menu.record);
this.editCampaignWindow.show(e.target);
}
});
Ext.reg('flexmail-grid-campaigns',Flexmail.grid.Campaigns);
Flexmail.window.editCampaign = function(config){
config = config || {};
Ext.applyIf(config,{
title: _('flexmail.campaigns.window_edit')
,url: Flexmail.config.connectorUrl
,baseParams: { action: 'mgr/campaigns/edit' }
,fields: [{
xtype: 'hidden'
,name: 'id'
},{
xtype: 'textfield'
,fieldLabel: _('flexmail.campaigns.label_jobname')
,name: 'jobname'
,anchor: '100%'
},{
xtype: 'textfield'
,fieldLabel: _('flexmail.campaigns.label_email_subject')
,name: 'msg_subj'
,anchor: '100%'
},{
xtype: 'textfield'
,fieldLabel: _('flexmail.campaigns.label_email_from_name')
,name: 'msg_from_name'
,anchor: '100%'
},{
xtype: 'textfield'
,fieldLabel: _('flexmail.campaigns.label_email_from_addr')
,name: 'msg_from_addr'
,anchor: '100%'
}]
});
Flexmail.window.editCampaign.superclass.constructor.call(this,config);
};
Ext.extend(Flexmail.window.editCampaign,MODx.Window);
Ext.reg('flexmail-window-campaign-edit',Flexmail.window.editCampaign);
public function prepareRow(xPDOObject $object) {
$objectArray = $object->toArray();
$objectArray['createdon'] = date('m/d/Y',$object->get('createdon'));
$objectArray['modifiedon'] = date('m/d/Y',$object->get('modifiedon'));
$sent = $object->get('send_end');
$objectArray['send_end'] = !empty($sent) ? date('m/d/Y',$sent) : 'Pending' ;
$msg_from = $object->get('msg_from');
$msg_from_arr = explode('|',$msg_from);
$objectArray['msg_from_name'] = count($msg_from_arr)==2 ? $msg_from_arr[1] : '' ;
$objectArray['msg_from_addr'] = $msg_from_arr[0];
return $objectArray;
}
This question has been answered by smg6511v2. See the first response.
<?php
/* parse JSON */
if (empty($scriptProperties['data'])) return $modx->error->failure('Invalid data.');
$_DATA = $modx->fromJSON($scriptProperties['data']);
if (!is_array($_DATA)) return $modx->error->failure('Invalid data.');
$msg_from = $_DATA['msg_from_addr'].'|'.$_DATA['msg_from_name'];
$object = $modx->getObject('yourObject');
$object->set('msgFrom',$msg_from);
$object->save();
public function beforeSave(){
$from_name = trim($this->getProperty('msg_from_name'));
$from_addr = trim($this->getProperty('msg_from_addr'));
$from = !empty($from_name) ? $from_addr.'|'.$from_name : $from_addr ;
$reply_name = trim($this->getProperty('msg_reply_name'));
$reply_addr = trim($this->getProperty('msg_reply_addr'));
$replyto = !empty($reply_name) ? $reply_addr.'|'.$reply_name : $reply_addr ;
$this->object->set('msg_from',$from);
$this->object->set('msg_replyto',$replyto);
$this->unsetProperty('msg_from_name');
$this->unsetProperty('msg_from_addr');
$this->unsetProperty('msg_reply_name');
$this->unsetProperty('msg_reply_addr');
return parent::beforeSave();
}