@@ -22,7 +22,7 @@ |
||
| 22 | 22 | $configOverrides = []; |
| 23 | 23 | |
| 24 | 24 | $this->setApplicationConfig(ArrayUtils::merge( |
| 25 | - include __DIR__ . '/../../../../config/application.config.php', |
|
| 25 | + include __DIR__.'/../../../../config/application.config.php', |
|
| 26 | 26 | $configOverrides |
| 27 | 27 | )); |
| 28 | 28 | |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | $configOverrides = []; |
| 23 | 23 | |
| 24 | 24 | $this->setApplicationConfig(ArrayUtils::merge( |
| 25 | - include __DIR__ . '/../../../../config/application.config.php', |
|
| 25 | + include __DIR__.'/../../../../config/application.config.php', |
|
| 26 | 26 | $configOverrides |
| 27 | 27 | )); |
| 28 | 28 | |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | $configOverrides = []; |
| 23 | 23 | |
| 24 | 24 | $this->setApplicationConfig(ArrayUtils::merge( |
| 25 | - include __DIR__ . '/../../../../config/application.config.php', |
|
| 25 | + include __DIR__.'/../../../../config/application.config.php', |
|
| 26 | 26 | $configOverrides |
| 27 | 27 | )); |
| 28 | 28 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $configOverrides = []; |
| 27 | 27 | |
| 28 | 28 | $this->setApplicationConfig(ArrayUtils::merge( |
| 29 | - include __DIR__ . '/../../../../config/application.config.php', |
|
| 29 | + include __DIR__.'/../../../../config/application.config.php', |
|
| 30 | 30 | $configOverrides |
| 31 | 31 | )); |
| 32 | 32 | |
@@ -54,6 +54,6 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | protected function getDataSet() |
| 56 | 56 | { |
| 57 | - return $this->createXMLDataSet(__DIR__ . '/../fixtures/database.xml'); |
|
| 57 | + return $this->createXMLDataSet(__DIR__.'/../fixtures/database.xml'); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | \ No newline at end of file |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | $configOverrides = []; |
| 23 | 23 | |
| 24 | 24 | $this->setApplicationConfig(ArrayUtils::merge( |
| 25 | - include __DIR__ . '/../../../../config/application.config.php', |
|
| 25 | + include __DIR__.'/../../../../config/application.config.php', |
|
| 26 | 26 | $configOverrides |
| 27 | 27 | )); |
| 28 | 28 | |
@@ -24,4 +24,4 @@ |
||
| 24 | 24 | ], |
| 25 | 25 | ], |
| 26 | 26 | ]; |
| 27 | - |
|
| 28 | 27 | \ No newline at end of file |
| 28 | + |
|
| 29 | 29 | \ No newline at end of file |
@@ -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 | */ |
@@ -6,14 +6,14 @@ |
||
| 6 | 6 | |
| 7 | 7 | class EmissionRepository extends EntityRepository |
| 8 | 8 | { |
| 9 | - public function findAllBySector($year) |
|
| 10 | - { |
|
| 11 | - return $this->createQueryBuilder() |
|
| 12 | - ->from() |
|
| 13 | - ->join() |
|
| 14 | - ->where() |
|
| 15 | - ->groupBy() |
|
| 16 | - ->setParameter() |
|
| 17 | - ->getResult(':year', $year); |
|
| 18 | - } |
|
| 9 | + public function findAllBySector($year) |
|
| 10 | + { |
|
| 11 | + return $this->createQueryBuilder() |
|
| 12 | + ->from() |
|
| 13 | + ->join() |
|
| 14 | + ->where() |
|
| 15 | + ->groupBy() |
|
| 16 | + ->setParameter() |
|
| 17 | + ->getResult(':year', $year); |
|
| 18 | + } |
|
| 19 | 19 | } |
| 20 | 20 | \ No newline at end of file |