Revisión 353
Añadido por Manu Mora Gordillo hace casi 13 años
controlies/trunk/applications/controlies/controllers/laptops.py | ||
---|---|---|
return dict(response=response)
|
||
|
||
@service.json
|
||
def getAllStates():
|
||
my = SQLiteConnection()
|
||
l = Laptops(my,"","","")
|
||
response = l.getAllStates()
|
||
return dict(response=response)
|
||
|
||
@service.json
|
||
def getAllUserTypes():
|
||
my = SQLiteConnection()
|
||
l = Laptops(my,"","","")
|
||
response = l.getAllUserTypes()
|
||
return dict(response=response)
|
||
|
||
@service.json
|
||
@auth.requires_login()
|
||
def delete():
|
||
my = SQLiteConnection()
|
||
... | ... | |
def laptops():
|
||
return dict()
|
||
|
||
def history():
|
||
return dict()
|
||
|
||
def form_history():
|
||
return dict()
|
||
|
controlies/trunk/applications/controlies/modules/Laptops.py | ||
---|---|---|
sql = "SELECT * FROM laptops_historical lh INNER JOIN states s ON lh.id_state=s.id_state"
|
||
sql = sql + " WHERE lh.id_laptop='"+args["id_laptop"]+"'"
|
||
sql = sql + " ORDER BY "+args['sidx']+" "+args['sord']
|
||
print sql
|
||
result = db.executesql(sql)
|
||
print result[0]
|
||
|
||
rows = []
|
||
for reg in result:
|
||
row = {
|
||
... | ... | |
"trademark":r[1]+" / "+r[2]
|
||
}
|
||
data.append(dataType)
|
||
return data
|
||
|
||
def getAllStates(self):
|
||
sql="SELECT * FROM states ORDER BY state"
|
||
db = self.SQLite.getDB()
|
||
result = db.executesql(sql)
|
||
|
||
data=[]
|
||
for r in result:
|
||
dataType = {
|
||
"id_state":str(r[0]),
|
||
"state":r[1]
|
||
}
|
||
data.append(dataType)
|
||
return data
|
||
|
||
def getAllUserTypes(self):
|
||
sql="SELECT * FROM users_types ORDER BY user_type"
|
||
db = self.SQLite.getDB()
|
||
result = db.executesql(sql)
|
||
|
||
data=[]
|
||
for r in result:
|
||
dataType = {
|
||
"id_user_type":str(r[0]),
|
||
"user_type":r[1]
|
||
}
|
||
data.append(dataType)
|
||
return data
|
controlies/trunk/applications/controlies/views/laptops/history.html | ||
---|---|---|
<script language="javascript">
|
||
|
||
$(function() {
|
||
$("#cancelButton")
|
||
.button({ icons: { primary: "ui-icon-close"}})
|
||
.click( function(){ $('#dialog-form').dialog('close'); });
|
||
});
|
||
|
||
function print_grid_historical(){
|
||
jQuery("#table_history #list_history").jqGrid({
|
||
url:"/controlies/laptops/call/json/listHistorical",
|
||
data: "{}",
|
||
datatype: 'json',
|
||
mtype: 'GET',
|
||
contentType: "application/json; charset=utf-8",
|
||
complete: function(jsondata, stat) {
|
||
if (stat == "success") {
|
||
var thegrid = jQuery("#table_history #list_history")[0];
|
||
thegrid.addJSONData(JSON.parse(jsondata.responseText).d);
|
||
}
|
||
},
|
||
|
||
colNames:['Fecha/Hora','Estado','Login','Nombre','Comentario'],
|
||
colModel:[
|
||
{name:'datetime',index:'datetime', width:60, align:"center"},
|
||
{name:'state',index:'state', width:60, align:"center"},
|
||
{name:'username',index:'username', width:50, align:"center"},
|
||
{name:'name',index:'name', width:100, align:"center"},
|
||
{name:'comment',index:'comment', width:100, align:"center"}
|
||
],
|
||
postData:{id_laptop:$("#form_history #id_laptop").val()},
|
||
rowNum:25,
|
||
height:150,
|
||
width: 780,
|
||
rowList:[25,50,75],
|
||
pager: '#pager_history',
|
||
sortname: 'datetime',
|
||
autowidth: false,
|
||
viewrecords: true,
|
||
sortorder: "desc",
|
||
caption:"Historial"
|
||
|
||
});
|
||
jQuery("#list_history").jqGrid('navGrid','#pager_history',{add:false,edit:false,del:false,search:false,refresh:false});
|
||
|
||
jQuery("#list_history").jqGrid('navButtonAdd','#pager_history',{
|
||
caption: "Insertar",
|
||
buttonicon :'ui-icon-plus',
|
||
onClickButton : function (){
|
||
addRecord();
|
||
}
|
||
});
|
||
jQuery("#list_history").jqGrid('navButtonAdd','#pager_history',{
|
||
caption: "Borrar",
|
||
buttonicon :'ui-icon-trash',
|
||
onClickButton : function (){
|
||
deleteRecord();
|
||
}
|
||
});
|
||
}
|
||
|
||
function addRecord(){
|
||
|
||
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 #messageForm").html("Todos los campos son obligatorios");
|
||
|
||
x = (jQuery(window).width()-350)/2;
|
||
y = (jQuery(window).height()-300)/2;
|
||
|
||
jQuery("#messageLoading").hide();
|
||
|
||
jQuery("#dialog-form-history").dialog({
|
||
resizable: false,
|
||
position: top,
|
||
modal: true,
|
||
width: 350,
|
||
title: "Añadir histórico"
|
||
}).dialog('option', 'position', [x, y]);
|
||
});
|
||
}
|
||
|
||
function getAllStates(){
|
||
$.post("/controlies/laptops/call/json/getAllStates", function(result) {
|
||
$.each( result.response, function(i, l){
|
||
jQuery("#form_data_history #id_state").append("<option value='"+l.id_state+"'>"+l.state+"</option>");
|
||
});
|
||
});
|
||
}
|
||
|
||
function getAllUserTypes(){
|
||
$.post("/controlies/laptops/call/json/getAllUserTypes", function(result) {
|
||
$.each( result.response, function(i, l){
|
||
jQuery("#form_data_history #id_user_type").append("<option value='"+l.id_user_type+"'>"+l.user_type+"</option>");
|
||
});
|
||
});
|
||
}
|
||
</script>
|
||
|
||
<form id="form_history">
|
||
<input type="hidden" id="id_laptop" name="id_laptop"/>
|
||
<div style="text-align:center;">
|
||
<b>Marca / Modelo:</b> <span id="id_trademark"></span> |
|
||
<b>Número Serie:</b> <span id="serial_number"></span>
|
||
</div>
|
||
<br><br>
|
||
<div>
|
||
<div id="table_history" class="centerGrid">
|
||
<table width="100%" align="center">
|
||
<tr>
|
||
<td style="width:2%"></td>
|
||
<td style="text-align:center;"><table id="list_history" width="100%"></table></td>
|
||
<td style="width:2%"></td>
|
||
</tr>
|
||
</table>
|
||
<div id="pager_history" style=""></div>
|
||
<div id="filter_history" style="margin-left:30%;display:none">Buscar nada</div>
|
||
</div>
|
||
</div>
|
||
<div id="message" style="text-align:center; font-weight:bold; color:red; padding:3px; "></div>
|
||
<div style="text-align:center;"><button type="button" id="cancelButton" style="width:100px;">Cerrar</button></div>
|
||
</form>
|
||
<div id="dialog-form-history"></div>
|
||
controlies/trunk/applications/controlies/views/laptops/form.html | ||
---|---|---|
<script language="javascript">
|
||
|
||
$(function() {
|
||
$("#name").focus();
|
||
$("#id_trademark").focus();
|
||
$("#saveButton").button({ icons: { primary: "ui-icon-disk"}});
|
||
$("#cancelButton")
|
||
.button({ icons: { primary: "ui-icon-close"}})
|
||
... | ... | |
break;
|
||
}
|
||
case "serial_number_exists":{
|
||
jQuery('#numero_serieTag').css("color","red");
|
||
jQuery('#numero_serie').effect("highlight", {"color":"yellow"}, 1000).focus();
|
||
jQuery('#serial_numberTag').css("color","red");
|
||
jQuery('#serial_number').effect("highlight", {"color":"yellow"}, 1000).focus();
|
||
jQuery('#message').html("Ya existe ese número de serie").effect("slide");
|
||
break;
|
||
}
|
controlies/trunk/applications/controlies/views/laptops/form_history.html | ||
---|---|---|
|
||
$(function() {
|
||
$("#name").focus();
|
||
$("#saveButton").button({ icons: { primary: "ui-icon-disk"}});
|
||
$("#cancelButton")
|
||
$("#saveButtonFormHistory").button({ icons: { primary: "ui-icon-disk"}});
|
||
$("#cancelButtonFormHistory")
|
||
.button({ icons: { primary: "ui-icon-close"}})
|
||
.click( function(){ $('#dialog-form').dialog('close'); });
|
||
.click( function(){ $('#dialog-form-history').dialog('close'); });
|
||
});
|
||
|
||
function restartStyle(){
|
||
... | ... | |
$('#message').html("");
|
||
}
|
||
|
||
|
||
function print_grid_historical(){
|
||
jQuery("#table_history #list_history").jqGrid({
|
||
url:"/controlies/laptops/call/json/listHistorical",
|
||
data: "{}",
|
||
datatype: 'json',
|
||
mtype: 'GET',
|
||
contentType: "application/json; charset=utf-8",
|
||
complete: function(jsondata, stat) {
|
||
if (stat == "success") {
|
||
var thegrid = jQuery("#table_history #list_history")[0];
|
||
thegrid.addJSONData(JSON.parse(jsondata.responseText).d);
|
||
}
|
||
},
|
||
|
||
colNames:['Fecha/Hora','Estado','Login','Nombre','Comentario'],
|
||
colModel:[
|
||
{name:'datetime',index:'datetime', width:60, align:"center"},
|
||
{name:'state',index:'state', width:60, align:"center"},
|
||
{name:'username',index:'username', width:50, align:"center"},
|
||
{name:'name',index:'name', width:100, align:"center"},
|
||
{name:'comment',index:'comment', width:100, align:"center"}
|
||
],
|
||
postData:{id_laptop:$("#form_data_history #id_laptop").val()},
|
||
rowNum:25,
|
||
height:150,
|
||
width: 780,
|
||
rowList:[25,50,75],
|
||
pager: '#pager_history',
|
||
sortname: 'datetime',
|
||
autowidth: false,
|
||
viewrecords: true,
|
||
sortorder: "desc",
|
||
caption:"Historial"
|
||
|
||
});
|
||
jQuery("#list_history").jqGrid('navGrid','#pager_history',{add:false,edit:false,del:false,search:false,refresh:false});
|
||
|
||
jQuery("#list_history").jqGrid('navButtonAdd','#pager_history',{
|
||
caption: "Insertar",
|
||
buttonicon :'ui-icon-plus',
|
||
onClickButton : function (){
|
||
addRecord();
|
||
}
|
||
});
|
||
jQuery("#list_history").jqGrid('navButtonAdd','#pager_history',{
|
||
caption: "Borrar",
|
||
buttonicon :'ui-icon-trash',
|
||
onClickButton : function (){
|
||
deleteRecord();
|
||
}
|
||
});
|
||
}
|
||
|
||
function send(){
|
||
|
||
restartStyle();
|
||
jQuery.post('call/json/modify', jQuery("#form_data").serialize(), function(result) {
|
||
jQuery.post('call/json/modify', jQuery("#form_data_history").serialize(), function(result) {
|
||
switch(result.response){
|
||
case "OK":{
|
||
jQuery('#message').html("Operación realizada correctamente").css("color","green").effect("highlight", {"color":"yellow"}, 1000);
|
||
... | ... | |
<form id="form_data_history" onsubmit="return send();">
|
||
<input type="hidden" id="action" name="action"/>
|
||
<input type="hidden" id="id_laptop" name="id_laptop"/>
|
||
<div style="text-align:center;">
|
||
<b>Marca / Modelo:</b> <span id="id_trademark"></span> |
|
||
<b>Número Serie:</b> <span id="serial_number"></span>
|
||
</div>
|
||
<br><br>
|
||
<div>
|
||
<div id="table_history" class="centerGrid">
|
||
<table width="100%" align="center">
|
||
<tr>
|
||
<td style="width:2%"></td>
|
||
<td style="text-align:center;"><table id="list_history" width="100%"></table></td>
|
||
<td style="width:2%"></td>
|
||
</tr>
|
||
</table>
|
||
<div id="pager_history" style=""></div>
|
||
<div id="filter_history" style="margin-left:30%;display:none">Buscar nada</div>
|
||
</div>
|
||
<p><span id="id_statesTag">Estado (*)</span><br>
|
||
<select type="text" id="id_state" name="id_state">
|
||
<option value="none">Seleccione...</option>
|
||
</select>
|
||
</p>
|
||
<p><span id="id_statesTag">Tipo usuario (*)</span><br>
|
||
<select type="text" id="id_user_type" name="id_user_type">
|
||
<option value="none">Seleccione...</option>
|
||
</select>
|
||
</p>
|
||
<p><span id="usernameTag">Login (*)</span><br><input type="text" id="username" name="username" size="20" maxlength="200"/></p>
|
||
<p><span id="nameTag">Nombre y Apellidos</span><br><input type="text" id="name" name="name" size="35" maxlength="200"/></p>
|
||
<p><span id="commentTag">Comentario</span><br><input type="text" id="comment" name="comment" size="35" maxlength="200"/></p>
|
||
</div>
|
||
<div id="message" style="text-align:center; font-weight:bold; color:red; padding:3px; "></div>
|
||
<div style="text-align:center;"><button type="button" id="cancelButton" style="width:100px;">Cerrar</button></div>
|
||
</form>
|
||
<div style="text-align:center;"><button id="saveButtonFormHistory" type="submit" style="width:100px;">Guardar</button> <button type="button" id="cancelButtonFormHistory" style="width:100px;">Cancelar</button></div>
|
||
<p style="padding-top:10px; text-align:center; font-size:10px;" id="messageForm"></p>
|
||
</form>
|
controlies/trunk/applications/controlies/views/laptops/index.html | ||
---|---|---|
</div>
|
||
|
||
<div id="dialog-form"></div>
|
||
<div id="dialog-form2"></div>
|
||
|
||
<div id="dialog-confirm" title="¿Borrar el registro seleccionado?" style="display:none;">
|
||
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Este elemento quedará permanentemente eliminado. ¿Está seguro?</p>
|
||
... | ... | |
return false;
|
||
|
||
jQuery("#dialog-form").html("").css("display","none");
|
||
jQuery("#dialog-form").load("form_history.html", function() {
|
||
jQuery("#form_data_history #id_laptop").val(id);
|
||
jQuery("#dialog-form").load("history.html", function() {
|
||
jQuery("#form_history #id_laptop").val(id);
|
||
print_grid_historical();
|
||
jQuery("#form_data_history #action").val("modify");
|
||
|
||
jQuery.post('call/json/getLaptopData',{ id_laptop: id }, function(result) {
|
||
|
||
jQuery("#form_data_history #id_laptop").val(result.response['id_laptop']);
|
||
jQuery("#form_data_history #serial_number").html(result.response['serial_number']);
|
||
jQuery("#form_data_history #id_trademark").html(result.response['id_trademark']);
|
||
jQuery("#form_history #id_laptop").val(result.response['id_laptop']);
|
||
jQuery("#form_history #serial_number").html(result.response['serial_number']);
|
||
jQuery("#form_history #id_trademark").html(result.response['id_trademark']);
|
||
|
||
x = (jQuery(window).width()-850)/2;
|
||
y = (jQuery(window).height()-500)/2;
|
Exportar a: Unified diff
Historial de portátiles