diff --git a/mL-ham_logbook.mpy b/mL-ham_logbook.mpy index 79dbc0c..996a56b 100755 --- a/mL-ham_logbook.mpy +++ b/mL-ham_logbook.mpy @@ -281,30 +281,53 @@ def viewLogBook() : def exportLogBook() : global db global handle + secLevel = mci2str('SL') + filter = handle + who = "" + if secLevel == "255" : + gotoxy(22,19) + write("View [A]ll or [S]elf only: ") + ch = onekey(chr(13) + 'AS', False) + if ch == "S" : + pass + write("SELF") + if ch == "A" : + filter = "all" + who = "ReportedBy," + write("ALL") + callsign = db["users"][handle]["callsign"] tempFile = script_path+"/"+"mL-ham_logbook_"+callsign.lower()+".csv" fHandle = open(tempFile, "w") - fHandle.write("Date,Callsign,Name,RST IN,RST OUT,Notes\n") + fHandle.write(who+"Date,Callsign,Name,RST IN,RST OUT,Notes\n") found = False for LOG in sorted(db["logs"], reverse=False) : - if db["logs"][LOG]["reportedBy"] == handle : + if (filter == "all") or (db["logs"][LOG]["reportedBy"] == handle) : found = True + reportedBy = str(db["logs"][LOG]["reportedBy"]) contactCall = str(db["logs"][LOG]["contactCall"]) observedSig = str(db["logs"][LOG]["observedSig"]) yourSig = str(db["logs"][LOG]["yourSig"]) theirName = str(db["logs"][LOG]["theirName"]) notes = str(db["logs"][LOG]["notes"]) - fHandle.write(LOG+","+contactCall+","+theirName+" "+observedSig+","+yourSig+","+notes+"\n") + if who != "" : + showWho = reportedBy+"," + else : + showWho = "" + fHandle.write(showWho+LOG+","+contactCall+","+theirName+" "+observedSig+","+yourSig+","+notes+"\n") fHandle.close() - menucmd('F3',tempFile) - os.remove(tempFile) - writeln("File exported") - writeln("|PA") - if not found : - writeln("Sorry, no records to export. Aborted.") + + if found : + menucmd('F3',tempFile) + writeln("|15File exported|07") writeln("|PA") + else : + writeln("|15Sorry, no records to export. Aborted.|07") + writeln("|PA") + + os.remove(tempFile) def checkConfig(S = None) :