feat: Dodaj moduł grup i fraz, oznaczanie wykluczonych na czerwono, CLAUDE.md
- Nowy moduł CampaignTerms z widokiem grup reklam, fraz wyszukiwanych i fraz wykluczających - Frazy wyszukiwane dodane do wykluczonych oznaczane czerwonym kolorem w tabeli - Instalator migracji (install.php) z obsługą schema_migrations - Migracja 003 dla tabel campaign_ad_groups, campaign_search_terms, campaign_negative_keywords - CLAUDE.md z dokumentacją architektury projektu - Aktualizacja layoutu, stylów i konfiguracji Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,12 +3,11 @@
|
||||
<h2><i class="fa-solid fa-chart-line"></i> Kampanie</h2>
|
||||
</div>
|
||||
|
||||
<!-- Filtry -->
|
||||
<div class="campaigns-filters">
|
||||
<div class="filter-group">
|
||||
<label for="client_id"><i class="fa-solid fa-building"></i> Klient</label>
|
||||
<select id="client_id" name="client_id" class="form-control">
|
||||
<option value="">— wybierz klienta —</option>
|
||||
<option value="">- wybierz klienta -</option>
|
||||
<?php foreach ( $this -> clients as $client ): ?>
|
||||
<option value="<?= $client['id']; ?>"><?= htmlspecialchars( $client['name'] ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
@@ -18,21 +17,19 @@
|
||||
<label for="campaign_id"><i class="fa-solid fa-bullhorn"></i> Kampania</label>
|
||||
<div class="filter-with-action">
|
||||
<select id="campaign_id" name="campaign_id" class="form-control">
|
||||
<option value="">— wybierz kampanię —</option>
|
||||
<option value="">- wybierz kampanie -</option>
|
||||
</select>
|
||||
<button type="button" id="delete_campaign" class="btn-icon btn-icon-delete" title="Usuń kampanię">
|
||||
<button type="button" id="delete_campaign" class="btn-icon btn-icon-delete" title="Usun kampanie">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Wykres -->
|
||||
<div class="campaigns-chart-wrap">
|
||||
<div id="container"></div>
|
||||
</div>
|
||||
|
||||
<!-- Tabela historii -->
|
||||
<div class="campaigns-table-wrap">
|
||||
<table class="table" id="products">
|
||||
<thead>
|
||||
@@ -40,22 +37,47 @@
|
||||
<th>Data</th>
|
||||
<th>ROAS (30 dni)</th>
|
||||
<th>ROAS (all time)</th>
|
||||
<th>Wartość konwersji (30 dni)</th>
|
||||
<th>Wartosc konwersji (30 dni)</th>
|
||||
<th>Wydatki (30 dni)</th>
|
||||
<th>Komentarz</th>
|
||||
<th>Strategia ustalania stawek</th>
|
||||
<th>Budżet</th>
|
||||
<th>Budzet</th>
|
||||
<th style="width: 60px; text-align: center;">Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var client_id = '';
|
||||
var STORAGE_CLIENT_KEY = 'campaigns.last_client_id';
|
||||
var STORAGE_CAMPAIGN_KEY = 'campaigns.last_campaign_id';
|
||||
var restore_campaign_after_client_load = '';
|
||||
|
||||
function storage_set( key, value )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( value === null || value === undefined || value === '' )
|
||||
localStorage.removeItem( key );
|
||||
else
|
||||
localStorage.setItem( key, String( value ) );
|
||||
}
|
||||
catch ( e ) {}
|
||||
}
|
||||
|
||||
function storage_get( key )
|
||||
{
|
||||
try
|
||||
{
|
||||
return localStorage.getItem( key ) || '';
|
||||
}
|
||||
catch ( e )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function reloadChart()
|
||||
{
|
||||
@@ -68,8 +90,8 @@ function reloadChart()
|
||||
data: { campaign_id: campaign_id },
|
||||
success: function( response )
|
||||
{
|
||||
const parsedData = JSON.parse( response );
|
||||
let plotLines = [];
|
||||
var parsedData = JSON.parse( response );
|
||||
var plotLines = [];
|
||||
|
||||
parsedData.comments.forEach( function( comment ) {
|
||||
plotLines.push({
|
||||
@@ -140,11 +162,21 @@ function reloadChart()
|
||||
|
||||
$( function()
|
||||
{
|
||||
// Załaduj kampanie po wyborze klienta
|
||||
$( 'body' ).on( 'change', '#client_id', function()
|
||||
{
|
||||
client_id = $( this ).val();
|
||||
var client_id = $( this ).val();
|
||||
storage_set( STORAGE_CLIENT_KEY, client_id );
|
||||
var campaigns_select = $( '#campaign_id' );
|
||||
var campaign_to_restore = restore_campaign_after_client_load;
|
||||
|
||||
if ( !campaign_to_restore )
|
||||
storage_set( STORAGE_CAMPAIGN_KEY, '' );
|
||||
|
||||
campaigns_select.empty();
|
||||
campaigns_select.append( '<option value="">- wybierz kampanie -</option>' );
|
||||
|
||||
if ( !client_id )
|
||||
return;
|
||||
|
||||
$.ajax({
|
||||
url: '/campaigns/get_campaigns_list/client_id=' + client_id,
|
||||
@@ -152,29 +184,33 @@ $( function()
|
||||
success: function( response )
|
||||
{
|
||||
var data = JSON.parse( response );
|
||||
campaigns_select.empty();
|
||||
campaigns_select.append( '<option value="">— wybierz kampanię —</option>' );
|
||||
|
||||
var campaigns = Object.entries( data.campaigns );
|
||||
var campaigns = Object.entries( data.campaigns || {} );
|
||||
|
||||
campaigns.sort( function( a, b ) {
|
||||
if ( a[1] === "--- konto ---" ) return -1;
|
||||
if ( b[1] === "--- konto ---" ) return 1;
|
||||
return a[1] > b[1] ? 1 : ( a[1] < b[1] ? -1 : 0 );
|
||||
var nameA = String( ( a[1] && a[1].campaign_name ) ? a[1].campaign_name : '' ).toLowerCase();
|
||||
var nameB = String( ( b[1] && b[1].campaign_name ) ? b[1].campaign_name : '' ).toLowerCase();
|
||||
if ( nameA === '--- konto ---' ) return -1;
|
||||
if ( nameB === '--- konto ---' ) return 1;
|
||||
if ( nameA > nameB ) return 1;
|
||||
if ( nameA < nameB ) return -1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
campaigns.forEach( function( [key, value] ) {
|
||||
campaigns.forEach( function( pair ) {
|
||||
var value = pair[1];
|
||||
campaigns_select.append( '<option value="' + value.id + '">' + value.campaign_name + '</option>' );
|
||||
});
|
||||
|
||||
<?php if ( $campaign_id ): ?>
|
||||
campaigns_select.val( '<?= $campaign_id; ?>' ).trigger( 'change' );
|
||||
<?php endif; ?>
|
||||
if ( campaign_to_restore && campaigns_select.find( 'option[value="' + campaign_to_restore + '"]' ).length )
|
||||
{
|
||||
campaigns_select.val( campaign_to_restore ).trigger( 'change' );
|
||||
}
|
||||
|
||||
restore_campaign_after_client_load = '';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Usuwanie kampanii
|
||||
$( 'body' ).on( 'click', '#delete_campaign', function()
|
||||
{
|
||||
var campaign_id = $( '#campaign_id' ).val();
|
||||
@@ -184,19 +220,19 @@ $( function()
|
||||
{
|
||||
$.alert({
|
||||
title: 'Uwaga',
|
||||
content: 'Najpierw wybierz kampanię do usunięcia.',
|
||||
content: 'Najpierw wybierz kampanie do usuniecia.',
|
||||
type: 'orange'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$.confirm({
|
||||
title: 'Potwierdzenie usunięcia',
|
||||
content: 'Czy na pewno chcesz usunąć kampanię <strong>' + campaign_name + '</strong>?<br><br>Ta operacja jest nieodwracalna i usunie również całą historię kampanii.',
|
||||
title: 'Potwierdzenie usuniecia',
|
||||
content: 'Czy na pewno chcesz usunac kampanie <strong>' + campaign_name + '</strong>?<br><br>Ta operacja jest nieodwracalna i usunie rowniez cala historie kampanii.',
|
||||
type: 'red',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Usuń',
|
||||
text: 'Usun',
|
||||
btnClass: 'btn-red',
|
||||
keys: ['enter'],
|
||||
action: function()
|
||||
@@ -209,9 +245,12 @@ $( function()
|
||||
var data = JSON.parse( response );
|
||||
if ( data.success )
|
||||
{
|
||||
if ( storage_get( STORAGE_CAMPAIGN_KEY ) === String( campaign_id ) )
|
||||
storage_set( STORAGE_CAMPAIGN_KEY, '' );
|
||||
|
||||
$.alert({
|
||||
title: 'Sukces',
|
||||
content: 'Kampania została usunięta.',
|
||||
content: 'Kampania zostala usunieta.',
|
||||
type: 'green',
|
||||
autoClose: 'ok|2000'
|
||||
});
|
||||
@@ -220,8 +259,8 @@ $( function()
|
||||
else
|
||||
{
|
||||
$.alert({
|
||||
title: 'Błąd',
|
||||
content: data.message || 'Nie udało się usunąć kampanii.',
|
||||
title: 'Blad',
|
||||
content: data.message || 'Nie udalo sie usunac kampanii.',
|
||||
type: 'red'
|
||||
});
|
||||
}
|
||||
@@ -234,7 +273,6 @@ $( function()
|
||||
});
|
||||
});
|
||||
|
||||
// Usuwanie wpisu historii
|
||||
$( 'body' ).on( 'click', '.delete-history-entry', function()
|
||||
{
|
||||
var btn = $( this );
|
||||
@@ -242,12 +280,12 @@ $( function()
|
||||
var date = btn.data( 'date' );
|
||||
|
||||
$.confirm({
|
||||
title: 'Potwierdzenie usunięcia',
|
||||
content: 'Czy na pewno chcesz usunąć wpis z dnia <strong>' + date + '</strong>?',
|
||||
title: 'Potwierdzenie usuniecia',
|
||||
content: 'Czy na pewno chcesz usunac wpis z dnia <strong>' + date + '</strong>?',
|
||||
type: 'red',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Usuń',
|
||||
text: 'Usun',
|
||||
btnClass: 'btn-red',
|
||||
keys: ['enter'],
|
||||
action: function()
|
||||
@@ -262,18 +300,19 @@ $( function()
|
||||
{
|
||||
$.alert({
|
||||
title: 'Sukces',
|
||||
content: 'Wpis został usunięty.',
|
||||
content: 'Wpis zostal usuniety.',
|
||||
type: 'green',
|
||||
autoClose: 'ok|2000'
|
||||
});
|
||||
$( '#products' ).DataTable().ajax.reload( null, false );
|
||||
if ( $.fn.DataTable.isDataTable( '#products' ) )
|
||||
$( '#products' ).DataTable().ajax.reload( null, false );
|
||||
reloadChart();
|
||||
}
|
||||
else
|
||||
{
|
||||
$.alert({
|
||||
title: 'Błąd',
|
||||
content: data.message || 'Nie udało się usunąć wpisu.',
|
||||
title: 'Blad',
|
||||
content: data.message || 'Nie udalo sie usunac wpisu.',
|
||||
type: 'red'
|
||||
});
|
||||
}
|
||||
@@ -286,13 +325,19 @@ $( function()
|
||||
});
|
||||
});
|
||||
|
||||
// Załaduj dane po wyborze kampanii
|
||||
$( 'body' ).on( 'change', '#campaign_id', function()
|
||||
{
|
||||
var campaign_id = $( this ).val();
|
||||
storage_set( STORAGE_CAMPAIGN_KEY, campaign_id );
|
||||
|
||||
table = $( '#products' ).DataTable();
|
||||
table.destroy();
|
||||
if ( $.fn.DataTable.isDataTable( '#products' ) )
|
||||
{
|
||||
$( '#products' ).DataTable().destroy();
|
||||
$( '#products tbody' ).empty();
|
||||
}
|
||||
|
||||
if ( !campaign_id )
|
||||
return;
|
||||
|
||||
new DataTable( '#products', {
|
||||
ajax: {
|
||||
@@ -316,11 +361,11 @@ $( function()
|
||||
{ width: '60px', name: 'actions', orderable: false, className: "dt-center" }
|
||||
],
|
||||
language: {
|
||||
processing: 'Ładowanie...',
|
||||
emptyTable: 'Brak danych do wyświetlenia',
|
||||
processing: 'Ladowanie...',
|
||||
emptyTable: 'Brak danych do wyswietlenia',
|
||||
info: 'Wpisy _START_ - _END_ z _TOTAL_',
|
||||
infoEmpty: '',
|
||||
lengthMenu: 'Pokaż _MENU_ wpisów',
|
||||
lengthMenu: 'Pokaz _MENU_ wpisow',
|
||||
paginate: {
|
||||
first: 'Pierwsza',
|
||||
last: 'Ostatnia',
|
||||
@@ -332,5 +377,14 @@ $( function()
|
||||
|
||||
reloadChart();
|
||||
});
|
||||
|
||||
var saved_client_id = storage_get( STORAGE_CLIENT_KEY );
|
||||
var saved_campaign_id = storage_get( STORAGE_CAMPAIGN_KEY );
|
||||
|
||||
if ( saved_client_id && $( '#client_id option[value="' + saved_client_id + '"]' ).length )
|
||||
{
|
||||
restore_campaign_after_client_load = saved_campaign_id;
|
||||
$( '#client_id' ).val( saved_client_id ).trigger( 'change' );
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user