]> git.plutz.net Git - confetti/blobdiff - pages/cards.sh
dirty fix: do not mess up with empty tags
[confetti] / pages / cards.sh
index 50fee63b76c70040b1a776172e19d3385337b5f4..08b88b94e11b75e8eeeab786df667adb1912af3c 100755 (executable)
 # You should have received a copy of the GNU Affero General Public License
 # along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
 
-[ -z "${_GET[order]}" ] && _GET[order]="firstname"
-
 BR='
 '
 
+case $PROFILE in
+medical)
+  view_card="$_EXEC/templates/view_client.sh"
+  edit_card="$_EXEC/templates/edit_client.sh"
+  _GET[order]="${_GET[order]:-lastname}"
+  _GET[filtertype]="${_GET[filtertype]:-name}"
+  profile_medical=x
+;;
+circus)
+  view_card="$_EXEC/templates/view_attendee.sh"
+  edit_card="$_EXEC/templates/edit_attendee.sh"
+  _GET[order]="${_GET[order]:-firstname}"
+  _GET[filtertype]="${_GET[filtertype]:-any}"
+  profile_circus=x
+;;
+esac
+
+edit="${_GET[edit]}"
+[ \! -f "vcard/$edit" -a \! -f "temp/$edit" ] && edit=''
+
 listcourses() {
   ls -1 ${_DATA}/ical/*ics |while read file; do
     icstime="$(sed -rn 's:^DTSTART\:(TZID=.*\:)?([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z?\r$:\2-\3-\4 \5\:\6\:\7:p' "$file")"
@@ -30,7 +48,8 @@ listcourses() {
 }
 
 list_hi_companies(){
-  sed -rn 's;^X-HEALTH-INSURANCE:([^\;]+)\;.*$;\1;p' ${_DATA}/vcard/*vcf
+  sed -rn 's;^X-HEALTH-INSURANCE:([^\;]+)\;.*$;\1;p' ${_DATA}/vcard/*vcf \
+  | sort -u
 }
 
 listcards() {
@@ -123,7 +142,7 @@ vcf_parse() {
       tag=*) ot=''
             printf %s "$line" \
             | sed -r 's:^tag=::;s:\;([A-Z+_-]+="[^"]+"|[A-Z+_-]+=[^\;]+):\n\1:g;' \
-            | sed -r 's:([A-Z+_-]+)="?(.*)"?:tag\[\1\]="\2":g' \
+            | sed -rn 's:([A-Z+_-]+)="?(.+)"?:tag\[\1\]="\2":gp' \
             | sed -r '/^ *$/d' \
             | sort |while read -r tag; do
               nt="$(printf %s "$tag" |sed -r 's:^tag\[([A-Z+_-]+)\]="(.*)"$:\1:')"