fix
This commit is contained in:
+1
-1
@@ -4,6 +4,6 @@
|
||||
"namespace": "Bx\\Null",
|
||||
"gitUrl": "https://bitbucket.org/bellord13/bx.null/",
|
||||
"version": "1.0.0",
|
||||
"date": "2023-04-13 00:00:00",
|
||||
"date": "2023-09-01 00:00:00",
|
||||
"deps": ["wt.core"]
|
||||
}
|
||||
@@ -11,9 +11,9 @@ require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admi
|
||||
*/
|
||||
$ormTable = resolve(NullTable::class);
|
||||
|
||||
$tableAdminPage = new TableAdminPage($ormTable, $_REQUEST, '/bitrix/admin/bx_null.main.null_table_row.php');
|
||||
$tableAdminPage = new TableAdminPage($ormTable, $_REQUEST, '/bitrix/admin/bx_null.main.null_table.null_table_row.php');
|
||||
$tableAdminPage
|
||||
->checkPermission('bx.null')
|
||||
->checkPermission()
|
||||
->start()
|
||||
->show();
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admi
|
||||
$ormTable = resolve(NullTable::class);
|
||||
|
||||
$AdminPageTableRow = new TableRowAdminPage($ormTable, $_REQUEST, '/bitrix/admin/bx_null.main.null_table.php');
|
||||
$AdminPageTableRow->checkPermission('bx.null');
|
||||
$AdminPageTableRow->checkPermission();
|
||||
$AdminPageTableRow->start();
|
||||
|
||||
\CJSCore::Init('jquery');
|
||||
@@ -12,7 +12,12 @@ return array(
|
||||
'MAIN' => array(
|
||||
'TITLE' => 'Общие сведения',
|
||||
'OPTIONS' => array(
|
||||
|
||||
'ENABLE' => array(
|
||||
'TITLE' => 'Enable module',
|
||||
'TYPE' => 'checkbox',
|
||||
'DEFAULT' => 'N',
|
||||
'HINT' => '',
|
||||
),
|
||||
),
|
||||
),
|
||||
'DOCS' => array(
|
||||
|
||||
+55
-12
@@ -4,6 +4,8 @@
|
||||
namespace Bx\Null\ORM;
|
||||
|
||||
|
||||
use Bitrix\Main\ORM\Fields\DatetimeField;
|
||||
use Bitrix\Main\Type\DateTime;
|
||||
use Wt\Core\ORM\ADataManager;
|
||||
|
||||
class NullTable extends ADataManager
|
||||
@@ -32,20 +34,61 @@ class NullTable extends ADataManager
|
||||
public static function getMap()
|
||||
{
|
||||
return array(
|
||||
'ID' => array(
|
||||
'data_type' => 'integer',
|
||||
'ID' => new \Bitrix\Main\Entity\IntegerField('ID', [
|
||||
'primary' => true,
|
||||
'autocomplete' => true,
|
||||
'title' => 'ID',
|
||||
),
|
||||
'CREATED_AT' => array(
|
||||
'data_type' => 'datetime',
|
||||
'title' => 'CREATED_AT',
|
||||
),
|
||||
'UPDATED_AT' => array(
|
||||
'data_type' => 'datetime',
|
||||
'title' => 'UPDATED_AT',
|
||||
),
|
||||
'title' => 'Id',
|
||||
]),
|
||||
'CREATED_AT' => new \Bitrix\Main\Entity\DatetimeField('CREATED_AT', [
|
||||
'default_value' => new \Bitrix\Main\Type\DateTime(),
|
||||
'title' => 'CreatedAt',
|
||||
'in_form' => false,
|
||||
]),
|
||||
'UPDATED_AT' => new \Bitrix\Main\Entity\DatetimeField('UPDATED_AT', [
|
||||
'title' => 'UpdatedAt',
|
||||
'in_form' => false,
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param array $fields
|
||||
* @return \Bitrix\Main\ORM\Data\UpdateResult
|
||||
* @throws \Bitrix\Main\ObjectException
|
||||
*/
|
||||
public static function update($id, $fields)
|
||||
{
|
||||
foreach (static::getEntity()->getFields() as $field){
|
||||
if(is_a($field, DatetimeField::class)){
|
||||
if(isset($fields[$field->getName()]) && !is_a($fields[$field->getName()], DateTime::class)) {
|
||||
$fields[$field->getName()] = new \Bitrix\Main\Type\DateTime($fields[$field->getName()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fields = array_merge($fields, [
|
||||
'UPDATED_AT' => new \Bitrix\Main\Type\DateTime(), // date(CDatabase::DateFormatToPHP(FORMAT_DATETIME))
|
||||
]);
|
||||
|
||||
$result = parent::update($id, $fields);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
* @return \Bitrix\Main\ORM\Data\AddResult
|
||||
* @throws \Bitrix\Main\ObjectException
|
||||
*/
|
||||
public static function add($fields)
|
||||
{
|
||||
$fields = array_merge($fields, [
|
||||
'CREATED_AT' => new \Bitrix\Main\Type\DateTime(),
|
||||
'UPDATED_AT' => new \Bitrix\Main\Type\DateTime(),
|
||||
]);
|
||||
|
||||
$result = parent::add($fields);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user