Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
musica_listas_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cristian Mauricio Diaz Canales
musica_listas_backend
Commits
e701966b
Commit
e701966b
authored
Dec 24, 2019
by
Cristian Mauricio Diaz Canales
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prueba Reporteria #3- Nuevo reporte suscripciones nuevas
parent
ffd356b8
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
316 additions
and
48 deletions
+316
-48
src/BackendBundle/Controller/ReportesController.php
src/BackendBundle/Controller/ReportesController.php
+67
-28
src/FrontendBundle/Repository/PluSuscripcionRepository.php
src/FrontendBundle/Repository/PluSuscripcionRepository.php
+16
-1
src/Utilities/CsvReporteGeneral.php
src/Utilities/CsvReporteGeneral.php
+16
-6
src/Utilities/CsvReporteNuevaSuscripciones.php
src/Utilities/CsvReporteNuevaSuscripciones.php
+68
-0
src/Utilities/Utiles.php
src/Utilities/Utiles.php
+25
-2
templates/backend/reportes/index.html.twig
templates/backend/reportes/index.html.twig
+124
-11
No files found.
src/BackendBundle/Controller/ReportesController.php
View file @
e701966b
...
...
@@ -10,6 +10,7 @@ use Symfony\Component\HttpFoundation\Request;
use
Symfony\Component\HttpFoundation\File\File
;
use
App\Utilities\CsvResponse
;
use
App\Utilities\CsvReporteGeneral
;
use
App\Utilities\CsvReporteNuevaSuscripciones
;
use
App\Entity\PluTag
;
use
App\Entity\PluSuscripcion
;
use
App\Utilities\Utiles
;
...
...
@@ -41,45 +42,84 @@ class ReportesController extends AbstractController {
$conjuntoDatosCsv
=
[];
if
(
$tipoReporte
==
1
)
{
$tituloReporte
=
date
(
"reporte_general_suscripciones_YmdHis.csv"
);
}
$registros
=
$this
->
manager
->
getRepository
(
PluSuscripcion
::
class
)
->
getSuscripcionesVigentesReporte
(
$fInicio
,
$fFin
);
$registros
=
$this
->
manager
->
getRepository
(
PluSuscripcion
::
class
)
->
getSuscripcionesVigentesReporte
(
$fInicio
,
$fFin
);
foreach
(
$registros
as
$index
=>
$registro
)
:
$lineaCsv
=
new
CsvReporteGeneral
();
if
(
$compania
==
"all"
)
{
$lineaCsv
->
setId
(
$registro
->
getSusId
());
$lineaCsv
->
setUsuario
(
$registro
->
getSusMsisdn
());
$lineaCsv
->
setLista
(
$registro
->
getLisId
()
->
getLisNombre
());
if
(
$registro
->
getSusTipoSuscripcion
()
==
1
)
{
$lineaCsv
->
setTipoSuscripcion
(
"Facturación Entel"
);
foreach
(
$registros
as
$index
=>
$registro
)
:
$lineaCsv
=
new
CsvReporteGeneral
();
if
(
$compania
==
"all"
)
{
$lineaCsv
->
setId
(
$registro
->
getSusId
());
$lineaCsv
->
setUsuario
(
$registro
->
getSusMsisdn
());
$lineaCsv
->
setLista
(
$registro
->
getLisId
()
->
getLisNombre
());
if
(
$registro
->
getSusTipoSuscripcion
()
==
1
)
{
$lineaCsv
->
setTipoSuscripcion
(
"Facturación Entel"
);
}
else
{
$lineaCsv
->
setTipoSuscripcion
(
"Tarjeta de Crédito"
);
}
$lineaCsv
->
setFechaCreacion
(
$registro
->
getCreatedAt
()
->
format
(
"Y-m-d H:i:s"
));
$lineaCsv
->
setFechaRenovacion
(
$registro
->
getUpdatedAt
()
->
format
(
"Y-m-d H:i:s"
));
$conjuntoDatosCsv
[]
=
$lineaCsv
;
}
else
{
$lineaCsv
->
setTipoSuscripcion
(
"Tarjeta de Crédito"
);
if
(
$compania
==
$registro
->
getLisId
()
->
getTag
()
->
getTagId
())
{
$lineaCsv
->
setId
(
$registro
->
getSusId
());
$lineaCsv
->
setUsuario
(
$registro
->
getSusMsisdn
());
$lineaCsv
->
setLista
(
$registro
->
getLisId
()
->
getLisNombre
());
if
(
$registro
->
getSusTipoSuscripcion
()
==
1
)
{
$lineaCsv
->
setTipoSuscripcion
(
"Facturación Entel"
);
}
else
{
$lineaCsv
->
setTipoSuscripcion
(
"Tarjeta de Crédito"
);
}
$lineaCsv
->
setFechaCreacion
(
$registro
->
getCreatedAt
()
->
format
(
"Y-m-d H:i:s"
));
$lineaCsv
->
setFechaRenovacion
(
$registro
->
getUpdatedAt
()
->
format
(
"Y-m-d H:i:s"
));
$conjuntoDatosCsv
[]
=
$lineaCsv
;
}
}
$lineaCsv
->
setFecha
(
$registro
->
getCreatedAt
()
->
format
(
"Y-m-d H:i:s"
));
$conjuntoDatosCsv
[]
=
$lineaCsv
;
}
else
{
if
(
$compania
==
$registro
->
getLisId
()
->
getTag
()
->
getTagId
())
{
endforeach
;
$dataCSV
=
Utiles
::
generarReporteGeneralCSV
(
$conjuntoDatosCsv
);
}
else
if
(
$tipoReporte
==
2
){
$registros
=
$this
->
manager
->
getRepository
(
PluSuscripcion
::
class
)
->
getSuscripcionesNuevasReporte
(
$fInicio
,
$fFin
);
foreach
(
$registros
as
$index
=>
$registro
)
:
$lineaCsv
=
new
CsvReporteNuevaSuscripciones
();
if
(
$compania
==
"all"
)
{
$lineaCsv
->
setId
(
$registro
->
getSusId
());
$lineaCsv
->
setUsuario
(
$registro
->
getSusMsisdn
());
$lineaCsv
->
setLista
(
$registro
->
getLisId
()
->
getLisNombre
());
if
(
$registro
->
getSusTipoSuscripcion
()
==
1
)
{
$lineaCsv
->
setTipoSuscripcion
(
"Facturación Entel"
);
}
else
{
$lineaCsv
->
setTipoSuscripcion
(
"Tarjeta de Crédito"
);
}
$lineaCsv
->
setFecha
(
$registro
->
getCreatedAt
()
->
format
(
"Y-m-d H:i:s"
));
$lineaCsv
->
setFechaCreacion
(
$registro
->
getCreatedAt
()
->
format
(
"Y-m-d H:i:s"
));
$conjuntoDatosCsv
[]
=
$lineaCsv
;
}
else
{
if
(
$compania
==
$registro
->
getLisId
()
->
getTag
()
->
getTagId
())
{
$lineaCsv
->
setId
(
$registro
->
getSusId
());
$lineaCsv
->
setUsuario
(
$registro
->
getSusMsisdn
());
$lineaCsv
->
setLista
(
$registro
->
getLisId
()
->
getLisNombre
());
if
(
$registro
->
getSusTipoSuscripcion
()
==
1
)
{
$lineaCsv
->
setTipoSuscripcion
(
"Facturación Entel"
);
}
else
{
$lineaCsv
->
setTipoSuscripcion
(
"Tarjeta de Crédito"
);
}
$lineaCsv
->
setFechaCreacion
(
$registro
->
getCreatedAt
()
->
format
(
"Y-m-d H:i:s"
));
$conjuntoDatosCsv
[]
=
$lineaCsv
;
}
}
}
endforeach
;
endforeach
;
$dataCSV
=
Utiles
::
generarReporteGeneralCSV
(
$conjuntoDatosCsv
);
$dataCSV
=
Utiles
::
generarReporteNuevaSuscripcionesCSV
(
$conjuntoDatosCsv
);
}
//generacion archivo
$file
=
fopen
(
"php://output"
,
'w'
);
foreach
(
$dataCSV
as
$fields
)
{
fputcsv
(
$file
,
$fields
);
...
...
@@ -89,18 +129,17 @@ class ReportesController extends AbstractController {
$data
.=
$line
;
}
$data
.=
fgets
(
$file
);
$response
=
new
Response
(
$data
,
200
);
$disposition
=
HeaderUtils
::
makeDisposition
(
HeaderUtils
::
DISPOSITION_INLINE
,
'test.csv'
HeaderUtils
::
DISPOSITION_INLINE
,
'test.csv'
);
$response
->
headers
->
set
(
'Content-Disposition'
,
$disposition
);
$response
->
headers
->
set
(
'Content-Type'
,
'text/csv'
);
//echo $response;
return
$response
;
}
...
...
src/FrontendBundle/Repository/PluSuscripcionRepository.php
View file @
e701966b
...
...
@@ -53,7 +53,8 @@ class PluSuscripcionRepository extends ServiceEntityRepository {
return
$result
;
}
public
function
getSuscripcionesVigentesReporte
(
$fechaInicio
,
$fechaFin
){
/*Suscripciones que se hayan creado en las fechas indicadas*/
public
function
getSuscripcionesNuevasReporte
(
$fechaInicio
,
$fechaFin
){
$result
=
$this
->
createQueryBuilder
(
'p'
)
->
andWhere
(
'p.susEliminado = 0'
)
->
andWhere
(
"p.susMsisdn != '' "
)
...
...
@@ -66,6 +67,20 @@ class PluSuscripcionRepository extends ServiceEntityRepository {
->
getResult
();
return
$result
;
}
/*Suscripciones vigentes en las fechas indicadas*/
public
function
getSuscripcionesVigentesReporte
(
$fechaInicio
,
$fechaFin
){
$result
=
$this
->
createQueryBuilder
(
'p'
)
->
andWhere
(
'p.susEliminado = 0'
)
->
andWhere
(
"p.susMsisdn != '' "
)
->
andWhere
(
"p.updatedAt >= :fechaInicio"
)
->
andWhere
(
"p.updatedAt <= :fechaFin"
)
->
andWhere
(
"p.susVigente = 1"
)
->
andWhere
(
"p.susUltimoTipoXml = 1"
)
->
setParameters
(
array
(
"fechaInicio"
=>
$fechaInicio
.
" 00:00:00"
,
"fechaFin"
=>
$fechaFin
.
" 23:59:59"
))
->
getQuery
()
->
getResult
();
return
$result
;
}
public
function
getSuscripcionesVigentes
(
$msisdn
){
$result
=
$this
->
createQueryBuilder
(
'p'
)
...
...
src/Utilities/CsvReporteGeneral.php
View file @
e701966b
...
...
@@ -13,7 +13,8 @@ class CsvReporteGeneral {
private
$lista
;
private
$usuario
;
private
$tipoSuscripcion
;
private
$fecha
;
private
$fechaCreacion
;
private
$fechaRenovacion
;
public
function
getId
()
{
return
$this
->
id
;
...
...
@@ -35,9 +36,6 @@ class CsvReporteGeneral {
return
$this
->
tipoSuscripcion
;
}
public
function
getFecha
()
{
return
$this
->
fecha
;
}
public
function
setLista
(
$lista
)
{
$this
->
lista
=
$lista
;
...
...
@@ -51,8 +49,20 @@ class CsvReporteGeneral {
$this
->
tipoSuscripcion
=
$tipoSuscripcion
;
}
public
function
setFecha
(
$fecha
)
{
$this
->
fecha
=
$fecha
;
public
function
getFechaCreacion
()
{
return
$this
->
fechaCreacion
;
}
public
function
getFechaRenovacion
()
{
return
$this
->
fechaRenovacion
;
}
public
function
setFechaCreacion
(
$fechaCreacion
)
{
$this
->
fechaCreacion
=
$fechaCreacion
;
}
public
function
setFechaRenovacion
(
$fechaRenovacion
)
{
$this
->
fechaRenovacion
=
$fechaRenovacion
;
}
...
...
src/Utilities/CsvReporteNuevaSuscripciones.php
0 → 100644
View file @
e701966b
<?php
namespace
App\Utilities
;
/**
* Clase CSV Reporte General Contenidos
*
* @author Cristian Diaz
*/
class
CsvReporteNuevaSuscripciones
{
private
$id
;
private
$lista
;
private
$usuario
;
private
$tipoSuscripcion
;
private
$fechaCreacion
;
public
function
getId
()
{
return
$this
->
id
;
}
public
function
setId
(
$id
)
{
$this
->
id
=
$id
;
}
public
function
getLista
()
{
return
$this
->
lista
;
}
public
function
getUsuario
()
{
return
$this
->
usuario
;
}
public
function
getTipoSuscripcion
()
{
return
$this
->
tipoSuscripcion
;
}
public
function
setLista
(
$lista
)
{
$this
->
lista
=
$lista
;
}
public
function
setUsuario
(
$usuario
)
{
$this
->
usuario
=
$usuario
;
}
public
function
setTipoSuscripcion
(
$tipoSuscripcion
)
{
$this
->
tipoSuscripcion
=
$tipoSuscripcion
;
}
public
function
getFechaCreacion
()
{
return
$this
->
fechaCreacion
;
}
public
function
setFechaCreacion
(
$fechaCreacion
)
{
$this
->
fechaCreacion
=
$fechaCreacion
;
}
}
src/Utilities/Utiles.php
View file @
e701966b
...
...
@@ -244,12 +244,35 @@ class Utiles {
$data
=
[];
//cabecera del CSV
$data
[]
=
array
(
'ID'
,
'USUARIO'
,
'LISTA'
,
'TIPO_SUSCRIPCION'
,
'FECHA'
);
$data
[]
=
array
(
'ID'
,
'USUARIO'
,
'LISTA'
,
'TIPO_SUSCRIPCION'
,
'FECHA
_CREACION'
,
'FECHA_RENOVACION
'
);
foreach
(
$datosCsv
as
$key
=>
$content
){
$csvLine
=
new
CsvReporteGeneral
();
$csvLine
=
$content
;
$data
[]
=
array
(
$csvLine
->
getId
(),
$csvLine
->
getUsuario
(),
$csvLine
->
getLista
(),
$csvLine
->
getTipoSuscripcion
(),
$csvLine
->
getFecha
());
$data
[]
=
array
(
$csvLine
->
getId
(),
$csvLine
->
getUsuario
(),
$csvLine
->
getLista
(),
$csvLine
->
getTipoSuscripcion
(),
$csvLine
->
getFechaCreacion
(),
$csvLine
->
getFechaRenovacion
());
}
return
$data
;
}
/**
* Función para generar reporte de nuevas suscripciones
* @param type $datosCsv
* @return type
*/
public
static
function
generarReporteNuevaSuscripcionesCSV
(
$datosCsv
)
{
$log
=
Utiles
::
setLog
(
'AppBundle\Lib\Utiles::generarReporteNuevaSuscripcionesCSV'
,
'app/reportes'
);
$log
->
debug
(
"generando archivo CSV Reporte Nueva Suscripciones..."
);
$csvLine
=
""
;
$data
=
[];
//cabecera del CSV
$data
[]
=
array
(
'ID'
,
'USUARIO'
,
'LISTA'
,
'TIPO_SUSCRIPCION'
,
'FECHA_CREACION'
);
foreach
(
$datosCsv
as
$key
=>
$content
){
$csvLine
=
new
CsvReporteGeneral
();
$csvLine
=
$content
;
$data
[]
=
array
(
$csvLine
->
getId
(),
$csvLine
->
getUsuario
(),
$csvLine
->
getLista
(),
$csvLine
->
getTipoSuscripcion
(),
$csvLine
->
getFechaCreacion
());
}
return
$data
;
...
...
templates/backend/reportes/index.html.twig
View file @
e701966b
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment