Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / WEB-INF / fusion / raptor / wizard_adhoc_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 <%--
21  Name: wizard_adhoc_schedule.jsp
22  Use : This JSP is used for accepting user parameters for scheduling the report.
23  
24  Change Log
25  ==========
26  
27  28-Aug-2009 : Version 8.4 (Sundar);  initFormFields function is removed as it is handled in back end.
28  23-Jun-2009 : Version 8.4 (Sundar); 
29                                 
30                                 <UL> 
31                                 <LI> Bug related to creating startDate variable (in Javascript) for the Validation purpose is fixed.</LI>
32                                 </UL>
33                                          
34
35 --%>
36
37 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.DataColumnType" %>
38 <%@ page import="org.openecomp.portalsdk.analytics.util.AppConstants" %>
39 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.ReportDefinition" %>
40 <%@ page import="org.openecomp.portalsdk.analytics.system.AppUtils" %>
41 <%@ page import="org.openecomp.portalsdk.analytics.system.Globals" %>
42 <%@ page import="org.openecomp.portalsdk.analytics.controller.WizardSequence" %>
43 <%@ page import="java.util.Vector" %>
44 <%@ page import="java.util.List" %>
45 <%@ page import="org.openecomp.portalsdk.analytics.model.DataCache" %>
46 <%@ page import="java.util.Iterator" %>
47 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.DataSourceType" %>
48 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.DBColumnInfo" %>
49 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.TableSource" %>
50 <%@ page import="org.openecomp.portalsdk.analytics.model.base.IdNameValue" %>
51 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.SemaphoreType" %>
52 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.FormFieldType" %>
53 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.ReportSchedule" %>
54 <%@ page import="org.openecomp.portalsdk.analytics.util.Utils" %>
55
56 <% 
57   ReportSchedule reportSchedule = (ReportSchedule) request.getSession().getAttribute(AppConstants.SI_REPORT_SCHEDULE);
58   ReportDefinition rdefRecurrance = (ReportDefinition) request.getAttribute(AppConstants.SI_REPORT_DEFINITION);
59   session.setAttribute("login_id", AppUtils.getUserBackdoorLoginId(request));
60   if(reportSchedule==null) reportSchedule = (ReportSchedule) request.getAttribute(AppConstants.SI_REPORT_SCHEDULE);
61   String remoteDbPrefix = (String) session.getAttribute("remoteDB");
62   boolean isSQLAllowed = Globals.getAllowSQLBasedReports();
63 %>
64 <%@page import="java.util.Calendar"%>
65 <%@page import="java.text.DateFormat"%>
66 <%@page import="java.text.SimpleDateFormat"%>
67 <%@page import="java.util.TimeZone"%>
68 <%@page import="java.util.Date"%>
69 <%@page import="org.openecomp.portalsdk.analytics.model.ReportLoader"%>
70 <script language="JavaScript">
71 <!--
72 function showTestConditionPopup() {
73         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");
74         w.focus();
75         w.opener = this;
76 }   // showTestConditionPopup
77         
78 function exclusiveCheckBox(which) {
79           var size = 2;
80           for (i=0; i<size; i++) {
81             if(document.getElementById("notify" + i) != which) {
82                 document.getElementById("notify" + i).checked = false;
83             } 
84           }
85           //alert("exclusive " + which.form.notify_type.value);
86 }       
87 //-->
88 </script>
89 <script language="javascript" src="<%= AppUtils.getBaseFolderURL() %>js/other_scripts.js"></script>
90 <script type="text/javascript" src="<%= AppUtils.getBaseFolderURL() %>js/CalendarPopup.js"></script> 
91 <script language="JavaScript" src="<%= AppUtils.getBaseFolderURL() %>js/rounded-corners.js"></script>
92 <script language="JavaScript" src="<%= AppUtils.getBaseFolderURL() %>js/form-field-tooltip.js"></script>
93 <link rel="stylesheet" type="text/css" href="<%= AppUtils.getBaseFolderURL() %>css/calendar.css">
94
95         <script type="text/javascript">
96 var stat;
97 var delay=0;//delay in milliseconds
98 function show(){
99
100
101 var oIfr = document.getElementById('calendarFrame');
102 var oCal = document.getElementById('calendarDiv');
103 oIfr.style.display=(oCal.style.display=='block')?'none':'block';
104 oIfr.style.top=findPosY()
105 oIfr.style.left=findPosX()-5
106
107 }
108 function hide(){
109
110 // added to show Iframe behind calender
111 var oIfr = document.getElementById('calendarFrame');
112 var oCal = document.getElementById('calendarDiv');
113 oIfr.style.display=(oCal.style.display=='none')?'block':'none';
114 }
115
116   function findPosX()
117   {
118  var obj= oCalendar
119     var curleft = 0;
120     if(obj.offsetParent)
121         while(1) 
122         {
123           curleft += obj.offsetLeft;
124           if(!obj.offsetParent)
125             break;
126           obj = obj.offsetParent;
127         }
128     else if(obj.x)
129         curleft += obj.x;
130     return curleft;
131     
132   }
133
134   function findPosY()
135   {
136   
137    var obj= oCalendar
138     var curtop = 0;
139     if(obj.offsetParent)
140         while(1)
141         {
142           curtop += obj.offsetTop;
143           if(!obj.offsetParent)
144             break;
145           obj = obj.offsetParent;
146         }
147     else if(obj.y)
148         curtop += obj.y;
149         //alert(curtop)
150     return curtop;   
151   }
152   
153   //frameborder="0" 
154         </SCRIPT>
155
156 <iframe id="calendarFrame" class="nav" z-index:199; scrolling="no"  frameborder="0"  width=165px height=165px src="" style="position:absolute; display:none;">
157 </iframe>
158
159  <div id="calendarDiv" name="calendarDiv" style="position:absolute; z-index:200; visibility:none; background-color:white;layer-background-color:white;"></div>
160  <%
161  Calendar startCalendarDate = Calendar.getInstance();
162  startCalendarDate.add(Calendar.DAY_OF_MONTH, - 540); 
163  Calendar endCalendarDate = Calendar.getInstance();
164  endCalendarDate.add(Calendar.DAY_OF_MONTH, 540);
165  SimpleDateFormat dtf = new SimpleDateFormat("MM/dd/yyyy");
166  SimpleDateFormat oracleDateFormat = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss");
167  Date sysdate = oracleDateFormat.parse(ReportLoader.getSystemDateTime());
168  SimpleDateFormat dtimestamp = new SimpleDateFormat(Globals.getScheduleDatePattern());
169  Calendar systemCalendar = Calendar.getInstance();
170  systemCalendar.setTime(sysdate);
171  Date sysNext15date = oracleDateFormat.parse(ReportLoader.getNext15MinutesOfSystemDateTime());
172  //dtimestamp = new SimpleDateFormat(Globals.getScheduleDatePattern());
173  Calendar systemNext15Calendar = Calendar.getInstance();
174  systemNext15Calendar.setTime(sysNext15date);
175  Date sysNext30date = oracleDateFormat.parse(ReportLoader.getNext30MinutesOfSystemDateTime());
176  //dtimestamp = new SimpleDateFormat(Globals.getScheduleDatePattern());
177  Calendar systemNext30Calendar = Calendar.getInstance();
178  systemNext30Calendar.setTime(sysNext30date);
179
180  System.out.println(" systemNext15Calendar " + systemNext15Calendar);
181  System.out.println(" systemNext30Calendar " + systemNext30Calendar);
182
183  //dtimestamp.setTimeZone(TimeZone.getTimeZone(Globals.getTimeZone()));
184  
185 %>
186
187  
188          
189
190         <SCRIPT LANGUAGE="JavaScript">
191         var oCalendar = new CalendarPopup("calendarDiv", "calendarFrame");
192         
193         oCalendar.addDisabledDates(null, "<%=dtf.format(startCalendarDate.getTime())%>");
194                 oCalendar.addDisabledDates("<%=dtf.format(endCalendarDate.getTime())%>", null);
195
196
197         oCalendar.setCssPrefix("raptor");
198
199         function fillStartEndDate(varSelect) {
200                 var flag = 0;
201                 <% if(!(nvl(reportSchedule.getStartDate()).length() > 0)) { %>
202                 a:
203                          for (var i = 0; i < varSelect.options.length; i++) {
204                                         if (varSelect.options[ i ].selected) {
205                                             if(!(varSelect.options[i].value.length > 0)) {
206                                                     var d = new Date();
207                                                     //alert(d.getMonth() + " " + d.getDate() + " " + d.getYear());
208                                                     //alert(d.getMonth()+1+"/"+d.getDate()+"/"+d.getYear());
209                                                 document.forma.schedStartDate.value = addZero(d.getMonth()+1)+"/"+addZero(d.getDate())+"/"+addZero(d.getYear());
210                                                 document.forma.schedEndDate.value = addZero(d.getMonth()+1)+"/"+addZero(d.getDate())+"/"+addZero(d.getYear());
211                                                 //alert(document.forma.schedStartDate.value);
212                                                 flag = 1;
213                                                 break a;
214                                             } 
215                                         }
216                          } 
217                          if(flag == 0) {
218                                 //alert("Here");
219                                 document.forma.schedStartDate.value = "";
220                                 document.forma.schedEndDate.value = "";
221                          }
222                          <% } %>
223         }
224
225         function initStartEndDate() { 
226                 var flag = 0;
227                 var varSelect = document.forma.schedRecurrence;
228                 var d = new Date();
229                 var d_end = null;
230                 d.setFullYear(<%=systemCalendar.get(Calendar.YEAR)%>, <%=systemCalendar.get(Calendar.MONTH)%>,<%=systemCalendar.get(Calendar.DAY_OF_MONTH)%>);
231                 d.setHours(<%=systemCalendar.get(Calendar.HOUR_OF_DAY)%>);
232                 d.setMinutes(<%=systemCalendar.get(Calendar.MINUTE)%>);
233                 d.setSeconds(<%=systemCalendar.get(Calendar.SECOND)%>);
234                 d_end = new Date();
235                 d_end.setFullYear(<%=systemNext15Calendar.get(Calendar.YEAR)%>, <%=systemNext15Calendar.get(Calendar.MONTH)%>,<%=systemNext15Calendar.get(Calendar.DAY_OF_MONTH)%>);
236                 d_end.setHours(<%=23%>);
237                 d_end.setMinutes(<%=45%>);
238                 d_end.setSeconds(<%=systemNext15Calendar.get(Calendar.SECOND)%>);
239
240                 if(d.getHours() == 23 && d.getMinutes()>=30) {
241                 d_end.setFullYear(<%=systemNext30Calendar.get(Calendar.YEAR)%>, <%=systemNext30Calendar.get(Calendar.MONTH)%>,<%=systemNext30Calendar.get(Calendar.DAY_OF_MONTH)%>);
242                 d_end.setHours(<%=23%>);
243                 d_end.setMinutes(<%=45%>);
244                 d_end.setSeconds(<%=systemNext30Calendar.get(Calendar.SECOND)%>);
245                         document.forma.schedEndDate.value = addZero(d_end.getMonth()+1)+"/"+addZero(d_end.getDate())+"/"+addZero(d_end.getYear());
246                         var obj = document.forma.schedEndHour;
247                         var hr = d_end.getHours();
248                                 //alert("end hr " + hr);
249                         //if(d_end.getMinutes()>=45) 
250                             //  hr = hr + 1;
251                         if(hr > 12) hr = hr - 12; 
252                         if(hr == 0) hr = 12;
253                                 for (var i=0; i<obj.options.length; i++) {
254                                         if (eval(obj.options[i].value) == hr) {
255                                                 obj.options[i].selected = true;
256                                                 break;
257                                         } 
258                                 }
259                                 var obj1 = document.forma.schedEndMin;
260                                 for (var i=0; i<obj1.options.length; i++) {
261                                         if (d_end.getMinutes() <= eval(obj1.options[i].value)) {
262                                                 obj1.options[i].selected = true;
263                                                 break;
264                                         } 
265                                 }
266                                 var obj2 = document.forma.schedEndAMPM;
267                                 
268                                 for (var i=0; i<obj2.options.length; i++) {
269                                         if (d_end.getHours() < 12 && obj2.options[i].value == 'AM') {
270                                                 obj2.options[i].selected = true;
271                                         } else if (d_end.getHours() >= 12 && obj2.options[i].value == 'PM')
272                                                 obj2.options[i].selected = true;
273                                 }
274                         
275                 }
276                 
277                 
278                       <% if(!(nvl(reportSchedule.getStartDate()).length() > 0)) { %>
279                         
280                                                     //alert(d.getMonth() + " " + d.getDate() + " " + d.getYear());
281                                                     //alert(d.getMonth()+1+"/"+d.getDate()+"/"+d.getYear());
282                                                         //alert(d.getHours());
283                                                     <%-- System.out.println(reportSchedule.getStartDate());
284                                                        if(!(nvl(reportSchedule.getStartDate()).length() > 0)) { --%>
285                                                             if(d.getHours() == 23 && d.getMinutes() > 45) {
286                                                                         //d.setDate(d.getDate() + 1);
287                                                                 document.forma.schedStartDate.value = addZero(d.getMonth()+1)+"/"+addZero(d.getDate()+1)+"/"+addZero(d.getYear());
288                                                                 }
289                                                                 else
290                                                         document.forma.schedStartDate.value = addZero(d.getMonth()+1)+"/"+addZero(d.getDate())+"/"+addZero(d.getYear());
291                                                         //document.forma.schedEndDate.value = addZero(d.getMonth()+1)+"/"+addZero(d.getDate())+"/"+addZero(d.getYear());
292                                                         document.forma.schedEndDate.value = addZero(d_end.getMonth()+1)+"/"+addZero(d_end.getDate())+"/"+addZero(d_end.getYear());
293
294                                                         var obj = document.forma.schedHour;
295                                                         var hr = d.getHours();
296                                                         if(d.getMinutes()>=45) 
297                                                                 hr = hr + 1;
298                                                         if(hr > 12) hr = hr - 12; 
299                                                         if(hr == 0) hr = 12;
300                                                                 for (var i=0; i<obj.options.length; i++) {
301                                                                         if (eval(obj.options[i].value) == hr) {
302                                                                                 obj.options[i].selected = true;
303                                                                                 break;
304                                                                         } 
305                                                                 }
306                                                                 var obj1 = document.forma.schedMin;
307                                                                 for (var i=0; i<obj1.options.length; i++) {
308                                                                         if (d.getMinutes() <= eval(obj1.options[i].value)) {
309                                                                                 obj1.options[i].selected = true;
310                                                                                 break;
311                                                                         } 
312                                                                 }
313                                                                 var obj2 = document.forma.schedAMPM;
314                                                                 
315                                                                 for (var i=0; i<obj2.options.length; i++) {
316                                                                  //alert(d.getHours() + " " + d.getMinutes());
317                                                                 if(d.getHours() == 23 && d.getMinutes() >= 45) { 
318                                                                     if(obj2.options[i].value == 'AM') {
319                                                                                 //alert("hello");
320                                                                                 obj2.options[i].selected = true;
321                                                                         }
322                                                                 } else {
323                                                                    //alert("hello2");
324                                                                         if ((d.getHours() < 12) && obj2.options[i].value == 'AM') {
325                                                                                 obj2.options[i].selected = true;
326                                                                         } else if ((d.getHours() >= 12)  && obj2.options[i].value == 'PM') {
327                                                                                 obj2.options[i].selected = true;
328                                                                 }
329                                                                 }
330                                                         }
331                                                                 
332                                                 
333                                                         
334                          <% }  %>
335         }       
336         
337         function addZero(num) {
338                 var numInt = 0;
339                 numInt = num;
340                 if(numInt < 10) {
341                 return "0"+numInt;
342                 }
343                 else return ""+numInt;
344         }               
345         </SCRIPT>
346 <table width="100%" border="0" cellspacing="1" cellpadding="3" align=center>
347         <tr class="rbg1">
348                 <td class=rbg1 colspan="2" align="left">
349                 <%if(nvl(Globals.getScheduleHelpMessage()).trim().length()>0) { %>
350                         <a href="javascript:uitmpl_qh('sch_help_text'); if(typeof window.parent.resizeWindow == 'function') window.parent.resizeWindow();" class="qh-link" style="position:fixed;"></a>
351                 <% } %>
352                 <b class=rtableheader>Please enter Time in <%= Globals.getTimeZone()%>. The Current System Time is <%=dtimestamp.format(sysdate)%>&nbsp;<%=Globals.getTimeZone()%></b>
353               </td>
354               
355         </tr>   
356         
357         <%if(nvl(Globals.getScheduleHelpMessage()).length()>0) {        %>
358            <tr>
359                 <td colspan="2" class="nopad"><!-- quick help text -->
360                 <div id="sch_help_text" class="mQH">
361                         <p><span class="label">Report Desc:</span>
362                         <%= Globals.getScheduleHelpMessage() %></p>
363                 </div>
364                 <!-- /quick help text --></td>          
365            </tr>
366         <% } %> 
367         
368         <tr>
369                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Schedule Emails: </font></td> 
370                 <td class=rbg3 align="left" width="50%" valign="middle" nowrap><font class=rtabletext>
371                         <input type='radio' name='schedEnabled' id='schedEnabled' value='Y' <%= reportSchedule.getSchedEnabled().equals("Y")?" checked":"" %> toolTipText="This is used for the enabling or disabling the scheduling feature for this report."/>Yes
372                         &nbsp;
373                         <input type='radio' name='schedEnabled' id='schedEnabled' value='N' <%= reportSchedule.getSchedEnabled().equals("N")?" checked":"" %> toolTipText="This is used for the enabling or disabling the scheduling feature for this report."/>No
374                         </font>
375                 </td>
376         </tr>
377         <tr>
378                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Email Attachment:</font></td> 
379                 <td class=rbg3 align="left" width="50%" valign="middle" nowrap>
380                         <font class=rtabletext>
381                         <%if(!rdefRecurrance.getReportType().equals(AppConstants.RT_HIVE)) {%>
382                         <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 " :"" %> toolTipText="Provides the capability to attach reports as PDF format to the email."/>PDF Attachment
383                         &nbsp;&nbsp;
384                         <input type='radio' name='notify' id='notify' value='4' <%= reportSchedule.getNotify_type().equals("4")?" checked":"" %> toolTipText="Provides the capability to attach reports as Excel format to the email."/>Excel Attachment
385                         &nbsp;&nbsp;
386                         <% } %>
387                         <input type='radio' name='notify' id='notify' value='5' <%= reportSchedule.getNotify_type().equals("5")?" checked":"" %> toolTipText="Provides the capability to attach reports as Excel format to the email."/>Excelx Attachment
388                         &nbsp;&nbsp;
389                         <input type='radio' name='notify' id='notify' value='3' <%= reportSchedule.getNotify_type().equals("3")?" checked":"" %> toolTipText="Provides the capability to attach reports as CSV format to the email."/>CSV Attachment
390                         <%if(!rdefRecurrance.getReportType().equals(AppConstants.RT_HIVE)) {%>
391                  <% if(nvl(Globals.getShellScriptDir()).length()>1) { %>
392                          <input type='radio' name='notify' id='notify' value='6' <%= reportSchedule.getNotify_type().equals("6")?" checked":"" %> toolTipText="Provides the capability to send only links to the generated report in the email."/>Link to Generated report
393                  <% }  %>        
394                          <% } %>
395                         <input type='hidden' name='notify_type' value='1'/>
396                         </font>
397             </td>
398         </tr>
399         <tr>
400                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Recurrence: </font></td> 
401                 <td class=rbg3 align="left" width="50%"><font class=rtabletext>
402                         <select name="schedRecurrence" toolTipText="This is used to select recurrence frequency.">
403                                 <%if (rdefRecurrance.getIsOneTimeScheduleAllowed() == null || rdefRecurrance.getIsOneTimeScheduleAllowed().equals("Y")){ %><option value=""                                  <%= reportSchedule.getRecurrence().equals(""                         )?" selected":"" %>>One Time<%} %>
404                                 <%if (rdefRecurrance.getIsHourlyScheduleAllowed() == null || rdefRecurrance.getIsHourlyScheduleAllowed().equals("Y")){ %><option value="<%= AppConstants.SR_HOURLY      %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_HOURLY     )?" selected":"" %>>Hourly<%} %>
405                                 <%if (rdefRecurrance.getIsDailyScheduleAllowed() == null || rdefRecurrance.getIsDailyScheduleAllowed().equals("Y")){ %><option value="<%= AppConstants.SR_DAILY       %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_DAILY      )?" selected":"" %>>Daily<%} %>
406                                 <%if (rdefRecurrance.getIsDailyMFScheduleAllowed() == null || rdefRecurrance.getIsDailyMFScheduleAllowed().equals("Y")){ %><option value="<%= AppConstants.SR_DAILY_MO_FR %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_DAILY_MO_FR)?" selected":"" %>>Daily Mo-Fr<%} %>
407                                 <%if (rdefRecurrance.getIsWeeklyScheduleAllowed() == null || rdefRecurrance.getIsWeeklyScheduleAllowed().equals("Y")){ %><option value="<%= AppConstants.SR_WEEKLY      %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_WEEKLY     )?" selected":"" %>>Weekly<%} %>
408                                 <%if (rdefRecurrance.getIsMonthlyScheduleAllowed() == null || rdefRecurrance.getIsMonthlyScheduleAllowed().equals("Y")){ %><option value="<%= AppConstants.SR_MONTHLY     %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_MONTHLY    )?" selected":"" %>>Monthly<%} %>
409                         </select></font>
410           </td>
411         </tr>
412         <tr>
413                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>First Schedule Date: </font></td> 
414                 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>
415                         <input type="text" size="10" maxlength="10" name="schedStartDate" value="<%= reportSchedule.getStartDate() %>" toolTipText="Enter the date and time scheduling is to start.">
416                         <!--<a href="#" onClick="window.dateField = document.forma.schedStartDate;calendar = window.open('<%= AppUtils.getRaptorActionURL() %>popup.calendar','cal','WIDTH=200,HEIGHT=250');return false;">
417                                 <img src="<%= AppUtils.getImgFolderURL() %>calender_icon.gif" align=absmiddle border=0 width="20" height="20">
418                         </a>-->
419                         <img src="<%= AppUtils.getImgFolderURL() %>calender_icon.gif" align=absmiddle border=0 width="20" height="20" onClick="oCalendar = new CalendarPopup('calendarDiv', 'calendarFrame');oCalendar.addDisabledDates(null, '<%=dtf.format(startCalendarDate.getTime())%>');oCalendar.addDisabledDates('<%=dtf.format(endCalendarDate.getTime())%>', null);oCalendar.setCssPrefix('raptor');oCalendar.select(document.getElementById('schedStartDate'),event,'MM/dd/yyyy'); return false;"  style="cursor:hand">
420                         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
421                         <select name="schedHour">
422                                 <option value="01"<%= reportSchedule.getRunHour().equals("01")?" selected":"" %>>1
423                                 <option value="02"<%= reportSchedule.getRunHour().equals("02")?" selected":"" %>>2
424                                 <option value="03"<%= reportSchedule.getRunHour().equals("03")?" selected":"" %>>3
425                                 <option value="04"<%= reportSchedule.getRunHour().equals("04")?" selected":"" %>>4
426                                 <option value="05"<%= reportSchedule.getRunHour().equals("05")?" selected":"" %>>5
427                                 <option value="06"<%= reportSchedule.getRunHour().equals("06")?" selected":"" %>>6
428                                 <option value="07"<%= reportSchedule.getRunHour().equals("07")?" selected":"" %>>7
429                                 <option value="08"<%= reportSchedule.getRunHour().equals("08")?" selected":"" %>>8
430                                 <option value="09"<%= reportSchedule.getRunHour().equals("09")?" selected":"" %>>9
431                                 <option value="10"<%= reportSchedule.getRunHour().equals("10")?" selected":"" %>>10
432                                 <option value="11"<%= reportSchedule.getRunHour().equals("11")?" selected":"" %>>11
433                                 <option value="12"<%= reportSchedule.getRunHour().equals("12")?" selected":"" %>>12
434                         </select>
435                         <select name="schedMin">
436                                 <option value="00"<%= reportSchedule.getRunMin().equals("00")?" selected":"" %>>00
437                                 <option value="15"<%= reportSchedule.getRunMin().equals("15")?" selected":"" %>>15
438                                 <option value="30"<%= reportSchedule.getRunMin().equals("30")?" selected":"" %>>30
439                                 <option value="45"<%= reportSchedule.getRunMin().equals("45")?" selected":"" %>>45
440                         </select>
441                         <select name="schedAMPM">
442                                 <option value="AM"<%= reportSchedule.getRunAMPM().equals("AM")?" selected":"" %>>AM
443                                 <option value="PM"<%= reportSchedule.getRunAMPM().equals("PM")?" selected":"" %>>PM
444                         </select>
445             <%= Globals.getTimeZone()%>
446
447                         </font>
448                 </td>
449         </tr>
450 <!-- /quick help text -->                               
451         <tr>
452                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Last Schedule Date: </font></td> 
453                 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>
454                         <input type="text" size="10" maxlength="10" name="schedEndDate" value="<%= reportSchedule.getEndDate() %>" toolTipText="Enter the date scheduling is to end. This is mandatory for recurring reports.">
455                         <!--<a href="#" onClick="window.dateField = document.forma.schedEndDate;calendar = window.open('<%= AppUtils.getRaptorActionURL() %>popup.calendar','cal','WIDTH=200,HEIGHT=250');return false;">
456                                 <img src="<%= AppUtils.getImgFolderURL() %>calender_icon.gif" align=absmiddle border=0 width="20" height="20">
457                         </a>-->
458                         <img src="<%= AppUtils.getImgFolderURL() %>calender_icon.gif" align=absmiddle border=0 width="20" height="20" onClick="oCalendar = new CalendarPopup('calendarDiv', 'calendarFrame');oCalendar.addDisabledDates(null, '<%=dtf.format(startCalendarDate.getTime())%>');oCalendar.addDisabledDates('<%=dtf.format(endCalendarDate.getTime())%>', null);oCalendar.setCssPrefix('raptor');oCalendar.select(document.getElementById('schedEndDate'),event,'MM/dd/yyyy'); return false;"  style="cursor:hand">
459                         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
460                         <select name="schedEndHour">
461                                 <option value="01"<%= reportSchedule.getEndHour().equals("01")?" selected":"" %>>1
462                                 <option value="02"<%= reportSchedule.getEndHour().equals("02")?" selected":"" %>>2
463                                 <option value="03"<%= reportSchedule.getEndHour().equals("03")?" selected":"" %>>3
464                                 <option value="04"<%= reportSchedule.getEndHour().equals("04")?" selected":"" %>>4
465                                 <option value="05"<%= reportSchedule.getEndHour().equals("05")?" selected":"" %>>5
466                                 <option value="06"<%= reportSchedule.getEndHour().equals("06")?" selected":"" %>>6
467                                 <option value="07"<%= reportSchedule.getEndHour().equals("07")?" selected":"" %>>7
468                                 <option value="08"<%= reportSchedule.getEndHour().equals("08")?" selected":"" %>>8
469                                 <option value="09"<%= reportSchedule.getEndHour().equals("09")?" selected":"" %>>9
470                                 <option value="10"<%= reportSchedule.getEndHour().equals("10")?" selected":"" %>>10
471                                 <option value="11"<%= reportSchedule.getEndHour().equals("11")?" selected":"" %>>11
472                                 <option value="12"<%= reportSchedule.getEndHour().equals("12")?" selected":"" %>>12
473                         </select>
474                         <select name="schedEndMin">
475                                 <option value="00"<%= reportSchedule.getEndMin().equals("00")?" selected":"" %>>00
476                                 <option value="15"<%= reportSchedule.getEndMin().equals("15")?" selected":"" %>>15
477                                 <option value="30"<%= reportSchedule.getEndMin().equals("30")?" selected":"" %>>30
478                                 <option value="45"<%= reportSchedule.getEndMin().equals("45")?" selected":"" %>>45
479                         </select>
480                         <select name="schedEndAMPM">
481                                 <option value="AM"<%= reportSchedule.getEndAMPM().equals("AM")?" selected":"" %>>AM
482                                 <option value="PM"<%= reportSchedule.getEndAMPM().equals("PM")?" selected":"" %>>PM
483                         </select>
484             <%= Globals.getTimeZone()%>
485
486                         </font>
487                 </td>
488         </tr>
489
490         <script type="text/javascript">initStartEndDate();</script>     
491
492         <% if(AppUtils.isAdminUser(request) || isSQLAllowed ) { %>
493         <tr>
494                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Use Condition:</font></td> 
495                 <td class=rbg3 align="left" width="50%" valign="middle" nowrap><font class=rtabletext>
496                         <input type="checkbox" name="conditional" value="Y"<%= reportSchedule.getConditional().equals("Y")?" checked":"" %>> Send Emails Only When Condition Is Met
497                         </font></td>
498         </tr> 
499         <tr>
500                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Condition SQL:</font></td> 
501                 <td class=rbg3 align="left" width="50%" valign="middle" nowrap>
502                         <textarea name="conditionSQL" cols="40" rows="3"><%= nvl(reportSchedule.getConditionSQL()) %></textarea>
503                         <input type="Button" class=button value="Test" onClick="showTestConditionPopup()">
504                         &nbsp;
505                         </font></td>
506         </tr> 
507         <% } %> 
508
509         <tr>
510                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Max rows in attachment:</font></td> 
511                 <td class=rbg3 align="left" width="50%" valign="middle" nowrap>
512                         <input type='text' name='downloadLimit' value="<%=Integer.parseInt(reportSchedule.getDownloadLimit())>0?reportSchedule.getDownloadLimit(): Integer.toString(rdefRecurrance.getMaxRowsInExcelDownload())%>" size='4' toolTipText="Specify the maximum number of rows that can be sent in an attachment."/>
513                         </font>
514                 </td>
515         </tr>
516         <tr class="rbg1">
517                 <td class=rbg1 colspan="2" align="left">
518                 <b class=rtableheader>Form Fields</b>
519                 </td>
520                       
521         </tr>
522         <jsp:include page="wizard_schedule_formfield_include.jsp" flush="true" />
523         <tr>
524                 <td colspan=4><hr></hr></td>
525         </tr>
526         <input type="hidden" name="toListUpdated" value="false" />
527         
528 <%      List emailToUsers = reportSchedule.getEmailToUsers();
529         for(int i=0; i<emailToUsers.size(); i++) { 
530                 IdNameValue userValue = (IdNameValue) emailToUsers.get(i); %>
531         <tr>
532                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext><%= (i==0)?"Email To: ":"&nbsp;" %></font></td> 
533                 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>
534                         <%= userValue.getName() %>
535                         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
536                         <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.all.toListUpdated.value='true'; document.forma.<%= AppConstants.RI_DETAIL_ID %>.value='<%= userValue.getId() %>'; }">
537                         </font></td>
538         </tr>
539 <%      }       // for 
540         List emailToRoles = reportSchedule.getEmailToRoles();
541         for(int i=0; i<emailToRoles.size(); i++) { 
542                 IdNameValue roleValue = (IdNameValue) emailToRoles.get(i); %>
543         <tr>
544                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext><%= (emailToUsers.size()==0&&i==0)?"Email To: ":"&nbsp;" %></font></td> 
545                 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>Everyone With Role:&nbsp;
546                         <%= roleValue.getName() %>
547                         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
548                         <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.all.toListUpdated.value='true'; document.forma.<%= AppConstants.RI_DETAIL_ID %>.value='<%= roleValue.getId() %>'; }">
549                         </font></td>
550         </tr>
551 <%      }       // for 
552         
553         Vector remainingUsers = Utils.getUsersNotInList(emailToUsers,request);
554         Vector remainingRoles = Utils.getRolesNotInList(emailToRoles,request);
555         if((emailToUsers.size()+emailToRoles.size()==0)||(remainingUsers.size()>0)||(remainingRoles.size()>0)) { %>
556         <tr>
557           <td colspan="2" align="center">
558                 <table width="100%" cellspacing="1" cellpadding="3" align="center" border="0"> <tr>
559                 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext><%= (emailToUsers.size()+emailToRoles.size()==0)?"Email To: ":"&nbsp;" %></font></td> 
560                 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>
561 <%              if(remainingUsers.size()>0) { %>
562                         <select name="schedEmailAdd" onChange="if(! dataValidate()) {selectedIndex=0;} else {document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_ADD_USER %>'; document.all.toListUpdated.value='true'; document.forma.submit();}" toolTipText="Select users and/or roles the report should be sent to">
563                             <option value="" selected>--- Select User ---
564 <%                      for(int i=0; i<remainingUsers.size(); i++) {
565                                 IdNameValue userValue = (IdNameValue) remainingUsers.get(i); %>
566                             <option value="<%= userValue.getId() %>"><%= userValue.getName() %>
567 <%                      }       // for %>
568                         </select>
569 <%              } else { %>
570                         No user emails available
571 <%              } %>
572                         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
573 <%              if(remainingRoles.size()>0) { %>
574                         <select name="schedEmailAddRole" onChange="if(! dataValidate()) {selectedIndex=0;} else {document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_ADD_ROLE %>'; document.all.toListUpdated.value='true'; document.forma.submit();}" toolTipText="Select users and/or roles the report should be sent to">
575                             <option value="" selected>--- Select Role ---
576 <%                      for(int i=0; i<remainingRoles.size(); i++) {
577                                 IdNameValue roleValue = (IdNameValue) remainingRoles.get(i); %>
578                             <option value="<%= roleValue.getId() %>"><%= roleValue.getName() %>
579 <%                      }       // for %>
580                         </select>
581 <%              } else { %>
582                         No roles available
583 <%              } %>
584                         </font>
585           </td>
586           <% if ( nvl(Globals.getEncryptedSMTPServer(),"").length() > 0 ) { %>
587           <td align="right" width="27%"><font class=rtabletext>Encrypt Attachment</font>
588                         <input type='radio' name='encryptMode' id='encryptMode' value='Y' <%= reportSchedule.getEncryptMode().equals("Y")?"":" checked" %> toolTipText="Choose the encryption mode."/>Yes
589                         &nbsp;&nbsp;
590                         <input type='radio' name='encryptMode' id='encryptMode' value='N' <%= reportSchedule.getEncryptMode().equals("N")?"":(reportSchedule.getEncryptMode().length()<=0)?" checked":(!reportSchedule.getEncryptMode().equals("N"))? " " :" checked " %> toolTipText="Choose the encryption mode."/>No
591           </td>
592           <% } %>
593           <% if (Globals.generateSchedReportsInFileSystem()) { %>
594           <td align="right" width="27%"><font class=rtabletext>Send as Attachment</font>
595                         <input type='radio' name='sendAttachment' id='sendAttachment' value='Y' <%= reportSchedule.isAttachmentMode()?" checked ":""%> toolTipText="Send As Attachment"/>Yes
596                         &nbsp;&nbsp;
597                         <input type='radio' name='sendAttachment' id='sendAttachment' value='N' <%= !reportSchedule.isAttachmentMode()?" checked":"" %> toolTipText="Store it in file system."/>No
598           </td>
599           <% } %>
600            </tr>
601                 </table>
602                 </td>     
603         </tr>
604 <%      }       // if 
605 %>
606 </table>
607
608
609 <br>
610
611 <script language="JavaScript">
612 <!--
613 function dataValidate() {
614         //alert("dataValidate called");
615         var startDate = new Date(document.forma.schedStartDate.value);
616         var startHour = eval(document.forma.schedHour.value);
617         if(document.forma.schedAMPM.value == 'PM') {
618                 if (startHour != 12) startHour = startHour + 12; 
619         } else {
620                 if (startHour == 12) startHour = startHour - 12;
621         }
622         startDate.setHours(startHour);
623         startDate.setMinutes(eval(document.forma.schedMin.value));
624
625         var endDate = new Date(document.forma.schedEndDate.value);
626         var endHour = eval(document.forma.schedEndHour.value);
627         if(document.forma.schedEndAMPM.value == 'PM') {
628                 if (endHour != 12) endHour = endHour + 12; 
629         } else {
630                 if (endHour == 12) endHour = endHour - 12;
631         }
632         endDate.setHours(endHour);
633         endDate.setMinutes(eval(document.forma.schedEndMin.value));
634         
635     //alert ("System Calendar " + "<%=systemCalendar.get(Calendar.YEAR)+ " " + (systemCalendar.get(Calendar.MONTH)+1)+ " " +  systemCalendar.get(Calendar.DAY_OF_MONTH) + " " +  systemCalendar.get(Calendar.HOUR_OF_DAY) + " " + systemCalendar.get(Calendar.MINUTE) + " " + systemCalendar.get(Calendar.SECOND)%>");
636         var currDate = new Date();
637         var curr1Date = new Date();
638         currDate.setFullYear(<%=systemCalendar.get(Calendar.YEAR)%>, <%=systemCalendar.get(Calendar.MONTH)%>,<%=systemCalendar.get(Calendar.DAY_OF_MONTH)%>);
639         currDate.setHours(<%=systemCalendar.get(Calendar.HOUR_OF_DAY)%>);
640         currDate.setMinutes(<%=systemCalendar.get(Calendar.MINUTE)%>);
641         currDate.setSeconds(<%=systemCalendar.get(Calendar.SECOND)%>);
642
643         //alert(startDate+ " " + currDate + " " + (startDate-currDate) + " " + (startDate.toString()==currDate.toString()));
644         
645
646         if(! checkDate(document.forma.schedStartDate.value, false)) {
647                 alert("Invalid Start Date. The date format should be MM/DD/YYYY");
648                 document.forma.schedStartDate.focus();
649                 document.forma.schedStartDate.select();
650                 return false;
651         }
652         if(! checkDate(document.forma.schedEndDate.value, false)) {
653                 alert("Invalid End Date. The date format should be MM/DD/YYYY");
654                 document.forma.schedEndDate.focus();
655                 document.forma.schedEndDate.select();
656                 return false;
657         }
658         if (startDate >= endDate){
659                         alert("Start Date has to be less than the End Date.");
660                 return false;
661         }
662
663         if (startDate - currDate < 0){
664                 if(startDate.toString()!=currDate.toString()) {
665                         var m_names = new Array("January", "February", "March", 
666                                         "April", "May", "June", "July", "August", "September", 
667                                         "October", "November", "December");
668             var curr_min = currDate.getMinutes();
669                         curr_min = curr_min + "";
670                         if (curr_min.length == 1) {
671                                 curr_min = "0" + curr_min;
672                         }  
673                         alert("Start Date/Time has to be greater or equal to the System Date/Time ("+m_names[currDate.getMonth()]+" "+ currDate.getDate() + ", " + currDate.getYear() + " " + currDate.getHours()+ ":" + curr_min+ ").");
674                         return false;
675                 }
676         }
677         /*if(! checkDate(document.forma.schedRunDate.value, true)) {
678                 alert("Invalid Execution Date. The date format should be MM/DD/YYYY");
679                 document.forma.schedRunDate.focus();
680                 document.forma.schedRunDate.select();
681                 return false;
682         }*/
683 <% if (AppUtils.isAdminUser(request) || isSQLAllowed){ %>
684         if(document.forma.conditional.checked&&document.forma.conditionSQL.value=="") {
685                 alert("Please provide Condition SQL");
686                 document.forma.conditionSQL.focus();
687                 document.forma.conditionSQL.select();
688                 return false;
689         }
690 <% } %> 
691         if(! checkNonNegativeInteger(document.forma.downloadLimit.value)) {
692                 alert("Max row in attachment is not a valid integer.\nPlease enter a valid value.");
693                 document.forma.downloadLimit.focus();
694                 document.forma.downloadLimit.select();
695                 return false;
696         }
697         else 
698         {
699                 if((document.forma.downloadLimit.value) > <%=Globals.getDownloadLimit()%>) {
700                         alert("Max row you can download should not be more than <%=Globals.getDownloadLimit()%> rows.\nPlease enter a valid value.");
701                         document.forma.downloadLimit.focus();
702                         document.forma.downloadLimit.select();
703                         return false;                   
704                 }
705                 
706         }
707         for (var i=0; i < document.forma.notify.length; i++) {
708                 if (document.forma.notify[i].checked) {
709                   document.forma.notify_type.value = document.forma.notify[i].value;
710                 }
711          } 
712         return validateForm();
713         
714         return true;
715 }   // dataValidate
716 //-->
717 </script>
718
719 <script type="text/javascript">
720 var tooltipObj = new DHTMLgoodies_formTooltip();
721 tooltipObj.setTooltipPosition('right');
722 tooltipObj.setPageBgColor('#EEEEEE');
723 //tooltipObj.setPageBgColor('#FFFFFF');
724 tooltipObj.setTooltipCornerSize(15);
725 tooltipObj.setTooltipBgColor("#99CCFF");
726 tooltipObj.initFormFieldTooltip();
727 </script>
728
729
730 <%!
731         private String nvl(String s)                  { return (s==null)?"":s; }
732         private String nvl(String s, String sDefault) { return nvl(s).equals("")?sDefault:s; } 
733 %>