Primer commit del sistema avantika sin cambios
This commit is contained in:
206
modules/ventas-sucursal.php
Executable file
206
modules/ventas-sucursal.php
Executable file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
$suc = $_GET['nom'];
|
||||
|
||||
if($suc == 'cuajimalpa')
|
||||
$sucursalId = 1;
|
||||
elseif($suc == 'atizapan')
|
||||
$sucursalId = 2;
|
||||
elseif($suc == 'ecatepec')
|
||||
$sucursalId = 12;
|
||||
elseif($suc == 'nicolasromero')
|
||||
$sucursalId = 13;
|
||||
elseif($suc == 'yautepec')
|
||||
$sucursalId = 26;
|
||||
else
|
||||
exit;
|
||||
|
||||
$rfc->setRfcId(1);
|
||||
$infE = $util->EncodeRow($rfc->Info());
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$infS = $sucursal->Info();
|
||||
$infS['nombre'] = strtoupper($infS['nombre']);
|
||||
$infS = $util->DecodeUrlRow($infS);
|
||||
$infS = $util->DecodeRow($infS);
|
||||
|
||||
//Obtenemos los Tickets
|
||||
|
||||
$sql = 'SELECT * FROM venta
|
||||
WHERE sucursalId = "'.$sucursalId.'"';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$resVentas = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$tickets = array();
|
||||
foreach($resVentas as $vta){
|
||||
|
||||
$ventaId = $vta['ventaId'];
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$info = $venta->Info();
|
||||
|
||||
$info['hora'] = date('H:i:s',strtotime($info['fecha']));
|
||||
$info['fecha'] = date('d-m-Y',strtotime($info['fecha']));
|
||||
|
||||
$usuario->setUsuarioId($info['vendedorId']);
|
||||
$info['vendedor'] = strtoupper($usuario->GetFullNameById());
|
||||
|
||||
$usuario->setUsuarioId($info['usuarioId']);
|
||||
$info['usuario'] = strtoupper($usuario->GetFullNameById());
|
||||
|
||||
//Obtenemos los Productos
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$resProds = $venta->GetProductos();
|
||||
|
||||
$productos = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$producto->setProdItemId($res['prodItemId']);
|
||||
$infI = $producto->GetInfoItemById();
|
||||
|
||||
$producto->setProductoId($infI['productoId']);
|
||||
$infP = $producto->Info();
|
||||
|
||||
$atribVal->setAtribValId($infI['tallaId']);
|
||||
$talla = $atribVal->GetNameById();
|
||||
|
||||
$atribVal->setAtribValId($infI['colorId']);
|
||||
$color = $atribVal->GetNameById();
|
||||
|
||||
if($res['monederoId']){
|
||||
$monedero->setMonederoId($res['monederoId']);
|
||||
$infM = $monedero->Info();
|
||||
$res['codigoBarra'] = $infM['codigo'];
|
||||
$res['nombre'] = 'Tarjeta de Prepago de '.$res['total'];
|
||||
}else{
|
||||
$res['nombre'] = $infP['modelo'];
|
||||
$res['codigoBarra'] = $infI['codigoBarra'];
|
||||
}
|
||||
|
||||
/*** OBTENEMOS TOTALES ***/
|
||||
|
||||
$total = $res['total'];
|
||||
$valDesc = $res['valDesc'];
|
||||
if($res['tipoDesc'] == 'Dinero')
|
||||
$total -= $valDesc * $res['cantidad'];
|
||||
elseif($res['tipoDesc'] == 'Porcentaje')
|
||||
$total -= $total * ($valDesc / 100);
|
||||
|
||||
$total = number_format($total,2,'.','');
|
||||
|
||||
$res['totalDesc'] = $total;
|
||||
|
||||
$productos[] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
//Obtenemos Totales
|
||||
|
||||
if($info['totalDesc'] > 0){
|
||||
|
||||
$subtotal2 = $info['subtotalDesc'];
|
||||
|
||||
$info['subtotal2'] = $subtotal2;
|
||||
$info['iva'] = $info['ivaDesc'];
|
||||
$info['total'] = $info['totalDesc'];
|
||||
|
||||
$valDesc = $info['valDesc'];
|
||||
if($info['tipoDesc'] == 'Dinero'){
|
||||
$subtotal = $subtotal2 + $valDesc;
|
||||
$info['descuento'] = $valDesc;
|
||||
}else{
|
||||
$resDesc = 100 - $valDesc;
|
||||
$subtotal = $subtotal2 / ($resDesc / 100);
|
||||
$subtotal = number_format($subtotal,2,'.','');
|
||||
|
||||
$info['descuento'] = $subtotal * ($valDesc / 100);
|
||||
}//else
|
||||
|
||||
$info['subtotal'] = $subtotal;
|
||||
|
||||
}//if
|
||||
|
||||
$cambio = 0;
|
||||
if($info['pago'] > $info['total'])
|
||||
$cambio = $info['pago'] - $info['total'];
|
||||
|
||||
$info['cambio'] = $cambio;
|
||||
|
||||
//Agrupamos los Productos solo para Vista
|
||||
|
||||
$prodIds = array();
|
||||
foreach($productos as $res){
|
||||
|
||||
$productoId = $res['productoId'];
|
||||
|
||||
if(!in_array($productoId, $prodIds))
|
||||
$prodIds[] = $productoId;
|
||||
|
||||
}//foreach
|
||||
|
||||
$products = array();
|
||||
foreach($prodIds as $productoId){
|
||||
|
||||
$promocionId = 0;
|
||||
$total2 = 0;
|
||||
$precio = 0;
|
||||
$cantidad = 0;
|
||||
$totalDesc = 0;
|
||||
$card = array();
|
||||
foreach($productos as $res){
|
||||
|
||||
if($res['productoId'] == $productoId){
|
||||
$card = $res;
|
||||
|
||||
if($res['promocionId'])
|
||||
$promocionId = $res['promocionId'];
|
||||
|
||||
if($res['precioUnitario'] > $precio)
|
||||
$precio = $res['precioUnitario'];
|
||||
|
||||
$cantidad += $res['cantidad'];
|
||||
$totalDesc += $res['totalDesc'];
|
||||
|
||||
$total2 += $res['total'];
|
||||
}
|
||||
|
||||
}//foreach
|
||||
|
||||
$card['precioUnitario'] = $precio;
|
||||
$card['cantidad'] = $cantidad;
|
||||
$card['total'] = $total2;
|
||||
$card['totalDesc'] = $totalDesc;
|
||||
$card['promocionId'] = $promocionId;
|
||||
|
||||
if($card['promocionId']){
|
||||
$promocion->setPromocionId($card['promocionId']);
|
||||
$nomPromo = $promocion->GetNameById();
|
||||
$card['nombre'] .= '<br>Promoción: '.$nomPromo;
|
||||
}
|
||||
|
||||
$products[] = $card;
|
||||
|
||||
}//foreach
|
||||
|
||||
$cardT['productos'] = $products;
|
||||
$cardT['info'] = $info;
|
||||
|
||||
$tickets[] = $cardT;
|
||||
|
||||
}//foreach
|
||||
|
||||
$fontSize = 12;
|
||||
|
||||
$smarty->assign('infE', $infE);
|
||||
$smarty->assign('infS', $infS);
|
||||
$smarty->assign('mode', $mode);
|
||||
$smarty->assign('fontSize', $fontSize);
|
||||
$smarty->assign('tickets', $tickets);
|
||||
$smarty->display(DOC_ROOT."/templates/ventas-sucursal.tpl");
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user