Beispiel #1
0
	def CloseAllWindows(self, ID):
		
		if miscmethods.ConfirmMessage(self.GetMenu("confirmcloseallwindowsmessage"), self.frame):
			
			while len(self.notebook.pages) > 0:
				
				self.notebook.ClosePage(self.notebook.activepage, True)
Beispiel #2
0
	def Delete(self, ID):
		
		if miscmethods.ConfirmMessage("Are you sure that you want to delete this appointment?") == True:
			
			action = "DELETE FROM appointment WHERE ID = " + str(self.appointmentdata.ID)
			db.SendSQL(action, self.appointmentdata.localsettings.dbconnection)
			
			
			self.Close(self)
Beispiel #3
0
	def DeleteProcedure(self, ID):
		
		if miscmethods.ConfirmMessage(self.GetLabel("proceduresdeletemessage")) == True:
			
			listboxid = self.procedureslistbox.GetSelection()
			procedureid = self.procedureslistbox.htmllist[listboxid][0]
			
			action = "DELETE FROM procedures WHERE ID = " + str(procedureid)
			db.SendSQL(action, self.localsettings.dbconnection)
			
			self.RefreshList()
Beispiel #4
0
    def Delete(self, ID):

        staffid = self.selectedstaffid

        if miscmethods.ConfirmMessage(
                "Are you sure that you want to remove this rota item?"):

            action = "DELETE FROM staff WHERE ID = " + str(staffid)
            db.SendSQL(action, self.localsettings.dbconnection)

            self.parent.GetParent().OpenDay()
Beispiel #5
0
	def ResetAllTables(self, ID=False):
		
		if miscmethods.ConfirmMessage(self.GetMenu("resetdatabasequestion")) == True:
			connection = db.GetConnection(self.localsettings)
			action = "DROP DATABASE evette"
			db.SendSQL(action, connection)
			connection.close()
			
			db.CreateDatabase(self.localsettings)
			
			miscmethods.ShowMessage(self.GetMenu("alltablesresetmessage"))
Beispiel #6
0
    def DeleteAppointment(self, ID):

        appointmentid = self.selectedappointmentdata[0]
        if miscmethods.ConfirmMessage("Really delete appointment?"):

            action = "DELETE FROM appointment WHERE ID = " + str(appointmentid)
            db.SendSQL(action, self.localsettings.dbconnection)

            self.detailswindow.SetPage("")
            self.RefreshLists()
            self.editbutton.Disable()
            self.deletebutton.Disable()
Beispiel #7
0
    def DeleteMedia(self, ID):

        if miscmethods.ConfirmMessage(
                self.GetLabel("deleteattachedfileconfirm")):

            listboxid = self.listbox.GetSelection()

            mediaid = self.listbox.htmllist[listboxid][0]

            action = "DELETE FROM media WHERE ID = " + str(mediaid)
            db.SendSQL(action, self.localsettings.dbconnection)

            self.listbox.RefreshList()
Beispiel #8
0
    def DeleteNote(self, ID):

        listboxid = self.diarylistbox.GetSelection()

        noteid = self.diarylistbox.htmllist[listboxid][0]

        if miscmethods.ConfirmMessage(
                self.GetLabel("confirmdeletediarynotemessage")):

            action = "DELETE FROM diary WHERE ID = " + str(noteid)
            results = db.SendSQL(action, self.localsettings.dbconnection)

            self.diarylistbox.RefreshList()
Beispiel #9
0
    def DeleteKennel(self, ID):

        if miscmethods.ConfirmMessage(
                self.GetLabel("deletekennelconfirmation"), self):

            self.listbox.selectedid = 0

            listboxid = self.listbox.GetSelection()
            kennelid = self.listbox.htmllist[listboxid][0]

            action = "DELETE FROM kennel WHERE ID = " + str(kennelid)
            db.SendSQL(action, self.localsettings.dbconnection)

            self.listbox.RefreshList()
Beispiel #10
0
	def Delete(self, ID):
		
		listboxid = self.parent.browserpanel.listbox.GetSelection()
		formid = self.parent.browserpanel.listbox.htmllist[listboxid][0]
		
		if miscmethods.ConfirmMessage("Are you sure that you want to delete this template?") == True:
			
			action = "DELETE FROM form WHERE ID = " + str(formid)
			db.SendSQL(action, self.localsettings.dbconnection)
			
			self.deletebutton.Disable()
			self.entry.Clear()
			self.nameentry.Clear()
			self.parent.browserpanel.listbox.RefreshList()
Beispiel #11
0
    def DeleteLookup(self, ID):

        lookup = self.lookup
        listboxid = self.listbox.GetSelection()
        lookupid = self.lookupsdata[listboxid][0]

        query = miscmethods.ConfirmMessage(
            self.GetLabel("lookupsdeletemessage"))

        if query == True:

            action = "DELETE FROM " + lookup + " WHERE ID = " + str(
                lookupid) + ";"
            db.SendSQL(action, self.localsettings.dbconnection)

            self.RefreshLookups()
Beispiel #12
0
    def DeleteUser(self, ID):

        listboxid = self.userlist.GetSelection()

        userid = self.users[listboxid]

        action = "SELECT * FROM user WHERE ID = " + str(userid) + ";"
        results = db.SendSQL(action, self.localsettings.dbconnection)

        self.selecteduserid = userid

        if miscmethods.ConfirmMessage(
                self.GetLabel("userdeletemessage")) == True:

            action = "DELETE FROM user WHERE ID = " + str(
                self.selecteduserid) + ";"
            results = db.SendSQL(action, self.localsettings.dbconnection)

            self.RefreshUsers()
Beispiel #13
0
	def Submit(self, ID):
		
		title = self.nameentry.GetValue()
		
		body = self.entry.GetValue()
		
		action = "SELECT ID FROM form WHERE Title = \"" + title + "\""
		results = db.SendSQL(action, self.localsettings.dbconnection)
		
		
		if len(results) > 0:
			if miscmethods.ConfirmMessage("A template called " + title + " already exists, would you like to overwrite it?") == True:
				formid = results[0][0]
				action = "REPLACE INTO form (ID, Title, Body, FormType) VALUES ( " + str(formid) + ", \"" + title + "\", \"" + body + "\", \"" + self.formtype + "\" )"
				db.SendSQL(action, self.localsettings.dbconnection)
		else:
			action = "INSERT INTO form (Title, Body, FormType) VALUES ( \"" + title + "\", \"" + body + "\", \"" + self.formtype + "\" )"
			db.SendSQL(action, self.localsettings.dbconnection)
			
		
		
		listbox = self.parent.browserpanel.listbox
		listbox.RefreshList()
Beispiel #14
0
	def Delete(self, ID):
		
		if miscmethods.ConfirmMessage(self.GetLabel("deleteassociationconfirm")):
			
			listboxid = self.listbox.GetSelection()
			
			output = ""
			
			for a in range(0, len(self.listbox.htmllist)):
				
				if a != listboxid:
					
					output = output + self.listbox.htmllist[a][1][0] + "$$$" + self.listbox.htmllist[a][1][1] + "\n"
			
			output = output.strip()
			
			pathtofiletypesfile = miscmethods.GetHome() + "/.evette/filetypes.conf"
			
			out = open(pathtofiletypesfile, "w")
			out.write(output)
			out.close()
			
			self.listbox.RefreshList()
Beispiel #15
0
	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)
Beispiel #16
0
def CheckVersion(localsettings):

    success = False

    try:
        connection = db.GetConnection(localsettings)
        action = "SELECT VersionNo FROM version"
        results = db.SendSQL(action, connection)
        oldversion = results[0][0]
        connection.close()
        success = True
    except:
        if miscmethods.ConfirmMessage(
                GetLabel(localsettings, "versiontablenotfoundquestion")):

            action = "CREATE TABLE version (ID int unsigned not null auto_increment primary key, VersionNo varchar(10))"
            db.SendSQL(action, localsettings.dbconnection)

            action = "INSERT INTO version (VersionNo) VALUES (\"1.1.2\")"
            db.SendSQL(action, localsettings.dbconnection)

            oldversion = "1.1.2"

            success = True

    if success == True:

        if versionno > oldversion:

            if miscmethods.ConfirmMessage(
                    GetLabel(localsettings, "versionupdatequestion1") + " " +
                    versionno + ", " +
                    GetLabel(localsettings, "versionupdatequestion2") + " " +
                    oldversion + ". " +
                    GetLabel(localsettings, "versionupdatequestion3")):

                if oldversion == "1.1.2":

                    action = "CREATE TABLE manualvaccination (ID int unsigned not null auto_increment primary key, AnimalID int, Date date, Name varchar(50), Batch varchar(50), Next date)"
                    db.SendSQL(action, localsettings.dbconnection)

                    currenttime = datetime.datetime.today().strftime("%x %X")

                    for a in ("medication", "medicationin", "medicationout",
                              "vaccinationtype", "vaccinationin",
                              "vaccinationout", "receipt"):
                        action = "ALTER TABLE " + a + " ADD ChangeLog text"
                        db.SendSQL(action, localsettings.dbconnection)
                        action = "UPDATE " + a + " SET ChangeLog = \"" + currenttime + "%%%" + str(
                            localsettings.userid) + "\""
                        db.SendSQL(action, localsettings.dbconnection)

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.1.3\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE settings DROP HTMLViewer"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE user ADD Permissions varchar(50)"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE user SET Permissions = \"111$11$111$11$11$11$11$111$111\""
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.1.3"

                if oldversion == "1.1.3":

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.1.4\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.1.4"

                if oldversion == "1.1.4":

                    action = "ALTER TABLE animal ADD IsDeceased int"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE animal SET IsDeceased = 0"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE animal ADD DeceasedDate date"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE animal SET DeceasedDate = \"0000-00-00\""
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE animal ADD CauseOfDeath text"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE animal SET CauseOfDeath = \"\""
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.1.5\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.1.5"

                if oldversion == "1.1.5":

                    action = "DROP TABLE staff"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "CREATE TABLE staff (ID int unsigned not null auto_increment primary key, Name varchar(20), Date date, Position varchar(20), TimeOn varchar(20), TimeOff varchar(20), Operating int)"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.1.6\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.1.6"

                if oldversion == "1.1.6":

                    dbmethods.CreateDiaryTable(localsettings.dbconnection)

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.1.7\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE user SET Permissions = CONCAT(Permissions, \"$111\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.1.7"

                if oldversion == "1.1.7":

                    dbmethods.CreateMediaTable(localsettings.dbconnection)

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.1.8\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.1.8"

                if oldversion == "1.1.8":

                    dbmethods.CreateWeightTable(localsettings.dbconnection)

                    action = "ALTER TABLE medication ADD ReOrderNo int"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE medication SET ReOrderNo = 0"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.1.9\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.1.9"

                if oldversion == "1.1.9" or oldversion == "1.2":

                    action = "ALTER TABLE settings ADD PracticeAddress varchar(250)"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE settings ADD PracticePostcode varchar(10)"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE settings ADD PracticeTelephone varchar(20)"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE settings ADD PracticeEmail varchar(100)"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE settings ADD PracticeWebsite varchar(250)"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE settings SET PracticeAddress = \"\", PracticePostcode = \"\", PracticeTelephone = \"\", PracticeEmail = \"\", PracticeWebsite = \"\""
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE form ADD FormType varchar(50)"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE form SET FormType = \"animal\""
                    db.SendSQL(action, localsettings.dbconnection)

                    formbody = """
<p>
<<PracticeName>><br>
<<PracticeAddress>><br>
<<PracticePostcode>><br>
<<PracticeTelephone>>
</p>

<p>
<<Today>>
</p>

<p>
<<ClientName>><br>
<<ClientAddress>><br>
<<ClientPostcode>>
</p>

<p>
Dear <<ClientName>>
</p>

<p>
We have been trying to contact you unsuccessfully for some time on the following numbers:
</p>

<p>
<ul>
<li><<ClientHomeTelephone>></li>
<li><<ClientMobileTelephone>></li>
<li><<ClientWorkTelephone>></li>
</ul>
</p>

<p>
Could you please contact us on <<PracticeTelephone>> so that we can update you record.
</p>

<p>
Thank you in advance
</p>

<p>
<<PracticeName>>
</p>
"""

                    action = "INSERT INTO form (Title, Body, FormType) VALUES (\"Unable to contact letter\", \"" + formbody + "\", \"client\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    formbody = """
<h2 align=center>Invoice #<<InvoiceNumber>></h2>

<p align=center>from <<FromDate>> to <<ToDate>></p>

<table align=center>
<tr>
<td valign=top>
<fieldset>
<legend>Client</legend>
<<ClientName>><br>
<<ClientAddress>><br>
<<ClientPostcode>>
</td>
<td width=20>
</td>
<td valign=top>
<<InvoiceBreakdown>>
<br>
<table align=right>
<tr>
<td>
<fieldset>
<legend>Total</legend>
<font size=5>&pound;<<InvoiceTotal>></font>
</fieldset>
</td>
</tr>
</table>
</td>
<td width=20>
</td>
<td valign=top>
<fieldset>
<legend>Payable to</legend>
<<PracticeName>><br>
<<PracticeAddress>><br>
<<PracticePostcode>>
</fieldset>
</td>
</tr>
</table>
"""

                    action = "INSERT INTO form (Title, Body, FormType) VALUES (\"Standard Invoice\", \"" + formbody + "\", \"invoice\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    formbody = """
<table width=300 align=center>
	<tr>
		<td colspan=2 align=center>
			<font size=2><b><<PracticeName>></b></font><br>
			<font size=1><<PracticeAddress>>, <<PracticePostcode>>, <<PracticeTelephone>>.</font>
		</td>
	</tr>
	<tr>
		<td valign=top>
			<fieldset><legend><font size=1>Client</font></legend>
			<font size=1><<ClientName>><br><<ClientAddress>><br><<ClientPostcode>></font>
			</fieldset>
		</td>
		<td valign=top>
			<fieldset><legend><font size=1>Animal</font></legend>
			<font size=1><<AnimalName>><br><<AnimalSpecies>><br><<AnimalColour>></font>
			</fieldset>
		</td>
	</tr>
	<tr>
		<td colspan=2>
			<fieldset><legend><div><font size=1>Medication</font></div></legend>
			<font size=2><b><<MedicationName>> x <<Quantity>></b></font>
			</fieldset>
		</td>
	</tr>
	<tr>
		<td colspan=2>
			<fieldset><legend><font size=1>Instructions</font></legend>
			<font size=2><b><<Instructions>></b></font>
			</fieldset>
		</td>
	</tr>
	<tr>
		<td colspan=2 align=center>
			<font size=1>Keep all medicines out of reach of children<br>ANIMAL TREATMENT ONLY</font>
		</td>
	</tr>
</table>
"""

                    action = "INSERT INTO form (Title, Body, FormType) VALUES (\"Medication Label\", \"" + formbody + "\", \"medication\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE medication ADD ExpiryDate date"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE medication SET ExpiryDate = \"0000-00-00\""
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "CREATE TABLE invoice (ID int unsigned not null auto_increment primary key, ClientID int, FromDate date, ToDate date, Total int, Body text, Paid int)"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.2.1\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.2.1"

                if oldversion == "1.2.1":

                    action = "ALTER TABLE medication ADD Type int"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE medication SET Type = 0"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE medicationout ADD NextDue date"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE medicationout SET NextDue = \"0000-00-00\""
                    db.SendSQL(action, localsettings.dbconnection)

                    try:

                        action = "SELECT * FROM vaccinationtype"
                        results = db.SendSQL(action,
                                             localsettings.dbconnection)

                        action = "SELECT * FROM vaccinationin"
                        vaccinationindata = db.SendSQL(
                            action, localsettings.dbconnection)

                        action = "SELECT * FROM vaccinationout"
                        vaccinationoutdata = db.SendSQL(
                            action, localsettings.dbconnection)

                        for a in results:

                            #VaccinationType --- (ID, Name, Description, CurrentBatch, Price, ChangeLog)

                            #MedicationType --- (ID, Name, Description, Unit, BatchNo, CurrentPrice, ChangeLog, ReOrderNo, ExpiryDate)

                            vaccinationid = a[0]

                            action = "INSERT INTO medication (Name, description, Unit, BatchNo, CurrentPrice, ChangeLog, ReOrderNo, ExpiryDate, Type) VALUES (\"" + a[
                                1] + "\", \"" + a[2] + "\", \"" + GetLabel(
                                    localsettings, "vaccinationsvaccinelabel"
                                ).lower() + "\", \"" + a[3] + "\", " + str(
                                    a[4]
                                ) + ", \"" + a[5] + "\", 0, \"0000-00-00\", 1)"
                            db.SendSQL(action, localsettings.dbconnection)

                            #action = "SELECT LAST_INSERT_ID() FROM medication"
                            action = "SELECT ID from medication ORDER BY ID DESC LIMIT 1"
                            medicationid = db.SendSQL(
                                action, localsettings.dbconnection)

                            #print 'medicationid', type(medicationid), medicationid

                            if type(medicationid) in [
                                    type(['array']),
                                    type(('touple'))
                            ]:

                                pass

                            medicationid = medicationid[0][0]

                            print 'medicationid', type(
                                medicationid), medicationid

                            for b in vaccinationindata:
                                if a[0] == b[1]:

                                    #Vaccinationin --- (ID, VaccinationID, Date, Amount, BatchNo, Expires, WhereFrom, ChangeLog)

                                    #Medicationin --- (ID, MedicationID, Date, Amount, BatchNo, Expires, WhereFrom, ChangeLog)

                                    action = "INSERT INTO medicationin (MedicationID, Date, Amount, BatchNo, Expires, WhereFrom, ChangeLog) VALUES (" + \
                                    str(medicationid) + ", \"" + str(b[2]) + "\", \"" + str(b[3]) + "\", \"" + b[4] + "\", \"" + str(b[5]) + "\", \"" + b[6] + "\", \"" + b[7] + "\")"

                                    db.SendSQL(action,
                                               localsettings.dbconnection)

                            for b in vaccinationoutdata:

                                if a[0] == b[1]:

                                    #Vaccinationout --- (ID, VaccinationID, Date, Amount, BatchNo, WhereTo, AppointmentID, NextDue, ChangeLog)

                                    #Medicationout --- (ID, MedicationID, Date, Amount, BatchNo, WhereTo, AppointmentID, ChangeLog, NextDue)

                                    action = "INSERT INTO medicationout (MedicationID, Date, Amount, BatchNo, WhereTo, AppointmentID, ChangeLog, NextDue) VALUES (" + str(
                                        medicationid
                                    ) + ", \"" + str(b[2]) + "\",  \"" + str(
                                        b[3]
                                    ) + "\", \"" + b[4] + "\", \"" + str(
                                        b[5]) + "\", " + str(
                                            b[6]
                                        ) + ", \"" + b[8] + "\", \"" + str(
                                            b[7]) + "\")"

                                    db.SendSQL(action,
                                               localsettings.dbconnection)

                        action = "DROP TABLE vaccinationtype"
                        db.SendSQL(action, localsettings.dbconnection)

                        action = "DROP TABLE vaccinationin"
                        db.SendSQL(action, localsettings.dbconnection)

                        action = "DROP TABLE vaccinationout"
                        db.SendSQL(action, localsettings.dbconnection)

                    except:

                        print "Vaccination tables not found - ignored!"

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.2.2\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.2.2"

                if oldversion == "1.2.2":

                    dbmethods.CreateKennelTables(localsettings.dbconnection)

                    action = "ALTER TABLE appointment ADD Staying int"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE appointment SET Staying = 0"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE animal ADD ASMRef varchar(10)"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE animal SET ASMRef = \"\""
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE settings ADD ShelterID int"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE settings SET ShelterID = 0"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "CREATE TABLE reason (ID int unsigned not null auto_increment primary key, ReasonName varchar(200))"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.2.3\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.2.3"

                if oldversion == "1.2.3":

                    action = "ALTER TABLE appointment ADD ArrivalTime time"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE appointment SET ArrivalTime = NULL"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "SELECT ID, Permissions FROM user"
                    results = db.SendSQL(action, localsettings.dbconnection)

                    for a in results:

                        permissions = a[1]

                        permissions = permissions[:30] + "1" + permissions[30:]

                        action = "UPDATE user SET Permissions = \"" + str(
                            permissions) + "\" WHERE ID = " + str(a[0])
                        db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE medication ADD CostPrice int"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE medication SET CostPrice = 0"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.2.6\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.2.6"

                if oldversion == "1.2.6":

                    action = "ALTER TABLE settings ADD MarkupMultiplyBy varchar(10)"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE settings SET MarkupMultiplyBy = \"1.175\""
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE settings ADD MarkupRoundTo int"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE settings SET MarkupRoundTo = 5"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.2.7\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.2.7"

                if oldversion == "1.2.7":

                    dbmethods.CreateLostAndFoundTables(
                        localsettings.dbconnection)

                    action = "ALTER TABLE client ADD PhonePermissions int"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE client SET PhonePermissions = 0"
                    db.SendSQL(action, localsettings.dbconnection)

                    animalsexes = []

                    action = "ALTER TABLE animal ADD TempSex int"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE animal SET TempSex = 0"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE animal SET TempSex = 1 WHERE Sex = \"" + GetLabel(
                        localsettings, "malelabel") + "\""
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE animal SET TempSex = 2 WHERE Sex = \"" + GetLabel(
                        localsettings, "femalelabel") + "\""
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE animal MODIFY Sex int"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE animal SET Sex = TempSex"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE animal DROP TempSex"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.2.8\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.2.8"

                if oldversion == "1.2.8":

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.2.9\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.2.9"

                if oldversion == "1.2.9":

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.3\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.3"

                if oldversion == "1.3":

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.3.1\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.3.1"

                if oldversion == "1.3.1":

                    action = "ALTER TABLE settings ADD ASMVaccinationID int"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE settings SET ASMVaccinationID = 0"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "ALTER TABLE settings ADD PrescriptionFee int"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "UPDATE settings SET PrescriptionFee = 0"
                    db.SendSQL(action, localsettings.dbconnection)

                    action = "SELECT ID, Permissions FROM user"
                    results = db.SendSQL(action, localsettings.dbconnection)

                    for a in results:

                        permissions = a[1]

                        permissions = permissions[:31] + "0" + permissions[31:]

                        action = "UPDATE user SET Permissions = \"" + str(
                            permissions) + "\" WHERE ID = " + str(a[0])
                        db.SendSQL(action, localsettings.dbconnection)

                    action = "REPLACE INTO version (ID, VersionNo) VALUES (1, \"1.3.2\")"
                    db.SendSQL(action, localsettings.dbconnection)

                    oldversion = "1.3.2"

                    home = miscmethods.GetHome()
                    out = open(home + "/.evette.conf", "w")
                    out.write(localsettings.dbip + "\n" +
                              localsettings.dbuser + "\n" +
                              localsettings.dbpass + "\n\nuser\n" +
                              str(localsettings.language) + "\n15")
                    out.close()

            else:

                success = False

        elif versionno < oldversion:

            miscmethods.ShowMessage(
                GetLabel(localsettings, "clientolderthanservermessage"))

            success = False

    return success
Beispiel #17
0
def AdjustSettingsDialog(parent, localsettings):

    if miscmethods.ConfirmMessage(
            GetLabel("launchnodatabaseservermessage", localsettings), parent):

        dialog = wx.Dialog(parent, -1,
                           GetLabel("launchdbiplabel", localsettings))

        dialogsizer = wx.BoxSizer(wx.VERTICAL)

        panel = wx.Panel(dialog)

        topsizer = wx.BoxSizer(wx.VERTICAL)

        gridsizer = wx.FlexGridSizer(cols=2)
        gridsizer.AddGrowableCol(1)

        dbiplabel = wx.StaticText(
            panel, -1,
            miscmethods.NoWrap(GetLabel("launchdbiplabel", localsettings)))
        gridsizer.Add(dbiplabel, 0, wx.EXPAND)
        dbipentry = wx.TextCtrl(panel, -1, localsettings.dbip, size=(200, -1))
        gridsizer.Add(dbipentry, 1, wx.EXPAND)

        dbuserlabel = wx.StaticText(
            panel, -1,
            miscmethods.NoWrap(GetLabel("launchdbuserlabel", localsettings)))
        gridsizer.Add(dbuserlabel, 0, wx.EXPAND)
        dbuserentry = wx.TextCtrl(panel, -1, localsettings.dbuser)
        gridsizer.Add(dbuserentry, 1, wx.EXPAND)

        dbpasslabel = wx.StaticText(
            panel, -1,
            miscmethods.NoWrap(GetLabel("launchdbpasslabel", localsettings)))
        gridsizer.Add(dbpasslabel, 0, wx.EXPAND)
        dbpassentry = wx.TextCtrl(panel, -1, localsettings.dbpass)
        gridsizer.Add(dbpassentry, 1, wx.EXPAND)

        topsizer.Add(gridsizer, 0, wx.EXPAND)

        submitbitmap = wx.Bitmap("icons/submit.png")
        submitbutton = wx.BitmapButton(panel, -1, submitbitmap)
        submitbutton.SetToolTipString(GetLabel("submitlabel", localsettings))
        submitbutton.Bind(wx.EVT_BUTTON, SubmitSettings)
        topsizer.Add(submitbutton, 0, wx.ALIGN_CENTER)

        panel.SetSizer(topsizer)

        panel.dbuserentry = dbuserentry
        panel.dbpassentry = dbpassentry
        panel.dbipentry = dbipentry

        panel.localsettings = localsettings

        dialogsizer.Add(panel, 1, wx.EXPAND)

        dialog.SetSizer(dialogsizer)

        dialog.Fit()

        dialog.ShowModal()

    else:

        sys.exit()