use yii_app\helpers\SalaryHelper;
use yii_app\records\Admin;
use yii_app\records\AdminGroup;
+use yii_app\records\AnalystsBusinessOperations;
use yii_app\records\ApiCron;
use yii_app\records\Assemblies;
use yii_app\records\Balances;
}
}
+
+ if (!empty($result['analysts_business_operations'])) {
+ $existingOperations = AnalystsBusinessOperations::find()
+ ->select(['id'])
+ ->column();
+ foreach ($result["analysts_business_operations"] as $operation) {
+ if (!in_array($operation['guid'], $existingOperations)) {
+ $newOperation = new AnalystsBusinessOperations();
+ $newOperation->id = $operation['guid'];
+ $newOperation->name = $operation['name'];
+ $newOperation->type = $operation['type'];
+ if (!$newOperation->save()) {
+ LogService::apiErrorLog(
+ json_encode(
+ ["error_id" => 44, "error" => $newOperation->getErrors()],
+ JSON_UNESCAPED_UNICODE
+ )
+ );
+ }
+ }
+
+ }
+ }
$mess['line'][] = __LINE__;
} catch (Exception $e) {
LogService::apiDataLogs(1, json_encode($mess, JSON_UNESCAPED_UNICODE), $requestIdText);
file_put_contents(self::OUT_DIR . '/log_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e->getMessage() . " " . $e->getLine(), FILE_APPEND);
Yii::error('Ошибка upload - блок catch '. json_encode($e->getMessage() . " " . $e->getLine(), JSON_UNESCAPED_UNICODE));
LogService::apiErrorLog(json_encode([
- "error_id" => 44,
+ "error_id" => 45,
"error" => "Ошибка загрузки " . $e->getMessage() . " " . $e->getLine(),
], JSON_UNESCAPED_UNICODE));
} finally {
--- /dev/null
+<?php
+
+namespace app\controllers;
+
+use yii_app\records\AnalystsBusinessOperations;
+use yii\data\ActiveDataProvider;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * AnalystsBusinessOperationsController implements the CRUD actions for AnalystsBusinessOperations model.
+ */
+class AnalystsBusinessOperationsController extends Controller
+{
+ /**
+ * @inheritDoc
+ */
+ public function behaviors()
+ {
+ return array_merge(
+ parent::behaviors(),
+ [
+ 'verbs' => [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => ['POST'],
+ ],
+ ],
+ ]
+ );
+ }
+
+ /**
+ * Lists all AnalystsBusinessOperations models.
+ *
+ * @return string
+ */
+ public function actionIndex()
+ {
+ $dataProvider = new ActiveDataProvider([
+ 'query' => AnalystsBusinessOperations::find(),
+ /*
+ 'pagination' => [
+ 'pageSize' => 50
+ ],
+ 'sort' => [
+ 'defaultOrder' => [
+ 'id' => SORT_DESC,
+ ]
+ ],
+ */
+ ]);
+
+ return $this->render('index', [
+ 'dataProvider' => $dataProvider,
+ ]);
+ }
+
+ /**
+ * Displays a single AnalystsBusinessOperations model.
+ * @param string $id
+ * @return string
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionView($id)
+ {
+ return $this->render('view', [
+ 'model' => $this->findModel($id),
+ ]);
+ }
+
+ /**
+ * Creates a new AnalystsBusinessOperations model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ * @return string|\yii\web\Response
+ */
+ public function actionCreate()
+ {
+ $model = new AnalystsBusinessOperations();
+
+ if ($this->request->isPost) {
+ if ($model->load($this->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'id' => $model->id]);
+ }
+ } else {
+ $model->loadDefaultValues();
+ }
+
+ return $this->render('create', [
+ 'model' => $model,
+ ]);
+ }
+
+ /**
+ * Updates an existing AnalystsBusinessOperations model.
+ * If update is successful, the browser will be redirected to the 'view' page.
+ * @param string $id
+ * @return string|\yii\web\Response
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionUpdate($id)
+ {
+ $model = $this->findModel($id);
+
+ if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'id' => $model->id]);
+ }
+
+ return $this->render('update', [
+ 'model' => $model,
+ ]);
+ }
+
+ /**
+ * Deletes an existing AnalystsBusinessOperations model.
+ * If deletion is successful, the browser will be redirected to the 'index' page.
+ * @param string $id
+ * @return \yii\web\Response
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionDelete($id)
+ {
+ $this->findModel($id)->delete();
+
+ return $this->redirect(['index']);
+ }
+
+ /**
+ * Finds the AnalystsBusinessOperations model based on its primary key value.
+ * If the model is not found, a 404 HTTP exception will be thrown.
+ * @param string $id
+ * @return AnalystsBusinessOperations the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($id)
+ {
+ if (($model = AnalystsBusinessOperations::findOne(['id' => $id])) !== null) {
+ return $model;
+ }
+
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+}
"employee" => ["name" => "Физ лица в 1с - продавцы"],
"prices" => ["name" => "Типы цен", "array" => ["type_price" => "Розничная цена"]],
"checks_dell" => ["name" => "Удаление чеков"],
+ "analysts_business_operations" => ["name" => "Аналитика хозяйственных операций"],
"checks" => [
"name" => "Чеки-продажи",
"array" => [
--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Handles the creation of table `{{%analysts_business_operations}}`.
+ */
+class m250825_141743_create_analysts_business_operations_table extends Migration
+{
+ const TABLE_NAME = 'erp24.analysts_business_operations';
+ /**
+ * {@inheritdoc}
+ */
+ public function safeUp()
+ {
+ $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+ if (!isset($tableSchema)) {
+ $this->createTable(self::TABLE_NAME, [
+ 'id' => $this->string()->notNull()->unique()->comment('GUID аналитики'),
+ 'name' => $this->string()->notNull()->comment('Название аналитики'),
+ 'type' => $this->integer()->notNull()->comment('Вид использования хозяйственной операции'),
+ 'type_id' => $this->string()->null()->comment('ID Вида'),
+ 'created_at' => $this->dateTime()->notNull()->comment('Дата создания'),
+ ]);
+ $this->addPrimaryKey('pk_analytics_id', self::TABLE_NAME, 'id');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+ if (isset($tableSchema)) {
+ $this->dropPrimaryKey('pk_analytics_id', self::TABLE_NAME);
+ $this->dropTable(self::TABLE_NAME);
+ }
+ }
+}
--- /dev/null
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+
+/**
+ * This is the model class for table "analysts_business_operations".
+ *
+ * @property string $id GUID аналитики
+ * @property string $name Название аналитики
+ * @property int $type Вид использования хозяйственной операции
+ * @property string|null $type_id ID Вида
+ * @property string $created_at Дата создания
+ */
+class AnalystsBusinessOperations extends \yii\db\ActiveRecord
+{
+
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function tableName()
+ {
+ return 'analysts_business_operations';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function rules()
+ {
+ return [
+ [['type_id'], 'default', 'value' => null],
+ [['id', 'name', 'type', 'created_at'], 'required'],
+ [['type'], 'default', 'value' => null],
+ [['type'], 'integer'],
+ [['created_at'], 'safe'],
+ [['id', 'name', 'type_id'], 'string', 'max' => 255],
+ [['id'], 'unique'],
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function attributeLabels()
+ {
+ return [
+ 'guid' => 'GUID аналитики',
+ 'name' => 'Название аналитики',
+ 'type' => 'Вид использования хозяйственной операции',
+ 'type_id' => 'ID Вида',
+ 'created_at' => 'Дата создания',
+ ];
+ }
+
+}
--- /dev/null
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\ActiveForm;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\AnalystsBusinessOperations $model */
+/** @var yii\widgets\ActiveForm $form */
+?>
+
+<div class="analysts-business-operations-form">
+
+ <?php $form = ActiveForm::begin(); ?>
+
+ <?= $form->field($model, 'id')->textInput(['maxlength' => true]) ?>
+
+ <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
+
+ <?= $form->field($model, 'type')->textInput() ?>
+
+ <?= $form->field($model, 'type_id')->textInput(['maxlength' => true]) ?>
+
+ <?= $form->field($model, 'created_at')->textInput() ?>
+
+ <div class="form-group">
+ <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
+ </div>
+
+ <?php ActiveForm::end(); ?>
+
+</div>
--- /dev/null
+<?php
+
+use yii\helpers\Html;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\AnalystsBusinessOperations $model */
+
+$this->title = 'Create Analysts Business Operations';
+$this->params['breadcrumbs'][] = ['label' => 'Analysts Business Operations', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="analysts-business-operations-create">
+
+ <h1><?= Html::encode($this->title) ?></h1>
+
+ <?= $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+</div>
--- /dev/null
+<?php
+
+use yii_app\records\AnalystsBusinessOperations;
+use yii\helpers\Html;
+use yii\helpers\Url;
+use yii\grid\ActionColumn;
+use yii\grid\GridView;
+
+/** @var yii\web\View $this */
+/** @var yii\data\ActiveDataProvider $dataProvider */
+
+$this->title = 'Аналитика хозяйственных операций';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="analysts-business-operations-index p-4">
+
+ <h1><?= Html::encode($this->title) ?></h1>
+
+
+ <?= GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'columns' => [
+ ['class' => 'yii\grid\SerialColumn'],
+
+ 'id',
+ 'name',
+ 'type',
+ 'type_id',
+ 'created_at',
+ [
+ 'class' => ActionColumn::class,
+ 'urlCreator' => function ($action, AnalystsBusinessOperations $model, $key, $index, $column) {
+ return Url::toRoute([$action, 'id' => $model->id]);
+ }
+ ],
+ ],
+ ]); ?>
+
+
+</div>
--- /dev/null
+<?php
+
+use yii\helpers\Html;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\AnalystsBusinessOperations $model */
+
+$this->title = 'Изменить аналитику: ' . $model->name;
+$this->params['breadcrumbs'][] = ['label' => 'Analysts Business Operations', 'url' => ['index']];
+$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
+$this->params['breadcrumbs'][] = 'Update';
+?>
+<div class="analysts-business-operations-update p-4">
+
+ <h1><?= Html::encode($this->title) ?></h1>
+
+ <?= $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+</div>
--- /dev/null
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\DetailView;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\AnalystsBusinessOperations $model */
+
+$this->title = $model->name;
+$this->params['breadcrumbs'][] = ['label' => 'Analysts Business Operations', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+\yii\web\YiiAsset::register($this);
+?>
+<div class="analysts-business-operations-view p-4">
+
+ <h1><?= Html::encode($this->title) ?></h1>
+
+ <p>
+ <?= Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
+ <?= Html::a('Удалить', ['delete', 'id' => $model->id], [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => 'Вы уверены, что хотите удалить запись?',
+ 'method' => 'post',
+ ],
+ ]) ?>
+ </p>
+
+ <?= DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ 'name',
+ 'type',
+ 'type_id',
+ 'created_at',
+ ],
+ ]) ?>
+
+</div>