def on_documents_add_button_clear_clicked(self, documents_add_button_clear): self.tree_selection.unselect_all() self.file_chooser.unselect_all() entries = self.entries Function.clear_entries(self, entries) self.current_filter = None
def on_equipment_proof_button_clear_clicked(self, equipment_proof_button_clear): self.tree_selection.unselect_all() self.file_chooser.unselect_all() entries = self.entries Function.clear_entries(self, entries) self.current_filter = None
def onSelectionChanged(self, tree_selection): (model, pathlist) = tree_selection.get_selected_rows() for path in pathlist: tree_iter = model.get_iter(path) c = self.columns self.row = [] for i in c: value = model.get_value(tree_iter, c[i]) self.row.append(str(value)) print(self.row) Function.set_entries(self, self.entries, self.row) if self.calander != None: for j in range(len(self.column_headings)): if self.column_headings[j].endswith("Expiry") == True: date_to_set = self.row[j] Cal_Date.set_date(self, calander_object=self.calander, date=date_to_set) elif self.column_headings[j].endswith("Date") == True: date_to_set = self.row[j] Cal_Date.set_date(self, calander_object=self.calander, date=date_to_set) if self.file_chooser != None: for k in range(len(self.column_headings)): if self.column_headings[k].endswith("Certificate") == True: f = Gio.File.new_for_path(self.row[k]) self.file_chooser.set_file(f) elif self.column_headings[k].endswith("File") == True: f = Gio.File.new_for_path(self.row[k]) self.file_chooser.set_file(f)
def on_documents_add_button_enter_clicked(self, documents_add_button_enter): entries = [ "documents_add_entry_for", "documents_add_entry_ref", "documents_add_entry_name", "documents_add_entry_issue", "documents_add_entry_reason" ] text = Function.get_entries(self, entries) date = Cal_Date.date(self, "documents_add_calendar_date") doc = '' if self.file != None: file_name = text[2] file_settings = { "dep": "Procedures", "sub": text[0], "eal_ref": None } doc = Function.file_path2(self, self.file, file_name, file_settings) shutil.copy(self.file, doc) self.file_chooser.unselect_all() else: doc = "Not Uploaded" now = datetime.now() for item in self.current_items: row = list(item) if row[1] == text[1]: match = True break else: match = False if match == True: query = self.queries.documents["update"] values = (now, text[0], text[2], text[3], text[4], date, doc, text[1]) procedure = 'N/A' message = text[1] + ' updated field' log_query = self.queries.logbook["insert"] log_values = (now, text[0], now, text[4], text[3], message) self.update(query, values, log_query, log_values) elif match == False: query = self.queries.documents["insert"] values = (now, text[0], text[1], text[2], text[3], text[4], date, doc) log_query = self.queries.logbook["insert"] log_values = (now, text[1], date, "N/A", text[2], text[4]) self.insert(query, values, log_query, log_values) Function.clear_entries(self, entries)
def on_equipment_log_button_enter_clicked(self, equipment_log_button_enter): entries = [ "equipment_log_entry_eal", "equipment_log_entry_from", "equipment_log_entry_procedure", "equipment_log_entry_message" ] text = Function.get_entries(self, entries) log_date = Cal_Date.date(self, "equipment_log_calendar_date") now = datetime.now() log_values = (now, text[0], log_date, text[1], text[2], text[3]) log_query = self.queries.logbook["insert"] self.log_insert(log_query, log_values) Function.clear_entries(self, entries)
def on_login_button_clicked(self, login_button): user = Function.get_entry(self, "login_username") p_word = Function.get_entry(self, "login_password") error = self.builder.get_object("warning_label") dbConfig['user'] = user dbConfig['password'] = p_word try: self.conn = mysql.connector.connect(**dbConfig) self.store_func = Store(dbConfig) self.queries = Queries(dbConfig) self.pages() self.login.destroy() self.main.show_all() except mysql.connector.Error as err: error.set_label("Error occured: {}".format(err))
def on_equipment_add_button_add_clicked(self, equipment_add_button_add): entries = [ "equipment_add_entry_eal", "equipment_add_entry_type", "equipment_add_entry_manufacturer", "equipment_add_entry_model", "equipment_add_entry_pressure", "equipment_add_entry_serial" ] text = Function.get_entries(self, entries) now = datetime.now() for item in self.current_items: row = list(item) if row[0] == text[0]: match = True break else: match = False if match == True: query = self.queries.equipment["update"] utext = text[1:] utext.append(text[0]) values = (now, utext[0], utext[1], utext[2], utext[3], utext[4], utext[5]) location = 'Westcott' procedure = 'N/A' message = text[0] + ' updated field' log_query = self.queries.logbook["insert"] log_values = (now, text[0], now, location, procedure, message) self.update(query, values, log_query, log_values) elif match == False: values = (now, text[0], text[1], text[2], text[3], text[4], text[5]) location = 'Westcott' procedure = 'N/A' message = text[0] + ' added to equipment store' log_query = self.queries.logbook["insert"] log_values = (now, text[0], now, location, procedure, message) query = self.queries.equipment["insert"] self.insert(query, values, log_query, log_values) Function.clear_entries(self, entries)
def __init__(self, queries, store_func, parent, com_store): self.queries = queries self.type = "External" self.entries = { "equipment_calibration_entry_eal": 0, "equipment_calibration_entry_company": 1 } setup = { "glade_file": "Glade/equipment_calibration.glade", "widget_id": "equipment_calibration_page", "widget_scroll_id": "equipment_calibration_scroll_window", "widget_calander_id": "equipment_calibration_calendar_date", "timer_query": queries.calibration["select"], "store_setup": Gtk.ListStore(str, str, str, str, str, str, str), "column_numbers": (0, 1, 2, 3, 4, 5, 6), "column_headings": [ "EAL Number", "Calibration Company", "Calibration Type", "Calibration Date", "Calibration Recall", "Calibration Expiry", "Calibration Certificate" ], "entries": self.entries, "file_chooser": "equipment_calibration_file_certificate" } Widget.__init__(self, store_func, parent, queries, **setup) Function.entry_completion(self, com_store, "equipment_calibration_entry_eal", 0)
def __init__(self, queries, store_func, parent, com_store, proc_store): self.queries = queries self.entries = { "equipment_log_entry_eal": 0, "equipment_log_entry_from": 2, "equipment_log_entry_procedure": 3, "equipment_log_entry_message": 4 } setup = { "glade_file": "Glade/equipment_log.glade", "widget_id": "equipment_log_page", "widget_scroll_id": "equipment_log_scroll_window", "widget_calander_id": "equipment_log_calendar_date", "timer_query": queries.logbook["select"], "store_setup": Gtk.ListStore(str, str, str, str, str), "column_numbers": (0, 1, 2, 3, 4), "column_headings": ["EAL Number", "Log Date", "Location", "Documents", "Message"], "entries": self.entries, "file_chooser": None } Widget.__init__(self, store_func, parent, queries, **setup) Function.entry_completion(self, com_store, "equipment_log_entry_eal", 0) Function.entry_completion(self, proc_store, "equipment_log_entry_procedure", 2)
def __init__(self, queries, store_func, parent, com_store, proc_store): self.queries = queries self.entries = { "equipment_cleanliness_entry_eal": 0, "equipment_cleanliness_entry_pco": 1, "equipment_cleanliness_entry_dew": 2, "equipment_cleanliness_entry_procedure": 3, "equipment_cleanliness_entry_location": 7 } self.result = "Pass" setup = { "glade_file": "Glade/equipment_cleanliness.glade", "widget_id": "equipment_cleanliness_page", "widget_scroll_id": "equipment_cleanliness_scroll_window", "widget_calander_id": "equipment_cleanliness_calendar_date", "timer_query": queries.cleanliness["select"], "store_setup": Gtk.ListStore(str, str, str, str, str, str, str, str, str, str), "column_numbers": (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), "column_headings": [ "EAL Number", "Particle Counter Number", "Dew Point Meter", "Procedure", "Cleanliness & Dryness Date", "Cleanliness & Dryness Recall", "Cleanliness & Dryness Expiry", "Test Location", "Result", "Proof Certificate" ], "entries": self.entries, "file_chooser": "equipment_cleanliness_file_certificate" } Widget.__init__(self, store_func, parent, queries, **setup) Function.entry_completion(self, com_store, "equipment_cleanliness_entry_eal", 0) Function.entry_completion(self, com_store, "equipment_cleanliness_entry_pco", 0) Function.entry_completion(self, com_store, "equipment_cleanliness_entry_dew", 0) Function.entry_completion(self, proc_store, "equipment_cleanliness_entry_procedure", 2)
def __init__(self, queries, store_func, parent): self.entries = { "equipment_add_entry_eal": 0, "equipment_add_entry_type": 1, "equipment_add_entry_manufacturer": 2, "equipment_add_entry_model": 3, "equipment_add_entry_pressure": 4, "equipment_add_entry_serial": 5 } self.queries = queries setup = { "glade_file": "Glade/equipment_add.glade", "widget_id": "equipment_add_page", "widget_scroll_id": "equipment_add_scroll_window", "widget_calander_id": None, "timer_query": queries.equipment["select"], "store_setup": Gtk.ListStore(str, str, str, str, int, str), "column_numbers": (0, 1, 2, 3, 4, 5), "column_headings": [ "EAL Number", "Equipment Type", "Manufacturer", "Model", "Pressure", "Serial Number" ], "entries": self.entries, "file_chooser": None } Widget.__init__(self, store_func, parent, queries, **setup) Function.entry_completion(self, self.store, "equipment_add_entry_eal", 0) Function.entry_completion(self, self.store, "equipment_add_entry_type", 1) Function.entry_completion(self, self.store, "equipment_add_entry_manufacturer", 2) Function.entry_completion(self, self.store, "equipment_add_entry_model", 3)
def __init__(self, queries, store_func, parent, com_store, proc_store): self.queries = queries self.entries = { "equipment_proof_entry_eal": 0, "equipment_proof_entry_bar": 1, "equipment_proof_entry_duration": 2, "equipment_proof_entry_pt": 3, "equipment_proof_entry_procedure": 4, "equipment_proof_entry_location": 8 } self.result = "Pass" setup = { "glade_file": "Glade/equipment_proof.glade", "widget_id": "equipment_proof_page", "widget_scroll_id": "equipment_proof_scroll_window", "widget_calander_id": "equipment_proof_calendar_date", "timer_query": queries.proof["select"], "store_setup": Gtk.ListStore(str, int, int, str, str, str, str, str, str, str, str), "column_numbers": (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), "column_headings": [ "EAL Number", "Test Pressure", "Test Duration", "Transducer Number", "Procedure", "Proof Date", "Proof Recall", "Proof Expiry", "Test Location", "Result", "Proof Certificate" ], "entries": self.entries, "file_chooser": "equipment_proof_file_certificate" } Widget.__init__(self, store_func, parent, queries, **setup) Function.entry_completion(self, com_store, "equipment_proof_entry_eal", 0) Function.entry_completion(self, com_store, "equipment_proof_entry_pt", 0) Function.entry_completion(self, proc_store, "equipment_proof_entry_procedure", 2)
def __init__(self, queries, store_func, parent): self.queries = queries self.entries = { "documents_add_entry_for": 0, "documents_add_entry_ref": 1, "documents_add_entry_name": 2, "documents_add_entry_issue": 3, "documents_add_entry_reason": 4 } setup = { "glade_file": "Glade/documents.glade", "widget_id": "documents_add_page", "widget_scroll_id": "documents_add_scroll_window", "widget_calander_id": "documents_add_calendar_date", "timer_query": queries.documents["select"], "store_setup": Gtk.ListStore(str, str, str, int, str, str, str), "column_numbers": (0, 1, 2, 3, 4, 5, 6), "column_headings": [ "Client", "Reference", "Name", "Issue", "Reason for Issue", "Date", "File" ], "entries": self.entries, "file_chooser": "documents_add_file_path" } Widget.__init__(self, store_func, parent, queries, **setup) Function.entry_completion(self, self.store, "documents_add_entry_for", 0) Function.entry_completion(self, self.store, "documents_add_entry_ref", 1) Function.entry_completion(self, self.store, "documents_add_entry_name", 2)
def on_equipment_cleanliness_button_enter_clicked( self, equipment_cleanliness_button_enter): entries = [ "equipment_cleanliness_entry_eal", "equipment_cleanliness_entry_pco", "equipment_cleanliness_entry_dew", "equipment_cleanliness_entry_procedure", "equipment_cleanliness_entry_location" ] text = Function.get_entries(self, entries) clean_date = Cal_Date.date(self, "equipment_cleanliness_calendar_date") clean_expiry = Cal_Date.expiry(self, clean_date, 12) clean_recall = Cal_Date.recall(self, clean_expiry) clean_certificate = '' if self.file != None: file_name = 'Cleanliness_&_Dryness_Certificate_' + str(clean_date) file_settings = { "dep": "Equipment", "sub": "Cleanliness_&_Dryness", "eal_ref": text[0] } clean_certificate = Function.file_path2(self, self.file, file_name, file_settings) shutil.copy(self.file, clean_certificate) self.file_chooser.unselect_all() else: clean_certificate = "Not Uploaded" now = datetime.now() for item in self.current_items: row = list(item) if row[0] == text[0]: match = True break else: match = False if match == True: query = self.queries.cleanliness["update"] utext = text[1:] utext.append(text[0]) values = (now, utext[0], utext[1], utext[2], clean_date, clean_recall, clean_expiry, utext[3], self.result, clean_certificate, utext[4]) procedure = 'N/A' message = text[0] + ' updated field' log_query = self.queries.logbook["insert"] log_values = (now, text[0], now, text[4], text[3], message) self.update(query, values, log_query, log_values) elif match == False: message = "Cleanliness & Dryness certificate added." values = (now, text[0], text[1], text[2], text[3], clean_date, clean_recall, clean_expiry, text[4], self.result, clean_certificate) log_values = (now, text[0], now, text[4], text[3], message) query = self.queries.cleanliness["insert"] log_query = self.queries.logbook["insert"] self.insert(query, values, log_query, log_values) Function.clear_entries(self, entries)
def on_equipment_calibration_button_enter_clicked( self, equipment_calibration_button_enter): entries = [ "equipment_calibration_entry_eal", "equipment_calibration_entry_company" ] text = Function.get_entries(self, entries) print(text) calibration_type = self.type if (calibration_type == "External"): length = 12 elif (calibration_type == "Internal"): length = 6 else: length = 12 calibration_date = Cal_Date.date( self, "equipment_calibration_calendar_date") calibration_expiry = Cal_Date.expiry(self, calibration_date, length) calibration_recall = Cal_Date.recall(self, calibration_expiry) calibration_certificate = '' if self.file != None: file_name = 'Calibration_Certificate_' + str(calibration_date) file_settings = { "dep": "Equipment", "sub": "Calibration", "eal_ref": text[0] } calibration_certificate = Function.file_path2( self, self.file, file_name, file_settings) shutil.copy(self.file, calibration_certificate) self.file_chooser.unselect_all() else: calibration_certificate = "Not Uploaded" now = datetime.now() location = Function.get_entry(self, "equipment_calibration_entry_location") for item in self.current_items: row = list(item) if row[0] == text[0]: match = True break else: match = False if match == True: query = self.queries.calibration["update"] utext = text[1:] utext.append(text[0]) values = (now, utext[0], calibration_type, calibration_date, calibration_recall, calibration_expiry, calibration_certificate, utext[1]) procedure = 'N/A' message = text[0] + ' updated field' log_query = self.queries.logbook["insert"] log_values = (now, text[0], now, location, procedure, message) self.update(query, values, log_query, log_values) elif match == False: message = "Calibration certificate added." procedure = "N/A" values = (now, text[0], text[1], calibration_type, calibration_date, calibration_recall, calibration_expiry, calibration_certificate) log_values = (now, text[0], now, location, procedure, message) query = self.queries.calibration["insert"] log_query = self.queries.logbook["insert"] self.insert(query, values, log_query, log_values) Function.clear_entries(self, entries)