Files
ventas_php/export/envios-transito.php

142 lines
3.5 KiB
PHP
Executable File

<?php
include_once('../init.php');
include_once('../config.php');
include_once(DOC_ROOT.'/libraries.php');
$Usr = $user->Info();
$name = "R_Envios_Transito";
extract($_POST);
$sucursalId2 = $_POST['sucursalId2'];
$proveedorId2 = $_POST['proveedorId2'];
if($_POST['fechaIni2'])
$fechaIni = date('Y-m-d',strtotime($_POST['fechaIni2']));
if($_POST['fechaFin2'])
$fechaFin = date('Y-m-d',strtotime($_POST['fechaFin2']));
$envio->setFechaIni($fechaIni);
$envio->setFechaFin($fechaFin);
$envio->setSucursalId($sucursalId2);
$envios = $envio->GetEnviosTransito();
$cantTotal = 0;
$productos = array();
foreach($envios as $res){
$envioId = $res['envioId'];
$sucursalId = $res['sucursalId'];
$sucursal->setSucursalId($sucursalId);
$nomSuc = utf8_decode(urldecode($sucursal->GetNameById()));
$envio->setEnvioId($envioId);
$pedidos = $envio->GetPedidosByEnvio();
foreach($pedidos as $val){
$pedidoId = $val['pedidoId'];
$envio->setPedidoId($pedidoId);
$envio->setSucursalId($sucursalId);
$resProds = $envio->GetProductos2();
foreach($resProds as $prod){
$productoId = $prod['productoId'];
$producto->setProductoId($productoId);
$infP = $producto->Info();
if($proveedorId2){
if($proveedorId2 != $infP['proveedorId'])
continue;
}
$proveedor->setProveedorId($infP['proveedorId']);
$card['proveedor'] = $proveedor->GetNameById();
$card['cantidad'] = $prod['cantidad'];
$card['sucursal'] = $nomSuc;
$card['modelo'] = $infP['modelo'];
$card['codigoBarra'] = $infP['codigoBarra'];
$card['envioId'] = $envioId;
$card['fecha'] = $res['fecha'];
$cantTotal += $card['cantidad'];
$productos[] = $card;
}//foreach
}//foreach
}//foreach
$x = "
<table>
<th colspan=\"7\" style=\"text-align:center\">COMERCIALIZADORA NOVOMODA S.A. DE C.V.</th>
</table>
<br><br>
";
$x .= "<table border=\"1\">
<thead>
<tr>
<th style=\"background:#E0E5E7;text-align:center\"><b>Sucursal</b></th>
<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>Producto</b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b>Cantidad</b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b>No. Envio</b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b>Fecha</b></th>
</tr>
</thead>
<tbody>";
foreach($productos as $res){
$x .= "
<tr>
<td style=\"text-align:left;\">".$res['sucursal']."</td>
<td style=\"text-align:left;\">".$res['proveedor']."</td>
<td style=\"text-align:center;\">".$res['codigoBarra']."</td>
<td style=\"text-align:left;\">".$res['modelo']."</td>
<td style=\"text-align:center;\">".$res['cantidad']."</td>
<td style=\"text-align:center;\">".$res['envioId']."</td>
<td style=\"text-align:center;\">".$res['fecha']."</td>
</tr>";
}//foreach
if(count($productos) > 0){
$x .= "
<tr>
<td></td>
<td></td>
<td></td>
<td style=\"text-align:left;\">TOTAL</td>
<td style=\"text-align:center;\">".$cantTotal."</td>
<td></td>
<td></td>
</tr>";
}
$x .= "
</tbody>
</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;
?>