1
|
package eu.dnetlib.client.monitor;
|
2
|
|
3
|
import com.github.gwtbootstrap.client.ui.Alert;
|
4
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
5
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
6
|
import com.google.gwt.core.client.GWT;
|
7
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
8
|
import com.google.gwt.user.client.Window;
|
9
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
10
|
import com.google.gwt.user.client.ui.FlowPanel;
|
11
|
import com.google.gwt.user.client.ui.HTML;
|
12
|
import com.google.gwt.user.client.ui.IsWidget;
|
13
|
import com.google.gwt.user.client.ui.Widget;
|
14
|
import eu.dnetlib.client.DataService;
|
15
|
import eu.dnetlib.client.DataServiceAsync;
|
16
|
import eu.dnetlib.goldoa.domain.*;
|
17
|
|
18
|
import java.util.List;
|
19
|
|
20
|
/**
|
21
|
* Created by panagiotis on 14/12/2017.
|
22
|
*/
|
23
|
public class AlternativeFundingBidInfoElement implements IsWidget {
|
24
|
|
25
|
private FlowPanel requestInfoPanel = new FlowPanel();
|
26
|
|
27
|
private Alert errorLabel = new Alert();
|
28
|
private Alert successLabel = new Alert();
|
29
|
|
30
|
private FlowPanel requestSummaryPanel = new FlowPanel();
|
31
|
private FlowPanel firstDivider = new FlowPanel();
|
32
|
|
33
|
private FlowPanel actionButtons = new FlowPanel();
|
34
|
|
35
|
private FlowPanel secondDivider = new FlowPanel();
|
36
|
|
37
|
private ActionListener actionListener;
|
38
|
|
39
|
private DataServiceAsync dataService = GWT.create(DataService.class);
|
40
|
|
41
|
public AlternativeFundingBidInfoElement(final AlternativeFundingBid bid,List<Object> docs) {
|
42
|
|
43
|
requestInfoPanel.addStyleName("requestInfoPanel");
|
44
|
|
45
|
successLabel.addStyleName("alertLabel");
|
46
|
successLabel.setType(AlertType.SUCCESS);
|
47
|
successLabel.setVisible(false);
|
48
|
successLabel.setClose(false);
|
49
|
|
50
|
errorLabel.addStyleName("alertLabel");
|
51
|
errorLabel.setType(AlertType.ERROR);
|
52
|
errorLabel.setVisible(false);
|
53
|
errorLabel.setClose(false);
|
54
|
|
55
|
requestSummaryPanel.addStyleName("requestDetailedInfoPanel");
|
56
|
|
57
|
if(docs.get(2)!=null)
|
58
|
requestSummaryPanel.add(createInvoiceInfo(bid.getId(),(Invoice)docs.get(2),"FIRST INVOICE","first_invoice"));
|
59
|
|
60
|
if(docs.get(3)!=null)
|
61
|
requestSummaryPanel.add(createInvoiceInfo(bid.getId(),(Invoice)docs.get(3),"SECOND INVOICE","second_invoice"));
|
62
|
|
63
|
if(docs.get(0) != null)
|
64
|
requestSummaryPanel.add(createBankTransferInfo(bid.getId(),(BankTransferReceipt)docs.get(0),"FIRST PAYMENT DOCUMENT","first_payment"));
|
65
|
|
66
|
if(docs.get(1) != null)
|
67
|
requestSummaryPanel.add(createBankTransferInfo(bid.getId(),(BankTransferReceipt)docs.get(1),"SECOND PAYMENT DOCUMENT","second_payment"));
|
68
|
|
69
|
if(docs.get(4) != null)
|
70
|
requestSummaryPanel.add(createContractInfo(bid.getId(),(File)docs.get(4),"Contract","contract"));
|
71
|
|
72
|
firstDivider.addStyleName("uk-grid-divider");
|
73
|
secondDivider.addStyleName("uk-grid-divider");
|
74
|
|
75
|
requestInfoPanel.add(successLabel);
|
76
|
requestInfoPanel.add(errorLabel);
|
77
|
requestInfoPanel.add(firstDivider);
|
78
|
requestInfoPanel.add(requestSummaryPanel);
|
79
|
|
80
|
requestInfoPanel.add(actionButtons);
|
81
|
|
82
|
requestInfoPanel.add(secondDivider);
|
83
|
|
84
|
}
|
85
|
|
86
|
private HTML createContractInfo(String bidId,File contract, String title,String mode) {
|
87
|
|
88
|
HTML contractInlineInfo = new HTML();
|
89
|
String contractInfoContents = "";
|
90
|
|
91
|
contractInfoContents = "<div class=\"displayInlineInfo\">";
|
92
|
|
93
|
contractInfoContents += "<dl><dt class=\"chronologySubTitle\">" + title + "</dt></dl>";
|
94
|
contractInfoContents += "<dd>";
|
95
|
|
96
|
contractInfoContents += "<dd>" + "<a href=\"" + GWT.getModuleBaseURL()
|
97
|
+ "fundingBid?fileId=" + bidId
|
98
|
+ "&mode=" + mode
|
99
|
+ "&fileType=contract"
|
100
|
+ "\" target=\"_blank\">Click here to download the bank transfer document</a>";
|
101
|
|
102
|
contractInfoContents += "</dd>";
|
103
|
|
104
|
contractInfoContents += "</div>";
|
105
|
contractInlineInfo.setHTML(contractInfoContents);
|
106
|
|
107
|
return contractInlineInfo;
|
108
|
}
|
109
|
|
110
|
private HTML createBankTransferInfo(String bidId,BankTransferReceipt doc, String title,String mode) {
|
111
|
|
112
|
HTML bankReceiptInlineInfo = new HTML();
|
113
|
String bankReceiptInfoContents = "";
|
114
|
|
115
|
DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
116
|
|
117
|
bankReceiptInfoContents = "<div class=\"displayInlineInfo\">";
|
118
|
|
119
|
bankReceiptInfoContents += "<dl><dt class=\"chronologySubTitle\">" + title + "</dt></dl>";
|
120
|
bankReceiptInfoContents += "<dd>";
|
121
|
|
122
|
bankReceiptInfoContents += "Date of payment: " + dtf.format(doc.getDate());
|
123
|
bankReceiptInfoContents += ", APC paid: " + Math.round(doc.getAmount()*100) / 100.0 + " EUR";
|
124
|
bankReceiptInfoContents += ", Transfer costs: " + Math.round(doc.getTransferCost()*100) / 100.0 + " EUR";
|
125
|
if(doc.getOtherCosts()!=null)
|
126
|
bankReceiptInfoContents += ", Other expenses: " + Math.round(doc.getOtherCosts()*100) / 100.0 + " EUR</dd>";
|
127
|
bankReceiptInfoContents += "<dd>" + "<a href=\"" + GWT.getModuleBaseURL()
|
128
|
+ "fundingBid?fileId=" + bidId
|
129
|
+ "&mode=" + mode
|
130
|
+ "&fileType=receipt"
|
131
|
+ "\" target=\"_blank\">Click here to download the bank transfer document</a>";
|
132
|
|
133
|
bankReceiptInfoContents += "</dd>";
|
134
|
|
135
|
bankReceiptInfoContents += "</div>";
|
136
|
bankReceiptInlineInfo.setHTML(bankReceiptInfoContents);
|
137
|
|
138
|
return bankReceiptInlineInfo;
|
139
|
}
|
140
|
|
141
|
private HTML createInvoiceInfo(String bidId,Invoice invoice, String title,String mode) {
|
142
|
|
143
|
HTML invoiceInlineInfo = new HTML();
|
144
|
String invoiceInfoContents = "";
|
145
|
|
146
|
DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
147
|
|
148
|
invoiceInfoContents = "<div class=\"displayInlineInfo\">";
|
149
|
|
150
|
invoiceInfoContents += "<dl><dt class=\"chronologySubTitle\">"+ title + "</dt></dl>";
|
151
|
invoiceInfoContents += "<dd>";
|
152
|
invoiceInfoContents += "Invoice number: " + invoice.getNumber();
|
153
|
|
154
|
if(invoice.getAlternativeId()!=null && !invoice.getAlternativeId().trim().equals(""))
|
155
|
invoiceInfoContents += ", Alternative ID: " + invoice.getAlternativeId();
|
156
|
|
157
|
if(invoice.getDate() != null)
|
158
|
invoiceInfoContents += ", Date issued: " + dtf.format(invoice.getDate());
|
159
|
|
160
|
|
161
|
invoiceInfoContents += ", " + "<a href=\"" + GWT.getModuleBaseURL()
|
162
|
+ "fundingBid?fileId=" + bidId
|
163
|
+ "&mode=" + mode
|
164
|
+ "&fileType=invoice"
|
165
|
+ "\" target=\"_blank\">Click here to download the invoice</a>";
|
166
|
|
167
|
invoiceInfoContents += "</dd>";
|
168
|
invoiceInfoContents += "</div>";
|
169
|
|
170
|
invoiceInlineInfo.setHTML(invoiceInfoContents);
|
171
|
return invoiceInlineInfo;
|
172
|
}
|
173
|
|
174
|
@Override
|
175
|
public Widget asWidget() {
|
176
|
return requestInfoPanel;
|
177
|
}
|
178
|
|
179
|
public interface ActionListener {
|
180
|
public void actionHappened(boolean succeeded, Request.RequestStatus status, Comment comment);
|
181
|
}
|
182
|
|
183
|
public void setActionListener(ActionListener actionListener) {
|
184
|
this.actionListener = actionListener;
|
185
|
}
|
186
|
|
187
|
}
|