Primer commit del sistema avantika sin cambios
This commit is contained in:
528
modules/pedidos-detalles.php
Executable file
528
modules/pedidos-detalles.php
Executable file
@@ -0,0 +1,528 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$pedidoId = intval($_GET['id']);
|
||||
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$info = $pedido->Info();
|
||||
|
||||
$info['distComp'] = $pedido->DistCompleta();
|
||||
|
||||
$proveedor->setProveedorId($info['proveedorId']);
|
||||
$infPv = $proveedor->Info();
|
||||
|
||||
$info['proveedor'] = $infPv['nombre'];
|
||||
$info['proveedor2'] = str_replace(''', '', $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'] == 'Aprobado'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaAprobacion']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaAprobacion']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaAprobacion'] = $fecha.' '.$hora;
|
||||
|
||||
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
||||
$sucursales = $util->DecodeUrlResult($resSuc);
|
||||
$sucursales = $util->DecodeResult($sucursales);
|
||||
|
||||
$usuario->setUsuarioId($info['userIdAprobacion']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
$smarty->assign('sucursales', $sucursales);
|
||||
|
||||
}elseif($info['status'] == 'Rechazado'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaRechazo']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaRechazo']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaRechazo'] = $fecha.' '.$hora;
|
||||
|
||||
$motivo->setMotivoId($info['motivoId']);
|
||||
$info['motivo'] = $motivo->GetNameById();
|
||||
|
||||
$usuario->setUsuarioId($info['userIdRechazo']);
|
||||
$info['usuario'] = $usuario->GetNameById();
|
||||
|
||||
}elseif($info['status'] == 'Distribucion'){
|
||||
|
||||
$fecha = date('d-m-Y',strtotime($info['fechaDistribucion']));
|
||||
$hora = date('H:i:s',strtotime($info['fechaDistribucion']));
|
||||
$fecha = $util->FormatDateDMMMY($fecha);
|
||||
$info['fechaDistribucion'] = $fecha.' '.$hora;
|
||||
|
||||
$usuario->setUsuarioId($info['userIdDistribucion']);
|
||||
$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();
|
||||
|
||||
$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);
|
||||
|
||||
}elseif($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 = $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'] == '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);
|
||||
}
|
||||
|
||||
//PROPORCIONES
|
||||
|
||||
//Colores
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$resColores = $producto->GetColores();
|
||||
|
||||
$colores = array();
|
||||
foreach($resColores as $res){
|
||||
|
||||
$colorId = $res['colorId'];
|
||||
|
||||
$pedido->setColorId($colorId);
|
||||
$pedido->setProductoId($productoId);
|
||||
$cantidad = $pedido->GetProporcionByColor();
|
||||
|
||||
$proporcionC[$colorId] = $cantidad;
|
||||
|
||||
$res['cantidad'] = $cantidad;
|
||||
|
||||
$atribVal->setAtribValId($res['colorId']);
|
||||
$res['nombre'] = $atribVal->GetNameById();
|
||||
|
||||
$colores[$colorId] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
//Tallas
|
||||
|
||||
$producto->setProductoId($productoId);
|
||||
$resTallas = $producto->GetTallas();
|
||||
|
||||
$tallas = array();
|
||||
foreach($resTallas as $res){
|
||||
|
||||
$tallaId = $res['tallaId'];
|
||||
|
||||
$pedido->setTallaId($tallaId);
|
||||
$pedido->setProductoId($productoId);
|
||||
$cantidad = $pedido->GetProporcionByTalla();
|
||||
|
||||
$proporcionT[$tallaId] = $cantidad;
|
||||
|
||||
$res['cantidad'] = $cantidad;
|
||||
|
||||
$atribVal->setAtribValId($tallaId);
|
||||
$res['nombre'] = $atribVal->GetNameById();
|
||||
|
||||
$tallas[$tallaId] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
//Obtenemos Totales
|
||||
|
||||
$totales = array();
|
||||
$subtotales = array();
|
||||
foreach($tallas as $idT => $t){
|
||||
|
||||
$cantT = $t['cantidad'];
|
||||
|
||||
$total = 0;
|
||||
foreach($colores as $idC => $c){
|
||||
|
||||
$cantC = $c['cantidad'];
|
||||
|
||||
$subtotal = $cantC * $cantT;
|
||||
$total += $subtotal;
|
||||
|
||||
$subtotales[$idT][$idC] = $subtotal;
|
||||
}
|
||||
|
||||
$totales[$idT] = $total;
|
||||
|
||||
}//foreach
|
||||
|
||||
$card['tallas'] = $tallas;
|
||||
$card['colores'] = $colores;
|
||||
$card['totales'] = $totales;
|
||||
$card['subtotales'] = $subtotales;
|
||||
$card['proporcionT'] = $proporcionT;
|
||||
$card['proporcionC'] = $proporcionC;
|
||||
|
||||
$card['costo'] = number_format($card['costo'],2);
|
||||
$card['precioVenta'] = number_format($card['precioVenta'],2);
|
||||
|
||||
//FIN PROPORCIONES
|
||||
|
||||
if($card['status'] == 'Sugerencia')
|
||||
$sugerencias++;
|
||||
|
||||
$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;
|
||||
|
||||
//Obtenemos las Dist. de Cajas por Sucursal
|
||||
$pedido->setPedidoId($pedidoId);
|
||||
$resSucCajas = $pedido->EnumSucCajas();
|
||||
|
||||
$sucCajas = array();
|
||||
foreach($resSucCajas as $res){
|
||||
$sucursal->setSucursalId($res['sucursalId']);
|
||||
$infS = $sucursal->Info();
|
||||
$res['noSuc'] = $infS['noSuc'];
|
||||
$sucCajas[] = $res;
|
||||
}
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('sucCajas', $sucCajas);
|
||||
$smarty->assign('pedidoId', $pedidoId);
|
||||
$smarty->assign('products', $products);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user