Пример #1
0
 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;
 }
Пример #2
0
 public function init()
 {
     /**
      * projeto_id
      */
     $modelProjeto = new Model_DbTable_Projeto();
     $projeto_id = new Zend_Form_Element_Select("projeto_id");
     $projeto_id->setLabel("Projeto: ");
     $projeto_id->setAttribs(array('class' => 'form-control'));
     $projeto_id->setMultiOptions($modelProjeto->fetchPairs());
     $this->addElement($projeto_id);
     /**
      * tarefa_nome
      */
     $tarefa_nome = new Zend_Form_Element_Text("tarefa_nome");
     $tarefa_nome->setLabel("Título: ");
     $tarefa_nome->setAttribs(array('class' => 'form-control'));
     $tarefa_nome->setRequired();
     $this->addElement($tarefa_nome);
     /**
      * tarefa_descricao
      */
     $tarefa_descricao = new Zend_Form_Element_Textarea("tarefa_descricao");
     $tarefa_descricao->setLabel("Descrição: ");
     $tarefa_descricao->setAttribs(array('class' => 'form-control', 'rows' => 10));
     $tarefa_descricao->setRequired();
     $this->addElement($tarefa_descricao);
     parent::init();
 }
 public function indexAction()
 {
     /**
      * Total de clientes
      */
     $modelClientes = new Model_DbTable_Cliente();
     $this->view->clientes = $modelClientes->fetchAll();
     /**
      * Total de propostas
      */
     $modelProposta = new Model_DbTable_Proposta();
     $propostas = $modelProposta->fetchAll();
     $this->view->propostas = $propostas;
     $total_horas_propostas = 0;
     $total_valor_propostas = 0;
     foreach ($propostas as $proposta) {
         $total_horas_propostas += $proposta->proposta_horas;
         $total_valor_propostas += $proposta->proposta_valor;
     }
     $this->view->total_horas_proposta = $total_horas_propostas;
     $this->view->total_valor_proposta = $total_valor_propostas;
     /**
      * Total de Projetos
      */
     $modelProjeto = new Model_DbTable_Projeto();
     $projetos = $modelProjeto->fetchAll();
     $this->view->projetos = $projetos;
     /**
      * Total Faturamento
      */
     $modelFaturamento = new Model_DbTable_Faturamento();
     $faturamentos = $modelFaturamento->fetchAll();
     $faturamento_total = 0;
     $receber = 0;
     $recebido = 0;
     foreach ($faturamentos as $faturamento) {
         if ($faturamento->faturamento_status === self::STATUS_AGUARDANDO_PAGAMENTO) {
             $receber += $faturamento->faturamento_valor;
         }
         if ($faturamento->faturamento_status === self::STATUS_PAGO) {
             $recebido += $faturamento->faturamento_valor;
         }
         $faturamento_total += $faturamento->faturamento_valor;
     }
     $this->view->faturamento_total = $faturamento_total;
     $this->view->receber = $receber;
     $this->view->recebido = $recebido;
     /**
      * Total de Horas Trbalhadas
      */
     $modelControleHoras = new Model_DbTable_ControleHoras();
     $horas = $modelControleHoras->fetchAll();
     $horas_trabalhadas = 0;
     foreach ($horas as $hora) {
         $zendDateInicio = new Zend_Date($hora->controle_horas_data_inicio);
         $zendDateFim = new Zend_Date($hora->controle_horas_data_fim);
         $horas_trabalhadas += $zendDateFim->sub($zendDateInicio)->get(Zend_Date::TIMESTAMP);
     }
     $this->view->horas = ceil($horas_trabalhadas / 3600);
 }
 private function getProjetos()
 {
     $options = array("" => "Sem projeto");
     $modelProjeto = new Model_DbTable_Projeto();
     $projetos = $modelProjeto->fetchAll();
     foreach ($projetos as $projeto) {
         $options[$projeto->projeto_id] = $projeto->projeto_nome;
     }
     return $options;
 }
 private function setPlayPause($projeto_id, $status, $projeto_controle_horas = null)
 {
     $modelProjeto = new Model_DbTable_Projeto();
     //Zend_Debug::dump($projeto_controle_horas); die();
     try {
         Zend_Db_Table_Abstract::getDefaultAdapter()->beginTransaction();
         // controle de horas
         $modelControleHoras = new Model_DbTable_ControleHoras();
         if ($status === self::STATUS_TRABALHANDO) {
             $controle_data = array("projeto_id" => $projeto_id, "controle_horas_data_inicio" => date("Y-m-d H:i:s"));
             $controle_horas_id = $modelControleHoras->insert($controle_data);
         } elseif (self::STATUS_PAUSADO) {
             if (!$projeto_controle_horas) {
                 throw new Exception("Controle Horas ID não encontrado!");
             }
             $controle_data = array("controle_horas_data_fim" => date("Y-m-d H:i:s"));
             $controle_horas_id = $modelControleHoras->updateById($controle_data, $projeto_controle_horas);
         }
         $update = array("projeto_status" => $status, "projeto_controle_horas" => $controle_horas_id);
         $modelProjeto->updateById($update, $projeto_id);
         Zend_Db_Table_Abstract::getDefaultAdapter()->commit();
         return true;
     } catch (Exception $ex) {
         Zend_Db_Table_Abstract::getDefaultAdapter()->rollBack();
         throw new Exception($ex->getMessage());
     }
 }
Пример #6
0
 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();
             }
         }
     }
 }
Пример #7
0
 public function cadastroAction()
 {
     /**
      * Form cadastro
      */
     $formProjetoCadastro = new Form_Site_ProjetoCadastro();
     $formProjetoCadastro->submit->setLabel("CADASTRAR");
     $this->view->formProjetoCadastro = $formProjetoCadastro;
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         if ($formProjetoCadastro->isValid($data)) {
             $formProjetoCadastro->removeElement("cliente");
             $data = $formProjetoCadastro->getValues();
             try {
                 $modelProjeto = new Model_DbTable_Projeto();
                 $modelProjeto->insert($data);
                 $this->_helper->flashMessenger->addMessage(array('success' => 'Projeto cadastrado com sucesso!'));
             } catch (Exception $ex) {
                 $this->_helper->flashMessenger->addMessage(array('danger' => $ex->getMessage()));
             }
             $this->_redirect("projeto/");
         }
     }
 }
Пример #8
0
 /**
  * Detalhes do cadastro e acoes para os registros
  */
 public function detalhesAction()
 {
     $cliente_id = $this->getRequest()->getParam("cliente");
     /**
      * Busca os dados do cliente
      */
     $modelCliente = new Model_DbTable_Cliente();
     $cliente = $modelCliente->getById($cliente_id);
     $this->view->cliente = $cliente;
     $where = "cliente_id = {$cliente_id}";
     /**
      * Busca quantidade de propostas
      */
     $modelProposta = new Model_DbTable_Proposta();
     $propostas = $modelProposta->fetchAll($where);
     $this->view->propostas = $propostas;
     /**
      * Busca quantidade de projetos
      */
     $modelProjeto = new Model_DbTable_Projeto();
     $projetos = $modelProjeto->fetchAll($where);
     $this->view->projetos = $projetos;
     /**
      * Faturamentos
      */
     $modelFaturamento = new Model_DbTable_Faturamento();
     $faturamento = $modelFaturamento->getTotalFaturadoCliente($cliente_id);
     $this->view->total_faturado = $faturamento->total_faturado ? $faturamento->total_faturado : 0;
     /**
      * Total de Horas
      */
     $modelControleHoras = new Model_DbTable_ControleHoras();
 }