include entities and repos

This commit is contained in:
Kayn Ty 2018-04-04 17:42:27 +02:00
parent 576a9b95ab
commit 06e1dcbb02
31 changed files with 741 additions and 142 deletions

View File

@ -3,6 +3,61 @@
{% block title %}Login{% endblock %} {% block title %}Login{% endblock %}
{% block body %} {% block body %}
<h2>Le login</h2> <h2>Le login</h2>
{% block hwi_oauth_content %} <div class="row">
{% endblock hwi_oauth_content %} <div class="col-xs-6">
<form action="{{ path("fos_user_security_check") }}" method="post">
{#<input type="hidden" name="_csrf_token" value="{{ csrf_token }}"/>#}
{#{{ form_rest(form) }}#}
{% if error %}
<div class="text-danger">{{ error|trans({}, 'FOSUserBundle') }}</div>
{% endif %}
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
{% if last_sername is defined %}
<input type="text" id="username" name="_username" value="{{ last_username }}"
required="required " class="form-control" id="username"
placeholder="{% trans %}Username{% endtrans %}">
{% else %}
<input type="text" id="username" name="_username" value=""
required="required " class="form-control" id="username"
placeholder="{% trans %}Username{% endtrans %}">
{% endif %}
</div>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input type="password" id="password" name="_password" required="required"
class="form-control"
id="password" placeholder="{% trans %}Password{% endtrans %}">
</div>
<input type="checkbox" id="remember_me" name="_remember_me" value="on"/>
<label for="remember_me">{% trans %}Remember me{% endtrans %}</label>
<br>
<!-- <font color=blue Garder ma session active /font>-->
<input type="submit" id="_submit" class="btn btn-primary btn-block" name="_submit"
value="connexion"/>
<br>
<fieldset>
<a href="{{ path("fos_user_resetting_request") }}">
{% trans %}Forgot your password
?{% endtrans %}</a>
<br>
<a href="{{ path('fos_user_registration_register') }}">
{% trans %}You don't have an account
?{% endtrans %} </a>
</fieldset>
</form>
</div>
<div class="col-xs-6">
{#{% block hwi_oauth_content %}#}
{#{% endblock hwi_oauth_content %}#}
</div>
</div>
{% endblock body %} {% endblock body %}

View File

@ -1,19 +1,19 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"/> <meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title> <title>{% block title %}Fiche de compte dynamique{% endblock %}</title>
{% block stylesheets %} {% block stylesheets %}
<link rel="stylesheet" href="{{ asset('build/app.css') }}"> <link rel="stylesheet" href="{{ asset('build/app.css') }}">
{% endblock %} {% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}"/>
</head> </head>
<body> <body>
{% block bigMain %} {% block navigation %}
<div class="container body-block"> {% include 'default/login-choices.html.twig' %}
{% block navigation %}{% endblock %} {% endblock %}
{% block body %}{% endblock %} {% block body %}
<div class="well">
Votre caisse mobile en ligne
</div> </div>
{% endblock %} {% endblock %}
{% block javascripts %} {% block javascripts %}

View File

@ -7,4 +7,5 @@
<i class="fa fa-mail"></i> <i class="fa fa-mail"></i>
contact contact
</a> </a>
- Symfony {{ constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') }}
</sub> </sub>

View File

@ -1,50 +1,38 @@
<div class="main-screen"> <div class="main-screen">
<div id="welcome" class="jumbotron"> <div id="welcome" class="jumbotron text-center">
<h1> <h1>
<span>Welcome to</span> Caisse
Symfony {{ constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') }}
</h1> </h1>
<div class="ajax-test"> <div class="description">
<button class="btn btn-primary" onclick="testAjax( '{{ path('test_ajax') }}' )">test ajax</button> Votre caisse mobile en ligne
</div> </div>
</div> </div>
<div class="product-values">
<div class="row">
<div class="col">
<i class="fa fa-clipboard-check "></i>
<h2>Gratuit</h2>
<p>Gérez votre comptabilité de stand en ligne sans dépenser un rond. Plus besoin de transporter un
inventaire et des feuilles de calcul faites à l'arrache.</p>
</div>
<div class="col">
<i class="fa fa-boxes"></i>
<h2>Flexible</h2>
<p>Modifiez vos produits à la volée, soyez plusieurs à gérer la caisse si vous le souhaitez, changez de
responsable en cours de journée. </p>
</div>
<div class="col">
<i class="fa fa-truck"></i>
<h2>Portable</h2>
<p>Fait pour être utilisé sur les marchés et les salons. Votre gestion des stocks n'en sera que
simplifiée.</p>
</div>
</div>
</div>
<div class="try">
<a href="{{ path('dashboard') }}" class="btn btn-primary">Essayez dès maintenant</a>
</div>
</div> </div>
<script> <script>
function makeRequest(method, url) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open(method, url);
var payload = {stuff: ['one', 'two', 'three'], other: "hah"};
xhr.send(payload);
xhr.onload = function () {
if (this.status >= 200 && this.status < 300) {
resolve(xhr.response);
} else {
reject({
status : this.status,
statusText: xhr.statusText
});
}
};
xhr.onerror = function () {
reject({
status : this.status,
statusText: xhr.statusText
});
};
xhr.send();
});
}
var testAjax = function (url) {
console.log('test ajax');
makeRequest('POST', url)
.then(function (datums) {
console.log(datums);
})
.catch(function (err) {
console.error('Augh, there was an error!', err.statusText);
});
};
</script> </script>

View File

@ -0,0 +1,59 @@
<div class="caisse-main row">
<div class="listing-products col-9">
{% for c in categories %}
{{ c.title }}
{% for p in c.products %}
{{ p.title }}
{% endfor %}
{% endfor %}
</div>
<div class="sellings col-3">
<div class="current-selling">
<form action="">
<ul>
<li>title x1 xxx€</li>
</ul>
<h3>Total: xxx€</h3>
<input type="number" id="paid_amount">
<h3>Rendu: xxxx€</h3>
<div class="row">
<div class="col">
<button class="btn btn-primary" id="pause_selling">
<i class="fa fa-clock"></i>
Pause
</button>
</div>
<div class="col">
<button class="btn btn-primary" id="validate_selling">
<i class="fa fa-check"></i>
Valider
</button>
</div>
</div>
</form>
<hr>
</div>
<div class="selling-on-hold">
<h4>
Ventes en pause
</h4>
<ul>
<li>h:m:s xxxx€</li>
</ul>
<hr>
</div>
<div class="selling-history">
<h4>
Ventes récentes
</h4>
<ul>
<li>h:m:s xxxx€</li>
</ul>
</div>
</div>
</div>

View File

@ -0,0 +1,27 @@
{% extends 'base.html.twig' %}
{% trans_default_domain 'FOSUserBundle' %}
{% block body %}
<div id="wrapper">
<div id="container" class="container">
<div id="menu-dashboard">
<a href="#caisse-now">Caisse</a>
<a href="#categories">Catégories</a>
<a href="#products">Produits</a>
<a href="#history">Historique</a>
</div>
<div id="caisse-now">
<h2>Caisse</h2>
{% include 'logged/caisse-main.html.twig' %}
</div>
<div id="categories">
<h2>Catégories</h2>
</div>
<div id="products">
<h2>Produits</h2>
</div>
<div id="history">
<h2>Historique</h2>
</div>
</div>
</div>
{% endblock %}

View File

@ -30,6 +30,7 @@ security:
#form_login: ~ #form_login: ~
secured_area: secured_area:
anonymous: ~ anonymous: ~
logout_on_user_change: true
oauth: oauth:
resource_owners: resource_owners:
facebook: "/login/check-facebook" facebook: "/login/check-facebook"

View File

@ -25,22 +25,25 @@ class DefaultController extends Controller {
} }
/** /**
* @Route("/test-ajax-request", name="test_ajax") * @Route("/dashboard", name="dashboard")
*/ */
public function testAjaxAction( Request $request ) { public function dashboardAction( Request $request ) {
$req = $request->request; $m = $this->getDoctrine()->getManager();
var_dump( $request->getMethod() ); $currentUser = $this->getUser();
var_dump( $request->isXmlHttpRequest() ); $categRepo = $m->getRepository( 'AppBundle:ProductCategory' );
if ( $request->isXmlHttpRequest() ) { $categories = $categRepo->findAll();
var_dump( $request->get( 'data' ) ); $csrfToken = $this->tokenManager
} ? $this->tokenManager->getToken( 'authenticate' )->getValue()
$recieved = $request->request->get( 'data' ); : null;
// var_dump( $request->request );
$json = [
'test' => 'it works',
'recieved' => $recieved,
];
return new JsonResponse( $json ); // replace this example code with whatever you need
return $this->render( 'logged/dashboard.html.twig',
[
'categories' => $categories,
'currentUser' => $currentUser,
'csrf_token' => $csrfToken,
'base_dir' => realpath( $this->getParameter( 'kernel.project_dir' ) ) . DIRECTORY_SEPARATOR,
] );
} }
} }

View File

@ -0,0 +1,132 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="AppBundle\Repository\ProductRepository")
*/
class Product {
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=100)
*/
private $name;
/**
* @ORM\Column(type="decimal", scale=2, nullable=true)
*/
private $price;
/**
* @ORM\ManyToOne(targetEntity="ProductCategory", inversedBy="products")
*/
private $category;
/**
* @ORM\OneToMany(targetEntity="SellRecord", mappedBy="products")
*/
private $sellRecords;
/**
* @return mixed
*/
public function getId() {
return $this->id;
}
/**
* @param mixed $id
*/
public function setId( $id ) {
$this->id = $id;
}
/**
* @return mixed
*/
public function getName() {
return $this->name;
}
/**
* @param mixed $name
*/
public function setName( $name ) {
$this->name = $name;
}
/**
* @return mixed
*/
public function getPrice() {
return $this->price;
}
/**
* @param mixed $price
*/
public function setPrice( $price ) {
$this->price = $price;
}
/**
* @return mixed
*/
public function getCategory() {
return $this->category;
}
/**
* @param ProductCategory $category
*/
public function setCategory( ProductCategory $category ) {
$this->category = $category;
}
/**
* Constructor
*/
public function __construct()
{
$this->sellRecords = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add sellRecord
*
* @param \AppBundle\Entity\SellRecord $sellRecord
*
* @return Product
*/
public function addSellRecord(\AppBundle\Entity\SellRecord $sellRecord)
{
$this->sellRecords[] = $sellRecord;
return $this;
}
/**
* Remove sellRecord
*
* @param \AppBundle\Entity\SellRecord $sellRecord
*/
public function removeSellRecord(\AppBundle\Entity\SellRecord $sellRecord)
{
$this->sellRecords->removeElement($sellRecord);
}
/**
* Get sellRecords
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getSellRecords()
{
return $this->sellRecords;
}
}

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Entity; namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;

View File

@ -0,0 +1,98 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="AppBundle\Repository\ProductCategoryRepository")
*/
class ProductCategory {
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=100)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="Product", mappedBy="category")
*/
private $products;
/**
* @return mixed
*/
public function getProducts() {
return $this->products;
}
/**
* @param mixed $products
*/
public function setProducts( $products ) {
$this->products = $products;
}
/**
* @return mixed
*/
public function getId() {
return $this->id;
}
/**
* @param mixed $id
*/
public function setId( $id ) {
$this->id = $id;
}
/**
* @return mixed
*/
public function getName() {
return $this->name;
}
/**
* @param mixed $name
*/
public function setName( $name ) {
$this->name = $name;
}
/**
* Constructor
*/
public function __construct() {
$this->products = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add product
*
* @param \AppBundle\Entity\Product $product
*
* @return ProductCategory
*/
public function addProduct( \AppBundle\Entity\Product $product ) {
$this->products[] = $product;
return $this;
}
/**
* Remove product
*
* @param \AppBundle\Entity\Product $product
*/
public function removeProduct( \AppBundle\Entity\Product $product ) {
$this->products->removeElement( $product );
}
}

View File

@ -1,8 +1,9 @@
<?php <?php
namespace App\Entity; namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity(repositoryClass="App\Repository\ProductCategoryRepository") * @ORM\Entity(repositoryClass="App\Repository\ProductCategoryRepository")
*/ */

View File

@ -1,11 +1,11 @@
<?php <?php
namespace App\Entity; namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity(repositoryClass="App\Repository\SellRecordRepository") * @ORM\Entity(repositoryClass="AppBundle\Repository\SellRecordRepository")
*/ */
class SellRecord { class SellRecord {
/** /**

View File

@ -0,0 +1,66 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\SellRecordRepository")
*/
class SellRecord {
/**
* @ORM\ManyToOne(targetEntity="Product", inversedBy="sellRecords")
*/
private $products;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="datetime")
*/
private $date;
/**
* @return mixed
*/
public function getId() {
return $this->id;
}
/**
* @param mixed $id
*/
public function setId( $id ) {
$this->id = $id;
}
/**
* @return mixed
*/
public function getProducts() {
return $this->products;
}
/**
* @param mixed $products
*/
public function setProducts( $products ) {
$this->products = $products;
}
/**
* @return mixed
*/
public function getDate() {
return $this->date;
}
/**
* @param mixed $date
*/
public function setDate( $date ) {
$this->date = $date;
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Stuff
*
* @ORM\Table(name="stuff")
* @ORM\Entity(repositoryClass="AppBundle\Repository\StuffRepository")
*/
class Stuff
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="truc", type="string", length=255)
*/
private $truc;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set truc
*
* @param string $truc
*
* @return Stuff
*/
public function setTruc($truc)
{
$this->truc = $truc;
return $this;
}
/**
* Get truc
*
* @return string
*/
public function getTruc()
{
return $this->truc;
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Stuff
*
* @ORM\Table(name="stuff")
* @ORM\Entity(repositoryClass="AppBundle\Repository\StuffRepository")
*/
class Stuff
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="truc", type="string", length=255)
*/
private $truc;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set truc
*
* @param string $truc
*
* @return Stuff
*/
public function setTruc($truc)
{
$this->truc = $truc;
return $this;
}
/**
* Get truc
*
* @return string
*/
public function getTruc()
{
return $this->truc;
}
}

View File

@ -21,6 +21,12 @@ class User extends BaseUser {
*/ */
protected $id; protected $id;
/**
* @ORM\Column(name="google_id", type="string", length=255, nullable=true)
*/
private $googleId;
private $googleAccessToken;
/** /**
* Get id * Get id
@ -30,5 +36,28 @@ class User extends BaseUser {
public function getId() { public function getId() {
return $this->id; return $this->id;
} }
/**
* Set googleId
*
* @param string $googleId
*
* @return User
*/
public function setGoogleId($googleId)
{
$this->googleId = $googleId;
return $this;
} }
/**
* Get googleId
*
* @return string
*/
public function getGoogleId()
{
return $this->googleId;
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;
/**
* User
*
* @ORM\Table(name="custom_user")
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
*/
class User extends BaseUser {
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="google_id", type="string", length=255, nullable=true)
*/
private $googleId;
private $googleAccessToken;
/**
* Get id
*
* @return int
*/
public function getId() {
return $this->id;
}
}

View File

@ -0,0 +1,12 @@
<?php
namespace AppBundle\Repository;
/**
* StuffRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class ProductCategoryRepository extends \Doctrine\ORM\EntityRepository {
}

View File

@ -0,0 +1,12 @@
<?php
namespace AppBundle\Repository;
/**
* StuffRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class ProductRepository extends \Doctrine\ORM\EntityRepository {
}

View File

@ -0,0 +1,12 @@
<?php
namespace AppBundle\Repository;
/**
* StuffRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class SellRecordRepository extends \Doctrine\ORM\EntityRepository {
}

View File

@ -8,6 +8,5 @@ namespace AppBundle\Repository;
* This class was generated by the Doctrine ORM. Add your own custom * This class was generated by the Doctrine ORM. Add your own custom
* repository methods below. * repository methods below.
*/ */
class UserRepository extends \Doctrine\ORM\EntityRepository class UserRepository extends \Doctrine\ORM\EntityRepository {
{
} }

View File

View File

@ -1,24 +0,0 @@
<?php
namespace App\Entity\User;
use MsgPhp\User\Entity\User as BaseUser;
use MsgPhp\User\UserIdInterface;
/**
* @final
*/
class User extends BaseUser
{
private $id;
public function __construct(UserIdInterface $id)
{
$this->id = $id;
}
public function getId(): UserIdInterface
{
return $this->id;
}
}

View File

@ -1,20 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}Fiche de compte dynamique{% endblock %}</title>
{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('build/css/app.css') }}">
{% endblock %}
</head>
<body>
{% block body %}
<div class="well">
Votre caisse mobile en ligne
</div>
{% endblock %}
{% block javascripts %}
<script src="{{ asset('build/js/app.js') }}"></script>
{% endblock %}
</body>
</html>

View File

@ -1,19 +0,0 @@
<div class="page">
le contenu
<h1>Page 1</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci dicta dolores eligendi facilis in inventore
libero, maiores modi, natus nesciunt nostrum quae quas quasi sit unde vel veniam veritatis voluptas!</p>
</div>
<div class="page">
<h1>Page 2</h1>
<p> etur adipisicing elit. Alias autem beatae dolorum impedit incidunt iusto necessitatibus, nulla perspiciatis
placeat repellat, suscipit vel! Aspernatur commodi consequuntur delectus dolore doloribus eaque exercitationem
incidunt inventore ipsum libero molestiae nesciunt non nostrum nulla, numquam porro, possimus quia quibusdam
ratione recusandae sed sunt totam veniam.</p>
</div>
<style>
.page {
page-break-after: always;
}
</style>

View File

@ -1 +0,0 @@
footer tadam

View File

@ -1 +0,0 @@
header hopla

View File

@ -1 +0,0 @@
<xml></xml>