fix add selling to current festival in api call from dashboard

This commit is contained in:
Tykayn 2025-02-26 14:51:48 +01:00 committed by tykayn
parent 7e120c030b
commit 457cafdaef
10 changed files with 174 additions and 90 deletions

View File

@ -1,6 +1,7 @@
#caisse-now { #caisse-now {
min-height: 90vh; min-height: 90vh;
padding-left: 10vw; width: 70vw;
padding-left: 0;
.product-box { .product-box {
display: inline-block; display: inline-block;
@ -21,7 +22,8 @@
background: yellowgreen; background: yellowgreen;
} }
.btn, button { .btn,
button {
font-size: 1.6rem; font-size: 1.6rem;
padding: 1.5rem; padding: 1.5rem;
-webkit-border-radius: 1rem; -webkit-border-radius: 1rem;
@ -67,14 +69,14 @@
// list of one category // list of one category
.one-category { .one-category {
background: #dedede; background: #dedede;
width: 350px; width: 31rem;
margin: 0 4px; margin: 0 4px;
height: calc(74vh - 1rem); height: calc(74vh - 1rem);
box-sizing: border-box; box-sizing: border-box;
display: inline-block; display: inline-block;
//vertical-align: top;
white-space: nowrap; white-space: nowrap;
//float: left; overflow-y: auto;
h2 { h2 {
font-weight: bold; font-weight: bold;
@ -106,6 +108,10 @@
} }
} }
#loaded {
padding-bottom: 10rem;
}
#not_loaded { #not_loaded {
width: 100%; width: 100%;
height: 75vh; height: 75vh;
@ -124,6 +130,6 @@
text-align: center; text-align: center;
} }
#main_options{ #main_options {
width: 100%; width: 100%;
} }

View File

@ -1,10 +1,11 @@
form { form {
label{ label {
min-width: 300px; min-width: 300px;
padding-right: 2rem; padding-right: 2rem;
padding-bottom: 1rem; padding-bottom: 1rem;
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} }
textarea, textarea,
select { select {
padding: 1rem 2rem; padding: 1rem 2rem;
@ -15,29 +16,36 @@ form {
width: 100%; width: 100%;
min-width: 50vw; min-width: 50vw;
} }
input { input {
padding: 1rem 2rem; padding: 1rem 2rem;
border-radius: 0.5rem; border-radius: 0.5rem;
border: solid 1px #ccc; border: solid 1px #ccc;
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
width: 100%; width: 100%;
min-width: 30vw; min-width: 30ch;
[type="text"] { [type="text"] {
padding: 1rem 2rem; padding: 1rem 2rem;
border-radius: 0.5rem; border-radius: 0.5rem;
} }
[type="textarea"] { [type="textarea"] {
padding: 1rem 2rem; padding: 1rem 2rem;
border-radius: 0.5rem; border-radius: 0.5rem;
} }
} }
button.btn, a { button.btn,
a {
padding: 1rem 2rem; padding: 1rem 2rem;
border-radius: 0.5rem; border-radius: 0.5rem;
border: solid 1px #ccc; border: solid 1px #ccc;
background: blue; background: blue;
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} }
}
.btn-remove-all {
color: white;
} }

View File

@ -8,7 +8,8 @@ body {
font-size: 1rem; font-size: 1rem;
line-height: 2rem; line-height: 2rem;
} }
.main-container-box{
.main-container-box {
padding-left: 5rem; padding-left: 5rem;
} }
@ -21,12 +22,12 @@ body {
} }
.bg-dark { .bg-dark {
background:rgba(0,0,0,0.55) !important; background: rgba(0, 0, 0, 0.55) !important;
} }
.bg-shader { .bg-shader {
@extend .bg-dark; @extend .bg-dark;
min-height: 100vh; min-height: 150vh;
} }
#portfolio { #portfolio {
@ -43,12 +44,13 @@ body {
} }
.logged { .logged {
#portfolio, #portfolio,
#mainNav, #mainNav,
.masthead, .masthead,
{ {
padding-left: 300px !important; padding-left: 300px !important;
} }
} }
.bg-img { .bg-img {
@ -200,10 +202,12 @@ input {
overflow-x: auto; overflow-x: auto;
z-index: 10; z-index: 10;
i, svg{ i,
svg {
min-width: 2rem; min-width: 2rem;
margin-right: 2ch; margin-right: 2ch;
} }
.nav { .nav {
width: 100%; width: 100%;
min-width: 300px; min-width: 300px;
@ -214,10 +218,11 @@ input {
color: $light; color: $light;
} }
.logo-home{ .logo-home {
width : 300px; width: 300px;
margin-bottom: 1em; margin-bottom: 1em;
} }
.btn-default { .btn-default {
color: $light; color: $light;
@ -241,8 +246,8 @@ input {
} }
} }
.nav > li > a:hover, .nav>li>a:hover,
.nav > li > a { .nav>li>a {
&:focus { &:focus {
background: transparent; background: transparent;
border: none; border: none;
@ -279,14 +284,14 @@ tr {
} }
.table { .table {
> div { >div {
&:hover { &:hover {
background: #ccc; background: #ccc;
} }
} }
} }
.table > thead > tr > td, .table>thead>tr>td,
table td { table td {
padding: 0.5em; padding: 0.5em;
} }
@ -324,7 +329,7 @@ table td {
min-height: 90vh; min-height: 90vh;
} }
> .row { >.row {
min-height: 90vh; min-height: 90vh;
// for crud forms // for crud forms
@ -335,7 +340,7 @@ table td {
} }
} }
+ ul { +ul {
a { a {
margin-top: 1em; margin-top: 1em;
} }

View File

@ -236,29 +236,29 @@ final class DefaultController extends AbstractController
$dataOfNewSelling = $data; $dataOfNewSelling = $data;
// return $this->json($dataOfNewSelling);
$newSelling = new Selling(); $newSelling = new Selling();
// si l'utilisateur courant n'a pas de festival actuel, en créer un // si l'utilisateur courant n'a pas de festival actuel, en créer un
// $currentFestival = $loggedUser->getCurrentFestival(); $currentFestival = $loggedUser->getActiveFestival();
// if (!$currentFestival) { if (!$currentFestival) {
//
// $currentFestival = new Festival(); $currentFestival = new Festival();
// $currentFestival $currentFestival
// ->setName('festival auto créé') ->setName('festival auto créé')
// ->setUser($loggedUser) ->setUser($loggedUser)
// ->setDateCreation(new \DateTime()) ->setDateCreation(new \DateTime())
// ->setDateStart(new \DateTime()) ->setDateStart(new \DateTime())
// ->setDateEnd((new \DateTime())->modify('+1 year')) ->setDateEnd((new \DateTime())->modify('+1 year'))
// ->setClientsCount(1); ->setClientsCount(1);
//
// $entityManager->persist($currentFestival); $entityManager->persist($currentFestival);
// } else { } else {
// $currentFestival->setClientsCount($currentFestival->getClientsCount() + 1); $currentFestival->setClientsCount($currentFestival->getClientsCount() + 1);
// } }
// $currentFestival->addSelling($newSelling); $currentFestival->addSelling($newSelling);
// prendre les identifiants des produits en base et les ajouter aux produits de ce Selling // prendre les identifiants des produits en base et les ajouter aux produits de ce Selling
// Récupérer les produits à partir des identifiants // Récupérer les produits à partir des identifiants
@ -286,7 +286,7 @@ final class DefaultController extends AbstractController
$entityManager->persist($newSelling); $entityManager->persist($newSelling);
$entityManager->persist($currentFestival);
$newSelling->setOwner($loggedUser); $newSelling->setOwner($loggedUser);
$entityManager->persist($loggedUser); $entityManager->persist($loggedUser);
@ -295,20 +295,20 @@ final class DefaultController extends AbstractController
$response = [ $response = [
'message' => 'yes', 'message' => 'yes',
// TODO démocker 'newChiffreAffaire' => $currentFestival->getChiffreAffaire(), 'newChiffreAffaire' => $currentFestival->getChiffreAffaire(),
'newChiffreAffaire' => 12, 'newChiffreAffaire' => 12,
// 'clientsCount' => $currentFestival->getClientsCount(), 'clientsCount' => $currentFestival->getClientsCount(),
'clientsCount' => 12, // 'clientsCount' => 12,
// 'activeFestival' => $currentFestival, 'activeFestival' => $currentFestival,
'activeFestival' => ['id' => 1, // 'activeFestival' => ['id' => 1,
'name' => 'le festival de mock', // 'name' => 'le festival de mock',
'dateCreation' => '2025-02-16', // 'dateCreation' => '2025-02-16',
'commentaire' => 'MOCK: hop le commentaire de festival', // 'commentaire' => 'MOCK: hop le commentaire de festival',
'chiffreAffaire' => '1234', // 'chiffreAffaire' => '1234',
'fondDeCaisseAvant' => '100', // 'fondDeCaisseAvant' => '100',
'fondDeCaisseAprès' => '150', // 'fondDeCaisseAprès' => '150',
'sold' => 123 // '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

@ -7,58 +7,87 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use Symfony\Component\Serializer\Annotation\Groups;
#[ApiResource(
operations: [
new GetCollection(normalizationContext: ['groups' => ['festival:read']]),
new Get(normalizationContext: ['groups' => ['festival:read', 'festival:item:read']]),
new Post(denormalizationContext: ['groups' => ['festival:write']]),
new Put(denormalizationContext: ['groups' => ['festival:write']])
],
paginationEnabled: false
)]
#[ORM\Entity(repositoryClass: FestivalRepository::class)] #[ORM\Entity(repositoryClass: FestivalRepository::class)]
class Festival class Festival
{ {
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue] #[ORM\GeneratedValue]
#[ORM\Column] #[ORM\Column]
#[Groups(['festival:read', 'selling:read'])]
private ?int $id = null; private ?int $id = null;
#[ORM\Column(length: 255)] #[ORM\Column(length: 255)]
#[Groups(['festival:read', 'festival:write', 'selling:read'])]
private ?string $name = null; private ?string $name = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)] #[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
#[Groups(['festival:read', 'festival:write'])]
private ?\DateTimeInterface $date_start = null; private ?\DateTimeInterface $date_start = null;
#[ORM\Column(type: Types::DATE_MUTABLE)] #[ORM\Column(type: Types::DATE_MUTABLE)]
#[Groups(['festival:read', 'festival:write'])]
private ?\DateTimeInterface $date_end = null; private ?\DateTimeInterface $date_end = null;
/** /**
* @var Collection<int, User> * @var Collection<int, User>
*/ */
#[ORM\OneToMany(targetEntity: User::class, mappedBy: 'currentFestival')] #[ORM\OneToMany(targetEntity: User::class, mappedBy: 'currentFestival')]
#[Groups(['festival:read'])]
private Collection $users; private Collection $users;
#[ORM\ManyToOne(inversedBy: 'festivals')] #[ORM\ManyToOne(inversedBy: 'festivals')]
#[Groups(['festival:read', 'festival:write'])]
private ?User $user = null; private ?User $user = null;
#[ORM\Column(nullable: true)] #[ORM\Column(nullable: true)]
#[Groups(['festival:read', 'festival:write'])]
private ?float $fraisInscription = null; private ?float $fraisInscription = null;
#[ORM\Column(nullable: true)] #[ORM\Column(nullable: true)]
#[Groups(['festival:read', 'festival:write'])]
private ?float $fondDeCaisseAvant = null; private ?float $fondDeCaisseAvant = null;
#[ORM\Column(nullable: true)] #[ORM\Column(nullable: true)]
#[Groups(['festival:read', 'festival:write'])]
private ?float $fondDeCaisseApres = null; private ?float $fondDeCaisseApres = null;
#[ORM\Column(type: Types::DATE_MUTABLE)] #[ORM\Column(type: Types::DATE_MUTABLE)]
#[Groups(['festival:read', 'festival:write'])]
private ?\DateTimeInterface $dateCreation = null; private ?\DateTimeInterface $dateCreation = null;
/** /**
* @var Collection<int, Selling> * @var Collection<int, Selling>
*/ */
#[ORM\OneToMany(targetEntity: Selling::class, mappedBy: 'festival')] #[ORM\OneToMany(targetEntity: Selling::class, mappedBy: 'festival')]
#[Groups(['festival:item:read'])]
private Collection $sellings; private Collection $sellings;
#[ORM\ManyToOne(inversedBy: 'festivals')] #[ORM\ManyToOne(inversedBy: 'festivals')]
#[Groups(['festival:read', 'festival:write'])]
private ?SerieFestival $serieFestival = null; private ?SerieFestival $serieFestival = null;
#[ORM\Column(nullable: true)] #[ORM\Column(nullable: true)]
#[Groups(['festival:read', 'festival:write'])]
private ?float $chiffreAffaire = null; private ?float $chiffreAffaire = null;
#[ORM\Column(nullable: true)] #[ORM\Column(nullable: true)]
#[Groups(['festival:read', 'festival:write'])]
private ?int $clientsCount = null; private ?int $clientsCount = null;
public function __construct() public function __construct()

View File

@ -5,52 +5,77 @@ namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
#[ApiResource(paginationEnabled: false)] #[ApiResource(
operations: [
new GetCollection(normalizationContext: ['groups' => ['selling:read']]),
new Get(normalizationContext: ['groups' => ['selling:read', 'selling:item:read']]),
new Post(denormalizationContext: ['groups' => ['selling:write']]),
new Put(denormalizationContext: ['groups' => ['selling:write']])
],
paginationEnabled: false
)]
#[ORM\Entity(repositoryClass: SellingRepository::class)] #[ORM\Entity(repositoryClass: SellingRepository::class)]
class Selling class Selling
{ {
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue] #[ORM\GeneratedValue]
#[ORM\Column] #[ORM\Column]
#[Groups(['selling:read'])]
private ?int $id = null; private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)] #[ORM\Column(length: 255, nullable: true)]
#[Groups(['selling:read', 'selling:write'])]
private ?string $note = null; private ?string $note = null;
#[ORM\Column] #[ORM\Column]
#[Groups(['selling:read', 'selling:write'])]
private ?float $sum = null; private ?float $sum = null;
#[ORM\Column(nullable: true)] #[ORM\Column(nullable: true)]
#[Groups(['selling:read', 'selling:write'])]
private ?float $reduction = null; private ?float $reduction = null;
/** /**
* @var Collection<int, GroupOfProducts> * @var Collection<int, GroupOfProducts>
*/ */
#[ORM\ManyToMany(targetEntity: GroupOfProducts::class, mappedBy: 'sellings')] #[ORM\ManyToMany(targetEntity: GroupOfProducts::class, mappedBy: 'sellings')]
#[Groups(['selling:read', 'selling:write'])]
private Collection $groupOfProducts; private Collection $groupOfProducts;
/** /**
* @var Collection<int, Product> * @var Collection<int, Product>
*/ */
#[ORM\ManyToMany(targetEntity: Product::class, inversedBy: 'sellings')] #[ORM\ManyToMany(targetEntity: Product::class, inversedBy: 'sellings')]
#[Groups(['selling:read', 'selling:write'])]
private Collection $products; private Collection $products;
#[ORM\ManyToOne(inversedBy: 'sellings')] #[ORM\ManyToOne(inversedBy: 'sellings')]
#[Groups(['selling:read', 'selling:write'])]
private ?Festival $festival = null; private ?Festival $festival = null;
#[ORM\Column(length: 255)] #[ORM\Column(length: 255)]
#[Groups(['selling:read', 'selling:write'])]
private ?string $customer_info = null; private ?string $customer_info = null;
#[ORM\Column] #[ORM\Column]
#[Groups(['selling:read', 'selling:write'])]
private ?float $paidByCustomer = null; private ?float $paidByCustomer = null;
#[ORM\ManyToOne(inversedBy: 'sellings')] #[ORM\ManyToOne(inversedBy: 'sellings')]
#[Groups(['selling:read', 'selling:write'])]
private ?User $owner = null; private ?User $owner = null;
#[ORM\Column(type: Types::DATE_MUTABLE)] #[ORM\Column(type: Types::DATE_MUTABLE)]
#[Groups(['selling:read', 'selling:write'])]
private ?\DateTimeInterface $date = null; private ?\DateTimeInterface $date = null;

View File

@ -17,6 +17,8 @@
<th>FondDeCaisseApres</th> <th>FondDeCaisseApres</th>
<th>DateCreation</th> <th>DateCreation</th>
<th>actions</th> <th>actions</th>
<th>Sellings</th>
<th>Set as active</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -36,9 +38,14 @@
<td>{{ festival.fondDeCaisseApres }}</td> <td>{{ festival.fondDeCaisseApres }}</td>
<td>{{ festival.dateCreation ? festival.dateCreation|date('Y-m-d') : '' }}</td> <td>{{ festival.dateCreation ? festival.dateCreation|date('Y-m-d') : '' }}</td>
<td> <td>
<a href="{{ path('app_festival_show', {'id': festival.id}) }}">show</a> <a href="{{ path('app_festival_show', {'id': festival.id}) }}">voir</a>
<a href="{{ path('app_festival_edit', {'id': festival.id}) }}">edit</a> <a href="{{ path('app_festival_edit', {'id': festival.id}) }}">modifier</a>
<a href="{{ path('app_set_active_festival', {'id': festival.id}) }}">Set as active</a>
</td>
<td>{{ festival.sellings|length }}</td>
<td>
<a href="{{ path('app_set_active_festival', {'id': festival.id}) }}">activer</a>
</td> </td>
</tr> </tr>
{% else %} {% else %}

View File

@ -18,33 +18,32 @@
<div ng-repeat="group in activeSellingFiltered track by $index"> <div ng-repeat="group in activeSellingFiltered track by $index">
<div class="row"> <div class="row">
<div class="col-xs-2">
<span class="btn btn-warning remove-item"
ng-click="removeGroupeProducts(group.groupId)">
<i class="fa fa-trash"></i>
</span>
</div>
<div class="col-xs-10"> <div class="col-xs-10">
<input class="group-name" type="text" ng-model="group.name"> <input class="group-name" type="text" ng-model="group.name">
</div> </div>
</div> <div class="col-xs-2">
<div class="row"> <span class="btn btn-warning remove-item"
ng-click="removeGroupeProducts(group.groupId)">
<i class="fa fa-trash"></i>
</span>
</div>
</div>
<div class="row">
<div class="col-xs-7 col-xs-offset-2 "> <div class="col-xs-7 col-xs-offset-2 ">
<span ng-if="group.count > 1"> <span ng-if="group.count > 1">
<strong>
<strong> {{group.unitPrice}}
{{group.unitPrice}} € </strong>
€ </strong> </span>
</span> <span class="badge badge-default" ng-if="group.count">
<span class="badge badge-default" ng-if="group.count"> <i class="fa fa-times"></i> {{group.count}}
<i class="fa fa-times"></i> {{group.count}} </span>
</span>
</div> </div>
<div class="col-xs-3 text-right"> <div class="col-xs-3 text-right">
<strong> <strong>
{{group.totalPrice}} {{group.totalPrice}}
€ </strong> € </strong>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
<!--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"> <div id="load_ok" class="row">
<div id="listing-products" class="listing-products col-xs-12 col-md-8"> <div id="listing-products" class="listing-products col-xs-12 col-md-8">
{% 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' %}
@ -11,7 +11,7 @@
<div class="list-sell" ng-class="{'bg-success text-success': sellingOk }"> <div class="list-sell" ng-class="{'bg-success text-success': sellingOk }">
<button class="button">valider</button> <button class="button btn btn-default">valider</button>
{% include 'logged/angular/validate-button.html.twig' %} {% include 'logged/angular/validate-button.html.twig' %}
{% if app.user.products |length %} {% if app.user.products |length %}
{% include 'logged/angular/current.html.twig' %} {% include 'logged/angular/current.html.twig' %}
@ -21,13 +21,18 @@
</div> </div>
</div> </div>
</div> </div>
<div id="other_time"> <div class="row">
ventes récentes <div class="col-xs-12 col-md-6">
{% include 'logged/angular/recent.html.twig' %} <div id="categories_visibility">
</div> catégories
<div class="col-xs-12 col-md-4 col-md-offset-8"> {% include 'logged/angular/categ-options.html.twig' %}
catégories </div>
{% include 'logged/angular/categ-options.html.twig' %} </div>
<div class="col-xs-12 col-md-6">
</div> <div id="other_time">
ventes récentes
{% include 'logged/angular/recent.html.twig' %}
</div>
</div>
</div>
</div> </div>

View File

@ -6,7 +6,7 @@
<label for="sellingComment"> <label for="sellingComment">
Client actuel: {{ activeSelling.length }} produit<span ng-if="activeSelling.length!=1">s</span> Client actuel: {{ activeSelling.length }} produit<span ng-if="activeSelling.length!=1">s</span>
</label> </label>
<button type="button" class="deleter pull-right" ng-click="sellingComment = ''"> <button type="button" class="btn btn-warning deleter pull-right" ng-click="sellingComment = ''">
<i class="fa fa-times"></i> <i class="fa fa-times"></i>
</button> </button>
<input type="text" <input type="text"