dolibarr  20.0.0-alpha
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  *
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 
27 // Load Dolibarr environment
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
34 
35 // Load translation files required by the page
36 $langs->loadLangs(array("admin", "members"));
37 
38 $action = GETPOST('action', 'aZ09');
39 
40 $defaultoppstatus = getDolGlobalInt('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD');
41 
42 $visibility = GETPOST('PROJET_VISIBILITY', 'alpha');
43 
44 if (!$user->admin) {
46 }
47 
48 $error = 0;
49 
50 
51 /*
52  * Actions
53  */
54 
55 if ($action == 'setPROJECT_ENABLE_PUBLIC') {
56  if (GETPOST('value')) {
57  dolibarr_set_const($db, 'PROJECT_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
58  } else {
59  dolibarr_set_const($db, 'PROJECT_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
60  }
61 }
62 
63 if ($action == 'update') {
64  $public = GETPOST('PROJECT_ENABLE_PUBLIC');
65  $defaultoppstatus = GETPOSTINT('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD');
66  $res = dolibarr_set_const($db, "PROJET_VISIBILITY", $visibility, 'chaine', 0, '', $conf->entity);
67 
68  $res = dolibarr_set_const($db, "PROJECT_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
69  $res = dolibarr_set_const($db, "PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD", $defaultoppstatus, 'chaine', 0, '', $conf->entity);
70 
71  if (!($res > 0)) {
72  $error++;
73  }
74 
75  if (!$error) {
76  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
77  } else {
78  setEventMessages($langs->trans("Error"), null, 'errors');
79  }
80 }
81 
82 
83 /*
84  * View
85  */
86 
87 $form = new Form($db);
88 $formproject = new FormProjets($db);
89 
90 $title = $langs->trans("ProjectsSetup");
91 $help_url = '';
92 llxHeader('', $title, $help_url);
93 
94 
95 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
96 print load_fiche_titre($title, $linkback, 'title_setup');
97 
99 
100 $param = '';
101 
102 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
103 print '<input type="hidden" name="action" value="update">';
104 print '<input type="hidden" name="token" value="'.newToken().'">';
105 
106 print dol_get_fiche_head($head, 'website', $langs->trans("Projects"), -1, 'project');
107 
108 
109 print '<span class="opacitymedium">'.$langs->trans("LeadPublicFormDesc").'</span><br><br>';
110 
111 $param = '';
112 
113 $enabledisablehtml = $langs->trans("EnablePublicLeadForm").' ';
114 if (!getDolGlobalString('PROJECT_ENABLE_PUBLIC')) {
115  // Button off, click to enable
116  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setPROJECT_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
117  $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
118  $enabledisablehtml .= '</a>';
119 } else {
120  // Button on, click to disable
121  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setPROJECT_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
122  $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
123  $enabledisablehtml .= '</a>';
124 }
125 print $enabledisablehtml;
126 print '<input type="hidden" id="PROJECT_ENABLE_PUBLIC" name="PROJECT_ENABLE_PUBLIC" value="'.(!getDolGlobalString('PROJECT_ENABLE_PUBLIC') ? 0 : 1).'">';
127 
128 print '<br>';
129 
130 if (getDolGlobalString('PROJECT_ENABLE_PUBLIC')) {
131  print '<br>';
132 
133  print '<div class="div-table-responsive-no-min">';
134  print '<table class="noborder centpercent">';
135 
136  print '<tr class="liste_titre">';
137  print '<td>'.$langs->trans("Parameter").'</td>';
138  print '<td class="right">'.$langs->trans("Value").'</td>';
139  print "</tr>\n";
140 
141  // Default opportunity status
142  print '<tr class="oddeven drag" id="trforcetype"><td>';
143  print $langs->trans("DefaultOpportunityStatus");
144  print '</td><td class="right">';
145  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);
146  print "</td></tr>\n";
147 
148 
149  // project visibility
150  $arrayofchoices = array('0' => $langs->trans("AssignedContacts"), '1' => $langs->trans("Everyone"));
151  print '<tr class="oddeven drag"><td>';
152  print $langs->trans("Visibility");
153  print '</td><td class="right">';
154  print $form->selectarray('PROJET_VISIBILITY', $arrayofchoices, getDolGlobalInt('PROJET_VISIBILITY'), 0);
155  print "</td></tr>\n";
156 
157  print '</table>';
158  print '</div>';
159 
160  print '<div class="center">';
161  print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
162  print '</div>';
163 }
164 
165 print dol_get_fiche_end();
166 
167 print '</form>';
168 
169 
170 if (getDolGlobalString('PROJECT_ENABLE_PUBLIC')) {
171  print '<br>';
172  //print $langs->trans('FollowingLinksArePublic').'<br>';
173  print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
174  if (isModEnabled('multicompany')) {
175  $entity_qr = '?entity='.$conf->entity;
176  } else {
177  $entity_qr = '';
178  }
179 
180  // Define $urlwithroot
181  $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
182  $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
183  //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
184 
185  print '<div class="urllink">';
186  print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/project/new.php'.$entity_qr.'">';
187  print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/project/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
188  print '</div>';
189  print ajax_autoselect('publicurlmember');
190 }
191 
192 // End of page
193 llxFooter();
194 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
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).
Definition: admin.lib.php:655
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.