protected function private_core() { /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); $this->cuenta = FALSE; if (isset($_POST['nsubcuenta'])) { $subc0 = new subcuenta(); $subc0->codcuenta = $_POST['codcuenta']; $subc0->codejercicio = $_POST['ejercicio']; $subc0->codsubcuenta = $_POST['nsubcuenta']; $subc0->descripcion = $_POST['descripcion']; $subc0->idcuenta = $_POST['idcuenta']; $subc0->alias = $_POST['alias']; if ($subc0->save()) { header('Location: ' . $subc0->url()); } else { $this->new_error_msg('Error al crear la subcuenta.'); } $this->cuenta = $subc0->get_cuenta(); } else { if (isset($_GET['deletes'])) { $subc0 = new subcuenta(); $subc1 = $subc0->get($_GET['deletes']); if ($subc1) { $this->cuenta = $subc1->get_cuenta(); if ($subc1->delete()) { $this->new_message('Subcuenta eliminada correctamente.'); } else { $this->new_error_msg('Error al eliminar la subcuenta.'); } } else { $this->new_error_msg('Subcuenta no encontrada.'); } } else { if (isset($_GET['id'])) { $cuenta = new cuenta(); $this->cuenta = $cuenta->get($_GET['id']); if ($this->cuenta and isset($_POST['descripcion'])) { $this->cuenta->descripcion = $_POST['descripcion']; if ($_POST['idcuentaesp'] == '---') { $this->cuenta->idcuentaesp = NULL; } else { $this->cuenta->idcuentaesp = $_POST['idcuentaesp']; } if ($this->cuenta->save()) { $this->new_message('Cuenta modificada correctamente.'); } else { $this->new_error_msg('Error al modificar la cuenta.'); } } } } } if ($this->cuenta) { /// configuramos la página previa $this->ppage = $this->page->get('contabilidad_epigrafes'); if ($this->ppage) { $this->ppage->title = 'Rubro: ' . $this->cuenta->codepigrafe; $this->ppage->extra_url = '&epi=' . $this->cuenta->idepigrafe; } $this->page->title = 'Cuenta: ' . $this->cuenta->codcuenta; $this->ejercicio = $this->cuenta->get_ejercicio(); $this->nuevo_codsubcuenta = sprintf('%-0' . $this->ejercicio->longsubcuenta . 's', $this->cuenta->codcuenta); } else { $this->new_error_msg("Cuenta no encontrada."); $this->ppage = $this->page->get('contabilidad_cuentas'); } }
public function get_cuenta() { $cuenta = new \cuenta(); return $cuenta->get($this->idcuenta); }
protected function process() { $this->codejercicio = $this->empresa->codejercicio; $this->ejercicio = new ejercicio(); $grupo0 = new grupo_epigrafes(); $epi0 = new epigrafe(); $this->super_epigrafes = array(); /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); if (isset($_POST['ngrupo'])) { $this->epigrafe = FALSE; $this->grupo = $grupo0->get_by_codigo($_GET['ngrupo'], $_POST['ejercicio']); if (!$this->grupo) { $this->grupo = new grupo_epigrafes(); $this->grupo->codejercicio = $_POST['ejercicio']; $this->grupo->codgrupo = $_POST['ngrupo']; $this->grupo->descripcion = $_POST['descripcion']; if ($this->grupo->save()) { header('Location: ' . $this->grupo->url()); } else { $this->new_error_msg('Error al guardar el grupo.'); $this->grupo = FALSE; } } } else { if (isset($_GET['grupo'])) { $this->epigrafe = FALSE; $this->grupo = $grupo0->get($_GET['grupo']); if ($this->grupo and isset($_POST['descripcion'])) { $this->grupo->descripcion = $_POST['descripcion']; if ($this->grupo->save()) { $this->new_message('Grupo modificado correctamente.'); } else { $this->new_error_msg('Error al modificar el grupo.'); } } } else { if (isset($_GET['deleteg'])) { $grupo1 = $grupo0->get($_GET['deleteg']); if ($grupo1) { if ($grupo1->delete()) { $this->new_message('Grupo eliminado correctamente.'); } else { $this->new_error_msg('Error al eliminar el grupo.'); } } else { $this->new_error_msg('Grupo no encontrado.'); } $this->grupo = FALSE; $this->epigrafe = FALSE; } else { if (isset($_POST['nepigrafe'])) { $this->epigrafe = $epi0->get_by_codigo($_POST['nepigrafe'], $_POST['ejercicio']); if (!$this->epigrafe) { $this->epigrafe = new epigrafe(); $this->epigrafe->codejercicio = $_POST['ejercicio']; $this->epigrafe->codepigrafe = $_POST['nepigrafe']; if (isset($_POST['idpadre'])) { $this->epigrafe->idpadre = $_POST['idpadre']; } else { $this->epigrafe->codgrupo = $_POST['codgrupo']; $this->epigrafe->idgrupo = $_POST['idgrupo']; $this->grupo = $grupo0->get($_POST['idgrupo']); } $this->epigrafe->descripcion = $_POST['descripcion']; if ($this->epigrafe->save()) { header('Location: ' . $this->epigrafe->url()); } else { $this->new_error_msg('Error al guardar el epígrafe.'); } } } else { if (isset($_GET['epi'])) { $this->grupo = FALSE; $this->epigrafe = $epi0->get($_GET['epi']); if ($this->ejercicio and isset($_POST['descripcion'])) { $this->epigrafe->descripcion = $_POST['descripcion']; if ($this->epigrafe->save()) { $this->new_message('Epígrafe modificado correctamente.'); } else { $this->new_error_msg('Error al modificar el epígrafe.'); } } } else { if (isset($_GET['deletee'])) { $epi1 = $epi0->get($_GET['deletee']); if ($epi1) { $this->grupo = $grupo0->get($epi1->idgrupo); if ($epi1->delete()) { $this->new_message('Epígrafe eliminado correctamente.'); } else { $this->new_error_msg('Error al eliminar el epígrafe.'); } } else { $this->new_error_msg('Epígrafe no encontrado.'); $this->grupo = FALSE; } } else { if (isset($_POST['ncuenta'])) { $this->grupo = FALSE; $this->epigrafe = FALSE; $cuenta0 = new cuenta(); $cuenta1 = $cuenta0->get_by_codigo($_POST['ncuenta'], $_POST['ejercicio']); if ($cuenta1) { header('Location: ' . $cuenta1->url()); } else { $cuenta1 = new cuenta(); $cuenta1->codcuenta = $_POST['ncuenta']; $cuenta1->codejercicio = $_POST['ejercicio']; $cuenta1->codepigrafe = $_POST['codepigrafe']; $cuenta1->descripcion = $_POST['descripcion']; $cuenta1->idepigrafe = $_POST['idepigrafe']; if ($cuenta1->save()) { header('Location: ' . $cuenta1->url()); } else { $this->new_error_msg('Error al guardar la cuenta.'); } $this->epigrafe = $epi0->get($_POST['idepigrafe']); } } else { if (isset($_GET['deletec'])) { $this->grupo = FALSE; $this->epigrafe = FALSE; $cuenta0 = new cuenta(); $cuenta1 = $cuenta0->get($_GET['deletec']); if ($cuenta1) { $this->epigrafe = $epi0->get($cuenta1->idepigrafe); if ($cuenta1->delete()) { $this->new_message('Cuenta eliminada correctamente.'); } else { $this->new_error_msg('Error al eliminar la cuenta.'); } } else { $this->new_error_msg('Cuenta no encontrada.'); } } } } } } } } } if ($this->grupo) { $this->ppage = $this->page->get($this->page->name); $this->page->title = 'Grupo: ' . $this->grupo->codgrupo; $this->resultados = $this->grupo->get_epigrafes(); } else { if ($this->epigrafe) { /// configuramos la página previa $this->ppage = $this->page->get($this->page->name); if (!is_null($this->epigrafe->idgrupo)) { $this->ppage->title = 'Grupo: ' . $this->epigrafe->codgrupo; $this->ppage->extra_url = '&grupo=' . $this->epigrafe->idgrupo; } else { if (!is_null($this->epigrafe->idpadre)) { $this->ppage->title = 'Padre'; $this->ppage->extra_url = '&epi=' . $this->epigrafe->idpadre; } } $this->page->title = 'Epigrafe: ' . $this->epigrafe->codepigrafe; $this->resultados = $this->epigrafe->get_cuentas(); } else { if (isset($_POST['ejercicio'])) { $this->codejercicio = $_POST['ejercicio']; $this->grupo = FALSE; $this->epigrafe = FALSE; $this->resultados = $grupo0->all_from_ejercicio($this->codejercicio); $this->super_epigrafes = $epi0->super_from_ejercicio($this->codejercicio); } else { $this->grupo = FALSE; $this->epigrafe = FALSE; $this->resultados = $grupo0->all_from_ejercicio($this->empresa->codejercicio); $this->super_epigrafes = $epi0->super_from_ejercicio($this->empresa->codejercicio); } } } }
protected function process() { $this->cuenta = FALSE; if (isset($_POST['nsubcuenta'])) { $subc0 = new subcuenta(); $subc0->codcuenta = $_POST['codcuenta']; $subc0->codejercicio = $_POST['ejercicio']; $subc0->codsubcuenta = $_POST['nsubcuenta']; $subc0->descripcion = $_POST['descripcion']; $subc0->idcuenta = $_POST['idcuenta']; if ($subc0->save()) { header('Location: ' . $subc0->url()); } else { $this->new_error_msg('Error al crear la subcuenta.'); } $this->cuenta = $subc0->get_cuenta(); } else { if (isset($_GET['deletes'])) { $subc0 = new subcuenta(); $subc1 = $subc0->get($_GET['deletes']); if ($subc1) { $this->cuenta = $subc1->get_cuenta(); if ($subc1->delete()) { $this->new_message('Subcuenta eliminada correctamente.'); } else { $this->new_error_msg('Error al eliminar la subcuenta.'); } } else { $this->new_error_msg('Subcuenta no encontrada.'); } } else { if (isset($_GET['id'])) { $cuenta = new cuenta(); $this->cuenta = $cuenta->get($_GET['id']); if ($this->cuenta and isset($_POST['descripcion'])) { $this->cuenta->descripcion = $_POST['descripcion']; if ($_POST['idcuentaesp'] == '---') { $this->cuenta->idcuentaesp = NULL; } else { $this->cuenta->idcuentaesp = $_POST['idcuentaesp']; } if ($this->cuenta->save()) { $this->new_message('Cuenta modificada correctamente.'); } else { $this->new_error_msg('Error al modificar la cuenta.'); } } } } } if ($this->cuenta) { /// configuramos la página previa $this->ppage = $this->page->get('contabilidad_epigrafes'); if ($this->ppage) { $this->ppage->title = 'Epígrafe: ' . $this->cuenta->codepigrafe; $this->ppage->extra_url = '&epi=' . $this->cuenta->idepigrafe; } $this->page->title = 'Cuenta: ' . $this->cuenta->codcuenta; $this->ejercicio = $this->cuenta->get_ejercicio(); $this->buttons[] = new fs_button_img('b_eliminar', 'Eliminar', 'trash.png', '#', TRUE); } else { $this->new_error_msg("Cuenta no encontrada."); $this->ppage = $this->page->get('contabilidad_cuentas'); } }