diff --git a/.stylelintrc.json b/.stylelintrc.json index e3df55e9862d4a5eb73c19cd8cf64fae286d6745..71060329a6583c791d1d15c79ee8239b3d4b25cd 100644 --- a/.stylelintrc.json +++ b/.stylelintrc.json @@ -6,6 +6,7 @@ "rules": { "selector-class-pattern": null, "selector-id-pattern": null, - "property-no-vendor-prefix": null + "property-no-vendor-prefix": null, + "no-descending-specificity": null } } \ No newline at end of file diff --git a/css/style.css b/css/style.css index 4df86a8c329a39acfc8bcc512593ae3e994ec1ab..eddb38552e62cc0ae549b20b52fd44f2052baf29 100644 --- a/css/style.css +++ b/css/style.css @@ -40,8 +40,11 @@ body { font-family: Montserrat, sans-serif; overflow-x: hidden; - background: linear-gradient(white, rgb(184 184 184 / 70%)); - height: 100vh; + background: radial-gradient(white, rgb(184 184 184)); + display: grid; + grid-template-columns: 100%; + grid-template-rows: 100%; + overflow-y: auto; } /* Chrome, Safari, Edge, Opera */ @@ -102,12 +105,15 @@ nav ul li a { .container { margin-top: 1%; + margin-bottom: 1%; display: grid; grid-template-columns: repeat(auto-fill, 320px); grid-gap: 10px; grid-auto-rows: minmax(320px, auto); justify-content: center; background-color: rgb(0 0 0 / 0%); + max-height: 100%; + position: relative; } .container-detail { @@ -465,21 +471,21 @@ html body .content #list-toggle:checked + label::after { color: grey; } -table { +.list table { width: 80vw; margin-top: 6%; border-collapse: collapse; } -table tr:nth-child(2n) { +.list table tr:nth-child(2n) { background: lightgrey; } -td img { +.list td img { height: 50px; } -td { +.list td { border: none; } diff --git a/package.json b/package.json index 95b30c179a741c1c253c5adfc0a84fbe97283d36..f83cf63ff57a4658eee83907642dfada56b5690a 100644 --- a/package.json +++ b/package.json @@ -8,5 +8,9 @@ "repository": { "type": "git", "url": "https://gitlab.univ-lorraine.fr/hohler3u/atelier_1.git" + }, + "scripts": { + "csslint": "npx stylelint **/*.css --fix && npx stylelint **/*.scss --fix", + "phplint": "./vendor/bin/phplint" } } \ No newline at end of file diff --git a/src/Controllers/CategoryController.php b/src/Controllers/CategoryController.php new file mode 100644 index 0000000000000000000000000000000000000000..896b604e6da1e291b75d8c50cb6d67bf0af388f1 --- /dev/null +++ b/src/Controllers/CategoryController.php @@ -0,0 +1,48 @@ +<?php + +use Doctrine\ORM\EntityManager; + +require_once '/database/models/Category'; + +class CategoryController { + + /** + * @var EntityManager + */ + private $em; + + public function __construct(EntityManager $em) + { + $this->em = $em; + } + + public function getById(int $id): Category + { + return $this->em->find('Category',$id); + } + + public function getAll() + { + return $this->em->getRepository(Category::class)->findAll(); + } + + public function createCategory(array $args) + { + $category = new Category(); + $category->setName($args['name']); + $category->setDescription($args['description']); + $this->em->persist($category); + $this->em->flush(); + } + + public function deleteCategory(int $id): bool + { + if ($category = $this->getById($id) != null) { + $this->em->remove($category); + $this->em->flush(); + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/src/Controllers/OrderController.php b/src/Controllers/OrderController.php new file mode 100644 index 0000000000000000000000000000000000000000..e21d67e67d6edecfd374524ee796f0263b179256 --- /dev/null +++ b/src/Controllers/OrderController.php @@ -0,0 +1,62 @@ +<?php + +use Doctrine\ORM\EntityManager; + +require_once '/database/models/Order'; + +class OrderController { + + /** + * @var EntityManager + */ + private $em; + + public function __construct(EntityManager $em) + { + $this->em = $em; + } + + public function getById(int $id): Order + { + return $this->em->find('Order',$id); + } + + public function getAll() + { + return $this->em->getRepository(Order::class)->findAll(); + } + + public function createOrder(array $args) + { + $order = new Order(); + $order->setClientName($args['name']); + $order->setClientAdress($args['adress']); + $order->setClientEmail($args['email']); + $order->setClientPhone($args['phone']); + $order->setPaid(false); + $order->setDelivered(false); + $this->em->persist($order); + $this->em->flush(); + } + + public function computeTotalPrice($id) { + $order = $this->getById($id); + $pos = $order->getProductOrders(); + $total_price = 0; + foreach ($pos as $po) { + $total_price+=$po->getQuantity() * $po->getProduct()->getPrice(); + } + $order->setTotalPrice($total_price); + + } + public function deleteOrder(int $id): bool + { + if ($order = $this->getById($id) != null) { + $this->em->remove($order); + $this->em->flush(); + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/src/Controllers/ProducerController.php b/src/Controllers/ProducerController.php new file mode 100644 index 0000000000000000000000000000000000000000..57e1c1fcd82d5e989f2a7a265ccc1e050e3671c0 --- /dev/null +++ b/src/Controllers/ProducerController.php @@ -0,0 +1,50 @@ +<?php + +use Doctrine\ORM\EntityManager; + +require_once '/database/models/Producer'; + +class OrderController { + + /** + * @var EntityManager + */ + private $em; + + public function __construct(EntityManager $em) + { + $this->em = $em; + } + + public function getById(int $id): Order + { + return $this->em->find('Producer',$id); + } + + public function getAll() + { + return $this->em->getRepository(Producer::class)->findAll(); + } + + public function createProducer(array $args) + { + $producer = new Producer(); + $producer->setName($args['name']); + $producer->setAdress($args['adress']); + $producer->setEmail($args['email']); + $producer->setPhone($args['phone']); + $this->em->persist($producer); + $this->em->flush(); + } + + public function deleteProducer(int $id): bool + { + if ($producer = $this->getById($id) != null) { + $this->em->remove($producer); + $this->em->flush(); + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/src/Controllers/ProductController.php b/src/Controllers/ProductController.php new file mode 100644 index 0000000000000000000000000000000000000000..c0c7156d5cd56c3b207e3c5b9530fdd1f4b9ab49 --- /dev/null +++ b/src/Controllers/ProductController.php @@ -0,0 +1,28 @@ +<?php + +use Doctrine\ORM\EntityManager; + +require_once '/database/models/Product'; + +class ProductController { + + /** + * @var EntityManager + */ + private $em; + + public function __construct(EntityManager $em) + { + $this->em = $em; + } + + public function getById(int $id): Product + { + return $this->em->find('Product',$id); + } + + public function getAll() + { + return $this->em->getRepository(Product::class)->findAll(); + } +} \ No newline at end of file diff --git a/src/database/models/Order.php b/src/database/models/Order.php index eb53693996457d285c7b5436c48ca347b585f432..949b71873c758fdff75f6e928c7f480de2a3638c 100644 --- a/src/database/models/Order.php +++ b/src/database/models/Order.php @@ -127,7 +127,7 @@ class Order return $this->delivered; } - public function setDelivered(string $delivered): bool + public function setDelivered(bool $delivered): bool { $this->delivered = $delivered; return true; @@ -138,7 +138,7 @@ class Order return $this->paid; } - public function setPaid(string $paid): bool + public function setPaid(bool $paid): bool { $this->paid = $paid; return true; diff --git a/src/database/models/ProductOrder.php b/src/database/models/ProductOrder.php index 04876c80f89fe77e0b1f2207e62f9d04e799d710..95df31528ef10b552809816c073ac9abb77b3d0e 100644 --- a/src/database/models/ProductOrder.php +++ b/src/database/models/ProductOrder.php @@ -59,4 +59,9 @@ class ProductOrder $this->quantity = $quantity; return true; } + + public function computePrice() + { + return $this->product->getPrice() * $this->quantity; + } }