protected function private_core() { $this->albaran = FALSE; $this->cliente = FALSE; $this->factura = FALSE; $this->impuesto = new impuesto(); /// obtenemos los datos de configuración de impresión $this->impresion = array('print_ref' => '1', 'print_dto' => '1', 'print_alb' => '0'); $fsvar = new fs_var(); $this->impresion = $fsvar->array_get($this->impresion, FALSE); if (isset($_REQUEST['albaran']) and isset($_REQUEST['id'])) { $alb = new albaran_cliente(); $this->albaran = $alb->get($_REQUEST['id']); if ($this->albaran) { $cliente = new cliente(); $this->cliente = $cliente->get($this->albaran->codcliente); } if (isset($_POST['email'])) { $this->enviar_email('albaran'); } else { $this->generar_pdf_albaran(); } } else { if (isset($_REQUEST['factura']) and isset($_REQUEST['id'])) { $fac = new factura_cliente(); $this->factura = $fac->get($_REQUEST['id']); $dirCli = new direccion_cliente(); $this->direccioncli = $dirCli->get_codcli($this->factura->codcliente); if ($this->factura) { $cliente = new cliente(); $this->cliente = $cliente->get($this->factura->codcliente); } if (isset($_POST['email'])) { $this->enviar_email('factura', $_REQUEST['tipo']); } else { $this->generar_pdf_factura($_REQUEST['tipo']); } } } $this->share_extensions(); }
protected function private_core() { $this->ppage = $this->page->get('ventas_clientes'); $this->agente = new agente(); $this->cuenta_banco = new cuenta_banco_cliente(); $this->divisa = new divisa(); $this->forma_pago = new forma_pago(); $this->grupo = new grupo_clientes(); $this->pais = new pais(); $this->serie = new serie(); /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); /// cargamos el cliente $cliente = new cliente(); $this->cliente = FALSE; if (isset($_POST['codcliente'])) { $this->cliente = $cliente->get($_POST['codcliente']); } else { if (isset($_GET['cod'])) { $this->cliente = $cliente->get($_GET['cod']); } } /// ¿Hay que hacer algo más? if (isset($_GET['delete_cuenta'])) { $cuenta = $this->cuenta_banco->get($_GET['delete_cuenta']); if ($cuenta) { if ($cuenta->delete()) { $this->new_message('Cuenta bancaria eliminada correctamente.'); } else { $this->new_error_msg('Imposible eliminar la cuenta bancaria.'); } } else { $this->new_error_msg('Cuenta bancaria no encontrada.'); } } else { if (isset($_GET['delete_dir'])) { $dir = new direccion_cliente(); $dir0 = $dir->get($_GET['delete_dir']); if ($dir0) { if ($dir0->delete()) { $this->new_message('Dirección eliminada correctamente.'); } else { $this->new_error_msg('Imposible eliminar la dirección.'); } } else { $this->new_error_msg('Dirección no encontrada.'); } } else { if (isset($_POST['coddir'])) { $dir = new direccion_cliente(); if ($_POST['coddir'] != '') { $dir = $dir->get($_POST['coddir']); } $dir->apartado = $_POST['apartado']; $dir->ciudad = $_POST['ciudad']; $dir->codcliente = $this->cliente->codcliente; $dir->codpais = $_POST['pais']; $dir->codpostal = $_POST['codpostal']; $dir->descripcion = $_POST['descripcion']; $dir->direccion = $_POST['direccion']; $dir->domenvio = isset($_POST['direnvio']); $dir->domfacturacion = isset($_POST['dirfact']); $dir->provincia = $_POST['provincia']; if ($dir->save()) { $this->new_message("Dirección guardada correctamente."); } else { $this->new_message("¡Imposible guardar la dirección!"); } } else { if (isset($_POST['iban'])) { if (isset($_POST['codcuenta'])) { $cuentab = $this->cuenta_banco->get($_POST['codcuenta']); } else { $cuentab = new cuenta_banco_cliente(); $cuentab->codcliente = $_POST['codcliente']; } $cuentab->descripcion = $_POST['descripcion']; if ($_POST['ciban'] != '') { $cuentab->iban = $this->calcular_iban($_POST['ciban']); } else { $cuentab->iban = $_POST['iban']; } $cuentab->swift = $_POST['swift']; if ($cuentab->save()) { $this->new_message('Cuenta bancaria guardada correctamente.'); } else { $this->new_error_msg('Imposible guardar la cuenta bancaria.'); } } else { if (isset($_POST['codcliente'])) { $this->cliente->nombre = $_POST['nombre']; $this->cliente->razonsocial = $_POST['razonsocial']; $this->cliente->cifnif = $_POST['cifnif']; $this->cliente->telefono1 = $_POST['telefono1']; $this->cliente->telefono2 = $_POST['telefono2']; $this->cliente->fax = $_POST['fax']; $this->cliente->web = $_POST['web']; $this->cliente->email = $_POST['email']; $this->cliente->observaciones = $_POST['observaciones']; $this->cliente->codserie = $_POST['codserie']; $this->cliente->codpago = $_POST['codpago']; $this->cliente->coddivisa = $_POST['coddivisa']; $this->cliente->regimeniva = $_POST['regimeniva']; $this->cliente->recargo = isset($_POST['recargo']); $this->cliente->debaja = isset($_POST['debaja']); $this->cliente->codagente = NULL; if ($_POST['codagente'] != '---') { $this->cliente->codagente = $_POST['codagente']; } $this->cliente->codgrupo = NULL; if ($_POST['codgrupo'] != '---') { $this->cliente->codgrupo = $_POST['codgrupo']; } if ($this->cliente->save()) { $this->new_message("Datos del cliente modificados correctamente."); } else { $this->new_error_msg("¡Imposible modificar los datos del cliente!"); } } } } } } if ($this->cliente) { $this->page->title = $this->cliente->codcliente; } else { $this->new_error_msg("¡Cliente no encontrado!"); } }
protected function private_core() { $this->share_extensions(); $this->cliente = new cliente(); $this->grupo = new grupo_clientes(); // cargamos la configuración $fsvar = new fs_var(); $this->nuevocli_setup = $fsvar->array_get(array('nuevocli_cifnif_req' => 0, 'nuevocli_direccion' => 0, 'nuevocli_direccion_req' => 0, 'nuevocli_codpostal' => 0, 'nuevocli_codpostal_req' => 0, 'nuevocli_pais' => 0, 'nuevocli_pais_req' => 0, 'nuevocli_provincia' => 0, 'nuevocli_provincia_req' => 0, 'nuevocli_ciudad' => 0, 'nuevocli_ciudad_req' => 0, 'nuevocli_telefono1' => 0, 'nuevocli_telefono1_req' => 0, 'nuevocli_telefono2' => 0, 'nuevocli_telefono2_req' => 0, 'nuevocli_codgrupo' => '', 'cal_inicio' => "09:00"), FALSE); $this->mostrar = 'todo'; if (isset($_GET['mostrar'])) { $this->mostrar = $_GET['mostrar']; } $this->offset = 0; if (isset($_GET['offset'])) { $this->offset = intval($_GET['offset']); } $contrato = new contrato_servicio(); if (isset($_POST['cliente'])) { $cliente_s = $this->cliente->get($_POST['cliente']); /** * Nuevo cliente */ if (isset($_POST['nuevo_cliente'])) { if ($_POST['nuevo_cliente'] != '') { $cliente_s = FALSE; if ($_POST['nuevo_cifnif'] != '') { $cliente_s = $this->cliente->get_by_cifnif($_POST['nuevo_cifnif']); if ($cliente_s) { $this->new_advice('Ya existe un cliente con ese ' . FS_CIFNIF . '. Se ha seleccionado.'); } } if (!$cliente_s) { $cliente_s = new cliente(); $cliente_s->codcliente = $cliente_s->get_new_codigo(); $cliente_s->nombre = $cliente_s->razonsocial = $_POST['nuevo_cliente']; $cliente_s->cifnif = $_POST['nuevo_cifnif']; $cliente_s->codserie = $this->empresa->codserie; if (isset($_POST['nuevo_grupo'])) { if ($_POST['nuevo_grupo'] != '') { $cliente_s->codgrupo = $_POST['nuevo_grupo']; } } if (isset($_POST['nuevo_telefono1'])) { $cliente_s->telefono1 = $_POST['nuevo_telefono1']; } if (isset($_POST['nuevo_telefono2'])) { $cliente_s->telefono2 = $_POST['nuevo_telefono2']; } if ($cliente_s->save()) { $dircliente = new direccion_cliente(); $dircliente->codcliente = $cliente_s->codcliente; $dircliente->codpais = $this->empresa->codpais; $dircliente->provincia = $this->empresa->provincia; $dircliente->ciudad = $this->empresa->ciudad; $dircliente->descripcion = 'Principal'; if (isset($_POST['nuevo_pais'])) { $dircliente->codpais = $_POST['nuevo_pais']; } if (isset($_POST['nuevo_provincia'])) { $dircliente->provincia = $_POST['nuevo_provincia']; } if (isset($_POST['nuevo_ciudad'])) { $dircliente->ciudad = $_POST['nuevo_ciudad']; } if (isset($_POST['nuevo_codpostal'])) { $dircliente->codpostal = $_POST['nuevo_codpostal']; } if (isset($_POST['nuevo_direccion'])) { $dircliente->direccion = $_POST['nuevo_direccion']; } if ($dircliente->save()) { $this->new_message('Cliente agregado correctamente.'); } } else { $this->new_error_msg("¡Imposible guardar la dirección del cliente!"); } } } } $con = new contrato_servicio(); $con->codcliente = $cliente_s->codcliente; $con->codagente = $this->user->codagente; $con->codpago = $cliente_s->codpago; if ($con->save()) { $this->new_message('Contrato guardado correctamente.'); header('Location: ' . $con->url()); } else { $this->new_error_msg('Error al guardar el contrato.'); } } else { if (isset($_GET['test'])) { $cli0 = new cliente(); foreach ($cli0->all(mt_rand(0, 1000)) as $cliente) { $con = new contrato_servicio(); $con->codcliente = $cliente->codcliente; $con->codagente = $this->user->codagente; $con->codpago = $this->empresa->codpago; $con->fecha_alta = date(mt_rand(1, 29) . '-3-Y'); $con->fecha_renovacion = date(mt_rand(1, 29) . '-11-Y'); $con->importe_anual = mt_rand(600, 60000); $con->observaciones = $this->random_string(); $con->periodo = '+' . mt_rand(7, 120) . 'days'; $con->fsiguiente_servicio = date('d-m-Y', strtotime($con->fecha_alta . ' ' . $con->periodo)); $con->save(); } } else { if (isset($_GET['delete'])) { $con = $contrato->get($_GET['delete']); if ($con) { if ($con->delete()) { $this->new_message('Contrato eliminado correctamente.'); } else { $this->new_error_msg('Error al eliminar el contrato.'); } } else { $this->new_error_msg('Contrato no encontrado.'); } } } } if (isset($_REQUEST['buscar_cliente'])) { $this->buscar_cliente(); } else { if (isset($_GET['minicron'])) { $this->minicron(); } else { if ($this->mostrar == 'renovacion') { $this->resultados = $contrato->all($this->offset, 'fecha_renovacion ASC'); } else { if ($this->mostrar == 'servicio') { $this->resultados = $contrato->all($this->offset, 'fsiguiente_servicio ASC'); } else { $this->resultados = $contrato->all($this->offset); } } } } $this->total = $contrato->count(); }
/** * Devuelve un array con las direcciones asociadas al cliente. * @return type */ public function get_direcciones() { $dir = new direccion_cliente(); return $dir->all_from_cliente($this->codcliente); }
private function test_models() { $last_errores = array(); switch ($this->informe['model']) { default: /// tablas $this->test_tablas(); break; case 'asiento': $asiento = new asiento(); $asientos = $asiento->all($this->informe['offset']); if ($asientos) { if ($this->informe['offset'] == 0) { foreach ($this->check_partidas_erroneas() as $err) { $last_errores[] = $err; } } foreach ($asientos as $asi) { if ($asi->codejercicio == $this->informe['ejercicio']) { if ($this->informe['all']) { $this->informe['model'] = 'factura cliente'; } else { $this->informe['model'] = 'fin'; } $this->informe['offset'] = 0; break; } else { if (!$asi->full_test($this->informe['duplicados'])) { $last_errores[] = array('error' => 'Fallo en full_test()', 'model' => $this->informe['model'], 'ejercicio' => $asi->codejercicio, 'id' => $asi->numero, 'url' => $asi->url(), 'fecha' => $asi->fecha, 'fix' => $asi->fix()); } } } $this->informe['offset'] += FS_ITEM_LIMIT; } else { if ($this->informe['all']) { $this->informe['model'] = 'factura cliente'; $this->informe['offset'] = 0; } else { $this->informe['model'] = 'fin'; $this->informe['offset'] = 0; } } break; case 'factura cliente': $factura = new factura_cliente(); $facturas = $factura->all($this->informe['offset']); if ($facturas) { foreach ($facturas as $fac) { if ($fac->codejercicio == $this->informe['ejercicio']) { if ($this->informe['all']) { $this->informe['model'] = 'factura proveedor'; } else { $this->informe['model'] = 'fin'; } $this->informe['offset'] = 0; break; } else { if (!$fac->full_test($this->informe['duplicados'])) { $last_errores[] = array('error' => 'Fallo en full_test()', 'model' => $this->informe['model'], 'ejercicio' => $fac->codejercicio, 'id' => $fac->codigo, 'url' => $fac->url(), 'fecha' => $fac->fecha, 'fix' => FALSE); } } } $this->informe['offset'] += FS_ITEM_LIMIT; } else { if ($this->informe['all']) { $this->informe['model'] = 'factura proveedor'; $this->informe['offset'] = 0; } else { $this->informe['model'] = 'fin'; $this->informe['offset'] = 0; } } break; case 'factura proveedor': $factura = new factura_proveedor(); $facturas = $factura->all($this->informe['offset']); if ($facturas) { foreach ($facturas as $fac) { if ($fac->codejercicio == $this->informe['ejercicio']) { if ($this->informe['all']) { $this->informe['model'] = 'albaran cliente'; } else { $this->informe['model'] = 'fin'; } $this->informe['offset'] = 0; break; } else { if (!$fac->full_test($this->informe['duplicados'])) { $last_errores[] = array('error' => 'Fallo en full_test()', 'model' => $this->informe['model'], 'ejercicio' => $fac->codejercicio, 'id' => $fac->codigo, 'url' => $fac->url(), 'fecha' => $fac->fecha, 'fix' => FALSE); } } } $this->informe['offset'] += FS_ITEM_LIMIT; } else { if ($this->informe['all']) { $this->informe['model'] = 'albaran cliente'; $this->informe['offset'] = 0; } else { $this->informe['model'] = 'fin'; $this->informe['offset'] = 0; } } break; case 'albaran cliente': $albaran = new albaran_cliente(); $albaranes = $albaran->all($this->informe['offset']); if ($albaranes) { foreach ($albaranes as $alb) { if ($alb->codejercicio == $this->informe['ejercicio']) { if ($this->informe['all']) { $this->informe['model'] = 'albaran proveedor'; } else { $this->informe['model'] = 'fin'; } $this->informe['offset'] = 0; break; } else { if (!$alb->full_test($this->informe['duplicados'])) { $last_errores[] = array('error' => 'Fallo en full_test()', 'model' => $this->informe['model'], 'ejercicio' => $alb->codejercicio, 'id' => $alb->codigo, 'url' => $alb->url(), 'fecha' => $alb->fecha, 'fix' => FALSE); } } } $this->informe['offset'] += FS_ITEM_LIMIT; } else { if ($this->informe['all']) { $this->informe['model'] = 'albaran proveedor'; $this->informe['offset'] = 0; } else { $this->informe['model'] = 'fin'; $this->informe['offset'] = 0; } } break; case 'albaran proveedor': $albaran = new albaran_proveedor(); $albaranes = $albaran->all($this->informe['offset']); if ($albaranes) { foreach ($albaranes as $alb) { if ($alb->codejercicio == $this->informe['ejercicio']) { $this->informe['model'] = 'fin'; $this->informe['offset'] = 0; break; } else { if (!$alb->full_test($this->informe['duplicados'])) { $last_errores[] = array('error' => 'Fallo en full_test()', 'model' => $this->informe['model'], 'ejercicio' => $alb->codejercicio, 'id' => $alb->codigo, 'url' => $alb->url(), 'fecha' => $alb->fecha, 'fix' => FALSE); } } } $this->informe['offset'] += FS_ITEM_LIMIT; } else { $this->informe['model'] = 'dirclientes'; $this->informe['offset'] = 0; } break; case 'dirclientes': $dircli0 = new direccion_cliente(); $direcciones = $dircli0->all($this->informe['offset']); if ($direcciones) { foreach ($direcciones as $dir) { /// simplemente guardamos para que se eliminen espacios de ciudades, provincias, etc... $dir->save(); } $this->informe['offset'] += FS_ITEM_LIMIT; } else { $this->informe['model'] = 'fin'; $this->informe['offset'] = 0; } break; case 'fin': break; } return $last_errores; }
protected function private_core() { /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); $this->cliente = new cliente(); $this->grupo = new grupo_clientes(); $this->pais = new pais(); $this->serie = new serie(); $this->tarifa = new tarifa(); /// cargamos la configuración $fsvar = new fs_var(); $this->nuevocli_setup = $fsvar->array_get(array('nuevocli_cifnif_req' => 0, 'nuevocli_direccion' => 1, 'nuevocli_direccion_req' => 0, 'nuevocli_codpostal' => 1, 'nuevocli_codpostal_req' => 0, 'nuevocli_pais' => 0, 'nuevocli_pais_req' => 0, 'nuevocli_provincia' => 1, 'nuevocli_provincia_req' => 0, 'nuevocli_ciudad' => 1, 'nuevocli_ciudad_req' => 0, 'nuevocli_telefono1' => 0, 'nuevocli_telefono1_req' => 0, 'nuevocli_telefono2' => 0, 'nuevocli_telefono2_req' => 0), FALSE); if (isset($_GET['delete_grupo'])) { $grupo = $this->grupo->get($_GET['delete_grupo']); if ($grupo) { if ($grupo->delete()) { $this->new_message('Grupo eliminado correctamente.'); } else { $this->new_error_msg('Imposible eliminar el grupo.'); } } else { $this->new_error_msg('Grupo no encontrado.'); } } else { if (isset($_POST['codgrupo'])) { $grupo = $this->grupo->get($_POST['codgrupo']); if (!$grupo) { $grupo = new grupo_clientes(); $grupo->codgrupo = $_POST['codgrupo']; } $grupo->nombre = $_POST['nombre']; $grupo->codtarifa = NULL; if ($_POST['codtarifa'] != '---') { $grupo->codtarifa = $_POST['codtarifa']; } if ($grupo->save()) { $this->new_message('Grupo guardado correctamente.'); } else { $this->new_error_msg('Imposible guardar el grupo.'); } } else { if (isset($_GET['delete'])) { $cliente = $this->cliente->get($_GET['delete']); if ($cliente) { if (FS_DEMO) { $this->new_error_msg('En el modo demo no se pueden eliminar clientes. Otros usuarios podrían necesitarlos.'); } else { if ($cliente->delete()) { $this->new_message('Cliente eliminado correctamente.'); } else { $this->new_error_msg('Ha sido imposible eliminar el cliente.'); } } } else { $this->new_error_msg('Cliente no encontrado.'); } } else { if (isset($_POST['cifnif'])) { $this->save_codpais($_POST['pais']); $cliente = FALSE; if ($_POST['cifnif'] != '') { $cliente = $this->cliente->get_by_cifnif($_POST['cifnif']); if ($cliente) { $this->new_advice('Ya existe un cliente con el ' . FS_CIFNIF . ' ' . $_POST['cifnif']); $this->query = $_POST['cifnif']; } } if (!$cliente) { $cliente = new cliente(); $cliente->codcliente = $cliente->get_new_codigo(); $cliente->nombre = $_POST['nombre']; $cliente->razonsocial = $_POST['nombre']; $cliente->cifnif = $_POST['cifnif']; $cliente->codserie = $this->empresa->codserie; $cliente->codgrupo = $_POST['scodgrupo']; if (isset($_POST['telefono1'])) { $cliente->telefono1 = $_POST['telefono1']; } if (isset($_POST['telefono2'])) { $cliente->telefono2 = $_POST['telefono2']; } if ($cliente->save()) { $dircliente = new direccion_cliente(); $dircliente->codcliente = $cliente->codcliente; $dircliente->codpais = $this->empresa->codpais; $dircliente->provincia = $this->empresa->provincia; $dircliente->ciudad = $this->empresa->ciudad; $dircliente->descripcion = 'Principal'; if (isset($_POST['pais'])) { $dircliente->codpais = $_POST['pais']; } if (isset($_POST['provincia'])) { $dircliente->provincia = $_POST['provincia']; } if (isset($_POST['ciudad'])) { $dircliente->ciudad = $_POST['ciudad']; } if (isset($_POST['codpostal'])) { $dircliente->codpostal = $_POST['codpostal']; } if (isset($_POST['direccion'])) { $dircliente->direccion = $_POST['direccion']; } if ($dircliente->save()) { header('location: ' . $cliente->url()); } else { $this->new_error_msg("¡Imposible guardar la dirección del cliente!"); } } else { $this->new_error_msg("¡Imposible guardar los datos del cliente!"); } } } } } } $this->offset = 0; if (isset($_GET['offset'])) { $this->offset = intval($_GET['offset']); } if ($this->query != '') { $this->resultados = $this->cliente->search($this->query, $this->offset); } else { $this->resultados = $this->cliente->all($this->offset); } $this->grupos = $this->grupo->all(); }
protected function process() { $this->show_fs_toolbar = FALSE; $this->cliente = new cliente(); $this->clientes_grupo = FALSE; $this->grupo = new grupo_clientes(); $this->pais = new pais(); $this->serie = new serie(); $this->tarifa = new tarifa(); if (isset($_GET['delete_grupo'])) { $grupo = $this->grupo->get($_GET['delete_grupo']); if ($grupo) { if ($grupo->delete()) { $this->new_message('Grupo eliminado correctamente.'); } else { $this->new_error_msg('Imposible eliminar el grupo.'); } } else { $this->new_error_msg('Grupo no encontrado.'); } } else { if (isset($_POST['codgrupo'])) { $grupo = $this->grupo->get($_POST['codgrupo']); if (!$grupo) { $grupo = new grupo_clientes(); $grupo->codgrupo = $_POST['codgrupo']; } $grupo->nombre = $_POST['nombre']; if ($_POST['codtarifa'] == '---') { $grupo->codtarifa = NULL; } else { $grupo->codtarifa = $_POST['codtarifa']; } if ($grupo->save()) { $this->new_message('Grupo guardado correctamente.'); } else { $this->new_error_msg('Imposible guardar el grupo.'); } } else { if (isset($_GET['delete'])) { $cliente = $this->cliente->get($_GET['delete']); if ($cliente) { if (FS_DEMO) { $this->new_error_msg('En el modo demo no se pueden eliminar clientes. Otros usuarios podrían necesitarlos.'); } else { if ($cliente->delete()) { $this->new_message('Cliente eliminado correctamente.'); } else { $this->new_error_msg('Ha sido imposible eliminar el cliente.'); } } } else { $this->new_error_msg('Cliente no encontrado.'); } } else { if (isset($_POST['cifnif'])) { $this->save_codpais($_POST['pais']); $this->save_codserie($_POST['codserie']); $cliente = new cliente(); $cliente->codcliente = $cliente->get_new_codigo(); $cliente->nombre = $_POST['nombre']; $cliente->nombrecomercial = $_POST['nombre']; $cliente->cifnif = $_POST['cifnif']; $cliente->codserie = $_POST['codserie']; if ($cliente->save()) { $dircliente = new direccion_cliente(); $dircliente->codcliente = $cliente->codcliente; $dircliente->codpais = $_POST['pais']; $dircliente->provincia = $_POST['provincia']; $dircliente->ciudad = $_POST['ciudad']; $dircliente->codpostal = $_POST['codpostal']; $dircliente->direccion = $_POST['direccion']; $dircliente->descripcion = 'Principal'; if ($dircliente->save()) { header('location: ' . $cliente->url()); } else { $this->new_error_msg("¡Imposible guardar la dirección del cliente!"); } } else { $this->new_error_msg("¡Imposible guardar los datos del cliente!"); } } } } } $this->offset = 0; if (isset($_GET['offset'])) { $this->offset = intval($_GET['offset']); } if ($this->query != '') { $this->resultados = $this->cliente->search($this->query, $this->offset); } else { $this->resultados = $this->cliente->all($this->offset); } $this->grupos = $this->grupo->all(); if (isset($_GET['grupo'])) { $this->clientes_grupo = $this->clientes_from_grupo($_GET['grupo']); } }
protected function private_core() { /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); $this->cliente = new cliente(); $this->grupo = new grupo_clientes(); $this->pais = new pais(); $this->serie = new serie(); $this->tarifa = new tarifa(); $this->tarifas = $this->tarifa->all(); $this->ncf_tipo = new ncf_tipo(); $this->ncf_entidad_tipo = new ncf_entidad_tipo(); /// cargamos la configuración $fsvar = new fs_var(); $this->nuevocli_setup = $fsvar->array_get(array('nuevocli_cifnif_req' => 0, 'nuevocli_direccion' => 1, 'nuevocli_direccion_req' => 0, 'nuevocli_codpostal' => 1, 'nuevocli_codpostal_req' => 0, 'nuevocli_pais' => 0, 'nuevocli_pais_req' => 0, 'nuevocli_provincia' => 1, 'nuevocli_provincia_req' => 0, 'nuevocli_ciudad' => 1, 'nuevocli_ciudad_req' => 0, 'nuevocli_telefono1' => 0, 'nuevocli_telefono1_req' => 0, 'nuevocli_telefono2' => 0, 'nuevocli_telefono2_req' => 0, 'nuevocli_codgrupo' => ''), FALSE); if (isset($_GET['delete_grupo'])) { $grupo = $this->grupo->get($_GET['delete_grupo']); if ($grupo) { if ($grupo->delete()) { $this->new_message('Grupo eliminado correctamente.'); } else { $this->new_error_msg('Imposible eliminar el grupo.'); } } else { $this->new_error_msg('Grupo no encontrado.'); } } else { if (isset($_POST['codgrupo'])) { $grupo = $this->grupo->get($_POST['codgrupo']); if (!$grupo) { $grupo = new grupo_clientes(); $grupo->codgrupo = $_POST['codgrupo']; } $grupo->nombre = $_POST['nombre']; $grupo->codtarifa = NULL; if ($_POST['codtarifa'] != '---') { $grupo->codtarifa = $_POST['codtarifa']; } if ($grupo->save()) { $this->new_message('Grupo guardado correctamente.'); } else { $this->new_error_msg('Imposible guardar el grupo.'); } } else { if (isset($_GET['delete'])) { $cliente = $this->cliente->get($_GET['delete']); if ($cliente) { if (FS_DEMO) { $this->new_error_msg('En el modo demo no se pueden eliminar clientes. Otros usuarios podrían necesitarlos.'); } else { if ($cliente->delete()) { $this->new_message('Cliente eliminado correctamente.'); } else { $this->new_error_msg('Ha sido imposible eliminar el cliente.'); } } } else { $this->new_error_msg('Cliente no encontrado.'); } } else { if (isset($_POST['cifnif'])) { $cliente = new cliente(); $cliente->codcliente = $cliente->get_new_codigo(); $cliente->nombre = $_POST['nombre']; $cliente->razonsocial = $_POST['nombre']; $cliente->tipoidfiscal = $_POST['tipoidfiscal']; $cliente->cifnif = $_POST['cifnif']; $cliente->personafisica = isset($_POST['personafisica']); if (isset($_POST['scodgrupo'])) { if ($_POST['scodgrupo'] != '') { $cliente->codgrupo = $_POST['scodgrupo']; } } if (isset($_POST['telefono1'])) { $cliente->telefono1 = $_POST['telefono1']; } if (isset($_POST['telefono2'])) { $cliente->telefono2 = $_POST['telefono2']; } if ($cliente->save()) { if (\filter_input(INPUT_POST, 'tipo_comprobante') != '') { $ncf_entidad_tipo = new ncf_entidad_tipo(); $ncf_entidad_tipo->idempresa = $this->empresa->id; $ncf_entidad_tipo->entidad = $cliente->codcliente; $ncf_entidad_tipo->tipo_entidad = 'CLI'; $ncf_entidad_tipo->tipo_comprobante = \filter_input(INPUT_POST, 'tipo_comprobante'); $ncf_entidad_tipo->estado = TRUE; $ncf_entidad_tipo->usuario_creacion = $this->user->nick; $ncf_entidad_tipo->fecha_creacion = Date('d-m-Y H:i:s'); $ncf_entidad_tipo->save(); } $dircliente = new direccion_cliente(); $dircliente->codcliente = $cliente->codcliente; $dircliente->codpais = $this->empresa->codpais; $dircliente->provincia = $this->empresa->provincia; $dircliente->ciudad = $this->empresa->ciudad; $dircliente->descripcion = 'Principal'; if (isset($_POST['pais'])) { $dircliente->codpais = $_POST['pais']; } if (isset($_POST['provincia'])) { $dircliente->provincia = $_POST['provincia']; } if (isset($_POST['ciudad'])) { $dircliente->ciudad = $_POST['ciudad']; } if (isset($_POST['codpostal'])) { $dircliente->codpostal = $_POST['codpostal']; } if (isset($_POST['direccion'])) { $dircliente->direccion = $_POST['direccion']; } if ($dircliente->save()) { if ($this->empresa->contintegrada) { /// forzamos la creación de la subcuenta $cliente->get_subcuenta($this->empresa->codejercicio); } /// redireccionamos a la página del cliente header('location: ' . $cliente->url()); } else { $this->new_error_msg("¡Imposible guardar la dirección del cliente!"); } } else { $this->new_error_msg("¡Imposible guardar los datos del cliente!"); } } } } } $this->offset = 0; if (isset($_GET['offset'])) { $this->offset = intval($_GET['offset']); } $this->ciudad = ''; if (isset($_REQUEST['ciudad'])) { $this->ciudad = $this->empresa->no_html($_REQUEST['ciudad']); } $this->provincia = ''; if (isset($_REQUEST['provincia'])) { $this->provincia = $this->empresa->no_html($_REQUEST['provincia']); } $this->codpais = ''; if (isset($_REQUEST['codpais'])) { $this->codpais = $_REQUEST['codpais']; } $this->codgrupo = ''; if (isset($_REQUEST['bcodgrupo'])) { $this->codgrupo = $_REQUEST['bcodgrupo']; } $this->orden = 'nombre ASC'; if (isset($_REQUEST['orden'])) { $this->orden = $_REQUEST['orden']; } $this->nocifnif = isset($_REQUEST['nocifnif']); $this->debaja = isset($_REQUEST['debaja']); $this->buscar(); $this->grupos = $this->grupo->all(); }
public function nuevo_cliente() { //---------------------------------------------- // agrega un cliente nuevo y retorna el id //---------------------------------------------- if (isset($_POST['nombre'])) { $cliente = new cliente(); $cliente->referencia = $cliente->get_new_codigo(); $cliente->nombre = $_POST['nombre']; $cliente->nombrecomercial = $_POST['nombre']; $cliente->cifnif = $_POST['cifnif']; $cliente->telefono1 = $_POST['telefono1']; $cliente->telefono2 = $_POST['telefono2']; $cliente->codserie = $this->empresa->codserie; if ($cliente->save()) { $dircliente = new direccion_cliente(); $dircliente->referencia = $cliente->referencia; $dircliente->codpais = $_POST['pais']; $dircliente->provincia = $_POST['provincia']; $dircliente->ciudad = $_POST['ciudad']; $dircliente->codpostal = $_POST['codpostal']; $dircliente->direccion = $_POST['direccion']; $dircliente->descripcion = 'Principal'; if ($dircliente->save()) { $this->new_message('Cliente agregado correctamente.'); } else { $this->new_error_msg("¡Imposible guardar la dirección del cliente!"); } } else { $this->new_error_msg('Error al agregar los datos del cliente.'); } } return $cliente->referencia; }
private function nuevo_sat() { $this->page->title = "Nuevo SAT"; if (isset($_GET['codcliente'])) { /// cliente ya seleccionado $this->cliente_s = $this->cliente->get($_GET['codcliente']); $this->template = "agregasat"; if (isset($_POST['averia'])) { /// el usuario ha hecho clic en Guardar el registro SAT $this->cliente_s->nombre = $_POST['nombre']; $this->cliente_s->telefono1 = $_POST['telefono1']; $this->cliente_s->telefono2 = $_POST['telefono2']; if ($this->cliente_s->save()) { $this->new_message('Cliente modificado correctamente.'); } else { $this->new_error_msg('Error al guardar los datos del cliente.'); } $this->nuevo_sat2(); } } else { /// nuevo cliente $cliente = $this->cliente->get_by_cifnif($_POST['cifnif']); if (!$cliente) { $cliente = new cliente(); $cliente->codcliente = $cliente->get_new_codigo(); $cliente->cifnif = $_POST['cifnif']; } $cliente->nombre = $cliente->razonsocial = $_POST['nombre']; $cliente->telefono1 = $_POST['telefono1']; $cliente->telefono2 = $_POST['telefono2']; $cliente->codserie = $this->empresa->codserie; if ($cliente->save()) { $dircliente = new direccion_cliente(); $dircliente->codcliente = $cliente->codcliente; $dircliente->codpais = $_POST['pais']; $dircliente->provincia = $_POST['provincia']; $dircliente->ciudad = $_POST['ciudad']; $dircliente->codpostal = $_POST['codpostal']; $dircliente->direccion = $_POST['direccion']; $dircliente->descripcion = 'Principal'; if ($dircliente->save()) { $this->new_message('Cliente agregado correctamente.'); /// redireccionamos header('Location: ' . $this->url() . '&nuevosat=TRUE&codcliente=' . $cliente->codcliente); } else { $this->new_error_msg("¡Imposible guardar la dirección del cliente!"); } } else { $this->new_error_msg('Error al agregar los datos del cliente.'); } } }
protected function private_core() { /// cargamos configuración de servicios $fsvar = new fs_var(); $this->fabricante = new fabricante(); $this->servicios_setup = $fsvar->array_get(array('servicios_diasfin' => 10, 'servicios_material' => 0, 'servicios_mostrar_material' => 0, 'servicios_material_estado' => 0, 'servicios_mostrar_marca' => 0, 'servicios_marca' => 0, 'servicios_mostrar_modelo' => 0, 'servicios_modelo' => 0, 'servicios_mostrar_tipo' => 0, 'servicios_tipo' => 0, 'servicios_mostrar_material_estado' => 0, 'servicios_accesorios' => 0, 'servicios_mostrar_accesorios' => 0, 'servicios_descripcion' => 0, 'servicios_mostrar_descripcion' => 0, 'servicios_solucion' => 0, 'servicios_mostrar_solucion' => 0, 'servicios_fechafin' => 0, 'servicios_mostrar_fechafin' => 0, 'servicios_fechainicio' => 0, 'servicios_mostrar_fechainicio' => 0, 'servicios_mostrar_garantia' => 0, 'servicios_garantia' => 0), FALSE); /// cargamos traducciones $this->st = $fsvar->array_get(array('st_servicio' => "Servicio", 'st_servicios' => "Servicios", 'st_material' => "Material", 'st_material_estado' => "Estado del material entregado", 'st_accesorios' => "Accesorios que entrega", 'st_descripcion' => "Descripción de la averia", 'st_solucion' => "Solución", 'st_marca' => "Marca del aparato", 'st_modelo' => "Modelo del aparato", 'st_tipo' => "Tipo de aparato"), FALSE); // cargamos la configuración $fsvar = new fs_var(); $this->nuevocli_setup = $fsvar->array_get(array('nuevocli_cifnif_req' => 0, 'nuevocli_direccion' => 0, 'nuevocli_direccion_req' => 0, 'nuevocli_codpostal' => 0, 'nuevocli_codpostal_req' => 0, 'nuevocli_pais' => 0, 'nuevocli_pais_req' => 0, 'nuevocli_provincia' => 0, 'nuevocli_provincia_req' => 0, 'nuevocli_ciudad' => 0, 'nuevocli_ciudad_req' => 0, 'nuevocli_telefono1' => 0, 'nuevocli_telefono1_req' => 0, 'nuevocli_telefono2' => 0, 'nuevocli_telefono2_req' => 0, 'nuevocli_grupo' => 0, 'nuevocli_grupo_req' => 0, 'nuevocli_grupo_pred' => 0), FALSE); $this->servicio = new servicio_cliente(); $this->cliente = new cliente(); $this->cliente_s = FALSE; $this->direccion = FALSE; $this->familia = new familia(); $this->impuesto = new impuesto(); $this->results = array(); $this->descripcion = NULL; $this->solucion = NULL; $this->prioridad = 3; $this->material = NULL; $this->material_estado = NULL; $this->accesorios = NULL; $this->codmarca = NULL; $this->codmodelo = NULL; $this->codtipo = NULL; $this->grupo = new grupo_clientes(); $this->estado = new estados_servicios(); $this->pais = new pais(); $this->fechaprevista = date('d-m-Y', strtotime($this->today() . '+ ' . $this->servicios_setup['servicios_diasfin'] . 'days')); $this->nueva_marca_url = FALSE; $this->nuevo_modelo_url = FALSE; $this->nuevo_tipo_url = FALSE; $this->marca = new marca(); $this->modelo = new modelo(); $this->tipo = new tipo(); $this->nueva_marca_url = $this->marca->url(); $this->nuevo_modelo_url = $this->modelo->url(); $this->nuevo_tipo_url = $this->tipo->url(); $this->marca_s = $this->marca->get($this->servicio->codmarca); $this->modelo_s = $this->modelo->get($this->servicio->codmodelo); $this->tipo_s = $this->tipo->get($this->servicio->codtipo); if (isset($_REQUEST['buscar_cliente'])) { $this->buscar_cliente(); } else { if (isset($_REQUEST['datoscliente'])) { $this->datos_cliente(); } else { if (isset($_REQUEST['new_articulo'])) { $this->new_articulo(); } else { if ($this->query != '') { $this->new_search(); } else { if (isset($_POST['referencia4precios'])) { $this->get_precios_articulo(); } else { if (isset($_POST['cliente'])) { $this->cliente_s = $this->cliente->get($_POST['cliente']); /** * Nuevo cliente */ if (isset($_POST['nuevo_cliente'])) { if ($_POST['nuevo_cliente'] != '') { $this->cliente_s = FALSE; if ($_POST['nuevo_cifnif'] != '') { $this->cliente_s = $this->cliente->get_by_cifnif($_POST['nuevo_cifnif']); if ($this->cliente_s) { $this->new_advice('Ya existe un cliente con ese ' . FS_CIFNIF . '. Se ha seleccionado.'); } } if (!$this->cliente_s) { $this->cliente_s = new cliente(); $this->cliente_s->codcliente = $this->cliente_s->get_new_codigo(); $this->cliente_s->nombre = $this->cliente_s->razonsocial = $_POST['nuevo_cliente']; $this->cliente_s->cifnif = $_POST['nuevo_cifnif']; $this->cliente_s->codserie = $this->empresa->codserie; if (isset($_POST['nuevo_grupo'])) { if ($_POST['nuevo_grupo'] != '') { $this->cliente_s->codgrupo = $_POST['nuevo_grupo']; } } if (isset($_POST['nuevo_telefono1'])) { $this->cliente_s->telefono1 = $_POST['nuevo_telefono1']; } if (isset($_POST['nuevo_telefono2'])) { $this->cliente_s->telefono2 = $_POST['nuevo_telefono2']; } if ($this->cliente_s->save()) { $dircliente = new direccion_cliente(); $dircliente->codcliente = $this->cliente_s->codcliente; $dircliente->codpais = $this->empresa->codpais; $dircliente->provincia = $this->empresa->provincia; $dircliente->ciudad = $this->empresa->ciudad; $dircliente->descripcion = 'Principal'; if (isset($_POST['nuevo_pais'])) { $dircliente->codpais = $_POST['nuevo_pais']; } if (isset($_POST['nuevo_provincia'])) { $dircliente->provincia = $_POST['nuevo_provincia']; } if (isset($_POST['nuevo_ciudad'])) { $dircliente->ciudad = $_POST['nuevo_ciudad']; } if (isset($_POST['nuevo_codpostal'])) { $dircliente->codpostal = $_POST['nuevo_codpostal']; } if (isset($_POST['nuevo_direccion'])) { $dircliente->direccion = $_POST['nuevo_direccion']; } if ($dircliente->save()) { $this->new_message('Cliente agregado correctamente.'); } } else { $this->new_error_msg("¡Imposible guardar la dirección del cliente!"); } } } } if ($this->cliente_s) { foreach ($this->cliente_s->get_direcciones() as $dir) { if ($dir->domfacturacion) { $this->direccion = $dir; break; } } } if (isset($_POST['codagente'])) { $agente = new agente(); $this->agente = $agente->get($_POST['codagente']); } else { $this->agente = $this->user->get_agente(); } $this->almacen = new almacen(); $this->serie = new serie(); $this->forma_pago = new forma_pago(); $this->divisa = new divisa(); if (isset($_POST['numlineas'])) { $this->nuevo_servicio_cliente(); if (!$this->direccion) { $this->direccion = new direccion_cliente(); $this->direccion->codcliente = $this->cliente_s->codcliente; $this->direccion->codpais = $_POST['codpais']; $this->direccion->provincia = $_POST['provincia']; $this->direccion->ciudad = $_POST['ciudad']; $this->direccion->codpostal = $_POST['codpostal']; $this->direccion->direccion = $_POST['direccion']; $this->direccion->descripcion = 'Principal'; $this->direccion->save(); } } } } } } } } }
protected function private_core() { $this->cliente = new cliente(); $this->grupo = new grupo_clientes(); $this->pais = new pais(); $this->serie = new serie(); $this->tarifa = new tarifa(); /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); if (isset($_REQUEST['buscar_provincia'])) { $this->buscar_provincia(); } else { if (isset($_REQUEST['buscar_ciudad'])) { $this->buscar_ciudad(); } else { if (isset($_GET['delete_grupo'])) { $grupo = $this->grupo->get($_GET['delete_grupo']); if ($grupo) { if ($grupo->delete()) { $this->new_message('Grupo eliminado correctamente.'); } else { $this->new_error_msg('Imposible eliminar el grupo.'); } } else { $this->new_error_msg('Grupo no encontrado.'); } } else { if (isset($_POST['codgrupo'])) { $grupo = $this->grupo->get($_POST['codgrupo']); if (!$grupo) { $grupo = new grupo_clientes(); $grupo->codgrupo = $_POST['codgrupo']; } $grupo->nombre = $_POST['nombre']; if ($_POST['codtarifa'] == '---') { $grupo->codtarifa = NULL; } else { $grupo->codtarifa = $_POST['codtarifa']; } if ($grupo->save()) { $this->new_message('Grupo guardado correctamente.'); } else { $this->new_error_msg('Imposible guardar el grupo.'); } } else { if (isset($_GET['delete'])) { $cliente = $this->cliente->get($_GET['delete']); if ($cliente) { if (FS_DEMO) { $this->new_error_msg('En el modo demo no se pueden eliminar clientes. Otros usuarios podrían necesitarlos.'); } else { if ($cliente->delete()) { $this->new_message('Cliente eliminado correctamente.'); } else { $this->new_error_msg('Ha sido imposible eliminar el cliente.'); } } } else { $this->new_error_msg('Cliente no encontrado.'); } } else { if (isset($_POST['cifnif'])) { $this->save_codpais($_POST['pais']); $cliente = new cliente(); $cliente->codcliente = $cliente->get_new_codigo(); if (isset($_POST['cli_codgrupo'])) { $cliente->codgrupo = $_POST['cli_codgrupo']; } if ($_POST['razonsocial'] != '') { $cliente->nombre = $cliente->razonsocial = $_POST['razonsocial']; } else { $cliente->nombre = $cliente->razonsocial = $_POST['nombre'] . ' ' . $_POST['nombre2'] . ' ' . $_POST['apellido'] . ' ' . $_POST['apellido2']; } $cliente->cifnif = $_POST['cifnif']; $cliente->codserie = $this->empresa->codserie; if ($cliente->save()) { $cliente_prop = new cliente_propiedad(); $cliente_prop->array_save($cliente->codcliente, array('nombre' => $_POST['nombre'], 'nombre2' => $_POST['nombre2'], 'apellido' => $_POST['apellido'], 'apellido2' => $_POST['apellido2'])); $dircliente = new direccion_cliente(); $dircliente->codcliente = $cliente->codcliente; $dircliente->codpais = $_POST['pais']; $dircliente->provincia = $_POST['provincia']; $dircliente->ciudad = $_POST['ciudad']; $dircliente->codpostal = $_POST['codpostal']; $dircliente->direccion = $_POST['direccion']; $dircliente->descripcion = 'Principal'; if ($dircliente->save()) { header('location: ' . $cliente->url()); } else { $this->new_error_msg("¡Imposible guardar la dirección del cliente!"); } } else { $this->new_error_msg("¡Imposible guardar los datos del cliente!"); } } } } } } } $this->offset = 0; if (isset($_GET['offset'])) { $this->offset = intval($_GET['offset']); } if ($this->query != '') { $this->resultados = $this->cliente->search($this->query, $this->offset); } else { $this->resultados = $this->cliente->all($this->offset); } $this->grupos = $this->grupo->all(); }
protected function private_core() { $this->ppage = $this->page->get('ventas_clientes'); $this->agente = new agente(); $this->cuenta_banco = new cuenta_banco_cliente(); $this->divisa = new divisa(); $this->forma_pago = new forma_pago(); $this->grupo = new grupo_clientes(); $this->pais = new pais(); $this->serie = new serie(); $this->ncf_tipo = new ncf_tipo(); $this->ncf_entidad_tipo = new ncf_entidad_tipo(); /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); /// cargamos el cliente $cliente = new cliente(); $this->cliente = FALSE; if (isset($_POST['codcliente'])) { $this->cliente = $cliente->get($_POST['codcliente']); } else { if (isset($_GET['cod'])) { $this->cliente = $cliente->get($_GET['cod']); } } $this->ncf_cliente_tipo = $this->ncf_entidad_tipo->get($this->empresa->id, $this->cliente->codcliente, 'CLI'); if ($this->cliente) { $this->page->title = $this->cliente->codcliente; /// ¿Hay que hacer algo más? if (isset($_GET['delete_cuenta'])) { $cuenta = $this->cuenta_banco->get($_GET['delete_cuenta']); if ($cuenta) { if ($cuenta->delete()) { $this->new_message('Cuenta bancaria eliminada correctamente.'); } else { $this->new_error_msg('Imposible eliminar la cuenta bancaria.'); } } else { $this->new_error_msg('Cuenta bancaria no encontrada.'); } } else { if (isset($_GET['delete_dir'])) { $dir = new direccion_cliente(); $dir0 = $dir->get($_GET['delete_dir']); if ($dir0) { if ($dir0->delete()) { $this->new_message('Dirección eliminada correctamente.'); } else { $this->new_error_msg('Imposible eliminar la dirección.'); } } else { $this->new_error_msg('Dirección no encontrada.'); } } else { if (isset($_POST['coddir'])) { $dir = new direccion_cliente(); if ($_POST['coddir'] != '') { $dir = $dir->get($_POST['coddir']); } $dir->apartado = $_POST['apartado']; $dir->ciudad = $_POST['ciudad']; $dir->codcliente = $this->cliente->codcliente; $dir->codpais = $_POST['pais']; $dir->codpostal = $_POST['codpostal']; $dir->descripcion = $_POST['descripcion']; $dir->direccion = $_POST['direccion']; $dir->domenvio = isset($_POST['direnvio']); $dir->domfacturacion = isset($_POST['dirfact']); $dir->provincia = $_POST['provincia']; if ($dir->save()) { $this->new_message("Dirección guardada correctamente."); } else { $this->new_message("¡Imposible guardar la dirección!"); } } else { if (isset($_POST['iban'])) { if (isset($_POST['codcuenta'])) { $cuentab = $this->cuenta_banco->get($_POST['codcuenta']); } else { $cuentab = new cuenta_banco_cliente(); $cuentab->codcliente = $_POST['codcliente']; } $cuentab->descripcion = $_POST['descripcion']; $cuentab->iban = $_POST['iban']; $cuentab->swift = $_POST['swift']; $cuentab->principal = isset($_POST['principal']); $cuentab->fmandato = NULL; if (isset($_POST['fmandato'])) { if ($_POST['fmandato'] != '') { $cuentab->fmandato = $_POST['fmandato']; } } if ($cuentab->save()) { $this->new_message('Cuenta bancaria guardada correctamente.'); } else { $this->new_error_msg('Imposible guardar la cuenta bancaria.'); } } else { if (isset($_POST['codcliente'])) { $this->cliente->nombre = $_POST['nombre']; $this->cliente->razonsocial = $_POST['razonsocial']; $this->cliente->tipoidfiscal = $_POST['tipoidfiscal']; $this->cliente->cifnif = $_POST['cifnif']; $this->cliente->telefono1 = $_POST['telefono1']; $this->cliente->telefono2 = $_POST['telefono2']; $this->cliente->fax = $_POST['fax']; $this->cliente->web = $_POST['web']; $this->cliente->email = $_POST['email']; $this->cliente->observaciones = $_POST['observaciones']; $this->cliente->codpago = $_POST['codpago']; $this->cliente->coddivisa = $_POST['coddivisa']; $this->cliente->regimeniva = $_POST['regimeniva']; $this->cliente->recargo = isset($_POST['recargo']); $this->cliente->debaja = isset($_POST['debaja']); $this->cliente->personafisica = isset($_POST['personafisica']); $this->cliente->codserie = NULL; if ($_POST['codserie'] != '') { $this->cliente->codserie = $_POST['codserie']; } $this->cliente->codagente = NULL; if ($_POST['codagente'] != '') { $this->cliente->codagente = $_POST['codagente']; } $this->cliente->codgrupo = NULL; if ($_POST['codgrupo'] != '') { $this->cliente->codgrupo = $_POST['codgrupo']; } if (isset($_POST['tipo_comprobante'])) { $continue = TRUE; $tipo_comprobante = \filter_input(INPUT_POST, 'tipo_comprobante'); if ($tipo_comprobante == '01' and strlen($this->cliente->cifnif) < 9) { $this->new_error_msg("¡Imposible actualizar información de NCF para el cliente, por favor corrija primero la Cédula o RNC asignados!"); } else { $ncf_entidad_tipo = new ncf_entidad_tipo(); $ncf_entidad_tipo->idempresa = $this->empresa->id; $ncf_entidad_tipo->entidad = \filter_input(INPUT_POST, 'codcliente'); $ncf_entidad_tipo->tipo_entidad = 'CLI'; $ncf_entidad_tipo->tipo_comprobante = $tipo_comprobante; $ncf_entidad_tipo->usuario_creacion = $this->user->nick; $ncf_entidad_tipo->fecha_creacion = \Date('d-m-Y H:i:s'); $ncf_entidad_tipo->usuario_modificacion = $this->user->nick; $ncf_entidad_tipo->fecha_modificacion = \Date('d-m-Y H:i:s'); $ncf_entidad_tipo->estado = TRUE; if (!$ncf_entidad_tipo->save()) { $this->new_error_msg("¡Imposible actualizar información de NCF para Cliente " . $ncf_entidad_tipo->entidad . "!"); } else { $this->ncf_cliente_tipo = $this->ncf_entidad_tipo->get($this->empresa->id, \filter_input(INPUT_POST, 'codcliente'), 'CLI'); } } } if ($this->cliente->save()) { $this->new_message("Datos del cliente modificados correctamente."); $this->propagar_cifnif(); } else { $this->new_error_msg("¡Imposible modificar los datos del cliente!"); } } } } } } } else { $this->new_error_msg("¡Cliente no encontrado!", 'error', FALSE, FALSE); } }
public function nuevo_cliente() { //---------------------------------------------- // agrega un cliente nuevo y retorna el id //---------------------------------------------- if (isset($_POST['nombre'])) { $cliente = new cliente(); $cliente->codcliente = $cliente->get_new_codigo(); $this->codcliente = $cliente->codcliente; $cliente->nombre = $_POST['nombre']; $this->nomcliente = $cliente->nombre; $cliente->nombrecomercial = $_POST['nombre']; $cliente->telefono1 = $_POST['telefono']; $cliente->cifnif = $_POST['cifnif']; $cliente->save(); $dir = new direccion_cliente(); $dir->ciudad = $_POST['ciudad']; $dir->codcliente = $cliente->codcliente; $dir->codpais = $_POST['pais']; $dir->codpostal = $_POST['codpostal']; $dir->direccion = $_POST['direccion']; $dir->domenvio = 1; $dir->domfacturacion = 1; $dir->descripcion = "Principal"; $dir->provincia = $_POST['provincia']; $dir->save(); } return $cliente->codcliente; }
protected function private_core() { $this->listado = FALSE; $this->ppage = $this->page->get('listado_clientes'); // $this->agente = new agente(); // $this->cuenta_banco = new cuenta_banco_cliente(); // $this->divisa = new divisa(); // $this->forma_pago = new forma_pago(); // $this->grupo = new grupo_clientes(); // $this->pais = new pais(); // $this->serie = new serie(); $this->maquinas = new maquinas(); if (isset($_GET['id_aviso'])) { $this->page = "index.php?page=editar_maquina&cod=" . $this->{$_GET}['id_aviso']; } if (isset($_POST['numero_serie'])) { ///Nueva maquina if ($_POST['contrato']) { $contratada = "Si"; } else { $contratada = "No"; } if ($_POST['alquilada']) { $alquiler = "Si"; } else { $alquiler = "No"; } $this->maquinas->ubicacion = $_POST['ubicacion']; $this->maquinas->codcliente = $_POST['codcliente']; $this->maquinas->nombre_cliente = $_POST['nombrecliente']; $this->maquinas->equipo = $_POST['equipo']; $this->maquinas->marca = $_POST['marca']; $this->maquinas->modelo = $_POST['modelo']; $this->maquinas->contrato = $contratada; $this->maquinas->alquilada = $alquiler; $this->maquinas->numero_serie = $_POST['numero_serie']; $this->maquinas->contacto = $_POST['contacto']; $this->maquinas->costo_copia_negro = $_POST['costo_copia_negro']; $this->maquinas->costo_copia_color = $_POST['costo_copia_color']; $this->maquinas->notas = $_POST['notas']; if ($this->maquinas->save()) { $this->new_message('Datos guardados correctamante'); } else { $this->new_error_msg('Error al Guardar'); } } $this->listado = $this->maquinas->get_maquina_cliente($_GET['cod']); /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); /// cargamos el cliente $cliente = new cliente(); $this->cliente = FALSE; if (isset($_POST['codcliente'])) { $this->cliente = $cliente->get($_POST['codcliente']); } else { if (isset($_GET['cod'])) { $this->cliente = $cliente->get($_GET['cod']); } } /// ¿Hay que hacer algo más? if (isset($_GET['delete_cuenta'])) { $cuenta = $this->cuenta_banco->get($_GET['delete_cuenta']); if ($cuenta) { if ($cuenta->delete()) { $this->new_message('Cuenta bancaria eliminada correctamente.'); } else { $this->new_error_msg('Imposible eliminar la cuenta bancaria.'); } } else { $this->new_error_msg('Cuenta bancaria no encontrada.'); } } else { if (isset($_GET['delete_dir'])) { $dir = new direccion_cliente(); $dir0 = $dir->get($_GET['delete_dir']); if ($dir0) { if ($dir0->delete()) { $this->new_message('Dirección eliminada correctamente.'); } else { $this->new_error_msg('Imposible eliminar la dirección.'); } } else { $this->new_error_msg('Dirección no encontrada.'); } } else { if (isset($_POST['coddir'])) { $dir = new direccion_cliente(); if ($_POST['coddir'] != '') { $dir = $dir->get($_POST['coddir']); } $dir->apartado = $_POST['apartado']; $dir->ciudad = $_POST['ciudad']; $dir->codcliente = $this->cliente->codcliente; $dir->codpais = $_POST['pais']; $dir->codpostal = $_POST['codpostal']; $dir->descripcion = $_POST['descripcion']; $dir->direccion = $_POST['direccion']; $dir->domenvio = isset($_POST['direnvio']); $dir->domfacturacion = isset($_POST['dirfact']); $dir->provincia = $_POST['provincia']; if ($dir->save()) { $this->new_message("Dirección guardada correctamente."); } else { $this->new_message("¡Imposible guardar la dirección!"); } } } } /* else if( isset($_POST['iban']) ) /// añadir/modificar dirección { if( isset($_POST['codcuenta']) ) { $cuentab = $this->cuenta_banco->get($_POST['codcuenta']); } else { $cuentab = new cuenta_banco_cliente(); $cuentab->codcliente = $_POST['codcliente']; } $cuentab->descripcion = $_POST['descripcion']; $cuentab->iban = $_POST['iban']; $cuentab->swift = $_POST['swift']; $cuentab->principal = isset($_POST['principal']); if( $cuentab->save() ) { $this->new_message('Cuenta bancaria guardada correctamente.'); } else $this->new_error_msg('Imposible guardar la cuenta bancaria.'); } else if( isset($_POST['codcliente']) ) /// modificar cliente { $this->cliente->nombre = $_POST['nombre']; $this->cliente->razonsocial = $_POST['razonsocial']; $this->cliente->cifnif = $_POST['cifnif']; $this->cliente->telefono1 = $_POST['telefono1']; $this->cliente->telefono2 = $_POST['telefono2']; $this->cliente->fax = $_POST['fax']; $this->cliente->web = $_POST['web']; $this->cliente->email = $_POST['email']; $this->cliente->observaciones = $_POST['observaciones']; $this->cliente->codserie = $_POST['codserie']; $this->cliente->codpago = $_POST['codpago']; $this->cliente->coddivisa = $_POST['coddivisa']; $this->cliente->regimeniva = $_POST['regimeniva']; $this->cliente->recargo = isset($_POST['recargo']); $this->cliente->debaja = isset($_POST['debaja']); $this->cliente->codagente = NULL; if($_POST['codagente'] != '---') { $this->cliente->codagente = $_POST['codagente']; } $this->cliente->codgrupo = NULL; if($_POST['codgrupo'] != '---') { $this->cliente->codgrupo = $_POST['codgrupo']; } if( $this->cliente->save() ) { $this->new_message("Datos del cliente modificados correctamente."); } else $this->new_error_msg("¡Imposible modificar los datos del cliente!"); }*/ if ($this->cliente) { $this->page->title = $this->cliente->codcliente; } else { $this->new_error_msg("¡Cliente no encontrado!"); } }
protected function private_core() { $this->agente = FALSE; $this->almacen = new almacen(); $this->cliente = new cliente(); $this->cliente_s = FALSE; $this->descripcion = NULL; $this->direccion = FALSE; $this->divisa = new divisa(); $this->estado = new estado_servicio(); $this->fabricante = new fabricante(); $this->familia = new familia(); $this->forma_pago = new forma_pago(); $this->grupo = new grupo_clientes(); $this->impuesto = new impuesto(); $this->pais = new pais(); $this->prioridad = 3; $this->results = array(); $this->serie = new serie(); $this->servicio = new servicio_cliente(); $this->solucion = NULL; /// cargamos la configuración de servicios $fsvar = new fs_var(); $this->setup = $fsvar->array_get(array('servicios_diasfin' => 10, 'servicios_material' => 0, 'servicios_mostrar_material' => 0, 'servicios_material_estado' => 0, 'servicios_mostrar_material_estado' => 0, 'servicios_accesorios' => 0, 'servicios_mostrar_accesorios' => 0, 'servicios_descripcion' => 0, 'servicios_mostrar_descripcion' => 0, 'servicios_solucion' => 0, 'servicios_mostrar_solucion' => 0, 'servicios_fechafin' => 0, 'servicios_mostrar_fechafin' => 0, 'servicios_fechainicio' => 0, 'servicios_mostrar_fechainicio' => 0, 'servicios_mostrar_garantia' => 0, 'servicios_garantia' => 0, 'cal_inicio' => "09:00", 'cal_fin' => "20:00", 'cal_intervalo' => "30", 'st_servicio' => "Servicio", 'st_servicios' => "Servicios", 'st_material' => "Material", 'st_material_estado' => "Estado del material entregado", 'st_accesorios' => "Accesorios que entrega", 'st_descripcion' => "Descripción de la averia", 'st_solucion' => "Solución", 'st_fechainicio' => "Fecha de Inicio", 'st_fechafin' => "Fecha de finalización", 'st_garantia' => "Garantía", 'nuevocli_cifnif_req' => 0, 'nuevocli_direccion' => 0, 'nuevocli_direccion_req' => 0, 'nuevocli_codpostal' => 0, 'nuevocli_codpostal_req' => 0, 'nuevocli_pais' => 0, 'nuevocli_pais_req' => 0, 'nuevocli_provincia' => 0, 'nuevocli_provincia_req' => 0, 'nuevocli_ciudad' => 0, 'nuevocli_ciudad_req' => 0, 'nuevocli_telefono1' => 0, 'nuevocli_telefono1_req' => 0, 'nuevocli_telefono2' => 0, 'nuevocli_telefono2_req' => 0, 'nuevocli_codgrupo' => ''), FALSE); if (isset($_REQUEST['buscar_cliente'])) { $this->buscar_cliente(); } else { if (isset($_REQUEST['datoscliente'])) { $this->datos_cliente(); } else { if (isset($_REQUEST['new_articulo'])) { $this->new_articulo(); } else { if ($this->query != '') { $this->new_search(); } else { if (isset($_POST['referencia4precios'])) { $this->get_precios_articulo(); } else { if (isset($_POST['cliente'])) { $this->cliente_s = $this->cliente->get($_POST['cliente']); /** * Nuevo cliente */ if (isset($_POST['nuevo_cliente'])) { if ($_POST['nuevo_cliente'] != '') { $this->cliente_s = FALSE; if ($_POST['nuevo_cifnif'] != '') { $this->cliente_s = $this->cliente->get_by_cifnif($_POST['nuevo_cifnif']); if ($this->cliente_s) { $this->new_advice('Ya existe un cliente con ese ' . FS_CIFNIF . '. Se ha seleccionado.'); } } if (!$this->cliente_s) { $this->cliente_s = new cliente(); $this->cliente_s->codcliente = $this->cliente_s->get_new_codigo(); $this->cliente_s->nombre = $this->cliente_s->razonsocial = $_POST['nuevo_cliente']; $this->cliente_s->tipoidfiscal = $_POST['nuevo_tipoidfiscal']; $this->cliente_s->cifnif = $_POST['nuevo_cifnif']; $this->cliente_s->personafisica = isset($_POST['personafisica']); if (isset($_POST['nuevo_grupo'])) { if ($_POST['nuevo_grupo'] != '') { $this->cliente_s->codgrupo = $_POST['nuevo_grupo']; } } if (isset($_POST['nuevo_telefono1'])) { $this->cliente_s->telefono1 = $_POST['nuevo_telefono1']; } if (isset($_POST['nuevo_telefono2'])) { $this->cliente_s->telefono2 = $_POST['nuevo_telefono2']; } if ($this->cliente_s->save()) { if ($this->empresa->contintegrada) { /// forzamos crear la subcuenta $this->cliente_s->get_subcuenta($this->empresa->codejercicio); } $dircliente = new direccion_cliente(); $dircliente->codcliente = $this->cliente_s->codcliente; $dircliente->codpais = $this->empresa->codpais; $dircliente->provincia = $this->empresa->provincia; $dircliente->ciudad = $this->empresa->ciudad; if (isset($_POST['nuevo_pais'])) { $dircliente->codpais = $_POST['nuevo_pais']; } if (isset($_POST['nuevo_provincia'])) { $dircliente->provincia = $_POST['nuevo_provincia']; } if (isset($_POST['nuevo_ciudad'])) { $dircliente->ciudad = $_POST['nuevo_ciudad']; } if (isset($_POST['nuevo_codpostal'])) { $dircliente->codpostal = $_POST['nuevo_codpostal']; } if (isset($_POST['nuevo_direccion'])) { $dircliente->direccion = $_POST['nuevo_direccion']; } if ($dircliente->save()) { $this->new_message('Cliente agregado correctamente.'); } } else { $this->new_error_msg("¡Imposible guardar la dirección del cliente!"); } } } } if ($this->cliente_s) { foreach ($this->cliente_s->get_direcciones() as $dir) { if ($dir->domfacturacion) { $this->direccion = $dir; break; } } } if (isset($_POST['codagente'])) { $agente = new agente(); $this->agente = $agente->get($_POST['codagente']); } else { $this->agente = $this->user->get_agente(); } if (isset($_POST['numlineas'])) { $this->nuevo_servicio_cliente(); if (!$this->direccion) { $this->direccion = new direccion_cliente(); $this->direccion->codcliente = $this->cliente_s->codcliente; $this->direccion->codpais = $_POST['codpais']; $this->direccion->provincia = $_POST['provincia']; $this->direccion->ciudad = $_POST['ciudad']; $this->direccion->codpostal = $_POST['codpostal']; $this->direccion->direccion = $_POST['direccion']; $this->direccion->descripcion = 'Principal'; $this->direccion->save(); } } } } } } } } }
protected function private_core() { $this->cliente = new cliente(); $this->cliente_s = FALSE; $this->direccion = FALSE; $this->fabricante = new fabricante(); $this->familia = new familia(); $this->impuesto = new impuesto(); $this->results = array(); $this->grupo = new grupo_clientes(); $this->pais = new pais(); /// cargamos la configuración $fsvar = new fs_var(); $this->nuevocli_setup = $fsvar->array_get(array('nuevocli_cifnif_req' => 0, 'nuevocli_direccion' => 0, 'nuevocli_direccion_req' => 0, 'nuevocli_codpostal' => 0, 'nuevocli_codpostal_req' => 0, 'nuevocli_pais' => 0, 'nuevocli_pais_req' => 0, 'nuevocli_provincia' => 0, 'nuevocli_provincia_req' => 0, 'nuevocli_ciudad' => 0, 'nuevocli_ciudad_req' => 0, 'nuevocli_telefono1' => 0, 'nuevocli_telefono1_req' => 0, 'nuevocli_telefono2' => 0, 'nuevocli_telefono2_req' => 0, 'nuevocli_codgrupo' => ''), FALSE); if (isset($_REQUEST['tipo'])) { $this->tipo = $_REQUEST['tipo']; } else { foreach ($this->tipos_a_guardar() as $t) { $this->tipo = $t['tipo']; break; } } if (isset($_REQUEST['buscar_cliente'])) { $this->buscar_cliente(); } else { if (isset($_REQUEST['datoscliente'])) { $this->datos_cliente(); } else { if (isset($_REQUEST['new_articulo'])) { $this->new_articulo(); } else { if ($this->query != '') { $this->new_search(); } else { if (isset($_POST['referencia4precios'])) { $this->get_precios_articulo(); } else { if (isset($_POST['cliente'])) { $this->cliente_s = $this->cliente->get($_POST['cliente']); /** * Nuevo cliente */ if (isset($_POST['nuevo_cliente'])) { if ($_POST['nuevo_cliente'] != '') { $this->cliente_s = FALSE; if ($_POST['nuevo_cifnif'] != '') { $this->cliente_s = $this->cliente->get_by_cifnif($_POST['nuevo_cifnif']); if ($this->cliente_s) { $this->new_advice('Ya existe un cliente con ese ' . FS_CIFNIF . '. Se ha seleccionado.'); } } if (!$this->cliente_s) { $this->cliente_s = new cliente(); $this->cliente_s->codcliente = $this->cliente_s->get_new_codigo(); $this->cliente_s->nombre = $this->cliente_s->razonsocial = $_POST['nuevo_cliente']; $this->cliente_s->cifnif = $_POST['nuevo_cifnif']; if (isset($_POST['codgrupo'])) { if ($_POST['codgrupo'] != '') { $this->cliente_s->codgrupo = $_POST['codgrupo']; } } if (isset($_POST['nuevo_telefono1'])) { $this->cliente_s->telefono1 = $_POST['nuevo_telefono1']; } if (isset($_POST['nuevo_telefono2'])) { $this->cliente_s->telefono2 = $_POST['nuevo_telefono2']; } if ($this->cliente_s->save()) { $dircliente = new direccion_cliente(); $dircliente->codcliente = $this->cliente_s->codcliente; $dircliente->codpais = $this->empresa->codpais; $dircliente->provincia = $this->empresa->provincia; $dircliente->ciudad = $this->empresa->ciudad; $dircliente->descripcion = 'Principal'; if (isset($_POST['nuevo_pais'])) { $dircliente->codpais = $_POST['nuevo_pais']; } if (isset($_POST['nuevo_provincia'])) { $dircliente->provincia = $_POST['nuevo_provincia']; } if (isset($_POST['nuevo_ciudad'])) { $dircliente->ciudad = $_POST['nuevo_ciudad']; } if (isset($_POST['nuevo_codpostal'])) { $dircliente->codpostal = $_POST['nuevo_codpostal']; } if (isset($_POST['nuevo_direccion'])) { $dircliente->direccion = $_POST['nuevo_direccion']; } if ($dircliente->save()) { $this->new_message('Cliente agregado correctamente.'); } } else { $this->new_error_msg("¡Imposible guardar la dirección del cliente!"); } } } } if ($this->cliente_s) { foreach ($this->cliente_s->get_direcciones() as $dir) { if ($dir->domfacturacion) { $this->direccion = $dir; break; } } } if (isset($_POST['codagente'])) { $agente = new agente(); $this->agente = $agente->get($_POST['codagente']); } else { $this->agente = $this->user->get_agente(); } $this->almacen = new almacen(); $this->serie = new serie(); $this->forma_pago = new forma_pago(); $this->divisa = new divisa(); if (isset($_POST['tipo'])) { if ($_POST['tipo'] == 'albaran') { $this->nuevo_albaran_cliente(); } else { if ($_POST['tipo'] == 'factura') { $this->nueva_factura_cliente(); } else { if ($_POST['tipo'] == 'presupuesto' and class_exists('presupuesto_cliente')) { $this->nuevo_presupuesto_cliente(); } else { if ($_POST['tipo'] == 'pedido' and class_exists('pedido_cliente')) { $this->nuevo_pedido_cliente(); } } } } if (!$this->direccion) { $this->direccion = new direccion_cliente(); $this->direccion->codcliente = $this->cliente_s->codcliente; $this->direccion->codpais = $_POST['codpais']; $this->direccion->provincia = $_POST['provincia']; $this->direccion->ciudad = $_POST['ciudad']; $this->direccion->codpostal = $_POST['codpostal']; $this->direccion->direccion = $_POST['direccion']; $this->direccion->descripcion = 'Principal'; $this->direccion->save(); } } } } } } } } }
protected function private_core() { $this->agencia = new agencia_transporte(); $this->cliente = new cliente(); $this->cliente_s = FALSE; $this->direccion = FALSE; $this->fabricante = new fabricante(); $this->familia = new familia(); $this->impuesto = new impuesto(); $this->results = array(); $this->grupo = new grupo_clientes(); $this->pais = new pais(); $this->ncf_tipo = new ncf_tipo(); $this->ncf_rango = new ncf_rango(); $this->ncf_entidad_tipo = new ncf_entidad_tipo(); $this->ncf_ventas = new ncf_ventas(); /// cargamos la configuración $fsvar = new fs_var(); $this->nuevocli_setup = $fsvar->array_get(array('nuevocli_cifnif_req' => 0, 'nuevocli_direccion' => 0, 'nuevocli_direccion_req' => 0, 'nuevocli_codpostal' => 0, 'nuevocli_codpostal_req' => 0, 'nuevocli_pais' => 0, 'nuevocli_pais_req' => 0, 'nuevocli_provincia' => 0, 'nuevocli_provincia_req' => 0, 'nuevocli_ciudad' => 0, 'nuevocli_ciudad_req' => 0, 'nuevocli_telefono1' => 0, 'nuevocli_telefono1_req' => 0, 'nuevocli_telefono2' => 0, 'nuevocli_telefono2_req' => 0, 'nuevocli_codgrupo' => ''), FALSE); if (isset($_REQUEST['tipo'])) { $this->tipo = $_REQUEST['tipo']; } else { foreach ($this->tipos_a_guardar() as $t) { $this->tipo = $t['tipo']; break; } } if (isset($_REQUEST['buscar_cliente'])) { $this->buscar_cliente(); } else { if (isset($_REQUEST['datoscliente'])) { $this->datos_cliente(); } else { if (isset($_REQUEST['new_articulo'])) { $this->new_articulo(); } else { if ($this->query != '') { $this->new_search(); } else { if (isset($_POST['referencia4precios'])) { $this->get_precios_articulo(); } else { if (isset($_POST['referencia4combi'])) { $this->get_combinaciones_articulo(); } else { if (isset($_POST['cliente'])) { $this->cliente_s = $this->cliente->get($_POST['cliente']); /** * Nuevo cliente */ if (isset($_POST['nuevo_cliente'])) { if ($_POST['nuevo_cliente'] != '') { $this->cliente_s = FALSE; if ($_POST['nuevo_cifnif'] != '') { $this->cliente_s = $this->cliente->get_by_cifnif($_POST['nuevo_cifnif']); if ($this->cliente_s) { $this->new_advice('Ya existe un cliente con ese ' . FS_CIFNIF . '. Se ha seleccionado.'); } } if (!$this->cliente_s) { $this->cliente_s = new cliente(); $this->cliente_s->codcliente = $this->cliente_s->get_new_codigo(); $this->cliente_s->nombre = $this->cliente_s->razonsocial = $_POST['nuevo_cliente']; $this->cliente_s->tipoidfiscal = $_POST['nuevo_tipoidfiscal']; $this->cliente_s->cifnif = $_POST['nuevo_cifnif']; $this->cliente_s->personafisica = isset($_POST['personafisica']); if (isset($_POST['codgrupo'])) { if ($_POST['codgrupo'] != '') { $this->cliente_s->codgrupo = $_POST['codgrupo']; } } if (isset($_POST['nuevo_telefono1'])) { $this->cliente_s->telefono1 = $_POST['nuevo_telefono1']; } if (isset($_POST['nuevo_telefono2'])) { $this->cliente_s->telefono2 = $_POST['nuevo_telefono2']; } if ($this->cliente_s->save()) { if (isset($_POST['tipo_comprobante'])) { $ncf_entidad_tipo = new ncf_entidad_tipo(); $ncf_entidad_tipo->idempresa = $this->empresa->id; $ncf_entidad_tipo->entidad = $this->cliente_s->codcliente; $ncf_entidad_tipo->tipo_entidad = 'CLI'; $ncf_entidad_tipo->tipo_comprobante = \filter_input(INPUT_POST, 'tipo_comprobante'); $ncf_entidad_tipo->usuario_creacion = $this->user->nick; $ncf_entidad_tipo->fecha_creacion = \Date('d-m-Y H:i:s'); $ncf_entidad_tipo->usuario_modificacion = $this->user->nick; $ncf_entidad_tipo->fecha_modificacion = \Date('d-m-Y H:i:s'); $ncf_entidad_tipo->estado = TRUE; if (!$ncf_entidad_tipo->save()) { $this->new_error_msg("¡Imposible actualizar información de NCF para Cliente " . $ncf_entidad_tipo->entidad . "!"); } else { $this->ncf_cliente_tipo = $this->ncf_entidad_tipo->get($this->empresa->id, $this->cliente_s->codcliente, 'CLI'); } } if ($this->empresa->contintegrada) { /// forzamos crear la subcuenta $this->cliente_s->get_subcuenta($this->empresa->codejercicio); } $dircliente = new direccion_cliente(); $dircliente->codcliente = $this->cliente_s->codcliente; $dircliente->codpais = $this->empresa->codpais; $dircliente->provincia = $this->empresa->provincia; $dircliente->ciudad = $this->empresa->ciudad; if (isset($_POST['nuevo_pais'])) { $dircliente->codpais = $_POST['nuevo_pais']; } if (isset($_POST['nuevo_provincia'])) { $dircliente->provincia = $_POST['nuevo_provincia']; } if (isset($_POST['nuevo_ciudad'])) { $dircliente->ciudad = $_POST['nuevo_ciudad']; } if (isset($_POST['nuevo_codpostal'])) { $dircliente->codpostal = $_POST['nuevo_codpostal']; } if (isset($_POST['nuevo_direccion'])) { $dircliente->direccion = $_POST['nuevo_direccion']; } if ($dircliente->save()) { $this->new_message('Cliente agregado correctamente.'); } } else { $this->new_error_msg("¡Imposible guardar la dirección del cliente!"); } } } } if ($this->cliente_s) { foreach ($this->cliente_s->get_direcciones() as $dir) { if ($dir->domfacturacion) { $this->direccion = $dir; break; } } } if (isset($_POST['codagente'])) { $agente = new agente(); $this->agente = $agente->get($_POST['codagente']); } else { $this->agente = $this->user->get_agente(); } $this->almacen = new almacen(); $this->serie = new serie(); $this->forma_pago = new forma_pago(); $this->divisa = new divisa(); if (isset($_POST['tipo'])) { if ($_POST['tipo'] == 'albaran') { $this->nuevo_albaran_cliente(); } else { if ($_POST['tipo'] == 'factura') { $this->nueva_factura_cliente(); } else { if ($_POST['tipo'] == 'presupuesto' and class_exists('presupuesto_cliente')) { $this->nuevo_presupuesto_cliente(); } else { if ($_POST['tipo'] == 'pedido' and class_exists('pedido_cliente')) { $this->nuevo_pedido_cliente(); } } } } /// si el cliente no tiene cifnif nos guardamos el que indique if ($this->cliente_s->cifnif == '') { $this->cliente_s->cifnif = $_POST['cifnif']; $this->cliente_s->save(); } /// ¿Guardamos la dirección como nueva? if ($_POST['coddir'] == 'nueva') { $this->direccion = new direccion_cliente(); $this->direccion->codcliente = $this->cliente_s->codcliente; $this->direccion->codpais = $_POST['codpais']; $this->direccion->provincia = $_POST['provincia']; $this->direccion->ciudad = $_POST['ciudad']; $this->direccion->codpostal = $_POST['codpostal']; $this->direccion->direccion = $_POST['direccion']; $this->direccion->apartado = $_POST['apartado']; $this->direccion->save(); } else { if ($_POST['envio_coddir'] == 'nueva') { $this->direccion = new direccion_cliente(); $this->direccion->codcliente = $this->cliente_s->codcliente; $this->direccion->codpais = $_POST['envio_codpais']; $this->direccion->provincia = $_POST['envio_provincia']; $this->direccion->ciudad = $_POST['envio_ciudad']; $this->direccion->codpostal = $_POST['envio_codpostal']; $this->direccion->direccion = $_POST['envio_direccion']; $this->direccion->apartado = $_POST['envio_apartado']; $this->direccion->domfacturacion = FALSE; $this->direccion->domenvio = TRUE; $this->direccion->save(); } } } } } } } } } } }