mirror of
https://github.com/rmontanana/inventario2.git
synced 2025-08-17 16:35:58 +00:00
ref# 3 #6 Terminada la importación de datos
This commit is contained in:
27
Csv.php
27
Csv.php
@@ -226,22 +226,29 @@ class Csv {
|
|||||||
return $mensaje;
|
return $mensaje;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function escribeFic($comando) {
|
private function escribeLog($comando) {
|
||||||
$fp = fopen("tmp/comandos", "a");
|
$fp = fopen($this->nombre.".log", "a");
|
||||||
fputs($fp, $comando . "\n");
|
$linea = strftime("%Y/%m/%d")."|".$this->nombre."|".$comando;
|
||||||
|
fputs($fp, $linea . "\n");
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function bajaElemento($i) {
|
private function bajaElemento($i) {
|
||||||
$id = $this->datosFichero[$i][$this->idElemento];
|
$id = $this->datosFichero[$i][$this->idElemento];
|
||||||
$comando = 'delete from Elementos where id="' . $id . '";';
|
$comando = 'delete from Elementos where id="' . $id . '";';
|
||||||
$this->escribeFic($comando);
|
$this->escribeLog($comando);
|
||||||
|
if (!$this->bdd->ejecuta($comando)) {
|
||||||
|
throw new Exception("Baja-".$this->bdd->mensajeError, $this->bdd->error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function modificaElemento($i) {
|
private function modificaElemento($i) {
|
||||||
$id = $this->datosFichero[$i][$this->idElemento];
|
$id = $this->datosFichero[$i][$this->idElemento];
|
||||||
$comando = 'update Elementos set Cantidad=' . $this->datosFichero[$i][$this->cantidadReal] . ' where id="' . $id . '";';
|
$comando = 'update Elementos set Cantidad=' . $this->datosFichero[$i][$this->cantidadReal] . ' where id="' . $id . '";';
|
||||||
$this->escribeFic($comando);
|
$this->escribeLog($comando);
|
||||||
|
if (!$this->bdd->ejecuta($comando)) {
|
||||||
|
throw new Exception("Modifica-".$this->bdd->mensajeError, $this->bdd->error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function altaElemento($i) {
|
private function altaElemento($i) {
|
||||||
@@ -256,7 +263,10 @@ class Csv {
|
|||||||
$idArt = $datosFichero[$i];
|
$idArt = $datosFichero[$i];
|
||||||
$comando = 'insert into Elementos () values (null,' . $idArticulo . ',' . $idUbicacion . ',"' . $this->datosFichero[$i][$this->nSerie];
|
$comando = 'insert into Elementos () values (null,' . $idArticulo . ',' . $idUbicacion . ',"' . $this->datosFichero[$i][$this->nSerie];
|
||||||
$comando .= '",' . $this->datosFichero[$i][$this->cantidadReal] . ',"' . $this->datosFichero[$i][$this->fechaCompra] . '");';
|
$comando .= '",' . $this->datosFichero[$i][$this->cantidadReal] . ',"' . $this->datosFichero[$i][$this->fechaCompra] . '");';
|
||||||
$this->escribeFic($comando);
|
$this->escribeLog($comando);
|
||||||
|
if (!$this->bdd->ejecuta($comando)) {
|
||||||
|
throw new Exception("Alta-".$this->bdd->mensajeError, $this->bdd->error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function cargaIndices($campos) {
|
private function cargaIndices($campos) {
|
||||||
@@ -278,8 +288,8 @@ class Csv {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->EscribeFic("Cantreal=[$this->cantidadReal] fechacompra=[$this->fechaCompra] ubicacion=[$this->idUbicacion] articulo=[$this->idArticulo]");
|
//$this->EscribeFic("Cantreal=[$this->cantidadReal] fechacompra=[$this->fechaCompra] ubicacion=[$this->idUbicacion] articulo=[$this->idArticulo]");
|
||||||
$this->EscribeFic("idElemento=[$this->idElemento] Cantidad=[$this->cantidad] nserie=[$this->nserie]");
|
//$this->EscribeFic("idElemento=[$this->idElemento] Cantidad=[$this->cantidad] nserie=[$this->nserie]");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -311,6 +321,7 @@ class Csv {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$mensaje = "Se han procesado correctamente $acciones acciones en la Base de Datos.";
|
$mensaje = "Se han procesado correctamente $acciones acciones en la Base de Datos.";
|
||||||
|
$this->bdd->confirmaTransaccion();
|
||||||
return $this->panelMensaje($mensaje,"success", "Información");
|
return $this->panelMensaje($mensaje,"success", "Información");
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->bdd->abortaTransaccion();
|
$this->bdd->abortaTransaccion();
|
||||||
|
Reference in New Issue
Block a user