Files
ventas_php/export/envios-traspasos.php

97 lines
2.6 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_Traspasos";
extract($_POST);
$sucursalId = $_POST['sucursalId2'];
$status = $_POST['status2'];
$fechaEnvio = $_POST['fechaEnvio2'];
$ordenCompra = $_POST['ordenCompra2'];
$envio->setSucursalId($sucursalId);
$envio->setNoPedido($ordenCompra);
$envio->setStatus($status);
if($fechaEnvio)
$envio->setFecha(date('Y-m-d',strtotime($fechaEnvio)));
if($Usr['type'] == 'gerente')
$envio->setSucursalId($_SESSION['idSuc']);
$resEnvios = $envio->Search();
$envios = array();
foreach($resEnvios as $res){
$sucursal->setSucursalId($res['sucursalId']);
$res['sucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));
$fecha = date('d-m-Y',strtotime($res['fecha']));
$res['fecha'] = $util->FormatDateDMMMY($fecha);
$envio->setEnvioId($res['envioId']);
$res['enviaron'] = $envio->GetTotalPrendas();
$res['recibieron'] = $envio->GetTotalRec();
$res['diferencia'] = $res['enviaron'] - $res['recibieron'];
$envios[] = $res;
}
$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>No.</b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b>Fecha Env&iacute;o</b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b>Sucursal</b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b>Enviaron</b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b>Recibieron</b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b>Diferencia</b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b>Status</b></th>
</tr>
</thead>
<tbody>";
foreach($envios as $res){
$x .= "
<tr>
<td style=\"text-align:center;\">".$res['envioId']."</td>
<td style=\"text-align:right;\">".$res['fecha']."</td>
<td style=\"text-align:right;\">".$res['sucursal']."</td>
<td style=\"text-align:right;\">".$res['enviaron']."</td>
<td style=\"text-align:center;\">".$res['recibieron']."</td>
<td style=\"text-align:center;\">".$res['diferencia']."</td>
<td style=\"text-align:center;\">".$res['status']."</td>
</tr>";
}//foreach
$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;
?>