dolibarr 19.0.3
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
24if (!defined('NOLOGIN')) {
25 define("NOLOGIN", 1); // This means this output page does not require to be logged.
26}
27if (!defined('NOCSRFCHECK')) {
28 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
29}
30if (!defined('NOIPCHECK')) {
31 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
32}
33if (!defined('NOBROWSERNOTIF')) {
34 define('NOBROWSERNOTIF', '1');
35}
36
37// Load Dolibarr environment
38require '../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.'/opensurvey/class/opensurveysondage.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
43
44// Load translation files required by the page
45$langs->loadLangs(array("companies", "other", "opensurveys"));
46
47// Get parameters
48$action = GETPOST('action', 'aZ09');
49$cancel = GETPOST('cancel', 'alpha');
50$SECUREKEY = GETPOST("securekey");
51$entity = GETPOST('entity', 'int') ? GETPOST('entity', 'int') : $conf->entity;
52$backtopage = '';
53$suffix = "";
54
55// Load variable for pagination
56$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
57$sortfield = GETPOST('sortfield', 'aZ09comma');
58$sortorder = GETPOST('sortorder', 'aZ09comma');
59$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
60if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
61 $page = 0;
62} // If $page is not defined, or '' or -1 or if we click on clear filters
63$offset = $limit * $page;
64$pageprev = $page - 1;
65$pagenext = $page + 1;
66
67if (GETPOST('btn_view')) {
68 unset($_SESSION['email_customer']);
69}
70if (isset($_SESSION['email_customer'])) {
71 $email = $_SESSION['email_customer'];
72}
73
74$object = new Opensurveysondage($db);
75
76// Define $urlwithroot
77//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
78//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
79$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
80
81// Security check
82if (!isModEnabled('opensurvey')) {
83 httponly_accessforbidden('Module Opensurvey not enabled');
84}
85
86
87/*
88 * Actions
89 */
90
91// None
92
93
94/*
95 * View
96 */
97
98$head = '';
99if (getDolGlobalString('MAIN_OPENSURVEY_CSS_URL')) {
100 $head = '<link rel="stylesheet" type="text/css" href="'.getDolGlobalString('MAIN_OPENSURVEY_CSS_URL').'?lang='.$langs->defaultlang.'">'."\n";
101}
102
103$conf->dol_hide_topmenu = 1;
104$conf->dol_hide_leftmenu = 1;
105
106if (!getDolGlobalString('OPENSURVEY_ENABLE_PUBLIC_INTERFACE')) {
107 $langs->load("errors");
108 print '<div class="error">'.$langs->trans('ErrorPublicInterfaceNotEnabled').'</div>';
109 $db->close();
110 exit();
111}
112
113$arrayofjs = array();
114$arrayofcss = array();
115
116$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
117llxHeader($head, $langs->trans("Surveys"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1);
118
119
120print '<span id="dolpaymentspan"></span>'."\n";
121print '<div class="center">'."\n";
122print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
123print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
124print '<input type="hidden" name="action" value="dosign">'."\n";
125print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
126print '<input type="hidden" name="suffix" value="'.GETPOST("suffix", 'alpha').'">'."\n";
127print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
128print '<input type="hidden" name="entity" value="'.$entity.'" />';
129print "\n";
130print '<!-- Form to view jobs -->'."\n";
131
132// Show logo (search order: logo defined by ONLINE_SIGN_LOGO_suffix, then ONLINE_SIGN_LOGO_, then small company logo, large company logo, theme logo, common logo)
133// Define logo and logosmall
134$logosmall = $mysoc->logo_small;
135$logo = $mysoc->logo;
136$paramlogo = 'ONLINE_OPENSURVEY_LOGO_'.$suffix;
137if (!empty($conf->global->$paramlogo)) {
138 $logosmall = $conf->global->$paramlogo;
139} elseif (getDolGlobalString('ONLINE_OPENSURVEY_LOGO')) {
140 $logosmall = $conf->global->ONLINE_OPENSURVEY_LOGO_;
141}
142//print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
143// Define urllogo
144$urllogo = '';
145$urllogofull = '';
146if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
147 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall);
148 $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
149} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
150 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo);
151 $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
152}
153// Output html code for logo
154if ($urllogo) {
155 print '<div class="backgreypublicpayment">';
156 print '<div class="logopublicpayment">';
157 print '<img id="dolpaymentlogo" src="'.$urllogo.'">';
158 print '</div>';
159 if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) {
160 print '<div class="poweredbypublicpayment opacitymedium right"><a class="poweredbyhref" href="https://www.dolibarr.org?utm_medium=website&utm_source=poweredby" target="dolibarr" rel="noopener">'.$langs->trans("PoweredBy").'<br><img class="poweredbyimg" src="'.DOL_URL_ROOT.'/theme/dolibarr_logo.svg" width="80px"></a></div>';
161 }
162 print '</div>';
163}
164
165if (getDolGlobalString('OPENSURVEY_IMAGE_PUBLIC_INTERFACE')) {
166 print '<div class="backimagepublicrecruitment">';
167 print '<img id="idOPENSURVEY_IMAGE_PUBLIC_INTERFACE" src="' . getDolGlobalString('OPENSURVEY_IMAGE_PUBLIC_INTERFACE').'">';
168 print '</div>';
169}
170
171
172$results = $object->fetchAll($sortfield, $sortorder, 0, 0, array('status' => 1));
173$now = dol_now();
174
175if (is_array($results)) {
176 if (empty($results)) {
177 print '<br>';
178 print $langs->trans("NoSurvey");
179 } else {
180 print '<br><br><br>';
181 print '<span class="opacitymedium">'.$langs->trans("ListOfOpenSurveys").'</span>';
182 print '<br><br><br>';
183 print '<br class="hideonsmartphone">';
184
185 foreach ($results as $survey) {
186 $object = $survey;
187
188 print '<table id="dolpaymenttable" summary="Job position offer" class="center centpercent">'."\n";
189
190 // Output payment summary form
191 print '<tr><td class="left">';
192
193 print '<div class="centpercent" id="tablepublicpayment">';
194
195 $error = 0;
196 $found = true;
197
198 // Label
199 print $langs->trans("Label").' : ';
200 print '<b>'.dol_escape_htmltag($object->title).'</b><br>';
201
202 // Date
203 print $langs->trans("DateExpected").' : ';
204 print '<b>';
205 if ($object->date_fin > $now) {
206 print dol_print_date($object->date_fin, 'day');
207 } else {
208 print $langs->trans("ASAP");
209 }
210 print '</b><br>';
211
212 // Description
213 //print $langs->trans("Desription").' : ';
214 print '<br>';
215 print '<div class="opensurveydescription centpercent">';
216 print dol_htmlwithnojs(dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->commentaires), 1, 1, 1));
217 //print dol_escape_htmltag($object->commentaires);
218 print '</div>';
219 print '<br>';
220
221 print '</div>'."\n";
222 print "\n";
223
224
225 if ($action != 'dosubmit') {
226 if ($found && !$error) {
227 // We are in a management option and no error
228 } else {
229 dol_print_error_email('ERRORSUBMITAPPLICATION');
230 }
231 } else {
232 // Print
233 }
234
235 print '</td></tr>'."\n";
236
237 print '</table>'."\n";
238
239 print '<br><br class="hideonsmartphone"><br class="hideonsmartphone"><br class="hideonsmartphone">'."\n";
240 }
241 }
242} else {
243 dol_print_error($db, $object->error, $object->errors);
244}
245
246print '</form>'."\n";
247print '</div>'."\n";
248print '<br>';
249
250
251htmlPrintOnlineFooter($mysoc, $langs);
252
253llxFooter('', 'public');
254
255$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Put here description of your class.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0)
Clean a string to keep only desirable HTML tags.
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_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 link.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.