280 lines
7.6 KiB
PHP
Executable File
280 lines
7.6 KiB
PHP
Executable File
<?php
|
|
|
|
include_once('../init.php');
|
|
include_once('../config.php');
|
|
include_once(DOC_ROOT.'/libraries.php');
|
|
|
|
session_start();
|
|
|
|
$sucursalId = $_SESSION['idSuc'];
|
|
|
|
$Usr = $user->Info();
|
|
$smarty->assign('Usr', $Usr);
|
|
|
|
if(isset($_POST['action']))
|
|
$_POST['type'] = $_POST['action'];
|
|
|
|
switch($_POST["type"]){
|
|
|
|
case 'search':
|
|
|
|
$disponible = $_POST['disponible2'];
|
|
|
|
$sucursalId = $_SESSION['idSuc'];
|
|
$inventario->setProveedorId($_POST['proveedorId2']);
|
|
$inventario->setProdCatId($_POST['prodCatId2']);
|
|
$inventario->setProdSubcatId($_POST['prodSubcatId2']);
|
|
$inventario->setModelo($_POST['modelo2']);
|
|
|
|
if($Usr['type'] == 'almacen' || $Usr['type'] == 'centralizador')
|
|
$sucursalId = $_POST['sucursalId'];
|
|
|
|
$resProds = $inventario->Search();
|
|
|
|
$items = array();
|
|
foreach($resProds 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();
|
|
|
|
if($disponible == 1 && $res['cantidad'] > 0)
|
|
$items[] = $util->EncodeRow($res);
|
|
elseif($disponible == 0)
|
|
$items[] = $util->EncodeRow($res);
|
|
|
|
}//foreach
|
|
|
|
/*
|
|
if($Usr['type'] == 'almacen'){
|
|
$items2 = $items;
|
|
$items = array();
|
|
|
|
foreach($items2 as $key => $resItem){
|
|
if($resItem['cantidad'] != 0)
|
|
$items[$key] = $items2[$key];
|
|
}
|
|
}
|
|
*/
|
|
|
|
$productos['items'] = $items;
|
|
|
|
$smarty->assign('productos', $productos);
|
|
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/lists/inventario.tpl');
|
|
|
|
break;
|
|
|
|
case 'searchBloq':
|
|
|
|
$sucursalId = $_SESSION['idSuc'];
|
|
$inventario->setProveedorId($_POST['proveedorId2']);
|
|
$inventario->setProdCatId($_POST['prodCatId2']);
|
|
$inventario->setProdSubcatId($_POST['prodSubcatId2']);
|
|
$inventario->setModelo($_POST['modelo2']);
|
|
$inventario->setDescripcion($_POST['descripcion2']);
|
|
|
|
$resProds = $inventario->Search();
|
|
|
|
$items = array();
|
|
foreach($resProds as $res){
|
|
|
|
$sql = "SELECT
|
|
SUM(cantidad)
|
|
FROM
|
|
inventario
|
|
WHERE
|
|
sucursalId = '".$sucursalId."'
|
|
AND
|
|
prodItemId = '".$res['productoId']."'
|
|
AND
|
|
status = 'Bloqueado'";
|
|
$util->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$res['cantidad'] = $util->DBSelect($_SESSION["empresaId"])->GetSingle();
|
|
|
|
if($res['cantidad'] == 0)
|
|
continue;
|
|
|
|
$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->GetTotalItemsBloqBySuc();
|
|
*/
|
|
if($res['cantidad'])
|
|
$items[] = $util->EncodeRow($res);
|
|
}
|
|
$productos['items'] = $items;
|
|
|
|
$smarty->assign('tipo', 'Bloqueados');
|
|
$smarty->assign('productos', $productos);
|
|
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/lists/inventario.tpl');
|
|
|
|
break;
|
|
|
|
case 'loadSubcats':
|
|
|
|
$prodSubcat->setProdCatId($_POST['prodCatId']);
|
|
$subcategorias = $prodSubcat->EnumerateAll();
|
|
$subcategorias = $util->EncodeResult($subcategorias);
|
|
|
|
echo 'ok[#]';
|
|
|
|
$smarty->assign('subcategorias', $subcategorias);
|
|
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/lists/enumProdSubcatSearch.tpl');
|
|
|
|
break;
|
|
|
|
case 'fillInfoProd':
|
|
|
|
$producto->setProdItemId($_POST['prodItemId']);
|
|
$info = $producto->GetInfoItemById();
|
|
|
|
$producto->setProductoId($info['productoId']);
|
|
$infP = $producto->Info();
|
|
|
|
echo 'ok[#]';
|
|
echo $info['prodItemId'];
|
|
echo '[#]';
|
|
echo $infP['precioVenta'];
|
|
echo '[#]';
|
|
echo $infP['modelo'].' '.$infP['descripcion'];
|
|
|
|
break;
|
|
|
|
case 'sendReportParcial':
|
|
|
|
$repInvParcialId = $_POST['repInvParcialId'];
|
|
$cantidades = $_POST['cant'];
|
|
|
|
foreach($cantidades as $productoId => $valor){
|
|
|
|
if($valor == ''){
|
|
$util->setError(10050,'error');
|
|
$util->PrintErrors();
|
|
echo 'fail[#]';
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
|
|
exit;
|
|
}
|
|
|
|
}//foreach
|
|
|
|
foreach($cantidades as $productoId => $valor){
|
|
|
|
$inventario->setProductoId($productoId);
|
|
$inventario->setSucursalId($sucursalId);
|
|
$cantReal = $inventario->GetTotalItemsBySuc();
|
|
|
|
$inventario->setRepInvParcialId($repInvParcialId);
|
|
$inventario->setProductoId($productoId);
|
|
$inventario->setCantidad($valor);
|
|
$inventario->setCantReal($cantReal);
|
|
$inventario->SaveRepProd();
|
|
|
|
}//foreach
|
|
|
|
//Actualizamos el status
|
|
$inventario->setRepInvParcialId($repInvParcialId);
|
|
$inventario->UpdateStatusRepParcial('Generado');
|
|
|
|
echo 'ok[#]';
|
|
echo '<div align="center">
|
|
<img src="'.WEB_ROOT.'/images/icons/ok2.png">
|
|
<h2>El reporte fue enviado correctamente.</h2>
|
|
</div>
|
|
<br>
|
|
<div align="center"><a href="'.WEB_ROOT.'/inventario"> << Regresar</a></div>';
|
|
|
|
break;
|
|
|
|
case 'liberarProductos':
|
|
|
|
$venta->setSucursalId($sucursalId);
|
|
$venta->LiberarProductos();
|
|
|
|
$util->setError(10052,'complete');
|
|
$util->PrintErrors();
|
|
|
|
echo 'ok[#]';
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
|
|
|
|
break;
|
|
|
|
}//switch
|
|
|
|
?>
|