- Added 'data' column to 'pp_shop_producer_lang' table for additional metadata storage. - Added 'security_information' column to 'pp_shop_products_langs' table to enhance product security details.
89 lines
2.3 KiB
PHP
89 lines
2.3 KiB
PHP
<?
|
|
namespace admin\factory;
|
|
class ShopProducer
|
|
{
|
|
static public function all()
|
|
{
|
|
global $mdb;
|
|
return $mdb -> select( 'pp_shop_producer', '*', [ 'ORDER' => [ 'name' => 'ASC' ] ] );
|
|
}
|
|
|
|
static public function delete( int $producer_id )
|
|
{
|
|
global $mdb;
|
|
return $mdb -> delete( 'pp_shop_producer', [ 'id' => $producer_id ] );
|
|
}
|
|
|
|
static public function save( $producer_id, $name, int $status, $img, $description, $data, $meta_title )
|
|
{
|
|
global $mdb;
|
|
|
|
if ( !$producer_id )
|
|
{
|
|
$mdb -> insert( 'pp_shop_producer', [
|
|
'name' => $name,
|
|
'status' => $status,
|
|
'img' => $img
|
|
] );
|
|
|
|
$id = $mdb -> id();
|
|
|
|
$langs = \admin\factory\Languages::languages_list( true );
|
|
foreach ( $langs as $lg )
|
|
{
|
|
$mdb -> insert( 'pp_shop_producer_lang', [
|
|
'producer_id' => $id,
|
|
'lang_id' => $lg['id'],
|
|
'description' => $description[ $lg['id'] ] ?? null,
|
|
'data' => $data[ $lg['id'] ] ?? null,
|
|
'meta_title' => $meta_title[ $lg['id'] ] ?? null
|
|
] );
|
|
}
|
|
|
|
\S::htacces();
|
|
\S::delete_dir( '../temp/' );
|
|
|
|
return $id;
|
|
}
|
|
else
|
|
{
|
|
$mdb -> update( 'pp_shop_producer', [
|
|
'name' => $name,
|
|
'status' => $status,
|
|
'img' => $img
|
|
], [
|
|
'id' => (int) $producer_id
|
|
] );
|
|
|
|
$langs = \admin\factory\Languages::languages_list( true );
|
|
foreach ( $langs as $lg )
|
|
{
|
|
if ( $translation_id = $mdb -> get( 'pp_shop_producer_lang', 'id', [ 'AND' => [ 'producer_id' => $producer_id, 'lang_id' => $lg['id'] ] ] ) )
|
|
{
|
|
$mdb -> update( 'pp_shop_producer_lang', [
|
|
'description' => $description[ $lg['id'] ] ?? null,
|
|
'meta_title' => $meta_title[ $lg['id'] ] ?? null,
|
|
'data' => $data[ $lg['id'] ] ?? null
|
|
], [
|
|
'id' => $translation_id
|
|
] );
|
|
}
|
|
else
|
|
{
|
|
$mdb -> insert( 'pp_shop_producer_lang', [
|
|
'producer_id' => $producer_id,
|
|
'lang_id' => $lg['id'],
|
|
'description' => $description[ $lg['id'] ] ?? null,
|
|
'data' => $data[ $lg['id'] ] ?? null,
|
|
'meta_title' => $meta_title[ $lg['id'] ] ?? null
|
|
] );
|
|
}
|
|
}
|
|
|
|
\S::htacces();
|
|
\S::delete_dir( '../temp/' );
|
|
return $producer_id;
|
|
}
|
|
return false;
|
|
}
|
|
} |