feat: update font to Roboto across templates and add campaign/ad group filters in product views

- Changed font from Open Sans to Roboto in layout files.
- Added campaign and ad group filters in products main view.
- Enhanced product history to include campaign and ad group IDs.
- Updated migrations to support new campaign and ad group dimensions in product statistics.
- Introduced new migration files for managing campaign types and dropping obsolete columns.
This commit is contained in:
2026-02-18 01:21:22 +01:00
parent 1cff9ba0eb
commit 4635cefcbb
23 changed files with 2444 additions and 410 deletions

View File

@@ -14,6 +14,18 @@
<?php endforeach; ?>
</select>
</div>
<div class="filter-group filter-group-campaign">
<label for="products_campaign_id"><i class="fa-solid fa-bullhorn"></i> Kampania</label>
<select id="products_campaign_id" name="products_campaign_id" class="form-control">
<option value="">- wszystkie kampanie -</option>
</select>
</div>
<div class="filter-group filter-group-ad-group">
<label for="products_ad_group_id"><i class="fa-solid fa-layer-group"></i> Grupa reklam</label>
<select id="products_ad_group_id" name="products_ad_group_id" class="form-control">
<option value="">- wszystkie grupy -</option>
</select>
</div>
<div class="filter-group filter-group-roas">
<label for="bestseller_min_roas"><i class="fa-solid fa-star"></i> Bestseller min ROAS</label>
<input type="text" id="bestseller_min_roas" name="bestseller_min_roas" class="form-control" placeholder="np. 500" value="" />
@@ -35,6 +47,8 @@
<th><input type="checkbox" id="select-all-products" title="Zaznacz wszystkie" /></th>
<th>Id</th>
<th>Id oferty</th>
<th>Kampania</th>
<th>Grupa reklam</th>
<th>Nazwa produktu</th>
<th>WyÅw.</th>
<th>WyÅw. (30d)</th>
@@ -111,82 +125,188 @@ function loadGoogleCategories( callback )
$( function()
{
// Załaduj produkty po wyborze klienta
$( 'body' ).on( 'change', '#client_id', function()
var products_table = new DataTable( '#products', {
ajax: {
type: 'POST',
url: '/products/get_products/',
data: function( d ) {
d.client_id = $( '#client_id' ).val() || '';
d.campaign_id = $( '#products_campaign_id' ).val() || '';
d.ad_group_id = $( '#products_ad_group_id' ).val() || '';
}
},
processing: true,
serverSide: true,
autoWidth: false,
searching: false,
lengthChange: false,
pageLength: 25,
columns: [
{ width: '30px', orderable: false, className: 'select-checkbox', render: function( data, type, row ) {
return '<input type="checkbox" class="product-checkbox" value="' + row[1] + '" />';
}
},
{ width: '50px', orderable: false },
{ width: '80px', name: 'offer_id' },
{ width: '200px', name: 'campaign_name' },
{ width: '200px', name: 'ad_group_name' },
{ name: 'name' },
{ width: '50px', name: 'impressions' },
{ width: '80px', name: 'impressions_30' },
{ width: '50px', name: 'clicks' },
{ width: '80px', name: 'clicks_30' },
{ width: '50px', name: 'ctr' },
{ width: '80px', name: 'cost', className: "dt-type-numeric" },
{ width: '50px', name: 'cpc', className: "dt-type-numeric" },
{ width: '50px', name: 'conversions' },
{ width: '90px', name: 'conversions_value', className: "dt-type-numeric" },
{ width: '60px', name: 'roas' },
{ width: '70px', name: 'min_roas' },
{ width: '50px', name: 'cl3', orderable: false },
{ width: '120px', orderable: false },
{ width: '50px', orderable: false, className: 'dt-center' }
],
order: [ [ 8, 'desc' ] ],
language: {
processing: '£adowanie...',
emptyTable: 'Brak produktów do wyœwietlenia',
info: 'Produkty _START_ - _END_ z _TOTAL_',
infoEmpty: '',
paginate: {
first: 'Pierwsza',
last: 'Ostatnia',
next: 'Dalej',
previous: 'Wstecz'
}
}
});
function reload_products_table()
{
var client_id = $( this ).val();
localStorage.setItem( 'products_client_id', client_id );
products_table.ajax.reload( null, false );
}
table = $( '#products' ).DataTable();
table.destroy();
function load_client_bestseller_min_roas( client_id )
{
if ( !client_id )
{
$( '#bestseller_min_roas' ).val( '' );
return;
}
// Pobierz min ROAS bestsellera
$.ajax({
url: '/products/get_client_bestseller_min_roas/',
type: 'POST',
data: { client_id: client_id },
success: function( response ) {
data = JSON.parse( response );
var data = JSON.parse( response );
$( '#bestseller_min_roas' ).val( data.status == 'ok' ? data.min_roas : '' );
}
});
}
new DataTable( '#products', {
ajax: {
type: 'POST',
url: '/products/get_products/client_id=' + client_id,
},
processing: true,
serverSide: true,
autoWidth: false,
searching: false,
lengthChange: false,
pageLength: 25,
columns: [
{ width: '30px', orderable: false, className: 'select-checkbox', render: function( data, type, row ) {
return '<input type="checkbox" class="product-checkbox" value="' + row[1] + '" />';
}
},
{ width: '50px', orderable: false },
{ width: '80px', name: 'offer_id' },
{ name: 'name' },
{ width: '50px', name: 'impressions' },
{ width: '80px', name: 'impressions_30' },
{ width: '50px', name: 'clicks' },
{ width: '80px', name: 'clicks_30' },
{ width: '50px', name: 'ctr' },
{ width: '80px', name: 'cost', className: "dt-type-numeric" },
{ width: '50px', name: 'cpc', className: "dt-type-numeric" },
{ width: '50px', name: 'conversions' },
{ width: '90px', name: 'conversions_value', className: "dt-type-numeric" },
{ width: '60px', name: 'roas' },
{ width: '70px', name: 'min_roas' },
{ width: '50px', name: 'cl3', orderable: false },
{ width: '120px', orderable: false },
{ width: '50px', orderable: false, className: 'dt-center' }
],
order: [ [ 6, 'desc' ] ],
language: {
processing: 'Ładowanie...',
emptyTable: 'Brak produktów do wyświetlenia',
info: 'Produkty _START_ - _END_ z _TOTAL_',
infoEmpty: '',
paginate: {
first: 'Pierwsza',
last: 'Ostatnia',
next: 'Dalej',
previous: 'Wstecz'
}
function load_products_campaigns( client_id, selected_campaign_id )
{
var $campaign = $( '#products_campaign_id' );
$campaign.empty().append( '<option value="">- wszystkie kampanie -</option>' );
if ( !client_id )
{
return $.Deferred().resolve().promise();
}
return $.ajax({
url: '/products/get_campaigns_list/client_id=' + client_id,
type: 'GET',
dataType: 'json'
}).done( function( res ) {
( res.campaigns || [] ).forEach( function( row ) {
$campaign.append( '<option value="' + row.id + '">' + row.campaign_name + '</option>' );
} );
if ( selected_campaign_id && $campaign.find( 'option[value="' + selected_campaign_id + '"]' ).length )
{
$campaign.val( selected_campaign_id );
}
});
} );
}
function load_products_ad_groups( campaign_id, selected_ad_group_id )
{
var $ad_group = $( '#products_ad_group_id' );
$ad_group.empty().append( '<option value="">- wszystkie grupy -</option>' );
if ( !campaign_id )
{
return $.Deferred().resolve().promise();
}
return $.ajax({
url: '/products/get_campaign_ad_groups/campaign_id=' + campaign_id,
type: 'GET',
dataType: 'json'
}).done( function( res ) {
( res.ad_groups || [] ).forEach( function( row ) {
$ad_group.append( '<option value="' + row.id + '">' + row.ad_group_name + '</option>' );
} );
if ( selected_ad_group_id && $ad_group.find( 'option[value="' + selected_ad_group_id + '"]' ).length )
{
$ad_group.val( selected_ad_group_id );
}
} );
}
$( 'body' ).on( 'change', '#client_id', function()
{
var client_id = $( this ).val() || '';
localStorage.setItem( 'products_client_id', client_id );
localStorage.removeItem( 'products_campaign_id' );
localStorage.removeItem( 'products_ad_group_id' );
load_client_bestseller_min_roas( client_id );
load_products_campaigns( client_id, '' ).done( function() {
load_products_ad_groups( '', '' ).done( function() {
reload_products_table();
} );
} );
});
// Przywróć ostatnio wybranego klienta
var savedClient = localStorage.getItem( 'products_client_id' );
if ( savedClient && $( '#client_id option[value="' + savedClient + '"]' ).length ) {
$( '#client_id' ).val( savedClient ).trigger( 'change' );
$( 'body' ).on( 'change', '#products_campaign_id', function()
{
var campaign_id = $( this ).val() || '';
localStorage.setItem( 'products_campaign_id', campaign_id );
localStorage.removeItem( 'products_ad_group_id' );
load_products_ad_groups( campaign_id, '' ).done( function() {
reload_products_table();
} );
});
$( 'body' ).on( 'change', '#products_ad_group_id', function()
{
var ad_group_id = $( this ).val() || '';
localStorage.setItem( 'products_ad_group_id', ad_group_id );
reload_products_table();
});
var savedClient = localStorage.getItem( 'products_client_id' ) || '';
var savedCampaign = localStorage.getItem( 'products_campaign_id' ) || '';
var savedAdGroup = localStorage.getItem( 'products_ad_group_id' ) || '';
if ( savedClient && $( '#client_id option[value="' + savedClient + '"]' ).length )
{
$( '#client_id' ).val( savedClient );
}
load_client_bestseller_min_roas( $( '#client_id' ).val() || '' );
load_products_campaigns( $( '#client_id' ).val() || '', savedCampaign ).done( function() {
var selected_campaign_id = $( '#products_campaign_id' ).val() || '';
load_products_ad_groups( selected_campaign_id, savedAdGroup ).done( function() {
reload_products_table();
} );
});
// Usuwanie produktu
$( 'body' ).on( 'click', '.delete-product', function( e )
{
@@ -575,3 +695,7 @@ $( function()
});
});
</script>