37if (!defined(
'NOLOGIN')) {
40if (!defined(
'NOCSRFCHECK')) {
41 define(
"NOCSRFCHECK", 1);
43if (!defined(
'NOBROWSERNOTIF')) {
44 define(
'NOBROWSERNOTIF',
'1');
51$entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
53define(
"DOLENTITY", $entity);
58require
'../../main.inc.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
60require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
61require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
62require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
63require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
64require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
65require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
67 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
71$backtopage =
GETPOST(
'backtopage',
'alpha');
72$action =
GETPOST(
'action',
'aZ09');
88$langs->loadLangs(array(
"main",
"donations",
"companies",
"install",
"other",
"errors"));
106$user->loadDefaultValues();
110 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
113 $dirModCaptcha = array_merge(
115 'main' =>
'/core/modules/security/captcha/'
117 is_array(
$conf->modules_parts[
'captcha']) ?
$conf->modules_parts[
'captcha'] : array()
119 $fullpathclassfile =
'';
120 foreach ($dirModCaptcha as $dir) {
121 $fullpathclassfile =
dol_buildpath($dir.
"modCaptcha".ucfirst($captcha).
'.class.php', 0, 2);
122 if ($fullpathclassfile) {
126 if ($fullpathclassfile) {
127 include_once $fullpathclassfile;
129 $classname =
"modCaptcha".ucfirst($captcha);
130 if (class_exists($classname)) {
131 $captchaobj =
new $classname(
$db,
$conf, $langs, $user);
132 '@phan-var-force ModeleCaptcha $captchaobj';
135 print
'Error, the captcha handler class '.$classname.
' was not found after the include';
138 print
'Error, the captcha handler '.$captcha.
' has no class file found modCaptcha'.ucfirst($captcha);
156function llxHeaderVierge($title, $head =
"", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [], $ws =
'')
160 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
162 print
'<body id="mainbody" class="publicnewmemberform">';
164 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
167 print
'<div class="divmainbodylarge">';
179 global
$conf, $langs;
185 if (!empty(
$conf->use_javascript_ajax)) {
186 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
187 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
200$parameters = array();
202$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
208if (empty($reshook) && $action ==
'add') {
215 $langs->load(
'errors');
217 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email",
"aZ09arobase")).
"<br>\n";
221 $errmsg .= $langs->trans(
"ErrorFieldMinimumAmount",
getDolGlobalInt(
'DONATION_MIN_AMOUNT')).
"<br>\n";
226 if (
getDolGlobalString(
'MAIN_SECURITY_ENABLECAPTCHA_DONATION') && is_object($captchaobj)) {
227 if (method_exists($captchaobj,
'validateCodeAfterLoginSubmit')) {
228 $ok = $captchaobj->validateCodeAfterLoginSubmit();
230 print
'Error, the captcha handler '.get_class($captchaobj).
' does not have any method validateCodeAfterLoginSubmit()';
234 $langs->load(
"errors");
235 $errmsg .= $langs->trans(
"ErrorBadValueForCode").
"<br>\n";
240 $public = GETPOSTISSET(
'public') ? 1 : 0;
244 $result = $project->fetch(
GETPOSTINT(
'project_id'));
246 $projectId = $project->id;
253 $donation->amount = (float)
GETPOST(
'amount');
254 $donation->status = Don::STATUS_DRAFT;
255 $donation->public = $public;
257 $donation->firstname =
GETPOST(
'firstname');
258 $donation->lastname =
GETPOST(
'lastname');
259 $donation->company =
GETPOST(
'societe');
260 $donation->societe = $donation->company;
261 $donation->address =
GETPOST(
'address');
262 $donation->zip =
GETPOST(
'zipcode');
263 $donation->town =
GETPOST(
'town');
264 $donation->email =
GETPOST(
'email',
'aZ09arobase');
265 $donation->country_id =
GETPOSTINT(
'country_id');
267 if (!empty($projectId)) {
268 $donation->fk_project = $projectId;
272 $donation->note_private =
GETPOST(
'note_private');
276 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
281 if ($nb_post_max > 0) {
282 $sql =
"SELECT COUNT(rowid) as nb_don";
283 $sql .=
" FROM ".MAIN_DB_PREFIX.
"don";
284 $sql .=
" WHERE ip = '".$db->escape($donation->ip).
"'";
285 $sql .=
" AND datedon > '".$db->idate($minmonthpost).
"'";
286 $resql =
$db->query($sql);
288 $num =
$db->num_rows($resql);
292 $obj =
$db->fetch_object($resql);
293 $nb_post_ip = $obj->nb_don;
298 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
300 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
301 array_push($donation->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
305 $extrafields->fetch_name_optionals_label($donation->table_element);
306 $ret = $extrafields->setOptionalsFromPost(
null, $donation);
309 $errmsg .= $donation->error;
313 $result = $donation->create($user);
315 if (!empty($backtopage)) {
316 $urlback = $backtopage;
318 $urlback = $_SERVER[
"PHP_SELF"].
"?action=added&token=".newToken();
322 $urlback = getOnlinePaymentUrl(0,
'donation', (
string) $donation->id, 0,
'');
325 $urlback .=
'&email='.urlencode(
GETPOST(
'email'));
328 $urlback .=
'&paymentmethod='.urlencode(
getDolGlobalString(
'DONATION_NEWFORM_PAYONLINE'));
331 if (!empty($entity)) {
332 $urlback .=
'&entity='.((int) $entity);
337 $errmsg .= implode(
'<br>', $donation->errors);
345 header(
"Location: ".$urlback);
357if (empty($reshook) && $action ==
'added') {
362 print
'<div class="center">';
363 print $langs->trans(
"NewDonationbyWeb").
'<br>';
377$extrafields->fetch_name_optionals_label(
$object->table_element);
381 $result = $project->fetch(
GETPOSTINT(
'project_id'));
383 $projectId = $project->id;
384 $projectTitle = $project->title;
392print
load_fiche_titre(
img_picto(
'',
'',
'class="pictofixedwidth"').
' '.$langs->trans(
"NewDonation"),
'',
'', 0,
'',
'center');
395print
'<div align="center">';
396print
'<div id="divsubscribe">';
398print
'<div class="center subscriptionformhelptext opacitymedium justify">';
399print $langs->trans(
"NewDonationDesc",
getDolGlobalString(
"MAIN_INFO_SOCIETE_MAIL")).
"<br>\n";
407print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="newdonation">'.
"\n";
408print
'<input type="hidden" name="token" value="'.newToken().
'" />';
409print
'<input type="hidden" name="entity" value="'.$entity.
'" />';
410print
'<input type="hidden" name="page_y" value="" />';
411print
'<input type="hidden" name="project_id" value="'.GETPOST(
'project_id').
'" />';
413if (!$action || $action ==
'create') {
414 print
'<input type="hidden" name="action" value="add" />';
417 $messagemandatory =
'<span class="">'.$langs->trans(
"FieldsWithAreMandatory",
'*').
'</span>';
423 print
'<script type="text/javascript">
424 jQuery(document).ready(function () {
425 jQuery(document).ready(function () {
426 jQuery("#selectcountry_id").change(function() {
427 document.newdonation.action.value="create";
428 document.newdonation.submit();
434 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
439 print
'<td class="project-label">' . $langs->trans(
"project") .
'</td>';
472 print
'<tr id="tremail"><td class="fieldrequired" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
"Email").
'</td><td>';
474 print
'<input type="email" name="email" maxlength="255" class="minwidth200" value="'.dol_escape_htmltag(
GETPOST(
'email',
"aZ09arobase")).
'"></td></tr>'.
"\n";
477 print
'<tr id="trcompany" class="trcompany"><td>'.$langs->trans(
"Company").
'</td><td>';
478 print
img_picto(
'',
'company',
'class="pictofixedwidth paddingright"');
479 print
'<input type="text" name="societe" class="minwidth150 widthcentpercentminusx" value="'.dol_escape_htmltag(
GETPOST(
'societe')).
'"></td></tr>'.
"\n";
482 print
'<tr id="trfirstname"><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
"Firstname").
'</td><td><input type="text" name="firstname" class="minwidth150" value="'.
dol_escape_htmltag(
GETPOST(
'firstname')).
'"></td></tr>'.
"\n";
485 print
'<tr id="trlastname"><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
"Lastname").
'</td><td><input type="text" name="lastname" class="minwidth150" value="'.
dol_escape_htmltag(
GETPOST(
'lastname')).
'"></td></tr>'.
"\n";
488 print
'<tr id="tradress"><td>'.$langs->trans(
"Address").
'</td><td>'.
"\n";
489 print
'<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
dol_escape_htmltag(
GETPOST(
'address',
'restricthtml'), 0, 1).
'</textarea></td></tr>'.
"\n";
492 print
'<tr id="trzip"><td>'.$langs->trans(
'Zip').
' / '.$langs->trans(
'Town').
'</td><td>';
493 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 1,
'',
'width75');
495 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
499 print
'<tr id="trcountry"><td>'.$langs->trans(
'Country').
'</td><td>';
500 print
img_picto(
'',
'country',
'class="pictofixedwidth paddingright"');
502 if (!$country_id && !empty(
$conf->geoipmaxmind->enabled)) {
506 $new_country_id =
getCountry($country_code,
'3',
$db, $langs);
508 if ($new_country_id) {
509 $country_id = $new_country_id;
514 print $form->select_country($country_id,
'country_id');
519 print
'<tr id="trstate"><td>'.$langs->trans(
'State').
'</td><td>';
521 print
img_picto(
'',
'state',
'class="pictofixedwidth paddingright"');
522 print $formcompany->select_state(
GETPOSTINT(
"state_id"), $country_code);
528 $parameters[
'tpl_context'] =
'public';
529 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
531 print
'<tr id="trseparator"><td colspan="2"><hr></td></tr>';
534 $publiclabel = $langs->trans(
"publicDonationFieldHelp",
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM'));
535 print
'<tr><td><label for="public">'.$form->textwithpicto($langs->trans(
"donationPublic"), $publiclabel).
'</label></td>';
536 print
'<td><input type="checkbox" name="public" id="public"></td></tr>'.
"\n";
542 $amount = max(0, (
float) $amount, (
float)
getDolGlobalInt(
"DONATION_MIN_AMOUNT"));
546 $showedamount = $amount > 0 ? $amount : 0;
547 print
'<tr><td>'.$langs->trans(
"donationAmount");
548 print
' <span>*</span></td><td class="nowrap">';
550 print
'<input type="text" name="amount" id="amount" class="flat amount width50" value="'.$showedamount.
'">';
551 print
' '.$langs->trans(
"Currency".
getDolCurrency()).
'<span class="opacitymedium hideifautoturnover"> - ';
552 print $langs->trans(
"AnyAmountForDonation");
560 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
561 print
'<td class="tdtop"><textarea name="note_private" id="note_private" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
dol_escape_htmltag(
GETPOST(
'note_private',
'restricthtml'), 0, 1).
'</textarea></td>';
565 if (
getDolGlobalString(
'MAIN_SECURITY_ENABLECAPTCHA_DONATION') && is_object($captchaobj)) {
566 print
'<tr><td class="titlefield"><label><span class="fieldrequired">'.$langs->trans(
"SecurityCode").
'</span></label></td><td><br>';
567 if (method_exists($captchaobj,
'getCaptchaCodeForForm')) {
568 print $captchaobj->getCaptchaCodeForForm(
'');
570 print
'Error, the captcha handler '.get_class($captchaobj).
' does not have any method getCaptchaCodeForForm()';
572 print
'<br></td></tr>';
579 print
'<div class="center">';
580 print
'<input type="submit" value="'.$langs->trans(
"GetDonationButtonLabel").
'" id="submitsave" class="button">';
581 if (!empty($backtopage)) {
582 print
' <input type="submit" value="'.$langs->trans(
"Cancel").
'" id="submitcancel" class="button button-cancel">';
589 print
'</div></div>';
if(! $sortfield) if(! $sortorder) $object
Class to manage donations.
Class to manage projects.
llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[], $ws='')
Show header for new prospect.
llxFooterVierge()
Show footer for new societe.
htmlPrintOnlineHeader($mysoc, $langs, $showlogo=1, $alttext='', $subimageconst='', $altlogo1='', $altlogo2='')
Show the header of a company in HTML public pages.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_user_country()
Return country code for current user.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
dol_htmloutput_events($disabledoutputofmessages=0)
Print formatted messages to output (Used to show messages on html output).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getUserRemoteIP($trusted=0)
Return the real IP of remote user.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.