/
log_table_functions.php
744 lines (616 loc) · 22.1 KB
/
log_table_functions.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
<?php
// Functions for the main log display
require_once("access_check.php");
#######################
##Display Log
#######################
include_once("sql_functions.php") ;
#function do_sql($query) {
# // Connect to DB
# $dbconn=$_GLOBAL['dbconn'];
# if (pg_connection_status($dbconn)!==PGSQL_CONNECTION_OK ) {
# $dbconn = pg_connect("host=localhost dbname=training_diary user=athlete password=ironman")
# or die('Could not connect: ' . pg_last_error());
# }
# #echo "\n<br>DEBUG $query <br> \n";
# $result = pg_query($query) or die('Query failed: ' . pg_last_error());
# #pg_close($dbconn);
# return $result ;
#}
function get_details_to_view($athlete_id) {
# Get an array of detail types selected for viewing
$details_to_view=array();
$result = do_sql("SELECT detail from athlete_view_preferences where athlete_id=$athlete_id order by display_sequence");
# pg_fetch_array returns the next whole row as an array at each iteration
while ( $row = pg_fetch_array($result, null, PGSQL_ASSOC) )
{
foreach ( $row as $prev_detail ){
array_push( $details_to_view, $prev_detail ) ;
}
}
return $details_to_view ;
}
function get_col_info($columns) {
// Column widths are specified in pixels in the log_field_names table
// as are column short names
$col_widths=array();
$col_shname=array();
foreach ( $columns as $column ) {
#$result = do_sql("SELECT col_width, log_col_short_name from log_field_names where log_column='$column' ");
$result = do_sql("SELECT * from log_field_names where log_column='$column' ");
$row = pg_fetch_array($result, null, PGSQL_ASSOC);
$col_width = $row['col_width'] ;
$col_widths[$column] = $row['col_width'] ;
$col_shnames[$column] = $row['log_col_short_name'] ;
$col_lnames[$column] = $row['log_col_long_name'] ;
$col_descriptions[$column] = $row['log_col_description'] ;
}
$col_info['col_widths'] = $col_widths ;
$col_info['col_shnames'] = $col_shnames ;
$col_info['col_lnames'] = $col_lnames ;
$col_info['col_descriptions'] = $col_descriptions ;
return $col_info ;
}
function get_datacell_class($entry_type) {
switch($entry_type) {
case "planned - not done":
return "datacell_planned_not_done";
break;
case "planned - done";
return "datacell_done";
break;
case "planned - incomplete";
return "datacell_done";
break;
case "unplanned";
return "datacell_done";
break;
case "plan";
return "datacell_plan";
break;
case "event - tentative";
return "datacell_event_tentative";
break;
case "event - done";
return "datacell_event_done";
break;
case "event - entered";
return "datacell_event_todo";
break;
case "event - to enter";
return "datacell_event_todo";
break;
case "event - enter by";
return "datacell_event_entry";
break;
// entry for competition session_type
case "competition";
return "datacell_event_done";
break;
default:
return "datacell" ;
}
}
########################
# Display JavaScript functions
########################
function display_jscript_functions(){
echo '<SCRIPT>
function reveal(whichEl)
{
whichEl.style.display = (whichEl.style.display == "block" ) ? "none" : "block";
}
</SCRIPT> ';
display_options_menu_js("options","OptMenu");
echo "</HEAD>\n\n\n";
}
########################
# Display Column headers
########################
function display_main_table($details_to_view,$extra) {
$headers = get_column_names();
$col_info = get_col_info($details_to_view) ;
$col_widths = $col_info['col_widths'];
$col_shnames = $col_info['col_shnames'];
$divheight = "73%";
if ( $extra[2] == "addlogentry" ) {
$divheight = "50%";
$extra[2] = "X" ;
}
#<DIV class=header STYLE="
# width: * ;
# border-left: 1px gray solid;
# border-bottom: 1px gray solid;
# border-top: 1px gray solid;
# padding:0px;
# margin: 0px">
echo <<<ENDHTML
<DIV id=tableheader >
<TABLE class=header STYLE="table-layout: fixed;" >
ENDHTML
;
// Set column widths for Header table data
echo "<COL WIDTH=100 > <COL WIDTH=10>\n";
foreach ( $details_to_view as $detail ){
$width= $col_widths[$detail];
echo "<COL WIDTH=$width >\n";
}
echo "<COL WIDTH=55>\n";
echo <<<ENDHTML
<tr>
<td class=colheader > </td>
<td class=colheader > </td>
ENDHTML
;
foreach ( $details_to_view as $detail ){
$width = $col_widths[$detail];
$name = $col_shnames[$detail];
echo " <td class=colheader >$name</td>\n ";
}
echo "<td class=colheader > </td>\n";
echo "</tr>" ;
#<![if ! IE]> <DIV id=maindivtopspace ></DIV> <![endif]>
#<!--[if IE]> <DIV id=body > <![endif]-->
echo <<< ENDHTML
</TABLE>
</DIV>
<DIV id=maindiv >
<TABLE cellspacing=0 class=maintable >
ENDHTML
;
# <DIV STYLE="overflow: auto; height: $divheight ; padding:0px; margin: 0px ; ">
// Set column widths for table data
echo "<COL WIDTH=100 > <COL WIDTH=10>\n";
foreach ( $details_to_view as $detail ){
$width= $col_widths[$detail];
echo "<COL WIDTH=$width >\n";
}
echo "<COL WIDTH=55>\n";
}
function display_column_headers($details_to_view) {
// Only used for subsession (split) tables
$headers = get_column_names();
$col_info = get_col_info($details_to_view) ;
$col_widths = $col_info['col_widths'];
$col_shnames = $col_info['col_shnames'];
// Set column widths for table column Header
echo "<TABLE class=subtable cellspacing=0 >\n";
echo "<COL WIDTH=0 > <COL WIDTH=0>\n";
foreach ( $details_to_view as $detail ){
$width= $col_widths[$detail];
echo "<COL WIDTH=$width >\n";
}
echo "<COL WIDTH=50>\n";
echo <<<ENDHTML
<tr>
<td class=colheader > </td>
<td class=colheader > </td>
ENDHTML
;
foreach ( $details_to_view as $detail ){
$width = $col_widths[$detail];
$name = $col_shnames[$detail];
echo " <td class=colheader >$name</td>\n ";
}
echo "<td class=colheader > </td>\n";
echo "</tr>" ;
}
########################
# Display log data
########################
function display_log_data($athlete_id, $split, $startdate, $enddate, $extra ){
if ( ! check_share_permission($_SESSION['athlete_id'],"view log $athlete_id") ){
echo "You are not allowed to view this person's log<br>";
exit ;
}
# Print column headers and open table
$details_to_view = get_details_to_view($athlete_id) ;
#display_column_headers($details_to_view);
display_main_table($details_to_view, $extra);
get_athlete_data($athlete_id, $details_to_view, $split, $startdate, $enddate, $extra );
echo "</TABLE>\n";
echo "</DIV>\n";
}
####
function show_week_row( $athlete_id, $date, $numcols ) {
$week_num=get_week_number( date("Y-m-d",$date) );
$num = $numcols+3;
// Calculate weekly totals
// and display totals for training done
include_once("weekly_total_functions.php");
$weektotals = weekly_done_totals($athlete_id, $date );
ksort($weektotals);
echo "<TR><TD class=weekcell colspan=$num > <font color=white ><b>Week $week_num </b>";
$total = $weektotals['Total Done'] ;
echo "<br> <b>Total Done:</b> <font color=#ffdddd > <b>$total</b> </font> - \n";
foreach ( array_keys($weektotals) as $ex_type ) {
if ( $ex_type == "Total Done" ) continue ;
$total = $weektotals[$ex_type] ;
echo " <b>$ex_type:</b> $total ";
}
// Display training plan totals if there are any
$weekplantotals = weekly_planned_totals($athlete_id, $date );
if ( count($weekplantotals) > 1 ) {
ksort($weektotals);
$total = $weekplantotals['Total To Do'] ;
echo "<br> <b>Total To Do:</b> <font color=#ffdddd > <b>$total</b> </font> - \n";
foreach ( array_keys($weekplantotals) as $ex_type ) {
if ( $ex_type == "Total To Do" ) continue ;
$total = $weekplantotals[$ex_type] ;
echo " <b>$ex_type:</b> $total ";
}
#echo "<TR><TD class=weekcell colspan=$num > <font color=white > $weekplantotals </TD></TR>\n\n" ;
}
echo " </TD></TR>\n\n" ;
}
####
function get_athlete_data($athlete_id, $details_to_view, $split, $startdate, $enddate, $extra ) {
// Set start and end dates
$startdmy = validate_date($startdate,"eu","eu") ;
$enddmy = validate_date($enddate,"eu","eu") ;
// Get array of dates in this range (range array dates are in Epoch secs)
$daterange= generate_date_range($startdmy, $enddmy);
$numcols= count($details_to_view);
# Get this athlete's data from the db
$result = do_sql("SELECT * from log
WHERE athlete_id = '$athlete_id' and parent_session=0
and start_date >= '$startdmy' and start_date <= '$enddmy'
ORDER BY start_date, start_time, stage ");
// get first entry
$row = pg_fetch_array($result, null, PGSQL_ASSOC) ;
// Start date loop to print each date
foreach ( $daterange as $date ) {
// Check for new week (Monday)
if ( preg_match("/Mon/i",date("D",$date) ) ){
// if it is Monday then print a weekly totals row
show_week_row($athlete_id, $date, $numcols ) ;
}
// print the day info row
print_date_row($date);
// Check that main entry has been selected for viewing and print it
// need pg style Y-n-j date for comparison
$pgdate=date("Y-m-d",$date);
// Display the entries for the day if they exist
do {
// if the row does not match the current date then break
// from this while loop into the next date loop iteration
$start_date=$row['start_date'] ;
if ( "$pgdate" == "$start_date" ) {
$session_id = $row['session_id'] ;
check_for_subsessions_and_print($athlete_id, $session_id, $details_to_view, $split, $row, $extra ) ;
// Get next row data and see if it is for this date
while( $row = pg_fetch_array($result, null, PGSQL_ASSOC) ) {
$start_date=$row['start_date'] ;
if ( "$pgdate" == "$start_date" ) {
echo "<TR><TD class=firstcolumn> </TD>\n";
$session_id = $row['session_id'] ;
check_for_subsessions_and_print($athlete_id, $session_id, $details_to_view, $split, $row, $extra ) ;
}
else {
//if it's not then get the next date (hanging on to this row data)
break 2 ;
}
// end of while loop
}
}
else {
print_blank_row($details_to_view);
break;
}
// end of do/while loop
} while ($row = pg_fetch_array($result, null, PGSQL_ASSOC)) ;
//end of foreach date loop
}
// END OF FUNCTION
}
function display_row_editor($session_id, $athlete_id, $extra ){
// Check whether this session is to be edited
if (( $extra[0] == "EDIT") && ( $extra[1] == $session_id )) {
echo "<TR><TD class=firstcell colspan=15 >\n";
echo "<b>Edit this session</b>";
session_edit_form($session_id, $athlete_id, "" );
echo "</TD></TR>\n\n";
}
}
function check_for_subsessions_and_print($athlete_id, $session_id, $details_to_view, $split, $row, $extra) {
# check whether this row has any subsessions
$sub_rows = do_sql("SELECT * from log WHERE athlete_id = '$athlete_id' and parent_session='$session_id' limit 1 ");
$numrows = pg_num_rows($sub_rows) ;
if ( $numrows > 0 ) { $sub = 1 ; } else { $sub = 0 ; }
# print parent row first
if ( $split == $session_id )
{
print_row( $sub , 0 , $row, $details_to_view , $athlete_id, $split );
# display_row_editor($session_id, $athlete_id, $extra );
# if this row has any subsessions print them
if ( $sub > 0 ) {get_subsession( 0 , $session_id , $details_to_view , $split, $extra ) ;}
}
else
{
print_row( $sub , 0 , $row, $details_to_view , $athlete_id, 0 );
#display_row_editor($session_id, $athlete_id, $extra );
# if this row has any subsessions print them
if ( $sub > 0 ) {get_subsession( 0 , $session_id , $details_to_view , $split, $extra ) ;}
}
}
####
function get_subsession($level,$parent_id, $details_to_view, $split, $extra ) {
# get the subsession info for this parent_id
$athlete_id = $GLOBALS['athlete_id'] ;
$level++ ;
$numcols= count($details_to_view);
# put children rows into sub_rows array
$sub_rows = do_sql("SELECT * from log WHERE athlete_id = '$athlete_id' and parent_session='$parent_id' ORDER BY start_date, start_time, stage ");
#this session is a subsession so hide it
$num=$numcols+2 ;
echo "<TR><TD class=firstcolumn > </TD>
<TD class=subtable colspan=$num align=right >
<DIV ID='el$parent_id' CLASS='hiddentext' >\n";
# Print Column headers and open sub-table
$details_to_view = get_details_to_view($athlete_id) ;
display_column_headers($details_to_view);
# then print each subsession and check whether it has subsessions
while ($sub_row = pg_fetch_array($sub_rows, null, PGSQL_ASSOC)) {
# sub_row now holds 1 subsession
# check whether this row has any subsessions
$session_id = $sub_row['session_id'] ;
$subtest = do_sql("SELECT * from log WHERE athlete_id = '$athlete_id' and parent_session='$session_id' ");
$numsubs = pg_num_rows($subtest) ;
#echo "NUMsubs: $numsubs <br> \n";
// Start the row
echo "\n<TR><TD class=firstcolumn></TD>\n";
if ( $numsubs > 0 ) {
if ( $split == $session_id )
{
print_row( 1 , $level , $sub_row, $details_to_view , $athlete_id, $split );
#display_row_editor($session_id, $athlete_id, $extra );
}
else
{
print_row( 1 , $level , $sub_row, $details_to_view , $athlete_id, 0 );
#display_row_editor($session_id, $athlete_id, $extra );
}
# call self to get subs of this sub
get_subsession( $level, $sub_row['session_id'], $details_to_view, $split, $extra ) ;
}
else {
if ( $split == $session_id )
{
print_row( 0 , $level , $sub_row, $details_to_view , $athlete_id, $split );
#display_row_editor($session_id, $athlete_id, $extra );
}
else
{
print_row( 0 , $level , $sub_row, $details_to_view , $athlete_id, 0 );
#display_row_editor($session_id, $athlete_id, $extra );
}
}
}
echo "\n</TABLE>
<font size=2 > <br> </font>
</DIV>\n\n";
}
#####
function format_display_date($start_date){
# Converts the postgres date to something prettier
$timestamp=get_timestamp($start_date) ;
# Return date in format Day dd/mm/yyyy
$formatted_date = date("D j/n/Y", $timestamp);
return $formatted_date ;
}
####
function get_timestamp($date){
# get strtotime timestamp from pg date doesn't need US format
preg_match_all( "/\d\d/", $date, $matches );
$dateparts=$matches[0];
$year= "$dateparts[0]$dateparts[1]";
$month= "$dateparts[2]";
$day= "$dateparts[3]";
# Get the timestamp
$timestamp=strtotime( "$year/$month/$day" );
if ($timestamp == -1 ) { echo "Date conversion failed $year/$month/$day.<br>\n"; }
return $timestamp ;
}
function get_week_number($start_date){
# Gets the week number of year
$timestamp=get_timestamp($start_date) ;
$week_number= date("W",$timestamp) ;
return $week_number ;
}
####
function print_date_row($date){
$formatted_date=date("D j/n/Y",$date);
$jnydate = date("j/n/Y",$date);
$anchorname = "anchorD".date("Ymd",$date);
echo <<< HTMLEND
<TR class=newday >
<TD class=datecell NOWRAP >
<A href="javascript:launchRemote('add_log_entry.php?start_date=$jnydate#log_entry_form')" class=plainlink name=$anchorname >
<B> $formatted_date </B>
</A>
</TD>
HTMLEND
;
// END OF FUNCTION print_date_row
}
function print_blank_row( $details_to_view ){
// Designed to tack onto the end of an empty date row
echo "<TD> </TD>";
foreach ( $details_to_view as $bla ) {
echo "<TD class=datacell > - </TD>";
}
echo "<TD></TD></TR>\n\n";
}
function print_split_expander_column($subyn, $session_id) {
#### Split expander column #####
echo "<TD class=firstcolumn ><a name=anchorS$session_id ></a>\n";
# if this row has splits (subsessions) then put a link in the first col
if ( $subyn == 1 ) {
# This session has subsessions so put a link in the first col
echo "<a onClick='reveal(el$session_id); return false' class=expander > + </a>\n";
}
else {
echo "\t  $nbsp ";
}
echo "</font>\n";
echo "</td>\n";
#### END of First column #####
}
function print_row( $subyn , $level , $row, $details_to_view, $athlete_id, $split ) {
# print the session details
$parent_id = $row['parent_session'] ;
$session_id = $row['session_id'] ;
$previous_date = $GLOBALS['previous_date'];
$start_date = $row['start_date'] ;
$numcols= count($details_to_view);
# Start the table row
# echo "<TR>\n\n";
print_split_expander_column($subyn, $session_id);
# foreach ( array_keys($row) as $key ) {
# if ( in_array( $key , $details_to_view ) ){
unset($fullentry);
$fullentry=array();
//Find out what sort of entry type it is and use the appropriate
//datacell class so the row gets the right background colour
$row['session_type'] = trim($row['session_type']);
$row['entry_type'] = trim($row['entry_type']);
if ( $row['session_type'] == "competition" && "X".$row['entry_type'] == "X" ) {
$datacell_class = get_datacell_class($row['session_type']);
}
else {
$datacell_class = get_datacell_class($row['entry_type']);
}
foreach ( $details_to_view as $key ) {
$entry = $row["$key"];
$width=""; $expander="";
if (strlen($entry) > 20 ) {
$width="width=120";
//put the full notes into fullentry
$fullentry[$key] = $entry ;
// trim down displayed notes
$entry = substr($entry,0,16);
$expander="<a onClick='reveal(${key}Note$session_id); return false' class=expander > +</a>\n";
}
if ($entry == "" ) { $entry=" " ;} ;
##echo "\t\t<td class=datacell nowrap $width >$entry $expander </td>\n";
echo "\t\t<td class=$datacell_class >$entry $expander </td>\n";
}
// Check that the current user has permission to use these edit commands
// on the athlete being viewed
$viewer=$_SESSION['athlete_id'];
if ( check_share_permission( $athlete_id, "edit log $viewer" ) ) {
# add a link to the end of each line to allow addition of sub-session
# this will call the add_log_entry sending it the
# session_id in _GET[parent_session]
$session_id= $row['session_id'] ;
echo "<td nowrap >";
display_options_menu($session_id, $start_date);
echo "\n</TD>\t</tr>\n";
}
else { echo "\n<TD> </TD>\n"; }
$num=$numcols+1 ;
foreach ( array_keys($fullentry) as $key ) {
$notes=$fullentry[$key];
echo <<< ENDHTML
<TR><TD border=0 cellpadding=0 cellspacing=0 class=firstcolumn ></TD><TD></TD><TD colspan=$num >
<DIV ID='${key}Note$session_id' class='hiddentext'>
<TABLE cellpadding=0 cellspacing=0 > <TR><TD class=datacell ><b>$key:</b> $notes </TD></TR></TABLE>
</DIV>
</TD></TR>
ENDHTML
;
}
if ( $split > 0 )
{
# This function has been called by the add-user split function
# and it is this session that is being split
# so dislplay the add-user session form here
$span=$num+2;
// Get the parent's start date
$start_date=$row['start_date'];
#echo "<TR><TD></TD><TD></TD><TD colspan=$span ><font size=2 >\n";
echo "<TR><TD colspan=$span ><font size=2 >\n";
echo "<b>Insert Session Split Info</b>\n";
session_form( $session_id , $athlete_id, "", $start_date ) ;
echo "\t</TD></TR>\n\n";
};
#echo "</table>\n";
# Set the global to the last start date so it can be compared on the next
# time this is run so we know whether this is a new day or not.
$GLOBALS['previous_date'] = $start_date ;
}
function display_options_menu_js($classname, $suckerfish) {
echo <<< ENDHTML
<SCRIPT type="text/javascript"><!--
$suckerfish = function() {
// Get all UL tags with a class of "$classname"
var sfULs = getElementsByClassName("$classname", "ul");
for(var iULs=0; iULs<sfULs.length; iULs++){
var sfEls = sfULs[iULs].getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" $suckerfish";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" $suckerfish\\\\b"), "");
}
}
}
}
if (window.attachEvent) window.attachEvent("onload", $suckerfish);
//--></SCRIPT>
ENDHTML
;
}
function display_options_menu($session_id, $start_date ){
// Despite huge problems with IE, managed to get the Option menus
// working in IE but found they appeared in the wrong location in FF
// due to absolute being relative to the page, not the scrolling DIV.
// so in FF I only give the old links list.
// Weird, appears to work in FFox now. Since I gave the div a defined height in all views so I could reduce the scrolling div size!
$browser=$_SERVER['HTTP_USER_AGENT'];
if ( 1 == 2 ) {
#if ( ! preg_match("/MSIE/",$browser) ) {
echo <<< ENDHTML
<a href="javascript:launchRemote('add_log_entry.php?parent_session=$session_id#anchorS$session_id')" >SPLIT</a>
<a href='delete_log_entry.php?session_id=$session_id#anchorS$session_id' >DEL</a>
<a href="javascript:launchRemote('edit_log_entry.php?session_id=$session_id#anchorS$session_id')" >EDIT</a>
ENDHTML
;
}
else {
// convert date from yyyy-mm-dd format to d/m/yyyy
preg_match_all("/\d+/", $start_date, $matches ) ;
$parts = $matches[0] ;
$jnydate = $parts[2]."/".$parts[1]."/".$parts[0] ;
// Generate dropdown menu
echo <<< ENDHTML
<UL class="options" >
<LI><a>Options</a>
<UL>
<LI>
<a href="javascript:launchRemote('add_log_entry.php?start_date=$jnydate#log_entry_form')" >ADD</a>
</LI>
<LI>
<a href="javascript:launchRemote('add_log_entry.php?parent_session=$session_id#anchorS$session_id')" >SPLIT</a>
</LI>
<LI>
<a href='delete_log_entry.php?session_id=$session_id#anchorS$session_id' >DEL</a>
</LI>
<LI>
<a href="javascript:launchRemote('edit_log_entry.php?session_id=$session_id#anchorS$session_id')" >EDIT</a>
</LI>
</UL>
</LI>
</UL>
ENDHTML
;
}
// END OF FUNCTION display_options_menu
}
#####################
# Disconnect from DB
#####################
#pg_close($dbconn) or die('Could not connect: ' . pg_last_error());
#####################
?>