document.php 688B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. require_once(dirname(__DIR__) . "/models/document.class.php");
  3. require_once(dirname(__DIR__) . "/models/promo.class.php");
  4. function document()
  5. {
  6. set("title", "Documents");
  7. set("data", Document::getAll());
  8. set("promos", Promo::getAll());
  9. return html("list.html.php", "layout.html.php");
  10. }
  11. function add_document()
  12. {
  13. $filePath = Document::addDocument($_FILES["document"], [
  14. "rang" => $_POST["rang"],
  15. "promo" => $_POST["promo"],
  16. "libelle" => $_POST["libelle"]
  17. ]);
  18. json_encode(array(
  19. "path" => $filePath
  20. ));
  21. }
  22. function delete_document($fileid)
  23. {
  24. (new Document($fileid))->erase();
  25. }