| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- <?php
- if (core::ifGet("id") == FALSE and access::ifAccesss("add-document") == FALSE) {
- get::page("unknow");
- exit();
- }
- if (core::getGet("id") == NULL) {
- $titre = "Ajouter un document";
- $id_form = '<input type="hidden" name="id" value="add">';
- $submit = "Ajouter ce nouveau document";
- } else {
- $document = document::get(core::getGet("id")); debug::log($document);
- if (empty($document["id"])) {
- get::page("unknow");
- exit();
- }
- $id_form = '<input type="hidden" name="id" value="' . $document["id"] . '">';
- $submit = "Modifier ce document";
- $badgeCSS = " font-size:0.4em; margin-top:-5px;";
- $titre = "[#" . $document["id"] . "] " . $document["titre"];
- }
- $userTags = user::getUserById(session::getId())["tags"];
- ?>
- <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
- <h2 class="bd-title" id="content">
- <span><?php echo $titre ?></span>
- </h2>
- </header>
- <?php
- if (core::ifGet("add")) {
- $labelFil = "Ajouter un document";
- $lienFil = "/add-document.html";
- } else {
- $labelFil = "[#" . $document["id"] . "] " . $document["titre"];
- $lienFil = "/document-" . core::getGet("id") . ".html";
- }
- echo core::filAriane(array(
- "current" => $labelFil,
- "arbo" => array(
- "Factures" => NULL,
- "Listes des documents" => "/documents.html",
- $labelFil => $lienFil
- )
- ));
- if(isset($document["id"]) AND tags::compareUserDocument($userTags, $document["tags"]) == FALSE ){
- ?>
- <div style="float:right; margin-top: -60px;">
- <a href="/submit.php?from=document-delete&id=<?php echo $document["id"] ?>" style="color: #dc3545; text-decoration:none;" onclick="return confirm('Voulez-vous supprimer ce document ?')"><button type="submit" class="btn btn-outline-danger btn-sm"><span data-feather="trash-2"></span> Supprimer</button></a>
- </div>
- <?php
- }
- ?>
- <link rel="stylesheet" href="css/dragAndDrop.css">
- <form method="post" action="/submit.php" enctype="multipart/form-data" onsubmit="loading()">
- <div class="row">
- <div class="col">
- <input type="hidden" name="from" value="document">
- <?php echo $id_form; ?>
- <?php $_titre = (isset($document["titre"])) ? $document["titre"] : NULL; ?>
- <div class="form-group">
- <label>Titre</label>
- <input type="text" class="form-control" value="<?php core::printFormValue($_titre) ?>" name="titre" placeholder="" required>
- </div>
- <br />
- <?php
- $_type_document = (isset($document["id_type"])) ? $document["id_type"] : NULL;
- $_label_type_document = document::getTypes();
- ?>
- <div class="form-group">
- <label>Type de document</label>
- <select name="id_type" class="form-select">
- <option value=""></option>
- <option value="1" <?php core::printFormSelectOption($_type_document, 1) ?>><?php echo $_label_type_document[1]["label"] ?></option>
- <option value="2" <?php core::printFormSelectOption($_type_document, 2) ?>><?php echo $_label_type_document[2]["label"] ?></option>
- <option value="3" <?php core::printFormSelectOption($_type_document, 3) ?>><?php echo $_label_type_document[3]["label"] ?></option>
- <option value="0" <?php core::printFormSelectOption($_type_document, 0) ?>><?php echo $_label_type_document[0]["label"] ?></option>
- </select>
- </div>
- <br />
- <?php $_date = (isset($document["date"])) ? $document["date"] : NULL; ?>
- <div class="form-group">
- <label>Date associée à ce document</label>
- <input type="date" class="form-control" name="date" value="<?php core::printFormValue($_date) ?>" placeholder="" required>
- </div>
- <br />
- <?php $_deadline = (isset($document["deadline"])) ? $document["deadline"] : NULL; ?>
- <div class="form-group">
- <label>Date limite de traitement</label>
- <input type="date" class="form-control" name="deadline" value="<?php core::printFormValue($_deadline) ?>" placeholder="" required>
- </div>
- <br />
- <?php $_description = (isset($document["description"])) ? $document["description"] : NULL; ?>
- <div class="form-group">
- <label>Description et commentaires</label>
- <textarea class="form-control" name="description" style="height:100%;"><?php core::printFormValue($_description) ?></textarea>
- </div>
- <br />
- <?php $_assign_document = (isset($document["tags"])) ? $document["tags"] : NULL; ?>
- <div class="form-group">
- <label>Attribution</label>
- <input type="text" value="<?php
- if (isset($document["tags"])) {
- echo $document["tags"];
- }
- ?>" name="tags" id="tags" />
- </div>
- <br />
- <?php if(isset($document) AND tags::compareUserDocument($userTags, $document["tags"]) == TRUE){
- $checkDone = (isset($document["id_user_done"])) ? " checked disabled" : NULL;
- $checkText = (isset($document["id_user_done"])) ? "Ce document a été traité par ". $document["doneUser"] . " le " . $document["date_done"] : "Ce document a été traité";
- ?>
- <div class="form-check form-switch">
- <input class="form-check-input" style="width:40px; height:20px;" type="checkbox" name="done" id="doneDocument"<?php echo $checkDone ?>>
- <label class="form-check-label" style="font-size:larger; margin-left:10px;" for="doneDocument" id="doneDocumentTxt"><?php echo $checkText ?></label>
- </div>
- <br />
- <?php } ?>
- <?php if(isset($document["id_file"])) { ?>
- <div class="form-group" style="opacity:0.5">
- <label style="color:var(--bs-link-color)">Nom du fichier</label>
- <input type="text" class="form-control" style="border-color:var(--bs-link-color); color:var(--bs-link-color);" value="<?php echo $document["name"] ?>" readonly>
- </div>
- <br />
- <div class="form-group" style="opacity:0.5">
- <label style="color:var(--bs-link-color)">Taille</label>
- <input type="text" class="form-control" style="border-color:var(--bs-link-color); color:var(--bs-link-color)" value="<?php echo $document["size"] ?>" readonly>
- </div>
- <br />
- <?php } ?>
- </div>
- <div class="col">
- <?php if(empty($document["id_file"])) { ?>
- <div class="file-drop-area" style="margin-top:22px;">
- <span class="choose-file-button">Choisissez votre document</span>
- <span class="file-message">ou drag & drop</span>
- <input id="document-import" class="import-excel" name="document-import" type="file" onchange="dargAndDrop()" required>
- </div>
- <br />
- <?php } else {
- $heigh = (mime_content_type(file::download($document["id_file"], DIR_DATAS_DOCS)) == "application/pdf") ? "height:110vh;" : NULL;
- echo ' <div style="margin-top:22px;">
- <a href="/document.php?id='.$document["id_file"].'" target="_blank" style="right:0;">
- <input class="btn btn-outline-secondary btn-sm" style="width: 100%; opacity:0.6;" value="Ouvrir le document">
- </a>
- <embed src="/document.php?id='.$document["id_file"].'" style="width:100%; margin-top:10px;'.$heigh.'" /></embed>
- </div><br />
- ';
- }
- ?>
- </div>
- </div>
- <input class="btn btn-primary btn-lg" style="width: 100%;" type="submit" value="<?php echo $submit ?>">
- <br /><br />
- </form>
- <script>
- function dargAndDrop() {
- var fileName = $("#document-import").val().split('\\').pop();
- $(".file-message").text($(".file-message").text().replace("ou drag & drop", fileName));
- }
- $(document).ready(function () {
- $('#tags').inputTags({
- autocomplete: {
- values: <?php echo tags::getJquery() ?>,
- only: true
- },
- max: 3
- });
- });
- </script>
|