public function getAll() { try { $pData = new DateTime($this->getData()); $sql = "SELECT id, cc, total\n FROM hor_aprop\n WHERE cod_prof_funcao = " . $this->getCodProfFuncao() . " AND data = '" . $pData->format("Y-m-d") . "';"; $rs = parent::obterRecordSet($sql); $vAprop = array(); foreach ($rs as $row) { $oAprop = new Apropriacao(); $oAprop->setId($row["id"]); $oAprop->setCc($row["cc"]); $oAprop->setCodProfFuncao($this->getCodProfFuncao()); $oAprop->setData($pData->format("d-m-Y")); $oAprop->setValor($row["total"]); $vAprop[] = $oAprop; unset($oAprop); } return $vAprop; } catch (Exception $e) { throw new Exception($e->getMessage()); } }
public function delete() { try { if (isset($_GET["_token"]) && is_numeric($_GET["_token"])) { $oProf = Sessao::getObject("oProf"); $oAprop = new Apropriacao(); $oAprop->setId($_GET["_token"]); $oAprop->getById(); // só pode excluir apropriação do próprio usuario if ($oAprop) { if ($oAprop->getCodProfFuncao() == $oProf->getCodProfFuncao()) { $oAprop->delete(); } else { $this->view->setValue("MSG", "Erro não foi possivel excluir"); } } else { $this->view->setValue("MSG", "Erro não foi possivel excluir"); } } else { $this->view->setValue("MSG", "Erro não foi possivel excluir"); } $this->show(); } catch (Exception $e) { $this->view->setValue("MSG", $e->getMessage()); } }