Files
AtomicOld/simpla/FeatureAdmin.php

64 lines
2.1 KiB
PHP
Raw Normal View History

2026-02-14 19:34:54 +03:00
<?PHP
require_once('api/Simpla.php');
class FeatureAdmin extends Simpla
{
function fetch()
{
if($this->request->method('post'))
{
$feature->id = $this->request->post('id', 'integer');
$feature->name = $this->request->post('name');
$feature->in_filter = intval($this->request->post('in_filter'));
$feature_categories = $this->request->post('feature_categories');
$feature->on_prod = $this->request->post('on_prod', 'boolean');
$feature->on_main = $this->request->post('on_main', 'boolean');
$feature->multiselect = $this->request->post('multiselect', 'boolean');
$feature->in_variant = $this->request->post('in_variant', 'boolean');
$feature->in_compare = $this->request->post('in_compare', 'boolean');
$feature->isrange = $this->request->post('isrange', 'boolean');
$feature->slider = $this->request->post('slider', 'boolean');
$feature->unit = $this->request->post('unit');
$feature->istext = $this->request->post('istext', 'boolean');
$feature->nameselect = $this->request->post('nameselect');
if(empty($feature->id))
{
$feature->id = $this->features->add_feature($feature);
$feature = $this->features->get_feature($feature->id);
$this->design->assign('message_success', 'added');
}
else
{
$this->features->update_feature($feature->id, $feature);
$feature = $this->features->get_feature($feature->id);
$this->design->assign('message_success', 'updated');
}
$this->features->update_feature_categories($feature->id, $feature_categories);
}
else
{
$feature->id = $this->request->get('id', 'integer');
$feature = $this->features->get_feature($feature->id);
}
$feature_categories = array();
if($feature)
{
$feature_categories = $this->features->get_feature_categories($feature->id);
}
$categories = $this->categories->get_categories_tree();
$this->design->assign('categories', $categories);
$this->design->assign('feature', $feature);
$this->design->assign('feature_categories', $feature_categories);
return $this->body = $this->design->fetch('feature.tpl');
}
}