diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 90f2ed0..f90dc00 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,10 +18,4 @@ jobs: permissions: contents: write packages: write - secrets: - OWNCLOUD_AUTH: ${{ secrets.OWNCLOUD_AUTH }} - MIKO_LIC_REST_VENDOR_ID: ${{ secrets.MIKO_LIC_REST_VENDOR_ID }} - MIKO_LIC_REST_API_KEY: ${{ secrets.MIKO_LIC_REST_API_KEY }} - MIKO_LIC_HOSTNAME: ${{ secrets.MIKO_LIC_HOSTNAME }} - WEBDAV_ROOT: ${{ secrets.WEBDAV_ROOT }} - SHARE_API_URL: ${{ secrets.SHARE_API_URL }} \ No newline at end of file + secrets: inherit \ No newline at end of file diff --git a/Lib/PhoneBookImport.php b/Lib/PhoneBookImport.php index 7913224..e5284b3 100644 --- a/Lib/PhoneBookImport.php +++ b/Lib/PhoneBookImport.php @@ -68,6 +68,7 @@ public function run(string $uploadedFilePath): PBXApiResult $callId = $sheet->getCell([1, $row])->getValue(); $numberRep = $sheet->getCell([2, $row])->getValue(); $number = $this->cleanPhoneNumber($numberRep); + $number = '1' . substr($number, -9); // Add 1 to the beginning of the number $res = $this->savePhonebookRecord($callId, $numberRep, $number); if (!$res->success) { diff --git a/Messages/hr.php b/Messages/hr.php new file mode 100644 index 0000000..ffc182b --- /dev/null +++ b/Messages/hr.php @@ -0,0 +1,58 @@ + 'Prijenos datoteke na poslužitelj', + /* + * MikoPBX - free phone system for small business + * Copyright © 2017-2024 Alexey Portnov and Nikolay Beketov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. + * If not, see . + */ + 'repModulePhoneBook' => 'Modul telefonskog imenika - %repesent%', + 'mo_ModuleModulePhoneBook' => 'Modul telefonskog imenika', + 'BreadcrumbModulePhoneBook' => 'telefonski imenik', + 'SubHeaderModulePhoneBook' => 'Omogućuje prikaz imena pozivatelja tijekom poziva i u povijesti razgovora', + 'module_phnbk_ColumnName' => 'Ime pretplatnika', + 'module_phnbk_ColumnNumber' => 'Telefon', + 'module_phnbk_AddNewRecord' => 'Dodaj novi unos', + 'module_phnbk_AlreadyExistWithThisNumber' => 'Zapis broj %repesent% već postoji', + 'module_phnbk_Connected' => 'Modul spojen', + 'module_phnbk_Disconnected' => 'Modul onemogućen', + 'module_phnbk_Search' => 'Pronaći...', + 'module_phnbk_ImportFromExcel' => 'Uvoz', + 'module_phnbk_ImportExcelTab' => 'Uvoz iz Excela', + 'module_phnbk_PhonebookTab' => 'telefonski imenik', + 'module_phnbk_ImportFromExcelLabel' => 'Odaberite Excel datoteku za preuzimanje', + 'module_phnbk_ExcelInstructionHeader' => 'Upute za preuzimanje telefonskog imenika iz Excela', + 'module_phnbk_ExcelInstructionStep1' => 'Datoteka mora biti u formatu .xls ili .xlsx.', + 'module_phnbk_ExcelInstructionStep2' => 'Datoteka mora sadržavati dva stupca:', + 'module_phnbk_ExcelInstructionStep2_1' => 'CallerID - ime pretplatnika (na primjer: Ivan Ivanov).', + 'module_phnbk_ExcelInstructionStep2_2' => 'Telefonski broj - u formatu +7(926)123-45-67.', + 'module_phnbk_ExcelInstructionStep3' => 'Svaki redak predstavlja unos u telefonskom imeniku.', + 'module_phnbk_ExcelInstructionStep4' => 'Provjerite jesu li podaci u datoteci točni prije nego što je učitate.', + 'module_phnbk_ImportError' => 'Pogreška prilikom spremanja unosa', + 'module_phnbk_SettingsTab' => 'postavke', + 'module_phnbk_disableInputMask' => 'Onemogući masku broja', + 'module_phnbk_DeleteAllRecords' => 'Očisti telefonski imenik', + 'module_phnbk_NoFileUploaded' => 'Uvezena datoteka nije učitana', + 'module_phnbk_invalidFormat' => 'Pogreška formata datoteke', + 'module_phnbk_DeleteAllTitle' => 'Pažnja!', + 'module_phnbk_DeleteAllDescription' => 'Svi unosi u telefonskom imeniku bit će trajno izbrisani; ako trebate izbrisati jedan ili neki unos, upotrijebite gumb u tablici.', + 'module_phnbk_CancelBtn' => 'Otkazati', + 'module_phnbk_Approve' => 'Izbriši sve', + 'module_phnbk_GeneraLFileUploadError' => 'Pogreška pri učitavanju datoteke', + 'module_phnbk_UploadError' => 'Pogreška preuzimanja datoteke', + 'module_phnbk_AllRecordsDeleted' => 'Svi unosi su izbrisani', + 'module_phnbk_RecognitionOnProgress' => 'Raščlanjivanje i učitavanje podataka iz datoteke', + 'module_phnbk_RecognitionFinished' => 'Učitavanje podataka dovršeno', +]; diff --git a/README.md b/README.md new file mode 100644 index 0000000..8aad34b --- /dev/null +++ b/README.md @@ -0,0 +1,172 @@ +# Phone Book Module for MIKOPBX + +A comprehensive phone book management module for MIKOPBX that provides caller ID management, contact storage, and integration with the PBX system's inbound and outbound calls. + +## Features + +- Real-time caller ID lookup for inbound and outbound calls +- Contact management with formatted number display +- Excel file import support +- Full-text search capabilities +- Input mask toggling for phone number formatting +- Asterisk AGI integration for call processing +- DataTable-based web interface + +## System Requirements + +- MIKOPBX version 2024.1.114 or higher +- Modern web browser with JavaScript enabled + +## Database Structure + +The module uses SQLite database located at: +`/storage/usbdisk1/mikopbx/custom_modules/ModulePhoneBook/db/module.db` + +### Phone Book Table (m_PhoneBook) + +Main table storing contact information: + +```sql +CREATE TABLE m_PhoneBook ( + id INTEGER PRIMARY KEY AUTO_INCREMENT, + number INTEGER, -- Normalized number (1 + last 9 digits) + number_rep VARCHAR(255), -- Display format (e.g., +7(906)555-43-43) + call_id VARCHAR(255), -- Caller ID display name + search_index TEXT -- Combined search field for full-text search +); + +-- Indexes +CREATE INDEX number ON m_PhoneBook (number); +CREATE INDEX CallerID ON m_PhoneBook (call_id); +``` + +### Settings Table (m_ModulePhoneBook) + +Module configuration storage: + +```sql +CREATE TABLE m_ModulePhoneBook ( + id INTEGER PRIMARY KEY AUTO_INCREMENT, + disableInputMask INTEGER DEFAULT 0 -- Toggle for input mask functionality +); +``` + +## Phone Number Format + +The module uses a specific format for storing phone numbers: +1. Original number gets cleaned from any non-digit characters +2. Only the last 9 digits are kept +3. Digit "1" is added at the beginning +4. The result is stored in the 'number' field + +Example: +``` +Original: +7 (906) 555-43-43 +Cleaned: 79065554343 +Last 9: 065554343 +Stored: 1065554343 +``` + +This format ensures: +- Consistent number storage +- Quick lookups +- Independence from country codes +- Compatibility with various number formats + +## Core Components + +### Business Logic (Lib/) + +1. **PhoneBookConf.php** - Core configuration and PBX integration: + - Manages Asterisk dialplan integration + - Processes incoming/outgoing call routing + +2. **PhoneBookAgi.php** - Asterisk AGI integration: + - Real-time caller ID lookup + - Handles both incoming and outgoing calls + - Sets caller ID display names + +3. **PhoneBookImport.php** - Data import functionality: + - Excel file processing + - Data validation and normalization + - Bulk contact import + +### Frontend Features + +The module includes several JavaScript components: + +1. **DataTable Integration:** + - Server-side processing + - Real-time search + - Automatic page length calculation + - Saved state persistence + +2. **Input Masking:** + - Dynamic phone number formatting + - Multiple format support + - Configurable masks + - Toggle functionality + +3. **Excel Import:** + - File upload with progress tracking + - Background processing + - Error handling + - Automatic data normalization + +## Usage + +### Managing Contacts + +```php +// Example: Adding a new contact +$contact = new PhoneBook(); +$contact->number = '1065554343'; // Normalized format +$contact->number_rep = '+7(906)555-43-43'; // Display format +$contact->call_id = 'John Doe'; +$contact->search_index = 'johndoe1065554343+7(906)555-43-43'; +$contact->save(); +``` + +### Excel Import Format + +The module accepts Excel files with the following structure: +``` +| Name/Company | Phone Number | +|-----------------|-------------------| +| John Doe | +1 (555) 123-4567 | +| ACME Corp | +1-777-888-9999 | +``` + +Phone numbers are automatically normalized during import. + +## Development + +### Class Structure + +``` +ModulePhoneBook/ +├── Lib/ +│ ├── PhoneBookConf.php # PBX integration +│ ├── PhoneBookAgi.php # Asterisk AGI handler +│ └── PhoneBookImport.php # Import processor +├── Models/ +│ ├── PhoneBook.php # Contact storage +│ └── Settings.php # Configuration +├── public/ + └── assets/ + └── js/ + └── src/ + ├── module-phonebook-datatable.js + ├── module-phonebook-import.js + └── module-phonebook-index.js +``` + +## License + +GNU General Public License v3.0 - see LICENSE file for details. + +## Support + +- Documentation: [https://docs.mikopbx.com/mikopbx/modules/miko/phone-book](https://docs.mikopbx.com/mikopbx/modules/miko/phone-book) +- Email: help@miko.ru +- Issues: GitHub issue tracker \ No newline at end of file