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