dolibarr 21.0.0-beta
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
116if (!getDolGlobalString('OPENSURVEY_ENABLE_PUBLIC_INTERFACE')) {
117 $langs->load("errors");
118 print '<div class="error">'.$langs->trans('ErrorPublicInterfaceNotEnabled').'</div>';
119 $db->close();
120 exit();
121}
122
123$arrayofjs = array();
124$arrayofcss = array();
125
126$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
127llxHeader($head, $langs->trans("Surveys"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1);
128
129
130print '<span id="dolpaymentspan"></span>'."\n";
131print '<div class="center">'."\n";
132print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
133print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
134print '<input type="hidden" name="action" value="dosign">'."\n";
135print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
136print '<input type="hidden" name="suffix" value="'.GETPOST("suffix", 'alpha').'">'."\n";
137print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
138print '<input type="hidden" name="entity" value="'.$entity.'" />';
139print "\n";
140print '<!-- Form to view jobs -->'."\n";
141
142// 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)
143// Define logo and logosmall
144$logosmall = $mysoc->logo_small;
145$logo = $mysoc->logo;
146$paramlogo = 'ONLINE_OPENSURVEY_LOGO_'.$suffix;
147if (getDolGlobalString($paramlogo)) {
148 $logosmall = getDolGlobalString($paramlogo);
149} elseif (getDolGlobalString('ONLINE_OPENSURVEY_LOGO')) {
150 $logosmall = getDolGlobalString('ONLINE_OPENSURVEY_LOGO_');
151}
152//print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
153// Define urllogo
154$urllogo = '';
155$urllogofull = '';
156if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
157 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall);
158 $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
159} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
160 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo);
161 $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
162}
163// Output html code for logo
164if ($urllogo) {
165 print '<div class="backgreypublicpayment">';
166 print '<div class="logopublicpayment">';
167 print '<img id="dolpaymentlogo" src="'.$urllogo.'">';
168 print '</div>';
169 if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) {
170 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>';
171 }
172 print '</div>';
173}
174
175if (getDolGlobalString('OPENSURVEY_IMAGE_PUBLIC_INTERFACE')) {
176 print '<div class="backimagepublicrecruitment">';
177 print '<img id="idOPENSURVEY_IMAGE_PUBLIC_INTERFACE" src="' . getDolGlobalString('OPENSURVEY_IMAGE_PUBLIC_INTERFACE').'">';
178 print '</div>';
179}
180
181
182$results = $object->fetchAll($sortorder, $sortfield, 0, 0, '(status:=:1)');
183$now = dol_now();
184
185if (is_array($results)) {
186 if (empty($results)) {
187 print '<br>';
188 print $langs->trans("NoSurvey");
189 } else {
190 print '<br><br><br>';
191 print '<span class="opacitymedium">'.$langs->trans("ListOfOpenSurveys").'</span>';
192 print '<br><br><br>';
193 print '<br class="hideonsmartphone">';
194
195 foreach ($results as $survey) {
196 $object = $survey;
197
198 print '<table id="dolpaymenttable" summary="Job position offer" class="center centpercent">'."\n";
199
200 // Output payment summary form
201 print '<tr><td class="left">';
202
203 print '<div class="centpercent" id="tablepublicpayment">';
204
205 $error = 0;
206 $found = true;
207
208 // Label
209 print $langs->trans("Label").' : ';
210 print '<b>'.dol_escape_htmltag($object->title).'</b><br>';
211
212 // Date
213 print $langs->trans("DateExpected").' : ';
214 print '<b>';
215 if ($object->date_fin > $now) {
216 print dol_print_date($object->date_fin, 'day');
217 } else {
218 print $langs->trans("ASAP");
219 }
220 print '</b><br>';
221
222 // Description
223 //print $langs->trans("Description").' : ';
224 print '<br>';
225 print '<div class="opensurveydescription centpercent">';
227 //print dol_escape_htmltag($object->commentaires);
228 print '</div>';
229 print '<br>';
230
231 print '</div>'."\n";
232 print "\n";
233
234
235 if ($action != 'dosubmit') {
236 if ($found && !$error) {
237 // We are in a management option and no error
238 } else {
239 dol_print_error_email('ERRORSUBMITAPPLICATION');
240 }
241 } else {
242 // Print
243 }
244
245 print '</td></tr>'."\n";
246
247 print '</table>'."\n";
248
249 print '<br><br class="hideonsmartphone"><br class="hideonsmartphone"><br class="hideonsmartphone">'."\n";
250 }
251 }
252} else {
253 dol_print_error($db, $object->error, $object->errors);
254}
255
256print '</form>'."\n";
257print '</div>'."\n";
258print '<br>';
259
260
261htmlPrintOnlineFooter($mysoc, $langs);
262
263llxFooter('', 'public');
264
265$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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
Put here description of your class.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
llxFooter()
Footer empty.
Definition document.php:107
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0, $allowscript=0, $allowstyle=0)
Clean a string to keep only desirable HTML tags.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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_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 link.
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
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.