Subversion Repositories DevTools

Rev

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