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