Files
ventas_php/export/inventario-fisico.php

134 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();
$invFisicoId = intval($_GET['id']);
$inventario->setInvFisicoId($invFisicoId);
$info = $inventario->InfoInvFisico();
if(!$info){
header('Location: '.WEB_ROOT.'/inventario-fisico');
exit;
}
if($Usr['type'] != 'admin'){
if($info['usuarioId'] != $Usr['usuarioId'] && $Usr['type'] == 'supervisor'){
header('Location: '.WEB_ROOT.'/inventario-fisico');
exit;
}
}
$name = "R_Inventario_Fisico_Teorico";
//Obtenemos los Productos
$inventario->setInvFisicoId($invFisicoId);
$resProds = $inventario->GetInvFisicoProds();
$productos = array();
foreach($resProds as $res){
$producto->setProductoId($res['productoId']);
$infP = $producto->Info();
$proveedor->setProveedorId($infP['proveedorId']);
$res['proveedor'] = $proveedor->GetNameById();
if($info['status'] == "Pendiente"){
$inventario->setProductoId($res['productoId']);
$inventario->setSucursalId($info['sucursalId']);
$res['disponible'] = $inventario->GetDispByProd();
}
$res['diferencia'] = $res['cantidad'] - $res['disponible'];
$res['codigoBarra'] = $infP['codigoBarra'];
$res['modelo'] = $infP['modelo'];
$productos[] = $res;
}
$sucursal->setSucursalId($info['sucursalId']);
$info['sucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));
$x .= "<table border=\"1\">";
$x.="<thead>
<tr>
<th style=\"background:#E0E5E7;text-align:center\"><b>SUCURSAL</b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b>FECHA REPORTE</b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b>FECHA PROCESO</b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b>STATUS</b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b></b></th>
<th style=\"background:#E0E5E7;text-align:center\"><b></b></th>
</tr>
</thead><tbody>";
$x .= "
<tr>
<td style=\"text-align:center\">".$info['sucursal']."</td>
<td style=\"text-align:center\">".$info['fecha']."</td>
<td style=\"text-align:center\">".$info['fechaAjuste']."</td>
<td style=\"text-align:center\">".$info['status']."</td>
<td style=\"text-align:center\"></td>
<td style=\"text-align:center\"></td>
</tr>";
$x .= "
<tr>
<td style=\"background:#E0E5E7;text-align:center\"><b>Codigo Barra</b></td>
<td style=\"background:#E0E5E7;text-align:center\"><b>Proveedor</b></td>
<td style=\"background:#E0E5E7;text-align:center\"><b>Modelo</b></td>
<td style=\"background:#E0E5E7;text-align:center\"><b>Cant. Fisica</b></td>
<td style=\"background:#E0E5E7;text-align:center\"><b>Cant. Teorico</b></td>
<td style=\"background:#E0E5E7;text-align:center\"><b>Diferencia</b></td>
</tr>";
$totales['fisico'] = 0;
$totales['teorico'] = 0;
$totales['diferencia'] = 0;
foreach($productos as $val){
$x .= "
<tr>
<td style='text-align:center;'>".$val['codigoBarra']."</td>
<td style='text-align:center;'>".$val['proveedor']."</td>
<td style='text-align:center;'>".$val['modelo']."</td>
<td style='text-align:center;'>".$val['cantidad']."</td>
<td style='text-align:center;'>".$val['disponible']."</td>
<td style='text-align:center;'>".$val['diferencia']."</td>
</tr>";
$totales['fisico'] += $val['cantidad'];
$totales['teorico'] += $val['disponible'];
$totales['diferencia'] += $val['diferencia'];
}//foreach
$x .= "
<tr>
<td style=\"text-align:center\" padding-right:20px\"></td>
<td style=\"text-align:center\" padding-right:20px\"></td>
<td style=\"text-align:center\" padding-right:20px\"><b>TOTAL GENERAL</b></td>
<td style=\"text-align:center\">".number_format($totales['fisico'],2)."</td>
<td style=\"text-align:center\">".number_format($totales['teorico'],2)."</td>
<td style=\"text-align:center\">".number_format($totales['diferencia'],2)."</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;
?>