Files
adsPRO/templates/products/main_view.php
2024-12-10 23:24:15 +01:00

118 lines
3.7 KiB
PHP

<div class="admin-form theme-primary">
<div class="panel heading-border panel-primary">
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<label class="field select">
<select id="client_id" name="client_id">
<option value="">--- wybierz klienta ---</option>
<? foreach ( $this -> clients as $client ):?>
<option value="<?= $client['id'];?>"><?= $client['name'];?></option>
<? endforeach;?>
</select>
<i class="arrow double"></i>
</label>
</div>
</div>
</div>
</div>
</div>
<div class="admin-form theme-primary">
<div class="panel heading-border panel-primary">
<div class="panel-body">
<table class="table table-sm" id="products">
<thead>
<tr>
<th scope="col">Id</th>
<th scope="col">Tytuł</th>
<th scope="col">Wyśw.</th>
<th scope="col">Wyśw. (30 dni)</th>
<th scope="col">Klik.</th>
<th scope="col">Klik. (30 dni)</th>
<th scope="col">CTR</th>
<th scope="col">Koszt</th>
<th scope="col">CPC</th>
<th scope="col">Konw.</th>
<th scope="col">Wartość konw.</th>
<th scope="col">ROAS</th>
<th scope="col">CL3</th>
<th scope="col">CL4</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
<script type="text/javascript">
$( function()
{
$( 'body' ).on( 'change', '#client_id', function()
{
var client_id = $( this ).val();
table = $( '#products' ).DataTable();
table.destroy();
new DataTable( '#products', {
ajax: {
type: 'POST',
url: '/products/get_products/client_id=' + client_id,
},
processing: true,
serverSide: true,
columns: [
{ width: '6.25rem', orderable: false },
{ width: 'auto', name: 'title', render: function( data, type, row ) {
return `
<div class="table-product-title">
<a href="/products/product_history/client_id=${client_id}&product_id=${row[0]}" target="_blank">
${data}
</a>
<span class="edit-product-title" offer-id="${row[0]}">
<i class="bi bi-pencil-square"></i>
</span>
</div>
`;
}},
{ width: 'auto', name: 'impressions' },
{ width: 'auto', name: 'impressions_30' },
{ width: 'auto', name: 'clicks' },
{ width: 'auto', name: 'clicks_30' },
{ width: 'auto', name: 'ctr' },
{ width: 'auto', name: 'cost', className: "dt-type-numeric" },
{ width: 'auto', name: 'cpc', className: "dt-type-numeric" },
{ width: 'auto', name: 'conversions' },
{ width: 'auto', name: 'conversions_value', className: "dt-type-numeric" },
{ width: 'auto', name: 'roas' },
{ width: 'auto', name: 'cl3', orderable: false },
{ width: '200px', orderable: false }],
order: [ [0, false], [ 4, 'desc'] ]
});
});
$( 'body' ).on( 'change', '.custom_label_4', function()
{
var input = $( this );
var product_id = $( this ).attr( 'product_id' );
var custom_label_4 = $( this ).val();
input.addClass('saving');
$.ajax({
url: '/products/save_custom_label_4/',
type: 'POST',
data: {
product_id: product_id,
custom_label_4: custom_label_4
},
success: function( response ) {
},
complete: function() {
}
});
});
});
</script>