-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathchooser.rvt
92 lines (75 loc) · 3.02 KB
/
chooser.rvt
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
<?
package require ergkeeper
::ergkeeper::page_init
::ergkeeper::page_response
::ergkeeper::page_head "ErgKeeper: Activity Chooser"
::ergkeeper::require_login
if {[info exists response(weeks)] && [string is integer $response(weeks)]} {
set weeks $response(weeks)
set title "$response(weeks) Weeks"
} else {
set weeks 1
set title "Week"
}
unset -nocomplain whereclauses
lappend whereclauses "start_time >= current_date - '$weeks week'::interval"
lappend whereclauses "user_id = $::user(id)"
if {[info exists response(resubmit)]} {
set resubmit 1
} else {
set resubmit 0
lappend whereclauses "posted IS NULL"
}
puts [head "Unposted Activities from the past $title"]
set opts [list]
foreach {wc title} {4 "One Month" 8 "Two Months" 9999 "All Time"} {
lappend opts "<a href=\"?weeks=$wc\">$title</a>"
}
puts "<p>[join $opts " · "]</p>"
form myform -defaults response -method post -name chooser -action post
myform start
if {[string is true -strict $resubmit]} {
myform hidden resubmit -value 1
}
puts [table start]
puts "<tr><th>Sel</th><th>User</th><th colspan=\"2\">Date</th><th>Time</th><th>Duration</th><th>Notes</th></tr>"
pg_select $::db "SELECT *, (duration::varchar||' seconds')::interval as dur_interval FROM activities WHERE [join $whereclauses " AND "] ORDER BY name, start_time" buf {
puts "<tr [rowclass row]>"
puts "<td>"
myform checkbox sel_$buf(id)
puts "</td>"
puts "<td>$buf(name)</td>"
puts "<td>[clock format [clock scan $buf(start_time)] -format "%A"]</td>"
puts "<td>[clock format [clock scan $buf(start_time)] -format "%d-%b-%Y"]</td>"
puts "<td>[clock format [clock scan $buf(start_time)] -format "%H:%M"]</td>"
puts "<td align=\"right\">$buf(dur_interval)</td>"
puts "<td><input type=\"text\" name=\"notes_$buf(id)\" size=\"40\" value=\"$buf(notes)\"/></td>"
puts "</tr>"
incr displaycount
}
puts "<tr><td colspan=\"7\" align=\"center\" style=\"background-color: #dfdfdf;\">"
myform submit submit -value "Upload to RunKeeper"
puts "</td></tr>"
puts [table end]
myform end
myform destroy
pg_select $::db "SELECT count(*) FROM activities WHERE user_id = $::user(id) AND posted IS NULL" buf {
if {![info exists displaycount] || $displaycount != $buf(count)} {
puts [head "Expecting to see more workouts?"]
puts "<p>"
puts "You have uploaded $buf(count) workouts to this site which have not been posted to"
puts "your RunKeeper account. However, some of these workouts are older than the date"
puts "range selected above."
puts "</p>"
puts "<p>"
puts "The RunKeeper API does not really support posting old activities, so if you post old"
puts "workouts they will all show up in your RunKeeper timeline as if you just completed them."
puts "They will be dated correctly for graphs and analysis, but it will spam your friends'"
puts "timelines. You can upload the older workouts anyway, if you wish, by selecting a"
puts "longer time range at the top of this page."
puts "</p>"
}
}
::ergkeeper::page_foot
::ergkeeper::page_term
?>