@@ 90-143 (lines=54) @@ | ||
87 | return new JsonModel($response); |
|
88 | } |
|
89 | ||
90 | public function getSectoralEvolutionAction() |
|
91 | { |
|
92 | $sector = (int) $this->params()->fromRoute('sector'); |
|
93 | ||
94 | $response = []; |
|
95 | ||
96 | // TRAIGO LOS SECTORES CON SUS COLORES |
|
97 | ||
98 | $arrSectores = $this->entityManager->getRepository(Sector::class)->getSector($sector); |
|
99 | ||
100 | if (empty($arrSectores)) { |
|
101 | $this->response->setStatusCode(404); |
|
102 | } |
|
103 | ||
104 | // TRAIGO LOS VALORES POR ANO |
|
105 | // LO QUE ESTA ADENTRO DEL LOOP DEBERIA IR ACA |
|
106 | ||
107 | $arrAnos = []; |
|
108 | $arrValores = []; |
|
109 | $arrColores = []; |
|
110 | ||
111 | for ($i = self::START_YEAR; $i <= self::END_YEAR; $i++) { |
|
112 | $arrAnos[] = $i; |
|
113 | } |
|
114 | ||
115 | $column = 2; |
|
116 | ||
117 | foreach ($arrSectores as $sector) { |
|
118 | $response['column_'.$column][] = $sector['name']; |
|
119 | $response['colores'][] = $sector['color']; |
|
120 | ||
121 | foreach ($arrAnos as $ano) { |
|
122 | // ATENCION, CABECEADA |
|
123 | // ESTOY EJECUTANDO EL QUERY CADA VEZ QUE NECESITO LA LISTA DE VALORES |
|
124 | // ESTA PARTE DEBERIA AFUERA DEL LOOP Y SE DEBERIA REUTILIZAR $arrValoresCrudo |
|
125 | $arrValoresCrudo = $this->entityManager->getRepository(Emission::class) |
|
126 | ->findSectorGroupedByYear(); |
|
127 | ||
128 | if (empty($arrValoresCrudo)) { |
|
129 | $this->response->setStatusCode(404); |
|
130 | } |
|
131 | // HASTA ACA |
|
132 | ||
133 | $response['column_'.$column][] = Utils::returnSectorAno($arrValoresCrudo, $sector['name'], $ano); |
|
134 | } |
|
135 | ||
136 | $column++; |
|
137 | } |
|
138 | ||
139 | $arrAnos = array_merge(array('x'), $arrAnos); |
|
140 | $response['column_1'] = $arrAnos; |
|
141 | ||
142 | return new JsonModel($response); |
|
143 | } |
|
144 | ||
145 | public function getSectoralEvolutionSubactivityAction() |
|
146 | { |
|
@@ 145-197 (lines=53) @@ | ||
142 | return new JsonModel($response); |
|
143 | } |
|
144 | ||
145 | public function getSectoralEvolutionSubactivityAction() |
|
146 | { |
|
147 | $sector = (int) $this->params()->fromRoute('sector'); |
|
148 | ||
149 | $response = []; |
|
150 | ||
151 | $arrSubactividades = $this->entityManager->getRepository(Subactivity::class) |
|
152 | ->findActivitySectorBySector($sector); |
|
153 | ||
154 | if (empty($arrSubactividades)) { |
|
155 | $this->response->setStatusCode(404); |
|
156 | } |
|
157 | ||
158 | // TRAIGO LOS VALORES POR ANO |
|
159 | // LO QUE ESTA ADENTRO DEL LOOP DEBERIA IR ACA |
|
160 | ||
161 | $arrAnos = []; |
|
162 | $arrValores = []; |
|
163 | $arrColores = []; |
|
164 | ||
165 | for ($i = self::START_YEAR; $i <= self::END_YEAR; $i++) { |
|
166 | $arrAnos[] = $i; |
|
167 | } |
|
168 | ||
169 | $column = 2; |
|
170 | ||
171 | foreach ($arrSubactividades as $subactividad) { |
|
172 | $response['column_'.$column][] = $subactividad['name']; |
|
173 | $response['groups'][] = $subactividad['name']; |
|
174 | ||
175 | foreach ($arrAnos as $ano) { |
|
176 | // ATENCION, CABECEADA |
|
177 | // ESTOY EJECUTANDO EL QUERY CADA VEZ QUE NECESITO LA LISTA DE VALORES |
|
178 | // ESTA PARTE DEBERIA AFUERA DEL LOOP Y SE DEBERIA REUTILIZAR $arrValoresCrudo |
|
179 | $arrValoresCrudo = $this->entityManager->getRepository(Emission::class) |
|
180 | ->findSubactivitySectorBySector($sector); |
|
181 | ||
182 | if (empty($arrValoresCrudo)) { |
|
183 | $this->response->setStatusCode(404); |
|
184 | } |
|
185 | // HASTA ACA |
|
186 | ||
187 | $response['column_'.$column][] = Utils::returnSectorAno($arrValoresCrudo, $subactividad['name'], $ano); |
|
188 | } |
|
189 | ||
190 | $column++; |
|
191 | } |
|
192 | ||
193 | $arrAnos = array_merge(array('x'), $arrAnos); |
|
194 | $response['column_1'] = $arrAnos; |
|
195 | ||
196 | return new JsonModel($response); |
|
197 | } |
|
198 | ||
199 | public function getSectoralEvolutionSubactivityCategoryAction() |
|
200 | { |