139 lines
4.2 KiB
PHP
Executable File
139 lines
4.2 KiB
PHP
Executable File
<?php
|
|
|
|
include_once('../init.php');
|
|
include_once('../config.php');
|
|
include_once(DOC_ROOT.'/libraries.php');
|
|
|
|
$Usr = $user->Info();
|
|
|
|
if($Usr['type'] != 'admin'){
|
|
header('Location: '.WEB_ROOT);
|
|
exit;
|
|
}
|
|
|
|
$name = "R_Prods_Transito";
|
|
|
|
extract($_POST);
|
|
|
|
$sucursalId = $_POST['idSucursal'];
|
|
|
|
$reportes->setIdSuc($sucursalId);
|
|
$resSucursales = $reportes->EnumSucursales();
|
|
|
|
$cantGral;
|
|
$totalGral;
|
|
foreach($resSucursales as $res){
|
|
$sucursalId = $res['sucursalId'];
|
|
|
|
$sql = 'SELECT p.codigoBarra, p.modelo, p.costo, p.precioVentaIva AS precioVenta,
|
|
SUM(pd.cantidad) AS cantidad, (SUM(pd.cantidad) * p.precioVentaIva) AS total
|
|
FROM envio e, envioPedido ep, pedidoDistribucion pd, producto AS p
|
|
WHERE e.envioId = ep.envioId
|
|
AND p.productoId = pd.productoId
|
|
AND ep.pedidoId = pd.pedidoId
|
|
AND e.status = "Pendiente"
|
|
AND e.sucursalId = "'.$sucursalId.'"
|
|
AND pd.sucursalId = "'.$sucursalId.'"
|
|
AND pd.cantidad > 0
|
|
GROUP BY pd.productoId';
|
|
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$res['productos'] = $util->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
$sql = 'SELECT SUM(pd.cantidad) AS cantidad, SUM(pd.cantidad * p.precioVentaIva) AS total
|
|
FROM envio e, envioPedido ep, pedidoDistribucion pd, producto AS p
|
|
WHERE e.envioId = ep.envioId
|
|
AND p.productoId = pd.productoId
|
|
AND ep.pedidoId = pd.pedidoId
|
|
AND e.status = "Pendiente"
|
|
AND e.sucursalId = "'.$sucursalId.'"
|
|
AND pd.sucursalId = "'.$sucursalId.'"
|
|
AND pd.cantidad > 0';
|
|
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$row = $util->DBSelect($_SESSION['empresaId'])->GetRow();
|
|
|
|
$res['cantidad'] = $row['cantidad'];
|
|
$res['total'] = $row['total'];
|
|
|
|
$cantGral += $res['cantidad'];
|
|
$totalGral += $res['total'];
|
|
|
|
if(count($res['productos']) > 0)
|
|
$sucursales[] = $res;
|
|
|
|
}//foreach
|
|
|
|
$x = "";
|
|
|
|
foreach($sucursales as $suc){
|
|
|
|
$x .= "<table border=\"1\">
|
|
<thead>
|
|
<tr>
|
|
<th style=\"background:#CCC;text-align:center\" colspan=\"6\">
|
|
<b>".utf8_decode(urldecode($suc['nombre']))."</b>
|
|
</th>
|
|
</tr>
|
|
<tr>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Codigo de Barras</b></th>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Producto</b></th>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Cantidad</b></th>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Costo</b></th>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Precio Venta</b></th>
|
|
<th style=\"background:#E0E5E7;text-align:center\"><b>Total Precio Venta</b></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>";
|
|
|
|
foreach($suc['productos'] as $res){
|
|
|
|
$x .= "
|
|
<tr>
|
|
<td style=\"text-align:center;\">".$res['codigoBarra']."</td>
|
|
<td style=\"text-align:left;\">".$res['modelo']."</td>
|
|
<td style=\"text-align:center;\">".number_format($res['cantidad'],2)."</td>
|
|
<td style=\"text-align:center;\">$".number_format($res['costo'],2)."</td>
|
|
<td style=\"text-align:center;\">$".number_format($res['precioVenta'],2)."</td>
|
|
<td style=\"text-align:center;\">$".number_format($res['total'],2)."</td>
|
|
</tr>";
|
|
|
|
}//foreach
|
|
|
|
$x .= "
|
|
<tr>
|
|
<td></td>
|
|
<td style=\"text-align:center;\"><b>TOTAL</b></td>
|
|
<td style=\"text-align:center;\">".number_format($suc['cantidad'],0)."</td>
|
|
<td style=\"text-align:center;\"></td>
|
|
<td style=\"text-align:center;\"></td>
|
|
<td style=\"text-align:center;\">".number_format($suc['total'],2)."</td>
|
|
</tr>";
|
|
|
|
$x .= "
|
|
</tbody>
|
|
</table>";
|
|
|
|
}//foreach
|
|
|
|
if(count($sucursales) > 1){
|
|
|
|
$x .= "<table border=\"1\">
|
|
<tr>
|
|
<td></td>
|
|
<td style=\"text-align:center;\"><b>TOTAL GENERAL</b></td>
|
|
<td style=\"text-align:center;\">".number_format($cantGral,0)."</td>
|
|
<td style=\"text-align:center;\"></td>
|
|
<td style=\"text-align:center;\"></td>
|
|
<td style=\"text-align:center;\">".number_format($totalGral,2)."</td>
|
|
</tr>
|
|
</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;
|
|
|
|
?>
|