mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-03 20:12:59 +00:00
Add files via upload
This commit is contained in:
@@ -187,6 +187,7 @@ func parseExcelFile(filename string) ([]Contact, error) {
|
|||||||
func parseTable(f *excelize.File, sheetName, startCol, endCol string, tableNum int) []Contact {
|
func parseTable(f *excelize.File, sheetName, startCol, endCol string, tableNum int) []Contact {
|
||||||
var contacts []Contact
|
var contacts []Contact
|
||||||
var currentContact *Contact
|
var currentContact *Contact
|
||||||
|
var lastUpdate string
|
||||||
|
|
||||||
// Get all rows in the sheet
|
// Get all rows in the sheet
|
||||||
rows, err := f.GetRows(sheetName)
|
rows, err := f.GetRows(sheetName)
|
||||||
@@ -217,13 +218,11 @@ func parseTable(f *excelize.File, sheetName, startCol, endCol string, tableNum i
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip general contacts and update date line
|
// Check for "Aktualizace" - end of data
|
||||||
if strings.Contains(row[nameCol], "převzetí hovoru") ||
|
if len(row) > nameCol && strings.Contains(strings.ToLower(row[nameCol]), "aktualizace") {
|
||||||
strings.Contains(row[nameCol], "hlavní vchod") ||
|
lastUpdate = row[nameCol]
|
||||||
strings.Contains(row[nameCol], "brána") ||
|
currentContact = nil // Reset to avoid attaching to previous contact
|
||||||
strings.HasPrefix(row[nameCol], "Aktualizace dne") ||
|
break
|
||||||
strings.HasPrefix(row[nameCol], "Poslední aktualizace") {
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for special formatting rows (like "*02(xx)")
|
// Check for special formatting rows (like "*02(xx)")
|
||||||
@@ -260,19 +259,43 @@ func parseTable(f *excelize.File, sheetName, startCol, endCol string, tableNum i
|
|||||||
Table: tableNum,
|
Table: tableNum,
|
||||||
}
|
}
|
||||||
contacts = append(contacts, *currentContact)
|
contacts = append(contacts, *currentContact)
|
||||||
} else if currentContact != nil && !strings.HasPrefix(row[nameCol], "Aktualizace dne") {
|
} else if strings.Contains(name, "Aktualizace") {
|
||||||
// This is additional data for the current contact
|
// Capture the update date
|
||||||
newContact := *currentContact
|
lastUpdate = name
|
||||||
if position != "" {
|
currentContact = nil // Reset to avoid attaching to previous contact
|
||||||
|
} else if currentContact != nil && name == "" {
|
||||||
|
// This is additional data for the current contact or a general contact
|
||||||
|
if position != "" && !strings.Contains(position, "Vorlová") && !strings.Contains(position, "inženýrka") {
|
||||||
|
// Treat as a general contact if it doesn't contain specific personal identifiers
|
||||||
|
currentContact = &Contact{
|
||||||
|
Name: position, // Use position as the name for general contacts
|
||||||
|
Position: "",
|
||||||
|
Phone: phone,
|
||||||
|
ServicePhone: servicePhone,
|
||||||
|
Table: tableNum,
|
||||||
|
}
|
||||||
|
contacts = append(contacts, *currentContact)
|
||||||
|
} else if position != "" {
|
||||||
|
newContact := *currentContact
|
||||||
newContact.Position = position
|
newContact.Position = position
|
||||||
|
if phone != "" {
|
||||||
|
newContact.Phone = phone
|
||||||
|
}
|
||||||
|
if servicePhone != "" {
|
||||||
|
newContact.ServicePhone = servicePhone
|
||||||
|
}
|
||||||
|
contacts = append(contacts, newContact)
|
||||||
}
|
}
|
||||||
if phone != "" {
|
}
|
||||||
newContact.Phone = phone
|
}
|
||||||
}
|
|
||||||
if servicePhone != "" {
|
// Update last updated date
|
||||||
newContact.ServicePhone = servicePhone
|
if lastUpdate != "" {
|
||||||
}
|
lastUpdated, err := time.Parse("2.1.2006", lastUpdate)
|
||||||
contacts = append(contacts, newContact)
|
if err != nil {
|
||||||
|
log.Printf("Error parsing last updated date: %v", err)
|
||||||
|
} else {
|
||||||
|
currentData.LastUpdated = lastUpdated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user