38 lines
1.2 KiB
PHP
38 lines
1.2 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 = json_decode( \S::get( 'values' ), true );
|
|
|
|
if ( $producer_id = \admin\factory\ShopProducer::save( $values['id'], $values['name'], $values['status'] == 'on' ? 1 : 0, $values['img'], $values['description'], $values['data'], $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' => ( new \Domain\Languages\LanguagesRepository( $GLOBALS['mdb'] ) )->languagesList()
|
|
] );
|
|
}
|
|
|
|
static public function list()
|
|
{
|
|
return \Tpl::view( 'shop-producer/list' );
|
|
}
|
|
}
|