up styles, handle owner of products on controllers

This commit is contained in:
Tykayn 2025-02-26 16:33:36 +01:00 committed by tykayn
parent 457cafdaef
commit e973573fd7
33 changed files with 773 additions and 818 deletions

View File

@ -306,17 +306,18 @@ angular
$scope.sellingError = false; $scope.sellingError = false;
$scope.tempMessage = {}; $scope.tempMessage = {};
$scope.showTemporaryMessage = function () { $scope.showTemporaryMessage = function () {
console.log('show message');
if ($scope.sellingOk) {
$scope.sellingOk = false;
return;
}
$scope.sellingOk = true; $scope.sellingOk = true;
$timeout.cancel($scope.tempMessage); $timeout.cancel($scope.tempMessage);
$scope.tempMessage = $timeout(function () { $scope.tempMessage = $timeout(function () {
console.log('hide message'); console.log('hide message');
$scope.sellingOk = false; $scope.sellingOk = false;
}, 2000) }, 2000)
console.log('show message');
if ($scope.sellingOk) {
$scope.sellingOk = false;
return;
}
}; };
$scope.showTemporaryErrorMessage = function () { $scope.showTemporaryErrorMessage = function () {
console.log('show message'); console.log('show message');

View File

@ -1,15 +1,15 @@
@import 'pages/libs'; @use 'split/bootstrap.min.css';
@import 'fonts/all'; @use 'pages/libs';
@import 'split/override_libs'; @use 'fonts/all';
@import 'split/custom_vars'; @use 'split/override_libs';
@import 'split/formulaires'; @use 'split/custom_vars';
@import 'split/typo'; @use 'split/formulaires';
@import 'pages/global'; @use 'split/typo';
@import 'pages/nav'; @use 'pages/global';
@import 'pages/demo'; @use 'pages/nav';
@import 'pages/home'; @use 'pages/demo';
@import 'pages/forms'; @use 'pages/home';
@import 'pages/history'; @use 'pages/forms';
@import 'pages/dashboard'; @use 'pages/history';
@import 'pages/special'; @use 'pages/dashboard';
// @import 'pages/responsive'; @use 'pages/special';

6
assets/styles/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,10 @@
@use "sass:color";
@use "../split/custom_vars";
#caisse-now { #caisse-now {
min-height: 90vh; min-height: 90vh;
width: 70vw; width: 70vw;
padding-left: 0; padding-left: 1vw;
.product-box { .product-box {
display: inline-block; display: inline-block;
@ -29,25 +32,25 @@
-webkit-border-radius: 1rem; -webkit-border-radius: 1rem;
-moz-border-radius: 1rem; -moz-border-radius: 1rem;
border-radius: 1rem; border-radius: 1rem;
border-color: $all-text-color; border-color: custom_vars.$all-text-color;
box-shadow: 5px 3px 10px 2px #ddd; box-shadow: 5px 3px 10px 2px #ddd;
border-width: 0; border-width: 0;
&.btn-primary { &.btn-primary {
background-color: $deepblue; background-color: custom_vars.$deepblue;
} }
&:hover { &:hover {
background: $lightblue; background: custom_vars.$lightblue;
} }
} }
.badge-default { .badge-default {
background: $lightblue; background: custom_vars.$lightblue;
} }
.badge-success { .badge-success {
background: mix(green, $lightblue); background: color.mix(green, custom_vars.$lightblue);
} }
} }
@ -87,7 +90,7 @@
} }
.category-listing { .category-listing {
border: solid 1px $grey; border: solid 1px custom_vars.$grey;
padding: 1rem; padding: 1rem;
margin: 0.5rem; margin: 0.5rem;
border-radius: 0.25rem; border-radius: 0.25rem;
@ -133,3 +136,11 @@
#main_options { #main_options {
width: 100%; width: 100%;
} }
#other_time,
#categories_visibility {
display: block;
padding-top: 1rem;
padding-bottom: 5rem;
min-height: 500px;
}

View File

@ -41,9 +41,13 @@ form {
padding: 1rem 2rem; padding: 1rem 2rem;
border-radius: 0.5rem; border-radius: 0.5rem;
border: solid 1px #ccc; border: solid 1px #ccc;
background: blue;
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} }
button.delete-button {
float: right;
min-width: 20rem;
}
} }
.btn-remove-all { .btn-remove-all {

View File

@ -1,3 +1,5 @@
@use "../split/custom_vars";
body { body {
background: #F5F5F5; background: #F5F5F5;
font: 18px/1.5 sans-serif; font: 18px/1.5 sans-serif;
@ -23,7 +25,7 @@ p {
} }
a { a {
color: $primary; color: custom_vars.$primary;
} }
a:hover { a:hover {
@ -127,10 +129,10 @@ code {
} }
.header-block { .header-block {
background: $darkblue; background: custom_vars.$darkblue;
.btn-default { .btn-default {
color: $grey; color: custom_vars.$grey;
} }
.btn { .btn {
@ -144,7 +146,7 @@ code {
} }
#menu-dashboard .nav .logo-home.btn-default { #menu-dashboard .nav .logo-home.btn-default {
background: $darkblue; background: custom_vars.$darkblue;
height: 52px; height: 52px;
font-size: 1em; font-size: 1em;
} }

View File

@ -1,9 +1,10 @@
@import '../split/custom_vars'; @use "sass:color";
@use '../split/custom_vars';
body { body {
margin: 0; margin: 0;
padding: 0; padding: 0;
color: $all-text-color; color: custom_vars.$all-text-color;
font-family: "Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif; font-family: "Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 1rem; font-size: 1rem;
line-height: 2rem; line-height: 2rem;
@ -47,9 +48,8 @@ body {
#portfolio, #portfolio,
#mainNav, #mainNav,
.masthead, .masthead {
{ padding-left: 10vw !important;
padding-left: 300px !important;
} }
} }
@ -74,23 +74,23 @@ body {
} }
.bg-color { .bg-color {
background: $deepblue; background: custom_vars.$deepblue;
color: $light; color: custom_vars.$light;
a { a {
color: $lightblue; color: custom_vars.$lightblue;
} }
padding: 1rem; padding: 1rem;
} }
.logo-main { .logo-main {
color: $logo-color; color: custom_vars.$logo-color;
} }
.big-footer { .big-footer {
background: $dark; background: custom_vars.$dark;
color: $light; color: custom_vars.$light;
height: 10em; height: 10em;
padding: 1em; padding: 1em;
box-sizing: border-box; box-sizing: border-box;
@ -102,8 +102,8 @@ body {
} }
thead { thead {
background: $darkblue; background: custom_vars.$darkblue;
color: $light; color: custom_vars.$light;
} }
ul { ul {
@ -191,13 +191,13 @@ input {
} }
#menu-dashboard { #menu-dashboard {
background: $dark; background: custom_vars.$dark;
display: flex; display: flex;
position: fixed; position: fixed;
left: 0; left: 0;
top: 0; top: 0;
min-height: 100vh; min-height: 100vh;
width: 13vw; width: 10vw;
min-width: 300px; min-width: 300px;
overflow-x: auto; overflow-x: auto;
z-index: 10; z-index: 10;
@ -212,10 +212,10 @@ input {
width: 100%; width: 100%;
min-width: 300px; min-width: 300px;
display: block; display: block;
border-right: solid 2px mix($dark, $grey); border-right: solid 2px color.mix(custom_vars.$dark, custom_vars.$grey);
.btn { .btn {
color: $light; color: custom_vars.$light;
} }
.logo-home { .logo-home {
@ -224,11 +224,11 @@ input {
} }
.btn-default { .btn-default {
color: $light; color: custom_vars.$light;
&:hover { &:hover {
background: mix($deepblue, $light); background: color.mix(custom_vars.$deepblue, custom_vars.$light);
color: $dark; color: custom_vars.$dark;
font-weight: 600; font-weight: 600;
} }
} }
@ -242,7 +242,7 @@ input {
i.fa { i.fa {
float: left; float: left;
margin-right: 1em; margin-right: 1em;
color: $light; color: custom_vars.$light;
} }
} }
@ -251,13 +251,13 @@ input {
&:focus { &:focus {
background: transparent; background: transparent;
border: none; border: none;
color: $lightblue; color: custom_vars.$lightblue;
} }
&:focus { &:focus {
background: transparent; background: transparent;
border: none; border: none;
color: $lightblue; color: custom_vars.$lightblue;
} }
} }
@ -271,7 +271,7 @@ input {
} }
.btn-success { .btn-success {
background-color: $deepblue; background-color: custom_vars.$deepblue;
font-weight: 800; font-weight: 800;
} }
@ -302,8 +302,8 @@ table td {
} }
input[type=submit] { input[type=submit] {
background: $primary; background: custom_vars.$primary;
color: $light; color: custom_vars.$light;
display: block; display: block;
margin-top: 1em; margin-top: 1em;
padding: 1em; padding: 1em;
@ -311,7 +311,7 @@ table td {
width: 100%; width: 100%;
&:hover { &:hover {
background: $lightblue; background: custom_vars.$lightblue;
} }
} }
} }
@ -324,6 +324,7 @@ table td {
#bodyland { #bodyland {
min-height: 100vh; min-height: 100vh;
padding-bottom: 10rem;
.container { .container {
min-height: 90vh; min-height: 90vh;

View File

@ -1,7 +1,9 @@
@use "../split/custom_vars";
.main-section { .main-section {
padding: 1rem; padding: 1rem;
display: flex; display: flex;
color: $light; color: custom_vars.$light;
justify-content: center; justify-content: center;
h1 { h1 {
@ -9,7 +11,7 @@
} }
h2 { h2 {
color: $light !important; color: custom_vars.$light !important;
} }
>div { >div {
@ -20,7 +22,7 @@
} }
.product-values { .product-values {
color: $light; color: custom_vars.$light;
padding: 4rem; padding: 4rem;
padding-top: 25vh; padding-top: 25vh;
} }
@ -32,7 +34,7 @@
h4, h4,
h5, h5,
h6 { h6 {
color: $light; color: custom_vars.$light;
} }
font-size: 1.5rem; font-size: 1.5rem;

View File

@ -1,5 +1,3 @@
@import '~font-awesome/css/font-awesome.css'; @import '~font-awesome/css/font-awesome.css';
//@import '~bootstrap-sass/assets/stylesheets/bootstrap';
@import '~intro.js/minified/introjs.min.css'; @import '~intro.js/minified/introjs.min.css';
@import '~intro.js/themes/introjs-dark.css'; @import '~intro.js/themes/introjs-dark.css';
@import "~bootstrap/scss/bootstrap";

View File

@ -3,187 +3,4 @@
padding-left: 5em; padding-left: 5em;
} }
#caisse-now {
margin-left: -1em;
} }
}
// @media all and(max-width: 1200px) {
// #caisse-now{
// margin-left: 0;
// }
// .big-footer{
// padding-left: 0;
// }
// nav {
// min-width: auto;
// }
// html, body {
// font-size: 1.2rem;
// }
// .bg-shader {
// height: 100%;
// min-height: 100vh;
// }
// .product-values-block {
// padding: 1em;
// }
// #homepage {
// .main-section {
// padding: 2rem;
// }
// .btn {
// display: block;
// width: 100%;
// font-size: 1.25em;
// }
// }
// #caisse-now {
// .product-box {
// width: 100%;
// &.active{
// .product-button{
// background: greenyellow;
// }
// }
// }
// .product-button {
// min-width: calc(100% - 56px)
// }
// .listing-products {
// .btn, button {
// font-size: 1rem;
// padding: 0.2em;
// border-radius: 0.3em;
// }
// }
// }
// }
// @media all and(max-width: 1200px) {
// #bodyland {
// .container {
// min-height: 100vh;
// width: 80vw;
// }
// }
// #menu-dashboard {
// font-size: 1rem;
// width: 19vw;
// min-width: 200px;
// .nav {
// min-width: 200px;
// }
// }
// form {
// margin-top: 3em;
// select {
// width: 100%;
// margin: 1em 0;
// }
// + ul {
// margin-top: 1em;
// list-style-type: none;
// a {
// display: block;
// .fa {
// margin-right: 1em;
// }
// }
// }
// }
// }
// @media all and(max-width: 600px) {
// #menu_button{
// }
// html, body {
// font-size: 1rem;
// }
// #menu-dashboard .nav .logo-home.btn-default {
// height: auto;
// font-size: 2em;
// }
// #menu-dashboard {
// width: 100vw;
// visibility: hidden;
// &.shown {
// visibility: visible;
// }
// .nav {
// min-width: 200px;
// min-height: 100vh;
// overflow: auto;
// a {
// font-size: 2rem;
// }
// }
// }
// .main-section > div {
// padding-top: 0;
// }
// .product-values {
// padding: 0;
// }
// .bigger-text, #homepage, .hint, .product-values-block {
// font-size: 1.25rem;
// line-height: 2rem;
// }
// .category-listing {
// width: calc(100vw - 4rem);
// height: 25vh;
// min-height: auto;
// float: left;
// clear: both;
// overflow: auto;
// }
// .sellings {
// input {
// width: 100%;
// }
// }
// .client-now {
// input {
// width: 50%;
// }
// }
// .sellings, .client-now {
// input {
// font-size: 1.5rem;
// padding: 0.5rem;
// }
// }
// .big-footer {
// font-size: 1rem;
// }
// #caisse-now .product-box {
// margin-bottom: 0.25rem;
// }
// #caisse-now .listing-products button {
// padding: 0.5rem 1rem;
// .express-button {
// padding: 0.5rem 1rem;
// }
// }
// }

6
assets/styles/split/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,11 +1,12 @@
@use "sass:color";
$dark: #222; $dark: #222;
$light: #dedede; $light: #dedede;
$deepblue: #1b6d85; $deepblue: #1b6d85;
$darkblue: mix(#000, $deepblue); $darkblue: color.mix(#000, $deepblue);
$lightblue: lightblue; $lightblue: lightblue;
$grey: #e3e3e3; $grey: #e3e3e3;
$logo-color: mix($deepblue, $light); $logo-color: color.mix($deepblue, $light);
$all-text-color: mix($deepblue, $light); $all-text-color: color.mix($deepblue, $light);
$primary: $deepblue; $primary: $deepblue;
$btn-primary-bg: $deepblue; $btn-primary-bg: $deepblue;

View File

@ -1,3 +1,5 @@
@use "custom_vars";
.current-selling { .current-selling {
ul { ul {
list-style-type: none; list-style-type: none;
@ -17,7 +19,7 @@ table {
} }
.btn-primary { .btn-primary {
background: $deepblue; background: custom_vars.$deepblue;
} }
.product-box { .product-box {

View File

@ -1,5 +1,8 @@
@use "sass:color";
@use "custom_vars";
h2, h3, h4, h5, h6 { h2, h3, h4, h5, h6 {
color: mix($dark, $all-text-color); color: color.mix(custom_vars.$dark, custom_vars.$all-text-color);
} }
h1, .h1, h2, .h2, h3, .h3 { h1, .h1, h2, .h2, h3, .h3 {

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250226145218 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE festvial');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE festvial (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, date_creation DATE DEFAULT NULL, chiffre_affaire DOUBLE PRECISION DEFAULT NULL, clients_count INT DEFAULT NULL, commentaire VARCHAR(500) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
}
}

View File

@ -121,21 +121,14 @@ final class DefaultController extends AbstractController
// récupérer les produits de l'user connecté // récupérer les produits de l'user connecté
$user = $this->getUser(); $user = $this->getUser();
// $products = $this->getUser()->getProducts(); $activeFest = $user->getActiveFestival();
return $this->json([ return $this->json([
'categories' => $user->getGroupOfProducts(), 'categories' => $user->getGroupOfProducts(),
'products' => $user->getProducts(), 'products' => $user->getProducts(),
// mock land // mock land
'lastFestival' => ['id' => 1, 'lastFestival' => $activeFest,
'name' => 'le festival de mock', 'history' => $activeFest->getSellings(),
'dateCreation' => '2025-02-16',
'commentaire' => 'MOCK: hop le commentaire de festival',
'chiffreAffaire' => '1234',
'fondDeCaisseAvant' => '100',
'fondDeCaisseAprès' => '150',
'sold' => 123
],
'history' => [],
]); ]);
} }
@ -274,6 +267,10 @@ final class DefaultController extends AbstractController
$productFound->addSelling($newSelling); $productFound->addSelling($newSelling);
$entityManager->persist($productFound); $entityManager->persist($productFound);
} }
else {
return $this->json(['message' => 'Produit '.$product['id'].' non trouvé'], 403);
}
} }
@ -285,6 +282,8 @@ final class DefaultController extends AbstractController
->setOwner($loggedUser); ->setOwner($loggedUser);
$currentFestival->updateChiffreAffaire();
$entityManager->persist($newSelling); $entityManager->persist($newSelling);
$entityManager->persist($currentFestival); $entityManager->persist($currentFestival);
@ -296,19 +295,8 @@ final class DefaultController extends AbstractController
$response = [ $response = [
'message' => 'yes', 'message' => 'yes',
'newChiffreAffaire' => $currentFestival->getChiffreAffaire(), 'newChiffreAffaire' => $currentFestival->getChiffreAffaire(),
'newChiffreAffaire' => 12, 'clientsCount' => count($currentFestival->getSellings()),
'clientsCount' => $currentFestival->getClientsCount(),
// 'clientsCount' => 12,
'activeFestival' => $currentFestival, 'activeFestival' => $currentFestival,
// 'activeFestival' => ['id' => 1,
// 'name' => 'le festival de mock',
// 'dateCreation' => '2025-02-16',
// 'commentaire' => 'MOCK: hop le commentaire de festival',
// 'chiffreAffaire' => '1234',
// 'fondDeCaisseAvant' => '100',
// 'fondDeCaisseAprès' => '150',
// 'sold' => 123
// ],
]; ];
// prendre en compte l'ajout de nouveaux produits si on a une valeur dans le POST // prendre en compte l'ajout de nouveaux produits si on a une valeur dans le POST

View File

@ -53,11 +53,17 @@ final class ExpenseController extends AbstractController
#[Route('/{id}/edit', name: 'app_expense_edit', methods: ['GET', 'POST'])] #[Route('/{id}/edit', name: 'app_expense_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Expense $expense, EntityManagerInterface $entityManager): Response public function edit(Request $request, Expense $expense, EntityManagerInterface $entityManager): Response
{ {
$userFound = $this->getUser();
if (!$userFound || $expense->getUser() !== $userFound) {
throw $this->createAccessDeniedException('Vous n\'êtes pas autorisé à modifier cette dépense.');
}
$form = $this->createForm(Expense1Type::class, $expense); $form = $this->createForm(Expense1Type::class, $expense);
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush(); $entityManager->flush();
$this->addFlash('success', 'La dépense a été modifiée avec succès.');
return $this->redirectToRoute('app_expense_index', [], Response::HTTP_SEE_OTHER); return $this->redirectToRoute('app_expense_index', [], Response::HTTP_SEE_OTHER);
} }
@ -71,9 +77,15 @@ final class ExpenseController extends AbstractController
#[Route('/{id}', name: 'app_expense_delete', methods: ['POST'])] #[Route('/{id}', name: 'app_expense_delete', methods: ['POST'])]
public function delete(Request $request, Expense $expense, EntityManagerInterface $entityManager): Response public function delete(Request $request, Expense $expense, EntityManagerInterface $entityManager): Response
{ {
$userFound = $this->getUser();
if (!$userFound || $expense->getUser() !== $userFound) {
throw $this->createAccessDeniedException('Vous n\'êtes pas autorisé à supprimer cette dépense.');
}
if ($this->isCsrfTokenValid('delete'.$expense->getId(), $request->getPayload()->getString('_token'))) { if ($this->isCsrfTokenValid('delete'.$expense->getId(), $request->getPayload()->getString('_token'))) {
$entityManager->remove($expense); $entityManager->remove($expense);
$entityManager->flush(); $entityManager->flush();
$this->addFlash('success', 'La dépense a été supprimée avec succès.');
} }
return $this->redirectToRoute('app_expense_index', [], Response::HTTP_SEE_OTHER); return $this->redirectToRoute('app_expense_index', [], Response::HTTP_SEE_OTHER);

View File

@ -45,6 +45,11 @@ final class FestivalController extends AbstractController
#[Route('/{id}', name: 'app_festival_show', methods: ['GET'])] #[Route('/{id}', name: 'app_festival_show', methods: ['GET'])]
public function show(Festival $festival): Response public function show(Festival $festival): Response
{ {
$userFound = $this->getUser();
if (!$userFound || $festival->getUser() !== $userFound) {
throw $this->createAccessDeniedException('Vous n\'êtes pas autorisé à consulter ce festival.');
}
return $this->render('festival/show.html.twig', [ return $this->render('festival/show.html.twig', [
'festival' => $festival, 'festival' => $festival,
]); ]);
@ -53,6 +58,11 @@ final class FestivalController extends AbstractController
#[Route('/{id}/edit', name: 'app_festival_edit', methods: ['GET', 'POST'])] #[Route('/{id}/edit', name: 'app_festival_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Festival $festival, EntityManagerInterface $entityManager): Response public function edit(Request $request, Festival $festival, EntityManagerInterface $entityManager): Response
{ {
$userFound = $this->getUser();
if (!$userFound || $festival->getUser() !== $userFound) {
throw $this->createAccessDeniedException('Vous n\'êtes pas autorisé à modifier ce festival.');
}
$form = $this->createForm(Festival1Type::class, $festival); $form = $this->createForm(Festival1Type::class, $festival);
$form->handleRequest($request); $form->handleRequest($request);
@ -71,10 +81,17 @@ final class FestivalController extends AbstractController
#[Route('/{id}', name: 'app_festival_delete', methods: ['POST'])] #[Route('/{id}', name: 'app_festival_delete', methods: ['POST'])]
public function delete(Request $request, Festival $festival, EntityManagerInterface $entityManager): Response public function delete(Request $request, Festival $festival, EntityManagerInterface $entityManager): Response
{ {
$userFound = $this->getUser();
if (!$userFound || $festival->getUser() !== $userFound) {
throw $this->createAccessDeniedException('Vous n\'êtes pas autorisé à supprimer ce festival.');
}
if ($this->isCsrfTokenValid('delete'.$festival->getId(), $request->getPayload()->getString('_token'))) { if ($this->isCsrfTokenValid('delete'.$festival->getId(), $request->getPayload()->getString('_token'))) {
$entityManager->remove($festival); $entityManager->remove($festival);
$entityManager->flush(); $entityManager->flush();
} }
$this->addFlash('success', 'Le festival a été supprimé avec succès.');
return $this->redirectToRoute('app_festival_index', [], Response::HTTP_SEE_OTHER); return $this->redirectToRoute('app_festival_index', [], Response::HTTP_SEE_OTHER);
} }

View File

@ -52,6 +52,11 @@ final class ProductController extends AbstractController
#[Route('/{id}', name: 'app_product_show', methods: ['GET'])] #[Route('/{id}', name: 'app_product_show', methods: ['GET'])]
public function show(Product $product): Response public function show(Product $product): Response
{ {
$userFound = $this->getUser();
if (!$userFound || $product->getUser() !== $userFound) {
throw $this->createAccessDeniedException('Vous n\'êtes pas autorisé à consulter ce produit.');
}
return $this->render('product/show.html.twig', [ return $this->render('product/show.html.twig', [
'product' => $product, 'product' => $product,
]); ]);
@ -60,6 +65,11 @@ final class ProductController extends AbstractController
#[Route('/{id}/edit', name: 'app_product_edit', methods: ['GET', 'POST'])] #[Route('/{id}/edit', name: 'app_product_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Product $product, EntityManagerInterface $entityManager): Response public function edit(Request $request, Product $product, EntityManagerInterface $entityManager): Response
{ {
$userFound = $this->getUser();
if (!$userFound || $product->getUser() !== $userFound) {
throw $this->createAccessDeniedException('Vous n\'êtes pas autorisé à modifier ce produit.');
}
$form = $this->createForm(Product1Type::class, $product); $form = $this->createForm(Product1Type::class, $product);
$form->handleRequest($request); $form->handleRequest($request);
@ -71,6 +81,7 @@ final class ProductController extends AbstractController
} }
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush(); $entityManager->flush();
$this->addFlash('success', 'Le produit a été modifié avec succès.');
return $this->redirectToRoute('app_product_index', [], Response::HTTP_SEE_OTHER); return $this->redirectToRoute('app_product_index', [], Response::HTTP_SEE_OTHER);
} }
@ -84,9 +95,15 @@ final class ProductController extends AbstractController
#[Route('/{id}', name: 'app_product_delete', methods: ['POST'])] #[Route('/{id}', name: 'app_product_delete', methods: ['POST'])]
public function delete(Request $request, Product $product, EntityManagerInterface $entityManager): Response public function delete(Request $request, Product $product, EntityManagerInterface $entityManager): Response
{ {
$userFound = $this->getUser();
if (!$userFound || $product->getUser() !== $userFound) {
throw $this->createAccessDeniedException('Vous n\'êtes pas autorisé à supprimer ce produit.');
}
if ($this->isCsrfTokenValid('delete'.$product->getId(), $request->getPayload()->getString('_token'))) { if ($this->isCsrfTokenValid('delete'.$product->getId(), $request->getPayload()->getString('_token'))) {
$entityManager->remove($product); $entityManager->remove($product);
$entityManager->flush(); $entityManager->flush();
$this->addFlash('success', 'Le produit a été supprimé avec succès.');
} }
return $this->redirectToRoute('app_product_index', [], Response::HTTP_SEE_OTHER); return $this->redirectToRoute('app_product_index', [], Response::HTTP_SEE_OTHER);

View File

@ -14,6 +14,9 @@ class SecurityController extends AbstractController
{ {
// get the login error if there is one // get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError(); $error = $authenticationUtils->getLastAuthenticationError();
if ($error) {
$this->addFlash('error', 'Identifiants invalides.');
}
// last username entered by the user // last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername(); $lastUsername = $authenticationUtils->getLastUsername();

View File

@ -26,6 +26,7 @@ final class SellingController extends AbstractController
#[Route('/new', name: 'app_selling_new', methods: ['GET', 'POST'])] #[Route('/new', name: 'app_selling_new', methods: ['GET', 'POST'])]
public function new(Request $request, EntityManagerInterface $entityManager): Response public function new(Request $request, EntityManagerInterface $entityManager): Response
{ {
$selling = new Selling(); $selling = new Selling();
$form = $this->createForm(Selling1Type::class, $selling); $form = $this->createForm(Selling1Type::class, $selling);
$form->handleRequest($request); $form->handleRequest($request);
@ -46,6 +47,11 @@ final class SellingController extends AbstractController
#[Route('/{id}', name: 'app_selling_show', methods: ['GET'])] #[Route('/{id}', name: 'app_selling_show', methods: ['GET'])]
public function show(Selling $selling): Response public function show(Selling $selling): Response
{ {
$userFound = $this->getUser();
if (!$userFound || $selling->getUser() !== $userFound) {
throw $this->createAccessDeniedException('Vous n\'êtes pas autorisé à consulter cette vente.');
}
return $this->render('selling/show.html.twig', [ return $this->render('selling/show.html.twig', [
'selling' => $selling, 'selling' => $selling,
]); ]);
@ -54,6 +60,11 @@ final class SellingController extends AbstractController
#[Route('/{id}/edit', name: 'app_selling_edit', methods: ['GET', 'POST'])] #[Route('/{id}/edit', name: 'app_selling_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Selling $selling, EntityManagerInterface $entityManager): Response public function edit(Request $request, Selling $selling, EntityManagerInterface $entityManager): Response
{ {
$userFound = $this->getUser();
if (!$userFound || $selling->getUser() !== $userFound) {
throw $this->createAccessDeniedException('Vous n\'êtes pas autorisé à modifier cette vente.');
}
$form = $this->createForm(Selling1Type::class, $selling); $form = $this->createForm(Selling1Type::class, $selling);
$form->handleRequest($request); $form->handleRequest($request);

View File

@ -45,6 +45,7 @@ final class SerieFestivalController extends AbstractController
#[Route('/{id}', name: 'app_serie_festival_show', methods: ['GET'])] #[Route('/{id}', name: 'app_serie_festival_show', methods: ['GET'])]
public function show(SerieFestival $serieFestival): Response public function show(SerieFestival $serieFestival): Response
{ {
return $this->render('serie_festival/show.html.twig', [ return $this->render('serie_festival/show.html.twig', [
'serie_festival' => $serieFestival, 'serie_festival' => $serieFestival,
]); ]);

View File

@ -269,6 +269,18 @@ class Festival
return $this; return $this;
} }
public function updateChiffreAffaire(): static
{
$total = 0;
foreach ($this->sellings as $selling) {
$total += $selling->getPaidByCustomer();
}
$this->setChiffreAffaire($total);
return $this;
}
public function getChiffreAffaire(): ?float public function getChiffreAffaire(): ?float
{ {
return $this->chiffreAffaire; return $this->chiffreAffaire;

View File

@ -12,6 +12,7 @@ use \App\Entity\Product;
use \App\Entity\Selling; use \App\Entity\Selling;
use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;
use App\Repository\GroupOfProductsRepository;
#[ApiResource(paginationEnabled: false)] #[ApiResource(paginationEnabled: false)]
#[ORM\Entity(repositoryClass: GroupOfProductsRepository::class)] #[ORM\Entity(repositoryClass: GroupOfProductsRepository::class)]
@ -40,7 +41,7 @@ class GroupOfProducts
private ?Collection $sellings = null; private ?Collection $sellings = null;
#[ORM\ManyToOne(inversedBy: 'groupOfProducts')] #[ORM\ManyToOne(inversedBy: 'groupOfProducts')]
private ?User $owner = null; private ?User $user = null;
public function __construct() public function __construct()
@ -132,14 +133,14 @@ class GroupOfProducts
return $this; return $this;
} }
public function getOwner(): ?User public function getUser(): ?User
{ {
return $this->owner; return $this->user;
} }
public function setOwner(?User $owner): static public function setUser(?User $user): static
{ {
$this->owner = $owner; $this->user = $user;
return $this; return $this;
} }

View File

@ -13,6 +13,7 @@ use ApiPlatform\Metadata\Put;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use App\Repository\SellingRepository;
#[ApiResource( #[ApiResource(
operations: [ operations: [
@ -72,7 +73,8 @@ class Selling
#[ORM\ManyToOne(inversedBy: 'sellings')] #[ORM\ManyToOne(inversedBy: 'sellings')]
#[Groups(['selling:read', 'selling:write'])] #[Groups(['selling:read', 'selling:write'])]
private ?User $owner = null; private ?User $user = null;
#[ORM\Column(type: Types::DATE_MUTABLE)] #[ORM\Column(type: Types::DATE_MUTABLE)]
#[Groups(['selling:read', 'selling:write'])] #[Groups(['selling:read', 'selling:write'])]
@ -218,14 +220,18 @@ class Selling
return $this; return $this;
} }
public function getOwner(): ?User public function getuser(): ?User
{ {
return $this->owner; return $this->user;
} }
public function setOwner(?User $owner): static public function setuser(?User $user): static
{ {
$this->owner = $owner; $this->user = $user;
return $this; return $this;
} }

View File

@ -87,13 +87,13 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
/** /**
* @var Collection<int, GroupOfProducts> * @var Collection<int, GroupOfProducts>
*/ */
#[ORM\OneToMany(targetEntity: GroupOfProducts::class, mappedBy: 'owner')] #[ORM\OneToMany(targetEntity: GroupOfProducts::class, mappedBy: 'user')]
private Collection $groupOfProducts; private Collection $groupOfProducts;
/** /**
* @var Collection<int, Selling> * @var Collection<int, Selling>
*/ */
#[ORM\OneToMany(targetEntity: Selling::class, mappedBy: 'owner')] #[ORM\OneToMany(targetEntity: Selling::class, mappedBy: 'user')]
private Collection $sellings; private Collection $sellings;
@ -381,7 +381,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
{ {
if (!$this->groupOfProducts->contains($groupOfProduct)) { if (!$this->groupOfProducts->contains($groupOfProduct)) {
$this->groupOfProducts->add($groupOfProduct); $this->groupOfProducts->add($groupOfProduct);
$groupOfProduct->setOwner($this); $groupOfProduct->setUser($this);
} }
return $this; return $this;
@ -391,8 +391,8 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
{ {
if ($this->groupOfProducts->removeElement($groupOfProduct)) { if ($this->groupOfProducts->removeElement($groupOfProduct)) {
// set the owning side to null (unless already changed) // set the owning side to null (unless already changed)
if ($groupOfProduct->getOwner() === $this) { if ($groupOfProduct->getUser() === $this) {
$groupOfProduct->setOwner(null); $groupOfProduct->setUser(null);
} }
} }
@ -411,7 +411,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
{ {
if (!$this->sellings->contains($selling)) { if (!$this->sellings->contains($selling)) {
$this->sellings->add($selling); $this->sellings->add($selling);
$selling->setOwner($this); $selling->setUser($this);
} }
return $this; return $this;
@ -421,8 +421,8 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
{ {
if ($this->sellings->removeElement($selling)) { if ($this->sellings->removeElement($selling)) {
// set the owning side to null (unless already changed) // set the owning side to null (unless already changed)
if ($selling->getOwner() === $this) { if ($selling->getUser() === $this) {
$selling->setOwner(null); $selling->setUser(null);
} }
} }

View File

@ -29,7 +29,9 @@ class Product1Type extends AbstractType
]) ])
->add('sellings', EntityType::class, [ ->add('sellings', EntityType::class, [
'class' => Selling::class, 'class' => Selling::class,
'choice_label' => 'date', 'choice_label' => function(Selling $selling) {
return $selling->getDate()->format('Y-m-d');
},
'multiple' => true, 'multiple' => true,
'required' => false, 'required' => false,
]) ])

View File

@ -20,26 +20,7 @@
logged logged
{% endif %} {% endif %}
"> ">
<!-- Navigation-->
{# <nav class="navbar navbar-expand-lg bg-secondary text-uppercase fixed-top" id="mainNav">#}
{# <div class="container">#}
{# <a class="navbar-brand" href="/#page-top">{% trans %}menu.title{% endtrans %}</a>#}
{# <button class="navbar-toggler text-uppercase font-weight-bold bg-primary text-white rounded" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">#}
{# Menu#}
{# <i class="fas fa-bars"></i>#}
{# </button>#}
{# <div class="collapse navbar-collapse" id="navbarResponsive">#}
{# <ul class="navbar-nav ms-auto">#}
{# #}
{# <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" href="/#about">About</a></li>#}
{# <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" href="/#contact">Contact</a></li>#}
{# </ul>#}
{# </div>#}
{# </div>#}
{# </nav>#}
{% include 'default/login-choices.html.twig' %} {% include 'default/login-choices.html.twig' %}
<!-- Portfolio Section--> <!-- Portfolio Section-->
<section class="page-section portfolio" id="portfolio"> <section class="page-section portfolio" id="portfolio">
@ -48,6 +29,16 @@ logged
{% block navigation %} {% block navigation %}
{% endblock %} {% endblock %}
<div id="bodyland"> <div id="bodyland">
{% for label, messages in app.flashes %}
{% for message in messages %}
<div class="alert alert-{{ label }} alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endfor %}
{% endfor %}
{% block bigMain %} {% block bigMain %}
{% include 'default/header.html.twig' %} {% include 'default/header.html.twig' %}

View File

@ -1,4 +1,7 @@
<form method="post" action="{{ path('app_festival_delete', {'id': festival.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');"> <form method="post" action="{{ path('app_festival_delete', {'id': festival.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ festival.id) }}"> <input type="hidden" name="_token" value="{{ csrf_token('delete' ~ festival.id) }}">
<button class="btn">Delete</button> <button class="btn btn-danger delete-button">
<i class="fas fa-trash"></i>
Delete
</button>
</form> </form>

View File

@ -4,9 +4,7 @@
<form> <form>
<div class="new-display"> <div class="new-display">
<div class="row">
</div>
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-6"> <div class="col-xs-12 col-sm-6">
<button class="btn btn-warning btn-remove-all marged-v" ng-click="removeAll()" ng-disable="!CurrentSellingTotal()"> <button class="btn btn-warning btn-remove-all marged-v" ng-click="removeAll()" ng-disable="!CurrentSellingTotal()">
@ -14,8 +12,6 @@
</button> </button>
</div> </div>
</div> </div>
<div ng-repeat="group in activeSellingFiltered track by $index"> <div ng-repeat="group in activeSellingFiltered track by $index">
<div class="row"> <div class="row">
@ -60,4 +56,3 @@
</div> </div>
</div>

View File

@ -1,13 +1,13 @@
<!--ok loading done--> <!--ok loading done-->
<div id="loaded" ng-if="initLoadDone"> <div id="loaded" ng-if="initLoadDone">
<!--caisse IHM--> <!--caisse IHM-->
<div id="load_ok" class="row"> <div id="load_ok" class="columns">
<div id="listing-products" class="listing-products col-xs-12 col-md-8"> <div id="listing-products" class="listing-products">
{% include 'logged/angular/messages.html.twig' %} {% include 'logged/angular/messages.html.twig' %}
{% include 'logged/angular/listing-products.html.twig' %} {% include 'logged/angular/listing-products.html.twig' %}
</div> </div>
<div id="sellings" class="sellings col-xs-12 col-md-4"> <div id="sellings" class="sellings">
<div class="list-sell" ng-class="{'bg-success text-success': sellingOk }"> <div class="list-sell" ng-class="{'bg-success text-success': sellingOk }">

View File

@ -3,6 +3,8 @@
{% block title %}Product index{% endblock %} {% block title %}Product index{% endblock %}
{% block body %} {% block body %}
<h1>Product index</h1> <h1>Product index</h1>
<table class="table"> <table class="table">
@ -14,6 +16,7 @@
<th>Stock</th> <th>Stock</th>
<th>Image</th> <th>Image</th>
<th>Comment</th> <th>Comment</th>
<th>Utilisateur-ice</th>
<th>actions</th> <th>actions</th>
</tr> </tr>
</thead> </thead>
@ -24,8 +27,13 @@
<td>{{ product.name }}</td> <td>{{ product.name }}</td>
<td>{{ product.price }}</td> <td>{{ product.price }}</td>
<td>{{ product.stock }}</td> <td>{{ product.stock }}</td>
<td>{{ product.image }}</td> <td>
<a href="{{ path('app_product_show', {'id': product.id}) }}">
<img src="{{ product.image }}" alt="{{ product.name }}" style="width: 100px; height: 100px;">
</a>
</td>
<td>{{ product.comment }}</td> <td>{{ product.comment }}</td>
<td>{{ product.user.name }}, {{ product.user.email }}</td>
<td> <td>
<a href="{{ path('app_product_show', {'id': product.id}) }}">show</a> <a href="{{ path('app_product_show', {'id': product.id}) }}">show</a>
<a href="{{ path('app_product_edit', {'id': product.id}) }}">edit</a> <a href="{{ path('app_product_edit', {'id': product.id}) }}">edit</a>

View File

@ -1,4 +1,7 @@
<form method="post" action="{{ path('app_serie_festival_delete', {'id': serie_festival.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');"> <form method="post" action="{{ path('app_serie_festival_delete', {'id': serie_festival.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ serie_festival.id) }}"> <input type="hidden" name="_token" value="{{ csrf_token('delete' ~ serie_festival.id) }}">
<button class="btn">Delete</button> <button class="btn btn-danger delete-button">
<i class="fas fa-trash"></i>
Delete
</button>
</form> </form>