function guardarHorario(EntityHorarios $horario) { $criteria = new Criteria(BD_SIGA); if (!$horario->hrs_ID) { $horario_aux = new EntityHorarios(); $horario_aux->FK_personal_pers_ID = $horario->FK_personal_pers_ID; $horario_aux->hrs_anio = $horario->hrs_anio; $criteria->find($horario_aux); if ($horario_aux->hrs_ID) { throw new HorarioException(HorarioException::ERROR_HORARIO_DUPLICADIO_MSG, HorarioException::ERROR_HORARIO_DUPLICADIO_COD); } $criteria->persist($horario); $horario->hrs_ID = $criteria->getInsertID(); } else { $criteria->merge($horario); } return $horario; }