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
fd5d74d0
Commit
fd5d74d0
authored
Dec 23, 2019
by
Cristian Mauricio Diaz Canales
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prueba Reporteria #1
parent
bc84cc87
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
420 additions
and
1 deletion
+420
-1
config/routes.yaml
config/routes.yaml
+12
-0
src/BackendBundle/Controller/ReportesController.php
src/BackendBundle/Controller/ReportesController.php
+84
-0
src/FrontendBundle/Repository/PluSuscripcionRepository.php
src/FrontendBundle/Repository/PluSuscripcionRepository.php
+15
-0
src/Utilities/CsvReporteGeneral.php
src/Utilities/CsvReporteGeneral.php
+65
-0
src/Utilities/CsvResponse.php
src/Utilities/CsvResponse.php
+47
-0
src/Utilities/Utiles.php
src/Utilities/Utiles.php
+26
-0
templates/backend/includes/sidebar.html.twig
templates/backend/includes/sidebar.html.twig
+15
-1
templates/backend/reportes/index.html.twig
templates/backend/reportes/index.html.twig
+156
-0
No files found.
config/routes.yaml
View file @
fd5d74d0
...
...
@@ -136,6 +136,18 @@ app_link_registracion_externo_confirmar:
controller
:
App\BackendBundle\Controller\PagosExternosController:confirmarPagoExternoKushki
methods
:
[
POST
]
#REPORTES
app_reporte_generar_inicio
:
path
:
reporte/inicio
controller
:
App\BackendBundle\Controller\ReportesController:inicio
methods
:
[
GET
]
app_reporte_generar_documento
:
path
:
reporte/generar
controller
:
App\BackendBundle\Controller\ReportesController:generar
methods
:
[
POST
]
#######
ws_enviarWapPush
:
path
:
app/ws/enviarWapPush/{suscripcionId}/{tipo}
...
...
src/BackendBundle/Controller/ReportesController.php
0 → 100644
View file @
fd5d74d0
<?php
namespace
App\BackendBundle\Controller
;
use
Symfony\Bundle\FrameworkBundle\Controller\AbstractController
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpFoundation\Request
;
use
App\Utilities\CsvResponse
;
use
App\Utilities\CsvReporteGeneral
;
use
App\Entity\PluTag
;
use
App\Entity\PluSuscripcion
;
use
App\Utilities\Utiles
;
class
ReportesController
extends
AbstractController
{
private
$manager
=
null
;
public
function
inicio
(
Request
$request
)
:
Response
{
$log
=
Utiles
::
setLog
(
'App\BackendBundle\Controller::ReportesController::inicio'
,
'app/reportes'
);
$log
->
debug
(
"ingresando a reporteria..."
);
$this
->
manager
=
$this
->
getDoctrine
()
->
getManager
(
'default'
);
$tags
=
$this
->
manager
->
getRepository
(
PluTag
::
class
)
->
getAvailableTags
();
return
$this
->
render
(
'backend/reportes/index.html.twig'
,
array
(
"tags"
=>
$tags
));
}
public
function
generar
(
Request
$request
)
:
Response
{
$log
=
Utiles
::
setLog
(
'App\BackendBundle\Controller::ReportesController::generar'
,
'app/reportes'
);
$log
->
debug
(
"generando reporte..."
);
$this
->
manager
=
$this
->
getDoctrine
()
->
getManager
(
'default'
);
$compania
=
$request
->
get
(
"compania"
,
null
);
$tipoReporte
=
$request
->
get
(
"tipoReporte"
,
null
);
$fInicio
=
$request
->
get
(
"fInicio"
,
null
);
$fFin
=
$request
->
get
(
"fFin"
,
null
);
$log
->
debug
(
"compania
$compania
|tipoReporte
$tipoReporte
| fInicio
$fInicio
| fFin
$fFin
"
);
$conjuntoDatosCsv
=
[];
if
(
$tipoReporte
==
1
)
{
$tituloReporte
=
date
(
"reporte_general_suscripciones_YmdHis.csv"
);
}
$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"
);
}
else
{
$lineaCsv
->
setTipoSuscripcion
(
"Tarjeta de Crédito"
);
}
$lineaCsv
->
setFecha
(
$registro
->
getCreatedAt
()
->
format
(
"Y-m-d H:i:s"
));
$conjuntoDatosCsv
[]
=
$lineaCsv
;
}
else
{
if
(
$compania
==
$registro
->
getLisId
()
->
getLisTag
()
->
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
->
setFecha
(
$registro
->
getCreatedAt
()
->
format
(
"Y-m-d H:i:s"
));
$conjuntoDatosCsv
[]
=
$lineaCsv
;
}
}
endforeach
;
$dataCSV
=
Utiles
::
generarReporteGeneralCSV
(
$conjuntoDatosCsv
);
$response
=
new
CsvResponse
(
$dataCSV
,
200
);
return
$response
;
}
}
src/FrontendBundle/Repository/PluSuscripcionRepository.php
View file @
fd5d74d0
...
...
@@ -53,6 +53,21 @@ class PluSuscripcionRepository extends ServiceEntityRepository {
return
$result
;
}
public
function
getSuscripcionesVigentesReporte
(
$fechaInicio
,
$fechaFin
){
$result
=
$this
->
createQueryBuilder
(
'p'
)
->
andWhere
(
'p.susEliminado = 0'
)
->
andWhere
(
"p.susMsisdn != '' "
)
->
andWhere
(
"p.createdAt >= :fechaInicio"
)
->
andWhere
(
"p.createdAt <= :fechaFin"
)
->
andWhere
(
"p.susVigente = 1"
)
->
andWhere
(
"p.susUltimoTipoXml = 1"
)
->
setParameters
(
array
(
"fechaInicio"
=>
$fechaInicio
.
" 00:00:00"
,
"fechaFin"
=>
$fechaFin
.
" 23:59:59"
))
->
orderBy
(
'p.susId'
,
'ASC'
)
->
getQuery
()
->
getResult
();
return
$result
;
}
public
function
getSuscripcionesVigentes
(
$msisdn
){
$result
=
$this
->
createQueryBuilder
(
'p'
)
->
andWhere
(
'p.susEliminado = 0'
)
...
...
src/Utilities/CsvReporteGeneral.php
0 → 100644
View file @
fd5d74d0
<?php
namespace
App\Utilities
;
/**
* Clase CSV Reporte General Contenidos
*
* @author Cristian Diaz
*/
class
CsvReporteGeneral
{
private
$id
;
private
$lista
;
private
$usuario
;
private
$tipoSuscripcion
;
private
$fecha
;
public
function
getId
()
{
return
$this
->
id
;
}
public
function
getLista
()
{
return
$this
->
lista
;
}
public
function
getUsuario
()
{
return
$this
->
usuario
;
}
public
function
getTipoSuscripcion
()
{
return
$this
->
tipoSuscripcion
;
}
public
function
getFecha
()
{
return
$this
->
fecha
;
}
public
function
setLista
(
$lista
)
{
$this
->
lista
=
$lista
;
}
public
function
setUsuario
(
$usuario
)
{
$this
->
usuario
=
$usuario
;
}
public
function
setTipoSuscripcion
(
$tipoSuscripcion
)
{
$this
->
tipoSuscripcion
=
$tipoSuscripcion
;
}
public
function
setFecha
(
$fecha
)
{
$this
->
fecha
=
$fecha
;
}
}
src/Utilities/CsvResponse.php
0 → 100644
View file @
fd5d74d0
<?php
namespace
App\Utilities
;
use
Symfony\Component\HttpFoundation\Response
;
class
CsvResponse
extends
Response
{
protected
$data
;
protected
$filename
=
'export.csv'
;
public
function
__construct
(
$data
=
array
(),
$status
=
200
,
$headers
=
array
())
{
parent
::
__construct
(
''
,
$status
,
$headers
);
$this
->
setData
(
$data
);
}
public
function
setData
(
array
$data
)
{
$output
=
fopen
(
'php://temp'
,
'r+'
);
foreach
(
$data
as
$row
)
{
fputcsv
(
$output
,
$row
,
';'
);
}
rewind
(
$output
);
$this
->
data
=
''
;
while
(
$line
=
fgets
(
$output
))
{
$this
->
data
.=
$line
;
}
$this
->
data
.=
fgets
(
$output
);
return
$this
->
update
();
}
public
function
getFilename
()
{
return
$this
->
filename
;
}
public
function
setFilename
(
$filename
)
{
$this
->
filename
=
$filename
;
return
$this
->
update
();
}
protected
function
update
()
{
$this
->
headers
->
set
(
'Content-Disposition'
,
sprintf
(
'attachment; filename="%s"'
,
$this
->
filename
));
if
(
!
$this
->
headers
->
has
(
'Content-Type'
))
{
$this
->
headers
->
set
(
'Content-Type'
,
'text/csv'
);
}
return
$this
->
setContent
(
$this
->
data
);
}
}
\ No newline at end of file
src/Utilities/Utiles.php
View file @
fd5d74d0
...
...
@@ -6,6 +6,7 @@ use Monolog\Logger;
use
Monolog\Formatter\LineFormatter
;
use
Monolog\Handler\StreamHandler
;
use
App\Entity\PluParametroConfiguracion
;
use
App\Utilities\CsvReporteGeneral
;
/*
* To change this license header, choose License Headers in Project Properties.
...
...
@@ -230,5 +231,30 @@ class Utiles {
return
0
;
}
}
/**
* Función para generar reporte general
* @param type $datosCsv
* @return type
*/
public
static
function
generarReporteGeneralCSV
(
$datosCsv
)
{
$log
=
Utiles
::
setLog
(
'AppBundle\Lib\Utiles::generarReporteGeneralCSV'
,
'app/reportes'
);
$log
->
debug
(
"generando archivo CSV Reporte General..."
);
$csvLine
=
""
;
$data
=
[];
//cabecera del CSV
$data
[]
=
array
(
'ID'
,
'USUARIO'
,
'LISTA'
,
'TIPO_SUSCRIPCION'
,
'FECHA'
);
foreach
(
$datosCsv
as
$key
=>
$content
){
$csvLine
=
new
CsvReporteGeneral
();
$csvLine
=
$content
;
$data
[]
=
array
(
$csvLine
->
getId
(),
$csvLine
->
getUsuario
(),
$csvLine
->
getLista
(),
$csvLine
->
getTipoSuscripcion
(),
$csvLine
->
getFecha
());
}
return
$data
;
}
}
templates/backend/includes/sidebar.html.twig
View file @
fd5d74d0
...
...
@@ -70,9 +70,23 @@
</div>
</li>#}
<li
class=
"nav-item"
>
<a
class=
"nav-link collapsed"
href=
"#"
data-toggle=
"collapse"
data-target=
"#reportes"
aria-expanded=
"true"
aria-controls=
"reportes"
>
<i
class=
"fas fa-fw fa-print"
></i>
<span>
Reportes
</span>
</a>
<div
id=
"reportes"
class=
"collapse"
aria-labelledby=
"headingReportes"
data-parent=
"#accordionSidebar"
>
<div
class=
"bg-white py-2 collapse-inner rounded"
>
<h6
class=
"collapse-header"
>
Opciones
</h6>
<a
class=
"collapse-item"
href=
"
{{
path
(
'app_reporte_generar_inicio'
)
}}
"
>
Generar Reporte
</a>
</div>
</div>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link collapsed"
href=
"#"
data-toggle=
"collapse"
data-target=
"#utilidades"
aria-expanded=
"true"
aria-controls=
"utilidades"
>
<i
class=
"fas fa-
fw fa-cogw
"
></i>
<i
class=
"fas fa-
toolbox
"
></i>
<span>
Utilidades
</span>
</a>
<div
id=
"utilidades"
class=
"collapse"
aria-labelledby=
"headingUtilities"
data-parent=
"#accordionSidebar"
>
...
...
templates/backend/reportes/index.html.twig
0 → 100644
View file @
fd5d74d0
{%
extends
'base.html.twig'
%}
{%
block
stylesheets
%}
<link
href=
"
{{
asset
(
'backend/bootstrap-daterangepicker/daterangepicker.css'
)
}}
"
rel=
"stylesheet"
/>
{%
endblock
%}
{%
block
title
%}
Reportes
{%
endblock
%}
{%
block
body
%}
<!-- begin breadcrumb -->
<nav
aria-label=
"breadcrumb"
>
<ol
class=
"breadcrumb pull-right"
>
<li><a
href=
"
{{
path
(
'app_reporte_generar_inicio'
)
}}
"
>
Reportes
</a></li>
</ol>
</nav>
<!-- end breadcrumb -->
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<div
class=
"card shadow mb-4"
>
<div
class=
"card-header py-3"
>
<h6
class=
"m-0 font-weight-bold text-primary"
>
Reporte General Suscripciones
</h6>
</div>
<div
class=
"card-body"
>
<form
class=
"form-horizontal"
action=
"/"
method=
"post"
>
{# <input type="hidden" id="_csrf_token" name="_csrf_token" value="{{ csrf_token('listado_register') }}" />#}
<div
class=
"form-group"
>
<label
class=
"col-md-3 control-label"
>
Tag
</label>
<div
class=
"col-md-9"
>
<select
name=
"tags"
id=
"tags"
class=
"dropdown no-arrow"
>
<option
id=
"tag_default"
value=
"all"
selected
>
-- Selecciona un Tag --
</option>
{%
for
tag
in
tags
%}
<option
id=
"tag_
{{
loop.index0
}}
"
value=
"
{{
tag.getTagId
()
}}
"
>
{{
tag.getTagDescripcion
}}
</option>
{%
endfor
%}
</select>
</div>
</div>
<label
class=
"col-md-3 control-label"
>
Fecha
</label>
<div
class=
"input-group"
id=
"default-daterange"
>
<div
class=
"col-md-9"
>
<input
type=
"text"
name=
"reporte1"
id=
"reporte1"
class=
"form-control"
value=
"
{{
"now"
|
date
(
"d-m-Y"
)
}}
-
{{
"now"
|
date
(
"d-m-Y"
)
}}
"
placeholder=
"click para seleccionar rango fechas del reporte..."
/>
</div>
<div
class=
"col-md-3"
>
<span
class=
"input-group-btn"
>
<button
class=
"btn btn-default"
id=
"reporte1Btn"
type=
"button"
><i
class=
"fa fa-calendar"
></i></button>
</span>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-md-3 control-label"
></label>
<div
class=
"col-md-9"
>
<button
id=
"btnCrearReporte"
name=
"btnCrearReporte"
onclick=
"generarReporte(event, 1)"
type=
"submit"
class=
"btn btn-success"
>
Generar
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{%
endblock
%}
{%
block
javascripts
%}
<script
src=
"
{{
asset
(
'backend/bootstrap-daterangepicker/moment.js'
)
}}
"
></script>
<script
src=
"
{{
asset
(
'backend/bootstrap-daterangepicker/daterangepicker.js'
)
}}
"
></script>
<script>
var
reporteDateRangePicker
=
function
()
{
$
(
'
#reporte1
'
).
daterangepicker
({
opens
:
'
right
'
,
format
:
'
DD/MM/YYYY
'
,
separator
:
'
to
'
,
startDate
:
moment
(),
endDate
:
moment
(),
dateLimit
:
{
days
:
720
},
minDate
:
moment
().
subtract
(
3
,
'
month
'
),
maxDate
:
moment
(),
locale
:
{
applyLabel
:
'
Ok
'
,
cancelLabel
:
'
Cancelar
'
,
fromLabel
:
'
Desde
'
,
toLabel
:
'
Hasta
'
,
customRangeLabel
:
'
Custom
'
,
daysOfWeek
:
[
'
Do
'
,
'
Lu
'
,
'
Ma
'
,
'
Mi
'
,
'
Ju
'
,
'
Vi
'
,
'
Sa
'
],
monthNames
:
[
'
Enero
'
,
'
Febrero
'
,
'
Marzo
'
,
'
Abril
'
,
'
Mayo
'
,
'
Junio
'
,
'
Julio
'
,
'
Agosto
'
,
'
Septiembre
'
,
'
Octubre
'
,
'
Noviembre
'
,
'
Diciembre
'
],
firstDay
:
1
}
},
function
(
start
,
end
)
{
$
(
'
#reporte1
'
).
val
(
start
.
format
(
'
DD/MM/YYYY
'
)
+
'
-
'
+
end
.
format
(
'
DD/MM/YYYY
'
));
});
};
function
generarReporte
(
e
,
tipoReporte
)
{
e
.
preventDefault
();
var
filtro
=
$
(
"
#tags
"
).
val
();
var
url
=
"
{{
path
(
'app_reporte_generar_documento'
)
}}
"
;
var
formData
=
new
FormData
();
$
(
"
#btnCrearReporte
"
).
addClass
(
'
disabled
'
);
$
(
"
#btnCrearReporte
"
).
button
(
"
Buscando...
"
);
if
(
tipoReporte
==
1
)
{
formData
.
append
(
"
compania
"
,
filtro
);
formData
.
append
(
"
tipoReporte
"
,
tipoReporte
);
formData
.
append
(
"
fechaInicio
"
,
$
(
'
#reporte
'
+
tipoReporte
).
data
(
'
daterangepicker
'
).
startDate
.
format
(
'
YYYY-MM-DD
'
));
formData
.
append
(
"
fechaFin
"
,
$
(
'
#reporte
'
+
tipoReporte
).
data
(
'
daterangepicker
'
).
endDate
.
format
(
'
YYYY-MM-DD
'
));
$
.
ajax
({
type
:
"
POST
"
,
url
:
url
,
data
:
formData
,
async
:
true
,
cache
:
false
,
contentType
:
false
,
processData
:
false
,
timeout
:
60000
,
statusCode
:
{
400
:
function
()
{
},
500
:
function
()
{
}
},
beforeSend
:
function
()
{
},
success
:
function
()
{
},
complete
:
function
()
{
$
(
"
#btnCrearReporte
"
).
button
(
'
reset
'
);
$
(
"
#btnCrearReporte
"
).
removeClass
(
'
disabled
'
);
}
});
}
}
/*Metodo para abrir reporte, haciendo click en el icono del calendario*/
$
(
'
#reporte1Btn
'
).
click
(
function
()
{
event
.
preventDefault
();
$
(
"
#reporte1
"
).
click
();
});
var
FormPlugins
=
function
()
{
"
use strict
"
;
return
{
init
:
function
()
{
reporteDateRangePicker
();
}
};
}();
</script>
<script>
$
(
document
).
ready
(
function
()
{
FormPlugins
.
init
();
});
</script>
{%
endblock
%}
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