]> git.plutz.net Git - confetti/blobdiff - pages/cards.sh
assignment of categories
[confetti] / pages / cards.sh
index d1170b0ada1f5cb767e4f04af476b2fcc6b6029d..106484b00cd41af64a6652fe305ad58e99c448b3 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
@@ -27,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() {
@@ -115,7 +137,7 @@ vcf_parse() {
     case "$line" in
       key=*) printf %s\\n "$line"
        ;;
-      value=*) printf %s\\n "$line"
+      value=*) printf %s\\n "${line}"
        ;;
       tag=*) ot=''
             printf %s "$line" \
@@ -154,7 +176,7 @@ view_card() {  #Parameter: Cardfile
           if [ -z "$key" ]; then
             eval "$line"
           else
-            values[$key]="$value"
+            values[$key]="${value//\\r\\n/$BR}"
             for t in ${(k)tag}; do
               tags[${key}_$t]="$tag[$t]"
             done
@@ -192,7 +214,7 @@ edit_card() {  #Parameter: Cardfile
         if [ -z "$key" ]; then
           eval "$line"
         else
-          [ -n "$value" ] && values[$key]="$value" || values[$key]='\r'
+          [ -n "$value" ] && values[$key]="${value//\\r\\n/$BR}" || values[$key]='\r'
           for t in ${(k)tag}; do
             tags[${key}_$t]="$tag[$t]"
           done