dolibarr 21.0.0-beta
website.php
Go to the documentation of this file.
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
34require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
35
46// Load translation files required by the page
47$langs->loadLangs(array("admin", "members"));
48
49$action = GETPOST('action', 'aZ09');
50
51$defaultoppstatus = getDolGlobalInt('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD');
52
53$visibility = GETPOST('PROJET_VISIBILITY', 'alpha');
54
55if (!$user->admin) {
57}
58
59$error = 0;
60
61
62/*
63 * Actions
64 */
65
66if ($action == 'setPROJECT_ENABLE_PUBLIC') {
67 if (GETPOST('value')) {
68 dolibarr_set_const($db, 'PROJECT_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
69 } else {
70 dolibarr_set_const($db, 'PROJECT_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
71 }
72}
73
74if ($action == 'update') {
75 $public = GETPOST('PROJECT_ENABLE_PUBLIC');
76 $defaultoppstatus = GETPOSTINT('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD');
77 $res = dolibarr_set_const($db, "PROJET_VISIBILITY", $visibility, 'chaine', 0, '', $conf->entity);
78
79 $res = dolibarr_set_const($db, "PROJECT_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
80 $res = dolibarr_set_const($db, "PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD", $defaultoppstatus, 'chaine', 0, '', $conf->entity);
81
82 if (!($res > 0)) {
83 $error++;
84 }
85
86 if (!$error) {
87 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
88 } else {
89 setEventMessages($langs->trans("Error"), null, 'errors');
90 }
91}
92
93
94/*
95 * View
96 */
97
98$form = new Form($db);
99$formproject = new FormProjets($db);
100
101$title = $langs->trans("ProjectsSetup");
102$help_url = '';
103llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-project page-admin_website');
104
105
106$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
107print load_fiche_titre($title, $linkback, 'title_setup');
108
110
111$param = '';
112
113print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
114print '<input type="hidden" name="action" value="update">';
115print '<input type="hidden" name="token" value="'.newToken().'">';
116
117print dol_get_fiche_head($head, 'website', $langs->trans("Projects"), -1, 'project');
118
119
120print '<span class="opacitymedium">'.$langs->trans("LeadPublicFormDesc").'</span><br><br>';
121
122$param = '';
123
124$enabledisablehtml = $langs->trans("EnablePublicLeadForm").' ';
125if (!getDolGlobalString('PROJECT_ENABLE_PUBLIC')) {
126 // Button off, click to enable
127 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setPROJECT_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
128 $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
129 $enabledisablehtml .= '</a>';
130} else {
131 // Button on, click to disable
132 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setPROJECT_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
133 $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
134 $enabledisablehtml .= '</a>';
135}
136print $enabledisablehtml;
137print '<input type="hidden" id="PROJECT_ENABLE_PUBLIC" name="PROJECT_ENABLE_PUBLIC" value="'.(!getDolGlobalString('PROJECT_ENABLE_PUBLIC') ? 0 : 1).'">';
138
139print '<br>';
140
141if (getDolGlobalString('PROJECT_ENABLE_PUBLIC')) {
142 print '<br>';
143
144 print '<div class="div-table-responsive-no-min">';
145 print '<table class="noborder centpercent">';
146
147 print '<tr class="liste_titre">';
148 print '<td>'.$langs->trans("Parameter").'</td>';
149 print '<td class="right">'.$langs->trans("Value").'</td>';
150 print "</tr>\n";
151
152 // Default opportunity status
153 print '<tr class="oddeven drag" id="trforcetype"><td>';
154 print $langs->trans("DefaultOpportunityStatus");
155 print '</td><td class="right">';
156 print $formproject->selectOpportunityStatus('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD', GETPOSTISSET('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD') ? GETPOSTINT('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD') : $defaultoppstatus, 1, 0, 0, 0, '', 0, 1);
157 print "</td></tr>\n";
158
159
160 // project visibility
161 $arrayofchoices = array('0' => $langs->trans("AssignedContacts"), '1' => $langs->trans("Everyone"));
162 print '<tr class="oddeven drag"><td>';
163 print $langs->trans("Visibility");
164 print '</td><td class="right">';
165 print $form->selectarray('PROJET_VISIBILITY', $arrayofchoices, getDolGlobalInt('PROJET_VISIBILITY'), 0);
166 print "</td></tr>\n";
167
168 print '</table>';
169 print '</div>';
170
171 print '<div class="center">';
172 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
173 print '</div>';
174}
175
176print dol_get_fiche_end();
177
178print '</form>';
179
180
181if (getDolGlobalString('PROJECT_ENABLE_PUBLIC')) {
182 print '<br>';
183 //print $langs->trans('FollowingLinksArePublic').'<br>';
184 print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
185 if (isModEnabled('multicompany')) {
186 $entity_qr = '?entity='.$conf->entity;
187 } else {
188 $entity_qr = '';
189 }
190
191 // Define $urlwithroot
192 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
193 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
194 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
195
196 print '<div class="urllink">';
197 print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/project/new.php'.$entity_qr.'">';
198 print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/project/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
199 print '</div>';
200 print ajax_autoselect('publicurlmember');
201}
202
203// End of page
204llxFooter();
205$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
project_admin_prepare_head()
Prepare array with list of tabs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.