1 # Copyright 2016 Paul Hänsch
3 # This file is part of Confetti.
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.
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.
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/>.
22 color=session${session_n}_note${note_n}_color
23 unset c0 c1 c2 c3 c4 c5 c6 c7
25 case "$tpy[$color]" in
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">'
39 printf '<input class="trailbtn" type="checkbox">'
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>
59 sid=session${session_n}
61 if [ "$tpy[${sid}_sigset]" = pos ]; then
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>
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 )
82 <button class=delete type=submit name=delete_session value=${session_n}>$(l10n delete_session)</button>
88 n=1; while [ -n "${tpy[session${n}]}" ]; do
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="">
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";;
119 <h1>$(l10n therapy)</h1>
121 <div class="patient">
122 <h2>$client_name</h2>
123 <a href="?p=prescriptions&client=${id%%.*}.vcf">< $(l10n prescriptionlist)</a>
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>
131 <label class="checkbox ${mpx[prescreviewed]:+checked}" for="prescreviewed">
132 $([ -n "${mpx[prescreviewed]}" ] && printf %s "$(l10n prescreviewed)" \
133 || printf %s "$(l10n prescreview)" )
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>}
141 <ul>$(for n in '' {0..10}; do
142 [ -n "${mpx[remidy$n]}" ] && \
143 printf '<li>%s %s %s</li>' "${mpx[quantity$n]}" \
145 "${mpx[quantity_weekly$n]:+($mpx[quantity_weekly$n] $(l10n weekly))}"
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>}
152 <label class='checkbox ${mpx[contribconfirm]:+checked}' for="addcontrib">
153 $([ -n "${mpx[contribconfirm]}" ] && printf %s "$(l10n contribconfirm)" ${mpx[contribconfirm]} \
154 || printf %s "$(l10n addcontrib)" )
159 <form method="POST" action="?action=update_therapy">
160 <input type="hidden" name="id" value="${id}">
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>
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>
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>
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>
193 <input type=hidden id=image_serialize name=imagedata value="">
195 <button type="submit">$(l10n save)</button>
198 <span id="jsdebug" style="display: none; position: fixed; right:0; bottom:0">Debug</span>
202 dbg = document.getElementById("jsdebug")
203 canvas = document.getElementById("canvas")
204 data=document.getElementById("image_serialize")
206 image = canvas.getContext("2d")
210 // start and current coordinates of a draw
211 // serves for tracking, whether path ends close to its beginning
217 image.strokeStyle = c
219 if ( c == "#FFF" ) image.lineWidth = 32
220 else image.lineWidth = 4
221 data.value += " stroke " + c + " stroke-width " + image.lineWidth
224 setcol("$tpy[color]")
227 if ( body.clientWidth >= 800 ){
228 return Math.floor(cscaleW * (x - canvas.offsetLeft))
230 return Math.floor(cscaleW * (x - canvas.offsetLeft + window.pageXOffset))
234 if ( body.clientWidth >= 800 ){
235 return Math.floor(cscaleH * (y - canvas.offsetTop))
237 return Math.floor(cscaleH * (y - canvas.offsetTop + window.pageYOffset))
241 function draw(x, y) {
243 cux=relX(x), cuy=relY(y)
245 image.lineTo( cux, cuy )
248 image_serialize += " " + cux + "," + cuy
252 function drawstart(x, y) {
255 cscaleW = canvas.width / canvas.clientWidth
256 cscaleH = canvas.height / canvas.clientHeight
258 stx=relX(x), sty=relY(y)
261 draw(x, y) // why must this not use relative Coords ???
263 image_serialize = " polyline"
266 function drawstop() {
268 // if path ends close to beginning ( < 50 px); then close path and fill
269 if ( mouse == 1 && Math.sqrt( Math.pow(stx - cux, 2) + Math.pow(sty - cuy, 2)) <= 50 && c !== "#FFF" ){
270 image.lineTo( stx, sty )
273 image.globalAlpha = .5
275 image.globalAlpha = 1
277 image_serialize += " " + stx + "," + sty
278 data.value += " fill " + c + "8" + image_serialize
279 } else if (mouse == 1) {
280 data.value += " fill #0000 " + image_serialize
282 dbg.innerHTML = " stx: " + stx + " cux: " + cux + " sty: " + sty + " cuy: " + cuy
289 window.addEventListener( 'mouseup', function() { drawstop() } )
290 canvas.addEventListener( 'mousedown', function(e) { drawstart(e.clientX, e.clientY) } )
291 canvas.addEventListener( 'mousemove', function(e) { draw(e.clientX, e.clientY) } )
293 window.addEventListener( 'touchend', function() { drawstop() } )
294 canvas.addEventListener( 'touchstart', function(e) { drawstart(e.touches[0].clientX, e.touches[0].clientY) } )
295 canvas.addEventListener( 'touchmove', function(e) { e.preventDefault(); draw(e.touches[0].clientX, e.touches[0].clientY) } )
298 # vi:set filetype=html: