diff --git a/mirzaev/ebala/system/models/worker.php b/mirzaev/ebala/system/models/worker.php index 9e976d7..9e152cb 100755 --- a/mirzaev/ebala/system/models/worker.php +++ b/mirzaev/ebala/system/models/worker.php @@ -90,6 +90,45 @@ final class worker extends core return null; } + /** + * Generate identifier + * + * @param array &$errors Реестр ошибок + * + * @return int Идентиикатор (свободный) + */ + public static function id(array &$errors = []): int + { + try { + if (collection::init(static::$arangodb->session, static::COLLECTION)) { + // Инициализирована коллекция + + // Exit (success) + return collection::search( + static::$arangodb->session, + sprintf( + <<<'AQL' + RETURN MAX((FOR d in %s RETURN +d.id)) + AQL, + $collection ?? static::COLLECTION + ) + ); + } else throw new exception('Не удалось инициализировать коллекцию'); + } catch (exception $e) { + // Запись в реестр ошибок + $errors[] = [ + 'text' => $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'stack' => $e->getTrace() + ]; + } + + // Exit (fail) + return 0; + } + + /** * Записать * diff --git a/mirzaev/ebala/system/views/elements/workers.html b/mirzaev/ebala/system/views/elements/workers.html index b54635f..a76559a 100644 --- a/mirzaev/ebala/system/views/elements/workers.html +++ b/mirzaev/ebala/system/views/elements/workers.html @@ -2,37 +2,46 @@ {% for row in rows %}
- {{ + {{ row.account._key }} - {{ + {{ row.worker.id }} {% + title="{% if row.worker.name.first is not empty %}{{ row.worker.name.first }}{% endif %}{% if row.worker.name.second is not empty %} {{ row.worker.name.second }}{% endif %}{% if row.worker.name.last is not empty %} {{ row.worker.name.last }}{% endif %}{% if row.worker.birth is not empty %} {{ row.worker.birth|date('d.m.Y') }}{% endif %}" + onclick="navigator.clipboard.writeText('{% if row.worker.name.first is not empty %}{{ row.worker.name.first }}{% endif %}{% if row.worker.name.second is not empty %} {{ row.worker.name.second }}{% endif %}{% if row.worker.name.last is not empty %} {{ row.worker.name.last }}{% endif %}{% if row.worker.birth is not empty %} {{ row.worker.birth|date('d.m.Y') }}{% endif %}')">{% if row.worker.name.first is not empty %}{{ row.worker.name.first|slice(0, 1)|upper }}.{% endif %}{% if row.worker.name.last is not empty %} {{ row.worker.name.last|slice(0, 1)|upper }}.{% endif %}{% if row.worker.name.second is not empty %} {{ row.worker.name.second }}{% endif %} - {{ row.worker.number|storaged_number_to_readable }} - {{ row.worker.mail }} + {{ + row.worker.number|storaged_number_to_readable }} + {{ + row.worker.mail }} {% if row.worker.city is not empty and row.worker.district is not + onclick="navigator.clipboard.writeText('{{ row.worker.city ~ ' ' ~ row.worker.district ~ ' ' ~ row.worker.address }}')">{% + if row.worker.city is not empty and row.worker.district is not empty and row.worker.district is not null %}{{ row.worker.city|slice(0,4) ~ '. ' ~ row.worker.district|slice(0,3) ~ '. ' ~ row.worker.address }}{% else %}{{ row.worker.city ~ ' ' ~ row.worker.district ~ ' ' ~ row.worker.address }}{% endif %} {{ (row.worker.passport ~ ', ' ~ row.worker.issued|date('d.m.Y') ~ ', ' ~ row.worker.department.number ~ ', ' ~ + onclick="navigator.clipboard.writeText('{{ (row.worker.passport ~ ', ' ~ row.worker.issued|date('d.m.Y') ~ ', ' ~ row.worker.department.number ~ ', ' ~ row.worker.department.address)|trim(', ') }}')">{{ + (row.worker.passport ~ ', ' ~ row.worker.issued|date('d.m.Y') ~ ', ' ~ row.worker.department.number ~ ', ' ~ row.worker.department.address)|trim(', ') }} - {{ row.worker.tax }} + {{ row.worker.tax }} {% if - row.worker.requisites is not empty and row.worker.payment is not empty %}{{ - row.worker.requisites|storaged_requisites_preview }} ({{ - row.worker.payment }}){% else %}{{ row.worker.payment }}{% endif %} + title="{% if row.worker.requisites is not empty and row.worker.payment is not empty %}{{ row.worker.requisites }} ({{ row.worker.payment }}){% else %}{{ row.worker.requisites }} {{ row.worker.payment }}{% endif %}" + onclick="navigator.clipboard.writeText('{{ row.worker.requisites|storaged_requisites_to_card }}')"> + {% if row.worker.requisites is not empty and row.worker.payment is not empty %} + {{ row.worker.requisites|storaged_requisites_preview }} ({{ row.worker.payment }}) + {% else %} + {{ row.worker.requisites }} {{ row.worker.payment }} + {% endif %} + {{ row.account.commentary }}