110 lines
2.8 KiB
PHP
Executable File
110 lines
2.8 KiB
PHP
Executable File
<?php
|
|
|
|
include_once('../init.php');
|
|
include_once('../config.php');
|
|
include_once(DOC_ROOT.'/libraries.php');
|
|
|
|
$Usr = $user->Info();
|
|
$smarty->assign('Usr', $Usr);
|
|
|
|
switch($_POST["type"])
|
|
{
|
|
case "addSolicitud":
|
|
|
|
$resSuc = $sucursal->GetSucursalesByEmpresaId();
|
|
$sucursales = $util->DecodeUrlResult($resSuc);
|
|
|
|
$smarty->assign('sucursales', $sucursales);
|
|
$smarty->assign("DOC_ROOT", DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/agregar-solicitud-invparcial-popup.tpl');
|
|
|
|
break;
|
|
|
|
case "saveSolicitud":
|
|
|
|
$inventario->setSucursalId2($_POST["sucursalId"]);
|
|
$inventario->setTipo($_POST["tipo"]);
|
|
|
|
if($inventario->ExistReport()){
|
|
$util->setError(10049,'error');
|
|
$util->PrintErrors();
|
|
echo "fail[#]";
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
|
exit;
|
|
}
|
|
|
|
if(!$inventario->SaveReporteParcial())
|
|
{
|
|
echo "fail[#]";
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
|
}
|
|
else
|
|
{
|
|
echo "ok[#]";
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
|
|
echo "[#]";
|
|
$reportesInv = $inventario->EnumReporteParcial();
|
|
|
|
if(count($reportesInv['items']))
|
|
$reportesInv['items'] = $util->EncodeResult($reportesInv['items']);
|
|
|
|
$items = array();
|
|
foreach($reportesInv['items'] as $res){
|
|
|
|
$sucursal->setSucursalId($res['sucursalId']);
|
|
$res['sucursal'] = urldecode($sucursal->GetNameById());
|
|
|
|
$items[] = $res;
|
|
}
|
|
$reportesInv['items'] = $items;
|
|
|
|
$smarty->assign("reportesInv", $reportesInv);
|
|
$smarty->assign("DOC_ROOT", DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/lists/reportes-invparcial.tpl');
|
|
}
|
|
|
|
break;
|
|
|
|
case "deleteSolicitud":
|
|
|
|
$inventario->setRepInvParcialId($_POST["id"]);
|
|
$info = $inventario->InfoInvParcialById();
|
|
|
|
if(!$inventario->DeleteReporteParcial())
|
|
{
|
|
echo "fail[#]";
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
|
}
|
|
else
|
|
{
|
|
//Eliminamos el archivo generado en reportes de inventario total
|
|
@unlink(DOC_ROOT.'/reportes/'.$info['archivo']);
|
|
|
|
echo "ok[#]";
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
|
|
echo "[#]";
|
|
$reportesInv = $inventario->EnumReporteParcial();
|
|
|
|
if(count($reportesInv['items']))
|
|
$reportesInv['items'] = $util->EncodeResult($reportesInv['items']);
|
|
|
|
$items = array();
|
|
foreach($reportesInv['items'] as $res){
|
|
|
|
$sucursal->setSucursalId($res['sucursalId']);
|
|
$res['sucursal'] = urldecode($sucursal->GetNameById());
|
|
|
|
$items[] = $res;
|
|
}
|
|
$reportesInv['items'] = $items;
|
|
|
|
$smarty->assign("reportesInv", $reportesInv);
|
|
$smarty->assign("DOC_ROOT", DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/lists/reportes-invparcial.tpl');
|
|
}
|
|
|
|
break;
|
|
|
|
}//switch
|
|
|
|
?>
|