@@ -2,17 +2,10 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Api\Controller; |
| 4 | 4 | |
| 5 | -use Zend\Db\Adapter\AdapterInterface; |
|
| 6 | 5 | use Zend\Mvc\Controller\AbstractRestfulController; |
| 7 | 6 | use Zend\View\Model\JsonModel; |
| 8 | -use Zend\Validator\StaticValidator; |
|
| 9 | 7 | use Api\Helper\Utils; |
| 10 | -use Api\Entity\Activity; |
|
| 11 | -use Api\Entity\Subactivity; |
|
| 12 | 8 | use Api\Entity\Emission; |
| 13 | -use Api\Entity\Sector; |
|
| 14 | -use Api\Entity\Category; |
|
| 15 | -use Api\Entity\Gas; |
|
| 16 | 9 | |
| 17 | 10 | class DistributionReportController extends AbstractRestfulController |
| 18 | 11 | { |
@@ -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 | { |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | $params = $this->params()->fromRoute(); |
| 43 | 43 | |
| 44 | - $ano = (int)$params['ano']; |
|
| 44 | + $ano = (int) $params['ano']; |
|
| 45 | 45 | |
| 46 | 46 | $response = []; |
| 47 | 47 | |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | $response = []; |
| 88 | 88 | $arrGraphData = []; |
| 89 | 89 | |
| 90 | - $ano = (int)$params['ano']; |
|
| 91 | - $sector_id = (int)$params['sector_id']; |
|
| 90 | + $ano = (int) $params['ano']; |
|
| 91 | + $sector_id = (int) $params['sector_id']; |
|
| 92 | 92 | |
| 93 | 93 | $sql = 'SELECT SUM(e.valor) as total, a.id, a.nombre |
| 94 | 94 | FROM emision e |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | { |
| 241 | 241 | $params = $this->params()->fromRoute(); |
| 242 | 242 | |
| 243 | - $ano = (int)$params['ano']; |
|
| 243 | + $ano = (int) $params['ano']; |
|
| 244 | 244 | |
| 245 | 245 | $response = []; |
| 246 | 246 | |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | { |
| 273 | 273 | $params = $this->params()->fromRoute(); |
| 274 | 274 | |
| 275 | - $ano = (int)$params['ano']; |
|
| 275 | + $ano = (int) $params['ano']; |
|
| 276 | 276 | |
| 277 | 277 | $response = []; |
| 278 | 278 | |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | /** |
| 90 | 90 | * Sets the }). |
| 91 | 91 | * |
| 92 | - * @param \Sector $sector the sector |
|
| 92 | + * @param Sector $sector the sector |
|
| 93 | 93 | * |
| 94 | 94 | * @return self |
| 95 | 95 | */ |