const OUT_DIR =
// __DIR__ . "/../json";
- // "/www/api2/json";
- "/var/www/erp24/api2/json";
+ "/www/api2/json";
+ //"/var/www/erp24/api2/json";
// "/var/www/www-root/data/www/api.bazacvetov24.ru/data/json";
private static function getPathJson()
$newOperation->id = $operation['id'];
$newOperation->name = $operation['name'];
$newOperation->type = (int)$operation['type'];
+ $newOperation->active = 1;
if (!in_array((int)$operation['type'], array_column($existingTypes, 'code'))) {
$newType = new AnalystsBusinessOperationsTypes();
$newType->code = (int)$operation['type'];
$newType->name = null;
+ $newType->alias = null;
$newType->created_at = date('Y-m-d H:i:s');
+ $newType->created_by = 1409;
if ($newType->save()) {
$newOperation->type_id = $newType->id;
} else {
Yii::error('Ошибка сохранение типа ' . json_encode($newType->getErrors(), JSON_UNESCAPED_UNICODE), __METHOD__ );
LogService::apiErrorLog(
json_encode(
- ["error_id" => 44.1, "error" => $operation->getErrors()],
+ ["error_id" => 44.1, "error" => $newType->getErrors()],
JSON_UNESCAPED_UNICODE
)
);
$newType = new AnalystsBusinessOperationsTypes();
$newType->code = (int)$operation['type'];
$newType->name = null;
+ $newType->alias = null;
$newType->created_at = date('Y-m-d H:i:s');
+ $newType->created_by = 1409;
if ($newType->save()) {
$oldOperation->type = (int)$operation['type'];
$oldOperation->type_id = $newType->id;
namespace app\controllers;
+use Yii;
use yii\web\ForbiddenHttpException;
use yii_app\records\Admin;
use yii_app\records\AdminGroup;
*/
public function actionUpdate($id)
{
+ $adminId = Yii::$app->user->id;
if (!$this->canEdit()) {
throw new ForbiddenHttpException('Недостаточно прав.');
}
$model = $this->findModel($id);
-
+ $model->updated_at = date('Y-m-d H:i:s');
+ $model->updated_by = $adminId ?? null;
if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
'id' => $this->string()->notNull()->unique()->comment('GUID аналитики'),
'name' => $this->string()->notNull()->comment('Название аналитики'),
'type' => $this->integer()->notNull()->comment('Вид использования хозяйственной операции'),
- 'type_id' => $this->integer()->null()->comment('ID Вида'),
+ 'type_id' => $this->tinyInteger()->defaultValue(1)->comment('Активность записи'),
+ 'active' => $this->integer()->null()->comment('ID Вида'),
'created_at' => $this->dateTime()->notNull()->defaultExpression('NOW()'),
]);
$this->addPrimaryKey('pk_analytics_id', self::TABLE_NAME, 'id');
$this->createTable(self::TABLE_NAME, [
'id' => $this->primaryKey()->comment('ID типа операции'),
'code' => $this->integer()->notNull()->unique()->comment('Код типа (0,1,2...)'),
+ 'alias' => $this->string()->null()->comment('Алиас типа операции'),
'name' => $this->string()->null()->comment('Название типа операции'),
- 'created_at' => $this->dateTime()->notNull()->defaultExpression('NOW()'),
+ 'created_by' => $this->integer()->null()->comment('Кем создано - id'),
+ 'updated_by' => $this->integer()->null()->comment('Кем обновлено - id'),
+ 'created_at' => $this->dateTime()->notNull()->defaultExpression('NOW()')->comment('Когда создано'),
+ 'updated_at' => $this->dateTime()->null()->comment('Когда обновлено'),
]);
$this->batchInsert(self::TABLE_NAME, ['code', 'name'], [
[0, 'Оприходование'],
* @property string $id GUID аналитики
* @property string $name Название аналитики
* @property int $type Вид использования хозяйственной операции
- * @property int|null $type_id ID Вида
- * @property string $created_at Дата создания
+ * @property int|null $type_id Активность записи
+ * @property int|null $active ID Вида
+ * @property string $created_at
*/
class AnalystsBusinessOperations extends \yii\db\ActiveRecord
{
public function rules()
{
return [
- [['type_id'], 'default', 'value' => null],
- [['id', 'name', 'type', 'created_at'], 'required'],
- [['type'], 'default', 'value' => null],
- [['type', 'type_id'], 'integer'],
+ [['active'], 'default', 'value' => null],
+ [['type_id'], 'default', 'value' => 1],
+ [['id', 'name', 'type'], 'required'],
+ [['type', 'type_id', 'active'], 'default', 'value' => null],
+ [['type', 'type_id', 'active'], 'integer'],
[['created_at'], 'safe'],
[['id', 'name'], 'string', 'max' => 255],
[['id'], 'unique'],
public function attributeLabels()
{
return [
- 'guid' => 'GUID аналитики',
- 'name' => 'Название аналитики',
- 'type' => 'Вид использования хозяйственной операции',
- 'type_id' => 'ID Вида',
- 'created_at' => 'Дата создания',
+ 'id' => 'ID',
+ 'name' => 'Name',
+ 'type' => 'Type',
+ 'type_id' => 'Type ID',
+ 'active' => 'Active',
+ 'created_at' => 'Created At',
];
}
*
* @property int $id ID типа операции
* @property int $code Код типа (0,1,2...)
+ * @property string|null $alias Алиас типа операции
* @property string|null $name Название типа операции
- * @property string $created_at
- *
- * @property AnalystsBusinessOperations[] $analystsBusinessOperations
+ * @property int|null $created_by Кем создано - id
+ * @property int|null $updated_by Кем обновлено - id
+ * @property string $created_at Когда создано
+ * @property string|null $updated_at Когда обновлено
*/
class AnalystsBusinessOperationsTypes extends \yii\db\ActiveRecord
{
public function rules()
{
return [
+ [['alias', 'name', 'created_by', 'updated_by', 'updated_at'], 'default', 'value' => null],
[['code'], 'required'],
- [['name'], 'default', 'value' => null],
- [['code'], 'integer'],
- [['created_at'], 'safe'],
- [['name'], 'string', 'max' => 255],
+ [['code', 'created_by', 'updated_by'], 'default', 'value' => null],
+ [['code', 'created_by', 'updated_by'], 'integer'],
+ [['created_at', 'updated_at'], 'safe'],
+ [['alias', 'name'], 'string', 'max' => 255],
[['code'], 'unique'],
];
}
return [
'id' => 'ID',
'code' => 'Code',
+ 'alias' => 'Alias',
'name' => 'Name',
+ 'created_by' => 'Created By',
+ 'updated_by' => 'Updated By',
'created_at' => 'Created At',
+ 'updated_at' => 'Updated At',
];
}
'id',
'code',
'name',
+ 'alias',
+ 'updated_at',
+ 'updated_by',
'created_at',
[
'class' => ActionColumn::class,
'id',
'code',
'name',
+ 'alias',
+ 'updated_by',
+ 'created_by',
+ 'updated_at',
'created_at',
],
]) ?>
],
'type',
'type_id',
+ [
+ 'attribute' => 'active',
+ 'label' => 'Активность',
+ 'value' => function ($model) {
+ return $model->active == 1 ? 'Да' : 'Нет';
+ },
+ ],
'created_at',
[
'class' => \yii\grid\ActionColumn::class,
'name',
'type',
'type_id',
+ 'active',
'created_at',
],
]) ?>