switch.tpl.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /* Copyright (C) 2017-2022 Regis Houssin <regis.houssin@inodbox.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. */
  19. // Protection to avoid direct call of template
  20. if (empty($conf) || !is_object($conf)) {
  21. print "Error, template page can't be called as URL";
  22. exit;
  23. }
  24. ?>
  25. <!-- BEGIN MULTICOMPANY AJAX TEMPLATE -->
  26. <div id="dialog-delete" title="<?php echo $langs->trans('DeleteAnEntity'); ?>" class="hideobject">
  27. <p><?php echo img_warning().' '.$langs->trans('ConfirmDeleteEntity'); ?></p>
  28. </div>
  29. <script type="text/javascript">
  30. $(document).ready(function() {
  31. $("#multicompany_entity_list").on('click', '.multicompany-button-active-on, .multicompany-button-visible-on', function() {
  32. var button = $(this);
  33. var type = button.attr('id').match(/^[a-z]+/g);
  34. var id = parseInt(button.attr('id').match(/[0-9]+$/g));
  35. $.post( "<?php echo dol_buildpath('/multicompany/core/ajax/functions.php',1); ?>", {
  36. 'action': 'setStatusDisable',
  37. 'type': type[0],
  38. 'id': id,
  39. 'token': '<?php echo currentToken(); ?>'
  40. },
  41. function (result) {
  42. if (result == 1) {
  43. $('#multicompany_entity_list').dataTable().fnDraw();
  44. } else {
  45. $.jnotify("<?php echo $langs->trans("ErrorEntityStatusDisable"); ?>", "error", true);
  46. }
  47. }
  48. );
  49. });
  50. $("#multicompany_entity_list").on('click', '.multicompany-button-active-off, .multicompany-button-visible-off', function() {
  51. var button = $(this);
  52. var type = button.attr('id').match(/^[a-z]+/g);
  53. var id = parseInt(button.attr('id').match(/[0-9]+$/g));
  54. $.post( "<?php echo dol_buildpath('/multicompany/core/ajax/functions.php',1); ?>", {
  55. 'action': 'setStatusEnable',
  56. 'type': type[0],
  57. 'id': id,
  58. 'token': '<?php echo currentToken(); ?>'
  59. },
  60. function (result) {
  61. if (result == 1) {
  62. $('#multicompany_entity_list').dataTable().fnDraw();
  63. } else {
  64. $.jnotify("<?php echo $langs->trans("ErrorEntityStatusEnable"); ?>", "error", true);
  65. }
  66. }
  67. );
  68. });
  69. $("#multicompany_entity_list").on('click', '.multicompany-button-delete', function() {
  70. var button = $(this);
  71. var id = parseInt(button.attr('id').match(/[0-9]+$/g));
  72. $('#dialog-delete').dialog({
  73. resizable: false,
  74. height: 170,
  75. width: 400,
  76. modal: true,
  77. open: function() {
  78. $('.ui-dialog-buttonset > button:last').focus();
  79. },
  80. buttons: {
  81. '<?php echo $langs->trans('Delete'); ?>': function() {
  82. $(this).dialog('close');
  83. $.post( "<?php echo dol_buildpath('/multicompany/core/ajax/functions.php',1); ?>", {
  84. "action" : "deleteEntity",
  85. "id" : id,
  86. "token": "<?php echo currentToken(); ?>"
  87. },
  88. function (result) {
  89. if (result == 1) {
  90. $('#multicompany_entity_list').dataTable().fnDraw();
  91. $.jnotify("<?php echo $langs->trans("ConfirmedEntityDeleted"); ?>", "ok");
  92. } else {
  93. $.jnotify("<?php echo $langs->trans("ErrorEntityDeleted"); ?>", "error", true);
  94. }
  95. }
  96. );
  97. },
  98. '<?php echo $langs->trans('Cancel'); ?>': function() {
  99. $(this).dialog('close');
  100. }
  101. }
  102. });
  103. });
  104. $("#multicompany_entity_list").on('click', '.multicompany-button-setup', function() {
  105. var button = $(this);
  106. var id = parseInt(button.attr('id').match(/([0-9]+)$/g));
  107. window.location.href = "<?php echo $_SERVER["PHP_SELF"].'?action=edit&id=' ?>" + id;
  108. });
  109. });
  110. </script>
  111. <!-- END MULTICOMPANY AJAX TEMPLATE -->