Subversion Repositories DevTools

Rev

Rev 5549 | Rev 5590 | 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
511
               Call OpenInParentWindowFromIFrame (parRfile & "?sort=" & parSortOrder)
512
            Else
513
               Call OpenInParentWindowFromIFrame (parRfile & "?rtag_id=" & parRtag_id & "&pv_id=" & parPv_id)
514
            End If
515
         End If
5549 dpurdie 516
       End If
517
    End If
5560 dpurdie 518
End Sub
519
%>
520
<%
521
'------------ RUN BEFORE PAGE RENDER ----------
522
'
523
' Access Control
524
If NOT objAccessControl.UserLogedIn Then
525
    Call sMessageAdd ( 1, "User is no longer logged in")
526
ElseIf NOT UserCanAddOrEditThisDaemonInst(DB_PROJ_ID, ReleaseMode, parOp_code) Then
527
    Call sMessageAdd ( 1, "You have been denied permission to add/update daemon instructions for the specified release." )
5549 dpurdie 528
End If
529
 
5560 dpurdie 530
' Are we in edit mode? If so, populate all parameters from the record being edited
531
If (NOT IsNull(parInst_id)) AND (parInst_id <> "") AND (Request("edit") = "true") Then
532
   If NOT DaemonInstructionInProgress(Request("inst_id")) Then
533
      Call Get_All_Params_From_Inst_Id(parInst_id)
534
   Else
535
      Call sMessageAdd(1,"Cannot edit an instruction that is currently being processed by a Daemon")
536
   End If
537
End If
5549 dpurdie 538
 
5560 dpurdie 539
' Make sure we dont have any null strings or empty strings for our parameters
540
If IsNull(parOp_code) OR parOp_code = "" Then
541
   parOp_code = "0"
542
End If
543
If IsNull(parProj_id) OR parProj_id = "" Then
544
   parProj_id = "0"
545
End If
546
If IsNull(parRtag_id) OR parRtag_id = "" Then
547
   parRtag_id = "0"
548
End If
549
If IsNull(parPv_id) OR parPv_id = "" Then
550
   parPv_id = "0"
551
End If
552
If IsNull(parRepeat) OR parRepeat = "" Then
553
   parRepeat = "0"
554
End If
555
If IsNull(parRfile) OR parRfile = "" Then
556
   parRfile = "admin_daemon_instructions.asp"
557
End If
558
 
559
If IsNull(parSchDateTime) OR parSchDateTime = "" Then
560
   parSchDateTime = EuroDateTimeForCalendarControl(Now())
561
End If
562
 
563
' If this form is opened with an OP_CODE, RTAG_ID and PV_ID only, then we need to derive the PROJ_ID before
564
' calling Get_Projects() to generate the project drop down list.
565
If parProj_id = "0" AND NOT IsNull(parRtag_id) AND parRtag_id <> "" AND parRtag_id <> "0" Then
566
   parProj_id = Get_Proj_ID(parRtag_id)
567
End If
568
 
569
' Hide the Package drop-down list if the Daemon Instruction does not require it
570
If DaemonInstructionNeedsPV_ID(parOp_code) Then
571
   bHidePackages = False
5549 dpurdie 572
Else
5560 dpurdie 573
   bHidePackages = True
574
   parPv_id = "0"
5549 dpurdie 575
End If
5560 dpurdie 576
' NOTE: from this moment on, any real use of parPv_id has to be guarded by examination of bHidePackages
5549 dpurdie 577
 
5560 dpurdie 578
 
579
' Hide the Repeat buttons if the Daemon Instruction does not require them
580
If DaemonInstructionNeedsRepeat(parOp_code) Then
581
   bHideRepeat = False
582
Else
583
   bHideRepeat = True
5549 dpurdie 584
End If
585
 
5560 dpurdie 586
' Call some 'Get' procedures without HTML generation to determine the values of parProj_id, par_Rtag_id, and parPv_id
587
' in case they are not currently present in the query string. This will then allow the use of the ReleasesAvailable() and
588
' DaemonsAvailable() functions further below to hide the form submit button.
589
' It will also support the submit action itself when it takes place during the editing of an existing record where
590
' the user changes (for example) the project without making any changes to release or package and so those items
591
' are nullified and must be reset to something other than their original values that came through the query string
592
' when the edit form was just opened.
593
Call Get_Projects(parProj_id)                  ' Ensures parProj_id has a good value
594
Call Get_Releases(parProj_id, parRtag_id)      ' Ensures parRtag_id has a good value
595
 
596
If NOT bHidePackages Then
597
   Call Get_Packages (parRtag_id, parPv_id, parOp_code)
5549 dpurdie 598
End If
5560 dpurdie 599
 
600
' Perform any required actions
601
Call performActions
602
 
5549 dpurdie 603
'----------------------------------------------
604
%>
5560 dpurdie 605
<script language="JavaScript" type="text/javascript">
606
<!--
607
 
608
// This function is designed to be called when a repeat radio button is pressed. It reloads the page with an updated query string
609
// to reflect the new setting of the radio button set
610
function Refresh_Repeat(newRepeat)
611
{
612
   var s;
613
   s  = '<%=scriptName%>';
614
   s += '?inst_id=' + document.getElementById('inst_id').value;
615
   s += '&op_code=' + document.getElementById('op_code').value;
616
   s += '&proj_id=' + document.getElementById('proj_id').value;
617
   s += '&rtag_id=' + document.getElementById('rtag_id').value;
618
   s += '&pv_id='   + document.getElementById('pv_id').value;
619
   s += '&sort='    + document.getElementById('sortOrder').value;
620
   s += '&sdt='     + document.getElementById('scheduled_time').value;
621
   s += '&repeat='  + newRepeat;
622
   s += '&rfile='   + document.getElementById('rfile').value;
623
 
624
   document.location = s;
625
}
626
 
627
//-->
628
</script>
629
 
5549 dpurdie 630
<html>
631
   <head>
632
      <title>Release Manager</title>
633
      <link rel="shortcut icon" href="<%=FavIcon%>"/>
634
      <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
635
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
636
      <link href="images/release_manager_style.css" rel="stylesheet" type="text/css">
637
      <script language="JavaScript" src="scripts/common.js"></script>
5560 dpurdie 638
      <script language="JavaScript" src="images/ts_picker.js"></script>
5549 dpurdie 639
      <!--#include file="_jquery_includes.asp"-->
640
      <script language="javascript">
641
        $(document).ready(function () {
642
            //  Cancel button must close this iFrame using a function provided by the parent
643
            $('#btn_cancel').on('click', function (e) {parent.closeIFrame()});
644
        });
5560 dpurdie 645
      </script>
5549 dpurdie 646
   </head>
647
 
5560 dpurdie 648
   <body background="images/bg_bage_0.gif" leftmargin="0" topmargin="0" >
649
      <table class="full_table">
5549 dpurdie 650
         <tr>
651
            <td bgcolor="#FFFFFF" class="body_txt">
652
                <span class="body_h1">
5560 dpurdie 653
                    <img src="icons/i_linkarrow_black.gif" width="11" height="11" align="absmiddle">&nbsp;Add/Update Daemon Instruction
5549 dpurdie 654
                </span>
5560 dpurdie 655
                <br>Add a new Daemon Instruction or edit an existing Daemon Instruction.
5549 dpurdie 656
            </td>
657
         </tr>
658
         <%
659
         '-- FROM START --------------------------------------------------------------------------------------------------------------
660
         objFormComponent.FormName = "DaemonInstruction"
661
         objFormComponent.Action = ScriptName &_
5560 dpurdie 662
                                   "?inst_id="& parInst_id &_
663
                                   "&op_code="& parOp_code &_
664
                                   "&proj_id="& parProj_id &_
5549 dpurdie 665
                                   "&rtag_id="& parRtag_id &_
5560 dpurdie 666
                                   "&pv_id="&   parPv_id &_
667
                                   "&sort="&    parSortOrder &_
668
                                   "&rfile="& parRfile
5549 dpurdie 669
         objFormComponent.OnSubmit = "ShowProgress();"
670
         Call objFormComponent.FormStart()
671
 
672
 
673
         %>
674
         <tr>
675
            <td background="images/bg_login.gif">
676
               <table class="full_table">
677
                  <tr>
678
                     <td><%=ProgressBar()%></td>
679
                  </tr>
680
               </table>
681
            </td>
682
         </tr>
683
         <tr>
684
            <td>
5560 dpurdie 685
               <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++ -->
5549 dpurdie 686
               <%Call Messenger ( sMessage , sMessageType, "100%" )%>
687
               <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
688
               <!--#include file="messages/_msg_inline.asp"-->
689
               <table class="full_table form_item">
690
                  <tr>
5560 dpurdie 691
                     <td width="1%" class="nowrap">
692
                        <%=Get_OpCodes(parOp_code)%>
693
                     </td>
5549 dpurdie 694
                  </tr>
5560 dpurdie 695
                  <tr><td>&nbsp;</td></tr>
5549 dpurdie 696
                  <tr>
5560 dpurdie 697
                     <td class="nowrap">
698
                        <div id="SelectProject" style="visibility:visible">
699
                           <%=Get_Projects(parProj_id)%>
700
                        </div>
701
                     </td>
5549 dpurdie 702
                  </tr>
703
                  <tr>
5560 dpurdie 704
                     <td class="nowrap">
705
                        <div id="SelectRelease" style="visibility:visible">
706
                           <%=Get_Releases(parProj_id, parRtag_id)%>
707
                        </div>
708
                     </td>
5549 dpurdie 709
                  </tr>
5560 dpurdie 710
 
711
                  <%If NOT bHidePackages Then%>
5549 dpurdie 712
                  <tr>
5560 dpurdie 713
                     <td class="nowrap">
714
                        <div id="SelectPackageVersion" style="visibility:visible">
715
                           <%=Get_Packages ( parRtag_id, parPv_id, parOp_code )%>
716
                        </div>
717
                     </td>
5549 dpurdie 718
                  </tr>
5560 dpurdie 719
                  <%End If%>
720
 
721
                  <tr><td>&nbsp;</td></tr>
5549 dpurdie 722
                  <tr>
723
                     <td>
5560 dpurdie 724
                        <td class="nowrap">Scheduled Time</td>
725
                        <td>
726
                           <input type="text" id="scheduled_time" name="scheduled_time" size="20" class="form_ivalue" value="<%=parSchDateTime%>">
727
                           <a href="javascript:show_calendar('document.DaemonInstruction.scheduled_time', document.DaemonInstruction.scheduled_time.value);">
728
                              <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">
729
                           </a>
730
                        </td>
731
                     </td>
732
                  </tr>
733
 
734
                  <%If NOT bHideRepeat Then%>
735
                     <tr>
736
                        <td>
737
                           <td>Repeat</td>
738
                           <td>
739
                              <input type="radio" name="repeat_inst" id="repeat_inst_no"     value="No"   <%If parRepeat =     "0" Then%>checked<%End If%> onchange='Refresh_Repeat(0)'     >No
740
                              <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
741
                           </td>
742
                        </td>
743
                     </tr>
744
                  <%End If%>
745
                 <tr>
746
                    <td background="images/bg_login.gif" colspan=3>
747
                       <table class="full_table">
748
                          <tr>
749
                             <td align="right">
750
                                <%
751
                                Dim disableText : disableText = ""
752
                                If NOT (ReleasesAvailable(parProj_id) AND DaemonsAvailable(parRtag_id) AND NOT bPreventSubmit AND IsNull(sMessage)) Then
753
                                    disableText = "disabled=""disabled"""
754
                                End If
755
                                %>
756
                                <button name="btn" type="submit" <%=disableText%>>Add/Update</button>
757
                                <button name="btn" type="reset" id="btn_cancel">Cancel</button>
758
                             </td>
759
                          </tr>
760
                       </table>
761
                    </td>
762
                 </tr>
763
                  <tr>
764
                     <td>
765
                        <input type="hidden" id="inst_id"     name="inst_id"      value="<%=parInst_id%>">
766
                        <input type="hidden" id="op_code"     name="op_code"      value="<%=parOp_code%>">
767
                        <input type="hidden" id="proj_id"     name="proj_id"      value="<%=parProj_id%>">
5549 dpurdie 768
                        <input type="hidden" id="rtag_id"     name="rtag_id"      value="<%=parRtag_id%>">
769
                        <input type="hidden" id="pv_id"       name="pv_id"        value="<%=parPv_id%>">
5560 dpurdie 770
                        <input type="hidden" id="repeat_secs" name="repeat_secs"  value="<%=parRepeat%>">
5549 dpurdie 771
                        <input type="hidden" id="rfile"       name="rfile"        value="<%=parRfile%>">
5560 dpurdie 772
                        <input type="hidden" id="sortOrder"   name="sortOrder"    value="<%=parSortOrder%>">
5549 dpurdie 773
                     </td>
774
                  </tr>
775
               </table>
776
            </td>
777
         </tr>
778
         <%=objPMod.ComposeHiddenTags()%>
779
         <input type="hidden" name="action" value="true">
780
 
781
         <%
782
         Call objFormComponent.FormEnd()
783
         '-- FROM END ----------------------------------------------------------------------------------------------------------------
784
         %>
785
      </table>
786
   </body>
787
</html>
788
<%
789
'------------ RUN AFTER PAGE RENDER -----------
790
Set objFormCollector = Nothing
791
'----------------------------------------------
792
Call Destroy_All_Objects
793
%>
794
 
795