protected function private_core() { $this->albaran = new albaran_proveedor(); $this->codserie = NULL; $this->forma_pago = new forma_pago(); $this->proveedor = FALSE; $this->serie = new serie(); $factura = new factura_proveedor(); $this->verif_factura = $factura->all(); $this->neto = 0; $this->total = 0; $this->desde = Date('01-m-Y'); $this->hasta = Date('t-m-Y'); if (isset($_REQUEST['buscar_proveedor'])) { $this->buscar_proveedor(); } else { if (isset($_POST['idalbaran'])) { $this->proveedor = new proveedor(); $this->agrupar(); } else { if (isset($_POST['codproveedor'])) { $pr0 = new proveedor(); $this->proveedor = $pr0->get($_REQUEST['codproveedor']); $this->codserie = $_POST['serie']; $this->desde = $_POST['desde']; $this->hasta = $_POST['hasta']; if ($this->proveedor) { $this->resultados = $this->albaran->search_from_proveedor($_POST['codproveedor'], $_POST['desde'], $_POST['hasta'], $_POST['serie']); if ($this->resultados) { foreach ($this->resultados as $alb) { $this->neto += $alb->neto; $this->total += $alb->total; } } else { $this->new_message("Sin resultados."); } } } else { $this->share_extensions(); } } } }
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; }
private function test_models() { $mpp = 100; $last_errores = array(); switch ($this->informe['model']) { default: /// tablas $this->test_tablas(); break; case 'asiento': $asiento = new asiento(); $asientos = $asiento->all($this->informe['offset'], $mpp); 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'] += $mpp; } 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'], $mpp); 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'] += $mpp; } 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'], $mpp); 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'] += $mpp; } 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'], $mpp); 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'] += $mpp; } 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'], $mpp); 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'] += $mpp; } else { $this->informe['model'] = 'fin'; $this->informe['offset'] = 0; } break; case 'fin': break; } return $last_errores; }