Primer commit del sistema avantika sin cambios
This commit is contained in:
90
ajax/reportes/tipoGral.php
Executable file
90
ajax/reportes/tipoGral.php
Executable file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
$fechaIni = $_POST['fechaI'];
|
||||
$fechaFin = $_POST['fechaF'];
|
||||
|
||||
$fechaIni = $util->FormatDateMySql($fechaIni);
|
||||
$fechaFin = $util->FormatDateMySql($fechaFin);
|
||||
|
||||
$idSucursal = $_POST['idSucursal'];
|
||||
|
||||
$Usr = $user->Info();
|
||||
|
||||
$start = microtime(true);
|
||||
$reportes->setIdSuc($idSucursal);
|
||||
$resSuc = $reportes->EnumSucursales($Usr['type'],$Usr['usuarioId']);
|
||||
|
||||
$totales = array();
|
||||
$sucursales = array();
|
||||
foreach($resSuc as $res){
|
||||
|
||||
$sucursalId = $res['sucursalId'];
|
||||
|
||||
$reportes->setIdSuc($sucursalId);
|
||||
$reportes->setFechaI($fechaIni);
|
||||
$reportes->setFechaF($fechaFin);
|
||||
|
||||
//Get total venta
|
||||
$ventas = $reportes->TotalVentasBySucReporte();
|
||||
$totalVenta = $ventas["totalVenta"];
|
||||
$noVentas = $ventas["ventas"];
|
||||
|
||||
$totalCostoVtas = $reportes->GetTotalSumProductosReporte();
|
||||
|
||||
$totalDev = $reportes->TotalDevolucionesBySucReporte();
|
||||
$totalCostoDev = $reportes->GetTotalCostoProductosReporte();
|
||||
|
||||
$totalVenta -= $totalDev;
|
||||
$totalCosto = $totalCostoVtas - $totalCostoDev;
|
||||
$utilidad = $totalVenta - $totalCosto;
|
||||
|
||||
$res['totalVenta'] = $totalVenta;
|
||||
$res['totalDev'] = $totalDev;
|
||||
$res['totalCosto'] = $totalCosto;
|
||||
$res['totalUtilidad'] = $utilidad;
|
||||
$res['totalNoVtas'] = $noVentas;
|
||||
|
||||
$totales['totalVenta'] += $totalVenta;
|
||||
$totales['totalDev'] += $totalDev;
|
||||
$totales['totalCosto'] += $totalCosto;
|
||||
$totales['totalUtilidad'] += $utilidad;
|
||||
$totales['totalNoVtas'] += $noVentas;
|
||||
|
||||
//Obtenemos las comisiones
|
||||
|
||||
$infG = $comision->getInfoGerente();
|
||||
$infSubG = $comision->getInfoSubgerente();
|
||||
|
||||
if($totalVenta <= $infG['rango'])
|
||||
$res['comisionGte'] = ($totalVenta * $infG['comisionBajo']) / 100;
|
||||
elseif($totalVenta > $infG['rango'])
|
||||
$res['comisionGte'] = ($totalVenta * $infG['comisionAlto']) / 100;
|
||||
|
||||
if($totalVenta <= $infSubG['rango'])
|
||||
$res['comisionSubGte'] = ($totalVenta * $infSubG['comisionBajo']) / 100;
|
||||
elseif($totalVenta > $infSubG['rango'])
|
||||
$res['comisionSubGte'] = ($totalVenta * $infSubG['comisionAlto']) / 100;
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$gerente = $sucursal->getGerente();
|
||||
$subGerente = $sucursal->getSubGerente();
|
||||
|
||||
$res['nomGte'] = $gerente['nombre']." ".$gerente['apellidos'];
|
||||
$res['nomSubGte'] = $subGerente['nombre']." ".$subGerente['apellidos'];
|
||||
|
||||
$sucursales[] = $res;
|
||||
|
||||
}//foreach
|
||||
|
||||
$smarty->assign('totales',$totales);
|
||||
$smarty->assign('idSucursal',$idSucursal);
|
||||
$smarty->assign('sucursales',$sucursales);
|
||||
$smarty->assign('fechaIni', $fechaIni);
|
||||
$smarty->assign('fechaFin', $fechaFin);
|
||||
|
||||
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
||||
$smarty->display(DOC_ROOT.'/templates/lists/reportes-venta.tpl');
|
||||
|
||||
$end = microtime(true);
|
||||
echo "Tiempo de Ejecución: ";
|
||||
echo $time = number_format(($end - $start), 2);
|
||||
?>
|
||||
Reference in New Issue
Block a user