47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?
|
|
namespace admin\controls;
|
|
class ShopProducer
|
|
{
|
|
static public function delete()
|
|
{
|
|
if ( \admin\factory\ShopProducer::delete( \S::get( 'id' ) ) )
|
|
\S::alert( 'Producent został usunięty' );
|
|
header( 'Location: /admin/shop_producer/list/' );
|
|
exit;
|
|
}
|
|
|
|
static public function save()
|
|
{
|
|
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania producenta wystąpił błąd. Proszę spróbować ponownie.' ];
|
|
$values_tmp = json_decode( \S::get( 'values' ), true );
|
|
|
|
$values = [];
|
|
|
|
foreach ( $values_tmp as $item )
|
|
{
|
|
$name = $item['name'];
|
|
$value = $item['value'];
|
|
$keys = \S::parse_name( $name );
|
|
\S::set_array_value( $values, $keys, $value );
|
|
}
|
|
|
|
if ( $producer_id = \admin\factory\ShopProducer::save( $values['id'], $values['name'], $values['status'] == 'on' ? 1 : 0, $values['img'], $values['description'], $values['meta_title'] ) )
|
|
$response = [ 'status' => 'ok', 'msg' => 'Producent został zapisany.', 'id' => $producer_id ];
|
|
|
|
echo json_encode( $response );
|
|
exit;
|
|
}
|
|
|
|
static public function edit()
|
|
{
|
|
return \Tpl::view( 'shop-producer/edit', [
|
|
'producer' => \S::get( 'id' ) ? new \shop\Producer( \S::get( 'id' ) ) : null,
|
|
'languages' => \admin\factory\Languages::languages_list()
|
|
] );
|
|
}
|
|
|
|
static public function list()
|
|
{
|
|
return \Tpl::view( 'shop-producer/list' );
|
|
}
|
|
} |