]> git.plutz.net Git - confetti/blob - templates/therapy.html.sh
unify css, increase responsiveness by reducing server communication
[confetti] / templates / therapy.html.sh
1 # Copyright 2016 Paul Hänsch
2 #
3 # This file is part of Confetti.
4
5 # Confetti is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9
10 # Confetti is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU Affero General Public License for more details.
14
15 # You should have received a copy of the GNU Affero General Public License
16 # along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
17
18 t_session_note(){
19   session_n="$1"
20   note_n="$2"
21   
22   color=session${session_n}_note${note_n}_color
23   unset c0 c1 c2 c3 c4 c5 c6 c7
24   
25   case "$tpy[$color]" in
26     \#888) c0=checked;;
27     \#00A) c1=checked;;
28     \#0A0) c2=checked;;
29     \#0AA) c3=checked;;
30     \#A00) c4=checked;;
31     \#A0A) c5=checked;;
32     \#AA0) c6=checked;;
33     *)    c7=checked;;
34   esac
35
36 if [ "$note_n" -eq 1 -o -n "${tpy[session${session_n}_note${note_n}]}" ]; then
37   printf '<input class="trailbtn" type="checkbox" checked="checked">'
38 else
39   printf '<input class="trailbtn" type="checkbox">'
40 fi
41 cat <<EOF
42   <fieldset class="note trailbox">
43     <input class=color type=radio name="$color" value="#888" id=${color}_000 $c0><label for=${color}_000></label>
44     <input class=color type=radio name="$color" value="#00A" id=${color}_001 $c1><label for=${color}_001></label>
45     <input class=color type=radio name="$color" value="#0A0" id=${color}_010 $c2><label for=${color}_010></label>
46     <input class=color type=radio name="$color" value="#0AA" id=${color}_011 $c3><label for=${color}_011></label>
47     <input class=color type=radio name="$color" value="#A00" id=${color}_100 $c4><label for=${color}_100></label>
48     <input class=color type=radio name="$color" value="#A0A" id=${color}_101 $c5><label for=${color}_101></label>
49     <input class=color type=radio name="$color" value="#AA0" id=${color}_110 $c6><label for=${color}_110></label>
50     <input class=color type=radio name="$color" value="#FFF" id=${color}_111 $c7><label for=${color}_111></label>
51     <textarea name="session${session_n}_note${note_n}">${tpy[session${session_n}_note${note_n}]}</textarea>
52   </fieldset>
53 EOF
54 }
55
56 t_session(){
57   session_n="$1"
58
59   sid=session${session_n}
60
61   if [ "$tpy[${sid}_sigset]" = pos ]; then
62     sigcheck=checked
63   else
64     unset sigcheck
65   fi
66
67 cat <<EOF
68   <input type=hidden name=$sid value=exists>
69   <input class="tab" type="checkbox" id=${sid}_open name="${sid}_open" value="checked" ${tpy[${sid}_open]}>
70   <label class="tab" for="${sid}_open">
71     <span class=no>${session_n}.</span><!--
72  --><span class=date>${tpy[${sid}_date]}</span><!--
73  --><input class="date" name="${sid}_date" value="${tpy[${sid}_date]}" placeholder="$(l10n date)"><!--
74  --><span class=therapist>${tpy[${sid}_therapist]}</span><!--
75  --><input class="therapist" name="${sid}_therapist" value="${tpy[${sid}_therapist]}" placeholder="$(l10n therapist)"><!--
76  --><span class=signature><input type="checkbox" name="${sid}_sigset" value="pos" $sigcheck></span>
77   </label>
78   <div class=tab>
79     <img class="dotmark ov" src="/therapies/${id%.tpy}_${sid}.png" alt="">
80     $( for n in {1..50}; do t_session_note $session_n $n; done )
81
82     <button class=delete type=submit name=delete_session value=${session_n}>$(l10n delete_session)</button>
83   </div>
84 EOF
85 }
86
87 therapy_sessions(){
88   n=1; while [ -n "${tpy[session${n}]}" ]; do
89     t_session $n
90     n=$(($n+1))
91   done
92
93   sid=session$n
94
95 cat <<EOF
96   <fieldset class="tab">
97     <button class=no type=submit name=new_session value=$sid>+</button><!--
98  --><input class=date name=${sid}_date value="" placeholder="$(l10n date)" /><!--
99  --><input class=therapist name=${sid}_therapist value="" placeholder="$(l10n therapist)" /><!--
100  --><span class=signature><span></span>
101     <input type=hidden name="${sid}_note1" value="">
102   </fieldset>
103 EOF
104 }
105
106 unset c0 c1 c2 c3 c4 c5 c6 c7
107 case "$tpy[color]" in
108   \#00A) c1="checked";;
109   \#0A0) c2="checked";;
110   \#0AA) c3="checked";;
111   \#A00) c4="checked";;
112   \#A0A) c5="checked";;
113   \#AA0) c6="checked";;
114   \#FFF) c7="checked";;
115       *) c0="checked";;
116 esac
117
118 cat <<EOF
119 <h1>$(l10n therapy)</h1>
120
121 <div class="patient">
122   <h2>$client_name</h2>
123   <a href="?p=prescriptions&amp;client=${id%%.*}.vcf">&lt; $(l10n prescriptionlist)</a>
124 </div>
125
126 <div class="prescription">
127   <h2>$(l10n therapy_prescription)</h2>
128   <span class="insurance">${mpx[insurance]}</span>
129   <span class="date"><label>$(l10n date):</label>${mpx[date]}</span>
130
131   <label class="checkbox ${mpx[prescreviewed]:+checked}" for="prescreviewed">
132     $([ -n "${mpx[prescreviewed]}" ] && printf %s "$(l10n prescreviewed)" \
133                                      || printf %s "$(l10n prescreview)" )
134   </label>
135
136        ${mpx[prescno]:+<span class="prescno">$(l10n presc${mpx[prescno]})</span>}
137   ${mpx[grouptherapy]:+<span class="catalogue">$(l10n grouptherapy)</span>}
138      ${mpx[housecall]:+<span class="catalogue">$(l10n housecall)</span>}
139         ${mpx[report]:+<span class="catalogue">$(l10n report)</span>}
140
141   <ul>$(for n in '' {0..10}; do
142     [ -n "${mpx[remidy$n]}" ] && \
143     printf '<li>%s %s %s</li>' "${mpx[quantity$n]}" \
144                                "${mpx[remidy$n]}" \
145                                "${mpx[quantity_weekly$n]:+($mpx[quantity_weekly$n] $(l10n weekly))}"
146   done)</ul>
147
148   ${mpx[indicator]:+<span class="indicator"><label>$(l10n indicator):</label>${mpx[indicator]}</span>}
149       ${mpx[icd10]:+<span class="icd10">    <label>$(l10n icd10):</label>${mpx[icd10]}</span>}
150
151   ${mpx[addcontrib]:+
152   <label class='checkbox ${mpx[contribconfirm]:+checked}' for="addcontrib">
153     $([ -n "${mpx[contribconfirm]}" ] && printf %s "$(l10n contribconfirm)" ${mpx[contribconfirm]} \
154                                       || printf %s "$(l10n addcontrib)" )
155   </label>
156   }
157 </div>
158
159 <form method="POST" action="?action=update_therapy">
160   <input type="hidden" name="id" value="${id}">
161
162   <input class="stickynote" type="checkbox" name="c_stickynote" id="show_stickynote">
163   <fieldset class="stickynote">
164     <label for="show_stickynote">$(l10n notes)</label>
165     <textarea name="stickynote">${tpy[stickynote]}</textarea>
166     <button type=submit>$(l10n save)</button>
167   </fieldset>
168
169   <label class="tab heading">
170     <span class=no>$(l10n number)</span><!--
171  --><span class=date>$(l10n date)</span><!--
172  --><span class=therapist>$(l10n therapist)</span><!--
173  --><span class=signature>$(l10n signature)</span>
174   </label>
175 EOF
176
177 therapy_sessions
178
179 cat <<EOF
180   <fieldset class=color>
181     <input class=color type=radio name=color onclick="javascript:setcol('#000')" value="#000" id=c000 $c0><label for=c000></label>
182     <input class=color type=radio name=color onclick="javascript:setcol('#00A')" value="#00A" id=c001 $c1><label for=c001></label>
183     <input class=color type=radio name=color onclick="javascript:setcol('#0A0')" value="#0A0" id=c010 $c2><label for=c010></label>
184     <input class=color type=radio name=color onclick="javascript:setcol('#0AA')" value="#0AA" id=c011 $c3><label for=c011></label>
185     <input class=color type=radio name=color onclick="javascript:setcol('#A00')" value="#A00" id=c100 $c4><label for=c100></label>
186     <input class=color type=radio name=color onclick="javascript:setcol('#A0A')" value="#A0A" id=c101 $c5><label for=c101></label>
187     <input class=color type=radio name=color onclick="javascript:setcol('#AA0')" value="#AA0" id=c110 $c6><label for=c110></label>
188     <input class=color type=radio name=color onclick="javascript:setcol('#FFF')" value="#FFF" id=c111 $c7><label for=c111></label>
189   </fieldset>
190   <img class="dotmark bg" src="?static=therapy_background.png" alt="WARNING: Background Image not available!">
191   <canvas id="canvas" class="dotmark ov" width="${bg_dim%x*}" height="${bg_dim#*x}"></canvas>
192
193   <input type=hidden id=image_serialize name=imagedata value="">
194   <span id="jsdebug" style="display: none; position: fixed; right:0; bottom:0">Debug</span>
195
196   <button type="submit">$(l10n save)</button>
197 </form>
198
199 <script><!--
200 body = document.body
201 canvas = document.getElementById("canvas")
202 dbg = document.getElementById("jsdebug")
203 image = canvas.getContext("2d")
204 mouse = 0
205 image_serialize=""
206 data=document.getElementById("image_serialize")
207
208 function setcol(c) {
209   image.strokeStyle = c
210   if ( c == "#FFF" ) image.lineWidth = 32
211   else image.lineWidth = 4
212   image_serialize += " stroke " + c + " stroke-width " + image.lineWidth
213 }
214
215 setcol("$tpy[color]")
216
217 function draw(x, y) {
218   if ( mouse == 1){
219     if ( body.clientWidth >= 800 ){
220       sx=Math.floor(cscaleW * (x - canvas.offsetLeft))
221       sy=Math.floor(cscaleH * (y - canvas.offsetTop))
222     } else { 
223       sx=Math.floor(cscaleW * (x - canvas.offsetLeft + window.pageXOffset))
224       sy=Math.floor(cscaleH * (y - canvas.offsetTop + window.pageYOffset))
225     }
226     image.lineTo( sx, sy )
227     image.stroke()
228
229     image_serialize += " " + sx + "," + sy
230   }
231 }
232
233 function drawstart(x, y) {
234   mouse = 1
235
236   cscaleW = canvas.width / canvas.clientWidth
237   cscaleH = canvas.height / canvas.clientHeight
238
239   image_serialize += " polyline"
240   image.beginPath()
241   draw(x, y)
242 }
243 function drawstop() {
244  mouse = 0
245  image.closePath()
246  //dbg.innerHTML = image_serialize
247  data.value = image_serialize
248 }
249
250 window.addEventListener( 'mouseup',   function()   { drawstop() } )
251 canvas.addEventListener( 'mousedown', function(e)  { drawstart(e.clientX, e.clientY) } )
252 canvas.addEventListener( 'mousemove', function(e)  {      draw(e.clientX, e.clientY) } )
253
254 window.addEventListener( 'touchend',   function()  { drawstop() } )
255 canvas.addEventListener( 'touchstart', function(e) { drawstart(e.touches[0].clientX, e.touches[0].clientY) } )
256 canvas.addEventListener( 'touchmove',  function(e) { e.preventDefault(); draw(e.touches[0].clientX, e.touches[0].clientY) } )
257 --></script>
258 EOF
259 # vi:set filetype=html: