178 lines
4.5 KiB
PHP
Executable File
178 lines
4.5 KiB
PHP
Executable File
<?php
|
|
|
|
$empresa->AuthUser();
|
|
|
|
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
|
header('Location: '.WEB_ROOT);
|
|
exit;
|
|
}
|
|
|
|
$sucursalId = $_SESSION['idSuc'];
|
|
|
|
//Checamos si hay solicitud de Reporte
|
|
$inventario->setSucursalId($sucursalId);
|
|
$infR = $inventario->InfoInvParcial();
|
|
|
|
if($_POST['type'] == 'sendReport'){
|
|
|
|
$repInvParcialId = $_POST['repInvParcialId'];
|
|
|
|
//Guardamos la identificacion
|
|
|
|
$ruta = DOC_ROOT.'/reportes';
|
|
|
|
// obtenemos los datos del archivo
|
|
$tamano = $_FILES["fileReport"]['size'];
|
|
$tipo = $_FILES["fileReport"]['type'];
|
|
$archivo = $_FILES["fileReport"]['name'];
|
|
|
|
$nom = explode('.',$archivo);
|
|
|
|
$prefijo = substr(md5(uniqid(rand())),0,3);
|
|
$time = time();
|
|
|
|
if($tipo != 'text/plain'){
|
|
|
|
$msgReport = 'typeFail';
|
|
|
|
}elseif($archivo != ""){
|
|
|
|
$fileName = $repInvParcialId.'_'.$time.'.'.$nom[1];
|
|
|
|
$destino = $ruta.'/'.$fileName;
|
|
if (move_uploaded_file($_FILES['fileReport']['tmp_name'],$destino)) {
|
|
|
|
//Actualizamos el status
|
|
|
|
$inventario->setRepInvParcialId($repInvParcialId);
|
|
$inventario->UpdateStatusRepParcial('Generado');
|
|
$inventario->UpdateFileRepParcial($fileName);
|
|
|
|
//Comparamos los Datos con el Inventario Real y guardamos los datos.
|
|
|
|
$fp = fopen(DOC_ROOT.'/reportes/'.$fileName,'r') or die('No se pudo abrir el archivo');
|
|
|
|
while(!feof($fp)){
|
|
|
|
$linea = fgets($fp);
|
|
$inv = preg_split('/\s+/', $linea);
|
|
|
|
if($inv[0] != ''){
|
|
|
|
$cantidad = $inv[1];
|
|
|
|
$producto->setCodigoBarra($inv[0]);
|
|
$productoId = $producto->GetProductIdByCodigo();
|
|
|
|
if($productoId){
|
|
|
|
$inventario->setProductoId($productoId);
|
|
$inventario->setSucursalId($sucursalId);
|
|
$cantReal = $inventario->GetTotalItemsBySuc();
|
|
|
|
$inventario->setRepInvParcialId($repInvParcialId);
|
|
$inventario->setProductoId($productoId);
|
|
$inventario->setCantidad($cantidad);
|
|
$inventario->setCantReal($cantReal);
|
|
$inventario->SaveRepProd();
|
|
}
|
|
|
|
}//if
|
|
|
|
}//while
|
|
|
|
$msgReport = 'success';
|
|
|
|
}//if
|
|
|
|
}//if
|
|
|
|
}else{
|
|
|
|
$inventario->SetPage($_GET["p"]);
|
|
$inventario->setSucursalId($sucursalId);
|
|
|
|
if($infR['repInvParcialId'])
|
|
$productos = $inventario->EnumDisponibleByRand();
|
|
else
|
|
$productos = $inventario->EnumDisponible();
|
|
|
|
$items = array();
|
|
foreach($productos['items'] as $res){
|
|
|
|
$proveedor->setProveedorId($res['proveedorId']);
|
|
$res['proveedor'] = $proveedor->GetNameById();
|
|
|
|
$producto->setProductoId($res['productoId']);
|
|
$resTallas = $producto->GetTallas();
|
|
|
|
$tallas = array();
|
|
foreach($resTallas as $val){
|
|
$atribVal->setAtribValId($val['tallaId']);
|
|
$tallas[] = $atribVal->GetNameById();
|
|
}
|
|
|
|
$res['talla'] = implode(', ',$tallas);
|
|
|
|
$producto->setProductoId($res['productoId']);
|
|
$resColores = $producto->GetColores();
|
|
|
|
$colores = array();
|
|
foreach($resColores as $val){
|
|
$atribVal->setAtribValId($val['colorId']);
|
|
$colores[] = $atribVal->GetNameById();
|
|
}
|
|
|
|
$res['color'] = implode(', ',$colores);
|
|
|
|
$producto->setProductoId($res['productoId']);
|
|
$resAtributos = $producto->GetAtributos();
|
|
|
|
$atributos = array();
|
|
foreach($resAtributos as $val){
|
|
$atribVal->setAtribValId($val['atribValId']);
|
|
$atributos[] = $atribVal->GetNameById();
|
|
}
|
|
|
|
$res['atributos'] = implode(', ',$atributos);
|
|
|
|
//Obtenemos los Codigos de Barra
|
|
$inventario->setProductoId($res['productoId']);
|
|
$inventario->setSucursalId($sucursalId);
|
|
$res['cantidad'] = $inventario->GetTotalItemsBySuc();
|
|
|
|
$items[] = $res;
|
|
}
|
|
$productos['items'] = $items;
|
|
|
|
|
|
$msg = $_SESSION['msgI'];
|
|
$_SESSION['msgI'] = '';
|
|
|
|
$sucursal->setSucursalId($sucursalId);
|
|
$nomSuc = utf8_decode(urldecode($sucursal->GetNameById()));
|
|
|
|
$proveedores = $proveedor->EnumerateAll();
|
|
$categorias = $prodCat->EnumerateAll();
|
|
|
|
}//else
|
|
|
|
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
|
$resSuc2 = $util->DecodeUrlResult($resSuc);
|
|
$sucursales = $util->DecodeResult($resSuc2);
|
|
|
|
$smarty->assign('msg', $msg);
|
|
$smarty->assign('nomSuc', $nomSuc);
|
|
$smarty->assign('envios', $resEnvios);
|
|
$smarty->assign('sucursales', $sucursales);
|
|
|
|
$smarty->assign('infR', $infR);
|
|
$smarty->assign('msg', $msg);
|
|
$smarty->assign('msgReport', $msgReport);
|
|
$smarty->assign('nomSuc', $nomSuc);
|
|
$smarty->assign('productos', $productos);
|
|
$smarty->assign('proveedores', $proveedores);
|
|
$smarty->assign('categorias', $categorias);
|
|
|
|
|
|
?>
|