Files
ventas_php/ajax/envios-reporte.php

86 lines
2.2 KiB
PHP
Executable File

<?php
include_once('../init.php');
include_once('../config.php');
include_once(DOC_ROOT.'/libraries.php');
session_start();
$Usr = $user->Info();
$smarty->assign('Usr', $Usr);
if(isset($_POST['action']))
$_POST['type'] = $_POST['action'];
switch($_POST['type']){
case 'search':
$sucursalId = $_POST['sucursalId2'];
$fechaRec = $_POST['fechaEnvio2'];
if(!$sucursalId){
$util->setError(30015,'error','');
$util->PrintErrors();
echo 'fail[#]';
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
exit;
}
if($fechaRec == ''){
$util->setError(20099,'error','');
$util->PrintErrors();
echo 'fail[#]';
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
exit;
}
$fechaRec = date('Y-m-d',strtotime($fechaRec));
$sucursal->setSucursalId($sucursalId);
$nomSuc = urldecode($sucursal->GetNameById());
$inventario->setSucursalId($sucursalId);
$inventario->setFecha($fechaRec);
$resProds = $inventario->GetSingleProds();
$cantTotal = 0;
$impTotal = 0;
$productos = array();
foreach($resProds as $res){
$producto->setProductoId($res['productoId']);
$info = $producto->Info();
$res['codigoBarra'] = $info['codigoBarra'];
$res['modelo'] = utf8_encode($info['modelo']);
$inventario->setSucursalId($sucursalId);
$inventario->setProductoId($res['productoId']);
$inventario->setFecha($fechaRec);
$res['cantidad'] = $inventario->GetCantByProd();
$res['precio'] = $info['precioVentaIva'];
$res['importe'] = $res['cantidad'] * $res['precio'];
$cantTotal += $res['cantidad'];
$impTotal += $res['importe'];
$productos[] = $res;
}
echo 'ok[#]';
$smarty->assign('fechaRec', $fechaRec);
$smarty->assign('impTotal', $impTotal);
$smarty->assign('cantTotal', $cantTotal);
$smarty->assign('nomSuc', $nomSuc);
$smarty->assign('productos', $productos);
$smarty->assign('DOC_ROOT', DOC_ROOT);
$smarty->display(DOC_ROOT.'/templates/lists/envios-reporte.tpl');
break;
}//switch
?>