Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / WEB-INF / fusion / raptor / wizard_schedule.jsp
1 <%--
2   ================================================================================
3   eCOMP Portal SDK
4   ================================================================================
5   Copyright (C) 2017 AT&T Intellectual Property
6   ================================================================================
7   Licensed under the Apache License, Version 2.0 (the "License");
8   you may not use this file except in compliance with the License.
9   You may obtain a copy of the License at
10   
11        http://www.apache.org/licenses/LICENSE-2.0
12   
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18   ================================================================================
19   --%>
20 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.DataColumnType" %>
21 <%@ page import="org.openecomp.portalsdk.analytics.util.AppConstants" %>
22 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.ReportDefinition" %>
23 <%@ page import="org.openecomp.portalsdk.analytics.system.AppUtils" %>
24 <%@ page import="org.openecomp.portalsdk.analytics.system.Globals" %>
25 <%@ page import="org.openecomp.portalsdk.analytics.controller.WizardSequence" %>
26 <%@ page import="java.util.Vector" %>
27 <%@ page import="java.util.List" %>
28 <%@ page import="org.openecomp.portalsdk.analytics.model.DataCache" %>
29 <%@ page import="java.util.Iterator" %>
30 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.DataSourceType" %>
31 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.DBColumnInfo" %>
32 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.TableSource" %>
33 <%@ page import="org.openecomp.portalsdk.analytics.model.base.IdNameValue" %>
34 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.SemaphoreType" %>
35 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.FormFieldType" %>
36 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.ReportSchedule" %>
37 <%@ page import="org.openecomp.portalsdk.analytics.util.Utils" %>
38
39 <% 
40   ReportDefinition rdef = (ReportDefinition) request.getAttribute(AppConstants.SI_REPORT_DEFINITION);
41   WizardSequence ws = rdef.getWizardSequence();
42   ReportSchedule reportSchedule = rdef.getReportSchedule(); 
43   String remoteDbPrefix = (String) session.getAttribute("remoteDB");
44   boolean isSQLAllowed = Globals.getAllowSQLBasedReports();
45   
46 %>
47 <%@page import="java.util.Calendar"%>
48 <%@page import="java.text.DateFormat"%>
49 <%@page import="java.text.SimpleDateFormat"%>
50 <%@page import="java.util.TimeZone"%>
51 <%@page import="java.util.Date"%>
52 <%@page import="org.openecomp.portalsdk.analytics.model.ReportLoader"%>
53 <script language="JavaScript">
54 <!--
55 function showTestConditionPopup() {
56         var w = window.open("<%= AppUtils.getRaptorActionURL() %>report.popup.test.cond&remoteDbPrefix=<%=remoteDbPrefix%>&<%= AppConstants.RI_FORMATTED_SQL %>="+escape(""+document.forma.conditionSQL.value), "testCondSQLPopup", "width=450,height=180,location=no,menubar=no,toolbar=no,status=no,resizable=yes,scrollbars=yes");
57         w.focus();
58         w.opener = this;
59 }   // showTestConditionPopup
60         
61 function exclusiveCheckBox(which) {
62           var size = 2;
63           for (i=0; i<size; i++) {
64             if(document.getElementById("notify" + i) != which) {
65                 document.getElementById("notify" + i).checked = false;
66             } 
67           }
68           //alert("exclusive " + which.form.notify_type.value);
69 }       
70 function initFormFields() {
71
72         var requestStr = "<%=reportSchedule.getFormFields()%>";
73         //alert(requestStr);
74        if(requestStr.length > 0) {
75         SplitName = requestStr.substring(1,requestStr.length).split("&");
76         for (num = 0; num < SplitName.length; num++) {
77                         keyValue = SplitName[num].split("=");
78                         //alert(keyValue[0]+ " " + keyValue[1]);
79                         var obj = eval("document.forma."+keyValue[0]);
80                         if(obj) {
81                             if(obj.tagName == "SELECT") {
82                                         //var opt = document.getElementsByName(keyValue[0]);
83                                         var selString = "";
84                                         for (var intLoop=0; intLoop < obj.length; intLoop++) {
85                                                  if (obj[intLoop].value == keyValue[1]) {
86                                   obj[intLoop].selected=true; 
87                                   break;                                                    
88                                                  }
89                                         }
90                                                                         
91                             } else 
92                           document.getElementsByName(keyValue[0])[0].value = unescape(keyValue[1]);
93         }
94        }
95 }
96 }       
97 //-->
98 </script>
99 <script language="javascript" src="<%= AppUtils.getBaseFolderURL() %>js/other_scripts.js"></script>
100 <script type="text/javascript" src="<%= AppUtils.getBaseFolderURL() %>js/CalendarPopup.js"></script> 
101 <link rel="stylesheet" type="text/css" href="<%= AppUtils.getBaseFolderURL() %>css/calendar.css">
102  <iframe id="calendarFrame" class="nav" z-index:199; scrolling="no"  frameborder="0"  width=165px height=165px src="" style="position:absolute; display:none;">
103 </iframe>
104  <div id="calendarDiv" name="calendarDiv" style="position:absolute; z-index:20000; visibility:hidden; background-color:white;layer-background-color:white;"></div>
105  <%
106  Calendar startCalendarDate = Calendar.getInstance();
107  startCalendarDate.add(Calendar.DAY_OF_MONTH, - 540); 
108  Calendar endCalendarDate = Calendar.getInstance();
109  endCalendarDate.add(Calendar.DAY_OF_MONTH, 540);
110  SimpleDateFormat dtf = new SimpleDateFormat("MM/dd/yyyy");
111  SimpleDateFormat oracleDateFormat = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss");
112  Date sysdate = oracleDateFormat.parse(ReportLoader.getSystemDateTime());
113  SimpleDateFormat dtimestamp = new SimpleDateFormat(Globals.getScheduleDatePattern());
114  //dtimestamp.setTimeZone(TimeZone.getTimeZone(Globals.getTimeZone())); 
115  
116
117  
118          
119  %>
120
121         <SCRIPT LANGUAGE="JavaScript">
122         var oCalendar = new CalendarPopup("calendarDiv");
123         
124         oCalendar.addDisabledDates(null, "<%=dtf.format(startCalendarDate.getTime())%>");
125                 oCalendar.addDisabledDates("<%=dtf.format(endCalendarDate.getTime())%>", null);
126
127
128         oCalendar.setCssPrefix("raptor");
129         </SCRIPT>
130 <table class=mSDL width="100%"  class="tableBorder" border="0" cellspacing="1" cellpadding="3" align=center>
131    <% if(request.getAttribute("schedule_only")!=null) { %>
132         <tr>
133                 <td class=rbg1 colspan=2 valign="Middle"><b class=rtableheader>Step <%= ws.getCurrentStepIndex() %> of <%= ws.getStepCount() %> - Report <%= ws.getCurrentStep() %></b></td>
134         </tr>
135    <% } %>      
136         <tr>
137                 <td class=rbg1 colspan=2 valign="Middle"><b class=rtableheader><a href="javascript:uitmpl_qh('schedule_help')" class="qh-link"></a>Please enter Time in <%= Globals.getTimeZone()%>. The Current System Time is <%=dtimestamp.format(sysdate)%>&nbsp;<%=Globals.getTimeZone()%></b></td>
138         </tr>
139         <tr>
140                         <td colspan=2 class="nopad"><!-- quick help text -->
141                                 <div id="schedule_help" class="mQH">
142                                         <p><span class="label">Quick Help:</span>
143                                                 </p>
144                                 </div>
145                         <!-- /quick help text --></td>
146         </tr>   
147         
148         <tr>
149                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Schedule Emails: </font></td> 
150                 <td class=rbg3 align="left" width="50%" valign="middle" nowrap><font class=rtabletext>
151                         <input type='radio' name='schedEnabled' id='schedEnabled' value='Y' <%= reportSchedule.getSchedEnabled().equals("Y")?" checked":"" %> />Yes
152                         &nbsp;
153                         <input type='radio' name='schedEnabled' id='schedEnabled' value='N' <%= reportSchedule.getSchedEnabled().equals("N")?" checked":"" %> />No
154                         </font></td>
155         </tr> 
156         <tr>
157                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Email Attachment:</font></td> 
158                 <td class=rbg3 align="left" width="50%" valign="middle" nowrap>
159                         <font class=rtabletext>
160                         <input type='radio' name='notify' id='notify' value='2' <%= reportSchedule.getNotify_type().equals("2")?" checked":(reportSchedule.getNotify_type().length()<=0)?" checked":(!reportSchedule.getNotify_type().equals("4"))? " checked " :"" %> />PDF Attachment
161                         &nbsp;&nbsp;
162                         <input type='radio' name='notify' id='notify' value='4' <%= reportSchedule.getNotify_type().equals("4")?" checked":"" %> />Excel Attachment
163                         <input type='hidden' name='notify_type' value='1'/>
164                         </font>
165             </td>
166         </tr>
167         <tr>
168                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Recurrence: </font></td> 
169                 <td class=rbg3 align="left" width="50%"><font class=rtabletext>
170                         <select name="schedRecurrence">
171                                 <option value=""                                  <%= reportSchedule.getRecurrence().equals(""                         )?" selected":"" %>>One Time
172                                 <option value="<%= AppConstants.SR_HOURLY      %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_HOURLY     )?" selected":"" %>>Hourly
173                                 <option value="<%= AppConstants.SR_DAILY       %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_DAILY      )?" selected":"" %>>Daily
174                                 <option value="<%= AppConstants.SR_DAILY_MO_FR %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_DAILY_MO_FR)?" selected":"" %>>Daily Mo-Fr
175                                 <option value="<%= AppConstants.SR_WEEKLY      %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_WEEKLY     )?" selected":"" %>>Weekly
176                                 <option value="<%= AppConstants.SR_MONTHLY     %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_MONTHLY    )?" selected":"" %>>Monthly
177                         </select></font></td>
178         </tr>
179         <tr>
180                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Start Date: </font></td> 
181                 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>
182                         <input type="text" size="10" maxlength="10" name="schedStartDate" value="<%= reportSchedule.getStartDate() %>">
183                         <!--<a href="#" onClick="window.dateField = document.forma.schedStartDate;calendar = window.open('<%= AppUtils.getRaptorActionURL() %>popup.calendar','cal','WIDTH=200,HEIGHT=250');return false;">
184                                 <img src="<%= AppUtils.getImgFolderURL() %>calender_icon.gif" align=absmiddle border=0 width="20" height="20">
185                         </a>-->
186                         <img src="<%= AppUtils.getImgFolderURL() %>calender_icon.gif" align=absmiddle border=0 width="20" height="20" onClick="oCalendar.select(document.getElementById('schedStartDate'),event,'MM/dd/yyyy'); return false;"  style="cursor:hand">
187                         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
188                         <select name="schedHour">
189                                 <option value="01"<%= reportSchedule.getRunHour().equals("01")?" selected":"" %>>1
190                                 <option value="02"<%= reportSchedule.getRunHour().equals("02")?" selected":"" %>>2
191                                 <option value="03"<%= reportSchedule.getRunHour().equals("03")?" selected":"" %>>3
192                                 <option value="04"<%= reportSchedule.getRunHour().equals("04")?" selected":"" %>>4
193                                 <option value="05"<%= reportSchedule.getRunHour().equals("05")?" selected":"" %>>5
194                                 <option value="06"<%= reportSchedule.getRunHour().equals("06")?" selected":"" %>>6
195                                 <option value="07"<%= reportSchedule.getRunHour().equals("07")?" selected":"" %>>7
196                                 <option value="08"<%= reportSchedule.getRunHour().equals("08")?" selected":"" %>>8
197                                 <option value="09"<%= reportSchedule.getRunHour().equals("09")?" selected":"" %>>9
198                                 <option value="10"<%= reportSchedule.getRunHour().equals("10")?" selected":"" %>>10
199                                 <option value="11"<%= reportSchedule.getRunHour().equals("11")?" selected":"" %>>11
200                                 <option value="12"<%= reportSchedule.getRunHour().equals("12")?" selected":"" %>>12
201                         </select>
202                         <select name="schedMin">
203                                 <option value="00"<%= reportSchedule.getRunMin().equals("00")?" selected":"" %>>00
204                                 <option value="15"<%= reportSchedule.getRunMin().equals("15")?" selected":"" %>>15
205                                 <option value="30"<%= reportSchedule.getRunMin().equals("30")?" selected":"" %>>30
206                                 <option value="45"<%= reportSchedule.getRunMin().equals("45")?" selected":"" %>>45
207                         </select>
208                         <select name="schedAMPM">
209                                 <option value="AM"<%= reportSchedule.getRunAMPM().equals("AM")?" selected":"" %>>AM
210                                 <option value="PM"<%= reportSchedule.getRunAMPM().equals("PM")?" selected":"" %>>PM
211                         </select>
212                         
213                         </font></td>
214         </tr> 
215         <tr>
216                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>End Date: </font></td> 
217                 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>
218                         <input type="text" size="10" maxlength="10" name="schedEndDate" value="<%= reportSchedule.getEndDate() %>">
219                         <!--<a href="#" onClick="window.dateField = document.forma.schedEndDate;calendar = window.open('<%= AppUtils.getRaptorActionURL() %>popup.calendar','cal','WIDTH=200,HEIGHT=250');return false;">
220                                 <img src="<%= AppUtils.getImgFolderURL() %>calender_icon.gif" align=absmiddle border=0 width="20" height="20">
221                         </a>-->
222                         <img src="<%= AppUtils.getImgFolderURL() %>calender_icon.gif" align=absmiddle border=0 width="20" height="20" onClick="oCalendar.select(document.getElementById('schedEndDate'),event,'MM/dd/yyyy'); return false;"  style="cursor:hand">
223                         </font></td>
224         </tr>
225
226         <% if(AppUtils.isAdminUser(request) || isSQLAllowed ) { %>
227         <tr>
228                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Use Condition:</font></td> 
229                 <td class=rbg3 align="left" width="50%" valign="middle" nowrap><font class=rtabletext>
230                         <input type="checkbox" name="conditional" value="Y"<%= reportSchedule.getConditional().equals("Y")?" checked":"" %>> Send Emails Only When Condition Is Met
231                         </font></td>
232         </tr> 
233         <tr>
234                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Condition SQL:</font></td> 
235                 <td class=rbg3 align="left" width="50%" valign="middle" nowrap><font class=rtabletext>SELECT 1 FROM DUAL WHERE EXISTS (<br>
236                         <textarea name="conditionSQL" cols="40" rows="3"><%= nvl(reportSchedule.getConditionSQL()) %></textarea>
237                         )
238                         &nbsp;&nbsp;&nbsp;&nbsp;
239                         <input type="Button" class=button value="Test" onClick="showTestConditionPopup()">
240                         &nbsp;
241                         </font></td>
242         </tr>
243         <% } %>         
244
245         <tr>
246                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Max rows in attachment:</font></td> 
247                 <td class=rbg3 align="left" width="50%" valign="middle" nowrap>
248                         <input type='text' name='downloadLimit' value="<%=reportSchedule.getDownloadLimit()%>" size='4'/>
249            </td>
250         </tr>                   
251         
252         <jsp:include page="wizard_schedule_formfield_include.jsp" flush="true" />
253         <script type="text/javascript">initFormFields();</script>       
254         
255 <%      List emailToUsers = reportSchedule.getEmailToUsers();
256         for(int i=0; i<emailToUsers.size(); i++) { 
257                 IdNameValue userValue = (IdNameValue) emailToUsers.get(i); %>
258         <tr>
259                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext><%= (i==0)?"Email To: ":"&nbsp;" %></font></td> 
260                 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>
261                         <%= userValue.getName() %>
262                         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
263                         <input type=image border="0" src="<%= AppUtils.getImgFolderURL() %>deleteicon.gif" alt="Remove" width="12" height="12" onClick="if(! dataValidate()) {return false;} else if(! confirm('Are you sure?')) {return false;} else {document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_DELETE_USER %>'; document.forma.<%= AppConstants.RI_DETAIL_ID %>.value='<%= userValue.getId() %>'; }">
264                         </font></td>
265         </tr>
266 <%      }       // for 
267         List emailToRoles = reportSchedule.getEmailToRoles();
268         for(int i=0; i<emailToRoles.size(); i++) { 
269                 IdNameValue roleValue = (IdNameValue) emailToRoles.get(i); %>
270         <tr>
271                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext><%= (emailToUsers.size()==0&&i==0)?"Email To: ":"&nbsp;" %></font></td> 
272                 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>Everyone With Role:&nbsp;
273                         <%= roleValue.getName() %>
274                         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
275                         <input type=image border="0" src="<%= AppUtils.getImgFolderURL() %>deleteicon.gif" alt="Remove" width="12" height="12" onClick="if(! dataValidate()) {return false;} else if(! confirm('Are you sure?')) {return false;} else {document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_DELETE_ROLE %>'; document.forma.<%= AppConstants.RI_DETAIL_ID %>.value='<%= roleValue.getId() %>'; }">
276                         </font></td>
277         </tr>
278 <%      }       // for 
279         
280         Vector remainingUsers = Utils.getUsersNotInList(emailToUsers,request);
281         Vector remainingRoles = Utils.getRolesNotInList(emailToRoles,request);
282         if((emailToUsers.size()+emailToRoles.size()==0)||(remainingUsers.size()>0)||(remainingRoles.size()>0)) { %>
283         <tr>
284                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext><%= (emailToUsers.size()+emailToRoles.size()==0)?"Email To: ":"&nbsp;" %></font></td> 
285                 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>
286 <%              if(remainingUsers.size()>0) { %>
287                         <select name="schedEmailAdd" onChange="if(! dataValidate()) {selectedIndex=0;} else {document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_ADD_USER %>'; document.forma.submit();}">
288                             <option value="" selected>--- Select User ---
289 <%                      for(int i=0; i<remainingUsers.size(); i++) {
290                                 IdNameValue userValue = (IdNameValue) remainingUsers.get(i); %>
291                             <option value="<%= userValue.getId() %>"><%= userValue.getName() %>
292 <%                      }       // for %>
293                         </select>
294 <%              } else { %>
295                         No user emails available
296 <%              } %>
297                         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
298 <%              if(remainingRoles.size()>0) { %>
299                         <select name="schedEmailAddRole" onChange="if(! dataValidate()) {selectedIndex=0;} else {document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_ADD_ROLE %>'; document.forma.submit();}">
300                             <option value="" selected>--- Select Role ---
301 <%                      for(int i=0; i<remainingRoles.size(); i++) {
302                                 IdNameValue roleValue = (IdNameValue) remainingRoles.get(i); %>
303                             <option value="<%= roleValue.getId() %>"><%= roleValue.getName() %>
304 <%                      }       // for %>
305                         </select>
306 <%              } else { %>
307                         No roles available
308 <%              } %>
309                 </font></td>
310         </tr>
311 <%      }       // if 
312 %>
313 </table>
314 <br>
315
316 <script language="JavaScript">
317 <!--
318 function dataValidate() {
319         if(! checkDate(document.forma.schedStartDate.value, true)) {
320                 alert("Invalid Start Date. The date format should be MM/DD/YYYY");
321                 document.forma.schedStartDate.focus();
322                 document.forma.schedStartDate.select();
323                 return false;
324         }
325         if(! checkDate(document.forma.schedEndDate.value, true)) {
326                 alert("Invalid End Date. The date format should be MM/DD/YYYY");
327                 document.forma.schedEndDate.focus();
328                 document.forma.schedEndDate.select();
329                 return false;
330         }
331         /*if(! checkDate(document.forma.schedRunDate.value, true)) {
332                 alert("Invalid Execution Date. The date format should be MM/DD/YYYY");
333                 document.forma.schedRunDate.focus();
334                 document.forma.schedRunDate.select();
335                 return false;
336         }*/
337 <% if (AppUtils.isAdminUser(request) || isSQLAllowed){ %>
338         if(document.forma.conditional.checked&&document.forma.conditionSQL.value=="") {
339                 alert("Please provide Condition SQL");
340                 document.forma.conditionSQL.focus();
341                 document.forma.conditionSQL.select();
342                 return false;
343         }
344   <% } %>
345         if(! checkNonNegativeInteger(document.forma.downloadLimit.value)) {
346                 alert("Max row in attachment is not a valid integer.\nPlease enter a valid value.");
347                 document.forma.downloadLimit.focus();
348                 document.forma.downloadLimit.select();
349                 return false;
350         }
351         else 
352         {
353                 if((document.forma.downloadLimit.value) > <%=Globals.getDownloadLimit()%>) {
354                         alert("Max row you can download should not be more than <%=Globals.getDownloadLimit()%> rows.\nPlease enter a valid value.");
355                         document.forma.downloadLimit.focus();
356                         document.forma.downloadLimit.select();
357                         return false;                   
358                 }
359                 
360         }
361         for (var i=0; i < document.forma.notify.length; i++) {
362                 if (document.forma.notify[i].checked) {
363                   document.forma.notify_type.value = document.forma.notify[i].value;
364                 }
365             } 
366         return validateForm();
367                 
368         return true;
369 }   // dataValidate
370 //-->
371 </script>
372
373 <%!
374         private String nvl(String s)                  { return (s==null)?"":s; }
375         private String nvl(String s, String sDefault) { return nvl(s).equals("")?sDefault:s; } 
376 %>