193 lines
4.8 KiB
PHP
Executable File
193 lines
4.8 KiB
PHP
Executable File
<?php
|
|
|
|
include_once('../init.php');
|
|
include_once('../config.php');
|
|
include_once(DOC_ROOT.'/libraries.php');
|
|
|
|
session_start();
|
|
|
|
$_SESSION['empresaId'] = 15;
|
|
|
|
switch($_POST["type"]){
|
|
|
|
case 'doLogin':
|
|
|
|
$rfc = trim($_POST['rfc']);
|
|
|
|
if($rfc == ''){
|
|
$util->setError(10057,'error','');
|
|
$util->PrintErrors();
|
|
echo "fail[#]";
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
|
|
exit;
|
|
}
|
|
|
|
$cliente->setRfc($rfc);
|
|
if(!$cliente->LoginFactura())
|
|
{
|
|
echo "fail[#]";
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
|
}
|
|
else
|
|
{
|
|
echo "ok[#]";
|
|
}
|
|
|
|
break;
|
|
|
|
case 'updateClte':
|
|
|
|
$clienteId = $_POST['clienteId'];
|
|
$cliente->setRfc(trim($_POST["rfc"]));
|
|
|
|
if(!$clienteId){
|
|
$clienteId = $cliente->ExistRfc();
|
|
}else{
|
|
|
|
$idCliente = $cliente->ExistRfc();
|
|
if($idCliente > 0 && $idCliente != $clienteId){
|
|
$util->setError(10058,'error','');
|
|
$util->PrintErrors();
|
|
echo 'fail[#]';
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
|
|
exit;
|
|
}
|
|
}
|
|
$cliente->setClienteId($clienteId);
|
|
$cliente->setRazonSocial(utf8_decode($_POST["razonSocial"]));
|
|
$cliente->setCalle(utf8_decode($_POST["calle"]));
|
|
$cliente->setNoExt(utf8_decode($_POST["noExt"]));
|
|
$cliente->setNoInt(utf8_decode($_POST["noInt"]));
|
|
$cliente->setReferencia(utf8_decode($_POST["referencia"]));
|
|
$cliente->setColonia(utf8_decode($_POST["colonia"]));
|
|
$cliente->setLocalidad(utf8_decode($_POST["localidad"]));
|
|
$cliente->setMunicipio(utf8_decode($_POST["municipio"]));
|
|
$cliente->setCodigoPostal(utf8_decode($_POST["cp"]));
|
|
$cliente->setEstado(utf8_decode($_POST["estado"]));
|
|
$cliente->setPais(utf8_decode($_POST["pais"]));
|
|
$cliente->setTelefono(utf8_decode($_POST["telefono"]));
|
|
$cliente->setEmail($_POST["email"]);
|
|
|
|
if($clienteId){
|
|
|
|
if($cliente->Update()){
|
|
echo "ok[#]";
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
|
|
}else{
|
|
echo 'fail[#]';
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
|
|
}
|
|
|
|
}else{
|
|
|
|
$clienteId = $cliente->Save();
|
|
|
|
if($clienteId){
|
|
$_SESSION['loginKey'] = $clienteId;
|
|
echo "ok[#]";
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
|
|
}else{
|
|
echo 'fail[#]';
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
|
|
}
|
|
|
|
echo '[#]';
|
|
echo $clienteId;
|
|
|
|
}//else
|
|
|
|
break;
|
|
|
|
case 'addTicket':
|
|
|
|
$_SESSION['idVta'] = '';
|
|
|
|
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/facturar-ticket-popup.tpl');
|
|
|
|
break;
|
|
|
|
case 'saveAddTicket':
|
|
|
|
$ventaId = intval(trim($_POST['ventaId']));
|
|
|
|
if($ventaId == 0){
|
|
$util->setError(10059,'error','');
|
|
$util->PrintErrors();
|
|
echo 'fail[#]';
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
|
exit;
|
|
}
|
|
|
|
//Checamos si existe la Nota de Venta
|
|
$venta->setVentaId($ventaId);
|
|
$infV = $venta->Info();
|
|
|
|
if($infV == ''){
|
|
$util->setError(10060,'error','');
|
|
$util->PrintErrors();
|
|
echo 'fail[#]';
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
|
exit;
|
|
}
|
|
|
|
//Checamos si esta Facturada
|
|
|
|
if($infV['status'] == 'Facturada'){
|
|
$util->setError(10061,'error','');
|
|
$util->PrintErrors();
|
|
echo 'fail[#]';
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
|
exit;
|
|
}
|
|
|
|
if($infV['status'] == 'Cancelado'){
|
|
$util->setError(10062,'error','');
|
|
$util->PrintErrors();
|
|
echo 'fail[#]';
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
|
exit;
|
|
}
|
|
|
|
//Checamos si esta Facturada
|
|
$fechaV = date('Y-m-d',strtotime($infV['fecha']));
|
|
|
|
$fechaHoy = date('Y-m-d');
|
|
$anioMes = date('Y-m',strtotime($fechaHoy));
|
|
|
|
$fechaIni = $anioMes.'-01';
|
|
$fechaFin = $anioMes.'-31';
|
|
|
|
$fechaT = $fechaIni;
|
|
$fecha2 = date('Y-m-d', strtotime($fechaT.' + 1 months'));
|
|
$fechaUlt = date('Y-m-d', strtotime($fecha2.' - 3 days'));
|
|
|
|
$fechaAnt = date('Y-m-d', strtotime($fechaIni.' - 3 days'));
|
|
|
|
if($fechaV >= $fechaIni && $fechaV <= $fechaFin){
|
|
$showError = false;
|
|
}elseif($fechaV > $fechaAnt && $fechaV <= $fechaFin){
|
|
$showError = false;
|
|
}else{
|
|
$showError = true;
|
|
}
|
|
|
|
if($showError){
|
|
$util->setError(10063,'error','');
|
|
$util->PrintErrors();
|
|
echo 'fail[#]';
|
|
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
|
exit;
|
|
}
|
|
|
|
$_SESSION['idVta'] = $ventaId;
|
|
|
|
echo 'ok[#]';
|
|
echo $ventaId;
|
|
|
|
break;
|
|
|
|
}//switch
|
|
|
|
?>
|