cms.document.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?php
  2. if (core::ifGet("id") == FALSE and access::ifAccesss("add-document") == FALSE) {
  3. get::page("unknow");
  4. exit();
  5. }
  6. if (core::getGet("id") == NULL) {
  7. $titre = "Ajouter un document";
  8. $id_form = '<input type="hidden" name="id" value="add">';
  9. $submit = "Ajouter ce nouveau document";
  10. $document = session::getTemp("document");
  11. } else {
  12. $datas = document::get(core::getGet("id"));
  13. $document = $datas["document"];
  14. $files = $datas["files"];
  15. if (empty($document["id"])) {
  16. get::page("unknow");
  17. exit();
  18. }
  19. $id_form = '<input type="hidden" name="id" value="' . $document["id"] . '">';
  20. $submit = "Modifier ce document";
  21. $badgeCSS = " font-size:0.4em; margin-top:-5px;";
  22. $titre = "[#" . $document["id"] . "] " . $document["titre"];
  23. }
  24. if (core::isDebug()) {
  25. (!empty($document)) ? debug::log($document, "Données brutes document") : NULL;
  26. (!empty($files)) ? debug::log($files, "Données brutes files") : NULL;
  27. }
  28. $userTags = user::getUserById(session::getId())["tags"];
  29. ?>
  30. <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
  31. <h2 class="bd-title" id="content">
  32. <span><?php echo $titre ?></span>
  33. </h2>
  34. </header>
  35. <?php
  36. if (core::ifGet("add")) {
  37. $labelFil = "Ajouter un document";
  38. $lienFil = "/add-document.html";
  39. } else {
  40. $labelFil = "[#" . $document["id"] . "] " . $document["titre"];
  41. $lienFil = "/document-" . core::getGet("id") . ".html";
  42. }
  43. echo core::filAriane(array(
  44. "current" => $labelFil,
  45. "arbo" => array(
  46. "Factures" => NULL,
  47. "Listes des documents" => "/documents.html",
  48. $labelFil => $lienFil
  49. )
  50. ));
  51. if (isset($document["id"])) {
  52. ?>
  53. <div style="float:right; margin-top: -60px;">
  54. <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"><?php icon::getFont(["icon" => "bi-trash-fill"]) ?></i> Supprimer</button></a>
  55. </div>
  56. <?php
  57. }
  58. ?>
  59. <link rel="stylesheet" href="css/dragAndDrop.css">
  60. <form id="form-document" method="post" action="/submit.php" enctype="multipart/form-data" onsubmit="return(false);">
  61. <div class="row">
  62. <div class="col">
  63. <input type="hidden" name="from" value="document">
  64. <?php echo $id_form; ?>
  65. <?php $_titre = (isset($document["titre"])) ? $document["titre"] : NULL; ?>
  66. <div class="form-group">
  67. <label>Titre</label>
  68. <input type="text" class="form-control" value="<?php core::printFormValue($_titre) ?>" name="titre" placeholder="" required>
  69. </div>
  70. <br />
  71. <?php
  72. $_type_document = (isset($document["id_type"])) ? $document["id_type"] : NULL;
  73. $_label_type_document = document::getTypes();
  74. ?>
  75. <div class="form-group">
  76. <label>Type de document</label>
  77. <select name="id_type" class="form-select">
  78. <option value=""></option>
  79. <option value="1" <?php core::printFormSelectOption($_type_document, 1) ?>><?php echo $_label_type_document[1] ?></option>
  80. <option value="2" <?php core::printFormSelectOption($_type_document, 2) ?>><?php echo $_label_type_document[2] ?></option>
  81. <option value="3" <?php core::printFormSelectOption($_type_document, 3) ?>><?php echo $_label_type_document[3] ?></option>
  82. <option value="0" <?php core::printFormSelectOption($_type_document, 0) ?>><?php echo $_label_type_document[0] ?></option>
  83. </select>
  84. </div>
  85. <br />
  86. <?php $_montant = (isset($document["montant"])) ? $document["montant"] : NULL; ?>
  87. <div class="form-group">
  88. <label>Montant associé</label>
  89. <input type="text" class="form-control" value="<?php core::printFormValue($_montant) ?>" name="montant" placeholder="" onkeypress="return (event.charCode >= 48 && event.charCode <= 57) || event.charCode == 46 || event.charCode == 0 ">
  90. </div>
  91. <br />
  92. <?php $_tagsSupplier = (isset($document["tagsSupplier"])) ? $document["tagsSupplier"] : NULL; ?>
  93. <div class="form-group">
  94. <label>Tags associés</label>
  95. <input type="text" value="<?php core::printFormValue($_tagsSupplier) ?>" name="tagsSupplier" id="tagsSupplier" />
  96. </div>
  97. <br />
  98. <?php $_date = (isset($document["date"])) ? $document["date"] : NULL; ?>
  99. <div class="form-group">
  100. <label>Date associée à ce document</label>
  101. <input type="date" class="form-control" name="date" value="<?php core::printFormValue($_date) ?>" placeholder="" required>
  102. </div>
  103. <br />
  104. <?php $_deadline = (isset($document["deadline"])) ? $document["deadline"] : NULL; ?>
  105. <div class="form-group">
  106. <label>Date limite de traitement</label>
  107. <input type="date" class="form-control" name="deadline" value="<?php core::printFormValue($_deadline) ?>" placeholder="" required>
  108. </div>
  109. <br />
  110. <?php $_description = (isset($document["description"])) ? $document["description"] : NULL; ?>
  111. <div class="form-group">
  112. <label>Description et commentaires</label>
  113. <textarea class="form-control" name="description" style="height:100%;"><?php core::printFormValue($_description) ?></textarea>
  114. </div>
  115. <br />
  116. <?php $_tagsUser = (isset($document["tagsUser"])) ? $document["tagsUser"] : NULL; ?>
  117. <div class="form-group">
  118. <label>Attribution</label>
  119. <input type="text" value="<?php core::printFormValue($_tagsUser) ?>" name="tagsUser" id="tagsUser" />
  120. </div>
  121. <br />
  122. <?php if (isset($files["principal"]["id"])) { ?>
  123. <div style="border:1px #CCCCCC solid; background-color:#F6F6F6; padding:20px; border-radius:.375rem;">
  124. <?php
  125. if ((isset($document) and tags::compareUserDocument($userTags, $document["tagsUser"]) == TRUE) or (isset($document["date_done"]))) {
  126. $checkDone = (isset($document["id_user_done"])) ? " disabled" : NULL;
  127. $checkColor = (isset($document["id_user_done"])) ? " style=\"background-color:#d1e7dd;\"" : NULL;
  128. $checkText = (isset($document["id_user_done"])) ? "Document traité par <span style=\"font-weight: bold;\">" . $document["doneUser"] . "</span> le" : "Document traité le";
  129. $_dateDone = (isset($document["date_done"])) ? $document["date_done"] : NULL;
  130. echo ' <div class="form-group">
  131. <label>' . $checkText . '</label>
  132. <input type="date" class="form-control"' . $checkColor . ' name="date_done" value="' . core::getFormValue($_dateDone) . '"' . $checkDone . '>
  133. </div><br />';
  134. }
  135. document::printAttachement($files);
  136. ?>
  137. <div class="file-drop-area">
  138. <span class="choose-file-button">Ajouter une pièce jointe</span>
  139. <span class="file-message">ou drag & drop</span>
  140. <input id="attachement-document" class="import-excel" name="attachement-document" type="file" onchange="dargAndDropAttachment()" accept="image/jpeg,image/png,application/pdf">
  141. </div>
  142. </div>
  143. <br />
  144. <?php } ?>
  145. </div>
  146. <div class="col">
  147. <?php if (empty($files["principal"]["id"])) { ?>
  148. <div class="file-drop-area" style="margin-top:22px;" id="file-document-import">
  149. <span class="choose-file-button">Choisissez votre document</span>
  150. <span class="file-message">ou drag & drop</span>
  151. <input id="document-import" class="import-excel" name="document-import" type="file" onchange="dargAndDrop()" accept="image/jpeg,image/png,application/pdf" required>
  152. </div>
  153. <br />
  154. <?php } else {
  155. $heigh = (mime_content_type(file::download($files["principal"]["id"], DIR_DATAS_DOCS)) == "application/pdf") ? "height:110vh;" : NULL;
  156. echo ' <div style="margin-top:22px;">
  157. <embed src="/document.php?id=' . $files["principal"]["id"] . '" style="width:100%; margin-top:10px;' . $heigh . '" /></embed>
  158. </div><br />
  159. ';
  160. }
  161. ?>
  162. </div>
  163. </div>
  164. <input class="btn btn-primary btn-lg" style="width: 100%;" type="button" value="<?php echo $submit ?>" onclick="validateAndSubmit()">
  165. <br /><br />
  166. </form>
  167. <?php
  168. get::javascript("document");
  169. ?>