Info(); extract($_POST); $proveedorId = $_POST['proveedorId']; $sucursalId = $_POST['sucursal']; $prodCatId = $_POST['prodCatId']; $prodSubcatId = $_POST['prodSubcatId']; $reportes->setIdSuc($sucursalId); $resSuc = $reportes->EnumSucursales(); if($proveedorId) $sqlFilter = ' AND proveedorId = '.$proveedorId; $sql = 'SELECT proveedorId FROM proveedor WHERE 1 '.$sqlFilter; $util->DBSelect($_SESSION['empresaId'])->setQuery($sql); $proveedores = $util->DBSelect($_SESSION['empresaId'])->GetResult(); $dispGral = 0; $totalGral = 0; $totalGralPV = 0; $sucursales = array(); foreach($resSuc as $res){ $sucursalId = $res['sucursalId']; $dispSuc = 0; $totalSuc = 0; $totalSucPV = 0; $productos = array(); foreach($proveedores as $prov){ $proveedorId = $prov['proveedorId']; $sql = "SELECT reporte, fecha FROM `reporteInvBest` WHERE proveedorId = ".$proveedorId; $util->DBSelect($_SESSION['empresaId'])->setQuery($sql); $row = $util->DBSelect($_SESSION['empresaId'])->GetRow(); if(!$row) continue; $reporte = $row['reporte']; $fechaRep = date('d-m-Y',strtotime($row['fecha'])); $resSucursales = unserialize(urldecode($reporte)); foreach($resSucursales as $res2){ if($sucursalId > 0 && $sucursalId != $res2['sucursalId']) continue; foreach($res2['productos'] as $prod){ if($prodCatId > 0 && $prodCatId != $prod['prodCatId']) continue; if($prodSubcatId > 0 && $prodSubcatId != $prod['prodSubcatId']) continue; $dispSuc += $prod['disponible']; $totalSuc += $prod['total']; $totalSucPV += $prod['totalPV']; $dispGral += $prod['disponible']; $totalGral += $prod['total']; $totalGralPV += $prod['totalPV']; $productos[] = $prod; }//foreach }//foreach }//foreach $res['disponible'] = $dispSuc; $res['total'] = $totalSuc; $res['totalPV'] = $totalSucPV; $res['productos'] = $productos; if(count($productos) > 0) $sucursales[] = $res; }//foreach $totales['disponible'] = $dispGral; $totales['total'] = $totalGral; $totales['totalPV'] = $totalGralPV; $x.=""; foreach($sucursales as $res){ $x .= ""; if(count($res['productos']) == 0) $res['productos'] = array(); foreach($res['productos'] as $val){ $x .= ""; }//foreach $x .= ''; }//foreach $x .= ''; $x .= ""; $x .= "
".utf8_decode(urldecode($res['nombre']))."
Proveedor Codigo Barra Modelo Costo Unitario Precio Venta Disponible Total Costo Total P.V.
".$val['proveedor']." ".$val['codigoBarra']." ".$val['modelo']." $".$val['costo']." $".$val['precioVentaIva']." ".$val['disponible']." $".number_format($val['total'],2)." $".number_format($val['totalPV'],2)."
TOTAL '.number_format($res['disponible'],0,'.',',').' $'.number_format($res['total'],2).' $'.number_format($res['totalPV'],2).'
TOTAL GENERAL '.number_format($totales['disponible'],0,'.',',').' $'.number_format($totales['total'],2).' $'.number_format($totales['totalPV'],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; ?>