fix add selling to current festival in api call from dashboard
This commit is contained in:
parent
7e120c030b
commit
457cafdaef
|
@ -1,6 +1,7 @@
|
|||
#caisse-now {
|
||||
min-height: 90vh;
|
||||
padding-left: 10vw;
|
||||
width: 70vw;
|
||||
padding-left: 0;
|
||||
|
||||
.product-box {
|
||||
display: inline-block;
|
||||
|
@ -21,7 +22,8 @@
|
|||
background: yellowgreen;
|
||||
}
|
||||
|
||||
.btn, button {
|
||||
.btn,
|
||||
button {
|
||||
font-size: 1.6rem;
|
||||
padding: 1.5rem;
|
||||
-webkit-border-radius: 1rem;
|
||||
|
@ -67,14 +69,14 @@
|
|||
// list of one category
|
||||
.one-category {
|
||||
background: #dedede;
|
||||
width: 350px;
|
||||
width: 31rem;
|
||||
margin: 0 4px;
|
||||
height: calc(74vh - 1rem);
|
||||
box-sizing: border-box;
|
||||
display: inline-block;
|
||||
//vertical-align: top;
|
||||
white-space: nowrap;
|
||||
//float: left;
|
||||
overflow-y: auto;
|
||||
|
||||
h2 {
|
||||
font-weight: bold;
|
||||
|
||||
|
@ -106,6 +108,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
#loaded {
|
||||
padding-bottom: 10rem;
|
||||
}
|
||||
|
||||
#not_loaded {
|
||||
width: 100%;
|
||||
height: 75vh;
|
||||
|
@ -124,6 +130,6 @@
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
#main_options{
|
||||
#main_options {
|
||||
width: 100%;
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
form {
|
||||
label{
|
||||
label {
|
||||
min-width: 300px;
|
||||
padding-right: 2rem;
|
||||
padding-bottom: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
textarea,
|
||||
select {
|
||||
padding: 1rem 2rem;
|
||||
|
@ -15,25 +16,28 @@ form {
|
|||
width: 100%;
|
||||
min-width: 50vw;
|
||||
}
|
||||
|
||||
input {
|
||||
padding: 1rem 2rem;
|
||||
border-radius: 0.5rem;
|
||||
border: solid 1px #ccc;
|
||||
margin-bottom: 0.5rem;
|
||||
width: 100%;
|
||||
min-width: 30vw;
|
||||
min-width: 30ch;
|
||||
|
||||
[type="text"] {
|
||||
padding: 1rem 2rem;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
[type="textarea"] {
|
||||
padding: 1rem 2rem;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
button.btn, a {
|
||||
button.btn,
|
||||
a {
|
||||
padding: 1rem 2rem;
|
||||
border-radius: 0.5rem;
|
||||
border: solid 1px #ccc;
|
||||
|
@ -41,3 +45,7 @@ form {
|
|||
margin-bottom: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-remove-all {
|
||||
color: white;
|
||||
}
|
|
@ -8,7 +8,8 @@ body {
|
|||
font-size: 1rem;
|
||||
line-height: 2rem;
|
||||
}
|
||||
.main-container-box{
|
||||
|
||||
.main-container-box {
|
||||
padding-left: 5rem;
|
||||
}
|
||||
|
||||
|
@ -21,12 +22,12 @@ body {
|
|||
}
|
||||
|
||||
.bg-dark {
|
||||
background:rgba(0,0,0,0.55) !important;
|
||||
background: rgba(0, 0, 0, 0.55) !important;
|
||||
}
|
||||
|
||||
.bg-shader {
|
||||
@extend .bg-dark;
|
||||
min-height: 100vh;
|
||||
min-height: 150vh;
|
||||
}
|
||||
|
||||
#portfolio {
|
||||
|
@ -43,12 +44,13 @@ body {
|
|||
}
|
||||
|
||||
.logged {
|
||||
|
||||
#portfolio,
|
||||
#mainNav,
|
||||
.masthead,
|
||||
{
|
||||
padding-left: 300px !important;
|
||||
}
|
||||
padding-left: 300px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.bg-img {
|
||||
|
@ -200,10 +202,12 @@ input {
|
|||
overflow-x: auto;
|
||||
z-index: 10;
|
||||
|
||||
i, svg{
|
||||
i,
|
||||
svg {
|
||||
min-width: 2rem;
|
||||
margin-right: 2ch;
|
||||
}
|
||||
|
||||
.nav {
|
||||
width: 100%;
|
||||
min-width: 300px;
|
||||
|
@ -214,10 +218,11 @@ input {
|
|||
color: $light;
|
||||
}
|
||||
|
||||
.logo-home{
|
||||
width : 300px;
|
||||
.logo-home {
|
||||
width: 300px;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.btn-default {
|
||||
color: $light;
|
||||
|
||||
|
@ -241,8 +246,8 @@ input {
|
|||
}
|
||||
}
|
||||
|
||||
.nav > li > a:hover,
|
||||
.nav > li > a {
|
||||
.nav>li>a:hover,
|
||||
.nav>li>a {
|
||||
&:focus {
|
||||
background: transparent;
|
||||
border: none;
|
||||
|
@ -279,14 +284,14 @@ tr {
|
|||
}
|
||||
|
||||
.table {
|
||||
> div {
|
||||
>div {
|
||||
&:hover {
|
||||
background: #ccc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.table > thead > tr > td,
|
||||
.table>thead>tr>td,
|
||||
table td {
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
@ -324,7 +329,7 @@ table td {
|
|||
min-height: 90vh;
|
||||
}
|
||||
|
||||
> .row {
|
||||
>.row {
|
||||
min-height: 90vh;
|
||||
|
||||
// for crud forms
|
||||
|
@ -335,7 +340,7 @@ table td {
|
|||
}
|
||||
}
|
||||
|
||||
+ ul {
|
||||
+ul {
|
||||
a {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
|
|
@ -236,29 +236,29 @@ final class DefaultController extends AbstractController
|
|||
|
||||
$dataOfNewSelling = $data;
|
||||
|
||||
// return $this->json($dataOfNewSelling);
|
||||
|
||||
|
||||
$newSelling = new Selling();
|
||||
|
||||
// si l'utilisateur courant n'a pas de festival actuel, en créer un
|
||||
|
||||
// $currentFestival = $loggedUser->getCurrentFestival();
|
||||
// if (!$currentFestival) {
|
||||
//
|
||||
// $currentFestival = new Festival();
|
||||
// $currentFestival
|
||||
// ->setName('festival auto créé')
|
||||
// ->setUser($loggedUser)
|
||||
// ->setDateCreation(new \DateTime())
|
||||
// ->setDateStart(new \DateTime())
|
||||
// ->setDateEnd((new \DateTime())->modify('+1 year'))
|
||||
// ->setClientsCount(1);
|
||||
//
|
||||
// $entityManager->persist($currentFestival);
|
||||
// } else {
|
||||
// $currentFestival->setClientsCount($currentFestival->getClientsCount() + 1);
|
||||
// }
|
||||
// $currentFestival->addSelling($newSelling);
|
||||
$currentFestival = $loggedUser->getActiveFestival();
|
||||
if (!$currentFestival) {
|
||||
|
||||
$currentFestival = new Festival();
|
||||
$currentFestival
|
||||
->setName('festival auto créé')
|
||||
->setUser($loggedUser)
|
||||
->setDateCreation(new \DateTime())
|
||||
->setDateStart(new \DateTime())
|
||||
->setDateEnd((new \DateTime())->modify('+1 year'))
|
||||
->setClientsCount(1);
|
||||
|
||||
$entityManager->persist($currentFestival);
|
||||
} else {
|
||||
$currentFestival->setClientsCount($currentFestival->getClientsCount() + 1);
|
||||
}
|
||||
$currentFestival->addSelling($newSelling);
|
||||
|
||||
// prendre les identifiants des produits en base et les ajouter aux produits de ce Selling
|
||||
// Récupérer les produits à partir des identifiants
|
||||
|
@ -286,7 +286,7 @@ final class DefaultController extends AbstractController
|
|||
|
||||
|
||||
$entityManager->persist($newSelling);
|
||||
|
||||
$entityManager->persist($currentFestival);
|
||||
|
||||
$newSelling->setOwner($loggedUser);
|
||||
$entityManager->persist($loggedUser);
|
||||
|
@ -295,20 +295,20 @@ final class DefaultController extends AbstractController
|
|||
|
||||
$response = [
|
||||
'message' => 'yes',
|
||||
// TODO démocker 'newChiffreAffaire' => $currentFestival->getChiffreAffaire(),
|
||||
'newChiffreAffaire' => $currentFestival->getChiffreAffaire(),
|
||||
'newChiffreAffaire' => 12,
|
||||
// 'clientsCount' => $currentFestival->getClientsCount(),
|
||||
'clientsCount' => 12,
|
||||
// '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
|
||||
],
|
||||
'clientsCount' => $currentFestival->getClientsCount(),
|
||||
// 'clientsCount' => 12,
|
||||
'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
|
||||
|
|
|
@ -7,58 +7,87 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
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)]
|
||||
class Festival
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['festival:read', 'selling:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[Groups(['festival:read', 'festival:write', 'selling:read'])]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
|
||||
#[Groups(['festival:read', 'festival:write'])]
|
||||
private ?\DateTimeInterface $date_start = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE)]
|
||||
#[Groups(['festival:read', 'festival:write'])]
|
||||
private ?\DateTimeInterface $date_end = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, User>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: User::class, mappedBy: 'currentFestival')]
|
||||
#[Groups(['festival:read'])]
|
||||
private Collection $users;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'festivals')]
|
||||
#[Groups(['festival:read', 'festival:write'])]
|
||||
private ?User $user = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
#[Groups(['festival:read', 'festival:write'])]
|
||||
private ?float $fraisInscription = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
#[Groups(['festival:read', 'festival:write'])]
|
||||
private ?float $fondDeCaisseAvant = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
#[Groups(['festival:read', 'festival:write'])]
|
||||
private ?float $fondDeCaisseApres = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE)]
|
||||
#[Groups(['festival:read', 'festival:write'])]
|
||||
private ?\DateTimeInterface $dateCreation = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Selling>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Selling::class, mappedBy: 'festival')]
|
||||
#[Groups(['festival:item:read'])]
|
||||
private Collection $sellings;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'festivals')]
|
||||
#[Groups(['festival:read', 'festival:write'])]
|
||||
private ?SerieFestival $serieFestival = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
#[Groups(['festival:read', 'festival:write'])]
|
||||
private ?float $chiffreAffaire = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
#[Groups(['festival:read', 'festival:write'])]
|
||||
private ?int $clientsCount = null;
|
||||
|
||||
public function __construct()
|
||||
|
|
|
@ -5,52 +5,77 @@ namespace App\Entity;
|
|||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
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;
|
||||
|
||||
#[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)]
|
||||
class Selling
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['selling:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['selling:read', 'selling:write'])]
|
||||
private ?string $note = null;
|
||||
|
||||
#[ORM\Column]
|
||||
#[Groups(['selling:read', 'selling:write'])]
|
||||
private ?float $sum = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
#[Groups(['selling:read', 'selling:write'])]
|
||||
private ?float $reduction = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, GroupOfProducts>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: GroupOfProducts::class, mappedBy: 'sellings')]
|
||||
#[Groups(['selling:read', 'selling:write'])]
|
||||
private Collection $groupOfProducts;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Product>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Product::class, inversedBy: 'sellings')]
|
||||
#[Groups(['selling:read', 'selling:write'])]
|
||||
private Collection $products;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'sellings')]
|
||||
#[Groups(['selling:read', 'selling:write'])]
|
||||
private ?Festival $festival = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[Groups(['selling:read', 'selling:write'])]
|
||||
private ?string $customer_info = null;
|
||||
|
||||
#[ORM\Column]
|
||||
#[Groups(['selling:read', 'selling:write'])]
|
||||
private ?float $paidByCustomer = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'sellings')]
|
||||
#[Groups(['selling:read', 'selling:write'])]
|
||||
private ?User $owner = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE)]
|
||||
#[Groups(['selling:read', 'selling:write'])]
|
||||
private ?\DateTimeInterface $date = null;
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
<th>FondDeCaisseApres</th>
|
||||
<th>DateCreation</th>
|
||||
<th>actions</th>
|
||||
<th>Sellings</th>
|
||||
<th>Set as active</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -36,9 +38,14 @@
|
|||
<td>{{ festival.fondDeCaisseApres }}</td>
|
||||
<td>{{ festival.dateCreation ? festival.dateCreation|date('Y-m-d') : '' }}</td>
|
||||
<td>
|
||||
<a href="{{ path('app_festival_show', {'id': festival.id}) }}">show</a>
|
||||
<a href="{{ path('app_festival_edit', {'id': festival.id}) }}">edit</a>
|
||||
<a href="{{ path('app_set_active_festival', {'id': festival.id}) }}">Set as active</a>
|
||||
<a href="{{ path('app_festival_show', {'id': festival.id}) }}">voir</a>
|
||||
<a href="{{ path('app_festival_edit', {'id': festival.id}) }}">modifier</a>
|
||||
|
||||
</td>
|
||||
<td>{{ festival.sellings|length }}</td>
|
||||
|
||||
<td>
|
||||
<a href="{{ path('app_set_active_festival', {'id': festival.id}) }}">activer</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
|
|
|
@ -18,33 +18,32 @@
|
|||
|
||||
<div ng-repeat="group in activeSellingFiltered track by $index">
|
||||
<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">
|
||||
<input class="group-name" type="text" ng-model="group.name">
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
<div class="row">
|
||||
<div class="col-xs-7 col-xs-offset-2 ">
|
||||
<span ng-if="group.count > 1">
|
||||
|
||||
<strong>
|
||||
{{group.unitPrice}}
|
||||
€ </strong>
|
||||
</span>
|
||||
<span class="badge badge-default" ng-if="group.count">
|
||||
<i class="fa fa-times"></i> {{group.count}}
|
||||
</span>
|
||||
<span ng-if="group.count > 1">
|
||||
<strong>
|
||||
{{group.unitPrice}}
|
||||
€ </strong>
|
||||
</span>
|
||||
<span class="badge badge-default" ng-if="group.count">
|
||||
<i class="fa fa-times"></i> {{group.count}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-xs-3 text-right">
|
||||
<strong>
|
||||
{{group.totalPrice}}
|
||||
{{group.totalPrice}}
|
||||
€ </strong>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!--ok loading done-->
|
||||
<div id="loaded" ng-if="initLoadDone">
|
||||
<!--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">
|
||||
{% include 'logged/angular/messages.html.twig' %}
|
||||
{% include 'logged/angular/listing-products.html.twig' %}
|
||||
|
@ -11,7 +11,7 @@
|
|||
|
||||
<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' %}
|
||||
{% if app.user.products |length %}
|
||||
{% include 'logged/angular/current.html.twig' %}
|
||||
|
@ -21,13 +21,18 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="other_time">
|
||||
ventes récentes
|
||||
{% include 'logged/angular/recent.html.twig' %}
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-4 col-md-offset-8">
|
||||
catégories
|
||||
{% include 'logged/angular/categ-options.html.twig' %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<div id="categories_visibility">
|
||||
catégories
|
||||
{% include 'logged/angular/categ-options.html.twig' %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<div id="other_time">
|
||||
ventes récentes
|
||||
{% include 'logged/angular/recent.html.twig' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<label for="sellingComment">
|
||||
Client actuel: {{ activeSelling.length }} produit<span ng-if="activeSelling.length!=1">s</span>
|
||||
</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>
|
||||
</button>
|
||||
<input type="text"
|
||||
|
|
Loading…
Reference in New Issue