fix(perfexcrm module): align version to 3.0.1, unify entrypoint, and harden routes/views
- Bump DESK_MOLONI version to 3.0.1 across module - Normalize hooks to after_client_* and instantiate PerfexHooks safely - Fix OAuthController view path and API client class name - Add missing admin views for webhook config/logs; adjust view loading - Harden client portal routes and admin routes mapping - Make Dashboard/Logs/Queue tolerant to optional model methods - Align log details query with existing schema; avoid broken joins This makes the module operational in Perfex (admin + client), reduces 404s, and avoids fatal errors due to inconsistent tables/methods.
This commit is contained in:
57
create_tables.php
Normal file
57
create_tables.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
// Simple script to create Desk-Moloni tables directly
|
||||
// Run this on the server to create missing tables
|
||||
|
||||
define('BASEPATH', true);
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
// Include CodeIgniter bootstrap
|
||||
require_once('index.php');
|
||||
|
||||
$CI = &get_instance();
|
||||
|
||||
echo "Creating Desk-Moloni mapping table...\n";
|
||||
|
||||
// Create the mapping table with correct structure
|
||||
$sql = "CREATE TABLE IF NOT EXISTS `" . db_prefix() . "deskmoloni_mapping` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`entity_type` enum('client','product','invoice','estimate','credit_note') NOT NULL,
|
||||
`perfex_id` int(11) NOT NULL,
|
||||
`moloni_id` int(11) NOT NULL,
|
||||
`sync_direction` enum('perfex_to_moloni','moloni_to_perfex','bidirectional') NOT NULL DEFAULT 'bidirectional',
|
||||
`last_sync_at` timestamp NULL DEFAULT NULL,
|
||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `unique_perfex_mapping` (`entity_type`, `perfex_id`),
|
||||
UNIQUE KEY `unique_moloni_mapping` (`entity_type`, `moloni_id`),
|
||||
KEY `idx_entity_perfex` (`entity_type`, `perfex_id`),
|
||||
KEY `idx_entity_moloni` (`entity_type`, `moloni_id`),
|
||||
KEY `idx_last_sync` (`last_sync_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";
|
||||
|
||||
try {
|
||||
$CI->db->query($sql);
|
||||
echo "✅ Table " . db_prefix() . "deskmoloni_mapping created successfully!\n";
|
||||
} catch (Exception $e) {
|
||||
echo "❌ Error creating table: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
// Check if table exists
|
||||
$query = $CI->db->query("SHOW TABLES LIKE '" . db_prefix() . "deskmoloni_mapping'");
|
||||
if ($query->num_rows() > 0) {
|
||||
echo "✅ Table exists and is ready!\n";
|
||||
|
||||
// Show table structure
|
||||
$structure = $CI->db->query("DESCRIBE " . db_prefix() . "deskmoloni_mapping");
|
||||
echo "\n📋 Table structure:\n";
|
||||
foreach ($structure->result() as $column) {
|
||||
echo " - {$column->Field}: {$column->Type}\n";
|
||||
}
|
||||
} else {
|
||||
echo "❌ Table was not created properly!\n";
|
||||
}
|
||||
|
||||
echo "\nDone!\n";
|
||||
Reference in New Issue
Block a user