Subversion Repositories DevTools

Rev

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