?>
<div class="<cron m-5">
-<h1>Создание задания для 1с</h1>
+ <h1>Создание задания для 1с</h1>
-<?php $form = ActiveForm::begin(); ?>
+ <?php $form = ActiveForm::begin(); ?>
-<?= Html::hiddenInput('_csrf', Yii::$app->request->getCsrfToken()) ?>
+ <?= Html::hiddenInput('_csrf', Yii::$app->request->getCsrfToken()) ?>
-<?php foreach ($items as $name => $ar): ?>
- <br>
- <?= Html::checkbox("in[{$name}]") ?> <?= Html::encode($ar['name']) ?>
- <table>
- <?php foreach ($ar['array'] ?? [] as $tip => $val): ?>
- <tr>
- <td><?= Html::encode($tip) ?></td>
- <td>
- <?= Html::input('text', "in_in[{$name}][{$tip}]", $val, ['class' => 'form-control', 'style' => 'width:220px;']) ?>
- </td>
- </tr>
- <?php endforeach; ?>
- </table>
-<?php endforeach; ?>
+ <?php foreach ($items as $name => $ar): ?>
+ <br>
+ <?= Html::checkbox("in[{$name}]") ?> <?= Html::encode($ar['name']) ?>
+ <table>
+ <?php foreach ($ar['array'] ?? [] as $tip => $val): ?>
+ <tr>
+ <td><?= Html::encode($tip) ?></td>
+ <td>
+ <?php if ($name == 'prices' && $ar["array"]["type_price"])
+ echo Html::dropDownList("in_in[{$name}][{$tip}]", null,
+ ['Розничная цена' => 'Розничная цена', 'Розничная маг на Московск' => 'Розничная маг на Московск'],
+ ['class' => 'form-control', 'style' => 'width:220px;']);
+ else
+ echo Html::input('text', "in_in[{$name}][{$tip}]", $val, ['class' => 'form-control', 'style' => 'width:220px;']) ?>
+ </td>
+ </tr>
+ <?php endforeach; ?>
+ </table>
+ <?php endforeach; ?>
-<br>
-<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
+ <br>
+ <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
-<?php ActiveForm::end(); ?>
+ <?php ActiveForm::end(); ?>
-<p><?= Html::a('Обновить', '/cron/1c', ['class' => 'btn']) ?></p>
+ <p><?= Html::a('Обновить', '/cron/1c', ['class' => 'btn']) ?></p>
-<h3>Задания для 1с</h3>
+ <h3>Задания для 1с</h3>
-<?php
-echo GridView::widget([
- 'dataProvider' => $tasksDataProvider,
- 'columns' => [
- [
- 'attribute' => 'request_id',
- 'label' => 'ID запроса',
- 'format' => 'raw',
- 'value' => function ($task) {
- return Html::a($task->request_id, "https://api2." . (YII_ENV_PROD ? 'erp.erp-flowers.ru' : 'dev.erp-flowers.ru')
- . "/json/upload_request_id_{$task->request_id}", ['target' => '_blank']);
- }
- ],
- [
- 'attribute' => 'date',
- 'label' => 'Дата',
- ],
- [
- 'attribute' => 'json_post',
- 'label' => 'JSON данные',
- 'format' => 'raw',
- 'value' => function ($task) {
- if (empty($task->json_post)) {
- return '';
+ <?php
+ echo GridView::widget([
+ 'dataProvider' => $tasksDataProvider,
+ 'columns' => [
+ [
+ 'attribute' => 'request_id',
+ 'label' => 'ID запроса',
+ 'format' => 'raw',
+ 'value' => function ($task) {
+ return Html::a($task->request_id, "https://api2." . (YII_ENV_PROD ? 'erp.erp-flowers.ru' : 'dev.erp-flowers.ru')
+ . "/json/upload_request_id_{$task->request_id}", ['target' => '_blank']);
}
- $decodedJson = json_decode($task->json_post, true);
- if ($decodedJson === null && json_last_error() !== JSON_ERROR_NONE) {
- return 'Ошибка в JSON';
+ ],
+ [
+ 'attribute' => 'date',
+ 'label' => 'Дата',
+ ],
+ [
+ 'attribute' => 'json_post',
+ 'label' => 'JSON данные',
+ 'format' => 'raw',
+ 'value' => function ($task) {
+ if (empty($task->json_post)) {
+ return '';
+ }
+ $decodedJson = json_decode($task->json_post, true);
+ if ($decodedJson === null && json_last_error() !== JSON_ERROR_NONE) {
+ return 'Ошибка в JSON';
+ }
+ $jsonPretty = json_encode($decodedJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
+ return Html::tag('pre', $jsonPretty);
+ },
+ 'contentOptions' => ['style' => 'white-space: pre-wrap; word-wrap: break-word;']
+ ],
+ [
+ 'attribute' => 'status',
+ 'label' => 'Статус',
+ 'value' => function ($task) {
+ return Html::encode(\yii_app\records\ApiCron::getStatus()[$task->status]);
}
- $jsonPretty = json_encode($decodedJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
- return Html::tag('pre', $jsonPretty);
- },
- 'contentOptions' => ['style' => 'white-space: pre-wrap; word-wrap: break-word;']
- ],
- [
- 'attribute' => 'status',
- 'label' => 'Статус',
- 'value' => function ($task) {
- return Html::encode(\yii_app\records\ApiCron::getStatus()[$task->status]);
- }
+ ],
+ [
+ 'attribute' => 'date_up',
+ 'label' => 'Дата обновления',
+ 'value' => function ($task) {
+ return $task->status == \yii_app\records\ApiCron::COMPLETE && $task->date_up != '0000-00-00 00:00:00' ? Html::encode($task->date_up) : '';
+ }
+ ],
],
- [
- 'attribute' => 'date_up',
- 'label' => 'Дата обновления',
- 'value' => function ($task) {
- return $task->status == \yii_app\records\ApiCron::COMPLETE && $task->date_up != '0000-00-00 00:00:00' ? Html::encode($task->date_up) : '';
+ 'rowOptions' => function ($task) {
+ $class = '';
+ if ($task->status == \yii_app\records\ApiCron::AWAITING_COMPLETION) {
+ $class = 'bg-warning';
}
- ],
- ],
- 'rowOptions' => function ($task) {
- $class = '';
- if ($task->status == \yii_app\records\ApiCron::AWAITING_COMPLETION) {
- $class = 'bg-warning';
- }
- return ['class' => $class];
- },
- 'tableOptions' => ['class' => 'table table-hover table-sm'],
- 'pager' => [],
- 'layout' => '{items}',
-]);
-?>
+ return ['class' => $class];
+ },
+ 'tableOptions' => ['class' => 'table table-hover table-sm'],
+ 'pager' => [],
+ 'layout' => '{items}',
+ ]);
+ ?>
-<h3>Логи от 1с</h3>
+ <h3>Логи от 1с</h3>
-<?php
-echo GridView::widget([
- 'dataProvider' => $logsDataProvider,
- 'columns' => [
- [
+ <?php
+ echo GridView::widget([
+ 'dataProvider' => $logsDataProvider,
+ 'columns' => [
+ [
- 'format' => 'raw',
- 'value' => function ($log) {
- return Html::a($log->request_id, "https://api2.erp.erp-flowers.ru/json/upload_request_id_{$log->request_id}", ['target' => '_blank']);
- }
- ],
- [
- 'attribute' => 'date',
- 'label' => 'Дата',
- ],
- [
- 'attribute' => 'url',
- 'label' => 'URL',
- 'value' => function ($log) {
- return Html::encode($log->url);
- }
- ],
- [
- 'attribute' => 'content',
- 'label' => 'Контент',
- 'format' => 'raw',
- 'value' => function ($task) {
- if (empty($task->content)) {
- return '';
+ 'format' => 'raw',
+ 'value' => function ($log) {
+ return Html::a($log->request_id, "https://api2.erp.erp-flowers.ru/json/upload_request_id_{$log->request_id}", ['target' => '_blank']);
}
- $decodedJson = json_decode($task->content, true);
- if ($decodedJson === null && json_last_error() !== JSON_ERROR_NONE) {
- return 'Ошибка в JSON';
+ ],
+ [
+ 'attribute' => 'date',
+ 'label' => 'Дата',
+ ],
+ [
+ 'attribute' => 'url',
+ 'label' => 'URL',
+ 'value' => function ($log) {
+ return Html::encode($log->url);
}
- $jsonPretty = json_encode($decodedJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
- return Html::tag('pre', $jsonPretty);
- },
- 'contentOptions' => ['style' => 'white-space: pre-wrap; word-wrap: break-word;'] // Разрыв слов и переносы
- ],
+ ],
+ [
+ 'attribute' => 'content',
+ 'label' => 'Контент',
+ 'format' => 'raw',
+ 'value' => function ($task) {
+ if (empty($task->content)) {
+ return '';
+ }
+ $decodedJson = json_decode($task->content, true);
+ if ($decodedJson === null && json_last_error() !== JSON_ERROR_NONE) {
+ return 'Ошибка в JSON';
+ }
+ $jsonPretty = json_encode($decodedJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
+ return Html::tag('pre', $jsonPretty);
+ },
+ 'contentOptions' => ['style' => 'white-space: pre-wrap; word-wrap: break-word;'] // Разрыв слов и переносы
+ ],
- ],
- 'tableOptions' => ['class' => 'table table-hover table-sm'],
- 'pager' => [],
- 'layout' => '{items}',
-]);
-?>
+ ],
+ 'tableOptions' => ['class' => 'table table-hover table-sm'],
+ 'pager' => [],
+ 'layout' => '{items}',
+ ]);
+ ?>
</div>