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()); } }