Subversion Repositories DevTools

Rev

Rev 6579 | Rev 6695 | 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
%>
6181 dpurdie 25
<!--#include file="_access_control_login_optional.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
6184 dpurdie 445
       Dim sErrorMsg
5549 dpurdie 446
 
5560 dpurdie 447
       ' determine if insert/update is enabled by permissions
448
       If NOT UserCanAddOrEditThisDaemonInst(parProj_id, ReleaseMode, parOp_code) Then
449
          ' redirect to an error message
450
          Call sMessageAdd (1, "You have been denied permission to add/update daemon instructions for the specified release.")
451
          Exit Sub
5549 dpurdie 452
       End If
453
 
5560 dpurdie 454
       ' do daemon instruction validation, continuing only if it passes
6184 dpurdie 455
       If ValidateDaemonInstruction(parOp_code, parRtag_id, parPv_id, sErrorMsg) = True Then
5549 dpurdie 456
 
5560 dpurdie 457
          ' Setup the repeat seconds count according to the radio button value
458
          If IsNull(Request("repeat_inst")) OR Request("repeat_inst") = "" OR Request("repeat_inst") = "No" Then
459
             RepeatSeconds = 0
460
          Else
461
             RepeatSeconds = 86400
462
          End If
5549 dpurdie 463
 
5560 dpurdie 464
          ' If user has not entered a scheduled time, set the scheduled date/time to now
465
          ScheduledDateTime = Request("scheduled_time")
466
          If IsNull(ScheduledDateTime) OR ScheduledDateTime = "" Then
5549 dpurdie 467
             ScheduledDateTime = ORA_SYSDATETIME
5560 dpurdie 468
          Else
5638 dpurdie 469
             ScheduledDateTime = "TO_DATE( '"& ScheduledDateTime &"','DY DD-MON-YYYY HH24:MI' )"
5560 dpurdie 470
          End If
5549 dpurdie 471
 
5560 dpurdie 472
          ' nullify parPv_id for the SQL, if the instruction op-code does not require one
473
          If bHidePackages Then
474
             parPv_id = "NULL"
475
          End If
5549 dpurdie 476
 
5560 dpurdie 477
 
478
         objEH.ErrorRedirect = FALSE
479
         objEH.TryORA ( OraSession )
480
         On Error Resume Next
481
 
482
          ' if the page has been provided an inst_id, we must be editing an existing record so we do an update
483
          If (NOT IsNull(parInst_id)) AND (parInst_id <> "") Then
484
             ' We are updating an existing record
485
             OraDatabase.ExecuteSQL "BEGIN PK_BUILDAPI.update_daemon_inst( "& parInst_id & ", " &_
486
                                                                            parOp_code & ", " &_
487
                                                                            parRtag_id & ", " &_
488
                                                                            parPv_id & ", " &_
489
                                                                            ScheduledDateTime & ", " &_
490
                                                                            CStr(RepeatSeconds) & ", " &_
491
                                                                            ORA_SYSDATETIME & ", " &_
492
                                                                            objAccessControl.UserId & "); END;"
493
          Else ' We are adding a new record
5549 dpurdie 494
             OraDatabase.ExecuteSQL "BEGIN PK_BUILDAPI.insert_daemon_inst( "& parOp_code & ", " &_
495
                                                                            parRtag_id & ", " &_
496
                                                                            parPv_id & ", " &_
497
                                                                            ScheduledDateTime & ", " &_
498
                                                                            CStr(RepeatSeconds) & ", " &_
499
                                                                            ORA_SYSDATETIME & ", " &_
500
                                                                            objAccessControl.UserId & "); END;"
5560 dpurdie 501
          End If
502
 
503
         objEH.CatchORA ( OraSession )
504
 
505
         '  If the operation was succesful, then redirect the parent
506
         '  This will also close the iframe
507
         '
508
         '  If an error has occured, then an error message will be displayed within the iframe
509
         ' via the _msg_inline.asp processing when the page is re-displayed
510
         '
511
         If objEH.Finally Then
512
            If parRfile = "admin_daemon_instructions.asp" Then
5590 dpurdie 513
               Call OpenInParentWindow (parRfile & "?sort=" & parSortOrder)
5560 dpurdie 514
            Else
5590 dpurdie 515
               Call OpenInParentWindow (parRfile & "?rtag_id=" & parRtag_id & "&pv_id=" & parPv_id)
5560 dpurdie 516
            End If
5590 dpurdie 517
            Call CloseWindow
5560 dpurdie 518
         End If
6184 dpurdie 519
       Else
520
        sMessage = sErrorMsg
521
        sMessageType = 1 
5549 dpurdie 522
       End If
523
    End If
5560 dpurdie 524
End Sub
525
%>
526
<%
527
'------------ RUN BEFORE PAGE RENDER ----------
528
'
529
' Access Control
530
If NOT objAccessControl.UserLogedIn Then
531
    Call sMessageAdd ( 1, "User is no longer logged in")
532
ElseIf NOT UserCanAddOrEditThisDaemonInst(DB_PROJ_ID, ReleaseMode, parOp_code) Then
533
    Call sMessageAdd ( 1, "You have been denied permission to add/update daemon instructions for the specified release." )
5549 dpurdie 534
End If
535
 
5560 dpurdie 536
' Are we in edit mode? If so, populate all parameters from the record being edited
537
If (NOT IsNull(parInst_id)) AND (parInst_id <> "") AND (Request("edit") = "true") Then
538
   If NOT DaemonInstructionInProgress(Request("inst_id")) Then
539
      Call Get_All_Params_From_Inst_Id(parInst_id)
540
   Else
541
      Call sMessageAdd(1,"Cannot edit an instruction that is currently being processed by a Daemon")
542
   End If
543
End If
5549 dpurdie 544
 
5560 dpurdie 545
' Make sure we dont have any null strings or empty strings for our parameters
546
If IsNull(parOp_code) OR parOp_code = "" Then
547
   parOp_code = "0"
548
End If
549
If IsNull(parProj_id) OR parProj_id = "" Then
550
   parProj_id = "0"
551
End If
552
If IsNull(parRtag_id) OR parRtag_id = "" Then
553
   parRtag_id = "0"
554
End If
555
If IsNull(parPv_id) OR parPv_id = "" Then
556
   parPv_id = "0"
557
End If
558
If IsNull(parRepeat) OR parRepeat = "" Then
559
   parRepeat = "0"
560
End If
561
If IsNull(parRfile) OR parRfile = "" Then
562
   parRfile = "admin_daemon_instructions.asp"
563
End If
564
 
565
If IsNull(parSchDateTime) OR parSchDateTime = "" Then
5684 dpurdie 566
   parSchDateTime = DisplayShortDateTimeSecs(Now())
5560 dpurdie 567
End If
568
 
569
' If this form is opened with an OP_CODE, RTAG_ID and PV_ID only, then we need to derive the PROJ_ID before
570
' calling Get_Projects() to generate the project drop down list.
571
If parProj_id = "0" AND NOT IsNull(parRtag_id) AND parRtag_id <> "" AND parRtag_id <> "0" Then
572
   parProj_id = Get_Proj_ID(parRtag_id)
573
End If
574
 
575
' Hide the Package drop-down list if the Daemon Instruction does not require it
576
If DaemonInstructionNeedsPV_ID(parOp_code) Then
577
   bHidePackages = False
5549 dpurdie 578
Else
5560 dpurdie 579
   bHidePackages = True
580
   parPv_id = "0"
5549 dpurdie 581
End If
5560 dpurdie 582
' NOTE: from this moment on, any real use of parPv_id has to be guarded by examination of bHidePackages
5549 dpurdie 583
 
5560 dpurdie 584
 
585
' Hide the Repeat buttons if the Daemon Instruction does not require them
586
If DaemonInstructionNeedsRepeat(parOp_code) Then
587
   bHideRepeat = False
588
Else
589
   bHideRepeat = True
5549 dpurdie 590
End If
591
 
5560 dpurdie 592
' Call some 'Get' procedures without HTML generation to determine the values of parProj_id, par_Rtag_id, and parPv_id
593
' in case they are not currently present in the query string. This will then allow the use of the ReleasesAvailable() and
594
' DaemonsAvailable() functions further below to hide the form submit button.
595
' It will also support the submit action itself when it takes place during the editing of an existing record where
596
' the user changes (for example) the project without making any changes to release or package and so those items
597
' are nullified and must be reset to something other than their original values that came through the query string
598
' when the edit form was just opened.
599
Call Get_Projects(parProj_id)                  ' Ensures parProj_id has a good value
600
Call Get_Releases(parProj_id, parRtag_id)      ' Ensures parRtag_id has a good value
601
 
602
If NOT bHidePackages Then
603
   Call Get_Packages (parRtag_id, parPv_id, parOp_code)
5549 dpurdie 604
End If
5560 dpurdie 605
 
606
' Perform any required actions
607
Call performActions
608
 
5549 dpurdie 609
'----------------------------------------------
610
%>
5560 dpurdie 611
<script language="JavaScript" type="text/javascript">
612
<!--
613
 
614
// This function is designed to be called when a repeat radio button is pressed. It reloads the page with an updated query string
615
// to reflect the new setting of the radio button set
616
function Refresh_Repeat(newRepeat)
617
{
618
   var s;
619
   s  = '<%=scriptName%>';
620
   s += '?inst_id=' + document.getElementById('inst_id').value;
621
   s += '&op_code=' + document.getElementById('op_code').value;
622
   s += '&proj_id=' + document.getElementById('proj_id').value;
623
   s += '&rtag_id=' + document.getElementById('rtag_id').value;
624
   s += '&pv_id='   + document.getElementById('pv_id').value;
625
   s += '&sort='    + document.getElementById('sortOrder').value;
626
   s += '&sdt='     + document.getElementById('scheduled_time').value;
627
   s += '&repeat='  + newRepeat;
628
   s += '&rfile='   + document.getElementById('rfile').value;
629
 
630
   document.location = s;
631
}
632
 
633
//-->
634
</script>
635
 
5549 dpurdie 636
<html>
637
   <head>
638
      <title>Release Manager</title>
639
      <link rel="shortcut icon" href="<%=FavIcon%>"/>
640
      <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
641
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6579 dpurdie 642
      <link href="images/release_manager_style.css?ver=<%=VixVerNum%>" rel="stylesheet" type="text/css">
6676 dpurdie 643
      <script language="JavaScript" src="scripts/common.js?ver=<%=VixVerNum%>"></script>
5636 dpurdie 644
      <%bJqueryTimePicker = TRUE%>
645
      <!--#include file="_jquery_includes.asp"-->
646
    <script>
647
    $(document).ready(function(){
648
    	var myDateTimePicker = null;
649
        $('#scheduled_time').datetimepicker({
650
    		timeFormat: "HH:mm",
651
            dateFormat: "D dd-M-yy",
652
    		controlType: 'select',
653
    		oneLine: true,
654
    		timeInput: true,
655
            constrainInput: true,
656
            showOn: 'both',
657
            buttonImageOnly : true,
658
            buttonImage: "images/cal.gif",
659
            buttonText: "Select Date and Time",
660
            minDate : 0,
661
    		onClose : function(p1,p2){
662
    			 //console.log("scheduled_time", p1 );
663
    			},
664
    	    });
665
    	})
666
    </script>
667
    <style>
668
        #ui-datepicker-div {
669
            position: absolute !important;
670
            top: 0px !important;
671
            left: 0px !important;
672
            }
673
    </style>
5549 dpurdie 674
   </head>
675
 
5560 dpurdie 676
   <body background="images/bg_bage_0.gif" leftmargin="0" topmargin="0" >
677
      <table class="full_table">
5549 dpurdie 678
         <%
679
         '-- FROM START --------------------------------------------------------------------------------------------------------------
680
         objFormComponent.FormName = "DaemonInstruction"
5590 dpurdie 681
         objFormComponent.FormClass = "form_tight"
5549 dpurdie 682
         objFormComponent.Action = ScriptName &_
5560 dpurdie 683
                                   "?inst_id="& parInst_id &_
684
                                   "&op_code="& parOp_code &_
685
                                   "&proj_id="& parProj_id &_
5549 dpurdie 686
                                   "&rtag_id="& parRtag_id &_
5560 dpurdie 687
                                   "&pv_id="&   parPv_id &_
688
                                   "&sort="&    parSortOrder &_
689
                                   "&rfile="& parRfile
5549 dpurdie 690
         objFormComponent.OnSubmit = "ShowProgress();"
691
         Call objFormComponent.FormStart()
692
         %>
693
         <tr>
694
            <td>
5560 dpurdie 695
               <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++ -->
5549 dpurdie 696
               <%Call Messenger ( sMessage , sMessageType, "100%" )%>
697
               <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
698
               <!--#include file="messages/_msg_inline.asp"-->
699
               <table class="full_table form_item">
700
                  <tr>
5560 dpurdie 701
                     <td width="1%" class="nowrap">
702
                        <%=Get_OpCodes(parOp_code)%>
703
                     </td>
5549 dpurdie 704
                  </tr>
5560 dpurdie 705
                  <tr><td>&nbsp;</td></tr>
5549 dpurdie 706
                  <tr>
5560 dpurdie 707
                     <td class="nowrap">
708
                        <div id="SelectProject" style="visibility:visible">
709
                           <%=Get_Projects(parProj_id)%>
710
                        </div>
711
                     </td>
5549 dpurdie 712
                  </tr>
713
                  <tr>
5560 dpurdie 714
                     <td class="nowrap">
715
                        <div id="SelectRelease" style="visibility:visible">
716
                           <%=Get_Releases(parProj_id, parRtag_id)%>
717
                        </div>
718
                     </td>
5549 dpurdie 719
                  </tr>
5560 dpurdie 720
 
721
                  <%If NOT bHidePackages Then%>
5549 dpurdie 722
                  <tr>
5560 dpurdie 723
                     <td class="nowrap">
724
                        <div id="SelectPackageVersion" style="visibility:visible">
725
                           <%=Get_Packages ( parRtag_id, parPv_id, parOp_code )%>
726
                        </div>
727
                     </td>
5549 dpurdie 728
                  </tr>
5560 dpurdie 729
                  <%End If%>
730
 
731
                  <tr><td>&nbsp;</td></tr>
5549 dpurdie 732
                  <tr>
733
                     <td>
5560 dpurdie 734
                        <td class="nowrap">Scheduled Time</td>
735
                        <td>
5636 dpurdie 736
                           <input type="text" id="scheduled_time" name="scheduled_time" size="25" class="form_ivalue" value="<%=DisplayDateTime(parSchDateTime)%>">
5560 dpurdie 737
                        </td>
738
                     </td>
739
                  </tr>
740
 
741
                  <%If NOT bHideRepeat Then%>
742
                     <tr>
743
                        <td>
744
                           <td>Repeat</td>
745
                           <td>
746
                              <input type="radio" name="repeat_inst" id="repeat_inst_no"     value="No"   <%If parRepeat =     "0" Then%>checked<%End If%> onchange='Refresh_Repeat(0)'     >No
747
                              <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
748
                           </td>
749
                        </td>
750
                     </tr>
751
                  <%End If%>
5636 dpurdie 752
                  <tr>
753
                    <td style="height:100px">
754
                    </td>
755
                  </tr>
5560 dpurdie 756
                 <tr>
757
                    <td background="images/bg_login.gif" colspan=3>
758
                       <table class="full_table">
759
                          <tr>
5590 dpurdie 760
                             <td><%=ProgressBar()%></td>
5636 dpurdie 761
                             <td align="right" >
5560 dpurdie 762
                                <%
763
                                Dim disableText : disableText = ""
764
                                If NOT (ReleasesAvailable(parProj_id) AND DaemonsAvailable(parRtag_id) AND NOT bPreventSubmit AND IsNull(sMessage)) Then
765
                                    disableText = "disabled=""disabled"""
766
                                End If
767
                                %>
768
                                <button name="btn" type="submit" <%=disableText%>>Add/Update</button>
5590 dpurdie 769
                                <button name="btn" type="reset" onclick="parent.closeIFrame();">Cancel</button>
5560 dpurdie 770
                             </td>
771
                          </tr>
772
                       </table>
773
                    </td>
774
                 </tr>
775
                  <tr>
776
                     <td>
777
                        <input type="hidden" id="inst_id"     name="inst_id"      value="<%=parInst_id%>">
778
                        <input type="hidden" id="op_code"     name="op_code"      value="<%=parOp_code%>">
779
                        <input type="hidden" id="proj_id"     name="proj_id"      value="<%=parProj_id%>">
5549 dpurdie 780
                        <input type="hidden" id="rtag_id"     name="rtag_id"      value="<%=parRtag_id%>">
781
                        <input type="hidden" id="pv_id"       name="pv_id"        value="<%=parPv_id%>">
5560 dpurdie 782
                        <input type="hidden" id="repeat_secs" name="repeat_secs"  value="<%=parRepeat%>">
5549 dpurdie 783
                        <input type="hidden" id="rfile"       name="rfile"        value="<%=parRfile%>">
5560 dpurdie 784
                        <input type="hidden" id="sortOrder"   name="sortOrder"    value="<%=parSortOrder%>">
5549 dpurdie 785
                     </td>
786
                  </tr>
787
               </table>
788
            </td>
789
         </tr>
790
         <%=objPMod.ComposeHiddenTags()%>
791
         <input type="hidden" name="action" value="true">
792
 
793
         <%
794
         Call objFormComponent.FormEnd()
795
         '-- FROM END ----------------------------------------------------------------------------------------------------------------
796
         %>
797
      </table>
798
   </body>
799
</html>
800
<%
801
'------------ RUN AFTER PAGE RENDER -----------
802
Set objFormCollector = Nothing
803
'----------------------------------------------
804
Call Destroy_All_Objects
805
%>
806
 
807