19 package org.turro.contacts.profile;
21 import java.util.Date;
22 import java.util.logging.Level;
23 import java.util.logging.Logger;
24 import org.apache.commons.mail.EmailException;
25 import org.turro.action.Actions;
26 import org.turro.action.Contacts;
27 import org.turro.action.PushSenders;
28 import org.turro.auth.Authentication;
29 import org.turro.collections.KeyValueMap;
30 import org.turro.contacts.BusinessRelation;
31 import org.turro.contacts.Contact;
32 import org.turro.contacts.db.ContactsPU;
33 import org.turro.contacts.organigram.RelationType;
34 import org.turro.elephant.TemplateControl;
35 import org.turro.elephant.context.Application;
36 import org.turro.elephant.context.ElephantContext;
37 import org.turro.entities.EntityCombobox;
38 import org.turro.i18n.I_;
39 import org.turro.mail.sender.MailPool;
40 import org.turro.plugin.contacts.IContact;
41 import org.turro.security.SecurityGroup;
42 import org.zkoss.zk.ui.select.annotation.Listen;
43 import org.zkoss.zk.ui.select.annotation.Wire;
44 import org.zkoss.zul.Datebox;
58 @Wire(
"#start")
private Datebox start;
59 @Wire(
"#end")
private Datebox end;
61 @Listen(
"onChange=#business")
66 @Listen(
"onChange=#position")
71 @Listen(
"onChange=#start")
76 @Listen(
"onChange=#end")
81 @Listen(
"onClick=#save")
86 sendNotification(relation);
90 @Listen(
"onClick=#cancel")
116 if(kvm.containsKey(
"relation")) {
118 }
else if(kvm.containsKey(
"element")) {
120 if(kvm !=
null && kvm.containsKey(
"contact")) {
133 private void initComponents() {
134 if(relation !=
null) {
140 correctDates(relation);
144 Application.getApplication().sendRedirect(path);
148 private void sendNotification(BusinessRelation r) {
152 .addBySyndication(SecurityGroup.CONTACTS_ADMIN)
155 .put(
"profile",
new Profile(r.getContact()))
156 .sendTemplate(
"relation-notification",
157 I_.get(
"Modified") +
": " + I_.get(
"Relation"));
158 }
catch (EmailException ex) {
159 Logger.getLogger(EditProfileControl.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
161 PushSenders.getPool()
163 .addBySyndication(SecurityGroup.CONTACTS_ADMIN)
164 .send(I_.get(
"Modified") +
": " + I_.get(
"Relation"),
165 r.getContact().getName() +
" > " + r.getBusiness().getName());
168 private void correctDates(BusinessRelation relation) {
169 if(relation.getStartDate() ==
null) {
170 if(relation.getEndDate() !=
null) {
171 relation.setStartDate(relation.getEndDate());
173 relation.setStartDate(
new Date());
static KeyValueMap getRightNowAction(IConstructor constructor)
static IContact getIContact()
IConstructor getConstructor()
abstract void sendRedirect(String uri)
static Application getApplication()
void setParameters(KeyValueMap kvm)
void setRoot(String root)