mirror of
https://forge.chapril.org/tykayn/caisse-bliss
synced 2025-10-09 17:02:47 +02:00
start add selling
This commit is contained in:
parent
0d672d5447
commit
c1b2c97350
14 changed files with 1798 additions and 92 deletions
|
@ -2,10 +2,14 @@
|
|||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use App\Entity\Festival;
|
||||
use App\Entity\Selling;
|
||||
use App\Entity\GroupOfProducts;
|
||||
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class DefaultController extends AbstractController
|
||||
{
|
||||
|
@ -16,6 +20,7 @@ final class DefaultController extends AbstractController
|
|||
'controller_name' => 'DefaultController',
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/accueil', name: 'app_home')]
|
||||
public function accueil(): Response
|
||||
{
|
||||
|
@ -23,6 +28,7 @@ final class DefaultController extends AbstractController
|
|||
'controller_name' => 'DefaultController',
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/dashboard', name: 'dashboard')]
|
||||
public function dashboard(): Response
|
||||
{
|
||||
|
@ -30,7 +36,7 @@ final class DefaultController extends AbstractController
|
|||
'controller_name' => 'DefaultController',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[Route('/export_all', name: 'export_all')]
|
||||
public function export_all(): Response
|
||||
|
@ -65,34 +71,34 @@ final class DefaultController extends AbstractController
|
|||
'controller_name' => 'DefaultController',
|
||||
'chiffreAffaires' => 10000,
|
||||
'statisticsSoldProducts' => [
|
||||
[
|
||||
'name' => 'mock 1',
|
||||
'count' => 10,
|
||||
'value' => 10,
|
||||
],[
|
||||
'name' => 'mock 2',
|
||||
'count' => 1,
|
||||
'value' => 20,
|
||||
],
|
||||
[
|
||||
'name' => 'mock 1',
|
||||
'count' => 10,
|
||||
'value' => 10,
|
||||
], [
|
||||
'name' => 'mock 2',
|
||||
'count' => 1,
|
||||
'value' => 20,
|
||||
],
|
||||
],
|
||||
'activeFestival' => [
|
||||
'fondDeCaisseAvant' => 10,
|
||||
'chiffreAffaire' => 10,
|
||||
'clientsCount' => 10,
|
||||
'name' => 'demo festival mock dans default controller',
|
||||
'fondDeCaisseAvant' => 10,
|
||||
'chiffreAffaire' => 10,
|
||||
'clientsCount' => 10,
|
||||
'name' => 'demo festival mock dans default controller',
|
||||
],
|
||||
'allSellings' => 12,
|
||||
'recentSellings' => [],
|
||||
'recentSells' => [
|
||||
[
|
||||
'id' => '1234',
|
||||
'date' => date_create('now'),
|
||||
'comment' => 'blah',
|
||||
'amount' => 52,
|
||||
'productsSold' => [
|
||||
'name' => 'un truc de démo aussi làààà'
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => '1234',
|
||||
'date' => date_create('now'),
|
||||
'comment' => 'blah',
|
||||
'amount' => 52,
|
||||
'productsSold' => [
|
||||
'name' => 'un truc de démo aussi làààà'
|
||||
],
|
||||
],
|
||||
],
|
||||
'activeSelling' => [],
|
||||
// 'sellingComment' => [],
|
||||
|
@ -105,39 +111,113 @@ final class DefaultController extends AbstractController
|
|||
#[Route('/logged/get-my-products', name: 'get_my_products')]
|
||||
public function get_my_products(): JsonResponse
|
||||
{
|
||||
// TODO: replace this with actual logic to get products of the logged user
|
||||
// récupérer les produits de l'user connecté
|
||||
// TODO: replace this with actual logic to get products of the logged user
|
||||
// récupérer les produits de l'user connecté
|
||||
|
||||
$user = $this->getUser();
|
||||
$user = $this->getUser();
|
||||
// $products = $this->getUser()->getProducts();
|
||||
return $this->json([
|
||||
'categories' => $user->getGroupOfProducts(),
|
||||
'products' => $user->getProducts(),
|
||||
// mock land
|
||||
'lastFestival' => ['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
|
||||
'lastFestival' => ['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
|
||||
],
|
||||
'history' => [],
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/logged/import', name: 'import')]
|
||||
public function import(): Response
|
||||
{
|
||||
// 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
|
||||
return $this->render('logged/import.html.twig', []);
|
||||
}
|
||||
|
||||
#[Route('/logged/mass_create', name: 'mass_create')]
|
||||
public function mass_create(): Response
|
||||
{
|
||||
// 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
|
||||
return $this->render('logged/import.html.twig', []);
|
||||
}
|
||||
|
||||
|
||||
#[Route('/logged/add-selling', name: 'add_selling')]
|
||||
public function add_selling(): JsonResponse
|
||||
{
|
||||
// créer un nouveau Selling et retourner une réponse
|
||||
//
|
||||
// $loggedUser = $this->getUser();
|
||||
// // Prendre les informations en POST et créer une vente avec.
|
||||
// $request = Request::createFromGlobals();
|
||||
// $data = json_decode($request->getContent(), true);
|
||||
//
|
||||
// $dataOfNewSelling = $data['activeSelling'];
|
||||
//
|
||||
// $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éé')
|
||||
// ->setClientsCount(1);
|
||||
// } else {
|
||||
// $currentFestival->setClientsCount($currentFestival->getClientsCount() + 1);
|
||||
// }
|
||||
// $currentFestival->addSelling($newSelling);
|
||||
//
|
||||
// // prendre les identifiants des produits en base et les ajouter aux produits de ce Selling
|
||||
//// $dataOfNewSelling['activeSelling']['id'];
|
||||
//
|
||||
//
|
||||
// // Récupérer l'EntityManager
|
||||
// $entityManager = $this->getDoctrine()->getManager();
|
||||
//
|
||||
// // Récupérer les produits à partir des identifiants
|
||||
// foreach ($dataOfNewSelling['products']['id'] as $productId) {
|
||||
//
|
||||
// $product = $entityManager->getRepository(Product::class)->find($productId);
|
||||
//
|
||||
// if ($product) {
|
||||
// $newSelling->addProduct($product);
|
||||
// $product->addSelling($newSelling);
|
||||
// $entityManager->persist($product);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// $newSelling
|
||||
// ->setPaidByCustomer($dataOfNewSelling['paidByClient'])
|
||||
// ->setCustomerInfo($dataOfNewSelling['comment'])
|
||||
// ->setDate(new \DateTime($data['date']))
|
||||
// ->setOwner($loggedUser);
|
||||
//
|
||||
// $entityManager = $this->getDoctrine()->getManager();
|
||||
// $entityManager->persist($newSelling);
|
||||
//
|
||||
// $entityManager->flush();
|
||||
// $newSelling = new Selling();
|
||||
// $newSelling->setOwner($loggedUser);
|
||||
|
||||
|
||||
$response = [
|
||||
// 'message' => 'yes',
|
||||
// 'newChiffreAffaire' => $currentFestival->getChiffreAffaire(),
|
||||
// 'clientsCount' => $currentFestival->getClientsCount(),
|
||||
// 'activeFestival' => $currentFestival,
|
||||
];
|
||||
|
||||
// prendre en compte l'ajout de nouveaux produits si on a une valeur dans le POST
|
||||
return $this->json($response);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue