1: <?php
2: 3: 4: 5:
6:
7: use Nette\Forms\Form,
8: Nette\Diagnostics\Debugger;
9:
10: 11: 12: 13: 14:
15: class PacientPresenter extends BasePresenter {
16:
17: 18: 19: 20: 21: 22:
23: public function renderView($id) {
24: if (is_null($id)) $this->redirect ('Pacient:');
25:
26: $this->template->id = $id;
27: $pacient = $this->getService('model')->getPacient($id);
28: $born_date = DateTime::createFromFormat('ymd',substr($pacient->id, 0, 6));
29: $pacient->vek = $born_date->diff(new DateTime)->format('%Y');
30: $pacient->born_date = $born_date;
31:
32: $this->template->pacient = $pacient;
33: $navstevy = $pacient->related('navsteva')->order('datum');
34: $this->template->navstevy = $navstevy;
35:
36: $info = array();
37:
38: foreach ($navstevy as $navsteva){
39: foreach ($navsteva->related('zdrav_info') as $data){
40: foreach ($data as $key => $value){
41: if((!is_null($value))and($key!='navsteva_id')and($key!='id')){
42: switch ($key) {
43: case "tehotenstvi":
44: $info[$key][$navsteva->id]['datum'] = $navsteva->datum;
45: $info[$key][$navsteva->id]['value'] = $value ? 'ano' : 'ne';
46: break;
47: case "tlak_s":
48: if ((isset($data->tlak_s))and(isset($data->tlak_d))){
49: $info['tlak'][$navsteva->id]['datum'] = $navsteva->datum;
50: $info['tlak'][$navsteva->id]['value'] = $data->tlak_s.'/'.$data->tlak_d;
51: }
52: break;
53: case "tlak_d":
54: break;
55: default:
56: $info[$key][$navsteva->id]['datum'] = $navsteva->datum;
57: $info[$key][$navsteva->id]['value'] = $value;
58: }
59:
60: }
61: }
62: }
63:
64: $this->template->info = $info;
65: }
66: }
67:
68: 69: 70: 71: 72:
73: public function actionDeletePacient($id) {
74: $this->getService('model')->getPacient($id)->delete();
75: $this->flashMessage('Pacient byl smazán');
76: $this->redirect('Pacient:default');
77: }
78:
79: 80: 81: 82: 83:
84: public function actionAutocompletePacient($term) {
85: $this->template->list = $this->getService('model')->getPacientByTerm($term);
86: }
87:
88: 89: 90: 91: 92:
93: public function actionSearchPacient($term) {
94: $this->template->list = $this->getService('model')->getPacientByTerm($term);
95: }
96: }