Primer commit del sistema avantika sin cambios
This commit is contained in:
314
javascript/datos-generales.js
Executable file
314
javascript/datos-generales.js
Executable file
@@ -0,0 +1,314 @@
|
||||
Event.observe(window, 'load', function() {
|
||||
|
||||
AddEditRfcListeners = function(e) {
|
||||
var el = e.element();
|
||||
var del = el.hasClassName('spanDelete');
|
||||
var id = el.identify();
|
||||
if(del == true)
|
||||
{
|
||||
DeleteRfcPopup(id);
|
||||
return;
|
||||
}
|
||||
|
||||
del = el.hasClassName('spanEdit');
|
||||
if(del == true)
|
||||
{
|
||||
EditRfcPopup(id);
|
||||
}
|
||||
|
||||
del = el.hasClassName('spanView');
|
||||
if(del == true)
|
||||
{
|
||||
ViewRfcPopup(id);
|
||||
}
|
||||
|
||||
del = el.hasClassName('spanSucursales');
|
||||
if(del == true)
|
||||
{
|
||||
ShowSucursales(id);
|
||||
}
|
||||
}
|
||||
|
||||
$('contenido').observe("click", AddEditRfcListeners);
|
||||
|
||||
SucursalesListeners = function(e) {
|
||||
var el = e.element();
|
||||
var del = el.hasClassName('spanDeleteSucursal');
|
||||
var id = el.identify();
|
||||
if(del == true)
|
||||
{
|
||||
DeleteSucursal(id);
|
||||
return;
|
||||
}
|
||||
|
||||
del = el.hasClassName('spanEditSucursal');
|
||||
if(del == true)
|
||||
{
|
||||
EditSucursalPopup(id);
|
||||
return;
|
||||
}
|
||||
|
||||
del = el.hasClassName('spanViewSucursal');
|
||||
if(del == true)
|
||||
{
|
||||
ViewSucursalPopup(id);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$('empresaSucursalesDiv').observe("click", SucursalesListeners);
|
||||
});
|
||||
|
||||
function EditRfcPopup(id)
|
||||
{
|
||||
grayOut(true);
|
||||
$('fview').show();
|
||||
if(id == 0)
|
||||
{
|
||||
$('fview').hide();
|
||||
grayOut(false);
|
||||
return;
|
||||
}
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/datos-generales.php',
|
||||
{
|
||||
method:'post',
|
||||
parameters: {type: "editRfc", id:id},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
FViewOffSet(response);
|
||||
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
|
||||
Event.observe($('editarRfc'), "click", EditarRfc);
|
||||
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
function EditarRfc()
|
||||
{
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/datos-generales.php',
|
||||
{
|
||||
method:'post',
|
||||
parameters: $('editRfcForm').serialize(true),
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
var splitResponse = response.split("[#]");
|
||||
|
||||
if(splitResponse[0] == "fail")
|
||||
{
|
||||
ShowStatusPopUp(splitResponse[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowStatusPopUp(splitResponse[1]);
|
||||
$('contenido').innerHTML = splitResponse[2];
|
||||
HideFview();
|
||||
}
|
||||
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
function ViewRfcPopup(id)
|
||||
{
|
||||
grayOut(true);
|
||||
$('fview').show();
|
||||
if(id == 0)
|
||||
{
|
||||
$('fview').hide();
|
||||
grayOut(false);
|
||||
return;
|
||||
}
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/datos-generales.php',
|
||||
{
|
||||
method:'post',
|
||||
parameters: {type: "viewRfc", id:id},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
FViewOffSet(response);
|
||||
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
|
||||
Event.observe($('btnClose'), "click", function(){ HideFview(); });
|
||||
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
/** SUCURSALES ***/
|
||||
|
||||
function AddSucursal(rfcId)
|
||||
{
|
||||
|
||||
var form = $('agregarSucursalForm').serialize();
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
|
||||
{
|
||||
method:'post',
|
||||
parameters: {form:form, rfcId:rfcId, type: "saveSucursal"},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
var splitResponse = response.split("[#]");
|
||||
|
||||
if(splitResponse[0] == "fail")
|
||||
{
|
||||
ShowStatusPopUp(splitResponse[1])
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowStatusPopUp(splitResponse[1])
|
||||
ShowSucursales(rfcId);
|
||||
HideFview();
|
||||
}
|
||||
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
function AddSucursalDiv(id, rfcId)
|
||||
{
|
||||
grayOut(true);
|
||||
$('fview').show();
|
||||
if(id == 0)
|
||||
{
|
||||
$('fview').hide();
|
||||
grayOut(false);
|
||||
return;
|
||||
}
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
|
||||
{
|
||||
method:'post',
|
||||
parameters: {type: "addSucursal"},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
FViewOffSet(response);
|
||||
Event.observe($('closePopUpDiv'), "click", function(){ AddSucursalDiv(0); });
|
||||
Event.observe($('agregarSucursal'), "click", function(){ AddSucursal(rfcId); });
|
||||
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function EditSucursalPopup(id)
|
||||
{
|
||||
grayOut(true);
|
||||
$('fview').show();
|
||||
if(id == 0)
|
||||
{
|
||||
$('fview').hide();
|
||||
grayOut(false);
|
||||
return;
|
||||
}
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
|
||||
{
|
||||
method:'post',
|
||||
parameters: {type: "editSucursal", id:id},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
FViewOffSet(response);
|
||||
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
|
||||
Event.observe($('editarSucursal'), "click", EditarSucursal);
|
||||
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
function EditarSucursal()
|
||||
{
|
||||
var form = $('editSucursalForm').serialize();
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
|
||||
{
|
||||
method:'post',
|
||||
parameters: {form:form, type: "saveEditSucursal", sucursalId:$('sucursalId').value},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
var splitResponse = response.split("[#]");
|
||||
|
||||
if(splitResponse[0] == "fail")
|
||||
{
|
||||
ShowStatusPopUp(splitResponse[1])
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowStatusPopUp(splitResponse[1]);
|
||||
ShowSucursales(splitResponse[2]);
|
||||
HideFview();
|
||||
}
|
||||
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
function ViewSucursalPopup(id)
|
||||
{
|
||||
grayOut(true);
|
||||
$('fview').show();
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
|
||||
{
|
||||
method:'post',
|
||||
parameters: {type: "viewSucursal", id:id},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
FViewOffSet(response);
|
||||
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
|
||||
Event.observe($('btnClose'), "click", function(){ HideFview(); });
|
||||
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
function DeleteSucursal(id)
|
||||
{
|
||||
var message = "Realmente deseas eliminar esta sucursal?";
|
||||
if(!confirm(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
|
||||
{
|
||||
method:'post',
|
||||
parameters: {type: "deleteSucursal", sucursalId: id},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
var splitResponse = response.split("[#]");
|
||||
|
||||
ShowStatus(splitResponse[1]);
|
||||
ShowSucursales(splitResponse[2]);
|
||||
HideFview();
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
function ShowSucursales(id)
|
||||
{
|
||||
var rfcId = id;
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
|
||||
{
|
||||
method:'post',
|
||||
parameters: {type: "listSucursales", rfc: id},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
|
||||
$('empresaSucursalesDiv').innerHTML = response;
|
||||
Event.observe($('addSucursal'), "click", function(){ AddSucursalDiv(1, rfcId); });
|
||||
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user