$(
for field in $VCF_FIELDS; do
for key in $field $field{0..100}; do
- [ -z "$_POST[$key]" ] && break
+ [ -z "${_POST[$key]+x}" ] && break
value="$(printf %s "$_POST[$key]" |sed -r ':a;N;$!ba;s:\n:\\n:g;s:\r:\\r:g')"
- printf '%s:%s\n' "${field}" "$value"
+ [ "${key%%[0-9]*}" = TEL ] && tag="TYPE=${_POST[phonetype${key#TEL}]}" || tag=''
+ [ -n "$value" ] && printf '%s:%s\n' "${field}${tag:+;$tag}" "$value"
done
done
[ "${_POST[action]}" = addfield ] && printf '%s:\n' "${_POST[newfield]}"
[ -z "${_GET[order]}" ] && _GET[order]="firstname"
+BR='
+'
+
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")"
case "$line" in
key=*) printf %s\\n "$line"
;;
- value=*) printf %s\\n "$line"
+ value=*) printf %s\\n "${line}"
;;
tag=*) ot=''
printf %s "$line" \
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
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
margin-top: 0;
}
+.card .section .item {
+ display: block;
+ max-width: 100%;
+ word-wrap: break-word;
+}
+.card .section .item label {
+ font-weight: bold;
+}
+
+.card .section textarea.NOTE {
+ min-height: 6em;
+}
+.card .section textarea.ADR {
+ min-height: 4em;
+}
+
+.card .section .PHOTO {
+ width: 100%;
+ max-height: 10em;
+}
+.card .section .GENDER { display: inline-block; padding-right: .5ex;}
+.card .section .BDAY { display: inline-block;}
+
+.card .section select {
+ display: block;
+ background-color: #FFF;
+ border: 1px solid black;
+}
+
.card .section.attendance ul { margin: 0; padding: 0; }
.card .section.attendance ul li {
display: block;
form.card .insurance input[type=radio]:checked + label + select + input {
display: block;
border: 1px solid black;
+ background-color: #FFF;
border-width: 0 1px 1px 1px;
padding: .25ex 0;
margin-top: -1px;
- background-color: #FFF;
-}
-
-.card .section .item {
- display: block;
- max-width: 100%;
- word-wrap: break-word;
-}
-.card .section .item label {
- font-weight: bold;
-}
-
-.card .section textarea.NOTE {
- min-height: 6em;
-}
-.card .section textarea.ADR {
- min-height: 4em;
-}
-
-.card .section .PHOTO {
- width: 100%;
- max-height: 10em;
}
EOF
# You should have received a copy of the GNU Affero General Public License
# along with Confetti. If not, see <http://www.gnu.org/licenses/>.
+setchecked() {
+ printf 'checked="checked"'
+}
+setselected() {
+ printf 'selected="selected"'
+}
check_gen() {
- [ "$values[GENDER]" = "$1" ] && echo 'selected="selected"'
+ [ "$values[GENDER]" = "$1" ] && setselected
}
check_a() {
- egrep -q "^${1}.${id}$" "$_DATA/mappings/attendance" && echo 'checked="checked"'
+ egrep -q "^${1}.${id}$" "$_DATA/mappings/attendance" && setchecked
+}
+teltype() {
+ cat <<-EOF
+ <select class="item phonetype" name="phonetype">
+ <option value="" disabled="disabled" $([ -z "$1" ] && setselected )>$(l10n phone_typeselect)</option>
+ <option value=""></option>
+ <option value="HOME" $([ "$1" = HOME ] && setselected)>$(l10n phone_home)</option>
+ <option value="CELL" $([ "$1" = CELL ] && setselected)>$(l10n phone_cell)</option>
+ <option value="WORK" $([ "$1" = WORK ] && setselected)>$(l10n phone_work)</option>
+ <option value="FAX" $([ "$1" = FAX ] && setselected)>$(l10n phone_fax )</option>
+ </select>
+ EOF
}
n_last="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){0} *([^;]*).*$:\2:p')"
<div class="section phone">
<h3>$(l10n TEL)</h3>
- <input class="item TEL" name="TEL" value="$values[TEL]" />
+ $(teltype "${tags[TEL_TYPE]}")<input class="item TEL" name="TEL" value="$values[TEL]" />
$(for n in TEL{0..10}; do
- echo "${values[$n]:+<input class="item TEL" name="TEL" value="'$values[$n]'" />}"
+ printf "${values[$n]:+$(teltype "${tags[$n_TYPE]}")<input class="item TEL" name="TEL" value="'$values[$n]'" />}"
done)
${values[EMAIL]:+<h3>$(l10n EMAIL)</h3>}
$(for n in EMAIL EMAIL{0..10}; do
- echo "${values[$n]:+<input class="item EMAIL" name="EMAIL" value="$values[$n]" />}"
+ printf "${values[$n]:+<input class="item EMAIL" name="EMAIL" value="$values[$n]" />}"
done)
${values[IMPP]:+<h3>$(l10n IMPP)</h3>}
$(for n in IMPP IMPP{0..10}; do
item_name[BDAY]="Geburtstag"
item_name[EMAIL]="E-Mail"
item_name[TEL]="Telefon"
+item_name[phone_typeselect]="Typ"
+item_name[phone_home]="Privat"
+item_name[phone_cell]="Mobil"
+item_name[phone_work]="Büro"
+item_name[phone_fax]="Fax"
+item_name[tHOME]="Privat:"
+item_name[tWORK]="Büro:"
+item_name[tCELL]="Mobil:"
+item_name[tFAX]="Fax:"
+item_name[tVOICE]=""
item_name[IMPP]="Chat"
item_name[ADR]="Anschrift"
item_name[URL]="Webseite"
-# Copyright 2014 Paul Hänsch
+# Copyright 2014, 2016 Paul Hänsch
#
# This file is part of Confetti.
#
item_name[t_times]="mal"
item_name[t_until]="Bis"
item_name[t_oclock]="Uhr"
-
-l10n() {
- [ -n "$item_name[$1]" ] && echo -n "$item_name[$1]" || echo -n "$1"
-}
cat <<END_HTML
<div class="section basic">
<h2 class="item FN">$fullname</h2>
- ${values[GENDER]:+<span class="item GENDER">$(l10n $values[GENDER])</span>}
+ ${values[GENDER]:+<span class="\""item GENDER"\"">$(l10n $values[GENDER])</span>}
$(for n in NICKNAME NICKNAME{0..10}; do
- echo "${values[$n]:+<span class="item NICKNAME">aka. $values[$n]</span>}"
+ echo "${values[$n]:+<span class="\""item NICKNAME"\"">aka. $values[$n]</span>}"
done)
- ${values[BDAY]:+<span class="item BDAY"><label>*:</label> ${values[BDAY]}</span>}
- ${values[SOUND]:+<audio controls="controls" class="item SOUND"><source type="audio/ogg" src="data:audio/ogg;base64,$values[SOUND]" /></audio>}
- ${values[PHOTO]:+<img class="item PHOTO" src="data:image/$tags[PHOTO_TYPE];base64,$values[PHOTO]" />}
- ${values[LOGO]:+<img class="item LOGO" src="data:image/$tags[LOGO_TYPE];base64,$values[LOGO]" />}
+ ${values[BDAY]:+<span class="\""item BDAY"\""><label>*:</label> ${values[BDAY]}</span>}
+ ${values[SOUND]:+<audio controls="controls" class="\""item SOUND"\""><source type="audio/ogg" src="\""data:audio/ogg;base64,$values[SOUND]"\"" /></audio>}
+ ${values[PHOTO]:+<img class="\""item PHOTO"\"" src="\""data:image/$tags[PHOTO_TYPE];base64,$values[PHOTO]"\"" />}
+ ${values[LOGO]:+<img class="\""item LOGO"\"" src="\""data:image/$tags[LOGO_TYPE];base64,$values[LOGO]"\"" />}
<h3>$(l10n ADR)</h3>
$(for n in ADR ADR{0..10}; do
- echo "${values[$n]:+<span class="item ADR">$values[$n]</span>}"
+ echo "${values[$n]:+<span class="\""item ADR"\"">$values[$n]</span>}"
done)
${values[URL]:+<h3>$(l10n URL)</h3>}
$(for n in URL URL{0..10}; do
- echo "${values[$n]:+<span class="item URL"><a href="$values[$n]">$values[$n]</a></span>}"
+ echo "${values[$n]:+<span class="\""item URL"\""><a href="\""$values[$n]"\"">$values[$n]</a></span>}"
done)
</div><!--
--><div class="section phone">
<h3>$(l10n TEL)</h3>
$(for n in TEL TEL{0..10}; do
- echo "${values[$n]:+<span class="item TEL">$tags[${n}_TYPE] $values[$n]</span>}"
+ echo "${values[$n]:+<span class="\""item TEL"\"">$(l10n t${tags[${n}_TYPE]}) $values[$n]</span>}"
done)
${values[EMAIL]:+<h3>$(l10n EMAIL)</h3>}
$(for n in EMAIL EMAIL{0..10}; do
- echo "${values[$n]:+<span class="item EMAIL"><a href="mailto:$values[$n]">$values[$n]</a></span>}"
+ echo "${values[$n]:+<span class="\""item EMAIL"\""><a href="\""mailto:$values[$n]"\"">$values[$n]</a></span>}"
done)
${values[IMPP]:+<h3>$(l10n IMPP)</h3>}
$(for n in IMPP IMPP{0..10}; do
- echo "${values[$n]:+<span class="item IMPP">$tags[${n}_TYPE] <a href="$values[$n]">$values[$n]</a></span>}"
+ echo "${values[$n]:+<span class="\""item IMPP"\"">$tags[${n}_TYPE] <a href="\""$values[$n]"\"">$values[$n]</a></span>}"
done)
</div><!--
--><div class="section insurance">
<h3>$(l10n X-HEALTH-INSURANCE)</h3>
- ${hi_company:+<span class="item hi_comapany">${hi_company}</span>}
- ${hi_number:+<span class="item hi_number"><label>$(l10n hi_number):</label> ${hi_number}</span>}
- ${hi_status:+<span class="item hi_status"><label>$(l10n hi_status):</label> ${hi_status}</span>}
+ ${hi_company:+<span class="\""item hi_comapany"\"">${hi_company}</span>}
+ ${hi_number:+<span class="\""item hi_number"\""><label>$(l10n hi_number):</label> ${hi_number}</span>}
+ ${hi_status:+<span class="\""item hi_status"\""><label>$(l10n hi_status):</label> ${hi_status}</span>}
</div><!--
--><div class="section note">
${values[NOTE]:+<h3>$(l10n NOTE)</h3>}
$(for n in NOTE NOTE{0..10}; do
- echo "${values[$n]:+<span class="item NOTE">$values[$n]</span>}"
+ echo "${values[$n]:+<span class="\""item NOTE"\"">$values[$n]</span>}"
done)
${values[X-CLIENT-REFERRAL]:+<h3>$(l10n X-CLIENT-REFERRAL)</h3>}
$(for n in X-CLIENT-REFERRAL X-CLIENT-REFERRAL{0..10}; do
- echo "${values[$n]:+<span class="item X-CLIENT-REFERRAL">$values[$n]</span>}"
+ echo "${values[$n]:+<span class="\""item X-CLIENT-REFERRAL"\"">$values[$n]</span>}"
done)
</div><!--