protected function private_core() { $this->cliente = FALSE; $this->logo = FALSE; if (file_exists('tmp/' . FS_TMP_NAME . 'logo.png')) { $this->logo = 'tmp/' . FS_TMP_NAME . 'logo.png'; } else { if (file_exists('tmp/' . FS_TMP_NAME . 'logo.jpg')) { $this->logo = 'tmp/' . FS_TMP_NAME . 'logo.jpg'; } } $this->template = FALSE; if (isset($_REQUEST['id'])) { $recibo0 = new recibo_cliente(); $this->recibo = $recibo0->get($_REQUEST['id']); if ($this->recibo) { $cliente = new cliente(); $this->cliente = $cliente->get($this->recibo->codcliente); $fact0 = new factura_cliente(); $this->factura = $fact0->get($this->recibo->idfactura); $this->generar_pdf_recibo(); } else { echo 'ERROR - Recibo no encontrado.'; } } else { $this->share_extensions(); } }
private function modificar_remesa() { if (isset($_POST['descripcion'])) { $this->remesa->descripcion = $_POST['descripcion']; $this->remesa->fecha = $_POST['fecha']; $this->remesa->fechacargo = $_POST['fechacargo']; $this->remesa->estado = $_POST['estado']; if ($this->remesa->save()) { $this->new_message('Datos guardados correctamente.'); } else { $this->new_error_msg('Error al guardar los datos.'); } } else { if (isset($_GET['pagar'])) { $this->pagar_recibos(); } else { if (!$this->remesa->editable() and (isset($_POST['addrecibo']) or isset($_GET['sacar']))) { $this->new_error_msg('Solamente se pueden hacer cambios en remesas <b>en trámite</b>.'); } else { if (isset($_POST['addrecibo'])) { $nuevos = 0; $recli = new recibo_cliente(); foreach ($_POST['addrecibo'] as $id) { $recibo = $recli->get($id); if ($recibo) { $recibo->idremesa = $this->remesa->idremesa; if ($recibo->save()) { $nuevos++; } } } $this->new_message($nuevos . ' recibos añadidos a la remesa.'); } else { if (isset($_GET['sacar'])) { $recli = new recibo_cliente(); $recibo = $recli->get($_GET['sacar']); if ($recibo) { $recibo->idremesa = NULL; if ($recibo->save()) { $this->new_message('Recibo ' . $recibo->codigo . ' excluido.'); } else { $this->new_error_msg('Error al excluir el recibo ' . $recibo->codigo); } } } } } } } }
private static function get_recibo($idRecibo) { $recibo = new recibo_cliente(); return $recibo->get($idRecibo); }
protected function private_core() { $this->share_extenstion(); $recibo = new recibo_cliente(); $this->check_vencimiento = FALSE; $this->cliente = FALSE; $this->desde = ''; $this->estado = ''; $this->hasta = ''; $this->num_pendientes = 0; $this->num_resultados = 0; $this->num_vencidos = 0; $this->total_resultados = 0; $this->total_resultados_txt = ''; $this->vencimiento = Date('d-m-Y', strtotime('+1month')); if (isset($_REQUEST['buscar_cliente'])) { $this->buscar_cliente(); } else { if (isset($_POST['fecha'])) { $this->nuevo_recibo(); } else { if (isset($_REQUEST['id'])) { /// pestaña recibos de una factura $this->template = 'tab_factura_cliente'; $factura = new factura_cliente(); $this->factura = $factura->get($_REQUEST['id']); if ($this->factura) { /// generamos los recibos a partir de los pagos en pedidos y albaranes $this->generar_recibos_pagos(); $this->resultados = $recibo->all_from_factura($_REQUEST['id']); if (isset($_GET['regenerar'])) { foreach ($this->resultados as $res) { $res->delete(); } $this->factura->pagada = FALSE; $this->factura->save(); $this->sync_factura(TRUE); } $this->pagada_previamente = FALSE; if ($this->factura->pagada and count($this->resultados) == 0) { $this->pagada_previamente = TRUE; } else { $this->sync_factura(TRUE); } } } else { $this->mostrar = 'todo'; if (isset($_GET['mostrar'])) { $this->mostrar = $_GET['mostrar']; } $this->offset = 0; if (isset($_GET['offset'])) { $this->offset = intval($_GET['offset']); } if (isset($_GET['delete'])) { $recibo2 = $recibo->get($_GET['delete']); if ($recibo2) { if ($recibo2->delete()) { $this->new_message('Recibo eliminado correctamente.'); } else { $this->new_message('Error al eliminar el recibo.'); } } else { $this->new_message('Recibo no encontrado.'); } } else { if (!isset($_GET['mostrar']) and isset($_REQUEST['codcliente'])) { $this->mostrar = 'buscar'; } } if (isset($_REQUEST['codcliente'])) { if ($_REQUEST['codcliente'] != '') { $cli0 = new cliente(); $this->cliente = $cli0->get($_REQUEST['codcliente']); } } if (isset($_REQUEST['desde'])) { $this->desde = $_REQUEST['desde']; $this->estado = $_REQUEST['estado']; $this->hasta = $_REQUEST['hasta']; $this->check_vencimiento = isset($_REQUEST['vencimiento']); } $this->order = 'fecha DESC'; if (isset($_GET['order'])) { if ($_GET['order'] == 'fecha_desc') { $this->order = 'fecha DESC'; } else { if ($_GET['order'] == 'fecha_asc') { $this->order = 'fecha ASC'; } else { if ($_GET['order'] == 'fechav_desc') { $this->order = 'fechav DESC'; } else { if ($_GET['order'] == 'fechav_asc') { $this->order = 'fechav ASC'; } else { if ($_GET['order'] == 'codigo_desc') { $this->order = 'codigo DESC'; } else { if ($_GET['order'] == 'codigo_asc') { $this->order = 'codigo ASC'; } } } } } } setcookie('ventas_recibos_order', $this->order, time() + FS_COOKIES_EXPIRE); } else { if (isset($_COOKIE['ventas_recibos_order'])) { $this->order = $_COOKIE['ventas_recibos_order']; } } $this->cron_job(); $this->buscar(); } } } }
protected function private_core() { /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); $recibo = new recibo_cliente(); $this->recibo = FALSE; if (isset($_REQUEST['id'])) { $this->recibo = $recibo->get($_REQUEST['id']); } if ($this->recibo) { if (isset($_POST['fechav'])) { $this->recibo->importe = floatval($_POST['importe']); $this->recibo->fecha = $_POST['emitido']; $this->recibo->fechav = $_POST['fechav']; $this->recibo->iban = $_POST['iban']; $this->recibo->swift = $_POST['swift']; if ($this->recibo->save()) { $this->new_message('Datos guardados correctamente.'); } else { $this->new_error_msg('Error al guardar los datos.'); } } $this->page->title = 'Recibo ' . $this->recibo->codigo; $fact = new factura_cliente(); $this->factura = $fact->get($this->recibo->idfactura); $this->check_recibo(); $this->get_subcuentas(); $pago = new pago_recibo_cliente(); if (isset($_POST['nuevopago'])) { $pago->idrecibo = $this->recibo->idrecibo; $pago->fecha = $_POST['fecha']; $pago->tipo = $_POST['tipo']; foreach ($this->subcuentas_pago as $sc) { if ($sc->codsubcuenta == $_POST['codsubcuenta']) { $pago->idsubcuenta = $sc->idsubcuenta; $pago->codsubcuenta = $sc->codsubcuenta; } } if ($pago->tipo == 'Pago') { if ($this->empresa->contintegrada and isset($_POST['generarasiento'])) { $pago->idasiento = $this->nuevo_asiento_pago($pago, $this->ejercicio); } $this->recibo->estado = 'Pagado'; $this->recibo->fechap = $_POST['fecha']; } else { if ($this->empresa->contintegrada and isset($_POST['generarasiento'])) { $pago->idasiento = $this->nuevo_asiento_devolucion($pago, $this->ejercicio); } $this->recibo->estado = 'Devuelto'; } if ($pago->save()) { $this->new_message('Pago guardado correctamente.'); $this->recibo->save(); } else { $this->new_error_msg('Error al guardar los pagos.'); } } else { if (isset($_GET['deletep'])) { foreach ($pago->all_from_recibo($this->recibo->idrecibo) as $pg) { if ($pg->idpagodevol == intval($_GET['deletep'])) { if ($pg->delete()) { $this->new_message($pg->tipo . ' eliminado correctamente'); $this->recibo->estado = 'Emitido'; $this->recibo->save(); } else { $this->new_error_msg('Error al eliminar el ' . $pg->tipo); } break; } } } } $this->pagos = $pago->all_from_recibo($this->recibo->idrecibo); $this->recibos = $this->recibo->all_from_factura($this->recibo->idfactura); $this->sync_factura(); } else { $this->new_error_msg('Recibo no encontrado.'); } }