setup.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?php
  2. /* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2021 Dorian Laurent <i.merraha@sofimedmaroc.com>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file partnership/admin/setup.php
  20. * \ingroup partnership
  21. * \brief Partnership setup page.
  22. */
  23. // Load Dolibarr environment
  24. require '../../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
  26. require_once '../lib/partnership.lib.php';
  27. //require_once "../class/myclass.class.php";
  28. // Translations
  29. $langs->loadLangs(array("admin", "partnership"));
  30. $action = GETPOST('action', 'aZ09');
  31. $value = GETPOST('value', 'alpha');
  32. $error = 0;
  33. // Security check
  34. if (!$user->admin) {
  35. accessforbidden();
  36. }
  37. /*
  38. * Actions
  39. */
  40. $nomessageinsetmoduleoptions = 1;
  41. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  42. if ($action == 'setting') {
  43. require_once DOL_DOCUMENT_ROOT."/core/modules/modPartnership.class.php";
  44. $modulemenu = (GETPOST('PARTNERSHIP_IS_MANAGED_FOR', 'alpha') == 'member') ? 'member' : 'thirdparty';
  45. $res = dolibarr_set_const($db, "PARTNERSHIP_IS_MANAGED_FOR", $modulemenu, 'chaine', 0, '', $conf->entity);
  46. $partnership = new modPartnership($db);
  47. $error += $partnership->delete_tabs();
  48. $error += $partnership->insert_tabs();
  49. $error += $partnership->delete_menus();
  50. $error += $partnership->insert_menus();
  51. if (GETPOSTISSET("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL")) {
  52. dolibarr_set_const($db, "PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", 'int'), 'chaine', 0, '', $conf->entity);
  53. }
  54. dolibarr_set_const($db, "PARTNERSHIP_BACKLINKS_TO_CHECK", GETPOST("PARTNERSHIP_BACKLINKS_TO_CHECK"), 'chaine', 0, '', $conf->entity);
  55. }
  56. if ($action) {
  57. if (!$error) {
  58. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  59. } else {
  60. setEventMessages($langs->trans("SetupNotError"), null, 'errors');
  61. }
  62. header("Location: ".$_SERVER['PHP_SELF']);
  63. exit;
  64. }
  65. /*
  66. * View
  67. */
  68. $title = $langs->trans('PartnershipSetup');
  69. llxHeader('', $title);
  70. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  71. print load_fiche_titre($title, $linkback, 'title_setup');
  72. $head = partnershipAdminPrepareHead();
  73. print dol_get_fiche_head($head, 'settings', $title, -1, 'partnership');
  74. $form = new Form($db);
  75. // Module to manage partnership / services code
  76. $dirpartnership = array('/core/modules/partnership/');
  77. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  78. /*
  79. * Other conf
  80. */
  81. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  82. print '<input type="hidden" name="token" value="'.newToken().'">';
  83. print '<input type="hidden" name="action" value="setting">';
  84. print '<input type="hidden" name="page_y" value="">';
  85. print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  86. print '<table class="noborder centpercent">';
  87. print '<tr class="liste_titre">';
  88. print '<td>'.$langs->trans("Setting").'</td>';
  89. print '<td>'.$langs->trans("Value").'</td>';
  90. print '<td>'.$langs->trans("Examples").'</td>';
  91. print '</tr>';
  92. print '<tr class="oddeven"><td>'.$langs->trans("PARTNERSHIP_IS_MANAGED_FOR").'</td>';
  93. print '<td>';
  94. print '<select class="flat minwidth100" id="select_PARTNERSHIP_IS_MANAGED_FOR" name="PARTNERSHIP_IS_MANAGED_FOR">';
  95. print '<option value="thirdparty" '.((getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty') ? 'selected' : '').'>'.$langs->trans("ThirdParty").'</option>';
  96. print '<option value="member" '.((getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'member') ? 'selected' : '').'>'.$langs->trans("Members").'</option>';
  97. print '</select>';
  98. print ajax_combobox('select_PARTNERSHIP_IS_MANAGED_FOR');
  99. print '</td>';
  100. print '<td><span class="opacitymedium">'.$langs->trans("partnershipforthirdpartyormember").'</span></td>';
  101. print '</tr>';
  102. //if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
  103. print '<tr class="oddeven"><td>'.$langs->trans("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL").'</td>';
  104. print '<td>';
  105. $dnbdays = '30';
  106. $backlinks = (!empty($conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL)) ? $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL : $dnbdays;
  107. print '<input class="maxwidth50" type="text" name="PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL" value="'.$backlinks.'">';
  108. print '</td>';
  109. print '<td><span class="opacitymedium">'.$dnbdays.'</span></td>';
  110. print '</tr>';
  111. //}
  112. print '</table>';
  113. print '</div>';
  114. print '<br>';
  115. print load_fiche_titre($langs->trans("ReferingWebsiteCheck"), '', '');
  116. print '<span class="opacitymedium">'.$langs->trans("ReferingWebsiteCheckDesc").'</span><br>';
  117. print '<br>';
  118. print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  119. print '<table class="noborder centpercent">';
  120. print '<tr class="liste_titre">';
  121. print '<td>'.$langs->trans("Setting").'</td>';
  122. print '<td>'.$langs->trans("Value").'</td>';
  123. print '<td>'.$langs->trans("Examples").'</td>';
  124. print '</tr>';
  125. print '<tr class="oddeven"><td>'.$langs->trans("PARTNERSHIP_BACKLINKS_TO_CHECK").'</td>';
  126. print '<td>';
  127. $backlinks = (empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) ? '' : $conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK);
  128. print '<input class="minwidth400" type="text" name="PARTNERSHIP_BACKLINKS_TO_CHECK" value="'.$backlinks.'">';
  129. print '</td>';
  130. print '<td><span class="opacitymedium">dolibarr.org|dolibarr.fr|dolibarr.es</span></td>';
  131. print '</tr>';
  132. print '</table>';
  133. print '</div>';
  134. print '<div class="center">';
  135. print '<input type="submit" class="button reposition" value="'.$langs->trans("Modify").'">';
  136. print '</div>';
  137. print '</form>';
  138. // End of page
  139. llxFooter();
  140. $db->close();