172 lines
4.9 KiB
PHP
Executable File
172 lines
4.9 KiB
PHP
Executable File
<?php
|
|
|
|
include_once('../init.php');
|
|
include_once('../config.php');
|
|
include_once(DOC_ROOT.'/libraries.php');
|
|
|
|
$name = "R_inventario_productos_disponibles";
|
|
|
|
$Usr = $user->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.="<table border=\"1\">";
|
|
|
|
foreach($sucursales as $res){
|
|
|
|
$x .= "<thead>
|
|
<tr>
|
|
<th style=\"background:#CCC;text-align:center\" colspan=\"8\"><b>".utf8_decode(urldecode($res['nombre']))."</b></th>
|
|
</tr>
|
|
<tr>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Proveedor</b></th>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Codigo Barra</b></th>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Modelo</b></th>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Costo Unitario</b></th>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Precio Venta</b></th>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Disponible</b></th>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Total Costo</b></th>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Total P.V.</b></th>
|
|
</tr>
|
|
</thead><tbody>";
|
|
|
|
if(count($res['productos']) == 0)
|
|
$res['productos'] = array();
|
|
|
|
foreach($res['productos'] as $val){
|
|
|
|
$x .= "<tr><td>".$val['proveedor']."</td>
|
|
<td style=\"text-align:center;\">".$val['codigoBarra']."</td>
|
|
<td style=\"text-align:center;\">".$val['modelo']."</td>
|
|
<td style=\"text-align:right; padding-right:20px\">$".$val['costo']."</td>
|
|
<td style=\"text-align:right; padding-right:20px\">$".$val['precioVentaIva']."</td>
|
|
<td style=\"text-align:center;\">".$val['disponible']."</td>
|
|
<td style=\"text-align:right;\">$".number_format($val['total'],2)."</td>
|
|
<td style=\"text-align:right;\">$".number_format($val['totalPV'],2)."</td>
|
|
</tr>";
|
|
|
|
}//foreach
|
|
|
|
$x .= '<tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td><b>TOTAL</b></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td align="center"><b>'.number_format($res['disponible'],0,'.',',').'</b></td>
|
|
<td align="right"><b>$'.number_format($res['total'],2).'</b></td>
|
|
<td align="right"><b>$'.number_format($res['totalPV'],2).'</b></td>
|
|
</tr>';
|
|
|
|
}//foreach
|
|
|
|
$x .= '<tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td><b>TOTAL GENERAL</b></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td align="center"><b>'.number_format($totales['disponible'],0,'.',',').'</b></td>
|
|
<td align="right"><b>$'.number_format($totales['total'],2).'</b></td>
|
|
<td align="right"><b>$'.number_format($totales['totalPV'],2).'</b></td>
|
|
</tr>';
|
|
|
|
$x .= "</tbody>";
|
|
$x .= "</table>";
|
|
|
|
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;
|
|
|
|
?>
|