Add migrations for Google Ads settings and demo data
- Create migration for global settings table and add google_ads_customer_id and google_ads_start_date columns to clients table. - Add migration to include product_url column in products_data table. - Insert demo data for campaigns, products, and their history for client 'pomysloweprezenty.pl'. - Implement client management interface with modals for adding and editing clients, including Google Ads Customer ID and data retrieval start date.
This commit is contained in:
158
templates/clients/main_view.php
Normal file
158
templates/clients/main_view.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<div class="clients-page">
|
||||
<div class="clients-header">
|
||||
<h2><i class="fa-solid fa-building"></i> Klienci</h2>
|
||||
<button type="button" class="btn btn-success" onclick="openClientForm()">
|
||||
<i class="fa-solid fa-plus mr5"></i>Dodaj klienta
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="clients-table-wrap">
|
||||
<table class="table" id="clients-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 60px;">#ID</th>
|
||||
<th>Nazwa klienta</th>
|
||||
<th>Google Ads Customer ID</th>
|
||||
<th>Dane od</th>
|
||||
<th style="width: 120px; text-align: center;">Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ( $this -> clients ): ?>
|
||||
<?php foreach ( $this -> clients as $client ): ?>
|
||||
<tr data-id="<?= $client['id']; ?>">
|
||||
<td class="client-id"><?= $client['id']; ?></td>
|
||||
<td class="client-name"><?= htmlspecialchars( $client['name'] ); ?></td>
|
||||
<td>
|
||||
<?php if ( $client['google_ads_customer_id'] ): ?>
|
||||
<span class="badge-id"><?= htmlspecialchars( $client['google_ads_customer_id'] ); ?></span>
|
||||
<?php else: ?>
|
||||
<span class="text-muted">— brak —</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ( $client['google_ads_start_date'] ): ?>
|
||||
<?= $client['google_ads_start_date']; ?>
|
||||
<?php else: ?>
|
||||
<span class="text-muted">— brak —</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="actions-cell">
|
||||
<button type="button" class="btn-icon btn-icon-edit" onclick="editClient(<?= $client['id']; ?>)" title="Edytuj">
|
||||
<i class="fa-solid fa-pen"></i>
|
||||
</button>
|
||||
<button type="button" class="btn-icon btn-icon-delete" onclick="deleteClient(<?= $client['id']; ?>, '<?= htmlspecialchars( addslashes( $client['name'] ) ); ?>')" title="Usuń">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="5" class="empty-state">
|
||||
<i class="fa-solid fa-building"></i>
|
||||
<p>Brak klientów. Dodaj pierwszego klienta.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal: Dodaj / Edytuj klienta -->
|
||||
<div class="default_popup" id="client-modal">
|
||||
<div class="popup_content" style="max-width: 520px;">
|
||||
<div class="popup_header">
|
||||
<div class="title" id="client-modal-title">Dodaj klienta</div>
|
||||
<div class="close"><i class="fa-solid fa-xmark"></i></div>
|
||||
</div>
|
||||
<div class="popup_body">
|
||||
<form method="POST" id="client-form" action="/clients/save">
|
||||
<input type="hidden" name="id" id="client-id" value="" />
|
||||
<div class="settings-field">
|
||||
<label for="client-name">Nazwa klienta</label>
|
||||
<input type="text" id="client-name" name="name" class="form-control" required placeholder="np. Firma XYZ" />
|
||||
</div>
|
||||
<div class="settings-field">
|
||||
<label for="client-gads-id">Google Ads Customer ID</label>
|
||||
<input type="text" id="client-gads-id" name="google_ads_customer_id" class="form-control" placeholder="np. 123-456-7890 (opcjonalnie)" />
|
||||
</div>
|
||||
<div class="settings-field">
|
||||
<label for="client-gads-start">Pobieraj dane od</label>
|
||||
<input type="date" id="client-gads-start" name="google_ads_start_date" class="form-control" />
|
||||
<small class="text-muted">Data od której CRON zacznie pobierać dane z Google Ads API</small>
|
||||
</div>
|
||||
<div style="margin-top: 20px; display: flex; gap: 10px;">
|
||||
<button type="submit" class="btn btn-success"><i class="fa-solid fa-check mr5"></i>Zapisz</button>
|
||||
<button type="button" class="btn btn-secondary" onclick="closeClientForm()">Anuluj</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function openClientForm()
|
||||
{
|
||||
$( '#client-modal-title' ).text( 'Dodaj klienta' );
|
||||
$( '#client-id' ).val( '' );
|
||||
$( '#client-name' ).val( '' );
|
||||
$( '#client-gads-id' ).val( '' );
|
||||
$( '#client-gads-start' ).val( '' );
|
||||
$( '#client-modal' ).fadeIn();
|
||||
}
|
||||
|
||||
function closeClientForm()
|
||||
{
|
||||
$( '#client-modal' ).fadeOut();
|
||||
}
|
||||
|
||||
function editClient( id )
|
||||
{
|
||||
$.getJSON( '/clients/get/id=' + id, function( data ) {
|
||||
$( '#client-modal-title' ).text( 'Edytuj klienta' );
|
||||
$( '#client-id' ).val( data.id );
|
||||
$( '#client-name' ).val( data.name );
|
||||
$( '#client-gads-id' ).val( data.google_ads_customer_id || '' );
|
||||
$( '#client-gads-start' ).val( data.google_ads_start_date || '' );
|
||||
$( '#client-modal' ).fadeIn();
|
||||
} );
|
||||
}
|
||||
|
||||
function deleteClient( id, name )
|
||||
{
|
||||
$.confirm( {
|
||||
title: 'Potwierdzenie',
|
||||
content: 'Czy na pewno chcesz usunąć klienta <strong>' + name + '</strong>?',
|
||||
type: 'red',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Usuń',
|
||||
btnClass: 'btn-red',
|
||||
action: function() {
|
||||
$.post( '/clients/delete', { id: id }, function( response ) {
|
||||
var data = JSON.parse( response );
|
||||
if ( data.success ) {
|
||||
$( 'tr[data-id="' + id + '"]' ).fadeOut( 300, function() { $( this ).remove(); } );
|
||||
}
|
||||
} );
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: 'Anuluj'
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
// Zamknij modal klawiszem Escape
|
||||
$( document ).on( 'keydown', function( e ) {
|
||||
if ( e.key === 'Escape' ) closeClientForm();
|
||||
} );
|
||||
|
||||
// Zamknij modal kliknięciem w tło
|
||||
$( '#client-modal' ).on( 'click', function( e ) {
|
||||
if ( e.target === this ) closeClientForm();
|
||||
} );
|
||||
</script>
|
||||
Reference in New Issue
Block a user