Fummeljob hierum darum
This commit is contained in:
@@ -27,6 +27,17 @@ class BusinessDAO(QObject):
|
||||
except mariadb.Error as e:
|
||||
print(str(e))
|
||||
|
||||
def getOneBusiness(self, business_id, enc_key = None):
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("getCustomer", (business_id, enc_key,))
|
||||
#self.__all_cols = [desc[0] for desc in self.__cur.description]
|
||||
return self.__cur.fetchall() #, self.__all_cols
|
||||
else:
|
||||
return None #, None
|
||||
except mariadb.Error as e:
|
||||
print(str(e))
|
||||
|
||||
def addBusiness(self, data, contact_id):
|
||||
try:
|
||||
if self.__cur:
|
||||
|
||||
@@ -65,6 +65,8 @@ class BusinessModel(QAbstractTableModel):
|
||||
__visible_index = {}
|
||||
__col_name = ""
|
||||
__business_dao = None
|
||||
__business = None
|
||||
__business_dict = {'business':{}} #,'contact':{}}
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@@ -80,6 +82,22 @@ class BusinessModel(QAbstractTableModel):
|
||||
self.__data = rows
|
||||
self.endResetModel()
|
||||
|
||||
def __getBusinessInfo(self):
|
||||
self.__business_dict['business']['id'] = self.__business[0][0]
|
||||
self.__business_dict['business']['contactid'] = self.__business[0][1]
|
||||
self.__business_dict['business']['company'] = self.__business[0][2]
|
||||
self.__business_dict['business']['phone'] = self.__business[0][3]
|
||||
self.__business_dict['business']['cell'] = self.__business[0][4]
|
||||
self.__business_dict['business']['email'] = self.__business[0][5]
|
||||
self.__business_dict['business']['website'] = self.__business[0][6]
|
||||
self.__business_dict['business']['ceo'] = self.__business[0][7]
|
||||
self.__business_dict['business']['info'] = self.__business[0][8]
|
||||
self.__business_dict['business']['tax'] = self.__business[0][9]
|
||||
self.__business_dict['business']['street'] = self.__business[0][10]
|
||||
self.__business_dict['business']['house'] = self.__business[0][11]
|
||||
self.__business_dict['business']['zip'] = self.__business[0][12]
|
||||
self.__business_dict['business']['city'] = self.__business[0][13]
|
||||
|
||||
def rowCount(self, parent= QModelIndex()):
|
||||
return len (self.__data)
|
||||
|
||||
@@ -113,7 +131,17 @@ class BusinessModel(QAbstractTableModel):
|
||||
|
||||
@Slot(int)
|
||||
def onRowClicked(self, row):
|
||||
print(f"Selected table row: {row}, corresponding DB ID: {self.__data[row][0]}")
|
||||
#print(f"Selected table row: {row}, corresponding DB ID: {self.__data[row][0]}")
|
||||
if not self.__business_dict['business'] or self.__data[row][0] != self.__business_dict['business']['id']:
|
||||
self.__business = self.__business_dao.getOneBusiness(self.__data[row][0], self.__key)
|
||||
#print(self.__business)
|
||||
self.__getBusinessInfo()
|
||||
# self.__getContactInfo()
|
||||
# print(self.__business_dict)
|
||||
|
||||
@Slot(result = dict)
|
||||
def getClientDetails(self):
|
||||
return self.__business_dict
|
||||
|
||||
@Slot(str)
|
||||
def viewCriterion(self, criterion):
|
||||
@@ -134,5 +162,3 @@ class BusinessModel(QAbstractTableModel):
|
||||
|
||||
def updateTable(self):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -30,4 +30,15 @@ class ContactDAO:
|
||||
except Exception as e:
|
||||
print("PYT: " + str(e))
|
||||
|
||||
def getContact(self, contact_id, enc_key = None):
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("getCustomerContact", (contact_id, enc_key,))
|
||||
#self.__all_cols = [desc[0] for desc in self.__cur.description]
|
||||
return self.__cur.fetchall() #, self.__all_cols
|
||||
else:
|
||||
return None #, None
|
||||
except mariadb.Error as e:
|
||||
print(str(e))
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@ import logging
|
||||
|
||||
class ContactModel(QObject):
|
||||
contactIdReady = Signal(int)
|
||||
|
||||
__contact = None
|
||||
__contact_dict = {'contact':{}}
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# print(f"*** File: {__file__}, __init__()")
|
||||
@@ -27,5 +31,29 @@ class ContactModel(QObject):
|
||||
i = ContactDAO().addContact(contact, self.__key)
|
||||
self.contactIdReady.emit(i)
|
||||
|
||||
def __getContact(self, contact):
|
||||
self.__contact = ContactDAO().getContact(contact, self.__key)
|
||||
self.__getContactInfo()
|
||||
|
||||
@Slot(int, result = dict)
|
||||
def getContactDetails(self, contact):
|
||||
self.__getContact(contact)
|
||||
#print(self.__contact_dict)
|
||||
return self.__contact_dict
|
||||
|
||||
def __getContactInfo(self):
|
||||
self.__contact_dict['contact']['id'] = self.__contact[0][0]
|
||||
self.__contact_dict['contact']['salute'] = self.__contact[0][1]
|
||||
self.__contact_dict['contact']['fname'] = self.__contact[0][2].decode("utf-8")
|
||||
self.__contact_dict['contact']['lname'] = self.__contact[0][3].decode("utf-8")
|
||||
self.__contact_dict['contact']['phone'] = self.__contact[0][4].decode("utf-8")
|
||||
self.__contact_dict['contact']['cell'] = self.__contact[0][5].decode("utf-8")
|
||||
self.__contact_dict['contact']['position'] = self.__contact[0][6]
|
||||
self.__contact_dict['contact']['email'] = self.__contact[0][7].decode("utf-8")
|
||||
self.__contact_dict['contact']['birthday'] = self.__contact[0][8].decode("utf-8")
|
||||
self.__contact_dict['contact']['priority'] = "Ja" if self.__contact[0][9] else "Nein"
|
||||
self.__contact_dict['contact']['invoice'] = "Ja" if self.__contact[0][10] else "Nein"
|
||||
self.__contact_dict['contact']['reminder'] = "Ja" if self.__contact[0][11] else "Nein"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
from .DbManager import DbManager
|
||||
from ..PyqcrmFlags import PyqcrmFlags
|
||||
from ..Vermasseln import Vermasseln
|
||||
from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput
|
||||
#from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput : Not working well with Nuitka
|
||||
import soundfile as sf
|
||||
import sounddevice as sd
|
||||
from .UserDAO import UserDAO
|
||||
from PySide6.QtCore import Slot, QObject, Signal, QUrl
|
||||
from PySide6.QtCore import Slot, QObject, Signal, QUrl, QFile
|
||||
import tempfile
|
||||
|
||||
|
||||
|
||||
class UserManager(QObject):
|
||||
@@ -61,12 +65,24 @@ class UserManager(QObject):
|
||||
if user:
|
||||
self.__checkPassword(password, user[2])
|
||||
else:
|
||||
player = QMediaPlayer(self)
|
||||
audioOutput = QAudioOutput(self)
|
||||
player.setAudioOutput(audioOutput)
|
||||
player.setSource(QUrl("qrc:/sounds/fail2c.ogg"))
|
||||
audioOutput.setVolume(150)
|
||||
player.play()
|
||||
fail_src = ":/sounds/fail2c.ogg"
|
||||
with tempfile.NamedTemporaryFile(suffix='.ogg') as ogg_file:
|
||||
failure_sound = QFile(fail_src)
|
||||
if not failure_sound.open(QFile.ReadOnly):
|
||||
print(f"Failed to open resource file: {fail_src}")
|
||||
else:
|
||||
ogg_file.write(failure_sound.readAll())
|
||||
ogg_path = ogg_file.name
|
||||
fail, samplerate = sf.read(ogg_path)
|
||||
sd.play(fail, samplerate)
|
||||
|
||||
### Not working with Nuitka
|
||||
# player = QMediaPlayer(self)
|
||||
# audioOutput = QAudioOutput(self)
|
||||
# player.setAudioOutput(audioOutput)
|
||||
# player.setSource(QUrl("qrc:/sounds/fail2c.ogg"))
|
||||
# audioOutput.setVolume(150)
|
||||
# player.play()
|
||||
|
||||
def __checkPassword(self, password, hash_password):
|
||||
pw_list = hash_password.split("$")
|
||||
|
||||
Reference in New Issue
Block a user