Skip to content

Commit aa02859

Browse files
author
Daniel Fernández Giménez
committed
Añadir soporte para el plugin CRM en el informe de contactos
1 parent e237530 commit aa02859

3 files changed

Lines changed: 70 additions & 59 deletions

File tree

Controller/ReportContacts.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<?php
2+
23
namespace FacturaScripts\Plugins\Informes\Controller;
34

45
use FacturaScripts\Core\Base\Controller;
6+
use FacturaScripts\Core\Plugins;
57
use FacturaScripts\Core\Tools;
68
use FacturaScripts\Plugins\Informes\Model\Report;
79
use FacturaScripts\Plugins\Informes\Lib\Informes\ContactsReport;
8-
use FacturaScripts\Dinamic\Model\Pais;
910

1011
class ReportContacts extends Controller
1112
{
13+
public $isEnabledCRM = false;
14+
1215
public $charts = [];
1316
public $totals = [];
1417
public $countries = [];
@@ -32,6 +35,7 @@ public function getPageData(): array
3235
public function privateCore(&$response, $user, $permissions)
3336
{
3437
parent::privateCore($response, $user, $permissions);
38+
$this->isEnabledCRM = Plugins::isEnabled('CRM');
3539

3640
// cargar datos
3741
$this->loadData();
@@ -41,12 +45,15 @@ public function privateCore(&$response, $user, $permissions)
4145
// charts
4246
$this->loadNewContactsByMonth();
4347
$this->loadNewContactsByYear();
44-
$this->loadSourcesChart();
45-
$this->loadInterestsChart();
4648

47-
// period breakdowns and comparison for view tables
48-
$this->sources_periods = ContactsReport::sourcesAnalysis();
49-
$this->interests_periods = ContactsReport::interestsAnalysis();
49+
if ($this->isEnabledCRM) {
50+
$this->loadSourcesChart();
51+
$this->loadInterestsChart();
52+
53+
$this->sources_periods = ContactsReport::sourcesAnalysis();
54+
$this->interests_periods = ContactsReport::interestsAnalysis();
55+
}
56+
5057
$this->comparison = ContactsReport::comparison12vsPrevious12();
5158
$this->months_history = ContactsReport::historyByMonths(12);
5259
$this->years_history = ContactsReport::historyByYears();

View/ReportContacts.html.twig

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -115,70 +115,74 @@
115115
</div>
116116
</div>
117117
</div>
118-
<div class="col-lg-4 d-flex">
119-
<div class="card shadow mb-4 w-100 h-100">
120-
<div class="card-header py-3 text-center">
121-
<h6 class="m-0 font-weight-bold text-primary">
122-
<i class="fa-solid fa-layer-group me-1"></i>
123-
{{ trans('sources') }}
124-
</h6>
125-
</div>
126-
<div class="card-body">
127-
{{ fsc.charts.sources.getChart().render({'height':320}) | raw }}
118+
{% if fsc.isEnabledCRM %}
119+
<div class="col-lg-4 d-flex">
120+
<div class="card shadow mb-4 w-100 h-100">
121+
<div class="card-header py-3 text-center">
122+
<h6 class="m-0 font-weight-bold text-primary">
123+
<i class="fa-solid fa-layer-group me-1"></i>
124+
{{ trans('sources') }}
125+
</h6>
126+
</div>
127+
<div class="card-body">
128+
{{ fsc.charts.sources.getChart().render({'height':320}) | raw }}
128129

129-
{# Period breakdowns for sources (30/90/365) #}
130-
<div class="mt-3">
131-
<h6>{{ trans('r-contactos-sources-periods') }}</h6>
132-
<div class="row">
133-
{% for days, rows in fsc.sources_periods %}
134-
<div class="col-12 col-md-4">
135-
<div class="small-card p-2">
136-
<strong>{{ days }} {{ trans('days') }}</strong>
137-
<ul class="list-unstyled mb-0">
138-
{% for r in rows|slice(0,8) %}
139-
<li>{{ r.nombre|default('-') }} - <span class="badge bg-light text-dark">{{ r.total }}</span></li>
140-
{% endfor %}
141-
</ul>
130+
{# Period breakdowns for sources (30/90/365) #}
131+
<div class="mt-3">
132+
<h6>{{ trans('r-contactos-sources-periods') }}</h6>
133+
<div class="row">
134+
{% for days, rows in fsc.sources_periods %}
135+
<div class="col-12 col-md-4">
136+
<div class="small-card p-2">
137+
<strong>{{ days }} {{ trans('days') }}</strong>
138+
<ul class="list-unstyled mb-0">
139+
{% for r in rows|slice(0,8) %}
140+
<li>{{ r.nombre|default('-') }} - <span class="badge bg-light text-dark">{{ r.total }}</span></li>
141+
{% endfor %}
142+
</ul>
143+
</div>
142144
</div>
143-
</div>
144-
{% endfor %}
145+
{% endfor %}
146+
</div>
145147
</div>
146148
</div>
147149
</div>
148150
</div>
149-
</div>
150-
<div class="col-lg-4 d-flex">
151-
<div class="card shadow mb-4 w-100 h-100">
152-
<div class="card-header py-3 text-center">
153-
<h6 class="m-0 font-weight-bold text-primary">
154-
<i class="fa-solid fa-tags me-1"></i>
155-
{{ trans('interests') }}
156-
</h6>
157-
</div>
158-
<div class="card-body">
159-
{{ fsc.charts.interests.getChart().render({'height':320}) | raw }}
151+
{% endif %}
152+
{% if fsc.isEnabledCRM %}
153+
<div class="col-lg-4 d-flex">
154+
<div class="card shadow mb-4 w-100 h-100">
155+
<div class="card-header py-3 text-center">
156+
<h6 class="m-0 font-weight-bold text-primary">
157+
<i class="fa-solid fa-tags me-1"></i>
158+
{{ trans('interests') }}
159+
</h6>
160+
</div>
161+
<div class="card-body">
162+
{{ fsc.charts.interests.getChart().render({'height':320}) | raw }}
160163

161-
{# Period breakdowns for interests (30/90/365) #}
162-
<div class="mt-3">
163-
<h6>{{ trans('r-contactos-interests-periods') }}</h6>
164-
<div class="row">
165-
{% for days, rows in fsc.interests_periods %}
166-
<div class="col-12 col-md-4">
167-
<div class="small-card p-2">
168-
<strong>{{ days }} {{ trans('days') }}</strong>
169-
<ul class="list-unstyled mb-0">
170-
{% for r in rows|slice(0,8) %}
171-
<li>{{ r.nombre|default('-') }} - <span class="badge bg-light text-dark">{{ r.total }}</span></li>
172-
{% endfor %}
173-
</ul>
164+
{# Period breakdowns for interests (30/90/365) #}
165+
<div class="mt-3">
166+
<h6>{{ trans('r-contactos-interests-periods') }}</h6>
167+
<div class="row">
168+
{% for days, rows in fsc.interests_periods %}
169+
<div class="col-12 col-md-4">
170+
<div class="small-card p-2">
171+
<strong>{{ days }} {{ trans('days') }}</strong>
172+
<ul class="list-unstyled mb-0">
173+
{% for r in rows|slice(0,8) %}
174+
<li>{{ r.nombre|default('-') }} - <span class="badge bg-light text-dark">{{ r.total }}</span></li>
175+
{% endfor %}
176+
</ul>
177+
</div>
174178
</div>
175-
</div>
176-
{% endfor %}
179+
{% endfor %}
180+
</div>
177181
</div>
178182
</div>
179183
</div>
180184
</div>
181-
</div>
185+
{% endif %}
182186
</div>
183187

184188
</div>

facturascripts.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ name = 'Informes'
22
description = 'Muestras informes de resultados anual, tesorería y desgloses de compras y ventas.'
33
version = 3.9
44
min_version = 2025.6
5-
compatible = 'Modelo303,Modelo115,Modelo111'
5+
compatible = 'Modelo303,Modelo115,Modelo111,CRM'

0 commit comments

Comments
 (0)