Files
adsPRO/autoload/controls/class.CampaignAlerts.php
Jacek Pyziak 0024a25bfb feat: add campaign alerts feature with alerts management and UI integration
- Introduced a new `CampaignAlerts` class for handling alerts logic.
- Added database migration for `campaign_alerts` table creation.
- Implemented methods for fetching, marking, and deleting alerts in the `CampaignAlerts` factory class.
- Created a new view for displaying campaign alerts with filtering options.
- Updated the main client view to include a badge for the number of alerts.
- Enhanced sync functionality to support campaigns and products separately.
- Adjusted styles for alert badges in the UI.
2026-02-20 01:33:53 +01:00

35 lines
941 B
PHP

<?php
namespace controls;
class CampaignAlerts
{
static public function main_view()
{
$client_id = (int) \S::get( 'client_id' );
$page = max( 1, (int) \S::get( 'page' ) );
$per_page = 15;
$offset = ( $page - 1 ) * $per_page;
\factory\CampaignAlerts::mark_all_seen();
\factory\CampaignAlerts::delete_old_alerts( 30 );
$total = \factory\CampaignAlerts::get_alerts_count( $client_id );
$total_pages = max( 1, (int) ceil( $total / $per_page ) );
if ( $page > $total_pages )
{
$page = $total_pages;
$offset = ( $page - 1 ) * $per_page;
}
return \Tpl::view( 'campaign_alerts/main_view', [
'clients' => \factory\CampaignAlerts::get_clients(),
'alerts' => \factory\CampaignAlerts::get_alerts( $client_id, $per_page, $offset ),
'selected_client_id' => $client_id,
'page' => $page,
'total_pages' => $total_pages,
'total' => $total
] );
}
}