- Created XmlFiles control class for handling XML file views and regeneration. - Implemented method to retrieve clients with XML feeds in the factory class. - Added database migration to include google_merchant_account_id in clients table. - Created migrations for products_keyword_planner_terms and products_merchant_sync_log tables. - Added campaign_keywords table migration for managing campaign keyword data. - Developed main view template for displaying XML files and their statuses. - Introduced a debug script for analyzing product URLs and their statuses.
73 lines
1.5 KiB
PHP
73 lines
1.5 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' ) );
|
|
$google_merchant_account_id = trim( \S::get( 'google_merchant_account_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_merchant_account_id' => $google_merchant_account_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;
|
|
}
|
|
}
|