/src/Core/MainBundle/Controller/DefaultController.php
PHP | 941 lines | 746 code | 54 blank | 141 comment | 78 complexity | 0e32ec97d7d14e8c0f7b669e8f0fb96c MD5 | raw file
Possible License(s): BSD-3-Clause, BSD-2-Clause, Apache-2.0, LGPL-2.1, CC-BY-3.0, LGPL-3.0
- <?php
- namespace Core\MainBundle\Controller;
- use Symfony\Bundle\FrameworkBundle\Controller\Controller;
- use Symfony\Component\HttpFoundation\Request;
- use Ps\PdfBundle\Annotation\Pdf;
- use Core\MainBundle\Entity\ReportTicketStatus;
- use Core\MainBundle\Entity\GlpiTickets;
- use Symfony\Component\HttpFoundation\Session\Session;
- /**
- * Clase principal encargada de ejecutar los reportes
- * y mostrarlos en la pagina web
- * @package ReporteCore
- * @subpackage Controllers
- */
- class DefaultController extends Controller
- {
- public function valorateListAction(){
- $request = Request::createFromGlobals();
- $rs = $this->get('report_service');
- $op = $this->getDatesPost();
- $title = "Reporte de Valoracion de atención".$op['label'];
- $data = $rs->getValoratesReport($op);
- # generar resumen
- $sum = 0;
- $tot = 0;
- foreach ($data[0]['campos'] as $row) {
- # code...
- // var_dump($row);
- $sum += $row['cantidad'];
- $tot += $row['ranking']*$row['cantidad'];
- }
- if($sum and $tot)
- $valProm = round(($tot/$sum),0);
- else
- $valProm = 0;
- //var_dump($data);
- if($this->getRequest()->isXmlHttpRequest()){
- $ajax='Ajax';
- return $this->render(
- 'CoreMainBundle:Default:valorateListAjax.html.twig',
- array('title'=>$title
- ,'datos'=>$data
- ,'del'=> $op['del']
- ,'al' => $op['al']
- ,'valProm'=>$valProm
- )
- );
- }
- return $this->render(
- 'CoreMainBundle:Default:valorateList.html.twig',
- array('title'=>$title
- ,'datos'=>$data
- ,'valProm'=>$valProm
- )
- );
- }
- public function getValoratesTicketsAction(){
- $request = Request::createFromGlobals();
- $rs = $this->get('report_service');
- $del = $request->query->get('del',false);
- $al = $request->query->get('al',false);
- $st = $request->query->get('stars',false);
- $op = array('del'=>$del,'al'=>$al,'stars'=>$st);
- $data = $rs->getValoratesTicketsReport($op);
- return $this->render(
- 'CoreMainBundle:Default:valorateTickets.html.twig',
- array('datos' => $data)
- );
- }
- public function testAction(){
- $cs = $this->get('config_service');
- $red = $cs->getConfParam('ranking','rojo');
- // echo "<h1>$red </h1>";
- return $this->render('CoreMainBundle:Default:index.html.twig',
- array('tickets' => 'ss'));
- }
-
- /**
- * Este Action se encarga de mostar la pantalla de index
- * @return html rendereado de la pagina index
- */
- public function indexAction()
- {
- $cs = $this->get('config_service');
- $time = $cs->getConfParam('ranking','time_act');
- return $this->render('CoreMainBundle:Default:index.html.twig',
- array('time' => $time));
- }
- /**
- * Este Action se encarga de generar el archivo de Exel
- * para el reporte de personas
- * @param area Boolead false sin area
- * @param area String area
- * @return archivo XLS
- */
- public function timeReportXlsAction($area = false){
- /** Aqui inicia el core **/
- $title = "Reporte de Tickets Generados y Cerrados ";
- $data = $this->getDatesPost();
- $od = $this->getDestOrigPost();
- $op = $this->getOptionsPost();
- $rs = $this->get('report_service');
- $report = $rs->getTimeReport($data, $od, $area);
- $title = "Reporte de Tiempo promedio de Atención por personas del".$data['label'];
- // ask the service for a Excel5
- $excelService = $this->get('xls.service_xls5');
- $excelService->excelObj->getProperties()->setCreator("ReportesGLPI")
- ->setLastModifiedBy("ReportesGLPI")
- ->setTitle($title)
- ->setSubject("Reporte de Personal GLPI")
- ->setDescription($title)
- ->setKeywords("office 2005 openxml php")
- ->setCategory("XLS result file");
- $letras = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
- 'Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF');
-
- $excelService->excelObj->setActiveSheetIndex(0)
- ->setCellValue('A2',$title);
- // {% for key, data in datos %}
-
- foreach ($report as $key => $value) {
- if($key == 0){
- $i=1;
- foreach ($value as $k => $val) {
- $excelService->excelObj->setActiveSheetIndex(0)
- ->setCellValue($letras[$i].'2',$k);
- $i+=2;
- }
- }
- }
- foreach ($report as $key => $value) {
- if($key == 0){
- $i=1;
- foreach ($value as $k => $val) {
- $excelService->excelObj->setActiveSheetIndex(0)
- ->setCellValue($letras[$i].'3','Numero de Tickets')
- ->setCellValue($letras[$i+1].'3','Tiempo Prom');
- $i+=2;
- }
- }
- }
- $n= 4;
- foreach ($report as $key => $value) {
- $excelService->excelObj->setActiveSheetIndex(0)
- ->setCellValue('A'.$n,$key);
- $i=2;
- foreach ($value as $k => $val) {
- $excelService->excelObj->setActiveSheetIndex(0)
- ->setCellValue($letras[$i].$n,$val['ticket'])
- ->setCellValue($letras[$i+1].$n,$val['prom']);
- $i+=2;
- }
- $n++;
- }
- $excelService->excelObj->getActiveSheet()->setTitle('Estados-'.$area);
- // Set active sheet index to the first sheet, so Excel opens this as the first sheet
- $excelService->excelObj->setActiveSheetIndex(0);
- //create the response
- $response = $excelService->getResponse();
- $response->headers->set('Content-Type', 'text/vnd.ms-excel; charset=utf-8');
- $response->headers->set('Content-Disposition', 'attachment;filename='.$area.'.xls');
- // If you are using a https connection, you have to set those two headers for compatibility with IE <9
- $response->headers->set('Pragma', 'public');
- $response->headers->set('Cache-Control', 'maxage=1');
- return $response;
- }
- /**
- *@Pdf()
- */
- public function timeReportAction($area = false){
- $request = Request::createFromGlobals();
- if ($request->getMethod() != 'POST'){
- #escapar a un plantilla vacio
- if($area)
- return $this->render('CoreMainBundle:Default:noPost.html.twig'
- ,array('person'=>'person','report' => 'person','area'=>$area));
- else
- return $this->render('CoreMainBundle:Default:noPost.html.twig'
- ,array('person'=>'person','report' => 'person'));
- }
- // Is ajax Action?
- $ajax = '';
- if($this->getRequest()->isXmlHttpRequest()){ $ajax='Ajax'; }
- // is pdf Request?
- $format = 'html';
- if($this->get('request')->get('_format') == 'pdf'){ $format='pdf'; }
- /** Aqui inicia el core **/
-
- $data = $this->getDatesPost();
- $od = $this->getDestOrigPost();
- $op = $this->getOptionsPost();
- $rs = $this->get('report_service');
- $report = $rs->getTimeReport($data, $od, $area);
- $title = "Reporte de Tiempo promedio de Atención por personas del".$data['label'];
- return $this->render(
- 'CoreMainBundle:Default:reporteTimeCute'.$ajax.'.'.$format.'.twig'
- ,array(
- 'datos' => $report
- ,'title'=> $title
- ,'type'=> $data['type']
- ,'options' => $op
- ,'area' => $area
- ,'report' => 'person'
- )
- );
- }
- /**
- *@Pdf()
- */
- public function mainReportAction(){
- $request = Request::createFromGlobals();
- if ($request->getMethod() != 'POST'){
- #escapar a un plantilla vacio
- return $this->render(
- 'CoreMainBundle:Default:noPost.html.twig',
- array('report' => 'main'));
- }
- // Is ajax Action?
- $ajax = '';
- if($this->getRequest()->isXmlHttpRequest()){ $ajax='Ajax'; }
- // is pdf Request?
- $format = 'html';
- if($this->get('request')->get('_format') == 'pdf'){ $format='pdf'; }
- /** Aqui inicia el core **/
-
- $data = $this->getDatesPost();
- $od = $this->getDestOrigPost();
- $op = $this->getOptionsPost();
- $rs = $this->get('report_service');
- $report = $rs->getMainReport($data, $od);
- $abstract = $rs->getAbstract($report);
- $title = "Reporte de Tickets Generados y Cerrados del ".$data['label'];
- return $this->render(
- 'CoreMainBundle:Default:reporte2'.$ajax.'.'.$format.'.twig'
- ,array(
- 'datos' => $report
- ,'title'=> $title
- ,'type'=> $data['type']
- ,'options' => $op
- ,'abs' => $abstract
- ,'report' => 'main'
- )
- );
- }
- /**
- * Este Action se encarga de generar el archivo de Exel
- * para el reporte de Tickets
- * @return archivo XLS
- */
- public function mainReportXlsAction(){
- $request = Request::createFromGlobals();
- if ($request->getMethod() != 'POST'){
- #escapar a un plantilla vacio
- return $this->render('CoreMainBundle:Default:noPost.html.twig');
- }
- // Is ajax Action?
- $ajax = '';
- if($this->getRequest()->isXmlHttpRequest()){ $ajax='Ajax'; }
- // is pdf Request?
- $format = 'html';
- if($this->get('request')->get('_format') == 'pdf'){ $format='pdf'; }
- // verificar si hay data enviada por post
- if ($request->getMethod() != 'POST'){
- #escapar a un plantilla vacio
- return $this->render(
- 'CoreMainBundle:Default:noPost.html.twig');
- }
- /** Aqui inicia el core **/
- $title = "Reporte de Tickets Generados y Cerrados ";
- $data = $this->getDatesPost();
- $od = $this->getDestOrigPost();
- $op = $this->getOptionsPost();
- $rs = $this->get('report_service');
- $report = $rs->getMainReport($data, $od);
- // $abstract = $rs->getAbstract($report);
- #$title = " Reportes del Area de $area ";
- // ask the service for a Excel5
- $excelService = $this->get('xls.service_xls5');
- // or $this->get('xls.service_pdf');
- // or create your own is easy just modify services.yml
- // create the object see http://phpexcel.codeplex.com documentation
- $excelService->excelObj->getProperties()->setCreator("ReportesGLPI")
- ->setLastModifiedBy("ReportesGLPI")
- ->setTitle("Office 2005 XLSX Test Document")
- ->setSubject("Office 2005 XLSX Test Document")
- ->setDescription("Test document for Office 2005 XLSX, generated using PHP classes.")
- ->setKeywords("office 2005 openxml php")
- ->setCategory("Test result file");
- $letras = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
- 'Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF');
- $i=1;
- foreach ($report as $data) {
- $excelService->excelObj->setActiveSheetIndex(0)
- ->setCellValue('A1',$title)
- ->setCellValue('A3','Tickets Generados.')
- ->setCellValue('A4','Tickets Atendidos..')
- ->setCellValue('A5','Tickets Pendientes del Dia.')
- ->setCellValue('A6','Tickets Pendientes Acumulados del dia anterior.')
- ->setCellValue('A7','Tickets endientes Totales.')
- ->setCellValue($letras[$i].'2', $data['fecha'])
- ->setCellValue($letras[$i].'3', $data['campos']['generados'])
- ->setCellValue($letras[$i+1].'3', $data['campos']['pendAnteriores'])
- ->setCellValue($letras[$i].'4', $data['campos']['atendidos'])
- ->setCellValue($letras[$i+1].'4', $data['campos']['atenAnteriores'])
- ->setCellValue($letras[$i].'5', $data['campos']['pendientes'])
- ->setCellValue($letras[$i+1].'5', $data['campos']['restantes'])
- ->setCellValue($letras[$i].'6', $data['campos']['pendAnteriores'])
- ->setCellValue($letras[$i+1].'6', '----')
- ->setCellValue($letras[$i].'7', $data['campos']['pendTotales'])
- ->setCellValue($letras[$i+1].'7', '----');
-
- $i+=2;
- }
- $excelService->excelObj->getActiveSheet()->setTitle('Simple ');
- // Set active sheet index to the first sheet, so Excel opens this as the first sheet
- $excelService->excelObj->setActiveSheetIndex(0);
- //create the response
- $response = $excelService->getResponse();
- $response->headers->set('Content-Type', 'text/vnd.ms-excel; charset=utf-8');
- $response->headers->set('Content-Disposition', 'attachment;filename=report.xls');
- // If you are using a https connection, you have to set those two headers for compatibility with IE <9
- $response->headers->set('Pragma', 'public');
- $response->headers->set('Cache-Control', 'maxage=1');
- return $response;
-
- }
- /**
- *@Pdf()
- */
- public function mainAreaReportAction($area){
- $request = Request::createFromGlobals();
- if ($request->getMethod() != 'POST'){
- #escapar a un plantilla vacio
- return $this->render('CoreMainBundle:Default:noPost.html.twig',
- array('area'=>$area,'report' => 'main'));
- }
- // Is ajax Action?
- $ajax = '';
- if($this->getRequest()->isXmlHttpRequest()){ $ajax='Ajax'; }
- // is pdf Request?
- $format = 'html';
- if($this->get('request')->get('_format') == 'pdf'){ $format='pdf'; }
- /** Aqui inicia el core **/
-
- $data = $this->getDatesPost();
- $od = $this->getDestOrigPost();
- $op = $this->getOptionsPost();
- $rs = $this->get('report_service');
- $report = $rs->getMainReport($data, $od, $area);
- $abstract = $rs->getAbstract($report);
- $title = "Reporte de Tickets del área $area, Generados y Cerrados del ".$data['label'];
- return $this->render(
- 'CoreMainBundle:Default:reporte2'.$ajax.'.'.$format.'.twig'
- ,array(
- 'datos' => $report
- ,'title'=> $title
- ,'type'=> $data['type']
- ,'options' => $op
- ,'area' => $area
- ,'abs' => $abstract
- ,'report' => 'main'
- )
- );
- }
- /**
- * Este Action se encarga de generar el archivo de Exel
- * para el reporte de tickets por area
- * @param area String area
- * @return archivo XLS
- */
- public function areaReportXlsAction($area)
- {
- /** Aqui inicia el core **/
- $title = "Reporte de Tickets Generados y Cerrados ";
- $data = $this->getDatesPost();
- $od = $this->getDestOrigPost();
- $op = $this->getOptionsPost();
- $rs = $this->get('report_service');
- $datos = $rs->getMainReport($data, $od, $area);
- $title = " Reportes del Area de $area ";
- // ask the service for a Excel5
- $excelService = $this->get('xls.service_xls5');
- // or $this->get('xls.service_pdf');
- // or create your own is easy just modify services.yml
- // create the object see http://phpexcel.codeplex.com documentation
- $excelService->excelObj->getProperties()->setCreator("ReportesGLPI")
- ->setLastModifiedBy("ReportesGLPI")
- ->setTitle("Office 2005 XLSX Test Document")
- ->setSubject("Office 2005 XLSX Test Document")
- ->setDescription("Test document for Office 2005 XLSX, generated using PHP classes.")
- ->setKeywords("office 2005 openxml php")
- ->setCategory("Test result file");
- $letras = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
- 'Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF');
- $i=1;
- foreach ($datos as $data) {
- $excelService->excelObj->setActiveSheetIndex(0)
- ->setCellValue('A1',$title)
- ->setCellValue('A3','Tickets Generados.')
- ->setCellValue('A4','Tickets Atendidos..')
- ->setCellValue('A5','Tickets Pendientes del Dia.')
- ->setCellValue('A6','Tickets Pendientes Acumulados del dia anterior.')
- ->setCellValue('A7','Tickets endientes Totales.')
- ->setCellValue($letras[$i].'2', $data['fecha'])
- ->setCellValue($letras[$i].'3', $data['campos']['generados'])
- ->setCellValue($letras[$i+1].'3', $data['campos']['pendAnteriores'])
- ->setCellValue($letras[$i].'4', $data['campos']['atendidos'])
- ->setCellValue($letras[$i+1].'4', $data['campos']['atenAnteriores'])
- ->setCellValue($letras[$i].'5', $data['campos']['pendientes'])
- ->setCellValue($letras[$i+1].'5', $data['campos']['restantes'])
- ->setCellValue($letras[$i].'6', $data['campos']['pendAnteriores'])
- ->setCellValue($letras[$i+1].'6', '----')
- ->setCellValue($letras[$i].'7', $data['campos']['pendTotales'])
- ->setCellValue($letras[$i+1].'7', '----');
-
- $i+=2;
- }
- $excelService->excelObj->getActiveSheet()->setTitle('Simple '.$area);
- // Set active sheet index to the first sheet, so Excel opens this as the first sheet
- $excelService->excelObj->setActiveSheetIndex(0);
- //create the response
- $response = $excelService->getResponse();
- $response->headers->set('Content-Type', 'text/vnd.ms-excel; charset=utf-8');
- $response->headers->set('Content-Disposition', 'attachment;filename='.$area.'.xls');
- // If you are using a https connection, you have to set those two headers for compatibility with IE <9
- $response->headers->set('Pragma', 'public');
- $response->headers->set('Cache-Control', 'maxage=1');
- return $response;
- }
- /**
- *@Pdf()
- */
- public function statusReportAction($area = false)
- {
- $request = Request::createFromGlobals();
- if ($request->getMethod() != 'POST'){
- #escapar a un plantilla vacio
- if($area)
- return $this->render('CoreMainBundle:Default:noPost.html.twig'
- ,array('status'=>'status','area'=>$area,'report' => 'status'));
- else
- return $this->render('CoreMainBundle:Default:noPost.html.twig'
- ,array('status'=>'status','report' => 'status'));
- }
- // Is ajax Action?
- $ajax = '';
- if($this->getRequest()->isXmlHttpRequest()){ $ajax='Ajax'; }
- // is pdf Request?
- $format = 'html';
- if($this->get('request')->get('_format') == 'pdf'){ $format='pdf'; }
- /** Aqui inicia el core **/
-
- $data = $this->getDatesPost();
- $od = $this->getDestOrigPost();
- $op = $this->getOptionsPost();
- $rs = $this->get('report_service');
- $datos = $rs->getStatusReport($data,$od, $area);
- $title = "Reporte de Estado de los Tickets del ".$data['label'];
- // $datos = $this->reciveStatusInformation();
- return $this->render(
- 'CoreMainBundle:Default:reporte1'.$ajax.'.'.$format.'.twig'
- ,array('datos' => $datos
- ,'title'=> $title
- ,'type'=> $data['type']
- ,'options' => $op
- ,'area' => $area
- ,'report' => 'status'
- //,'abs' => $abstract
- )
- );
- }
- /**
- * Este Action se encarga de generar el archivo de Exel
- * para el reporte de Estados
- * @param area Boolead false sin area
- * @param area String area
- * @return archivo XLS
- */
- public function statusReportXlsAction($area = false)
- {
- /** Aqui inicia el core **/
- $title = "Reporte de Tickets Generados y Cerrados ";
- $data = $this->getDatesPost();
- $od = $this->getDestOrigPost();
- $op = $this->getOptionsPost();
- $rs = $this->get('report_service');
- $datos = $rs->getStatusReport($data,$od, $area);
- $title = "Reporte de Estado de los Tickets del ".$data['label'];
- // ask the service for a Excel5
- $excelService = $this->get('xls.service_xls5');
- $excelService->excelObj->getProperties()->setCreator("ReprtesGLPI")
- ->setLastModifiedBy("ReprtesGLPI")
- ->setTitle($title)
- ->setSubject("Reporte de estados GLPI")
- ->setDescription($title)
- ->setKeywords("office 2005 openxml php")
- ->setCategory("XLS result file");
- $letras = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
- 'Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF');
- $i=1;
- foreach ($datos as $data) {
- if(!isset($data['campos']['new'])) $data['campos']['new']=0;
- if(!isset($data['campos']['assign'])) $data['campos']['assign']=0;
- if(!isset($data['campos']['plan'])) $data['campos']['plan']=0;
- if(!isset($data['campos']['waiting'])) $data['campos']['waiting']=0;
- if(!isset($data['campos']['closed'])) $data['campos']['closed']=0;
- $excelService->excelObj->setActiveSheetIndex(0)
- ->setCellValue('A2',$title)
- ->setCellValue('A3','Tickets Nuevos.')
- ->setCellValue('A4','Tickets Asignados.')
- ->setCellValue('A5','Tickets Planificados.')
- ->setCellValue('A6','Tickets en Espera.')
- ->setCellValue('A7','Tickets Cerrados.')
- ->setCellValue($letras[$i].'2', $data['fecha'])
- ->setCellValue($letras[$i].'3', $data['campos']['new'])
- ->setCellValue($letras[$i].'4', $data['campos']['assign'])
- ->setCellValue($letras[$i].'5', $data['campos']['plan'])
- ->setCellValue($letras[$i].'6', $data['campos']['waiting'])
- ->setCellValue($letras[$i].'7', $data['campos']['closed']);
- $i+=1;
- }
- $excelService->excelObj->getActiveSheet()->setTitle('Estados-'.$area);
- // Set active sheet index to the first sheet, so Excel opens this as the first sheet
- $excelService->excelObj->setActiveSheetIndex(0);
- //create the response
- $response = $excelService->getResponse();
- $response->headers->set('Content-Type', 'text/vnd.ms-excel; charset=utf-8');
- $response->headers->set('Content-Disposition', 'attachment;filename='.$area.'.xls');
- // If you are using a https connection, you have to set those two headers for compatibility with IE <9
- $response->headers->set('Pragma', 'public');
- $response->headers->set('Cache-Control', 'maxage=1');
- return $response;
- }
- /**
- * Obtiene los filtros de Fechas elegidas por el usuario
- * esta clase revisa las peticiones POST y regresa
- * - los parametros de la consulta
- * - tipo seleccionado
- * @return Array fechas de fltrado
- */
- private function getDatesPost(){
- $request = Request::createFromGlobals();
- if ($request->getMethod() != 'POST'){
- return array(
- 'parameters'=>false
- ,'type'=>false
- ,'label'=>'');
- }
- $request->getPathInfo();
- // leyendo las variables Basicas
- $tipoFech = $request->request->get('tipoFecha', false);
- // inicializando variables
- $label = "";
- $dataPar = array();
- // si se selecciono Dia
- if($tipoFech == 'day'){
- $val = $request->request->get('dayValue', '2012-01-01');
- $nextDay = date(
- 'Y-m-d',strtotime('+1 day', strtotime($val)));
- $beforeDay = date(
- 'Y-m-d',strtotime('-1 day', strtotime($val)));
- $parametros = array(
- 'day' => $val
- ,'protoDay' => $beforeDay
- ,'nextDay' => $nextDay
- ,'beforeDay' => $beforeDay
- );
- $dataPar[]=$parametros;
- $label = 'día '.$this->days[date('l',strtotime($val))].' '
- .date('d',strtotime($val))
- .' de '.$this->months[date('F',strtotime($val))].' '
- .date('Y',strtotime($val));
- $delDay = $beforeDay;
- $alDay = $nextDay;
- }
- // si se selecciono Semana
- elseif($tipoFech == 'week'){
- $year = $request->request->get('weekYearValue', '13');
- $week = $request->request->get('weekValue', '2013');
- $rs = $this->get('report_service');
- $days = $rs->WeekToDates($week, $year);
- $diaIni = $days['monday'];
- $diaFin = $days['sunday'];
- $datos = array();
- $i=0;
- $proDay = $diaIni;
- while (strtotime($diaIni) <= strtotime($diaFin) ){
- $nextDay = date(
- 'Y-m-d',strtotime('+1 day', strtotime($diaIni)));
- $beforeDay = date(
- 'Y-m-d',strtotime('-1 day', strtotime($diaIni)));
- $parametros = array(
- 'day' => $diaIni
- ,'protoDay' => $proDay
- ,'nextDay' => $nextDay
- ,'beforeDay' => $beforeDay
- );
- $dataPar[]=$parametros;
- $diaIni = date(
- 'Y-m-d',strtotime('+1 day', strtotime($diaIni)));
- $dia = date('l',strtotime($diaIni));
- if($dia == 'Sunday'){
- $diaIni = date(
- 'Y-m-d',strtotime('+1 day', strtotime($diaIni)));
- }
- $i++;
- }
- $label = ' día '
- .$this->days[date('l',strtotime($proDay))].' '
- .date('d',strtotime($proDay))
- .' de '.$this->months[date('F',strtotime($proDay))].' '
- .date('Y',strtotime($proDay))
- .' al día '.$this->days[date('l',strtotime($diaFin))].' '
- .date('d',strtotime($diaFin))
- .' de '.$this->months[date('F',strtotime($diaFin))].' '
- .date('Y',strtotime($diaFin));
- $delDay = $proDay;
- $alDay = $diaFin;
- }
- // si se selecciono Mes
- elseif($tipoFech == 'month'){
- $year = $request->request->get('yearMonthValue', '2012');
- $month = $request->request->get('monthValue', '01');
- $diaIni = "$year-$month-01";
- if($month < 12){ $month2 = $month+1; }
- else { $year +=1; $month2=1; }
-
- $diaFin = "$year-$month2-01";
- $datos = array();
- $i=0;
- $proDay = $diaIni;
- while (strtotime($diaIni) < strtotime($diaFin) ){
- // echo "$diaIni - $diaFin <br>";
- $nextDay = date(
- 'Y-m-d',strtotime('+7 day', strtotime($diaIni)));
- if(strtotime($nextDay) >= strtotime($diaFin)) {
- $nextDay = date(
- 'Y-m-d',strtotime('-1 day', strtotime($diaFin)));
- }
- $beforeDay = date(
- 'Y-m-d',strtotime('-7 day', strtotime($diaIni)));
- $labelNextDay = date(
- 'Y-m-d',strtotime('+6 day', strtotime($diaIni)));
- $parametros = array(
- 'day' => $diaIni
- ,'protoDay' => $proDay
- ,'nextDay' => $nextDay
- ,'beforeDay' => $beforeDay
- );
- $dataPar[]=$parametros;
- #sumarle una Semana
- $diaIni = date(
- 'Y-m-d',strtotime('+7 day', strtotime($diaIni)));
- $dia = date('l',strtotime($diaIni));
- $i++;
- }
- $label = ' mes de '.$this->months[date('F',strtotime($proDay))].' de '
- .date('Y',strtotime($proDay));
- $delDay = date('Y',strtotime($proDay)).'-'.$month.'-01';
- $alDay = date('Y',strtotime($proDay)).'-'.$month.'-31';
- }
- // si se selecciono Anio
- elseif($tipoFech == 'year'){
- $year = $request->request->get('yearValue', '2012');
- $year2 = $year + 1;
- $diaIni = "$year-01-01";
- $diaFin = "$year2-01-01";
- $datos = array();
- $i=0;
- $proDay = $diaIni;
- while (strtotime($diaIni) < strtotime($diaFin) ){
- $nextDay = date(
- 'Y-m-d',strtotime('+1 month', strtotime($diaIni)));
- $beforeDay = date(
- 'Y-m-d',strtotime('-1 month', strtotime($diaIni)));
- $parametros = array(
- 'day' => $diaIni
- ,'protoDay' => $proDay
- ,'nextDay' => $nextDay
- ,'beforeDay' => $beforeDay
- );
- $dataPar[]=$parametros;
- #ordenar los resultados
- $label = 'año '.date('Y',strtotime($diaIni));
- #sumarle un dia
- $diaIni = date(
- 'Y-m-d',strtotime('+1 month', strtotime($diaIni)));
- $i++;
- if($nextDay > date('Y-m-d')){ break;}
- }
- $delDay = $year.'-01-01';
- $alDay = $year2.'-01-01';
- }
- // si se selecciono Custom/personalizado
- elseif($tipoFech == 'custom'){
- $diaIni = $request->request->get('cusValue', '2012-01-01');
- $diaFin = $request->request->get('cusValue1', '2012-01-07');
- $datos = array();
- $i=0;
- $proDay = $diaIni;
- while (strtotime($diaIni) <= strtotime($diaFin) ){
- $nextDay = date(
- 'Y-m-d',strtotime('+1 day', strtotime($diaIni)));
- $beforeDay = date(
- 'Y-m-d',strtotime('-1 day', strtotime($diaIni)));
- $parametros = array(
- 'day' => $diaIni
- ,'protoDay' => $proDay
- ,'nextDay' => $nextDay
- ,'beforeDay' => $beforeDay
- );
- $dataPar[]=$parametros;
- $diaIni = date(
- 'Y-m-d',strtotime('+1 day', strtotime($diaIni)));
- $dia = date('l',strtotime($diaIni));
- if($dia == 'Sunday'){
- $diaIni = date(
- 'Y-m-d',strtotime('+1 day', strtotime($diaIni)));
- }
- $i++;
- }
- $label = 'día '.$this->days[date('l',strtotime($proDay))].' '
- .date('d',strtotime($proDay))
- .' de '.$this->months[date('F',strtotime($proDay))].' '
- .date('Y',strtotime($proDay))
- .' al día '.$this->days[date('l',strtotime($diaFin))].' '
- .date('d',strtotime($diaFin))
- .' de '.$this->months[date('F',strtotime($diaFin))].' '
- .date('Y',strtotime($diaFin));
- $delDay = $proDay;
- $alDay = $diaFin;
- }
- return array(
- 'parameters'=>$dataPar
- ,'type'=>$tipoFech
- ,'label' => $label
- ,'del'=> $delDay
- ,'al'=>$alDay
- );
- }
- /**
- * Obtiene los Destinos/Origenes seleccionadas por el usuario
- * esta clase revisa las peticiones POST y regresa
- * - los valores de opciones
- * - el query "cleanned"
- * - el query "bruto"
- * @return Array opciones de filtrado adicional
- */
- private function getDestOrigPost(){
- $request = Request::createFromGlobals();
- $request->getPathInfo();
- if ($request->getMethod() != 'POST'){
- return array(
- 'cleannedQuery'=> false
- ,'parameters'=>false
- ,'query' => false
- );
- }
- # Tipos Generales
- $tipoArea = $request->request->get('tipoArea', false);
- $tipoServ = $request->request->get('tipoServicio', false);
- $tipoPers = $request->request->get('tipoPersona', false);
- $query="";
- $filterQuery = "";
- $filterParametros = array();
- $cont=0;
- if($tipoArea){
- $uneg = $request->request->get('uneg', 'corp');
- $areas = $request->request->get('areaValues', false );
- if(!$areas){
- //filtra solo unidad de negocio
- $unegs= array(
- 'uc' => $this->container->getParameter('uneg_uc')
- ,'cic' => $this->container->getParameter('uneg_cic')
- ,'apec' => $this->container->getParameter('uneg_apec' )
- ,'epgc' => $this->container->getParameter('uneg_epgc' )
- ,'ceg' => $this->container->getParameter('uneg_ceg')
- ,'corp' => $this->container->getParameter('uneg_corp' )
- );
- $value = $unegs[$uneg];
- $filterQuery .="(r.unidadnegocio = :value )" ;
- $query .= "( r.unidadnegocio = $value )";
- $filterParametros['value'] = $value;
- }
- else{
- $filterQuery .= " ( ";
- $query .= " ( ";
- $aux = 0;
- foreach ($areas as $key => $value) {
- if($aux>0) { $filterQuery .= " or "; $query .= " or ";}
- $filterQuery .="t.requesttypesId = :orig$key " ;
- $query .= "t.requesttypes_id = $value ";
- $filterParametros['orig'.$key] = $value;
- $aux++;
- }
- $filterQuery .=" )";
- $query .= " )";
- $cont++;
- }
- }
- if($tipoServ){
- $servicios = $request->request->get(
- 'servicioValues', array(0) );
- if($cont>0) { $filterQuery .= " and "; $query.=" and "; }
- $filterQuery .=" ( ";
- $query .= " ( ";
- $aux = 0;
- foreach ($servicios as $key => $value) {
- if($aux>0) { $filterQuery .= " or "; $query .= " or ";}
- $filterQuery .="t.itilcategoriesId = :servicio$key " ;
- $query .= "t.itilcategories_id = $value ";
- $filterParametros['servicio'.$key] = $value;
- $filterQuery++;
- $aux++;
- }
- $filterQuery .= " ) ";
- $query .= " ) ";
- $cont++;
- }
- if($tipoPers){
- $personas = $request->request->get(
- 'personaValues', '1' );
- $personas = explode(',', $personas);
- if($cont>0) { $filterQuery .= " and "; $query.=" and "; }
- $filterQuery .=" ( ";
- $query .= " ( ";
- $aux = 0;
- foreach ($personas as $key => $value) {
- if($aux>0) { $filterQuery .= " or "; $query .= " or ";}
- $filterQuery .="u.id = :user$key " ;
- $query .= "u.id = $value ";
- $filterParametros['user'.$key] = $value;
- #$filterQuery++;
- $aux++;
- }
- $filterQuery .= " ) ";
- $query .= " ) ";
- $cont++;
- // echo "<h1>$query<br>$filterQuery </h1>";
- }
- return array(
- 'cleannedQuery'=> $filterQuery
- ,'parameters'=>$filterParametros
- ,'query' => $query
- );
- }
- /**
- * Obtiene las opciones seleccionadas por el usuario
- * esta clase revisa las peticiones POST y regresa
- * - los valores de opciones adicinales
- * - Parte del labeval in /home/arturo/www/reportes/src/l del titulo
- * @return Array Opciones extras
- */
- private function getOptionsPost(){
- $request = Request::createFromGlobals();
- if ($request->getMethod() != 'POST'){
- return false;
- }
- $data = array(
- 'showHoyayer' => $request->request->get('showHoyayer', false)
- ,'showGrafica1' => $request->request->get('showGrafica1', false)
- ,'showGrafica2' => $request->request->get('showGrafica2', false)
- ,'showGrafica3' => $request->request->get('showGrafica3', false)
- ,'showResumen' => $request->request->get('showResumen', false)
- ,'showComent ' => $request->request->get('showComent', false)
- );
- return $data;
- }
- private $areas = array(
- "Redes"=>"Redes"
- ,"Desarrollo"=>"Desarrollo"
- ,"Service"=>"ServiceDesk"
- ,"Soporte"=>"Soporte T."
- );
-
- private $months = array(
- "Jan"=>"Ene" ,"January"=>"Enero"
- ,"Feb"=>"Feb" ,"February"=>"Febrero"
- ,"Mar"=>"Mar" ,"March"=>"Marzo"
- ,"Apr"=>"Abr" ,"April"=>"Abril"
- ,"May"=>"May" ,"May"=>"Mayo"
- ,"Jun"=>"Jun" ,"June"=>"Junio"
- ,"Jul"=>"Jul" ,"July"=>"Julio"
- ,"Aug"=>"Ago" ,"August"=>"Agosto"
- ,"Sep"=>"Sep" ,"September"=>"Septiembre"
- ,"Oct"=>"Oct" ,"October"=>"Octubre"
- ,"Nov"=>"Nov" ,"November"=>"Noviembre"
- ,"Dec"=>"Dic" ,"December"=>"Diciembre"
- );
- private $days = array(
- "Monday"=>"Lunes"
- ,"Tuesday"=>"Martes"
- ,"Wednesday"=>"Miercoles"
- ,"Thursday"=>"Jueves"
- ,"Friday"=>"Viernes"
- ,"Saturday"=>"Sabado"
- ,"Sunday"=>"Domingo"
- );
- }