Mercurial > avadmin > converted
view av_room.py @ 508:64f8666690d8
README update
(Logical change 1.149)
author | optonline.net!jeffpc |
---|---|
date | Fri, 16 Jan 2004 02:53:48 +0000 |
parents | 524a0baf7f24 |
children | 903781c081b7 |
line wrap: on
line source
#/* # * AV Admin - Helps to manage an AV department # * # * Copyright (C) 2003, 2004 Josef "Jeff" Sipek # * # * This program is free software; you can redistribute it and/or modify # * it under the terms of the GNU General Public License as published by # * the Free Software Foundation; either version 2 of the License, or # * (at your option) any later version. # * # * This program is distributed in the hope that it will be useful, # * but WITHOUT ANY WARRANTY; without even the implied warranty of # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # * GNU General Public License for more details. # * # * You should have received a copy of the GNU General Public License # * along with this program; if not, write to the Free Software # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # * # * $Id$ # */ import av_consts ROOM_DROPNPICK = 0x00 ROOM_DROP = 0x01 ROOM_PICK = 0x02 class Room: """ Class to hold all room data and more """ def __init__(self,conn,id=-1): """ Set all variables to their default values does not return anything """ self.conn = conn self.db = conn.db self.html = conn.html self.user = conn.user self.utils = conn.utils if (id==-1): self.__ID = -1 self.__ROOM = "" self.__NAME = "" self.__NOTE = "" else: self.Load(id) def Load(self,id): """ does not return anything """ rec = self.db.execSQL("SELECT `room`, `name`, `note` FROM `rooms` WHERE `id` = " + str(id) + ";")[0] # FIXME: error checking is required self.__ID = id self.__ROOM = rec[0] self.__NAME = rec[1] self.__NOTE = rec[2] def getID(self): return self.__ID def setID(self,id): self.__ID = id def getRoom(self): return self.__ROOM def setRoom(self,room): self.__ROOM = room def getName(self): return self.__NAME def setName(self,name): self.__NAME = name def getFullName(self): if (self.__NAME): return self.__ROOM + " (" + self.__NAME + ")" return self.__ROOM def getNote(self): return self.__NOTE def setNote(self,note): self.__NOTE = note def listEquip(self): """ Returns list """ result = [] # # This SQL statement returns wrong date in this particular case, however, it may be useful in other situations # # for dbres in self.db.execSQL("SELECT enumber, doroom, puroom FROM leases WHERE (doroom=" + str(self.__ID) + " OR puroom=" + str(self.__ID) + ") AND " + "sdate<=" + str(self.conn.today()) + " AND edate>=" + str(self.conn.today()) + " AND droped=1 AND picked=0;"): # for dbres in self.db.execSQL("SELECT `enumber`, `doroom`, `puroom` FROM `leases` WHERE (`doroom`=" + str(self.__ID) + " OR `puroom`=" + str(self.__ID) + ") AND `sdate`<=" + str(self.conn.today()) + " AND `droped`=1 AND `picked`=0;"): added = False if (dbres[1]==dbres[2]): # drop off room == pick up room == this room result.append((dbres[0], ROOM_DROPNPICK)) added = True if (dbres[1]==self.__ID) and (not added): # drop off room == this room result.append((dbres[0], ROOM_DROP)) added = True if (dbres[2]==self.__ID) and (not added): # pick up room == this room result.append((dbres[0], ROOM_PICK)) added = True return result def Add(self): """ Adds variables to the db returns nothing """ pass # FIXME: add vars to db def Update(self): pass # FIXME: update the db if __name__ == "__main__": print "ERROR"