
var Settings=new Application.Module({title:'My account',name:'settings',isHaveOverview:false,showMain:function(){Preferences.init().showMain();},initParams:function(){Sessions.init({section:'settings'});},showSessions:function(){Sessions.showMain();}});var Sessions=new Application.Module({title:'Your access sessions',parentModule:Settings,name:'settings-sessions',initParams:function(){this.rd=[{name:'id'},{name:'created_at',type:'date',dateFormat:app.conf.dtFormat},{name:'country'},{name:'user_agent'},{name:'remote_address'}];this.cm=[new Ext.grid.CheckboxSelectionModel(),{header:"Logged At",dataIndex:'created_at',width:200,renderer:dtRenderer},{header:"IP Address",dataIndex:'remote_address',width:100},{header:"Country",dataIndex:'country',width:200}];},initFilters:function(){return[new Ext.form.DateField({hiddenName:'from_at',labelName:'From date',width:100}),new Ext.form.DateField({hiddenName:'to_at',labelName:'To date',width:100})];},showMain:function(){this.showFilteredGrid({isHaveEdit:false,isHaveDelete:false,pagerUrl:makeUrl('settings','getSessionsPager'),sortInfo:{field:"created_at",direction:"DESC"},summary:'user_agent'});}});SettingsWizard=function(){this.store=new Ext.data.Store({url:makeUrl('wizards','getSettings'),autoLoad:false,reader:new Ext.data.JsonReader({},['email','password','time_format','date_format','currency_id','currency','page_size','timezone','tz_id','beats_ids','beats','countries_ids','countries','permission_edit','permission_type',{name:'is_show_my_beats',type:'bool'}])});var pageSizeStore=new Ext.data.SimpleStore({fields:['value'],data:[['5'],['10'],['20'],['50'],['100'],['200'],['500'],['1000']]});var config={title:'Your settings',width:800,height:(Ext.getBody().getSize().height-100),cls:'wiz',headerConfig:{title:'<div class="sprite sprite-tools">&nbsp;</div><h1>Your settings</h1>'},cardPanelConfig:{defaults:{baseCls:'x-small-editor',bodyStyle:'padding:20px',border:false,autoScroll:true}},store:this.store,open:function(){this.store.on('load',function(grid,records,options){this.data=records[0].data;this.show();Ext.each(this.cards,function(c){c.getForm().setValues(this.data);},this);},this);this.store.load();},onNextClick:function(){if(this.currentCard==this.cards.length-2){var data={};Ext.each(this.cards,function(e,i){if(i>0&&e.form){Ext.apply(data,e.form.getFieldValues());}});this.cards[0].form.submit({url:makeUrl('wizards','updateSettings'),params:Ext.apply(data,{}),success:function(form,action){msg('Notification',action.result.info);this.cardPanel.getLayout().setActiveItem(this.currentCard+1);},failure:function(form,action){var errorStr='';Ext.each(action.result.errors,function(f){if(f.msg!=undefined){errorStr+='<br/><b>'+f.id+'</b>: '+f.msg;}});Ext.MessageBox.alert('Error Message',action.result.errorInfo+errorStr);},scope:this});}else{if(this.currentCard==this.cardCount-1){this.onFinish();}else{this.cardPanel.getLayout().setActiveItem(this.currentCard+1);}}},cards:[new Ext.ux.Wiz.Card({title:'Log-in details',monitorValid:true,labelAlign:'top',autoScroll:true,defaults:{labelSeparator:''},items:[{cls:'title pb20',html:'Please add your basic details and press \'Next\' at the bottom of this page'},{name:'email',fieldLabel:'Email',xtype:'textfield',itemCls:'label',allowBlank:false},{cls:'note',html:'Your primary email is used to log you into service and is where you will receive notifications and system emails<hr>'},{fieldLabel:'Password',name:'password',xtype:'textfield',itemCls:'label'},{fieldLabel:'Confirm Password',name:'password_confirm',xtype:'textfield',itemCls:'label'},{cls:'note',html:'Only fill in these password fields if you wish to change your password'}]}),new Ext.ux.Wiz.Card({title:'Site Settings',monitorValid:true,labelAlign:'top',defaults:{xtype:'panel',labelSeparator:''},autoScroll:true,items:[{cls:'title pb20',html:'and press \'Next\' at the bottom of this page'},{fieldLabel:'Personalise site?',itemCls:'label',xtype:'checkbox',name:'is_show_my_beats',inputValue:'1'},{cls:'note',html:'If you tick this box then you will see only information pertaining to your selected beats and countries. If this box unticked you will see information pertining  to all media across all beats<hr>'},getComboOptions({store:pageSizeStore,fieldLabel:'Table size',allowBlank:false,hiddenName:'page_size',valueField:'value',itemCls:'label'}),{cls:'note',html:'This option sets the number of rows that will be loaded into tables by default. If you have slow internet connection and you want to speed up how quickly the first set of tables rows load then decrease the number of rows. If you have fast connection you might want to increase the number of rows shown to reduce the number of times you have to page thru a table set'}]}),new Ext.ux.Wiz.Card({title:'Regional settings',monitorValid:true,labelAlign:'top',defaults:{labelSeparator:''},items:[{cls:'title pb20',html:' and press \'Next\' at the bottom of this page'},getRemoteComboOptions(makeUrl('settings','getDateFormats'),{fieldLabel:'Date format',itemCls:'label',allowBlank:false,hiddenName:'date_format'}),{html:'<hr>'},getRemoteComboOptions(makeUrl('settings','getTimeFormats'),{fieldLabel:'Time format',itemCls:'label',allowBlank:false,hiddenName:'time_format'}),{html:'<hr>'},prepareComboBox(makeUrl('settings','getCurrencyTypes'),{fieldLabel:'Currency',itemCls:'label',allowBlank:false,hiddenName:'currency_id'}),{html:'<hr>'},prepareComboBox(makeUrl('settings','getTimezones'),{fieldLabel:'Timezone',itemCls:'label',hiddenName:'tz_id'})]}),new Ext.ux.Wiz.Card({title:'Beats settings',monitorValid:true,items:[{cls:'title pb20',html:'Please tick the beats that are relevant to you. These selections can be used to show only the information relevant to you'},{xtype:'checkboxespanel',name:'beats_ids',objType:'beats',height:400,width:400,autoScroll:true,layout:'fit'}],listeners:{'show':{fn:function(){this.doLayout();}}}}),new Ext.ux.Wiz.Card({title:'Countries settings',monitorValid:true,items:[{cls:'title pb20',html:'Please tick the countries that are relevant to you. These selections can be used to show only the information relevant to you'},{xtype:'checkboxespanel',name:'countries_ids',objType:'countries',height:500,width:400,layout:'fit'}],listeners:{'show':{fn:function(){this.doLayout();}}}}),new Ext.ux.Wiz.Card({title:'Permissions',monitorValid:true,labelAlign:'top',defaults:{labelSeparator:''},items:[{cls:'title pb20',html:'Please set your permission options and then press \'Save and Finish\' at bottom of this page'},getComboOptions({fieldLabel:'View permission',hiddenName:"permission_type",itemCls:'label',store:new Ext.data.SimpleStore({fields:['id','value'],data:[['Hidden','Hidden'],['Private','Private'],['Public','Public'],['Journos','Journos'],['Clients','Clients']]}),value:'Private'}),{cls:'note',html:'This option defines who can see your profile. Team means your profile is not visible to users outside of your account. If you do not wish for others in the PR/bisiness commmunity to see your profile, set it to journalist or leave it at default setting of public so it can be seen by all.<hr>'},getComboOptions({fieldLabel:'Edit permission',hiddenName:"permission_edit",itemCls:'label',store:new Ext.data.SimpleStore({fields:['id','value'],data:[['Me','Me'],['Account','Account'],['All','All']]}),value:'Me'}),{cls:'note',html:'This option defines who can edit your profile. If you do not wish for anyone else to edit your account then select \'Me\'. If you wish to enable other users in your account to update your profile, select shared while All will allow your profile to be edited Wiki-style by any one in the community<hr>'}]}),new Ext.ux.Wiz.Card({title:'Next Steps',monitorValid:true,items:[{border:false,cls:'title pb20',html:'Congratulations! You have now set your basic preferences'}]})]};SettingsWizard.superclass.constructor.call(this,config);}
Ext.extend(SettingsWizard,Ext.ux.Wiz,{});ProfileWizard=Ext.extend(Ext.ux.Wiz,{initComponent:function(){Ext.apply(this,this.initialConfig);this.store=new Ext.data.JsonStore({url:makeUrl('wizards','getProfile'),autoLoad:false,fields:['id','contact_id','first_name','last_name','fullname','company','company_id','job_title','emails','phones','websites','ims','messengers','addresses','summary','expertise','responsibilities','experiences','tips','blogs','beats_ids','permission_type','permission_edit','title','image_id','image_url_original','image_url_big','contactsString','tags','tags_ids','tag_links','module','rate','twitterAccount','twitterPassword','roles','roles_ids','profile','main_email',{name:'is_editable',type:'bool'},{name:'is_journo',type:'bool'},{name:'isFacebookStatusSync',type:'bool'},{name:'twitterIsUpdateStatus',type:'bool'},{name:'facebookIsUpdateStatus',type:'bool'}]});var logoViewTpl=new Ext.XTemplate('<tpl for=".">','<div class="x-form-item">','<tpl if="image_id">','<div style="float: left; padding: 2px;"><img onclick="showPreviewImageDialog(\'{image_url_original}\', \'\', \'\')" src="{image_url_big}" style="float:left"/>','<a id="wizard_profile_delete_logo_{contact_id}" style="float:left; padding-left: 20px">Delete</a></div>','</tpl>','<tpl if="!image_id">','<div style="float: left; padding: 2px;">no image uploaded yet</div>','</tpl>','</div>','<div class="x-clear"></div>','</tpl>');var config={title:'User profile wizard',width:800,height:(Ext.getBody().getSize().height-100),cls:'wiz',headerConfig:{title:'<div class="sprite sprite-contact">&nbsp;</div><h1>Your profile</h1>'},cardPanelConfig:{defaults:{baseCls:'x-small-editor',bodyStyle:'padding:20px',border:false,autoScroll:true}},cards:[new Ext.ux.Wiz.Card({title:'User details',xtype:'wizard-card',monitorValid:true,labelAlign:'top',fileUpload:true,autoScroll:true,defaults:{xtype:'panel',labelSeparator:'',allowBlank:false},items:[{cls:'title pb20',html:'Please add your basic details and upload picture of yourself then press \'Next\' at the bottom of the page'},{name:'first_name',fieldLabel:'First name',xtype:'textfield',itemCls:'label'},{name:'last_name',fieldLabel:'Surname',xtype:'textfield',itemCls:'label'},{html:'<hr>'},{name:'main_email',itemCls:'big',xtype:'textfield',vtype:'email',fieldLabel:'Email'},{cls:'note',html:'Any email you send via this site will be sent using this email<hr>'},{name:'job_title',itemCls:'big',xtype:'textfield',fieldLabel:'Job Title'},{cls:'note',html:'Please include your organisation in your job title; ie CEO, Acme Corp.<hr>'},{fieldLabel:"Your picture",name:"uploadFile",itemCls:'big',allowBlank:true,xtype:'fileuploadfield',width:250},{cls:'note',html:'Click the browse button to select a file and then press \'Next\' at the bottom of this page. Your image will be automatically uploaded on wizard save.'},{xtype:'dataview',store:this.store,tpl:logoViewTpl,autoHeight:true,itemSelector:'div.x-form-item'}]}),new Ext.ux.Wiz.Card({title:'Contact details',monitorValid:true,defaults:{xtype:'panel',labelSeparator:''},listeners:{'show':{fn:function(){this.suspendEvents();Ext.each(this.findByType('dyn-panel'),function(c){c.setFirstTime(this.ownerCt.ownerCt.data);},this);this.resumeEvents();this.doLayout();}}},items:[{xtype:'panel',cls:'note',html:''},{xtype:'panel',cls:'big',html:'Additional Email Addresses'},this.emailsPanel=new DynamicFieldsPanel({fields:[{fieldLabel:'Email',hideLabel:true,name:'email[]'}],fieldSetCfg:{panelCls:'addedPanelEmpty'},addNote:'If you use any additional email addresses to your main email address, please click the Add button',set:function(obj){try{if(!obj.emails.length){this.appendField();}
Ext.each(obj.emails,function(n){this.appendField([n.email]);},this);}catch(e){this.appendField();}}}),{html:'<hr>'},{cls:'big',html:'Phones'},this.phonesPanel=new DynamicFieldsPanel({fields:[{hideLabel:true,fieldLabel:'Phone',name:'phone[]',anchor:'absolute',width:120},getComboOptions({width:80,anchor:'absolute',hideLabel:true,fieldLabel:'Type',hiddenName:"phoneType[]",store:app.ds.phoneTypes,value:405})],fieldSetCfg:{panelCls:'addedPanelEmpty',layout:'hbox'},addNote:'You may add multiple contact numbers by clicking the Add button',set:function(obj){try{if(!obj.phones.length){this.appendField();}
Ext.each(obj.phones,function(n){this.appendField([n.phone,n.type_id]);},this);}catch(e){this.appendField();}}}),{html:'<hr>'},{cls:'big',html:'Websites & Online Services'},new DynamicFieldsPanel({fields:[{hideLabel:true,fieldLabel:'Website',vtype:'svurl',name:'url[]',width:220},getComboOptions({width:80,hideLabel:true,fieldLabel:'Type',hiddenName:"websiteType[]",store:app.ds.websiteTypes,value:502})],fieldSetCfg:{panelCls:'addedPanelEmpty',layout:'hbox'},addNote:'Click the Add button to include websites, blogs, Twitter feeds, etc.',set:function(obj){try{if(!obj.websites.length){this.appendField();}
Ext.each(obj.websites,function(n){this.appendField([n.url,n.type_id]);},this);}catch(e){this.appendField();}}}),{html:'<hr>'},{html:'IMs',cls:'big'},new DynamicFieldsPanel({fields:[{hideLabel:true,fieldLabel:'Messenger id',name:'im[]',width:140},getComboOptions({width:80,hideLabel:true,fieldLabel:'Account Type',hiddenName:"imAccountType[]",store:app.ds.imTypes}),getComboOptions({width:80,hideLabel:true,fieldLabel:'Type',hiddenName:"messengerType[]",store:app.ds.imAccountTypes,value:702})],fieldSetCfg:{panelCls:'addedPanelEmpty',layout:'hbox'},addNote:'Click the Add button to include addresses from multiple instant messaging services',set:function(obj){try{if(!obj.messengers.length){this.appendField();}
Ext.each(obj.messengers,function(n){this.appendField([n.im,n.type_id,n.im_type_id]);},this);}catch(e){this.appendField();}}}),{html:'<hr>'},{html:'Addresses',cls:'big'},new DynamicFieldsPanel({fields:[{fieldLabel:'Street',name:'street[]',preventScrollbars:true},{fieldLabel:'City',name:'city[]'},{fieldLabel:'State',name:'state[]'},{fieldLabel:'Zip',name:'zip[]'},getComboOptions({fieldLabel:'Country',hiddenName:"countryId[]",store:app.ds.countries}),getComboOptions({fieldLabel:'Type',hiddenName:"typeId[]",store:app.ds.addressTypes,value:801})],addNote:'Click the Add button to include multiple address locations',set:function(obj){try{if(!obj.addresses.length){this.appendField();}
Ext.each(obj.addresses,function(n){this.appendField([n.street,n.city,n.state,n.zip,n.country_id,n.type_id]);},this);}catch(e){this.appendField();}}})]}),new Ext.ux.Wiz.Card({title:'Biography',monitorValid:true,defaults:{xtype:'panel',labelSeparator:''},autoScroll:true,items:[{cls:'title pb20',html:'Use your profile to describe what you do and your experience and press \'Next\''},{xtype:'htmleditor',width:740,hideLabel:true,name:'profile',height:200}]}),new Ext.ux.Wiz.Card({title:'Roles and Responsibilities',monitorValid:true,listeners:{'show':{fn:function(){this.suspendEvents();Ext.each(this.findByType('dyn-panel'),function(c){c.setFirstTime(this.ownerCt.ownerCt.data);},this);this.resumeEvents();this.doLayout();}}},items:[{border:false,cls:'title pb20',html:'For each company you work with please add a responsibility. For example, if you are a PR consultant working on multiple client accounts, please add yourself as a PR representative for each of those clients.'},new DynamicFieldsPanel({fieldSetCfg:{labelWidth:160,panelCls:'addedPanelHr'},fields:[{name:"relation_type_id[]",value:2501,hidden:true,labelSeparator:"",height:0},{fieldLabel:"Role Title",name:"relation_role_title[]"},getRemoteComboOptions(makeUrl("contacts","getOrganisationOptions"),{fieldLabel:'Outlet/Organisation',hiddenName:"relation_relation_id[]"}),{xtype:'select',fieldLabel:'Roles',hiddenName:'relation_role_ids[]',store:app.ds.personRoleTypes,valueField:'id',displayField:'value',triggerAction:'all',mode:'local',multiSelect:true},{fieldLabel:'Is media contact',xtype:'checkbox',name:'relation_is_mediacontact[]',inputValue:'1'}],addNote:'Click the Add button to add additional roles and responsibilities',set:function(obj){try{if(!obj.responsibilities.length){this.appendField();}
Ext.each(obj.responsibilities,function(n){this.appendField([2501,n.role_title,[n.relation_id,n.related],n.role_ids,n.is_mediacontact]);},this);}catch(e){this.appendField();}}})]}),new Ext.ux.Wiz.Card({title:'Experience',monitorValid:true,listeners:{'show':{fn:function(){this.suspendEvents();Ext.each(this.findByType('dyn-panel'),function(c){c.setFirstTime(this.ownerCt.ownerCt.data);},this);this.resumeEvents();this.doLayout();}}},items:[{border:false,cls:'title pb20',html:'Please add an item for each of your past jobs'},new DynamicFieldsPanel({fields:[{fieldLabel:"Role Title",name:"experience_role[]"},getRemoteComboOptions(makeUrl("contacts","getOrganisationOptions"),{fieldLabel:'Employer',name:"experience_contact[]",typeAhead:true,forceSelection:true}),getComboOptions({store:app.ds.yearsStore,fieldLabel:'Start Year',valueField:'value',name:"experience_begin_year[]"}),getComboOptions({store:app.ds.yearsStore,fieldLabel:'End Year',valueField:'value',name:"experience_end_year[]"}),{fieldLabel:"Description",name:"experience_description[]"}],addNote:'Click the Add button to add multiple past roles',set:function(obj){try{if(!obj.experiences.length){this.appendField();}
Ext.each(obj.experiences,function(n){this.appendField([n.role,[n.contact_id,n.contact],n.begin_year,n.end_year,n.description]);},this);}catch(e){this.appendField();}}})]}),new Ext.ux.Wiz.Card({title:'Next Steps',monitorValid:true,items:[{border:false,cls:'title pb20',html:'Congratulations! You have now set up your profile. You may now continue on to set up your account, settings and preferences.'},this.overviewView=new Ext.DataView({store:{xtype:'jsonstore',url:makeUrl('wizards','getProfileData'),autoLoad:false,fields:['prefs','feeds','homePages','streams']},tpl:['<tpl for=".">','<div class="finish"><div class="sprite sprite-tools">&nbsp;</div><div class="desc"><h1>Account setup</h1><span class="note">Click <a href=# onclick="ProfileEditWizard.close(); new SettingsWizard().open();">here</a> to set up your account-wide settings and preferences</span><br>','<tpl if="prefs!=0">','<span style="">You have previously setup your settings</span>','</tpl>','<tpl if="prefs==0">','<span style="color: #f00">You have not yet setup your account preferences and settings</span>','</tpl>','</div></div>',app.isHaveModule('reader')?['<hr size=1 class="hr"/><div class="finish"><div class="sprite sprite-lists">&nbsp;</div><div class="desc"><h1>Reading lists</h1><span class="note">Click <a href=# onclick="ProfileEditWizard.close();Reader.init().showOverview();">here</a> to personalise your reader by adding or removing feeds</span><br>','<tpl if="feeds!=0">','<span style="">You currently are reading {feeds} feeds</span>','</tpl>','<tpl if="feeds==0">','<span style="color: #f00">You have not yet setup reading feeds</span>','</tpl>','</div></div>'].join(''):'',app.isHaveModule('dashboards')?['<hr size=1 class="hr"/><div class="finish"><div class="sprite sprite-dashboards">&nbsp;</div><div class="desc"><h1>Home pages</h1><span class="note">Click <a href=# onclick="ProfileEditWizard.close();Dashboards.init().showMain();">here</a> to personalise your homepage or add new dashboards</span><br>','<tpl if="homePages!=0">','<span style="">You currently have {homePages} dashboards</span>','</tpl>','<tpl if="homePages==0">','<span style="color: #f00">You have not yet setup dashboards</span>','</tpl>','</div></div>'].join(''):'',app.isHaveModule('streams')?['<hr size=1 class="hr"/><div class="finish"><div class="sprite sprite-stream">&nbsp;</div><div class="desc"><h1>Streams</h1><span class="note">Click <a href=# onclick="ProfileEditWizard.close();Streams.init().showOverview();">here</a> to add your Twitter or Facebook feeds</span><br>','<tpl if="streams!=0">','<span style="">You currently have setup twitter/facebook feed</span>','</tpl>','<tpl if="streams==0">','<span style="color: #f00">You have not yet imported any streams</span>','</tpl>','</div></div>'].join(''):'','</tpl>'],loadingText:'Loading',autoHeight:true,multiSelect:true,overClass:'x-view-over',autoWidth:true,itemSelector:'div.thumb-wrap'})]})]};Ext.apply(this,config);ProfileWizard.superclass.initComponent.apply(this);},open:function(){this.store.on('load',function(grid,records,options){this.data=records[0].data;this.show();Ext.each(this.cards,function(card){card.getForm().setValues(this.data);card.isShown=false;},this);if(Ext.get('wizard_profile_delete_logo_'+this.data.contact_id)){Ext.get('wizard_profile_delete_logo_'+this.data.contact_id).addListener('click',function(){Ext.MessageBox.confirm('Message','Do you really want to delete?',function(btn,text){if(btn=='yes'){sendJsonRequest(makeUrl('contacts','deleteImage'),{contactId:this.data.contact_id},function(){Ext.get('wizard_profile_delete_logo_'+app.conf.user.contact_id).parent().update('');});}},this);},this);}},this);this.store.load();},onNextClick:function(){if(this.currentCard==this.cards.length-2){var data={};Ext.each(this.cards,function(e,i){if(i>0&&e.form){Ext.apply(data,e.form.getValues(false));}});var i=0;var isValid=true;var errors=new Array();while(data['street['+i+']']){if(data['street['+i+']'].length){if(!data['countryId['+i+']']){errors.push('Please specify country for address #'+(i+1)+' on step 2');isValid=false;}}
i++;}
if(!isValid){Ext.MessageBox.alert('Error Message',errors.join('<br>'));}else{this.cards[0].form.submit({url:makeUrl('wizards','updateProfile'),params:data,clientValidation:true,success:function(form,action){msg('Notification',action.result.info);this.overviewView.store.reload();this.cardPanel.getLayout().setActiveItem(this.currentCard+1);},failure:function(form,action){var errorStr='';Ext.each(action.result.errors,function(f){if(f.msg!=undefined){errorStr+='<br/><b>'+f.id+'</b>: '+f.msg;}});Ext.MessageBox.alert('Please fix following errors and resubmit',action.result.errorInfo+errorStr);},scope:this});}}else{if(this.currentCard==this.cardCount-1){this.onFinish();}else{this.cardPanel.getLayout().setActiveItem(this.currentCard+1);}}}});var Preferences=new Application.Module({title:'Preferences',loadUrl:makeUrl('settings','load'),dialogTitle:'Update User Account Details',parentModule:Settings,itemTitle:'settings',name:'settings',overviewFields:['name','email','account_name','image_url','job_title','emails','addresses','websites','phones','messengers','beats','countries','timezone','currency','date_format','time_format','page_size','email_preference_str','is_send_newsletter','opportunities_beats_ids','opportunities_beats'],overviewUrl:makeUrl('settings','getOverviewData'),overviewTpl:new Ext.XTemplate('<tpl for=".">','<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr valign="top">','<td width="50%">','<div class="overview-container">','<div class="block-title sprite sprite-tools"><h1>Login Details</h1><a href=# class="see-more" onclick="Preferences.edit(); return false;">Edit</a><hr></div>','<div class="updates-item">','<div class="overview-bold pt10">Email:</div><div class="fl pt10">{email}</div><div class="x-clear"></div>','<div class="overview-bold pt10">Password:</div><div class="fl pt10">********</div><div class="x-clear"></div>','<div class="overview-bold pt10">Account:</div><div class="fl pt10">{account_name}</div><div class="x-clear"></div>','</div>','</div>','<div class="overview-container">','<div class="block-title sprite sprite-contact"><h1>Profile Overview</h1><a href=# class="see-more" onclick="Preferences.edit(); return false;">Edit</a><hr></div>','<div class="updates-item">','<table cellpadding=0 cellspacing=0 border=0><tr valign="top" width="100%">','<td width="120px"><img src="{image_url}"></td>','<td><b>{name}</b><div class="clip-details">{job_title}</div>','<tpl if="emails">','<table cellpadding=0 cellspacing=0 border=0><tr valign="top" width="100%"><tr valign="top"><td width="20px"><div class="icon icon-email"></div></td><td style="padding-bottom: 5px">','<tpl for="emails"><a href="mailto:{contact_email}">{email}</a><br></tpl>','</td></tr></table>','</tpl>','<tpl if="phones">','<table cellpadding=0 cellspacing=0 border=0><tr valign="top" width="100%"><tr valign="top"><td width="20px"><div class="icon icon-phone"></div></td><td style="padding-bottom: 5px">','<tpl for="phones">{type}: {phone} </tpl>','</td></tr></table>','</tpl>','<tpl if="websites">','<table cellpadding=0 cellspacing=0 border=0><tr valign="top" width="100%"><tr valign="top"><td width="20px"><div class="icon icon-online"></div></td><td style="padding-bottom: 5px">','<tpl for="websites"><a href="{url}" target="_blank">{url}</a><br></tpl>','</td></tr></table>','</tpl>','<tpl if="addresses">','<table cellpadding=0 cellspacing=0 border=0><tr valign="top" width="100%"><tr valign="top"><td width="20px"><div class="icon icon-address"></div></td><td style="padding-bottom: 5px">','<tpl for="addresses">{address}<br></tpl>','</td></tr></table>','</tpl>','</td>','</tr></table>','</div>','</div>','<div class="overview-container tools-block">','<div class="block-title sprite sprite-inbox"><h1>Emails & Notifications</h1><a href=# class="see-more" onclick="Preferences.edit(); return false;">Edit</a><hr/></div>','<div class="updates-item">','<div class="updates-item">','<div class="overview-bold pt10" style="width: 140px;">Receive Newsletter:</div><div class="fl pt10">{is_send_newsletter:booleanRenderer}</div><div class="x-clear"></div>','<div class="overview-bold pt10" style="width: 140px;">Opportunities beats:</div><div class="fl pt10">{opportunities_beats}</div><div class="x-clear"></div>','</div>','</div>','</div>','</td><td>','<div class="overview-container tools-block">','<div class="block-title sprite sprite-tools"><h1>Tools & Assistance</h1><hr/></div>','<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-add"></div><a href=# onclick="return false;" class="title">Need help?</a></div>','<div class="summary"><b>For Help & Support: </b>MediaConnect Australia (02) 9894 6277<div class="pt10"><b>Company Administrator: </b>Philip Sim (02) 9894 6277</div></div>','</div>','</div>','<div class="overview-container tools-block">','<div class="block-title sprite sprite-tools"><h1>Follow Details</h1><a href=# class="see-more" onclick="Preferences.edit(); return false;">Edit</a><hr/></div>','<div class="updates-item">','<div class="updates-item">','This option lets you to define the beats and countries that you wish to follow, allowing Influencing to present only relevent information to you.','<div class="x-clear"></div>','<div class="overview-bold pt10">Beats:</div><div class="fl pt10">{beats}</div><div class="x-clear"></div>','<div class="overview-bold pt10">Countries:</div><div class="fl pt10">{countries}</div><div class="x-clear"></div>','</div>','</div>','</div>','<div class="overview-container tools-block">','<div class="block-title sprite sprite-tools"><h1>Regional Settings</h1><a href=# class="see-more" onclick="Preferences.edit(); return false;">Edit</a><hr/></div>','<div class="updates-item">','<div class="updates-item">','<div class="overview-bold pt10">Timezone:</div><div class="fl pt10">{timezone}</div><div class="x-clear"></div>','<div class="overview-bold pt10">Date Format:</div><div class="fl pt10">{date_format}</div><div class="x-clear"></div>','<div class="overview-bold pt10">Time Format:</div><div class="fl pt10">{time_format}</div><div class="x-clear"></div>','<div class="overview-bold pt10">Currency:</div><div class="fl pt10">{currency}</div><div class="x-clear"></div>','</div>','</div>','</div>','<div class="overview-container tools-block">','<div class="block-title sprite sprite-tools"><h1>Appearance</h1><a href=# class="see-more" onclick="Preferences.edit(); return false;">Edit</a><hr/></div>','<div class="updates-item">','<div class="updates-item">','<div class="overview-bold pt10">Grid Size:</div><div class="fl pt10">{page_size}</div><div class="x-clear"></div>','<div class="overview-bold pt10">Email Format:</div><div class="fl pt10">{email_preference_str}</div><div class="x-clear"></div>','</div>','</div>','</div>','</td>','</tr></table>','</tpl>').compile(),initParams:function(){this.rd=['email','password','theme','css_name','time_format','date_format','contact','account','currency_id','currency','newsletter_dt','modules_str','account_admins','partner_name','partner_account_info','page_size','email_preference','email_preference_str','timezone','tz_id','beats_ids','beats','countries_ids','countries','opportunities_beats','opportunities_beats_ids','newsletter_stream_types',{name:'is_send_newsletter',type:'bool'},{name:'is_show_my_beats',type:'bool'}];this.tplCenter=new Ext.XTemplate('<tpl for=".">','<div class="account-view"><div class="left">','<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>','<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc">','<h1>User Account</h1>','<fieldset class="x-fieldset x-fieldset-noborder x-form-label-right">','<legend class="x-fieldset-header x-fieldset-header-noborder x-unselectable" style="-moz-user-select: none;">','<span class="x-fieldset-header-text">Account Details</span>','</legend>','<div class="x-fieldset-bwrap">','<div class="x-fieldset-body x-fieldset-body-noborder" style="height: auto;">','<label>Email</label><span>{email}</span>','<div class="x-clear"></div>','<tpl for="account">','<label>Account</label><span>{name}</span>','<div class="x-clear"></div>','<label>Edition</label><span>{edition}</span>','<div class="x-clear"></div>','</tpl>','<label>Modules</label><span>{modules_str}</span>','<div class="x-clear"></div>','</div>','</div>','</fieldset>','<fieldset class="x-fieldset x-fieldset-noborder x-form-label-right">','<legend class="x-fieldset-header x-fieldset-header-noborder x-unselectable" style="-moz-user-select: none;">','<span class="x-fieldset-header-text">Preferences</span>','</legend>','<div class="x-fieldset-bwrap">','<div class="x-fieldset-body x-fieldset-body-noborder" style="height: auto;">','<label>Timezone</label><span>{timezone}</span>','<div class="x-clear"></div>','<label>Date format</label><span>{date_format}</span>','<div class="x-clear"></div>','<label>Time format</label><span>{time_format}</span>','<div class="x-clear"></div>','<label>Currency</label><span>{currency}</span>','<div class="x-clear"></div>','<label>Page size</label><span>{page_size}</span>','<div class="x-clear"></div>','<label>Email preference</label><span>{email_preference_str}</span>','<div class="x-clear"></div>','</div>','</div>','</fieldset>','<fieldset class="x-fieldset x-fieldset-noborder x-form-label-right">','<legend class="x-fieldset-header x-fieldset-header-noborder x-unselectable" style="-moz-user-select: none;">','<span class="x-fieldset-header-text">Filtering Preferences</span>','</legend>','<div class="x-fieldset-bwrap">','<div class="x-fieldset-body x-fieldset-body-noborder" style="height: auto;">','<label>Beats</label><span>{beats}</span>','<div class="x-clear"></div>','<label>Countries</label><span>{countries}</span>','<div class="x-clear"></div>','<label>Show only my beats/countries</label><span>{is_show_my_beats:booleanRenderer}</span>','<div class="x-clear"></div>','</div>','</div>','</fieldset>','<fieldset class="x-fieldset x-fieldset-noborder x-form-label-right">','<legend class="x-fieldset-header x-fieldset-header-noborder x-unselectable" style="-moz-user-select: none;">','<span class="x-fieldset-header-text">Newsletter</span>','</legend>','<div class="x-fieldset-bwrap">','<div class="x-fieldset-body x-fieldset-body-noborder" style="height: auto;">','<label>Receive Newsletter</label><span>{is_send_newsletter:booleanRenderer}</span>','<div class="x-clear"></div>','<label>Newsletter opportunities beats</label><span>{opportunities_beats}</span>','<div class="x-clear"></div>','</div>','</div>','</fieldset>','<div><div id="settings-preferences-editBtn" style="float: left; height: 30px; padding-left: 40px;"></div><div id="settings-preferences-resetUIBtn" style="float: left; height: 30px; padding-left: 20px;"></div></div>','<div class="x-clear"></div>','</div></div></div>','<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>','</div></div>','</tpl>').compile();this.tplEast=new Ext.XTemplate('<tpl for=".">','<div class="account-view"><div class="right">','<b>This account is linked to the following record:</b><br><br>','<tpl for="contact">','<b>{title}</b><br>{job_title}<br><br>{info}<br>','<a onclick="showContact({id})">Contact Details</a>','</tpl>','<tpl for="account">','<hr><b>{name}</b><br><br></tpl>Account administrators: <br><br>','<tpl for="account_admins">{title} - {email}<br></tpl>','</div></div>','</tpl>').compile();PreferencesTags.init();this.loadStore=prepareDs(this.loadUrl,this.rd);this.loadStore.on('load',function(){this.getDialog().action='update';this.getDialog().show();var tabPanel=this.formPanel.items.first();if(tabPanel.xtype=="tabpanel"){tabPanel.items.each(function(p,index,len){tabPanel.setActiveTab(len-index-1);});}
this.fillForm(this.loadStore.getAt(0).data);},this);this.viewStore=prepareDs(this.loadUrl,this.rd);this.viewStore.on('load',function(){this.editBtn=new Ext.Button({renderTo:'settings-preferences-editBtn',text:"Edit Details",handler:this.edit.createDelegate(this)});this.resetUIBtn=new Ext.Button({renderTo:'settings-preferences-resetUIBtn',text:"Reset UI Settings",handler:this.resetUI.createDelegate(this)});},this);},getFormItems:function(){var pageSizeStore=new Ext.data.SimpleStore({fields:['value'],data:[['5'],['10'],['20'],['50'],['100'],['200'],['500'],['1000']]});var items=[];items.push({title:'Main',autoHeight:true,defaultType:'textfield',labelWidth:180,items:[{fieldLabel:'Email',name:'email',allowBlank:false},{fieldLabel:'Password',name:'password'},{fieldLabel:'Password Confirmation',name:'password_confirm'},getRemoteComboOptions(this.makeUrl('getDateFormats'),{fieldLabel:'Date format',allowBlank:false,hiddenName:'date_format'}),getRemoteComboOptions(this.makeUrl('getTimeFormats'),{fieldLabel:'Time format',allowBlank:false,hiddenName:'time_format'}),prepareComboBox(this.makeUrl('getCurrencyTypes'),{fieldLabel:'Currency',allowBlank:false,hiddenName:'currency_id'}),prepareComboBox(this.makeUrl('getTimezones'),{fieldLabel:'Timezone',hiddenName:'tz_id'}),getComboOptions({store:pageSizeStore,fieldLabel:'Page size',allowBlank:false,hiddenName:'page_size',valueField:'value'}),getComboOptions({fieldLabel:'Email preference',hiddenName:"email_preference",store:app.ds.emailPrefStore,value:0}),{fieldLabel:'Show only my beats/countries',xtype:'checkbox',name:'is_show_my_beats',inputValue:'1'}]});items.push({title:'Newsletter',autoHeight:true,items:[{xtype:'checkbox',fieldLabel:'Receive Newsletter',name:'is_send_newsletter',inputValue:'1'},{xtype:'checkboxespanel',name:'opportunities_beats_ids',title:'Opportunities beats',objType:'beats',height:290,width:400,autoScroll:true}]},{title:"Beats preferences",overflow:'auto',autoScroll:true,bodyStyle:'position:relative;',defaults:{autoHeight:true,labelWidth:200},items:[{xtype:'checkboxespanel',name:'beats_ids',objType:'beats',height:400,width:400,autoScroll:true}]},{title:"Countries preferences",bodyStyle:'position:relative;',defaults:{autoHeight:true,labelWidth:200},overflow:'auto',autoScroll:true,items:[{xtype:'checkboxespanel',name:'countries_ids',objType:'countries',height:400,width:400,autoScroll:true}]},{title:'Reset UI',items:this.resetUIBtn=new Ext.Button({text:"Reset UI Settings",handler:this.resetUI.createDelegate(this)})});return items;},initForm:function(){return{defaults:{bodyStyle:'padding:10px'},items:{xtype:'tabpanel',height:400,activeTab:0,layoutOnTabChange:true,defaultType:'fieldset',items:this.getFormItems()}}},edit:function(){this.loadStore.load();},afterItemUpdate:function(){this.viewStore.load({callback:function(records,options,success){if(success){app.conf.pageSize=records[0].get('page_size');}}});app.getNavigationTree().root.reload();},fillForm:function(obj){this.getForm().setValues(obj);},showPersonal:function(){this.showMain();},showModules:function(){PreferencesModules.showMain();},showTags:function(){PreferencesTags.showMain();},resetUI:function(btn){Ext.MessageBox.confirm('Message','All User Interface settings will be reset. Do you really want to reset UI settings?',function(btn2){if(btn2=='yes'){sendJsonRequest(this.makeUrl("resetUI"),{id:1});}},this);},showMain:function(){this.showOverview();}});var PreferencesTags=new Application.Module({title:'Tags',parentModule:Preferences,itemTitle:'tag',createUrl:makeUrl('settings','createTag'),updateUrl:makeUrl('settings','updateTag'),name:'tags',initParams:function(){this.rd=['id','name','user_id','owner','account_id','account','is_shared','articles_count','requests_count','contacts_count','releases_count','clips_count','stories_count','events_count','users','readonly'];this.cm=[new Ext.grid.CheckboxSelectionModel(),{id:'name',header:"Name",dataIndex:'name',width:230},{header:"Owner",dataIndex:'owner',width:230,sortable:false},{header:"Account",dataIndex:'account',width:230},{header:"Is shared",dataIndex:'is_shared',width:80},{header:"Articles",dataIndex:'articles_count',width:60,sortable:false},{header:"Requests",dataIndex:'requests_count',width:60,sortable:false},{header:"Contacts",dataIndex:'contacts_count',width:60,sortable:false},{header:"Releases",dataIndex:'releases_count',width:60,sortable:false},{header:"Clips",dataIndex:'clips_count',width:60,sortable:false},{header:"Stories",dataIndex:'stories_count',width:60,sortable:false},{header:"Events",dataIndex:'events_count',width:60,sortable:false}];this.loadUrl=makeUrl('settings','getTag');},initForm:function(){return{defaultType:'textfield',items:[{id:'preferences-tag-name-field',fieldLabel:'Name',name:'name',allowBlank:false,anchor:'100%'},{xtype:'checkbox',fieldLabel:'Is shared in account',name:'is_shared',inputValue:'1'},{id:'preferences-tag-users-field',fieldLabel:'Shared with users',name:'users',anchor:'100%',listeners:{'render':{fn:function(c){makeAutocomplete(c.el.dom,makeUrl("core","getAllUsersOptions"));}}}}]};},fillForm:function(obj){this.getForm().setValues(obj);Ext.getCmp('preferences-tag-name-field').setDisabled(obj.readonly);},resetForm:function(){this.getForm().reset();Ext.getCmp('preferences-tag-name-field').setDisabled(false);},showMain:function(){this.showFilteredGrid({pagerUrl:makeUrl('settings','getPagerTags'),updateUrl:makeUrl('settings','updateTag'),deleteUrl:makeUrl('settings','deleteTag'),autoExpandColumn:'name'});this.grid.on('rowclick',function(grid,rowIndex,e){grid.deleteBtn.setDisabled(grid.store.data.items[rowIndex].data.is_shared)});}});NewslettersModule=Ext.extend(Application.Module,{title:'Newsletters',parentModule:Preferences,itemTitle:'newsletter',initParams:function(){this.rd=['id','title','user_id','frequency_id','day_or_time','type','frequency','groups',{name:'last_mailed_at',type:'date',dateFormat:app.conf.dtFormat}];this.cm=[new Ext.grid.CheckboxSelectionModel(),{id:"title",header:"Title",dataIndex:'title',width:200},{header:"Type",dataIndex:'type',width:160},{header:"Last mailed at",dataIndex:'last_mailed_at',renderer:dtRenderer,width:120},{header:"Frequency",dataIndex:'frequency',width:100},{header:"Day/Time",dataIndex:'day_or_time',width:100}];},initForm:function(){return{defaults:{bodyStyle:'padding:10px'},items:[{xtype:'tabpanel',activeTab:0,height:400,layoutOnTabChange:true,items:[{title:'Details',autoScroll:true,height:400,layout:'form',defaults:{autoHeight:true,xtype:'fieldset'},items:[this.titleField=new Ext.form.TextField({fieldLabel:'Title',name:'title',width:400,autoHeight:false,allowBlank:false}),getComboOptions({fieldLabel:'Frequency',hiddenName:"frequency_id",allowBlank:false,width:200,listeners:{'select':{fn:function(combo){Ext.get('newsletter-freqDaily-fieldset').setDisplayed(false);Ext.get('newsletter-freqWeekly-fieldset').setDisplayed(false);Ext.get('newsletter-freqMonthly-fieldset').setDisplayed(false);if(combo.getValue()=='3602'){Ext.get('newsletter-freqDaily-fieldset').setDisplayed(true);}else if(combo.getValue()=='3603'){Ext.get('newsletter-freqWeekly-fieldset').setDisplayed(true);}else if(combo.getValue()=='3604'){Ext.get('newsletter-freqMonthly-fieldset').setDisplayed(true);}},scope:this}},store:app.ds.mailoutFrequencyTypes,value:3601}),{id:'newsletter-freqDaily-fieldset',title:'Mailout time/day',defaultType:'combo',items:{xtype:'timefield',value:'13:00',name:'hour',emptyText:'Time to receive',fieldLabel:'Time to receive',format:app.conf.timeFormat,increment:60}},{id:'newsletter-freqWeekly-fieldset',title:'Mailout time/day',items:this.weekDayCombo=prepareComboBox({store:app.ds.weekDayStore,name:'weekDay',valueField:'value',fieldLabel:'Week\'s day'})},{id:'newsletter-freqMonthly-fieldset',title:'Mailout time/day',defaultType:'textfield',items:this.monthDayCombo=prepareComboBox({store:app.ds.monthDayStore,name:'monthDay',valueField:'value',emptyText:'Day',fieldLabel:'Month\'s day'})}]},{title:'Rules',autoScroll:true,height:400,layout:'form',defaultType:'textfield',items:[prepareComboBox({hiddenName:"clause",width:80,fieldLabel:'Clause',valueField:'value',store:app.ds.ruleTypes,value:'AND',allowBlank:false}),this.groupsPanel=new DynamicFieldsPanel({autoScroll:true,fields:[getComboOptions({fieldLabel:'Type',store:app.ds.newsletterRuleTypes,hiddenName:"group_type[]",listeners:{'select':{fn:function(combo,record,index){var type=combo.value;var items=Ext.getCmp(combo.getEl().findParent('div[class*=addedPanel]').id).items.items;for(var i=1;i<items.length;i++){try{var com=items[i].items.items[0].items.items[0].items.items[1];com.store.baseParams.type_id=type;com.store.reload();}catch(e){}}},scope:this}}})],innerFields:[getComboOptions({store:new Ext.data.SimpleStore({fields:['id','value'],data:[['1','include'],['0','exclude']]}),fieldLabel:'Is include',hiddenName:"group_include"}),getRemoteComboOptions(makeUrl('newsletters','getValuesOptions'),{fieldLabel:'Value',hiddenName:"group_value"})]})]}]}]};},fillForm:function(obj){this.getForm().setValues(obj);Ext.get('newsletter-freqDaily-fieldset').setDisplayed(false);Ext.get('newsletter-freqWeekly-fieldset').setDisplayed(false);Ext.get('newsletter-freqMonthly-fieldset').setDisplayed(false);if(obj.frequency_id=='3602'){Ext.get('newsletter-freqDaily-fieldset').setDisplayed(true);}else if(obj.frequency_id=='3603'){Ext.get('newsletter-freqWeekly-fieldset').setDisplayed(true);this.weekDayCombo.setValue(obj.day_or_time);}else if(obj.frequency_id=='3604'){Ext.get('newsletter-freqMonthly-fieldset').setDisplayed(true);this.monthDayCombo.setValue(obj.day_or_time);}
if(obj.groups&&obj.groups.length>0){for(var i=0;i<obj.groups.length;i++){var o=obj.groups[i];var rules=[];for(var j=0;j<o.rules.length;j++){rules[j]=[o.rules[j].is_include,[o.rules[j].value,o.rules[j].value_str]];}
this.groupsPanel.appendField([o.type_id],rules);}}else{this.groupsPanel.appendField([6201]);}
this.groupsPanel.doLayout();},resetForm:function(){try{this.getForm().reset();}catch(e){}
this.groupsPanel.reset();},setFormDefaults:function(){this.groupsPanel.appendField([6201]);Ext.get('newsletter-freqDaily-fieldset').setDisplayed(false);Ext.get('newsletter-freqWeekly-fieldset').setDisplayed(false);Ext.get('newsletter-freqMonthly-fieldset').setDisplayed(false);},showMain:function(){this.showFilteredGrid({autoExpandColumn:'title',footerAddons:[new Ext.Toolbar.Button({iconCls:'icon icon-run',tooltip:'Run',text:'Run',handler:function(){this.selectionAction(null,function(){this.sendJsonRequest(this.module.makeUrl('run'),{id:this.getSelections()[0].get('id')});});}})]});}});var Search=new Application.Module({title:'Search',isInfoModule:false,isNavigation:false,name:'search',initParams:function(){this.rd=['id','type','title','sub_title','contact_id','contact','description'];this.cm=[new Ext.grid.CheckboxSelectionModel(),{header:"Title",dataIndex:'title',width:150},{header:"Details",dataIndex:'sub_title',width:200},{header:"Contact",dataIndex:'contact',width:200}];this.resultTpl=new Ext.XTemplate('<tpl for=".">','<table width="100%"><tr><td class="title"><a onclick="Search.showItem({ type: \'{type}\', id: \'{id}\', contact_id: \'{contact_id}\' })">{title}</a></td></tr>','<tr><td class="sub-title">{sub_title}</td></tr>','</table>','</tpl>').compile();this.searchType='contacts';this.initDialog();},initDialog:function(){this.dlg=new Ext.Window({layout:'fit',width:750,closeAction:'hide',plain:true,id:'search-dlg',bodyStyle:'padding:5px;',buttonAlign:'center',height:480,title:"Advanced search",items:this.formPanel=new Ext.form.FormPanel({xtype:'form',labelWidth:200,defaultType:'fieldset',autoScroll:true,bodyStyle:'background-color:#fff;',defaults:{autoHeight:true,style:"margin: 10px;"},items:[{height:70,xtype:'panel',autoHeight:false,style:"margin: 0px;",items:{bodyStyle:'padding:10px;background-color:#dfe8f6;',items:[{bodyStyle:'font-size: 20px;background-color:#dfe8f6;padding-bottom: 4px;',html:'What do you want to search for?'},this.itemType=prepareComboBox({emptyText:'All Types',hiddenName:'type',labelName:'Types',store:app.ds.searchItemTypes,value:(isJourno()?'companies':'persons'),listeners:{'select':{fn:function(c,r){this.hideFieldsets();if(r.id=='inbox'){this.infoFieldSet.hide();}
try{eval('this.'+r.id+'Fieldset.show().enable();');}catch(e){}
this.formPanel.doLayout();},scope:this}}})]}},this.personsFieldset=new Ext.form.FieldSet({autoHeight:true,hidden:true,title:'Find items that...',defaultType:'textfield',layoutConfig:{labelSeparator:''},items:[{fieldLabel:'have the name',name:'persons_filter'},new Ext.form.CheckBoxesField({fieldClass:"x-form-text x-form-field w250",fieldLabel:'work this beat',editable:false,valuesType:'beats',name:'persons_beatId'}),new Ext.form.CheckBoxesField({fieldClass:"x-form-text x-form-field w250",fieldLabel:'work from this location',editable:false,valuesType:'countries',name:'persons_countryId'}),{fieldLabel:'work for this company',name:'persons_for_company'},{xtype:'select',fieldLabel:'in this role',hiddenName:'persons_roleId',store:app.ds.personRoleTypes,valueField:'id',displayField:'value',triggerAction:'all',mode:'local',multiSelect:false},{fieldLabel:'with this tag',name:'persons_tag'}]}),this.companiesFieldset=new Ext.form.FieldSet({autoHeight:true,hidden:true,title:'Find items that...',defaultType:'textfield',layoutConfig:{labelSeparator:''},items:[{fieldLabel:'have the name',name:'companies_filter'},new Ext.form.CheckBoxesField({fieldClass:"x-form-text x-form-field w250",fieldLabel:'work this beat',editable:false,valuesType:'beats',name:'companies_beatId'}),prepareComboBox({fieldLabel:'operates from this location',emptyText:'All Regions',labelName:'Regions',hiddenName:'companies_countryId',store:app.ds.countries,width:100}),{fieldLabel:'with this tag',name:'companies_tag'}]}),this.outletsFieldset=new Ext.form.FieldSet({autoHeight:true,hidden:true,title:'Find items that...',defaultType:'textfield',layoutConfig:{labelSeparator:''},items:[{fieldLabel:'have the name',name:'outlets_filter'},new Ext.form.CheckBoxesField({fieldClass:"x-form-text x-form-field w250",fieldLabel:'work this beat',editable:false,valuesType:'beats',name:'outlets_beatId'}),new Ext.form.CheckBoxesField({fieldClass:"x-form-text x-form-field w250",fieldLabel:'operates from this location',editable:false,valuesType:'countries',name:'outlets_countryId'}),{xtype:'select',fieldLabel:'is one of the formats',hiddenName:'outlets_format',store:app.ds.outletFormats,valueField:'id',displayField:'value',triggerAction:'all',mode:'local',multiSelect:true},{fieldLabel:'with this tag',name:'outlets_tag'}]}),this.articlesFieldset=new Ext.form.FieldSet({autoHeight:true,hidden:true,title:'Find items that...',defaultType:'textfield',layoutConfig:{labelSeparator:''},items:[{fieldLabel:'have the title',name:'articles_filter'},{fieldLabel:'with this tag',name:'articles_tag'}]}),this.storiesFieldset=new Ext.form.FieldSet({autoHeight:true,title:'Find items that...',hidden:true,defaultType:'textfield',layoutConfig:{labelSeparator:''},items:[{fieldLabel:'have the title',name:'stories_filter'},{fieldLabel:'with this tag',name:'stories_tag'}]}),this.releasesFieldset=new Ext.form.FieldSet({autoHeight:true,title:'Find items that...',hidden:true,defaultType:'textfield',layoutConfig:{labelSeparator:''},items:[{fieldLabel:'have the title',name:'releases_filter'},{fieldLabel:'with this tag',name:'releases_tag'}]}),this.opportunitiesFieldset=new Ext.form.FieldSet({autoHeight:true,hidden:true,title:'Find items that...',defaultType:'textfield',layoutConfig:{labelSeparator:''},items:[{fieldLabel:'have the title',name:'opportunities_filter'},{fieldLabel:'with this tag',name:'opportunities_tag'}]}),this.requestsFieldset=new Ext.form.FieldSet({autoHeight:true,hidden:true,title:'Find items that...',defaultType:'textfield',layoutConfig:{labelSeparator:''},items:[{fieldLabel:'have the title',name:'requests_filter'},{fieldLabel:'with this tag',name:'requests_tag'}]}),this.inboxFieldset=new Ext.form.FieldSet({autoHeight:true,hidden:true,title:'Find items that...',defaultType:'textfield',layoutConfig:{labelSeparator:''},items:[{fieldLabel:'have the subject',name:'inbox_filter'}]}),this.infoFieldSet=new Ext.form.FieldSet({layoutConfig:{labelSeparator:''},autoHeight:true,title:'From these data sets'})]}),buttons:[{text:'Search',handler:function(){if(this.formPanel.getForm().isValid()){this.dlg.hide();var params=this.formPanel.getForm().getFieldValues();this.showResults(params,this.itemType.getValue());}},scope:this},{text:'Cancel',handler:function(){this.dlg.hide();},scope:this}]});Ext.each(app.conf.user.ims,function(f){this.infoFieldSet.add({boxLabel:f[1],xtype:'checkbox',name:'informations',checked:f[2],cId:f[0],inputValue:f[0]});},this);if(isJourno()){this.companiesFieldset.show();}else{this.personsFieldset.show();}},getGridPanelCfg:function(cfg){var result={pagerUrl:makeUrl('search','getPager'),dblclickShow:true,showFieldId:"id",summary:'description',isHaveEdit:false,isHaveDelete:false};return Ext.apply(result,cfg||{});},showMain:function(){this.showFilteredGrid(this.getGridPanelCfg());},showResults:function(sparams,type){var sparams=Ext.apply(sparams,{type:type});var params={};Ext.iterate(sparams,function(p){if(p.substr(0,p.indexOf('_'))==type&&sparams[p]){eval('params.'+p.substr(p.indexOf('_')+1)+' =\''+sparams[p]+'\';');}});if(sparams.filter){params.filter=sparams.filter;}
params.informations=sparams.informations;if(type=='contacts'){this.showFilteredGrid(this.getGridPanelCfg({baseParams:params}),Ext.id());return;}
if(type=='contacts')type='persons';switch(type){case'articles':Reader.showSearchResults(params);break;case'releases':Prwire.showSearchResults(params);break;case'stories':Stories.showSearchResults(params);break;case'persons':Persons.showSearchResults(params);break;case'outlets':Outlets.showSearchResults(params);break;case'companies':Companies.showSearchResults(params);break;case'requests':Requests.showSearchResults(params);break;case'opportunities':Opportunities.showSearchResults(params);break;case'inbox':Inbox.showSearchResults(params);break;}},showDlg:function(items){this.dlg.show();if(!items)items='persons';this.itemType.setValue(items);this.itemType.fireEvent('select',this.itemType,this.itemType.store.getById(items));},hideFieldsets:function(){Ext.each(this.formPanel.findByType('fieldset'),function(f){f.hide();});this.infoFieldSet.show();},renderArea:function(){if(!Ext.get("search-field"))return;this.initParams();var ds=prepareDs(makeUrl('search','getPager'),this.rd,false);ds.baseParams.query='contacts';var resultTpl=new Ext.XTemplate('<tpl for=".">','<div class="search-item">','<table width="100%"><tr><td class="title"><a onclick="Search.showItem({type: \'{type}\', id: \'{id}\', contact_id: \'{contact_id}\' })">{title}</a></td><td class="type">{contact}</td></tr>','<tr><td class="sub-title" colspan=2>{sub_title}</td></tr>','</table>','</div>','</tpl>').compile();app.search=new Ext.form.ComboBox({store:ds,displayField:'title',typeAhead:false,loadingText:'Searching...',name:'search',cls:'search-field',style:'float: left',pageSize:20,tpl:resultTpl,forceSelection:false,isFormField:false,applyTo:'search-field',emptyText:'Search contacts (or click links above to change search type)',hideTrigger:true,itemSelector:'div.search-item',listeners:{beforequery:function(qe){delete qe.combo.lastQuery;}},onRender:function(ct,position){Ext.form.TriggerField.superclass.onRender.call(this,ct,position);this.wrap=this.el.wrap({cls:"x-form-field-wrap",style:'float:left'});this.trigger=this.wrap.createChild(this.triggerConfig||{tag:"img",src:Ext.BLANK_IMAGE_URL,cls:"x-form-trigger "+this.triggerClass});this.trigger.setDisplayed(false);this.initTrigger();if(!this.width){this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());}
if(this.hiddenName){this.hiddenField=this.el.insertSibling({tag:'input',type:'hidden',name:this.hiddenName,id:(this.hiddenId||this.hiddenName)},'before',true);this.el.dom.removeAttribute('name');}
if(Ext.isGecko){this.el.dom.setAttribute('autocomplete','off');}
if(!this.lazyInit){this.initList();}else{this.on('focus',this.initList,this,{single:true});}
if(!this.editable){this.editable=true;this.setEditable(false);}}});this.delayTask=new Ext.util.DelayedTask(function(){if(app.conf.isFacebookStatusSync=='1'){Ext.get('search-stats').update('<iframe src="http://influencing.com/facebook_request.php" style="display:none"/>');this.delayTask.delay(60000);}},this)
Ext.select('a',true,'searchTypes').each(function(e,i){e.on('click',this.setSearchType.createDelegate(this,[e]));},this);Ext.get('search-field').on('keypress',function(e){if(e.isSpecialKey()&&e.getKey()==e.ENTER){app.search.collapse();this.showResults({filter:Ext.get('search-field').getValue()},this.searchType);}},this);},setSearchType:function(ci){Ext.select('a',false,'searchTypes').each(function(e,i){e.removeClass('selected');});ci.addClass('selected');this.searchType=ci.getAttribute('type');app.search.emptyText='Search '+this.searchType+' ...';app.search.clearValue();app.search.doQuery("",true);app.search.reset();app.search.store.baseParams.items=this.searchType;app.search.store.reload({params:{items:this.searchType}});},showItem:function(obj){if(Ext.isNumber(obj)){showContact(obj);}else{if(obj.type=='Person'||obj.type=='Company'||obj.type=='Outlet'){showContact(obj.contact_id);}else if(obj.type=='Article'){showArticle(obj.id);}else if(obj.type=='Clip'){showClip(obj.id);}else if(obj.type=='Request'||obj.type=='Opportunity'){showRequest(obj.id);}else if(obj.type=='Event'){showEvent(obj.id);}else if(obj.type=='Story'){showStory(obj.id);}else if(obj.type=='Release'){showRelease(obj.id);}else if(obj.type=='Message'){showMessage(obj.id);}}},showArticle:function(id){showArticle(id);},showClip:function(id){showClip(id);},showRequest:function(id){showRequest(id);},showEvent:function(id){showEvent(id);},showStory:function(id){showStory(id);},showRelease:function(id){showRelease(id);},showReaderItem:function(id,type){showReaderItem(id,type);},showReaderUrl:function(url,title,id){showReaderUrl(url,title,id);},showContact:function(id){showContact(id);}});Support=new Application.Module({title:'Support',name:'support',showMain:function(){this.showPanel({id:this.name+'-panel',layout:'border',title:this.title,items:[{id:this.name+'-inner-panel',region:'center',layout:'fit',items:[{xtype:'iframepanel',fitToFrame:true,isLoaded:false}]}],listeners:{'activate':{fn:function(){var p=Ext.getCmp(this.name+'-inner-panel').items.get(0);if(!p.isLoaded){p.setSrc('http://sites.google.com/a/mediaconnect.com.au/userguide/');p.isLoaded=true;}},scope:this}}});}});HelpSupport=new Application.Module({title:'Help & Support',name:'help_support',iconCls:'ico-new-question',showMain:function(){this.showPanel({id:this.name+'-panel',layout:'border',title:this.title,items:[{id:this.name+'-inner-panel',region:'center',layout:'fit',items:[{xtype:'iframepanel',fitToFrame:true,isLoaded:false}]}],listeners:{'activate':{fn:function(){var p=Ext.getCmp(this.name+'-inner-panel').items.get(0);if(!p.isLoaded){p.setSrc('https://sites.google.com/a/mediaconnect.com.au/influencing-support/home');p.isLoaded=true;}},scope:this}}});},showOverview:function(){this.showMain();}});ContactsModule=Ext.extend(Application.Module,{isInfoModule:true,isTagged:true,isHavePreview:true,isAlwaysPreview:true,itemTitle:'contact',isNewGrid:true,isResearchGrid:true,overviewFields:['recently_viewed','lists','persons','outlets','companies','updates','beats','letters'],overviewTpl:new Ext.XTemplate('<tpl for=".">','Overview page in development','</tpl>'),logoViewTpl:new Ext.XTemplate('<div class="x-form-item">','<label class="x-form-item-label" style="width: 120px;">Current image:</label>','<tpl if="image_url_big">','<div style="float: left; padding: 2px;"><img onclick="showPreviewImageDialog(\'{image_url_original}\', \'\', \'\')" src="{image_url_normal_cropped}" style="float:left"/>','<a id="contacts_delete_logo_{id}" style="float:left">Delete</a></div>','</tpl>','<tpl if="!image_url_big">','<div style="float: left; padding: 2px;">no image uploaded yet</div>','</tpl>','<tpl if="typeof(cover_url_big) !== &quot;undefined&quot;">','<label class="x-form-item-label" style="width: 120px;">Current cover:</label>','<tpl if="cover_url_big">','<div style="float: left; padding: 2px;"><img onclick="showPreviewImageDialog(\'{cover_url_original}\', \'\', \'\')" src="{cover_url_normal_cropped}" style="float:left"/>','<a id="contacts_delete_cover_{id}" style="float:left">Delete</a></div>','</tpl>','<tpl if="!cover_url_big">','<div style="float: left; padding: 2px;">no cover uploaded yet</div>','</tpl>','</tpl>','</div>','<div class="x-clear"></div>'),itemTopTpl:new Ext.XTemplate('<tpl for=".">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="125px" align="middle" class="item-image">','<table cellspacing=0 cellpadding=0 border=0><tr valign="middle"><td align="center" width="105px" height="105px"><img onclick="showPreviewImageDialog(\'{image_url_original}\', \'\', \'\')" src="{image_url_normal_cropped}"/></td></tr></table>','</td>','<td align="left" class="item-actions">','<h1>{title}</h1>','<tpl if="type_id != 301 || (type_id == 301 && is_premium && !isJourno())">','<h2 id="contact-{id}-item-action-title">',(isJourno()?'Write a note':'Share note with your team'),'</h2>','<div class="x-clear"></div>','<div style="padding-right: 45px;">','<div id="contact-{id}-textarea-div"></div>','<div id="contact-{id}-textarea-autocomplete" class="stream-autocomplete"></div>','<input type="hidden" id="contact-{id}-autocomplete-contacts" value="">','<input type="hidden" id="contact-{id}-autocomplete-contacts-ids" value="">','<input type="hidden" id="contact-{id}-autocomplete-contacts-types" value="">','<input type="hidden" id="contact-{id}-company-id" value="{company_id}">','<div id="contact-{id}-textarea-pointer" class="textarea-pointer" style="backgound-position: -950px top;"></div>','</div>','<table cellpadding=0 cellspacing=0 border=0 width="100%"><tr valign="top"><td align="left">','<div class="item-actions">','<input type="hidden" name="item_action" id="contact-{id}-item-action" value="note">','<a href=# class="item-action-link ico-new-pencil bold" act="note" onclick="setItemAction(this, \'contact-{id}\', \'note\')">Note</a>','<tpl if="this.isHaveModule(\'tasks\')">','<a href=# class="item-action-link ico-new-task" act="task" onclick="setItemAction(this, \'contact-{id}\', \'task\')">Task</a>','</tpl>','<tpl if="this.isShowPitch(\'{user_id}\')">','<a href=# class="item-action-link ico-new-task" act="pitch" onclick="setItemAction(this, \'contact-{id}\', \'pitch\')">Pitch</a>','</tpl>','<tpl if="this.isShowInquiry(\'{user_id}\')">','<a href=# class="item-action-link ico-new-question" act="enquiry" onclick="setItemAction(this, \'contact-{id}\', \'enquiry\')">Enquiry</a>','</tpl>','<tpl if="this.isShowRelease(\'{user_id}\')">','<a href=# class="item-action-link ico-new-releases" act="release" onclick="setItemAction(this, \'contact-{id}\', \'release\');document.getElementById(\'contact-{id}-comment-submit\').click();">Release</a>','</tpl>','<a href=# class="item-action-link ico-new-add" onclick="Companies.showMoreItemActions(this, event, {id});return false;"><span>More</span></a>','</div>','</td><td align="right" style="padding-right: 30px;">','<input type="button" id="contact-{id}-comment-submit"><div class="processing" style="display: none; width: 68px;">Processing...</div>','</td></tr></table>','</tpl>','</td>','</tr></table>','</tpl>',{isHaveModule:function(name){return app.isHaveModule(name);},isShowPitch:function(user_id){return(user_id!=app.conf.user.id&&!isJourno());},isShowInquiry:function(user_id){return(user_id!=app.conf.user.id&&!isJourno());},isShowRelease:function(user_id){return(user_id!=app.conf.user.id&&!isJourno());}}),duplicatesCheckStore:new Ext.data.Store({url:makeUrl('contacts','checkDuplicates'),autoLoad:false,reader:new Ext.data.JsonReader({},['duplicating_id','duplicating_title','owner','permission_type','verified_at','image','is_suggested','type_id','obj_id','is_editable'])}),duplicatingDlg:new Ext.Window({id:'contacts-duplicated-dlg',width:460,height:150,modal:true,closeAction:'hide',plain:true,hidden:true,bodyStyle:'padding:5px;',buttonAlign:'center',defaults:{flex:1,border:true},title:"Warning! This Record Already Exists!",items:{xtype:'panel',height:75,id:'contacts-duplicates-dataview'},listeners:{'show':{fn:function(dlg){if(dlg.isEditable){dlg.buttons[1].show();}else{dlg.buttons[1].hide();}}},scope:this},buttons:[{minWidth:120,text:'Cancel and Close',scope:this,handler:function(){var dlg=Ext.getCmp('contacts-duplicated-dlg');dlg.hide();if(dlg.actionDlg){dlg.actionDlg.close();}}},{minWidth:120,text:'Edit Existing Record',scope:this,handler:function(){var dlg=Ext.getCmp('contacts-duplicated-dlg');dlg.hide();if(dlg.actionDlg){dlg.actionDlg.close();}
if(dlg.typeId==302){Persons.edit(dlg.objId);}else if(dlg.typeId==304){Outlets.edit(dlg.objId);}else if(dlg.typeId==301){Companies.edit(dlg.objId);}}},{minWidth:100,text:'Add Anyway',scope:this,handler:function(){Ext.getCmp('contacts-duplicated-dlg').hide();}}]}),duplicatingTpl:new Ext.XTemplate('<tpl for=".">','<div class="details">','<table><tr><td class="ico"><img src="{image}"></td><td class="info"><div class="details-header-1" style="float: left">','{duplicating_title}','</div>','<div class="clear"></div>','<div class="verified">{owner} <b>{permission_type}<tpl if="is_suggested"> suggested</tpl></b> contact (Verified {verified_at})</div>','</tr></table>','</div>','</tpl>').compile(),reportIssueDlg:new Ext.Window({id:'contacts-report-issue-dlg',width:460,height:150,modal:true,closeAction:'hide',plain:true,hidden:true,bodyStyle:'padding:5px;',buttonAlign:'center',defaults:{flex:1,border:true},title:"Report issue",items:[{xtype:'textarea',height:75,width:437}],buttons:[{minWidth:90,text:'Submit',scope:this,handler:function(){var dlg=Ext.getCmp('contacts-report-issue-dlg');if(!dlg.items.items[0].getValue()){msg("Error","Please enter text");return;}
sendJsonRequest(makeUrl('contacts','reportIssue'),{id:dlg.objId,text:dlg.items.items[0].getValue()},function(scope){dlg.hide();},this);}},{minWidth:90,text:'Cancel',scope:this,handler:function(){var dlg=Ext.getCmp('contacts-report-issue-dlg');dlg.hide();}}]}),initListDetails:function(id){},getListDetailsTpl:function(id){return new Ext.XTemplate('<tpl for=".">','<div class="details">','<tpl if="list_id &gt; 0">','<div class="profile-bg p3" style="margin-top: 0px !important;"><h1>List criteria</h1><a href="#" class="refine-link" onclick=Ext.getCmp(\''+id+'\').refineListCriteria()>Revise criteria</a></div>','<div style="float: left; padding-left: 10px;">','<tpl for="list_params">','<span style="font-weight: bold;">{name}:</span> {value}<br>','</tpl>','</div>','<div class="clear"></div>','</tpl>','<div class="profile-bg p3"><h1>Current search</h1>'+((Ext.getCmp(id).pagerUrl.indexOf('companies')==-1)?['<a href="#" class="refine-link" onclick="Ext.getCmp(\''+id+'\').refineSearch()">Refine this search</a>'].join(''):'')+'</div>','<div style="float: left; padding-left: 10px;">','<tpl for="search_params">','<tpl if="name && value"><span style="font-weight: bold;">{name}:</span> {value}<br></tpl>','</tpl>','<tpl if="search_params.length &gt; 0"><br></tpl>','<b>Items selected:</b> <span id="'+id+'-items-selected">0</span> (<a href="#" onclick="Contacts.selectAllItemsConfirm(this, \''+id+'\')">Use all {total}</a> | <a href="#" onclick="Contacts.clearSelectedItems(\''+id+'\')">Clear selected</a>)','</div>','<div class="clear"></div>','<tpl if="list_items_new &gt; 0 || list_items_remove &gt; 0">','<div class="profile-bg p3"><h1>List updates</h1><a href="#" class="refine-link" onclick="ListReviewWizard = new ReviewListWizard(\'{list_id}\');ListReviewWizard.open();return false;">Review list items</a></div>','<div style="float: left; padding-left: 10px;">','<tpl if="list_items_new &gt; 0">','{list_items_new} new items to review<br>','</tpl>','<tpl if="list_items_remove &gt; 0">','{list_items_remove} items may no longer be relevent<br>','</tpl>','</div>','<div class="clear"></div>','</tpl>',(Ext.getCmp(id).pagerUrl.indexOf('companies')==-1)?[app.isHaveModule('lists')?['<tpl if="list_id == 0">','<div class="profile-bg p3"><h1>Save as list</h1></div>','<div class="preview-actions" style="padding-left: 10px;">','<div><a href="#" onclick="new SaveAsListWizard(\''+id+'\', true, \''+id+'\').open();return false;">Use all items</a><span>Will create a list using all {total} items in this search result</span></div>','<div><a href="#" onclick="new SaveAsListWizard(\''+id+'\', false, \''+id+'\').open();return false;">Use selected items</a><span>Will create a list using the items you have selected</span></div>','</div></tpl>'].join(''):''].join(''):'',app.isHaveModule('inbox')?['<div class="profile-bg p3"><h1>Email using these items</h1></div>','<div class="preview-actions" style="padding-left: 10px;">','<div><a href="#" onclick="Contacts.mailSelected(\''+id+'\',\'external\')">External Email</a><span>Click to use your default mail client (May not work with large lists)</span></div>','<div><a href="#" onclick="Contacts.mailSelected(\''+id+'\',\'internal\')">Influencing Email</a><span>Click to use Influencing\'s web-based mail client</span></div>','<div><a href="#" onclick="Contacts.mailSelected(\''+id+'\',\'campaign\')">Influencing Distributions</a><span>Click to use Influencing\'s powerful distribution destribution tools with reporting</span></div>','</div>'].join(''):'','<div class="profile-bg p3"><h1>Export these items</h1></div>','<div class="preview-actions" style="padding-left: 10px;">','<div><a href="#" onclick="Contacts.exportSelected(\''+id+'\',\'txt\')">Text output</a><span>This option will open a new tab with the list outputted as simple text</span></div>','<div><a href="#" onclick="Contacts.exportSelected(\''+id+'\',\'csv\')">Spreadsheet</a><span>Output fields as a CSV file which can be used in spreadsheet programs</span></div>','<div><a href="#" onclick="Contacts.exportSelected(\''+id+'\',\'rtf\')">Document</a><span>Outputs list as an RTF document that can be edited in a word processor</span></div>','<div><a href="#" onclick="Contacts.exportSelected(\''+id+'\',\'pdf\')">PDF</a><span>Outputs list as a PDF briefing document with pics and bios</span></div>','</div>',app.isHaveModule('lists')?['<tpl if="list_id &gt; 0">','<div class="profile-bg p3"><h1>Manage this list</h1></div>','<div class="preview-actions" style="padding-left: 10px;">','<div><a href="#" onclick="Lists.cloneList({list_id})">Clone this list</a><span>Create another list based on the contacts from this list</span></div>','</div>','</tpl>'].join(''):'','</div>','</tpl>').compile();},rd:['id','has_articles','object_id','phones','emails','websites','messengers','addresses','image_url_original','image_url_big','image_url_normal_cropped','image_url_tweet',{name:'status_updated_at',type:'date',dateFormat:app.conf.dtFormat},'title','status',{name:'is_editable',type:'bool'},'tags','tags_ids','tag_links','type_id','rate','job_title','owner','owner_id','edit_status','permission_type','verified_at','email','media_contacts','user_id','slug','person_id','company_id','outlet_id','account_id','note',{name:'note_edited_at',type:'date',dateFormat:app.conf.dtFormat},'note_editor','objType','responsibilities','related_outlets','updates','description','readership','circulation','frequency','language','type','start_time','end_time','reach','beats','media_kits','testimonials','is_premium','is_suggested','is_journo','is_responsible','subtypes','profile_id','no_tasks','is_verification_needed','is_shared'],getPreviewTemplate:function(showEdit,showVoter,module){return new Ext.XTemplate('<tpl for=".">','<div class="details">','<table><tr><td class="ico"><img src="{image_url_tweet}"></td><td class="info"><div class="details-header-1" style="float: left">','{title}','</div>','<tpl if="owner_id != ',app.conf.account.id,'">',showVoter?'<div class="x-voter" style="float: left" id="contact-{id}-voter-panel"></div>':'','</tpl>','<div class="clear"></div>','<tpl if="type_id != 301">','<div class="details-header-2">','{job_title}','</div>','</tpl>','<div class="clear"></div>','<div class="verified">{owner} <b>{permission_type}<tpl if="is_suggested"> suggested</tpl></b> contact (Verified {verified_at})</div>','</td></tr></table>','<tpl if="emails.length &gt; 0">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="20px"><div class="icon icon-email"></div></td>','<td width="100%"><b>Emails</b><br>','<tpl for="emails">','<tpl if="!this.isFirst(xindex)">',',','</tpl>',' <a href="mailto:{email}">{email}</a>','</tpl>','</td>','</tr></table>','</tpl>','<tpl if="phones.length &gt; 0">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="20px"><div class="icon icon-phone"></div></td>','<td width="100%"><b>Phones</b><br>','<tpl for="phones">','{type}: {phone}','<tpl if="xindex != xcount"><br></tpl>','</tpl>','</td>','</tr></table>','</tpl>','<tpl if="websites.length &gt; 0">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="20px"><div class="icon icon-online"></div></td>','<td width="100%"><b>Websites</b><br>','<tpl for="websites">',' <a href="{url}" target="blank">{url}</a><br>','</tpl>','</td>','</tr></table>','</tpl>','<tpl if="media_contacts.length &gt; 0">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="20px"><div class="icon icon-spoke"></div></td>','<td width="100%"><b>Media Contacts</b><br>','<tpl for="media_contacts">','<tpl if="!this.isFirst(xindex)">',',','</tpl>',' <a href="#" onclick="showContact({contact_id})" onmouseover="showTip(this, \'{office_phone}\');">{contact} {office_phone}</a>','</tpl>','</td>','</tr></table>','</tpl>','<tpl if="addresses.length &gt; 0">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="20px"><div class="icon icon-company"></div></td>','<td width="100%"><b>Addresses</b><br>','<tpl for="addresses">','<a onmouseover="showTip(this, \'Google map\')" onclick="showGmap(\'{street}, {city}, {state}, {zip}, {country}\', \'{[String.escape(parent.title)]}\')">{address}</a><br>','</tpl>','</td>','</tr></table>','</tpl>','<div class="clear"></div><br>','<div>','<div class="icon icon-tag"></div><div class="tags-edit-selector" onclick="editTags(this);">tags</div>','<div class="tags-editor"><input objType="{objType}" objId="{object_id}" type="text" name="tags" ids="{tags_ids}" class="tags-input" value="{tags}"/></div>','<div class="tags-show">{tags_links}</div>','</div>','<div class="clear"></div><br><div class="clear"></div>','<tpl if="type_id != 301 || (type_id == 301 && is_premium)">','<div class="profile-bg p10">','<h1>Noteworthy</h1>','</div>','<span>','<span style="width: auto;" id="contact-note',module,'-text-{id}">{note}</span><font class="last-editor" id="note-editor',module,'-{id}"><tpl if="note_edited_at">&nbsp;Last edited at {note_edited_at:dtRenderer} by {note_editor}&nbsp;</tpl></font>','{noteActionAdd}','{noteActionEdit}',showVoter?['<div id="add-contact-note',module,'-{id}" class="profile-form"></div>'].join(""):'','</span>','</tpl>','<tpl if="type_id == 304">','<div class="profile-bg p10">','<h1>About {title}</h1>','</div>','<b class="title">Type:</b> {type}<tpl if="start_time"><br><b class="title">Start time: </b>{start_time}</tpl><tpl if="end_time"><br><b class="title">End time: </b>{end_time}</tpl><hr>','<b class="title">Subtypes:</b> {subtypes}<hr>','<b class="title">Frequency:</b> {frequency}<hr>','<tpl if="circulation"><b class="title">Circulation:</b> {circulation}<hr></tpl>','<tpl if="readership"><b class="title">Readership:</b> {readership}<hr></tpl>','<b class="title">Reach:</b> {reach}<hr>','<b class="title">Language:</b> {language}<hr>','<tpl if="media_kits.length &gt; 0">','<hr><b>Media kit: </b>','<tpl for="media_kits"><a href="{link}" target="_blank">download</a><tpl if="xindex != xcount"> | </tpl></tpl>','</tpl>','<tpl if="updates.length &gt; 0">','<div class="subblock-title">Most Recent Updates<hr></div>','<tpl for="updates">','<div class="portlet-item"><div class="icon icon-{type}"></div>{message}</div><hr>','</tpl>','</tpl>','<tpl if="description">','<hr>{description}','</tpl>','</tpl>','<tpl if="responsibilities.length &gt; 0">','<div class="profile-bg p10">','<h1><tpl if="type_id == 301">Media contacts</tpl><tpl if="type_id == 302">Responsibilities</tpl></h1>','</div>','<tpl for="responsibilities">','<tpl if="role_title"><b>{role_title}</b>,</tpl> <a onclick="showContact({relation_id})">{related}</a><br>','<tpl if="xindex != xcount"><hr></tpl>','</tpl>','</tpl>','<tpl if="type_id == 301">','<div class="profile-bg p10">','<h1>About</h1>','</div>{description}','<tpl if="testimonials.length &gt; 0 && is_premium">','<div class="profile-bg p10">','<h1>Testimonials</h1>','</div>','<tpl for="testimonials">','"{content}"<br>','<b>{person}<tpl if="person_company">, {person_company}<hr></tpl></b><br>','<tpl if="xindex != xcount"><br></tpl>','</tpl>','</tpl>','<tpl if="related_outlets.length &gt; 0">','<div class="profile-bg p10">','<h1>Related</h1>','</div>','<tpl for="related_outlets">','<tpl if="role_title"><b>{role_title}</b>,</tpl> <a onclick="showContact({relation_id})">{related}</a><br>','<tpl if="xindex != xcount"><hr></tpl>','</tpl>','</tpl>','</tpl>','<tpl if="beats.length &gt; 0">','<div class="profile-bg p10">','<h1>Beats</h1>','</div>','<div>{beats}</div>','</tpl>','</div>','</tpl>',{isFirst:function(index){return index==1;}}).compile();},getTypeById:function(typeId){if(typeId==301)return'company';if(typeId==304)return'outlet';return'person';},getItemToolbarItems:function(data,scope){var items=[];if(data.is_editable){if(data.type_id!=301){items.push(' ',{text:'Edit',iconCls:'icon icon-edit',tooltip:'Edit',handler:function(){var sm=null;switch(data.type_id){case 302:sm=Persons.init();break;case 304:sm=Outlets.init();break;}
sm.edit(data.object_id);}});}else{items.push(' ',{text:'Edit Company',iconCls:'icon icon-edit',tooltip:'Edit company',handler:function(){new CompanyWizard(data.object_id).open();}});}
if((data.type_id==302)||(data.type_id==304)){items.push(this.deleteBtn=new Ext.Toolbar.Button({iconCls:'icon icon-delete',tooltip:'Delete item',text:'Delete',scope:this,handler:function(){this.confirmAction('Do you really want to delete?',function(){var deleteUrl='';switch(data.type_id){case 302:deleteUrl='persons/delete';break;case 304:deleteUrl='outlets/delete';break;}
this.sendJsonRequest(deleteUrl,Ext.apply(this.baseParams||{},{ids:'[{"id":'+data.object_id+'}]'}),function(scope){msg("Notice","Deletion complete");});});}}));}}
if(!isJourno()&&!data.is_suggested&&(data.permission_type=='Private')){items.push({text:'Make Public',iconCls:'icon icon-tick',handler:function(){confirm(function(){this.sendJsonRequest(makeUrl('contacts','makePublic'),{id:data.id},function(scope){scope.afterItemUpdate();msg("Notice","Contact marked. It will become shared after admins approval");});},this,'Do you really want make public?');},scope:scope});}
if(data.account_id==app.conf.account.id||isPartnerAdmin()||data.is_shared){items.push({text:'Verify',iconCls:'icon icon-accept',tooltip:'Verify',handler:function(){this.sendJsonRequest(makeUrl('contacts','verify'),{id:data.id},function(scope){scope.afterItemUpdate(data);});},scope:scope});}else{items.push({text:'Report Issue',iconCls:'icon icon-email',tooltip:'Send email to account administrators',handler:function(){this.reportIssueDlg.objId=data.id;this.reportIssueDlg.show();},scope:this});}
if(data.type_id!=301){items.push('-',{text:'Email',iconCls:'icon icon-email',tooltip:'Email',handler:function(){Inbox.showCompose(data.email);},scope:scope});}
if(app.isHaveModule('lists')&&data.type_id!=301){items.push({text:'Add to List',iconCls:'icon icon-table-add',tooltip:'Add to List',menu:[],scope:scope,listeners:{'render':{fn:function(b){app.ds.listOptionsStore.filter({fn:function(record){return record.get('type')=='Media'||record.get('type')==Ext.util.Format.capitalize(data.objType);},scope:this});app.ds.listOptionsStore.data.each(function(r){b.menu.addItem({text:r.get('name'),handler:function(cb){this.sendJsonRequest(makeUrl('lists','addObjects'),{id:r.get('id'),object_ids:'[{"id": '+data.id+'}]',type:data.objType},function(scope){scope.afterItemUpdate();});},scope:this});},this);},scope:this}}});}
return items;},getPreviewPanelCfg:function(name,grid){return this.getDefaultPreviewPanelCfg(name);},previewItem:function(id,data,panel){var grid=panel.grid;var store=new Ext.data.JsonStore({url:makeUrl('contacts','getContact'),autoLoad:false,fields:Contacts.rd,listeners:{'load':{fn:function(scope,rec){var data=rec[0].data;var type=Contacts.getTypeById(data.type_id);data.tags_links=makeLinks(data.tags_ids,data.tags,'Ext.getCmp(\''+grid.id+'\').showTagged');formatAddressString(data);var p=grid.getPreviewPanel();var el=p.get(0).el;var tb=p.getTopToolbar();tb.removeAll();tb.add({text:'Open',iconCls:'icon icon-'+type,handler:Contacts.showItem.createDelegate(this,[data.id,type,grid])});tb.add(this.getItemToolbarItems(data,this));tb.add('->',{text:'Close',iconCls:'icon icon-cross',handler:function(){grid.showListDetails();}});tb.doLayout();el.hide().update(this.getPreviewTemplate(false,false,'contacts').apply(data)).slideIn('l',{stopFx:true,duration:.2});},scope:this}}});store.reload({params:{id:id}});},getItemPanelCfg:function(id,type){if(!type){type='person';}
var iconCls='ico-module-'+type+'s';if(type=='company'){var iconCls='ico-module-companies';}
return{layout:"border",border:false,id:"contact-"+id+"-panel",title:'Loading',iconCls:'ico-new '+iconCls,items:[{region:'east',id:"contact-"+id+"-preview-panel",cls:'preview',autoScroll:true,split:true,width:420,tbar:{cls:'item-toolbar',enableOverflow:true},layout:'fit'},{region:'center',overflow:'hidden',autoScroll:true,bodyBorder:false,layout:'border',id:"contact-"+id+"-center-panel",split:false,items:[{id:"contact-"+id+"-top-panel",region:'north',split:false,collapsible:false,height:148},{tbarCfg:{style:'display: none'},cls:'item-tabs-panel',region:'center',split:false,id:"contact-"+id+"-tabs-panel",xtype:'tabpanel',deferredRender:true,layoutOnTabChange:true}]}]};},showItem:function(id,type,grid){var cfg=this.getItemPanelCfg(id,type);var module=this;if(type=='company'){module=Companies;}else if(type=='outlet'){module=Outlets;}else if(type=='person'){module=Persons.init();}
cfg.iconCls='ico-new ico-module-'+module.name;track('Viewed contact','Contacts');app.showModulePanel(cfg,function(){app.getMainPanel().add(new ContactModule(Ext.apply(cfg,{name:'contact-'+id,objId:id,objModule:module,objType:type,grid:grid})));app.getMainPanel().activate(cfg.id);},this);return false;},createContactsPanel:function(type){return{title:"Contacts",overflow:'auto',autoScroll:true,bodyStyle:'position:relative;',defaults:{xtype:"fieldset",defaultType:'textfield',autoHeight:true,bodyStyle:"border: none",collapsible:true,overflow:'auto'},set:function(obj){Ext.each(this.items,function(v){v.items.set(obj);});},reset:function(){Ext.each(this.items,function(v){v.items.reset();});},appendField:function(){Ext.each(this.items,function(v){v.items.appendField();});},items:[{title:'Emails',items:new DynamicFieldsPanel({fields:[{fieldLabel:'Email',name:'email[]',width:250,vtype:'email'}],set:function(obj){try{if(!obj.emails.length){this.appendField();}
Ext.each(obj.emails,function(n){this.appendField([n.email]);},this);}catch(e){this.appendField();}}})},{title:'Phones',items:new DynamicFieldsPanel({fields:[{fieldLabel:'Phone',name:'phone[]'},getComboOptions({fieldLabel:'Type',hiddenName:"phoneType[]",store:(type=='company'||type=='outlet'?app.ds.phoneTypesCompany:app.ds.phoneTypes)})],set:function(obj){try{if(!obj.phones.length){this.appendField();}
Ext.each(obj.phones,function(n){this.appendField([n.phone,n.type_id]);},this);}catch(e){this.appendField();}}})},{title:'Websites',items:new DynamicFieldsPanel({fields:[{fieldLabel:'Website',name:'url[]',vtype:'svurl'},getComboOptions({fieldLabel:'Type',hiddenName:"websiteType[]",store:(type=='company'||type=='outlet'?app.ds.websiteTypesCompany:app.ds.websiteTypes)})],set:function(obj){try{if(!obj.websites.length){this.appendField();}
Ext.each(obj.websites,function(n){this.appendField([n.url,n.type_id]);},this);}catch(e){this.appendField();}}})},{title:'IMs',items:new DynamicFieldsPanel({fields:[{fieldLabel:'Messenger id',name:'im[]'},getComboOptions({fieldLabel:'Account Type',hiddenName:"imAccountType[]",store:app.ds.imTypes}),getComboOptions({fieldLabel:'Type',hiddenName:"messengerType[]",store:app.ds.imAccountTypes})],set:function(obj){try{if(!obj.messengers.length){this.appendField();}
Ext.each(obj.messengers,function(n){this.appendField([n.im,n.type_id,n.im_type_id]);},this);}catch(e){this.appendField();}}})},{title:'Addresses',items:new DynamicFieldsPanel({fields:[{fieldLabel:'Street',name:'street[]',preventScrollbars:true},{fieldLabel:'City',name:'city[]'},{fieldLabel:'State',name:'state[]'},{fieldLabel:'Zip',name:'zip[]'},getComboOptions({fieldLabel:'Country',hiddenName:"countryId[]",store:app.ds.countries}),getComboOptions({fieldLabel:'Type',hiddenName:"typeId[]",store:(type=='company'||type=='outlet'?app.ds.addressTypesCompany:app.ds.addressTypes)})],set:function(obj){try{if(!obj.addresses.length){this.appendField();}
Ext.each(obj.addresses,function(n){this.appendField([n.street,n.city,n.state,n.zip,n.country_id,n.type_id]);},this);}catch(e){this.appendField();}}})}]};},createTopicsPanel:function(){return{title:"Topics",height:400,overflow:'auto',bodyStyle:'position:relative;',autoScroll:true,items:[new DynamicFieldsPanel({id:'topics-dyn-panel',fields:[getComboOptions({fieldLabel:'Topic',hiddenName:"beat_id[]",store:app.ds.beats}),getComboOptions({fieldLabel:'Regularity',hiddenName:"regularity_id[]",store:app.ds.topicRegularity,allowBlank:false}),{xtype:'textarea',fieldLabel:'Summary',name:'summary[]'},{xtype:'checkboxesfield',fieldLabel:'Additional beats',name:'additional_beats_ids[]',valuesType:'beats',valueName:'additional_beats_ids[]'},{xtype:'superboxselect',fieldLabel:'Related outlets',emptyText:'Outlets...',resizable:true,minChars:2,name:'related_outlets_ids[]',removeValuesFromStore:false,preventDuplicates:true,store:{autoLoad:false,autoDestroy:true,xtype:'arraystore',url:makeUrl('contacts','getRelatedTopicOutlets'),idIndex:0,fields:[{name:'id'},{name:'value'}]},mode:'remote',displayField:'value',displayFieldTpl:'{value}',valueField:'id',queryDelay:0,value:0,queryParam:'query',triggerAction:'all'},{xtype:'superboxselect',fieldLabel:'Contact/s',emptyText:'Contacts...',resizable:true,minChars:2,name:'related_persons_ids[]',removeValuesFromStore:false,preventDuplicates:true,store:{autoLoad:false,autoDestroy:true,xtype:'arraystore',url:makeUrl('contacts','getRelatedTopicPersons'),idIndex:0,fields:[{name:'id'},{name:'value'}]},mode:'remote',displayField:'value',displayFieldTpl:'{value}',valueField:'id',queryDelay:0,queryParam:'query',triggerAction:'all'}],set:function(obj){try{if(!obj.length){}
Ext.each(obj,function(n){this.appendField([n.beat_id,n.regularity_id,n.summary,n.additional_beats_ids,n.related_outlets_ids,n.related_persons_ids]);},this);}catch(e){this.appendField();}}})],reset:function(){this.items[0].reset();},set:function(obj){this.items[0].set(obj);}};},createTipsPanel:function(){return{title:'Q & A',overflow:'auto',autoScroll:true,items:[new DynamicFieldsPanel({fields:[{fieldLabel:'Question',name:'question[]'},{xtype:'textarea',fieldLabel:'Answer',name:'answer[]'}],set:function(obj){try{if(!obj.length){this.appendField();}
Ext.each(obj,function(n){this.appendField([n.question,n.answer]);},this);}catch(e){this.appendField();}}})],reset:function(){this.items[0].reset();},set:function(obj){this.items[0].set(obj);}};},createFeedsPanel:function(title,val,isShowTip){var items=[];if(isShowTip){items.push({html:'Feed items of those feeds possible will be saved as clips/releases'});}
items.push(new DynamicFieldsPanel({fields:[{fieldLabel:'RSS feed',name:val}],set:function(obj){try{if(!obj.length){this.appendField();}
Ext.each(obj,function(n){this.appendField([n]);},this);}catch(e){this.appendField();}}}));return{title:title,overflow:'auto',items:items,reset:function(){this.items[isShowTip?1:0].reset();},set:function(obj){this.items[isShowTip?1:0].set(obj);}};},showCompany:function(id){this.showItem(id,'company');},createBeatsPanel:function(isHideHeader){return{header:!isHideHeader,title:"Categories",layout:"fit",bodyStyle:'position:relative;',defaultType:'fieldset',defaults:{autoHeight:true,labelWidth:200},overflow:'auto',autoScroll:true,items:[{xtype:'checkboxespanel',name:'beats_ids',objType:'beats',height:400,width:400,autoScroll:true}]}},createPermissionsPanel:function(type){var items=[{title:'Permissions',items:[getComboOptions({fieldLabel:'View permission',hiddenName:"permission_type",store:new Ext.data.SimpleStore({fields:['id','value'],data:[['Hidden','Hidden'],['Private','Private'],['Public','Public'],['Journos','Journos'],['Clients','Clients']]}),value:type=='company'?'Journos':'Clients'}),getComboOptions({fieldLabel:'Edit permission',hiddenName:"permission_edit",store:new Ext.data.SimpleStore({fields:['id','value'],data:[['Me','Me'],['Account','Account'],['All','All']]}),value:'Me'})]},{title:'Verification',items:[getRemoteComboOptions(makeUrl('partner','getManagersOptions'),{fieldLabel:'Account manager',hiddenName:"verification_manager_id"}),{fieldLabel:'Verification Days',name:"verification_days",xtype:'textfield',value:90,vtype:'numeric'},getComboOptions({fieldLabel:'Verification Status',hiddenName:"verification_status",store:app.ds.verificationStatuses,value:'Unverified'})]}];return{title:"Administration",height:400,overflow:'auto',autoScroll:true,defaults:{xtype:'fieldset',autoHeight:true},items:items}},getGridTopPanelLeftColumnItems:function(){var result=[{fieldLabel:'have the name',hiddenName:'filter',name:'filter'},new Ext.form.CheckBoxesField({fieldLabel:'work this beat',editable:false,valuesType:'beats',emptyText:'All Beats',width:200,name:'beatId'})];if(this.name=='persons'){result.push({xtype:'select',fieldLabel:'in this role',hiddenName:'roleId',store:app.ds.personRoleTypes,valueField:'id',displayField:'value',triggerAction:'all',mode:'local',multiSelect:true});}
if(this.name=='companies'){result.push(prepareComboBox({fieldLabel:'operates from this location',emptyText:'All Regions',labelName:'Regions',hiddenName:'countryId',store:app.ds.countries,width:100}));}else{result.push(new Ext.form.CheckBoxesField({fieldClass:"x-form-text x-form-field w250",fieldLabel:this.name=='outlets'?'operates from this location':'work from this location',editable:false,valuesType:'countries',name:'countryId'}));}
return result;},getGridTopPanelRightColumnItems:function(){var result=[];if(this.name!='companies'&&this.name!='outlets'){result.push({fieldLabel:'work for this company',name:'for_company'});}
if(this.name=='outlets'){result.push({xtype:'select',fieldLabel:'is one of the formats',hiddenName:'format',store:app.ds.outletFormats,valueField:'id',displayField:'value',triggerAction:'all',mode:'local',multiSelect:true});}
result.push({fieldLabel:'with this tag',hiddenName:'tag',name:'tag',value:''});return result;},downloadFile:function(listId,param,format,type,fields){var body=Ext.getBody();var frame=body.createChild({tag:'iframe',cls:'x-hidden',id:'iframe_'+listId,name:'iframe_'+listId});var form=body.createChild({tag:'form',method:'post',action:Lists.makeUrl('exportContactsWithoutPopup'),target:'iframe_'+listId,children:[{tag:'input',name:'list_id',value:listId},{tag:'input',name:'ids',value:Ext.util.Format.htmlEncode(param)},{tag:'input',name:'format',value:format},{tag:'input',name:'type',value:type||'all'},{tag:'input',name:'fields',value:fields}]});form.dom.submit();},exportSelected:function(id,format,type){var store=Ext.getCmp(id).getSelectionModel().store;var ids=[];store.each(function(n){ids.push(n.get('contact_id'));});if(ids.length>0){var fields=['id','value'];var myData={results:[{id:'email',value:'Email'},{id:'name',value:'Name'},{id:'phone',value:'Phone'},{id:'job',value:'Job Title'},{id:'address',value:'Address'}]};var sourceGridStore=new Ext.data.JsonStore({fields:fields,data:myData,root:'results'});var sourceGrid=new Ext.grid.GridPanel({ddGroup:'destGridDDGroup',store:sourceGridStore,columns:[{id:'name',header:"Drag from here",width:160,sortable:true,dataIndex:'value'}],enableDragDrop:true,stripeRows:true,autoExpandColumn:'name',title:'Available Fields'});var destGridStore=new Ext.data.JsonStore({fields:fields,root:'results'});var destGrid=new Ext.grid.GridPanel({ddGroup:'sourceGridDDGroup',store:destGridStore,columns:[{id:'name',header:"Drop and reorder here",width:160,sortable:true,dataIndex:'value'}],enableDragDrop:true,stripeRows:true,autoExpandColumn:'name',title:'Fields to Export'});var dlg=new Ext.Window({layout:'hbox',width:350,height:400,modal:true,closeAction:'close',plain:true,hidden:true,bodyStyle:'padding:5px;',buttonAlign:'center',defaults:{flex:1,border:true},layoutConfig:{align:'stretch'},title:"Export to Spreadsheet",items:[sourceGrid,destGrid],bbar:[{text:'Use All',handler:function(){destGridStore.loadData(myData);sourceGridStore.removeAll();}},'->',{text:'Remove All',handler:function(){sourceGridStore.loadData(myData);destGridStore.removeAll();}}],buttons:[{minWidth:80,text:'Cancel',handler:function(){dlg.close();}},{minWidth:80,text:'Export Now',scope:this,handler:function(){var fields=[];destGridStore.each(function(n){fields.push(n.get('id'));});Contacts.downloadFile(id,ids.join(','),format,type,fields.join(','));}}]});dlg.show();var blankRecord=Ext.data.Record.create(fields);var sourceGridDropTargetEl=sourceGrid.getView().scroller.dom;var sourceGridDropTarget=new Ext.dd.DropTarget(sourceGridDropTargetEl,{ddGroup:'sourceGridDDGroup',notifyDrop:function(ddSource,e,data){var records=ddSource.dragData.selections;Ext.each(records,ddSource.grid.store.remove,ddSource.grid.store);sourceGrid.store.add(records);sourceGrid.store.sort('name','ASC');return true}});var destGridDropTargetEl=destGrid.getView().scroller.dom;var destGridDropTarget=new Ext.dd.DropTarget(destGridDropTargetEl,{ddGroup:'destGridDDGroup',notifyDrop:function(ddSource,e,data){var sm=destGrid.getSelectionModel();var rows=sm.getSelections();var cindex=ddSource.getDragData(e).rowIndex;if(sm.hasSelection()){for(i=0;i<rows.length;i++){destGridStore.remove(destGridStore.getById(rows[i].id));destGridStore.insert(cindex,rows[i]);}
sm.selectRecords(rows);}else{var records=ddSource.dragData.selections;Ext.each(records,ddSource.grid.store.remove,ddSource.grid.store);destGrid.store.add(records);return true}}});var destGridDropTargetEl=destGrid.getView().scroller.dom;var destGridDropTarget2=new Ext.dd.DropTarget(destGridDropTargetEl,{ddGroup:'sourceGridDDGroup',notifyDrop:function(ddSource,e,data){var sm=destGrid.getSelectionModel();var rows=sm.getSelections();var cindex=ddSource.getDragData(e).rowIndex;if(sm.hasSelection()){for(i=0;i<rows.length;i++){destGridStore.remove(destGridStore.getById(rows[i].id));destGridStore.insert(cindex,rows[i]);}
sm.selectRecords(rows);}else{var records=ddSource.dragData.selections;Ext.each(records,ddSource.grid.store.remove,ddSource.grid.store);destGrid.store.add(records);return true}}});}else{confirm(function(){Ext.getCmp(id).getSelectionModel().selectAll();this.selectAllItems(this.exportSelected,id,format,type);},this,'No items selected. Do you want use all items? It can take several minutes');}},mailSelected:function(id,type){var store=Ext.getCmp(id).getSelectionModel().store;var emails=[];store.each(function(n){if(n.get('email')){emails.push(n.get('email'));}});if(emails.length>0){if(type=='external'){var mailto_link='mailto:'+app.conf.user.contact_email+'?bcc='+emails.join(',');win=window.open(mailto_link,'emailWindow');if(win&&win.open&&!win.closed)win.close();}
if(type=='internal'){if(app.isHaveModule('inbox')){Inbox.showCompose(emails.join(', '));}else{msg("Notice","This module not enabled for you");}}
if(type=='campaign'){if(app.isHaveModule('inbox')){new EmailCampaignWizard(null,null,null,null,store).open();}else{msg("Notice","This module not enabled for you");}}}else if(store.getCount()){msg("Notice","Selected contacts have no emails");}else{confirm(function(){this.selectAllItems(this.mailSelected,id,type);},this,'No items selected. Do you want use all items? It can take several minutes');}},exportSelectedToPdf:function(id,format,type){var store=Ext.getCmp(id).getSelectionModel().store;var ids=[];store.each(function(n){ids.push({id:n.get('contact_id')});});if(ids.length==0){Ext.MessageBox.confirm('Message','No items selected. Do you want use all items? It can take several minutes',function(btn,text){if(btn=='yes'){this.selectAllItems(this.mailSelected,id,type);}else{msg("Notice","Please select at least one item to export");return;}},this);}
sendJsonRequest(Lists.makeUrl('exportContacts'),{ids:Ext.encode(ids),type:type||'all',format:format},function(scope,data){win=window.open(data.fn,'exportWindow');},this);},titleRenderer:function(val,p,record,rowIndex,columnIndex,ds){return'<a href=# onclick="showContact('+record.data.contact_id+');" class="item-title">'+val+'</a>';},openWordCloud:function(id,type){var dlg=new Ext.Window({layout:'fit',width:500,height:500,modal:true,closeAction:'close',plain:true,hidden:true,bodyStyle:'padding:5px;',buttonAlign:'center',title:"Word Cloud",items:{xtype:'panel',html:'<div id="contact-'+id+'-word-cloud-all" class="word-cloud"></div>',autoScroll:true,listeners:{afterrender:{fn:function(){var cloud=new Ext.ux.TagCloud({store:prepareDs(makeUrl('contacts','keywordsCloud')+'?id='+id+'&type='+type+'&limit=1000',[{name:'count'},{name:'keyword'}],false),displayField:'keyword',weightField:'count',loadMask:true,displayWeight:false,tagsName:'tags',listeners:{'tagselect':{fn:function(cloud,tag,idx,el){var p=Ext.getCmp('contact-'+id+'-panel').coveragePanel;tabs=Ext.getCmp('contact-'+id+'-panel').getPanel('tabs');tabs.activate(p);p.grid.loadFilters({keyword:tag.data.keyword});dlg.close();},scope:this}}});new Ext.Panel({renderTo:'contact-'+id+'-word-cloud-all',items:cloud});cloud.store.reload();}}}},buttons:[{minWidth:80,text:'Close',scope:this,handler:function(){dlg.close();}}]});dlg.show();},prepareViewPermissionCombo:function(){return prepareComboBox({hiddenName:"permission_type",emptyText:'All types',labelName:'Permission type',store:new Ext.data.SimpleStore({fields:['id','value'],data:[['Hidden','Hidden'],['Private','Private'],['Public','Public'],['Clients','Clients'],['Journos','Journos']]})});},prepareEditPermissionCombo:function(){return prepareComboBox({hiddenName:"permission_edit",emptyText:'All edit types',labelName:'Permission edit',store:new Ext.data.SimpleStore({fields:['id','value'],data:[['Me','Me'],['Account','Account'],['All','All']]})});},prepareBeatsCombo:function(){return prepareComboBox({emptyText:'All Beats',labelName:'Beats',hiddenName:'beatId',store:app.ds.beats,width:200});},prepareVerifiedCombo:function(){return prepareComboBox({emptyText:'All Contacts',labelName:'Verification',hiddenName:'verified',store:new Ext.data.SimpleStore({fields:['id','value'],data:[['','All'],['expired3','Expired 3 Months'],['expired4','Expired 4 Months'],['expired6','Expired 6 Months'],['expired12','Expired Year'],['not_verified','Not Verified']]})});},prepareVerificationStatusCombo:function(){return prepareComboBox({emptyText:'All Statuses',labelName:'Verification Status',hiddenName:"verification_status",store:app.ds.verificationStatuses})}});var Contacts=new ContactsModule();ContactModule=Ext.extend(Application.ViewModule,{objType:null,objId:null,parentModule:Contacts,title:'Loading...',itemTitle:'contact',loadUrl:makeUrl('contacts','getContact'),makeUrl:function(action){return makeUrl('contacts',action);},refreshTabs:function(relationshipsOnly,activitiesOnly,all){this.getPanel('tabs').items.each(function(n){if(all||(!(relationshipsOnly==true&&n.relationships!=true)&&!(activitiesOnly==true&&n.activities!=true))){try{n.refresh();}catch(e){}}});},afterItemUpdate:function(){ContactModule.superclass.afterItemUpdate.apply(this);this.refreshTabs(true,true,true);},getTabsCfg:function(){var data=this.data;var id=this.objId;switch(data.type_id){case 301:var items=new Array();if(data.is_premium){items=[];if(isJourno()){items.push(new ContactCompanyReleasesPanel({objId:id,isResponsible:this.data.is_responsible,companyId:this.data.company_id}),new ContactPeoplePanel({objType:'companyForJourno',objId:id,objIsEditable:data.is_editable}),new ContactPhotosPanel({objId:id}));}else{items.push(new CompanyOverviewPanel({objId:id,objType:'company',id:'company-'+id+'-overview-panel'}),{xtype:'streampanel',title:'Stream',id:this.name+'-stream-panel',pagerUrl:makeUrl('companies','getUpdatesPager')+'?contact_id='+id,filters:['team','contacts','types']});items.push(new ContactCompanyReleasesPanel({objId:id,isResponsible:this.data.is_responsible,companyId:this.data.company_id}),new ContactCompanyCoveragePanel({objId:id,companyId:this.data.company_id,profileId:this.data.profile_id}));if(app.isHaveModule('opportunities')){items.push(new ContactOpportunitiesPanel({companyId:this.data.company_id,objId:id,contactTitle:data.title,pagerUrl:makeUrl('contacts','getCompanyOpportunitiesPager')}));}
if(app.isHaveModule('lists')){items.push(new ContactListsPanel({companyId:this.data.company_id}));}}}else{items.push(new ContactCompanyReleasesPanel({objId:id}));}
break;case 302:var items=new Array();items.push(new PersonOverviewPanel({objId:id,objType:'person',id:'person-'+id+'-overview-panel'}));items.push({xtype:'streampanel',id:this.name+'-stream-panel',pagerUrl:makeUrl('persons','getUpdatesPager')+'?contact_id='+id});if((data.has_articles!=0)&&app.isHaveModule('coverage')){items.push(this.coveragePanel=new ContactCoveragePanel({objId:id}));}
if(app.isHaveModule('lists')){items.push(new ContactListsPanel({objId:id}));}
if(!isJourno()){items.push(new ContactRelationshipsPanel({objId:id}));}
break;case 304:var items=[new OutletOverviewPanel({objId:id,objType:'outlet',id:'outlet-'+id+'-overview-panel'}),{xtype:'streampanel',id:this.name+'-stream-panel',pagerUrl:makeUrl('outlets','getUpdatesPager')+'?contact_id='+id}];items.push(new ContactPeoplePanel({objType:'outlet',objId:id}),new ContactRelatedOutletsPanel({objId:id,contactTitle:data.title,outletId:id}));if(!isJourno()){if(app.isHaveModule('opportunities')){items.push(new ContactOpportunitiesPanel({objId:id,contactTitle:data.title,outletId:id}));}}
items.push(this.coveragePanel=new ContactCoveragePanel({outletId:id}));break;}
return items;},getToolbarItemsCfg:function(){return Contacts.getItemToolbarItems(this.data,this);},initTopPanel:function(){var data=this.store.getAt(0).data;this.objType=data.objType;this.data=data;var p=this.getPanel('tabs');if(!p.items.length){p.add(this.getTabsCfg());p.doLayout();p.activate(0);p.doLayout();p.addListener('tabchange',function(tabpanel,newTab){if(newTab.title=='Overview'){var chart=Ext4.getCmp('contact-'+this.data.id+'-chart-component');if(!chart.rendered){newTab.store.reload();}}},this);}
var preview=this.getPanel('preview');preview.removeAll();if(isJourno()||this.data.type_id!=301){preview.add(this.getProfileDataview());preview.doLayout();preview.listHtml=preview.get(0).el.dom.innerHTML;}else{var items=[];if(app.conf.user.edition!='Community'){items.push(this.tasksPanel=new StreamTasksPanel({id:"contact-"+this.data.id+"-tasks-panel",autoScroll:true,stateful:true,autoWidth:true,autoHeight:true,companyId:this.data.company_id,listeners:{'afterrender':{fn:function(cmp){cmp.el.removeListener('contextmenu');cmp.el.on('contextmenu',function(e,node,d){e.stopEvent();if(!this.contextMenu){this.contextMenu=new Ext.menu.Menu({items:[{iconCls:'icon icon-refresh',text:'Refresh',handler:function(){this.tasksPanel.removeAll();this.tasksPanel.store.reload({params:{start:0}});},scope:this}]});}
this.contextMenu.showAt(e.getXY());},this);},scope:this},scope:this}}));}
items.push({xtype:'panel',title:'Profile',cls:'preview',items:{xtype:'panel',tbar:[],items:this.getProfileDataview()}});if(isPartnerAdmin()){items.push({xtype:'panel',title:'Reports',items:{xtype:'panel',html:'<div style="padding: 10px;"><h3>Under construction</h3></div>'}},this.teamsFeedPanel=new Ext.Panel({id:"stream-module-teams-panel",title:'Teams',autoScroll:true,stateful:true,defaults:{autoWidth:true,autoHeight:true},tbar:{hidden:true,items:[this.viewTeamsMenu=new Ext.Button({text:'View teams',cls:'twitter-buttons',scope:this,menu:[]}),{text:'New team',cls:'twitter-buttons',scope:this,handler:function(btn){new TeamWizard().open();}},this.teamRequestMenu=new Ext.Button({text:'Team request',cls:'twitter-buttons',scope:this,menu:[]}),{text:'Manage Teams',cls:'twitter-buttons',scope:this,handler:function(){Teams.showMain();}}]},items:[{id:'stream-module-teams-check-panel'},this.teamsPanel=new StreamTeamsPanel({id:'stream-module-teams-feed-panel',cls:'preview'})],listeners:{'render':{fn:function(store,r){this.teamsFeedPanel.getTopToolbar().show();this.teamsPanel.store.reload();this.teamsPanel.teamsStore.reload();this.teamsPanel.accountTeamsStore.reload();},scope:this}}}));}
preview.removeClass('preview');preview.topToolbar.doHide();preview.add({id:"contact-"+this.data.id+"-details-panel",hidden:true},{xtype:'tabpanel',id:"contact-"+this.data.id+"-preview-tabs-panel",activeTab:(app.conf.user.edition!='Community')?this.data.no_tasks:0,stateful:false,tbar:false,listeners:{'tabchange':{fn:function(tabPanel,newTab){if(newTab.id=='stream-module-tasks-panel'||newTab.id=='stream-module-notifications-panel'){newTab.store.reload();}
newTab.doLayout();},scope:this},scope:this},items:items});}
preview.doLayout();if(this.data.type_id==301&&this.data.is_editable&&this.data.is_verification_needed){this.verificationNeededDlg=new Ext.Window({width:350,height:130,modal:true,closeAction:'hide',plain:true,buttonAlign:'center',defaults:{flex:1,border:true},title:"Verification needed!",items:{xtype:'panel',height:65,style:'background-color: #FFF; font-weight: bold;',bodyStyle:'padding: 5px;',html:'This company\'s contact details have not been verified. Please check contact details in the right-hand panel and click on the  verify button to confirm they are correct.'},buttons:[{minWidth:120,text:'Close',scope:this,handler:function(){this.verificationNeededDlg.hide();Ext.getCmp("contact-"+this.data.id+"-preview-tabs-panel").setActiveTab(1);}}]});this.verificationNeededDlg.show();}
ContactModule.superclass.initTopPanel.call(this);},showMain:function(){},getProfileDataview:function(){return{xtype:'dataview',store:this.store,tpl:this.parentModule.getPreviewTemplate(false,true),loadingText:'Loading',autoHeight:true,multiSelect:true,overClass:'x-view-over',autoWidth:true,itemSelector:'div.thumb-wrap',prepareData:function(data){if(data.type_id!=301||(data.type_id==301&&data.is_premium)){data.noteActionAdd='&nbsp;<span style="width: auto; '+((data.note&&data.note.length>0)?'display: none;':'')+'" id="internal-note-add-'+data.id+'">No note entered [<a href=# onclick="Ext.getCmp(\'add-contact-note-form-'+data.id+'\').setVisible(true);Ext.get(\'contact-note-text-'+data.id+'\').setDisplayed(false);Ext.get(\'note-editor-'+data.id+'\').setDisplayed(false);Ext.get(this).parent().setDisplayed(false);return false;">Click here to add a note</a>]</span>';data.noteActionEdit='&nbsp;<a href=# style="'+((!data.note||data.note.length==0)?'display: none;':'')+'" id="internal-note-edit-'+data.id+'" id="internal-note-edit-'+data.id+'" onclick="Ext.getCmp(\'add-contact-note-form-'+data.id+'\').setVisible(true);Ext.get(\'contact-note-text-'+data.id+'\').setDisplayed(false);Ext.get(\'note-editor-'+data.id+'\').setDisplayed(false);Ext.get(this).setDisplayed(false);return false;">Edit note</a>';}
return data;},plugins:new Ext.ux.RefreshMenu(),listeners:{'afterrender':{fn:function(c){var tb=c.findParentByType('panel').getTopToolbar();tb.removeAll();tb.add(Contacts.getItemToolbarItems(this.data,this));if(this.data.type_id!=301||(this.data.type_id==301&&this.data.is_premium)){this.addNoteForm=new Ext.form.FormPanel({renderTo:"add-contact-note-"+this.objId,id:"add-contact-note-form-"+this.objId,url:this.makeUrl('saveNote'),labelWidth:0,hideLabels:true,defaults:{xtype:'hidden'},style:'padding-left:0;',buttonAlign:'left',hideMode:'display',items:[this.contactNote=new Ext.form.TextArea({name:'note',xtype:'textarea',hideLabel:true,height:60,allowBlank:false,value:this.data.note}),{xtype:'panel',bodyCssClass:'verified',html:'Note can only be viewed by your team and are encrypted to ensure security'},{name:'id',value:this.objId}],buttons:[{minWidth:80,text:'Save',scope:this,handler:function(){if(this.addNoteForm.getForm().isValid()){this.addNoteForm.getForm().submit({reset:false,failure:function(form,action){Ext.MessageBox.alert('Error Message',action.result.errorInfo);},success:function(form,action){msg('Notification',action.result.info);this.data.id=action.result.contact_id;this.data.note=action.result.note;this.data.note_edited_at=action.result.note_edited_at;this.data.note_editor=action.result.note_editor;this.addNoteForm.setVisible(false);Ext.DomHelper.overwrite(Ext.getDom('contact-note-text-'+this.data.id),Ext.util.Format.nl2br(this.data.note));Ext.get('contact-note-text-'+this.data.id).setDisplayed(true);if(this.data.note){Ext.DomHelper.overwrite(Ext.getDom('note-editor-'+this.objId),'&nbsp;Last edited at '+Ext.util.Format.dtRenderer(this.data.note_edited_at)+' by '+this.data.note_editor+'&nbsp;');Ext.get('note-editor-'+this.data.id).setDisplayed(true);Ext.get('internal-note-edit-'+this.data.id).setDisplayed(true);}else{Ext.get('internal-note-add-'+this.data.id).setDisplayed(true);}
this.contactNote.setValue(this.data.note);},scope:this});}}},{minWidth:80,text:'Cancel',scope:this,handler:function(){this.addNoteForm.setVisible(false);this.contactNote.setValue(this.data.note);Ext.get('contact-note-text-'+this.data.id).setDisplayed(true);Ext.get('note-editor-'+this.data.id).setDisplayed(true);if(this.data.note){Ext.get('note-editor-'+this.data.id).setDisplayed(true);Ext.get('internal-note-edit-'+this.data.id).setDisplayed(true);}else{Ext.get('internal-note-add-'+this.data.id).setDisplayed(true);}}}]});this.addNoteForm.setVisible(false);}
if(Ext.get(this.name+"-voter-panel")){new Ext.ux.Voter({applyTo:this.name+"-voter-panel",url:this.makeUrl('setVote')+"?contactId="+this.data.id,value:this.data.rate,scope:this,callback:function(voter,data){voter.setValue(data.value);voter.scope.afterItemUpdate();}});}}},scope:this}}}});ContactRelationshipsPanel=Ext.extend(Ext.Panel,{title:"Relationships",relationships:true,layout:'fit',initComponent:function(){Ext.apply(this,this.initialConfig);function voteRenderer(value,meta,record,row,col,store){switch(col){case 2:return'<div class="x-voter grid-voter-rate" style="float: left"></div>';case 3:return'<div class="x-voter grid-voter-importance" style="float: left"></div>';case 4:return'<div class="x-voter grid-voter-contr" style="float: left"></div>';}
return"";}
var cm=[new Ext.grid.CheckboxSelectionModel(),{id:'contact',header:"Contact",dataIndex:'contact',width:150},{header:"Their Rating",dataIndex:'rate',width:50,renderer:voteRenderer},{header:"Importance",dataIndex:'importance',width:50,renderer:voteRenderer},{header:"Relationship",dataIndex:'contr_rate',width:50,renderer:voteRenderer},{header:"Type",hidden:true,id:'contact_type',dataIndex:'contact_type',width:100}];this.items=this.grid=new FilteredGrid({recordDef:['id','contact_id','contact_type_id','contact_type','contact','rate','importance','relationship','contr_rate'],cm:cm,pagerUrl:makeUrl("contacts","getRelationshipsPager"),autoExpandColumn:'contact',groupField:'contact_type',isHaveFilter:false,baseParams:{contactId:this.objId},listeners:{'render':{fn:function(){var task=new Ext.util.DelayedTask(this.renderVoters,this,[this,this.objId]);task.delay(500);},scope:this}}});ContactRelationshipsPanel.superclass.initComponent.apply(this);this.grid.store.on('load',function(){try{this.renderVoters(this,this.objId);}catch(e){}},this);},renderVoters:function(element,contactId){var records=element.grid.store.getRange();var els=Ext.get(element.id).select("div[class='x-voter grid-voter-rate']");var active=app.conf.user.contact_id==contactId;for(var i=0;i<els.getCount();i++){var record=records[i];new Ext.ux.Voter({active:active,applyTo:els.elements[i],url:makeUrl('contacts','setVote')+"?contactId="+record.get("contact_id"),value:record.get("rate"),scope:this,callback:function(voter,data){voter.setValue(data.value);}});}
els=Ext.get(element.id).select("div[class='x-voter grid-voter-importance']");for(var i=0;i<els.getCount();i++){var record=records[i];if(record.get('contact_type_id')==301||record.get('contact_type_id')==302){if(record.get('contact_type_id')==301){active=true;}else{active=record.get('contact_id')==app.conf.user.contact_id;}
var url=makeUrl('contacts','setImportance')+"?contactId="+contactId+"&importanceForId= "+record.get("contact_id");if(this.objType=='company'){url=makeUrl('contacts','setImportance')+"?contactId="+record.get("contact_id")+"&importanceForId= "+contactId;active=true;}
new Ext.ux.Voter({active:active,noclick:true,applyTo:els.elements[i],url:url,value:record.get("importance"),scope:this,callback:function(voter,data){voter.setValue(data.value);}});}}
els=Ext.get(element.id).select("div[class='x-voter grid-voter-contr']");for(var i=0;i<els.getCount();i++){var record=records[i];if(record.get('contact_type_id')==301||record.get('contact_type_id')==302){var url;var value;if(this.objType=='company'){value=record.get("relationship");url=makeUrl('contacts','setImportance')+"?contactId="+record.get("contact_id")+"&importanceForId= "+contactId+"&type=relationship";active=true;}else{active=record.get('contact_id')==app.conf.user.contact_id;value=record.get("contr_rate");url=makeUrl('contacts','setVote')+"?contactId="+contactId;}
if(record.get('contact_type_id')==301){active=true;url=makeUrl('contacts','setImportance')+"?contactId="+contactId+"&importanceForId= "+record.get("contact_id")+"&type=relationship";value=record.get("relationship");}
new Ext.ux.Voter({active:active,applyTo:els.elements[i],url:url,value:value,scope:this,callback:function(voter,data){voter.setValue(data.value);}});}}}});ContactActivitiesPanel=Ext.extend(Ext.Panel,{title:"Activities",activities:true,relationships:true,layout:'fit',initComponent:function(){Ext.apply(this,this.initialConfig);var cm=[new Ext.grid.CheckboxSelectionModel(),{header:"Activity",dataIndex:'message',width:80},{header:"Time",dataIndex:'time',width:50,sortable:false},{id:"date",hidden:true,header:"Date",dataIndex:'created_at',renderer:dRenderer,width:50}];var rd=['id','icon','message','time','type','main_type',{name:'created_at',type:'date',dateFormat:app.conf.dtFormat},{name:'is_editable',type:"bool"}];this.items=this.grid=new FilteredGrid({recordDef:rd,cm:cm,pagerUrl:makeUrl("activities","getPager"),autoExpandColumn:'title',groupField:'created_at',sortInfo:{field:"created_at",direction:"DESC"},isHaveFilter:true,filters:[prepareComboBox(makeUrl('contacts','getResponsibleCompaniesOptions'),{hiddenName:"companyId",forceSelection:true,emptyText:'All Companies',labelName:'Company'})],summary:'note',summaryLength:0,dblclickShow:true,showFieldId:"id",baseParams:{objId:this.objId,objType:this.objType},footerAddons:[{iconCls:'icon icon-delete',tooltip:'Delete activity',text:'Delete',scope:this,handler:function(){this.grid.selectionAction('Do you really want to delete?',function(){this.sendJsonRequest(makeUrl('activities','delete'),{ids:this.selectedIdsToJson()});})}}]});ContactActivitiesPanel.superclass.initComponent.apply(this);},resetForm:function(){},fillForm:function(){},edit:function(id){Activities.doEdit(id);},showItem:function(id){Activities.preview(id);}});ContactUpdatesPanel=Ext.extend(Ext.Panel,{title:"Updates",activities:true,layout:'fit',initComponent:function(){Ext.apply(this,this.initialConfig);var cm=[new Ext.grid.CheckboxSelectionModel(),{id:'message',header:"Message",dataIndex:'message',width:330,renderer:function(v,meta,r){return'<div class="icon icon-'+r.get("icon")+'"></div>'+v;}},{header:"Date",hidden:true,dataIndex:'created_at',renderer:dRenderer,width:100},{header:"Time",dataIndex:'time',width:100,sortable:false}];this.items=this.grid=new FilteredGrid({recordDef:['id','type_id','icon','message','time',{name:'created_at',type:'date',dateFormat:app.conf.dtFormat}],cm:cm,pagerUrl:makeUrl('contacts','getUpdatesPager'),autoExpandColumn:'message',groupField:'created_at',sortInfo:{field:"created_at",direction:"DESC"},isHaveFilter:false,baseParams:{entryId:this.objId}});ContactUpdatesPanel.superclass.initComponent.apply(this);}});ContactOpportunitiesPanel=Ext.extend(Ext.Panel,{title:"Opportunities",layout:'fit',initComponent:function(){Ext.apply(this,this.initialConfig);var cm=[new Ext.grid.CheckboxSelectionModel(),{id:'title',header:"Opportunity",dataIndex:'subject',renderer:this.titleRenderer,width:330},{header:"Issue Date",dataIndex:'issue_date',width:100},{header:"Type",dataIndex:'type',width:130},{header:"Status",dataIndex:'status_id',renderer:function(value){switch(parseInt(value)){case 3001:return"Briefed";case 3002:return"Confirmed";case 3003:return"New";case 3004:return"Scheduled";}},width:130},{header:"Deadline",dataIndex:'deadline_at',renderer:dRenderer,width:100}];this.items=this.grid=new FilteredGrid({recordDef:['id','date','time','created_at','subject','description','status_id','issue_date','type','outlet','outlet_id',{name:'deadline_at',type:'date',dateFormat:app.conf.dtFormat}],cm:cm,pagerUrl:this.pagerUrl||makeUrl('contacts','getOpportunitiesPager'),autoExpandColumn:'title',sortInfo:{field:"deadline_at",direction:"ASC"},filters:[prepareComboBox(makeUrl('contacts','getOutletContactOptions'),{hiddenName:"outletId",forceSelection:true,emptyText:'All Outlets',labelName:'Outlet'})],isHaveFilter:true,dblclickShow:true,passDataToView:false,summary:'description',baseParams:{companyId:this.companyId||'',contactId:this.objId,outletId:this.outletId},footerAddons:[{iconCls:'icon icon-tick',text:'Show current only',scope:this,enableToggle:true,pressed:true,toggleHandler:function(btn,state){this.grid.store.baseParams.show_expired=!state;this.grid.store.reload();}}],showItem:function(id,data){app.centerPanel.setActiveTab('requests-panel');Requests.init().showItem(id);}});ContactOpportunitiesPanel.superclass.initComponent.apply(this);Opportunities.init();var opportunities=new OpportunityModule();opportunities.init();this.grid.module=opportunities;var objId=this.objId;var grid=this.grid;this.grid.getPreviewPanel=function(){return Ext.getCmp("contact-"+objId+"-details-panel").ownerCt;}
this.grid.previewItem=function(index){var record=this.store.getAt(index);Ext.getCmp("contact-"+objId+"-preview-tabs-panel").hide();var panel=Ext.getCmp("contact-"+objId+"-details-panel");panel.ownerCt.grid=grid;panel.show();grid.getPreviewPanel().getTopToolbar().show();Opportunities.init().previewItem(record.data.id,record.data,panel.ownerCt,objId)}
this.grid.getSelectionModel().on('rowselect',function(sm,index,record){Ext.getCmp("contact-"+this.objId+"-preview-tabs-panel").hide();var panel=Ext.getCmp("contact-"+this.objId+"-details-panel");panel.ownerCt.grid=this.grid;panel.show();this.grid.getPreviewPanel().getTopToolbar().show();Opportunities.previewItem(record.data.id,record.data,panel.ownerCt,this.objId)},this);},titleRenderer:function(val,p,record,rowIndex,columnIndex,ds){return'<a href=# onclick="showOpportunity('+record.data.id+');" class="item-title">'+val+'</a>';}});ContactCoveragePanel=Ext.extend(Ext.Panel,{title:"Coverage",layout:'fit',initComponent:function(){Ext.apply(this,this.initialConfig);var cm=[new Ext.grid.CheckboxSelectionModel(),{id:'headline',header:"Title",dataIndex:'headline',width:420},{header:"Outlet",dataIndex:'outlet',width:220},{header:"Published At",dataIndex:'published_at',renderer:dRenderer,width:220}];var baseParams={}
if(this.objId){baseParams=Ext.apply(baseParams,{contactId:this.objId});}
if(this.outletId){baseParams=Ext.apply(baseParams,{outletId:this.outletId});}
if(this.companyId){baseParams=Ext.apply(baseParams,{companyId:this.companyId});}
this.items=this.grid=new FilteredGrid({recordDef:['id','headline','headline_for_contacts','url','outlet',{name:'published_at',type:'date',dateFormat:app.conf.dtFormat}],cm:cm,pagerUrl:makeUrl('contacts','getCoveragePager'),autoExpandColumn:'headline',baseParams:baseParams,listeners:{rowdblclick:function(grid,rowIndex,e){open(grid.store.data.items[rowIndex].data.url);}},filters:[prepareComboBox(makeUrl('contacts','getOutletContactOptions'),{hiddenName:"outletId",forceSelection:true,emptyText:'All Outlets',labelName:'Outlet'}),new Ext.form.TextField({hiddenName:'keyword',labelName:'Keyword'})],isHaveFilter:true,footerAddons:[{iconCls:'icon icon-go-to-post',text:'Open source',tooltip:'Open selected clips source',handler:function(){var m=this.getSelections();for(var i=0,len=m.length;i<len;i++){var d=m[i].data;window.open(d.url);self.focus();}}}]});ContactCoveragePanel.superclass.initComponent.apply(this);}});ContactPeoplePanel=Ext.extend(Ext.Panel,{title:"People",layout:'fit',initComponent:function(){Ext.apply(this,this.initialConfig);var cm=[new Ext.grid.CheckboxSelectionModel(),{header:"Contact",dataIndex:'contact',width:330,renderer:this.titleRenderer},{header:"Role",dataIndex:'role_title',width:200},{header:"Office phone",dataIndex:'office_phone',width:200,sortable:false},{header:"Email",dataIndex:'email',width:200,sortable:false}];if(this.objType!='outlet'){cm.push({header:"Type",dataIndex:'type_id',renderer:function(v){switch(v){case 2501:return"Person";case 2502:return"Editorial Staff";case 2504:return"Additional Staff";case 2503:return"Contributor";case 2505:return"Media contact";default:return v;}},width:330,sortable:false});}
var url=makeUrl('outlets','getPeoplePager');switch(this.objType){case'outlet':url=makeUrl('outlets','getPeoplePager');break;case'company':url=makeUrl('companies','getPeoplePager');break;case'companyForJourno':url=makeUrl('companies','getMediaContactsPager');break;}
this.items=this.grid=new FilteredGrid({recordDef:['id','contact_id','related','contact','type_id','role_title','job_title','email','office_phone'],summary:'job_title',cm:cm,pagerUrl:url,isHaveFilter:false,dblclickShow:true,showFieldId:'contact_id',baseParams:{contactId:this.objId},footerAddons:[this.objIsEditable?{text:'Clear Responsibilities',iconCls:'icon icon-delete',handler:function(btn){this.selectionAction('Do you really want to delete responsibilities of selected contacts?',function(){this.sendJsonRequest(makeUrl('companies','clearResponsibilities'),{ids:this.selectedIdsToJson(),contact_id:this.baseParams.contactId},function(scope){scope.store.reload();Ext.getCmp('contact-'+scope.baseParams.contactId+'-panel').store.reload();});});}}:'']});this.grid.module=this;this.grid.getSelectionModel().on('rowselect',function(sm,index,record){this.previewItem(record.data.contact_id,record.data,this.ownerCt.ownerCt.ownerCt.getPanel('preview'));},this);ContactPeoplePanel.superclass.initComponent.apply(this);},previewItem:function(id,data,panel){var grid=this;this.previewStore=new Ext.data.JsonStore({url:makeUrl('contacts','getContact'),autoLoad:false,fields:Contacts.rd,listeners:{'load':{fn:function(scope,rec){var data=rec[0].data;data.tags_links=makeLinks(data.tags_ids,data.tags,'Contacts.showTagged');formatAddressString(data);var p=panel;var el=p.get(0).el;var tb=p.getTopToolbar();tb.removeAll();tb.add({text:'Open',iconCls:'icon icon-person',handler:function(){this.showItem(data.id,Contacts.getTypeById(data.type_id),grid);},scope:this},'->',{text:'Close',iconCls:'icon icon-cross',handler:function(){tb.removeAll();var module=p.ownerCt;tb.add(Contacts.getItemToolbarItems(module.data,module));tb.doLayout();el.hide().update(p.listHtml).slideIn('l',{stopFx:true,duration:.2});}});tb.doLayout();el.hide().update(Contacts.getPreviewTemplate(false,false,this.name).apply(data)).slideIn('l',{stopFx:true,duration:.2});},scope:this}}});this.previewStore.reload({params:{id:id}});},showItem:function(id){showContact(id);},titleRenderer:function(val,p,record,rowIndex,columnIndex,ds){return'<a href=# onclick="showContact('+record.data.contact_id+');" class="item-title">'+val+'</a>';}});ContactRelatedCompaniesAndOutletsPanel=Ext.extend(Ext.Panel,{title:"Companies and Outlets",layout:'fit',initComponent:function(){Ext.apply(this,this.initialConfig);var cm=[new Ext.grid.CheckboxSelectionModel(),{header:"Contact",dataIndex:'related',width:330},{header:"Relation",dataIndex:'type_id',renderer:function(v){switch(v){case 2506:return"Related Outlet";case 2507:return"Partner";case 2508:return"Subsidiary";case 2509:return"Division";default:return v;}},width:330}];this.items=this.grid=new FilteredGrid({recordDef:['related','type_id'],cm:cm,pagerUrl:makeUrl('companies','getRelatedPager'),isHaveFilter:false,baseParams:{contactId:this.objId}});ContactRelatedCompaniesAndOutletsPanel.superclass.initComponent.apply(this);}});ContactCompanyReleasesPanel=Ext.extend(Ext.Panel,{title:"Releases",layout:'fit',initComponent:function(){Ext.apply(this,this.initialConfig);var cm=[new Ext.grid.CheckboxSelectionModel(),{id:'title',header:"Headline",dataIndex:'headline',renderer:this.titleRenderer,width:330},{header:"Published at",dataIndex:'published_at',width:330}];this.previewTpl=new Ext.XTemplate('<tpl for=".">','<div class="details">','<div class="details-header-1" style="float: left">','{title}','</div>','<div class="clear"></div>','<div class="verified" style="font-style: italic;"><tpl if="company_name">For {company_name}</tpl> {pubdate} ago</div>','<div class="clear"></div>','<div class="description">','<div id="preview-release-{id}-body">{body}</div>','<tpl if="body_full.length != 0">','<a id="preview-release-{id}-show-more-link" href=# onclick="Ext.get(\'preview-release-{id}-show-more-link\').setDisplayed(false); Ext.get(\'preview-release-{id}-body\').setDisplayed(false); Ext.get(\'preview-release-{id}-body-full\').setDisplayed(true); return false;">Show more</a>','</tpl>','<tpl if="body_full.length != 0">','<div id="preview-release-{id}-body-full" style="display: none;">{body_full}</div>','</tpl>','</div>','<div class="clear"></div>','<div class="divArrow"><span style="font-weight: bold;">{views_via_prwire} views via PRWire</span></div>','<div class="divArrow"><span style="font-weight: bold;">{total_count_opens} opens from {total_count_recipients} recipients via {count_distributions} distributions</span></div>','<tpl if="mailings">','<tpl for="mailings">','<div style="padding: 0px 0px 5px 12px;">','<a style="font-weight: bold;" onclick="Mailings.showItem({mailing_id}); return false;" href="#">{mailing_title}</a><br>','{count_opens} opens from {count_recipients} recipients and {count_clicks} clicks','</div>','</tpl>','</tpl>','</div>','</tpl>').compile();this.items=this.grid=new FilteredGrid({recordDef:['id','headline','summary','published_at'],cm:cm,pagerUrl:makeUrl('companies','getReleasesPager'),autoExpandColumn:'title',summary:'summary',height:300,isHaveFilter:true,dblclickShow:true,showFieldId:"id",baseParams:{contactId:this.objId},headerAddons:[(this.isResponsible||isAdmin())?[{text:'Add',iconCls:'icon icon-add',scope:this,handler:function(){var dlg=Streams.getDlg('release',this.objId,null);dlg.get(0).get(1).setValue(this.objId);dlg.show();}},{text:'Edit',iconCls:'icon icon-edit',scope:this,handler:function(){if(this.grid.getSelections().length==1){Releases.doEdit(this.grid.getSelections()[0].data.id);}else{msg('Error','Please select one item to process');}}},{text:'Delete',iconCls:'icon icon-delete',scope:this,handler:function(){this.grid.selectionAction('Do you really want to delete this release(s)?',function(){this.sendJsonRequest(makeUrl('releases','delete'),{ids:this.selectedIdsToJson()});});}}]:'',{text:'Send as Email',iconCls:'icon icon-email',scope:this,handler:function(){if(this.grid.getSelections().length){Releases.composeEmail(this.grid.getSelections()[0].data.id);}else{msg('Error','Please select at least one item to process');}}}],filters:[prepareComboBox({emptyText:'Read Status',labelName:'Read Status',hiddenName:'unreaded',store:app.ds.unreaded}),prepareComboBox({emptyText:'All',hiddenName:'starred',labelName:'Stars',store:app.ds.starredTypes}),new Ext.form.TextField({width:100,labelName:'Tag',hiddenName:'tag'})]});ContactCompanyReleasesPanel.superclass.initComponent.apply(this);Reader.init();var reader=new ReaderModule({companyId:this.companyId,contactId:this.objId,profileId:this.profileId});reader.init();this.grid.module=reader;var objId=this.objId;this.grid.getPreviewPanel=function(){return Ext.getCmp("contact-"+objId+"-details-panel").ownerCt;}
this.grid.getSelectionModel().on('rowselect',function(sm,index,record){Ext.getCmp("contact-"+this.objId+"-preview-tabs-panel").hide();var panel=Ext.getCmp("contact-"+this.objId+"-details-panel");panel.ownerCt.grid=this.grid;panel.show();this.grid.getPreviewPanel().getTopToolbar().show();this.previewItem(record.data.id,record.data,panel.ownerCt,this.objId)},this);},previewItem:function(id,data,panel,contactId){var grid=panel.grid;var store=new Ext.data.JsonStore({url:makeUrl('prwire','previewInCompany'),autoLoad:false,fields:['id','title','company_name','pubdate','body','body_full','views_via_prwire','link_prwire','mailings','total_count_opens','total_count_recipients','total_count_clicks','count_distributions'],listeners:{'load':{fn:function(scope,rec){var data=rec[0].data;data.tags_links=makeLinks(data.tags_ids,data.tags,'Ext.getCmp(\''+grid.id+'\').showTagged');var p=grid.getPreviewPanel();var el=p.get(0).el;var tb=p.getTopToolbar();tb.removeAll();tb.add({iconCls:'icon icon-edit',tooltip:'Edit release',text:'Edit',scope:this,handler:function(combo){Releases.doEdit(data.id);}},{text:'Open',iconCls:'icon icon-new-tab',handler:function(){showRelease(data.id);},scope:this},{text:'View on PRWire',iconCls:'icon icon-new-tab',handler:function(){window.open(data.link_prwire);},scope:this},'->',{text:'Close',iconCls:'icon icon-cross',handler:function(){tb.removeAll();tb.hide();if(!contactId){try{el.hide().update(p.listHtml).slideIn('l',{stopFx:true,duration:.2});Ext.DomHelper.overwrite(Ext.getDom(grid.id+'-items-selected'),grid.getSelectionModel().selections.length+'');}catch(e){}}else{Ext.getCmp("contact-"+contactId+"-details-panel").hide();Ext.getCmp("contact-"+contactId+"-preview-tabs-panel").show();}}});tb.doLayout();el.hide().update(this.previewTpl.apply(data)).slideIn('l',{stopFx:true,duration:.2});},scope:this}}});store.reload({params:{id:id}});},resetForm:function(){},edit:function(id){Newsrooms.releasesModule.doEdit(id);},showItem:function(id){Newsrooms.showRelease(id);},titleRenderer:function(val,p,record,rowIndex,columnIndex,ds){return'<a href=# onclick="showRelease('+record.data.id+');" class="item-title">'+val+'</a>';}});ContactPhotosPanel=Ext.extend(Ext.Panel,{title:"Images",layout:'fit',initComponent:function(){Ext.apply(this,this.initialConfig);var cm=[new Ext.grid.CheckboxSelectionModel(),{header:"Thumbnail",dataIndex:'url_normal',renderer:function(value,p,record){return String.format('<img onclick="showPreviewImageDialog(\'{0}\', \'{2}\', \'{2}\')" src="{1}"/>',record.data['url_big'],value,record.data['title']);},width:300},{id:'title',header:"Title",dataIndex:'title',width:120},{header:"Filesize",dataIndex:'filesize',renderer:Ext.util.Format.fileSize,width:60},{header:"Last updated",dataIndex:'updated_at',renderer:dtRenderer,width:100},{header:"Company",dataIndex:'company',width:200}];this.items=this.grid=new FilteredGrid({recordDef:['id','company_id','company','title','filesize','url_normal','url_big',{name:'updated_at',type:'date',dateFormat:app.conf.dtFormat}],cm:cm,pagerUrl:makeUrl('images','getPager'),autoExpandColumn:'title',isHaveFilter:false,baseParams:{contactId:this.objId}});ContactPhotosPanel.superclass.initComponent.apply(this);}});ContactListsPanel=Ext.extend(Ext.Panel,{title:"Lists",layout:'fit',initComponent:function(){Ext.apply(this,this.initialConfig);var cm=[new Ext.grid.CheckboxSelectionModel(),{id:'name',header:"Name",dataIndex:'name',width:330},{header:"Owner",dataIndex:'owner',width:230},{header:"Created At",dataIndex:'created_at',width:100,renderer:dRenderer}];this.items=this.grid=new FilteredGrid({recordDef:['id','name','owner',{name:'created_at',type:'date',dateFormat:app.conf.dtFormat}],cm:cm,pagerUrl:makeUrl('contacts','getListsPager'),autoExpandColumn:'name',sortInfo:{field:"name",direction:"ASC"},isHaveFilter:false,dblclickShow:true,passDataToView:false,baseParams:{contactId:this.objId,outletId:this.outletId,companyId:this.companyId,listType:this.listType},footerAddons:{iconCls:'icon icon-delete',text:'Remove',tooltip:'Remove contact from selected lists',scope:this,handler:function(btn){this.grid.selectionAction('Do you really want to delete contact from selected lists?',function(){sendJsonRequest(makeUrl('lists','removeContactFromLists'),{ids:this.selectedIdsToJson(),contactId:btn.scope.objId},'reload',this);});}},showItem:function(id,data,grid){Lists.showItem(id,data,grid);}});ContactListsPanel.superclass.initComponent.apply(this);}});ContactPitchesPanel=Ext.extend(Ext.Panel,{title:"Pitch Tips",layout:'fit',autoScroll:true,initComponent:function(){Ext.apply(this,this.initialConfig);this.items=[{xtype:'dataview',store:{xtype:'jsonstore',url:makeUrl('contacts','getPitches')+'?contactId='+this.objId,autoLoad:true,root:'results',fields:['id','question','answer']},tpl:['<tpl for=".">','<div class="pitch"><b>{question}</b> - {answer}</div>','<div class="clear"></div>','</tpl>'],loadingText:'Loading',autoHeight:true,multiSelect:true,overClass:'x-view-over',autoWidth:true,itemSelector:'div.thumb-wrap',plugins:new Ext.ux.RefreshMenu()}]
ContactPitchesPanel.superclass.initComponent.apply(this);}});ContactAnalysisPanel=Ext.extend(Ext.Panel,{title:"Analisys",layout:'fit',initComponent:function(){Ext.apply(this,this.initialConfig);this.items=[{title:'Keywords cloud',html:'<div id="test4" class="overview-tagcloud"></div>'}];this.on('afterlayout',function(){var cloud=new Ext.ux.TagCloud({store:prepareDs(makeUrl('contacts','keywordsCloud')+'?id='+this.objId+'&type='+this.objType,[{name:'count'},{name:'keyword'}],false),displayField:'keyword',weightField:'count',loadMask:true,displayWeight:false,tagsName:'tags'})
new Ext.Panel({renderTo:'test4',items:cloud})
cloud.store.reload();},this);ContactAnalysisPanel.superclass.initComponent.apply(this);}});PersonOverviewPanel=Ext.extend(Ext.Panel,{title:"Overview",layout:'fit',bodyStyle:'overflow-y: scroll; overflow-x: hidden;, color: red; padding-right: 20px;',initComponent:function(){Ext.apply(this,this.initialConfig);this.items=[{xtype:'dataview',store:this.store=prepareDs(makeUrl('persons','getPersonOverviewData')+'?contact_id='+this.objId,['stories','updates','activities','words','twitter_statuses','profile_user','profile_partner','profile_account','pitch_tips','profile_user_full','profile_partner_full','profile_account_full']),plugins:new Ext.ux.RefreshMenu(),tpl:new Ext.XTemplate('<tpl for=".">','<div class="overview-container">','<div class="block-title"><h1 style="padding-left: 0;">Profiles</h1>'+'<tpl if="pitch_tips.length != 0">','<a id="person-'+this.objId+'-pitch-tips" style="margin-left: 5px;" href=# class="see-more" >Pitch Tips</a>'+'<else >','</tpl>','<tpl if="profile_user.length != 0">','<a id="person-'+this.objId+'-user-profile" style="margin-left: 5px;" href=# class="see-more">User Profile</a>'+'</tpl>','<tpl if="pitch_tips.length == 0">','<a id="person-'+this.objId+'-pitch-tips" style="display: none; margin-left: 5px;" href=# class="see-more" >Pitch Tips</a>'+'<else >','</tpl>','<tpl if="profile_user.length == 0">','<a hidden="true" id="person-'+this.objId+'-user-profile"  style="display: none; margin-left: 5px;" href=# class="see-more">User Profile</a>'+'</tpl>','<a id="person-'+this.objId+'-account-profile" style="margin-left: 5px;" href=# class="see-more">Account Profile</a>'+'<a id="person-'+this.objId+'-system-profile" style="margin-left: 5px; font-weight: bold;" href=# class="see-more">System Profile</a>'+'<hr style="margin-left: 0;"></div>','<div><div id="person-'+this.objId+'-system-profile-text" class="analysis" style="text-align: justify;">{profile_partner}<tpl if="profile_partner_full.length != 0"><a id="person-'+this.objId+'show-more-partner-profile" href=# onclick="streamAction(\'person-'+this.objId+'show-more-partner-profile\', \'show_more\'); return false;">Show more</a></tpl></div><tpl if="profile_partner_full.length != 0"><div id="person-'+this.objId+'-system-profile-full-text" class="note note-full" style="display: none; text-align: justify;">{profile_partner_full}</div></tpl></div>','<div><div hidden ="true" id="person-'+this.objId+'-account-profile-text" class="analysis" style="text-align: justify;">{profile_account}<tpl if="profile_account_full.length != 0"><a id="person-'+this.objId+'show-more-account-profile" href=# onclick="streamAction(\'person-'+this.objId+'show-more-account-profile\', \'show_more\'); return false;">Show more</a></tpl></div><tpl if="profile_account_full.length != 0"><div id="person-'+this.objId+'-account-profile-full-text" class="note note-full" style="display: none; text-align: justify;">{profile_account_full}</div></tpl><br><div id="person-'+this.objId+'-account-profile-edit-form"></div><a href="#" style="display: none;" id="person-'+this.objId+'-account-profile-edit-link">Edit profile</a></div>','<div><div hidden ="true" id="person-'+this.objId+'-user-profile-text" class="analysis" style="text-align: justify;">{profile_user}<tpl if="profile_user_full.length != 0"><a id="person-'+this.objId+'show-more-user-profile" href=# onclick="streamAction(\'person-'+this.objId+'show-more-user-profile\', \'show_more\'); return false;">Show more</a></tpl></div><tpl if="profile_user_full.length != 0"><div id="person-'+this.objId+'-user-profile-full-text" class="note note-full" style="display: none; text-align: justify;">{profile_user_full}</div></tpl></div>','<tpl if="pitch_tips.length != 0">','<div hidden ="true" id="person-'+this.objId+'-pitch-tips-text" class="analysis">','<tpl for="pitch_tips">','<div class="updates-item" style="text-align: justify;">','<span style="font-weight: bold;">{question}</span> - {answer}<br>','</div>','</tpl>','</div>','</tpl>','</div>','<table border=0 cellpadding=0 cellspacing=0 width="100%" class="item-overview"><tr valign="top">','<td width="50%">','<tpl if="stories.length != 0">','<div class="overview-container">','<div class="block-title"><h1>Latest Articles</h1><a id="person-',this.objId,'-all-coverage" href=# class="see-more">All coverage</a><hr/></div>','<tpl for="stories">','<div class="updates-item">','<tpl if="link != 0"><a href="{link}" target="_blank" class="title">{headline}</a><br></tpl>','<tpl if="link == 0"><a href=# onclick="showClip({id});" class="title">{headline}</a><br></tpl>','<tpl if="outlet"><span class="item-info">{outlet}</span> | </tpl>{created_at} ago','</div>','</tpl>','</div>','</tpl>','<tpl if="activities.length != 0">','<div class="overview-container">','<div class="block-title"><h1>Latest Activities</h1><a id="person-',this.objId,'-all-activities" href=# class="see-more">All activities</a><hr/></div>','<tpl for="activities">','<div class="updates-item">','{message} <span class="item-info">{created_at} ago</span><br>{desc}','</div>','</tpl>','</div>','</tpl>','</td><td>','<div class="overview-container tools-block">','<div class="block-title"><h1>Word Cloud</h1><a href=# class="see-more" onclick="Contacts.openWordCloud(',this.objId,',\'',this.objType,'\')">All word cloud</a><hr/></div>','<div id="person-'+this.objId+'-word-cloud" class="word-cloud"></div>','</div>','<tpl if="twitter_statuses">','<div class="overview-container">','<div class="block-title"><h1>Social Media</h1><hr></div>','<div id="person-'+this.objId+'-twitter-updates"></div>','</div>','</tpl>','</td>','</tr></table>','</tpl>').compile()}];this.on('afterrender',function(){this.store.addListener('load',function(store,data){var cloud=new Ext.ux.TagCloud({store:prepareDs(makeUrl('contacts','keywordsCloud')+'?id='+this.objId+'&type='+this.objType,[{name:'count'},{name:'keyword'}],false),displayField:'keyword',weightField:'count',loadMask:true,displayWeight:false,tagsName:'tags',listeners:{'tagselect':{fn:function(cloud,tag,idx,el){var tabs=this.ownerCt;var p=tabs.ownerCt.ownerCt.coveragePanel;tabs.activate(p);p.grid.loadFilters({keyword:tag.data.keyword});},scope:this}}});new Ext.Panel({renderTo:'person-'+this.objId+'-word-cloud',items:cloud});cloud.store.reload();if(Ext.get('person-'+this.objId+'-all-coverage')){Ext.get('person-'+this.objId+'-all-coverage').on('click',function(){Ext.getCmp('contact-'+this.objId+'-tabs-panel').setActiveTab(2);},this);}
if(Ext.get('person-'+this.objId+'-all-activities')){Ext.get('person-'+this.objId+'-all-activities').on('click',function(){Ext.getCmp('contact-'+this.objId+'-tabs-panel').setActiveTab(1);},this);}
if(Ext.get('person-'+this.objId+'-system-profile')){Ext.get('person-'+this.objId+'-system-profile').on('click',function(){setVisibleProfile('system-profile',this.objId);},this);}
if(Ext.get('person-'+this.objId+'-account-profile')){Ext.get('person-'+this.objId+'-account-profile').on('click',function(){setVisibleProfile('account-profile',this.objId);},this);}
if(Ext.get('person-'+this.objId+'-user-profile')){Ext.get('person-'+this.objId+'-user-profile').on('click',function(){setVisibleProfile('user-profile',this.objId);},this);}
if(Ext.get('person-'+this.objId+'-pitch-tips')){Ext.get('person-'+this.objId+'-pitch-tips').on('click',function(){setVisibleProfile('pitch-tips',this.objId);},this);}
function setVisibleProfile(profile,objectId){if(Ext.get('person-'+objectId+'-account-profile-text')){Ext.get('person-'+objectId+'-account-profile-text').setStyle('display','none');Ext.get('person-'+objectId+'-account-profile').setStyle('font-weight','normal');}
if(Ext.get('person-'+objectId+'-account-profile-full-text')){Ext.get('person-'+objectId+'-account-profile-full-text').setStyle('display','none');}
if(Ext.get('person-'+objectId+'-system-profile-text')){Ext.get('person-'+objectId+'-system-profile-text').setStyle('display','none');Ext.get('person-'+objectId+'-system-profile').setStyle('font-weight','normal');}
if(Ext.get('person-'+objectId+'-system-profile-full-text')){Ext.get('person-'+objectId+'-system-profile-full-text').setStyle('display','none');}
if(Ext.get('person-'+objectId+'-user-profile-text')){Ext.get('person-'+objectId+'-user-profile-text').setStyle('display','none');Ext.get('person-'+objectId+'-user-profile').setStyle('font-weight','normal');}
if(Ext.get('person-'+objectId+'-user-profile-full-text')){Ext.get('person-'+objectId+'-user-profile-full-text').setStyle('display','none');}
if(Ext.get('person-'+objectId+'-pitch-tips-text')){Ext.get('person-'+objectId+'-pitch-tips-text').setStyle('display','none');Ext.get('person-'+objectId+'-pitch-tips').setStyle('font-weight','normal');}
Ext.get('person-'+objectId+'-'+profile+'-text').setVisible(true);Ext.get('person-'+objectId+'-'+profile).setStyle('font-weight','bold');if(profile!='account-profile'){Ext.get('person-'+objectId+'-account-profile-edit-link').setDisplayed(false);}else{Ext.get('person-'+objectId+'-account-profile-edit-link').setDisplayed(true);}
var form=Ext.getCmp('person-'+objectId+'-account-profile-edit-form-cmp');if(form){form.hide();}};if(Ext.get('person-'+this.objId+'-account-profile-edit-link')){Ext.get('person-'+this.objId+'-account-profile-edit-link').on('click',function(){this.showEditProfile(this.objId);},this);}
this.profileEditForm=new Ext.FormPanel({renderTo:'person-'+this.objId+'-account-profile-edit-form',id:'person-'+this.objId+'-account-profile-edit-form-cmp',hidden:true,buttonAlign:'left',cls:'profile-inline-edit',hideLabels:true,style:'padding: 0;',items:[{xtype:'htmleditor',width:600,height:200,value:data[0].data.profile_account_full||data[0].data.profile_account,name:'account-profile-text'}],buttons:[{text:'Save',width:80,scope:this,handler:function(btn){sendJsonRequest(makeUrl('persons','updateAccountProfile'),{id:this.objId,text:this.profileEditForm.items.items[0].getValue()},function(scope){scope.profileEditForm.hide();setVisibleProfile('account-profile',scope.objId);Ext.get('person-'+scope.objId+'-account-profile-edit-link').setDisplayed(true);Ext.get('person-'+scope.objId+'-account-profile-text').dom.innerHTML=scope.profileEditForm.items.items[0].getValue();},this);}},{text:'Cancel',width:80,style:'margin-left: 5px;',scope:this,handler:function(btn){this.profileEditForm.hide();setVisibleProfile('account-profile',this.objId);Ext.get('person-'+this.objId+'-account-profile-edit-link').setDisplayed(true);}}]});if(Ext.get('person-'+this.objId+'-twitter-updates')){this.twitterDataView=new Ext.DataView({store:prepareDs(makeUrl('persons','getTwitterUpdates'),['updates'],false,this.objId),renderTo:'person-'+this.objId+'-twitter-updates',tpl:new Ext.XTemplate('<tpl for=".">','<tpl for="updates">','<div class="updates-item">','<div class="portlet-item"><div class="ico-new ico-new-twitter"></div>{message} <span class="item-info">{created_at} ago</span>','</div>','</div><tpl if="xindex!=xcount"><hr></tpl>','</tpl>','</tpl>'),autoHeight:true,loadingText:'Loading twitter updates',multiSelect:true,overClass:'x-view-over',itemSelector:'div.thumb-wrap'});this.twitterDataView.store.reload();this.delayTask=new Ext.util.DelayedTask(function(){this.twitterDataView.store.reload();this.delayTask.delay(60*3*1000);},this)
this.delayTask.delay(60*3*1000);}},this);this.items.items[0].store.load();},this);PersonOverviewPanel.superclass.initComponent.apply(this);},refresh:function(){this.store.reload();},showEditProfile:function(objectId){this.profileEditForm.show();if(Ext.get('person-'+objectId+'-account-profile-text')){Ext.get('person-'+objectId+'-account-profile-text').setDisplayed(false);Ext.get('person-'+objectId+'-account-profile').setStyle('font-weight','normal');}
if(Ext.get('person-'+objectId+'-account-profile-full-text')){Ext.get('person-'+objectId+'-account-profile-full-text').setDisplayed(false);}
Ext.get('person-'+this.objId+'-account-profile-edit-link').setDisplayed(false);Ext.get('person-'+this.objId+'-account-profile').setStyle('font-weight','bold');}});OutletOverviewPanel=Ext.extend(Ext.Panel,{title:"Overview",layout:'fit',bodyStyle:'overflow-y: scroll; overflow-x: hidden;, color: red; padding-right: 20px;',initComponent:function(){Ext.apply(this,this.initialConfig);this.items=[{xtype:'dataview',store:this.store=prepareDs(makeUrl('outlets','getOutletOverviewData')+'?contact_id='+this.objId,['updates','activities','words','profile_partner','profile_account','profile_partner_full','profile_account_full','key_editorials','opportunities','clips','activities','cover','related_outlets','topics']),plugins:new Ext.ux.RefreshMenu(),tpl:new Ext.XTemplate('<tpl for=".">','<div class="overview-container">','<div class="block-title"><h1 style="padding-left: 0;">Profiles</h1>'+'<tpl if="!'+isPartnerAdmin()+'"><a id="outlet-'+this.objId+'-account-profile" style="margin-left: 5px;" href=# class="see-more">Account Profile</a></tpl>'+'<a id="outlet-'+this.objId+'-system-profile" style="margin-left: 5px; font-weight: bold;" href=# class="see-more">System Profile</a>'+'<hr style="margin-left: 0;"></div>','<table><tr valign="top">','<td>','<tpl if="cover != 0"><img src="{cover}"></tpl>','</td>','<tpl if="cover != 0"><td><span style="padding-left: 20px"> </span></td></tpl>','<td>','<div><div id="outlet-'+this.objId+'-system-profile-text" style="text-align: justify;" class="analysis">{profile_partner}<tpl if="profile_partner_full.length != 0"><a id="outlet-'+this.objId+'show-more-partner-profile" href=# onclick="streamAction(\'outlet-'+this.objId+'show-more-partner-profile\', \'show_more\'); return false;">Show more</a></tpl></div><tpl if="profile_partner_full.length != 0"><div id="outlet-'+this.objId+'-system-profile-full-text" class="note note-full" style="display: none; text-align: justify;">{profile_partner_full}</div></tpl></div>','<tpl if="!'+isPartnerAdmin()+'"><div><div hidden ="true" id="outlet-'+this.objId+'-no-account-profile-text" style="text-align: justify;" class="analysis">You do not have an Account Profile for this person. Account Profiles are private and encrypted so they can only be seen by users of your account.</div></div></tpl>','<tpl if="!'+isPartnerAdmin()+'"><div><div hidden ="true" id="outlet-'+this.objId+'-account-profile-text" style="text-align: justify;" class="analysis">{profile_account}<tpl if="profile_account_full.length != 0"><a id="outlet-'+this.objId+'show-more-account-profile" href=# onclick="streamAction(\'outlet-'+this.objId+'show-more-account-profile\', \'show_more\'); return false;">Show more</a></tpl></div><tpl if="profile_account_full.length != 0"><div id="outlet-'+this.objId+'-account-profile-full-text" class="note note-full" style="display: none; text-align: justify;">{profile_account_full}</div></tpl><br><div id="outlet-'+this.objId+'-account-profile-edit-form"></div><a href="#" style="display: none;" id="outlet-'+this.objId+'-account-profile-edit-link">Edit profile</a></div></tpl>','</td>','</tr></table>','</div>','<table border=0 cellpadding=0 cellspacing=0 width="100%" class="item-overview"><tr valign="top">','<td width="50%">','<tpl if="key_editorials.length != 0">','<div class="overview-container">','<div class="block-title"><h1>Key Editorial</h1><a id="outlet-',this.objId,'-key-editorial" href=# class="see-more">All People</a><hr/></div>','<tpl for="key_editorials">','<div class="updates-item">','<table><tr valign="top">','<td width="50px">','<tpl if="key_editorial_logo != 0"><img src="{key_editorial_logo}"></tpl>','</td>','<td> </td>','<td> </td>','<td>','<a href=# onclick="showPerson({person_contact_id});" class="title">{name}</a><br>','<span style="font-weight:bold;">{role}</span> <span style="color:gray;">{phone}</span><br>','<a href="mailto:{email}">{email}</a><br>','</td>','</tr></table>','</div>','</tpl>','</div>','</tpl>','<tpl if="related_outlets.length != 0">','<div class="overview-container">','<div class="block-title"><h1>Related Outlets</h1><a id="outlet-',this.objId,'-related-outlets" href=# class="see-more">All Related Outlets</a><hr/></div>','<tpl for="related_outlets">','<div class="updates-item">','<table><tr valign="top">','<td width="50px">','<tpl if="related_outlet_logo != 0"><img src="{related_outlet_logo}"></tpl>','</td>','<td> </td>','<td> </td>','<td>','<a href=# onclick="showOutlet({related_outlet_contact_id});" class="title">{related_outlet_name}</a><br>','<span style="font-weight:bold;">Type:</span> {type}<br>','<tpl if="mediacontact.length != 0"><tpl for="mediacontact"><a href=# onclick="showPerson({person_contact_id});">{person_name} {person_phone}</a><br></tpl></tpl>','</td>','</tr></table>','</div>','</tpl>','</div>','</tpl>','<tpl if="opportunities.length != 0">','<div class="overview-container">','<div class="block-title"><h1>Opportunities</h1><a id="outlet-',this.objId,'-all-opportunities" href=# class="see-more">All Opportunities</a><hr/></div>','<tpl for="opportunities">','<div class="updates-item">','<tpl if="readed == 0"><div class="icon icon-new"/></div></tpl><a href=# onclick="Opportunities.showItem({id});/* showOpportunity({id});*/" class="title">{subject} </a>','<i>Deadline: {deadline}</i><br>','<a href=# onclick="showPerson({person_contact_id});">{person_name} </a>','<i>posted {time} ago</i><br>','</div>','</tpl>','</div>','</tpl>','</td><td>','<tpl if="topics.length != 0">','<div class="overview-container">','<div class="block-title"><h1>Topics covered</h1><hr/></div>','<tpl for="topics">','<div class="updates-item">','<a href=# onclick="" class="title">{beat}</a> ({regularity})<br>','<tpl if="persons.length != 0"><tpl for="persons"><a href=# onclick="showPerson({person_contact_id});">{person_name} {person_phone}</a><tpl if="xindex != xcount">, </tpl></tpl><br></tpl>','{summary}<br>','<tpl if="outlets.length != 0"><span style="font-weight:bold;">Related outlets: </span><tpl for="outlets"><a href=# onclick="showOutlet({outlet_contact_id});">{outlet_title}</a><tpl if="xindex != xcount">, </tpl></tpl><br></tpl>','<tpl if="beats.length != 0"><span style="font-weight:bold;">Additional beats: </span><tpl for="beats">{beat_name}<tpl if="xindex != xcount">, </tpl></tpl><br></tpl>','</div>','</tpl>','</div>','</tpl>','<tpl if="clips.length != 0">','<div class="overview-container">','<div class="block-title"><h1>Latest Coverage</h1><a id="outlet-',this.objId,'-all-coverage" href=# class="see-more">All Articles</a><hr/></div>','<tpl for="clips">','<div class="updates-item">','<tpl if="link != 0"><a href="{link}" target="_blank" class="title">{headline}</a><br></tpl>','<tpl if="link == 0"><a href=# onclick="showClip({id});" class="title">{headline}</a><br></tpl>','<tpl if="outlet != 0"><span class="item-info">{outlet}</span> | </tpl>{created_at} ago','</div>','</tpl>','</div>','</tpl>','<tpl if="activities.length != 0">','<div class="overview-container">','<div class="block-title"><h1>Latest Activities</h1><a id="outlet-',this.objId,'-all-activities" href=# class="see-more">All Activities</a><hr/></div>','<tpl for="activities">','<div class="updates-item">','{message} <span class="item-info">{created_at} ago</span><br>{desc}','</div>','</tpl>','</div>','</tpl>','<div class="overview-container tools-block">','<div class="block-title"><h1>Word Cloud</h1><a href=# class="see-more" onclick="Contacts.openWordCloud(',this.objId,',\'',this.objType,'\')">All word cloud</a><hr/></div>','<div id="outlet-'+this.objId+'-word-cloud" class="word-cloud"></div>','</div>','</td>','</tr></table>','</tpl>').compile()}];this.on('afterrender',function(){this.store.addListener('load',function(store,data){var companyId='';if(this.store.baseParams.company_id){companyId='&company_id='+this.store.baseParams.company_id;}
var cloud=new Ext.ux.TagCloud({store:prepareDs(makeUrl('contacts','keywordsCloud')+'?id='+this.objId+'&type='+this.objType+companyId,[{name:'count'},{name:'keyword'}],false),displayField:'keyword',weightField:'count',loadMask:true,displayWeight:false,tagsName:'tags',listeners:{'tagselect':{fn:function(cloud,tag,idx,el){var tabs=this.ownerCt;var p=tabs.ownerCt.ownerCt.coveragePanel;tabs.activate(p);p.grid.loadFilters({keyword:tag.data.keyword});},scope:this}}});new Ext.Panel({renderTo:'outlet-'+this.objId+'-word-cloud',items:cloud});cloud.store.reload();Ext.get('outlet-'+this.objId+'-system-profile').on('click',function(){setVisibleProfile('system-profile',this.objId);},this);if(Ext.get('outlet-'+this.objId+'-account-profile')){Ext.get('outlet-'+this.objId+'-account-profile').on('click',function(){setVisibleProfile('account-profile',this.objId);},this);}
if(Ext.get('outlet-'+this.objId+'-key-editorial')){Ext.get('outlet-'+this.objId+'-key-editorial').on('click',function(){Ext.getCmp('contact-'+this.objId+'-tabs-panel').setActiveTab(2);},this);}
if(Ext.get('outlet-'+this.objId+'-related-outlets')){Ext.get('outlet-'+this.objId+'-related-outlets').on('click',function(){Ext.getCmp('contact-'+this.objId+'-tabs-panel').setActiveTab(3);},this);}
if(Ext.get('outlet-'+this.objId+'-all-opportunities')){Ext.get('outlet-'+this.objId+'-all-opportunities').on('click',function(){Ext.getCmp('contact-'+this.objId+'-tabs-panel').setActiveTab(4);},this);}
if(Ext.get('outlet-'+this.objId+'-all-coverage')){Ext.get('outlet-'+this.objId+'-all-coverage').on('click',function(){Ext.getCmp('contact-'+this.objId+'-tabs-panel').setActiveTab(5);},this);}
if(Ext.get('outlet-'+this.objId+'-all-activities')){Ext.get('outlet-'+this.objId+'-all-activities').on('click',function(){Ext.getCmp('contact-'+this.objId+'-tabs-panel').setActiveTab(1);},this);}
function setVisibleProfile(profile,objectId){if(Ext.get('outlet-'+objectId+'-account-profile-text')){Ext.get('outlet-'+objectId+'-account-profile-text').setStyle('display','none');Ext.get('outlet-'+objectId+'-account-profile').setStyle('font-weight','normal');}
if(Ext.get('outlet-'+objectId+'-account-profile-full-text')){Ext.get('outlet-'+objectId+'-account-profile-full-text').setStyle('display','none');}
if(Ext.get('outlet-'+objectId+'-system-profile-text')){Ext.get('outlet-'+objectId+'-system-profile-text').setStyle('display','none');Ext.get('outlet-'+objectId+'-system-profile').setStyle('font-weight','normal');}
if(Ext.get('outlet-'+objectId+'-system-profile-full-text')){Ext.get('outlet-'+objectId+'-system-profile-full-text').setStyle('display','none');}
Ext.get('outlet-'+objectId+'-'+profile+'-text').setVisible(true);Ext.get('outlet-'+objectId+'-'+profile).setStyle('font-weight','bold');if(!isPartnerAdmin()){if(profile!='account-profile'){Ext.get('outlet-'+objectId+'-account-profile-edit-link').setDisplayed(false);Ext.get('outlet-'+objectId+'-no-account-profile-text').setStyle('display','none');}else{Ext.get('outlet-'+objectId+'-account-profile-edit-link').setDisplayed(true);checkAccountProfile(objectId);}
var form=Ext.getCmp('outlet-'+objectId+'-account-profile-edit-form-cmp');if(form){form.hide();}}};function checkAccountProfile(objectId){if((Ext.get('outlet-'+objectId+'-account-profile-text').dom.innerHTML=='<br>')||(Ext.get('outlet-'+objectId+'-account-profile-text').dom.innerHTML=='')){Ext.get('outlet-'+objectId+'-no-account-profile-text').setVisible(true);}
else{Ext.get('outlet-'+objectId+'-no-account-profile-text').setStyle('display','none');}}
if(Ext.get('outlet-'+this.objId+'-account-profile-edit-link')){Ext.get('outlet-'+this.objId+'-account-profile-edit-link').on('click',function(){this.showEditProfile(this.objId);},this);}
if(!isPartnerAdmin()){this.profileEditForm=new Ext.FormPanel({renderTo:'outlet-'+this.objId+'-account-profile-edit-form',id:'outlet-'+this.objId+'-account-profile-edit-form-cmp',hidden:true,buttonAlign:'left',cls:'profile-inline-edit',hideLabels:true,style:'padding: 0;',items:[{xtype:'htmleditor',width:500,height:200,value:data[0].data.profile_account_full||data[0].data.profile_account,name:'account-profile-text'}],buttons:[{text:'Save',width:80,scope:this,handler:function(btn){sendJsonRequest(makeUrl('outlets','updateAccountProfile'),{id:this.objId,text:this.profileEditForm.items.items[0].getValue()},function(scope){scope.profileEditForm.hide();setVisibleProfile('account-profile',scope.objId);Ext.get('outlet-'+scope.objId+'-account-profile-edit-link').setDisplayed(true);Ext.get('outlet-'+scope.objId+'-account-profile-text').dom.innerHTML=scope.profileEditForm.items.items[0].getValue();checkAccountProfile(scope.objId);},this);}},{text:'Cancel',width:80,style:'margin-left: 5px;',scope:this,handler:function(btn){this.profileEditForm.hide();setVisibleProfile('account-profile',this.objId);Ext.get('outlet-'+this.objId+'-account-profile-edit-link').setDisplayed(true);}}]});}},this);this.items.items[0].store.load();},this);OutletOverviewPanel.superclass.initComponent.apply(this);},refresh:function(){this.store.reload();},showEditProfile:function(objectId){this.profileEditForm.show();if(Ext.get('outlet-'+objectId+'-account-profile-text')){Ext.get('outlet-'+objectId+'-account-profile-text').setDisplayed(false);Ext.get('outlet-'+objectId+'-account-profile').setStyle('font-weight','normal');}
if(Ext.get('outlet-'+objectId+'-account-profile-full-text')){Ext.get('outlet-'+objectId+'-account-profile-full-text').setDisplayed(false);}
Ext.get('outlet-'+this.objId+'-account-profile-edit-link').setDisplayed(false);Ext.get('outlet-'+this.objId+'-account-profile').setStyle('font-weight','bold');}});ContactRelatedOutletsPanel=Ext.extend(Ext.Panel,{title:"Related Outlets",layout:'fit',initComponent:function(){Ext.apply(this,this.initialConfig);var cm=[new Ext.grid.CheckboxSelectionModel(),{header:"Title",dataIndex:'title',width:330,renderer:this.titleRenderer},{header:"Format",dataIndex:'format',width:200},{header:"Media Contact",dataIndex:'mediacontact_name',width:200,sortable:false},{header:"Phone Number",dataIndex:'phone',width:200,sortable:false}];var url=makeUrl('outlets','getRelatedOutletsPager');this.items=this.grid=new FilteredGrid({recordDef:['id','contact_id','title','format','phone','mediacontact_name','job_title','email','office_phone','description','mediacontact'],summary:'description',cm:cm,pagerUrl:url,isHaveFilter:false,dblclickShow:true,showFieldId:'contact_id',baseParams:{contactId:this.objId},footerAddons:[this.objIsEditable?{text:'Clear Responsibilities',iconCls:'icon icon-delete',handler:function(btn){this.selectionAction('Do you really want to delete responsibilities of selected contacts?',function(){this.sendJsonRequest(makeUrl('companies','clearResponsibilities'),{ids:this.selectedIdsToJson(),contact_id:this.baseParams.contactId},function(scope){scope.store.reload();Ext.getCmp('contact-'+scope.baseParams.contactId+'-panel').store.reload();});});}}:'']});this.grid.module=this;this.grid.getSelectionModel().on('rowselect',function(sm,index,record){this.previewItem(record.data.contact_id,record.data,this.ownerCt.ownerCt.ownerCt.getPanel('preview'));},this);ContactRelatedOutletsPanel.superclass.initComponent.apply(this);},previewItem:function(id,data,panel){var grid=this;this.previewStore=new Ext.data.JsonStore({url:makeUrl('contacts','getContact'),autoLoad:false,fields:Contacts.rd,listeners:{'load':{fn:function(scope,rec){var data=rec[0].data;data.tags_links=makeLinks(data.tags_ids,data.tags,'Contacts.showTagged');formatAddressString(data);var p=panel;var el=p.get(0).el;var tb=p.getTopToolbar();tb.removeAll();tb.add({text:'Open',iconCls:'icon icon-person',handler:function(){this.showItem(data.id,Contacts.getTypeById(data.type_id),grid);},scope:this},'->',{text:'Close',iconCls:'icon icon-cross',handler:function(){tb.removeAll();var module=p.ownerCt;tb.add(Contacts.getItemToolbarItems(module.data,module));tb.doLayout();el.hide().update(p.listHtml).slideIn('l',{stopFx:true,duration:.2});}});tb.doLayout();el.hide().update(Contacts.getPreviewTemplate(false,false,this.name).apply(data)).slideIn('l',{stopFx:true,duration:.2});},scope:this}}});this.previewStore.reload({params:{id:id}});},showItem:function(id){showContact(id);},titleRenderer:function(val,p,record,rowIndex,columnIndex,ds){return'<a href=# onclick="showContact('+record.data.contact_id+');" class="item-title">'+val+'</a>';}});CompanyOverviewPanel=Ext.extend(Ext.Panel,{title:"Overview",layout:'fit',bodyStyle:'overflow-y: scroll; overflow-x: hidden;, color: red; padding-right: 20px;',initComponent:function(){Ext.apply(this,this.initialConfig);this.items=[{xtype:'dataview',store:this.store=prepareDs(makeUrl('companies','getCompanyOverviewData')+'?contact_id='+this.objId,['contact_id','company_id','clips','clips_count','clips_range','releases','releases_count','releases_range','total_views_per_period','activities','activities_count','interactions_range','chart_period','chart_range','upcoming_opp','upcoming_opp_count','upcoming_opp_range','no_opportunity_lists']),plugins:new Ext.ux.RefreshMenu(),tpl:new Ext.XTemplate('<tpl for=".">','<div class="overview-container">','<div class="block-title sprite sprite-chart"><h1>Outcomes</h1><h2 class="dropdown-options" onclick="Companies.showPeriodOptionsForChart(this, event, '+this.objId+');return false;">last {chart_range}</h2><a href=# class="see-more chart-period <tpl if="chart_period == \'month\'">bold</tpl>" onclick="Companies.changeChartPeriod(this, \'month\', '+this.objId+');return false;">Months</a><a href=# class="see-more chart-period  <tpl if="chart_period == \'week\'">bold</tpl>" style="margin-right: 3px;" onclick="Companies.changeChartPeriod(this, \'week\', '+this.objId+');return false;">Weeks</a><a href=# class="see-more chart-period  <tpl if="chart_period == \'day\'">bold</tpl>" style="margin-right: 3px;" onclick="Companies.changeChartPeriod(this, \'day\', '+this.objId+');return false;">Days</a><hr></div>','<div id="company-'+this.objId+'-chart" style="height: 200px"></div>','</div>','<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr valign="top">','<td width="50%">','<div class="overview-container">','<div class="block-title sprite sprite-empty"><div style="clear: none; float: left; font-size: 16px; font-weight: bold; text-align: center; width: 48px; height: 10px; padding-top: 8px;">{clips_count}</div><h1 style="padding-left: 3px;">Clips</h1><h2 class="dropdown-options" onclick="Companies.showPeriodOptionsForOverview(this, event, '+this.objId+', \'clips\');return false;">{clips_range}</h2><a href=# class="see-more" onclick="Ext.getCmp(\'contact-',this.objId,'-tabs-panel\').setActiveTab(3);">See more</a><hr></div>','<tpl for="clips">','<div class="updates-item">','<a href=# onclick="showClip({id});" class="title">{headline}</a><br>','<tpl if="outlet != 0"><span class="item-info">{outlet}</span> | </tpl>{created_at} ago','</div>','</tpl>','</div>','</td><td>','<div class="overview-container">','<div class="block-title sprite sprite-empty"><div style="clear: none; float: left; font-size: 16px; font-weight: bold; text-align: center; width: 48px; height: 10px; padding-top: 8px;">{upcoming_opp_count}</div><h1 style="padding-left: 3px;">Upcoming</h1><h2 class="dropdown-options" onclick="Companies.showPeriodOptionsForOverview(this, event, '+this.objId+', \'upcoming_opp\', \'Next\');return false;">{upcoming_opp_range}</h2><a href=# class="see-more" onclick="Ext.getCmp(\'contact-',this.objId,'-tabs-panel\').setActiveTab(4);">See more</a><hr></div>','<tpl for="upcoming_opp">','<div class="updates-item" style="padding-bottom: 10px;">','<a href=# onclick="showOpportunity({id});" class="title">{subject}</a><br>','<span class="item-info">{type}<tpl if="outlet"> for {outlet}</tpl></span> | closes in {deadline_at}<br>','</div>','</tpl>','<tpl if="upcoming_opp_count == 0 && !no_opportunity_lists">No upcoming opportunities for this period</tpl>','<tpl if="no_opportunity_lists"><b>You have not saved any Opportunity lists for this company</b><br><a href=# onclick="Companies.showResearchSection(\'researchOpportunitiesTab\');return false;">Click here to identify publicity opportunities for this client</a></tpl>','</div>','<div class="overview-container">','<div class="block-title sprite sprite-empty"><div style="clear: none; float: left; font-size: 16px; font-weight: bold; text-align: center; width: 48px; height: 10px; padding-top: 8px;">{activities_count}</div><h1 style="padding-left: 3px;">Interactions</h1><h2 class="dropdown-options" onclick="Companies.showPeriodOptionsForOverview(this, event, '+this.objId+', \'interactions\');return false;">{interactions_range}</h2><a href=# class="see-more" onclick="Ext.getCmp(\'contact-',this.objId,'-tabs-panel\').setActiveTab(1);">See more</a><hr></div>','<tpl for="activities">','<div class="updates-item" style="padding-bottom: 10px;">','{message} <span class="item-info">{created_at} ago</span><br>{desc}','</div>','</tpl>','</div>','<div class="overview-container">','<div class="block-title sprite sprite-empty"><div style="clear: none; float: left; font-size: 16px; font-weight: bold; text-align: center; width: 48px; height: 10px; padding-top: 8px;">{total_views_per_period}</div><h1 style="padding-left: 3px;">Release Views</h1><h2 class="dropdown-options" onclick="Companies.showPeriodOptionsForOverview(this, event, '+this.objId+', \'releases\');return false;">{releases_range}</h2><a href=# class="see-more" onclick="Ext.getCmp(\'contact-',this.objId,'-tabs-panel\').setActiveTab(2);">See more</a><hr></div>','<tpl for="releases">','<div class="updates-item">','<a href=# onclick="showRelease({id});" class="title">{headline}</a><br>','<span class="item-info">{created_at} ago</span> | {prwire_views} PRWire view<tpl if="prwire_views!=1">s</tpl> | Opened by {count_opens} recipient<tpl if="count_opens!=1">s</tpl>','</div>','</tpl>','</div>','</td>','</tr></table>','</tpl>').compile(),listeners:{'afterrender':{fn:function(){},scope:this}}}];this.on('afterrender',function(){this.store.addListener('load',function(store,data){var companyId=this.store.data.items[0].data.company_id;var objId=this.objId;Ext4.onReady(function(){Ext4.define('CompanyStat',{extend:'Ext.data.Model',fields:[{name:'id',type:'int'},{name:'period',type:'string'},{name:'year',type:'int'},{name:'start_date',type:'string'},{name:'clips',type:'int'},{name:'interactions',type:'int'}]});this.chartStore=new Ext4.create('Ext.data.Store',{model:'CompanyStat',proxy:{type:'ajax',url:makeUrl('newsrooms','stats')+'?contact_id='+objId,extraParams:{period:data[0].data.chart_period,range:data[0].data.chart_range},reader:{type:'json',root:'stats'}},autoLoad:true});var chart=Ext4.create('Ext.chart.Chart',{width:Ext.get('company-'+objId+'-chart').getWidth(),height:Ext.get('company-'+objId+'-chart').getHeight(),id:'contact-'+objId+'-chart-component',animate:true,renderTo:'company-'+objId+'-chart',store:this.chartStore,shadow:false,listeners:{'beforerender':{fn:function(){if(Ext.getCmp('contact-'+objId+'-tabs-panel').getActiveTab().title!='Overview'){return false;}},scope:this}},axes:[{type:'Numeric',minimum:0,position:'left',fields:['clips','interactions']},{type:'Category',position:'bottom',grid:true,fields:['period']}],legend:{position:'top',isVertical:false},series:[{type:'line',axis:'left',xField:'period',yField:'clips',style:{stroke:'#00a','stroke-width':3},tips:{trackMouse:true,width:80,height:26,renderer:function(storeItem,item){this.setTitle('Clips: '+storeItem.get('clips'));}},markerConfig:{type:'circle',fill:'#00a',radius:5,'stroke-width':0},listeners:{itemmousedown:{fn:function(e){if(e.storeItem.data.clips>0){var start_date=e.storeItem.data.start_date;var end_date=e.storeItem.data.period+'/'+e.storeItem.data.year;Ext.getCmp('company-'+companyId+'-coverage-grid-start-date').setValue(start_date).setVisible(true);Ext.getCmp('company-'+companyId+'-coverage-grid-end-date').setValue(end_date).setVisible(true);Ext.getCmp('contact-'+objId+'-tabs-panel').setActiveTab(3);Ext.getCmp('contact-'+objId+'-tabs-panel').get(3).get(0).store.reload();}},scope:this}}},{type:'line',axis:'left',xField:'period',yField:'interactions',style:{stroke:'#0a0','stroke-width':2},tips:{trackMouse:true,width:120,height:26,renderer:function(storeItem,item){this.setTitle('Interactions: '+storeItem.get('interactions'));}},markerConfig:{fill:'#0a0',type:'circle',radius:3,stroke:'#fff','stroke-width':0}}]});});},this);this.items.items[0].store.load();},this);OutletOverviewPanel.superclass.initComponent.apply(this);},refresh:function(){this.store.reload();},showEditProfile:function(objectId){this.profileEditForm.show();if(Ext.get('outlet-'+objectId+'-account-profile-text')){Ext.get('outlet-'+objectId+'-account-profile-text').setDisplayed(false);Ext.get('outlet-'+objectId+'-account-profile').setStyle('font-weight','normal');}
if(Ext.get('outlet-'+objectId+'-account-profile-full-text')){Ext.get('outlet-'+objectId+'-account-profile-full-text').setDisplayed(false);}
Ext.get('outlet-'+this.objId+'-account-profile-edit-link').setDisplayed(false);Ext.get('outlet-'+this.objId+'-account-profile').setStyle('font-weight','bold');}});ContactCompanyCoveragePanel=Ext.extend(Ext.Panel,{title:"Coverage",layout:'fit',initComponent:function(){Ext.apply(this,this.initialConfig);var rd=['id','outlet_id','outlet_contact_id','headline','byline','outlet','type_id','type','copy','url','beats_ids','beats','tags_ids','tags','tags_links','synopsis','size_percent','size_centimetre','article_loading','page','mentioned','scans','comments_count','countries','countries_ids','pull_quote','published_day','readed','outlet_descr','image_url_normal_cropped','byline_links','location_country','location_country_id','location_state','location_state_id','location_suburb','location_suburb_id',{name:'is_have_images',type:'bool'},{name:'is_processed',type:'bool'},{name:'is_show_copy',type:'bool'},{name:'published_at',type:'date',dateFormat:app.conf.dtFormat},{name:'updated_at',type:'date',dateFormat:app.conf.dtFormat},'length','words','duplicates','duplicates_count','unique_daily_browsers','preview_img','is_editable'];var cm=[new Ext.grid.CheckboxSelectionModel(),{id:'headline',header:"Title",dataIndex:'headline',renderer:this.titleRenderer,scope:this,width:400},{header:"Published At",dataIndex:'published_at',renderer:dtRenderer,width:100}];this.items=this.grid=new FilteredGrid({recordDef:rd,cm:cm,pagerUrl:makeUrl('contacts','getCoveragePager'),autoExpandColumn:'headline',summary:'synopsis',height:300,isHavePreview:true,isHaveFilter:true,dblclickShow:true,showFieldId:"id",baseParams:{profile_id:this.profileId},headerAddons:[{iconCls:'icon icon-add',text:'Add',tooltip:'Add clip',handler:function(){this.module.doAdd();}},'-',{iconCls:'icon icon-go-to-post',text:'Open',tooltip:'Open selected clips',handler:function(){Ext.each(this.getSelections(),function(d){this.module.showItem(d.id,d.type);},this);}},{iconCls:'icon icon-go-to-post',text:'Open source',tooltip:'Open selected clips source',handler:function(){Ext.each(this.getSelections(),function(d){this.module.showSource(d.id,d.headline,d.url);},this);}},'-',{text:'Mark as read',iconCls:'icon icon-tick',tooltip:'Mark as read',handler:function(){this.selectionAction(null,function(){this.sendJsonRequest(app.makeUrl('markReaded'),{ids:this.selectedIdsToJson(),type:'clip'});});}},{text:'Mark all read',iconCls:'icon icon-tick',tooltip:'Mark all read',handler:function(){sendJsonRequest(app.makeUrl('markReaded'),{all:1,type:'clip'});}},'-',{text:'Quick edit',iconCls:'icon icon-new-tab',tooltip:'Quick edit',handler:function(){this.selectionAction(null,function(){Coverage.showQuickClip(this.getSelections()[0].get('id'),this);});}},{iconCls:'icon icon-edit',text:'Edit',tooltip:'Edit clip',handler:function(){var sel=this.grid.getSelections();if(sel.length!=1){msg('Error','Please select one item to process');return;}
if(!sel[0].get('is_editable')){msg('Error','You don\'t have permission to edit this clip');return;}
this.grid.selectionAction(null,function(){this.module.doEdit(sel[0].get('id'));});},scope:this},{iconCls:'icon icon-delete',text:'Delete',tooltip:'Delete clips',handler:function(){var sel=this.grid.getSelections();var forbiddenCount=0;Ext.each(sel,function(clip){if(!clip.get('is_editable')){forbiddenCount++;}});if(forbiddenCount>0){msg('Error','There is a clip you don\'t have permission to delete');return;}
confirm(function(){sendJsonRequest(makeUrl('coverage','deleteClipCompany'),{ids:this.grid.selectedIdsToJson(),company_id:this.companyId},function(scope){scope.grid.store.reload();msg("Notice","Deletion complete");},this);},this,'Are you sure you want to delete?');},scope:this},{iconCls:'icon icon-excel',text:'Export',menu:[],scope:this,listeners:{'render':{fn:function(b){app.ds.exportOptions.data.each(function(r){b.menu.addItem({text:r.get('value'),group:'report',xtype:'menucheckitem',scope:this,checkHandler:function(cb){cb.setChecked(false);var params=this.grid.store.baseParams;Ext.each(this.grid.filters,function(f){if(f.xtype=='datefield'){eval('params.'+f.hiddenName+'=\''+Ext.util.Format.date(f.getValue(),app.conf.dateFormat)+'\';');}else{eval('params.'+f.hiddenName+'=\''+f.getValue()+'\';');}},this);if(this.grid.selectedIdsToJson()!='[]'){window.open(makeUrl('coverage','report')+'?report_id='+r.get('id')+'&'+Ext.urlEncode(params)+'&profile_id='+this.profileId+'&ids='+this.grid.selectedIdsToJson(),'Report');}else{window.open(makeUrl('coverage','report')+'?report_id='+r.get('id')+'&'+Ext.urlEncode(params)+'&profile_id='+this.profileId,'Report');}},scope:b.scope});});},scope:this}}},{iconCls:'icon icon-feed',tooltip:'Feed',text:'Feed',scope:this,handler:function(){window.open(makeUrl('coverageFeed/'+this.profileId));}},{iconCls:'icon icon-page',text:'Report',menu:[],listeners:{'render':{fn:function(b){app.ds.reportOptions.data.each(function(r){b.menu.addItem({text:r.get('value'),group:'report',xtype:'menucheckitem',checkHandler:function(cb){cb.setChecked(false);var params=this.store.baseParams;Ext.each(this.filters,function(f){if(f.xtype=='datefield'){eval('params.'+f.hiddenName+'=\''+Ext.util.Format.date(f.getValue(),app.conf.dateFormat)+'\';');}else{eval('params.'+f.hiddenName+'=\''+f.getValue()+'\';');}},this);if(this.selectedIdsToJson()!='[]'){window.open(this.module.makeUrl('report')+'?report_id='+r.get('id')+'&'+Ext.urlEncode(params)+'&ids='+this.selectedIdsToJson(),'Report');}else{window.open(this.module.makeUrl('report')+'?report_id='+r.get('id')+'&'+Ext.urlEncode(params),'Report');}},scope:b.scope});});}}}},{iconCls:'icon icon-chart-pie',text:'Charts',menu:{defaults:{group:'type',scope:this,handler:function(cb){Coverage.showChart(cb.initValue,'',cb.text,this.grid);}},items:[{text:'Clips',initValue:'clips'},{text:'Companies',initValue:'companies'},{text:'Outlets',initValue:'outlets'},{text:'Journos',initValue:'journos'},{text:'Media',initValue:'media'},{text:'Origin',initValue:'origin'},{text:'Ad value',initValue:'value'},{text:'Score',initValue:'score'},{text:'Tone',initValue:'tone'}]}},{iconCls:'icon icon-printer',text:'Print',menu:[],listeners:{'render':{fn:function(b){app.ds.reportOptions.data.each(function(r){if(r.get('id')==7||r.get('id')==8){b.menu.addItem({text:r.get('value'),group:'report',xtype:'menucheckitem',checkHandler:function(cb){cb.setChecked(false);window.open(this.module.makeUrl('report')+'?report_id='+r.get('id')+'&'+Ext.urlEncode(this.store.baseParams)+'&ids='+this.selectedIdsToJson()+'&print=1','Report');},scope:b.scope});}});}}}}],footerAddons:['clone'],filters:[new Ext.form.DateField({labelName:'Published From',hiddenName:"start_date",width:100,xtype:'datefield',id:'company-'+this.companyId+'-coverage-grid-start-date',value:new Date().add(Date.MONTH,-1),scope:this}),new Ext.form.DateField({labelName:'Published To',hiddenName:"end_date",width:100,id:'company-'+this.companyId+'-coverage-grid-end-date',xtype:'datefield',emptyText:'Today'}),prepareComboBox({emptyText:'All Regions',labelName:'Regions',hiddenName:'country',store:app.ds.countries}),prepareComboBox({emptyText:'All Types',hiddenName:'type',labelName:'Types',store:app.ds.clipTypes}),prepareComboBox(makeUrl('contacts','getOutletOptions'),{emptyText:'All Outlets',labelName:'Outlets',hiddenName:'outlet'}),prepareComboBox({emptyText:'All beats',labelName:'Beats',hiddenName:'beatId',store:app.ds.beats}),prepareComboBox(makeUrl('contacts','getPersonOptions'),{emptyText:'All journos',labelName:'Journo',hiddenName:'journo'}),new Ext.form.TextField({width:100,labelName:'Tag',hiddenName:'tag'})]});ContactCompanyReleasesPanel.superclass.initComponent.apply(this);Coverage.init();var coverage=new CoverageModule({companyId:this.companyId,contactId:this.objId,profileId:this.profileId});coverage.init();this.grid.module=coverage;var objId=this.objId;var grid=this.grid;this.grid.getPreviewPanel=function(){return Ext.getCmp("contact-"+objId+"-details-panel").ownerCt;}
this.grid.previewItem=function(index){var record=this.store.getAt(index);Ext.getCmp("contact-"+objId+"-preview-tabs-panel").hide();var panel=Ext.getCmp("contact-"+objId+"-details-panel");panel.ownerCt.grid=grid;panel.show();grid.getPreviewPanel().getTopToolbar().show();Coverage.previewItem(record.data.id,record.data,panel.ownerCt,objId)}},titleRenderer:function(val,p,record,rowIndex,columnIndex,ds){return'<a href=# onclick="showClip('+record.data.id+');" class="item-title">'+val+'</a>';},resetForm:function(){console.log('reset form');},doEdit:function(id){Coverage.doEdit(id);},showItem:function(id){Coverage.showItem(id);}});CompaniesModule=Ext.extend(ContactsModule,{itemTitle:'company',itemsTitle:'companies',title:'Companies',name:'companies',isResearchGrid:false,overviewFields:['letters','updates','beats'],initParams:function(){this.rd=['id','title','contact_id','description','keywords','monitoring_keywords','emails','email','phones','phone','websites','messengers','addresses','tips','beats_ids','type','permission_type','permission_edit',{name:'is_editable',type:'bool'},'relatedCompanies','relatedOutlets','release_feeds','blog_feeds','podcast_feeds','prblog_feeds','domain','is_center','slug','image_id','image_url_original','image_url_big','news_feed0','news_feed1','news_feed2','is_premium','is_in_directory','verification_status','verification_manager_id','verification_days'];this.cm=[new StoreSelectionModel({recordDef:this.rd}),{header:"Title",dataIndex:'title',width:330,renderer:this.titleRenderer,scope:this},{header:"Type",dataIndex:'type',width:80},{header:"Phone",dataIndex:'phone',width:100,sortable:false}];this.company_id=0;this.overviewTpl=new Ext.XTemplate('<tpl for=".">','<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr valign="top">','<td width="50%">','<div class="overview-container">','<div class="block-title sprite sprite-outlet"><h1>Browse Companies</h1><hr></div>','<div class="updates-item">','<a onclick="Companies.showMain();">All</a> ','<tpl for="letters">','<a onclick="Companies.browseByLetter(\'{0}\')">{0}</a> ','</tpl>','</div>','</div>','<div class="overview-container">','<div class="block-title sprite sprite-folder"><h1>Companies by Beat</h1><hr/></div>','<tpl for="beats">','<tpl if="leaf">','<div class="arrows"></div><div class="overview-beat"><a href=# class="subject" onclick="Companies.showBeat(\'{id}\',\'{text}\');">{text}</a></div>','</tpl>','<tpl if="!leaf">','<div class="arrows arrow-black" id="'+this.name+'-beat-{id}"><a href=# onclick="Companies.toggleSubCategories({id});return false;"></a></div><div class="overview-beat"><a href=# class="subject" onclick="Companies.showBeat(\'{id}\',\'{text}\');">{text}</a></div>','<div class="subcategories" id="'+this.name+'-beat-children-{id}" style="display: none;">','<tpl for="children">','<a href=# onclick="Companies.showBeat(\'{id}\',\'{text}\');">{text}</a><tpl if="xindex!=xcount"> | </tpl>','</tpl>','</div>','</tpl>','<tpl if="xindex!=xcount"><hr></tpl>','</tpl>','</div>','</td><td>','<div class="overview-container" style="padding: 10px;">','<div class="overview-search-form">','<div class="block-title sprite sprite-search"><h1>Find Companies</h1><hr></div>','<div class="inputs">','<label for="companies_search_by_name">Find companies with the <b>name</b> (eg. MediaConnect Australia)</label><br>','<input class="x-form-text x-form-field w250" name="companies_search_by_name" id="companies_search_by_name" type="text" /><br><br>','<label for="companies_search_by_beat">That cover this <b>beat or topic</b> (eg. education)</label><br>','<input class="x-form-text x-form-field w250" name="companies_search_by_format" id="companies_search_by_beat" type="text" /><br><br>','</div>','<div class="x-small-editor" id="companies_submit_search_by_name" style="float: right; padding-top: 23px;"></div>','</div>','</div>','<div class="overview-container tools-block">','<div class="block-title sprite sprite-tools"><h1>Tools & Assistance</h1><hr/></div>','<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-add"></div><a href=# onclick="Companies.doAdd();return false;" class="title">Add a new company</a></div>','<div class="summary">If you can\'t find an outlet, you can add it by clicking here. Outlets can be set to bee seen only by yourself, shared only within your company or they can be shared with the entire community</div>','</div>','</div>','<div class="overview-container">','<div class="block-title sprite sprite-stream"><h1>Company Updates</h1><hr></div>','<tpl for="updates">','<div class="portlet-item"><div class="ico-new ico-new-{icon}"></div>{message} <span class="item-info">{created_at} ago</span></div><tpl if="xindex!=xcount"><hr></tpl>','</tpl>','</div>','</td>','</tr></table>','</tpl>').compile();},initFilters:function(){return[prepareComboBox({emptyText:'All Regions',labelName:'Regions',hiddenName:'countryId',store:app.ds.countries}),new Ext.form.ComboBox({valueField:'value',displayField:'value',width:120,editable:false,labelName:'Letter',hiddenName:'letter',mode:'local',store:app.ds.letterFilterStore,triggerAction:'all'}),Contacts.prepareBeatsCombo(),new Ext.form.TextField({width:100,labelName:'Tag',hiddenName:'tag',value:''})];},initForm:function(){var items=[{title:"General",layout:"form",height:400,autoScroll:true,bodyStyle:'padding-right: 10px;',defaults:{xtype:'fieldset'},items:[{title:'General information',defaults:{xtype:'textarea'},autoHeight:true,collapsible:false,items:[{fieldLabel:'Title',name:'title',xtype:'textfield',listeners:{'change':{fn:function(field,newVal){this.checkDuplicatesListener();},scope:this}}},{fieldLabel:'Description',name:'description',grow:false,fieldClass:"x-form-textarea x-form-field",preventScrollbars:true},{xtype:'textarea',fieldLabel:'Keywords',name:'keywords',grow:false,fieldClass:"x-form-textarea x-form-field",preventScrollbars:true,allowBlank:true},{xtype:'fieldset',autoHeight:true,border:false,labelWidth:110,hidden:!isPartnerAdmin(),items:{xtype:'textarea',fieldLabel:'Monitoring Keywords',name:'monitoring_keywords',grow:false,fieldClass:"x-form-textarea x-form-field",preventScrollbars:true,allowBlank:true}},{xtype:'fieldset',hidden:!isPartnerAdmin(),border:false,labelWidth:110,items:{xtype:'checkbox',inputValue:1,name:'is_premium',fieldLabel:'Is Premium'}},{xtype:'fieldset',hidden:!isPartnerAdmin(),border:false,labelWidth:110,items:{xtype:'checkbox',inputValue:1,name:'is_in_directory',fieldLabel:'Is in PR Directory'}}]},{title:'Logo',autoHeight:true,collapsible:false,items:[{fieldLabel:"Upload image",name:"uploadFile",xtype:'fileuploadfield',width:250},this.logoViewPanel=new Ext.Panel({autoheight:true,items:[new Ext.DataView({store:this.store,tpl:this.logoViewTpl,autoHeight:true})]})]}]}];if(isPartnerAdmin()){items.push(this.createPermissionsPanel('company'));}
items.push(this.contactsPanel=this.createContactsPanel('company'),{title:"Feeds",layout:"fit",bodyStyle:'position:relative;',defaultType:'fieldset',defaults:{autoHeight:true,labelWidth:200},overflow:'auto',autoScroll:true,items:[this.releasesFeedsPanel=this.createFeedsPanel('Releases','release_feed[]',true),this.blogsFeedsPanel=this.createFeedsPanel('Blogs','blog_feed[]'),this.podcastsFeedsPanel=this.createFeedsPanel('Podcasts','podcast_feed[]'),this.prblogsFeedsPanel=this.createFeedsPanel('PR Blogs','prblog_feed[]')]},this.createRelationsPanel(this),this.createBeatsPanel());return{fileUpload:true,defaults:{bodyStyle:'padding:10px'},items:{xtype:'tabpanel',layoutOnTabChange:true,height:400,activeTab:0,items:items}};},fillForm:function(obj){this.getForm().setValues(obj);this.contactsPanel.set(obj);this.releasesFeedsPanel.set(obj.release_feeds);this.blogsFeedsPanel.set(obj.blog_feeds);this.podcastsFeedsPanel.set(obj.podcast_feeds);this.prblogsFeedsPanel.set(obj.prblog_feeds);this.logoViewPanel.show();this.logoViewPanel.doLayout();this.logoViewTpl.overwrite(this.logoViewPanel.body,obj);Ext.get('contacts_delete_logo_'+obj.id).addListener('click',function(){Ext.MessageBox.confirm('Message','Do you really want to delete?',function(btn,text){if(btn=='yes'){sendJsonRequest(makeUrl('contacts','deleteImage'),{contactId:obj.contact_id},function(scope){Ext.get('contacts_delete_logo_'+obj.id).parent().update('');});}},this);},this);},fillDynamicFields:function(obj){this.relationCompaniesPanel.set(obj);this.relationOutletsPanel.set(obj);},resetForm:function(){this.getForm().reset();this.logoViewPanel.hide();this.contactsPanel.reset();this.relationCompaniesPanel.reset();this.relationOutletsPanel.reset();this.releasesFeedsPanel.reset();this.blogsFeedsPanel.reset();this.podcastsFeedsPanel.reset();this.prblogsFeedsPanel.reset();if(!isPartnerAdmin()){this.domainFieldSet.hide();this.clientCenter.hide();}},setFormDefaults:function(){this.contactsPanel.set();this.relationCompaniesPanel.set();this.relationOutletsPanel.set();this.releasesFeedsPanel.set();this.blogsFeedsPanel.set();this.podcastsFeedsPanel.set();this.prblogsFeedsPanel.set();},getGridPanelCfg:function(cfg){var result={saveListUrl:makeUrl('lists','addContacts')+"?type=company",deleteUrl:makeUrl("companies","delete"),previewFieldId:"contact_id",dblclickShow:true,summary:'description',showFieldId:"contact_id"};return Ext.apply(result,cfg||{});},afterItemUpdate:function(actionResult){var companyPanel=Ext.getCmp('contact-'+actionResult.contactId+'-panel');if(companyPanel){companyPanel.afterItemUpdate();}},createRelationsPanel:function(){return{title:"Relations",overflow:'auto',autoScroll:true,bodyStyle:'position:relative;',height:400,defaults:{xtype:"fieldset",defaultType:'textfield',autoHeight:true,bodyStyle:"border: none",collapsible:true},items:[{title:"Companies",items:this.relationCompaniesPanel=new DynamicFieldsPanel({fields:[getRemoteComboOptions(makeUrl("contacts","getCompanyContactOptions"),{fieldLabel:'Company',hiddenName:"relatedContactId[]"}),getComboOptions({fieldLabel:'Type',hiddenName:"relationTypeId[]",store:app.ds.companyCompanyRelationTypes})],set:function(obj){try{if(!obj.relatedCompanies.length){this.appendField();}
Ext.each(obj.relatedCompanies,function(n){this.appendField([[n.relation_id,n.related],n.type_id]);},this);}catch(e){this.appendField();}}})},{title:"Outlets",items:this.relationOutletsPanel=new DynamicFieldsPanel({fields:[getRemoteComboOptions(makeUrl("contacts","getOutletContactOptions"),{fieldLabel:'Outlet',hiddenName:"relatedOutletId[]"})],set:function(obj){try{if(!obj.relatedOutlets.length){this.appendField();}
Ext.each(obj.relatedOutlets,function(n){this.appendField([[n.relation_id,n.related]]);},this);}catch(e){this.appendField();}}})}]};},initOverviewElements:function(){new Ext.Button({minWidth:60,text:'Search',scope:this,renderTo:'companies_submit_search_by_name',handler:function(){var filt=Ext.get("companies_search_by_name").getValue();var beat=Ext.get("companies_search_by_beat").getValue();if(filt||beat){this.showFilteredGrid({pagerUrl:this.makeUrl("getPager"),title:filt||beat,baseParams:{filter:filt,beat:beat}},'by-filter');}}});makeAutocompleteBeats("companies_search_by_beat");},checkDuplicatesListener:function(){var values=this.getForm().getValues();if(!values.title){return;}
var dlg=this.getDialog();this.duplicatesCheckStore.removeListener('load');this.duplicatesCheckStore.addListener('load',function(store,data){if(data[0].data.duplicating_id){this.duplicatingDlg.objId=data[0].data.obj_id;this.duplicatingDlg.actionDlg=dlg;this.duplicatingDlg.isEditable=data[0].data.is_editable;this.duplicatingDlg.typeId=data[0].data.type_id;this.duplicatingDlg.buttons[2].hide();this.duplicatingDlg.show();this.duplicatingTpl.overwrite(Ext.getCmp('contacts-duplicates-dataview').body,data[0].data);}},this);this.duplicatesCheckStore.load({params:{type_id:301,title:values.title.trim(),id:dlg.objId}});},showMoreItemActions:function(lnk,ev,itemId){this.itemActionsContextMenu=new Ext.menu.Menu({items:[{text:'Images',handler:function(item,e){Images.init().doAdd();},scope:this}]});this.itemActionsContextMenu.showAt(new Array(ev.clientX,ev.clientY));},showPeriodOptionsForChart:function(lnk,ev,itemId){this.periodsChartContextMenu=new Ext.menu.Menu({items:[{text:'Month',handler:function(item,e){this.changeChartRange(lnk,item.text,itemId);},scope:this},{text:'3 Months',handler:function(item,e){this.changeChartRange(lnk,item.text,itemId);},scope:this},{text:'6 Months',handler:function(item,e){this.changeChartRange(lnk,item.text,itemId);},scope:this},{text:'Year',handler:function(item,e){this.changeChartRange(lnk,item.text,itemId);},scope:this}]});this.periodsChartContextMenu.showAt(new Array(ev.clientX,ev.clientY));},changeChartRange:function(lnk,text,id){lnk=Ext.get(lnk);lnk.dom.innerHTML='last '+text.toLowerCase();var chart=Ext4.getCmp('contact-'+id+'-chart-component');chart.store.proxy.extraParams=Ext.apply(chart.store.proxy.extraParams,{range:text.toLowerCase()});chart.store.load();var contactPanel=Ext.getCmp('contact-'+id+'-panel');contactPanel.getPanel('tabs').items.items[0].store.baseParams.chart_range=text.toLowerCase();},changeChartPeriod:function(lnk,period,id){var chart=Ext4.getCmp('contact-'+id+'-chart-component');chart.store.proxy.extraParams=Ext.apply(chart.store.proxy.extraParams,{period:period});chart.store.load();Ext.select('.chart-period').removeClass('bold');Ext.get(lnk).addClass('bold');var contactPanel=Ext.getCmp('contact-'+id+'-panel');contactPanel.getPanel('tabs').items.items[0].store.baseParams.chart_period=period.toLowerCase();},showPeriodOptionsForOverview:function(lnk,ev,itemId,itemType,time){if(!time){time='This';}
this.periodsOverviewContextMenu=new Ext.menu.Menu({items:[{text:time+' week',handler:function(item,e){this.setPeriodOptionsForOverview(itemId,itemType,item);},scope:this},{text:time+' month',handler:function(item,e){this.setPeriodOptionsForOverview(itemId,itemType,item);},scope:this},{text:time+' quarter',handler:function(item,e){this.setPeriodOptionsForOverview(itemId,itemType,item);},scope:this},{text:time+' year',handler:function(item,e){this.setPeriodOptionsForOverview(itemId,itemType,item);},scope:this},{text:'Total',handler:function(item,e){this.setPeriodOptionsForOverview(itemId,itemType,item);},scope:this}]});this.periodsOverviewContextMenu.showAt(new Array(ev.clientX,ev.clientY));},setPeriodOptionsForOverview:function(itemId,itemType,menuItem){var contactPanel=Ext.getCmp('contact-'+itemId+'-panel');var params={};switch(itemType){case'clips':params={clips_range:menuItem.text};break;case'interactions':params={interactions_range:menuItem.text};break;case'releases':params={releases_range:menuItem.text};break;case'upcoming_opp':params={upcoming_opp_range:menuItem.text};break;}
var store=contactPanel.getPanel('tabs').items.items[0].store;store.reload({params:Ext.apply(store.lastOptions,params)});},showResearchSection:function(tabId){app.showResearchPanel();var tabNumber=0;switch(tabId){case'researchMediaTab':tabNumber=1;break;case'researchJournalistsTab':tabNumber=2;break;case'researchOutletsTab':tabNumber=3;break;case'researchOpportunitiesTab':tabNumber=4;break;}
var p=Ext.getCmp('topic-research-tpl-panel');if(!p.store.totalLength){p.store.nextTab=tabNumber;}else{Ext.getCmp('section-research-top-panel').items.items[1].setActiveTab(tabNumber);}}});var Companies=new CompaniesModule();SourcesSection=Ext.extend(Application.SectionModule,{title:'Sources',name:'sources',iconCls:'ico-module-search',style:'overflow-y: scroll;',id:'sources-panel',getRelatedTpl:function(ds,picture){return['<tpl for=".">','<table style="background-color: white; width: 100%;">','<tr valign="top">','<td>','<div class="overview-container tools-block" style="padding: 15px 0 0 0;">','<div class="block-title sprite sprite-lists"><h1>'+Ext.util.Format.capitalize(ds)+' Lists</h1><div><table style="float: right;"><tr><td><div id="import-list-'+ds+'-research-button"></div></td></tr></table></div><hr></div>','<table><tr>',(ds=='journalists')?'<td style="padding-right: 20px;"><div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-lists"></div><a href=# class="item-headline" style="font-style:normal;" onclick="Lists.init().showGridByType({ type : \'Person\' })">All Journalists Lists</a></div></td><td style="padding-right: 20px;"><div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-contacts"></div><a href=# class="item-headline" style="font-style:normal;" onclick="Persons.init().showJournos()">All Journalists ({journalists_count})</a></div></td>':'',(ds=='outlets')?'<td style="padding-right: 20px;"><div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-lists"></div><a href=# class="item-headline" style="font-style:normal;" onclick="Lists.init().showGridByType({ type : \'Outlet\' })">All Outlets Lists</a></div></td><td style="padding-right: 20px;"><div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-outlets"></div><a href=# class="item-headline" style="font-style:normal;" onclick="Outlets.init().showMain()">All Outlets ({outlets_count})</a></div></td>':'',(ds=='opportunities')?'<td style="padding-right: 20px;"><div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-lists"></div><a href=# class="item-headline" style="font-style:normal;" onclick="Lists.init().showGridByType({ type : \'Opportunity\' })">All Opportunities Lists</a></div></td><td style="padding-right: 20px;"><div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-opportunity"></div><a href=# class="item-headline" style="font-style:normal;" onclick="Opportunities.init().showOverview()">All Opportunities ({opportunities_count})</a></div></td>':'',(ds=='medias')?'<td style="padding-right: 20px;"><div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-lists"></div><a href=# class="item-headline" style="font-style:normal;" onclick="Lists.init().showGridByType({ type : \'Media\' })">All Media Lists</a></div></td>':'','</tr></table>','<div style="padding-top: 15px;"> </div>','<tpl for="'+ds+'">','<div class="portlet-item" style="padding: 2px;"><div class="ico-new ico-new-'+picture+'"></div><a href=# class="item-headline" style="font-style:normal; margin-right: 7px;" onclick="Lists.showItem({id}, \'{type}\', \'{name}\')">{name}</a>{records_count} Item<tpl if="records_count != 1">s</tpl> <span class="research-form-text-count" style="margin-right: 7px; <tpl if="recommendations_count &gt; 0">font-weight: bold;</tpl>">{recommendations_count} Update<tpl if="recommendations_count != 1">s</tpl></span><span style="color: #888; font-weight: bold;">{company_name}</span></div>','</tpl>','</div>','</td>','</tr>','</table>','</tpl>'].join('');},initParams:function(){this.topicSearchTpl=new Ext.XTemplate('<tpl for=".">','<div id="research-topic-search">','<tpl if="!search_results">','<table style="background-color: white; width: 100%;">','<tr valign="top">','<td>','<div class="overview-container tools-block" style="padding: 15px 0 0 0;">','<div class="block-title sprite sprite-reader2"><h1>PRWire</h1><hr></div>','<table><tr>','<td style="padding-right: 30px;"><div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-lists"></div><a href=# class="item-headline" style="font-style:normal;" onclick="Prwire.showMain({creator_id: app.conf.user.id})">My Releases</a></div></td>','<td style="padding-right: 30px;"><div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-lists"></div><a href=# class="item-headline" style="font-style:normal;" onclick="Prwire.showMain()">All Releases</a></div></td>','</tr></table>','<div style="padding-top: 15px;"> </div>','<tpl for="releases">','<table cellpadding=0 cellspacing=0 border=0 class="item" width="100%" <tpl if="xindex==xcount">style="border-bottom: none;"</tpl>><tr valign="top">','<td class="image" width="100"><tpl if="image_url != \'\'"><img width=100 src="{image_url}" border=0 /></tpl><tpl if="image_url == \'\'">&nbsp;</tpl></td>','<td class="content">','<a href=# class="item-headline" onclick="showRelease({id})">{title}</a>','<div class="summary">{description}</div>','<div class="item-info"><a href=# onclick="showContact({newsroom_contact_id});return false;">{newsroom}</a> | {published_at} ago </div>','</td>','</tr></table><tpl if="xindex!=xcount"><!--<hr class="reader">--></tpl>','</tpl>','</div>','</td>','</tr>','</table>','</tpl>','<tpl if="search_results">','<tpl for="search_results">','<table style="background-color: white; width: 100%;">','<tr valign="top">','<td>','<div class="overview-container tools-block" style="padding: 15px 0 0 0;">','<div class="block-title sprite sprite-search"><h1>Results for \'{keyword}\'</h1><hr><tpl if="exact_match"><span style="padding-left: 50px; font-size: 8pt; margin-top: 0px;">Searching for keyword: {keyword}. Did you mean {exact_match}?</span></tpl></div>','<br>','<a href=# class="item-headline" style="font-style:normal; font-weight: bold; float: left;" onclick="Coverage.showRelevantClips(Ext.get(\'research-topic-search-textfield\').getValue()); return false;">Most recent coverage</a><div class="import-wizard-contact" style="display: inline;"><div style="display: inline;" class="block-title sprite sprite-opportunity"><a href=# onclick="Coverage.showRelevantClips(Ext.get(\'research-topic-search-textfield\').getValue()); return false;" class="see-more">See more</a></div><span class="action" style="float: left; padding-left: 5px;"><a href=# onclick="Ext.getCmp(\'sources-panel\').initSortByButton(\'coverage\', \'clips-sort-by\', event); return false;" id="clips-sort-by" style="text-decoration: none; font-weight: normal; font-size: 13px; color: #000;">&nbsp</a></span></div>','<hr>','<div id="research-topic-coverage-search">','<tpl if="clips">','<tpl for="clips">','<div style="padding-bottom: 3px;"><span style="margin-right: 7px; color: #888888; font-weight: bold;">{clip_published_at} ago</span><a href=# class="item-headline" style="font-size: 9.5pt; font-style: normal; font-weight: bold;" onclick="Coverage.showSource({clip_id}, \'{clip_title}\', \'{clip_url}\')">{clip_title}</a> <tpl if="clip_byline">by {clip_byline}</tpl><tpl if="clip_byline && clip_outlet">, </tpl><tpl if="clip_outlet">{clip_outlet}</tpl></div>','</tpl>','</tpl>','<tpl if="!clips.length">','Sorry, nothing was found','</tpl>','</div>','<br>','<a href=# class="item-headline" style="font-style:normal; font-weight: bold; float: left;" onclick="Ext.getCmp(\'sources-panel\').showRelevantReleases();">Recent announcements</a><div class="import-wizard-contact" style="display: inline;"><div style="display: inline;" class="block-title sprite sprite-releases"><a href=# onclick="Ext.getCmp(\'sources-panel\').showRelevantReleases(); return false;" class="see-more">See more</a></div><span class="action" style="float: left; padding-left: 5px;"><a href=# onclick="Ext.getCmp(\'sources-panel\').initSortByButton(\'releases\', \'releases-sort-by\', event); return false;" id="releases-sort-by" style="text-decoration: none; font-weight: normal; font-size: 13px; color: #000;">&nbsp</a></span></div>','<hr>','<div id="research-topic-releases-search">','<tpl if="releases">','<tpl for="releases">','<div style="padding-bottom: 3px;"><span style="margin-right: 7px; color: #888888; font-weight: bold;">{release_published_at} ago</span><a href=# class="item-headline" style="font-size: 9.5pt; font-style: normal; font-weight: bold;" onclick="showRelease({release_id})">{release_title}</a><tpl if="newsroom">, <a href="#" style="color: #000000; text-decoration: none;" onclick="showContact({newsroom_contact_id})">{newsroom}</a>. </tpl></div>','</tpl>','</tpl>','<tpl if="!releases.length">','Sorry, nothing was found','</tpl>','</div>','<br>','<a href=# class="item-headline" style="font-style:normal; font-weight: bold; float: left;" onclick="Ext.getCmp(\'sources-panel\').showRelevantCompanies();">Most relevant companies</a><div class="import-wizard-contact" style="display: inline;"><div style="display: inline;" class="block-title sprite sprite-company"><a href=# onclick="Ext.getCmp(\'sources-panel\').showRelevantCompanies(); return false;" class="see-more">See more</a></div><span style="text-align: right; float: right; padding: 5px 10px 0px 0px;" class="section-inline-note">Click on icon to preview & link to open</span><span class="action" style="float: left; padding-left: 5px;"><a href=# onclick="Ext.getCmp(\'sources-panel\').initSortByButton(\'companies\', \'companies-sort-by\', event); return false;" id="companies-sort-by" style="text-decoration: none; font-weight: normal; font-size: 13px; color: #000;">&nbsp</a></span></div>','<hr>','<div id="research-topic-companies-search">','<table><tr valign="top">','<tpl if="companies">','<tpl for="companies">','<td width="50" style="padding-right: 25px;">','<div style="height: 48px; padding-bottom: 3px;"><img src="{company_img_url}" onclick="Ext.getCmp(\'sources-panel\').previewItem({company_contact_id}, \'company\');"></div>','<a href="#" onclick="showContact({company_contact_id})" style="font-size: 9pt; font-style: normal;">{company_title}</a>','</td>','</tpl>','</tpl>','<tpl if="!companies.length">','Sorry, nothing was found','</tpl>','</tr></table>','</div>','<br>','<a href=# class="item-headline" style="font-style:normal; font-weight: bold; float: left;" onclick="Ext.getCmp(\'sources-panel\').showRelevantExperts();">Most relevant experts</a><div class="import-wizard-contact" style="display: inline;"><div style="display: inline;" class="block-title sprite sprite-opportunity"><a href=# onclick="Ext.getCmp(\'sources-panel\').showRelevantExperts(); return false;" class="see-more">See more</a></div><span style="text-align: right; float: right; padding: 5px 10px 0px 0px;" class="section-inline-note">Click on icon to preview & link to open</span>'+'</div>','<hr>','<div id="research-topic-experts-search">','<table><tr valign="top">','<tpl if="experts">','<tpl for="experts">','<td width="50" style="padding-right: 25px;">','<div style="height: 48px; padding-bottom: 3px;"><img src="{expert_img_url}" onclick="Ext.getCmp(\'sources-panel\').previewItem({expert_contact_id}, \'expert\');"></div>','<a href="#" onclick="showContact({expert_contact_id})" style="font-size: 9pt; font-style: normal;">{expert_title}</a>','</td>','</tpl>','</tpl>','<tpl if="!experts.length">','Sorry, nothing was found','</tpl>','</tr></table>','</div>','<br>','</div>','</td>','</tr>','</table>','</tpl>','</tpl>','</div>','</tpl>').compile();this.listsStore=prepareDs(makeUrl('lists','getResearchOverviewData'),['journalists','outlets','opportunities','medias','journalists_count','outlets_count','opportunities_count']);this.topicSearchStore=prepareDs(makeUrl('search','getSourcesTopicSearch'),['releases','search_results']);this.topicSearchSortingStore=prepareDs(makeUrl('search','getSourcesTopicSearch'),['search_results']);this.listsStore.on('load',function(store,data){Ext.getCmp('sourcesReleasesTab').setDisabled(false);Ext.getCmp('sourcesCompaniesTab').setDisabled(false);Ext.getCmp('sourcesContactsTab').setDisabled(false);});},previewItem:function(id,type){panel=Ext.getCmp('section-sources-panel');this.previewStore=new Ext.data.JsonStore({url:(type=='company')?makeUrl('companies','getRelevantCompany'):makeUrl('contacts','getContact'),autoLoad:false,fields:['id','image_url_tweet','title',{name:'is_editable',type:'bool'},'job_title','owner','permission_type','verified_at','responsibilities','type','beats','is_suggested','emails','phones','websites','addresses','note_edited_at','note_editor','noteActionAdd','noteActionEdit','type_id','clips_count','matching_count','relevance','clips'],listeners:{'load':{fn:function(scope,rec){var data=rec[0].data;var p=panel;var el=p.get(0).get(1).el;var tb=p.get(0).get(0);tb.removeAll();tb.add({text:'Open',iconCls:'icon icon-open',handler:function(){showContact(data.id,data.type,data.name);},scope:this},'->',{text:'Close',iconCls:'icon icon-cross',handler:function(){tb.removeAll();tb.add({text:'Actions'});tb.setHeight(27);el.hide().update('');p.doLayout();}});tb.doLayout();if(type=='company'){el.hide().update(Ext.getCmp('sources-panel').getPreviewCompanyTemplate(false,false,this.name).apply(data)).slideIn('l',{stopFx:true,duration:.2});}else{el.hide().update(Ext.getCmp('sources-panel').getPreviewExpertTemplate(false,false,this.name).apply(data)).slideIn('l',{stopFx:true,duration:.2});}},scope:this}}});this.previewStore.reload({params:{id:id,keyword:Ext.get('research-topic-search-textfield').getValue()}});},getPreviewExpertTemplate:function(showEdit,showVoter,module){return new Ext.XTemplate('<tpl for=".">','<div class="details">','<table><tr><td class="ico"><img src="{image_url_tweet}"></td><td class="info"><div class="details-header-1" style="float: left">','{title}','</div>',showVoter?'<div class="x-voter" style="float: left" id="contact-{id}-voter-panel"></div>':'','<div class="clear"></div>','<div class="details-header-2">','{job_title}','</div>','<div class="clear"></div>','<div class="verified">{owner} <b>{permission_type}<tpl if="is_suggested"> suggested</tpl></b> contact (Verified {verified_at})</div>','</td></tr></table>','<tpl if="emails.length &gt; 0">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="20px"><div class="icon icon-email"></div></td>','<td width="100%"><b>Emails</b><br>','<tpl for="emails">','<tpl if="!this.isFirst(xindex)">',',','</tpl>',' <a href="mailto:{email}">{email}</a>','</tpl>','</td>','</tr></table>','</tpl>','<tpl if="phones.length &gt; 0">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="20px"><div class="icon icon-phone"></div></td>','<td width="100%"><b>Phones</b><br>','<tpl for="phones">','{type}: {phone}','<tpl if="xindex != xcount"><br></tpl>','</tpl>','</td>','</tr></table>','</tpl>','<tpl if="websites.length &gt; 0">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="20px"><div class="icon icon-online"></div></td>','<td width="100%"><b>Websites</b><br>','<tpl for="websites">',' <a href="{url}" target="blank">{url}</a><br>','</tpl>','</td>','</tr></table>','</tpl>','<tpl if="addresses.length &gt; 0">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="20px"><div class="icon icon-company"></div></td>','<td width="100%"><b>Addresses</b><br>','<tpl for="addresses">','<a onmouseover="showTip(this, \'Google map\')" onclick="showGmap(\'{street}, {city}, {state}, {zip}, {country}\', \'{[String.escape(parent.title)]}\')">{address}</a><br>','</tpl>','</td>','</tr></table>','</tpl>','<div class="clear"></div><br>','<div>','<div class="icon icon-tag"></div><div class="tags-edit-selector" onclick="editTags(this);">tags</div>','<div class="tags-editor"><input objType="{objType}" objId="{object_id}" type="text" name="tags" ids="{tags_ids}" class="tags-input" value="{tags}"/></div>','<div class="tags-show">{tags_links}</div>','</div>','<div class="clear"></div><br><div class="clear"></div>','<div class="profile-bg p10">','<h1>Noteworthy</h1>','</div>','<span>','<span style="width: auto;" id="contact-note',module,'-text-{id}">{note}</span><font class="last-editor" id="note-editor',module,'-{id}"><tpl if="note_edited_at">&nbsp;Last edited at {note_edited_at:dtRenderer} by {note_editor}&nbsp;</tpl></font>','{noteActionAdd}','{noteActionEdit}',showVoter?['<div id="add-contact-note',module,'-{id}" class="profile-form"></div>'].join(""):'','</span>','<tpl if="responsibilities.length &gt; 0">','<div class="profile-bg p10">','<h1><tpl if="type_id == 301">Media contacts</tpl><tpl if="type_id == 302">Responsibilities</tpl></h1>','</div>','<tpl for="responsibilities">','<tpl if="role_title"><b>{role_title}</b>,</tpl> <a onclick="showContact({relation_id})">{related}</a><br>','<tpl if="xindex != xcount"><hr></tpl>','</tpl>','</tpl>','<tpl if="beats.length &gt; 0">','<div class="profile-bg p10">','<h1>Beats</h1>','</div>','<div>{beats}</div>','</tpl>','</div>','</tpl>',{isFirst:function(index){return index==1;}}).compile();},getPreviewCompanyTemplate:function(showEdit,showVoter,module){return new Ext.XTemplate('<tpl for=".">','<div class="details">','<table><tr><td class="ico"><img src="{image_url_tweet}"></td><td class="info"><div class="details-header-1" style="float: left">','{title}','</div>','<div class="clear"></div>','<div class="details-header-2">','{job_title}','</div>','<div class="clear"></div>','<div class="verified">{owner} <b>{permission_type}<tpl if="is_suggested"> suggested</tpl></b> contact (Verified {verified_at})</div>','</td></tr></table>','<tpl if="beats.length &gt; 0">','<div>{beats}</div>','</tpl>','<br>','<div class="profile-bg p3" style="margin-top: 0px !important;"><h1>Relevance</h1></div>','<div style="float: left; padding: 0px 0px 10px 0px;">','Sample: {clips_count} clip<tpl if="clips_count != 1">s</tpl><br>','Matched terms: {matching_count} clip<tpl if="matching_count != 1">s</tpl><br>','Relevance: {relevance}%<br>','</div>','<br>','<div class="profile-bg p3" style="margin-top: 0px !important;"><h1>Related Coverage</h1></div>','<div style="float: left; padding: 0px 0px 10px 0px;">','<tpl if="clips.length &gt; 0">','<tpl for="clips">','<a onclick="Coverage.showSource({id}, \'{headline}\', \'{url}\')" href="#" class="item-title">{headline}</a>','<tpl if="byline"> by {byline}</tpl><tpl if="outlet_name">, {outlet_name}</tpl>','<tpl if="xindex!=xcount"><hr style="margin-bottom: 2px;"></tpl>','</tpl>','</tpl>','</div>','</div>','</tpl>').compile();},showRelevantExperts:function(){Persons.showRelevantExperts(Ext.get('research-topic-search-textfield').getValue());},showRelevantCompanies:function(){var cfg={baseParams:{sphinx_keyword:Ext.get('research-topic-search-textfield').getValue()}};Companies.showMain(cfg);},showRelevantReleases:function(){Prwire.showMain({keyword:Ext.get('research-topic-search-textfield').getValue()},true);},initImportTopButton:function(ds){this.importListResearchButton=new Ext.Button({applyTo:'import-list-'+ds+'-research-button',height:27,width:86,text:'Import list',handler:function(){ContactsListImportWizard=new ListImportWizard();ContactsListImportWizard.open();return false;}});},getSortByMenu:function(section,link){var m=Ext.getCmp(section+'-sortby-menu');var items=[{text:'Today',value:'day'},{text:'Last week',value:'week'},{text:'Last month',value:'month'}];if(section=='experts'){items.push({text:'Last 3 months',value:'three_months'},{text:'Last 6 months',value:'six_months'},{text:'Last year',value:'year'});}
return m?m:new Ext.menu.Menu({id:section+'-sortby-menu',defaults:{group:section+'sort',xtype:'menucheckitem',checkHandler:function(item,e){if(item.checked){Ext.getCmp('sources-panel').doSorting(section,item.value);Ext.get(link).update('| '+item.text);}},scope:this},items:items});},initSortByButton:function(section,link,ev){this.getSortByMenu(section,link).showAt(new Array(ev.clientX,ev.clientY));},getSortingTpl:function(section){return new Ext.XTemplate('<tpl for=".">','<tpl for="search_results">',(section=='coverage')?['<tpl if="clips">','<tpl for="clips">','<div style="padding-bottom: 3px;"><span style="margin-right: 7px; color: #888888; font-weight: bold;">{clip_published_at} ago</span><a href=# class="item-headline" style="font-size: 9.5pt; font-style: normal; font-weight: bold;" onclick="showClip({clip_id})">{clip_title}</a> <tpl if="clip_byline">by {clip_byline}</tpl><tpl if="clip_byline && clip_outlet">, </tpl><tpl if="clip_outlet">{clip_outlet}</tpl></div>','</tpl>'+'</tpl>','<tpl if="!clips.length">','Sorry, nothing was found','</tpl>'].join(''):'',(section=='releases')?['<tpl if="releases">','<tpl for="releases">','<div style="padding-bottom: 3px;"><span style="margin-right: 7px; color: #888888; font-weight: bold;">{release_published_at} ago</span><a href=# class="item-headline" style="font-size: 9.5pt; font-style: normal; font-weight: bold;" onclick="showRelease({release_id})">{release_title}</a><tpl if="newsroom">, <a href="#" style="color: #000000; text-decoration: none;" onclick="showContact({newsroom_contact_id})">{newsroom}</a>. </tpl></div>','</tpl>','</tpl>','<tpl if="!releases.length">','Sorry, nothing was found','</tpl>'].join(''):'',(section=='companies')?['<table><tr valign="top">','<tpl if="companies">','<tpl for="companies">','<td width="50" style="padding-right: 25px;">','<div style="height: 48px; padding-bottom: 3px;"><img src="{company_img_url}" onclick="Ext.getCmp(\'sources-panel\').previewItem({company_contact_id}, \'company\');"></div>','<a href="#" onclick="showContact({company_contact_id})" style="font-size: 9pt; font-style: normal;">{company_title}</a>','</td>','</tpl>','</tpl>','<tpl if="!companies.length">','Sorry, nothing was found','</tpl>','</tr></table>'].join(''):'',(section=='experts')?['<table><tr valign="top">','<tpl if="experts">','<tpl for="experts">','<td width="50" style="padding-right: 25px;">','<div style="height: 48px; padding-bottom: 3px;"><img src="{expert_img_url}" onclick="Ext.getCmp(\'sources-panel\').previewItem({expert_contact_id}, \'expert\');"></div>','<a href="#" onclick="showContact({expert_contact_id})" style="font-size: 9pt; font-style: normal;">{expert_title}</a>','</td>','</tpl>','</tpl>','<tpl if="!experts.length">','Sorry, nothing was found','</tpl>','</tr></table>'].join(''):'','</tpl>','</tpl>').compile()},doSorting:function(section,sorting){var p=Ext.get("research-topic-"+section+"-search");p.dom.innerHTML='&nbsp;';p.addClass("overview-loading");this.topicSearchSortingStore.removeListener('load');this.topicSearchSortingStore.addListener('load',function(st,data,options){p.removeClass("overview-loading");var items=Array();Ext.each(data,function(e){items.push(e.json)},this);if(items.length){this.getSortingTpl(section).overwrite(p,items);}else{p.dom.innerHTML='<span class="item-info">Sorry, nothing was found</span>';}},this,{stopEvent:true,single:true});this.topicSearchSortingStore.reload({params:{keyword:Ext.get('research-topic-search-textfield').getValue(),section:section,sorting:sorting}});return true;},doTopicSearch:function(){var p=Ext.get("research-topic-search");p.dom.innerHTML='&nbsp;';p.addClass("overview-loading");this.topicSearchStore.on('load',function(st,data,options){p.removeClass("overview-loading");var items=Array();Ext.each(data,function(e){items.push(e.json)},this);if(items.length){}else{p.dom.innerHTML='<span class="item-info">Sorry, nothing was found</span>';}},this);this.topicSearchStore.load({params:{keyword:Ext.get('research-topic-search-textfield').getValue()}});return true;},doReleasesSearch:function(){Prwire.showMain({filter:Ext.get('sources-releases-search-textfield').getValue()});return true;},doCompaniesSearch:function(){var cfg={baseParams:{filter:Ext.get('sources-companies-search-textfield').getValue()}};Companies.showMain(cfg);return true;},initAddTopButton:function(){if(this.addResearchButton){return;}
this.addResearchButton=new Ext.Button({applyTo:'add-research-button',text:'Add',height:27,width:73,scope:this,menu:{items:[{text:'Person',handler:function(item,e){ContactAddWizard=new ContactWizard();ContactAddWizard.open();},scope:this}]}});},processEnter:function(e){var keycode;if(window.event){keycode=window.event.keyCode;}else{if(e){keycode=e.which;}else{return true;}}
if(keycode==13){return false;}else{return true;}},getTopAreaItems:function(){this.listsStore.reload();this.topicSearchStore.reload();return[{height:60,html:this.researchTop=['<div class="overview-container">','<div class="block-title sprite sprite-search"><h1>Sources</h1><div><table style="float: right;"><tr><td><div id="add-research-button"></div></td></tr></table></div>','<hr></div>','</div>'].join('')},{xtype:'tabpanel',baseCls:'section-tabs',activeTab:0,autoHeight:true,autoWidth:true,items:[{title:'Topic',autoHeight:true,autoWidth:true,items:[{bodyStyle:'padding: 15px 15px 0px 15px;',id:'research-section-topic-form',cls:'section-inline-form',layout:'column',items:[{columnWidth:.8,items:{html:'<input type="text" class="section-search" id="research-topic-search-textfield" onkeypress="if (!Ext.getCmp(\'sources-panel\').processEnter(event)) { Ext.getCmp(\'sources-panel\').doTopicSearch(); return false; } else return true;">'}},{columnWidth:.2,items:{xtype:'panel',style:'padding-left: 10px;',html:'<a href=# onclick="Ext.getCmp(\'sources-panel\').doTopicSearch()" class="submit-search search-word" title="Submit search"></a>'}}]},{bodyStyle:'padding: 0px 0px 5px 15px;',cls:'section-inline-note',html:'Enter a search term and Influencing will return most relevent coverage, releases, companies and experts'},{id:'topic-research-tpl-panel',xtype:'dataview',store:this.topicSearchStore,tpl:this.topicSearchTpl,plugins:new Ext.ux.RefreshMenu(),listeners:{afterrender:{fn:function(){this.doLayout();}},scope:this}}],listeners:{activate:{fn:function(){this.initAddTopButton();Ext.get('topic-research-tpl-panel-123').show();this.doLayout();}},scope:this}},{title:'Releases',id:'sourcesReleasesTab',disabled:true,items:[{bodyStyle:'padding: 15px 15px 0px 15px;',id:'sources-section-releases-form',cls:'section-inline-form',layout:'column',items:[{columnWidth:.8,items:{html:'<input type="text" class="section-search" id="sources-releases-search-textfield" onkeypress="if (!Ext.getCmp(\'sources-panel\').processEnter(event)) { Ext.getCmp(\'sources-panel\').doReleasesSearch(); return false; } else return true;">'}},{columnWidth:.2,items:{xtype:'panel',style:'padding-left: 10px;',html:'<a href=# onclick="return Ext.getCmp(\'sources-panel\').doReleasesSearch()" class="submit-search search-word" title="Submit search"></a>'}}]},{bodyStyle:'padding: 0px 0px 5px 15px;',cls:'section-inline-note',html:'Enter a search term and Influencing will return most relevent releases'}]},{title:'Companies',id:'sourcesCompaniesTab',disabled:true,items:[{bodyStyle:'padding: 15px 15px 0px 15px;',id:'sources-section-companies-form',cls:'section-inline-form',layout:'column',items:[{columnWidth:.8,items:{html:'<input type="text" class="section-search" id="sources-companies-search-textfield" onkeypress="if (!Ext.getCmp(\'sources-panel\').processEnter(event)) { Ext.getCmp(\'sources-panel\').doCompaniesSearch(); return false; } else return true;">'}},{columnWidth:.2,items:{xtype:'panel',style:'padding-left: 10px;',html:'<a href=# onclick="Ext.getCmp(\'sources-panel\').doCompaniesSearch();" class="submit-search search-word" title="Submit search"></a>'}}]},{bodyStyle:'padding: 0px 0px 5px 15px;',cls:'section-inline-note',html:'Enter a search term and Influencing will return most relevent companies'}]},{title:'Contacts',id:'sourcesContactsTab',disabled:true,items:[{bodyStyle:'padding: 15px;',id:'sources-section-contacts-form',cls:'section-inline-form',items:Media.getSearchFormCfg('sources-contacts',true)},{id:'contacts-sources-tpl-panel',xtype:'dataview',plugins:new Ext.ux.RefreshMenu(),listeners:{afterrender:{fn:function(){this.doLayout();}},scope:this}}]}],listeners:{afterrender:{fn:function(){this.doLayout();this.initAddTopButton();}},scope:this}}];},getTopAreaCfg:function(){return{id:"section-"+this.name+"-top-panel",items:this.getTopAreaItems()};},getBottomAreaCfg:function(){return{id:"section-"+this.name+"-bottom-panel",autoHeight:true,cls:'overview-container'}}});var Outlets=new ContactsModule({itemTitle:'outlet',itemsTitle:'outlets',title:'Outlets',name:'outlets',overviewFields:['letters','updates','reach_types','states','beats'],initParams:function(){this.rd=['id','contact_id','title','description','parent_outlet_id','type_id','media_company_id','publication_value_id','reach_type_id','language','frequency_id','currency_id','is_colored','full_page_price','half_page_price','quarter_page_price','column_centimetre_price','color_loading','banner_ad_price','per_sec_price','emails','email','phones','phone','websites','messengers','addresses','profile_partner','profile_account','start_time','end_time','tips','beats_ids','beats','relationOutlets','permission_type','permission_edit',{name:'is_editable',type:'bool'},'parent_outlet','media_company','type','publication_value','reach_type','frequency','currency','image_id','image_url_original','image_url_big','image_url_normal_cropped','cover_id','cover_url_original','cover_url_big','cover_url_normal_cropped','location_country','location_country_id','location_state','location_state_id','location_suburb','location_suburb_id','media_kit_url','media_kits','topics','readerships','feeds','prblog_feeds','clipping_urls','monitoring_type_id','monitoring_cost','monitoring_urls',{name:'is_ignore_monitoring',type:'bool'},'distributes_scheduled_features','verification_status','verification_manager_id','verification_days','subtype_ids'];this.cm=[new StoreSelectionModel({recordDef:this.rd}),{header:"Title",dataIndex:"title",width:260,renderer:this.titleRenderer,scope:this},{header:"Phone",dataIndex:'phone',width:100,sortable:false}];this.overviewTpl=new Ext.XTemplate('<tpl for=".">','<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr valign="top">','<td width="50%">','<div class="overview-container">','<div class="block-title sprite sprite-outlet"><h1>Browse Outlets</h1><hr></div>','<div class="updates-item">','<a onclick="Outlets.showMain();">All</a> ','<tpl for="letters">','<a onclick="Outlets.browseByLetter(\'{0}\')">{0}</a> ','</tpl>','</div>','</div>','<div class="overview-container">','<div class="block-title sprite sprite-folder"><h1>Outlets by Beat</h1><hr/></div>','<tpl for="beats">','<tpl if="leaf">','<div class="arrows"></div><div class="overview-beat"><a href=# class="subject" onclick="Outlets.showBeat(\'{id}\',\'{text}\');">{text}</a></div>','</tpl>','<tpl if="!leaf">','<div class="arrows arrow-black" id="'+this.name+'-beat-{id}"><a href=# onclick="Outlets.toggleSubCategories({id});return false;"></a></div><div class="overview-beat"><a href=# class="subject" onclick="Outlets.showBeat(\'{id}\',\'{text}\');">{text}</a></div>','<div class="subcategories" id="'+this.name+'-beat-children-{id}" style="display: none;">','<tpl for="children">','<a href=# onclick="Outlets.showBeat(\'{id}\');">{text}</a><tpl if="xindex!=xcount"> | </tpl>','</tpl>','</div>','</tpl>','<tpl if="xindex!=xcount"><hr></tpl>','</tpl>','</div>','</td><td>','<div class="overview-container" style="padding: 10px;">','<div class="overview-search-form">','<div class="block-title sprite sprite-search"><h1>Find Outlets</h1><hr></div>','<div class="inputs">','<label for="outlets_search_by_name">Find outlets with the <b>name</b> (eg. The Australian)</label><br>','<input class="x-form-text x-form-field w250" name="outlets_search_by_name" id="outlets_search_by_name" type="text" /><br><br>','<label for="outlets_search_by_beat">That cover this <b>beat or theme</b> (eg. education)</label><br>','<input class="x-form-text x-form-field w250" name="outlets_search_by_beat" id="outlets_search_by_beat" type="text" /><br><br>','<label for="outlets_search_by_format">That are of the following <b>format</b> (eg. Newspapers)</label><br>','<div class="x-small-editor" id="outlets_search_by_format"></div>','</div>','<div class="x-small-editor" id="outlets_submit_search_by_name" style="float: right; padding-top: 23px;"></div>','</div>','</div>','<div class="overview-container tools-block">','<div class="block-title sprite sprite-tools"><h1>Tools & Assistance</h1><hr/></div>','<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-add"></div><a href=# onclick="new OutletWizard().open(); return false;" class="title">Add a new outlet</a></div>','<div class="summary">If you can\'t find an outlet, you can add it by clicking here. Outlets can be set to bee seen only by yourself, shared only within your company or they can be shared with the entire community</div>','</div>','</div>','<div class="overview-container">','<div class="block-title sprite sprite-outlet"><h1>Outlet by Type</h1><hr></div>','<div class="updates-item">','<a href=# class="title" onclick="Outlets.browseByFormat(8105, \'Newspapers\')">Newspapers</a><br>','<tpl for="states">','<a onclick="Outlets.browseByFormatAndState(8105, \'Newspapers {value}\', \'{id}\')">{value}</a><tpl if="xindex!=xcount"> | </tpl>','</tpl><br>','<tpl for="reach_types">','<a onclick="Outlets.browseByFormatAndReachType(8105, \'Newspapers {[this.toLower(values["value"])]}\', \'{id}\')">{value}</a><tpl if="xindex!=xcount"> | </tpl>','</tpl><br><br>','<a href=# class="title" onclick="Outlets.browseByFormat(8102, \'Radio\')">Radio</a><br>','<tpl for="states">','<a onclick="Outlets.browseByFormatAndState(8102, \'Radio {value}\', \'{id}\')">{value}</a><tpl if="xindex!=xcount"> | </tpl>','</tpl><br>','<tpl for="reach_types">','<a onclick="Outlets.browseByFormatAndReachType(8102, \'Radio {[this.toLower(values["value"])]}\', \'{id}\')">{value}</a><tpl if="xindex!=xcount"> | </tpl>','</tpl><br><br>','<a href=# class="title" onclick="Outlets.browseByFormat(8106, \'Television\')">Television</a><br>','<tpl for="states">','<a onclick="Outlets.browseByFormatAndState(8106, \'Television {value}\', \'{id}\')">{value}</a><tpl if="xindex!=xcount"> | </tpl>','</tpl><br>','<tpl for="reach_types">','<a onclick="Outlets.browseByFormatAndReachType(8106, \'Television {[this.toLower(values["value"])]}\', \'{id}\')">{value}</a><tpl if="xindex!=xcount"> | </tpl>','</tpl><br><br>','</div>','</div>','<div class="overview-container">','<div class="block-title sprite sprite-stream"><h1>Outlet Updates</h1><hr></div>','<tpl for="updates">','<div class="portlet-item"><div class="ico-new ico-new-{icon}"></div>{message} <span class="item-info">{created_at} ago</span></div><tpl if="xindex!=xcount"><hr></tpl>','</tpl>','</div>','</td>','</tr></table>','</tpl>',{toLower:function(v){return v.toLowerCase();}}).compile();this.mediaKitViewTpl=new Ext.XTemplate('<tpl for=".">','<div class="x-form-item">','<label class="x-form-item-label" style="width: 200px;">Current media kit:</label>','<tpl for="media_kits">','<div style="float: left; padding: 3px 2px 2px;"><a href="{link}" target="_blank">{link}</a><tpl if="is_file">&nbsp;&nbsp;[ <a id="outlets_delete_media_kit_{parent.id}">Delete</a> ]</tpl></div>','</tpl>','<tpl if="media_kits.length == 0">','<div style="float: left; padding: 3px 2px 2px;">not specified</div>','</tpl>','</div>','<div class="x-clear"></div>','</tpl>').compile();},createProfilePanel:function(){var items=[];if(isPartnerAdmin()){items.push({xtype:'htmleditor',name:'profile_partner',fieldLabel:'Profile',height:200,width:500,expandTo:620});}
else{items.push(this.accountProfile=new Ext.form.HtmlEditor({xtype:'htmleditor',name:'profile_account',fieldLabel:'Account profile',height:200,width:500,expandTo:620}));}
return{title:"Profile",height:400,overflow:'auto',autoScroll:true,bodyStyle:'position:relative;',defaults:{autoHeight:true,xtype:"fieldset",collapsible:true},items:[{title:'Profile',overflow:'auto',autoScroll:true,items:items}]}},initFilters:function(){return[prepareComboBox({emptyText:'All Regions',labelName:'Regions',hiddenName:'countryId',store:app.ds.countries}),Contacts.prepareBeatsCombo(),prepareComboBox({emptyText:'All Types',labelName:'Types',hiddenName:'type',store:app.ds.outletTypes,width:120}),new Ext.form.ComboBox({valueField:'value',displayField:'value',width:120,editable:false,labelName:'Letter',hiddenName:'letter',mode:'local',store:app.ds.letterFilterStore,triggerAction:'all'}),prepareComboBox({emptyText:'All Reach Types',labelName:'Reach Types',hiddenName:'reach_type_id',store:app.ds.reachTypes,width:120}),prepareComboBox({emptyText:'All Formats',labelName:'Formats',hiddenName:'format',store:app.ds.outletFormats,width:120}),prepareComboBox({emptyText:'All States',labelName:'States',hiddenName:'state',store:app.ds.states}),new Ext.form.TextField({width:100,labelName:'Tag',hiddenName:'tag',value:''})];},initForm:function(){var items=[{title:"General",layout:"form",height:400,autoScroll:true,bodyStyle:'padding-right: 10px;',defaults:{xtype:'fieldset'},items:[{title:'General information',defaults:{xtype:'textfield'},autoHeight:true,collapsible:false,items:[{fieldLabel:'Title',name:'title',allowBlank:false,listeners:{'change':{fn:function(field,newVal){this.checkDuplicatesListener();},scope:this}}},prepareComboBox(makeUrl("contacts","getOutletContactOptions"),{fieldLabel:'Parent Outlet',hiddenName:"parent_outlet_id"}),getComboOptions({store:app.ds.outletTypes,fieldLabel:"Type",hiddenName:"type_id",allowBlank:false,listeners:{change:{fn:function(field,v){var f=Ext.getCmp('outlets-outlet-subtype-field');if(!v){f.store.removeAll();f.store.load({params:{pid:-1}});}else{f.store.load({params:{pid:v}});}
f.reset();}}}}),{xtype:'select',id:'outlets-outlet-subtype-field',fieldLabel:"Subtypes",hiddenName:'subtype_ids',store:prepareOptionsDs(Outlets.makeUrl('getSubtypeOptions'),null,{autoLoad:false}),valueField:'id',displayField:'value',triggerAction:'all',allowBlank:false,mode:'local',multiSelect:true},{xtype:'timefield',name:'start_time',fieldLabel:'Start Time',format:app.conf.timeFormat,increment:5},{xtype:'timefield',name:'end_time',fieldLabel:'End Time',format:app.conf.timeFormat,increment:5},prepareComboBox(makeUrl("contacts","getCompanyOptions"),{fieldLabel:"Media Company",hiddenName:"media_company_id"}),getComboOptions({store:app.ds.publicationValueTypes,fieldLabel:"Publication Value",hiddenName:"publication_value_id"}),getComboOptions({store:app.ds.reachTypes,fieldLabel:"Reach Type",allowBlank:false,hiddenName:"reach_type_id"}),{fieldLabel:'Language',name:'language'},getComboOptions({store:app.ds.frequencyTypes,fieldLabel:"Frequency",hiddenName:"frequency_id"}),getComboOptions({fieldLabel:'Currency',hiddenName:"currency_id",allowBlank:false,store:app.ds.currencyTypes})]},{title:'Features',defaults:{xtype:'textarea'},autoHeight:true,collapsible:false,items:getComboOptions({fieldLabel:'Distributes Scheduled Features',hiddenName:"distributes_scheduled_features",allowBlank:false,valueField:'value',store:new Ext.data.SimpleStore({fields:['value'],data:[['Yes'],['No'],['Unknown']]})})},{title:'Location',items:[this.locationCountryField=prepareComboBox(app.makeUrl('getCountriesOptions'),{fieldLabel:'Country',hiddenName:'location_country_id',listeners:{'select':{fn:function(combo){this.locationStateField.store.load({params:{country_id:combo.getValue()}})},scope:this}}}),this.locationStateField=prepareComboBox(app.makeUrl('getStateOptions'),{fieldLabel:'State',hiddenName:'location_state_id',listeners:{'select':{fn:function(combo){this.locationSuburbField.store.load({params:{state_id:combo.getValue()}})},scope:this}}}),this.locationSuburbField=prepareComboBox(app.makeUrl('getSuburbOptions'),{fieldLabel:'Suburb',hiddenName:'location_suburb_id'})]},{title:'Logo',autoHeight:true,collapsible:false,items:[{fieldLabel:"Upload logo",name:"uploadFile",xtype:'fileuploadfield',width:250},{fieldLabel:"Upload cover/screenshot",name:"uploadCover",xtype:'fileuploadfield',width:250},this.logoViewPanel=new Ext.Panel({autoheight:true,items:[new Ext.DataView({store:this.store,tpl:this.logoViewTpl,autoHeight:true})]})]}]}];if(isPartnerAdmin()){items.push(this.createPermissionsPanel('outlet'));}
items.push(this.profilePanel=this.createProfilePanel(),this.contactsPanel=this.createContactsPanel('outlet'),this.relatedOutletsPanel=this.createRelationPanel(),this.topicsPanel=this.createTopicsPanel(),this.createBeatsPanel(),{title:"Media Kit",height:400,overflow:'auto',autoScroll:true,items:{title:'Media Kit',xtype:'fieldset',autoHeight:true,labelWidth:200,items:[{fieldLabel:"Attach Media Kit",name:"uploadMediaKit",xtype:'fileuploadfield',width:220},{xtype:'textfield',fieldLabel:"and/or specify media kit url",name:'media_kit_url',allowBlank:true,vtype:'url'},this.mediaKitViewPanel=new Ext.Panel({autoheight:true,items:[new Ext.DataView({store:this.store,tpl:this.logoViewTpl,autoHeight:true})]})]}});if(isPartnerAdmin()){items.push({title:'Monitoring',height:400,overflow:'auto',autoScroll:true,defaults:{xtype:'fieldset',autoHeight:true,labelWidth:200},items:[{title:'Subscriptions',items:[getComboOptions({fieldLabel:'Monitoring Type',hiddenName:"monitoring_type_id",store:app.ds.monitoringTypes}),{fieldLabel:'Annual cost $',name:'monitoring_cost',xtype:'textfield',vtype:'price'},{xtype:'textarea',fieldLabel:'ID Urls',name:'monitoring_urls'}]},{title:'Monitoring',items:[{xtype:'textarea',fieldLabel:'Clipping domains',name:'clipping_urls',emptyText:'Input comma separated domains (without www or http://)'},{boxLabel:'Is ignore monitoring',name:'is_ignore_monitoring',xtype:'checkbox',inputValue:'1'}]}]});items.push(this.readershipsPanel=this.createReadershipPanel());}
items.push({title:"Feeds",layout:"fit",bodyStyle:'position:relative;',defaultType:'fieldset',defaults:{autoHeight:true,labelWidth:200},overflow:'auto',autoScroll:true,items:[this.feedsPanel=this.createFeedsPanel('Feeds','feed[]',true),this.prblogsFeedsPanel=this.createFeedsPanel('PR Blogs','prblog_feed[]')]});return{fileUpload:true,defaults:{bodyStyle:'padding:10px'},items:{xtype:'tabpanel',layoutOnTabChange:true,height:400,activeTab:0,defaults:{bodyStyle:'position:relative;'},items:items}};},fillForm:function(obj){this.getForm().setValues(obj);var f=Ext.getCmp('outlets-outlet-subtype-field');f.store.load({params:{pid:obj.type_id},callback:function(){Ext.getCmp('outlets-outlet-subtype-field').setValue(obj.subtype_ids.split(','));}});this.contactsPanel.set(obj);this.topicsPanel.set(obj.topics);this.feedsPanel.set(obj.feeds);this.prblogsFeedsPanel.set(obj.prblog_feeds);var i=0;Ext.each(obj.topics,function(n){var relatedOutletCmpId='related_'+(4+(i*6));Ext.getCmp(relatedOutletCmpId).store.load({params:{ids:n.related_outlets_ids},callback:function(){Ext.getCmp(relatedOutletCmpId).setValue(n.related_outlets_ids.split(','));}});var relatedPersonCmpId='related_'+(5+(i*6));Ext.getCmp(relatedPersonCmpId).store.load({params:{ids:n.related_persons_ids},callback:function(){Ext.getCmp(relatedPersonCmpId).setValue(n.related_persons_ids.split(','));}});i++;},this);this.logoViewPanel.show();this.logoViewPanel.doLayout();this.logoViewTpl.overwrite(this.logoViewPanel.body,obj);this.mediaKitViewTpl.overwrite(this.mediaKitViewPanel.body,obj);if(Ext.get('contacts_delete_logo_'+obj.id)){Ext.get('contacts_delete_logo_'+obj.id).addListener('click',function(){Ext.MessageBox.confirm('Message','Do you really want to delete?',function(btn,text){if(btn=='yes'){sendJsonRequest(makeUrl('contacts','deleteImage'),{contactId:obj.contact_id},function(){Ext.get('contacts_delete_logo_'+obj.id).parent().update('');});}},this);},this);}
if(Ext.get('contacts_delete_cover_'+obj.id)){Ext.get('contacts_delete_cover_'+obj.id).addListener('click',function(){Ext.MessageBox.confirm('Message','Do you really want to delete?',function(btn,text){if(btn=='yes'){sendJsonRequest(makeUrl('outlets','deleteCover'),{contactId:obj.contact_id},function(){Ext.get('contacts_delete_cover_'+obj.id).parent().update('');});}},this);},this);}
if(Ext.get('outlets_delete_media_kit_'+obj.id)){Ext.get('outlets_delete_media_kit_'+obj.id).addListener('click',function(){Ext.MessageBox.confirm('Message','Do you really want to delete attached media kit?',function(btn,text){if(btn=='yes'){sendJsonRequest(makeUrl('outlets','deleteMediaKit'),{id:obj.id},function(){Ext.get('outlets_delete_media_kit_'+obj.id).parent().update('');});}},this);},this);}},fillDynamicFields:function(obj){this.relatedOutletsPanel.set(obj.relationOutlets);if(this.readershipsPanel){this.readershipsPanel.set(obj.readerships);}},resetForm:function(){try{this.getForm().reset();}catch(e){}
this.logoViewPanel.hide();this.contactsPanel.reset();this.topicsPanel.reset();this.feedsPanel.reset();this.prblogsFeedsPanel.reset();this.relatedOutletsPanel.reset();},setFormDefaults:function(){this.contactsPanel.set();this.topicsPanel.set();this.feedsPanel.set();this.prblogsFeedsPanel.set();this.relatedOutletsPanel.set();},getGridPanelCfg:function(cfg){var result={deleteUrl:makeUrl("outlets","delete"),previewFieldId:"contact_id",dblclickShow:true,summary:'description',showFieldId:"contact_id"};return Ext.apply(result,cfg||{});},afterItemUpdate:function(actionResult){var outletPanel=Ext.getCmp('contact-'+actionResult.contactId+'-panel');if(outletPanel){outletPanel.afterItemUpdate();}},initOverviewElements:function(){new Ext.Button({minWidth:60,text:'Search',scope:this,renderTo:'outlets_submit_search_by_name',handler:function(){var filt=Ext.get("outlets_search_by_name").getValue();var beat=Ext.get("outlets_search_by_beat").getValue();var format_id=this.overviewOutletFormatsCombo.getValue();var format=this.overviewOutletFormatsCombo.getRawValue();if(filt||beat||format_id){this.showFilteredGrid(this.getGridPanelCfg({pagerUrl:this.makeUrl("getPager"),title:filt||beat||format,baseParams:{filter:filt,beat:beat,format:format_id}}),'by-filter');}}});this.overviewOutletFormatsCombo=prepareComboBox({emptyText:'All Formats',labelName:'Formats',hiddenName:'format',renderTo:'outlets_search_by_format',store:app.ds.outletFormats,forceSelection:true,typeAhead:true,width:258});makeAutocompleteBeats("outlets_search_by_beat");},browseByReachType:function(type_id,type){this.showFilteredGrid(this.getGridPanelCfg({title:type,baseParams:{reach_type_id:type_id}}),'by-reach-type-'+type_id);},browseByFormat:function(format_id,name){this.showFilteredGrid(this.getGridPanelCfg({title:name,baseParams:{format:format_id}}),'by-format-'+format_id);},browseByState:function(state_id,name){this.showFilteredGrid(this.getGridPanelCfg({title:name,baseParams:{state:state_id}}),'by-state-'+state_id);},browseByFormatAndReachType:function(format_id,title,reach_id){this.showFilteredGrid(this.getGridPanelCfg({title:title,baseParams:{format:format_id,reach_type_id:reach_id}}),'by-reach-type-'+format_id+'-'+reach_id);},browseByFormatAndState:function(format_id,title,state_id){this.showFilteredGrid(this.getGridPanelCfg({title:title,baseParams:{format:format_id,state:state_id}}),'by-reach-type-'+format_id+'-'+state_id);},createRelationPanel:function(){return{title:"Relation Outlets",height:400,overflow:'auto',bodyStyle:'position:relative;',autoScroll:true,items:[new DynamicFieldsPanel({fields:[getRemoteComboOptions(makeUrl("contacts","getOutletContactOptions"),{fieldLabel:'Outlet',hiddenName:"outletContactId[]"})],set:function(obj){try{if(!obj.length){this.appendField();}
Ext.each(obj,function(n){this.appendField([[n.relation_id,n.related]]);},this);}catch(e){this.appendField();}}})],reset:function(){this.items[0].reset();},set:function(obj){this.items[0].set(obj);}};},createReadershipPanel:function(){return{title:'Readership',overflow:'auto',autoScroll:true,items:[new DynamicFieldsPanel({fields:[getComboOptions({store:app.ds.readershipTypes,fieldLabel:'Type',hiddenName:"readership_type[]"}),getComboOptions({store:app.ds.readershipBenchmarks,fieldLabel:'Benchmark',hiddenName:"readership_benchmark[]"}),{fieldLabel:'Readership',name:'readership_value[]'},{xtype:'datefield',fieldLabel:'Date',name:'readership_date[]',value:new Date(),format:app.conf.dateFormat}],set:function(obj){try{if(!obj.length){this.appendField();}
Ext.each(obj,function(n){this.appendField([n.type_id,n.benchmark_id,n.readership,n.date]);},this);}catch(e){this.appendField();}}})],reset:function(){this.items[0].reset();},set:function(obj){this.items[0].set(obj);}};},checkDuplicatesListener:function(){var values=this.getForm().getValues();if(!values.title){return;}
var dlg=this.getDialog();this.duplicatesCheckStore.removeListener('load');this.duplicatesCheckStore.addListener('load',function(store,data){if(data[0].data.duplicating_id){this.duplicatingDlg.objId=data[0].data.obj_id;this.duplicatingDlg.actionDlg=dlg;this.duplicatingDlg.isEditable=data[0].data.is_editable;this.duplicatingDlg.typeId=data[0].data.type_id;this.duplicatingDlg.buttons[2].show();this.duplicatingDlg.show();this.duplicatingTpl.overwrite(Ext.getCmp('contacts-duplicates-dataview').body,data[0].data);}},this);this.duplicatesCheckStore.load({params:{type_id:304,title:values.title.trim(),id:dlg.objId}});},getSearchFormCfg:function(name,withControls){var form=new SearchFormPanel({name:name,id:name+'-searchForm',module:this,withControls:withControls?true:false,sections:['beats','type','frequency','location','language','circulation','address','datasets'],getFormItems:function(){var items=[];if(!withControls){items.push(this.getFieldCfg('filter'));}
items.push(this.getFieldCfg('filter',false,'Search for outlets with the following <b>title</b>','Search for outlets with the following title'),this.getFieldCfg('beats',false,'Find outlets who cover the following <b>beats</b>','Find outlets who cover the following beats'),this.getFieldCfg('type',false),this.getFieldCfg('frequency',withControls),this.getFieldCfg('location',withControls),this.getFieldCfg('language',withControls),this.getFieldCfg('circulation',withControls),this.getFieldCfg('address',withControls),this.getFieldCfg('datasets',withControls));return items;}});return form;}});var Home=new Application.Module({name:'home',title:'Home',section:'home',initParams:function(){this.activityTpl=['<div class="updates-item">','<div class="portlet-item"><div class="ico-new ico-new-{icon}"></div>{message} <span class="item-info">{created_at} ago</span>','<div class="desc">{desc}</div>','</div>','</div><tpl if="xindex!=xcount"><hr></tpl>'].join('');this.activitiesStore=prepareDs(this.makeUrl("getStatusesForHomeOverview"),[],false);this.overviewFields=['featured_news','featured_section','news','activities_all','last_session','media_news','marcoms_news','pr_blogs'];if(isJourno()){this.overviewFields.push('latest_coverage','events','releases','requests_count','recruitments','status','status_updated_at');this.overviewTpl=new Ext.XTemplate('<tpl for=".">','<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr valign="top">','<td width="50%">','<div class="overview-container">',Stories.getStoriesTpl('featured_news','{featured_section}'),'</div>','<div class="overview-container">',Stories.getStoriesTpl('news',null,'Latest News',2),'</div>','<div class="overview-container">','<div class="block-title sprite sprite-releases"><h1>Latest Announcements</h1><a href=# class="see-more" onclick="">See more</a><hr/></div>','<tpl for="releases">','<tpl if="xindex&lt;4">','<table cellpadding=0 cellspacing=0 border=0 class="item" width="100%"><tr valign="top">','<td class="image" width="125px"><img src="{image_url}" border=0 /></td>','<td class="content">','<a href=# class="item-headline" onclick="showRelease({id})">{title}</a><br>','<div class="summary">{description}</div>','<div class="item-info"><a href=# onclick="Companies.showItem({company_contact_id})">{company}</a> | {published_at} ago</div>','</td>','</tr></table><tpl if="xindex!=xcount"><hr></tpl>','</tpl>','<tpl if="xindex&gt;3">','<div class="articleTitle"><a href=# onclick="showRelease({id})">{title}</a> <span class="item-info release"><a href=# onclick="Outlets.showItem({outlet_id})">{outlet}</a> | {published_at} ago</span></div>','</tpl>','</tpl>','</div>','</td><td>','<div class="overview-container">','<div class="block-title sprite sprite-tools"><h1>Tools</h1><hr/></div>','<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-releases"></div><a href=# onclick="new RequestWizard().open(); return false;" class="title">Post a Media Request</a> [ <a href=# onclick="Requests.showMain();">{requests_count} current</a> ]</div>','<div class="summary">Quickly request information, spokespeople or product from the vendor and PR community in seconds.</div>','</div>','<div class="tools"><b>More tools:</b> ','<a href=# onclick="ProfileEditWizard = new ProfileWizard();ProfileEditWizard.open()">Edit my profile</a> | ','<a href=# onclick="Persons.showItem(',cfg.user.contact_id,');">Preview my profile</a> | <a href=# onclick="Preferences.init().edit();">Edit my settings</a> | <a href=# onclick="HomePages.init().doAdd();return false;">New dashboard</a></div>','</div>','<div class="overview-container">','<div class="block-title sprite sprite-stream"><h1>Site Stream</h1><hr></div>','<div class="overview-activity-form">','<table width="100%" cellpadding=0 cellspacing=0 border=0><tr><td style="padding-right: 15px;"><div id="overview-activity-textarea"></div></td>','<td valign="top"><div class="button">','<input type="button" id="home-activity-submit">','</div></td></tr></table>','</div>','<span class="activities-types-links">','<div class="include">Broadcast to: </div><div id="home-activities-types-checkboxes"></div>','</span>','<hr>','<div id="home-overview-activities" class="activity-type">','<tpl for="activities_all">',this.activityTpl,'</tpl>','</div>','</div>','<div class="overview-container">','<div style="padding-left: 10px;">','<a href="http://ninefold.com/?utm_source=itjourno&utm_medium=logo&utm_term=ninefold&utm_campaign=contra" target="_blank"><img src="/images/prwire/ninefold_logo.png" style="width: 230px;" alt="Ninefold Cloud Computing" title="Ninefold Cloud Computing"></a>','<br>','<a href="http://ninefold.com/cloud-hosting?utm_source=itjourno&utm_medium=text&utm_term=cloud%2Bhosting&utm_campaign=contra" alt="Cloud Hosting by Ninefold" title="Cloud Hosting by Ninefold" target="_blank">Cloud Hosting</a> by <a href="http://ninefold.com/?utm_source=itjourno&utm_medium=text&utm_term=ninefold&utm_campaign=contra" alt="Ninefold - Cloud Computing" title="Ninefold - Cloud Computing" target="_blank">Ninefold</a>','</div>','</div>','</td>','</tr></table>','<div style="padding: 10px; text-align: right; background-color:#f1f1f1"><a href="#" onclick="Sessions.showMain()">Last login: {last_session}</a></div>','</tpl>').compile();}else{this.opportunityTpl=['<div class="articleTitle opp <tpl if="is_starred"> starred</tpl>">','<a href=# onclick="Opportunities.init().showItem({id});">{subject}</a>','<tpl if="outlet">',' for <a href=# onclick="showOutlet({outlet_contact_id});">{outlet}</a>','</tpl>','</div>'].join('');this.overviewFields.push('calendar','opp_expiring_today','opp_date_today','opp_expiring_tomorrow','opp_date_tomorrow','opp_expiring_week','opp_date_week','opp_new','recruitments','comments','is_show_guide');this.overviewTpl=new Ext.XTemplate('<tpl for=".">',isGuest()?['<div style="background-color: #f0f0f0; padding: 7px; font-size: 13px; font-weight: bold">You are not logged in. <a href="#" onclick="return Home.showLogin()">Log in</a> or <a href="#" onclick="return Home.showRegistration()">register</a>. Registration is free!</div>','<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr valign="top">','<td width="50%">','<div class="overview-container">',Stories.getStoriesTpl('marcoms_news','Marcoms News','Marcoms News',2),'</div>','<div class="overview-container">',Stories.getPrBlogsTpl('pr_blogs','PR Blogs','PR Blogs'),'</div>','</td>','<td>','<div class="overview-container">',Stories.getStoriesTpl('media_news','Media News','Media News',2),'</div>','<div class="overview-container">',Jobs.getJobsTpl('recruitments','Recruitment'),'</div>','<div class="overview-container">','<div class="block-title sprite sprite-information"><h1>About Influencing</h1><a href=# class="see-more" onclick="Information.init().showOverview();return false;">Learn more</a><hr/></div>','<div class="updates-item">','<iframe src="http://player.vimeo.com/video/20631142?byline=0&amp;portrait=0&amp;color=59a5d1" width="400" height="225" frameborder="0"></iframe>','</div>','</div>','</div>','<div class="overview-container">','<div style="padding-left: 10px;">','<a href="http://ninefold.com/?utm_source=influencing&utm_medium=logo&utm_term=ninefold&utm_campaign=contra" target="_blank"><img src="/images/prwire/ninefold_logo.png" style="width: 230px;" alt="Ninefold Cloud Computing" title="Ninefold Cloud Computing"></a>','<br>','Powered by <a href="http://ninefold.com/?utm_source=influencing&utm_medium=text&utm_term=ninefold&utm_campaign=contra" alt="Ninefold Cloud Computing" title="Ninefold Cloud Computing" target="_blank">Ninefold</a> <a href="http://ninefold.com/?utm_source=influencing&utm_medium=text&utm_term=ninefold%2Bcloud%2Bcomputing&utm_campaign=contra" alt="Cloud Computing by Ninefold" title="Cloud Computing by Ninefold" target="_blank">Cloud Computing</a>','</div>','</div>','</td>','</tr></table>'].join(''):[(app.conf.account.id==1123)?'<tpl if="is_show_guide"><div style="background-color: #f0f0f0; padding: 7px; font-size: 13px; font-weight: bold">How well do you know this service. <a href="#" onclick="new IntroProfessionalWizard().open();return false;">Click here</a> to read our Orientation Guide. <span style="font-size: 12px;">(<a href="#" onclick="Home.hideGuideLink(this);return false;">hide this notice</a>)</span></div></tpl>':'','<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr valign="top">','<td width="50%">','<div class="overview-container">',Stories.getStoriesTpl('media_news','Media News','Media News',2),'</div>','<div class="overview-container">',Stories.getStoriesTpl('marcoms_news','Marcoms News','Marcoms News',2),'</div>','<div class="overview-container">',Stories.getPrBlogsTpl('pr_blogs','PR Blogs','PR Blogs'),'</div>',!isInfluencing()?['<div class="overview-container">'+Jobs.getJobsTpl('recruitments','Recruitment')+'</div>']:'','</td>','<td>','<div class="overview-container tools-block">',Ext.state.Manager.get("tools-section")?Ext.state.Manager.get("tools-section").is_visible?'<div class="block-title sprite sprite-tools"><h1>Tools</h1><a href=# class="see-more" id="shrink-link">Shrink this section</a><hr/></div>':'<div class="block-title sprite sprite-tools"><h1>Tools</h1><a href=# class="see-more" id="shrink-link">Expand this section</a><hr/></div>':'<div class="block-title sprite sprite-tools"><h1>Tools</h1><a href=# class="see-more" id="shrink-link">Shrink this section</a><hr/></div>','<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-releases"></div><a href=# onclick="Releases.init().doAdd();return false;" style="font-style:normal; font-weight:bold;" class="item-headline">Post a Media Release</a></div>','<div class="summary">Distribute your press release through ITJourno, PRWire, Twitter, RSS and more. <a href=# style="text-decoration: underline; font-weight: bold;" onclick="Prwire.showMain()">View past releases</a> to edit or make changes.</div>','</div>',Ext.state.Manager.get("tools-section")?Ext.state.Manager.get("tools-section").is_visible?'<div id="tools-section" value="true">':'<div id="tools-section" value="true" hidden="true">':'<div id="tools-section" value="true">',app.isHaveModule('newsrooms')?['<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-folder"></div><a href=# class="item-headline" style="font-style:normal; font-weight:bold;" onclick="Newsrooms.init().showOverview()">Manage my clients</a></div>','<div class="summary">Click her to view and manage your client information. You can also <a href=# style="text-decoration: underline; font-weight: bold;" onclick="new CompanyWizard().open()">add a new client</a>.</div>','</div>'].join(''):'',app.isHaveModule('persons')?['<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-contacts"></div><a href=# class="item-headline" style="font-style:normal; font-weight:bold;" onclick="Companies.showResearchSection(\'researchJournalistsTab\'); return false;">Find and research journalists</a></div>','<div class="summary">Search by criteria or browse journalists by the subjects they write about. If you know the name of a journalist just type their name into the top search bar. Or you can search and research <a href=# style="text-decoration: underline; font-weight: bold;" onclick="Companies.showResearchSection(\'researchOutletsTab\'); return false;">media outlets</a>.</div>','</div>'].join(''):'',app.isHaveModule('opportunities')?['<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-opportunity"></div><a href=# class="item-headline" style="font-style:normal; font-weight:bold;" onclick="Companies.showResearchSection(\'researchOpportunitiesTab\'); return false;">Find publicity opportunities</a></div>','<div class="summary">Search out Opportunity database to find upcoming articles listed in features lists and editorials calendars. Check the latest media opportunities.</div>','</div>'].join(''):'',app.isHaveModule('lists')?['<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-lists"></div><a href=# class="item-headline" style="font-style:normal; font-weight:bold;" onclick="Lists.showMain()">Build and manage media lists</a></div>','<div class="summary">Get your media lists out of spreadsheets and into a format that auto-updates, sharable and more easily managed. You can <a href=# style="text-decoration: underline; font-weight: bold;" onclick="ContactsListImportWizard = new ListImportWizard().open()">import a list</a> you have already built in a spreadsheet or <a href=# style="text-decoration: underline; font-weight: bold;" onclick="Companies.showResearchSection(\'researchMediaTab\'); return false;">build a list</a> by specifying criteria.</div>','</div>'].join(''):'',app.isHaveModule('inbox')?['<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-inbox"></div><a href=# class="item-headline" style="font-style:normal; font-weight:bold;" onclick="new EmailCampaignWizard().open()">Distribute a media release</a></div>','<div class="summary">Create personalised email distributions, which tracks opens and click-through. You can also <a href=# style="text-decoration: underline; font-weight: bold;" onclick="Inbox.init().showOverview()">view past distributions.</a></div>','</div>'].join(''):'','<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-contact"></div><a href=# class="item-headline" style="font-style:normal; font-weight:bold;" onclick="ProfileEditWizard = new ProfileWizard();ProfileEditWizard.open()">Edit your profile</a></div>','<div class="summary">Edit your profile and contact information which is viewable by journalists and influencers. You can also <a href=# onclick="Persons.showItem(',cfg.user.contact_id,');" style="text-decoration: underline; font-weight: bold;">preview your profile</a> or <a href=# style="text-decoration: underline; font-weight: bold;" onclick="new SettingsWizard().open();">edit your settings.</a></div>','</div>','</div>',Ext.state.Manager.get("tools-section")?Ext.state.Manager.get("tools-section").is_visible?'<div id="div-more-tools" hidden="true" class="tools"><b>More tools:</b> ':'<div id="div-more-tools" class="tools"><b>More tools:</b> ':'<div id="div-more-tools" hidden="true" class="tools"><b>More tools:</b> ',app.isHaveModule('newsrooms')?'<a href=# onclick="Newsrooms.init().showOverview()">Manage my clients</a> | ':'','<a href=# onclick="Companies.showResearchSection(\'researchJournalistsTab\'); return false;">Find and research journalists</a> | ',app.isHaveModule('opportunities')?'<a href=# onclick="Companies.showResearchSection(\'researchOpportunitiesTab\'); return false;">Find publicity opportunities</a> | ':'',app.isHaveModule('lists')?'<a href=# onclick="Lists.showMain()">Build and manage media lists</a> | ':'',app.isHaveModule('inbox')?'<a href=# onclick="new EmailCampaignWizard().open()">Distribute a media release</a> | ':'','<a href=# onclick="ProfileEditWizard = new ProfileWizard();ProfileEditWizard.open()">Edit your profile</a>','</div>',isPartnerAdmin()?'<div class="tools"><b>Also</b> you can view the site as <a href=# id="manage-community-edition" title="community@community.com.au">Community</a> | <a href=# id="manage-tech-edition" title="tech@tech.com.au">Tech</a> | <a href=# id="manage-professional-edition" title="professional@professional.com.au">Professional</a> | <a href=# id="manage-contacts-edition" title="contacts@contacts.com.au">Contacts</a> | <a href=# id="manage-itjourno-edition" title="itjourno@itjourno.com.au">ITJourno</a> edition</div>':'','</div>',isInfluencing()?['<div class="overview-container">','<div class="block-title sprite sprite-information"><h1>About Influencing</h1><a href=# class="see-more" onclick="Information.init().showOverview();return false;">Learn more</a><hr/></div>','<div class="updates-item">','<iframe src="http://player.vimeo.com/video/20631142?byline=0&amp;portrait=0&amp;color=59a5d1" width="400" height="225" frameborder="0"></iframe>','</div>','</div>','</div>','<div class="overview-container">',Stories.init().getCommentsTpl('comments','Latest comments'),'</div>'].join(''):['<div class="overview-container">','<div class="block-title sprite sprite-stream"><h1>Site Stream</h1><hr></div>','<div class="overview-activity-form">','<table width="100%" cellpadding=0 cellspacing=0 border=0>','<tr>','<td style="padding-right: 15px;"><div id="overview-activity-textarea"></div></td>','<td style="width: 75px"><div class="button"><input type="button" id="home-activity-submit"></div></td>','</tr>','<tr>','<td><span class="activities-types-links"><div class="include">Broadcast to: </div><div id="home-activities-types-checkboxes"></div></span></td>','</tr>','</table>','</div>','<div id="home-overview-activities" class="activity-type">','<tpl for="activities_all">',this.activityTpl,'</tpl>','</div>','</div>'].join(''),app.isHaveModule('opportunities')?['<div class="overview-container">','<div class="block-title sprite sprite-opportunity"><h1>Editorial Opportunities</h1><a href=# class="see-more" onclick="Opportunities.init().showOverview();return false;">See more</a><hr/></div>','<tpl for="opp_new">','<div class="updates-item">','<div class="portlet-item">','<a href=# class="title {new}" onclick="Opportunities.init().showItem({id})">{subject}</a> <i>Deadline: {deadline_at}</i><br>','<div class="byline">','<tpl if="person"><a href=# onclick="showContact({person_contact_id});">{person}</a></tpl>','<tpl if="outlet"> for <a href=# onclick="showOutlet({outlet_contact_id});">{outlet}</a></tpl>','<i> posted {created_at} ago</i>','</div>','<div class="summary">{description}</div>','</div>','</div>','</tpl>','<tpl for="opp_expiring_today">','<tpl if="xindex==1">','<hr><span style="color: #000;"><b>Expiring today</b> <span class="item-info">{parent.opp_date_today}</span></span><hr>','</tpl>',this.opportunityTpl,'</tpl>','<tpl for="opp_expiring_tomorrow">','<tpl if="xindex==1">','<hr><span style="color: #000;"><b>Expiring tomorrow</b> <span class="item-info">{parent.opp_date_tomorrow}</span></span><hr>','</tpl>',this.opportunityTpl,'</tpl>','<tpl for="opp_expiring_week">','<tpl if="xindex==1">','<hr><span style="color: #000;"><b>Expiring in less than a week</b> <span class="item-info">Prior to {parent.opp_date_week}</span></span><hr>','</tpl>',this.opportunityTpl,'</tpl>','</div>'].join(''):'','</td>','</tr></table>','<div style="padding: 10px; text-align: right; background-color:#f1f1f1"><a href="#" onclick="Sessions.showMain()">Last login: {last_session}</a></div>',].join(''),'</tpl>').compile();}
this.delayTask=new Ext.util.DelayedTask(function(){this.overviewStore.reload();},this)},showMainNavigation:function(){Ext.getCmp('sidebar-trees-accordion').expand();},getOverviewPanelCfg:function(){return{layout:'fit',id:this.name+'-overview-panel',autoScroll:true,module:this,closable:false,items:this.overviewDataview=new Ext.DataView({store:this.overviewStore=new Ext.data.JsonStore({url:this.overviewUrl||this.makeUrl('getOverviewData'),baseParams:{limit:6},autoLoad:false,root:'results',fields:this.overviewFields,listeners:{'load':{fn:function(){this.isLoadedOk=true;if(this.initOverviewElements){this.initOverviewElements();}},scope:this},'beforeload':{fn:function(){this.oldContent=this.overviewDataview.getEl().dom.innerHTML;},scope:this},'exception':{fn:function(){var html='';if(this.isLoadedOk){html='<div style="background-color: #f0f0f0; padding: 7px; font-size: 13px; font-weight: bold">You have lost connection with this server. <a href="#" onclick="return Home.overviewStore.reload()">Click here</a> to reconnect.</div>';this.isLoadedOk=false;}
this.overviewDataview.getEl().update(html+this.oldContent);this.delayTask.delay(60*1000);},scope:this}}}),tpl:this.overviewTpl,loadingText:'Loading',autoHeight:true,multiSelect:true,overClass:'x-view-over',autoWidth:true,itemSelector:'div.thumb-wrap',plugins:new Ext.ux.RefreshMenu(),listeners:{'afterrender':{fn:function(c){c.store.reload();}}}})}},showOverview:function(){var cfg=this.getOverviewPanelCfg();this.overviewStore.addListener('load',function(){app.getMainPanel().activate('home-overview-panel');},this,{single:true});app.showPanel(cfg);this.delayTask=new Ext.util.DelayedTask(function(){this.overviewStore.reload();},this)
this.overviewStore.addListener('beforeload',function(){this.oldContent=this.getPanel('overview').getEl().dom.innerHTML;},this);this.overviewStore.addListener('exception',function(e,e1){var html='<div style="background-color: #f0f0f0; padding: 7px; font-size: 13px; font-weight: bold">You have lost connection with this server. <a href="#" onclick="return Home.overviewStore.reload()">Click here</a> to reconnect.</div>'+this.oldContent;this.delayTask.delay(60*1000);},this);},showMain:function(){},showOverviewActivity:function(){var p=Ext.get("home-overview-activities");if(!p)return;p.dom.innerHTML='&nbsp;';p.addClass("overview-loading");this.activitiesStore.removeListener('load');this.activitiesStore.purgeListeners();this.activitiesStore.on('load',function(st,data,options){p.removeClass("overview-loading");var items=Array();Ext.each(data,function(e){items.push(e.json)},this);var tpl=new Ext.XTemplate('<tpl for=".">'+this.activityTpl+'</tpl>');if(items.length){tpl.overwrite(p,items);}else{p.dom.innerHTML='<span class="item-info">no updates of this type</span>';}},this);this.activitiesStore.load();},initOverviewElements:function(){if(isGuest())return;var activityStream=app.conf.activityStream.split(',');var items=[];if(!isJourno()){items=[{value:'2274',checked:true,boxMaxWidth:22,boxMinWidth:22,id:'radiobutton-status-only'},{xtype:'panel',html:'<a href=# onclick="Home.setActivityTypeCheckboxes(new Array(\'2274\'));return false;">Media Only</a> |',bodyCssClass:'activity-type-link'},{value:'2275',checked:false,boxMaxWidth:22,boxMinWidth:22,style:'margin-left: 5px',id:'radiobutton-status-all'},{xtype:'panel',html:'<a href=# onclick="Home.setActivityTypeCheckboxes(new Array(\'2275\'));return false;">Entire community</a>',bodyCssClass:'activity-type-link'}];}else{items=[{value:'2273',checked:true,boxMaxWidth:22,boxMinWidth:22,style:'margin-left: 5px',id:'radiobutton-status-only'},{xtype:'panel',html:'<a href=# onclick="Home.setActivityTypeCheckboxes(new Array(\'2273\'));return false;">PR/Marcoms only</a> |',bodyCssClass:'activity-type-link'},{value:'2275',checked:false,boxMaxWidth:22,boxMinWidth:22,style:'margin-left: 5px',id:'radiobutton-status-all'},{xtype:'panel',html:'<a href=# onclick="Home.setActivityTypeCheckboxes(new Array(\'2275\'));return false;">Entire community</a>',bodyCssClass:'activity-type-link'}];}
Ext.DomHelper.overwrite('home-activities-types-checkboxes','',true);this.activityTypesCheckboxGroup=new Ext.form.RadioGroup({fieldLabel:'Single Column',itemCls:'x-check-group-alt',renderTo:'home-activities-types-checkboxes',columns:8,defaults:{name:'activity_types'},items:items});this.commentTextArea=new Ext.form.TextArea({name:'home-activity',renderTo:'overview-activity-textarea',emptyText:'Broadcast a comment or notification',emptyClass:'stream-textarea-empty',cls:'stream-textarea',height:35,listeners:{afterrender:function(el){el.setWidth(el.getWidth()-15);}}});var btn=Ext.get("home-activity-submit");btn.addListener('click',function(){if(this.commentTextArea.getValue()){this.activityTypesCheckboxGroup.items.each(function(el){if(el.getValue()){this.sendJsonRequest(makeUrl("activities","create"),{note:this.commentTextArea.getValue(),type_id:el.value},function(scope,data){scope.showOverviewActivity();scope.commentTextArea.setValue();});}},this);}},this);if(isPartnerAdmin()){Ext.get('manage-community-edition').on('click',function(){sendJsonRequest(makeUrl('users','manageFromHomepage'),{email:'community@community.com.au'},function(scope,data){document.location.href=data.url||makeUrl();});})
Ext.get('manage-tech-edition').on('click',function(){sendJsonRequest(makeUrl('users','manageFromHomepage'),{email:'tech@tech.com.au'},function(scope,data){document.location.href=data.url||makeUrl();});})
Ext.get('manage-professional-edition').on('click',function(){sendJsonRequest(makeUrl('users','manageFromHomepage'),{email:'professional@professional.com.au'},function(scope,data){document.location.href=data.url||makeUrl();});})
Ext.get('manage-contacts-edition').on('click',function(){sendJsonRequest(makeUrl('users','manageFromHomepage'),{email:'contacts@contacts.com.au'},function(scope,data){document.location.href=data.url||makeUrl();});})
Ext.get('manage-itjourno-edition').on('click',function(){sendJsonRequest(makeUrl('users','manageFromHomepage'),{email:'itjourno@itjourno.com.au'},function(scope,data){document.location.href=data.url||makeUrl();});})}
if(Ext.get('shrink-link')){Ext.get('shrink-link').on('click',function(){if(Ext.get('tools-section').isVisible()){Ext.get('tools-section').slideOut('t',{easing:'easeOut',duration:.5,remove:false,useDisplay:true});Ext.get('shrink-link').update('Expand this section');Ext.get('div-more-tools').setVisible(true);var state={is_visible:false};Ext.state.Manager.set('tools-section',state);return;}
if(!Ext.get('tools-section').isVisible()){Ext.get('tools-section').slideIn('t',{easing:'easeOut',duration:.5});Ext.get('shrink-link').update('Shrink this section');Ext.get('div-more-tools').setStyle('display','none');var state={is_visible:true};Ext.state.Manager.set('tools-section',state);return;}},this);}
this.delayTask.delay(15*60*1000);},setActivityTypeCheckboxes:function(types){this.activityTypesCheckboxGroup.items.each(function(el){if(el.value==types[0]){el.setValue(true);}else{el.setValue(false);}},this);},showLogin:function(){if(!Home.loginDlg){Home.loginDlg=new Application.LoginWindow();}
Home.loginDlg.show();return false;},showRegistration:function(){new RegistrationWizard().show();return false;},showPasswordRestore:function(){Home.passwordRestoreDlg.show();return false;},showProfileWizard:function(){this.showMain();new ProfileWizard().open();},hideGuideLink:function(lnk){this.sendJsonRequest(makeUrl("home","hideGuideLink"),{},function(scope,data){Ext.get(lnk).parent().parent().slideOut('t',{remove:true});});}});ActivitiesModule=Ext.extend(Application.Module,{title:'Activities',itemTitle:'activity',outletCombo:null,companyCombo:null,personCombo:null,previewActivityDialog:null,previewDialogStore:null,name:'activities',dialogWidth:720,dialogHeight:350,afterInitParams:function(){},initParams:function(){this.cm=[new Ext.grid.CheckboxSelectionModel(),{id:'title',header:"Title",dataIndex:'title',width:300},{id:'note',header:"Note",dataIndex:'note',width:300},{id:'info',header:"Info",dataIndex:'info',width:300}];this.rd=['id','title','note','attachments','person_id','person','company_id','company','outlet_id','outlet','story_id','story','time','creator','type','project_id','task_id','project','task','subject','time_spent','request_id','request','is_editable','photo','date_time','date',{name:'created_at',type:'date',dateFormat:app.conf.dtFormat}];this.previewTpl=new Ext.XTemplate('<tpl for=".">','<div class="contacts-history-item">','<div class="module-header-3"><img src="/images/icons/user_suit.gif"></div>','<div class="module-header-3">{title}</div>','<div class="contacts-history-item-attachments">{attachments}</div>','<div class="clear"></div>','<div class="contacts-history-item-info">{info}</div>','<div class="feed-item-body">{note}</div>','</div>','</tpl>').compile();this.previewDialogStore=prepareDs(this.makeUrl('load'),this.rd,false,true);var previewDialogtableTpl=new Ext.XTemplate('<tpl for=".">','<div style="padding-bottom: 10px;">','<table width=100%>','<tr>','<td>Logged by:</td>','<td>{creator}</td>','<td>Person:</td>','<td>{person}</td>','</tr>','<tr>','<td>Activity type:</td>','<td>{type}</td>','<td>Company:</td>','<td>{company}</td>','</tr>','<tr>','<td>Date:</td>','<td>{date}</td>','<td>Outlet:</td>','<td>{outlet}</td>','</tr>','<tr>','<td>Time:</td>','<td>{time}</td>','<td>Opportunity/Request:</td>','<td>{request}</td>','</tr>','</table>','</div>','</tpl>');var previewDialogtableNoteTpl=new Ext.XTemplate('<tpl for=".">','<td colspan=4>{note}</td>','</tpl>');this.attachmentsTpl=new Ext.XTemplate('<tpl for=".">','<div class="contacts-history-item">','<div class="note-attachments">{attachments}</div>','</div>','</tpl>');this.previewActivityDialog=new Ext.Window({layout:'fit',width:600,height:400,autoScroll:true,modal:true,closeAction:'hide',plain:true,bodyStyle:'padding:5px;',buttonAlign:'center',title:'Activity Preview',items:[{xtype:'tabpanel',layoutOnTabChange:true,height:400,activeTab:0,bodyStyle:'padding:5px;',items:[{title:"Activity",xtype:"panel",autoScroll:true,autoHeight:true,defaults:{autoHeight:true,xtype:"fieldset"},items:[{xtype:"dataview",loadingText:"Loading...",store:this.previewDialogStore,tpl:previewDialogtableTpl,autoHeight:true,multiSelect:true,overClass:'x-view-over',itemSelector:'div.thumb-wrap'},{title:"Activity",collapsible:true,items:[{xtype:"dataview",loadingText:"Loading...",store:this.previewDialogStore,tpl:previewDialogtableNoteTpl,autoHeight:true,multiSelect:true,overClass:'x-view-over',itemSelector:'div.thumb-wrap'}]}]}]}],buttons:[{minWidth:80,text:'Hide',handler:function(){Activities.previewActivityDialog.hide();}}]});this.afterInitParams();},getTpl:function(){return this.previewTpl},getStore:function(id,type){return prepareDs(this.makeUrl('list?objId='+id+'&objType='+type),this.rd);},prepareData:function(data,isPreview){var attachments=Ext.util.JSON.decode(data.attachments);data.attachments="";if(isPreview){var tpl=new Ext.Template('<a href="#" onclick="location.href=\'',app.makeUrl('downloadAttachment'),'?id={id}\'" onmouseover="showTip(this, \'Download\');"><img class="contacts-history-attachment-img" src="/images/icons/attach.gif" />  {tipText}</a>','<br/>').compile();}else{var tpl=new Ext.Template('<img class="contacts-history-attachment-img" src="/images/icons/attach.gif" onclick="location.href=\'',app.makeUrl('downloadAttachment'),'?id={id}\'" onmouseover="showTip(this, \'{tipText}\');"/>').compile();}
for(var i=0;i<attachments.results.length;i++){var attachment=attachments.results[i];data.attachments+=tpl.applyTemplate({i:attachment.filename,tipText:attachment.filename,id:attachment.id});}
data.desc=data.note.replace(/<\/?[^>]+>/gi,'').ellipse(250);return data;},fillForm:function(obj){Activities.getForm().setValues(obj);},showMain:function(){this.showFilteredGrid({autoExpandColumn:'subject',isHaveFilter:false,isHaveEdit:false,footerAddons:['delete']});},make:function(id,type,scope){this.init();this.objId=id;this.objType=type;this.scope=scope||this;this.getDialog().setTitle('Log activity');this.getDialog().action="create";this.getDialog().show();},makeParamsOnDialogSubmit:function(){return{item_id:this.objId,item_type:this.objType};},preview:function(id){this.previewActivityDialog.show();this.previewDialogStore.load({params:{id:id}});}});ActivitiesPanel=function(config){var id=config.objectType+'-'+config.objectId
var module='';if(config.objectType=='task'){module='Tasks';}else if(config.objectType=='contact'||config.objectType=='person'){module='Contacts';this.noteActionAdd='No note entered [<a href=# style="color: #000;" onclick="Ext.get(\'contact-note-'+config.objectId+'\').setDisplayed(false);Ext.getCmp(\'add-contact-note-form-'+config.objectId+'\').setVisible(true);Ext.get(this).parent().setDisplayed(false);return false;">Click here to add a note</a>]';this.noteActionEdit='[<a href=# style="color: #000;" onclick="Ext.get(\'contact-note-'+config.objectId+'\').setDisplayed(false);Ext.getCmp(\'add-contact-note-form-'+config.objectId+'\').setVisible(true);Ext.get(this).parent().setDisplayed(false);return false;">edit</a>]';}
var descriptionTpl=new Ext.XTemplate('<tpl for=".">','<div id="description-container-'+config.objectId+'">','<div class="x-clear"></div>','<tpl if="this.showInternalNote(account_id, \''+module+'\')">','<div class="tasks-bg p10">','<b>Internal note:</b><br>','<div id="contact-note-{id}">','<div id="contact-note-text-{id}"><tpl if="note.length!=0">{note:nl2br}</tpl></div>','<tpl if="note.length!=0"><div class="last-editor" id="note-editor-'+config.objectId+'"><tpl if="note_edited_at.length!=0">Last edited at {note_edited_at:dtRenderer} by {note_editor}</tpl></div></tpl>','</div>','<div id="add-contact-note-{id}"></div>','<tpl if="note.length==0">','<div id="no-task-descr-{id}">'+this.noteActionAdd+'</div>','</tpl>','<tpl if="note.length!=0">','<div id="no-task-descr-{id}">'+this.noteActionEdit+'</div>','</tpl>','</div>','</tpl>','<div class="p20">','Add note:<br>','<textarea class="x-form-textarea x-form-field" style="width: 600px; height: 80px; margin-bottom: 3px;" id="add-activity-note-'+id+'" name="note"></textarea><br>','<div id="add-activity-addons-'+id+'" style="clear: both; ">','<div style="float: left; clear: none; padding: 2px 0 10px; width: 80px;">Person: </div><div style="float: left; clear: none;" id="add-activity-person-'+id+'"></div><br>','<div class="x-clear"></div>','<div style="float: left; clear: none; padding: 2px 0 10px; width: 80px;">Company: </div><div style="float: left; clear: none;" id="add-activity-company-'+id+'"></div>','</div>','<div class="x-clear"></div>','<div style="float: left; clear: none;"><div id="add-activity-submit-'+id+'"></div></div><div style="float: left; clear: none; height: 20px; padding: 5px 0 0 5px;"><a href=# id="show-activity-addons-'+id+'">Show advanced options</a></div>','</div>','<div class="tasks-bg p10">','<div style="float: left; clear: none;"><h1>ACTIVITIES</h1></div>','<div style="float: right; clear: none;"><a href=# id="'+id+'-activities-sort-asc" onclick="'+module+'.reloadActivities(\''+id+'\', \'ASC\');return false;">Sort Ascending</a> | <a href=# id="'+id+'-activities-sort-desc" style="font-weight:bold" onclick="'+module+'.reloadActivities(\''+id+'\', \'DESC\');return false;">Sort Descending</a></div>','</div>','<div class="p20" style="padding:10px 20px 20px;">','<div id="activities-'+id+'"></div>','</div>','</div>','</tpl>',{showInternalNote:function(account_id,module){return(account_id==app.conf.account.id&&module=='Contacts');}}).compile();ActivitiesPanel.superclass.constructor.call(this,Ext.apply(config,{title:'Activities',overflow:'auto',autoScroll:true,height:400,items:[{overflow:'auto',autoScroll:true,bodyStyle:'position:relative;',id:'activity-panel-'+id,listeners:{'afterrender':{fn:function(){descriptionTpl.overwrite(this.body,this.data);if(module=='Contacts'){this.addNoteForm=new Ext.form.FormPanel({renderTo:"add-contact-note-"+this.objectId,id:"add-contact-note-form-"+this.objectId,url:Contacts.makeUrl('saveNote'),labelWidth:0,hideLabels:true,defaults:{xtype:'hidden'},style:'padding-left:0;',buttonAlign:'left',hideMode:'display',items:[this.contactNote=new Ext.form.TextArea({name:'note',xtype:'textarea',hideLabel:true,width:500,height:100,allowBlank:false,value:this.data.note}),{name:'id',value:this.objectId}],buttons:[{minWidth:80,text:'Save',scope:this,handler:function(){if(this.addNoteForm.getForm().isValid()){this.addNoteForm.getForm().submit({reset:false,failure:function(form,action){Ext.MessageBox.alert('Error Message',action.result.errorInfo);},success:function(form,action){msg('Notification',action.result.info);this.data.note=action.result.note;this.data.note_edited_at=action.result.note_edited_at;this.data.note_editor=action.result.note_editor;this.addNoteForm.setVisible(false);Ext.DomHelper.overwrite(Ext.getDom('contact-note-text-'+this.data.id),Ext.util.Format.nl2br(this.data.note));Ext.DomHelper.overwrite(Ext.getDom('note-editor-'+this.data.id),'Last edited at '+Ext.util.Format.dtRenderer(this.data.note_edited_at)+' by '+this.data.note_editor);Ext.get('contact-note-'+this.data.id).setDisplayed(true);Ext.get('no-task-descr-'+this.data.id).setDisplayed(true);this.contactNote.setValue(this.data.note);},scope:this});}}},{minWidth:80,text:'Cancel',scope:this,handler:function(){this.addNoteForm.setVisible(false);this.contactNote.setValue(this.data.description);Ext.get('contact-note-'+this.objectId).setDisplayed(true);Ext.get('add-contact-note-form-'+this.objectId).setDisplayed(true);Ext.get('no-task-descr-'+this.objectId).setDisplayed(true);}}]});this.addNoteForm.setVisible(false);}
Ext.get('show-activity-addons-'+id).on('click',function(e,el){el=Ext.get(el.id);Ext.get('add-activity-addons-'+id).setVisibilityMode(Ext.Element.DISPLAY).toggle();if(el.dom.innerHTML=='Show advanced options'){el.dom.innerHTML='Hide Advanced Options';}else{el.dom.innerHTML='Show Advanced Options';}},this);this.personCombo=prepareComboBox(makeUrl('contacts','getPersonOptions'),{hiddenName:'person_id',width:200,renderTo:'add-activity-person-'+id});this.personCombo.setValue(this.data.person_id);this.companyCombo=prepareComboBox(app.makeUrl('getNewsroomsOptions'),{hiddenName:'company_id',renderTo:'add-activity-company-'+id});Ext.get('add-activity-addons-'+id).setDisplayed(false);this.addActivityBtn=new Ext.Button({text:'Save',tooltip:'Save activity',applyTo:"add-activity-submit-"+id,style:'float: left;',handler:function(){var noteTextArea=Ext.get('add-activity-note-'+id);if(!noteTextArea.getValue()){Ext.MessageBox.alert('Error Message','Please enter note');return;}
if(this.objectType=='task'){this.sendJsonRequest(Activities.makeUrl('create'),{type_id:'2205',task_id:this.objectId,is_shared:'1',note:noteTextArea.getValue(),company_id:this.companyCombo.getValue(),person_id:this.personCombo.getValue()},function(scope,data){Ext.get('add-activity-note-'+scope.objectType+'-'+scope.objectId).dom.value='';scope.personCombo.reset();scope.companyCombo.reset();scope.activitiesStore.reload();});}else if(this.objectType=='person'){if(!this.personCombo.getValue()){Ext.MessageBox.alert('Error Message','Please specify person');return;}
this.sendJsonRequest(Activities.makeUrl('create'),{type_id:'2205',is_shared:'1',note:noteTextArea.getValue(),company_id:this.companyCombo.getValue(),person_id:this.personCombo.getValue()},function(scope,data){Ext.get('add-activity-note-'+scope.objectType+'-'+scope.objectId).dom.value='';scope.personCombo.setValue(scope.data.person_id);scope.companyCombo.reset();scope.activitiesStore.reload();});}},scope:this});this.activitiesStore.load();this.panel=new Ext.Panel({id:'activities-panel-'+id,autoHeight:true,renderTo:'activities-'+id,layout:'fit',items:this.activitiesDataview=new Ext.DataView({store:this.activitiesStore,tpl:this.activitiesTpl,autoHeight:true,loadingText:'Loading...',multiSelect:true,overClass:'x-view-over',itemSelector:'div.thumb-wrap',emptyText:'No activities are logged'})});this.doLayout();},scope:this}}}]}));this.activitiesTpl=new Ext.XTemplate('<tpl for=".">','<div class="article-comment task-activ" style="margin: 0 0 10px 0;">','<div class="feed-item-pix"><img src="{photo}"></div>','<div class="feed-item-comment" style="font-size: 13px;">{title}</div>','<div class="feed-item-comment">{note}</div>','<div class="feed-item-date">{date_time}</div>','<div class="delete-{is_editable}"><tpl if="is_editable == true"><div class="icon icon-delete"></div></tpl><a onclick="'+module+'.deleteActivity('+this.id+', {id});">delete</a></div>','<div class="x-clear"></div>','</div>','</tpl>','<div class="x-clear"></div>').compile();this.activitiesStore=new Ext.data.JsonStore({url:makeUrl("activities","getPager"),root:'results',fields:Activities.rd,baseParams:{objId:this.objectId,objType:this.objectType,dir:'DESC',sort:'created_at',simpleMode:'1'},listeners:{'load':{fn:function(){},scope:this}}});};Ext.extend(ActivitiesPanel,Ext.Panel,{});Activities=new ActivitiesModule().init();CompanyWizard=function(companyId){this.companyId=companyId;this.store=new Ext.data.Store({url:makeUrl('wizards','getCompany'),autoLoad:false,reader:new Ext.data.JsonReader({},['id','title','contact_id','description','keywords','monitoring_keywords','emails','phones','websites','messengers','addresses','beats_ids','type','image_id','image_url_original','image_url_big','media_contacts'])});var logoViewTpl=new Ext.XTemplate('<tpl for=".">','<div class="x-form-item">','<tpl if="image_id">','<div style="float: left; padding: 2px;"><img onclick="showPreviewImageDialog(\'{image_url_original}\', \'\', \'\')" src="{image_url_big}" style="float:left"/>','<a id="wizard_company_delete_logo_{contact_id}" style="float:left; padding-left: 20px">Delete</a></div>','</tpl>','<tpl if="!image_id">','<div style="float: left; padding: 2px;">no image uploaded yet</div>','</tpl>','</div>','<div class="x-clear"></div>','</tpl>');var cards=[new Ext.ux.Wiz.Card({title:'Company Details',monitorValid:true,labelAlign:'top',autoScroll:true,fileUpload:true,defaults:{xtype:'panel',labelSeparator:''},items:[{cls:'title pb20',html:'Please add company details and upload a logo and press \'Next\' at the bottom of this page'},{name:'title',fieldLabel:'Company name',xtype:'textfield',itemCls:'label',allowBlank:false,listeners:{'change':{fn:function(field,newVal){this.checkDuplicatesListener();},scope:this}}},{fieldLabel:'Company Description',name:'description',grow:false,itemCls:'label',xtype:'textarea',allowBlank:false,fieldClass:"x-form-textarea x-form-field",preventScrollbars:true},{cls:'note',html:'This description will appear in your company profile and should describe what you company does'},this.keywordsField=new Ext.form.TextField({fieldLabel:'Search Keywords',name:'keywords',xtype:'textfield',itemCls:'big'}),{cls:'note',html:'Please enter any search keywords that are revelant to your company'},{fieldLabel:'Aliases',name:'monitoring_keywords',xtype:'textfield',itemCls:'big'},{cls:'note',html:'Please add any alternative spellings or names for this company - this will be used for identifying relevant media coverage<hr>'},{fieldLabel:"Your logo",name:"uploadFile",itemCls:'big',xtype:'fileuploadfield',width:250},{xtype:'dataview',store:this.store,tpl:logoViewTpl,autoHeight:true,itemSelector:'div.x-form-item'}]}),new Ext.ux.Wiz.Card({title:'Contact Details',monitorValid:true,defaults:{xtype:'panel',labelSeparator:''},autoScroll:true,listeners:{'show':{fn:function(){this.suspendEvents();Ext.each(this.findByType('dyn-panel'),function(c){c.setFirstTime(this.ownerCt.ownerCt.data);},this);this.resumeEvents();this.doLayout();}}},items:[{cls:'title pb20',html:'Please provide your company\'s contact details and press \'Next\' at the bottom of this page'},{cls:'big',html:'Websites & Online Services'},new DynamicFieldsPanel({fields:[{hideLabel:true,fieldLabel:'Website',vtype:'svurl',name:'url[]',width:220},getComboOptions({width:80,hideLabel:true,fieldLabel:'Type',hiddenName:"websiteType[]",store:app.ds.websiteTypesCompany})],fieldSetCfg:{panelCls:'addedPanelEmpty',layout:'hbox'},addNote:'Add related websites, blogs, twitter feeds, etc',set:function(obj){try{if(!obj.websites.length){this.appendField();}
Ext.each(obj.websites,function(n){this.appendField([n.url,n.type_id]);},this);}catch(e){this.appendField();}}}),{html:'<hr>'},{cls:'big',html:'Emails'},new DynamicFieldsPanel({fields:[{fieldLabel:'Email',vtype:'email',name:'email[]',width:220}],fieldSetCfg:{panelCls:'addedPanelEmpty',layout:'hbox'},addNote:'Add company\'s emails',set:function(obj){try{if(!obj.emails.length){this.appendField();}
Ext.each(obj.emails,function(n){this.appendField([n.email]);},this);}catch(e){this.appendField();}}}),{html:'<hr>'},{cls:'big',html:'Phones'},this.phonesPanel=new DynamicFieldsPanel({fields:[{hideLabel:true,fieldLabel:'Phone',name:'phone[]',anchor:'absolute',width:120},getComboOptions({width:80,anchor:'absolute',hideLabel:true,fieldLabel:'Type',hiddenName:"phoneType[]",store:app.ds.phoneTypesCompany})],fieldSetCfg:{panelCls:'addedPanelEmpty',layout:'hbox'},set:function(obj){try{if(!obj.phones.length){this.appendField();}
Ext.each(obj.phones,function(n){this.appendField([n.phone,n.type_id]);},this);}catch(e){this.appendField();}}}),{html:'<hr>'},{html:'Addresses',cls:'big'},new DynamicFieldsPanel({fields:[{fieldLabel:'Street',name:'street[]',preventScrollbars:true},{fieldLabel:'City',name:'city[]'},{fieldLabel:'State',name:'state[]'},{fieldLabel:'Zip',name:'zip[]'},getComboOptions({fieldLabel:'Country',hiddenName:"countryId[]",store:app.ds.countries}),getComboOptions({fieldLabel:'Type',hiddenName:"typeId[]",store:app.ds.addressTypesCompany})],addNote:'Please add relevant addresses',set:function(obj){try{if(!obj.addresses.length){this.appendField();}
Ext.each(obj.addresses,function(n){this.appendField([n.street,n.city,n.state,n.zip,n.country_id,n.type_id]);},this);}catch(e){this.appendField();}}})]}),new Ext.ux.Wiz.Card({title:'Categories',monitorValid:true,items:[{cls:'title pb20',html:'Please select the categories that are relevant to your company and press \'Next\' at the bottom of this page'},this.beatsTree=createBeatsTreePanel('company','')]}),new Ext.ux.Wiz.Card({title:'Media contacts',listeners:{'show':{fn:function(){this.suspendEvents();Ext.each(this.findByType('dyn-panel'),function(c){c.setFirstTime(this.ownerCt.ownerCt.data);},this);this.resumeEvents();this.doLayout();}}},items:[{border:false,cls:'title pb20',html:'Please identify who are the media contacts for this company and press \'Next\' at the bottom of this page'},new DynamicFieldsPanel({fieldSetCfg:{labelWidth:160,panelCls:'addedPanelHr'},fields:[{fieldLabel:"Role Title",name:"role_title[]",value:'Media Contact'},getRemoteComboOptions(makeUrl('persons','getContactsOptionsForMediacontacts'),{fieldLabel:'Person',hiddenName:"contact_id[]"}),getComboOptions({fieldLabel:'Role',hiddenName:"role_id[]",store:app.ds.personRoleTypes,value:1912}),{fieldLabel:"Description",name:"descr[]"}],set:function(obj){try{if(!obj.media_contacts.length){this.appendField();}
Ext.each(obj.media_contacts,function(n){this.appendField([n.role_title,[n.contact_id,n.contact],n.role_id,n.role_descr]);},this);}catch(e){this.appendField();}}})]}),new Ext.ux.Wiz.Card({title:'Next Steps',monitorValid:true,items:[{cls:'title pb20',html:'<b>Congratulations.</b> You have now set up your company, including:'+'<br><br>'+'1. A media monitoring profile<br>'+'2. A media list with possible relevant journalists<br>'+'3. A list of opportunities<br>'+'4. Newsroom content you may have provided us with.'+'<br><br>'+'Click the close button to see your company page, which can be viewed by clicking on the link in left-hand navigation area.'}]})];if(!this.companyId){cards.splice(4,0,new Ext.ux.Wiz.Card({title:'Media Lists',monitorValid:true,labelAlign:'top',autoScroll:true,fileUpload:true,defaults:{xtype:'panel',labelSeparator:'',allowBlank:false},items:[this.mediaListsOverview=new Ext.DataView({store:{xtype:'jsonstore',url:makeUrl('persons','getPeopleCountBySearch'),autoLoad:false,fields:['journos_count']},tpl:['<tpl for=".">','<div class="title pb20">','Influencing has automatically created a media list for you based on the information you have already given us.','<br><br>','We have identified <b>{journos_count}</b> journalists who we believe may be relevant to your business. Once you have completed this set up ','process, we recommend that you review this list to review journalists who may not be relevant.','<br><br>','This list is intended to provide a starting point for managing your media lists. You can use it as the basis for additional lists ','that segment interested journalists, or cross-check and extend it using a list you may already have.','<br><br>','If you\'d like to know more about Influencing\'s Media List capabilities you can watch the following video. If you wish to do ','this later you can find this video in the Help & Support section.','<br><br>','</div>','</tpl>'],loadingText:'Loading',autoHeight:true,multiSelect:true,overClass:'x-view-over',autoWidth:true,itemSelector:'div.thumb-wrap'})],listeners:{'show':{fn:function(){this.suspendEvents();this.mediaListsOverview.store.load({params:{beats_ids:this.beatsTree.getValues(),roles_ids:2005,datasets:'public,private',ims:'public'}});this.doLayout();},scope:this}}}),new Ext.ux.Wiz.Card({title:'Opportunities Lists',monitorValid:true,labelAlign:'top',autoScroll:true,fileUpload:true,defaults:{xtype:'panel',labelSeparator:'',allowBlank:false},items:[this.opportunitiesListsOverview=new Ext.DataView({store:{xtype:'jsonstore',url:makeUrl('opportunities','getOpportunitiesCountBySearch'),autoLoad:false,fields:['opportunities_count']},tpl:['<tpl for=".">','<div class="title pb20">','Influencing has automatically created an opportunities list for you based on the information you have already given us.','<br><br>','We have identified <b>{opportunities_count}</b> opportunities which we believe may be relevant to your business. Once you have completed this set up ','process, we recommend that you review this list to review opportunities who may not be relevant.','<br><br>','This list is intended to provide a starting point for managing your lists. You can use it as the basis for additional lists ','that segment opportunities, or cross-check and extend it using a list you may already have.','<br><br>','If you\'d like to know more about Influencing\'s Media List capabilities you can watch the following video. If you wish to do ','this later you can find this video in the Help & Support section.','<br><br>','</div>','</tpl>'],loadingText:'Loading',autoHeight:true,multiSelect:true,overClass:'x-view-over',autoWidth:true,itemSelector:'div.thumb-wrap'})],listeners:{'show':{fn:function(){this.suspendEvents();this.opportunitiesListsOverview.store.load({params:{beats_ids:this.beatsTree.getValues(),filter:this.keywordsField.getValue(),datasets:'public,private',ims:'public'}});this.doLayout();},scope:this}}}),new Ext.ux.Wiz.Card({title:'Media Releases',monitorValid:true,labelAlign:'top',autoScroll:true,fileUpload:true,defaults:{xtype:'panel',labelSeparator:'',allowBlank:false},items:[{cls:'title pb20',html:'When you upload your press release to Influencing it is distributed via our PRWire network. This includes:'+'<br><br>'+'- <b>PRWire.com.au</b> which will be indexed by Google News, ensuring your release hits relevant alerts and searches<br>'+'- <b>PRWire twitter feeds</b> making it easy to get your news out onto social networks<br>'+'- <b>PRWire RSS feeds and email digests</b> which make it easy for journalists and consumers to pull the news they are interested in<br>'+'- <b>Journo portal</b> which will display your site to relevant journalists<br>'+'- <b>Journo email</b> which will display your release to relevant journalists in their daily email.'+'<br><br>'+'All of your PRWire releases are searchable by both the media and by consumers on PRWire on Journo. If you have and RSS feed containing your releases, we can now automatically import those releases.'+'<br>'},{name:'rss_url',fieldLabel:'RSS url',xtype:'textfield',vtype:'svurl',itemCls:'label',allowBlank:true},{cls:'title pb20',html:'<br>'+'You can also watch the following video to learn more about releases or simply click next to go onto the next step of this setup.'+'<br><br>'}]}));}
var config={title:'Company wizard',width:800,height:(Ext.getBody().getSize().height-100),cls:'wiz',headerConfig:{title:'<div class="sprite sprite-folder">&nbsp;</div><h1>Company details</h1>'},cardPanelConfig:{defaults:{baseCls:'x-small-editor',bodyStyle:'padding:20px',border:false,autoScroll:true}},store:this.store,open:function(){this.store.on('load',function(grid,records){this.data=records[0].data;this.show();Ext.each(this.cards,function(c){c.getForm().setValues(this.data);},this);if(Ext.get('wizard_company_delete_logo_'+this.data.contact_id)){Ext.get('wizard_company_delete_logo_'+this.data.contact_id).addListener('click',function(){Ext.MessageBox.confirm('Message','Do you really want to delete?',function(btn){if(btn=='yes'){sendJsonRequest(makeUrl('contacts','deleteImage'),{contactId:this.data.contact_id},function(scope){Ext.get('wizard_company_delete_logo_'+scope.data.id).parent().update('');},this);}},this);},this);}
this.beatsTree.setValues(this.data.beats_ids);},this);if(this.companyId){this.store.load({params:{id:this.companyId}});}else{this.show();}},onNextClick:function(){if(this.currentCard==this.cards.length-2){var data={};Ext.each(this.cards,function(e,i){if(i>0&&e.form){Ext.apply(data,e.form.getValues(false));}});this.cards[0].form.submit({url:makeUrl('wizards','updateCompany'),params:Ext.apply(data,{id:this.companyId,beats_ids:this.beatsTree.getValues()}),success:function(form,action){msg('Notification',action.result.info);this.cardPanel.getLayout().setActiveItem(this.currentCard+1);try{Newsrooms.overviewStore.reload();}catch(e){}},failure:function(form,action){var errorStr='';Ext.each(action.result.errors,function(f){if(f.msg!=undefined){errorStr+='<br/><b>'+f.id+'</b>: '+f.msg;}});Ext.MessageBox.alert('Error Message',action.result.errorInfo+errorStr);},scope:this});}else{if(this.currentCard==this.cardCount-1){this.onFinish();}else{this.cardPanel.getLayout().setActiveItem(this.currentCard+1);}}},cards:cards};CompanyWizard.superclass.constructor.call(this,config);this.addListener('close',function(p){var p=Ext.getCmp('contact-'+this.data.contact_id+'-panel');if(p){p.afterItemUpdate();}},this);};Ext.extend(CompanyWizard,Ext.ux.Wiz,{checkDuplicatesListener:function(){var values=this.cards[0].form.getValues(false);if(!values.title){return;}
Contacts.duplicatesCheckStore.removeListener('load');Contacts.duplicatesCheckStore.addListener('load',function(store,data){if(data[0].data.duplicating_id){Contacts.duplicatingDlg.objId=data[0].data.obj_id;Contacts.duplicatingDlg.actionDlg=this;Contacts.duplicatingDlg.isEditable=data[0].data.is_editable;Contacts.duplicatingDlg.typeId=data[0].data.type_id;Contacts.duplicatingDlg.buttons[2].hide();Contacts.duplicatingDlg.show();Contacts.duplicatingTpl.overwrite(Ext.getCmp('contacts-duplicates-dataview').body,data[0].data);}},this);Contacts.duplicatesCheckStore.load({params:{type_id:301,title:values.title.trim(),id:this.companyId}});}});Application.LoginWindow=Ext.extend(Ext.Window,{layout:'fit',width:350,modal:true,height:175,closeAction:'hide',plain:true,id:'login-dlg',hidden:true,bodyStyle:'padding:5px; background-color: #FFF;',buttonAlign:'center',title:"Login",callbackFunction:function(p1,p2){var response=Ext.get(app.xdm.iframePostContainerName).dom.contentWindow.name;var result=Ext.util.JSON.decode(response);if(result.info){msg('Notification',result.info);window.location.href=result.redirect;}else{Ext.MessageBox.alert('Error',result.errors[0].msg);}},onShow:function(){if(Ext.getCmp('email-field')){if(app.registrationInput.getValue()!=''){Ext.getCmp('email-field').setRawValue(app.registrationInput.getValue());Ext.getCmp('email-field').value=app.registrationInput.getValue();}
else{if(app.conf.lastEmail){Ext.getCmp('email-field').setRawValue(app.conf.lastEmail);Ext.getCmp('email-field').value=app.conf.lastEmail;}
else{Ext.getCmp('email-field').setRawValue('');Ext.getCmp('email-field').value='';}}}},initComponent:function(){Application.LoginWindow.superclass.initComponent.apply(this);this.add({xtype:'form',items:[{xtype:'fieldset',labelWidth:70,border:false,style:'padding: 0; margin: 0;',hideLabels:false,defaults:{width:170,labelWidth:70,allowBlank:false,xtype:'textfield'},items:[{name:'email',id:'email-field',xtype:'textfield',fieldLabel:'Email',value:app.registrationInput.getValue()||app.conf.lastEmail||''},{name:'password',inputType:'password',fieldLabel:'Password'}]},{xtype:'panel',layout:'column',bodyStyle:'background-color: #CCD9E8;',width:311,items:[{columnWidth:.5,xtype:'panel',bodyStyle:'background-color: #CCD9E8;',items:{name:'remember',hideLabel:true,xtype:'checkbox',inputValue:1,boxLabel:'Stay signed in',checked:true}},{columnWidth:.5,xtype:'panel',bodyStyle:'padding:5px 0 0; text-align: right; background-color: #CCD9E8;',html:'<a href=# onclick="Home.showPasswordRestore();return false;">Password recovery</a>'}]},{xtype:'panel',layout:'column',bodyStyle:'background-color: #CCD9E8;',width:311,items:[{columnWidth:.5,xtype:'panel',bodyStyle:'background-color: #CCD9E8;',items:{name:'is_secure_login',hideLabel:true,xtype:'checkbox',inputValue:1,boxLabel:'Secure login using SSL',checked:false}},{hidden:true,renderTo:'xdm-iframe-div',html:'<iframe id="xdm-iframe" name="xdm-iframe" onload="app.xdm.setupIFrameOnLoad(\'Home.loginDlg.callbackFunction\')"></iframe>'}]}]});},keys:[{key:[Ext.EventObject.ENTER],handler:function(){Home.loginDlg.submitForm();}}],buttons:[{minWidth:80,text:'Login',scope:this,handler:function(){Home.loginDlg.submitForm();}},{minWidth:80,text:'Cancel',scope:this,handler:function(){Home.loginDlg.hide().get(0).getForm().reset();}}],submitForm:function(){var form=Home.loginDlg.get(0).getForm();if(form.isValid()){if(form.findField('is_secure_login').getValue()==true){form.standardSubmit=true,form.url=makeSecureUrl('core','ajaxLogin')+'?xdm='+!app.conf.isSecure,form.getEl().dom.target=app.xdm.iframePostContainerName;app.xdm.formSubmitted=true;form.submit();}else{form.standardSubmit=false,form.submit({url:makeUrl('core','ajaxLogin'),clientValidation:true,success:function(form,action){msg('Notification',action.result.info);window.location.href=action.result.redirect;},failure:function(form,action){Ext.MessageBox.alert('Error',action.result.errors[0].msg);},scope:this});}}}});Home.passwordRestoreDlg=new Ext.Window({layout:'fit',width:350,modal:true,height:95,closeAction:'hide',plain:true,id:'password-restore-dlg',hidden:true,bodyStyle:'padding:5px; background-color: #FFF;',buttonAlign:'center',title:"Password recovery",items:{xtype:'form',hideLabels:true,fileUpload:true,items:{name:'email',xtype:'textfield',hideLabel:true,emptyText:'Email',vtype:'email',allowBlank:false}},buttons:[{minWidth:140,text:'Send me new password',scope:this,handler:function(){var form=Home.passwordRestoreDlg.get(0).getForm();if(form.isValid()){form.submit({url:makeUrl('core','ajaxRestorePassword'),clientValidation:true,success:function(form,action){msg('Notification',action.result.info);Home.passwordRestoreDlg.hide();},failure:function(form,action){Ext.MessageBox.alert('Error',action.result.errorInfo);},scope:this,reset:true});}}},{minWidth:80,text:'Cancel',scope:this,handler:function(){Home.passwordRestoreDlg.hide().get(0).getForm().reset();}}]});ReaderModule=Ext.extend(Application.Module,{isTagged:true,itemTitle:'article',overviewFields:['feeds','starred'],isAlwaysPreview:true,overviewTpl:new Ext.XTemplate('<tpl for=".">','<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr valign="top">','<td width="50%">','<div class="overview-container">','<div class="block-title sprite sprite-rssfeed"><h1>Latest Items</h1><a href=# onclick="Reader.showMain()">See more</a>','<hr/></div>','<div id="reader-recent-articles"></div>','</div>','</td><td>','<div class="overview-container tools-block">','<div class="block-title sprite sprite-tools"><h1>Tools & Assistance</h1><hr/></div>','<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-add"></div><a href=# onclick="Reader.showAddFeed();return false;" class="title">Add an RSS feed</a></div>','<div class="summary">You can star your favourite articles so as you can easily recall then in the future.</div>','</div><hr>','<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-tools"></div><a href=# onclick="Reader.showFeeds();return false;" class="title">Manage Feeds</a></div>','<div class="summary">Click here to manage folders, categorise and delete feeds</div>','</div><hr>','<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-tools"></div><a href=# onclick="Reader.showUploadOPML();return false;" class="title">Import your feeds</a></div>','<div class="summary">If you have used or still use another RSS reader, you can import your feeds here. Just export your feed as an OPML file and then click the above link.</div>','</div>','</div>','<div class="overview-container">','<div class="block-title sprite sprite-star"><h1>Starred Items</h1><a href=# class="see-more" onclick="Reader.showStarred()" style="margin: 0 0 1px 15px;">See more</a><hr/></div>','<tpl for="starred">','<div class="articleTitle">','<a href=# onclick="Reader.showSource(\'{link}\', \'{title:escape}\', {id});">{title}</a> by <a href=# onclick="Reader.showFeed({feed_id:\'{feed_id}\', title: \'{feed}\'});">{feed}</a>','</div>','</tpl>','</div>','<div class="overview-container">','<div class="block-title sprite sprite-cloud"><h1>Tags</h1><hr/></div>','<div id="reader-overview-tagcloud-panel" class="overview-tagcloud"></div>','</div>','</td>','</tr></table>','</tpl>').compile(),initParams:function(){this.rd=['id','title','author_name','author_email','description','link','rss_id','feed_title','readed','body','url','comments_count','tags','tags_ids','tags_links','type','related','starred','p_date','images','package',{name:'pubdate',type:'date',dateFormat:app.conf.dtFormat}];var columns=[new Ext.grid.CheckboxSelectionModel()];if(!isGuest()){columns.push({header:"",dataIndex:'starred',width:25,resizable:false,renderer:function(val,p,record,rowIndex,columnIndex,ds){return['<div class="x-voter" style="float:left;"><a objId="',record.data.id,'" objType="',record.data.type,'" class="rate ',(val==true?'rated':''),'" onclick="rateItem(this)"><img width="16" height="15" alt="" src="',Ext.BLANK_IMAGE_URL,'" /></a></div>'].join('');}});}
columns.push({id:'title',header:"Title",dataIndex:'title',sortable:true,renderer:this.titleRenderer},{id:'last',header:"Date",dataIndex:'pubdate',width:120,renderer:this.formatDate,sortable:true});this.cm=columns;this.previewTpl=new Ext.XTemplate('<tpl for=".">','<div class="details">','<div class="details-header-1" style="float: left">','{title}','</div>','<div class="clear"></div>','<div class="verified">Posted by {author_name:defaultValue("Unknown")}<br>{pubdate:dtRenderer}</div>','<div class="clear"></div>','<div class="description">{body}</div>','<div class="clear"></div>','<tpl if="type!=\'article\'">','<div style="padding-bottom: 10px;"><a href=# onclick="showStory({id});return false;"><b>{comments_count} comment<tpl if="comments_count &gt; 1">s</tpl></b></a></div>','<div class="clear"></div>','<tpl for="images">','<img src="{src}" width="80" style="padding: 3px;" onclick="showPreviewImageDialog(\'{src}\', \'{title}\'); return false;">','</tpl>','<div class="clear pb10"></div>','</tpl>','<div class="icon icon-tag"></div><div class="tags-edit-selector" onclick="editTags(this);">tags</div>','<div class="tags-editor"><input objType="{type}" objId="{id}" type="text" name="tags" ids="{tags_ids}" class="tags-input" value="{tags}"/></div>','<div class="tags-show">{tags_links}</div>','</div>','</tpl>').compile();var tpl=new Ext.XTemplate('<tpl for=".">','<div id="reader-add-feed" style="visibility:hidden;">','<img alt="tab-close" id="reader-add-feed-close" width=11 height=11 src="<!--{image_path source="spacer.gif"}-->" />','<span id="reader-add-title">Please enter the URL for the feed:</span>','<p id="reader-loading-feed"><img src="<!--{image_path source="wait.gif"}-->" width="18" height="18" align="absmiddle" />&nbsp;Loading feed...</p>','<input type="text" id="reader-feed-url" name="feed-url" class="input-text"/><input id="reader-add-btn" type="button" value="Add"/><br>','<span class="eg">e.g. http://www.mediaconnect.com.au/rss.xml</span>','<span id="reader-add-title">Feed category:</span>','<input type="text" id="reader-feed-category" name="feed-category" class="input-text"/>','</div>','</tpl>').compile();this.itemPreviewTpl=new Ext.XTemplate('<tpl for=".">','<div class="article">','<div class="title">{title}</div>','<div class="x-voter" style="width: 30px; float:left;padding-top: 3px;"><a class="rate ','<tpl if="starred == true">','rated','</tpl>','" onclick="rateItem(this)" objId="{id}" objType="{type}"><img width="16" height="15" alt="" src="',Ext.BLANK_IMAGE_URL,'" /></a></div>','<div class="clear"></div>','<tpl if="this.isRelease(type) == false">','<div class="from"><tpl if="author_name">By <b>{author_name}&nbsp;</b></tpl>','for <b>{feed_title}</b> on {p_date}</div>','</tpl>','<tpl if="this.isRelease(type) == true">','<div class="from">from <b>{feed_title}</b></div>','</tpl>','<div class="clear"></div>','<div class="feed-item-date">{pubdate:dtRenderer}</div>','<div class="icon icon-tag ml20"></div><div class="tags-edit-selector" onclick="editTags(this);">tags</div>','<div class="tags-editor"><input objId="{id}" objType="{type}" objModule="',Ext.util.Format.capitalize(this.name),'" type="text" name="tags" ids="{tags_ids}" class="tags-input" value="{tags}"/></div>','<div class="tags-show">{tags_links}</div>','<div class="clear"></div>','<div class="body">{body}</div>','<tpl if="this.isArticle(type) == true">','<div class="from"><a target=_blank href="{link}">Click here to view full story</a></div>','<div class="clear"><br></div>','</tpl>',isGuest()?'':['<div class="feed-item-comments"><div class="icon icon-comments"/></div>','<tpl if="package==\'media\'">Comments on this story are only open to registered users of ITJourno</tpl>','<tpl if="package==\'pr\'">Comments on this story are only open to registered users of Influencing</tpl>','<tpl if="package==\'info\'">Comments on this story are only open to registered users of Influencing and ITJourno.</tpl>','</div>'].join(''),'<div class="x-clear"></div>','</div>','</tpl>',{isRelease:function(type){return type=='release';},isArticle:function(type){return type=='article';}}).compile();this.itemReleaseTpl=new Ext.XTemplate('<tpl for=".">','<div class="article">','<div class="title">{headline}</div>',isGuest()?'':['<div class="x-voter" style="width: 30px; float:left;padding-top: 3px;"><p id="reader-starred-{type}-{id}" class="rate ','<tpl if="starred == true">','rated','</tpl>','"><img id="reader-starred-img-{type}-{id}" width="16" height="15" alt="" src="',Ext.BLANK_IMAGE_URL,'" /></p></div>'].join(''),'<div class="clear"></div>','<h2>{subheading}</h2>','<div class="clear"></div>','<div class="p10 reader-press-release">{body}</div>','<div class="feed-item-comments"><div class="icon icon-comments"/></div>Comments</div>','<div class="x-clear"></div>','</div>','</tpl>').compile();this.itemReleaseDetailsTpl=new Ext.XTemplate('<tpl for=".">','<div class="preview">','<div class="left">','<div class="image">','<img onclick="showPreviewImageDialog(\'{image_url_original}\', \'\', \'\')" src="{image_url_big}"/>','</div>','<div>','<h3>Release details</h3>','<hr/>','<b>Issued by:</b> {company}<br>','<b>Type:</b> {type}<br>','<b>Date line:</b> {published_at}<br>','<b>Place line:</b> {place}<br>','</div>','<br><br>','<tpl if="this.isShowContacts() == true">','<div class="contacts">','<h3>Media contacts</h3>','<hr/>','<tpl for="contacts">','<tpl if="person_id">','<a onclick="showContact({person_id})">{name}</a><br> ','</tpl>','{name} {job_title} {phone} {email}<br>','</tpl>','</div><br><br>','</tpl>','<div class="medias">','<h3>Medias</h3>','<hr/>','<tpl for="medias">','<div style="padding:5px; margin:5px; width: 180px; float: left; text-align:left;">','<div style="width:180px; overflow: hidden;">','{content}','<div style="text-align: left;">','{description}','</div>','</div>','</div>','</tpl>','</div>','</div>','</div>','</tpl>',{isShowContacts:function(){return true;}}).compile();},getGridPanelCfg:function(cfg){var result={isHaveEdit:false,title:'All articles',autoExpandColumn:'title',autoExpandMax:2000,sortInfo:{field:'pubdate',direction:"DESC"},headerAddons:[{iconCls:'icon icon-go-to-post',text:'Open selected',tooltip:'Open selected articles',handler:function(){var m=this.getSelections();for(var i=0,len=m.length;i<len;i++){var d=m[i].data;if(d.url){window.open(d.url);}else{if(d.type!='article'){this.module.showItem(d.id,d.type);}else{this.module.showSource(d.link,d.title,d.id);}}}}},isGuest()?'':{text:'Mark as read',iconCls:'icon icon-tick',tooltip:'Mark as read',handler:function(){this.selectionAction(null,function(){this.sendJsonRequest(app.makeUrl('markReaded'),{ids:this.selectedIdsToJson(),type:this.store.baseParams.type||this.getSelections()[0].data.type});});}},isGuest()?'':{text:'Mark all read',iconCls:'icon icon-tick',tooltip:'Mark all read',handler:function(){this.sendJsonRequest(app.makeUrl('markReaded'),{all:1,type:this.store.baseParams.type});}}],dblclickShow:false,summary:'description',summaryLength:0,ctCls:'autoheight-summary'};return Ext.apply(result,cfg);},makeLead:function(id,type){sendJsonRequest(this.makeUrl('makeLead'),{id:id,type:type});},showItem:function(id,data,grid){if(!data.id){data={type:data};}
switch(data.type){case'story':track('Viewed article','Articles');break;case'release':track('Viewed release','PRWire');break;}
if(data.type=='article'){this.showSource(data.link,data.title,data.id);return;}
var cfg={layout:'border',bodyStyle:'background-color: #fff',defaults:{autoHeight:true,autoScroll:true},id:'reader-'+data.type+'-'+id+'-panel',autoScroll:true,items:[{region:'center',id:'reader-'+data.type+'-'+id+'-center-panel',listeners:this.linkInterceptor},{region:'east',width:'300px',id:'reader-'+data.type+'-'+id+'-east-panel',listeners:this.linkInterceptor}]};if(data.type&&data.type=='release'){var releasePanel=Ext.getCmp('reader-release-'+id+'-panel');if(releasePanel){releasePanel.previewView.store.reload();}}
app.showModulePanel(cfg,function(){app.getMainPanel().add(new ReaderItemModule(Ext.apply(cfg,{name:'reader-'+data.type+'-'+id,objId:id,objType:data.type,grid:grid})));app.getMainPanel().activate(cfg.id);},this);return false;},formatDate:function(date){if(!date){return'';}
if(date.clearTime(true).getTime()==new Date().clearTime(true).getTime()){return'Today '+date.dateFormat(app.conf.timeFormat);}
return date.dateFormat(app.conf.dtFormat);},openAll:function(){this.innerPanel.beginUpdate();this.grid.store.data.each(this.openTab,this);this.innerPanel.endUpdate();this.innerPanel.setActiveTab(0);},openTab:function(record){record=(record&&record.data)?record:this.gsm.getSelected();this.showItem(record.data.id,record.data.type);},linkInterceptor:{render:function(p){p.body.on({'mousedown':function(e,t){},'click':function(e,t){var el=Ext.get(t);if(el){var ch=el.dom.attributes.getNamedItem('onclick');if(ch&&(ch.nodeValue.indexOf('Reader.')!=-1||ch.nodeValue.indexOf('Prwire.')!=-1||ch.nodeValue.indexOf('Stories.')!=-1||ch.nodeValue.indexOf('showContact(')!=-1||ch.nodeValue.indexOf('Home.')!=-1)){return false;}}
t.target='_blank';e.stopEvent();window.open(t.href);},delegate:'a'});}},resetParams:function(){return Ext.apply(this.grid.store.baseParams,{feed_id:null,tag_id:null,category_id:null,user_category_id:null,section:null,mark:'',sparams:null,type:'',unreaded:0});},previewItem:function(id,data,panel){var grid=panel.grid;var store=new Ext.data.JsonStore({url:this.makeUrl('preview'),autoLoad:false,fields:this.rd,listeners:{'load':{fn:function(scope,rec){var data=rec[0].data;data.tags_links=makeLinks(data.tags_ids,data.tags,'Ext.getCmp(\''+grid.id+'\').showTagged');var p=grid.getPreviewPanel();var el=p.get(0).el;var tb=p.getTopToolbar();tb.removeAll();tb.add({text:'Open',iconCls:'icon icon-open',handler:function(){if(data.url){window.open(data.url);}else{if(data.type!='article'){this.showItem(data.id,data.type);}else{this.showSource(data.link,data.title,data.id);}}},scope:this},'->',{text:'Close',iconCls:'icon icon-cross',handler:function(){tb.removeAll();el.hide().update(p.listHtml).slideIn('l',{stopFx:true,duration:.2});Ext.DomHelper.overwrite(Ext.getDom(grid.id+'-items-selected'),grid.getSelectionModel().selections.length+'');}});tb.doLayout();el.hide().update(this.previewTpl.apply(data)).slideIn('l',{stopFx:true,duration:.2});},scope:this}}});store.reload({params:{id:id}});},getPreviewPanelCfg:function(name,grid){return this.getDefaultPreviewPanelCfg(name);},showSource:function(url,title,id){var p=app.getMainPanel().add({layout:"border",title:Ext.util.Format.ellipsis(title,40),closable:true,items:[{layout:"fit",region:'center',tbar:[{iconCls:'icon icon-go-to-post',text:'Open in new window',tooltip:'Open in new window',scope:this,handler:function(){window.open(url);}}],items:{xtype:'iframepanel',fitToFrame:true,defaultSrc:url}}]});var markStore=prepareDs(makeUrl('reader','show'),[]);markStore.load({params:{id:id,type:'article'}});app.getMainPanel().setActiveTab(p);return false;},showStory:function(id){this.showItem(id,'story');return false;},showArticle:function(id){this.showItem(id,'article');return false;},showSection:function(section){this.showMain({section:section});},initFilters:function(){return isGuest()?[]:[prepareComboBox({emptyText:'Read Status',labelName:'Read Status',hiddenName:'unreaded',store:app.ds.unreaded}),prepareComboBox({emptyText:'All',hiddenName:'starred',labelName:'Stars',store:app.ds.starredTypes})]},titleRenderer:function(val,p,record,rowIndex,columnIndex,ds){record.data.tags_links=makeLinks(record.data.tags_ids,record.data.tags,'Ext.getCmp(\''+ds.grid.id+'\').showTagged');record.data.tags=record.data.tags||'';record.data.title_e=String.escape(record.data.title);record.data.desc=record.data.description;record.data.module='reader';var tpl=new Ext.XTemplate('<tpl for=".">','<div class="feed-item">','<div class="feed-item-title">',!isGuest()?'<tpl if="readed == false"><div class="icon icon-new"/></div></tpl>':'','<tpl if="this.isArticle(type) == false">','<tpl if="!url">','<a onclick="Reader.showItem(\'{id}\',\'{type}\');">{title}</a>','</tpl>','<tpl if="url">','<a href="{url}" target="_blank">{title}</a>','</tpl>','</tpl>','<tpl if="this.isArticle(type) == true">','<a onclick="Reader.showSource(\'{link}\',\'{title:escape}\', {id});">{title}</a>','</tpl>','</div>','<div class="date">','<tpl if="this.isRelease(type) == false">','<div class="from"><tpl if="author_name">by <b>{author_name}&nbsp;</b></tpl>','<tpl if="feed_title">for <b>{feed_title}</b></tpl>',' {comments_count} comment<tpl if="comments_count &gt; 1">s</tpl>','</div>','</tpl>','<tpl if="this.isRelease(type) == true">','<div class="from">from <b>{feed_title}</b></div>','</tpl>','</div>','</div>','</tpl>',{isRelease:function(type){return type=='release';},isArticle:function(type){return type=='article';}});return tpl.apply(record.data);}});ReaderModuleClass=Ext.extend(ReaderModule,{name:'reader',title:'Reader',initParams:function(){ReaderModuleClass.superclass.initParams.call(this);this.uploadOpmlDlg=new Ext.Window({layout:'fit',width:550,modal:true,closeAction:'hide',plain:true,id:'reader-ompl-dlg',bodyStyle:'padding:5px;',buttonAlign:'center',title:"Upload OPML-file",items:this.fp=new Ext.FormPanel({defaults:{bodyStyle:'position:relative;padding:10px'},height:60,fileUpload:true,items:[{xtype:'fileuploadfield',fieldLabel:'Select OPML-file',allowBlank:false,name:'opml-file'}]}),buttons:[{text:'Save',minWidth:80,scope:this,handler:function(){if(this.fp.getForm().isValid()){this.fp.getForm().submit({url:'reader/uploadOpml',waitMsg:'Uploading your opml file...',params:{id:1},reset:true,failure:function(form,action){var errors=action.result.errors;var errorStr='';if(errors)for(var i=0;i<errors.length;i++){if(errors[i].msg!=undefined){errorStr+='<br/><b>'+errors[i].id+'</b>: '+errors[i].msg;}}
Ext.MessageBox.alert('Error Message',action.result.errorInfo+errorStr);},success:function(scope,action){msg('Success',action.result.info);this.Reader.uploadOpmlDlg.hide();this.Reader.reloadNavigationTree();}});}else{Ext.MessageBox.alert('Errors','No file selected');}}},{minWidth:80,text:'Cancel',scope:this,handler:function(){this.uploadOpmlDlg.hide();this.fp.getForm().reset();}}]});this.addFeedDlg=new Ext.Window({layout:'fit',width:550,modal:true,closeAction:'hide',plain:true,id:'reader-add-rss-feed-dlg',bodyStyle:'padding:5px;',buttonAlign:'center',title:"Add RSS feed",items:this.addFeedForm=new Ext.FormPanel({defaults:{bodyStyle:'position:relative;padding:10px'},height:60,items:[{xtype:'textfield',fieldLabel:'Feed URL',allowBlank:false,name:'url',vtype:'url'},{xtype:'textfield',fieldLabel:'Feed category',name:'category'}]}),buttons:[{text:'Save',minWidth:80,scope:this,handler:function(){if(this.addFeedForm.getForm().isValid()){this.addFeedForm.getForm().submit({url:makeUrl('reader','addSubscription'),waitMsg:'Adding RSS feed...',params:{id:1},reset:true,scope:this,failure:function(form,action){var errors=action.result.errors;var errorStr='';if(errors)for(var i=0;i<errors.length;i++){if(errors[i].msg!=undefined){errorStr+='<br/><b>'+errors[i].id+'</b>: '+errors[i].msg;}}
Ext.MessageBox.alert('Error Message',action.result.errorInfo+errorStr);},success:function(form,action){msg('Success',action.result.info);this.addFeedDlg.hide();this.addFeedForm.getForm().reset();this.reloadNavigationTree();this.showFeed({feed_id:action.result.id,title:action.result.title});}});}else{Ext.MessageBox.alert('Errors','Please fix all errors and resubmit');}}},{minWidth:80,text:'Cancel',scope:this,handler:function(){this.addFeedDlg.hide();this.addFeedForm.getForm().reset();}}]});},grabArticles:function(){var link=Ext.get('rss-reader-grab-articles-btn');link.addClass('loading');link.dom.innerHTML='Processing';this.sendJsonRequest(this.makeUrl('grabArticles'),{test:true},function(scope){scope.reloadNavigationTree();link.removeClass('loading');link.dom.innerHTML='Refresh';if(scope.grid){scope.grid.store.reload();}
scope.overviewStore.reload();});},showUploadOPML:function(btn){this.uploadOpmlDlg.show();},showAddFeed:function(btn){this.addFeedDlg.show();},showFeed:function(params){track('Oppened reader','Reader');this.showFilteredGrid(this.getGridPanelCfg({title:params.title,baseParams:{feed_id:params.feed_id}}),'feed-'+params.feed_id);},showTag:function(params){track('Oppened reader','Reader');this.showFilteredGrid(this.getGridPanelCfg({title:params.title,baseParams:{tag_id:params.tag_id}}),'tag-'+params.tag_id);},showDeleteFeed:function(){var node=this.articlesNavigation.getSelectionModel().getSelectedNode();if(node.attributes.feed_id){Ext.MessageBox.confirm('Message','Do you really want to delete?',function(btn){if(btn=='yes'){params={feed_id:node.attributes.feed_id};this.sendJsonRequest(this.makeUrl('deleteSubscription'),params,function(scope){scope.reloadNavigationTree();Ext.getCmp('reader-feed-delete-btn').disable();});}},this);}else{Ext.MessageBox.alert('Error','Please select at least one item to delete');}},showMain:function(params,isSearch){var title=isSearch?'Search results':'All articles';var id='';var baseParams={type:'article'};if(params){Ext.apply(baseParams,params);if(params.unreaded){title='Unread articles';id='unread';}}
track('Opened reader','Reader');this.showFilteredGrid(this.getGridPanelCfg({title:title,baseParams:baseParams}),id);},initOverviewElements:function(){this.overviewTagCloud=new Ext.ux.TagCloud({store:prepareDs(makeUrl('reader','tagCloud'),[{name:'id'},{name:'count'},{name:'tag'}]),displayField:'tag',weightField:'count',loadMask:true,displayWeight:false,tagsName:'reader-overview-tags',listeners:{'tagselect':{fn:function(cloud,tag,idx,el){this.showTagged(el.hasClass('x-cloud-item-selected')?tag.id:'');},scope:this}}});this.tagCloudPanel=new Ext.Panel({renderTo:'reader-overview-tagcloud-panel',items:this.overviewTagCloud});this.overviewTagCloud.store.reload();if(this.articlesStore){this.showArticles();}},reloadNavigationTree:function(){var nodeId='node-reader-overview';app.getNavigationTree().root.cascade(function(n){if(n.attributes.id==nodeId){app.parentNode=n;return false;}},this);if(app.parentNode){var node=app.parentNode.attributes.module;var more='all';app.parentNode.getUI().addClass('x-tree-node-loading');app.parentNode.collapse();app.seeMoreStore.load({params:{node:'Reader',more:'all'}});}
try{this.module.reloadNavigations();}catch(e){}}});Reader=new ReaderModuleClass({title:'RSS Reader',articlesTpl:new Ext.XTemplate('<tpl for=".">','<a onclick="Reader.showFeed({feed_id:\'{rss_id}\', title: \'{rss_title}\'})" class="item-headline">{rss_title}</a>','<div class="summary">','<tpl for="data">','<div class="articleTitle"><a onclick="Reader.showSource(\'{link}\', \'{title:escape}\', {id})">{title}</a></div>','</tpl>','<tpl if="xindex != xcount"><hr class="reader"></tpl>','</div>','</tpl>').compile(),articlesStore:prepareDs(makeUrl('reader',"getArticlesForOverview"),[],false),showArticles:function(){var p=Ext.get("reader-recent-articles");p.dom.innerHTML='&nbsp;';p.addClass("overview-loading");this.articlesStore.on('load',function(st,data,options){p.removeClass("overview-loading");var items=Array();Ext.each(data,function(e){items.push(e.json)},this);if(items.length){this.articlesTpl.overwrite(p,items);}else{p.dom.innerHTML='<span class="item-info">You are not subscribed to any RSS-feeds or feeds have no articles</span>';}},this);this.articlesStore.load();},showFeeds:function(){Feeds=new ReaderFeedsModule({}).init();Feeds.showMain();},getListDetailsRD:function(){return(['total','name','filters']);}});ReaderItemModule=Ext.extend(Application.Module,{parentModule:Reader,section:'',objType:null,objId:null,title:'Loading...',initComponent:function(){Ext.apply(this,this.initialConfig);if(this.objType=='release'){this.parentModule=Prwire;}else if(this.objType=='story'){this.parentModule=Stories;}else if(this.objType=='info'){this.parentModule=Information;}
ReaderItemModule.superclass.initComponent.apply(this);},initParams:function(){this.releaseRD=['id','headline','subheading','summary','company','image_url_original','body','image_url_big','contacts','published_at','place','medias','status','pages','type','starred','p_date'];this.previewTpl=this.parentModule.itemPreviewTpl;this.relatedTpl=new Ext.XTemplate('<tpl for=".">','<div class="article-related"><h1>More from {feed_title}</h1><hr style="margin: 0 0 10px 0;" />','<tpl for="related">','<h2><a onclick="Reader.showItem({id}, \'',this.objType,'\');">{title}</a></h2>','{description:ellipsis(300)}','<div class="x-clear"></div><hr>','</tpl></tpl>','<div class="x-clear"></div>').compile();this.commentTpl=new Ext.XTemplate('<tpl for=".">','<div class="article-comment">','<div class="feed-item-pix"><img src="{author_pix}"></div>','<div class="feed-item-comment">{comment}</div>','<div class="feed-item-date">{created_at:dtRenderer} by&nbsp; <a onclick=showContact({contact_id})>{author_name}</a></div>','<div class="delete-{is_editable}"><tpl if="is_editable == true"><div class="icon icon-delete"></div></tpl><a onclick="Reader.deleteComment({id}, {item_id}, \'',this.objType,'\');">delete</a></div>','<div class="x-clear"></div>','</div>','</tpl>','<div class="x-clear"></div>').compile();this.getPanel('center').add({autoScroll:true,items:[this.previewView=new Ext.DataView({store:prepareDs(makeUrl('reader','show'),this.getRD()),tpl:this.getPreviewTpl(),loadingText:'Loading',autoScroll:true,multiSelect:true,overClass:'x-view-over',itemSelector:'div.thumb-wrap',panel:this,prepareData:function(data){this.panel.setTitle(Ext.util.Format.ellipsis(data.headline?data.headline:data.title,40));if(this.panel.grid){data.tags_links=makeLinks(data.tags_ids,data.tags,'Ext.getCmp(\''+this.panel.grid.id+'\').showTagged');}else{data.tags_links=data.tags;}
data.tags=data.tags||'';data.body=data.body||data.description;return data;},onContextMenu:function(e,node,d){e.stopEvent();if(!d.scope.contextMenu){d.scope.contextMenu=new Ext.menu.Menu({items:[{iconCls:'icon icon-refresh',text:'Refresh',handler:function(){d.scope.panel.previewView.store.reload();d.scope.panel.commentsView.store.reload();}}]});}
d.scope.contextMenu.showAt(e.getXY());}}),isGuest()?{xtype:'panel',baseCls:'article',bodyStyle:'background-color: #DDD;padding: 10px; margin: 10px 20px; font-family: sans-serif; line-height: 25px; line-height: 25px; font-size: 16px;',html:'Not registered yet? If you\'re a PR or marketing communications professional, registration is free. Once you\'re registered you\'ll be able to see and leave comments, post free job advertisements, create free online newsrooms and submit press releases to our PRWire service.<br><a href=# onclick="return Home.showRegistration();" style="text-decoration: underline;">Please click here to register you and your company.</a>'}:Commentable.initView(this)]});this.getPanel('east').add({layout:'fit',items:{xtype:'dataview',store:this.previewView.store,tpl:this.getEastTpl(),loadingText:'Loading',autoHeight:true,multiSelect:true,overClass:'x-view-over',itemSelector:'div.thumb-wrap'}});this.previewView.store.on('load',function(){if(!isGuest()){Commentable.init(this,this.getPanel('center'));}},this);this.doLayout();},getPreviewTpl:function(){return this.objType=='release'?this.parentModule.itemReleaseTpl:this.parentModule.itemPreviewTpl;},getEastTpl:function(){return this.objType=='release'?this.parentModule.itemReleaseDetailsTpl:this.relatedTpl;},getRD:function(){return this.objType=='release'?this.releaseRD:this.parentModule.rd;},showMain:function(){this.previewView.store.load({params:{id:this.objId,type:this.objType}});}});StoriesModuleClass=Ext.extend(ReaderModule,{name:'stories',initParams:function(){StoriesModuleClass.superclass.initParams.call(this);this.overviewTpl=new Ext.XTemplate('<tpl for=".">','<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr valign="top">','<td width="50%">','<div class="overview-container">','<div class="block-title sprite sprite-latestcoverage">','<h1>Latest Articles</h1>','<span class="activities-types-links" style="float: right;">','<a href=# class="see-more stories-types bold" onclick="Stories.showOverviewStories(this)">All</a>','<tpl for="articles_sections">',' | <a href=# class="see-more stories-types" onclick="Stories.showOverviewStories(this, \'{.}\')">{.}</a>','</tpl>','</span><hr>','</div>','<div id="stories-overview" class="stories-news">','<tpl for="articles">','<table cellpadding=0 cellspacing=0 border=0 class="item" width="100%" <tpl if="xindex==xcount">style="border-bottom: none;"</tpl>><tr valign="top">','<td class="image" width="125px"><img width=100 src="{image_url}" border=0 /></td>','<td class="content">','<a href=#!story/{id} class="item-headline" onclick="showStory({id})">{title}</a>','<div class="summary">{description}</div>','<div class="item-info">{section} | {published_at} ago | {comments_count} comment<tpl if="comments_count!=1">s</tpl></div>','</td>','</tr></table><tpl if="xindex!=xcount"><hr class="reader"></tpl>','</tpl>','</div>','</div>','</td><td>','<div class="overview-container" style="padding: 10px;">','<div class="overview-search-form">','<div class="block-title sprite sprite-search"><h1>Find Articles</h1><hr></div>','<div class="inputs">','<label for="stories_search_by_text">Find articles with the following <b>text</b></label><br>','<input class="x-form-text x-form-field w250" name="stories_search_by_text" id="stories_search_by_text" type="text" /><br><br>','<label for="stories_search_by_timeframe">And/or in the <b>timeframe</b> of (eg. last week)</label><br>','<div id="stories_search_by_timeframe"></div>','</div>','<div class="x-small-editor" id="stories_submit_search" style="float: right; padding-top: 23px;"></div>','</div>','</div>','<div class="overview-container tools-block">','<div class="block-title sprite sprite-tools"><h1>Tools & Assistance</h1><hr/></div>','<div class="updates-item">',isGuest()?['<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-add"></div><a href=# onclick="Home.showRegistration();return false;" class="title">Register for an account</a></div>','<div class="summary">Join the Influencing community to post comments, manage your online PR newsroom and post releases and jobs.</div>'].join(''):['<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-star"></div><a href=# onclick="Stories.showStarred();return false;" class="title">View Starred Articles</a></div>','<div class="summary">You can star your favourite articles so as you can easily recall then in the future.</div>'].join(''),'</div>','</div>','<div class="overview-container">',this.getCommentsTpl('comments','Latest Comments'),'</div>',isGuest()?'':['<div class="overview-container">','<div class="block-title sprite sprite-cloud"><h1>Tags</h1><hr/></div>','<div id="stories-overview-tagcloud-panel" class="overview-tagcloud"></div>','</div>'].join(''),'</td>','</tr></table>','</tpl>').compile();}});Stories=new StoriesModuleClass({title:'Articles',overviewFields:['articles','articles_sections','comments'],storiesTpl:new Ext.XTemplate('<tpl for=".">','<table cellpadding=0 cellspacing=0 border=0 class="item" width="100%"><tr valign="top" <tpl if="xindex==xcount">style="border-bottom: none;"</tpl>>','<td class="image" width="125px"><img width=100 src="{image_url}" border=0 /></td>','<td class="content">','<a href=#!story/{id} class="item-headline" onclick="showStory({id})">{title}</a>','<div class="summary">{description}</div>','<div class="item-info"><tpl if="section">{section} | </tpl>{published_at} ago | {comments_count} comment<tpl if="comments_count!=1">s</tpl></div>','</td>','</tr></table>','<tpl if="xindex != xcount"><hr class="reader"></tpl>','</tpl>'),storiesStore:prepareDs(makeUrl("stories","getStoriesForOverview"),[],false),showMain:function(params,isSearch){var title=isSearch?'Search results':'All stories';var id='';var baseParams={type:'story'};if(params){Ext.apply(baseParams,params);if(params.unreaded){title='Unread stories';id='unread';}
if(params.section){title=params.article_section||params.section;id=params.article_section||params.section;if(params.section=='Select Agency'){baseParams.is_directory=true;delete baseParams.section;}
if(params.article_section=='all'){title='All articles';delete baseParams.article_section;delete baseParams.section;}}
if(params.starred){title='Starred stories';id='starred';delete baseParams.section;}}
this.showFilteredGrid(this.getGridPanelCfg({title:title,baseParams:baseParams}),id||'main');},initFilters:function(){var result=[prepareComboBox({store:app.ds.timeframe,emptyText:'All Time',labelName:'Timeframe',hiddenName:'timeframe'})]
return isGuest()?result:Ext.apply(result,[prepareComboBox({emptyText:'Read Status',labelName:'Read Status',hiddenName:'unreaded',store:app.ds.unreaded}),prepareComboBox({emptyText:'All',hiddenName:'starred',labelName:'Stars',store:app.ds.starredTypes}),new Ext.form.TextField({width:100,labelName:'Tag',hiddenName:'tag'})]);},initOverviewElements:function(){if(!isGuest()){this.overviewTagCloud=new Ext.ux.TagCloud({store:prepareDs(makeUrl('stories','tagCloud'),[{name:'id'},{name:'count'},{name:'tag'}]),displayField:'tag',weightField:'count',loadMask:true,displayWeight:false,tagsName:'stories-overview-tags',listeners:{'tagselect':{fn:function(cloud,tag,idx,el){this.showTagged(el.hasClass('x-cloud-item-selected')?tag.id:'');},scope:this}}});this.tagCloudPanel=new Ext.Panel({renderTo:'stories-overview-tagcloud-panel',items:this.overviewTagCloud});this.overviewTagCloud.store.reload();}
this.overviewTimeframeCombo=prepareComboBox({store:app.ds.timeframe,emptyText:'All time',hiddenName:"stories_search_timeframe",allowBlank:true,renderTo:'stories_search_by_timeframe',width:296,style:{width:'296px'},typeAhead:true});new Ext.Button({minWidth:60,text:'Search',scope:this,renderTo:'stories_submit_search',handler:function(){var filt=Ext.get("stories_search_by_text").getValue();var timeframe=this.overviewTimeframeCombo.getValue();var timeframe_name=this.overviewTimeframeCombo.getRawValue();if(filt||timeframe){this.showFilteredGrid(this.getGridPanelCfg({pagerUrl:makeUrl("stories","getPager"),title:filt||timeframe_name,baseParams:{filter:filt,timeframe:timeframe}}),'by-filter');}}});},showOverviewStories:function(el,section){Ext.select('a.stories-types').each(function(s){s.removeClass("bold");});var sel=Ext.get(el);sel.addClass("bold");var p=Ext.get("stories-overview");p.update('');p.addClass("overview-loading");this.storiesStore.baseParams.section=section;this.storiesStore.removeListener('load');this.storiesStore.purgeListeners();this.storiesStore.on('load',function(st,data,options){p.removeClass("overview-loading");var items=Array();Ext.each(data,function(e){items.push(e.json)},this);this.storiesTpl.overwrite(p,items);},this);this.storiesStore.load();return false;},showEpitome:function(){this.showMain({section:'Epitome'});},getCommentsTpl:function(dataName,title){return['<div class="block-title sprite sprite-comments"><h1>',title,'</h1><hr/></div>','<tpl for="',dataName,'">','<div class="updates-item">','<div class="portlet-item"><div class="ico-new ico-new-comments"></div>','<a href=# onclick="showContact({author_id});">{author}</a> commented on <a class="title" href=#!story/{id} onclick="showStory(\'{story_id}\');">{title}</a> <span class="item-info">{published_at} ago</span>','<div class="summary">{description}</div>','</div><tpl if="xindex!=xcount"><hr></tpl>','</div>','</tpl>'].join('');},getStoriesTpl:function(dataName,section,title,mainCount,notShowInfo){var storyTpl=['<table cellpadding=0 cellspacing=0 border=0 class="item" width="100%"><tr valign="top">','<td class="image" width="110px"><img width=100 src="{image_url}" border=0 /></td>','<td class="content">','<a href=#!story/{id} class="item-headline" onclick="showStory({id})">{title}</a>','<div class="summary">{description}</div>',notShowInfo?'':'<div class="item-info">{published_at} ago | {comments_count} comment<tpl if="comments_count!=1">s</tpl></div>','</td>','</tr></table>'].join('');if(!section||section!='{featured_section}'){var sprite='latestcoverage';}else{var sprite='<tpl if="featured_section == \'Thought Leaders\'">lightbolb</tpl>'+'<tpl if="featured_section == \'Epitome\'">epitome</tpl>';}
var result=['<div class="block-title sprite sprite-'+sprite+'"><h1>',(title?title:section),'</h1><a href=# class="see-more" onclick="Stories.init().',(section?'showSection(\''+section+'\')">More '+section+'':'showOverview()">All Articles'),'</a><hr/></div>','<tpl if="',dataName,'">','<tpl for="',dataName,'">'];if(mainCount){result.push('<tpl if="xindex&lt;',(mainCount+1),'">',storyTpl,'<tpl if="xindex!=xcount"><hr></tpl>','</tpl>','<tpl if="xindex == ',(mainCount+1),'">','<div class="summary"><b>More '+(!isJourno()?section:'News')+'</b></div>','</tpl>','<tpl if="xindex&gt;',(mainCount),'">','<div class="articleTitle"><a href=#!story/{id} onclick="showStory({id})">{title}</a> <span class="item-info">{published_at} ago | {comments_count} comment<tpl if="comments_count != 1">s</tpl></span></div>','</tpl>');}else{result.push(storyTpl);}
result.push('</tpl></tpl>');return result.join('');},getPrBlogsTpl:function(dataName,section,title){return['<div class="block-title sprite sprite-'+'latestcoverage'+'"><h1>',(title?title:section),'</h1><a href=# class="see-more" onclick="Stories.init().',(section?'showSection(\''+section+'\')">More '+section+'':'showOverview()">All Articles'),'</a><hr/></div>','<tpl if="',dataName,'">','<tpl for="',dataName,'">','<table cellpadding=0 cellspacing=0 border=0 class="item" width="100%"><tr valign="top">','<td class="content">','<a href="{link}" target="_blank" class="item-headline">{title}</a>','<div class="summary">{description}</div>','<div class="item-info">{objects} PR Blog | {published_at} ago | {comments_count} comment<tpl if="comments_count!=1">s</tpl></div>','</td>','</tr></table>','</tpl>','</tpl>'].join('');},getListDetailsTpl:function(id){return new Ext.XTemplate('<tpl for=".">','<div class="details">','<div class="details-header-1" style="float: left; clear: both">','{name}','</div>','<div class="x-clear"></div>','<div class="pb20 pt10">','<b>Items selected:</b> <span id="'+id+'-items-selected">0</span> (Use all {total})','</div>','<tpl if="filters.length &gt; 0">','<div class="details-header-2" style="float: left; clear: both; padding-bottom: 20px;">','Filters: ','</div>','<div style="float: left; padding-left: 10px;"><tpl for="filters">','{name}: {value}<br>','</tpl></div>','<div class="clear"></div>','</tpl>','</div>','</tpl>').compile();},getListDetailsRD:function(){return(['name','total','filters','popular_week','popular_month']);}});Prwire=new ReaderModule({name:'prwire',title:'PRWire',itemTitle:'release',overviewFields:['announcements','beats'],overviewTpl:new Ext.XTemplate('<tpl for=".">','<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr valign="top">','<td width="50%">','<div class="overview-container">','<div class="block-title sprite sprite-reader2"><h1>Latest Announcements</h1><a href=# class="see-more" onclick="Prwire.showMain()">See more</a><hr></div>','<tpl for="announcements">','<table cellpadding=0 cellspacing=0 border=0 class="item" width="100%" <tpl if="xindex==xcount">style="border-bottom: none;"</tpl>><tr valign="top">','<td class="image" width="125px"><tpl if="image_url != \'\'"><img width=100 src="{image_url}" border=0 /></tpl><tpl if="image_url == \'\'">&nbsp;</tpl></td>','<td class="content">','<a href=# class="item-headline" onclick="showRelease({id})">{title}</a>','<div class="summary">{description}</div>','<div class="item-info"><a href=# onclick="showContact({newsroom_contact_id});return false;">{newsroom}</a> | {published_at} ago </div>','</td>','</tr></table><tpl if="xindex!=xcount"><hr class="reader"></tpl>','</tpl>','</div>','</td><td>','<div class="overview-container" style="padding: 10px;">','<div class="overview-search-form">','<div class="block-title sprite sprite-search"><h1>Find Releases</h1><hr></div>','<div class="inputs">','<label for="prwire_search_by_text">Find releases containing the <b>text</b></label><br>','<input class="x-form-text x-form-field w250" name="prwire_search_by_text" id="prwire_search_by_text" type="text" /><br><br>','<label for="prwire_search_by_company">And/or for the <b>company</b> (eg. MediaConnect Australia)</label><br>','<div id="prwire_search_by_company"></div><br>','<label for="prwire_search_by_timeframe">And/or in the <b>timeframe</b> of (eg. last week)</label><br>','<div id="prwire_search_by_timeframe"></div>','</div>','<div class="x-small-editor" id="prwire_submit_search" style="float: right; padding-top: 23px;"></div>','</div>','</div>','<div class="overview-container tools-block">','<div class="block-title sprite sprite-tools"><h1>Tools & Assistance</h1><hr/></div>','<div class="updates-item">',isGuest()?['<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-add"></div><a href=# onclick="Home.showRegistration();return false;" class="title">Register for an account</a></div>','<div class="summary">Join the Influencing community to post comments, manage your online PR newsroom and post releases and jobs.</div>'].join(''):['<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-star"></div><a href=# onclick="Prwire.showStarred();return false;" class="title">View Starred Releases</a></div>','<div class="summary">You can star your favourite releases so as you can easily recall then in the future.</div>'].join(''),'</div>','</div>','<div class="overview-container">','<div class="block-title sprite sprite-folder"><h1>View by Beat</h1><hr/></div>','<tpl for="beats">','<tpl if="leaf">','<div class="arrows"></div><div class="overview-beat"><a href=# class="subject" onclick="Prwire.showBeat(\'{id}\',\'{text}\');">{text}</a></div>','</tpl>','<tpl if="!leaf">','<div class="arrows arrow-black" id="prwire-beat-{id}"><a href=# onclick="Prwire.toggleSubCategories({id});return false;"></a></div><div class="overview-beat"><a href=# class="subject" onclick="Prwire.showBeat(\'{id}\',\'{text}\');">{text}</a></div>','<div class="subcategories" id="prwire-beat-children-{id}" style="display: none;">','<tpl for="children">','<a href=# onclick="Prwire.showBeat(\'{id}\');">{text}</a><tpl if="xindex!=xcount"> | </tpl>','</tpl>','</div>','</tpl>','<tpl if="xindex!=xcount"><hr></tpl>','</tpl>','</div>',isGuest()?'':['<div class="overview-container">','<div class="block-title sprite sprite-cloud"><h1>Tags</h1><hr/></div>','<div id="prwire-overview-tagcloud-panel" class="overview-tagcloud"></div>','</div>'].join(''),'</td>','</tr></table>','</tpl>').compile(),showMain:function(params,isSearch){var title=isSearch?'Search results':'All releases';var id='';var baseParams={type:'release'};if(params){Ext.apply(baseParams,params);if(params.unreaded){title='Unread releases';id='unread';}
if(params.starred){title='Starred releases';id='starred';}}
this.showFilteredGrid({title:title,baseParams:baseParams},id||'main');},initFilters:function(){var result=[prepareComboBox({emptyText:'All beats',labelName:'Beats',hiddenName:'beatId',store:app.ds.beats}),prepareComboBox(app.makeUrl('getNewsroomsOptions'),{emptyText:'All Newsrooms',labelName:'Newsrooms',hiddenName:'newsroom_id'}),prepareComboBox({store:app.ds.timeframe,emptyText:'All Time',labelName:'Timeframe',hiddenName:'timeframe'})];return isGuest()?result:Ext.apply(result,[prepareComboBox({emptyText:'Read Status',labelName:'Read Status',hiddenName:'unreaded',store:app.ds.unreaded}),prepareComboBox({emptyText:'All',hiddenName:'starred',labelName:'Stars',store:app.ds.starredTypes})]);},initOverviewElements:function(){if(!isGuest()){this.overviewTagCloud=new Ext.ux.TagCloud({store:prepareDs(makeUrl('prwire','tagCloud'),[{name:'id'},{name:'count'},{name:'tag'}]),displayField:'tag',weightField:'count',loadMask:true,displayWeight:false,tagsName:'prwire-overview-tags',listeners:{'tagselect':{fn:function(cloud,tag,idx,el){this.showTagged(el.hasClass('x-cloud-item-selected')?tag.id:'');},scope:this}}});this.tagCloudPanel=new Ext.Panel({renderTo:'prwire-overview-tagcloud-panel',items:this.overviewTagCloud});this.overviewTagCloud.store.reload();}
this.overviewCompaniesCombo=prepareComboBox(app.makeUrl('getNewsroomsOptions'),{emptyText:'All companies',hiddenName:"prwire_search_company",allowBlank:true,renderTo:'prwire_search_by_company',width:296,style:{width:'296px'},typeAhead:true});this.overviewTimeframeCombo=prepareComboBox({store:app.ds.timeframe,emptyText:'All time',hiddenName:"prwire_search_timeframe",allowBlank:true,renderTo:'prwire_search_by_timeframe',width:296,style:{width:'296px'},typeAhead:true});new Ext.Button({minWidth:60,text:'Search',scope:this,renderTo:'prwire_submit_search',handler:function(){var filt=Ext.get("prwire_search_by_text").getValue();var company_id=this.overviewCompaniesCombo.getValue();var company=this.overviewCompaniesCombo.getRawValue();var timeframe=this.overviewTimeframeCombo.getValue();var timeframe_name=this.overviewTimeframeCombo.getRawValue();if(filt||company_id||timeframe){this.showFilteredGrid(this.getGridPanelCfg({pagerUrl:makeUrl("prwire","getPager"),title:filt||company||timeframe_name,baseParams:{filter:filt,newsroom_id:company_id,timeframe:timeframe}}),'by-filter');}}});},browseByNewsroom:function(name,id){this.showFilteredGrid(this.getGridPanelCfg({title:name,baseParams:{newsroom_id:id}}),'by-newsroom-'+id);},getListDetailsTpl:function(id){return new Ext.XTemplate('<tpl for=".">','<div class="details">','<div class="details-header-1" style="float: left; clear: both">','{name}','</div>','<div class="x-clear"></div>','<div class="pb20 pt10">','<b>Items selected:</b> <span id="'+id+'-items-selected">0</span> (Use all {total})','</div>','<tpl if="filters.length &gt; 0">','<div class="details-header-2" style="float: left; clear: both; padding-bottom: 20px;">','Filters: ','</div>','<div style="float: left; padding-left: 10px;"><tpl for="filters">','{name}: {value}<br>','</tpl></div>','<div class="clear"></div>','</tpl>','<tpl if="popular_week">','<div class="profile-bg p10"><h1>Popular This Week</h1></div>','<div class="p10">','<tpl for="popular_week">','<div class="articleTitle pb5"><a href=# onclick="showRelease({id});"><b>{headline}</b></a></div>','</tpl>','</div>','</tpl>','<tpl if="popular_month">','<div class="profile-bg p10"><h1>Popular This Month</h1></div>','<div class="p10">','<tpl for="popular_month">','<div class="articleTitle pb5"><a href=# onclick="showRelease({id});"><b>{headline}</b></a></div>','</tpl>','</div>','</tpl>','</div>','</tpl>').compile();},getListDetailsRD:function(){return(['name','total','filters','popular_week','popular_month']);}});var Agencies=new Application.Module({itemTitle:'agency',title:'PR Directory',name:'agencies',overviewFields:['stories_selection','is_in_directory'],isHavePreview:true,initParams:function(){this.rd=['id','title','contact_id','description','phone','size'];this.cm=[new Ext.grid.CheckboxSelectionModel(),{header:"Title",dataIndex:'title',width:330},{header:"Size",dataIndex:'size',width:80},{header:"Phone",dataIndex:'phone',width:100,sortable:false}];this.overviewTpl=new Ext.XTemplate('<tpl for=".">','<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr valign="top">','<td width="50%">','<div class="overview-container">','<div class="block-title sprite sprite-search"><h1>Find an agency</h1><a href=# class="see-more" onclick="Agencies.showMain()">See more</a><hr></div>','<div class="updates-item">','Influencing can assist in many PR activities, like list building, identifying editorial opportunities and managing PR projects. However, if you require strategic PR counsel, we recommend that you find a PR agency that fits your business.<br><br>','Just fill in the search criteria below, and we\'ll help you find an agency that matches your specific needs.<br>','<h1 style="padding: 10px 0;">I\'m looking for PR agency that:</h1>','<div id="pragency-search-form"></div>','</div>','</div>','</td><td>','<div class="overview-container">','<tpl if="is_in_directory == 0">','<div class="block-title sprite sprite-add"><h1>List your agency</h1>',isGuest()?'<a href=# class="see-more" onclick="return Home.showRegistration()">Register</a>':'<a href=# class="see-more" onclick="new PRDirectoryWizard().open();return false;">Register</a>','<hr>','</div>','<div class="updates-item">','Are you a PR agency and not listed in Influencing\'s PR Directory? All you need is a free Influenicng account and a couple of minutes<br><br>',isGuest()?'<a href=# onclick="return Home.showRegistration()"><b>Click here to join Influencing</b></a>':'<a href=# onclick="new PRDirectoryWizard().open();return false;"><b>Click here to list in PR directory</b></a>','</div>','</tpl>','<tpl if="is_in_directory == 1">','<div class="block-title sprite sprite-add"><h1>Edit your listing</h1>','<a href=# class="see-more" onclick="new PRDirectoryWizard().open();return false;">Edit</a>','<hr>','</div>','<div class="updates-item">','You can update your listing at any time to reflect changes in your company and the services you offer<br><br>','<a href=# onclick="new PRDirectoryWizard().open();return false;"><b>Click here to edit your listing</b></a>','</div>','</tpl>','</div>','<div class="overview-container tools-block">',Stories.getStoriesTpl('stories_selection','Select Agency','How to choose an agency',null,true),'</div>','</td>','</tr></table>','</tpl>').compile();this.previewTpl=new Ext.XTemplate('<tpl for=".">','<div class="details">','<div class="details-header-1" style="float: left">','{title}','</div>','<div class="clear"></div>','<tpl if="emails.length &gt; 0">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="20px"><div class="icon icon-email"></div></td>','<td width="100%"><b>Emails</b><br>','<tpl for="emails">','<tpl if="!this.isFirst(xindex)">',',','</tpl>',' <a href="mailto:{email}">{email}</a>','</tpl>','</td>','</tr></table>','</tpl>','<tpl if="phones.length &gt; 0">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="20px"><div class="icon icon-phone"></div></td>','<td width="100%"><b>Phones</b><br>','<tpl for="phones">','{type}: {phone}','<tpl if="xindex != xcount"><br></tpl>','</tpl>','</td>','</tr></table>','</tpl>','<tpl if="websites.length &gt; 0">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="20px"><div class="icon icon-online"></div></td>','<td width="100%"><b>Websites</b><br>','<tpl for="websites">',' <a href="{url}" target="blank">{url}</a><br>','</tpl>','</td>','</tr></table>','</tpl>','<tpl if="addresses.length &gt; 0">','<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">','<td width="20px"><div class="icon icon-company"></div></td>','<td width="100%"><b>Addresses</b><br>','<tpl for="addresses">','<a onmouseover="showTip(this, \'Google map\')" onclick="showGmap(\'{street}, {city}, {state}, {zip}, {country}\', \'{[String.escape(parent.title)]}\')">{address}</a><br>','</tpl>','</td>','</tr></table>','</tpl>','<div class="profile-bg p10">','<h1>Description</h1>','</div>{description}','<tpl if="testimonials.length &gt; 0">','<div class="profile-bg p10">','<h1>Testimonials</h1>','</div>','<tpl for="testimonials">','"{content}"<br>','<b>{person}<tpl if="person_company">, {person_company}</tpl></b><br>','<tpl if="xindex != xcount"><br></tpl>','</tpl>','</tpl>','</div>','</tpl>',{isFirst:function(index){return index==1;}}).compile();},initFilters:function(){return[prepareComboBox({emptyText:'All Locations',labelName:'Locations',hiddenName:'locationId',store:app.ds.jobLocationTypes}),prepareComboBox({emptyText:'All sizes',labelName:'Sizes',hiddenName:'sizeId',store:app.ds.agencySizeTypes}),prepareComboBox({emptyText:'All Beats',labelName:'Beats',hiddenName:'beatId',store:app.ds.beats})]},getGridPanelCfg:function(cfg){var result={isHaveEdit:false,previewFieldId:"id",dblclickShow:true,title:'All agencies',summary:'description'};return Ext.apply(result,cfg||{});},previewItem:function(id,data,panel){var grid=panel.grid;var store=new Ext.data.JsonStore({url:this.makeUrl('preview'),autoLoad:false,fields:['id','object_id','phones','emails','websites','addresses','title','services','beats','description','testimonials'],listeners:{'load':{fn:function(scope,rec){var data=rec[0].data;formatAddressString(data);var p=panel;var el=p.get(0).el;var tb=p.getTopToolbar();tb.removeAll();tb.add({text:'Add to shortlist',iconCls:'icon icon-tick',handler:function(){}},'->',{text:'Close',iconCls:'icon icon-cross',handler:function(){tb.removeAll();el.hide().update(p.listHtml).slideIn('l',{stopFx:true,duration:.2});Ext.DomHelper.overwrite(Ext.getDom(grid.id+'-items-selected'),grid.getSelectionModel().selections.length+'');}});tb.doLayout();el.hide().update(this.previewTpl.apply(data)).slideIn('l',{stopFx:true,duration:.2});},scope:this}}});store.reload({params:{id:id}});},getPreviewPanelCfg:function(name,grid){return this.getDefaultPreviewPanelCfg(name);},initOverviewElements:function(){this.agencySearchForm=new Ext.FormPanel({renderTo:'pragency-search-form',labelAlign:'top',items:[getComboOptions({forceSelection:true,fieldLabel:'Is located in',hiddenName:"locationId",allowBlank:true,store:app.ds.jobLocationTypes,width:200}),getComboOptions({forceSelection:false,fieldLabel:'With experience in the folowing sector',hiddenName:"beatId",allowBlank:true,store:app.ds.beats,width:200}),{xtype:'checkboxgroup',fieldLabel:'Size of agency desired',columns:3,labelStyle:'float:left; padding: 15px 0 0 0; font-weight: bold;',defaults:{name:'sizeId[]'},itemCls:'x-check-group-alt',items:[{boxLabel:'Small',inputValue:'7301'},{boxLabel:'Medium',inputValue:'7302'},{boxLabel:'Large',inputValue:'7303'}]},{xtype:'checkboxgroup',labelStyle:'float:left; padding: 15px 0 0 0; font-weight: bold;',fieldLabel:'Services required',columns:2,itemCls:'x-check-group-alt',items:this.getServiceTypesCheckBoxes()},{xtype:'checkboxgroup',fieldLabel:'Work arrangement desired',columns:3,labelStyle:'float:left; padding: 15px 0 0 0; font-weight: bold;',itemCls:'x-check-group-alt',items:this.getArrangementTypesCheckBoxes()},{xtype:'button',text:'Search',scope:this,style:'padding-top: 10px',handler:function(){this.showFilteredGrid({pagerUrl:this.makeUrl("getPager"),title:'Agency search',baseParams:this.agencySearchForm.getForm().getValues()},'by-filter');}}]});makeAutocompleteBeats("companies_search_by_beat");},getServiceTypesCheckBoxes:function(){var cfg=new Array();Ext.each(app.ds.agencyServiceTypes.data.items,function(el,i){cfg.push({inputValue:el.data.id,boxLabel:el.data.value,itemCls:'',name:'services_ids[]'});});return cfg;},getArrangementTypesCheckBoxes:function(){var cfg=new Array();Ext.each(app.ds.agencyArrangementTypes.data.items,function(el,i){cfg.push({inputValue:el.data.id,boxLabel:el.data.value,itemCls:'',name:'arrangements_ids[]'});});return cfg;},getListDetailsRD:function(){return(['total','name','filters']);}});PRDirectoryWizard=function(){this.store=new Ext.data.Store({url:makeUrl('agencies','getAgencyWizardData'),autoLoad:false,reader:new Ext.data.JsonReader({},['id','title','contact_id','description','keywords','emails','type_id','phones','websites','messengers','beats_ids','type','image_id','image_url_original','image_url_big','media_contacts','addr_street','addr_city','addr_state','addr_zip','addr_country','size_id','services_ids','arrangements_ids','testimonials','location_id'])});var logoViewTpl=new Ext.XTemplate('<tpl for=".">','<div class="x-form-item">','<tpl if="image_id">','<div style="float: left; padding: 2px;"><img onclick="showPreviewImageDialog(\'{image_url_original}\', \'\', \'\')" src="{image_url_big}" style="float:left"/>','<a id="wizard_company_delete_logo_{contact_id}" style="float:left; padding-left: 20px">Delete</a></div>','</tpl>','<tpl if="!image_id">','<div style="float: left; padding: 2px;">no image uploaded yet</div>','</tpl>','</div>','<div class="x-clear"></div>','</tpl>');var config={title:'Company wizard',width:800,height:(Ext.getBody().getSize().height-100),cls:'wiz',headerConfig:{title:'<div class="sprite sprite-folder">&nbsp;</div><h1>Company details</h1>'},cardPanelConfig:{defaults:{baseCls:'x-small-editor',bodyStyle:'padding:20px',border:false,autoScroll:true}},open:function(){this.store.on('load',function(grid,records){this.data=records[0].data;this.show();Ext.DomHelper.overwrite(Ext.getDom('prdirectory-wizard-details-left'),'<b>'+this.data.title+'</b><br>'+this.data.websites+'<br>'+this.data.phones);Ext.DomHelper.overwrite(Ext.getDom('prdirectory-wizard-details-right'),this.data.addr_street+',<br>'+this.data.addr_city+', '+this.data.addr_state+', '+this.data.addr_zip+',<br>'+this.data.addr_country);Ext.each(this.cards,function(c){c.getForm().setValues(this.data);},this);this.servicesOfferedGroup.setValue(this.data.services_ids);this.arrangementsOfferedGroup.setValue(this.data.arrangements_ids);this.beatsTree.setValues(this.data.beats_ids);this.nextButton.enable();},this);this.store.load();},onNextClick:function(){if(this.currentCard==this.cards.length-2){var data={};Ext.each(this.cards,function(e,i){if(i>0&&e.form){Ext.apply(data,e.form.getValues(false));}});this.cards[0].form.submit({url:makeUrl('agencies','updateAgencyFromWizard'),params:Ext.apply(data,{beats_ids:this.beatsTree.getValues()}),success:function(form,action){msg('Notification',action.result.info);this.cards[0].form.reset();this.cardPanel.getLayout().setActiveItem(this.currentCard+1);try{Agencies.overviewStore.reload();}catch(e){}},failure:function(form,action){var errorStr='';Ext.each(action.result.errors,function(f){if(f.msg!=undefined){errorStr+='<br/><b>'+f.id+'</b>: '+f.msg;}});Ext.MessageBox.alert('Error Message',action.result.errorInfo+errorStr);},scope:this});}else{if(this.currentCard==this.cardCount-1){this.onFinish();}else{this.cardPanel.getLayout().setActiveItem(this.currentCard+1);}}},cards:[new Ext.ux.Wiz.Card({title:'Company Details',monitorValid:true,labelAlign:'top',autoScroll:true,defaults:{xtype:'panel',labelSeparator:'',allowBlank:false},items:[{cls:'title pb20',html:'A basic listing in Influencing\'s PR directory is free and takes just minutes to complete'},getComboOptions({forceSelection:true,fieldLabel:'Located in',hiddenName:"location_id",allowBlank:false,itemCls:'label',store:app.ds.jobLocationTypes,width:250}),{cls:'big',html:'<hr>Agency details'},{layout:'column',cls:'title',items:[{columnWidth:.5,html:'<div id="prdirectory-wizard-details-left" style="color: #000;"></div>'},{columnWidth:.5,html:'<div id="prdirectory-wizard-details-right" style="color: #000;"></div>'}]},{html:'<hr>'},{fieldLabel:'Agency Description',name:'description',grow:false,itemCls:'label',xtype:'textarea',fieldClass:"x-form-textarea x-form-field",preventScrollbars:true},{cls:'note',html:'Please note that basic accounts are limited to 300 characters'},{html:'<hr>'},getComboOptions({fieldLabel:'Agency Size',hiddenName:'size_id',allowBlank:false,itemCls:'label',width:250,store:app.ds.agencySizeTypes}),{cls:'note',html:'Small (1-3 consultants), Medium (4-9 consultants), Large (10+ consultants)'},{html:'<hr>'},{cls:'big',html:'Services offered',style:'padding-bottom: 0;'},this.servicesOfferedGroup=new Ext.form.CheckboxGroup({labelStyle:'height: 0; padding: 0',hideLabel:true,width:710,columns:3,allowBlank:true,items:Agencies.getServiceTypesCheckBoxes()}),{html:'<hr>'},{cls:'big',html:'Arrangements offered',style:'padding-bottom: 0;'},this.arrangementsOfferedGroup=new Ext.form.CheckboxGroup({labelStyle:'height: 0; padding: 0',hideLabel:true,width:710,columns:3,allowBlank:true,items:Agencies.getArrangementTypesCheckBoxes()})]}),new Ext.ux.Wiz.Card({title:'Categories',monitorValid:true,items:[{cls:'title pb20',html:'Please select the categories that are relevant to your company and press \'Next\' at the bottom of this page'},this.beatsTree=createBeatsTreePanel('company','')]}),new Ext.ux.Wiz.Card({title:'Testimonials',monitorValid:true,listeners:{'show':{fn:function(){this.suspendEvents();Ext.each(this.findByType('dyn-panel'),function(c){c.setFirstTime(this.ownerCt.ownerCt.data);},this);this.resumeEvents();this.doLayout();}}},items:[{cls:'title pb20',html:'Please select the categories that are relevant to your company and press \'Next\' at the bottom of this page'},new DynamicFieldsPanel({fieldSetCfg:{labelWidth:160,panelCls:'addedPanelHr'},fields:[{name:'content[]',fieldLabel:'Testimonial',xtype:'textarea',maxLength:isInfluencing()?300:1000,height:80},{xtype:'panel',bodyStyle:'padding-left: 165px; padding-bottom: 8px;',html:'Max length is '+(isInfluencing()?300:1000)+' chars',cls:'note'},{xtype:'textfield',name:"person[]",fieldLabel:'Person'},{xtype:'textfield',name:"person_company[]",fieldLabel:'Company'}],addNote:'Click the Add button to add additional testimonials',set:function(obj){try{if(!obj.testimonials.length){this.appendField();}
Ext.each(obj.testimonials,function(n){this.appendField([n.content,n.person,n.person_company]);},this);}catch(e){this.appendField();}}})]}),new Ext.ux.Wiz.Card({title:'Next Steps',monitorValid:true,items:[{border:false,cls:'title pb20',html:'Congratulations! All PR Agency information is saved!'}]})]};PRDirectoryWizard.superclass.constructor.call(this,config);};Ext.extend(PRDirectoryWizard,Ext.ux.Wiz,{});var Jobs=new Application.Module({itemTitle:'recruitment',title:'Recruitment',name:'jobs',overviewFields:['latest'],isHavePreview:true,initParams:function(){this.rd=['id','title','account_id','account','description','category_id','category','location_id','location','salary','salary_min','salary_max','created_at','is_email','apply_to','image_url','related',{name:'is_editable',type:'bool'}];this.cm=[new Ext.grid.CheckboxSelectionModel(),{id:'title',header:"Title",dataIndex:'title',renderer:this.titleRenderer,scope:this},{header:"Category",dataIndex:'category',width:120},{header:"Salary",dataIndex:'salary',width:120,sortable:false}];this.overviewTpl=new Ext.XTemplate('<tpl for=".">','<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr valign="top">','<td width="50%">','<div class="overview-container tools-block">',this.getJobsTpl('latest','Latest jobs'),'</div>','</td><td>','<div class="overview-container" style="padding: 10px;">','<div class="overview-search-form">','<div class="block-title sprite sprite-search"><h1>Find Jobs</h1><hr></div>','<table width="100%" cellspacing=0 cellpadding=0 border=0><tr valign="top">','<td><div id="jobs-overview-search-form"></div></td>','<td width="90px" style="padding-top: 18px;"><div id="jobs-overview-search-form-submit"></div></td>','</tr></table>','</div>','</div>','<div class="overview-container tools-block">','<div class="block-title sprite sprite-tools"><h1>Tools & Assistance</h1><hr></div>','<div class="updates-item">','<div class="portlet-item" style="padding: 2px 0;">',isGuest()?['<div class="portlet-item" style="padding: 2px 0;"><div class="ico-new ico-new-add"></div><a href=# onclick="Home.showRegistration();return false;" class="title">Register for an account</a></div>','<div class="summary">Join the Influencing community to post comments, manage your online PR newsroom and post releases and jobs.</div>'].join(''):'<div class="ico-new ico-new-star"></div><a href=# onclick="new JobWizard().open();return false;" class="title">Post a job advertisement</a>','<div class="summary">LAUNCH OFFER: Post your public relations vacancies for free</div>','</div><hr>','</div></div>','</td>','</tr></table>','</tpl>').compile();this.previewTpl=new Ext.XTemplate('<tpl for=".">','<div class="details">','<div><img src="{image_url}" border=0 /></div>','<div class="clear"></div>','<div class="details-header-1" style="float: left">{title}</div>','<div class="clear"></div>','<div class="verified">Posted by {account}<br>{created_at}</div>','<div style="font-size: 12px; padding-top: 10px;">','<div class="label">Location</div><div>{location}</div>','<div class="label">Salary</div><div>{salary}</div>','</div>','<div class="description">{description}</div><hr>','<center><tpl if="is_email">','<a href="mailto:{apply_to}?subject=Recruitment" target="_blank">','</tpl>','<tpl if="!is_email">','<a href="{apply_to}" target="_blank">','</tpl><img src="/images/jobs_apply.png" border="0"></a></center>','</div>','</tpl>').compile();this.jobViewTpl=new Ext.XTemplate('<tpl for=".">','<div class="article">','<div class="title">{title}</div>','<div class="clear"></div>','<div class="from">Posted by <b>{account}</b> on {created_at}</div>','<div class="clear"></div>','<div class="job-details">','<table><tr><td width=100% valign="top">','<div class="details-title">Job Category:</div><div class="details-value">{category}</div>','<div class="details-title">Location:</div><div class="details-value">{location}</div>','<div class="details-title">Salary:</div><div class="details-value">{salary}</div>','</td><td width=100><div class="pic"><img src="{image_url}" border=0 style="padding-top: 0;"/></div>','</td></tr></table>','</div>','<div class="job-description">','{description}','</div><br>','<tpl if="is_email">','<a href="mailto:{apply_to}?subject=Recruitment" target="_blank">','</tpl>','<tpl if="!is_email">','<a href="{apply_to}" target="_blank">','</tpl><img src="/images/jobs_apply.png" border="0" style="padding: 0;"></a>','</div>','</tpl>').compile();this.moreJobsTpl=new Ext.XTemplate('<tpl for=".">','<div class="article-related"><h1>More Jobs</h1><hr style="margin: 0 0 10px 0;" />','<tpl for="related">','<h2><a onclick="Jobs.showItem({id});">{title}</a></h2>','{description:ellipsis(300)}','<div class="x-clear"></div><hr>','</tpl>','</tpl>','<div class="x-clear"></div>').compile();},initFilters:function(){return[prepareComboBox({emptyText:'All locations',labelName:'Locations',hiddenName:'locationId',store:app.ds.jobLocationTypes}),prepareComboBox({emptyText:'All categories',labelName:'Categories',hiddenName:'categoryId',store:app.ds.jobCategoryTypes}),new Ext.form.NumberField({xtype:'numberfield',hiddenName:'salary_min',labelName:'Salary MIN',emptyText:'Min $',allowDecimal:false,allowNegative:false}),new Ext.form.NumberField({xtype:'numberfield',hiddenName:'salary_max',labelName:'Salary MAX',emptyText:'Max $',allowDecimal:false,allowNegative:false})]},doAdd:function(){new JobWizard().open();},doEdit:function(btn){var grid=btn.scope;if(grid.getSelections().length){new JobWizard(grid.getSelections()[0].data.id,grid).open();}else{msg('Error','Please select at least one item to process');}},getGridPanelCfg:function(cfg){var result={previewFieldId:"id",dblclickShow:true,autoExpandColumn:'title',summary:'description'};return Ext.apply(result,cfg||{});},previewItem:function(id,data,panel){var grid=panel.grid;var store=new Ext.data.JsonStore({url:this.makeUrl('preview'),autoLoad:false,fields:this.rd,listeners:{'load':{fn:function(scope,rec){var data=rec[0].data;var p=grid.getPreviewPanel();var el=p.get(0).el;var tb=p.getTopToolbar();tb.removeAll();tb.add({text:'Email job',iconCls:'icon icon-email',handler:function(){var email="";var subject="Recruitment";var body_message=data.title+"%0D%0DPosted by "+data.account+" at "+data.created_at+"%0DCategory: "+data.category+"%0DLocation: "+data.location+"%0DSalary: "+data.salary+"%0D-------------------------------------------%0D"+data.description;var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_message;win=window.open(mailto_link,'emailWindow');if(win&&win.open&&!win.closed)win.close();}},'->',{text:'Close',iconCls:'icon icon-cross',handler:function(){tb.removeAll();el.hide().update(p.listHtml).slideIn('l',{stopFx:true,duration:.2});Ext.DomHelper.overwrite(Ext.getDom(grid.id+'-items-selected'),grid.getSelectionModel().selections.length+'');}});tb.doLayout();el.hide().update(this.previewTpl.apply(data)).slideIn('l',{stopFx:true,duration:.2});},scope:this}}});store.reload({params:{id:id}});},getPreviewPanelCfg:function(name,grid){return this.getDefaultPreviewPanelCfg(name);},initOverviewElements:function(){this.jobSearchForm=new Ext.FormPanel({renderTo:'jobs-overview-search-form',labelAlign:'top',defaults:{xtype:'panel'},items:[{xtype:'textfield',name:'filter',fieldLabel:'Find jobs with the following <b>keywords</b>'},getComboOptions({forceSelection:false,fieldLabel:'And/or in the following <b>categories</b> (eg. Consultant)',hiddenName:"categoryId",allowBlank:true,store:app.ds.jobCategoryTypes}),getComboOptions({forceSelection:false,fieldLabel:'And/or in the <b>region</b> (eg. Sydney)',hiddenName:"locationId",allowBlank:true,store:app.ds.jobLocationTypes}),{bodyStyle:'background-color: #edf4fc;',html:'<label>And/or in the <b>salary range</b> (eg. $4000-$5000)</label>'},{layout:'column',bodyStyle:'background-color: #edf4fc;',items:[{xtype:'numberfield',allowNegative:false,allowDecimal:false,emptyText:'Min $',name:'salary_min'},{xtype:'numberfield',style:'margin-left: 10px',allowNegative:false,allowDecimal:false,emptyText:'Max $',name:'salary_max'}]}]});new Ext.Button({minWidth:60,text:'Search',scope:this,renderTo:'jobs-overview-search-form-submit',handler:function(){this.showFilteredGrid({pagerUrl:this.makeUrl("getPager"),title:'Search for job',baseParams:this.jobSearchForm.getForm().getValues()},'by-filter');}});},getJobsTpl:function(dataName,title){return['<div class="block-title sprite sprite-recruitment"><h1>',title,'</h1><a href=# class="see-more" onclick="Jobs.showMain()">See more</a><hr/></div>','<tpl if="',dataName,'">','<tpl for="',dataName,'">','<table cellpadding=0 cellspacing=0 border=0 class="item" width="100%" <tpl if="xindex==xcount">style="border-bottom: none;"</tpl>><tr valign="top">','<td class="image" width="100px" align="center"><img src="{image_url}" border=0 /></td>','<td class="content">','<a href=# class="item-headline" onclick="showJob({id})">{title}</a>','<div class="summary">{description}</div>','<div class="item-info">{salary} | {location}</div>','</td>','</tr></table>','</tpl>','</tpl>'].join('');},showItem:function(id,data,grid){var cfg={layout:'border',bodyStyle:'background-color: #fff',defaults:{autoHeight:true,autoScroll:true},id:'jobs-job-'+id+'-panel',autoScroll:true,items:[{region:'center',id:'jobs-job-'+id+'-center-panel'},{region:'east',width:'300px',id:'jobs-job-'+id+'-east-panel'}]};app.showModulePanel(cfg,function(){app.getMainPanel().add(new JobModule(Ext.apply(cfg,{name:'jobs-job-'+id,objId:id,data:data})));app.getMainPanel().activate(cfg.id);},this);return false;},getListDetailsRD:function(){return(['total','name','filters']);}});JobModule=Ext.extend(Application.Module,{title:'Loading...',parentModule:Jobs,initParams:function(){this.previewTpl=this.parentModule.previewTpl;this.store=prepareDs(makeUrl('jobs','preview'),this.parentModule.rd,false,true);this.store.on('load',function(grid,records,options){this.data=records[0].data;this.setTitle(this.data.title);},this);},showMain:function(){this.getPanel('center').add({xtype:'dataview',store:this.store,tpl:this.parentModule.jobViewTpl,autoHeight:true,autoScroll:true,loadingText:'Loading',overClass:'x-view-over',itemSelector:'div.thumb-wrap',grid:this.grid});this.getPanel('east').add({layout:'fit',items:{xtype:'dataview',store:this.store,tpl:this.parentModule.moreJobsTpl,loadingText:'Loading',autoHeight:true,overClass:'x-view-over',itemSelector:'div.thumb-wrap'}});this.store.load({params:{id:this.objId}});}});JobWizard=function(jobId,grid){this.objId=jobId;this.grid=grid;this.store=new Ext.data.Store({url:makeUrl('jobs','load'),autoLoad:false,reader:new Ext.data.JsonReader({},Jobs.rd),listeners:{'load':{fn:function(grid,records){this.data=records[0].data;Ext.each(this.cards,function(c){c.getForm().setValues(this.data);},this);this.show();this.nextButton.enable();},scope:this}}});var config={title:'Job Advertisement Wizard',width:800,height:(Ext.getBody().getSize().height-100),cls:'wiz',headerConfig:{title:'<div class="sprite sprite-releases">&nbsp;</div><h1>Job Advertisement</h1>'},cardPanelConfig:{defaults:{baseCls:'x-small-editor',bodyStyle:'padding:20px',border:false,autoScroll:true}},open:function(){if(this.objId){this.store.load({params:{id:this.objId}});}else{this.show();}},onNextClick:function(){if(this.currentCard==this.cards.length-2){var data={};Ext.each(this.cards,function(e,i){if(i!=3&&e.form){Ext.apply(data,e.form.getValues(false));}});var isValid=true;if(data.salary_min&&data.salary_max&&data.salary_min!='Minimum $'&&data.salary_max!='Maximum $'&&(parseInt(data.salary_min)>parseInt(data.salary_max))){msg('Error','Salary minimum can not be greater than maximum');isValid=false;}
if(data.apply_to&&!Ext.form.VTypes.url(data.apply_to)&&!Ext.form.VTypes.email(data.apply_to)){msg('Error','Apply to is not valid URL or email');isValid=false;}
if(!isValid){return;}
this.cards[0].form.submit({url:makeUrl('jobs','update'),params:{id:this.objId},success:function(form,action){msg('Notification',action.result.info);this.cardPanel.getLayout().setActiveItem(this.currentCard+1);Jobs.overviewStore.reload();try{this.grid.store.reload();}catch(e){}},failure:function(form,action){var errorStr='';Ext.each(action.result.errors,function(f){if(f.msg!=undefined){errorStr+='<br/><b>'+f.id+'</b>: '+f.msg;}});Ext.MessageBox.alert('Error Message',action.result.errorInfo+errorStr);},scope:this});}else{if(this.currentCard==this.cardCount-1){this.onFinish();}else{this.cardPanel.getLayout().setActiveItem(this.currentCard+1);}}},cards:[new Ext.ux.Wiz.Card({title:'Details',xtype:'wizard-card',monitorValid:true,labelAlign:'top',autoScroll:true,defaults:{xtype:'panel',labelSeparator:'',allowBlank:false},items:[{name:'title',fieldLabel:'Job Title',xtype:'textfield',itemCls:'label'},{cls:'note',html:'This will be used as headline description for your job advertisement<hr>'},getComboOptions({forceSelection:false,fieldLabel:'Job Category',hiddenName:"category_id",allowBlank:false,store:app.ds.jobCategoryTypes,forceSelection:true,itemCls:'label'}),{html:'<hr>'},{xtype:'htmleditor',width:740,height:150,fieldlabel:'Job Description',name:'description',maxLength:isFree()?300:100000},{cls:'note',html:'Please note that basic accounts are limited to 300 characters<hr>'},{cls:'big',html:'Salary'},{layout:'column',width:500,style:'padding-bottom: 3px',defaults:{xtype:'numberfield',allowNegative:false,allowDecimal:false,width:200,allowBlank:true},items:[{emptyText:'Minimum $',name:'salary_min',allowBlank:true},{style:'margin-left: 10px',emptyText:'Maximum $',name:'salary_max',allowBlank:true}]},{cls:'note',html:'This field is optional but used in search criteria<hr>'},getComboOptions({forceSelection:false,fieldLabel:'Location',hiddenName:"location_id",allowBlank:false,store:app.ds.jobLocationTypes,forceSelection:true,itemCls:'label'}),{html:'<hr>'},{name:'apply_to',fieldLabel:'Apply to',allowBlank:true,xtype:'textfield',itemCls:'label'},{cls:'note',html:'You may enter a URL or email address. Please note you must enter full URL including http://'}]}),new Ext.ux.Wiz.Card({title:'Next Steps',monitorValid:true,items:[{border:false,cls:'title pb20',html:'Congratulations! Job advertisement posted successully!'}]})]};JobWizard.superclass.constructor.call(this,config);};Ext.extend(JobWizard,Ext.ux.Wiz,{});InformationModuleClass=Ext.extend(ReaderModule,{name:'information',title:'About Influencing',overviewFields:['about','community','contacts','professional','vertical','upgrades','pricing_id'],initParams:function(){InformationModuleClass.superclass.initParams.call(this);this.overviewTpl=new Ext.XTemplate('<tpl for=".">','<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr valign="top">','<td width="50%">','<div class="overview-container">',this.getStoriesTpl('about','About Influencing'),'</div>','<div class="overview-container">',this.getStoriesTpl('community','Community Edition'),'</div>','<div class="overview-container">',this.getStoriesTpl('upgrades','Newsroom Upgrades'),'</div>','</td><td>','<div class="overview-container tools-block">','<div class="block-title sprite sprite-information"><h1>Contacts Us</h1><hr/></div>','<div class="updates-item">','Want to talk to someone or sign up for an online demonstration. Please call us on +61 2 9894 6277 or email <a href=mailto:info@mediaconnect.com.au>info@mediaconnect.com.au</a>','</div>','</div>','<div class="overview-container">',this.getStoriesTpl('contacts','Contacts Edition'),'</div>','<div class="overview-container">',this.getStoriesTpl('professional','Professional Edition'),'</div>','<div class="overview-container">',this.getStoriesTpl('vertical','Vertical Editions'),'</div>','</td>','</tr></table>','</tpl>').compile();},showItem:function(id){InformationModuleClass.superclass.showItem.call(this,id,'info');}});Information=new InformationModuleClass({showMain:function(params,isSearch){var title=isSearch?'Search results':'All stories';var id='';var baseParams={type:'story'};if(params){Ext.apply(baseParams,params);if(params.unreaded){title='Unread releases';id='unread';}
if(params.starred){title='Starred releases';id='starred';}
if(params.section){title=params.section;id=params.section.toLowerCase();}}
this.showFilteredGrid({title:title,baseParams:baseParams},id||'main');},initFilters:function(){var result=[prepareComboBox({store:app.ds.timeframe,emptyText:'All Time',labelName:'Timeframe',hiddenName:'timeframe'})];return isGuest()?result:Ext.apply(result,[prepareComboBox({emptyText:'Read Status',labelName:'Read Status',hiddenName:'unreaded',store:app.ds.unreaded}),prepareComboBox({emptyText:'All',hiddenName:'starred',labelName:'Stars',store:app.ds.starredTypes})]);},getStoriesTpl:function(dataName,section,title){if(!title){title=section;}
return['<div class="block-title sprite sprite-information"><h1>',title,'</h1>'+(!isGuest()&&isFree()?'<a href=# class="see-more" onclick="Information.showPricing();return false;">Pricing</a>':'')+'<hr/></div>','<tpl if="',dataName,'">','<tpl for="',dataName,'">','<table cellpadding=0 cellspacing=0 border=0 class="item" width="100%"><tr valign="top">','<td class="image" width="110px"><img width=100 src="{image_url}" border=0 /></td>','<td class="content">','<a href=# class="item-headline" onclick="Information.showItem({id})">{title}</a>','<div class="summary">{description}</div>','<div class="item-info">{published_at} ago | {comments_count} comment<tpl if="comments_count!=1">s</tpl></div>','</td>','</tr></table>','</tpl>','</tpl>'].join('');},showPricing:function(){app.getMainPanel().add({title:'Editions & Pricing',id:'information-editions-and-pricing',xtype:'iframepanel',autoScroll:true,loadMask:{msg:'Loading ...'},fitToFrame:true,defaultSrc:app.conf.baseUrl+'../pricing/index.html'});app.getMainPanel().activate('information-editions-and-pricing');},getPricingTpl:function(){return new Ext.XTemplate('<table cellpadding=0 cellspacing=0 border=0 width="100%">','<tr valign="top">','<td>','<h1 style="font-size: 24px; font-weight: bold; font-family: sans-serif; padding:5px 0;">Transform your PR operations with Influencing</h1>','<h2 style="font-size: 15px; font-family: sans-serif; color: #808080;">The Real-Time Platform for PR Professionals in Australia and New Zealand</h2>','</td>','<td align="right"><a href=# onclick="alert(\'in development\');return false;"><img src="images/request-demo.png"></a></td>','</tr>','<tr valign="top">','<td width="67%" style="padding-top: 10px;">','<table cellpadding=0 cellspacing=0 border=0 width="100%">','<tr valign="top">','<td width="33%" style="padding-top: 10px; background-color: #F7F7F7; border-left: 1px solid #99bbe8; border-top: 1px solid #99bbe8; padding: 20px 0;">','<div style="text-align: center;" class="pricing-block">','<h1 class="pricing">Community Edition</h1>','Join the influencing community<br>','<span style="font-size: 16px;">Free</span><br>','<a href=# onclick="alert(\'in development\');return false;"><img src="images/wizard_select_plan.png" border=0></a><br>','<div style="text-align: left; padding-left: 20px;"><b>No cost. No risk.</b></div>','<ul class="pricing">','<li>Read the comment on the latest PR News</li>','<li>Create an online newsroom for your business and/or clients</li>','<li>Post media releases to our highly effective PRWire service</li>','<li>Read and post PR job advertisements</li>','<li>Promote upcoming media events and launches</li>','</ul>','<a href=# onclick="alert(\'in development\');return false;">Learn more about this plan</a>','</div>','</td>','<td width="33%" style="padding-top: 20px; background-color: #F7F7F7; border-top: 1px solid #99bbe8;">','<div class="pricing-block" style="text-align: center; border-left: 1px solid #99bbe8;">','<h1 class="pricing">Contacts Edition</h1>','Manage your media contacts<br>','<span style="font-size: 16px;">A$100/month</span><br>','<a href=# onclick="alert(\'in development\');return false;"><img src="images/wizard_select_plan.png" border=0></a><br>','<div style="text-align: left; padding-left: 20px;"><b>All basic features PLUS:</b></div>','<ul class="pricing">','<li>More than 5,000 media contacts and influencers from newspapers, magazines, websites, blogs, radio and television</li>','<li>Read our Journo editorial service - featuring the latest media news, journalist movements and profiles</li>','<li>Track your media interactions and collaborate in real-time via your personal Activity Stream</li>','<li>Includes 2 user license</li>','</ul>','<a href=# onclick="alert(\'in development\');return false;">Learn more about this plan</a>','</div>','</td>','</tr>','<tr>','<td colspan="2" align="center" style="background-color: #F7F7F7; border-left: 1px solid #99bbe8;"><hr class="pricing"><h1 style="font-size: 18px;" class="pricing">Optional Upgrades Available On <b>ALL PLANS</b></h1></td>','</tr>','<tr valign="top">','<td width="33%" style="background-color: #F7F7F7; border-left: 1px solid #99bbe8; border-bottom: 1px solid #99bbe8;" class="pricing-block">','<ul class="pricing">','<li><h2 class="pricing">PREMIUM NEWSROOMS</h2><span style="color: #777; font-weight: bold;">$50 per month</span><br>Images, Video, Experts, Analytics<br><i>Includes one additional user license</i><br><a href=# onclick="alert(\'in development\');return false;">Learn more about this upgrade</a></li>','</ul>','</td>','<td width="33%" style="background-color: #F7F7F7; border-bottom: 1px solid #99bbe8;" class="pricing-block">','<ul class="pricing">','<li><h2 class="pricing">MEDIA MONITORING</h2><span style="color: #777; font-weight: bold;">From $50 per month rep profile</span><br>Print, Online & Reporting<br><i>Zero-admin coverage reports</i><br><a href=# onclick="alert(\'in development\');return false;">Learn more about this upgrade</a></li>','</ul>','</td>','</tr>','</table>','</td>','<td width="33%">','<div style="background-color: #eef5fd; border: 2px solid #99bbe8; text-align: center; padding-bottom: 10px;" class="pricing-block">','<h1 style="display: block; border-bottom: 1px solid #99bbe8; color: #FFF; font-size:18px; padding:8px 0; background-color: #cddbf0;">MOST POPULAR PLAN</h1><br>','<h1 class="pricing">Professional Edition</h1>','Transform your PR operations<br>','<span style="font-size: 16px;">A$250/month</span><br>','<a href=# onclick="alert(\'in development\');return false;"><img src="images/wizard_select_plan.png" border=0></a><br>','<div style="text-align: left; padding-left: 20px;"><b>All contacts features PLUS:</b></div>','<ul class="pricing">','<li>Thousands editorial opportunities collated from hundreds of publications across Australia and New Zealand</li>','<li>Powerful distribution tool lets you distribute releases and track opens, clicks and bounces</li>','<li>Powerful reporting capabilities lets you export and automate reports for management and clients</li>','<li>Project Management and Time-sheets (Coming soon)</li>','</ul>','<a href=# onclick="alert(\'in development\');return false;">Learn more about this plan</a>','<hr class="pricing">','<ul class="pricing">','<li><h2 class="pricing">VERTICAL EDITIONS</h2><span style="color: #777; font-weight: bold;">Additional $100 per month</span><br>Specialist editorial service provides deep insight into vertical markets<br><i>Current verticals: technology</i><br><a href=# onclick="alert(\'in development\');return false;">Learn more about this plan</a></li>','</ul>','</div>','</td>','</tr>','</table>','<div style="border: 1px solid #CCC; margin-top:20px; padding:20px;">','<h1 style="font-size: 18px;" class="pricing">All charges are invoiced monthly with 14 days trading terms. Minimum commitnent is 6 months for Contacts Edition and 3 months for Professional Edition.</h1>','</div>','<h1 class="pricing" style="padding: 30px 0 10px 0;">Frequently Asked Questions</h1>','<table cellpadding=0 cellspacing=5 border=0 width="100%" class="pricing-faq">','<tr valign="top">','<td align="left" width="50%">','<b>What\'s a file?</b><br>','Files are legal entities. When you subscribe to Saasu you pay for the number of files you need.<br>','</td>','<td align="left" width="50%">','<b>What document or attachments limits do you have?</b><br>','Files are legal entities. When you subscribe to Saasu you pay for the number of files you need.<br>','</td>','</tr>','</table>','<br><br>');}});RegistrationWizard=Ext.extend(Ext.ux.Wiz,{initComponent:function(){Ext.apply(this,this.initialConfig);var config={id:'registration-wizard',title:'Register for an account',width:800,height:(Ext.getBody().getSize().height-100),cls:'wiz',headerConfig:{title:'<div class="wizard-influencing-logo">&nbsp;</div><h1 class="registration-wizard">Influencing registration</h1>'},cardPanelConfig:{defaults:{baseCls:'x-small-editor',border:false,autoScroll:true,bodyStyle:"position: relative; padding:20px;"}},cards:[this.getInitCard()]};Ext.apply(this,config);RegistrationWizard.superclass.initComponent.apply(this);},getInitCard:function(){return new Ext.ux.Wiz.Card({title:'Register for an account',id:'registration-wizard-init-card',monitorValid:true,labelAlign:'top',fileUpload:false,defaults:{xtype:'panel',labelSeparator:'',allowBlank:false},items:[{html:'In order to identify the account you belong to? please enter your work email address. Then click next',cls:'title pb20'},{name:'email',vtype:'email',fieldLabel:'What is your email address?',xtype:'textfield',itemCls:'label'},{html:'',style:'color: RED; font-weight: bold; padding-top: 10px;',id:'registration-wizard-join-error',cls:'title pb20'}]});},onNextClick:function(){var cardId=this.cards[this.currentCard].id;if(cardId=='registration-wizard-init-card'){if(this.cards[0].form.isValid()){this.cards[0].form.submit({url:makeUrl('core','wizardFindCompany'),reset:false,success:function(form,action){if(action.result.info=='Account not found'){this.showNewAccount(action.result.email);return;}
Ext.DomHelper.overwrite(Ext.getDom('registration-wizard-join-error'),'');this.showJoinAccount(action.result.email);this.cards[1].form.setValues(action.result);Ext.DomHelper.overwrite(Ext.getDom('registration-wizard-join-company-name'),action.result.company);this.companyTitle=action.result.company;},failure:function(form,action){Ext.DomHelper.overwrite(Ext.getDom('registration-wizard-join-error'),action.result.errorInfo);},scope:this});}}else if(cardId=='registration-wizard-join-acc-details-card'){var data={};Ext.each(this.cards,function(e,i){if(i>0&&e.form){Ext.apply(data,e.form.getValues(false));}});this.cards[2].form.submit({url:app.makeUrl('wizardJoinAccount'),clientValidation:true,params:data,success:function(form,action){msg('Notification',action.result.info);this.cardPanel.getLayout().setActiveItem(this.currentCard+1);Ext.DomHelper.overwrite(Ext.getDom('registration-wizard-join-company-name2'),this.companyTitle);},failure:function(form,action){var errorStr='';Ext.each(action.result.errors,function(f){if(f.msg!=undefined){errorStr+='<br/><b>'+f.id+'</b>: '+f.msg;}});Ext.MessageBox.alert('Please fix following errors and resubmit',action.result.errorInfo+errorStr);},scope:this});}else if(cardId=='registration-wizard-signup-card'){var data={};Ext.each(this.cards,function(e,i){if(i>0&&e.form){Ext.apply(data,e.form.getValues(false));}});this.cards[1].form.submit({url:makeUrl('core','wizardSignupAccount'),clientValidation:true,params:data,success:function(form,action){msg('Notification',action.result.info);this.cardPanel.getLayout().setActiveItem(this.currentCard+1);},failure:function(form,action){var errorStr='';if(action.result){Ext.each(action.result.errors,function(f){if(f.msg!=undefined){errorStr+='<br/><b>'+f.id+'</b>: '+f.msg;}});}
Ext.MessageBox.alert('Please fix following errors and resubmit',action.result.errorInfo+errorStr);},scope:this});}
else{if(this.currentCard==this.cardCount-1){this.close();}else{this.cardPanel.getLayout().setActiveItem(this.currentCard+1);}}},showNewAccount:function(email){var initCard=this.cards[0];this.cardPanel.removeAll(true);this.cardPanel.add(this.getInitCard());this.cards=[initCard];var finishCard=new Ext.ux.Wiz.Card({title:'Registration finished',monitorValid:true,items:[{border:false,cls:'title pb20',html:'Congratulations! A message with confirmation code was sent to your email.'}]});var companyDetailsCard=new Ext.ux.Wiz.Card({title:'Company details',monitorValid:true,labelAlign:'top',id:'registration-wizard-signup-card',defaults:{xtype:'panel',labelSeparator:'',allowBlank:false},items:[{cls:'title pb10',bodyStyle:'font-size: 18px; color: #888;',html:'Welcome to Influencing, the online platform of Australia\'s public relations community.'},{cls:'title',bodyStyle:'font-size: 15px; color: #888;',html:'Currently, we have no account set up under your domain. Simply fill in the short form below and we\'ll get you started with a fresh account. Please note for your account to be approved you must be either:<br>'+'a) A public relations or marketing professional<br>'+'b) Have responsibility for public relations in your organisation'},{layout:'column',height:55,items:[{width:350,height:55,items:[{cls:'big',html:'First name'},{name:'first_name',itemCls:'big',width:340,allowBlank:false,xtype:'textfield'}]},{width:350,height:55,items:[{cls:'big',html:'Surname'},{name:'last_name',itemCls:'big',allowBlank:false,width:340,xtype:'textfield'}]}],listeners:{'afterrender':{fn:function(p){p.doLayout();},scope:this}}},{name:'job_title',itemCls:'big',xtype:'textfield',allowBlank:false,fieldLabel:'Job Title'},{cls:'note',html:'What is your current job title (ie managing Director, Account Director, etc)'},{html:'<hr>'},{name:'company',itemCls:'big',xtype:'textfield',fieldLabel:'Company'},{cls:'note',html:'What company do you work for?'},{cls:'big',html:'Company type',style:'padding-bottom: 0;'},{xtype:'radiogroup',itemCls:'wizard-radio-group',labelStyle:'height: 0; padding: 0',columns:2,defaults:{name:'company_type'},items:[{boxLabel:'Public Relations or Marketing Agency',checked:true,inputValue:'marketing'},{boxLabel:'Business managing its own public relations',inputValue:'business'}]},{html:'<hr>'},{name:'company_phone',itemCls:'big',xtype:'textfield',fieldLabel:'Phone'},{cls:'note',html:'What is your company phone line<hr>'},{name:'company_website',itemCls:'big',xtype:'textfield',vtype:'url',fieldLabel:'Web Address',value:'http://'},{cls:'note',html:'Please type the full URL for your website including http://'},{xtype:'hidden',name:'email',value:email}]});this.cardPanel.add(companyDetailsCard,finishCard);this.cardPanel.doLayout();this.cards.push(companyDetailsCard,finishCard);for(var i=0,len=this.cards.length;i<len;i++){this.cards[i].on('show',this.onCardShow,this);this.cards[i].on('hide',this.onCardHide,this);this.cards[i].on('clientvalidation',this.onClientValidation,this);}
this.cardCount=this.cards.length;this.currentCard=1;this.headPanel=new Ext.ux.Wiz.Header({title:'<div class="wizard-influencing-logo">&nbsp;</div><h1 class="registration-wizard">'+this.title+'</h1>',steps:this.cardCount,id:'registration-wizard-header-panel'});this.headPanel.applyToMarkup(this.id+'-header-panel');this.cardPanel.getLayout().setActiveItem(1);this.nextButton.setText('Submit');},showJoinAccount:function(email){var initCard=this.cards[0];this.cardPanel.removeAll(true);this.cardPanel.add(this.getInitCard());this.cards=[initCard];var joinAccDetailsCard=new Ext.ux.Wiz.Card({title:'User details',id:'registration-wizard-join-acc-details-card',monitorValid:true,labelAlign:'top',style:"position: relative;",bodyStyle:"position: relative;",defaults:{xtype:'panel',labelSeparator:'',allowBlank:false},items:[{cls:'title-medium pb10',style:"position: relative;",bodyStyle:"position: relative;",html:'Welcome to Influencing,<br>The email domain you have used is managed by <span id="registration-wizard-join-company-name"></span>. Please complete the form below and your request will be passed onto the administrator of that account for approval.<br>If this is not the case or your believe your administrator has left the company please call us on (02) 9894 6277'},{xtype:'hidden',name:'account_id'},{name:'firstName',fieldLabel:'First name',xtype:'textfield',style:"position: relative;",bodyStyle:"position: relative;",labelStyle:"position: relative;",itemCls:'label'},{name:'lastName',fieldLabel:'Surname',xtype:'textfield',itemCls:'label'},{html:'<hr>'},{cls:'note',html:'This will be used to confirm your registration<hr>'},{name:'phone',itemCls:'big',xtype:'textfield',fieldLabel:'Phone'},{cls:'note',html:'What number can we reach you on if there is a problem with your account<hr>'},{name:'jobTitle',itemCls:'big',xtype:'textfield',fieldLabel:'Job Title'},{cls:'note',html:'Please include title and company or division; ie Account Manager, Big PR<hr>'},{html:'Address',cls:'big',style:'padding-bottom: 0;'},{cls:'big',layout:'column',style:'padding: 0; position: relative;',items:[{columnWidth:.4,items:{xtype:'fieldset',labelAlign:'left',border:false,style:'padding: 0; position: relative;',defaults:{width:150,labelWidth:80,xtype:'textfield',allowBlank:false,labelStyle:'text-align: right; float: left; color: #000; padding-top: 6px;',labelWidth:80,bodyStyle:'position: relative;'},items:[{fieldLabel:'Street',name:'street'},{fieldLabel:'State',name:'state'},getComboOptions({forceSelection:false,fieldLabel:'Country',hiddenName:"countryId",store:app.ds.countries,value:13})]}},{columnWidth:.6,height:100,items:{xtype:'fieldset',labelAlign:'left',width:300,border:false,allowBlank:false,style:'padding: 0;',defaults:{width:150,labelWidth:80,xtype:'textfield',allowBlank:false,labelStyle:'text-align: right; float: left; color: #000; padding-top: 6px;',labelWidth:80,bodyStyle:'width: 150px;'},items:[{fieldLabel:'Zip',name:'zip'},getComboOptions({fieldLabel:'Type',hiddenName:"typeId",store:app.ds.addressTypes,value:801})]}}],listeners:{'afterrender':{fn:function(p){p.doLayout();},scope:this}}},{html:'<hr>'},{cls:'note',html:'All fields are required'},{xtype:'hidden',name:'email',value:email}]});var finishCard=new Ext.ux.Wiz.Card({title:'Email confirmation',monitorValid:true,items:[{border:false,cls:'title-big pb10',html:'Thank you, that\'s all we need right now.'},{border:false,cls:'title-big pb10',html:'We\'ve sent you an email that contains a confirmation link. It should arrive within a couple of minutes so please check your trash folder if it doesn\'t promptly'},{border:false,cls:'title-big pb10',html:'Please click that link and your registration will then be passed onto the administrator of the <span id="registration-wizard-join-company-name2"></span> account. Once approved, you will receive another email with your login details.'},{border:false,cls:'title-big pb10',html:'We look forward to having you join the Influencing community.'}]})
this.cardPanel.add(joinAccDetailsCard,finishCard);this.cardPanel.doLayout();this.cards.push(joinAccDetailsCard,finishCard);for(var i=0,len=this.cards.length;i<len;i++){this.cards[i].on('show',this.onCardShow,this);this.cards[i].on('hide',this.onCardHide,this);this.cards[i].on('clientvalidation',this.onClientValidation,this);}
this.cardCount=this.cards.length;this.currentCard=1;this.headPanel=new Ext.ux.Wiz.Header({title:'<div class="wizard-influencing-logo">&nbsp;</div><h1 class="registration-wizard">'+this.title+'</h1>',steps:this.cardCount,id:'registration-wizard-header-panel'});this.headPanel.applyToMarkup('registration-wizard-header-panel');this.cardPanel.getLayout().setActiveItem(1);this.nextButton.setText('Submit');},onPreviousClick:function(){if(this.currentCard>0){if(this.currentCard==1){this.close();Home.showRegistration();}else{this.cardPanel.getLayout().setActiveItem(this.currentCard-1);}}},onCardShow:function(card){RegistrationWizard.superclass.onCardShow.call(this,card);if(this.currentCard<1){this.nextButton.setText('Next');this.nextButton.show();this.previousButton.hide();}else{this.nextButton.show();this.previousButton.show();}}});
