mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-05 13:02:58 +00:00
Add files via upload
This commit is contained in:
+20
-37
@@ -20,7 +20,6 @@ type Contact struct {
|
|||||||
Position string `json:"position"`
|
Position string `json:"position"`
|
||||||
Phone string `json:"phone,omitempty"`
|
Phone string `json:"phone,omitempty"`
|
||||||
ServicePhone string `json:"service_phone,omitempty"`
|
ServicePhone string `json:"service_phone,omitempty"`
|
||||||
Table int `json:"table"` // 1 for first table, 2 for second table
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContactData struct {
|
type ContactData struct {
|
||||||
@@ -32,7 +31,7 @@ type ContactData struct {
|
|||||||
var (
|
var (
|
||||||
currentData *ContactData
|
currentData *ContactData
|
||||||
dataFile = "data/contacts.json"
|
dataFile = "data/contacts.json"
|
||||||
xlsxFile = "contacts.xlsx"
|
xlsxFile = "TelefonniSeznamWeb.xlsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func startAutoReload() {
|
func startAutoReload() {
|
||||||
@@ -222,12 +221,12 @@ func parseTable(f *excelize.File, sheetName, startCol, endCol string, tableNum i
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Column indices
|
// Column indices
|
||||||
var nameCol, positionCol, phoneCol, servicePhoneCol int
|
const (
|
||||||
if tableNum == 1 {
|
nameCol = 0
|
||||||
nameCol, positionCol, phoneCol, servicePhoneCol = 0, 1, 2, 3 // A, B, C, D
|
phoneCol = 2
|
||||||
} else {
|
servicePhoneCol = 3
|
||||||
nameCol, positionCol, phoneCol = 5, 6, 7 // F, G, H
|
mobileKlapkaCol = 4
|
||||||
}
|
)
|
||||||
|
|
||||||
for i := startRow; i < len(rows); i++ {
|
for i := startRow; i < len(rows); i++ {
|
||||||
row := rows[i]
|
row := rows[i]
|
||||||
@@ -243,52 +242,36 @@ func parseTable(f *excelize.File, sheetName, startCol, endCol string, tableNum i
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for special formatting rows (like "*02(xx)")
|
// Check for special formatting rows (like "*02(xx)")
|
||||||
if len(row) > positionCol && strings.Contains(row[positionCol], "*") {
|
if len(row) > 1 && strings.Contains(row[1], "*") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
name := strings.TrimSpace(row[nameCol])
|
// Get values from columns (new structure: name, position, phone, service phone, mobile)
|
||||||
position := ""
|
name := strings.TrimSpace(row[0])
|
||||||
phone := ""
|
position := strings.TrimSpace(row[1])
|
||||||
servicePhone := ""
|
phone := strings.TrimSpace(row[2])
|
||||||
|
servicePhone := strings.TrimSpace(row[3])
|
||||||
if len(row) > positionCol {
|
mobileKlapka := ""
|
||||||
position = strings.TrimSpace(row[positionCol])
|
if len(row) > 4 {
|
||||||
}
|
mobileKlapka = strings.TrimSpace(row[4])
|
||||||
if len(row) > phoneCol {
|
|
||||||
phone = strings.TrimSpace(row[phoneCol])
|
|
||||||
}
|
|
||||||
if tableNum == 1 && len(row) > servicePhoneCol {
|
|
||||||
servicePhone = strings.TrimSpace(row[servicePhoneCol])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean phone numbers
|
// Clean phone numbers
|
||||||
phone = cleanPhoneNumber(phone)
|
phone = cleanPhoneNumber(phone)
|
||||||
servicePhone = cleanPhoneNumber(servicePhone)
|
servicePhone = cleanPhoneNumber(servicePhone)
|
||||||
|
|
||||||
// If we have a name, start a new contact
|
// If we have a name, create new contact
|
||||||
if name != "" && !strings.Contains(name, "(") {
|
if name != "" && !strings.Contains(name, "(") {
|
||||||
currentContact = &Contact{
|
currentContact = &Contact{
|
||||||
Name: name,
|
Name: name,
|
||||||
Position: position,
|
Position: position,
|
||||||
Phone: phone,
|
Phone: phone,
|
||||||
ServicePhone: servicePhone,
|
ServicePhone: servicePhone,
|
||||||
Table: tableNum,
|
}
|
||||||
|
if mobileKlapka != "" {
|
||||||
|
currentContact.Phone += " " + mobileKlapka
|
||||||
}
|
}
|
||||||
contacts = append(contacts, *currentContact)
|
contacts = append(contacts, *currentContact)
|
||||||
} else if currentContact != nil {
|
|
||||||
// This is additional data for the current contact
|
|
||||||
newContact := *currentContact
|
|
||||||
if position != "" {
|
|
||||||
newContact.Position = position
|
|
||||||
}
|
|
||||||
if phone != "" {
|
|
||||||
newContact.Phone = phone
|
|
||||||
}
|
|
||||||
if servicePhone != "" {
|
|
||||||
newContact.ServicePhone = servicePhone
|
|
||||||
}
|
|
||||||
contacts = append(contacts, newContact)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user