website.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <?php
  2. /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2006-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/partnership/admin/website.php
  22. * \ingroup partnership
  23. * \brief File of main public page for partnership module
  24. */
  25. // Load Dolibarr environment
  26. require '../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/partnership/lib/partnership.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
  32. // Load translation files required by the page
  33. $langs->loadLangs(array("admin", "partnership"));
  34. $action = GETPOST('action', 'aZ09');
  35. $error = 0;
  36. if (!$user->admin) {
  37. accessforbidden();
  38. }
  39. /*
  40. * Actions
  41. */
  42. if ($action == 'setPARTNERSHIP_ENABLE_PUBLIC') {
  43. if (GETPOST('value')) {
  44. dolibarr_set_const($db, 'PARTNERSHIP_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
  45. } else {
  46. dolibarr_set_const($db, 'PARTNERSHIP_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
  47. }
  48. }
  49. if ($action == 'update') {
  50. $public = GETPOST('PARTNERSHIP_ENABLE_PUBLIC');
  51. $res = dolibarr_set_const($db, "PARTNERSHIP_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
  52. if (!($res > 0)) {
  53. $error++;
  54. }
  55. if (!$error) {
  56. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  57. } else {
  58. setEventMessages($langs->trans("Error"), null, 'errors');
  59. }
  60. }
  61. /*
  62. * View
  63. */
  64. $form = new Form($db);
  65. $title = $langs->trans('PartnershipSetup');
  66. $help_url = '';
  67. //$help_url = 'EN:Module_Partnership|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
  68. llxHeader('', $title, $help_url);
  69. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  70. print load_fiche_titre($title, $linkback, 'title_setup');
  71. $head = partnershipAdminPrepareHead();
  72. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  73. print '<input type="hidden" name="action" value="update">';
  74. print '<input type="hidden" name="token" value="'.newToken().'">';
  75. print dol_get_fiche_head($head, 'website', $langs->trans("Partnerships"), -1, 'partnership');
  76. if ($conf->use_javascript_ajax) {
  77. print "\n".'<script type="text/javascript" language="javascript">';
  78. print 'jQuery(document).ready(function () {
  79. function initemail()
  80. {
  81. if (jQuery("#PARTNERSHIP_NEWFORM_PAYONLINE").val()==\'-1\')
  82. {
  83. jQuery("#tremail").hide();
  84. }
  85. else
  86. {
  87. jQuery("#tremail").show();
  88. }
  89. }
  90. function initfields()
  91. {
  92. if (jQuery("#PARTNERSHIP_ENABLE_PUBLIC").val()==\'0\')
  93. {
  94. jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide();
  95. }
  96. if (jQuery("#PARTNERSHIP_ENABLE_PUBLIC").val()==\'1\')
  97. {
  98. jQuery("#trforcetype, #tramount, #tredit, #trpayment").show();
  99. if (jQuery("#PARTNERSHIP_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
  100. else jQuery("#tremail").show();
  101. }
  102. }
  103. initfields();
  104. jQuery("#PARTNERSHIP_ENABLE_PUBLIC").change(function() { initfields(); });
  105. jQuery("#PARTNERSHIP_NEWFORM_PAYONLINE").change(function() { initemail(); });
  106. })';
  107. print '</script>'."\n";
  108. }
  109. print '<span class="opacitymedium">'.$langs->trans("PublicFormRegistrationPartnerDesc").'</span><br><br>';
  110. $param = '';
  111. $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
  112. if (empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
  113. // Button off, click to enable
  114. $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setPARTNERSHIP_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
  115. $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
  116. $enabledisablehtml .= '</a>';
  117. } else {
  118. // Button on, click to disable
  119. $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setPARTNERSHIP_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
  120. $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
  121. $enabledisablehtml .= '</a>';
  122. }
  123. print $enabledisablehtml;
  124. print '<input type="hidden" id="PARTNERSHIP_ENABLE_PUBLIC" name="PARTNERSHIP_ENABLE_PUBLIC" value="'.(empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC) ? 0 : 1).'">';
  125. print '<br>';
  126. /*
  127. if (!empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
  128. print '<br>';
  129. print '<div class="div-table-responsive-no-min">';
  130. print '<table class="noborder centpercent">';
  131. print '<tr class="liste_titre">';
  132. print '<td>'.$langs->trans("Parameter").'</td>';
  133. print '<td class="right">'.$langs->trans("Value").'</td>';
  134. print "</tr>\n";
  135. // Amount
  136. print '<tr class="oddeven" id="tramount"><td>';
  137. print $langs->trans("DefaultAmount");
  138. print '</td><td class="right">';
  139. print '<input type="text" class="right width75" id="PARTNERSHIP_NEWFORM_AMOUNT" name="PARTNERSHIP_NEWFORM_AMOUNT" value="'.(!empty($conf->global->PARTNERSHIP_NEWFORM_AMOUNT) ? $conf->global->PARTNERSHIP_NEWFORM_AMOUNT : '').'">';
  140. print "</td></tr>\n";
  141. // Jump to an online payment page
  142. print '<tr class="oddeven" id="trpayment"><td>';
  143. print $langs->trans("PARTNERSHIP_NEWFORM_PAYONLINE");
  144. print '</td><td class="right">';
  145. $listofval = array();
  146. $listofval['-1'] = $langs->trans('No');
  147. $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
  148. if (isModEnabled('paybox')) {
  149. $listofval['paybox'] = 'Paybox';
  150. }
  151. if (isModEnabled('paypal')) {
  152. $listofval['paypal'] = 'PayPal';
  153. }
  154. if (isModEnabled('stripe')) {
  155. $listofval['stripe'] = 'Stripe';
  156. }
  157. print $form->selectarray("PARTNERSHIP_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE) ? $conf->global->PARTNERSHIP_NEWFORM_PAYONLINE : ''), 0);
  158. print "</td></tr>\n";
  159. print '</table>';
  160. print '</div>';
  161. print '<div class="center">';
  162. print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
  163. print '</div>';
  164. }
  165. */
  166. print dol_get_fiche_end();
  167. print '</form>';
  168. if (!empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
  169. print '<br>';
  170. //print $langs->trans('FollowingLinksArePublic').'<br>';
  171. print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
  172. if (isModEnabled('multicompany')) {
  173. $entity_qr = '?entity='.$conf->entity;
  174. } else {
  175. $entity_qr = '';
  176. }
  177. // Define $urlwithroot
  178. $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
  179. $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  180. //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
  181. print '<div class="urllink">';
  182. print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/partnership/new.php'.$entity_qr.'">';
  183. print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/partnership/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
  184. print '</div>';
  185. print ajax_autoselect('publicurlmember');
  186. }
  187. // End of page
  188. llxFooter();
  189. $db->close();