Skip to content
This repository was archived by the owner on Apr 26, 2021. It is now read-only.

Commit d730db0

Browse files
committed
Atualização referente à tarefa #4
1 parent eb52043 commit d730db0

File tree

10 files changed

+163
-86
lines changed

10 files changed

+163
-86
lines changed

Diff for: agana/agana/modules/assistance/controllers/ActivityController.php

+69-12
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,67 @@ protected function _isUserAllowed($resource, $privilege) {
2626

2727
public function createAction() {
2828

29-
parent::createAction();
29+
//parent::createAction();
30+
31+
32+
try {
33+
34+
if ($this->_isUserAllowed(null, null)) {
35+
36+
$f = $this->getFormCRUName();
37+
$form = new $f($f::ACTION_ADD);
38+
39+
$request = $this->getRequest();
40+
41+
if ($request->isPost()) {
42+
43+
$data = $request->getPost();
44+
45+
$form->populate($data);
46+
if ($form->save->isChecked()) {
47+
if ($form->isValid($data)) {
48+
try {
49+
50+
// var_dump($form->getValues());
51+
// die();
52+
foreach ($data['task_type_id'] as $tarefa) {
53+
$dadosInsercao = array();
54+
foreach ($form->getValues() as $key => $value) {
55+
if ($key == 'task_type_id') {
56+
$dadosInsercao[$key] = $tarefa;
57+
} else {
58+
$dadosInsercao[$key] = $value;
59+
}
60+
}
61+
62+
$id = $this->_createRecord($dadosInsercao);
63+
64+
$urlRedirect = $this->getUrlRedirectionCreateSuccess();
65+
66+
if ($this->_useIdCreatedOnUrl && $id) {
67+
$urlRedirect['id'] = $id;
68+
}
69+
}
70+
71+
$this->_formSuccess($urlRedirect);
72+
} catch (Exception $e) {
73+
$this->_addSavingExceptionMessage($e);
74+
}
75+
} else {
76+
$this->_addFormValidationMessage();
77+
}
78+
} else {
79+
if ($form->cancel->isChecked()) {
80+
$urlRedirect = $this->getUrlRedirectionCreateCancel();
81+
$this->_formCancel($urlRedirect);
82+
}
83+
}
84+
}
85+
$this->view->form = $form;
86+
}
87+
} catch (Exception $e) {
88+
$this->_addExceptionMessage($e);
89+
}
3090

3191
// preenche os campos com os dados da pessoa de usuário que
3292
// está usando o sistema
@@ -40,6 +100,7 @@ public function createAction() {
40100
$this->view->person_helped = new Persons_Model_Person();
41101

42102
if ($this->getRequest()->isPost()) {
103+
43104
$phId = $this->getRequest()->getParam('person_helped_id', 0);
44105
if ($phId > 0) {
45106
$person = $personDomain->getById($phId);
@@ -90,21 +151,17 @@ public function listByPersonHelpedAction() {
90151
}
91152

92153
public function reportByProjectAction() {
93-
$meta = new Agana_Print_Meta('Atendimentos por projeto', 'Sistema Comercial',
94-
'ONG ONLINE', 'http://www.ongonline.com.br');
154+
$meta = new Agana_Print_Meta('Atendimentos por projeto', 'Sistema Comercial', 'ONG ONLINE', 'http://www.ongonline.com.br');
155+
156+
$renderViews['form'] = 'report-by-project-form';
157+
$renderViews['report'] = 'report-by-project-report';
158+
$renderViews['summarized'] = 'report-by-project-report-summarized';
95159

96-
$renderViews['form'] = 'report-by-project-form';
97-
$renderViews['report'] = 'report-by-project-report';
98-
$renderViews['summarized'] = 'report-by-project-report-summarized';
99-
100160
// Zend_Debug::dump($this->getRequest());
101161
// die();
102-
162+
103163
$report = new Agana_Print_Report();
104-
return $report->handleRequest('Assistance_Domain_Activity', 'getActivitiesByProject',
105-
'Assistance_Form_ActivityReportByProject',
106-
$renderViews,
107-
'activity', $meta, $this);
164+
return $report->handleRequest('Assistance_Domain_Activity', 'getActivitiesByProject', 'Assistance_Form_ActivityReportByProject', $renderViews, 'activity', $meta, $this);
108165
}
109166

110167
}

Diff for: agana/agana/modules/assistance/controllers/EventController.php

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ public function createActivityAction() {
6969

7070
if ($request->isPost()) {
7171
$data = $request->getPost();
72+
73+
var_dump($request);
74+
die();
75+
7276
$form->populate($data);
7377
if ($form->save->isChecked()) {
7478
if ($form->isValid($data)) {

Diff for: agana/agana/modules/assistance/domain/Event.php

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public function populate($data) {
6363
}
6464

6565
public function create() {
66+
67+
Zend_Debug::dump("É assahdiu?");
68+
die();
69+
6670
if ($this->_isAllowed()) {
6771
try {
6872
$u = new Assistance_Persist_Dao_Event();

Diff for: agana/agana/modules/assistance/forms/Activity.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,20 @@ private function _addProjectId() {
9898
}
9999

100100
private function _addTaskId() {
101-
$this->addElement('select', 'task_type_id', array(
101+
102+
$this->addElement('MultiCheckbox', 'task_type_id', array(
102103
'required' => true,
103104
'label' => 'Tipo de tarefa',
104-
'dimension' => 6,
105+
'dimension' => 6
105106
));
106107

107108
$el = $this->getElement('task_type_id');
108109

109110
$taskDomain = new Project_Domain_Tasktype();
110111
$task = $taskDomain->getAllChildrenTask();
112+
111113

112-
$el->addMultiOption(null, null);
114+
// $el->addMultiOption(null, null);
113115
foreach ($task as $tsk) {
114116
$tskName = '';
115117
if (trim($tsk->getParent_id()) != '') {

Diff for: agana/agana/modules/assistance/persist/dao/Activity.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ class Assistance_Persist_Dao_Activity extends Agana_Persist_Dao_Abstract impleme
3939
protected function _prepareInsertData($data) {
4040
$dataPrepared = $this->_prepareUpdateData($data);
4141

42+
4243
$dataPrepared['appaccount_id'] = $data->getAppaccount_id();
43-
44+
4445
return $dataPrepared;
4546
}
4647

@@ -51,6 +52,7 @@ protected function _prepareInsertData($data) {
5152
* @return Array
5253
*/
5354
protected function _prepareUpdateData($data) {
55+
5456
$data = array(
5557
'assistance_time' => $data->getAssistance_time(),
5658
'assistance_date' => Agana_Util_DateTime::dateToYYMMDD($data->getAssistance_date()),
@@ -64,9 +66,9 @@ protected function _prepareUpdateData($data) {
6466
'id_by_finger_key' => $data->getId_by_finger_key(),
6567
//'birthdate' => ($data->getBirthdate()) ? Agana_Util_DateTime::dateToYYMMDD($data->getBirthdate()) : null,
6668
);
67-
69+
6870
unset($data['appaccount_id']);
69-
71+
7072
return $data;
7173
}
7274

@@ -86,16 +88,14 @@ protected function _prepareReturnData($data, $returnArray = true) {
8688
public function getAllByPersonHelped($id, $appaccount_id, $orderby) {
8789
$db = $this->getDefaultAdapter();
8890

89-
$sql = $db->select()
91+
$sql = $db->select()
9092
->from(array('at' => 'atividade_assistencia'))
91-
92-
->join(array('ph'=>'person'),
93-
'at.person_helped_id = ph.id')
93+
->join(array('ph' => 'person'), 'at.person_helped_id = ph.id')
9494
->order($orderby);
9595

9696
$sql->where('person_helped_id = ?', $id);
9797
$sql->where('ph.appaccount_id = ?', $appaccount_id);
98-
98+
9999
$db->setFetchMode(Zend_DB::FETCH_ASSOC);
100100

101101
$r = $db->fetchAll($sql);
@@ -115,13 +115,13 @@ public function getActivitiesByProject($appaccount_id, $params = null) {
115115
$db = $this->getDefaultAdapter();
116116

117117
$sql = $db->select()
118-
->from(array('proj' => 'project'), array('project_id' => 'id','project_name' => 'name',
118+
->from(array('proj' => 'project'), array('project_id' => 'id', 'project_name' => 'name',
119119
'project_status' => 'status'))
120120
->join(array('act' => 'atividade_assistencia'), 'act.project_id = proj.id', array('assistance_id' => 'id', 'assistance_date', 'assistance_time', 'id_by_finger_key'))
121121
->join(array('task' => 'task_type'), 'act.task_type_id = task.id', array('task_id' => 'id', 'task_name' => 'name'))
122122
->join(array('p' => 'person'), 'act.person_helped_id = p.id', array('person_id' => 'id', 'person_name' => 'name'))
123123
->joinLeft(array('task_parent' => 'task_type'), 'task.parent_id = task_parent.id', array('task_parent_id' => 'id', 'task_parent_name' => 'name'))
124-
->order(array('proj.name', 'task_parent.name', 'task.name', 'act.assistance_date','p.name'));
124+
->order(array('proj.name', 'task_parent.name', 'task.name', 'act.assistance_date', 'p.name'));
125125

126126
$sql->where('proj.appaccount_id = ?', $appaccount_id);
127127

@@ -162,4 +162,4 @@ public function getActivitiesByProject($appaccount_id, $params = null) {
162162
return $r;
163163
}
164164

165-
}
165+
}

Diff for: agana/agana/modules/assistance/persist/dao/Event.php

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ protected function _prepareInsertData($data) {
5151
* @return Array
5252
*/
5353
protected function _prepareUpdateData($data) {
54+
5455
$data = array(
5556
'event_date' => Agana_Util_DateTime::dateToYYMMDD($data->getEvent_date()),
5657
'task_type_id' => $data->getTask_type_id(),

Diff for: agana/agana/modules/assistance/views/scripts/activity/create.phtml

+13-11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ $title = 'Atendimento de assistência';
33
$this->title = $title . ' - ' . $this->translate("Add new");
44
$this->headTitle($title);
55
$this->form->setAction($this->url());
6+
67
$form = $this->form;
78

89
$urlSearchForm = $this->url(array(
@@ -22,6 +23,8 @@ $urlPersonDetails = $this->url(array(
2223
<div class="window-header">
2324
<h3><i class="icon-food"></i> <?php echo $this->title; ?></h3>
2425
</div>
26+
27+
2528
<form id="person"
2629
class=" form-horizontal well"
2730
action="<?= $this->form->getAction() ?>"
@@ -134,7 +137,7 @@ $urlPersonDetails = $this->url(array(
134137
<span class="span4">
135138
<?= $form->getElement('assistance_date')->render() ?>
136139
</span>
137-
<span class="span4 ">
140+
<span class="span4">
138141
<?= $form->getElement('assistance_time')->render() ?>
139142
</span>
140143
</div>
@@ -162,21 +165,20 @@ $urlPersonDetails = $this->url(array(
162165
</div>
163166

164167
<script>
165-
<?php
166-
$urlImgPersonHelped = $this->url(array(
167-
'module' => 'persons',
168-
'controller' => 'person',
169-
'action' => 'image-url'
170-
), null, true);
171-
172-
?>
173-
$('#windowCreateActivityAssistance').on('atualizarImagemAssistido', null, function(ev) {
168+
<?php
169+
$urlImgPersonHelped = $this->url(array(
170+
'module' => 'persons',
171+
'controller' => 'person',
172+
'action' => 'image-url'
173+
), null, true);
174+
?>
175+
$('#windowCreateActivityAssistance').on('atualizarImagemAssistido', null, function (ev) {
174176
console.log('Chamou atualizar imagem');
175177
var urlImgSrc = '<?= $urlImgPersonHelped ?>/id/' + $('#person_helped_id').val();
176178
console.log('img src = ' + urlImgSrc);
177179
$.ajax({
178180
url: urlImgSrc
179-
}).done(function(imgUrl) {
181+
}).done(function (imgUrl) {
180182
console.log(imgUrl);
181183
$('#imgPersonHelped').attr({src: imgUrl});
182184
});

0 commit comments

Comments
 (0)