Proyecto

General

Perfil

« Anterior | Siguiente » 

Revisión 360

Añadido por Manu Mora Gordillo hace casi 13 años

Ya inserta/modifica/borra historico de portatiles

Ver diferencias:

controlies/trunk/applications/controlies/modules/LaptopsHistory.py
def __init__(self):
pass
def __init__(self,SQLite,id_history,id_laptop,id_state,id_user_type,nif,username,name,comment):
def __init__(self,SQLite,id_historical,id_laptop,id_state,id_user_type,nif,username,name,comment):
self.SQLite = SQLite
self.id_history = id_history
self.id_historical = id_historical
self.id_laptop = id_laptop
self.id_state = id_state
self.id_user_type = id_user_type
......
def delete(self):
sql = "DELETE FROM laptops WHERE id_laptop='"+str(self.id_laptop)+"'"
sql = "DELETE FROM laptops_historical WHERE id_historical='"+str(self.id_historical)+"'"
db = self.SQLite.getDB()
result = db.executesql(sql)
......
data.append(dataType)
return data
def getDataHistory(self):
sql="SELECT * FROM laptops_historical WHERE id_historical='"+str(self.id_historical)+"'"
db = self.SQLite.getDB()
result = db.executesql(sql)
data = {"id_historical":"","id_laptop":"","username":"","name":"","id_user_type":"","nif":"","comment":"","id_state":""}
if len(result)>0:
data = {
"id_historical":str(result[0][0]),
"id_laptop":str(result[0][1]),
"username":str(result[0][3]),
"name":str(result[0][4]),
"id_user_type":str(result[0][5]),
"nif":str(result[0][6]),
"comment":str(result[0][7]),
"id_state":str(result[0][8])
}
return data
def getLastHistory(self):
sql="SELECT username, id_state FROM laptops_historical WHERE id_laptop='"+str(self.id_laptop)+"' ORDER BY datetime desc LIMIT 0,1"
db = self.SQLite.getDB()
result = db.executesql(sql)
data=[]
for r in result:
dataType = {
"username":str(r[0]),
"id_state":str(r[1])
data={"username":"","id_state":""}
if len(result)>0:
data = {
"username":str(result[0][0]),
"id_state":str(result[0][1])
}
data.append(dataType)
return data
controlies/trunk/applications/controlies/views/laptops/form_history.html
jQuery("#form_data_history #commentP").hide();
}
function resetFields(){
jQuery("#form_data_history #username").val("");
jQuery("#form_data_history #id_user_type").val("none");
jQuery("#form_data_history #nif").val("");
jQuery("#form_data_history #name").val("");
}
function showFields(){
hideAllFields();
switch(jQuery("#form_data_history #id_state").val()){
......
jQuery("#form_data_history #commentP").show();
break;
case '1':
resetFields();
jQuery("#form_data_history #commentP").show();
break;
}
if(jQuery("#form_data_history #id_state").val()=="3"){
if(jQuery("#form_data_history #id_state").val()=="3" && jQuery("#form_data_history #action").val()=="add"){
jQuery.post('call/json/getDataLastHistory', jQuery("#form_data_history").serialize(), function(result) {
jQuery("#form_data_history #name").val(result.response['name']);
jQuery("#form_data_history #nif").val(result.response['nif']);
switch(result.response['type']){
case 'teacher': jQuery("#form_data_history #id_user_type").val(1); break;
case 'student': jQuery("#form_data_history #id_user_type").val(2); break;
}
if(result.response['username']!=""){
jQuery("#form_data_history #username").val(result.response['username']);
getDataLDAP();
}
});
}
}
controlies/trunk/applications/controlies/views/laptops/history.html
onClickButton : function (){
addRecordHistory();
}
});
jQuery("#list_history").jqGrid('navButtonAdd','#pager_history',{
caption: "Modificar",
buttonicon :'ui-icon-pencil',
onClickButton : function (){
modifyRecordHistory();
}
});
jQuery("#list_history").jqGrid('navButtonAdd','#pager_history',{
caption: "Borrar",
......
});
}
function rowSelectedHistory(){
var id = jQuery("#list_history").jqGrid('getGridParam','selrow');
if( id == null ){
jQuery( "#dialog-alert" ).dialog({
resizable: false,
height:150,
width:290,
modal: true,
buttons: { "Aceptar": function() { $( this ).dialog( "close" ); }}
}).dialog('open');
return false;
}
return id;
}
function addRecordHistory(){
jQuery("#messageLoading").show();
jQuery("#messageLoading").show();
jQuery("#dialog-form-history").html("").css("display","none");
jQuery("#dialog-form-history").load("form_history.html", function() {
getAllStates();
getAllUserTypes();
jQuery("#form_data_history #action").val("add");
jQuery("#form_data_history #id_laptop").val(jQuery("#form_history #id_laptop").val());
jQuery("#form_data_history #messageFormHistory").html("Los campos marcados con asterisco son obligatorios");
x = (jQuery(window).width()-400)/2;
y = (jQuery(window).height()-300)/2;
jQuery("#messageLoading").hide();
jQuery("#dialog-form-history").dialog({
resizable: false,
position: top,
modal: true,
width: 400,
title: "Añadir histórico"
}).dialog('option', 'position', [x, y]);
});
}
function modifyRecordHistory(){
var id;
jQuery("#messageLoading").show();
var id = rowSelectedHistory();
if(id==false)
return false;
jQuery("#dialog-form-history").html("").css("display","none");
jQuery("#dialog-form-history").load("form_history.html", function() {
getAllStates();
getAllUserTypes();
jQuery("#form_data_history #action").val("modify");
jQuery("#form_data_history #messageFormHistory").html("Los campos marcados con asterisco son obligatorios");
jQuery.post('call/json/getDataHistory',{ id_historical: id }, function(result) {
jQuery("#form_data_history #id_state").val(result.response['id_state']);
jQuery("#form_data_history #id_historical").val(result.response['id_historical']);
jQuery("#form_data_history #id_laptop").val(result.response['id_laptop']);
jQuery("#form_data_history #username").val(result.response['username']);
jQuery("#form_data_history #id_user_type").val(result.response['id_user_type']);
jQuery("#form_data_history #name").val(result.response['name']);
jQuery("#form_data_history #nif").val(result.response['nif']);
jQuery("#form_data_history #comment").val(result.response['comment']);
showFields();
x = (jQuery(window).width()-400)/2;
y = (jQuery(window).height()-300)/2;
jQuery("#messageLoading").hide();
jQuery("#dialog-form-history").dialog({
resizable: false,
modal: true,
width: 400,
title: "Modificar histórico"
}).dialog('option', 'position', [x, y]);
});
});
}
function deleteRecordHistory(){
jQuery("#dialog-form-history").html("").css("display","none");
jQuery("#dialog-form-history").load("form_history.html", function() {
getAllStates();
getAllUserTypes();
jQuery("#form_data_history #action").val("add");
jQuery("#form_data_history #id_laptop").val(jQuery("#form_history #id_laptop").val());
jQuery("#form_data_history #messageForm").html("Todos los campos son obligatorios");
var id = rowSelectedHistory();
if(id==false)
return false;
x = (jQuery(window).width()-400)/2;
y = (jQuery(window).height()-300)/2;
jQuery("#messageLoading").hide();
jQuery("#dialog-form-history").dialog({
resizable: false,
position: top,
modal: true,
width: 400,
title: "Añadir histórico"
}).dialog('option', 'position', [x, y]);
});
jQuery( "#dialog-confirm" ).dialog({
resizable: false,
height:160,
width:350,
modal: true,
buttons: {
"Borrar": function() {
jQuery.post("call/json/deleteHistory","id_historical="+id, function(data){
jQuery("#dialog-confirm").dialog( "close" );
jQuery("#list_history").trigger("reloadGrid");
});
},
"Cancelar": function() {
$(this).dialog( "close" );
}
}
}).dialog('open');
}
function getAllStates(){
controlies/trunk/applications/controlies/controllers/laptops.py
return dict(response = response)
@service.json
@auth.requires_login()
def deleteHistory():
my = SQLiteConnection()
l = LaptopsHistory(my,request.vars["id_historical"],"","","","","","","")
response = l.delete()
return dict(response=response)
@service.json
def getAllStates():
my = SQLiteConnection()
l = LaptopsHistory(my,"","","","","","","","")
......
return dict(response=response)
@service.json
def getDataHistory():
my = SQLiteConnection()
l = LaptopsHistory(my,request.vars["id_historical"],"","","","","","","")
response = l.getDataHistory()
return dict(response=response)
@service.json
def getDataLastHistory():
my = SQLiteConnection()
l = LaptopsHistory(my,"",request.vars["id_laptop"],"","","","","","")

Exportar a: Unified diff