⚡ export user data in json
This commit is contained in:
parent
19c7935f58
commit
fa5fdfa180
@ -7,7 +7,7 @@
|
||||
<h1>Historique</h1>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<div class="col-xs-12">
|
||||
<div class="sells">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-4">
|
||||
@ -51,7 +51,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-6 text-right">
|
||||
<div class="col-xs-12 ">
|
||||
<h2>Exporter toutes vos données</h2>
|
||||
<a class="btn btn-success" href="{{ path('export_all') }}">
|
||||
<i class="fa fa-file-excel-o fa-3x"></i>
|
||||
|
@ -80,7 +80,7 @@ code {
|
||||
|
||||
@media (min-width: 768px) {
|
||||
#wrapper {
|
||||
width: 80%;
|
||||
//width: 80%;
|
||||
margin: 2em auto;
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
"sonata-project/admin-bundle": "^3.38",
|
||||
"symfony/monolog-bundle": "^3.1.0",
|
||||
"symfony/polyfill-apcu": "^1.0",
|
||||
"symfony/serializer": "^4.3",
|
||||
"symfony/swiftmailer-bundle": "^2.6.4",
|
||||
"symfony/symfony": "~3.4",
|
||||
"symfony/templating": "^4.0",
|
||||
|
@ -14,15 +14,17 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
|
||||
class DefaultController extends Controller
|
||||
{
|
||||
class DefaultController extends Controller {
|
||||
|
||||
private $ownerService;
|
||||
private $tokenManager;
|
||||
|
||||
public function __construct(CsrfTokenManagerInterface $tokenManager = null, OwnerService $ownerService)
|
||||
{
|
||||
public function __construct( CsrfTokenManagerInterface $tokenManager = null, OwnerService $ownerService ) {
|
||||
$this->tokenManager = $tokenManager;
|
||||
$this->ownerService = $ownerService;
|
||||
}
|
||||
@ -30,69 +32,66 @@ class DefaultController extends Controller
|
||||
/**
|
||||
* @Route("/", name="homepage")
|
||||
*/
|
||||
public function indexAction(Request $request)
|
||||
{
|
||||
public function indexAction( Request $request ) {
|
||||
$m = $this->getDoctrine()->getManager();
|
||||
$userRepo = $m->getRepository('AppBundle:User');
|
||||
$userRepo = $m->getRepository( 'AppBundle:User' );
|
||||
$allUsers = $userRepo->findAll();
|
||||
|
||||
// replace this example code with whatever you need
|
||||
return $this->render('default/index.html.twig',
|
||||
return $this->render( 'default/index.html.twig',
|
||||
[
|
||||
'usersCount' => count($allUsers),
|
||||
'base_dir' => realpath($this->getParameter('kernel.project_dir')) . DIRECTORY_SEPARATOR,
|
||||
]);
|
||||
'usersCount' => count( $allUsers ),
|
||||
'base_dir' => realpath( $this->getParameter( 'kernel.project_dir' ) ) . DIRECTORY_SEPARATOR,
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/dashboard", name="dashboard")
|
||||
*/
|
||||
public function dashboardAction(Request $request)
|
||||
{
|
||||
public function dashboardAction( Request $request ) {
|
||||
$m = $this->getDoctrine()->getManager();
|
||||
$currentUser = $this->getUser();
|
||||
|
||||
// TODO on first login set default values
|
||||
$lastFestival = $currentUser->getActiveFestival();
|
||||
if (!$lastFestival) {
|
||||
$lastFestival = $m->getRepository('AppBundle:Festival')
|
||||
->findOneBy(['user' => $this->getUser()->getId()],
|
||||
['id' => 'desc'],
|
||||
if ( ! $lastFestival ) {
|
||||
$lastFestival = $m->getRepository( 'AppBundle:Festival' )
|
||||
->findOneBy( [ 'user' => $this->getUser()->getId() ],
|
||||
[ 'id' => 'desc' ],
|
||||
0,
|
||||
1);
|
||||
1 );
|
||||
}
|
||||
if ($lastFestival) {
|
||||
if ( $lastFestival ) {
|
||||
$lastFestival->recalculateChiffreAffaire();
|
||||
}
|
||||
$categRepo = $m->getRepository('AppBundle:ProductCategory');
|
||||
$sellingRepo = $m->getRepository('AppBundle:SellRecord');
|
||||
$categRepo = $m->getRepository( 'AppBundle:ProductCategory' );
|
||||
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
|
||||
$categories = $categRepo->findAll();
|
||||
$recentSells = $sellingRepo->findBy(['user' => $currentUser->getId()], ['id' => 'desc'], 0, 5);
|
||||
$recentSells = $sellingRepo->findBy( [ 'user' => $currentUser->getId() ], [ 'id' => 'desc' ], 0, 5 );
|
||||
|
||||
return $this->render('logged/dashboard.html.twig',
|
||||
return $this->render( 'logged/dashboard.html.twig',
|
||||
[
|
||||
'lastFestival' => $lastFestival,
|
||||
'categories' => $categories,
|
||||
'currentUser' => $currentUser,
|
||||
'recentSells' => $recentSells,
|
||||
'base_dir' => realpath($this->getParameter('kernel.project_dir')) . DIRECTORY_SEPARATOR,
|
||||
]);
|
||||
'base_dir' => realpath( $this->getParameter( 'kernel.project_dir' ) ) . DIRECTORY_SEPARATOR,
|
||||
] );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* envoyer un email
|
||||
*/
|
||||
public function emailAction()
|
||||
{
|
||||
public function emailAction() {
|
||||
$name = "noble barbare";
|
||||
$message = \Swift_Message::newInstance()
|
||||
->setSubject('Hello Email')
|
||||
->setFrom('test-symfony-tykayn@caisse.ciperbliss.com')
|
||||
->setTo('tykayn@gmail.com')
|
||||
->setBody($this->renderView('default/test-email.html.twig'),
|
||||
'text/html');
|
||||
$this->get('mailer')->send($message);
|
||||
->setSubject( 'Hello Email' )
|
||||
->setFrom( 'test-symfony-tykayn@caisse.ciperbliss.com' )
|
||||
->setTo( 'tykayn@gmail.com' )
|
||||
->setBody( $this->renderView( 'default/test-email.html.twig' ),
|
||||
'text/html' );
|
||||
$this->get( 'mailer' )->send( $message );
|
||||
|
||||
//return 'yay test de mail';
|
||||
return $this->render(
|
||||
@ -106,127 +105,126 @@ class DefaultController extends Controller
|
||||
* get user products
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function getMyProductsAction()
|
||||
{
|
||||
public function getMyProductsAction() {
|
||||
$m = $this->getDoctrine()->getManager();
|
||||
|
||||
|
||||
$currentUser = $this->getUser();
|
||||
if (!$currentUser) {
|
||||
return new JsonResponse([
|
||||
'categories' => [[]],
|
||||
'recentSells' => [['']],
|
||||
]);
|
||||
if ( ! $currentUser ) {
|
||||
return new JsonResponse( [
|
||||
'categories' => [ [] ],
|
||||
'recentSells' => [ [ '' ] ],
|
||||
] );
|
||||
}
|
||||
|
||||
$ownerService = $this->ownerService;
|
||||
$ownerService->setupNewFestival($currentUser);
|
||||
$ownerService->setupNewFestival( $currentUser );
|
||||
$activeFestival = $currentUser->getActiveFestival();
|
||||
|
||||
$categRepo = $m->getRepository('AppBundle:ProductCategory');
|
||||
$sellingRepo = $m->getRepository('AppBundle:SellRecord');
|
||||
$categRepo = $m->getRepository( 'AppBundle:ProductCategory' );
|
||||
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
|
||||
|
||||
|
||||
$categories = $ownerService->serializeCategoriesOfUser($currentUser);
|
||||
$categories = $ownerService->serializeCategoriesOfUser( $currentUser );
|
||||
|
||||
|
||||
$recentSells = $sellingRepo->findBy(['user' => $currentUser->getId()], ['id' => 'desc'], 0, 5);
|
||||
$recentSells = $sellingRepo->findBy( [ 'user' => $currentUser->getId() ], [ 'id' => 'desc' ], 0, 5 );
|
||||
|
||||
return new JsonResponse([
|
||||
return new JsonResponse( [
|
||||
'categories' => $categories,
|
||||
'recentSells' => count($recentSells),
|
||||
'recentSells' => count( $recentSells ),
|
||||
'lastFestival' => $activeFestival->makeArray(),
|
||||
]);
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* get user expenses
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function getMyExpensesAction()
|
||||
{
|
||||
public function getMyExpensesAction() {
|
||||
$m = $this->getDoctrine()->getManager();
|
||||
|
||||
|
||||
$currentUser = $this->getUser();
|
||||
if (!$currentUser) {
|
||||
return new JsonResponse([
|
||||
'expenses' => [[]],
|
||||
]);
|
||||
if ( ! $currentUser ) {
|
||||
return new JsonResponse( [
|
||||
'expenses' => [ [] ],
|
||||
] );
|
||||
}
|
||||
|
||||
$ownerService = $this->ownerService;
|
||||
$ownerService->setupNewFestival($currentUser);
|
||||
$expensesOfUser = $ownerService->serializeExpensesOfUser($currentUser);
|
||||
$ownerService->setupNewFestival( $currentUser );
|
||||
$expensesOfUser = $ownerService->serializeExpensesOfUser( $currentUser );
|
||||
|
||||
return new JsonResponse([
|
||||
return new JsonResponse( [
|
||||
'expenses' => $expensesOfUser,
|
||||
'disponibility' => $currentUser->getDisponibility(),
|
||||
'averageMonthlyEarnings' => $currentUser->getAverageMonthlyEarnings(),
|
||||
]);
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* recieve the json containing the expanse config of a user
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JsonResponse the list of expanses
|
||||
*/
|
||||
public function saveMyExpensesAction(Request $request)
|
||||
{
|
||||
public function saveMyExpensesAction( Request $request ) {
|
||||
|
||||
$json = json_decode($request->getContent(), true);
|
||||
$json = json_decode( $request->getContent(), true );
|
||||
$currentUser = $this->getUser();
|
||||
$m = $this->getDoctrine()->getManager();
|
||||
$myExpenses = $currentUser->getExpenses();
|
||||
$categoriesByID = [];
|
||||
|
||||
foreach ($myExpenses as $expense) {
|
||||
$categoriesByID[$expense->getId()] = $expense;
|
||||
foreach ( $myExpenses as $expense ) {
|
||||
$categoriesByID[ $expense->getId() ] = $expense;
|
||||
}
|
||||
// loop on the json config for expanse
|
||||
// save the user configuration
|
||||
foreach ($json['expenses'] as $expens) {
|
||||
foreach ( $json[ 'expenses' ] as $expens ) {
|
||||
|
||||
if(isset($expens['id'])){
|
||||
$foundExpense = $categoriesByID[$expens['id']];
|
||||
if($foundExpense){
|
||||
if ( isset( $expens[ 'id' ] ) ) {
|
||||
$foundExpense = $categoriesByID[ $expens[ 'id' ] ];
|
||||
if ( $foundExpense ) {
|
||||
// update existing expenses of logged in user
|
||||
$foundExpense->setName($expens['name']);
|
||||
$foundExpense->setAmount($expens['amount']);
|
||||
$foundExpense->setDelay($expens['delay']);
|
||||
$foundExpense->setRepeatitions($expens['repeat']);
|
||||
$foundExpense->setEnabled($expens['enabled']);
|
||||
$m->persist($foundExpense);
|
||||
$foundExpense->setName( $expens[ 'name' ] );
|
||||
$foundExpense->setAmount( $expens[ 'amount' ] );
|
||||
$foundExpense->setDelay( $expens[ 'delay' ] );
|
||||
$foundExpense->setRepeatitions( $expens[ 'repeat' ] );
|
||||
$foundExpense->setEnabled( $expens[ 'enabled' ] );
|
||||
$m->persist( $foundExpense );
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
// create new expense for user
|
||||
$newExpense = new ExpenseKind();
|
||||
$newExpense->setUser($currentUser);
|
||||
$newExpense->setName($expens['name']);
|
||||
$newExpense->setDelay($expens['delay']);
|
||||
$newExpense->setAmount($expens['amount']);
|
||||
$newExpense->setRepeatitions($expens['repeat']);
|
||||
$newExpense->setEnabled($expens['enabled']);
|
||||
$m->persist($newExpense);
|
||||
$newExpense->setUser( $currentUser );
|
||||
$newExpense->setName( $expens[ 'name' ] );
|
||||
$newExpense->setDelay( $expens[ 'delay' ] );
|
||||
$newExpense->setAmount( $expens[ 'amount' ] );
|
||||
$newExpense->setRepeatitions( $expens[ 'repeat' ] );
|
||||
$newExpense->setEnabled( $expens[ 'enabled' ] );
|
||||
$m->persist( $newExpense );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$currentUser->setDisponibility($json['config']['disponibility']);
|
||||
$currentUser->setAverageMonthlyEarnings($json['config']['averageMonthlyEarnings']);
|
||||
$currentUser->setDisponibility( $json[ 'config' ][ 'disponibility' ] );
|
||||
$currentUser->setAverageMonthlyEarnings( $json[ 'config' ][ 'averageMonthlyEarnings' ] );
|
||||
|
||||
|
||||
$m->persist($currentUser);
|
||||
$m->persist( $currentUser );
|
||||
$m->flush();
|
||||
|
||||
$ownerService = $this->ownerService;
|
||||
$expensesOfUser = $ownerService->serializeExpensesOfUser($currentUser);
|
||||
$expensesOfUser = $ownerService->serializeExpensesOfUser( $currentUser );
|
||||
|
||||
return new JsonResponse([
|
||||
return new JsonResponse( [
|
||||
'expenses' => $expensesOfUser,
|
||||
'disponibility' => $currentUser->getDisponibility(),
|
||||
'averageMonthlyEarnings' => $currentUser->getAverageMonthlyEarnings(),
|
||||
]);
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,82 +233,81 @@ class DefaultController extends Controller
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function addSellingAction(Request $request)
|
||||
{
|
||||
public function addSellingAction( Request $request ) {
|
||||
|
||||
$json = json_decode($request->getContent(), true);
|
||||
$json = json_decode( $request->getContent(), true );
|
||||
$currentUser = $this->getUser();
|
||||
$m = $this->getDoctrine()->getManager();
|
||||
$newSellRecord = new SellRecord();
|
||||
// sort user categories
|
||||
$myCategories = $currentUser->getCategories();
|
||||
$categoriesByID = [];
|
||||
foreach ($myCategories as $my_category) {
|
||||
$categoriesByID[$my_category->getId()] = $my_category;
|
||||
foreach ( $myCategories as $my_category ) {
|
||||
$categoriesByID[ $my_category->getId() ] = $my_category;
|
||||
}
|
||||
|
||||
$productsModels = $m->getRepository('AppBundle:Product')->findAll();
|
||||
$productsModels = $m->getRepository( 'AppBundle:Product' )->findAll();
|
||||
$productsModelsByID = [];
|
||||
foreach ($productsModels as $product) {
|
||||
$productsModelsByID[$product->getId()] = $product;
|
||||
foreach ( $productsModels as $product ) {
|
||||
$productsModelsByID[ $product->getId() ] = $product;
|
||||
}
|
||||
|
||||
$sumAmount = 0;
|
||||
foreach ($json['activeSelling'] as $record) {
|
||||
$productModel = $productsModelsByID[$record['id']];
|
||||
foreach ( $json[ 'activeSelling' ] as $record ) {
|
||||
$productModel = $productsModelsByID[ $record[ 'id' ] ];
|
||||
$newProductSold = new ProductSold();
|
||||
$newProductSold->setName($record['name']);
|
||||
$newProductSold->setImage("image mock");
|
||||
$newProductSold->setUser($currentUser);
|
||||
$newProductSold->setPrice($record['price']);
|
||||
$newProductSold->setComment($json['sellingComment']);
|
||||
$newProductSold->setProduct($productModel);
|
||||
$newProductSold->setSellRecords($newSellRecord);
|
||||
$newProductSold->setName( $record[ 'name' ] );
|
||||
$newProductSold->setImage( "image mock" );
|
||||
$newProductSold->setUser( $currentUser );
|
||||
$newProductSold->setPrice( $record[ 'price' ] );
|
||||
$newProductSold->setComment( $json[ 'sellingComment' ] );
|
||||
$newProductSold->setProduct( $productModel );
|
||||
$newProductSold->setSellRecords( $newSellRecord );
|
||||
// link selling record with user, festival
|
||||
$currentUser->addProductsSold($newProductSold);
|
||||
$currentUser->addProductsSold( $newProductSold );
|
||||
// persist all
|
||||
$productModel->setStockCount($productModel->getStockCount() - 1);
|
||||
$m->persist($productModel);
|
||||
$m->persist($newProductSold);
|
||||
$m->persist($newProductSold);
|
||||
$sumAmount += $record['price'];
|
||||
$productModel->setStockCount( $productModel->getStockCount() - 1 );
|
||||
$m->persist( $productModel );
|
||||
$m->persist( $newProductSold );
|
||||
$m->persist( $newProductSold );
|
||||
$sumAmount += $record[ 'price' ];
|
||||
}
|
||||
|
||||
$festivalFound = $m->getRepository('AppBundle:Festival')->find($json['activeFestival']['id']);
|
||||
$newSellRecord->setFestival($festivalFound);
|
||||
$newSellRecord->setAmount($sumAmount);
|
||||
$newSellRecord->setDate(new \DateTime());
|
||||
$newSellRecord->setUser($currentUser);
|
||||
$newSellRecord->setPaidByClient($json['paidByClient']);
|
||||
$newSellRecord->setComment($json['sellingComment']);
|
||||
$festivalFound = $m->getRepository( 'AppBundle:Festival' )->find( $json[ 'activeFestival' ][ 'id' ] );
|
||||
$newSellRecord->setFestival( $festivalFound );
|
||||
$newSellRecord->setAmount( $sumAmount );
|
||||
$newSellRecord->setDate( new \DateTime() );
|
||||
$newSellRecord->setUser( $currentUser );
|
||||
$newSellRecord->setPaidByClient( $json[ 'paidByClient' ] );
|
||||
$newSellRecord->setComment( $json[ 'sellingComment' ] );
|
||||
|
||||
|
||||
$festivalFound->addSellRecord($newSellRecord);
|
||||
$currentUser->addSellRecords($newSellRecord);
|
||||
$festivalFound->addSellRecord( $newSellRecord );
|
||||
$currentUser->addSellRecords( $newSellRecord );
|
||||
|
||||
$m->persist($newSellRecord);
|
||||
$m->persist($currentUser);
|
||||
$m->persist($festivalFound);
|
||||
$m->persist( $newSellRecord );
|
||||
$m->persist( $currentUser );
|
||||
$m->persist( $festivalFound );
|
||||
$m->flush();
|
||||
|
||||
$festivalFound->recalculateChiffreAffaire();
|
||||
$m->persist($festivalFound);
|
||||
$m->persist( $festivalFound );
|
||||
$m->flush();
|
||||
|
||||
// setup dates
|
||||
|
||||
// fetch back history of selling
|
||||
$sellingRepo = $m->getRepository('AppBundle:SellRecord');
|
||||
$lastSellings = $sellingRepo->findBy(['user' => $currentUser->getId()], ['id' => 'desc'], 0, 3);
|
||||
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
|
||||
$lastSellings = $sellingRepo->findBy( [ 'user' => $currentUser->getId() ], [ 'id' => 'desc' ], 0, 3 );
|
||||
|
||||
return new JsonResponse([
|
||||
return new JsonResponse( [
|
||||
"message" => "ok",
|
||||
"activeFestival" => $festivalFound->makeArray(),
|
||||
"newChiffreAffaire" => $festivalFound->getChiffreAffaire(),
|
||||
"clientsCount" => count($festivalFound->getSellRecords()),
|
||||
"recent_sellings" => json_encode($lastSellings),
|
||||
"clientsCount" => count( $festivalFound->getSellRecords() ),
|
||||
"recent_sellings" => json_encode( $lastSellings ),
|
||||
"dump" => $json,
|
||||
], 200);
|
||||
], 200 );
|
||||
}
|
||||
|
||||
|
||||
@ -318,13 +315,12 @@ class DefaultController extends Controller
|
||||
* get the history of user's sellings
|
||||
* @Route("/history", name="history")
|
||||
*/
|
||||
public function historyAction()
|
||||
{
|
||||
public function historyAction() {
|
||||
$currentUser = $this->getUser();
|
||||
$m = $this->getDoctrine()->getManager();
|
||||
$sellingRepo = $m->getRepository('AppBundle:SellRecord');
|
||||
$allSellingList = $sellingRepo->findBy(['user'=>$currentUser->getId()],['id'=>'desc']);
|
||||
$mySellings = array_splice($allSellingList, 0, 15);
|
||||
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
|
||||
$allSellingList = $sellingRepo->findBy( [ 'user' => $currentUser->getId() ], [ 'id' => 'desc' ] );
|
||||
$mySellings = array_splice( $allSellingList, 0, 15 );
|
||||
$chiffreAffaires = 0;
|
||||
|
||||
$myFestivals = $currentUser->getFestivals();
|
||||
@ -332,11 +328,11 @@ class DefaultController extends Controller
|
||||
$statisticsFestivals = [
|
||||
];
|
||||
|
||||
foreach ($myFestivals as $festival) {
|
||||
foreach ( $myFestivals as $festival ) {
|
||||
$statisticsFestivals[] = [
|
||||
'date' => $festival->getDateCreation(),
|
||||
'name' => $festival->getName(),
|
||||
'clients_count' => count($festival->getSellRecords()),
|
||||
'clients_count' => count( $festival->getSellRecords() ),
|
||||
'chiffreAffaire' => $festival->getChiffreAffaire(),
|
||||
];
|
||||
}
|
||||
@ -345,59 +341,99 @@ class DefaultController extends Controller
|
||||
];
|
||||
|
||||
$statsForFestivalMock = [
|
||||
['name' => 'festoche bidule', 'clients_count' => 125, 'chiffreAffaire' => 236, 'date' => new \DateTime()],
|
||||
[ 'name' => 'festoche bidule', 'clients_count' => 125, 'chiffreAffaire' => 236, 'date' => new \DateTime() ],
|
||||
];
|
||||
foreach ($allSellingList as $client) {
|
||||
foreach ($client->getProductsSold() as $product) {
|
||||
foreach ( $allSellingList as $client ) {
|
||||
foreach ( $client->getProductsSold() as $product ) {
|
||||
$chiffreAffaires += $product->getPrice();
|
||||
}
|
||||
}
|
||||
foreach ($mySellings as $client) {
|
||||
foreach ($client->getProductsSold() as $product) {
|
||||
foreach ( $mySellings as $client ) {
|
||||
foreach ( $client->getProductsSold() as $product ) {
|
||||
$chiffreAffaires += $product->getPrice();
|
||||
|
||||
if (!isset($statisticsSoldProducts[$product->getName()])) {
|
||||
$statisticsSoldProducts[$product->getName()] =
|
||||
if ( ! isset( $statisticsSoldProducts[ $product->getName() ] ) ) {
|
||||
$statisticsSoldProducts[ $product->getName() ] =
|
||||
[
|
||||
'name' => $product->getName(),
|
||||
'count' => 0,
|
||||
'value' => 0
|
||||
'value' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
$statisticsSoldProducts[$product->getName()]['count']++;
|
||||
$statisticsSoldProducts[$product->getName()]['value'] = $statisticsSoldProducts[$product->getName()]['value'] + intval($product->getPrice());
|
||||
$statisticsSoldProducts[ $product->getName() ][ 'count' ] ++;
|
||||
$statisticsSoldProducts[ $product->getName() ][ 'value' ] = $statisticsSoldProducts[ $product->getName() ][ 'value' ] + intval( $product->getPrice() );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('logged/history.html.twig',
|
||||
return $this->render( 'logged/history.html.twig',
|
||||
[
|
||||
// 'statisticsFestivals' => $statsForFestivalMock, // mock of festival stats
|
||||
'statisticsFestivals' => $statisticsFestivals,
|
||||
'statisticsSoldProducts' => $statisticsSoldProducts,
|
||||
'chiffreAffaires' => $chiffreAffaires,
|
||||
'recentSells' => $mySellings,
|
||||
'allSellings' => count($mySellings),
|
||||
'base_dir' => realpath($this->getParameter('kernel.project_dir')) . DIRECTORY_SEPARATOR,
|
||||
]);
|
||||
'allSellings' => count( $mySellings ),
|
||||
'base_dir' => realpath( $this->getParameter( 'kernel.project_dir' ) ) . DIRECTORY_SEPARATOR,
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* export user data in JSON
|
||||
* @return JsonResponse
|
||||
* @Route("/logged/export-all-json", name="export_all_json")
|
||||
*/
|
||||
public function exportJsonAction() {
|
||||
$currentUser = $this->getUser();
|
||||
$m = $this->getDoctrine()->getManager();
|
||||
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
|
||||
$encoders = [ new XmlEncoder(), new JsonEncoder() ];
|
||||
$normalizers = [ new ObjectNormalizer() ];
|
||||
|
||||
$serializer = new Serializer( $normalizers, $encoders );
|
||||
|
||||
$mySellings = $sellingRepo->findByUser( $currentUser->getId() );
|
||||
$export = [
|
||||
'export_version' => '1.0',
|
||||
'user' => $serializer->normalize( $currentUser,
|
||||
null,
|
||||
[ 'attributes' => [ 'id', 'username', 'email', 'salt', 'password' ] ] ),
|
||||
'products' => $serializer->normalize( $currentUser->getProducts(),
|
||||
null,
|
||||
[ 'attributes' => [ 'id', 'name', 'price' ] ] ),
|
||||
'categories' => $serializer->normalize( $currentUser->getCategories(),
|
||||
null,
|
||||
[ 'attributes' => [ 'id', 'name' ] ] ),
|
||||
'series_festivals' => $serializer->normalize( $currentUser->getSeriesFestivals(),
|
||||
null, ['attributes'=> [
|
||||
'id', 'name',
|
||||
]]),
|
||||
'festivals' => $serializer->normalize( $currentUser->getFestivals(),
|
||||
null,
|
||||
[ 'attributes' => [ 'id', 'name', 'chiffreAffaire','fraisInscription','fraisHebergement','fraisTransport','fraisRepas' ] ] ),
|
||||
'sellings' => $serializer->normalize( $mySellings,
|
||||
null,
|
||||
[ 'attributes' => [ 'id', 'amount', 'paidByClient', 'comment', 'gender' ] ] ),
|
||||
];
|
||||
|
||||
return new JsonResponse( $export );
|
||||
}
|
||||
|
||||
/**
|
||||
* export all clients
|
||||
* @Route("/export-all", name="export_all")
|
||||
*/
|
||||
public function exportAllAction()
|
||||
{
|
||||
public function exportAllAction() {
|
||||
// TODO
|
||||
$currentUser = $this->getUser();
|
||||
$m = $this->getDoctrine()->getManager();
|
||||
$sellingRepo = $m->getRepository('AppBundle:SellRecord');
|
||||
$mySellings = $sellingRepo->findByUser($currentUser->getId());
|
||||
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
|
||||
$mySellings = $sellingRepo->findByUser( $currentUser->getId() );
|
||||
|
||||
$fileName = "export_caisse-cipherbliss_" . $currentUser->getUsername() . '_' . date('Y-m-d_H-i-s');
|
||||
$fileName = "export_caisse-cipherbliss_" . $currentUser->getUsername() . '_' . date( 'Y-m-d_H-i-s' );
|
||||
|
||||
$handle = fopen('php://memory', 'r+');
|
||||
$handle = fopen( 'php://memory', 'r+' );
|
||||
$firstLine = [
|
||||
'product sold id',
|
||||
'date',
|
||||
@ -420,21 +456,21 @@ class DefaultController extends Controller
|
||||
'festival comment',
|
||||
];
|
||||
// save the column headers
|
||||
fputcsv($handle,
|
||||
$firstLine);
|
||||
fputcsv( $handle,
|
||||
$firstLine );
|
||||
|
||||
$chiffreAffaires = 0;
|
||||
foreach ($mySellings as $sellRecord) {
|
||||
foreach ($sellRecord->getProductsSold() as $productSold) {
|
||||
foreach ( $mySellings as $sellRecord ) {
|
||||
foreach ( $sellRecord->getProductsSold() as $productSold ) {
|
||||
$chiffreAffaires += $productSold->getPrice();
|
||||
// add a line to the csv file
|
||||
fputcsv($handle,
|
||||
fputcsv( $handle,
|
||||
[
|
||||
$productSold->getId(),
|
||||
$sellRecord->getDate()->format('c'),
|
||||
$sellRecord->getDate()->format('H'),
|
||||
$sellRecord->getDate()->format('i'),
|
||||
$sellRecord->getDate()->format('s'),
|
||||
$sellRecord->getDate()->format( 'c' ),
|
||||
$sellRecord->getDate()->format( 'H' ),
|
||||
$sellRecord->getDate()->format( 'i' ),
|
||||
$sellRecord->getDate()->format( 's' ),
|
||||
$sellRecord->getComment(),
|
||||
$sellRecord->getPaidByClient(),
|
||||
$productSold->getName(),
|
||||
@ -442,9 +478,9 @@ class DefaultController extends Controller
|
||||
$productSold->getProduct()->getCategory()->getId(),
|
||||
$productSold->getProduct()->getCategory()->getName(),
|
||||
$productSold->getPrice(),
|
||||
]);
|
||||
if ($sellRecord->getFestival()) {
|
||||
fputcsv($handle,
|
||||
] );
|
||||
if ( $sellRecord->getFestival() ) {
|
||||
fputcsv( $handle,
|
||||
[
|
||||
'',
|
||||
'',
|
||||
@ -460,19 +496,19 @@ class DefaultController extends Controller
|
||||
'',
|
||||
$sellRecord->getFestival()->getId(),
|
||||
$sellRecord->getFestival()->getName(),
|
||||
$sellRecord->getFestival()->getDateCreation()->format('c'),
|
||||
$sellRecord->getFestival()->getDateCreation()->format( 'c' ),
|
||||
$sellRecord->getFestival()->getFondDeCaisseAvant(),
|
||||
$sellRecord->getFestival()->getFondDeCaisseApres(),
|
||||
$sellRecord->getFestival()->getChiffreAffaire(),
|
||||
$sellRecord->getFestival()->getComment(),
|
||||
]);
|
||||
] );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
rewind($handle);
|
||||
$content = stream_get_contents($handle);
|
||||
fclose($handle);
|
||||
rewind( $handle );
|
||||
$content = stream_get_contents( $handle );
|
||||
fclose( $handle );
|
||||
|
||||
return new Response(
|
||||
$content, 200, [
|
||||
@ -486,56 +522,52 @@ class DefaultController extends Controller
|
||||
/**
|
||||
* @Route("/set-active-festival/{id}", name="set_active_festival")
|
||||
*/
|
||||
public function setActiveFestivalAction($id)
|
||||
{
|
||||
public function setActiveFestivalAction( $id ) {
|
||||
$currentUser = $this->getUser();
|
||||
$m = $this->getDoctrine()->getManager();
|
||||
$repo = $m->getRepository('AppBundle:Festival');
|
||||
$repo = $m->getRepository( 'AppBundle:Festival' );
|
||||
|
||||
$currentUser->setActiveFestival($repo->find($id));
|
||||
$m->persist($currentUser);
|
||||
$currentUser->setActiveFestival( $repo->find( $id ) );
|
||||
$m->persist( $currentUser );
|
||||
$m->flush();
|
||||
|
||||
// replace this example code with whatever you need
|
||||
return $this->redirectToRoute('festival_index');
|
||||
return $this->redirectToRoute( 'festival_index' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/import", name="import")
|
||||
*/
|
||||
public function importAction()
|
||||
{
|
||||
public function importAction() {
|
||||
$currentUser = $this->getUser();
|
||||
$m = $this->getDoctrine()->getManager();
|
||||
$sellingRepo = $m->getRepository('AppBundle:SellRecord');
|
||||
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
|
||||
|
||||
return $this->render('logged/import.html.twig',
|
||||
return $this->render( 'logged/import.html.twig',
|
||||
[
|
||||
'base_dir' => '',
|
||||
]);
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/previsionnel", name="previsionnel")
|
||||
*/
|
||||
public function previsionnelAction()
|
||||
{
|
||||
public function previsionnelAction() {
|
||||
// $currentUser = $this->getUser();
|
||||
// $m = $this->getDoctrine()->getManager();
|
||||
// $sellingRepo = $m->getRepository('AppBundle:SellRecord');
|
||||
|
||||
return $this->render('logged/previsionnel.html.twig',
|
||||
return $this->render( 'logged/previsionnel.html.twig',
|
||||
[
|
||||
'base_dir' => '',
|
||||
]);
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* import lots of products at once
|
||||
* @Route("/mass-create", name="mass_create")
|
||||
*/
|
||||
public function massCreateAction(Request $request)
|
||||
{
|
||||
public function massCreateAction( Request $request ) {
|
||||
$currentUser = $this->getUser();
|
||||
$m = $this->getDoctrine()->getManager();
|
||||
|
||||
@ -544,35 +576,35 @@ class DefaultController extends Controller
|
||||
$myProductsByName = [];
|
||||
$currentCategory = new ProductCategory();
|
||||
$currentCategory
|
||||
->addUser($currentUser)
|
||||
->setName('default category');
|
||||
->addUser( $currentUser )
|
||||
->setName( 'default category' );
|
||||
|
||||
foreach ($myCategories as $my_category) {
|
||||
$myCategoriesByName [$my_category->getName()] = $my_category;
|
||||
foreach ($my_category->getProducts() as $product) {
|
||||
$myProductsByName[$product->getName()] = $product;
|
||||
foreach ( $myCategories as $my_category ) {
|
||||
$myCategoriesByName [ $my_category->getName() ] = $my_category;
|
||||
foreach ( $my_category->getProducts() as $product ) {
|
||||
$myProductsByName[ $product->getName() ] = $product;
|
||||
}
|
||||
$currentCategory = $my_category;
|
||||
}
|
||||
$massLines = $request->request->get('produits');
|
||||
if ($request->getMethod() == 'POST') {
|
||||
$lines = preg_split('/$\R?^/m', trim($massLines));
|
||||
foreach ($lines as $line) {
|
||||
$massLines = $request->request->get( 'produits' );
|
||||
if ( $request->getMethod() == 'POST' ) {
|
||||
$lines = preg_split( '/$\R?^/m', trim( $massLines ) );
|
||||
foreach ( $lines as $line ) {
|
||||
|
||||
if (strpos($line, ':')) {
|
||||
if ( strpos( $line, ':' ) ) {
|
||||
// manage catgegories
|
||||
$boom = explode(':', trim($line));
|
||||
$firstPart = $boom[0];
|
||||
$value = $boom[1];
|
||||
if ($firstPart === 'catégorie' && $value) {
|
||||
$boom = explode( ':', trim( $line ) );
|
||||
$firstPart = $boom[ 0 ];
|
||||
$value = $boom[ 1 ];
|
||||
if ( $firstPart === 'catégorie' && $value ) {
|
||||
// look for category by name
|
||||
if (!isset($myCategoriesByName[$value])) {
|
||||
if ( ! isset( $myCategoriesByName[ $value ] ) ) {
|
||||
$newCateg = new ProductCategory();
|
||||
$newCateg
|
||||
->addUser($currentUser)
|
||||
->setName($value);
|
||||
$currentUser->addCategory($newCateg);
|
||||
$m->persist($newCateg);
|
||||
->addUser( $currentUser )
|
||||
->setName( $value );
|
||||
$currentUser->addCategory( $newCateg );
|
||||
$m->persist( $newCateg );
|
||||
$currentCategory = $newCateg; // associate further categories with the newly created one
|
||||
} else {
|
||||
// echo " la catégorie existe déjà";
|
||||
@ -580,37 +612,37 @@ class DefaultController extends Controller
|
||||
}
|
||||
} else {
|
||||
// manage product
|
||||
$boom = explode(';', $line);
|
||||
$productName = $boom[0];
|
||||
$boom = explode( ';', $line );
|
||||
$productName = $boom[ 0 ];
|
||||
$price = 0;
|
||||
if ($boom[1]) {
|
||||
$price = intval(str_replace('€', '', $boom[1]));// removing euro symbol
|
||||
if ( $boom[ 1 ] ) {
|
||||
$price = intval( str_replace( '€', '', $boom[ 1 ] ) );// removing euro symbol
|
||||
}
|
||||
// or create new product
|
||||
if ($productName && !isset($myProductsByName[$productName])) {
|
||||
if ( $productName && ! isset( $myProductsByName[ $productName ] ) ) {
|
||||
$newProduct = new Product();
|
||||
$newProduct->setCategory($currentCategory)
|
||||
->setName($productName)
|
||||
->setStockCount(500)
|
||||
->setUser($currentUser)
|
||||
->setPrice($price);
|
||||
$currentUser->addProduct($newProduct);
|
||||
$m->persist($newProduct);
|
||||
$newProduct->setCategory( $currentCategory )
|
||||
->setName( $productName )
|
||||
->setStockCount( 500 )
|
||||
->setUser( $currentUser )
|
||||
->setPrice( $price );
|
||||
$currentUser->addProduct( $newProduct );
|
||||
$m->persist( $newProduct );
|
||||
}// look for existing products
|
||||
else {
|
||||
$myProductsByName[$productName]->setPrice($price);
|
||||
$myProductsByName[ $productName ]->setPrice( $price );
|
||||
}
|
||||
}
|
||||
|
||||
$m->persist($currentUser);
|
||||
$m->persist( $currentUser );
|
||||
}
|
||||
// check with existing categories and products, sort them by name.
|
||||
// save all
|
||||
$m->flush();
|
||||
}
|
||||
|
||||
return $this->render('logged/import.html.twig',
|
||||
[]);
|
||||
return $this->render( 'logged/import.html.twig',
|
||||
[] );
|
||||
}
|
||||
|
||||
}
|
||||
|
0
src/AppBundle/Entity/ExpenseKind.php
Executable file → Normal file
0
src/AppBundle/Entity/ExpenseKind.php
Executable file → Normal file
200
src/AppBundle/Entity/ExpenseKind.php~
Normal file
200
src/AppBundle/Entity/ExpenseKind.php~
Normal 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
0
src/AppBundle/Entity/Festival.php
Executable file → Normal file
@ -40,7 +40,7 @@ class Festival {
|
||||
/**
|
||||
* @var \stdClass
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\SellRecord",mappedBy="festival")
|
||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\SellRecord",mappedBy="festival", cascade={"remove"})
|
||||
*/
|
||||
private $sellRecords;
|
||||
|
||||
@ -48,6 +48,10 @@ class Festival {
|
||||
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="festivals")
|
||||
*/
|
||||
private $user;
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\SerieFestival", inversedBy="festivals")
|
||||
*/
|
||||
private $serieFestival;
|
||||
|
||||
/**
|
||||
* @var
|
||||
@ -83,11 +87,42 @@ class Festival {
|
||||
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
|
||||
* @return array
|
||||
*/
|
||||
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 [
|
||||
'id' => $this->getId(),
|
||||
'name' => $this->getName(),
|
||||
@ -97,6 +132,7 @@ class Festival {
|
||||
'clientsCount' => count($this->getSellRecords()),
|
||||
'fondDeCaisseAvant' => $this->getFondDeCaisseAvant(),
|
||||
'fondDeCaisseApres' => $this->getFondDeCaisseApres(),
|
||||
'sold' => $soldItems,
|
||||
];
|
||||
|
||||
}
|
||||
|
0
src/AppBundle/Entity/Product.php
Executable file → Normal file
0
src/AppBundle/Entity/Product.php
Executable file → Normal file
@ -43,7 +43,7 @@ class Product {
|
||||
*/
|
||||
private $user;
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\ProductSold", mappedBy="product")
|
||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\ProductSold", mappedBy="product", cascade={"remove"})
|
||||
*/
|
||||
private $productsSold;
|
||||
|
||||
|
0
src/AppBundle/Entity/ProductCategory.php
Executable file → Normal file
0
src/AppBundle/Entity/ProductCategory.php
Executable file → Normal file
@ -21,11 +21,11 @@ class ProductCategory {
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Product", mappedBy="category")
|
||||
* @ORM\OneToMany(targetEntity="Product", mappedBy="category", cascade={"remove"})
|
||||
*/
|
||||
private $products;
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="ProductSold", mappedBy="product")
|
||||
* @ORM\OneToMany(targetEntity="ProductSold", mappedBy="product", cascade={"remove"})
|
||||
*/
|
||||
private $productsSold;
|
||||
|
||||
|
0
src/AppBundle/Entity/ProductSold.php
Executable file → Normal file
0
src/AppBundle/Entity/ProductSold.php
Executable file → Normal file
0
src/AppBundle/Entity/SellRecord.php
Executable file → Normal file
0
src/AppBundle/Entity/SellRecord.php
Executable file → Normal file
@ -24,7 +24,7 @@ class SellRecord {
|
||||
private $gender;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
33
src/AppBundle/Entity/SerieFestival.php
Executable file → Normal file
33
src/AppBundle/Entity/SerieFestival.php
Executable file → Normal file
@ -127,4 +127,37 @@ class SerieFestival {
|
||||
{
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
130
src/AppBundle/Entity/SerieFestival.php~
Normal file
130
src/AppBundle/Entity/SerieFestival.php~
Normal 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
83
src/AppBundle/Entity/User.php
Executable file → Normal file
@ -35,6 +35,10 @@ class User extends BaseUser {
|
||||
* @ORM\Column(name="google_id", type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $googleId;
|
||||
/**
|
||||
* @ORM\Column(name="mastodon_id", type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $mastodonId;
|
||||
|
||||
private $googleAccessToken;
|
||||
/**
|
||||
@ -76,11 +80,12 @@ class User extends BaseUser {
|
||||
private $averageMonthlyEarnings;
|
||||
|
||||
/**
|
||||
* available money, for previsionnel calculation
|
||||
* @ORM\Column(name="disponibility", type="float", nullable=true)
|
||||
*/
|
||||
private $disponibility;
|
||||
/**
|
||||
* variabilised products sold
|
||||
* expenses by kind, for previsionnel
|
||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\ExpenseKind", mappedBy="user")
|
||||
*/
|
||||
private $expenses;
|
||||
@ -468,4 +473,80 @@ class User extends BaseUser {
|
||||
public function getDisqusId() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -35,9 +35,16 @@ class User extends BaseUser {
|
||||
* @ORM\Column(name="google_id", type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $googleId;
|
||||
/**
|
||||
* @ORM\Column(name="mastodon_id", type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $mastodonId;
|
||||
|
||||
private $googleAccessToken;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\ProductCategory", inversedBy="users")
|
||||
*/
|
||||
private $categories;
|
||||
/**
|
||||
* templates products
|
||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Product", mappedBy="user")
|
||||
@ -54,6 +61,11 @@ class User extends BaseUser {
|
||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Festival", mappedBy="user")
|
||||
*/
|
||||
private $festivals;
|
||||
/**
|
||||
* series of festivals
|
||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\SerieFestival", mappedBy="user")
|
||||
*/
|
||||
private $seriesFestivals;
|
||||
|
||||
/**
|
||||
* current festival we are recording sellings for
|
||||
@ -61,10 +73,84 @@ class User extends BaseUser {
|
||||
*/
|
||||
private $activeFestival;
|
||||
|
||||
//expenses previsionnel configs
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\ProductCategory", inversedBy="users")
|
||||
* @ORM\Column(name="averageMonthlyEarnings", type="float", nullable=true)
|
||||
*/
|
||||
private $categories;
|
||||
private $averageMonthlyEarnings;
|
||||
|
||||
/**
|
||||
* available money, for previsionnel calculation
|
||||
* @ORM\Column(name="disponibility", type="float", nullable=true)
|
||||
*/
|
||||
private $disponibility;
|
||||
/**
|
||||
* expenses by kind, for previsionnel
|
||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\ExpenseKind", mappedBy="user")
|
||||
*/
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user