355 lines
10 KiB
PHP
Executable File
355 lines
10 KiB
PHP
Executable File
<?php
|
|
|
|
$empresa->AuthUser();
|
|
|
|
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
|
header('Location: '.WEB_ROOT);
|
|
exit;
|
|
}
|
|
|
|
$pedidoId = intval($_GET['id']);
|
|
|
|
$pedido->setPedidoId($pedidoId);
|
|
$info = $pedido->Info();
|
|
|
|
$proveedor->setProveedorId($info['proveedorId']);
|
|
$infPv = $proveedor->Info();
|
|
|
|
$info['proveedor'] = $infPv['nombre'];
|
|
$info['noProv'] = $infPv['noProv'];
|
|
|
|
$fecha = date('d-m-Y',strtotime($info['fecha']));
|
|
$hora = date('H:i:s',strtotime($info['fecha']));
|
|
$fecha = $util->FormatDateDMMMY($fecha);
|
|
$info['fecha'] = $fecha.' '.$hora;
|
|
|
|
$fechaEntrega = date('d-m-Y',strtotime($info['fechaEntrega']));
|
|
$info['fechaEntrega'] = $util->FormatDateDMMMY($fechaEntrega);
|
|
|
|
if($info['fechaEntregaF']){
|
|
$fechaEntregaF = date('d-m-Y',strtotime($info['fechaEntregaF']));
|
|
$info['fechaEntregaF'] = $util->FormatDateDMMMY($fechaEntregaF);
|
|
}
|
|
|
|
if($info['status'] == 'Autorizado'){
|
|
|
|
$fecha = date('d-m-Y',strtotime($info['fechaAutorizacion']));
|
|
$hora = date('H:i:s',strtotime($info['fechaAutorizacion']));
|
|
$fecha = $util->FormatDateDMMMY($fecha);
|
|
$info['fechaAutorizacion'] = $fecha.' '.$hora;
|
|
|
|
$resProducts = $pedido->GetProdsDistribucion();
|
|
|
|
$dist = array();
|
|
foreach($resProducts as $res){
|
|
$productoId = $res['productoId'];
|
|
$sucursalId = $res['sucursalId'];
|
|
|
|
$pedido->setProductoId($productoId);
|
|
$infPP = $pedido->GetInfoProd();
|
|
|
|
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
|
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
|
}
|
|
|
|
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
|
$sucursales = $util->DecodeUrlResult($resSuc);
|
|
$sucursales = $util->DecodeResult($sucursales);
|
|
|
|
$smarty->assign('dist', $dist);
|
|
$smarty->assign('sucursales', $sucursales);
|
|
|
|
}elseif($info['status'] == 'Sugerencia'){
|
|
|
|
$fecha = date('d-m-Y',strtotime($info['fechaSugerencia']));
|
|
$hora = date('H:i:s',strtotime($info['fechaSugerencia']));
|
|
$fecha = $util->FormatDateDMMMY($fecha);
|
|
$info['fechaSugerencia'] = $fecha.' '.$hora;
|
|
|
|
$usuario->setUsuarioId($info['userIdSugerencia']);
|
|
$info['usuario'] = $usuario->GetNameById();
|
|
|
|
$resProducts = $pedido->GetProdsDistribucion();
|
|
|
|
$dist = array();
|
|
foreach($resProducts as $res){
|
|
|
|
$productoId = $res['productoId'];
|
|
$sucursalId = $res['sucursalId'];
|
|
|
|
$pedido->setProductoId($productoId);
|
|
$infPP = $pedido->GetInfoProd();
|
|
|
|
if($infPP['status'] == 'Sugerencia3'){
|
|
|
|
$pedido->setSucursalId($sucursalId);
|
|
$pedido->setUsuario('Distribucion');
|
|
$infPS = $pedido->GetInfoProdSug();
|
|
$cantSug = $infPS['cantidad'];
|
|
|
|
}elseif($infPP['status'] == 'Sugerencia2'){
|
|
|
|
$pedido->setSucursalId($sucursalId);
|
|
$pedido->setUsuario('Directivo');
|
|
$infPS = $pedido->GetInfoProdSug();
|
|
|
|
$res['cantidad'] = $infPS['cantidad'];
|
|
|
|
$pedido->setUsuario('Distribucion');
|
|
$infPS = $pedido->GetInfoProdSug();
|
|
$cantSug = $infPS['cantidad'];
|
|
|
|
}elseif($infPP['status'] == 'Sugerencia' || $infPP['status'] == 'Aprobado2'){
|
|
|
|
$pedido->setSucursalId($sucursalId);
|
|
$pedido->setUsuario('Directivo');
|
|
$infPS = $pedido->GetInfoProdSug();
|
|
$cantSug = $infPS['cantidad'];
|
|
|
|
}else{
|
|
$cantSug = $res['cantidad'];
|
|
}
|
|
|
|
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
|
$dist[$productoId][$sucursalId]['sugerencia'] = $cantSug;
|
|
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
|
}
|
|
|
|
$resSuc = $pedido->GetSucursales();
|
|
|
|
$sucursales = array();
|
|
foreach($resSuc as $res){
|
|
$sucursal->setSucursalId($res['sucursalId']);
|
|
$res['nombre'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
|
|
|
$infS = $sucursal->Info();
|
|
$res['noSuc'] = $infS['noSuc'];
|
|
|
|
$sucursales[] = $res;
|
|
}
|
|
|
|
|
|
$smarty->assign('dist', $dist);
|
|
$smarty->assign('sucursales', $sucursales);
|
|
|
|
}elseif($info['status'] == 'OrdenCompEnv'){
|
|
|
|
$fecha = date('d-m-Y',strtotime($info['fechaOrdenCompEnv']));
|
|
$hora = date('H:i:s',strtotime($info['fechaOrdenCompEnv']));
|
|
$fecha = $util->FormatDateDMMMY($fecha);
|
|
$info['fechaOrdenCompEnv'] = $fecha.' '.$hora;
|
|
|
|
$usuario->setUsuarioId($info['userIdOrdenCompEnv']);
|
|
$info['usuario'] = $usuario->GetNameById();
|
|
|
|
$resProducts = $pedido->GetProdsDistribucion();
|
|
|
|
$dist = array();
|
|
foreach($resProducts as $res){
|
|
$productoId = $res['productoId'];
|
|
$sucursalId = $res['sucursalId'];
|
|
|
|
$pedido->setProductoId($productoId);
|
|
$infPP = $pedido->GetInfoProd();
|
|
|
|
if($infPP['status'] == 'Sugerencia'){
|
|
$pedido->setSucursalId($sucursalId);
|
|
$infPS = $pedido->GetInfoProdSug();
|
|
$res['cantidad'] = $infPS['cantidad'];
|
|
}
|
|
|
|
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
|
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
|
}
|
|
|
|
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
|
$sucursales = $util->DecodeUrlResult($resSuc);
|
|
$sucursales = $util->DecodeResult($sucursales);
|
|
|
|
$smarty->assign('dist', $dist);
|
|
$smarty->assign('sucursales', $sucursales);
|
|
|
|
}elseif($info['status'] == 'OrdenCompEnvCan'){
|
|
|
|
$usuario->setUsuarioId($info['userIdOrdenCompEnv']);
|
|
$info['usuario'] = $usuario->GetNameById();
|
|
|
|
}elseif($info['status'] == 'OrdenCompIng'){
|
|
|
|
$fecha = date('d-m-Y',strtotime($info['fechaOrdenCompIng']));
|
|
$hora = date('H:i:s',strtotime($info['fechaOrdenCompIng']));
|
|
$fecha = $util->FormatDateDMMMY($fecha);
|
|
$info['fechaOrdenCompIng'] = $fecha.' '.$hora;
|
|
|
|
$usuario->setUsuarioId($info['userIdOrdenCompIng']);
|
|
$info['usuario'] = $usuario->GetNameById();
|
|
|
|
$resProducts = $pedido->GetProdsDistribucion();
|
|
|
|
$dist = array();
|
|
foreach($resProducts as $res){
|
|
$productoId = $res['productoId'];
|
|
$sucursalId = $res['sucursalId'];
|
|
|
|
$pedido->setProductoId($productoId);
|
|
$infPP = $pedido->GetInfoProd();
|
|
|
|
if($infPP['status'] == 'Sugerencia'){
|
|
$pedido->setSucursalId($sucursalId);
|
|
$infPS = $pedido->GetInfoProdSug();
|
|
$res['cantidad'] = $infPS['cantidad'];
|
|
}
|
|
|
|
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
|
$dist[$productoId][$sucursalId]['prendas'] = $res['prendas'];
|
|
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
|
$dist[$productoId][$sucursalId]['noCajas'] = $res['cajas'];
|
|
}
|
|
|
|
$resSuc = $pedido->GetSucursales();
|
|
|
|
$sucursales = array();
|
|
foreach($resSuc as $res){
|
|
$sucursal->setSucursalId($res['sucursalId']);
|
|
$res['nombre'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
|
|
|
$infS = $sucursal->Info();
|
|
$res['noSuc'] = $infS['noSuc'];
|
|
|
|
$sucursales[] = $res;
|
|
}
|
|
|
|
|
|
$smarty->assign('dist', $dist);
|
|
$smarty->assign('sucursales', $sucursales);
|
|
|
|
}elseif($info['status'] == 'EnvSuc'){
|
|
|
|
$resProducts = $pedido->GetProdsDistribucion();
|
|
|
|
$dist = array();
|
|
foreach($resProducts as $res){
|
|
$productoId = $res['productoId'];
|
|
$sucursalId = $res['sucursalId'];
|
|
|
|
$pedido->setProductoId($productoId);
|
|
$infPP = $pedido->GetInfoProd();
|
|
|
|
if($infPP['status'] == 'Sugerencia'){
|
|
$pedido->setSucursalId($sucursalId);
|
|
$infPS = $pedido->GetInfoProdSug();
|
|
$res['cantidad'] = $infPS['cantidad'];
|
|
}
|
|
|
|
$dist[$productoId][$sucursalId]['cantidad'] = $res['cantidad'];
|
|
$dist[$productoId][$sucursalId]['pedDistId'] = $res['pedDistId'];
|
|
}
|
|
|
|
$resSuc = $pedido->GetSucursales();
|
|
|
|
$sucursales = array();
|
|
foreach($resSuc as $res){
|
|
$sucursal->setSucursalId($res['sucursalId']);
|
|
$res['nombre'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
|
|
|
$infS = $sucursal->Info();
|
|
$res['noSuc'] = $infS['noSuc'];
|
|
|
|
$sucursales[] = $res;
|
|
}
|
|
|
|
$smarty->assign('dist', $dist);
|
|
$smarty->assign('sucursales', $sucursales);
|
|
|
|
}else{
|
|
|
|
$usuario->setUsuarioId($info['usuarioId']);
|
|
$info['usuario'] = $usuario->GetNameById();
|
|
|
|
}//elseif
|
|
|
|
if($info['metodoCompra'] == "sinIva")
|
|
$info['metodoCompra'] = 'IVA No Incluido';
|
|
else
|
|
$info['metodoCompra'] = 'IVA Incluido';
|
|
|
|
$resProducts = $pedido->GetProductos();
|
|
|
|
$products = array();
|
|
$products2 = array();
|
|
|
|
$sugerencias = 0;
|
|
$subtotalP = 0;
|
|
$totalPzas = 0;
|
|
foreach($resProducts as $card){
|
|
|
|
$prodCatId = $card['prodCatId'];
|
|
$prodSubcatId = $card['prodSubcatId'];
|
|
$productoId = $card['productoId'];
|
|
|
|
$card['productoId'] = $productoId;
|
|
$card['prodCatId'] = $prodCatId;
|
|
$card['prodSubcatId'] = $prodSubcatId;
|
|
|
|
$prodCat->setProdCatId($prodCatId);
|
|
$card['departamento'] = $prodCat->GetNameById();
|
|
|
|
$prodSubcat->setProdSubcatId($prodSubcatId);
|
|
$card['linea'] = $prodSubcat->GetNameById();
|
|
|
|
$producto->setProductoId($productoId);
|
|
$infP = $producto->Info();
|
|
$card['modelo'] = strtoupper($infP['modelo']);
|
|
$card['imagen'] = $infP['imagen'];
|
|
$card['codigoBarra'] = $infP['codigoBarra'];
|
|
|
|
$card['atributos'] = $producto->GetAtributosAll();
|
|
|
|
$card['cantidad'] = $card['totalLote'] * $card['cantLotes'];
|
|
$totalP = $card['costo'] * $card['cantidad'];
|
|
$card['total'] = number_format($totalP,2);
|
|
|
|
$totalPzas += $card['cantidad'];
|
|
$subtotalP += $totalP;
|
|
|
|
if($info['status'] == 'OrdenCompIng' || $info['status'] == 'EnvSuc'){
|
|
$card['cantidad'] = ($card['prendasComp'] == 1) ? $card['cantPrendas'] : $card['prendasRec'];
|
|
$totalP = $card['costo'] * $card['cantidad'];
|
|
$card['total'] = number_format($totalP,2);
|
|
}
|
|
|
|
$card['costo'] = number_format($card['costo'],2);
|
|
$card['precioVenta'] = number_format($card['precioVenta'],2);
|
|
|
|
if($card['status'] == 'Sugerencia')
|
|
$sugerencias++;
|
|
|
|
$pedido->setPedidoId($pedidoId);
|
|
$pedido->setProductoId($productoId);
|
|
$totalDist = $pedido->GetTotalDistByProd();
|
|
$card['prendasFaltantes'] = $card['cantPrendas'] - $totalDist;
|
|
|
|
$products[] = $card;
|
|
|
|
}//foreach
|
|
|
|
if($info['subtotal2'] > 0){
|
|
$info['subtotal'] = $info['subtotal2'];
|
|
$info['iva'] = $info['iva2'];
|
|
$info['total'] = $info['total2'];
|
|
}
|
|
|
|
$info['subtotal'] = number_format($info['subtotal'],2);
|
|
$info['iva'] = number_format($info['iva'],2);
|
|
$info['total'] = number_format($info['total'],2);
|
|
|
|
$info['totalPzas'] = $totalPzas;
|
|
|
|
$info['view'] = 1;
|
|
$info['sugerencias'] = $sugerencias;
|
|
|
|
$smarty->assign('info', $info);
|
|
$smarty->assign('pedidoId', $pedidoId);
|
|
$smarty->assign('products', $products);
|
|
|
|
?>
|