139 lines
4.3 KiB
PHP
139 lines
4.3 KiB
PHP
|
|
<?
|
||
|
|
namespace achi\progress;
|
||
|
|
|
||
|
|
use achi\progress\history\structure\eAchiProgressHistoryType;
|
||
|
|
use core\db\structure\Column as C;
|
||
|
|
use core\db\structure\eColumnType;
|
||
|
|
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 achi\progress\history\structure\achiProgressHistoryLang as Vars;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
class History extends msModuleTable {
|
||
|
|
static $self;
|
||
|
|
static $table_name = 'achiProgressHistory';
|
||
|
|
static $controller = 'achi.progress.history';
|
||
|
|
|
||
|
|
static $ID = 'id';
|
||
|
|
static $PROGRESS = 'progress';
|
||
|
|
static $TYPE = 'type';
|
||
|
|
static $DATA = 'data';
|
||
|
|
static $CREATED = 'created';
|
||
|
|
static $ACCOUNT = 'account';
|
||
|
|
|
||
|
|
|
||
|
|
static function getTitle(){return V::get(Vars::$MODULE_NAME);}
|
||
|
|
static function getSystemLangValues():array{ return Vars::getArray(); }
|
||
|
|
|
||
|
|
static function start($progress_id){
|
||
|
|
$progress_id = intval($progress_id);
|
||
|
|
self::insert([
|
||
|
|
self::$PROGRESS => $progress_id,
|
||
|
|
self::$TYPE => eAchiProgressHistoryType::START,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
static function finished($progress_id){
|
||
|
|
$progress_id = intval($progress_id);
|
||
|
|
self::insert([
|
||
|
|
self::$PROGRESS => $progress_id,
|
||
|
|
self::$TYPE => eAchiProgressHistoryType::FINISHED,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
static function increment($progress_id,$value,$newValue){
|
||
|
|
$progress_id = intval($progress_id);
|
||
|
|
self::insert([
|
||
|
|
self::$PROGRESS => $progress_id,
|
||
|
|
self::$DATA => je(['value'=>$value,'new_value'=>$newValue]),
|
||
|
|
self::$TYPE => eAchiProgressHistoryType::INCREMENT,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
static function getForm($values = [], $options = []) :array {
|
||
|
|
return [
|
||
|
|
self::getCommonFormInputs(),
|
||
|
|
[
|
||
|
|
Form::VIEW=>Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW =>Form::INPUT,
|
||
|
|
Form::COL_CLASSES =>'col-12',
|
||
|
|
Form::KEY_VALUE =>self::$NAME,
|
||
|
|
Form::TYPE =>eInputType::TEXT,
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::PLACEHOLDER => $c = V::get(Vars::$NAME),
|
||
|
|
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::$PROGRESS,
|
||
|
|
C::TYPE => eColumnType::INT,
|
||
|
|
]),
|
||
|
|
new C([
|
||
|
|
C::VAR_NAME => &self::$TYPE,
|
||
|
|
C::TYPE => eColumnType::TINYINT,
|
||
|
|
]),
|
||
|
|
new C([
|
||
|
|
C::VAR_NAME => &self::$DATA,
|
||
|
|
C::TYPE => eColumnType::TEXT,
|
||
|
|
]),
|
||
|
|
|
||
|
|
|
||
|
|
new C([
|
||
|
|
C::VAR_NAME => &self::$ACCOUNT,
|
||
|
|
C::TYPE => eColumnType::INT,
|
||
|
|
C::LENGTH => 11,
|
||
|
|
C::TH => V::get(Vars::$ACCOUNT),
|
||
|
|
C::DEFAULT => intval(\Site::$owner_id),
|
||
|
|
c::HIDDEN=>true,
|
||
|
|
c::FUNC_VALUE => function($v){
|
||
|
|
if($id = $v[self::$ACCOUNT]) {
|
||
|
|
return \Account::getName( \Account::getByID($id) );
|
||
|
|
} else return '-';
|
||
|
|
},
|
||
|
|
]),
|
||
|
|
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 History();
|
||
|
|
|
||
|
|
|
||
|
|
///
|