/
ajax_forms.php
1097 lines (879 loc) · 38.2 KB
/
ajax_forms.php
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
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
**************************************************************************************************************************
** CORAL Organizations Module
**
** Copyright (c) 2010 University of Notre Dame
**
** This file is part of CORAL.
**
** CORAL is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
**
** CORAL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along with CORAL. If not, see <http://www.gnu.org/licenses/>.
**
**************************************************************************************************************************
*/
include_once 'directory.php';
include_once 'user.php';
switch ($_GET['action']) {
case 'getOrganizationForm':
if (isset($_GET['organizationID'])) $organizationID = $_GET['organizationID']; else $organizationID = '';
$organization = new Organization(new NamedArguments(array('primaryKey' => $organizationID)));
//get parent organizations
$sanitizedInstance = array();
$instance = new Organization();
$parentOrganizationArray = array();
foreach ($organization->getParentOrganizations() as $instance) {
foreach (array_keys($instance->attributeNames) as $attributeName) {
$sanitizedInstance[$attributeName] = $instance->$attributeName;
}
$sanitizedInstance[$instance->primaryKeyName] = $instance->primaryKey;
array_push($parentOrganizationArray, $sanitizedInstance);
}
//get organization roles
$sanitizedInstance = array();
$instance = new OrganizationRole();
$organizationRoleProfileArray = array();
foreach ($organization->getOrganizationRoles() as $instance) {
$organizationRoleProfileArray[] = $instance->organizationRoleID;
}
//get all org roles for output in drop down
$organizationRoleArray = array();
$organizationRoleObj = new OrganizationRole();
$organizationRoleArray = $organizationRoleObj->allAsArray();
?>
<div id='div_organizationForm'>
<form id='organizationForm'>
<input type='hidden' name='editOrganizationID' id='editOrganizationID' value='<?php echo $organizationID; ?>'>
<table class="thickboxTable" style="background-image:url('images/title.gif');background-repeat:no-repeat;width:340px;">
<tr>
<td colspan='2'><span class='headerText'><?php if ($organizationID != "") { echo _("Update Organization"); }else{ echo _("Add New Organization"); } ?></span>
<br /></td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='organizationName'><b><?php echo _("Name:");?></b></label></td>
<td><input type='text' id='organizationName' name='organizationName' value = "<?php echo htmlentities($organization->name); ?>" style='width:220px;' /><span id='span_errors' style='color:red'></span></td>
</tr>
<?php if (count($parentOrganizationArray) > 0){ ?>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='parentOrganization'><b><?php echo _("Parent:");?></b></label></td>
<td>
<?php
foreach ($parentOrganizationArray as $parentOrganization){
echo "<input type='text' id='parentOrganization' name='parentOrganization' value = \"" . $parentOrganization['name'] . "\" style='width:220px;' />";
echo "<input type='hidden' id='parentOrganizationID' name='parentOrganizationID' value=\"" . $parentOrganization['organizationID'] . "\">";
}
?>
</td>
</tr>
<?php
}else{
?>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='parentOrganization'><b><?php echo _("Parent:");?></b></label></td>
<td>
<input type='text' id='parentOrganization' name='parentOrganization' value = '' style='width:220px;' />
<input type='hidden' id='parentOrganizationID' name='parentOrganizationID' value=''>
</td>
</tr>
<?php } ?>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='companyURL'><b><?php echo _("Company URL:");?></b></label></td>
<td><input type='text' id='companyURL' name='companyURL' value = '<?php if (!$organizationID) { echo "http://"; } else { echo $organization->companyURL; } ?>' style='width:220px' />
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='orgRoles'><b><?php echo _("Role(s):");?></b></label></td>
<td>
<table>
<?php
$i=0;
if (count($organizationRoleArray) > 0){
foreach ($organizationRoleArray as $organizationRoleIns){
$i++;
if(($i % 2)==1){
echo "<tr>\n";
}
if (in_array($organizationRoleIns['organizationRoleID'],$organizationRoleProfileArray)){
echo "<td><input class='check_roles' type='checkbox' name='" . $organizationRoleIns['organizationRoleID'] . "' id='" . $organizationRoleIns['organizationRoleID'] . "' value='" . $organizationRoleIns['organizationRoleID'] . "' checked /> " . $organizationRoleIns['shortName'] . "</td>\n";
}else{
echo "<td><input class='check_roles' type='checkbox' name='" . $organizationRoleIns['organizationRoleID'] . "' id='" . $organizationRoleIns['organizationRoleID'] . "' value='" . $organizationRoleIns['organizationRoleID'] . "' /> " . $organizationRoleIns['shortName'] . "</td>\n";
}
if(($i % 2)==0){
echo "</tr>\n";
}
}
if(($i % 2)==1){
echo "<td> </td></tr>\n";
}
}
?>
</table>
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='accountDetailText'><b><?php echo _("Account Details:");?></b></label></td>
<td><textarea rows='3' id='accountDetailText' name='accountDetailText' style='width:220px'><?php echo $organization->accountDetailText; ?></textarea></td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='noteText'><b><?php echo _("Notes:");?></b></label></td>
<td><textarea rows='3' id='noteText' name='noteText' style='width:220px'><?php echo $organization->noteText; ?></textarea></td>
</tr>
<tr style="vertical-align:middle;">
<td style="padding-top:8px;text-align:right;"> </td>
<td style="padding-top:8px;padding-right:8px;text-align:left;">
<table class='noBorderTable' style='width:100%;'>
<tr>
<td style='text-align:left'><input type='button' value='<?php echo _("submit");?>' name='submitOrganizationChanges' id ='submitOrganizationChanges'></td>
<td style='text-align:right'><input type='button' value='<?php echo _("cancel");?>' onclick="tb_remove()"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>
<script type="text/javascript" src="js/forms/organizationSubmitForm.js?random=<?php echo rand(); ?>"></script>
<?php
break;
case 'getAliasForm':
$organizationID = $_GET['organizationID'];
if (isset($_GET['aliasID'])) $aliasID = $_GET['aliasID']; else $aliasID = '';
$alias = new Alias(new NamedArguments(array('primaryKey' => $aliasID)));
//get all alias types for output in drop down
$aliasTypeArray = array();
$aliasTypeObj = new AliasType();
$aliasTypeArray = $aliasTypeObj->allAsArray();
?>
<div id='div_aliasForm'>
<form id='aliasForm'>
<input type='hidden' name='organizationID' id='organizationID' value='<?php echo $organizationID; ?>'>
<input type='hidden' name='editOrganizationID' id='editOrganizationID' value='<?php echo $organizationID; ?>'>
<input type='hidden' name='editAliasID' id='editAliasID' value='<?php echo $aliasID; ?>'>
<input type='hidden' name='showTab' id='showTab' value='alias'>
<table class="thickboxTable" style="background-image:url('images/title.gif');background-repeat:no-repeat;width:280px;">
<tr>
<td colspan='2'><span class='headerText'><?php if ($aliasID){ echo _("Update Alias"); } else { echo _("Add Alias"); } ?></span>
<span id='span_errors' style='color:red;'></span><br />
</td>
</tr>
<tr>
<td><label for='aliasTypeID'><b><?php echo _("Alias Type");?></b></label></td>
<td>
<select name='aliasTypeID' id='aliasTypeID'>
<?php
foreach ($aliasTypeArray as $aliasType){
if (!(trim(strval($aliasType['aliasTypeID'])) != trim(strval($alias->aliasTypeID)))){
echo "<option value='" . $aliasType['aliasTypeID'] . "' selected>" . $aliasType['shortName'] . "</option>\n";
}else{
echo "<option value='" . $aliasType['aliasTypeID'] . "'>" . $aliasType['shortName'] . "</option>\n";
}
}
?>
</select>
</td>
</tr>
<tr>
<td><label for='aliasName'><b><?php echo _("Name");?></b></label></td>
<td>
<input type='text' id='aliasName' name='aliasName' value = "<?php echo $alias->name; ?>" style='width:195px' /><span id='span_error_aliasName'></span>
</td>
</tr>
<tr style="vertical-align:middle;">
<td style="padding-top:8px;text-align:right;"> </td>
<td style="padding-top:8px;padding-right:8px;text-align:left;">
<table class='noBorderTable' style='width:100%;'>
<tr>
<td style='text-align:left'><input type='button' value='<?php echo _("submit");?>' name='submitAliasForm' id ='submitAliasForm'></td>
<td style='text-align:right'><input type='button' value='<?php echo _("cancel");?>' onclick="tb_remove()"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>
<script type="text/javascript" src="js/forms/aliasSubmitForm.js?random=<?php echo rand(); ?>"></script>
<?php
break;
case 'getInlineContactForm':
//get all contact roles for output in drop down
$contactRoleArray = array();
$contactRoleObj = new ContactRole();
$contactRoleArray = $contactRoleObj->allAsArray();
?>
<div style="display:inline-block;vertical-align:top;width:42%;">
<div class="form-element">
<label for="contactAddName">Name</label>
<input type='text' id='contactAddName' name='contactName' /><br />
<span id='span_error_contactAddName' class='smallDarkRedText'></span>
</div>
<div class="form-element">
<label for="emailAddress">Email</label>
<input type='text' id='emailAddress' name='emailAddress' />
<span id='span_error_contactEmailAddress' class='smallDarkRedText'></span>
</div>
</div>
<?php
if (count($contactRoleArray) > 0){
echo '<div style="display:inline-block;vertical-align:top;width:48%;">
<label style="display:block;" for="'.$contactRoleIns['contactRoleID'].'">Roles</label>';
foreach ($contactRoleArray as $contactRoleIns){
echo "<div class=\"form-element form-element-tight\">
<input class='check_roles' type='checkbox' name='" . $contactRoleIns['contactRoleID'] . "' id='" . $contactRoleIns['contactRoleID'] . "' value='" . $contactRoleIns['contactRoleID'] . "' />
<span class='smallText'>" . $contactRoleIns['shortName'] . "</span>
</div>";
}
echo '</div>
<input type="button" id="createContact" value="Create" />';
}
break;
case 'getContactForm':
$organizationID = $_GET['organizationID'];
if (isset($_GET['contactID'])) $contactID = $_GET['contactID']; else $contactID = '';
$contact = new Contact(new NamedArguments(array('primaryKey' => $contactID)));
if (($contact->archiveDate) && ($contact->archiveDate != '0000-00-00')){
$invalidChecked = 'checked';
}else{
$invalidChecked = '';
}
//get contact roles
$sanitizedInstance = array();
$instance = new ContactRole();
$contactRoleProfileArray = array();
foreach ($contact->getContactRoles() as $instance) {
$contactRoleProfileArray[] = $instance->contactRoleID;
}
//get all contact roles for output in drop down
$contactRoleArray = array();
$contactRoleObj = new ContactRole();
$contactRoleArray = $contactRoleObj->allAsArray();
?>
<div id='div_contactForm'>
<form id='contactForm'>
<input type='hidden' name='editOrganizationID' id='editOrganizationID' value='<?php echo $organizationID; ?>'>
<input type='hidden' name='editContactID' id='editContactID' value='<?php echo $contactID; ?>'>
<table class="thickboxTable" style="background-image:url('images/title.gif');background-repeat:no-repeat;width:340px;">
<tr>
<td colspan='2'><span class='headerText'><?php if ($contactID){ echo _("Update Contact"); } else { echo _("Add Contact"); } ?></span>
<span id='span_errors' style='color:red;'></span>
</td>
</tr>
<tr>
<td style='text-align:right'><label for='contactName'><b><?php echo _("Name:");?></b></label></td>
<td>
<input type='text' id='contactName' name='contactName' value = "<?php echo $contact->name; ?>" style='width:150px' /><span id='span_error_contactName' style='color:red'></span>
</td>
</tr>
<tr>
<td style='text-align:right'><label for='contactTitle'><b><?php echo _("Title:");?></b></label></td>
<td>
<input type='text' id='contactTitle' name='contactTitle' value = '<?php echo $contact->title; ?>' style='width:150px' />
</td>
</tr>
<tr>
<td style='text-align:right'><label for='phoneNumber'><b><?php echo _("Phone:");?></b></label></td>
<td>
<input type='text' id='phoneNumber' name='phoneNumber' value = '<?php echo $contact->phoneNumber; ?>' style='width:150px' />
</td>
</tr>
<tr>
<td style='text-align:right'><label for='altPhoneNumber'><b><?php echo _("Alt Phone:");?></b></label></td>
<td>
<input type='text' id='altPhoneNumber' name='altPhoneNumber' value = '<?php echo $contact->altPhoneNumber; ?>' style='width:150px' />
</td>
</tr>
<tr>
<td style='text-align:right'><label for='faxNumber'><b><?php echo _("Fax:");?></b></label></td>
<td>
<input type='text' id='faxNumber' name='faxNumber' value = '<?php echo $contact->faxNumber; ?>' style='width:150px' />
</td>
</tr>
<tr>
<td style='text-align:right'><label for='emailAddress'><b><?php echo _("Email:");?></b></label></td>
<td>
<input type='text' id='emailAddress' name='emailAddress' value = '<?php echo $contact->emailAddress; ?>' style='width:150px' />
</td>
</tr>
<tr>
<td style='text-align:right'><label for='invalidInd'><b><?php echo _("Archived:");?></b></label></td>
<td>
<input type='checkbox' id='invalidInd' name='invalidInd' <?php echo $invalidChecked; ?> />
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right'><label for='addressText'><b><?php echo _("Address:");?></b></label></td>
<td><textarea rows='3' id='addressText' name='addressText' style='width:150px;'><?php echo $contact->addressText; ?></textarea></td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='orgRoles'><b><?php echo _("Role(s):");?></b></label></td>
<td>
<table>
<?php
$i=0;
if (count($contactRoleArray) > 0){
foreach ($contactRoleArray as $contactRoleIns){
$i++;
if(($i % 3)==1){
echo "<tr>\n";
}
if (in_array($contactRoleIns['contactRoleID'],$contactRoleProfileArray)){
echo "<td style='vertical-align:top;text-align:left;'><input class='check_roles' type='checkbox' name='" . $contactRoleIns['contactRoleID'] . "' id='" . $contactRoleIns['contactRoleID'] . "' value='" . $contactRoleIns['contactRoleID'] . "' checked /> <span class='smallText'>" . $contactRoleIns['shortName'] . "</span></td>\n";
}else{
echo "<td style='vertical-align:top;text-align:left;'><input class='check_roles' type='checkbox' name='" . $contactRoleIns['contactRoleID'] . "' id='" . $contactRoleIns['contactRoleID'] . "' value='" . $contactRoleIns['contactRoleID'] . "' /> <span class='smallText'>" . $contactRoleIns['shortName'] . "</span></td>\n";
}
if(($i % 3)==0){
echo "</tr>\n";
}
}
if(($i % 3)==1){
echo "<td> </td><td> </td></tr>\n";
}else if(($i % 3)==2){
echo "<td> </td></tr>\n";
}
}
?>
</table>
<span id='span_error_contactRole' class='redText'></span>
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right'><label for='noteText'><b><?php echo _("Notes:");?></b></label></td>
<td><textarea cols='36' rows='6' id='noteText' name='noteText' style='width:250px;'><?php echo $contact->noteText; ?></textarea></td>
</tr>
<tr style="vertical-align:middle;">
<td style="padding-left:8px;padding-top:8px;"> </td>
<td style="padding-top:8px;padding-right:8px;">
<table class='noBorderTable' style='width:100%;'>
<tr>
<td style='text-align:left'><input type='button' value='<?php echo _("submit");?>' name='submitContactForm' id ='submitContactForm'></td>
<td style='text-align:right'><input type='button' value='<?php echo _("cancel");?>' onclick="tb_remove()"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>
<script type="text/javascript" src="js/forms/contactSubmitForm.js?random=<?php echo rand(); ?>"></script>
<?php
break;
case 'getAccountForm':
$organizationID = $_GET['organizationID'];
if (isset($_GET['externalLoginID'])) $externalLoginID = $_GET['externalLoginID']; else $externalLoginID = '';
$externalLogin = new ExternalLogin(new NamedArguments(array('primaryKey' => $externalLoginID)));
//get all contact roles for output in drop down
$externalLoginTypeArray = array();
$externalLoginTypeObj = new ExternalLoginType();
$externalLoginTypeArray = $externalLoginTypeObj->allAsArray();
?>
<div id='div_organizationForm'>
<form id='organizationForm'>
<input type='hidden' name='editOrganizationID' id='editOrganizationID' value='<?php echo $organizationID; ?>'>
<input type='hidden' name='editExternalLoginID' id='editExternalLoginID' value='<?php echo $externalLoginID; ?>'>
<table class="thickboxTable" style="background-image:url('images/title.gif');background-repeat:no-repeat;width:340px;">
<tr>
<td colspan='2'><span class='headerText'><?php if ($externalLoginID){ echo _("Update Login"); } else { echo _("Add Login"); } ?></span>
<span id='span_errors' style='color:red;'></span><br />
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='externalLoginTypeID'><b><?php echo _("Login Type:");?></b></label></td>
<td>
<select name='externalLoginTypeID' id='externalLoginTypeID'>
<?php
foreach ($externalLoginTypeArray as $externalLoginType){
if ($externalLoginType['externalLoginTypeID'] == $externalLogin->externalLoginTypeID){
echo "<option value='" . $externalLoginType['externalLoginTypeID'] . "' selected>" . $externalLoginType['shortName'] . "</option>\n";
}else{
echo "<option value='" . $externalLoginType['externalLoginTypeID'] . "'>" . $externalLoginType['shortName'] . "</option>\n";
}
}
?>
</select>
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='loginURL'><b><?php echo _("URL:");?></b></label></td>
<td>
<input type='text' id='loginURL' name='loginURL' value = '<?php echo $externalLogin->loginURL; ?>' style='width:200px' />
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='emailAddress'><b><?php echo _("Local Account Email:");?></b></label></td>
<td>
<input type='text' id='emailAddress' name='emailAddress' value = '<?php echo $externalLogin->emailAddress; ?>' style='width:200px' />
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='username'><b><?php echo _("Username:");?></b></label></td>
<td>
<input type='text' id='username' name='username' value = '<?php echo $externalLogin->username; ?>' style='width:200px' />
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='password'><b><?php echo _("Password:");?></b></label></td>
<td>
<input type='text' id='password' name='password' value = '<?php echo $externalLogin->password; ?>' style='width:200px' />
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='noteText'><b><?php echo _("Notes:");?></b></label></td>
<td><textarea rows='3' id='noteText' name='noteText' style='width:200px'><?php echo $externalLogin->noteText; ?></textarea></td>
</tr>
<tr style="vertical-align:middle;">
<td style="padding-left:8px;padding-top:8px;"> </td>
<td style="padding-top:8px;padding-right:8px;">
<table class='noBorderTable' style='width:100%;'>
<tr>
<td style='text-align:left'><input type='button' value='<?php echo _("submit");?>' name='submitExternalLoginForm' id ='submitExternalLoginForm'></td>
<td style='text-align:right'><input type='button' value='<?php echo _("cancel");?>' onclick="tb_remove()"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>
<script type="text/javascript" src="js/forms/externalLoginSubmitForm.js?random=<?php echo rand(); ?>"></script>
<?php
break;
case 'getCloseResourceIssueForm':
$issueID = $_GET['issueID'];
?>
<div id="closeIssue">
<form>
<input type="hidden" id="issueID" name="issueID" value="<?php echo $issueID; ?>">
<table class="thickboxTable" style="width:98%;background-image:url('images/title.gif');background-repeat:no-repeat;">
<tr>
<td colspan='2'>
<span id='headerText' class='headerText'>Issue Resolution</span><br />
</td>
</tr>
<tr>
<td colspan='2'>
<label for="resolutionText">Resolution:</label>
<textarea id="resolutionText" name="resolutionText"></textarea>
</td>
</tr>
</table>
<table class='noBorderTable' style='width:125px;'>
<tr>
<td class="text-left"><input type="button" value="submit" name="submitCloseResourceIssue" id="submitCloseResourceIssue"></td>
<td class='text-right'><input type='button' value='cancel' onclick="tb_remove();"></td>
</tr>
</table>
</form>
</div>
<?php
break;
case 'getNewIssueForm':
$organizationID = $_GET["organizationID"];
$organization = new Organization(new NamedArguments(array('primaryKey' => $organizationID)));
$organizationContactsArray = $organization->getContacts();
$organizationResourcesArray = $organization->getResources(5);
?>
<form id='newIssueForm'>
<input type="hidden" id="sourceOrganizationID" name="sourceOrganizationID" value="<?php echo $organizationID;?>" />
<table class="thickboxTable">
<tr>
<td colspan="2">
<h1> Report New Problem</h1>
<span class='error smallDarkRedText'>* required fields</span>
</td>
</tr>
<tr>
<td><label>Organization: <span class='bigDarkRedText'>*</span></label></td>
<td>
<p><?php echo $organization->name; ?></p>
<span id='error span_error_organizationId' class='smallDarkRedText'></span>
</td>
</tr>
<tr>
<td><label>Contact: <span class='bigDarkRedText'>*</span></label></td>
<td>
<select multiple style="min-height: 60px;" type='text' id='contactIDs' name='contactIDs[]'>
<?php
foreach ($organizationContactsArray as $contact) {
echo " <option value=\"{$contact->contactID}\">{$contact->name}</option>";
}
?>
</select>
<span id='span_error_contactName' class='error smallDarkRedText'></span>
</td>
</tr>
<tr>
<td></td>
<td>
<a id="getCreateContactForm" href="#">add contact</a>
<div id="inlineContact"></div>
</td>
</tr>
<tr>
<td><label>CC myself:</label></td>
<td>
<input type='checkbox' id='ccCreator' name='ccCreator' class='changeInput' checked />
<span id='span_error_ccCreator' class='error smallDarkRedText'></span>
</td>
</tr>
<tr>
<td><label>CC:</label></td>
<td>
<input type="text" id="inputEmail" name="inputEmail" />
<input type="button" id="addEmail" name="addEmail" value="Add" />
<p>
Current CCs: <span id="currentEmails"></span>
</p>
<input type="hidden" id='ccEmails' name='ccEmails' value='' class='changeInput' />
<span id='span_error_contactIDs' class='error smallDarkRedText'></span>
</td>
</tr>
<tr>
<td><label>Subject: <span class='bigDarkRedText'>*</span></label></td>
<td>
<input type='text' id='subjectText' name='issue[subjectText]' value='' class='changeInput' />
<span id='span_error_subjectText' class='error smallDarkRedText'></span>
</td>
</tr>
<tr>
<td><label>Body: <span class='bigDarkRedText'>*</span></label></td>
<td>
<textarea id='bodyText' name='issue[bodyText]' value='' />
<span id='span_error_bodyText' class='error smallDarkRedText'></span>
</td>
</tr>
<tr>
<td><label>Applies to: <span class='bigDarkRedText'>*</span></label></td>
<td>
<div>
<input type="checkbox" class="issueResources" id="organizationID" name="organizationID" value="<?php echo $organization->organizationID;?>" /> <label for="allResources">Applies to all <?php echo $organization->name; ?> resources.</label>
</div>
<div>
<input type="checkbox" class="issueResources" id="otherResources" /><label for="otherResources"> Applies to selected <?php echo $organization->name; ?> resources.</label>
</div>
<select multiple id="resourceIDs" name="resourceIDs[]">
<?php
if (!empty($organizationResourcesArray)) {
foreach ($organizationResourcesArray as $resource) {
echo " <option value=\"{$resource['resourceID']}\">{$resource['titleText']}</option>";
}
}
?>
</select>
<span id='span_error_entities' class='error smallDarkRedText'></span>
</td>
</tr>
</table>
<p> Send me a reminder every
<select name="issue[reminderInterval]">
<?php for ($i = 1; $i <= 31; $i++) echo "<option".(($i==7) ? ' selected':'').">{$i}</option>"; ?>
</select> day(s)
</p>
<table class='noBorderTable' style='width:125px;'>
<tr>
<td style='text-align:left'><input type='button' value='submit' name='submitNewResourceIssue' id='submitNewResourceIssue'></td>
<td style='text-align:right'><input type='button' value='cancel' onclick="tb_remove();"></td>
</tr>
</table>
</form>
<?php
break;
case 'getNewDowntimeForm':
$organizationID = $_GET["organizationID"];
$organization = new Organization(new NamedArguments(array('primaryKey' => $organizationID)));
$issueID = $_GET['issueID'];
$issues = $organization->getIssues();
$downtimeObj = new Downtime();
$downtimeTypeNames = $downtimeObj->getDowntimeTypesArray();
$defaultStart = date("Y-m-d\TH:i");
$defaultEnd = date("Y-m-d\TH:i", strtotime("+1 day"));
?>
<form id='newDowntimeForm'>
<input type="hidden" name="sourceOrganizationID" value="<?php echo $organization->organizationID;?>" />
<table class="thickboxTable" style="width:98%;background-image:url('images/title.gif');background-repeat:no-repeat;">
<tr>
<td colspan="2">
<h1> Resource Downtime Report</h1>
</td>
</tr>
<tr>
<td><label>Downtime Start:</label></td>
<td>
<input value="<?php echo $defaultStart; ?>" type="datetime-local" name="startDate" id="startDate" />
<span id='span_error_startDate' class='smallDarkRedText addDowntimeError'></span>
</td>
</tr>
<tr>
<td><label>Downtime Resolution:</label></td>
<td>
<input value="<?php echo $defaultEnd; ?>" type="datetime-local" name="endDate" id="endDate" />
<span id='span_error_endDate' class='smallDarkRedText addDowntimeError'></span>
</td>
</tr>
<tr>
<td><label>Problem Type:</label></td>
<td>
<select class="downtimeType" name="downtimeType">
<?php
foreach ($downtimeTypeNames as $downtimeType) {
echo "<option value=".$downtimeType["downtimeTypeID"].">".$downtimeType["shortName"]."</option>";
}
?>
</select>
</td>
</tr>
<?php
if ($issues) {
?>
<tr>
<td><label>Link to open issue:</label></td>
<td>
<select class="issueID" name="issueID">
<option value="">none</option>
<?php
foreach ($issues as $issue) {
echo "<option".(($issueID == $issue->issueID) ? ' selected':'')." value=".$issue->issueID.">".$issue->subjectText."</option>";
}
?>
</select>
</td>
</tr>
<?php
}
?>
<tr>
<td><label>Note:</label></td>
<td>
<textarea name="note"></textarea>
</td>
</tr>
</table>
<table class='noBorderTable' style='width:125px;'>
<tr>
<td style='text-align:left'><input type='button' value='submit' name='submitNewDowntime' id='submitNewDowntime'></td>
<td style='text-align:right'><input type='button' value='cancel' onclick="tb_remove();"></td>
</tr>
</table>
</form>
<?php
break;
case 'getIssueLogForm':
$organizationID = $_GET['organizationID'];
if (isset($_GET['issueLogID'])) $issueLogID = $_GET['issueLogID']; else $issueLogID = '';
$issueLog = new IssueLog(new NamedArguments(array('primaryKey' => $issueLogID)));
if (($issueLog->issueStartDate != '') && ($issueLog->issueStartDate != "0000-00-00")) {
$issueStartDate=format_date($issueLog->issueStartDate);
}else{
$issueStartDate='';
}
if (($issueLog->issueEndDate != '') && ($issueLog->issueEndDate != "0000-00-00")) {
$issueEndDate=format_date($issueLog->issueEndDate);
}else{
$issueEndDate='';
}
$issueLogTypeObj = new IssueLogType();
$issueLogTypeArray = $issueLogTypeObj->allAsArray();
?>
<div id='div_issueForm'>
<form id='issueForm'>
<input type='hidden' name='editOrganizationID' id='editOrganizationID' value='<?php echo $organizationID; ?>'>
<input type='hidden' name='editIssueLogID' id='editIssueLogID' value='<?php echo $issueLogID; ?>'>
<table class="thickboxTable" style="background-image:url('images/title.gif');background-repeat:no-repeat;width:260px;">
<tr>
<td colspan='2'><span class='headerText'><?php if ($issueLogID){ echo _("Update Issue"); } else { echo _("Add Issue"); } ?></span>
<span id='span_errors' style='color:red;'></span><br />
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='issueLogTypeID'><b><?php echo _("Type:");?></b></label></td>
<td>
<select name='issueLogTypeID' id='issueLogTypeID'>
<option value=''></option>
<?php
foreach ($issueLogTypeArray as $issueLogType){
if (!(trim(strval($issueLogType['issueLogTypeID'])) != trim(strval($issueLog->issueLogTypeID)))){
echo "<option value='" . $issueLogType['issueLogTypeID'] . "' selected>" . $issueLogType['shortName'] . "</option>\n";
}else{
echo "<option value='" . $issueLogType['issueLogTypeID'] . "'>" . $issueLogType['shortName'] . "</option>\n";
}
}
?>
</select>
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='issueStartDate'><b><?php echo _("Start date:");?></b></label></td>
<td>
<input class='date-pick' id='issueStartDate' name='issueStartDate' style='width:80px' value='<?php echo $issueStartDate; ?>' />
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='issueDate'><b><?php echo _("End date:");?></b></label></td>
<td>
<input class='date-pick' id='issueEndDate' name='issueEndDate' style='width:80px' value='<?php echo $issueEndDate; ?>' />
</td>
</tr>
<tr>
<td style='vertical-align:top;text-align:right;'><label for='noteText'><b><?php echo _("Notes:");?></b></label></td>
<td><textarea rows='3' id='noteText' name='noteText' style='width:200px'><?php echo $issueLog->noteText; ?></textarea></td>
</tr>
<tr style="vertical-align:middle;">
<td style="padding-left:8px;padding-top:8px;"> </td>
<td style="padding-top:8px;padding-right:8px;">
<table class='noBorderTable' style='width:100%;'>
<tr>
<td style='text-align:left'><input type='button' value='<?php echo _("submit");?>' name='submitIssueLogForm' id ='submitIssueLogForm'></td>
<td style='text-align:right'><input type='button' value='<?php echo _("cancel");?>' onclick="tb_remove()"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>
<script type="text/javascript" src="js/forms/issueLogSubmitForm.js?random=<?php echo rand(); ?>"></script>
<?php
break;
case 'getAdminDisplay':
$className = $_GET['className'];
$instanceArray = array();
$obj = new $className();
$instanceArray = $obj->allAsArray();
if (count($instanceArray) > 0){
?>
<table class='dataTable' style='width:350px'>
<?php
foreach($instanceArray as $instance) {
echo "<tr>";
echo "<td>" . $instance['shortName'] . "</td>";
echo "<td style='width:30px'><a href='ajax_forms.php?action=getAdminUpdateForm&className=" . $className . "&updateId=" . $instance[lcfirst($className) . 'ID'] . "&height=130&width=250&modal=true' class='thickbox' id='expression'>"._("edit")."</a></td>";
echo "<td style='width:50px'><a href='javascript:deleteData(\"" . $className . "\",\"" . $instance[lcfirst($className) . 'ID'] . "\")'>"._("remove")."</a></td>";
echo "</tr>";
}
?>
</table>
<?php
}else{
echo _("(none found)");
}
break;
case 'getAdminUpdateForm':
$className = $_GET['className'];
$updateId = $_GET['updateId'];
$instance = new $className(new NamedArguments(array('primaryKey' => $updateId)));
?>
<div id='div_updateForm'>
<table class="thickboxTable" style="background-image:url('images/title.gif');background-repeat:no-repeat;width:200px;">
<tr>
<td colspan='2'><br /><span class='headerText'><?php _("Update");?></span><br /><span id='span_errors' style='color:#F00;'></span><br /></td>
</tr>
<tr>
<td>
<?php
echo "<input type='text' id='updateVal' name='updateVal' value='" . $instance->shortName . "' style='width:190px;'/></td><td><a href='javascript:updateData(\"" . $className . "\", \"" . $updateId . "\");'>"._("update")."</a>";
?>
</td>
</tr>
<tr>
<td colspan='2'><p><a href='#' onclick='window.parent.tb_remove(); return false'><?php echo _("close");?></a></td>
</tr>
</table>
</div>
<script type="text/javascript">
//attach enter key event to new input and call add data when hit
$('#updateVal').keyup(function(e) {
if(e.keyCode == 13) {
updateData("<?php echo $className; ?>", "<?php echo $updateId; ?>");
}
});
</script>
<?php
break;
case 'getAdminUserForm':
$instanceArray = array();
$user = new User();
$tempArray = array();
foreach ($user->allAsArray() as $tempArray) {
$privilege = new Privilege(new NamedArguments(array('primaryKey' => $tempArray['privilegeID'])));
$tempArray['priv'] = $privilege->shortName;
array_push($instanceArray, $tempArray);
}
if (count($instanceArray) > 0){
?>
<table class='dataTable' style='width:550px'>
<tr>
<th align='left'><?php echo _("Login ID");?></th>
<th align='left'><?php echo _("First Name");?></th>
<th align='left'><?php echo _("Last Name");?></th>
<th align='left'><?php echo _("Privilege");?></th>
<th> </th>
<th> </th>
</tr>