56 lines
1.8 KiB
PHP
56 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\CRM\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
use App\Modules\CRM\Models\DealModel;
|
|
use App\Modules\CRM\Models\DealStageModel;
|
|
use App\Modules\CRM\Models\ContactModel;
|
|
use App\Modules\Clients\Models\ClientModel;
|
|
|
|
class DashboardController extends BaseController
|
|
{
|
|
protected DealModel $dealModel;
|
|
protected DealStageModel $stageModel;
|
|
protected ContactModel $contactModel;
|
|
protected ClientModel $clientModel;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->dealModel = new DealModel();
|
|
$this->stageModel = new DealStageModel();
|
|
$this->contactModel = new ContactModel();
|
|
$this->clientModel = new ClientModel();
|
|
}
|
|
|
|
/**
|
|
* Главная страница CRM - дашборд
|
|
*/
|
|
public function index()
|
|
{
|
|
$organizationId = $this->requireActiveOrg();
|
|
|
|
// Статистика по сделкам
|
|
$stats = $this->dealModel->getDealStats($organizationId);
|
|
|
|
// Количество контактов
|
|
$contactsCount = $this->contactModel->where('organization_id', $organizationId)->countAllResults();
|
|
|
|
// Количество клиентов
|
|
$clientsCount = $this->clientModel->where('organization_id', $organizationId)->countAllResults();
|
|
|
|
// Количество этапов
|
|
$stagesCount = $this->stageModel->where('organization_id', $organizationId)->countAllResults();
|
|
|
|
return $this->renderTwig('@CRM/dashboard', [
|
|
'title' => 'CRM - Панель управления',
|
|
'stats' => $stats,
|
|
'counts' => [
|
|
'contacts' => $contactsCount,
|
|
'clients' => $clientsCount,
|
|
'stages' => $stagesCount,
|
|
],
|
|
]);
|
|
}
|
|
}
|