214 lines
5.7 KiB
PHP
Executable File
214 lines
5.7 KiB
PHP
Executable File
<?php
|
|
|
|
include_once('../init.php');
|
|
include_once('../config.php');
|
|
include_once(DOC_ROOT.'/libraries.php');
|
|
|
|
session_start();
|
|
|
|
$sucursalId = $_SESSION['idSuc'];
|
|
$empresaId = $_SESSION['empresaId'];
|
|
|
|
$Usr = $user->Info();
|
|
$smarty->assign('Usr', $Usr);
|
|
|
|
switch($_POST['type']){
|
|
|
|
case 'buscar':
|
|
|
|
if($Usr['type'] == 'facturacion')
|
|
$sucursalId = $_POST['idSucursal'];
|
|
|
|
$facturacion->setSucursalId($sucursalId);
|
|
$facturacion->setNombre($_POST['nombre']);
|
|
$facturacion->setRfc($_POST['rfc']);
|
|
$facturacion->setMes($_POST['mes']);
|
|
$facturacion->setAnio($_POST['anio']);
|
|
$facturacion->setTiposComprobanteId($_POST['tiposComprobanteId']);
|
|
$facturacion->setStatus($_POST['status']);
|
|
|
|
$comprobantes = $facturacion->Buscar();
|
|
|
|
$items = array();
|
|
foreach($comprobantes['items'] as $res){
|
|
|
|
$cliente->setClienteId($res['userId']);
|
|
$infC = $cliente->Info();
|
|
$res['nombre'] = utf8_encode($infC['nombre']);
|
|
$res['rfc'] = $infC['rfc'];
|
|
|
|
$res['total'] = number_format($res['total'],2);
|
|
|
|
$timbreFiscal = unserialize($res['timbreFiscal']);
|
|
$res["uuid"] = $timbreFiscal["UUID"];
|
|
|
|
$res['fecha'] = date('d-m-Y H:i:s',strtotime($res['fecha']));
|
|
|
|
$venta->setComprobanteId($res['comprobanteId']);
|
|
$resFolios = $venta->GetFoliosByCompId();
|
|
|
|
$folios = array();
|
|
foreach($resFolios as $val)
|
|
$folios[] = $val['folio'];
|
|
|
|
$res['tickets'] = implode(',',$folios);
|
|
|
|
$items[] = $res;
|
|
}
|
|
$comprobantes['items'] = $items;
|
|
|
|
echo 'ok[#]';
|
|
|
|
$version = $_SESSION['version'];
|
|
|
|
$smarty->assign('version', $version);
|
|
$smarty->assign('comprobantes', $comprobantes);
|
|
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/lists/facturacion.tpl');
|
|
|
|
break;
|
|
|
|
case 'buscarMens':
|
|
|
|
echo 'ok[#]';
|
|
|
|
if($Usr['type'] == 'facturacion')
|
|
$sucursalId = $_POST['idSucursal'];
|
|
|
|
$facturacion->setSucursalId($sucursalId);
|
|
$facturacion->setNombre($_POST['nombre']);
|
|
$facturacion->setRfc($_POST['rfc']);
|
|
$facturacion->setMes($_POST['mes']);
|
|
$facturacion->setAnio($_POST['anio']);
|
|
$facturacion->setTiposComprobanteId($_POST['tiposComprobanteId']);
|
|
$facturacion->setStatus($_POST['status']);
|
|
|
|
$comprobantes = $facturacion->BuscarMens();
|
|
|
|
$items = array();
|
|
foreach($comprobantes['items'] as $res){
|
|
|
|
$rfc->setRfcId(1);
|
|
$infC = $rfc->Info();
|
|
$res['nombre'] = utf8_encode($infC['razonSocial']);
|
|
$res['rfc'] = $infC['rfc'];
|
|
|
|
$res['total'] = number_format($res['total'],2);
|
|
|
|
$timbreFiscal = unserialize($res['timbreFiscal']);
|
|
$res["uuid"] = $timbreFiscal["UUID"];
|
|
|
|
$res['fecha'] = date('d-m-Y H:i:s',strtotime($res['fecha']));
|
|
|
|
$venta->setComprobanteId($res['comprobanteId']);
|
|
$resFolios = $venta->GetFoliosByCompId();
|
|
|
|
$folios = array();
|
|
foreach($resFolios as $val)
|
|
$folios[] = $val['folio'];
|
|
|
|
$res['tickets'] = implode(',',$folios);
|
|
|
|
$items[] = $res;
|
|
}
|
|
$comprobantes['items'] = $items;
|
|
|
|
|
|
|
|
$version = $_SESSION['version'];
|
|
|
|
$smarty->assign('version', $version);
|
|
$smarty->assign('comprobantes', $comprobantes);
|
|
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/lists/facturacion-mensual.tpl');
|
|
|
|
break;
|
|
|
|
case 'showDetails':
|
|
|
|
$comprobanteId = $_POST['comprobanteId'];
|
|
|
|
$infC = $comprobante->GetInfoComprobante($comprobanteId);
|
|
|
|
$info['serie'] = $infC['serie'];
|
|
$info['folio'] = $infC['folio'];
|
|
|
|
if($infC['facturaGlobal']){
|
|
$rfc->setRfcId(1);
|
|
$infR = $rfc->Info();
|
|
$info['rfc'] = $infR['rfc'];
|
|
}else{
|
|
$cliente->setClienteId($infC['userId']);
|
|
$infU = $cliente->Info();
|
|
$info['rfc'] = $infU['rfc'];
|
|
}
|
|
|
|
|
|
$info['version'] = $_SESSION['version'];
|
|
|
|
$smarty->assign("info", $info);
|
|
$smarty->assign('comprobanteId', $comprobanteId);
|
|
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/acciones-factura-popup.tpl');
|
|
|
|
break;
|
|
|
|
case 'enviarPdf':
|
|
|
|
$comprobanteId = $_POST['comprobanteId'];
|
|
|
|
$facturacion->setComprobanteId($comprobanteId);
|
|
$facturacion->SendComprobante();
|
|
|
|
echo 'ok[#]';
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
|
|
|
break;
|
|
|
|
case 'cancelarDiv':
|
|
|
|
$comprobanteId = $_POST['comprobanteId'];
|
|
|
|
$infC = $comprobante->GetInfoComprobante($comprobanteId);
|
|
|
|
$info['serie'] = $infC['serie'];
|
|
$info['folio'] = $infC['folio'];
|
|
$info['status'] = $infC['status'];
|
|
|
|
$cliente->setClienteId($infC['userId']);
|
|
$infU = $cliente->Info();
|
|
|
|
$info['rfc'] = $infU['rfc'];
|
|
$info['version'] = $_SESSION['version'];
|
|
|
|
$smarty->assign('info', $info);
|
|
$smarty->assign('comprobanteId', $comprobanteId);
|
|
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/cancelar-factura-popup.tpl');
|
|
|
|
break;
|
|
|
|
case 'cancelarFactura':
|
|
|
|
$facturacion->setComprobanteId($_POST['comprobanteId']);
|
|
$facturacion->setMotivoCancelacion($_POST['motivo']);
|
|
|
|
if(!$facturacion->CancelarComprobante()){
|
|
echo 'fail[#]';
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
|
}else{
|
|
//Cambiamos a Activo el status del Ticket
|
|
$ventaId = $facturacion->GetVentaId();
|
|
|
|
$venta->setVentaId($ventaId);
|
|
$venta->setStatus('Activo');
|
|
$venta->UpdateStatus();
|
|
|
|
echo 'ok[#]';
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
|
|
}//else
|
|
break;
|
|
|
|
}//switch
|
|
|
|
?>
|