Subversion Repositories DevTools

Rev

Rev 5684 | Rev 6181 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5549 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'=====================================================
5560 dpurdie 4
'   wAddDaemonInstruction.asp
5
'   
6
'   This page is designed to be loaded into an iframe
7
'
5549 dpurdie 8
'=====================================================
9
%>
10
<%
11
Option explicit
12
Response.Expires = 0
13
%>
14
<!--#include file="common/conf.asp"-->
15
<!--#include file="common/globals.asp"-->
16
<!--#include file="common/formating.asp"-->
17
<!--#include file="common/qstr.asp"-->
18
<!--#include file="common/common_subs.asp"-->
19
<!--#include file="common/_form_window_common.asp"-->
20
<!--#include file="common/common_dbedit.asp"-->
21
<!--#include file="common/daemon_instructions.asp"-->
22
<%
23
'------------ ACCESS CONTROL ------------------
24
%>
6048 dpurdie 25
<!--#include file="_access_control_login.asp"-->
5549 dpurdie 26
<!--#include file="_access_control_general.asp"-->
27
<%
28
'------------ VARIABLE DEFINITION -------------
29
Dim sMessage, sMessageType
5560 dpurdie 30
Dim parProj_id
5549 dpurdie 31
Dim parPv_id
32
Dim parOp_code
5560 dpurdie 33
Dim parRepeat
34
Dim parInst_id
35
Dim parSchDateTime
5549 dpurdie 36
Dim parRfile
5560 dpurdie 37
Dim bHideRepeat
38
Dim bHidePackages
5549 dpurdie 39
Dim bPreventSubmit
5560 dpurdie 40
Dim parSortOrder
41
Dim ReleaseMode
5549 dpurdie 42
 
43
'------------ VARIABLE INIT -------------------
44
sMessage = NULL
45
sMessageType = 3
46
bPreventSubmit = False
47
 
48
' collect all parameters from query string
5560 dpurdie 49
parOp_code = Request("op_code")
50
parProj_id = Request("proj_id")
5549 dpurdie 51
parPv_id = Request("pv_id")
5560 dpurdie 52
parRepeat = Request("repeat")
53
parInst_id = Request("inst_id")
54
parSchDateTime = Request("sdt")
5549 dpurdie 55
parRfile = Request("rfile")
5560 dpurdie 56
ReleaseMode = GetReleaseMode(parRtag_id)
57
 
58
parSortOrder = Request("sort")
59
If IsNull(parSortOrder) OR parSortOrder = "" Then
60
   parSortOrder = "0"
61
End If
62
 
5549 dpurdie 63
Set objFormCollector = CreateObject("Scripting.Dictionary")
64
 
65
'------------------------------------------------------------------------------------------------------------------------------------------
5560 dpurdie 66
'
67
' Add a line of text to the System Message
68
'
69
Sub sMessageAdd(eLevel, text)
70
    If NOT isNull(sMessage) Then
71
        sMessage = sMessage & "<br>"
72
    End If
73
    sMessage = sMessage & text
74
 
75
    If eLevel < sMessageType  Then
76
        sMessageType = eLevel
77
    End If
78
End Sub
79
'------------------------------------------------------------------------------------------------------------------------------------------
80
' For the specified project ID, get a list of all that project's releases that are not closed/archived.
81
' Return True if at least one release was found, else False
82
'------------------------------------------------------------------------------------------------------------------------------------------
83
Function ReleasesAvailable(NNproj_id)
84
   Dim rsTemp, Query_String
85
 
86
   ReleasesAvailable = True
87
   Query_String = "SELECT rtag_id, rtag_name "&_
88
                  "  FROM release_tags rt"&_
89
                  " WHERE rt.proj_id = "& NNproj_id &_
90
                  "   AND ((rt.official = 'N') OR (rt.official = 'C') OR (rt.official = 'R'))"
91
 
92
	Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
93
   If rsTemp.RecordCount = 0 Then
94
      ReleasesAvailable = False
95
   End If
96
 
97
   rsTemp.Close
98
   Set rsTemp = nothing
99
End Function
100
'------------------------------------------------------------------------------------------------------------------------------------------
5549 dpurdie 101
' For the specified Release, get a list of all that release's daemon configurations.
102
' Return True if at least one daemon configuration was found, else False
103
'------------------------------------------------------------------------------------------------------------------------------------------
104
Function DaemonsAvailable(NNrtag_id)
105
   Dim rsTemp, Query_String
106
 
107
   DaemonsAvailable = True
108
   Query_String = "SELECT * "&_
109
                  "  FROM release_config rc"&_
110
                  " WHERE rc.rtag_id = "& NNrtag_id
111
	Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
112
   If rsTemp.RecordCount = 0 Then
113
      DaemonsAvailable = False
114
   End If
115
 
116
   rsTemp.Close
117
   Set rsTemp = nothing
118
End Function
5560 dpurdie 119
'------------------------------------------------------------------------------------------------------------------------------------------
120
' Formulate the HTML for a combo box listing all the daemon instruction operations, and select the one that matches
121
' the op-code passed in as a parameter. If the parameter value could not be found, correct it to the first valid op-code
122
' in the list.
123
'------------------------------------------------------------------------------------------------------------------------------------------
124
Function Get_OpCodes ( NNop_code )
125
   Dim op_code_str_array
126
   Dim op_code_str
127
   Dim op_code_val
128
	Dim selectedFound
129
   Dim tempLINK
130
   Dim s
5549 dpurdie 131
 
5560 dpurdie 132
   selectedFound = False
5549 dpurdie 133
 
5560 dpurdie 134
   ' Get the op-codes in terms of human readable string names - these will be used in the drop down select list
135
   Call GetDaemonInstructionOperationNameArray(op_code_str_array)
5549 dpurdie 136
 
5560 dpurdie 137
   s = "<td width='20%' align='left' class='nowrap'>Operation</td>"
138
   s = s + "<td align='left'><select name='op_code_list' id='op_code_list' class='form_item' onchange=""MM_jumpMenu('document',this,0)"">"
139
 
140
   For each op_code_str in op_code_str_array
141
 
142
      ' get equivalent op-code value for this op-code string
143
      op_code_val = DaemonInstructionOperationValue(op_code_str)
144
 
145
      tempLINK = scriptName & "?inst_id="& parInst_id &_
146
                              "&op_code="& op_code_val &_
147
                              "&rtag_id=" & parRtag_id &_
148
                              "&pv_id=" & parPv_id &_
149
                              "&sort=" & parSortOrder &_
150
                              "&sdt="& parSchDateTime &_
151
                              "&repeat="& parRepeat &_
152
                              "&rfile="& parRfile
153
 
154
      If ((NNop_code = op_code_val) OR (NNop_code = "0")) AND (selectedFound = False) Then
155
         s = s + "<option value='"& tempLINK &"' selected>"& op_code_str &"</option>"
156
         selectedFound = True
157
         NNop_code = op_code_val
158
      Else
159
         s = s + "<option value='"& tempLINK &"'>"& op_code_str &"</option>"
160
      End If
161
   Next
162
 
163
   s = s + "</select></td>"
164
   Get_OpCodes = s
165
End Function
166
'------------------------------------------------------------------------------------------------------------------------------------------
167
' Formulate the HTML for a combo box listing all the Projects, and select the one that matches
168
' the proj-id passed in as a parameter. If the parameter value could not be found, correct it to the first valid proj-id
169
' in the list.
170
'------------------------------------------------------------------------------------------------------------------------------------------
171
Function Get_Projects ( NNproj_id )
172
   Dim rsTemp, Query_String, projName, tempLINK, selectedFound, s
173
 
174
   selectedFound = False
175
   Query_String = "SELECT * FROM projects ORDER BY  UPPER( proj_name )"
176
 
177
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
178
 
179
   s = "<td class='nowrap'>Project</td>"
180
   s = s + "<td><select id='proj_id_list' name='proj_id_list' class='form_item' onChange=""MM_jumpMenu('document',this,0)"">"
181
 
182
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
183
      projName = UCase(rsTemp.Fields("proj_name"))
184
 
185
      tempLINK = scriptName & "?inst_id="& parInst_id &_
186
                              "&op_code="& parOp_code &_
187
                              "&proj_id=" & rsTemp.Fields("proj_id") &_
188
                              "&sdt="& parSchDateTime &_
189
                              "&repeat="& parRepeat &_
190
                              "&sort=" & parSortOrder &_
191
                              "&rfile="& parRfile
192
 
193
      If ((NNproj_id = Cstr(rsTemp.Fields("proj_id"))) OR (NNproj_id = "0")) AND (selectedFound = False) Then
194
         s = s + "<option value='"& tempLINK &"' selected>"& projName &"</option>"
195
         selectedFound = True
196
         NNproj_id = CStr(rsTemp.Fields("proj_id"))
197
      Else
198
         s = s + "<option value='"& tempLINK &"'>"& projName &"</option>"
199
      End If
200
 
201
      rsTemp.MoveNext
202
   WEnd
203
   s = s + "</select>"
204
 
205
   ' Correct for a situation where selectedFound is still FALSE.
206
   If NOT selectedFound Then
207
      rsTemp.MoveFirst
208
      If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
209
         NNproj_id = CStr(rsTemp.Fields("proj_id"))
210
      Else
211
         NNproj_id = "0"
212
      End If
213
   End If
214
 
215
   rsTemp.Close
216
   Set rsTemp = nothing
217
 
218
   s = s + "</td>"
219
 
220
   Get_Projects = s
221
End Function
222
 
223
'------------------------------------------------------------------------------------------------------------------------------------------
224
' Formulate the HTML for a combo box listing all the Release for a specified project, and select the one that matches
225
' the release-tag passed in as a parameter. If the parameter value could not be found, correct it to the first valid release-tag
226
' in the list.
227
'------------------------------------------------------------------------------------------------------------------------------------------
228
Function Get_Releases ( NNproj_id, NNrtag_id )
229
   Dim rsTemp, Query_String, releaseName, tempLINK, selectedFound, s, numReleases
230
 
231
   selectedFound = False
232
 
233
   numReleases = 0
234
 
235
   Query_String = "SELECT rtag_id, rtag_name "&_
236
                  "  FROM release_tags rt"&_
237
                  " WHERE rt.proj_id = "& NNproj_id &_
238
                  "   AND ((rt.official = 'N') OR (rt.official = 'C') OR (rt.official = 'R'))"&_
239
                  " ORDER BY UPPER(rtag_name)"
240
	Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
241
 
242
   s = "<td class='nowrap'>Release</td>"
243
   s = s + "<td><select id='rtag_id_list' name='rtag_id_list' class='form_item' onChange=""MM_jumpMenu('document',this,0)"">"
244
 
245
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
246
      releaseName = rsTemp.Fields("rtag_name")
247
 
248
      tempLINK = scriptName & "?inst_id="& parInst_id &_
249
                              "&op_code="& parOp_code &_
250
                              "&proj_id="& NNproj_id &_
251
                              "&rtag_id="& rsTemp.Fields("rtag_id") &_
252
                              "&sdt="& parSchDateTime &_
253
                              "&repeat="& parRepeat &_
254
                              "&sort=" & parSortOrder &_
255
                              "&rfile="& parRfile
256
 
257
      If ((NNrtag_id = CStr(rsTemp.Fields("rtag_id"))) OR (NNrtag_id = "0")) AND (selectedFound = False) Then
258
            s = s + "<option value='"& tempLINK &"' selected>"& releaseName &"</option>"
259
         selectedFound = True
260
         NNrtag_id = Cstr(rsTemp.Fields("rtag_id"))
261
      Else
262
         s = s + "<option value='"& tempLINK &"'>"& releaseName &"</option>"
263
      End If
264
 
265
      numReleases = numReleases + 1
266
 
267
      rsTemp.MoveNext
268
   WEnd
269
   s = s + "</select>"
270
 
271
   ' Correct for a situation where selectedFound is still FALSE.
272
   If NOT selectedFound Then
273
      rsTemp.MoveFirst
274
      If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
275
         NNrtag_id = CStr(rsTemp.Fields("rtag_id"))
276
      Else
277
         NNrtag_id = "0"
278
      End If
279
   End If
280
 
281
   ' If no releases were found then replace drop down list with some warning text and disable form submission
282
   If numReleases = 0 Then
283
      bPreventSubmit = True
284
      s = "<td class='nowrap'>Release</td><td><a style=color:Red>WARNING: No active releases found. The operation cannot be performed.</a></td>"
285
   Else
286
      ' If the selected release does not have a daemon configuration, append some warning text to the right of the drop down list.
287
      If DaemonsAvailable(NNrtag_id) = False Then
288
         s = s + "<a style=color:Red>WARNING: Release has no build daemon(s)</a>"
289
      End If
290
   End If
291
 
292
   rsTemp.Close
293
   Set rsTemp = nothing
294
 
295
   s = s + "</td>"
296
 
297
   Get_Releases = s
298
End Function
299
'------------------------------------------------------------------------------------------------------------------------------------------
300
' Formulate the HTML for a combo box listing all the Package Versions in a specified release, and select the one that matches
301
' the pv_id passed in as a parameter. If the parameter value could not be found, correct it to the first valid pv_id
302
' in the list.
303
' This function must deal with op-codes that want to read package versions from the work_in_progress table, and op-codes
304
' that need to read package versions from the release_content table.
305
' The function should only be called if a package versions drop down list is required for the form.
306
'------------------------------------------------------------------------------------------------------------------------------------------
307
Function Get_Packages ( NNrtag_id, NNpv_id, NNop_code )
308
   Dim rsTemp, Query_String, pkgName, tempLINK, selectedFound, s, numPackages
309
 
310
   selectedFound = False
311
 
312
   numPackages = 0
313
 
314
   If (NNop_code = OP_CODE_1_TEST_BUILD_PACKAGE) Then
315
      ' Get list of packages from from work_in_progress table
316
      Query_String = "SELECT pk.pkg_id, pk.pkg_name, pv.pkg_version, wip.pv_id "&_
317
                     "  FROM work_in_progress wip, release_tags rt, packages pk, package_versions pv "&_
318
                     " WHERE wip.rtag_id = "& Cstr(NNrtag_id) &_
319
                     "   AND wip.rtag_id = rt.rtag_id"&_
320
                     "   AND ((rt.official = 'N') OR (rt.official = 'C') OR (rt.official = 'R'))"&_
321
                     "   AND wip.pv_id = pv.pv_id"&_
322
                     "   AND pk.pkg_id = pv.pkg_id"&_
323
                     " ORDER BY UPPER(pkg_name)"
324
 
325
   Else
326
      ' Get list of packages from from release_content table
327
      Query_String = "SELECT pk.pkg_id, pk.pkg_name, pv.pkg_version, rc.pv_id "&_
328
                     "  FROM release_content rc, release_tags rt, packages pk, package_versions pv "&_
329
                     " WHERE rc.rtag_id = "& Cstr(NNrtag_id) &_
330
                     "   AND rc.rtag_id = rt.rtag_id"&_
331
                     "   AND ((rt.official = 'N') OR (rt.official = 'C') OR (rt.official = 'R'))"&_
332
                     "   AND rc.pv_id = pv.pv_id"&_
333
                     "   AND pk.pkg_id = pv.pkg_id"&_
334
                     " ORDER BY UPPER(pkg_name)"
335
   End If
336
 
337
	Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
338
 
339
   ' modify the control heading to indicate the source of the package version list
340
   If (NNop_code = OP_CODE_1_TEST_BUILD_PACKAGE) Then
341
      s = "<td class='nowrap'>WIP Package</td>"
342
   Else
343
      s = "<td class='nowrap'>Released Package</td>"
344
   End If
345
 
346
   s = s + "<td><select id='pv_id_list' name='pv_id_list' class='form_item' onChange=""MM_jumpMenu('document',this,0)"">"
347
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
348
      pkgName = rsTemp.Fields("pkg_name") & " " & rsTemp.Fields("pkg_version")
349
 
350
      tempLINK = scriptName & "?inst_id="& parInst_id &_
351
                              "&op_code="& NNop_code &_
352
                              "&proj_id="& parProj_id &_
353
                              "&rtag_id="& NNrtag_id &_
354
                              "&pv_id="&   rsTemp.Fields("pv_id") &_
355
                              "&sdt="& parSchDateTime &_
356
                              "&repeat="& parRepeat &_
357
                              "&sort=" & parSortOrder &_
358
                              "&rfile="& parRfile
359
 
360
      If ((NNpv_id = Cstr(rsTemp.Fields("pv_id"))) OR (NNpv_id = "0")) AND (selectedFound = False) Then
361
         s = s + "<option value='"& tempLINK &"' selected>"& pkgName &"</option>"
362
         selectedFound = True
363
         NNpv_id = CStr(rsTemp.Fields("pv_id"))
364
      Else
365
         s = s + "<option value='"& tempLINK &"'>"& pkgName &"</option>"
366
      End If
367
 
368
      numPackages = numPackages + 1
369
 
370
      rsTemp.MoveNext
371
   WEnd
372
   s = s + "</select></td>"
373
 
374
   ' Correct for a situation where selectedFound is still FALSE.
375
   If NOT selectedFound Then
376
      rsTemp.MoveFirst
377
      If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
378
         NNpv_id = Cstr(rsTemp.Fields("pv_id"))
379
      Else
380
         NNpv_id = "0"
381
      End If
382
   End If
383
 
384
   ' replace drop down list with a warning if no package versions were found, and ensure that the user cannot submit the form
385
   If numPackages = 0 Then
386
      bPreventSubmit = True
387
      If (NNop_code = OP_CODE_1_TEST_BUILD_PACKAGE) Then
388
         s = "<td>Package</td><td><a style=color:Red>WARNING: No WIP package versions found. The operation cannot be performed.</a></td>"
389
      Else
390
         s = "<td>Package</td><td><a style=color:Red>WARNING: No released package versions found. The operation cannot be performed.</a></td>"
391
      End If
392
   End If
393
 
394
   rsTemp.Close
395
   Set rsTemp = nothing
396
 
397
   Get_Packages = s
398
End Function
399
 
400
'------------------------------------------------------------------------------------------------------------------------------------------
401
' This function will be called if and only if the form is first opened in circumstances where the user is editing an existing record
402
' and all of the form's parameters must be set to the values found in that record. The database record must be obtained using a query
403
' and the relevant parameters assigned from the record fields
404
'------------------------------------------------------------------------------------------------------------------------------------------
405
Sub Get_All_Params_From_Inst_Id(NNInstId)
406
   Dim rsTemp, Query_String
407
 
408
   Query_String = "SELECT op_code, rtag_id, pv_id, repeat_secs, "&_
409
                  "  TO_CHAR(scheduled_datetime, 'DD-MM-YYYY HH24:MI:SS') AS schedDate "&_
410
                  "  FROM DAEMON_INSTRUCTIONS "&_
411
                  " WHERE DAEMON_INSTRUCTIONS_ID = " & NNInstId
412
	Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
413
   If rstemp.RecordCount = 0 Then
414
      Call sMessageAdd(1, "Attempt to Edit a non-existent record")
415
      Exit Sub
416
   End If
417
 
418
   ' assign record fields to global parameters
419
   parOp_code = rsTemp("op_code")
420
   parRtag_id = rsTemp("rtag_id")
421
   parPv_id   = rsTemp("pv_id")
422
   parRepeat  = rsTemp("repeat_secs")
423
   parSchDateTime = rsTemp("schedDate")
424
 
425
   ' derive project id since that is not stored in the table
426
   If NOT IsNull(parRtag_id) AND parRtag_id <> "" Then
427
      parProj_id = Get_Proj_ID(parRtag_id)
428
   Else
429
      parProj_id = "0"
430
   End If
431
 
432
   rsTemp.Close
433
   Set rsTemp = nothing
434
End Sub
435
'------------------------------------------------------------------------------------------------------------------------------------------
436
'   Perform any form callback actions
437
'   This is implemented in a subroutine to simplify error handling
438
'
439
Sub performActions
440
    ' Check if form submit is happening
441
    If CBool(Request("action")) Then
442
 
5549 dpurdie 443
       Dim RepeatSeconds
444
       Dim ScheduledDateTime
445
 
5560 dpurdie 446
       ' determine if insert/update is enabled by permissions
447
       If NOT UserCanAddOrEditThisDaemonInst(parProj_id, ReleaseMode, parOp_code) Then
448
          ' redirect to an error message
449
          Call sMessageAdd (1, "You have been denied permission to add/update daemon instructions for the specified release.")
450
          Exit Sub
5549 dpurdie 451
       End If
452
 
5560 dpurdie 453
       ' do daemon instruction validation, continuing only if it passes
454
       If ValidateDaemonInstruction(parOp_code, parRtag_id, parPv_id) = True Then
5549 dpurdie 455
 
5560 dpurdie 456
          ' Setup the repeat seconds count according to the radio button value
457
          If IsNull(Request("repeat_inst")) OR Request("repeat_inst") = "" OR Request("repeat_inst") = "No" Then
458
             RepeatSeconds = 0
459
          Else
460
             RepeatSeconds = 86400
461
          End If
5549 dpurdie 462
 
5560 dpurdie 463
          ' If user has not entered a scheduled time, set the scheduled date/time to now
464
          ScheduledDateTime = Request("scheduled_time")
465
          If IsNull(ScheduledDateTime) OR ScheduledDateTime = "" Then
5549 dpurdie 466
             ScheduledDateTime = ORA_SYSDATETIME
5560 dpurdie 467
          Else
5638 dpurdie 468
             ScheduledDateTime = "TO_DATE( '"& ScheduledDateTime &"','DY DD-MON-YYYY HH24:MI' )"
5560 dpurdie 469
          End If
5549 dpurdie 470
 
5560 dpurdie 471
          ' nullify parPv_id for the SQL, if the instruction op-code does not require one
472
          If bHidePackages Then
473
             parPv_id = "NULL"
474
          End If
5549 dpurdie 475
 
5560 dpurdie 476
 
477
         objEH.ErrorRedirect = FALSE
478
         objEH.TryORA ( OraSession )
479
         On Error Resume Next
480
 
481
          ' if the page has been provided an inst_id, we must be editing an existing record so we do an update
482
          If (NOT IsNull(parInst_id)) AND (parInst_id <> "") Then
483
             ' We are updating an existing record
484
             OraDatabase.ExecuteSQL "BEGIN PK_BUILDAPI.update_daemon_inst( "& parInst_id & ", " &_
485
                                                                            parOp_code & ", " &_
486
                                                                            parRtag_id & ", " &_
487
                                                                            parPv_id & ", " &_
488
                                                                            ScheduledDateTime & ", " &_
489
                                                                            CStr(RepeatSeconds) & ", " &_
490
                                                                            ORA_SYSDATETIME & ", " &_
491
                                                                            objAccessControl.UserId & "); END;"
492
          Else ' We are adding a new record
5549 dpurdie 493
             OraDatabase.ExecuteSQL "BEGIN PK_BUILDAPI.insert_daemon_inst( "& parOp_code & ", " &_
494
                                                                            parRtag_id & ", " &_
495
                                                                            parPv_id & ", " &_
496
                                                                            ScheduledDateTime & ", " &_
497
                                                                            CStr(RepeatSeconds) & ", " &_
498
                                                                            ORA_SYSDATETIME & ", " &_
499
                                                                            objAccessControl.UserId & "); END;"
5560 dpurdie 500
          End If
501
 
502
         objEH.CatchORA ( OraSession )
503
 
504
         '  If the operation was succesful, then redirect the parent
505
         '  This will also close the iframe
506
         '
507
         '  If an error has occured, then an error message will be displayed within the iframe
508
         ' via the _msg_inline.asp processing when the page is re-displayed
509
         '
510
         If objEH.Finally Then
511
            If parRfile = "admin_daemon_instructions.asp" Then
5590 dpurdie 512
               Call OpenInParentWindow (parRfile & "?sort=" & parSortOrder)
5560 dpurdie 513
            Else
5590 dpurdie 514
               Call OpenInParentWindow (parRfile & "?rtag_id=" & parRtag_id & "&pv_id=" & parPv_id)
5560 dpurdie 515
            End If
5590 dpurdie 516
            Call CloseWindow
5560 dpurdie 517
         End If
5549 dpurdie 518
       End If
519
    End If
5560 dpurdie 520
End Sub
521
%>
522
<%
523
'------------ RUN BEFORE PAGE RENDER ----------
524
'
525
' Access Control
526
If NOT objAccessControl.UserLogedIn Then
527
    Call sMessageAdd ( 1, "User is no longer logged in")
528
ElseIf NOT UserCanAddOrEditThisDaemonInst(DB_PROJ_ID, ReleaseMode, parOp_code) Then
529
    Call sMessageAdd ( 1, "You have been denied permission to add/update daemon instructions for the specified release." )
5549 dpurdie 530
End If
531
 
5560 dpurdie 532
' Are we in edit mode? If so, populate all parameters from the record being edited
533
If (NOT IsNull(parInst_id)) AND (parInst_id <> "") AND (Request("edit") = "true") Then
534
   If NOT DaemonInstructionInProgress(Request("inst_id")) Then
535
      Call Get_All_Params_From_Inst_Id(parInst_id)
536
   Else
537
      Call sMessageAdd(1,"Cannot edit an instruction that is currently being processed by a Daemon")
538
   End If
539
End If
5549 dpurdie 540
 
5560 dpurdie 541
' Make sure we dont have any null strings or empty strings for our parameters
542
If IsNull(parOp_code) OR parOp_code = "" Then
543
   parOp_code = "0"
544
End If
545
If IsNull(parProj_id) OR parProj_id = "" Then
546
   parProj_id = "0"
547
End If
548
If IsNull(parRtag_id) OR parRtag_id = "" Then
549
   parRtag_id = "0"
550
End If
551
If IsNull(parPv_id) OR parPv_id = "" Then
552
   parPv_id = "0"
553
End If
554
If IsNull(parRepeat) OR parRepeat = "" Then
555
   parRepeat = "0"
556
End If
557
If IsNull(parRfile) OR parRfile = "" Then
558
   parRfile = "admin_daemon_instructions.asp"
559
End If
560
 
561
If IsNull(parSchDateTime) OR parSchDateTime = "" Then
5684 dpurdie 562
   parSchDateTime = DisplayShortDateTimeSecs(Now())
5560 dpurdie 563
End If
564
 
565
' If this form is opened with an OP_CODE, RTAG_ID and PV_ID only, then we need to derive the PROJ_ID before
566
' calling Get_Projects() to generate the project drop down list.
567
If parProj_id = "0" AND NOT IsNull(parRtag_id) AND parRtag_id <> "" AND parRtag_id <> "0" Then
568
   parProj_id = Get_Proj_ID(parRtag_id)
569
End If
570
 
571
' Hide the Package drop-down list if the Daemon Instruction does not require it
572
If DaemonInstructionNeedsPV_ID(parOp_code) Then
573
   bHidePackages = False
5549 dpurdie 574
Else
5560 dpurdie 575
   bHidePackages = True
576
   parPv_id = "0"
5549 dpurdie 577
End If
5560 dpurdie 578
' NOTE: from this moment on, any real use of parPv_id has to be guarded by examination of bHidePackages
5549 dpurdie 579
 
5560 dpurdie 580
 
581
' Hide the Repeat buttons if the Daemon Instruction does not require them
582
If DaemonInstructionNeedsRepeat(parOp_code) Then
583
   bHideRepeat = False
584
Else
585
   bHideRepeat = True
5549 dpurdie 586
End If
587
 
5560 dpurdie 588
' Call some 'Get' procedures without HTML generation to determine the values of parProj_id, par_Rtag_id, and parPv_id
589
' in case they are not currently present in the query string. This will then allow the use of the ReleasesAvailable() and
590
' DaemonsAvailable() functions further below to hide the form submit button.
591
' It will also support the submit action itself when it takes place during the editing of an existing record where
592
' the user changes (for example) the project without making any changes to release or package and so those items
593
' are nullified and must be reset to something other than their original values that came through the query string
594
' when the edit form was just opened.
595
Call Get_Projects(parProj_id)                  ' Ensures parProj_id has a good value
596
Call Get_Releases(parProj_id, parRtag_id)      ' Ensures parRtag_id has a good value
597
 
598
If NOT bHidePackages Then
599
   Call Get_Packages (parRtag_id, parPv_id, parOp_code)
5549 dpurdie 600
End If
5560 dpurdie 601
 
602
' Perform any required actions
603
Call performActions
604
 
5549 dpurdie 605
'----------------------------------------------
606
%>
5560 dpurdie 607
<script language="JavaScript" type="text/javascript">
608
<!--
609
 
610
// This function is designed to be called when a repeat radio button is pressed. It reloads the page with an updated query string
611
// to reflect the new setting of the radio button set
612
function Refresh_Repeat(newRepeat)
613
{
614
   var s;
615
   s  = '<%=scriptName%>';
616
   s += '?inst_id=' + document.getElementById('inst_id').value;
617
   s += '&op_code=' + document.getElementById('op_code').value;
618
   s += '&proj_id=' + document.getElementById('proj_id').value;
619
   s += '&rtag_id=' + document.getElementById('rtag_id').value;
620
   s += '&pv_id='   + document.getElementById('pv_id').value;
621
   s += '&sort='    + document.getElementById('sortOrder').value;
622
   s += '&sdt='     + document.getElementById('scheduled_time').value;
623
   s += '&repeat='  + newRepeat;
624
   s += '&rfile='   + document.getElementById('rfile').value;
625
 
626
   document.location = s;
627
}
628
 
629
//-->
630
</script>
631
 
5549 dpurdie 632
<html>
633
   <head>
634
      <title>Release Manager</title>
635
      <link rel="shortcut icon" href="<%=FavIcon%>"/>
636
      <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
637
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
638
      <link href="images/release_manager_style.css" rel="stylesheet" type="text/css">
639
      <script language="JavaScript" src="scripts/common.js"></script>
5636 dpurdie 640
      <%bJqueryTimePicker = TRUE%>
641
      <!--#include file="_jquery_includes.asp"-->
642
    <script>
643
    $(document).ready(function(){
644
    	var myDateTimePicker = null;
645
        $('#scheduled_time').datetimepicker({
646
    		timeFormat: "HH:mm",
647
            dateFormat: "D dd-M-yy",
648
    		controlType: 'select',
649
    		oneLine: true,
650
    		timeInput: true,
651
            constrainInput: true,
652
            showOn: 'both',
653
            buttonImageOnly : true,
654
            buttonImage: "images/cal.gif",
655
            buttonText: "Select Date and Time",
656
            minDate : 0,
657
    		onClose : function(p1,p2){
658
    			 //console.log("scheduled_time", p1 );
659
    			},
660
    	    });
661
    	})
662
    </script>
663
    <style>
664
        #ui-datepicker-div {
665
            position: absolute !important;
666
            top: 0px !important;
667
            left: 0px !important;
668
            }
669
    </style>
5549 dpurdie 670
   </head>
671
 
5560 dpurdie 672
   <body background="images/bg_bage_0.gif" leftmargin="0" topmargin="0" >
673
      <table class="full_table">
5549 dpurdie 674
         <%
675
         '-- FROM START --------------------------------------------------------------------------------------------------------------
676
         objFormComponent.FormName = "DaemonInstruction"
5590 dpurdie 677
         objFormComponent.FormClass = "form_tight"
5549 dpurdie 678
         objFormComponent.Action = ScriptName &_
5560 dpurdie 679
                                   "?inst_id="& parInst_id &_
680
                                   "&op_code="& parOp_code &_
681
                                   "&proj_id="& parProj_id &_
5549 dpurdie 682
                                   "&rtag_id="& parRtag_id &_
5560 dpurdie 683
                                   "&pv_id="&   parPv_id &_
684
                                   "&sort="&    parSortOrder &_
685
                                   "&rfile="& parRfile
5549 dpurdie 686
         objFormComponent.OnSubmit = "ShowProgress();"
687
         Call objFormComponent.FormStart()
688
         %>
689
         <tr>
690
            <td>
5560 dpurdie 691
               <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++ -->
5549 dpurdie 692
               <%Call Messenger ( sMessage , sMessageType, "100%" )%>
693
               <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
694
               <!--#include file="messages/_msg_inline.asp"-->
695
               <table class="full_table form_item">
696
                  <tr>
5560 dpurdie 697
                     <td width="1%" class="nowrap">
698
                        <%=Get_OpCodes(parOp_code)%>
699
                     </td>
5549 dpurdie 700
                  </tr>
5560 dpurdie 701
                  <tr><td>&nbsp;</td></tr>
5549 dpurdie 702
                  <tr>
5560 dpurdie 703
                     <td class="nowrap">
704
                        <div id="SelectProject" style="visibility:visible">
705
                           <%=Get_Projects(parProj_id)%>
706
                        </div>
707
                     </td>
5549 dpurdie 708
                  </tr>
709
                  <tr>
5560 dpurdie 710
                     <td class="nowrap">
711
                        <div id="SelectRelease" style="visibility:visible">
712
                           <%=Get_Releases(parProj_id, parRtag_id)%>
713
                        </div>
714
                     </td>
5549 dpurdie 715
                  </tr>
5560 dpurdie 716
 
717
                  <%If NOT bHidePackages Then%>
5549 dpurdie 718
                  <tr>
5560 dpurdie 719
                     <td class="nowrap">
720
                        <div id="SelectPackageVersion" style="visibility:visible">
721
                           <%=Get_Packages ( parRtag_id, parPv_id, parOp_code )%>
722
                        </div>
723
                     </td>
5549 dpurdie 724
                  </tr>
5560 dpurdie 725
                  <%End If%>
726
 
727
                  <tr><td>&nbsp;</td></tr>
5549 dpurdie 728
                  <tr>
729
                     <td>
5560 dpurdie 730
                        <td class="nowrap">Scheduled Time</td>
731
                        <td>
5636 dpurdie 732
                           <input type="text" id="scheduled_time" name="scheduled_time" size="25" class="form_ivalue" value="<%=DisplayDateTime(parSchDateTime)%>">
5560 dpurdie 733
                        </td>
734
                     </td>
735
                  </tr>
736
 
737
                  <%If NOT bHideRepeat Then%>
738
                     <tr>
739
                        <td>
740
                           <td>Repeat</td>
741
                           <td>
742
                              <input type="radio" name="repeat_inst" id="repeat_inst_no"     value="No"   <%If parRepeat =     "0" Then%>checked<%End If%> onchange='Refresh_Repeat(0)'     >No
743
                              <input type="radio" name="repeat_inst" id="repeat_inst_24hrs"  value="24Hrs"<%If parRepeat = "86400" Then%>checked<%End If%> onchange='Refresh_Repeat(86400)' >24 Hrs
744
                           </td>
745
                        </td>
746
                     </tr>
747
                  <%End If%>
5636 dpurdie 748
                  <tr>
749
                    <td style="height:100px">
750
                    </td>
751
                  </tr>
5560 dpurdie 752
                 <tr>
753
                    <td background="images/bg_login.gif" colspan=3>
754
                       <table class="full_table">
755
                          <tr>
5590 dpurdie 756
                             <td><%=ProgressBar()%></td>
5636 dpurdie 757
                             <td align="right" >
5560 dpurdie 758
                                <%
759
                                Dim disableText : disableText = ""
760
                                If NOT (ReleasesAvailable(parProj_id) AND DaemonsAvailable(parRtag_id) AND NOT bPreventSubmit AND IsNull(sMessage)) Then
761
                                    disableText = "disabled=""disabled"""
762
                                End If
763
                                %>
764
                                <button name="btn" type="submit" <%=disableText%>>Add/Update</button>
5590 dpurdie 765
                                <button name="btn" type="reset" onclick="parent.closeIFrame();">Cancel</button>
5560 dpurdie 766
                             </td>
767
                          </tr>
768
                       </table>
769
                    </td>
770
                 </tr>
771
                  <tr>
772
                     <td>
773
                        <input type="hidden" id="inst_id"     name="inst_id"      value="<%=parInst_id%>">
774
                        <input type="hidden" id="op_code"     name="op_code"      value="<%=parOp_code%>">
775
                        <input type="hidden" id="proj_id"     name="proj_id"      value="<%=parProj_id%>">
5549 dpurdie 776
                        <input type="hidden" id="rtag_id"     name="rtag_id"      value="<%=parRtag_id%>">
777
                        <input type="hidden" id="pv_id"       name="pv_id"        value="<%=parPv_id%>">
5560 dpurdie 778
                        <input type="hidden" id="repeat_secs" name="repeat_secs"  value="<%=parRepeat%>">
5549 dpurdie 779
                        <input type="hidden" id="rfile"       name="rfile"        value="<%=parRfile%>">
5560 dpurdie 780
                        <input type="hidden" id="sortOrder"   name="sortOrder"    value="<%=parSortOrder%>">
5549 dpurdie 781
                     </td>
782
                  </tr>
783
               </table>
784
            </td>
785
         </tr>
786
         <%=objPMod.ComposeHiddenTags()%>
787
         <input type="hidden" name="action" value="true">
788
 
789
         <%
790
         Call objFormComponent.FormEnd()
791
         '-- FROM END ----------------------------------------------------------------------------------------------------------------
792
         %>
793
      </table>
794
   </body>
795
</html>
796
<%
797
'------------ RUN AFTER PAGE RENDER -----------
798
Set objFormCollector = Nothing
799
'----------------------------------------------
800
Call Destroy_All_Objects
801
%>
802
 
803