]> git.plutz.net Git - confetti/blobdiff - templates/therapy.html.sh
Lobster: time sheet on therapy note
[confetti] / templates / therapy.html.sh
index 0c91487cee322764b670f06608a124cf98d7f1fe..1821c24530c97b980d31fbad9ba50c87a116ac45 100755 (executable)
@@ -1,4 +1,4 @@
-# Copyright 2016 Paul Hänsch
+# Copyright 2016, 2017 Paul Hänsch
 #
 # This file is part of Confetti.
 # 
@@ -22,30 +22,26 @@ t_session_note(){
   color=session${session_n}_note${note_n}_color
   unset c0 c1 c2 c3 c4 c5 c6 c7
   
-  case "$tpy[$color]" in
-    \#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="#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
+  _checked="$(validate "$tpy[$color]" '#(888|00A|0A0|0AA|A00|A0A|AA0)' '#FFF')"
+       cat <<-EOF
+         <fieldset class="note trailbox">
+           <input class=color type=radio name="$color" value="#888" id=${color}_000 $(checked \#888)><label for=${color}_000></label>
+           <input class=color type=radio name="$color" value="#00A" id=${color}_001 $(checked \#00A)><label for=${color}_001></label>
+           <input class=color type=radio name="$color" value="#0A0" id=${color}_010 $(checked \#0A0)><label for=${color}_010></label>
+           <input class=color type=radio name="$color" value="#0AA" id=${color}_011 $(checked \#0AA)><label for=${color}_011></label>
+           <input class=color type=radio name="$color" value="#A00" id=${color}_100 $(checked \#A00)><label for=${color}_100></label>
+           <input class=color type=radio name="$color" value="#A0A" id=${color}_101 $(checked \#A0A)><label for=${color}_101></label>
+           <input class=color type=radio name="$color" value="#AA0" id=${color}_110 $(checked \#AA0)><label for=${color}_110></label>
+           <input class=color type=radio name="$color" value="#FFF" id=${color}_111 $(checked \#FFF)><label for=${color}_111></label>
+           <textarea name="session${session_n}_note${note_n}">${tpy[session${session_n}_note${note_n}]}</textarea>
+         </fieldset>
+       EOF
 }
 
 t_session(){
@@ -54,43 +50,37 @@ 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
 
-cat <<EOF
-  <input type=hidden name=$sid value=exists>
-  <input class="tab" type="checkbox" id=${sid}_open name="${sid}_open" value="checked" ${tpy[${sid}_open]}>
-  <label class="tab" for="${sid}_open">
-    <span class=no>${session_n}.</span><!--
- --><span class=date>${tpy[${sid}_date]}</span><!--
- --><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>
-  </label>
-  <div class=tab>
-    <img class="dotmark ov" 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"
-    )
-
-    <button class=delete type=submit name=delete_session value=${session_n}>$(l10n delete_session)</button>
-    <button type=submit>$(l10n save)</button>
-  </div>
-EOF
+       cat <<-EOF
+         <input type=hidden name=$sid value=exists>
+         <input class="tab" type="checkbox" id=${sid}_open name="${sid}_open" value="checked" ${tpy[${sid}_open]}>
+         <label class="tab" for="${sid}_open">
+           <span class=no>${session_n}.</span><!--
+        --><span class=date>${tpy[${sid}_date]}</span><!--
+        --><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}_sigset" value="pos" $sigcheck></span>
+         </label>
+         <div class=tab>
+           <img class="dotmark ov" src="/therapies/${id%.tpy}_${sid}.png" alt="">
+           $(n=1;
+              while [ -n "${tpy[session${session_n}_note${n}]+x}" ]; do
+                if [ -n "${tpy[session${session_n}_note${n}]}" ]; then
+                  x=$n
+                fi
+                n=$(($n + 1))
+              done
+              for n in $(seq 1 $((${x:-0} + 3)) ); do t_session_note $session_n $n; done
+             )
+           <button class="trailbtn" type="submit">$(l10n trailsave)</button>
+           <button class=delete type=submit name=delete_session value=${session_n}>$(l10n delete_session)</button>
+         </div>
+       EOF
 }
 
 therapy_sessions(){
@@ -101,29 +91,17 @@ therapy_sessions(){
 
   sid=session$n
 
-cat <<EOF
-  <fieldset class="tab">
-    <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)" /><!--
- --><span class=signature><span></span>
-    <input type=hidden name="${sid}_note1" value="">
-  </fieldset>
-EOF
+       cat <<-EOF
+         <fieldset class="tab">
+           <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)" /><!--
       --><span class=signature><span></span>
+           <input type=hidden name="${sid}_note1" value="">
+         </fieldset>
+       EOF
 }
 
-unset c0 c1 c2 c3 c4 c5 c6 c7
-case "$tpy[color]" in
-  \#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>$(l10n therapy)</h1>
 
@@ -147,10 +125,12 @@ cat <<EOF
      ${mpx[housecall]:+<span class="catalogue">$(l10n housecall)</span>}
         ${mpx[report]:+<span class="catalogue">$(l10n report)</span>}
 
-  <ul>
-    ${mpx[remidy]:+ <li>${mpx[quantity]}  ${mpx[remidy]}  ${mpx[quantity_weekly]:+($mpx[quantity_weekly] $(l10n weekly))}</li>}
-    ${mpx[remidy1]:+<li>${mpx[quantity1]} ${mpx[remidy1]} ${mpx[quantity_weekly1]:+($mpx[quantity_weekly1] $(l10n weekly))}</li>}
-  </ul>
+  <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>}
@@ -161,18 +141,45 @@ cat <<EOF
                                       || printf %s "$(l10n addcontrib)" )
   </label>
   }
+
+  <input class="tab" type="checkbox" id="indicator_reading">
+  <label class="tab" for="indicator_reading">$(l10n indicator_reading)</label>
+  <div class="tab">${mpx[indicator_reading]}</div>
 </div>
 
-<form method="POST" action="?action=update_therapy">
+<form id="report" 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>
+    <h2>$(l10n notes)</h2>
     <textarea name="stickynote">${tpy[stickynote]}</textarea>
-    <button type=submit>$(l10n save)</button>
+    <button type="submit">$(l10n save)</button>
   </fieldset>
 
+  <input class="stickynote" type="checkbox" name="c_timesheet" id="show_timesheet">
+  <fieldset class="stickynote">
+    <label for="show_timesheet">$(l10n timesheet)</label>
+    <h2>$(l10n timesheet)</h2>
+    <table><thead>
+      <tr><th>$(l10n time_goal)</th><th>$(l10n time_actual)</th><th>$(l10n time_difference)</th></tr>
+    </thead><tbody>
+      $(for n in '' {0..10}; do
+        printf '<tr><td><input type="number" name="tsgoal" value="%s"/></td>
+                    <td><input type="number" name="tsactual" value="%s"/></td>
+                    <td>%s</td>
+                </tr>\n' \
+                "$mpx[tsgoal${n}]" "$mpx[tsactual${n}]" "$((${mpx[tsgoal${n}]:-0} - ${mpx[tsactual${n}]:-0}))"
+      done)
+    </tbody></table>
+    <button type="submit">$(l10n save)</button>
+  </fieldset>
+
+  <!--input class="tab" type="checkbox" id="lookout">
+  <label class="tab" for="lookout">$(l10n indicator_reading)</label>
+  <div class="tab"><textarea name="lookout">${mpx[lookout]}</textarea -->
+
   <label class="tab heading">
     <span class=no>$(l10n number)</span><!--
  --><span class=date>$(l10n date)</span><!--
@@ -183,84 +190,38 @@ EOF
 
 therapy_sessions
 
+_checked="$(validate "$tpy[penwidth]" '(4|12|36)' '4')"
 cat <<EOF
-  <fieldset class=color>
-    <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 class="penwidth">
+    <input type="radio" name="penwidth" value="4"  id="pw1" $(checked  4)><label for="pw2"></label>
+    <input type="radio" name="penwidth" value="12" id="pw2" $(checked 12)><label for="pw3"></label>
+    <input type="radio" name="penwidth" value="36" id="pw3" $(checked 36)><label for="pw1"></label>
+  </fieldset>
+EOF
+
+_checked="$(validate "$tpy[color]" '#(0[0A]{2}|A00|A0A|AA0|FFF)' '#000')"
+cat <<EOF
+  <fieldset class="color">
+    <input class="color" type="radio" name="color" value="#000" id="c000" $(checked \#000)><label for="c000"></label>
+    <input class="color" type="radio" name="color" value="#00A" id="c001" $(checked \#00A)><label for="c001"></label>
+    <input class="color" type="radio" name="color" value="#0A0" id="c010" $(checked \#0A0)><label for="c010"></label>
+    <input class="color" type="radio" name="color" value="#0AA" id="c011" $(checked \#0AA)><label for="c011"></label>
+    <input class="color" type="radio" name="color" value="#A00" id="c100" $(checked \#A00)><label for="c100"></label>
+    <input class="color" type="radio" name="color" value="#A0A" id="c101" $(checked \#A0A)><label for="c101"></label>
+    <input class="color" type="radio" name="color" value="#AA0" id="c110" $(checked \#AA0)><label for="c110"></label>
+    <input class="color" type="radio" name="color" value="#FFF" id="c111" $(checked \#FFF)><label for="c111"></label>
   </fieldset>
   <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="">
-  <span id="jsdebug" style="display: none; position: fixed; right:0; bottom:0">Debug</span>
-
-  <script><!--
-  body = document.body
-  canvas = document.getElementById("canvas")
-  dbg = document.getElementById("jsdebug")
-  image = canvas.getContext("2d")
-  mouse = 0
-  image_serialize=""
-  data=document.getElementById("image_serialize")
-
-  function setcol(c) {
-    image.strokeStyle = c
-    if ( c == "#FFF" ) image.lineWidth = 32
-    else image.lineWidth = 4
-    image_serialize += " stroke " + c + " stroke-width " + image.lineWidth
-  }
-
-  setcol("$tpy[color]")
-
-  function draw(x, y) {
-    if ( mouse == 1){
-      if ( body.clientWidth >= 800 ){
-        sx=Math.floor(cscaleW * (x - canvas.offsetLeft))
-        sy=Math.floor(cscaleH * (y - canvas.offsetTop))
-      } else { 
-        sx=Math.floor(cscaleW * (x - canvas.offsetLeft + window.pageXOffset))
-        sy=Math.floor(cscaleH * (y - canvas.offsetTop + window.pageYOffset))
-      }
-      image.lineTo( sx, sy )
-      image.stroke()
-
-      image_serialize += " " + sx + "," + sy
-    }
-  }
-
-  function drawstart(x, y) {
-    mouse = 1
-
-    cscaleW = canvas.width / canvas.clientWidth
-    cscaleH = canvas.height / canvas.clientHeight
-
-    image_serialize += " polyline"
-    image.beginPath()
-    draw(x, y)
-  }
-  function drawstop() {
-   mouse = 0
-   image.closePath()
-   dbg.innerHTML = image_serialize
-   data.value = image_serialize
-  }
-
-  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>
+  <button type="submit">$(l10n save)</button>
 </form>
 
+<span id="jsdebug" style="display: none; position: fixed; right:0; bottom:0">Debug</span>
+
+<script type="text/javascript" src="?static=therapy_draw.js"></script>
 EOF
+
 # vi:set filetype=html: