|
|
@@ -8,6 +8,7 @@ if (core::getGet("id") == NULL) {
|
|
|
$titre = "Ajouter un document";
|
|
|
$id_form = '<input type="hidden" name="id" value="add">';
|
|
|
$submit = "Ajouter ce nouveau document";
|
|
|
+ $document = session::getTemp("document");
|
|
|
} else {
|
|
|
$datas = document::get(core::getGet("id"));
|
|
|
$document = $datas["document"];
|
|
|
@@ -50,12 +51,12 @@ echo core::filAriane(array(
|
|
|
)
|
|
|
));
|
|
|
|
|
|
-if(isset($document["id"])){
|
|
|
+if (isset($document["id"])) {
|
|
|
?>
|
|
|
<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
|
|
|
+<?php
|
|
|
}
|
|
|
?>
|
|
|
|
|
|
@@ -77,9 +78,9 @@ if(isset($document["id"])){
|
|
|
</div>
|
|
|
|
|
|
<br />
|
|
|
- <?php
|
|
|
- $_type_document = (isset($document["id_type"])) ? $document["id_type"] : NULL;
|
|
|
- $_label_type_document = document::getTypes();
|
|
|
+ <?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>
|
|
|
@@ -128,18 +129,18 @@ if(isset($document["id"])){
|
|
|
</div>
|
|
|
<br />
|
|
|
|
|
|
- <?php if(isset($document) AND tags::compareUserDocument($userTags, $document["tagsUser"]) == TRUE){
|
|
|
+ <?php if (isset($document) and tags::compareUserDocument($userTags, $document["tagsUser"]) == 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é";
|
|
|
+ $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 />
|
|
|
+ <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($files[0]["id"])) { ?>
|
|
|
+ <?php if (isset($files[0]["id"])) { ?>
|
|
|
<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 $files[0]["name"] ?>" readonly>
|
|
|
@@ -156,43 +157,66 @@ if(isset($document["id"])){
|
|
|
</div>
|
|
|
|
|
|
<div class="col">
|
|
|
- <?php if(empty($files[0]["id"])) { ?>
|
|
|
- <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($files[0]["id"], DIR_DATAS_DOCS)) == "application/pdf") ? "height:110vh;" : NULL;
|
|
|
- echo ' <div style="margin-top:22px;">
|
|
|
- <a href="/document.php?id='.$files[0]["id"].'" target="_blank" style="right:0;">
|
|
|
+ <?php if (empty($files[0]["id"])) { ?>
|
|
|
+ <div class="file-drop-area" style="margin-top:22px;" id="file-document-import">
|
|
|
+ <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($files[0]["id"], DIR_DATAS_DOCS)) == "application/pdf") ? "height:110vh;" : NULL;
|
|
|
+ echo ' <div style="margin-top:22px;">
|
|
|
+ <a href="/document.php?id=' . $files[0]["id"] . '" 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='.$files[0]["id"].'" style="width:100%; margin-top:10px;'.$heigh.'" /></embed>
|
|
|
+ <embed src="/document.php?id=' . $files[0]["id"] . '" style="width:100%; margin-top:10px;' . $heigh . '" /></embed>
|
|
|
</div><br />
|
|
|
';
|
|
|
- }
|
|
|
- ?>
|
|
|
+ }
|
|
|
+ ?>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <input class="btn btn-primary btn-lg" style="width: 100%;" type="button" value="<?php echo $submit ?>" onclick="submit()">
|
|
|
+ <input class="btn btn-primary btn-lg" style="width: 100%;" type="button" value="<?php echo $submit ?>" onclick="validateAndSubmit()">
|
|
|
<br /><br />
|
|
|
</form>
|
|
|
|
|
|
<script>
|
|
|
+ function validateAndSubmit() {
|
|
|
+ const form = document.getElementById('form-document');
|
|
|
+ const requiredFields = form.querySelectorAll('[required]');
|
|
|
+ const fileDoc = document.getElementById('file-document-import');
|
|
|
+ let allFieldsFilled = true;
|
|
|
+
|
|
|
+ requiredFields.forEach(field => {
|
|
|
+ if (!field.value.trim()) {
|
|
|
+ if(field.name === "document-import"){
|
|
|
+ fileDoc.style.borderColor = 'red';
|
|
|
+ }
|
|
|
+ allFieldsFilled = false;
|
|
|
+ field.style.borderColor = 'red';
|
|
|
+ } else {
|
|
|
+ field.style.borderColor = '';
|
|
|
+ fileDoc.style.borderColor = '';
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (allFieldsFilled) {
|
|
|
+ form.submit();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
function dargAndDrop() {
|
|
|
var fileName = $("#document-import").val().split('\\').pop();
|
|
|
$(".file-message").text($(".file-message").text().replace("ou drag & drop", fileName));
|
|
|
}
|
|
|
|
|
|
- function upperCase(input){
|
|
|
+ function upperCase(input) {
|
|
|
input.value = input.value.toUpperCase();
|
|
|
}
|
|
|
|
|
|
- $(document).ready(function () {
|
|
|
+ $(document).ready(function() {
|
|
|
$('#tagsUser').inputTags({
|
|
|
autocomplete: {
|
|
|
values: <?php echo tags::getJquery(1) ?>,
|