edit course attendees form course display
authorpaul <paul@plutz.net>
Wed, 12 Mar 2014 16:15:07 +0000 (16:15 +0000)
committerpaul <paul@plutz.net>
Wed, 12 Mar 2014 16:15:07 +0000 (16:15 +0000)
svn path=/trunk/; revision=41

pages/courses.sh
templates/edit_course.sh

index c0aab02..ea708e9 100755 (executable)
@@ -2,6 +2,14 @@
 
 [ -z "$_GET[\"order\"]" ] && _GET["order"]=DOW
 
+listcards() {
+  ls -1 ${_DATA}/vcard/*vcf 2>/dev/null |while read file; do
+    fn=$(sed -rn 's:^N(;.+)*\:([^;]*;){1} *([^;]*).*$:\3:p' "$file")
+    echo "$fn\t$file"
+  done |sort |sed -r 's:^.*\t(.*/)([^/]+)$:\2:'
+}
+
+
 listcourses() {
   case "$_GET[\"filtertype\"]" in
     *) ls -1 ${_DATA}/ical/*ics 2>/dev/null
index ff932a1..ea5e88d 100755 (executable)
@@ -132,6 +132,21 @@ done
 echo '    </select>'
 echo '  </div>'
 
+echo '  <div class="section select_attendance">'
+echo '    <span class="sectitle">'$(l10n course_attendance)'</span>'
+echo '    <select class="item attendance" name="attendance" multiple="multiple">'
+listcards |while read card; do
+  cfile="$_DATA/vcard/$card"
+  aname=$(sed -rn 's:^N(;[^"\:]+|;"[^"]+")*\:([^;]*)(\;[^;]*)(\;[^;]*)?(\;[^;]*)?(\;[^;]*)?$:\5 \3 \4 \2 \6:p' "$cfile" \
+          |sed -r 's:,: :;s:\;: :g;s: +: :g' \
+          |tr -d '\r'
+         )
+  selected=$(sed -rn "s:^$id\t$card\$:selected=\"selected\":p" $_DATA/mappings/attendance)
+  echo '    <option value="'$card'" '$selected'>'$aname'</option>'
+done
+echo '    </select>'
+echo '  </div>'
+
 echo '  <div class="section control">'
 echo '    <button class="item control" type="submit" name="action" value="addfield">'$(l10n edit_addfield)'</button>'
 echo '    <select class="item control" name="newfield">'