website.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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/projet/admin/website.php
  22. * \ingroup member
  23. * \brief File of main public page for project module to catch lead
  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/project.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  32. // Load translation files required by the page
  33. $langs->loadLangs(array("admin", "members"));
  34. $action = GETPOST('action', 'aZ09');
  35. $defaultoppstatus = getDolGlobalInt('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD');
  36. if (!$user->admin) {
  37. accessforbidden();
  38. }
  39. $error = 0;
  40. /*
  41. * Actions
  42. */
  43. if ($action == 'setPROJECT_ENABLE_PUBLIC') {
  44. if (GETPOST('value')) {
  45. dolibarr_set_const($db, 'PROJECT_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
  46. } else {
  47. dolibarr_set_const($db, 'PROJECT_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
  48. }
  49. }
  50. if ($action == 'update') {
  51. $public = GETPOST('PROJECT_ENABLE_PUBLIC');
  52. $defaultoppstatus = GETPOST('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD', 'int');
  53. $res = dolibarr_set_const($db, "PROJECT_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
  54. $res = dolibarr_set_const($db, "PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD", $defaultoppstatus, 'chaine', 0, '', $conf->entity);
  55. if (!($res > 0)) {
  56. $error++;
  57. }
  58. if (!$error) {
  59. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  60. } else {
  61. setEventMessages($langs->trans("Error"), null, 'errors');
  62. }
  63. }
  64. /*
  65. * View
  66. */
  67. $form = new Form($db);
  68. $formproject = new FormProjets($db);
  69. $title = $langs->trans("ProjectsSetup");
  70. $help_url = '';
  71. llxHeader('', $title, $help_url);
  72. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  73. print load_fiche_titre($title, $linkback, 'title_setup');
  74. $head = project_admin_prepare_head();
  75. $param = '';
  76. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  77. print '<input type="hidden" name="action" value="update">';
  78. print '<input type="hidden" name="token" value="'.newToken().'">';
  79. print dol_get_fiche_head($head, 'website', $langs->trans("Projects"), -1, 'project');
  80. print '<span class="opacitymedium">'.$langs->trans("LeadPublicFormDesc").'</span><br><br>';
  81. $param = '';
  82. $enabledisablehtml = $langs->trans("EnablePublicLeadForm").' ';
  83. if (empty($conf->global->PROJECT_ENABLE_PUBLIC)) {
  84. // Button off, click to enable
  85. $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setPROJECT_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
  86. $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
  87. $enabledisablehtml .= '</a>';
  88. } else {
  89. // Button on, click to disable
  90. $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setPROJECT_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
  91. $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
  92. $enabledisablehtml .= '</a>';
  93. }
  94. print $enabledisablehtml;
  95. print '<input type="hidden" id="PROJECT_ENABLE_PUBLIC" name="PROJECT_ENABLE_PUBLIC" value="'.(empty($conf->global->PROJECT_ENABLE_PUBLIC) ? 0 : 1).'">';
  96. print '<br>';
  97. if (!empty($conf->global->PROJECT_ENABLE_PUBLIC)) {
  98. print '<br>';
  99. print '<div class="div-table-responsive-no-min">';
  100. print '<table class="noborder centpercent">';
  101. print '<tr class="liste_titre">';
  102. print '<td>'.$langs->trans("Parameter").'</td>';
  103. print '<td class="right">'.$langs->trans("Value").'</td>';
  104. print "</tr>\n";
  105. // Default opportunity status
  106. print '<tr class="oddeven drag" id="trforcetype"><td>';
  107. print $langs->trans("DefaultOpportunityStatus");
  108. print '</td><td class="right">';
  109. print $formproject->selectOpportunityStatus('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD', GETPOSTISSET('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD') ? GETPOST('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD', 'int') : $defaultoppstatus, 1, 0, 0, 0, '', 0, 1);
  110. print "</td></tr>\n";
  111. print '</table>';
  112. print '</div>';
  113. print '<div class="center">';
  114. print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
  115. print '</div>';
  116. }
  117. print dol_get_fiche_end();
  118. print '</form>';
  119. if (!empty($conf->global->PROJECT_ENABLE_PUBLIC)) {
  120. print '<br>';
  121. //print $langs->trans('FollowingLinksArePublic').'<br>';
  122. print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
  123. if (isModEnabled('multicompany')) {
  124. $entity_qr = '?entity='.$conf->entity;
  125. } else {
  126. $entity_qr = '';
  127. }
  128. // Define $urlwithroot
  129. $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
  130. $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  131. //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
  132. print '<div class="urllink">';
  133. print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/project/new.php'.$entity_qr.'">';
  134. print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/project/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
  135. print '</div>';
  136. print ajax_autoselect('publicurlmember');
  137. }
  138. // End of page
  139. llxFooter();
  140. $db->close();