yf_manage_shop_region admin module

Fileplugins/shop/admin_modules/manage_shop/yf_manage_shop_region.class.php
Useadmin URL ?object=manage_shop_region

Public properties

A site sets them in its config with $PROJECT_CONF['manage_shop_region']['NAME'] = ...;

PropertyDefaultDescription
$_uri null

Public methods 8

region

public function region()
    public function region()
    {
        $session_key = ($_GET['object'] ?? null) . '__' . ($_GET['action'] ?? null);
        $filter = [
            'filter' => ($_SESSION[$session_key] ?? null),
            'filter_params' => [
                'id' => 'in',
                'value' => 'like',
            ],
            // // 'hide_empty'    => 1,
        ];

        $table = table('SELECT * FROM ' . db('shop_regions'), $filter)
            ->text('id', 'Number')
            ->text('value', 'Name')
            ->btn_edit('', $this->_uri['edit'], ['no_ajax' => 1])
            ->btn_delete('', $this->_uri['delete'])
            ->btn_active('', $this->_uri['active'])
            ->footer_add('', $this->_uri['add'], ['no_ajax' => 1]);

        return  $table;
    }

region_active

public function region_active()
    public function region_active()
    {
        return  _class('admin_methods')->active($this->_table);
    }

region_add

public function region_add()
    public function region_add()
    {
        $replace = _class('admin_methods')->add($this->_table);
        return  $this->_form($replace);
    }

region_delete

public function region_delete()
    public function region_delete()
    {
        return  _class('admin_methods')->delete($this->_table);
    }

region_edit

public function region_edit()
    public function region_edit()
    {
        $replace = _class('admin_methods')->edit($this->_table);
        return  $this->_form($replace);
    }

Methods starting with _ hooks and helpers; not routable as page actions

_form

public function _form($replace)
    public function _form($replace)
    {
        $replace = (array) $replace;
        $_form = form($replace)
            ->info('id', 'Number')
            ->text('value', ' Name')
            ->active_box('active')
            ->save_and_back();
        return  $_form;
    }

_init

public function _init()
    public function _init()
    {
        $this->_class_region = _class('_shop_region', 'modules/shop/');
        $this->_class_admin_methods = _class('admin_methods');
        // actions urls
        $_object = main()->_get('object');
        $_module = 'region';
        $_uri_object = "./?object=$_object";
        $_uri_action = "$_uri_object&action=$_module";

        $this->_uri = [
            'show' => $_uri_action,
            'add' => $_uri_action . '_add',
            'edit' => $_uri_action . '_edit' . '&id=%d',
            'delete' => $_uri_action . '_delete' . '&id=%d',
            'active' => $_uri_action . '_active' . '&id=%d',
        ];
        $this->_table['back_link'] = $this->_uri['show'];
        $_instance = $this;
        $this->_instance = $_instance;
        $this->_table['on_after_update'] = function (&$fields) use ($_instance) {
            return  $_instance->_on_after_update($fields);
        };
    }
public function _on_after_update(&$fields)
    public function _on_after_update(&$fields)
    {
        $_class_region = $this->_class_region;
        $_class_region->_cache_refresh();
    }