1 ) ); $aieo_rex_form_id = 'aieo-remote-export-form'; list( $aieo_rex_open, $aieo_rex_close ) = AIEO_DMM_UI::card( array( 'anchor' => 'remote-export-settings', 'icon' => 'settings', 'title' => __( 'Settings', 'ai-eshop-optimizer' ), 'description' => __( 'Stream Rooster One raw events + rollups to an operator-owned remote MariaDB / MySQL instance for unbounded BI / analyst access. The local store stays small (capped by retention); the remote holds the full event history.', 'ai-eshop-optimizer' ), 'class' => 'aieo-remote-export', 'footer' => \Rooster\Admin\States::save_button( $aieo_rex_form_id, array( 'label' => __( 'Save settings', 'ai-eshop-optimizer' ), 'attrs' => array( 'id' => 'aieo-rex-save' ) ) ), ) ); echo $aieo_rex_open; $aieo_rex_erp_url = admin_url( 'admin.php?page=' . AIEO_DMM::MENU_SLUG . '&dmm_tab=erp_database' ); if ( empty( $connections ) ) { $aieo_rex_none = \Rooster\Admin\Ui::notice( wp_kses_post( sprintf( __( 'No ERP connections configured yet. Add one in %s first.', 'ai-eshop-optimizer' ), '' . esc_html__( 'Tools → ERP Database', 'ai-eshop-optimizer' ) . '' ) ), 'warning', array( 'inline' => true ) ); echo $aieo_rex_none; } $aieo_rex_manage = __( 'Manage destination connections at %s. They are the same encrypted connections used by the ERP-bridge tab; passwords never round-trip through this form.', 'ai-eshop-optimizer' ); $aieo_rex_guide = \Rooster\Admin\Guidance::text( sprintf( $aieo_rex_manage, __( 'Tools → ERP Database', 'ai-eshop-optimizer' ) ), 'guidance', array( 'html' => sprintf( esc_html( $aieo_rex_manage ), '' . esc_html__( 'Tools → ERP Database', 'ai-eshop-optimizer' ) . '' ) ) ); echo $aieo_rex_guide; $aieo_rex_connection_options = array( '0' => __( '— select a connection —', 'ai-eshop-optimizer' ) ); foreach ( $connections as $c ) { $aieo_rex_connection_options[ (string) $c['id'] ] = $c['name'] . ' (' . $c['host'] . ' / ' . $c['db_name'] . ')'; } $aieo_rex_table_options = array(); $aieo_rex_table_notes = array(); foreach ( $tables as $slug => $label ) { $aieo_rex_table_options[ $slug ] = $slug; $aieo_rex_table_notes[ $slug ] = $label; } ob_start(); ?>
'aieo-rex-connection', 'label' => __( 'Destination connection', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::select( 'connection_id', $aieo_rex_connection_options, (string) (int) $settings['connection_id'], array( 'id' => 'aieo-rex-connection' ) ), ) ); echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-rex-tables', 'label' => __( 'Tables to export', 'ai-eshop-optimizer' ), 'group' => true, 'control' => \Rooster\Admin\Ui::checks( 'tables', $aieo_rex_table_options, array_map( 'strval', (array) $settings['tables'] ), array( 'descriptions' => $aieo_rex_table_notes ) ), ) ); echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-rex-frequency', 'label' => __( 'Export frequency', 'ai-eshop-optimizer' ), 'group' => true, 'control' => \Rooster\Admin\Fields::segmented( 'frequency', array( '15min' => __( 'Every 15 minutes', 'ai-eshop-optimizer' ), 'hourly' => __( 'Hourly', 'ai-eshop-optimizer' ), 'daily' => __( 'Daily', 'ai-eshop-optimizer' ), ), (string) $settings['frequency'], array( 'labelledby' => 'aieo-rex-frequency-label', 'id' => 'aieo-rex-frequency-switch' ) ), ) ); echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-rex-batch', 'label' => __( 'Batch size', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::input( 'batch_size', (string) (int) $settings['batch_size'], array( 'id' => 'aieo-rex-batch', 'type' => 'number', 'short' => true, 'min' => 50, 'max' => 50000, 'unit' => __( 'rows', 'ai-eshop-optimizer' ) ) ), 'help' => __( 'Rows per remote INSERT IGNORE statement. Lower if the remote times out on large batches.', 'ai-eshop-optimizer' ), ) ); echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-rex-purge', 'label' => __( 'Local retention failsafe', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::toggle( 'purge_only_on_success', ! empty( $settings['purge_only_on_success'] ), array( 'id' => 'aieo-rex-purge', 'hidden' => false, 'label' => __( 'Hold local archive deletes until the remote confirms (recommended).', 'ai-eshop-optimizer' ) ) ), 'help' => __( 'When ON, the AE / Reco archive purges check the remote-export bookkeeping before deleting any hot row. If the remote is unreachable, local rows are kept until the export catches up.', 'ai-eshop-optimizer' ), ) ); ?>
array( 'autocomplete' => 'off' ) ) ); $aieo_rex_run = \Rooster\Admin\States::job( array( 'id' => 'aieo-rex-run-job', 'state' => 'idle', 'run' => __( 'Run export now', 'ai-eshop-optimizer' ), 'primary' => false, 'run_attrs' => array( 'id' => 'aieo-rex-force-run' ), ) ); echo $aieo_rex_run; ?> 'remote-export-per-table-status', 'icon' => 'table', 'title' => __( 'Per-table status', 'ai-eshop-optimizer' ), 'description' => __( 'Check, table by table, how far behind the remote database is and whether the last export worked, and send a test batch.', 'ai-eshop-optimizer' ), 'class' => 'aieo-remote-export', 'flush' => true, ) ); echo $aieo_rex_open; ?>
'remote-export-force-re-export', 'icon' => 'refresh-cw', 'title' => __( 'Force re-export', 'ai-eshop-optimizer' ), 'description' => __( 'Operator escape hatch — rewinds the bookkeeping watermark for one table to a chosen timestamp so the next cron tick re-streams every row after that point. INSERT IGNORE on the remote prevents duplicates.', 'ai-eshop-optimizer' ), 'class' => 'aieo-remote-export', ) ); echo $aieo_rex_open; $aieo_rex_pick = array( '' => __( '— pick —', 'ai-eshop-optimizer' ) ); foreach ( $tables as $slug => $label ) { $aieo_rex_pick[ $slug ] = $slug; } ?>
'aieo-rex-reexp-table', 'label' => __( 'Table', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::select( '', $aieo_rex_pick, '', array( 'id' => 'aieo-rex-reexp-table' ) ), ) ); echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-rex-reexp-ts', 'label' => __( 'From (GMT)', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::input( '', '', array( 'id' => 'aieo-rex-reexp-ts', 'medium' => true, 'code' => true, 'placeholder' => 'YYYY-MM-DD HH:MM:SS' ) ), ) ); ?>
'aieo-rex-reexp-job', 'state' => 'idle', 'run' => __( 'Reset watermark', 'ai-eshop-optimizer' ), 'primary' => false, 'run_attrs' => array( 'id' => 'aieo-rex-reexp-run' ), ) ); echo $aieo_rex_reset; $aieo_rex_ask = \Rooster\Admin\States::confirm( 'aieo-rex-reexp-confirm', 'reset', __( 'Reset the watermark?', 'ai-eshop-optimizer' ), '

' . esc_html__( 'Force re-export from this timestamp? Remote rows will not be deleted (INSERT IGNORE keeps them).', 'ai-eshop-optimizer' ) . '

', array( 'confirm' => __( 'Reset watermark', 'ai-eshop-optimizer' ) ) ); echo $aieo_rex_ask; ?>