public function andamento($projeto_id) { $porcentagem = 0; $trabalhados = 0; $horas_projeto = 0; $horas_trabalhadas = 0; // dados do projeto $modelProjeto = new Model_DbTable_Projeto(); $projeto = $modelProjeto->getById($projeto_id); $horas_projeto = $projeto->projeto_horas; $modelControleHoras = new Model_DbTable_ControleHoras(); $horas = $modelControleHoras->fetchAll("projeto_id = {$projeto_id}"); foreach ($horas as $hora) { $zendDateInicio = new Zend_Date($hora->controle_horas_data_inicio); $zendDateFim = new Zend_Date($hora->controle_horas_data_fim); $trabalhados += $zendDateFim->sub($zendDateInicio)->get(Zend_Date::TIMESTAMP); } // converte horas trabalhadas para horas $horas_trabalhadas = $trabalhados / 3600; if ($horas_trabalhadas < 1) { return 0; } if ($horas_projeto == 0) { return 100; } $porcentagem = number_format($horas_trabalhadas * 100 / $horas_projeto, 2, '.', ''); return $porcentagem; }
/** * */ public function pauseAction() { $this->_helper->viewRenderer->setNoRender(); $projeto_id = $this->getRequest()->getParam("projeto_id"); // dados do projeto $modelProjeto = new Model_DbTable_Projeto(); $projeto = $modelProjeto->getById($projeto_id); //Zend_Debug::dump($projeto); die(); try { $this->setPlayPause($projeto_id, self::STATUS_PAUSADO, $projeto->projeto_controle_horas); $this->_helper->flashMessenger->addMessage(array('success' => "Projeto pausado")); } catch (Exception $ex) { $this->_helper->flashMessenger->addMessage(array('danger' => $ex->getMessage())); } $this->_redirect("controle-horas/"); }
public function cadastroAction() { $this->_helper->viewRenderer->setNoRender(); $formTarefaCadastro = new Form_Site_TarefaCadastro(); $formTarefaCadastro->submit->setLabel("CADASTRAR"); if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost(); if ($formTarefaCadastro->isValid($data)) { $data = $formTarefaCadastro->getValues(); // bsucar o cliente do projeto $modelProjeto = new Model_DbTable_Projeto(); $projeto = $modelProjeto->getById($data['projeto_id']); $data['cliente_id'] = $projeto->cliente_id; try { $modelTarefa = new Model_DbTable_Tarefa(); $modelTarefa->insert($data); $this->_redirect("tarefa/"); } catch (Exception $ex) { echo $ex->getMessage(); } } } }