Primer commit del sistema avantika sin cambios
This commit is contained in:
82
modules/ventas-cobrar.php
Executable file
82
modules/ventas-cobrar.php
Executable file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
$empresa->AuthUser();
|
||||
|
||||
if(!$usuario->AllowPage($page, $_SESSION['loginKey'])){
|
||||
header('Location: '.WEB_ROOT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$ventaId = intval($_GET['ventaId']);
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$info = $venta->Info();
|
||||
$sucursalId = $info['sucursalId'];
|
||||
|
||||
$usuario->setUsuarioId($info['vendedorId']);
|
||||
$info['vendedor'] = $usuario->GetFullNameById();
|
||||
|
||||
$usuario->setUsuarioId($info['usuarioId']);
|
||||
$info['usuario'] = $usuario->GetFullNameById();
|
||||
|
||||
$sucursal->setSucursalId($info['sucursalId']);
|
||||
$info['sucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$resProds = $venta->GetSingleProds();
|
||||
|
||||
$productos = array();
|
||||
foreach($resProds as $res){
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$venta->setProdItemId($res['prodItemId']);
|
||||
$res['cantidad'] = $venta->GetCantProdsByItem();
|
||||
$res['precioUnitario'] = $venta->GetMaxPrecioByItem();
|
||||
$res['total'] = $venta->GetTotalByItem();
|
||||
|
||||
$producto->setProductoId($res['productoId']);
|
||||
$res['nombre'] = $producto->GetModeloById();
|
||||
|
||||
$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['tipoDesc'] != ''){
|
||||
|
||||
$valDesc = $info['valDesc'];
|
||||
if($info['tipoDesc'] == 'Dinero')
|
||||
$descuento = $valDesc;
|
||||
elseif($info['tipoDesc'] == 'Porcentaje')
|
||||
$descuento = $info['subtotal'] * ($valDesc / 100);
|
||||
|
||||
$info['descuento'] = $descuento;
|
||||
$info['subtotal'] = $info['subtotalDesc'] + $descuento;
|
||||
|
||||
$info['iva'] = $info['ivaDesc'];
|
||||
$info['total'] = $info['totalDesc'];
|
||||
|
||||
}elseif($info['totalDesc'] > 0){
|
||||
|
||||
$info['subtotal'] = $info['subtotalDesc'];
|
||||
$info['iva'] = $info['ivaDesc'];
|
||||
$info['total'] = $info['totalDesc'];
|
||||
|
||||
}//if
|
||||
|
||||
$smarty->assign('productos', $productos);
|
||||
$smarty->assign('info', $info);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user