2
0

cms.proweb-export-csv.php 9.5 KB

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