def ProcessRow(self, rowdata): #(ID, VaccinationID, Date, Amount, BatchNo, WhereTo, AppointmentID) date = miscmethods.GetDateFromSQLDate(rowdata[1]) date = miscmethods.FormatDate(date, self.localsettings) name = rowdata[2] position = rowdata[3] subject = rowdata[4] note = rowdata[5] linkinfo = rowdata[10] if str(rowdata[6]) != "None": removed = miscmethods.GetDateFromSQLDate(rowdata[6]) removed = miscmethods.FormatDate(removed, self.localsettings) #isremoved = "<font color=red size=3><b>" + self.parent.GetLabel("removedlabel") + "</b></font>" else: removed = "" output = ((rowdata[0], date, name, position, linkinfo, subject, removed), -1) return output
def ProcessRow(self, rowdata): filename = rowdata[3] description = rowdata[4] uploaddate = rowdata[6].split("$$$")[0] uploaddate = miscmethods.GetDateFromSQLDate(uploaddate) uploaddate = miscmethods.FormatDate(uploaddate, self.localsettings) filesize = str(rowdata[5]) + " KB" if description == "": filetext = filename else: if filename.__contains__("."): fileextension = filename.split(".")[-1] else: fileextension = "" filetext = description + " (" + fileextension + ")" output = ((rowdata[0], uploaddate, filetext, filesize), -1) return output
def OnGetItem(self, n): if len(self.htmllist) != 0: name = self.htmllist[n][0] surname = self.htmllist[n][1] vaccine = self.htmllist[n][2] date = self.htmllist[n][4] date = miscmethods.GetDateFromSQLDate(date) date = miscmethods.FormatDate(date, self.localsettings) return "<table width=100% cellspacing=0 cellpadding=0><tr><td align=left><font color=blue size=5><b>" + name + " " + surname + "</b> - " + vaccine + "</font></td><td align=right><font color=red size=5><b>" + str( date) + "</b></font> </td></tr></table>"
def SwitchToOps(self, ID=False): isop = self.opcheckbox.GetValue() date = self.appointmententry.GetValue() weekday = date.GetWeekDay() weekday = miscmethods.GetDayNameFromID(weekday, self.appointmentdata.localsettings) sqldate = miscmethods.GetSQLDateFromWXDate(date) datestring = miscmethods.GetDateFromWXDate(date) datestring = miscmethods.FormatDate(datestring, self.appointmentdata.localsettings) if isop == True: self.appointmenttimeentry.SetValue("09:00") self.appointmenttimeentry.Disable() else: self.appointmenttimeentry.Enable() self.RefreshAppointment() self.RefreshTotal()
def GenerateMedicationDocument(formname, appointmentdata, medicationname, unit, quantity, instructions, batchno, expires): if str(expires) == None or str(expires) == "": expires = "" else: expires = miscmethods.GetDateFromWXDate(expires) expires = miscmethods.FormatDate(expires, appointmentdata.localsettings) action = "SELECT Body FROM form WHERE Title = \"" + formname + "\" AND FormType = \"medication\"" results = db.SendSQL(action, appointmentdata.localsettings.dbconnection) body = unicode(results[0][0], "utf-8") clientname = appointmentdata.clientdata.title + " " + appointmentdata.clientdata.forenames + " " + appointmentdata.clientdata.surname clientaddress = miscmethods.RemoveLineBreaks(appointmentdata.clientdata.address) time = datetime.datetime.today() todaysdate = time.strftime("%A %d %B %Y") body = body.replace("<<ClientName>>", clientname).replace("<<ClientAddress>>", clientaddress).replace("<<ClientPostcode>>", appointmentdata.clientdata.postcode).replace("<<ClientHomeTelephone>>", appointmentdata.clientdata.hometelephone).replace("<<ClientMobileTelephone>>", appointmentdata.clientdata.mobiletelephone).replace("<<ClientWorkTelephone>>", appointmentdata.clientdata.worktelephone).replace("<<ClientEmailAddress>>", appointmentdata.clientdata.emailaddress).replace("<<ClientComments>>", unicode(appointmentdata.clientdata.comments, "utf-8")).replace("<<Today>>", todaysdate).replace("<<MedicationName>>", medicationname).replace("<<Unit>>", unit).replace("<<Quantity>>", quantity).replace("<<Instructions>>", instructions).replace("<<BatchNo>>", batchno).replace("<<Expires>>", expires).replace("<<PracticeName>>", appointmentdata.clientdata.localsettings.practicename).replace("<<PracticeAddress>>", appointmentdata.clientdata.localsettings.practiceaddress.replace("\n", "<br>")).replace("<<PracticePostcode>>", appointmentdata.clientdata.localsettings.practicepostcode).replace("<<PracticeTelephone>>", appointmentdata.clientdata.localsettings.practicetelephone).replace("<<AnimalName>>", appointmentdata.animaldata.name).replace("<<AnimalSpecies>>", appointmentdata.animaldata.species).replace("<<AnimalColour>>", appointmentdata.animaldata.colour).replace("<<AnimalBreed>>", appointmentdata.animaldata.breed).replace("<<AnimalDOB>>", appointmentdata.animaldata.dob).replace("<<AnimalComments>>", appointmentdata.animaldata.comments).replace("<<AnimalChipNo>>", appointmentdata.animaldata.chipno) if appointmentdata.animaldata.sex == 0: body = body.replace("<<AnimalSex>>", appointmentdata.localsettings.dictionary["unknownlabel"][appointmentdata.localsettings.language]) elif appointmentdata.animaldata.sex == 1: body = body.replace("<<AnimalSex>>", appointmentdata.localsettings.dictionary["malelabel"][appointmentdata.localsettings.language]) else: body = body.replace("<<AnimalSex>>", appointmentdata.localsettings.dictionary["femalelabel"][appointmentdata.localsettings.language]) BuildLabel(appointmentdata.localsettings, body)
def RefreshAppointment(self, ID=False): localsettings = self.appointmentdata.localsettings date = self.appointmententry.GetValue() weekday = date.GetWeekDay() weekday = miscmethods.GetDayNameFromID(weekday, self.appointmentdata.localsettings) sqldate = miscmethods.GetSQLDateFromWXDate(date) datestring = miscmethods.GetDateFromWXDate(date) datestring = miscmethods.FormatDate(datestring, self.appointmentdata.localsettings) isop = self.opcheckbox.GetValue() if isop == True: appointmentslistboxlabeltext = self.GetLabel("appointmentoperationsforlabel") + " " + weekday + " " + str(datestring) else: appointmentslistboxlabeltext = self.GetLabel("appointmentappointmentsforlabel") + " " + weekday + " " + str(datestring) self.appointmentslistboxlabel.SetLabel(appointmentslistboxlabeltext) self.appointmentslistbox.sqldate = sqldate self.appointmentslistbox.RefreshList() self.RefreshTotal()
def __init__(self, parent, localsettings, date): self.parent = parent self.localsettings = localsettings self.date = date wx.Panel.__init__(self, parent) #self.SetBackgroundColour("yellow") topsizer = wx.BoxSizer(wx.VERTICAL) titlesizer = wx.BoxSizer(wx.HORIZONTAL) upbitmap = wx.Bitmap("icons/uparrow.png") calendarbutton = wx.BitmapButton(self, -1, upbitmap) calendarbutton.SetToolTipString( self.parent.GetLabel("backtocalendartooltip")) calendarbutton.Bind(wx.EVT_BUTTON, self.parent.BackToCalendar) titlesizer.Add(calendarbutton, 0, wx.EXPAND) topsizer.Add(titlesizer, 0, wx.EXPAND) action = "SELECT Name, Position FROM user ORDER BY Name" results = db.SendSQL(action, self.localsettings.dbconnection) stafflist = [] positionlist = [] for a in results: stafflist.append(a[0]) positionlist.append(a[1]) horizontalsizer = wx.BoxSizer(wx.HORIZONTAL) horizontalsizer.Add(wx.StaticText(self, -1, ""), 1, wx.EXPAND) self.stafflist = stafflist self.positionlist = positionlist stafftablesizer = wx.BoxSizer(wx.VERTICAL) weekday = miscmethods.GetWeekday(int(self.date.strftime("%w")), self.localsettings) datestring = weekday + u"\xa0" + miscmethods.FormatDate( self.date, self.localsettings) datelabel = wx.StaticText(self, -1, datestring) datelabel.SetForegroundColour("red") font = datelabel.GetFont() font.SetPointSize(font.GetPointSize() + 6) datelabel.SetFont(font) stafftablesizer.Add(datelabel, 0, wx.ALIGN_CENTER) stafftablewidget = StaffTable(self, self.localsettings, self.date) stafftablesizer.Add(stafftablewidget, 1, wx.EXPAND) horizontalsizer.Add(stafftablesizer, 5, wx.EXPAND) horizontalsizer.Add(wx.StaticText(self, -1, ""), 1, wx.EXPAND) topsizer.Add(horizontalsizer, 1, wx.EXPAND) self.SetSizer(topsizer)
def __init__(self, notebook, appointmentdata): self.appointmentdata = appointmentdata wx.Panel.__init__(self, notebook) self.viewappointmentspanel = False if self.appointmentdata.operation == 0: pagetitle = self.GetLabel("appointmentappointmentforlabel") + " " + self.appointmentdata.animaldata.name + " " + self.appointmentdata.clientdata.surname else: pagetitle = self.GetLabel("appointmentoperationforlabel") + " " + self.appointmentdata.animaldata.name + " " + self.appointmentdata.clientdata.surname self.pagetitle = miscmethods.GetPageTitle(notebook, pagetitle) datesizer = wx.BoxSizer(wx.HORIZONTAL) self.appointmententry = customwidgets.DateCtrl(self, self.appointmentdata) appointmentdate = miscmethods.GetWXDateFromSQLDate(self.appointmentdata.date) self.appointmententry.SetValue(appointmentdate) action = "SELECT Name FROM user WHERE Position = \"Vet\" OR Position = \"Manager\"" results = db.SendSQL(action, self.appointmentdata.localsettings.dbconnection) vets = [] if len(results) != 0: for a in results: vets.append(a[0]) self.vetcombobox = wx.ComboBox(self, -1, "Vet", choices=vets) if self.appointmentdata.vet != "None": self.vetcombobox.SetValue(str(self.appointmentdata.vet)) self.vetcombobox.Bind(wx.EVT_CHAR, self.UseVetComboBox) self.vetcombobox.SetToolTipString(self.GetLabel("appointmententervettooltip")) refreshbitmap = wx.Bitmap("icons/refresh.png") refreshappointmentsbutton = wx.BitmapButton(self, -1, refreshbitmap) refreshappointmentsbutton.Bind(wx.EVT_BUTTON, self.RefreshAppointment) refreshappointmentsbutton.SetToolTipString(self.GetLabel("appointmentrefreshtooltip")) datesizer.Add(self.appointmententry, 1, wx.EXPAND) datesizer.Add(self.vetcombobox, 1, wx.EXPAND) datesizer.Add(refreshappointmentsbutton, 0, wx.ALIGN_LEFT) reasonsizer = wx.BoxSizer(wx.VERTICAL) self.reasonlabel = wx.StaticText(self, -1, self.GetLabel("appointmentreasonlabel")) reasonsizer.Add(self.reasonlabel, 0, wx.ALIGN_LEFT) self.reasonentry = wx.TextCtrl(self, -1, self.appointmentdata.reason, style=wx.TE_MULTILINE, size=(-1,100)) self.reasonentry.SetFocus() reasonsizer.Add(self.reasonentry, 0, wx.EXPAND) searchsizer = wx.BoxSizer(wx.VERTICAL) searchsizer.Add(datesizer, 0, wx.EXPAND) searchsizer.Add(reasonsizer, 0, wx.EXPAND) searchspacer2 = wx.StaticText(self, -1, "", size=(-1,10)) searchsizer.Add(searchspacer2, 0, wx.EXPAND) appointmenttimesizer = wx.BoxSizer(wx.HORIZONTAL) self.appointmenttimelabel = wx.StaticText(self, -1, self.GetLabel("appointmenttimelabel")) time = str(self.appointmentdata.time) if len(str(time)) == 7: time = "0" + time[:4] else: time = time[:5] self.appointmenttimeentry = wx.TextCtrl(self, -1, time) appointmenttimesizer.Add(self.appointmenttimelabel, 0, wx.ALIGN_CENTER) appointmenttimesizer.Add(self.appointmenttimeentry, 0, wx.EXPAND) appointmenttimespacer = wx.StaticText(self, -1, "") appointmenttimesizer.Add(appointmenttimespacer, 1, wx.EXPAND) self.opcheckbox = wx.CheckBox(self, -1, self.GetButtonLabel("appointmentisopcheckbox", 0)) self.opcheckbox.Bind(wx.EVT_CHECKBOX, self.SwitchToOps) self.opcheckbox.SetToolTipString(self.GetButtonLabel("appointmentisopcheckbox", 1)) appointmenttimesizer.Add(self.opcheckbox, 0, wx.ALIGN_CENTER) appointmenttimespacer1 = wx.StaticText(self, -1, "") appointmenttimesizer.Add(appointmenttimespacer1, 1, wx.EXPAND) submitbitmap = wx.Bitmap("icons/submit.png") appointmentsubmitbutton = wx.BitmapButton(self, -1, submitbitmap) appointmentsubmitbutton.Bind(wx.EVT_BUTTON, self.Submit) appointmentsubmitbutton.SetToolTipString(self.GetLabel("appointmentsubmittooltip")) appointmenttimesizer.Add(appointmentsubmitbutton) searchsizer.Add(appointmenttimesizer, 0, wx.EXPAND) searchspacer3 = wx.StaticText(self, -1, "", size=(-1,10)) searchsizer.Add(searchspacer3, 0, wx.EXPAND) buttonssizer = wx.BoxSizer(wx.HORIZONTAL) deletebitmap = wx.Bitmap("icons/delete.png") deletebutton = wx.BitmapButton(self, -1, deletebitmap) deletebutton.SetToolTipString(self.GetLabel("appointmentdeletetooltip")) deletebutton.Bind(wx.EVT_BUTTON, self.Delete) buttonssizer.Add(deletebutton, 0, wx.EXPAND) if self.appointmentdata.localsettings.deleteappointments == 0: deletebutton.Disable() buttonsspacer = wx.StaticText(self, -1, "") buttonssizer.Add(buttonsspacer, 1, wx.EXPAND) statuslabel = wx.StaticText(self, -1, self.GetLabel("appointmentstatuslabel")) buttonssizer.Add(statuslabel, 0, wx.ALIGN_CENTER) statuschoice = wx.Choice(self, -1, choices=(self.GetLabel("appointmentnotarrivedlabel"), self.GetLabel("appointmentwaitinglabel"), self.GetLabel("appointmentwithvetlabel"), self.GetLabel("appointmentdonelabel"))) if self.appointmentdata.done == 1: statuschoice.SetSelection(3) elif self.appointmentdata.withvet == 1: statuschoice.SetSelection(2) elif self.appointmentdata.arrived == 1: statuschoice.SetSelection(1) else: statuschoice.SetSelection(0) buttonssizer.Add(statuschoice, 0, wx.EXPAND) searchsizer.Add(buttonssizer, 0, wx.EXPAND) searchspacer = wx.StaticText(self, -1, "", size=(-1,10)) searchsizer.Add(searchspacer, 0, wx.EXPAND) owneranimalsizer = wx.BoxSizer(wx.HORIZONTAL) editownerbutton = wx.Button(self, -1, self.GetButtonLabel("appointmenteditownerbutton", 0)) editownerbutton.SetForegroundColour("blue") editownerbutton.SetToolTipString(self.GetButtonLabel("appointmenteditownerbutton", 1)) editownerbutton.Bind(wx.EVT_BUTTON, self.OpenClientRecord) owneranimalsizer.Add(editownerbutton, 0, wx.EXPAND) if self.appointmentdata.localsettings.editclients == 0: editownerbutton.Disable() owneranimalspacer = wx.StaticText(self, -1, "") owneranimalsizer.Add(owneranimalspacer, 1, wx.EXPAND) editanimalbutton = wx.Button(self, -1, self.GetButtonLabel("appointmenteditanimalbutton", 0)) editanimalbutton.SetForegroundColour("blue") editanimalbutton.SetToolTipString(self.GetButtonLabel("appointmenteditanimalbutton", 1)) editanimalbutton.Bind(wx.EVT_BUTTON, self.OpenAnimalRecord) owneranimalsizer.Add(editanimalbutton, 0, wx.EXPAND) if self.appointmentdata.localsettings.editanimals == 0: editanimalbutton.Disable() searchsizer.Add(owneranimalsizer, 0, wx.EXPAND) searchspacer1 = wx.StaticText(self, -1, "") searchsizer.Add(searchspacer1, 1, wx.EXPAND) #Right hand pane date = self.appointmententry.GetValue() date = miscmethods.GetDateFromWXDate(date) date = miscmethods.FormatDate(date, self.appointmentdata.localsettings) appointmentslistboxlabeltext = self.GetLabel("appointmentappointmentsforlabel") + " " + str(date) self.appointmentslistboxlabel = wx.StaticText(self, -1, appointmentslistboxlabeltext) self.appointmentslistbox = customwidgets.DayPlannerListbox(self, appointmentdata.localsettings, date, 10) self.appointmentslistbox.Bind(wx.EVT_LISTBOX_DCLICK, self.GetTime) appointmentslistboxsizer = wx.BoxSizer(wx.VERTICAL) appointmentslistboxsizer.Add(self.appointmentslistboxlabel, 0, wx.EXPAND) appointmentslistboxsizer.Add(self.appointmentslistbox, 1, wx.EXPAND) self.appointmentlistboxtotal = wx.StaticText(self, -1, self.GetLabel("totallabel") + ": 0") appointmentslistboxsizer.Add(self.appointmentlistboxtotal, 0, wx.ALIGN_RIGHT) mainsizer = wx.BoxSizer(wx.HORIZONTAL) mainsizer.Add(searchsizer, 1, wx.EXPAND) spacer = wx.StaticText(self, -1, "", size=(50,-1)) mainsizer.Add(spacer, 0, wx.EXPAND) mainsizer.Add(appointmentslistboxsizer, 2, wx.EXPAND) topsizer = wx.BoxSizer(wx.VERTICAL) closebuttonsizer = wx.BoxSizer(wx.HORIZONTAL) closebuttonspacer2 = wx.StaticText(self, -1, "") closebuttonsizer.Add(closebuttonspacer2, 1, wx.EXPAND) topsizer.Add(closebuttonsizer, 0, wx.EXPAND) topsizer.Add(mainsizer, 1, wx.EXPAND) self.SetSizer(topsizer) self.appointmentslistboxsizer = appointmentslistboxsizer self.statuschoice = statuschoice if self.appointmentdata.operation == 1: self.opcheckbox.SetValue(True) self.SwitchToOps() self.RefreshAppointment()
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)
def GenerateBatchMovementReport(self, ID): busy = wx.BusyCursor() parent = ID.GetEventObject().GetParent() batchno = parent.batchinput.GetValue() if parent.containscheckbox.GetValue() == True: action = "SELECT medicationin.Date, medication.Name, medicationin.MedicationID, medicationin.Amount, medicationin.BatchNo, DATE_FORMAT(medicationin.Expires, \"%Y-%m-%d\"), medicationin.WhereFrom, 0, medication.Unit FROM medicationin INNER JOIN medication ON medicationin.MedicationID = medication.ID WHERE medicationin.BatchNo LIKE \"%" + str(batchno) + "%\"" resultsin = db.SendSQL(action, self.localsettings.dbconnection) action = "SELECT medicationout.Date, medication.Name, medicationout.MedicationID, medicationout.Amount, medicationout.BatchNo, 0, medicationout.WhereTo, 1, medication.Unit FROM medicationout INNER JOIN medication ON medicationout.MedicationID = medication.ID WHERE medicationout.BatchNo LIKE \"%" + str(batchno) + "%\"" resultsout = db.SendSQL(action, self.localsettings.dbconnection) else: action = "SELECT medicationin.Date, medication.Name, medicationin.MedicationID, medicationin.Amount, medicationin.BatchNo, DATE_FORMAT(medicationin.Expires, \"%Y-%m-%d\"), medicationin.WhereFrom, 0, medication.Unit FROM medicationin INNER JOIN medication ON medicationin.MedicationID = medication.ID WHERE medicationin.BatchNo = \"" + str(batchno) + "\"" resultsin = db.SendSQL(action, self.localsettings.dbconnection) action = "SELECT medicationout.Date, medication.Name, medicationout.MedicationID, medicationout.Amount, medicationout.BatchNo, 0, medicationout.WhereTo, 1, medication.Unit FROM medicationout INNER JOIN medication ON medicationout.MedicationID = medication.ID WHERE medicationout.BatchNo = \"" + str(batchno) + "\"" resultsout = db.SendSQL(action, self.localsettings.dbconnection) header = "<h1 align=center><u>" + self.GetMenu("medicationmovementsofbatchnumberlabel") + str(batchno) + "</u></h1><table align=center>" results = [] for a in resultsin: results.append(a) for a in resultsout: results.append(a) results.sort() body = "" for a in results: date = miscmethods.GetDateFromSQLDate(a[0]) date = miscmethods.FormatDate(date, self.localsettings) name = a[1] if a[7] == 0: fromorto = self.GetMenu("fromlabel").lower() else: fromorto = self.GetMenu("tolabel").lower() quantity = a[3] destination = a[6] body = body + "<tr><td valign=top>" + date + "</td><td valign=top>" + name + " x " + str(quantity) + " " + fromorto + " " + destination + "</td></tr>" footer = "</table>" formmethods.BuildForm(self.localsettings, header + body + footer) del busy parent.GetParent().Close()