]> git.plutz.net Git - confetti/blobdiff - templates/therapy.html.sh
enable closed shape drawing for haptic improvements
[confetti] / templates / therapy.html.sh
index f6533f74d3dc0ca9a111ce145f7b7615e65321a6..63216ad703ced7ce40ca7120f70d4362e2932c3a 100755 (executable)
@@ -23,26 +23,31 @@ t_session_note(){
   unset c0 c1 c2 c3 c4 c5 c6 c7
   
   case "$tpy[$color]" in
-    c000) c0=checked;;
-    c001) c1=checked;;
-    c010) c2=checked;;
-    c011) c3=checked;;
-    c100) c4=checked;;
-    c101) c5=checked;;
-    c110) c6=checked;;
+    \#888) c0=checked;;
+    \#00A) c1=checked;;
+    \#0A0) c2=checked;;
+    \#0AA) c3=checked;;
+    \#A00) c4=checked;;
+    \#A0A) c5=checked;;
+    \#AA0) c6=checked;;
     *)    c7=checked;;
   esac
 
+if [ "$note_n" -eq 1 -o -n "${tpy[session${session_n}_note${note_n}]}" ]; then
+  printf '<input class="trailbtn" type="checkbox" checked="checked">'
+else
+  printf '<input class="trailbtn" type="checkbox">'
+fi
 cat <<EOF
-  <fieldset class=note>
-    <input class=color type=radio name="$color" value="c000" id=${color}_000 $c0><label for=${color}_000></label>
-    <input class=color type=radio name="$color" value="c001" id=${color}_001 $c1><label for=${color}_001></label>
-    <input class=color type=radio name="$color" value="c010" id=${color}_010 $c2><label for=${color}_010></label>
-    <input class=color type=radio name="$color" value="c011" id=${color}_011 $c3><label for=${color}_011></label>
-    <input class=color type=radio name="$color" value="c100" id=${color}_100 $c4><label for=${color}_100></label>
-    <input class=color type=radio name="$color" value="c101" id=${color}_101 $c5><label for=${color}_101></label>
-    <input class=color type=radio name="$color" value="c110" id=${color}_110 $c6><label for=${color}_110></label>
-    <input class=color type=radio name="$color" value="c111" id=${color}_111 $c7><label for=${color}_111></label>
+  <fieldset class="note trailbox">
+    <input class=color type=radio name="$color" value="#888" id=${color}_000 $c0><label for=${color}_000></label>
+    <input class=color type=radio name="$color" value="#00A" id=${color}_001 $c1><label for=${color}_001></label>
+    <input class=color type=radio name="$color" value="#0A0" id=${color}_010 $c2><label for=${color}_010></label>
+    <input class=color type=radio name="$color" value="#0AA" id=${color}_011 $c3><label for=${color}_011></label>
+    <input class=color type=radio name="$color" value="#A00" id=${color}_100 $c4><label for=${color}_100></label>
+    <input class=color type=radio name="$color" value="#A0A" id=${color}_101 $c5><label for=${color}_101></label>
+    <input class=color type=radio name="$color" value="#AA0" id=${color}_110 $c6><label for=${color}_110></label>
+    <input class=color type=radio name="$color" value="#FFF" id=${color}_111 $c7><label for=${color}_111></label>
     <textarea name="session${session_n}_note${note_n}">${tpy[session${session_n}_note${note_n}]}</textarea>
   </fieldset>
 EOF
@@ -54,16 +59,8 @@ t_session(){
   sid=session${session_n}
 
   if [ "$tpy[${sid}_sigset]" = pos ]; then
-    sig=neg
-    sigcheck=checked
-  elif [ "$tpy[${sid}_sigset]" = neg ]; then
-    sig=pos
-    unset sigcheck
-  elif [ "$tpy[${sid}_signature]" = pos ]; then
-    sig=neg
     sigcheck=checked
   else
-    sig=pos
     unset sigcheck
   fi
 
@@ -76,19 +73,13 @@ cat <<EOF
  --><input class="date" name="${sid}_date" value="${tpy[${sid}_date]}" placeholder="$(l10n date)"><!--
  --><span class=therapist>${tpy[${sid}_therapist]}</span><!--
  --><input class="therapist" name="${sid}_therapist" value="${tpy[${sid}_therapist]}" placeholder="$(l10n therapist)"><!--
- --><span class=signature><input type=checkbox name="${sid}_signature" value=pos $sigcheck><button type=submit name=${sid}_sigset value=$sig></button></span>
+ --><span class=signature><input type="checkbox" name="${sid}_sigset" value="pos" $sigcheck></span>
   </label>
   <div class=tab>
-    <input class="dotmark ov" type="image" name=dotmark value="$sid" src="/therapies/${id%.tpy}_${sid}.png" alt="">
-    $(n=1; while [ -n "${tpy[${sid}_note${n}]+x}" ]; do
-      t_session_note $session_n $n
-      n=$(($n+1))
-    done
-    printf '<button type=submit name=%s_note%s value="">+</button>' "$sid" "$n"
-    )
+    <img class="dotmark ov" src="/therapies/${id%.tpy}_${sid}.png" alt="">
+    $( for n in {1..50}; do t_session_note $session_n $n; done )
 
     <button class=delete type=submit name=delete_session value=${session_n}>$(l10n delete_session)</button>
-    <button type=submit>$(l10n save)</button>
   </div>
 EOF
 }
@@ -103,81 +94,205 @@ therapy_sessions(){
 
 cat <<EOF
   <fieldset class="tab">
-    <span class=no>…</span><!--
+    <button class=no type=submit name=new_session value=$sid>+</button><!--
  --><input class=date name=${sid}_date value="" placeholder="$(l10n date)" /><!--
  --><input class=therapist name=${sid}_therapist value="" placeholder="$(l10n therapist)" /><!--
- --><button type=submit name=new_session value=$sid>+</button></span>
+ --><span class=signature><span></span>
     <input type=hidden name="${sid}_note1" value="">
-    <input type=hidden name="${sid}_open" value="checked">
   </fieldset>
 EOF
 }
 
 unset c0 c1 c2 c3 c4 c5 c6 c7
 case "$tpy[color]" in
-  c001) c1=checked;;
-  c010) c2=checked;;
-  c011) c3=checked;;
-  c100) c4=checked;;
-  c101) c5=checked;;
-  c110) c6=checked;;
-  c111) c7=checked;;
-     *) c0=checked;;
+  \#00A) c1="checked";;
+  \#0A0) c2="checked";;
+  \#0AA) c3="checked";;
+  \#A00) c4="checked";;
+  \#A0A) c5="checked";;
+  \#AA0) c6="checked";;
+  \#FFF) c7="checked";;
+      *) c0="checked";;
 esac
 
 cat <<EOF
-  <h1>Behandlungen</h1>
+<h1>$(l10n therapy)</h1>
 
-  <div class="patient">
-    <h2>$client_name</h2>
-    <a href="?p=prescriptions&amp;client=${id%%.*}.vcf">&lt; $(l10n prescriptionlist)</a>
-  </div>
+<div class="patient">
+  <h2>$client_name</h2>
+  <a href="?p=prescriptions&amp;client=${id%%.*}.vcf">&lt; $(l10n prescriptionlist)</a>
+</div>
 
-  <div class="prescription">
-    <h2>$(l10n therapy_prescription)</h2>
-    <span class="insurance">${mpx[insurance]}</span>
-    <label class="checkbox ${mpx[prescreviewed]:+checked}" for="prescreviewed">
-      $([ -n "${mpx[prescreviewed]}" ] && printf %s "$(l10n prescreviewed)" \
-                                       || printf %s "$(l10n prescreview)" )
-    </label>
-    <ul>
-      ${mpx[remidy]:+ <li>${mpx[quantity]}  ${mpx[remidy]}</li>}
-      ${mpx[remidy1]:+<li>${mpx[quantity1]} ${mpx[remidy1]}</li>}
-    </ul>
-
-    ${mpx[addcontrib]:+
-    <label class='checkbox ${mpx[contribconfirm]:+checked}' for="addcontrib">
-      $([ -n "${mpx[contribconfirm]}" ] && printf %s "$(l10n contribconfirm)" ${mpx[contribconfirm]} \
-                                        || printf %s "$(l10n addcontrib)" )
-    </label>
-    }
-  </div>
+<div class="prescription">
+  <h2>$(l10n therapy_prescription)</h2>
+  <span class="insurance">${mpx[insurance]}</span>
+  <span class="date"><label>$(l10n date):</label>${mpx[date]}</span>
+
+  <label class="checkbox ${mpx[prescreviewed]:+checked}" for="prescreviewed">
+    $([ -n "${mpx[prescreviewed]}" ] && printf %s "$(l10n prescreviewed)" \
+                                     || printf %s "$(l10n prescreview)" )
+  </label>
+
+       ${mpx[prescno]:+<span class="prescno">$(l10n presc${mpx[prescno]})</span>}
+  ${mpx[grouptherapy]:+<span class="catalogue">$(l10n grouptherapy)</span>}
+     ${mpx[housecall]:+<span class="catalogue">$(l10n housecall)</span>}
+        ${mpx[report]:+<span class="catalogue">$(l10n report)</span>}
+
+  <ul>$(for n in '' {0..10}; do
+    [ -n "${mpx[remidy$n]}" ] && \
+    printf '<li>%s %s %s</li>' "${mpx[quantity$n]}" \
+                               "${mpx[remidy$n]}" \
+                               "${mpx[quantity_weekly$n]:+($mpx[quantity_weekly$n] $(l10n weekly))}"
+  done)</ul>
+
+  ${mpx[indicator]:+<span class="indicator"><label>$(l10n indicator):</label>${mpx[indicator]}</span>}
+      ${mpx[icd10]:+<span class="icd10">    <label>$(l10n icd10):</label>${mpx[icd10]}</span>}
+
+  ${mpx[addcontrib]:+
+  <label class='checkbox ${mpx[contribconfirm]:+checked}' for="addcontrib">
+    $([ -n "${mpx[contribconfirm]}" ] && printf %s "$(l10n contribconfirm)" ${mpx[contribconfirm]} \
+                                      || printf %s "$(l10n addcontrib)" )
+  </label>
+  }
+</div>
 
 <form method="POST" action="?action=update_therapy">
   <input type="hidden" name="id" value="${id}">
 
+  <input class="stickynote" type="checkbox" name="c_stickynote" id="show_stickynote">
+  <fieldset class="stickynote">
+    <label for="show_stickynote">$(l10n notes)</label>
+    <textarea name="stickynote">${tpy[stickynote]}</textarea>
+    <button type=submit>$(l10n save)</button>
+  </fieldset>
+
   <label class="tab heading">
-    <span class=no>Nr.</span><!--
- --><span class=date>Datum</span><!--
- --><span class=therapist>Therapeut</span><!--
- --><span class=signature>Sig.</span>
+    <span class=no>$(l10n number)</span><!--
+ --><span class=date>$(l10n date)</span><!--
+ --><span class=therapist>$(l10n therapist)</span><!--
+ --><span class=signature>$(l10n signature)</span>
   </label>
+EOF
 
-  $(therapy_sessions)
+therapy_sessions
 
+cat <<EOF
   <fieldset class=color>
-    <input class=color type=radio name=color value="c000" id=c000 $c0><label for=c000></label>
-    <input class=color type=radio name=color value="c001" id=c001 $c1><label for=c001></label>
-    <input class=color type=radio name=color value="c010" id=c010 $c2><label for=c010></label>
-    <input class=color type=radio name=color value="c011" id=c011 $c3><label for=c011></label>
-    <input class=color type=radio name=color value="c100" id=c100 $c4><label for=c100></label>
-    <input class=color type=radio name=color value="c101" id=c101 $c5><label for=c101></label>
-    <input class=color type=radio name=color value="c110" id=c110 $c6><label for=c110></label>
-    <input class=color type=radio name=color value="c111" id=c111 $c7><label for=c111></label>
+    <input class=color type=radio name=color onclick="javascript:setcol('#000')" value="#000" id=c000 $c0><label for=c000></label>
+    <input class=color type=radio name=color onclick="javascript:setcol('#00A')" value="#00A" id=c001 $c1><label for=c001></label>
+    <input class=color type=radio name=color onclick="javascript:setcol('#0A0')" value="#0A0" id=c010 $c2><label for=c010></label>
+    <input class=color type=radio name=color onclick="javascript:setcol('#0AA')" value="#0AA" id=c011 $c3><label for=c011></label>
+    <input class=color type=radio name=color onclick="javascript:setcol('#A00')" value="#A00" id=c100 $c4><label for=c100></label>
+    <input class=color type=radio name=color onclick="javascript:setcol('#A0A')" value="#A0A" id=c101 $c5><label for=c101></label>
+    <input class=color type=radio name=color onclick="javascript:setcol('#AA0')" value="#AA0" id=c110 $c6><label for=c110></label>
+    <input class=color type=radio name=color onclick="javascript:setcol('#FFF')" value="#FFF" id=c111 $c7><label for=c111></label>
   </fieldset>
-  <img class="dotmark bg" src="?action=static_file&amp;name=therapy_background.png" alt="">
+  <img class="dotmark bg" src="?static=therapy_background.png" alt="WARNING: Background Image not available!">
+  <canvas id="canvas" class="dotmark ov" width="${bg_dim%x*}" height="${bg_dim#*x}"></canvas>
 
+  <input type=hidden id=image_serialize name=imagedata value="">
+
+  <button type="submit">$(l10n save)</button>
 </form>
 
+<span id="jsdebug" style="display: none; position: fixed; right:0; bottom:0">Debug</span>
+
+<script><!--
+body = document.body
+dbg = document.getElementById("jsdebug")
+canvas = document.getElementById("canvas")
+data=document.getElementById("image_serialize")
+
+image = canvas.getContext("2d")
+mouse = 0
+image_serialize=""
+
+// start and current coordinates of a draw
+// serves for tracking, whether path ends close to its beginning
+stx=0, sty=0
+cux=0, cuy=0
+
+function setcol(c) {
+  this.c = c
+  image.strokeStyle = c
+  image.fillStyle =  c
+  if ( c == "#FFF" ) image.lineWidth = 32
+  else image.lineWidth = 4
+  data.value += " stroke " + c + " stroke-width " + image.lineWidth
+}
+
+setcol("$tpy[color]")
+
+function relX(x){
+  if ( body.clientWidth >= 800 ){
+    return Math.floor(cscaleW * (x - canvas.offsetLeft))
+  } else { 
+    return Math.floor(cscaleW * (x - canvas.offsetLeft + window.pageXOffset))
+  }
+}
+function relY(y){
+  if ( body.clientWidth >= 800 ){
+    return Math.floor(cscaleH * (y - canvas.offsetTop))
+  } else { 
+    return Math.floor(cscaleH * (y - canvas.offsetTop + window.pageYOffset))
+  }
+}
+
+function draw(x, y) {
+  if ( mouse == 1){
+    cux=relX(x), cuy=relY(y)
+
+    image.lineTo( cux, cuy )
+    image.stroke()
+
+    image_serialize += " " + cux + "," + cuy
+  }
+}
+
+function drawstart(x, y) {
+  mouse = 1
+
+  cscaleW = canvas.width / canvas.clientWidth
+  cscaleH = canvas.height / canvas.clientHeight
+
+  stx=relX(x), sty=relY(y)
+
+  image.beginPath()
+  draw(x, y)  // why must this not use relative Coords ???
+
+  image_serialize = " polyline"
+}
+
+function drawstop() {
+  // if path ends close to beginning ( < 50 px); then close path and fill
+  if ( mouse == 1 && Math.sqrt( Math.pow(stx - cux, 2) + Math.pow(sty - cuy, 2)) <= 50 ){
+    image.lineTo( stx, sty )
+    image.stroke()
+
+    image.globalAlpha = .5
+    image.fill()
+    image.globalAlpha = 1
+
+    image_serialize += " " + stx + "," + sty
+    data.value += " fill " + c + "8" + image_serialize
+  } else if (mouse == 1)  {
+    data.value += " fill #0000 " + image_serialize
+  }
+  dbg.innerHTML = " stx: " + stx + " cux: " + cux + " sty: " + sty + " cuy: " + cuy
+  image.closePath()
+  image_serialize = ""
+  mouse = 0
+}
+
+window.addEventListener( 'mouseup',   function()   { drawstop() } )
+canvas.addEventListener( 'mousedown', function(e)  { drawstart(e.clientX, e.clientY) } )
+canvas.addEventListener( 'mousemove', function(e)  {      draw(e.clientX, e.clientY) } )
+
+window.addEventListener( 'touchend',   function()  { drawstop() } )
+canvas.addEventListener( 'touchstart', function(e) { drawstart(e.touches[0].clientX, e.touches[0].clientY) } )
+canvas.addEventListener( 'touchmove',  function(e) { e.preventDefault(); draw(e.touches[0].clientX, e.touches[0].clientY) } )
+--></script>
 EOF
 # vi:set filetype=html: