add CRM module start

This commit is contained in:
root
2026-01-15 07:09:36 +03:00
parent b14f293a45
commit b810a17649
40 changed files with 3807 additions and 14 deletions
+41
View File
@@ -0,0 +1,41 @@
<?php
/**
* Конвертирует HEX цвет в RGBA
*/
if (!function_exists('hex2rgba')) {
function hex2rgba(string $color, float $opacity = 1): string
{
$color = ltrim($color, '#');
if (strlen($color) === 3) {
$color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2];
}
$hex = [hexdec($color[0] . $color[1]), hexdec($color[2] . $color[3]), hexdec($color[4] . $color[5])];
return 'rgba(' . implode(', ', $hex) . ', ' . $opacity . ')';
}
}
/**
* Форматировать сумму в валюте
*/
if (!function_exists('format_currency')) {
function format_currency(float $amount, string $currency = 'RUB'): string
{
$locale = locale_get_default() ?: 'ru_RU';
$formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
return $formatter->formatCurrency($amount, $currency);
}
}
/**
* Получить текущую организацию
*/
function current_organization_id(): ?int
{
$session = session();
$orgId = $session->get('active_org_id');
return $orgId ? (int) $orgId : null;
}