cms.proweb-export-csv.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?php
  2. if ($lastExcelForSFTP = salaries::lastExcelForSFTP()) {
  3. $getExcelJsonForSFTP = salaries::getExcelJsonForSFTP($lastExcelForSFTP)["md5forSFTP"];
  4. } else {
  5. $getExcelJsonForSFTP = "";
  6. }
  7. json::create("host");
  8. $jsonTarget1 = "/json.php?jsonData=proweb-transfert-sftp";
  9. $jsonTarget2 = "/json.php?jsonData=proweb-transfert-local";
  10. if(debug::isFile("debug")){
  11. debug::log(debug::getBadge($jsonTarget1, "OUVRIR LE JSON : ".$jsonTarget1), "JSON chargé en arrière plan");
  12. debug::log(debug::getBadge($jsonTarget2, "OUVRIR LE JSON : ".$jsonTarget2), "JSON chargé en arrière plan");
  13. }
  14. ?>
  15. <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
  16. <h2 class="bd-title" id="content">
  17. <span>Proweb : Exporter vers ProWeb</span>
  18. </h2>
  19. </header>
  20. <?php
  21. echo core::filAriane(array(
  22. "current" => "Exporter vers ProWeb",
  23. "arbo" => array(
  24. "Proweb" => NULL,
  25. "Exporter vers ProWeb" => "/proweb-export-csv.html"
  26. )
  27. ));
  28. ?>
  29. <br />
  30. <div class="card text-center">
  31. <div class="card-header" style="font-size: 1.3em;">
  32. Informations liées à ProWeb
  33. </div>
  34. <div class="card-body">
  35. <div class="row">
  36. <div class="col">
  37. <label style="color: gray;">Hôte</label>
  38. <input type="text" value="<?php echo SFTP_HOST ?>" class="form-control text-center" disabled>
  39. </div>
  40. <div class="col">
  41. <label style="color: gray;">Identifiant</label>
  42. <input type="text" value="<?php echo SFTP_USER ?>" class="form-control text-center" disabled>
  43. </div>
  44. <div class="col">
  45. <label style="color: gray;">Mot de passe</label>
  46. <input type="text" value="<?php echo SFTP_PASS ?>" style="color:#e9ecef;" class="form-control text-center" disabled>
  47. </div>
  48. </div>
  49. <br />
  50. <div class="row">
  51. <div class="col">
  52. <label style="color: gray;">Dossier distant</label>
  53. <input type="text" value="<?php echo SFTP_REMOTE ?>" class="form-control text-center" disabled>
  54. </div>
  55. <div class="col">
  56. <label style="color: gray;">Protocole</label>
  57. <input type="text" value="SFTP (PORT 22)" class="form-control text-center" disabled>
  58. </div>
  59. <div class="col">
  60. <label style="color: gray;">Test de connexion</label>
  61. <input type="text" id="testConnexionSFTP" value="" class="form-control text-center" disabled>
  62. </div>
  63. </div>
  64. <br />
  65. <div class="row">
  66. <div class="col m-3">
  67. <label style="color: gray;">Fichiers présents sur le serveur</label>
  68. <table id="table" class="table-striped table-hover table-sm" data-toggle="table" data-sort-name="date" data-sort-order="desc" data-url="<?php echo $jsonTarget1 ?>">
  69. <thead>
  70. <tr>
  71. <th data-formatter="downloadFileRemote" data-sortable="true" data-field="file" data-filter-control="input" data-align="left">Nom</th>
  72. <th data-sortable="true" data-field="size" data-filter-control="input" data-width="100">Taille</th>
  73. <th data-sortable="true" data-field="date" data-filter-control="input" data-width="170">Date de transfert</th>
  74. <th data-formatter="deleteFileRemote" data-width="150"></th>
  75. </tr>
  76. </thead>
  77. </table>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. <script>
  83. function downloadFileRemote(value, row) {
  84. return '<form method="post" action="/submit.php">\n\
  85. <input type="hidden" name="from" value="sftp-download-file-remote">\n\
  86. <input type="hidden" name="file" value="' + row.file + '">\n\
  87. <button type="submit" style="border:none; background:none;" title="Télécharger le fichier : ' + row.file + '">' + row.file + '</button>\n\
  88. </form>';
  89. }
  90. function deleteFileRemote(value, row) {
  91. return '<form method="post" action="/submit.php">\n\
  92. <input type="hidden" name="from" value="sftp-delete-file-remote">\n\
  93. <input type="hidden" name="file" value="' + row.file + '">\n\
  94. <button type="submit" class="btn btn-outline-danger btn-sm" onclick="return confirm(\'Voulez-vous vraiment supprimer ce fichier ?\')">Supprimer</button>\n\
  95. </form>';
  96. }
  97. </script>
  98. <br />
  99. <div class="card text-center">
  100. <div class="card-header" style="font-size: 1.3em;">
  101. Informations liées au serveur du CSE
  102. </div>
  103. <div class="card-body">
  104. <div class="row">
  105. <div class="col">
  106. <label style="color: gray;">IP du serveur</label>
  107. <input type="text" value="<?php echo $_SERVER['SERVER_ADDR'] ?>" class="form-control text-center" disabled>
  108. </div>
  109. <div class="col">
  110. <label style="color: gray;">Dernière emprunte des données générées</label>
  111. <input type="text" value="<?php echo $getExcelJsonForSFTP ?>" class="form-control text-center" disabled>
  112. </div>
  113. </div>
  114. <div class="row">
  115. <div class="col m-3">
  116. <label style="color: gray;">Fichiers présents dans le dossier du CSE</label>
  117. <table id="table" class="table-striped table-hover table-sm" data-toggle="table" data-sort-name="date" data-sort-order="desc" data-url="<?php echo $jsonTarget2 ?>">
  118. <thead>
  119. <tr>
  120. <th data-formatter="downloadFileLocal" data-sortable="true" data-field="file" data-filter-control="input" data-align="left">Nom</th>
  121. <th data-sortable="true" data-field="size" data-filter-control="input" data-width="100">Taille</th>
  122. <th data-sortable="true" data-field="date" data-filter-control="input" data-width="170">Date de création</th>
  123. <th data-formatter="transfertFileLocal" data-width="130"></th>
  124. <th data-formatter="deleteFileLocal" data-width="130"></th>
  125. </tr>
  126. </thead>
  127. </table>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. <script>
  133. function downloadFileLocal(value, row) {
  134. return '<form method="post" action="/submit.php">\n\
  135. <input type="hidden" name="from" value="sftp-download-file-local">\n\
  136. <input type="hidden" name="file" value="' + row.file + '">\n\
  137. <button type="submit" style="border:none; background:none;" title="Télécharger le fichier : ' + row.file + '">' + row.file + '</button>\n\
  138. </form>';
  139. }
  140. function transfertFileLocal(value, row) {
  141. return '<form method="post" action="/submit.php">\n\
  142. <input type="hidden" name="from" value="sftp-transfert-file-local">\n\
  143. <input type="hidden" name="file" value="' + row.file + '">\n\
  144. <button type="submit" class="btn btn-outline-success btn-sm">Transférer</button>\n\
  145. </form>';
  146. }
  147. function deleteFileLocal(value, row) {
  148. return '<form method="post" action="/submit.php">\n\
  149. <input type="hidden" name="from" value="sftp-delete-file-local">\n\
  150. <input type="hidden" name="file" value="' + row.file + '">\n\
  151. <button type="submit" class="btn btn-outline-danger btn-sm">Supprimer</button>\n\
  152. </form>';
  153. }
  154. </script>
  155. <?php
  156. if (salaries::ifSubmitLastForSFTP()) {
  157. ?>
  158. <br />
  159. <form method="post" action="/submit.php">
  160. <input type="hidden" name="from" value="sftp-create-csv-salaries">
  161. <input class="btn btn-primary btn-lg" style="width: 100%" type="submit" value="Générer le CSV à envoyer à ProWeb">
  162. </form>
  163. <?php
  164. }
  165. ?>
  166. <script>
  167. $(document).ready(function() {
  168. $.ajax('/json.php', {
  169. type: 'GET', // http method
  170. data: {
  171. jsonData: 'proweb-transfert-test-connexion'
  172. }, // data to submit
  173. success: function(data, status, xhr) {
  174. var json = $.parseJSON(data);
  175. if (json == "OK") {
  176. $('#testConnexionSFTP').val("Opérationnel");
  177. $('#testConnexionSFTP').addClass("is-valid");
  178. $('#testConnexionSFTP').css("background-color", "#d4edda");
  179. $('#testConnexionSFTP').css("color", "green");
  180. } else {
  181. $('#testConnexionSFTP').val("En erreur");
  182. $('#testConnexionSFTP').addClass("is-invalid");
  183. $('#testConnexionSFTP').css("background-color", "#f8d7da");
  184. $('#testConnexionSFTP').css("color", "red");
  185. }
  186. },
  187. error: function() {
  188. $('#testConnexionSFTP').val("En erreur");
  189. $('#testConnexionSFTP').addClass("is-invalid");
  190. $('#testConnexionSFTP').css("background-color", "#f8d7da");
  191. $('#testConnexionSFTP').css("color", "red");
  192. }
  193. });
  194. });
  195. </script>