Info(); extract($_POST); $fechaIni = $_POST['fechaI']; $fechaFin = $_POST['fechaF']; $idSucursal = $_POST['idSucursal']; $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); $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 comiisiones $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 $x .= "
Periodo del ".$fechaIni." Al ".$fechaFin."


"; foreach($sucursales as $res){ $x .= "
".utf8_decode(urldecode($res['nombre']))."
$ Venta Total $ Devolucion Total $ Costo Total $ Utilidad Número de Ventas
Realizadas
$".number_format($res['totalVenta'],2)." $".number_format($res['totalDev'],2)." $".number_format($res['totalCosto'],2)." ".number_format($res['totalUtilidad'],2)." ".number_format($res['totalNoVtas'],2,'.','')."


"; }//foreach $x .= "
"; if(($Usr['type'] == "admin" || $Usr['type'] == "centralizador" || $Usr['type'] == "almacen") && $idSucursal == ''){ $x .= ""; $x .= "
TOTALES GENERALES
$ Venta Total $ Devolucion Total $ Costo Total $ Utilidad Número de Productos
Vendidos
$".number_format($totales['totalVenta'],2)." $".number_format($totales['totalDev'],2)." $".number_format($totales['totalCosto'],2)." $".number_format($totales['totalUtilidad'],2)." ".number_format($totales['totalNoVtas'],2,'.','')."
"; } header("Content-Type: application/vnd.ms-excel; charset=utf-8"); header("Content-type: application/x-msexcel; charset=utf-8"); header("Content-Disposition: attachment; filename=".$name.".xls"); header("Pragma: no-cache"); header("Expires: 0"); echo $x; ?>