Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony #2

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/.web-server-pid
/app/config/parameters.yml
/build/
/phpunit.xml
/var/*
!/var/cache
/var/cache/*
!var/cache/.gitkeep
!/var/logs
/var/logs/*
!var/logs/.gitkeep
!/var/sessions
/var/sessions/*
!var/sessions/.gitkeep
!var/SymfonyRequirements.php
/vendor/
/web/bundles/
/myconfig/
44 changes: 38 additions & 6 deletions CreateTables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,45 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
Create the used Database structure and then grant access to the database tables with SELECT,INSERT,UPDATE privileges.
map these user and password into config.php MYSQL_USER and MYSQL_PASS.
Create the used Database structure and then grant access to the database tables with SELECT,INSERT,UPDATE,DELETE privileges.
map these user and password into parameters.yml 'database_user:' and 'database_password:'.
* Author: mysli
* Created: 24.07.2017
* Created: 14.08.2017
*/

CREATE DATABASE `consumption`;
CREATE TABLE `consumption`.`epower` ( `CaptureDate` DATE NULL DEFAULT NULL , `SubmitDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `Value` INT(9) NULL , `AbsoluteValue` INT(11) NOT NULL , `Note` TEXT NULL DEFAULT NULL ) ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_german2_ci;
CREATE TABLE `consumption`.`gas` ( `CaptureDate` DATE NULL DEFAULT NULL , `SubmitDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `Value` INT(9) NULL , `AbsoluteValue` INT(11) NOT NULL , `Note` TEXT NULL DEFAULT NULL ) ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_german2_ci;
CREATE TABLE `consumption`.`water` ( `CaptureDate` DATE NULL DEFAULT NULL , `SubmitDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `Value` INT(9) NULL , `AbsoluteValue` INT(11) NOT NULL , `Note` TEXT NULL DEFAULT NULL ) ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_german2_ci;
CREATE TABLE IF NOT EXISTS `epower` (
`captureDate` date NOT NULL,
`submitDate` datetime NOT NULL,
`value` int(11) NOT NULL,
`AbsoluteValue` int(11) NOT NULL,
`note` varchar(255) COLLATE utf8_german2_ci DEFAULT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
UNIQUE KEY `UNIQ_8453C9F7342E0551` (`submitDate`),
UNIQUE KEY `UNIQ_8453C9F75B39DB79` (`AbsoluteValue`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_german2_ci;

CREATE TABLE IF NOT EXISTS `gas` (
`captureDate` date NOT NULL,
`submitDate` datetime NOT NULL,
`value` int(11) NOT NULL,
`AbsoluteValue` int(11) NOT NULL,
`note` varchar(255) COLLATE utf8_german2_ci DEFAULT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
UNIQUE KEY `UNIQ_8453C9F7342E0551` (`submitDate`),
UNIQUE KEY `UNIQ_8453C9F75B39DB79` (`AbsoluteValue`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_german2_ci;

CREATE TABLE IF NOT EXISTS `water` (
`captureDate` date NOT NULL,
`submitDate` datetime NOT NULL,
`value` int(11) NOT NULL,
`AbsoluteValue` int(11) NOT NULL,
`note` varchar(255) COLLATE utf8_german2_ci DEFAULT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
UNIQUE KEY `UNIQ_8453C9F7342E0551` (`submitDate`),
UNIQUE KEY `UNIQ_8453C9F75B39DB79` (`AbsoluteValue`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_german2_ci;
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PhpProject1
===========

A Symfony project created on July 30, 2017, 10:56 pm.
7 changes: 7 additions & 0 deletions app/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
7 changes: 7 additions & 0 deletions app/AppCache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;

class AppCache extends HttpCache
{
}
57 changes: 57 additions & 0 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel

{
public function registerBundles()
{
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
//added according https://symfony.com/doc/master/bundles/StofDoctrineExtensionsBundle/index.html
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
];

if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();

if ('dev' === $this->getEnvironment()) {
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
}
}

return $bundles;
}

public function getRootDir()
{
return __DIR__;
}

public function getCacheDir()
{
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
}

public function getLogDir()
{
return dirname(__DIR__).'/var/logs';
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}
57 changes: 57 additions & 0 deletions app/Resources/views/base.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">

<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />

<title>{% block title %}Your Ressource Consumption{% endblock %}</title>

<!-- Bootstrap core CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
{% block stylesheets %}{% endblock %}

</head>

<body>

<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Ressource Consumption Monitor</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/">Home</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>

<div class="container">
<div class="row">
{% for flash_message in app.session.flashbag.get('notice')%}
<div class="alert alert-success">{{flash_message}}</div>
{%endfor%}
<div class="col-md-12">
{% block body %}{% endblock %}
<div></div>

</div><!-- /.container -->


{% block javascripts %}{% endblock %}
</body>
</html>

8 changes: 8 additions & 0 deletions app/Resources/views/consumptionmonitor/add.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'base.html.twig' %}
{% block body %}
{% block header %}
{{form_start(form)}}
{{form_widget(form)}}
{{form_end(form)}}
{% endblock %}
{% endblock %}
4 changes: 4 additions & 0 deletions app/Resources/views/consumptionmonitor/capture.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends 'base.html.twig' %}
{% block body %}
CAPTURE
{% endblock %}
7 changes: 7 additions & 0 deletions app/Resources/views/consumptionmonitor/editEpower.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends 'consumptionmonitor/editconsumption.html.twig' %}
{% block header %}
<h2>Bearbeite die markierte Zeile Elektroenergie</h2>
{% endblock %}



4 changes: 4 additions & 0 deletions app/Resources/views/consumptionmonitor/editGas.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends 'consumptionmonitor/editconsumption.html.twig' %}
{% block header %}
<h2>Bearbeite die markierte Zeile Gas</h2>
{% endblock %}
4 changes: 4 additions & 0 deletions app/Resources/views/consumptionmonitor/editWater.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends 'consumptionmonitor/editconsumption.html.twig' %}
{% block header %}
<h2>Bearbeite die markierte Zeile Wasser</h2>
{% endblock %}
44 changes: 44 additions & 0 deletions app/Resources/views/consumptionmonitor/editconsumption.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{% extends 'base.html.twig' %}
{% block body %}
{% block header %}
{% endblock %}
<div class="bs-example" data-example-id="striped-table">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Datum</th>
<th>Zählerstand</th>
<th>Durschnitt/Tag</th>
<th>Optionen</th>
</tr>
</thead>
<tbody>
{%for counter in consumption %}
{%if counter.id==edit.id %}
<tr>{{form_start(form)}}
<th scope="row">{{edit.id}}</th>
{{form_errors(form)}}
<td> {{form_widget(form.captureDate)}} </td>
<td> {{form_widget(form.value)}} </td>
<td> - </td>
<td> {{form_widget(form.note)}} </td>
<td> {{form_widget(form.save)}} </td>
<td> {{form_widget(form.cancel)}} </td>
{{form_end(form)}}
</tr>
{%else%}
<tr> <th scope="row">{{counter.id}}</th>
<td>{{counter.captureDate|date('d.m.Y')}}</td>
<td>{{counter.value}}</td>
<td>-</td>
<td>{{counter.note}}</td>
{% block options %}
{% endblock %}
</tr>
{%endif%}
{%endfor%}

</tbody>
</table> </div>
{% endblock %}
34 changes: 34 additions & 0 deletions app/Resources/views/consumptionmonitor/index.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% extends 'base.html.twig' %}
{% block body %}
<div class="bs-example" data-example-id="striped-table">
<table class="table table-striped">
<thead>
<tr>
<th>Ressource</th>
<th>Zählerstand</th>
<th>Durschnitt/Tag</th>
<th>Optionen</th>
</tr>
</thead>
<tbody>
<tr> <th scope="row">1</th>
<td>Elektroenergie</td>
<td>xx</td>
<td><a href="/consumptionmonitor/addEpower" class="btn btn-success">Hinzuf&uuml;gen</a> <a href="/consumptionmonitor/listEpower" class="btn btn-success">Auflisten</a></td>
</tr>
<tr> <th scope="row">1</th>
<td>Gas</td>
<td>xx</td>
<td><a href="/consumptionmonitor/addGas" class="btn btn-warning">Hinzuf&uuml;gen</a> <a href="/consumptionmonitor/listGas" class="btn btn-success">Auflisten</a></td>
</tr>

<tr> <th scope="row">1</th>
<td>Wasser</td>
<td>xx</td>
<td><a href="/consumptionmonitor/addWater" class="btn btn-primary">Hinzuf&uuml;gen</a> <a href="/consumptionmonitor/listWater" class="btn btn-success">Auflisten</a></td>
</tr>

</tbody>
</table> </div>
{% endblock %}

8 changes: 8 additions & 0 deletions app/Resources/views/consumptionmonitor/listEpower.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'consumptionmonitor/listconsumptions.html.twig' %}

{% block header %}
<h1>Elektroenergie </h1>
{% endblock %}
{% block options %}
<td><a href="/consumptionmonitor/editEpower/{{counter.id}}" class="btn btn-success">Bearbeiten</a> <a href="/consumptionmonitor/deleteEpower/{{counter.id}}" class="btn btn-success">L&ouml;schen</a></td>
{% endblock %}
8 changes: 8 additions & 0 deletions app/Resources/views/consumptionmonitor/listGas.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'consumptionmonitor/listconsumptions.html.twig' %}

{% block header %}
<h1>Gas </h1>
{% endblock %}
{% block options %}
<td><a href="/consumptionmonitor/editGas/{{counter.id}}" class="btn btn-success">Bearbeiten</a> <a href="/consumptionmonitor/deleteGas/{{counter.id}}" class="btn btn-success">L&ouml;schen</a></td>
{% endblock %}
32 changes: 32 additions & 0 deletions app/Resources/views/consumptionmonitor/listconsumptions.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% extends 'base.html.twig' %}
{% block body %}
{% block header %}
{% endblock %}
<div class="bs-example" data-example-id="striped-table">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Datum</th>
<th>Zählerstand</th>
<th>Durschnitt/Tag</th>
<th>Bemerkung</th>
<th>Optionen</th>
</tr>
</thead>
<tbody>
{%for counter in consumption %}
<tr> <th scope="row">{{counter.id}}</th>
<td>{{counter.captureDate|date('d.m.Y')}}</td>
<td>{{counter.value}}</td>
<td>{{counter.dailyAvg}}</td>
<td>{{counter.note}}</td>

{% block options %}
{% endblock %}
</tr>
{%endfor%}

</tbody>
</table> </div>
{% endblock %}
8 changes: 8 additions & 0 deletions app/Resources/views/consumptionmonitor/listwater.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'consumptionmonitor/listconsumptions.html.twig' %}

{% block header %}
<h1>Wasser </h1>
{% endblock %}
{% block options %}
<td><a href="/consumptionmonitor/editWater/{{counter.id}}" class="btn btn-success">Bearbeiten</a> <a href="/consumptionmonitor/deleteWater/{{counter.id}}" class="btn btn-success">L&ouml;schen</a></td>
{% endblock %}
5 changes: 5 additions & 0 deletions app/Resources/views/consumptionmonitor/report.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends 'base.html.twig' %}
{% block body %}
REPORT
{% endblock %}

Loading