export user data in json

This commit is contained in:
ty kayn 2019-07-05 16:41:33 +02:00
parent 19c7935f58
commit fa5fdfa180
19 changed files with 1127 additions and 528 deletions

View File

@ -7,7 +7,7 @@
<h1>Historique</h1> <h1>Historique</h1>
</div> </div>
<div class="row"> <div class="row">
<div class="col-xs-6"> <div class="col-xs-12">
<div class="sells"> <div class="sells">
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
@ -51,7 +51,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-xs-6 text-right"> <div class="col-xs-12 ">
<h2>Exporter toutes vos données</h2> <h2>Exporter toutes vos données</h2>
<a class="btn btn-success" href="{{ path('export_all') }}"> <a class="btn btn-success" href="{{ path('export_all') }}">
<i class="fa fa-file-excel-o fa-3x"></i> <i class="fa fa-file-excel-o fa-3x"></i>

View File

@ -80,7 +80,7 @@ code {
@media (min-width: 768px) { @media (min-width: 768px) {
#wrapper { #wrapper {
width: 80%; //width: 80%;
margin: 2em auto; margin: 2em auto;
} }

View File

@ -33,6 +33,7 @@
"sonata-project/admin-bundle": "^3.38", "sonata-project/admin-bundle": "^3.38",
"symfony/monolog-bundle": "^3.1.0", "symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0", "symfony/polyfill-apcu": "^1.0",
"symfony/serializer": "^4.3",
"symfony/swiftmailer-bundle": "^2.6.4", "symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "~3.4", "symfony/symfony": "~3.4",
"symfony/templating": "^4.0", "symfony/templating": "^4.0",

File diff suppressed because it is too large Load Diff

0
src/AppBundle/Entity/ExpenseKind.php Executable file → Normal file
View File

View File

@ -0,0 +1,200 @@
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* ExpenseKind, for previsional compta
*
* @ORM\Table(name="expense_kind")
* @ORM\Entity(repositoryClass="AppBundle\Repository\ExpenseKindRepository")
*/
class ExpenseKind
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var int|null
*
* @ORM\Column(name="delay", type="integer", nullable=true)
*/
private $delay;
/**
* line enabled to calculate on
*
* @ORM\Column(name="enabled", type="boolean", nullable=true)
*/
private $enabled;
/**
* @var int|null
*
* @ORM\Column(name="repeatitions", type="integer", nullable=true)
*/
private $repeatitions;
/**
* @var float
*
* @ORM\Column(name="amount", type="float")
*/
private $amount;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="expenses")
*/
private $user;
/**
* @return int|null
*/
public function getEnabled()
{
return $this->enabled;
}
/**
* @param int|null $enabled
*/
public function setEnabled($enabled)
{
$this->enabled = $enabled;
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return mixed
*/
public function getUser()
{
return $this->user;
}
/**
* @param mixed $user
*/
public function setUser($user)
{
$this->user = $user;
}
/**
* Set name.
*
* @param string $name
*
* @return ExpenseKind
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set delay.
*
* @param int|null $delay
*
* @return ExpenseKind
*/
public function setDelay($delay = null)
{
$this->delay = $delay;
return $this;
}
/**
* Get delay.
*
* @return int|null
*/
public function getDelay()
{
return $this->delay;
}
/**
* Set repeatitions.
*
* @param int|null $repeatitions
*
* @return ExpenseKind
*/
public function setRepeatitions($repeatitions = null)
{
$this->repeatitions = $repeatitions;
return $this;
}
/**
* Get repeatitions.
*
* @return int|null
*/
public function getRepeatitions()
{
return $this->repeatitions;
}
/**
* Set amount.
*
* @param float $amount
*
* @return ExpenseKind
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* Get amount.
*
* @return float
*/
public function getAmount()
{
return $this->amount;
}
}

0
src/AppBundle/Entity/Festival.php Executable file → Normal file
View File

View File

@ -40,7 +40,7 @@ class Festival {
/** /**
* @var \stdClass * @var \stdClass
* *
* @ORM\OneToMany(targetEntity="AppBundle\Entity\SellRecord",mappedBy="festival") * @ORM\OneToMany(targetEntity="AppBundle\Entity\SellRecord",mappedBy="festival", cascade={"remove"})
*/ */
private $sellRecords; private $sellRecords;
@ -48,6 +48,10 @@ class Festival {
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="festivals") * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="festivals")
*/ */
private $user; private $user;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\SerieFestival", inversedBy="festivals")
*/
private $serieFestival;
/** /**
* @var * @var
@ -83,11 +87,42 @@ class Festival {
private $fraisRepas; private $fraisRepas;
public function __toString() {
return $this->getName();
}
/**
* @return mixed
*/
public function getSerieFestival()
{
return $this->serieFestival;
}
/**
* @param mixed $serieFestival
*/
public function setSerieFestival($serieFestival)
{
$this->serieFestival = $serieFestival;
}
/** /**
* array usable by js * array usable by js
* @return array * @return array
*/ */
public function makeArray(){ public function makeArray(){
$sellRecords = $this->getSellRecords();
$soldItems = [];
foreach ( $sellRecords as $sell_record ) {
foreach ( $sell_record->getProductsSold() as $sold ) {
if(!isset($soldItems[$sold->getProduct()->getId()])){
$soldItems[$sold->getProduct()->getId()] = 0;
}
$soldItems[$sold->getProduct()->getId()]++;
}
}
return [ return [
'id' => $this->getId(), 'id' => $this->getId(),
'name' => $this->getName(), 'name' => $this->getName(),
@ -97,8 +132,9 @@ class Festival {
'clientsCount' => count($this->getSellRecords()), 'clientsCount' => count($this->getSellRecords()),
'fondDeCaisseAvant' => $this->getFondDeCaisseAvant(), 'fondDeCaisseAvant' => $this->getFondDeCaisseAvant(),
'fondDeCaisseApres' => $this->getFondDeCaisseApres(), 'fondDeCaisseApres' => $this->getFondDeCaisseApres(),
'sold' => $soldItems,
]; ];
} }
public function recalculateChiffreAffaire() { public function recalculateChiffreAffaire() {
$sellings = $this->getSellRecords(); $sellings = $this->getSellRecords();

0
src/AppBundle/Entity/Product.php Executable file → Normal file
View File

View File

@ -43,7 +43,7 @@ class Product {
*/ */
private $user; private $user;
/** /**
* @ORM\OneToMany(targetEntity="AppBundle\Entity\ProductSold", mappedBy="product") * @ORM\OneToMany(targetEntity="AppBundle\Entity\ProductSold", mappedBy="product", cascade={"remove"})
*/ */
private $productsSold; private $productsSold;

0
src/AppBundle/Entity/ProductCategory.php Executable file → Normal file
View File

View File

@ -21,11 +21,11 @@ class ProductCategory {
private $name; private $name;
/** /**
* @ORM\OneToMany(targetEntity="Product", mappedBy="category") * @ORM\OneToMany(targetEntity="Product", mappedBy="category", cascade={"remove"})
*/ */
private $products; private $products;
/** /**
* @ORM\OneToMany(targetEntity="ProductSold", mappedBy="product") * @ORM\OneToMany(targetEntity="ProductSold", mappedBy="product", cascade={"remove"})
*/ */
private $productsSold; private $productsSold;

0
src/AppBundle/Entity/ProductSold.php Executable file → Normal file
View File

0
src/AppBundle/Entity/SellRecord.php Executable file → Normal file
View File

View File

@ -24,7 +24,7 @@ class SellRecord {
private $gender; private $gender;
/** /**
* liste des produits de la vente * liste des produits de la vente
* @ORM\OneToMany(targetEntity="AppBundle\Entity\ProductSold", mappedBy="sellRecords") * @ORM\OneToMany(targetEntity="AppBundle\Entity\ProductSold", mappedBy="sellRecords", cascade={"remove", "persist","detach"})
*/ */
private $productsSold; private $productsSold;

33
src/AppBundle/Entity/SerieFestival.php Executable file → Normal file
View File

@ -127,4 +127,37 @@ class SerieFestival {
{ {
$this->dateCreation = $dateCreation; $this->dateCreation = $dateCreation;
} }
/**
* Constructor
*/
public function __construct()
{
$this->festivals = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add festival.
*
* @param \AppBundle\Entity\Festival $festival
*
* @return SerieFestival
*/
public function addFestival(\AppBundle\Entity\Festival $festival)
{
$this->festivals[] = $festival;
return $this;
}
/**
* Remove festival.
*
* @param \AppBundle\Entity\Festival $festival
*
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
*/
public function removeFestival(\AppBundle\Entity\Festival $festival)
{
return $this->festivals->removeElement($festival);
}
} }

View File

@ -0,0 +1,130 @@
<?php
namespace AppBundle\Entity;
use AppBundle\Traits\Commentable;
use Doctrine\ORM\Mapping as ORM;
/**
* Festival
*
* @ORM\Table(name="serieFestival")
* @ORM\Entity(repositoryClass="AppBundle\Repository\FestivalRepository")
*/
class SerieFestival {
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* variabilised products sold
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Festival", mappedBy="serieFestival")
*/
private $festivals;
/**
* @var \DateTime
*
* @ORM\Column(name="dateCreation", type="datetime")
*/
private $dateCreation;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="seriesFestivals")
*/
private $user;
/**
* @return mixed
*/
public function getUser()
{
return $this->user;
}
/**
* @param mixed $user
*/
public function setUser($user)
{
$this->user = $user;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return mixed
*/
public function getFestivals()
{
return $this->festivals;
}
/**
* @param mixed $festivals
*/
public function setFestivals($festivals)
{
$this->festivals = $festivals;
}
/**
* @return \DateTime
*/
public function getDateCreation()
{
return $this->dateCreation;
}
/**
* @param \DateTime $dateCreation
*/
public function setDateCreation($dateCreation)
{
$this->dateCreation = $dateCreation;
}
}

83
src/AppBundle/Entity/User.php Executable file → Normal file
View File

@ -35,6 +35,10 @@ class User extends BaseUser {
* @ORM\Column(name="google_id", type="string", length=255, nullable=true) * @ORM\Column(name="google_id", type="string", length=255, nullable=true)
*/ */
private $googleId; private $googleId;
/**
* @ORM\Column(name="mastodon_id", type="string", length=255, nullable=true)
*/
private $mastodonId;
private $googleAccessToken; private $googleAccessToken;
/** /**
@ -76,11 +80,12 @@ class User extends BaseUser {
private $averageMonthlyEarnings; private $averageMonthlyEarnings;
/** /**
* available money, for previsionnel calculation
* @ORM\Column(name="disponibility", type="float", nullable=true) * @ORM\Column(name="disponibility", type="float", nullable=true)
*/ */
private $disponibility; private $disponibility;
/** /**
* variabilised products sold * expenses by kind, for previsionnel
* @ORM\OneToMany(targetEntity="AppBundle\Entity\ExpenseKind", mappedBy="user") * @ORM\OneToMany(targetEntity="AppBundle\Entity\ExpenseKind", mappedBy="user")
*/ */
private $expenses; private $expenses;
@ -468,4 +473,80 @@ class User extends BaseUser {
public function getDisqusId() { public function getDisqusId() {
return $this->disqusId; return $this->disqusId;
} }
/**
* Set mastodonId.
*
* @param string|null $mastodonId
*
* @return User
*/
public function setMastodonId($mastodonId = null)
{
$this->mastodonId = $mastodonId;
return $this;
}
/**
* Get mastodonId.
*
* @return string|null
*/
public function getMastodonId()
{
return $this->mastodonId;
}
/**
* Add seriesFestival.
*
* @param \AppBundle\Entity\SerieFestival $seriesFestival
*
* @return User
*/
public function addSeriesFestival(\AppBundle\Entity\SerieFestival $seriesFestival)
{
$this->seriesFestivals[] = $seriesFestival;
return $this;
}
/**
* Remove seriesFestival.
*
* @param \AppBundle\Entity\SerieFestival $seriesFestival
*
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
*/
public function removeSeriesFestival(\AppBundle\Entity\SerieFestival $seriesFestival)
{
return $this->seriesFestivals->removeElement($seriesFestival);
}
/**
* Add expense.
*
* @param \AppBundle\Entity\ExpenseKind $expense
*
* @return User
*/
public function addExpense(\AppBundle\Entity\ExpenseKind $expense)
{
$this->expenses[] = $expense;
return $this;
}
/**
* Remove expense.
*
* @param \AppBundle\Entity\ExpenseKind $expense
*
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
*/
public function removeExpense(\AppBundle\Entity\ExpenseKind $expense)
{
return $this->expenses->removeElement($expense);
}
} }

View File

@ -35,9 +35,16 @@ class User extends BaseUser {
* @ORM\Column(name="google_id", type="string", length=255, nullable=true) * @ORM\Column(name="google_id", type="string", length=255, nullable=true)
*/ */
private $googleId; private $googleId;
/**
* @ORM\Column(name="mastodon_id", type="string", length=255, nullable=true)
*/
private $mastodonId;
private $googleAccessToken; private $googleAccessToken;
/**
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\ProductCategory", inversedBy="users")
*/
private $categories;
/** /**
* templates products * templates products
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Product", mappedBy="user") * @ORM\OneToMany(targetEntity="AppBundle\Entity\Product", mappedBy="user")
@ -54,17 +61,96 @@ class User extends BaseUser {
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Festival", mappedBy="user") * @ORM\OneToMany(targetEntity="AppBundle\Entity\Festival", mappedBy="user")
*/ */
private $festivals; private $festivals;
/** /**
* current festival we are recording sellings for * series of festivals
* @ORM\OneToOne(targetEntity="AppBundle\Entity\Festival") * @ORM\OneToMany(targetEntity="AppBundle\Entity\SerieFestival", mappedBy="user")
*/ */
private $activeFestival; private $seriesFestivals;
/**
* current festival we are recording sellings for
* @ORM\OneToOne(targetEntity="AppBundle\Entity\Festival")
*/
private $activeFestival;
//expenses previsionnel configs
/**
* @ORM\Column(name="averageMonthlyEarnings", type="float", nullable=true)
*/
private $averageMonthlyEarnings;
/**
* available money, for previsionnel calculation
* @ORM\Column(name="disponibility", type="float", nullable=true)
*/
private $disponibility;
/** /**
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\ProductCategory", inversedBy="users") * expenses by kind, for previsionnel
* @ORM\OneToMany(targetEntity="AppBundle\Entity\ExpenseKind", mappedBy="user")
*/ */
private $categories; private $expenses;
/**
* @return mixed
*/
public function getAverageMonthlyEarnings()
{
return $this->averageMonthlyEarnings;
}
/**
* @param mixed $averageMonthlyEarnings
*/
public function setAverageMonthlyEarnings($averageMonthlyEarnings)
{
$this->averageMonthlyEarnings = $averageMonthlyEarnings;
}
/**
* @return mixed
*/
public function getDisponibility()
{
return $this->disponibility;
}
/**
* @param mixed $disponibility
*/
public function setDisponibility($disponibility)
{
$this->disponibility = $disponibility;
}
/**
* @return mixed
*/
public function getSeriesFestivals()
{
return $this->seriesFestivals;
}
/**
* @param mixed $seriesFestivals
*/
public function setSeriesFestivals($seriesFestivals)
{
$this->seriesFestivals = $seriesFestivals;
}
/**
* @return mixed
*/
public function getExpenses()
{
return $this->expenses;
}
/**
* @param mixed $expenses
*/
public function setExpenses($expenses)
{
$this->expenses = $expenses;
}
/** /**
* @return mixed * @return mixed