def __init__(self, localsettings, animalid, ID): #(ID, AnimalID, OwnerID, Date, Time, AppointmentReason, Arrived, WithVet, Problem, Notes, Plan, Done, Operation, Vet) self.localsettings = localsettings if ID == False: self.ID = False self.animalid = animalid self.animaldata = animalmethods.AnimalSettings(self.localsettings, False, self.animalid) self.clientdata = clientmethods.ClientSettings(self.localsettings, self.animaldata.ownerid) self.ownerid = self.clientdata.ID self.date = datetime.date.today() self.date = miscmethods.GetSQLDateFromDate(self.date) self.time = "14:00" self.reason = "Checkover" self.arrived = 0 self.withvet = 0 self.problem = "" self.notes = "" self.plan = "" self.done = 0 self.operation = 0 self.vet = "None" currenttime = datetime.datetime.today().strftime("%x %X") self.changelog = str(currenttime) + "%%%" + str(self.localsettings.userid) else: action = "SELECT * FROM appointment WHERE ID = " + str(ID) results = db.SendSQL(action, localsettings.dbconnection) self.ID = ID self.animalid = results[0][1] self.ownerid = results[0][2] self.date = results[0][3] self.time = results[0][4] self.reason = results[0][5] self.arrived = results[0][6] self.withvet = results[0][7] self.problem = results[0][8] self.notes = results[0][9] self.plan = results[0][10] self.done = results[0][11] self.operation = results[0][12] self.vet = results[0][13] self.changelog = results[0][14] self.animaldata = animalmethods.AnimalSettings(self.localsettings, False, self.animalid) self.clientdata = clientmethods.ClientSettings(self.localsettings, self.animaldata.ownerid)
def OpenLink(self, ID): listboxid = self.diarylistbox.GetSelection() linktype = GetLinkType(self.diarylistbox.htmllist[listboxid][8]) linkid = self.diarylistbox.htmllist[listboxid][9] if linktype == "client": clientsettings = clientmethods.ClientSettings( self.localsettings, linkid) clientpanel = clientmethods.ClientPanel(self.notebook, clientsettings) self.notebook.AddPage(clientpanel) elif linktype == "animal": animalsettings = animalmethods.AnimalSettings( self.localsettings, False, linkid) animalpanel = animalmethods.AnimalPanel(self.notebook, animalsettings) self.notebook.AddPage(animalpanel) elif linktype == "appointment": appointmentsettings = appointmentmethods.AppointmentSettings( self.localsettings, False, linkid) appointmentpanel = appointmentmethods.AppointmentPanel( self.notebook, appointmentsettings) self.notebook.AddPage(appointmentpanel)
def AddClient(self, ID): clientsettings = clientmethods.ClientSettings(self.localsettings) addclientpanel = clientmethods.ClientPanel(self.notebook, clientsettings) self.notebook.AddPage(addclientpanel) wx.CallAfter(addclientpanel.titleentry.SetFocus)
def EditOwner(self, ID=False): listboxid = self.listbox.GetSelection() clientid = self.listbox.htmllist[listboxid][6] clientdata = clientmethods.ClientSettings(self.localsettings, clientid) notebook = self.GetGrandParent().GetGrandParent() clientpanel = clientmethods.ClientPanel(notebook, clientdata) notebook.AddPage(clientpanel)
def EditClient(self, ID): panel = ID.GetEventObject().panel listbox = panel.listbox notebook = self.GetGrandParent().GetParent() appointmentid = listbox.htmllist[listbox.GetSelection()][3] appointmentdata = appointmentmethods.AppointmentSettings( self.localsettings, False, appointmentid) clientid = appointmentdata.ownerid clientdata = clientmethods.ClientSettings(self.localsettings, clientid) clientpanel = clientmethods.ClientPanel(notebook, clientdata) notebook.AddPage(clientpanel)
def run(self): self.parent.submitbutton.Disable() noofclients = int(self.parent.noofclientsentry.GetValue()) noofanimals = int(self.parent.noofanimalsentry.GetValue()) noofappointments = int(self.parent.noofappointmentsentry.GetValue()) noofoperations = int(self.parent.noofoperationsentry.GetValue()) noofmedications = int(self.parent.noofmedicationsentry.GetValue()) #connection = db.GetConnection(self.parent.localsettings) #action = "SELECT * FROM vaccinationtype" #results = db.SendSQL(action, connection) # #if len(results) == 0: #doggivac = vaccinationmethods.VaccinationTypeData() #doggivac.name = "Doggivac" #doggivac.description = "Vaccine for dogs" #doggivac.price = 2000 #doggivac.batchno = "123456" #doggivac.Submit(self.parent.localsettings) #doggivacin = vaccinationmethods.VaccinationInData(doggivac.ID) #doggivacin.amount = 100 #doggivacin.batchno = "123456" #doggivacin.wherefrom = "Big Fogs Veterinary Superstore" #doggivacin.Submit(self.parent.localsettings) #cattivac = vaccinationmethods.VaccinationTypeData() #cattivac.name = "Cattivac" #cattivac.description = "Vaccine for cats" #cattivac.price = 2000 #cattivac.batchno = "123456" #cattivac.Submit(self.parent.localsettings) #cattivacin = vaccinationmethods.VaccinationInData(cattivac.ID) #cattivacin.amount = 100 #cattivacin.batchno = "123456" #cattivacin.wherefrom = "Big Fogs Veterinary Superstore" #cattivacin.Submit(self.parent.localsettings) wx.CallAfter(self.parent.clientgauge.SetValue, 0) for a in range(0, noofclients): clientdata = clientmethods.ClientSettings( self.parent.localsettings, False) sex = GetRandomSex() clientdata.title = GetRandomTitle(sex) clientdata.forenames = GetRandomForenames(sex) clientdata.surname = GetRandomSurname() clientdata.address = GetRandomAddress() clientdata.postcode = GetRandomPostCode() clientdata.hometelephone = GetRandomLandLine() clientdata.mobiletelephone = GetRandomMobileNo() clientdata.worktelephone = GetRandomLandLine() clientdata.emailaddress = GetRandomEmailAddress(clientdata.surname) clientdata.comments = GetRandomClientComments() dbmethods.WriteToClientTable( self.parent.localsettings.dbconnection, clientdata) count = (float(a) / float(noofclients)) * 100 count = int(count) lastcount = (float(a - 1) / float(noofclients)) * 100 lastcount = int(lastcount) if count != lastcount: wx.CallAfter(self.parent.clientgauge.SetValue, count) wx.CallAfter(self.parent.clientgauge.SetValue, 100) wx.CallAfter(self.parent.animalgauge.SetValue, 0) action = "SELECT ID FROM client" results = db.SendSQL(action, self.parent.localsettings.dbconnection) clientids = [] for a in results: clientids.append(a[0]) for a in range(0, noofanimals): ownerid = GetRandomEntry(clientids) animaldata = animalmethods.AnimalSettings( self.parent.localsettings, ownerid, False) animaldata.ownerid = GetRandomEntry(clientids) animaldata.name = unicode(GetRandomAnimalName(sex)) animaldata.sex = GetRandomEntry((1, 2)) animaldata.neutered = 0 animaldata.species = unicode(GetRandomSpecies()) animaldata.breed = unicode(GetRandomBreed(animaldata.species)) animaldata.colour = unicode(GetRandomColour(animaldata.species)) animaldata.dob = unicode(GetRandomDOB(animaldata.species)) animaldata.chipno = GetRandomChipNo(animaldata.species) animaldata.comments = unicode(GetRandomAnimalComments()) dbmethods.WriteToAnimalTable( self.parent.localsettings.dbconnection, animaldata) action = "SELECT * FROM medication WHERE Type = 1" results = db.SendSQL(action, self.parent.localsettings.dbconnection) if len(results) != 0: noofvaccines = int(random.random() * 5) randno = int(random.random() * 365) date = datetime.date.today() datepivot = datetime.timedelta(days=randno) date = date + datepivot for b in range(0, noofvaccines): datedue = date + datepivot datedue = miscmethods.GetSQLDateFromDate(datedue) datepivot = datetime.timedelta(days=-365) dategiven = date + datepivot date = dategiven dategiven = miscmethods.GetSQLDateFromDate(dategiven) name = "Foggovac" batch = str(int(random.random() * 1000000)) dbmethods.WriteToManualVaccinationTable( self.parent.localsettings.dbconnection, False, animaldata.ID, dategiven, name, batch, datedue) count = (float(a) / float(noofanimals)) * 100 count = int(count) lastcount = (float(a - 1) / float(noofanimals)) * 100 lastcount = int(lastcount) if count != lastcount: wx.CallAfter(self.parent.animalgauge.SetValue, count) wx.CallAfter(self.parent.animalgauge.SetValue, 100) wx.CallAfter(self.parent.appointmentgauge.SetValue, 0) action = "SELECT ID FROM animal" results = db.SendSQL(action, self.parent.localsettings.dbconnection) animalids = [] for a in results: animalids.append(a[0]) todaysdate = datetime.datetime.today() sqldate = miscmethods.GetSQLDateFromDate(todaysdate) for a in range(0, noofappointments): animalid = GetRandomEntry(animalids) CreateRandomAppointment(self.parent.localsettings.dbconnection, animalid, self.parent.localsettings) count = (float(a) / float(noofappointments)) * 100 count = int(count) lastcount = (float(a - 1) / float(noofappointments)) * 100 lastcount = int(lastcount) if count != lastcount: wx.CallAfter(self.parent.appointmentgauge.SetValue, count) wx.CallAfter(self.parent.appointmentgauge.SetValue, 100) wx.CallAfter(self.parent.operationgauge.SetValue, 0) for a in range(0, noofoperations): animalid = GetRandomEntry(animalids) CreateRandomOperation(self.parent.localsettings.dbconnection, animalid, self.parent.localsettings) count = (float(a) / float(noofoperations)) * 100 count = int(count) lastcount = (float(a - 1) / float(noofoperations)) * 100 lastcount = int(lastcount) if count != lastcount: wx.CallAfter(self.parent.operationgauge.SetValue, count) wx.CallAfter(self.parent.operationgauge.SetValue, 100) wx.CallAfter(self.parent.medicationgauge.SetValue, 0) medicationnames = [] for a in range(0, noofmedications): success = False while success == False: medicationdata = GetRandomMedication() if medicationnames.__contains__(medicationdata.name) == False: success = True medicationnames.append(medicationdata.name) medicationdata.Submit(self.parent.localsettings) medicationindata = medicationmethods.MedicationInData( medicationdata.ID) medicationindata.amount = "200" medicationindata.batchno = "000000" medicationindata.wherefrom = "Big Fogs Veterinary Superstore" medicationindata.Submit(self.parent.localsettings) count = (float(a) / float(noofmedications)) * 100 count = int(count) lastcount = (float(a - 1) / float(noofmedications)) * 100 lastcount = int(lastcount) if count != lastcount: wx.CallAfter(self.parent.medicationgauge.SetValue, count) wx.CallAfter(self.parent.medicationgauge.SetValue, 100) self.parent.GetGrandParent().GetParent().Close()
def UpdateViewAppointments(ID, force=False): try: appointmentpanel = ID.GetEventObject().appointmentpanel except: appointmentpanel = ID try: if appointmentpanel.IsShown() or force == True: #print "updating view appointments " + datetime.datetime.today().strftime("%H:%M:%S") date = datetime.datetime.today().strftime("%A %d %B %Y") sqldate = datetime.datetime.today().strftime("%Y-%m-%d") timestring = datetime.datetime.today().strftime("%X")[:5] action = "SELECT Name FROM staff WHERE Date = \"" + sqldate + "\" AND \"" + timestring + ":00\" BETWEEN TimeOn AND TimeOff AND Operating = " + str( appointmentpanel.operations ) + " AND Position = \"" + appointmentpanel.GetLabel( "vetpositiontitle") + "\" ORDER BY Name" results = db.SendSQL(action, appointmentpanel.localsettings.dbconnection) vets = "" appointmentpanel.vetlist = [] for a in results: vets = vets + a[0] + ", " appointmentpanel.vetlist.append(a[0]) vets = vets[:-2] appointmentpanel.datetimewindow.SetPage( "<center><font size=2>" + date + "</font><br><font color=blue size=5><b>" + timestring + "</b></font></center><br><font size=1><u>" + appointmentpanel.GetLabel("viewappointmentsvetsonlabel") + "</u>: " + vets + "</font>") for a in range(0, 4): index = a action = "SELECT appointment.ID, appointment.Time, animal.ID, animal.Name, client.ClientSurname, animal.Sex, animal.Neutered, animal.Species, animal.Breed, animal.Comments, client.ClientComments, appointment.AppointmentReason, animal.DOB, client.ClientTitle, appointment.Vet, client.ID, animal.ASMRef, appointment.ArrivalTime FROM appointment INNER JOIN animal ON appointment.AnimalID = animal.ID INNER JOIN client ON animal.OwnerID = client.ID WHERE appointment.Operation = " + str( appointmentpanel.operations ) + " AND appointment.Date = \"" + sqldate + "\"" if index == 0: action = action + " AND appointment.Arrived = 0" elif index == 1: action = action + " AND appointment.Arrived = 1 AND appointment.WithVet = 0 AND appointment.done = 0" elif index == 2: action = action + " AND appointment.WithVet = 1" else: action = action + " AND appointment.Done = 1" action = action + " AND appointment.Staying = 0 ORDER BY appointment.Time" if index == 0: appointmentpanel.notarrivedlistbox.htmllist = db.SendSQL( action, appointmentpanel.localsettings.dbconnection) elif index == 1: appointmentpanel.waitinglistbox.htmllist = db.SendSQL( action, appointmentpanel.localsettings.dbconnection) elif index == 2: appointmentpanel.withvetlistbox.htmllist = db.SendSQL( action, appointmentpanel.localsettings.dbconnection) else: results = db.SendSQL( action, appointmentpanel.localsettings.dbconnection) htmllist = [] for b in results: clientid = b[15] clientdata = clientmethods.ClientSettings( appointmentpanel.localsettings, clientid) balance = miscmethods.GetBalance( clientdata, appointmentpanel.localsettings) #if balance < 0: #colour = "red" #else: #colour = "green" balance = miscmethods.FormatPrice(balance) #balance = "<font size=2 color=" + colour + "> " + appointmentpanel.GetLabel("currency") + balance + "</font>" listitem = list(b) listitem.append(balance) htmllist.append(listitem) appointmentpanel.donelistbox.htmllist = htmllist busy = wx.BusyCursor() appointmentpanel.RefreshLists() del busy except: pass
def SubmitASMImport(self, ID): panel = ID.GetEventObject().GetGrandParent() listboxid = panel.listbox.GetSelection() if listboxid != -1: animaldata = panel.animaldata[listboxid] action = "SELECT ID FROM animal WHERE ASMRef = \"" + animaldata[0] + "\"" results = db.SendSQL(action, self.localsettings.dbconnection) if len(results) > 0: if miscmethods.ConfirmMessage(self.GetMenu("alreadyimportedmessage"), self.notebook): animalsettings = animalmethods.AnimalSettings(self.localsettings, False, results[0][0]) animalpanel = animalmethods.AnimalPanel(self.notebook, animalsettings) self.notebook.AddPage(animalpanel) panel.GetParent().Close() else: archived = animaldata[10] activemovementtype = animaldata[11] if archived == 0 or activemovementtype == 2: action = "SELECT ShelterID FROM settings" clientid = db.SendSQL(action, self.localsettings.dbconnection)[0][0] #miscmethods.ShowMessage("Animal is on shelter", panel) else: action = "SELECT owner.OwnerSurname, owner.OwnerAddress, owner.OwnerPostcode, owner.HomeTelephone, owner.MobileTelephone, owner.WorkTelephone, owner.EmailAddress, animal.ActiveMovementType, owner.OwnerTitle, owner.OwnerForenames FROM owner INNER JOIN adoption ON adoption.OwnerID = owner.ID INNER JOIN animal ON adoption.ID = animal.ActiveMovementID WHERE animal.ShelterCode = \"" + animaldata[0] + "\" AND ( animal.ActiveMovementType = 1 OR animal.ActiveMovementType = 2 ) AND animal.Archived = 1" results = db.SendSQL(action, panel.asmconnection) if len(results) == 1: ownersurname = results[0][0] if ownersurname == None: ownersurname = "" owneraddress = results[0][1] if owneraddress == None: owneraddress = "" owneraddress = owneraddress.replace("\r", "") ownerpostcode = results[0][2] if ownerpostcode == None: ownerpostcode = "" ownerhometelephone = results[0][3] if ownerhometelephone == None: ownerhometelephone = "" ownermobiletelephone = results[0][4] if ownermobiletelephone == None: ownermobiletelephone = "" ownerworktelephone = results[0][5] if ownerworktelephone == None: ownerworktelephone = "" owneremailaddress = results[0][6] if owneremailaddress == None: owneremailaddress = "" movementtype = results[0][7] ownertitle = results[0][8] if ownertitle == None: ownertitle = "" ownerforenames = results[0][9] if ownerforenames == None: ownerforenames = "" action = "SELECT ID, ClientTitle, ClientForenames, ClientSurname, ClientAddress FROM client WHERE ClientPostCode = \"" + ownerpostcode + "\" OR ClientSurname = \"" + ownersurname + "\"" evetteowners = db.SendSQL(action, self.localsettings.dbconnection) possiblematches = [] asmhousenumber = owneraddress.split(" ")[0] for a in evetteowners: evettehousenumber = a[4].split(" ")[0] if asmhousenumber == evettehousenumber: possiblematches.append(a) else: if ownerforenames == "" or a[2] == "" or ownerforenames == a[2]: possiblematches.append(a) selectedownerid = 0 panel.chosenownerid = 0 if len(possiblematches) > 0: panel.possiblematches = possiblematches dialog = wx.Dialog(panel, -1, "Possible Owners") dialog.panel = panel topsizer = wx.BoxSizer(wx.VERTICAL) sheltermanagerownerinfo = wx.StaticText(dialog, -1, ownertitle + " " + ownerforenames + " " + ownersurname + ". " + owneraddress.replace("\n", ", ") + ". " + ownerpostcode) topsizer.Add(sheltermanagerownerinfo, 0, wx.EXPAND) topsizer.Add(wx.StaticText(dialog, -1, "", size=(-1,10))) chooseownerlabel = wx.StaticText(dialog, -1, "Choose an owner") topsizer.Add(chooseownerlabel, 0, wx.ALIGN_LEFT) dialog.listbox = wx.ListBox(dialog) dialog.listbox.Bind(wx.EVT_LISTBOX_DCLICK, self.SelectOwner) for v in possiblematches: listboxoutput = v[1] + " " + v[2] + " " + v[3] + ". " + v[4].replace("\n", ", ").replace("\r", "") dialog.listbox.Append(listboxoutput) topsizer.Add(dialog.listbox, 1, wx.EXPAND) dialog.SetSizer(topsizer) dialog.ShowModal() clientid = panel.chosenownerid if panel.chosenownerid == 0: clientsettings = clientmethods.ClientSettings(self.localsettings) clientsettings.title = ownertitle clientsettings.forenames = ownerforenames clientsettings.surname = ownersurname clientsettings.address = owneraddress clientsettings.postcode = ownerpostcode clientsettings.hometelephone = ownerhometelephone clientsettings.mobiletelephone = ownermobiletelephone clientsettings.worktelephone = ownerworktelephone clientsettings.emailaddress = owneremailaddress clientsettings.comments = "Imported from ASM" clientsettings.Submit() clientid = clientsettings.ID else: clientid = 0 if clientid > 0: animalsettings = animalmethods.AnimalSettings(self.localsettings, clientid) animalsettings.name = animaldata[1] ## print "animaldata[2] = " + str(animaldata[2]) ## if animaldata[2] == 0: ## animalsettings.sex = 2 ## elif animaldata[2] == 1: ## animalsettings.sex = 1 ## else: ## animalsettings.sex = 0 ## ## print "sex = " + str(animalsettings.sex) if animaldata[2] == self.GetMenu("malelabel"): animalsettings.sex = 1 elif animaldata[2] == self.GetMenu("femalelabel"): animalsettings.sex = 2 else: animalsettings.sex = 0 animalsettings.species = animaldata[4] animalsettings.breed = animaldata[5] animalsettings.colour = animaldata[6] dob = animaldata[7] animalsettings.dob = miscmethods.FormatDate(dob, self.localsettings) animalsettings.comments = "" animalsettings.neutered = animaldata[3] animalsettings.chipno = animaldata[8] if animalsettings.chipno == None: animalsettings.chipno = "" if animalsettings.comments == None: animalsettings.comments = "" animalsettings.asmref = animaldata[0] animalsettings.Submit() animalpanel = animalmethods.AnimalPanel(self.notebook, animalsettings) self.notebook.AddPage(animalpanel) panel.GetParent().Close() else: miscmethods.ShowMessage(self.GetMenu("errorobtainingownermessage"), panel)