@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | $activities = $this->entityManager->getRepository(Emission::class) |
| 38 | - ->findAll(); |
|
| 38 | + ->findAll(); |
|
| 39 | 39 | var_dump($activities); |
| 40 | 40 | return new JsonModel($activities); |
| 41 | 41 | |
@@ -236,37 +236,37 @@ discard block |
||
| 236 | 236 | /** |
| 237 | 237 | * |
| 238 | 238 | */ |
| 239 | - public function getGasesDistributionAction() |
|
| 240 | - { |
|
| 241 | - $params = $this->params()->fromRoute(); |
|
| 239 | + public function getGasesDistributionAction() |
|
| 240 | + { |
|
| 241 | + $params = $this->params()->fromRoute(); |
|
| 242 | 242 | |
| 243 | - $ano = (int)$params['ano']; |
|
| 243 | + $ano = (int)$params['ano']; |
|
| 244 | 244 | |
| 245 | - $response = []; |
|
| 245 | + $response = []; |
|
| 246 | 246 | |
| 247 | - $sql = 'SELECT e.gas_id, g.nombre, g.color, sum(e.valor) as total |
|
| 247 | + $sql = 'SELECT e.gas_id, g.nombre, g.color, sum(e.valor) as total |
|
| 248 | 248 | FROM emision e |
| 249 | 249 | LEFT JOIN gas g ON (e.gas_id = g.id) |
| 250 | 250 | where e.ano = ? GROUP BY e.gas_id ORDER BY total DESC'; |
| 251 | 251 | |
| 252 | - $parameters = [ |
|
| 252 | + $parameters = [ |
|
| 253 | 253 | $ano, |
| 254 | 254 | ]; |
| 255 | 255 | |
| 256 | - $statement = $this->db->createStatement($sql, $parameters); |
|
| 256 | + $statement = $this->db->createStatement($sql, $parameters); |
|
| 257 | 257 | |
| 258 | - $results = $statement->execute(); |
|
| 258 | + $results = $statement->execute(); |
|
| 259 | 259 | |
| 260 | - $response['gases'][] = 'x'; |
|
| 261 | - $response['valores'][] = 'Gases'; |
|
| 260 | + $response['gases'][] = 'x'; |
|
| 261 | + $response['valores'][] = 'Gases'; |
|
| 262 | 262 | |
| 263 | - while ($a = $results->next()) { |
|
| 264 | - $response['gases'][] = (strpos($a['nombre'], ',')) ? '"'.$a['nombre'].'"' : $a['nombre']; |
|
| 265 | - $response['valores'][] = round($a['total']); |
|
| 266 | - $response['colores'][] = $a['color']; |
|
| 267 | - } |
|
| 268 | - return new JsonModel($response); |
|
| 269 | - } |
|
| 263 | + while ($a = $results->next()) { |
|
| 264 | + $response['gases'][] = (strpos($a['nombre'], ',')) ? '"'.$a['nombre'].'"' : $a['nombre']; |
|
| 265 | + $response['valores'][] = round($a['total']); |
|
| 266 | + $response['colores'][] = $a['color']; |
|
| 267 | + } |
|
| 268 | + return new JsonModel($response); |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | 271 | public function getSectoralGasesDistributionAction() |
| 272 | 272 | { |