dolibarr 23.0.3
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26if (!defined('NOLOGIN')) {
27 define("NOLOGIN", 1); // This means this output page does not require to be logged.
28}
29if (!defined('NOCSRFCHECK')) {
30 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
31}
32if (!defined('NOIPCHECK')) {
33 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
34}
35if (!defined('NOBROWSERNOTIF')) {
36 define('NOBROWSERNOTIF', '1');
37}
47// Load Dolibarr environment
48require '../../main.inc.php';
49require_once DOL_DOCUMENT_ROOT.'/opensurvey/class/opensurveysondage.class.php';
50require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
51require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
52require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
53
54// Load translation files required by the page
55$langs->loadLangs(array("companies", "other", "opensurveys"));
56
57// Get parameters
58$action = GETPOST('action', 'aZ09');
59$cancel = GETPOST('cancel', 'alpha');
60$SECUREKEY = GETPOST("securekey");
61$entity = GETPOSTINT('entity') ? GETPOSTINT('entity') : $conf->entity;
62$backtopage = '';
63$suffix = "";
64
65// Load variable for pagination
66$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
67$sortfield = GETPOST('sortfield', 'aZ09comma');
68$sortorder = GETPOST('sortorder', 'aZ09comma');
69$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
70if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
71 $page = 0;
72} // If $page is not defined, or '' or -1 or if we click on clear filters
73$offset = $limit * $page;
74$pageprev = $page - 1;
75$pagenext = $page + 1;
76
77if (GETPOST('btn_view')) {
78 unset($_SESSION['email_customer']);
79}
80if (isset($_SESSION['email_customer'])) {
81 $email = $_SESSION['email_customer'];
82}
83
84$object = new Opensurveysondage($db);
85
86// Define $urlwithroot
87//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
88//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
89$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
90
91// Security check
92if (!isModEnabled('opensurvey')) {
93 httponly_accessforbidden('Module Opensurvey not enabled');
94}
95
96
97/*
98 * Actions
99 */
100
101// None
102
103
104/*
105 * View
106 */
107
108$head = '';
109if (getDolGlobalString('MAIN_OPENSURVEY_CSS_URL')) {
110 $head = '<link rel="stylesheet" type="text/css" href="'.getDolGlobalString('MAIN_OPENSURVEY_CSS_URL').'?lang='.$langs->defaultlang.'">'."\n";
111}
112
113$conf->dol_hide_topmenu = 1;
114$conf->dol_hide_leftmenu = 1;
115
116$conf->global->OPENSURVEY_ENABLE_PUBLIC_INTERFACE = 1;
117
118if (!getDolGlobalString('OPENSURVEY_ENABLE_PUBLIC_INTERFACE')) {
119 $langs->load("errors");
120 print '<div class="error">'.$langs->trans('ErrorPublicInterfaceNotEnabled').'</div>';
121 $db->close();
122 exit();
123}
124
125$arrayofjs = array();
126$arrayofcss = array();
127
128$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
129llxHeader($head, $langs->trans("Surveys"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1);
130
131
132include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
133htmlPrintOnlineHeader($mysoc, $langs, 1, getDolGlobalString('OPENSURVEY_PUBLIC_INTERFACE_TOPIC'), 'OPENSURVEY_IMAGE_PUBLIC_INTERFACE', 'ONLINE_OPENSURVEY_LOGO_'.$suffix, 'ONLINE_OPENSURVEY_LOGO');
134
135
136print '<span id="dolpaymentspan"></span>'."\n";
137print '<div class="center">'."\n";
138print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
139print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
140print '<input type="hidden" name="action" value="dosign">'."\n";
141print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
142print '<input type="hidden" name="suffix" value="'.GETPOST("suffix", 'alpha').'">'."\n";
143print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
144print '<input type="hidden" name="entity" value="'.$entity.'" />';
145print "\n";
146print '<!-- Form to view survey -->'."\n";
147
148$results = $object->fetchAll($sortorder, $sortfield, 0, 0, '(status:=:1)');
149$now = dol_now();
150
151if (is_array($results)) {
152 if (empty($results)) {
153 print '<br>';
154 print $langs->trans("NoSurvey");
155 } else {
156 print '<br><br><br>';
157 print '<span class="opacitymedium">'.$langs->trans("ListOfOpenSurveys").'</span>';
158 print '<br><br><br>';
159 print '<br class="hideonsmartphone">';
160
161 foreach ($results as $survey) {
162 $object = $survey;
163
164 print '<table id="dolpaymenttable" summary="Job position offer" class="center centpercent">'."\n";
165
166 // Output payment summary form
167 print '<tr><td class="left">';
168
169 print '<div class="centpercent" id="tablepublicpayment">';
170
171 $error = 0;
172 $found = true;
173
174 // Label
175 print $langs->trans("Label").' : ';
176 print '<b>'.dol_escape_htmltag(empty($object->titre) ? $object->title : $object->titre).'</b><br>';
177
178 // Date
179 print $langs->trans("DateExpected").' : ';
180 print '<b>';
181 if ($object->date_fin > $now) {
182 print dol_print_date($object->date_fin, 'day');
183 } else {
184 print $langs->trans("ASAP");
185 }
186 print '</b><br>';
187
188 // Description
189 //print $langs->trans("Description").' : ';
190 print '<br>';
191 print '<div class="opensurveydescription centpercent">';
193 //print dol_escape_htmltag($object->commentaires);
194 print '</div>';
195 print '<br>';
196
197 print '</div>'."\n";
198 print "\n";
199
200
201 if ($action != 'dosubmit') {
202 if ($found && !$error) {
203 // We are in a management option and no error
204 } else {
205 dol_print_error_email('ERRORSUBMITAPPLICATION');
206 }
207 } else {
208 // Print
209 }
210
211 print '</td></tr>'."\n";
212
213 print '</table>'."\n";
214
215 print '<br><br class="hideonsmartphone"><br class="hideonsmartphone"><br class="hideonsmartphone">'."\n";
216 }
217 }
218} else {
219 dol_print_error($db, $object->error, $object->errors);
220}
221
222print '</form>'."\n";
223print '</div>'."\n";
224print '<br>';
225
226
228
229llxFooter('', 'public');
230
231$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Put here description of your class.
htmlPrintOnlineHeader($mysoc, $langs, $showlogo=1, $alttext='', $subimageconst='', $altlogo1='', $altlogo2='')
Show the header of a company in HTML public pages.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML public pages.
global $mysoc
dol_now($mode='gmt')
Return date for now.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error_email($prefixcode, $errormessage='', $errormessages=array(), $morecss='error', $email='')
Show a public email and error code to contact if technical error.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox=0, $check='restricthtml')
Sanitize a HTML to remove js, dangerous content and external links.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0, $allowscript=0, $allowstyle=0, $allowphp=0)
Clean a string to keep only desirable HTML tags.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.