Debian Codegraph @

src/hics/hics206.cxx

raw
1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2014
3 // David Freese, W1HKJ
4 //
5 // This file is part of flmsg
6 //
7 // flrig is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // flrig is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 // ----------------------------------------------------------------------------
20
21 #include <stdlib.h>
22 #include <iostream>
23 #include <fstream>
24 #include <cstring>
25 #include <ctime>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <stdio.h>
29 #include <errno.h>
30
31 #include <FL/Fl.H>
32 #include <FL/Enumerations.H>
33 #include <FL/Fl_Window.H>
34 #include <FL/Fl_Button.H>
35 #include <FL/Fl_Group.H>
36 #include <FL/Fl_Sys_Menu_Bar.H>
37 #include <FL/x.H>
38 #include <FL/Fl_Help_Dialog.H>
39 #include <FL/Fl_Menu_Item.H>
40 #include <FL/Fl_File_Icon.H>
41
42 #include "config.h"
43 #include "flmsg_config.h"
44
45 #include "flmsg.h"
46 #include "templates.h"
47 #include "debug.h"
48 #include "util.h"
49 #include "gettext.h"
50 #include "flmsg_dialog.h"
51 #include "flinput2.h"
52 #include "date.h"
53 #include "calendar.h"
54 #include "icons.h"
55 #include "fileselect.h"
56 #include "wrap.h"
57 #include "status.h"
58 #include "parse_xml.h"
59
60 #ifdef WIN32
61 # include "flmsgrc.h"
62 # include "compat.h"
63 # define dirent fl_dirent_no_thanks
64 #endif
65
66 #include <FL/filename.H>
67 #include "dirent-check.h"
68
69 #include <FL/x.H>
70 #include <FL/Fl_Pixmap.H>
71 #include <FL/Fl_Image.H>
72
73 // hics206 tag fields
74 std::string h206_tag_name = ":1:";
75 std::string h206_tag_date_prepared = ":2:";
76 std::string h206_tag_time_prepared = ":3:";
77 std::string h206_tag_period = ":4:";
78
79 std::string h206_tag_location = ":5:";
80 std::string h206_tag_loc_contact = ":6:";
81 std::string h206_tag_team_leader = ":7:";
82 std::string h206_tag_team_contact = ":8:";
83 std::string h206_tag_special_instructions = ":9:";
84
85 std::string h206_tag_md_do = ":10:";
86 std::string h206_tag_litters = ":11:";
87 std::string h206_tag_pa_np = ":14:";
88 std::string h206_tag_portable = ":15:";
89 std::string h206_tag_rn_lpn = ":18:";
90 std::string h206_tag_transport = ":19:";
91 std::string h206_tag_tech_cn = ":22:";
92 std::string h206_tag_wheelchairs = ":23:";
93 std::string h206_tag_team_other = ":26:";
94 std::string h206_tag_transport_other = ":27:";
95
96 std::string h206_tag_meds_1 = ":12:";
97 std::string h206_tag_meds_2 = ":16:";
98 std::string h206_tag_meds_3 = ":20:";
99 std::string h206_tag_meds_4 = ":24:";
100 std::string h206_tag_meds_5 = ":28:";
101 std::string h206_tag_supp_1 = ":13:";
102 std::string h206_tag_supp_2 = ":17:";
103 std::string h206_tag_supp_3 = ":21:";
104 std::string h206_tag_supp_4 = ":25:";
105 std::string h206_tag_supp_5 = ":29:";
106
107 std::string h206_tag_site_1 = ":30:";
108 std::string h206_tag_address_1 = ":31:";
109 std::string h206_tag_phone_1 = ":32:";
110 std::string h206_tag_spec_care_1 = ":33:";
111
112 std::string h206_tag_site_2 = ":34:";
113 std::string h206_tag_address_2 = ":35:";
114 std::string h206_tag_phone_2 = ":36:";
115 std::string h206_tag_spec_care_2 = ":37:";
116
117 std::string h206_tag_site_3 = ":38:";
118 std::string h206_tag_address_3 = ":39:";
119 std::string h206_tag_phone_3 = ":40:";
120 std::string h206_tag_spec_care_3 = ":41:";
121
122 std::string h206_tag_site_4 = ":42:";
123 std::string h206_tag_address_4 = ":43:";
124 std::string h206_tag_phone_4 = ":44:";
125 std::string h206_tag_spec_care_4 = ":45:";
126
127 std::string h206_tag_preparer = ":46:";
128 std::string h206_tag_facility = ":47:";
129
130 std::string h206_name;
131 std::string h206_period;
132 std::string h206_date_prepared;
133 std::string h206_time_prepared;
134
135 std::string h206_location;
136 std::string h206_loc_contact;
137 std::string h206_team_leader;
138 std::string h206_team_contact;
139 std::string h206_special_instructions;
140
141 std::string h206_md_do;
142 std::string h206_litters;
143 std::string h206_pa_np;
144 std::string h206_portable;
145 std::string h206_rn_lpn;
146 std::string h206_transport;
147 std::string h206_tech_cn;
148 std::string h206_wheelchairs;
149 std::string h206_team_other;
150 std::string h206_transport_other;
151
152 std::string h206_meds_1;
153 std::string h206_meds_2;
154 std::string h206_meds_3;
155 std::string h206_meds_4;
156 std::string h206_meds_5;
157 std::string h206_supp_1;
158 std::string h206_supp_2;
159 std::string h206_supp_3;
160 std::string h206_supp_4;
161 std::string h206_supp_5;
162
163 std::string h206_site_1;
164 std::string h206_address_1;
165 std::string h206_phone_1;
166 std::string h206_spec_care_1;
167 std::string h206_site_2;
168 std::string h206_address_2;
169 std::string h206_phone_2;
170 std::string h206_spec_care_2;
171 std::string h206_site_3;
172 std::string h206_address_3;
173 std::string h206_phone_3;
174 std::string h206_spec_care_3;
175 std::string h206_site_4;
176 std::string h206_address_4;
177 std::string h206_phone_4;
178 std::string h206_spec_care_4;
179
180 std::string h206_preparer;
181 std::string h206_facility;
182
183 std::string h206_buff;
184 std::string h206_def_filename = "";
185 std::string h206_base_filename = "";
186 std::string h206_def_template_name = "";
187 bool h206_using206_template = false;
188
189 void h206_cb_setdate()
190 {
191 h206_txt_date_prepared->value(szDate(progStatus.dtformat));
192 }
193
194 void h206_cb_settime()
195 {
196 h206_txt_time_prepared->value(szTime(progStatus.UTC));
197 }
198
199 void h206_clear_fields()
200 {
201 h206_name.clear();
202 h206_period.clear();
203 h206_date_prepared.clear();
204 h206_time_prepared.clear();
205
206 h206_location.clear();
207 h206_loc_contact.clear();
208 h206_team_leader.clear();
209 h206_team_contact.clear();
210
211 h206_md_do.clear();
212 h206_litters.clear();
213 h206_pa_np.clear();
214 h206_portable.clear();
215 h206_rn_lpn.clear();
216 h206_transport.clear();
217 h206_tech_cn.clear();
218 h206_wheelchairs.clear();
219 h206_team_other.clear();
220 h206_transport_other.clear();
221 h206_meds_1.clear();
222 h206_supp_1.clear();
223 h206_meds_2.clear();
224 h206_supp_2.clear();
225 h206_meds_3.clear();
226 h206_supp_3.clear();
227 h206_meds_4.clear();
228 h206_supp_4.clear();
229 h206_meds_5.clear();
230 h206_supp_5.clear();
231
232 h206_special_instructions.clear();
233 h206_preparer.clear();
234 h206_facility.clear();
235
236 h206_site_1.clear();
237 h206_address_1.clear();
238 h206_phone_1.clear();
239 h206_spec_care_1.clear();
240 h206_site_2.clear();
241 h206_address_2.clear();
242 h206_phone_2.clear();
243 h206_spec_care_2.clear();
244 h206_site_3.clear();
245 h206_address_3.clear();
246 h206_phone_3.clear();
247 h206_spec_care_3.clear();
248 h206_site_4.clear();
249 h206_address_4.clear();
250 h206_phone_4.clear();
251 h206_spec_care_4.clear();
252
253 }
254
255 bool check_hics206fields()
256 {
257 if (h206_name != h206_txt_name->value())
258 return true;
259 if (h206_period != h206_txt_op_period->value())
260 return true;
261 if (h206_date_prepared != h206_txt_date_prepared->value())
262 return true;
263 if (h206_time_prepared != h206_txt_time_prepared->value())
264 return true;
265
266 if (h206_location != h206_txt_location->value())
267 return true;
268 if (h206_loc_contact != h206_txt_loc_contact->value())
269 return true;
270 if (h206_team_leader != h206_txt_team_leader->value())
271 return true;
272 if (h206_team_contact != h206_txt_team_contact->value())
273 return true;
274 if (h206_md_do != h206_txt_md_do->value())
275 return true;
276 if (h206_litters != h206_txt_litters->value())
277 return true;
278 if (h206_pa_np != h206_txt_pa_np->value())
279 return true;
280 if (h206_portable != h206_txt_portable->value())
281 return true;
282 if (h206_rn_lpn != h206_txt_rn_lpn->value())
283 return true;
284 if (h206_transport != h206_txt_transport->value())
285 return true;
286 if (h206_tech_cn != h206_txt_tech_cn->value())
287 return true;
288 if (h206_wheelchairs != h206_txt_wheelchairs->value())
289 return true;
290 if (h206_team_other != h206_txt_team_other->value())
291 return true;
292 if (h206_transport_other != h206_txt_transport_other->value())
293 return true;
294 if (h206_meds_1 != h206_txt_meds_1->value())
295 return true;
296 if (h206_supp_1 != h206_txt_supp_1->value())
297 return true;
298 if (h206_meds_2 != h206_txt_meds_2->value())
299 return true;
300 if (h206_supp_2 != h206_txt_supp_2->value())
301 return true;
302 if (h206_meds_3 != h206_txt_meds_3->value())
303 return true;
304 if (h206_supp_3 != h206_txt_supp_3->value())
305 return true;
306 if (h206_meds_4 != h206_txt_meds_4->value())
307 return true;
308 if (h206_supp_4 != h206_txt_supp_4->value())
309 return true;
310 if (h206_meds_5 != h206_txt_meds_5->value())
311 return true;
312 if (h206_supp_5 != h206_txt_supp_5->value())
313 return true;
314
315 if (h206_special_instructions != h206_txt_special_instructions->buffer()->text())
316 return true;
317
318 if (h206_preparer != h206_txt_preparer->value())
319 return true;
320 if (h206_facility != h206_txt_facility->value())
321 return true;
322
323 if (h206_site_1 != h206_txt_site_1->value())
324 return true;
325 if (h206_address_1 != h206_txt_address_1->value())
326 return true;
327 if (h206_phone_1 != h206_txt_phone_1->value())
328 return true;
329 if (h206_spec_care_1 != h206_txt_spec_care_1->value())
330 return true;
331 if (h206_site_2 != h206_txt_site_2->value())
332 return true;
333 if (h206_address_2 != h206_txt_address_2->value())
334 return true;
335 if (h206_phone_2 != h206_txt_phone_2->value())
336 return true;
337 if (h206_spec_care_2 != h206_txt_spec_care_2->value())
338 return true;
339 if (h206_site_3 != h206_txt_site_3->value())
340 return true;
341 if (h206_address_3 != h206_txt_address_3->value())
342 return true;
343 if (h206_phone_3 != h206_txt_phone_3->value())
344 return true;
345 if (h206_spec_care_3 != h206_txt_spec_care_3->value())
346 return true;
347 if (h206_site_4 != h206_txt_site_4->value())
348 return true;
349 if (h206_address_4 != h206_txt_address_4->value())
350 return true;
351 if (h206_phone_4 != h206_txt_phone_4->value())
352 return true;
353 if (h206_spec_care_4 != h206_txt_spec_care_4->value())
354 return true;
355
356 return false;
357 }
358
359 void h206_update_fields()
360 {
361 h206_name = h206_txt_name->value();
362 h206_period = h206_txt_op_period->value();
363 h206_date_prepared = h206_txt_date_prepared->value();
364 h206_time_prepared = h206_txt_time_prepared->value();
365
366 h206_location = h206_txt_location->value();
367 h206_loc_contact = h206_txt_loc_contact->value();
368 h206_team_leader = h206_txt_team_leader->value();
369 h206_team_contact = h206_txt_team_contact->value();
370 h206_md_do = h206_txt_md_do->value();
371 h206_litters = h206_txt_litters->value();
372 h206_pa_np = h206_txt_pa_np->value();
373 h206_portable = h206_txt_portable->value();
374 h206_rn_lpn = h206_txt_rn_lpn->value();
375 h206_transport = h206_txt_transport->value();
376 h206_tech_cn = h206_txt_tech_cn->value();
377 h206_wheelchairs = h206_txt_wheelchairs->value();
378 h206_team_other = h206_txt_team_other->value();
379 h206_transport_other = h206_txt_transport_other->value();
380 h206_meds_1 = h206_txt_meds_1->value();
381 h206_supp_1 = h206_txt_supp_1->value();
382 h206_meds_2 = h206_txt_meds_2->value();
383 h206_supp_2 = h206_txt_supp_2->value();
384 h206_meds_3 = h206_txt_meds_3->value();
385 h206_supp_3 = h206_txt_supp_3->value();
386 h206_meds_4 = h206_txt_meds_4->value();
387 h206_supp_4 = h206_txt_supp_4->value();
388 h206_meds_5 = h206_txt_meds_5->value();
389 h206_supp_5 = h206_txt_supp_5->value();
390
391 h206_special_instructions = h206_txt_special_instructions->buffer()->text();
392
393 h206_preparer = h206_txt_preparer->value();
394 h206_facility = h206_txt_facility->value();
395
396 h206_site_1 = h206_txt_site_1->value();
397 h206_address_1 = h206_txt_address_1->value();
398 h206_phone_1 = h206_txt_phone_1->value();
399 h206_spec_care_1 = h206_txt_spec_care_1->value();
400 h206_site_2 = h206_txt_site_2->value();
401 h206_address_2 = h206_txt_address_2->value();
402 h206_phone_2 = h206_txt_phone_2->value();
403 h206_spec_care_2 = h206_txt_spec_care_2->value();
404 h206_site_3 = h206_txt_site_3->value();
405 h206_address_3 = h206_txt_address_3->value();
406 h206_phone_3 = h206_txt_phone_3->value();
407 h206_spec_care_3 = h206_txt_spec_care_3->value();
408 h206_site_4 = h206_txt_site_4->value();
409 h206_address_4 = h206_txt_address_4->value();
410 h206_phone_4 = h206_txt_phone_4->value();
411 h206_spec_care_4 = h206_txt_spec_care_4->value();
412 }
413
414 void h206_update_form()
415 {
416 h206_txt_name->value(h206_name.c_str());
417 h206_txt_op_period->value(h206_period.c_str());
418 h206_txt_date_prepared->value(h206_date_prepared.c_str());
419 h206_txt_time_prepared->value(h206_time_prepared.c_str());
420
421 h206_txt_location->value(h206_location.c_str());
422 h206_txt_loc_contact->value(h206_loc_contact.c_str());
423 h206_txt_team_leader->value(h206_team_leader.c_str());
424 h206_txt_team_contact->value(h206_team_contact.c_str());
425
426 h206_txt_md_do->value(h206_md_do.c_str());
427 h206_txt_litters->value(h206_litters.c_str());
428 h206_txt_pa_np->value(h206_pa_np.c_str());
429 h206_txt_portable->value(h206_portable.c_str());
430 h206_txt_rn_lpn->value(h206_rn_lpn.c_str());
431 h206_txt_transport->value(h206_transport.c_str());
432 h206_txt_tech_cn->value(h206_tech_cn.c_str());
433 h206_txt_wheelchairs->value(h206_wheelchairs.c_str());
434 h206_txt_team_other->value(h206_team_other.c_str());
435 h206_txt_transport_other->value(h206_transport_other.c_str());
436 h206_txt_meds_1->value(h206_meds_1.c_str());
437 h206_txt_supp_1->value(h206_supp_1.c_str());
438 h206_txt_meds_2->value(h206_meds_2.c_str());
439 h206_txt_supp_2->value(h206_supp_2.c_str());
440 h206_txt_meds_3->value(h206_meds_3.c_str());
441 h206_txt_supp_3->value(h206_supp_3.c_str());
442 h206_txt_meds_4->value(h206_meds_4.c_str());
443 h206_txt_supp_4->value(h206_supp_4.c_str());
444 h206_txt_meds_5->value(h206_meds_5.c_str());
445 h206_txt_supp_5->value(h206_supp_5.c_str());
446
447 h206_txt_special_instructions->addstr(h206_special_instructions.c_str());
448
449 h206_txt_preparer->value(h206_preparer.c_str());
450 h206_txt_facility->value(h206_facility.c_str());
451
452 h206_txt_site_1->value(h206_site_1.c_str());
453 h206_txt_address_1->value(h206_address_1.c_str());
454 h206_txt_phone_1->value(h206_phone_1.c_str());
455 h206_txt_spec_care_1->value(h206_spec_care_1.c_str());
456 h206_txt_site_2->value(h206_site_2.c_str());
457 h206_txt_address_2->value(h206_address_2.c_str());
458 h206_txt_phone_2->value(h206_phone_2.c_str());
459 h206_txt_spec_care_2->value(h206_spec_care_2.c_str());
460 h206_txt_site_3->value(h206_site_3.c_str());
461 h206_txt_address_3->value(h206_address_3.c_str());
462 h206_txt_phone_3->value(h206_phone_3.c_str());
463 h206_txt_spec_care_3->value(h206_spec_care_3.c_str());
464 h206_txt_site_4->value(h206_site_4.c_str());
465 h206_txt_address_4->value(h206_address_4.c_str());
466 h206_txt_phone_4->value(h206_phone_4.c_str());
467 h206_txt_spec_care_4->value(h206_spec_care_4.c_str());
468
469 }
470
471 void h206_clear__form()
472 {
473 h206_clear_fields();
474
475 h206_txt_name->value("");
476 h206_txt_op_period->value("");
477 h206_txt_date_prepared->value("");
478 h206_txt_time_prepared->value("");
479
480 h206_txt_location->value("");
481 h206_txt_loc_contact->value("");
482 h206_txt_team_leader->value("");
483 h206_txt_team_contact->value("");
484
485 h206_txt_md_do->value("");
486 h206_txt_litters->value("");
487 h206_txt_pa_np->value("");
488 h206_txt_portable->value("");
489 h206_txt_rn_lpn->value("");
490 h206_txt_transport->value("");
491 h206_txt_tech_cn->value("");
492 h206_txt_wheelchairs->value("");
493 h206_txt_team_other->value("");
494 h206_txt_transport_other->value("");
495 h206_txt_meds_1->value("");
496 h206_txt_supp_1->value("");
497 h206_txt_meds_2->value("");
498 h206_txt_supp_2->value("");
499 h206_txt_meds_3->value("");
500 h206_txt_supp_3->value("");
501 h206_txt_meds_4->value("");
502 h206_txt_supp_4->value("");
503 h206_txt_meds_5->value("");
504 h206_txt_supp_5->value("");
505
506 h206_txt_special_instructions->clear();
507
508 h206_txt_preparer->value("");
509 h206_txt_facility->value("");
510
511 h206_txt_site_1->value("");
512 h206_txt_address_1->value("");
513 h206_txt_phone_1->value("");
514 h206_txt_spec_care_1->value("");
515 h206_txt_site_2->value("");
516 h206_txt_address_2->value("");
517 h206_txt_phone_2->value("");
518 h206_txt_spec_care_2->value("");
519 h206_txt_site_3->value("");
520 h206_txt_address_3->value("");
521 h206_txt_phone_3->value("");
522 h206_txt_spec_care_3->value("");
523 h206_txt_site_4->value("");
524 h206_txt_address_4->value("");
525 h206_txt_phone_4->value("");
526 h206_txt_spec_care_4->value("");
527
528 }
529
530 void h206_make_buff(bool compress = false)
531 {
532 std::string mbuff;
533 mbuff.assign( lineout( h206_tag_name, h206_name ) );
534 mbuff.append( lineout( h206_tag_period, h206_period ) );
535 mbuff.append( lineout( h206_tag_date_prepared, h206_date_prepared ) );
536 mbuff.append( lineout( h206_tag_time_prepared, h206_time_prepared ) );
537
538 mbuff.append( lineout( h206_tag_location, h206_location));
539 mbuff.append( lineout( h206_tag_loc_contact, h206_loc_contact));
540 mbuff.append( lineout( h206_tag_team_leader, h206_team_leader));
541 mbuff.append( lineout( h206_tag_team_contact, h206_team_contact));
542
543 mbuff.append( lineout( h206_tag_md_do, h206_md_do));
544 mbuff.append( lineout( h206_tag_litters, h206_litters));
545 mbuff.append( lineout( h206_tag_pa_np, h206_pa_np));
546 mbuff.append( lineout( h206_tag_portable, h206_portable));
547 mbuff.append( lineout( h206_tag_rn_lpn, h206_rn_lpn));
548 mbuff.append( lineout( h206_tag_transport, h206_transport));
549 mbuff.append( lineout( h206_tag_tech_cn, h206_tech_cn));
550 mbuff.append( lineout( h206_tag_wheelchairs, h206_wheelchairs));
551 mbuff.append( lineout( h206_tag_team_other, h206_team_other));
552 mbuff.append( lineout( h206_tag_transport_other, h206_transport_other));
553 mbuff.append( lineout( h206_tag_meds_1, h206_meds_1));
554 mbuff.append( lineout( h206_tag_supp_1, h206_supp_1));
555 mbuff.append( lineout( h206_tag_meds_2, h206_meds_2));
556 mbuff.append( lineout( h206_tag_supp_2, h206_supp_2));
557 mbuff.append( lineout( h206_tag_meds_3, h206_meds_3));
558 mbuff.append( lineout( h206_tag_supp_3, h206_supp_3));
559 mbuff.append( lineout( h206_tag_meds_4, h206_meds_4));
560 mbuff.append( lineout( h206_tag_supp_4, h206_supp_4));
561 mbuff.append( lineout( h206_tag_meds_5, h206_meds_5));
562 mbuff.append( lineout( h206_tag_supp_5, h206_supp_5));
563
564 mbuff.append( lineout( h206_tag_special_instructions, h206_special_instructions ) );
565
566 mbuff.append( lineout( h206_tag_preparer, h206_preparer ) );
567 mbuff.append( lineout( h206_tag_facility, h206_facility ) );
568
569 mbuff.append( lineout( h206_tag_site_1, h206_site_1 ) );
570 mbuff.append( lineout( h206_tag_address_1, h206_address_1 ) );
571 mbuff.append( lineout( h206_tag_phone_1, h206_phone_1 ) );
572 mbuff.append( lineout( h206_tag_spec_care_1, h206_spec_care_1 ) );
573 mbuff.append( lineout( h206_tag_site_2, h206_site_2 ) );
574 mbuff.append( lineout( h206_tag_address_2, h206_address_2 ) );
575 mbuff.append( lineout( h206_tag_phone_2, h206_phone_2 ) );
576 mbuff.append( lineout( h206_tag_spec_care_2, h206_spec_care_2 ) );
577 mbuff.append( lineout( h206_tag_site_3, h206_site_3 ) );
578 mbuff.append( lineout( h206_tag_address_3, h206_address_3 ) );
579 mbuff.append( lineout( h206_tag_phone_3, h206_phone_3 ) );
580 mbuff.append( lineout( h206_tag_spec_care_3, h206_spec_care_3 ) );
581 mbuff.append( lineout( h206_tag_site_4, h206_site_4 ) );
582 mbuff.append( lineout( h206_tag_address_4, h206_address_4 ) );
583 mbuff.append( lineout( h206_tag_phone_4, h206_phone_4 ) );
584 mbuff.append( lineout( h206_tag_spec_care_4, h206_spec_care_4 ) );
585
586 if (compress) compress_maybe(mbuff);
587 h206_buff.append(mbuff);
588 }
589
590 void h206_read_buffer(std::string data)
591 {
592 h206_clear_fields();
593 read_header(data);
594
595 h206_name = findstr(data, h206_tag_name);
596 h206_period = findstr(data, h206_tag_period);
597 h206_date_prepared = findstr(data, h206_tag_date_prepared);
598 h206_time_prepared = findstr(data, h206_tag_time_prepared);
599
600 h206_location = findstr(data, h206_tag_location);
601 h206_loc_contact = findstr(data, h206_tag_loc_contact);
602 h206_team_leader = findstr(data, h206_tag_team_leader);
603 h206_team_contact = findstr(data, h206_tag_team_contact);
604
605 h206_md_do = findstr(data, h206_tag_md_do);
606 h206_litters = findstr(data, h206_tag_litters);
607 h206_pa_np = findstr(data, h206_tag_pa_np);
608 h206_portable = findstr(data, h206_tag_portable);
609 h206_rn_lpn = findstr(data, h206_tag_rn_lpn);
610 h206_transport = findstr(data, h206_tag_transport);
611 h206_tech_cn = findstr(data, h206_tag_tech_cn);
612 h206_wheelchairs = findstr(data, h206_tag_wheelchairs);
613 h206_team_other = findstr(data, h206_tag_team_other);
614 h206_transport_other = findstr(data, h206_tag_transport_other);
615 h206_meds_1 = findstr(data, h206_tag_meds_1);
616 h206_supp_1 = findstr(data, h206_tag_supp_1);
617 h206_meds_2 = findstr(data, h206_tag_meds_2);
618 h206_supp_2 = findstr(data, h206_tag_supp_2);
619 h206_meds_3 = findstr(data, h206_tag_meds_3);
620 h206_supp_3 = findstr(data, h206_tag_supp_3);
621 h206_meds_4 = findstr(data, h206_tag_meds_4);
622 h206_supp_4 = findstr(data, h206_tag_supp_4);
623 h206_meds_5 = findstr(data, h206_tag_meds_5);
624 h206_supp_5 = findstr(data, h206_tag_supp_5);
625
626 h206_special_instructions = findstr(data, h206_tag_special_instructions);
627
628 h206_preparer = findstr(data, h206_tag_preparer);
629 h206_facility = findstr(data, h206_tag_facility);
630
631 h206_site_1 = findstr(data, h206_tag_site_1);
632 h206_address_1 = findstr(data, h206_tag_address_1);
633 h206_phone_1 = findstr(data, h206_tag_phone_1);
634 h206_spec_care_1 = findstr(data, h206_tag_spec_care_1);
635 h206_site_2 = findstr(data, h206_tag_site_2);
636 h206_address_2 = findstr(data, h206_tag_address_2);
637 h206_phone_2 = findstr(data, h206_tag_phone_2);
638 h206_spec_care_2 = findstr(data, h206_tag_spec_care_2);
639 h206_site_3 = findstr(data, h206_tag_site_3);
640 h206_address_3 = findstr(data, h206_tag_address_3);
641 h206_phone_3 = findstr(data, h206_tag_phone_3);
642 h206_spec_care_3 = findstr(data, h206_tag_spec_care_4);
643 h206_site_4 = findstr(data, h206_tag_site_4);
644 h206_address_4 = findstr(data, h206_tag_address_4);
645 h206_phone_4 = findstr(data, h206_tag_phone_4);
646 h206_spec_care_4 = findstr(data, h206_tag_spec_care_4);
647
648 h206_update_form();
649 }
650
651 void h206_cb_new()
652 {
653 if (check_hics206fields()) {
654 if (fl_choice2("Form modified, save?", "No", "Yes", NULL) == 1) {
655 update_header(CHANGED);
656 h206_cb_save();
657 }
658 }
659 h206_clear__form();
660 clear_header();
661 h206_def_filename = ICS_msg_dir;
662 h206_def_filename.append("new").append(HF206_EXT);
663 show_filename(h206_def_filename);
664 h206_using206_template = false;
665 }
666
667 void h206_cb_import()
668 {
669 fl_alert2("Not implemented");
670 }
671
672 void h206_cb_export()
673 {
674 fl_alert2("Not implemented");
675 }
676
677 void h206_cb_wrap_import(std::string wrapfilename, std::string inpbuffer)
678 {
679 h206_clear__form();
680 h206_read_buffer(inpbuffer);
681 h206_def_filename = ICS_msg_dir;
682 h206_def_filename.append(wrapfilename);
683 show_filename(h206_def_filename);
684 h206_using206_template = false;
685 }
686
687 int eval_h206_fsize()
688 {
689 Ccrc16 chksum;
690 evalstr.assign("[WRAP:beg][WRAP:lf][WRAP:fn ");
691 evalstr.append(h206_base_filename).append("]");
692 h206_update_fields();
693 update_header(FROM);
694 evalstr.append(header("<hics206>"));
695 h206_buff.clear();
696 h206_make_buff(true);
697 if (h206_buff.empty()) return 0;
698 compress_maybe( h206_buff );
699 evalstr.append( h206_buff );
700 evalstr.append("[WRAP:chksum ").append(chksum.scrc16(evalstr)).append("][WRAP:end]");
701 return evalstr.length();
702 }
703
704 void h206_cb_wrap_export()
705 {
706 if (check_hics206fields()) {
707 if (fl_choice2("Form modified, save?", "No", "Yes", NULL) == 0)
708 return;
709 update_header(CHANGED);
710 }
711 h206_update_fields();
712
713 if (h206_base_filename == std::string("new").append(HF206_EXT) ||
714 h206_base_filename == std::string("default").append(HF206_EXT) )
715 if (!h206_cb_save_as()) return;
716
717 std::string wrapfilename = WRAP_send_dir;
718 wrapfilename.append(h206_base_filename);
719 wrapfilename.append(".wrap");
720 const char *p = FSEL::saveas(
721 "Save as wrap file",
722 "Wrap file\t*.{wrap,WRAP}",
723 wrapfilename.c_str());
724 if (p) {
725 std::string pext = fl_filename_ext(p);
726 wrapfilename = p;
727 update_header(FROM);
728 h206_buff.assign(header("<hics206>"));
729 h206_make_buff(true);
730 export_wrapfile(h206_base_filename, wrapfilename, h206_buff, pext != ".wrap");
731
732 h206_buff.assign(header("<hics206>"));
733 h206_make_buff(false);
734 h206_write(h206_def_filename);
735 }
736 }
737
738 void h206_cb_wrap_autosend()
739 {
740 if (check_hics206fields()) {
741 if (fl_choice2("Form modified, save?", "No", "Yes", NULL) == 0)
742 return;
743 update_header(CHANGED);
744 }
745 h206_update_fields();
746
747 if (h206_base_filename == std::string("new").append(HF206_EXT) ||
748 h206_base_filename == std::string("default").append(HF206_EXT) )
749 if (!h206_cb_save_as()) return;
750
751 update_header(FROM);
752 h206_buff.assign(header("<hics206>"));
753 h206_make_buff(true);
754 xfr_via_socket(h206_base_filename, h206_buff);
755
756 h206_buff.assign(header("<hics206>"));
757 h206_make_buff(false);
758 h206_write(h206_def_filename);
759 }
760
761 void h206_cb_load_template()
762 {
763 std::string h206_def_filename = h206_def_template_name;
764 const char *p = FSEL::select(
765 "Open template file",
766 std::string("Template file\t*").append(HT206_EXT).c_str(),
767 h206_def_filename.c_str());
768 if (p) {
769 h206_clear__form();
770 read_data_file(p);
771 h206_def_template_name = p;
772 show_filename(h206_def_template_name);
773 h206_using206_template = true;
774 }
775 }
776
777 void h206_cb_save_template()
778 {
779 if (!h206_using206_template) {
780 h206_cb_save_as_template();
781 return;
782 }
783 std::string h206_def_filename = h206_def_template_name;
784 const char *p = FSEL::saveas(
785 "Save template file",
786 std::string("Template file\t*").append(HT206_EXT).c_str(),
787 h206_def_filename.c_str());
788 if (p) {
789 update_header(CHANGED);
790 h206_update_fields();
791 h206_buff.assign(header("<hics206>"));
792 h206_make_buff();
793 h206_write(p);
794 }
795 }
796
797 void h206_cb_save_as_template()
798 {
799 std::string h206_def_filename = h206_def_template_name;
800 const char *p = FSEL::saveas(
801 "Save as template file",
802 std::string("Template file\t*").append(HT206_EXT).c_str(),
803 h206_def_filename.c_str());
804 if (p) {
805 const char *pext = fl_filename_ext(p);
806 h206_def_template_name = p;
807 if (strlen(pext) == 0) h206_def_template_name.append(HT206_EXT);
808 remove_spaces_from_filename(h206_def_template_name);
809 clear_header();
810 update_header(CHANGED);
811 h206_update_fields();
812 h206_buff.assign(header("<hics206>"));
813 h206_make_buff();
814 h206_write(h206_def_template_name);
815 show_filename(h206_def_template_name);
816 h206_using206_template = true;
817 }
818 }
819
820 void h206_cb_open()
821 {
822 const char *p = FSEL::select(
823 _("Open data file"),
824 std::string("HICS-206\t*").append(HF206_EXT).c_str(),
825 h206_def_filename.c_str());
826 if (!p) return;
827 if (strlen(p) == 0) return;
828 h206_clear__form();
829 read_data_file(p);
830 h206_using206_template = false;
831 h206_def_filename = p;
832 show_filename(h206_def_filename);
833 }
834
835 void h206_write(std::string s)
836 {
837 FILE *file206 = fopen(s.c_str(), "w");
838 if (!file206) return;
839
840 fwrite(h206_buff.c_str(), h206_buff.length(), 1, file206);
841 fclose(file206);
842 }
843
844 bool h206_cb_save_as()
845 {
846 const char *p;
847 std::string newfilename;
848
849 std::string name = named_file();
850 if (!name.empty()) {
851 name.append(HF206_EXT);
852 newfilename = ICS_msg_dir;
853 newfilename.append(name);
854 } else
855 newfilename = h206_def_filename;
856
857 p = FSEL::saveas(
858 _("Save data file"),
859 std::string("HICS-206\t*").append(HF206_EXT).c_str(),
860 newfilename.c_str());
861
862 if (!p) return false;
863 if (strlen(p) == 0) return false;
864
865 if (progStatus.sernbr_fname) update_sernbr();
866
867 const char *pext = fl_filename_ext(p);
868 h206_def_filename = p;
869 if (strlen(pext) == 0) h206_def_filename.append(HF206_EXT);
870
871 remove_spaces_from_filename(h206_def_filename);
872 h206_update_fields();
873 update_header(NEW);
874 h206_buff.assign(header("<hics206>"));
875 h206_write(h206_def_filename);
876
877 h206_using206_template = false;
878 show_filename(h206_def_filename);
879 return true;
880 }
881
882 void h206_cb_save()
883 {
884 if (h206_base_filename == std::string("new").append(HF206_EXT) ||
885 h206_base_filename == std::string("default").append(HF206_EXT) ||
886 h206_using206_template == true) {
887 h206_cb_save_as();
888 return;
889 }
890 if (check_hics206fields()) update_header(CHANGED);
891 h206_buff.assign(header("<hics206>"));
892 h206_make_buff();
893 h206_write(h206_def_filename);
894 h206_using206_template = false;
895 }
896
897 void h206_cb_html()
898 {
899 std::string fname_name = fl_filename_name(h206_def_filename.c_str());
900 size_t p = fname_name.rfind('.');
901 if (p != std::string::npos) fname_name.erase(p);
902
903 std::string hics206_fname = ICS_dir;
904 hics206_fname.append(fname_name);
905 hics206_fname.append(".html");
906
907 std::string html_text = "";
908
909 h206_update_fields();
910 std::string form206 = hics206_html_template;
911
912 replacestr(form206, TITLE, fname_name);
913 replacestr(form206, h206_tag_name, h206_name);
914 replacestr(form206, h206_tag_date_prepared, h206_date_prepared);
915 replacestr(form206, h206_tag_time_prepared, h206_time_prepared);
916 replacestr(form206, h206_tag_period, h206_period);
917
918 replacestr(form206, h206_tag_location, h206_location);
919 replacestr(form206, h206_tag_loc_contact, h206_loc_contact);
920 replacestr(form206, h206_tag_team_leader, h206_team_leader);
921 replacestr(form206, h206_tag_team_contact, h206_team_contact);
922
923 replacestr(form206, h206_tag_md_do, h206_md_do);
924 replacestr(form206, h206_tag_litters, h206_litters);
925 replacestr(form206, h206_tag_pa_np, h206_pa_np);
926 replacestr(form206, h206_tag_portable, h206_portable);
927 replacestr(form206, h206_tag_rn_lpn, h206_rn_lpn);
928 replacestr(form206, h206_tag_transport, h206_transport);
929 replacestr(form206, h206_tag_tech_cn, h206_tech_cn);
930 replacestr(form206, h206_tag_wheelchairs, h206_wheelchairs);
931 replacestr(form206, h206_tag_team_other, h206_team_other);
932 replacestr(form206, h206_tag_transport_other, h206_transport_other);
933 replacestr(form206, h206_tag_meds_1, h206_meds_1);
934 replacestr(form206, h206_tag_supp_1, h206_supp_1);
935 replacestr(form206, h206_tag_meds_2, h206_meds_2);
936 replacestr(form206, h206_tag_supp_2, h206_supp_2);
937 replacestr(form206, h206_tag_meds_3, h206_meds_3);
938 replacestr(form206, h206_tag_supp_3, h206_supp_3);
939 replacestr(form206, h206_tag_meds_4, h206_meds_4);
940 replacestr(form206, h206_tag_supp_4, h206_supp_4);
941 replacestr(form206, h206_tag_meds_5, h206_meds_5);
942 replacestr(form206, h206_tag_supp_5, h206_supp_5);
943 std::string temp = h206_special_instructions;
944 if (progStatus.autowordwrap)
945 temp = wordwrap(h206_special_instructions, progStatus.charcount);
946 replacestr(form206, h206_tag_special_instructions, temp);
947 replacestr(form206, h206_tag_site_1, h206_site_1);
948 replacestr(form206, h206_tag_address_1, h206_address_1);
949 replacestr(form206, h206_tag_phone_1, h206_phone_1);
950 replacestr(form206, h206_tag_spec_care_1, h206_spec_care_1);
951 replacestr(form206, h206_tag_site_2, h206_site_2);
952 replacestr(form206, h206_tag_address_2, h206_address_2);
953 replacestr(form206, h206_tag_phone_2, h206_phone_2);
954 replacestr(form206, h206_tag_spec_care_2, h206_spec_care_2);
955 replacestr(form206, h206_tag_site_3, h206_site_3);
956 replacestr(form206, h206_tag_address_3, h206_address_3);
957 replacestr(form206, h206_tag_phone_3, h206_phone_3);
958 replacestr(form206, h206_tag_spec_care_3, h206_spec_care_3);
959 replacestr(form206, h206_tag_site_4, h206_site_4);
960 replacestr(form206, h206_tag_address_4, h206_address_4);
961 replacestr(form206, h206_tag_phone_4, h206_phone_4);
962 replacestr(form206, h206_tag_spec_care_4, h206_spec_care_4);
963
964 replacestr(form206, h206_tag_preparer, h206_preparer);
965 replacestr(form206, h206_tag_facility, h206_facility);
966
967 FILE *file206 = fopen(hics206_fname.c_str(), "w");
968 fprintf(file206,"%s", form206.c_str());
969 fclose(file206);
970
971 open_url(hics206_fname.c_str());
972 }
973
974 void h206_cb_textout()
975 {
976 std::string hics206_fname = ICS_dir;
977 hics206_fname.append("hics206.txt");
978
979 h206_update_fields();
980 std::string form206 = hics206_text_template;
981
982 replacestr(form206, h206_tag_name, h206_name);
983 replacestr(form206, h206_tag_period, h206_period);
984 replacestr(form206, h206_tag_date_prepared, h206_date_prepared);
985 replacestr(form206, h206_tag_time_prepared, h206_time_prepared);
986
987 replacestr(form206, h206_tag_location, h206_location);
988 replacestr(form206, h206_tag_loc_contact, h206_loc_contact);
989 replacestr(form206, h206_tag_team_leader, h206_team_leader);
990 replacestr(form206, h206_tag_team_contact, h206_team_contact);
991
992 replacestr(form206, h206_tag_md_do, h206_md_do);
993 replacestr(form206, h206_tag_litters, h206_litters);
994 replacestr(form206, h206_tag_pa_np, h206_pa_np);
995 replacestr(form206, h206_tag_portable, h206_portable);
996 replacestr(form206, h206_tag_rn_lpn, h206_rn_lpn);
997 replacestr(form206, h206_tag_transport, h206_transport);
998 replacestr(form206, h206_tag_tech_cn, h206_tech_cn);
999 replacestr(form206, h206_tag_wheelchairs, h206_wheelchairs);
1000 replacestr(form206, h206_tag_team_other, h206_team_other);
1001 replacestr(form206, h206_tag_transport_other, h206_transport_other);
1002 replacestr(form206, h206_tag_meds_1, h206_meds_1);
1003 replacestr(form206, h206_tag_supp_1, h206_supp_1);
1004 replacestr(form206, h206_tag_meds_2, h206_meds_2);
1005 replacestr(form206, h206_tag_supp_2, h206_supp_2);
1006 replacestr(form206, h206_tag_meds_3, h206_meds_3);
1007 replacestr(form206, h206_tag_supp_3, h206_supp_3);
1008 replacestr(form206, h206_tag_meds_4, h206_meds_4);
1009 replacestr(form206, h206_tag_supp_4, h206_supp_4);
1010 replacestr(form206, h206_tag_meds_5, h206_meds_5);
1011 replacestr(form206, h206_tag_supp_5, h206_supp_5);
1012
1013 replacestr(form206, h206_tag_special_instructions, h206_special_instructions);
1014
1015 replacestr(form206, h206_tag_site_1, h206_site_1);
1016 replacestr(form206, h206_tag_address_1, h206_address_1);
1017 replacestr(form206, h206_tag_phone_1, h206_phone_1);
1018 replacestr(form206, h206_tag_spec_care_1, h206_spec_care_1);
1019 replacestr(form206, h206_tag_site_2, h206_site_2);
1020 replacestr(form206, h206_tag_address_2, h206_address_2);
1021 replacestr(form206, h206_tag_phone_2, h206_phone_2);
1022 replacestr(form206, h206_tag_spec_care_2, h206_spec_care_2);
1023 replacestr(form206, h206_tag_site_3, h206_site_3);
1024 replacestr(form206, h206_tag_address_3, h206_address_3);
1025 replacestr(form206, h206_tag_phone_3, h206_phone_3);
1026 replacestr(form206, h206_tag_spec_care_3, h206_spec_care_3);
1027 replacestr(form206, h206_tag_site_4, h206_site_4);
1028 replacestr(form206, h206_tag_address_4, h206_address_4);
1029 replacestr(form206, h206_tag_phone_4, h206_phone_4);
1030 replacestr(form206, h206_tag_spec_care_4, h206_spec_care_4);
1031
1032 replacestr(form206, h206_tag_preparer, h206_preparer);
1033 replacestr(form206, h206_tag_facility, h206_facility);
1034
1035 FILE *file206 = fopen(hics206_fname.c_str(), "w");
1036 fprintf(file206,"%s", form206.c_str());
1037 fclose(file206);
1038
1039 open_url(hics206_fname.c_str());
1040 }