Subversion Repositories DevTools

Rev

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