-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeforeRajesh.js
955 lines (839 loc) · 34.5 KB
/
beforeRajesh.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
//***************************************************************
//* Project Name : GSS
//* Application name :Genomics Experiments
//* Dependencies :
//* Limitations :
//* Created Date :30 Dec 2012
//* Author :Vijay Bhaskar C
//****************************************************************
var url = window.location.search;
var n = url.indexOf("itmid");
var IshavingItm = false;
var itmid = "";
var curUser = $().SPServices.SPGetCurrentUser();
//var curUser = "NA\\yeddula.ar";
//var curUser = "CN\\bolla.su";
//var curUser = "EU\\terala.l";
//var curUser = "ap\\thaduri.us";
//onload function
$(document).ready(function () {
load();
if (n > -1)
IshavingItm = true;
else
IshavingItm = false;
//alert(IshavingItm);
isGc();
$("#progressbar").hide();
//submit study information
$('#studyInfo').click(function () {
submitStudyInfo();
});
$('#btnMilestones').click(function () {
submitMilestoneInfo();
});
$('#btnBuGc').click(function () {
submitstudyDetails();
});
$('#btnStatistics').click(function () {
submitStatistics();
});
$('#btnBioInfo').click(function () {
submitBioinfo();
});
$("#reqStudy").click(function () {
addPurpose();
});
//allow only numbers
$('#txtSamples').bind('keypress', function (e) {
return (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) ? false : true;
});
getDatePicker();
fillSelects();
if (IshavingItm) {
itmid = window.location.search.split("?itmid=")[1];
contentLoad(itmid);
} else {
$("#div1 :input").attr('disabled', true);
$("#div2 :input").attr('disabled', true);
$("#div3 :input").attr('disabled', true);
$("#div4 :input").attr('disabled', true);
$("#div5 :input").attr('disabled', true);
}
});
function getDatePicker() {
$("[id$='Date']").datepicker({
minDate : '0'
});
}
var isgcUser = false;
function isGc() {
$().SPServices({
operation : "GetGroupCollectionFromUser",
userLoginName : curUser,
async : false,
completefunc : function (xData, Status) {
if ($(xData.responseXML).find("Group[Name='GC']").length == 1) {
$("#div1 :input").attr('disabled', false);
isgcUser = true;
} else {
isgcUser = false;
$('#div1').find('img:last').hide();
$('#div2').find('img:last').hide();
$('#div3').find('img:last').hide();
$('#div4').find('img:last').hide();
$('#div5').find('img:last').hide();
$("[id$='Attach']").hide();
$("#div1 :input").attr('disabled', true);
$("#div2 :input").attr('disabled', true);
$("#div3 :input").attr('disabled', true);
$("#div4 :input").attr('disabled', true);
$("#div5 :input").attr('disabled', true);
}
}
});
}
//fill existed item
function contentLoad(itmid) {
//debugger
$().SPServices({
operation : "GetListItems",
async : false,
listName : "Study",
CAMLQueryOptions : "<QueryOptions><IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls></QueryOptions>",
CAMLQuery : "<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + itmid + "</Value></Eq></Where></Query>",
completefunc : function (xData, Status) {
//alert(xData.responseText);
$(xData.responseXML).SPFilterNode("z:row").each(function () {
//request study
if ($(this).attr("ows_Purpose") != null) {
var purpose = $(this).attr("ows_Purpose").split(";")[0];
$("#selPurpose").val(purpose);
if (!isgcUser && IshavingItm) {
$('#divmain').find('img:last').hide();
$("#divmain").attr('disabled', true);
}
}
if ($(this).attr("ows_Fundamental_questions") != null) {
var FundamentalQuestion = $(this).attr("ows_Fundamental_questions");
$("#txtQuestion").val(FundamentalQuestion);
}
//request study
//studyInformation
if ($(this).attr("ows_GSSID") != null) {
var txtGssId = $(this).attr("ows_GSSID");
$("#txtGssId").val(txtGssId);
} else {
var txtGssId = "GSS" + randomN();
$("#txtGssId").val(txtGssId);
$("#div2 :input").attr('disabled', true);
$("#div3 :input").attr('disabled', true);
$("#div4 :input").attr('disabled', true);
$("#div5 :input").attr('disabled', true);
}
if ($(this).attr("ows_GC_x0020_Analyst") != null) {
var txtGCAnalyst = $(this).attr("ows_GC_x0020_Analyst").split(";#")[1];
$("#ctl00_PlaceHolderMain_GCAnalyst_upLevelDiv").text(txtGCAnalyst);
$("#ctl00_PlaceHolderMain_GCAnalyst_checkNames").click();
}
if ($(this).attr("ows_Statistics_x0020_Owner") != null) {
var txtStatOwner = $(this).attr("ows_Statistics_x0020_Owner").split(";#")[1];
$("#ctl00_PlaceHolderMain_statistics_upLevelDiv").text(txtStatOwner);
$("#ctl00_PlaceHolderMain_statistics_checkNames").click();
if (getuserId(curUser) == $(this).attr("ows_Statistics_x0020_Owner").split(";#")[0]) {
$("#div3 :input").attr('disabled', false);
$('#div3').find('img:last').show();
$("#statAttach").show();
} else {
$("#div3 :input").attr('disabled', true);
$('#div3').find('img:last').hide();
$("#statAttach").hide();
}
}
if ($(this).attr("ows_Bio_x0020_Informatics_x0020_Owne") != null) {
var txtBioInforOwner = $(this).attr("ows_Bio_x0020_Informatics_x0020_Owne").split(";#")[1];
$("#ctl00_PlaceHolderMain_bolInfo_upLevelDiv").text(txtBioInforOwner);
$("#ctl00_PlaceHolderMain_bolInfo_checkNames").click();
if (getuserId(curUser) == $(this).attr("ows_Bio_x0020_Informatics_x0020_Owne").split(";#")[0]) {
$("#div4 :input").attr('disabled', false);
$('#div4').find('img:last').show();
$("#bioAttach").show();
} else {
$("#div4 :input").attr('disabled', true);
$('#div4').find('img:last').hide();
$("#bioAttach").hide();
}
}
if ($(this).attr("ows_Study_x0020_Name") != null) {
var txtStudyName = $(this).attr("ows_Study_x0020_Name");
$("#txtStudyName").val(txtStudyName);
}
if ($(this).attr("ows_DescriptionPurpose") != null) {
var txtPurpose = $(this).attr("ows_DescriptionPurpose");
$("#txtPurpose").val(txtPurpose);
}
if ($(this).attr("ows_Estimated_x0020_Number_x0020_of_") != null) {
var txtSamples = $(this).attr("ows_Estimated_x0020_Number_x0020_of_");
$("#txtSamples").val(txtSamples);
}
if ($(this).attr("ows_Chip_x0020_Type") != null) {
var selChipType = $(this).attr("ows_Chip_x0020_Type").split(";")[0];
$("#selChipType").val(selChipType);
}
if ($(this).attr("ows_ProtocolNumber") != null) {
var txtProtocol = $(this).attr("ows_ProtocolNumber");
$("#txtProtocol").val(txtProtocol);
}
if ($(this).attr("ows_Estimated_timing") != null) {
var timingsSampleDate = $(this).attr("ows_Estimated_timing");
timingsSampleDate = conDate(timingsSampleDate);
$("#timingsSampleDate").val(timingsSampleDate);
}
if ($(this).attr("ows_TissueType") != null) {
var selTissue = $(this).attr("ows_TissueType").split(";")[0];
$("#selTissue").val(selTissue);
}
//studyInformation
//Milestones
if ($(this).attr("ows_M1_Anticipated_Samples") != null) {
var PlannedSmplDate = $(this).attr("ows_M1_Anticipated_Samples");
PlannedSmplDate = conDate(PlannedSmplDate);
$("#PlannedSmplDate").val(PlannedSmplDate);
} else {
$("#div2 :input").attr('disabled', true);
$("#div3 :input").attr('disabled', true);
$("#div4 :input").attr('disabled', true);
}
if ($(this).attr("ows_M2a_RNA_Isolation_Date") != null) {
var rna2aDate = $(this).attr("ows_M2a_RNA_Isolation_Date");
rna2aDate = conDate(rna2aDate);
$("#rna2aDate").val(rna2aDate);
}
if ($(this).attr("ows_M2b_cRNA_Dates_Label") != null) {
var crna2bDate = $(this).attr("ows_M2b_cRNA_Dates_Label");
crna2bDate = conDate(crna2bDate);
$("#crna2bDate").val(crna2bDate);
}
if ($(this).attr("ows_M2c_Date_Chips_Run") != null) {
var chips2cDate = $(this).attr("ows_M2c_Date_Chips_Run");
chips2cDate = conDate(chips2cDate);
$("#chips2cDate").val(chips2cDate);
}
if ($(this).attr("ows_M2d_Date_Data_Posted") != null) {
var dataPosted2dDate = $(this).attr("ows_M2d_Date_Data_Posted");
dataPosted2dDate = conDate(dataPosted2dDate);
$("#dataPosted2dDate").val(dataPosted2dDate);
}
if ($(this).attr("ows_M3a_Initial_QC_completion_date") != null) {
var QC3aDate = $(this).attr("ows_M3a_Initial_QC_completion_date");
QC3aDate = conDate(QC3aDate);
$("#QC3aDate").val(QC3aDate);
}
if ($(this).attr("ows_M3b_Statistics_Report_Date") != null) {
var statistics3bDate = $(this).attr("ows_M3b_Statistics_Report_Date");
statistics3bDate = conDate(statistics3bDate);
$("#statistics3bDate").val(statistics3bDate);
}
if ($(this).attr("ows_M4_BioInformatics_Analysis_date") != null) {
var bioInformatics4Date = $(this).attr("ows_M4_BioInformatics_Analysis_date");
bioInformatics4Date = conDate(bioInformatics4Date);
$("#bioInformatics4Date").val(bioInformatics4Date);
}
if ($(this).attr("ows_Overall_Study_Status") != null) {
var selOverStatus = $(this).attr("ows_Overall_Study_Status");
$("#selOverStatus").val(selOverStatus);
}
if ($(this).attr("ows_Delayed") != null) {
var chkDelay = $(this).attr("ows_Delayed");
if (chkDelay == 1)
$('#chkDelay').attr('checked', true);
else
$('#chkDelay').attr('checked', false);
}
//Milestones
//BU/GC Study Details
if ($(this).attr("ows_M1_Actual_Samples_Received_Date") != null) {
var txtM1Date = $(this).attr("ows_M1_Actual_Samples_Received_Date");
txtM1Date = conDate(txtM1Date);
$("#txtM1Date").val(txtM1Date);
$("#PlannedSmplDate").attr('disabled', true);
} else {
//$("#PlannedSmplDate").attr('disabled', false);
}
if ($(this).attr("ows_Reason_for_Delay_m1") != null) {
var selM1Reason = $(this).attr("ows_Reason_for_Delay_m1").split(";")[0];
$("#selM1Reason").val(selM1Reason);
}
if ($(this).attr("ows_RNA_x0020_Procotol") != null) {
var selRNA = $(this).attr("ows_RNA_x0020_Procotol").split(";")[0];
$("#selRNA").val(selRNA);
}
if ($(this).attr("ows_M2a_act_RNA_Isolation_Date") != null) {
var txtM2aDate = $(this).attr("ows_M2a_act_RNA_Isolation_Date");
txtM2aDate = conDate(txtM2aDate);
$("#txtM2aDate").val(txtM2aDate);
$("#rna2aDate").attr('disabled', true);
} else {
//$("#rna2aDate").attr('disabled', false);
}
if ($(this).attr("ows_Reason_for_Delay_M2a") != null) {
var selM2Reason = $(this).attr("ows_Reason_for_Delay_M2a").split(";")[0];
$("#selM2Reason").val(selM2Reason);
}
if ($(this).attr("ows_Comments_M2a") != null) {
var txtCommentsM2a = $(this).attr("ows_Comments_M2a");
$("#txtCommentsM2a").val(txtCommentsM2a);
}
if ($(this).attr("ows_cRNA_Protocol") != null) {
var selcRNAprotocol = $(this).attr("ows_cRNA_Protocol").split(";")[0];
$("#selcRNAprotocol").val(selcRNAprotocol);
}
if ($(this).attr("ows_M2b_cRNA_act_Dates_Label") != null) {
var M2bDate = $(this).attr("ows_M2b_cRNA_act_Dates_Label");
M2bDate = conDate(M2bDate);
$("#M2bDate").val(M2bDate);
$("#crna2bDate").attr('disabled', true);
} else {
//$("#crna2bDate").attr('disabled', false);
}
if ($(this).attr("ows_M2c_act_Chips_Run_date") != null) {
var M2cDate = $(this).attr("ows_M2c_act_Chips_Run_date");
M2cDate = conDate(M2cDate);
$("#M2cDate").val(M2cDate);
$("#chips2cDate").attr('disabled', true);
} else {
//$("#chips2cDate").attr('disabled', false);
}
if ($(this).attr("ows_M2d_act_Data_Posted_date") != null) {
var M2dDate = $(this).attr("ows_M2d_act_Data_Posted_date");
M2dDate = conDate(M2dDate);
$("#M2dDate").val(M2dDate);
$("#dataPosted2dDate").attr('disabled', true);
} else {
//$("#dataPosted2dDate").attr('disabled', false);
}
if ($(this).attr("ows_Reason_for_Delay_m2b") != null) {
var selM2bReason = $(this).attr("ows_Reason_for_Delay_m2b").split(";")[0];
$("#selM2bReason").val(selM2bReason);
}
if ($(this).attr("ows_Reason_for_Delay_m2c") != null) {
var selM2cReason = $(this).attr("ows_Reason_for_Delay_m2c").split(";")[0];
$("#selM2cReason").val(selM2cReason);
}
if ($(this).attr("ows_Reason_for_Delay_m2d") != null) {
var selM2dReason = $(this).attr("ows_Reason_for_Delay_m2d").split(";")[0];
$("#selM2dReason").val(selM2dReason);
}
if ($(this).attr("ows_Comments_m2d") != null) {
var txtCommentsM2d = $(this).attr("ows_Comments_m2d");
$("#txtCommentsM2d").val(txtCommentsM2d);
}
//BU/GC Study Details
//Statistics
if ($(this).attr("ows_M3a_act_Initial_QC_completion_da") != null) {
var M3aDate = $(this).attr("ows_M3a_act_Initial_QC_completion_da");
M3aDate = conDate(M3aDate);
$("#M3aDate").val(M3aDate);
$("#QC3aDate").attr('disabled', true);
} else {
//$("#QC3aDate").attr('disabled', false);
}
if ($(this).attr("ows_M3b_act_Statistics_Report_Date") != null) {
var M3bDate = $(this).attr("ows_M3b_act_Statistics_Report_Date");
M3bDate = conDate(M3bDate);
$("#M3bDate").val(M3bDate);
$("#statistics3bDate").attr('disabled', true);
} else {
//$("#statistics3bDate").attr('disabled', false);
}
if ($(this).attr("ows_Reason_for_Delay_m3a") != null) {
var sel3aReason = $(this).attr("ows_Reason_for_Delay_m3a").split(";")[0];
$("#sel3aReason").val(sel3aReason);
}
if ($(this).attr("ows_Reason_for_Delay_m3b") != null) {
var sel3bReason = $(this).attr("ows_Reason_for_Delay_m3b").split(";")[0];
$("#sel3bReason").val(sel3bReason);
}
if ($(this).attr("ows_Comments_m3b") != null) {
var txtComments3b = $(this).attr("ows_Comments_m3b");
$("#txtComments3b").val(txtComments3b);
}
//Statistics
//BioInformatics
if ($(this).attr("ows_BioInformatics_Analysis_date_4") != null) {
var M4Date = $(this).attr("ows_BioInformatics_Analysis_date_4");
M4Date = conDate(M4Date);
$("#M4Date").val(M4Date);
$("#bioInformatics4Date").attr('disabled', true);
} else {
//$("#bioInformatics4Date").attr('disabled', false);
}
if ($(this).attr("ows_Reason_for_Delay_4") != null) {
var sel4Reason = $(this).attr("ows_Reason_for_Delay_4").split(";")[0];
$("#sel4Reason").val(sel4Reason);
}
if ($(this).attr("ows_Comments_4") != null) {
var txtComments4 = $(this).attr("ows_Comments_4");
$("#txtComments4").val(txtComments4);
}
});
}
});
}
//change date format to jquery calendar
function conDate(date) {
var ndate = date.split(" ")[0];
ndate = ndate.split('-')[1] + "/" + ndate.split('-')[2] + "/" + ndate.split('-')[0];
//alert(ndate);
return ndate;
}
//check validations
function chkAllfilled(divID) {
var status = false;
$("#" + divID).find("input[type=text]").each(function () {
//debugger
if ($(this).val() == "") {
status = true;
$(this).focus();
return false;
}
});
$("#" + divID).find("select").each(function () {
var n = $(this).prop("selectedIndex");
//alert(n);
if (n == 0) {
status = true;
$(this).focus();
return false;
}
});
$("#" + divID).find("textarea").each(function () {
if ($(this).val() == "") {
status = true;
$(this).focus();
return false;
}
});
if (status == true) {
alert("Please fill all mandatory fields.");
} else {
return true;
}
}
//submit study info
function submitStudyInfo() {
var gssCode = $('#txtGssId').val();
var userGC = $('#ctl00_PlaceHolderMain_GCAnalyst_downlevelTextBox').val();
var statisticOwner = $('#ctl00_PlaceHolderMain_statistics_downlevelTextBox').val();
var bioInfoOwner = $('#ctl00_PlaceHolderMain_bolInfo_downlevelTextBox').val(); ;
var studyName = $('#txtStudyName').val();
var descriptionPurpose = $('#txtPurpose').val();
var numOfsamples = $('#txtSamples').val();
var strChipTypeVal = $("select[id='selChipType'] option:selected").val();
var protocolNumber = $('#txtProtocol').val();
var timingsOfsample = $('#timingsSampleDate').val();
var strTissueTypeVal = $("select[id='selTissue'] option:selected").val();
var strBatch = "<Batch OnError='Continue' PreCalc='TRUE'>" +
"<Method ID='1' Cmd='Update'>" +
"<Field Name='GSSID'>" + gssCode + "</Field>" +
"<Field Name='GC_x0020_Analyst'>" + getuserId(userGC) + "</Field>" +
"<Field Name='Statistics_x0020_Owner'>" + getuserId(statisticOwner) + "</Field>" +
"<Field Name='Bio_x0020_Informatics_x0020_Owne'>" + getuserId(bioInfoOwner) + "</Field>" +
"<Field Name='Study_x0020_Name'>" + studyName + "</Field>" +
"<Field Name='DescriptionPurpose'>" + descriptionPurpose + "</Field>" +
"<Field Name='Estimated_x0020_Number_x0020_of_'>" + numOfsamples + "</Field>" +
"<Field Name='Chip_x0020_Type'>" + strChipTypeVal + "</Field>" +
"<Field Name='ProtocolNumber'>" + protocolNumber + "</Field>" +
"<Field Name='Estimated_timing'>" + SPdate(timingsOfsample) + "</Field>" +
"<Field Name='TissueType'>" + strTissueTypeVal + "</Field>" +
"<Field Name='enableStage'>Step2</Field>" +
"<Field Name='ID'>" + itmid + "</Field>" +
"</Method>" +
"</Batch>";
if (chkAllfilled('div1')) {
update(strBatch);
}
}
//create milestones
function submitMilestoneInfo() {
var selOverStatus = $("select[id='selOverStatus'] option:selected").val();
var PlannedSmplDate = $('#PlannedSmplDate').val();
var rna2aDate = $('#rna2aDate').val();
var crna2bDate = $('#crna2bDate').val();
var chips2cDate = $('#chips2cDate').val();
var dataPosted2dDate = $('#dataPosted2dDate').val();
var QC3aDate = $('#QC3aDate').val();
var statistics3bDate = $('#statistics3bDate').val();
var bioInformatics4Date = $('#bioInformatics4Date').val();
var chkDelay = $('#chkDelay').attr('checked') ? 1 : 0;
var strBatch = "<Batch OnError='Continue' PreCalc='TRUE'>" +
"<Method ID='1' Cmd='Update'>" +
"<Field Name='M1_Anticipated_Samples'>" + SPdate(PlannedSmplDate) + "</Field>" +
"<Field Name='M2a_RNA_Isolation_Date'>" + SPdate(rna2aDate) + "</Field>" +
"<Field Name='M2b_cRNA_Dates_Label'>" + SPdate(crna2bDate) + "</Field>" +
"<Field Name='M2c_Date_Chips_Run'>" + SPdate(chips2cDate) + "</Field>" +
"<Field Name='M2d_Date_Data_Posted'>" + SPdate(dataPosted2dDate) + "</Field>" +
"<Field Name='M3a_Initial_QC_completion_date'>" + SPdate(QC3aDate) + "</Field>" +
"<Field Name='M3b_Statistics_Report_Date'>" + SPdate(statistics3bDate) + "</Field>" +
"<Field Name='M4_BioInformatics_Analysis_date'>" + SPdate(bioInformatics4Date) + "</Field>" +
"<Field Name='Overall_Study_Status'>" + selOverStatus + "</Field>" +
"<Field Name='Delayed'>" + chkDelay + "</Field>" +
"<Field Name='ReminderIds'>Reminder IDs will be placed</Field>" +
"<Field Name='ID'>" + itmid + "</Field>" +
"</Method>" +
"</Batch>";
if (chkAllfilled('div5')) {
update(strBatch);
}
}
//to submit BU & GC Study details
function submitstudyDetails() {
var txtM1Date = SPdate($('#txtM1Date').val());
var selRNA = $("select[id='selRNA'] option:selected").val();
var selM1Reason = $("select[id='selM1Reason'] option:selected").val();
var txtM2aDate = SPdate($('#txtM2aDate').val());
var selM2Reason = $("select[id='selM2Reason'] option:selected").val();
var txtCommentsM2a = $('#txtCommentsM2a').val();
var selcRNAprotocol = $("select[id='selcRNAprotocol'] option:selected").val();
var M2bDate = SPdate($('#M2bDate').val());
var M2cDate = SPdate($('#M2cDate').val());
var M2dDate = SPdate($('#M2dDate').val());
var selM2bReason = $("select[id='selM2bReason'] option:selected").val();
var selM2cReason = $("select[id='selM2cReason'] option:selected").val();
var selM2dReason = $("select[id='selM2dReason'] option:selected").val();
var txtCommentsM2d = $('#txtCommentsM2d').val();
var strBatch = "<Batch OnError='Continue' PreCalc='TRUE'>" +
"<Method ID='1' Cmd='Update'>" +
"<Field Name='M1_Actual_Samples_Received_Date'>" + txtM1Date + "</Field>" +
"<Field Name='Reason_for_Delay_m1'>" + selM1Reason + "</Field>" +
"<Field Name='RNA_x0020_Procotol'>" + selRNA + "</Field>" +
"<Field Name='M2a_act_RNA_Isolation_Date'>" + txtM2aDate + "</Field>" +
"<Field Name='Reason_for_Delay_M2a'>" + selM2Reason + "</Field>" +
"<Field Name='Comments_M2a'>" + txtCommentsM2a + "</Field>" +
"<Field Name='cRNA_Protocol'>" + selcRNAprotocol + "</Field>" +
"<Field Name='M2b_cRNA_act_Dates_Label'>" + M2bDate + "</Field>" +
"<Field Name='Reason_for_Delay_m2b'>" + selM2bReason + "</Field>" +
"<Field Name='M2c_act_Chips_Run_date'>" + M2cDate + "</Field>" +
"<Field Name='Reason_for_Delay_m2c'>" + selM2cReason + "</Field>" +
"<Field Name='M2d_act_Data_Posted_date'>" + M2dDate + "</Field>" +
"<Field Name='Reason_for_Delay_m2d'>" + selM2dReason + "</Field>" +
"<Field Name='Comments_m2d'>" + txtCommentsM2d + "</Field>" +
"<Field Name='ID'>" + itmid + "</Field>" +
"</Method>" +
"</Batch>";
//debugger
if (chkAllfilled('div2')) {
update(strBatch);
}
}
function isValid() {
DateComparison();
}
function submitStatistics() {
var M3aDate = SPdate($('#M3aDate').val());
var M3bDate = SPdate($('#M3bDate').val());
var sel3aReason = $("select[id='sel3aReason'] option:selected").val();
var sel3bReason = $("select[id='sel3bReason'] option:selected").val();
var txtComments3b = $('#txtComments3b').val();
var strBatch = "<Batch OnError='Continue' PreCalc='TRUE'>" +
"<Method ID='1' Cmd='Update'>" +
"<Field Name='M3a_act_Initial_QC_completion_da'>" + M3aDate + "</Field>" +
"<Field Name='Reason_for_Delay_m3a'>" + sel3aReason + "</Field>" +
"<Field Name='M3b_act_Statistics_Report_Date'>" + M3bDate + "</Field>" +
"<Field Name='Reason_for_Delay_m3b'>" + sel3bReason + "</Field>" +
"<Field Name='Comments_m3b'>" + txtComments3b + "</Field>" +
"<Field Name='ID'>" + itmid + "</Field>" +
"</Method>" +
"</Batch>";
if (chkAllfilled('div3')) {
update(strBatch);
}
}
function submitBioinfo() {
var M4Date = SPdate($('#M4Date').val());
var sel4Reason = $("select[id='sel4Reason'] option:selected").val();
var txtComments4 = $('#txtComments4').val();
var strBatch = "<Batch OnError='Continue' PreCalc='TRUE'>" +
"<Method ID='1' Cmd='Update'>" +
"<Field Name='BioInformatics_Analysis_date_4'>" + M4Date + "</Field>" +
"<Field Name='Reason_for_Delay_4'>" + sel4Reason + "</Field>" +
"<Field Name='Comments_4'>" + txtComments4 + "</Field>" +
"<Field Name='ID'>" + itmid + "</Field>" +
"</Method>" +
"</Batch>";
if (chkAllfilled('div4')) {
update(strBatch);
}
}
function update(strBatch) {
$().SPServices({
operation : "UpdateListItems",
async : false,
batchCmd : "Update",
listName : "Study",
updates : strBatch,
debug : true,
completefunc : function (xData, Status) {
if (Status != 'success')
alert(Status);
else {
jAlert('Item Submitted', 'Alert Dialog');
}
}
});
}
//convert date to SPDate
function SPdate(strdate) {
var Gdate = strdate.split('/')[2] + "-" + strdate.split('/')[0] + "-" + strdate.split('/')[1] + "T00:00:00Z";
//2013-01-28T00:00:00Z
return Gdate;
}
//get user id by passing the login name
function getuserId(userName) {
var uId = '';
$().SPServices({
operation : 'GetUserInfo',
userLoginName : userName,
async : false,
completefunc : function (xData, Status) {
//alert(xData.responseText);
$(xData.responseXML).SPFilterNode("User").each(function () {
uId = $(this).attr("ID");
});
}
});
return uId;
}
//fill dropdowns
function fillSelects() {
addOption(document.getElementById('selPurpose'), 'Purpose');
addOption(document.getElementById('selChipType'), 'Chip Type');
addOption(document.getElementById('selTissue'), 'Tissue Type');
addOption(document.getElementById('selRNA'), 'RNA Procotol');
addOption(document.getElementById('selcRNAprotocol'), 'cRNA Protocol');
addOption(document.getElementById('selcRNAprotocol'), 'cRNA Protocol');
addOption(document.getElementById('selM1Reason'), 'Milestone1 Delay Reason');
addOption(document.getElementById('selM2Reason'), 'Milestone2a Delay Reason');
addOption(document.getElementById('selM2bReason'), 'Milestone2b Delay Reason');
addOption(document.getElementById('selM2cReason'), 'Milestone2c Delay Reason');
addOption(document.getElementById('selM2dReason'), 'Milestone2d Delay Reason');
addOption(document.getElementById('sel3aReason'), 'Milestone3a-3b Delay Reason');
addOption(document.getElementById('sel3bReason'), 'Milestone3a-3b Delay Reason');
addOption(document.getElementById('sel4Reason'), 'Milestone4 Delay Reason');
}
//add options to dropdown controls
function addOption(selectbox, strCat) {
//debugger
var options = loadControls(strCat);
var items = options[0];
var vals = options[1];
for (i = 0; i < items.length; i++) {
var optn = document.createElement("OPTION");
optn.text = items[i];
optn.value = vals[i];
selectbox.options.add(optn);
}
}
//reset controls
function resetControls() {
$('input[type="text"]').val('');
$('select').prop('selectedIndex', 0);
$('textarea').val('');
}
//load control items from the source list
function loadControls(strCat) {
var selOptions = new Array();
var FSObjType = new Array();
var i = 0;
$().SPServices({
operation : "GetListItems",
async : false,
listName : "Keywords",
CAMLViewFields : "<ViewFields><FieldRef Name='Title' /></ViewFields>",
CAMLQuery : "<Query><OrderBy><FieldRef Name='Category' /><FieldRef Name='ID' /></OrderBy><Where><Contains><FieldRef Name='Category' /><Value Type='Choice'>" + strCat + "</Value></Contains></Where></Query>",
completefunc : function (xData, Status) {
if (Status == 'success') {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
selOptions[i] = $(this).attr("ows_Title");
FSObjType[i] = $(this).attr("ows_FSObjType").split(';')[0];
i++;
});
} else {
alert(Status);
}
}
});
//debugger
return [selOptions, FSObjType];
}
//add item when clicked submit button
function addPurpose() {
var errMsgQue = "Please enter Question";
var errMsgPur = "Please select valid Purpose";
if (DropdownValidation('selPurpose', '-Select Purpose-', errMsgPur) && TextValidation('txtQuestion', errMsgQue)) {
var strPurpose = $("select[id='selPurpose'] option:selected").text();
var strPurposeval = $("select[id='selPurpose'] option:selected").val();
var strQuestion = $("textarea#txtQuestion").val();
if (strPurpose != '-Select Purpose-') {
//alert(strPurpose + "," + strQuestion);
$().SPServices({
operation : "UpdateListItems",
async : false,
batchCmd : "New",
listName : "Study",
updates : "<Batch OnError='Continue' PreCalc='TRUE'>" +
"<Method ID='1' Cmd='New'>" +
"<Field Name='Fundamental_questions'>" + strQuestion + "</Field>" +
"<Field Name='Purpose' Type='LookUp' LookUpID='True'>" + strPurposeval + "</Field>" +
"<Field Name='enableStage'>Step1</Field>" +
"</Method>" +
"</Batch>",
completefunc : function (xData, Status) {
resetControls();
jAlert('Successfully added', 'Alert Dialog');
if (Status != 'success')
alert(Status);
}
});
} else
alert('Please select valid item');
}
}
//generate random number
function randomN() {
var randomNum = Math.floor((Math.random() * 1000) + 1);
return randomNum;
}
//to load first div
function load() {
document.getElementById("divmain").style.display = 'block';
document.getElementById("div1").style.display = 'none';
document.getElementById("div2").style.display = 'none';
document.getElementById("div3").style.display = 'none';
document.getElementById("div4").style.display = 'none';
document.getElementById("div5").style.display = 'none';
}
//to load other tabs when cliked on the tabs
function GeneralDiv(divs) {
document.getElementById("tb1").src = '../../images/tb1_nor.jpg';
document.getElementById("tb2").src = '../../images/tb2_ovr.jpg';
document.getElementById("tb3").src = '../../images/tb3_ovr.jpg';
document.getElementById("tb4").src = '../../images/tb4_ovr.jpg';
document.getElementById("tb5").src = '../../images/tb5_ovr.jpg';
document.getElementById("tb6").src = '../../images/tb6_ovr.jpg';
if (divs == 1) {
document.getElementById("tb1").style.cursor = 'default';
document.getElementById("tb2").style.cursor = 'pointer';
document.getElementById("tb3").style.cursor = 'pointer';
document.getElementById("tb4").style.cursor = 'pointer';
document.getElementById("tb5").style.cursor = 'pointer';
document.getElementById("tb6").style.cursor = 'pointer';
document.getElementById("divmain").style.display = 'block';
document.getElementById("div1").style.display = 'none';
document.getElementById("div2").style.display = 'none';
document.getElementById("div3").style.display = 'none';
document.getElementById("div4").style.display = 'none';
document.getElementById("div5").style.display = 'none';
document.getElementById("tb1").src = '../../images/tb1_nor.jpg';
document.getElementById("tb2").src = '../../images/tb2_ovr.jpg';
document.getElementById("tb3").src = '../../images/tb3_ovr.jpg';
document.getElementById("tb4").src = '../../images/tb4_ovr.jpg';
document.getElementById("tb5").src = '../../images/tb5_ovr.jpg';
document.getElementById("tb6").src = '../../images/tb6_ovr.jpg';
} else if (divs == 2) {
document.getElementById("tb1").style.cursor = 'pointer';
document.getElementById("tb2").style.cursor = 'default';
document.getElementById("tb3").style.cursor = 'pointer';
document.getElementById("tb4").style.cursor = 'pointer';
document.getElementById("tb5").style.cursor = 'pointer';
document.getElementById("tb6").style.cursor = 'pointer';
document.getElementById("divmain").style.display = 'none';
document.getElementById("div1").style.display = 'block';
document.getElementById("div2").style.display = 'none';
document.getElementById("div3").style.display = 'none';
document.getElementById("div4").style.display = 'none';
document.getElementById("div5").style.display = 'none';
document.getElementById("tb1").src = '../../images/tb1_ovr.jpg';
document.getElementById("tb2").src = '../../images/tb2_nor.jpg';
document.getElementById("tb3").src = '../../images/tb3_ovr.jpg';
document.getElementById("tb4").src = '../../images/tb4_ovr.jpg';
document.getElementById("tb5").src = '../../images/tb5_ovr.jpg';
document.getElementById("tb6").src = '../../images/tb6_ovr.jpg';
} else if (divs == 3) {
document.getElementById("tb1").style.cursor = 'pointer';
document.getElementById("tb2").style.cursor = 'pointer';
document.getElementById("tb3").style.cursor = 'default';
document.getElementById("tb4").style.cursor = 'pointer';
document.getElementById("tb5").style.cursor = 'pointer';
document.getElementById("tb6").style.cursor = 'pointer';
document.getElementById("divmain").style.display = 'none';
document.getElementById("div1").style.display = 'none';
document.getElementById("div2").style.display = 'block';
document.getElementById("div3").style.display = 'none';
document.getElementById("div4").style.display = 'none';
document.getElementById("div5").style.display = 'none';
document.getElementById("tb1").src = '../../images/tb1_ovr.jpg';
document.getElementById("tb2").src = '../../images/tb2_ovr.jpg';
document.getElementById("tb3").src = '../../images/tb3_nor.jpg';
document.getElementById("tb4").src = '../../images/tb4_ovr.jpg';
document.getElementById("tb5").src = '../../images/tb5_ovr.jpg';
document.getElementById("tb6").src = '../../images/tb6_ovr.jpg';
} else if (divs == 4) {
document.getElementById("tb1").style.cursor = 'pointer';
document.getElementById("tb2").style.cursor = 'pointer';
document.getElementById("tb3").style.cursor = 'pointer';
document.getElementById("tb4").style.cursor = 'default';
document.getElementById("tb5").style.cursor = 'pointer';
document.getElementById("tb6").style.cursor = 'pointer';
document.getElementById("divmain").style.display = 'none';
document.getElementById("div1").style.display = 'none';
document.getElementById("div2").style.display = 'none';
document.getElementById("div3").style.display = 'block';
document.getElementById("div4").style.display = 'none';
document.getElementById("div5").style.display = 'none';
document.getElementById("tb1").src = '../../images/tb1_ovr.jpg';
document.getElementById("tb2").src = '../../images/tb2_ovr.jpg';
document.getElementById("tb3").src = '../../images/tb3_ovr.jpg';
document.getElementById("tb4").src = '../../images/tb4_nor.jpg';
document.getElementById("tb5").src = '../../images/tb5_ovr.jpg';
document.getElementById("tb6").src = '../../images/tb6_ovr.jpg';
} else if (divs == 5) {
document.getElementById("tb1").style.cursor = 'pointer';
document.getElementById("tb2").style.cursor = 'pointer';
document.getElementById("tb3").style.cursor = 'pointer';
document.getElementById("tb4").style.cursor = 'pointer';
document.getElementById("tb5").style.cursor = 'default';
document.getElementById("tb6").style.cursor = 'pointer';
document.getElementById("divmain").style.display = 'none';
document.getElementById("div1").style.display = 'none';
document.getElementById("div2").style.display = 'none';
document.getElementById("div3").style.display = 'none';
document.getElementById("div4").style.display = 'block';
document.getElementById("div5").style.display = 'none';
document.getElementById("tb1").src = '../../images/tb1_ovr.jpg';
document.getElementById("tb2").src = '../../images/tb2_ovr.jpg';
document.getElementById("tb3").src = '../../images/tb3_ovr.jpg';
document.getElementById("tb4").src = '../../images/tb4_ovr.jpg';
document.getElementById("tb5").src = '../../images/tb5_nor.jpg';
document.getElementById("tb6").src = '../../images/tb6_ovr.jpg';
} else if (divs == 6) {
document.getElementById("tb1").style.cursor = 'pointer';
document.getElementById("tb2").style.cursor = 'pointer';
document.getElementById("tb3").style.cursor = 'pointer';
document.getElementById("tb4").style.cursor = 'pointer';
document.getElementById("tb5").style.cursor = 'pointer';
document.getElementById("tb6").style.cursor = 'default';
document.getElementById("divmain").style.display = 'none';
document.getElementById("div1").style.display = 'none';
document.getElementById("div2").style.display = 'none';
document.getElementById("div3").style.display = 'none';
document.getElementById("div4").style.display = 'none';
document.getElementById("div5").style.display = 'block';
document.getElementById("tb1").src = '../../images/tb1_ovr.jpg';
document.getElementById("tb2").src = '../../images/tb2_ovr.jpg';
document.getElementById("tb3").src = '../../images/tb3_ovr.jpg';
document.getElementById("tb4").src = '../../images/tb4_ovr.jpg';
document.getElementById("tb5").src = '../../images/tb5_ovr.jpg';
document.getElementById("tb6").src = '../../images/tb6_nor.jpg';
}
}