Index: controlies/trunk/debian/changelog
===================================================================
--- controlies/trunk/debian/changelog	(revision 421)
+++ controlies/trunk/debian/changelog	(revision 422)
@@ -1,3 +1,10 @@
+controlies (0.6.4-3) unstable; urgency=low
+
+  * Se a�aden nuevos campos al formulario de BD de portatiles
+  * Se a�aden los informes
+
+ -- Manuel Mora Gordillo <manuito@gmail.com>  Tue, 30 Oct 2012 10:30:00 +0200
+
 controlies (0.6.4-2) unstable; urgency=low
 
   * Correcci�n de errores
Index: controlies/trunk/applications/controlies/models/menu.py
===================================================================
--- controlies/trunk/applications/controlies/models/menu.py	(revision 421)
+++ controlies/trunk/applications/controlies/models/menu.py	(revision 422)
@@ -56,7 +56,7 @@
 
 response.menu+=[('Informes', False, None,[            
             ('Compromisos Portátiles', False,URL( 'reports', 'laptops')),
-            ('Usuarios', False,URL( 'reports', 'users')),
+            #('Usuarios', False,URL( 'reports', 'users')),
             ]
    )]
 
Index: controlies/trunk/applications/controlies/models/controliesDB.py
===================================================================
--- controlies/trunk/applications/controlies/models/controliesDB.py	(revision 421)
+++ controlies/trunk/applications/controlies/models/controliesDB.py	(revision 422)
@@ -2,6 +2,11 @@
 cdb.define_table('laptops', 
                         Field('id_laptop','integer'),
                         Field('serial_number','string'),
+                        Field('name','string'),
+                        Field('mac_eth0','string'),
+                        Field('mac_wlan0','string'),
+                        Field('battery_sn','string'),
+                        Field('charger_sn','string'),
                         Field('id_trademark','integer'),
                         primarykey=['id_laptop'])
 
Index: controlies/trunk/applications/controlies/views/laptops/index.html
===================================================================
--- controlies/trunk/applications/controlies/views/laptops/index.html	(revision 421)
+++ controlies/trunk/applications/controlies/views/laptops/index.html	(revision 422)
@@ -130,7 +130,7 @@
 				getAllLaptopTypes();
 				            	
                 jQuery("#form_data #action").val("add");
-                jQuery("#form_data #messageForm").html("Todos los campos son obligatorios");                                     
+                jQuery("#form_data #messageForm").html("Los campos marcados con asterisco son obligatorios");                                     
         
                 x = (jQuery(window).width()-350)/2;
                 y = (jQuery(window).height()-500)/2;
@@ -162,14 +162,14 @@
 				getAllLaptopTypes();
 
 				jQuery("#form_data #action").val("modify");
-				jQuery("#form_data #messageForm").html("Todos los campos son obligatorios");
+				jQuery("#form_data #messageForm").html("Los campos marcados con asterisco son obligatorios");
 				
-				jQuery.post('call/json/getLaptopData',{ id_laptop: id }, function(result) {						
+				jQuery.post('call/json/getLaptopData',{ id_laptop: id }, function(result) {
+					jQuery.each(result.response, function(index, value) {
+						try { jQuery("#form_data #"+index).val(value); }
+						catch(err){ }
+					});			
 
-					jQuery("#form_data #id_laptop").val(result.response['id_laptop']);
-					jQuery("#form_data #serial_number").val(result.response['serial_number']);
-					jQuery("#form_data #id_trademark").val(result.response['id_trademark']);					
-
 					x = (jQuery(window).width()-350)/2;
 					y = (jQuery(window).height()-500)/2;
 					
Index: controlies/trunk/applications/controlies/views/laptops/form.html
===================================================================
--- controlies/trunk/applications/controlies/views/laptops/form.html	(revision 421)
+++ controlies/trunk/applications/controlies/views/laptops/form.html	(revision 422)
@@ -34,6 +34,18 @@
                     jQuery('#message').html("Ya existe ese número de serie").effect("slide");                  
                     break;
                 }
+                case "mac_eth0_exists":{
+                    jQuery('#mac_eth0Tag').css("color","red");
+                    jQuery('#mac_eth0').effect("highlight", {"color":"yellow"}, 1000).focus();
+                    jQuery('#message').html("Ya hay otro equipo con esa mac").effect("slide");                  
+                    break;
+                }
+                case "mac_wlan0_exists":{
+                    jQuery('#mac_wlan0Tag').css("color","red");
+                    jQuery('#mac_wlan0').effect("highlight", {"color":"yellow"}, 1000).focus();
+                    jQuery('#message').html("Ya hay otro equipo con esa mac").effect("slide");                  
+                    break;
+                }
                 default:{
                     jQuery('#'+result.response+"Tag").css("color","red");
                     jQuery('#'+result.response).effect("highlight", {"color":"yellow"}, 1000).focus();
@@ -52,12 +64,17 @@
     <input type="hidden" id="action" name="action"/>
     <input type="hidden" id="id_laptop" name="id_laptop"/>    
     <div>
-		<p><span id="id_trademarkTag">Marca / Modelo</span><br>
+		<p><span id="id_trademarkTag">Marca / Modelo (*)</span><br>
 			<select type="text" id="id_trademark" name="id_trademark">
 				<option value="none">Seleccione...</option>
 			</select>
 		</p>    
-		<p><span id="serial_numberTag">Número Serie</span><br><input type="text" id="serial_number" name="serial_number"/></p>
+		<p><span id="serial_numberTag">Número Serie (*)</span><br><input type="text" id="serial_number" name="serial_number"/></p>
+		<p><span id="nameTag">Nombre</span><br><input type="text" id="name" name="name" maxlength="20"/></p>
+		<p><span id="battery_snTag">Número Serie Batería</span><br><input type="text" id="battery_sn" name="battery_sn"/></p>
+		<p><span id="charger_snTag">Número Serie Cargador</span><br><input type="text" id="charger_sn" name="charger_sn"/></p>
+		<p><span id="mac_eth0Tag">MAC eth0</span><br><input type="text" id="mac_eth0" name="mac_eth0" maxlength="17"/></p>
+		<p><span id="mac_wlan0Tag">MAC wlan0</span><br><input type="text" id="mac_wlan0" name="mac_wlan0" maxlength="17"/></p>
     </div>
     <div id="message" style="text-align:center; font-weight:bold; color:red; padding:3px; "></div>
     <div style="text-align:center;"><button id="saveButton" type="submit" style="width:100px;">Guardar</button>&nbsp;&nbsp;<button type="button" id="cancelButton" style="width:100px;">Cancelar</button></div>
Index: controlies/trunk/applications/controlies/views/layout.html
===================================================================
--- controlies/trunk/applications/controlies/views/layout.html	(revision 421)
+++ controlies/trunk/applications/controlies/views/layout.html	(revision 422)
@@ -151,7 +151,7 @@
 	}
 	</script>
    <div id="dialog-info" title="Acerca de ControlIES" style="display:none;"><br>
-       <b>Versi&oacute;n del paquete:</b> 0.6.3-5<br><br>
+       <b>Versi&oacute;n del paquete:</b> 0.6.4-3<br><br>
        <b>Autores:</b>
        <p> - Manuel Mora Gordillo - manuel.mora.gordillo@gmail.com</p>
        <p> - Francisco Damián Méndez Palma - fmendezpalma@gmail.com</p>
Index: controlies/trunk/applications/controlies/views/laptops_groups/form.html
===================================================================
--- controlies/trunk/applications/controlies/views/laptops_groups/form.html	(revision 421)
+++ controlies/trunk/applications/controlies/views/laptops_groups/form.html	(revision 422)
@@ -36,6 +36,18 @@
                     jQuery('#message').html("Ya existe ese número de serie").effect("slide");                  
                     break;
                 }
+                case "mac_eth0_exists":{
+                    jQuery('#mac_eth0Tag').css("color","red");
+                    jQuery('#mac_eth0').effect("highlight", {"color":"yellow"}, 1000).focus();
+                    jQuery('#message').html("Ya hay otro equipo con esa mac").effect("slide");                  
+                    break;
+                }
+                case "mac_wlan0_exists":{
+                    jQuery('#mac_wlan0Tag').css("color","red");
+                    jQuery('#mac_wlan0').effect("highlight", {"color":"yellow"}, 1000).focus();
+                    jQuery('#message').html("Ya hay otro equipo con esa mac").effect("slide");                  
+                    break;
+                }
                 default:{
                     jQuery('#'+result.response+"Tag").css("color","red");
                     jQuery('#'+result.response).effect("highlight", {"color":"yellow"}, 1000).focus();
@@ -59,6 +71,11 @@
 			</select>
 		</p>    
 		<p><span id="serial_numberTag">Número Serie</span><br><input type="text" id="serial_number" name="serial_number"/></p>
+		<p><span id="nameTag">Nombre</span><br><input type="text" id="name" name="name" maxlength="20"/></p>
+		<p><span id="battery_snTag">Número Serie Batería</span><br><input type="text" id="battery_sn" name="battery_sn"/></p>
+		<p><span id="charger_snTag">Número Serie Cargador</span><br><input type="text" id="charger_sn" name="charger_sn"/></p>
+		<p><span id="mac_eth0Tag">MAC eth0</span><br><input type="text" id="mac_eth0" name="mac_eth0" maxlength="17"/></p>
+		<p><span id="mac_wlan0Tag">MAC wlan0</span><br><input type="text" id="mac_wlan0" name="mac_wlan0" maxlength="17"/></p>
     </div>
     <div id="message" style="text-align:center; font-weight:bold; color:red; padding:3px; "></div>
     <div style="text-align:center;"><button id="saveButton" type="submit" style="width:100px;">Guardar</button>&nbsp;&nbsp;<button type="button" id="cancelButton" style="width:100px;">Cancelar</button></div>
Index: controlies/trunk/applications/controlies/controllers/laptops_groups.py
===================================================================
--- controlies/trunk/applications/controlies/controllers/laptops_groups.py	(revision 421)
+++ controlies/trunk/applications/controlies/controllers/laptops_groups.py	(revision 422)
@@ -64,7 +64,7 @@
     if serialNumber=="":
         response = "unassignment"
     else:
-        l = Laptops(cdb,"","","")
+        l = Laptops(cdb,"","","","","","","","")
         id_laptop = l.existsSerialNumber(serialNumber)
         response=""
         if not id_laptop:
@@ -91,7 +91,7 @@
     serialNumber = request.vars["serial_number"].strip()
     newSerialNumber = request.vars["newSerial"].strip()
     
-    l = Laptops(cdb,"","","")
+    l = Laptops(cdb,"","","","","","","","")
             
     if serialNumber!="":
         id_laptop = l.existsSerialNumber(serialNumber)
@@ -110,7 +110,14 @@
 @auth.requires_login()    
 def addLaptop():
     serialNumber = request.vars["serial_number"].strip()
-    l = Laptops(cdb,"",serialNumber,request.vars["id_trademark"])
+    l = Laptops(cdb,"",
+                serialNumber,
+                request.vars["name"],
+                request.vars["battery_sn"],
+                request.vars["charger_sn"],
+                request.vars["mac_eth0"],
+                request.vars["mac_wlan0"],
+                request.vars["id_trademark"])
     response = l.process("add")
     
     if response=="OK":
Index: controlies/trunk/applications/controlies/controllers/laptops.py
===================================================================
--- controlies/trunk/applications/controlies/controllers/laptops.py	(revision 421)
+++ controlies/trunk/applications/controlies/controllers/laptops.py	(revision 422)
@@ -12,19 +12,19 @@
 @service.json
 @auth.requires_login()
 def list():
-    l = Laptops(cdb,"","","")
+    l = Laptops(cdb,"","","","","","","","")
     response = l.list(request.vars)
     return response
 
 @service.json
 def getLaptopData():
-    l = Laptops(cdb,request.vars['id_laptop'],"","")
+    l = Laptops(cdb,request.vars['id_laptop'],"","","","","","","")
     response = l.getLaptopData()
     return dict(response=response)
 
 @service.json
 def getAllLaptopTypes():
-    l = Laptops(cdb,"","","")
+    l = Laptops(cdb,"","","","","","","","")
     response = l.getAllLaptopTypes()
     return dict(response=response)
 
@@ -32,8 +32,14 @@
 @auth.requires_login()    
 def modify():
     serial = request.vars["serial_number"].strip()
-
-    l = Laptops(cdb,request.vars["id_laptop"],serial,request.vars["id_trademark"])
+    l = Laptops(cdb,request.vars["id_laptop"],
+                serial,
+                request.vars["name"],
+                request.vars["battery_sn"],
+                request.vars["charger_sn"],
+                request.vars["mac_eth0"],
+                request.vars["mac_wlan0"],
+                request.vars["id_trademark"])
     response = l.process(request.vars["action"])
         
     return dict(response = response)            
@@ -41,7 +47,7 @@
 @service.json
 @auth.requires_login()       
 def delete():
-    l = Laptops(cdb,request.vars["id_laptop"],"","")
+    l = Laptops(cdb,request.vars["id_laptop"],"","","","","","","")
     response = l.delete()                         
     return dict(response=response)
 
Index: controlies/trunk/applications/controlies/modules/Laptops.py
===================================================================
--- controlies/trunk/applications/controlies/modules/Laptops.py	(revision 421)
+++ controlies/trunk/applications/controlies/modules/Laptops.py	(revision 422)
@@ -24,6 +24,7 @@
 
 from math import floor
 from applications.controlies.modules.LaptopsHistory import LaptopsHistory
+from Utils import ValidationUtils
 
 class Laptops(object):
 
@@ -30,10 +31,15 @@
     def __init__(self):
         pass
     
-    def __init__(self,DB,id_laptop,serial_number,id_trademark):
+    def __init__(self,DB,id_laptop,serial_number,name,battery_sn,charger_sn,mac_eth0,mac_wlan0,id_trademark):
         self.DB = DB
         self.id_laptop = id_laptop        
         self.serial_number = serial_number
+        self.name = name
+        self.battery_sn = battery_sn
+        self.charger_sn = charger_sn
+        self.mac_eth0 = mac_eth0
+        self.mac_wlan0 = mac_wlan0
         self.id_trademark = id_trademark        
         
     def validation(self,action):
@@ -52,7 +58,35 @@
         if action=="modify" and exists!=False:
             if exists!=self.id_laptop:
                 return "serial_number_exists"
-                
+            
+        # Validacion mac eth0
+        if self.mac_eth0 != "":
+            if not ValidationUtils.validMAC(self.mac_eth0):
+                return "mac_eth0"
+            
+            existsMAC_eth0 = self.existsMAC(self.mac_eth0)
+    
+            if action=="add" and existsMAC_eth0!=False:
+                return "mac_eth0_exists"
+    
+            if action=="modify" and existsMAC_eth0!=False:
+                if existsMAC_eth0!=self.id_laptop:
+                    return "mac_eth0_exists"
+
+        # Validacion mac wlan0
+        if self.mac_wlan0 != "":
+            if not ValidationUtils.validMAC(self.mac_wlan0):
+                return "mac_wlan0"
+    
+            existsMAC_wlan0 = self.existsMAC(self.mac_wlan0)
+            
+            if action=="add" and existsMAC_wlan0!=False:
+                return "mac_wlan0_exists"
+    
+            if action=="modify" and existsMAC_wlan0!=False:
+                if existsMAC_wlan0!=self.id_laptop:
+                    return "mac_wlan0_exists"
+
         return "OK"
 
     def process(self,action):
@@ -171,7 +205,8 @@
         #self.DB.laptops.insert(serial_number=self.serial_number,id_trademark=int(self.id_trademark))
         #self.DB.commit()
 
-        sql = "INSERT INTO laptops VALUES (null,'"+self.serial_number+"',"+self.id_trademark+")"
+        sql = "INSERT INTO laptops (id_laptop,serial_number,name,battery_sn,charger_sn,mac_eth0,mac_wlan0,id_trademark)"
+        sql = sql+" VALUES (null,'"+self.serial_number+"','"+self.name+"','"+self.battery_sn+"','"+self.charger_sn+"','"+self.mac_eth0+"','"+self.mac_wlan0+"',"+self.id_trademark+")"
         result = self.DB.executesql(sql)
 
         max = self.getMaxId()
@@ -182,7 +217,13 @@
             
             
     def modify(self):
-        self.DB(self.DB.laptops.id_laptop==self.id_laptop).update(serial_number=self.serial_number, id_trademark=self.id_trademark)
+        self.DB(self.DB.laptops.id_laptop==self.id_laptop).update(serial_number=self.serial_number,
+                                                                  name=self.name,
+                                                                  battery_sn=self.battery_sn,
+                                                                  charger_sn=self.charger_sn,
+                                                                  mac_eth0=self.mac_eth0,
+                                                                  mac_wlan0=self.mac_wlan0,
+                                                                  id_trademark=self.id_trademark)
         self.DB.commit()
         return "OK"
 
@@ -203,10 +244,20 @@
             return str(result[0][0])
         
         return False
+
+    def existsMAC(self,mac):
         
+        sql = "SELECT p.id_laptop FROM laptops p WHERE p.mac_eth0='"+mac+"' OR p.mac_wlan0='"+mac+"'"
+        result = self.DB.executesql(sql)
+
+        if len(result) > 0:
+            return str(result[0][0])
+        
+        return False
+
     def getLaptopData(self):
 		
-        sql="SELECT l.id_laptop, l.serial_number, l.id_trademark, lt.trademark, lt.model "
+        sql="SELECT l.id_laptop, l.serial_number, l.id_trademark, lt.trademark, lt.model, l.name, l.battery_sn, l.charger_sn, mac_eth0, mac_wlan0 "
         sql=sql+"FROM laptops l, laptops_trademarks lt WHERE l.id_trademark=lt.id_trademark AND l.id_laptop='"+str(self.id_laptop)+"'"
 
         result = self.DB.executesql(sql)
@@ -215,7 +266,12 @@
             "id_laptop":str(result[0][0]),
             "serial_number":result[0][1],
             "id_trademark":str(result[0][2]),
-            "trademark":str(result[0][3]+"/"+result[0][4])
+            "trademark":str(result[0][3]+"/"+result[0][4]),
+            "name":str(result[0][5]),
+            "battery_sn":str(result[0][6]),
+            "charger_sn":str(result[0][7]),
+            "mac_eth0":str(result[0][8]),
+            "mac_wlan0":str(result[0][9]),
         }
         return dataLaptop
 
