197 lines
7.8 KiB
PHP
197 lines
7.8 KiB
PHP
<?
|
|
namespace market;
|
|
|
|
use core\db\structure\Column as C;
|
|
use core\db\structure\eColumnType;
|
|
use market\item\structure\eMarketItemCategory;
|
|
use market\item\structure\eMarketItemType;
|
|
use ui\form\structure\eInputType;
|
|
use ui\Form;
|
|
use ui\input\Input;
|
|
use core\lang\structure\LangVariable as V;
|
|
use ms\ms\structure\msModuleTable;
|
|
use market\item\structure\marketItemLang as Vars;
|
|
use ms\MS;
|
|
|
|
class Item extends msModuleTable {
|
|
static $self;
|
|
static $table_name = 'marketItem';
|
|
static $controller = 'market.item';
|
|
|
|
static $ID = 'id';
|
|
static $NAME = 'name';
|
|
static $PRICE = 'price';
|
|
static $CATEGORY = 'category';
|
|
static $TYPE = 'type';
|
|
static $TEXT = 'text';
|
|
static $PUBLIC = 'public';
|
|
static $CREATED = 'created';
|
|
static $UPDATED = 'updated';
|
|
|
|
static function getTitle(){return V::get(Vars::$MODULE_NAME);}
|
|
static function getSystemLangValues():array{ return Vars::getArray(); }
|
|
public function _update(\Where $w, array $values) {
|
|
$values[self::$UPDATED] = time();
|
|
return parent::_update($w, $values);
|
|
}
|
|
|
|
static function getForm($values = [], $options = []) :array {
|
|
return [
|
|
self::getCommonFormInputs(),
|
|
[
|
|
Form::VIEW=>Form::ROW,
|
|
Form::COLS => [
|
|
[
|
|
Form::VIEW =>Form::INPUT,
|
|
Form::COL_CLASSES =>'c-1-3',
|
|
Form::KEY_VALUE =>self::$NAME,
|
|
Form::TYPE =>eInputType::TEXT,
|
|
Form::INPUT_OPT => [
|
|
Input::PLACEHOLDER => $c = V::get(Vars::$NAME),
|
|
Input::LABEL => $c,
|
|
],
|
|
],
|
|
[
|
|
Form::VIEW =>Form::INPUT,
|
|
Form::COL_CLASSES =>'c-1-3',
|
|
Form::KEY_VALUE =>self::$PRICE,
|
|
Form::TYPE =>eInputType::TEXT,
|
|
Form::INPUT_OPT => [
|
|
Input::PLACEHOLDER => $c = V::get(Vars::$PRICE),
|
|
Input::LABEL => $c,
|
|
],
|
|
],
|
|
[
|
|
Form::VIEW =>Form::INPUT,
|
|
Form::COL_CLASSES =>'c-1-3',
|
|
Form::KEY_VALUE =>self::$PUBLIC,
|
|
Form::TYPE =>eInputType::SWITCH_IOS,
|
|
Form::INPUT_OPT => [
|
|
Input::PLACEHOLDER => $c = V::get(Vars::$PUBLIC),
|
|
Input::LABEL => ' ',
|
|
Input::CHECKED => boolval($values[self::$PUBLIC]),
|
|
],
|
|
],
|
|
]
|
|
],
|
|
[
|
|
Form::VIEW=>Form::ROW,
|
|
Form::COLS => [
|
|
[
|
|
Form::VIEW =>Form::INPUT,
|
|
Form::COL_CLASSES =>'c-50',
|
|
Form::KEY_VALUE =>self::$CATEGORY,
|
|
Form::TYPE =>eInputType::SELECT,
|
|
Form::INPUT_OPT => [
|
|
Input::PLACEHOLDER => $c = V::get(Vars::$CATEGORY),
|
|
Input::LABEL => $c,
|
|
Input::OPTIONS => eMarketItemCategory::getArray(),
|
|
],
|
|
],
|
|
[
|
|
Form::VIEW =>Form::INPUT,
|
|
Form::COL_CLASSES =>'c-50',
|
|
Form::KEY_VALUE =>self::$TYPE,
|
|
Form::TYPE =>eInputType::SELECT,
|
|
Form::INPUT_OPT => [
|
|
Input::PLACEHOLDER => $c = V::get(Vars::$TYPE),
|
|
Input::LABEL => $c,
|
|
Input::OPTIONS => eMarketItemType::getArray(),
|
|
],
|
|
],
|
|
]
|
|
],
|
|
[
|
|
Form::VIEW=>Form::ROW,
|
|
Form::COLS => [
|
|
[
|
|
Form::VIEW =>Form::INPUT,
|
|
Form::COL_CLASSES =>'c-100',
|
|
Form::KEY_VALUE =>self::$TEXT,
|
|
Form::TYPE =>eInputType::TEXTAREA,
|
|
Form::INPUT_OPT => [
|
|
Input::PLACEHOLDER => $c = V::get(Vars::$TEXT),
|
|
Input::LABEL => $c,
|
|
],
|
|
],
|
|
]
|
|
],
|
|
self::getCommonFormSubmits($values),
|
|
];
|
|
}
|
|
|
|
static function columnInfo() : array {
|
|
return [
|
|
new C([
|
|
C::VAR_NAME =>&self::$ID,
|
|
C::TYPE =>eColumnType::INT,
|
|
C::AUTO_INCREMENT =>true,
|
|
C::PRIMARY =>true,
|
|
C::DEFAULT =>0,
|
|
C::HIDDEN =>true,
|
|
C::TH =>V::get(Vars::$ID),
|
|
]),
|
|
new C([
|
|
C::VAR_NAME => &self::$NAME,
|
|
C::TYPE => eColumnType::VARCHAR,
|
|
C::LENGTH => 1023,
|
|
C::TH => V::get(Vars::$NAME),
|
|
]),
|
|
|
|
new C([
|
|
C::VAR_NAME => &self::$PRICE,
|
|
C::TYPE => eColumnType::DOUBLE,
|
|
C::DEFAULT => 0,
|
|
C::TH => V::get(Vars::$PRICE),
|
|
]),
|
|
new C([
|
|
C::VAR_NAME => &self::$PUBLIC,
|
|
C::TYPE => eColumnType::TINYINT,
|
|
C::DEFAULT => 0,
|
|
C::TH => V::get(Vars::$PUBLIC),
|
|
c::FUNC_VALUE_DATA => function($v){ return ms::getBoolValText( $v[self::$PUBLIC]); },
|
|
c::FUNC_VALUE => function($v){ return ms::getBoolValText( $v[self::$PUBLIC]); },
|
|
]),
|
|
new C([
|
|
C::VAR_NAME => &self::$TYPE,
|
|
C::TYPE => eColumnType::INT,
|
|
C::DEFAULT => 0,
|
|
C::TH => V::get(Vars::$TYPE),
|
|
c::FUNC_VALUE_DATA => function($v){ return eMarketItemType::getName( $v[self::$TYPE]); },
|
|
c::FUNC_VALUE => function($v){ return eMarketItemType::getName( $v[self::$TYPE]); },
|
|
]),
|
|
new C([
|
|
C::VAR_NAME => &self::$CATEGORY,
|
|
C::TYPE => eColumnType::INT,
|
|
C::DEFAULT => 0,
|
|
C::TH => V::get(Vars::$CATEGORY),
|
|
c::FUNC_VALUE_DATA => function($v){ return eMarketItemCategory::getName( $v[self::$CATEGORY]); },
|
|
c::FUNC_VALUE => function($v){ return eMarketItemCategory::getName( $v[self::$CATEGORY]); },
|
|
]),
|
|
|
|
new C([
|
|
C::VAR_NAME => &self::$CREATED,
|
|
C::TYPE => eColumnType::INT,
|
|
C::LENGTH => 11,
|
|
C::TH => V::get(Vars::$CREATED),
|
|
C::DEFAULT => time(),
|
|
c::FUNC_VALUE => function($v){return self::formatDate($v[self::$CREATED]);},
|
|
c::HIDDEN=>true,
|
|
]),
|
|
new C([
|
|
C::VAR_NAME => &self::$UPDATED,
|
|
C::TYPE => eColumnType::INT,
|
|
C::DEFAULT => time(),
|
|
C::TH => V::get(Vars::$UPDATED),
|
|
c::FUNC_VALUE => function($v){return self::formatDate($v[self::$UPDATED]);},
|
|
c::HIDDEN=>true,
|
|
]),
|
|
];
|
|
}
|
|
|
|
}
|
|
new Item();
|
|
|
|
|
|
///
|