Files
adsPRO/autoload/controls/class.Clients.php
Jacek Pyziak afe9d6216d 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.
2026-02-15 17:46:32 +01:00

71 lines
1.3 KiB
PHP

<?php
namespace controls;
class Clients
{
static public function main_view()
{
return \view\Clients::main_view(
\factory\Clients::get_all()
);
}
static public function save()
{
$id = \S::get( 'id' );
$name = trim( \S::get( 'name' ) );
$google_ads_customer_id = trim( \S::get( 'google_ads_customer_id' ) );
if ( !$name )
{
\S::alert( 'Nazwa klienta jest wymagana.' );
header( 'Location: /clients' );
exit;
}
$google_ads_start_date = trim( \S::get( 'google_ads_start_date' ) );
$data = [
'name' => $name,
'google_ads_customer_id' => $google_ads_customer_id ?: null,
'google_ads_start_date' => $google_ads_start_date ?: null,
];
if ( $id )
{
\factory\Clients::update( $id, $data );
\S::alert( 'Klient został zaktualizowany.' );
}
else
{
\factory\Clients::create( $data );
\S::alert( 'Klient został dodany.' );
}
header( 'Location: /clients' );
exit;
}
static public function delete()
{
$id = \S::get( 'id' );
if ( $id )
{
\factory\Clients::delete( $id );
}
echo json_encode( [ 'success' => true ] );
exit;
}
static public function get()
{
$id = \S::get( 'id' );
$client = \factory\Clients::get( $id );
echo json_encode( $client ?: [] );
exit;
}
}