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() { /// ¿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 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(); }
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; }
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() { /// 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() { /// ¿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(); }
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() { $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(); }
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 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() { $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(); } } } } } } } } } } }