Исправления ляляля хуй соси

This commit is contained in:
Arsen Mirzaev Tatyano-Muradovich 2021-12-06 14:20:16 +10:00
parent 3f0b342d48
commit 9fb2e4dc90
8 changed files with 170 additions and 80 deletions

View File

@ -221,11 +221,11 @@ abstract class Document extends ActiveRecord
/** /**
* Конвертировать _id в _key * Конвертировать _id в _key
*/ */
private static function keyFromId(string $_id): string private static function keyFromId(string $_id): ?string
{ {
$_key = preg_match_all('/\/([0-9]+)$/m', $_id, $mathes); preg_match_all('/\/([0-9]+)$/m', $_id, $mathes);
return $mathes[0][1]; return $mathes[1][0] ?? null;
} }
/** /**

View File

@ -139,6 +139,12 @@ abstract class Edge extends Document
/** /**
* Поиск ребра по его вершинам * Поиск ребра по его вершинам
*
* @param string $_from Идентификатор исходящей вершины
* @param string $_to Идентификатор входящей вершины
* @param string|null $type deprecated
* @param int $limit Ограничение по количеству
* @param array|null $filter Фильтр (where())
*/ */
public static function searchByVertex(string $_from, string $_to, string|null $type = null, int $limit = 1, array|null $filter = null): array|null public static function searchByVertex(string $_from, string $_to, string|null $type = null, int $limit = 1, array|null $filter = null): array|null
{ {

View File

@ -876,4 +876,29 @@ class Supply extends Product implements ProductInterface, OfferInterface
// Отправка // Отправка
return (bool) $model->write(); return (bool) $model->write();
} }
/**
* Поиск связи поставки с товаром
*
* Если не передать товар, то ищется любой товар с которым есть связь
*
* @param Product|null $product Товар с которым проверяется связь
* @param int $limit Ограничение по максимальному количеству
*/
public function searchConnectWithProduct(Product|null $product = null, int $limit = 1): SupplyEdgeProduct|array|null
{
if (isset($product)) {
// Передан товар
$edge = SupplyEdgeProduct::searchByVertex($this->readId(), $product->readId(), filter: ['type' => 'connect'], limit: $limit);
return $limit === 1 ? $edge[0] ?? null : $edge;
} else {
// Не передан товар
$edge = SupplyEdgeProduct::searchBySupplyId($this->readId(), $limit);
return $limit === 1 ? $edge[0] ?? null : $edge;
}
}
} }

View File

@ -68,6 +68,12 @@ class SupplyEdgeProduct extends Edge implements OfferInterface
return self::findOne([self::getIdFieldName1c() => $ocid]); return self::findOne([self::getIdFieldName1c() => $ocid]);
} }
/**
* Поиск по идентификатору поставки
*
* @param string $_id Идентификатор поставки
* @param int $limit Ограничение по максимальному количеству
*/
public static function searchBySupplyId(string $_id, int $limit = 1): array public static function searchBySupplyId(string $_id, int $limit = 1): array
{ {
return self::find()->where(['_from' => $_id])->limit($limit)->all(); return self::find()->where(['_from' => $_id])->limit($limit)->all();

View File

@ -8,6 +8,7 @@ use yii\helpers\Html;
use app\models\Notification; use app\models\Notification;
use app\models\Account; use app\models\Account;
use app\models\Document;
use app\models\Product; use app\models\Product;
use app\models\Settings; use app\models\Settings;
use app\models\Supply; use app\models\Supply;
@ -124,19 +125,19 @@ $timezone = $timezone[1][0];
<div class="mb-3 row"> <div class="mb-3 row">
<div class="pr-0 col-auto"><?= ++$amount ?>.</div> <div class="pr-0 col-auto"><?= ++$amount ?>.</div>
<div class="pr-0 col overflow-hidden" title="<?= $account->name ?? 'Неизвестно' ?>"> <div class="pr-0 col overflow-hidden" title="ФИО">
<?= $account->name ?? 'Неизвестно' ?> <?= $account->name ?? 'Неизвестно' ?>
</div> </div>
<div class="my-auto pr-0 col-auto"> <div class="my-auto pr-0 col-auto" title="Псевдоним">
<?= $account->indx ?? '' ?> <?= $account->indx ?? '' ?>
</div> </div>
<div class="my-auto pr-0 col-auto"> <div class="my-auto pr-0 col-auto" title="Тип аккаунта">
<?= $account->agnt ? 'Поставщик' : 'Покупатель' ?> <?= $account->agnt ? 'Поставщик' : 'Покупатель' ?>
</div> </div>
<div class="mr-3 my-auto pr-0 col-2"> <div class="mr-3 my-auto pr-0 col-2" title="Уровень авторизации">
<?= $account->type() ?> <?= $account->type() ?>
</div> </div>
<div class="my-auto pr-0 col-auto text-right"> <div class="my-auto pr-0 col-auto text-right" title="Дата регистрации">
<?= $create ?? 'Неизвестно' ?> <?= $create ?? 'Неизвестно' ?>
</div> </div>
<a class="my-auto col-auto fas fa-trash-alt text-dark" type="button" onclick="page_profile_supplies_delete()"></a> <a class="my-auto col-auto fas fa-trash-alt text-dark" type="button" onclick="page_profile_supplies_delete()"></a>
@ -187,9 +188,9 @@ $timezone = $timezone[1][0];
<div class="mb-3 row"> <div class="mb-3 row">
<div class="pr-0 col-auto"><?= ++$amount ?>.</div> <div class="pr-0 col-auto"><?= ++$amount ?>.</div>
<div class="pr-0 col overflow-hidden" title="<?= $product->name ?? 'Неизвестно' ?>"> <a class="pr-0 col overflow-hidden" title="<?= $product->name ?? 'Открыть страницу товара' ?>" href="/product/<?= $product->catn ?? 'Неизвестно' ?>">
<?= $product->catn ?? 'Неизвестно' ?> <?= $product->catn ?? 'Неизвестно' ?>
</div> </a>
<div class="my-auto pr-0 col-auto text-right"> <div class="my-auto pr-0 col-auto text-right">
<?= $create ?? 'Неизвестно' ?> <?= $create ?? 'Неизвестно' ?>
</div> </div>
@ -215,6 +216,18 @@ $timezone = $timezone[1][0];
?> ?>
<?php foreach ($supplies ?? [] as $supply) : ?> <?php foreach ($supplies ?? [] as $supply) : ?>
<?php <?php
// Поиск аккаунта владельца
$account = '/account/' . Account::searchBySupplyId($supply->readId())['_key'];
// Деинициализация товара
unset($product);
if ($connect = $supply->searchConnectWithProduct()) {
// Найдена привязка поставки к аккаунту
$product = Product::searchById($connect->_to);
}
foreach ($supply->jrnl ?? [] as $jrnl) { foreach ($supply->jrnl ?? [] as $jrnl) {
// Перебор записей в журнале // Перебор записей в журнале
@ -233,22 +246,28 @@ $timezone = $timezone[1][0];
<div class="mb-3 row"> <div class="mb-3 row">
<div class="pr-0 col-auto"><?= ++$amount ?>.</div> <div class="pr-0 col-auto"><?= ++$amount ?>.</div>
<div class="pr-0 col-2 overflow-hidden" title="<?= $supply->name ?? 'Неизвестно' ?>"> <div class="pr-0 col-2 overflow-hidden" title="Название">
<?= $supply->catn ?? 'Неизвестно' ?> <?= $supply->catn ?? 'Неизвестно' ?>
</div> </div>
<div class="my-auto pr-0 col"> <div class="my-auto pr-0 col" title="Описание">
<?= $supply->dscr ?? 'Без описания' ?> <?= $supply->dscr ?? 'Без описания' ?>
</div> </div>
<div class="my-auto pr-0 col-auto"> <div class="my-auto pr-0 col-auto" title="Количество">
<?= $supply->amnt ?? '0' ?>шт <?= $supply->amnt ?? '0' ?>шт
</div> </div>
<div class="my-auto pr-0 col-auto"> <div class="my-auto pr-0 col-auto" title="Стоимость">
<?= $supply->cost ?? '0' ?>р <?= $supply->cost ?? '0' ?>р
</div> </div>
<div class="my-auto pr-0 col-auto text-right"> <div class="my-auto pr-0 col-auto text-right" title="Дата создания">
<?= $create ?? 'Неизвестно' ?> <?= $create ?? 'Неизвестно' ?>
</div> </div>
<a class="my-auto col-auto fas fa-trash-alt text-dark" type="button" onclick="page_profile_supplies_delete()"></a> <?php if (empty($product)) : ?>
<a class="my-auto pr-0 col-auto fas fa-shopping-basket icon_red" title="Товар отсутствует" type="button" onclick="create_product()"></a>
<?php else : ?>
<a class="my-auto pr-0 col-auto fas fa-shopping-basket text-dark" title="Товар" href="<?= "/product/$product->catn" ?>"></a>
<?php endif ?>
<a class="my-auto pr-0 col-auto fas fa-user text-dark" title="Владелец" href="<?= $account ?? '/' ?>"></a>
<a class="my-auto col-auto fas fa-trash-alt text-dark" type="button" title="Удалить" onclick="page_profile_supplies_delete()"></a>
</div> </div>
<?php if ($amount < count($supplies)) : ?> <?php if ($amount < count($supplies)) : ?>

View File

@ -115,7 +115,7 @@ $panel ?? $panel = 'profile_panel_supplies_input_import';
<a class="my-auto col-auto fas fa-trash-alt text-dark" type="button" onclick="page_profile_supplies_delete()"></a> <a class="my-auto col-auto fas fa-trash-alt text-dark" type="button" onclick="page_profile_supplies_delete()"></a>
</div> </div>
<? if ($amount < count($imports)) : ?> <?php if ($amount < count($imports)) : ?>
<div class="dropdown-divider mb-3"></div> <div class="dropdown-divider mb-3"></div>
<?php endif ?> <?php endif ?>
<?php endforeach ?> <?php endforeach ?>

View File

@ -61,17 +61,40 @@ location / {
# add_header X-Frame-Options 'SAMEORIGIN' always; # add_header X-Frame-Options 'SAMEORIGIN' always;
# add_header Referrer-Policy 'no-referrer-when-downgrade' always; # add_header Referrer-Policy 'no-referrer-when-downgrade' always;
# CSP syntax: <host-source> <scheme-source>(http: https: data: mediastream: blob: filesystem:) 'self' 'unsafe-inline' 'unsafe-eval' 'none' # CSP syntax: <host-source> <scheme-source>(http: https: data: mediastream: blob: filesystem:) 'self' 'unsafe-inline' 'unsafe-eval' 'none'
# Content-Security-Policy-Report-Only (report-uri https://site.com/csp/) # Content-Security-Policy-Report-Only (report-uri https://site.com/csp/)
# add_header Content-Security-Policy "default-src 'self'; connect-src 'self'; font-src 'self'; frame-src 'self'; img-src 'self'; manifest-src 'self'; media-src 'self'; object-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; base-uri 'none'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests" always; # add_header Content-Security-Policy "default-src 'self'; connect-src 'self'; font-src 'self'; frame-src 'self'; img-src 'self'; manifest-src 'self'; media-src 'self'; object-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; base-uri 'none'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests" always;
fastcgi_pass backend; fastcgi_pass backend;
include '%sprogdir%/userdata/config/nginx_fastcgi_params.txt'; include '%sprogdir%/userdata/config/nginx_fastcgi_params.txt';
} }
} }
# Service configuration (do not edit!)
# ----------------------------
location /openserver/ {
root 'e:/programs/openserver/modules/system/html';
autoindex off;
index index.php index.html index.htm;
allow all;
allow 127.0.0.0/8;
allow ::1/128;
allow 127.0.0.1;
deny all;
location ~* ^/openserver/.+\.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|webm|svgz?|ttf|ttc|otf|eot|woff2?)$ {
expires 1d;
access_log off;
}
location /openserver/server-status {
stub_status on;
}
location ~ ^/openserver/.*\.php$ {
try_files $fastcgi_script_name =404;
fastcgi_index index.php;
fastcgi_pass backend;
include 'e:/programs/openserver/userdata/config/nginx_fastcgi_params.txt';
}
} }
# ---------------------------- # ----------------------------
# End host config # End host config
# ---------------------------- # ----------------------------
}

View File

@ -164,8 +164,7 @@ main {
transition: 0s; transition: 0s;
} }
.button_red_softer:active, .button_red_softer:is(:active, :focus) {
.button_red_softer:focus {
color: #ddd; color: #ddd;
background-color: #b82d2d; background-color: #b82d2d;
transition: 0s; transition: 0s;
@ -176,6 +175,18 @@ main {
background-color: #fff; background-color: #fff;
} }
.icon_red {
color: #ce2c2c;
}
.icon_red:hover {
color: #da3636;
}
.icon_red:is(:active, :focus) {
color: #b82d2d;
}
:is(.button_white, .button_white_small):is(.hover,:hover) { :is(.button_white, .button_white_small):is(.hover,:hover) {
background-color: #eaebee; background-color: #eaebee;
transition: 0s; transition: 0s;