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);
155function llxHeaderVierge($title, $head =
"", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [])
157 global $conf, $langs,
$mysoc;
159 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
161 print
'<body id="mainbody" class="publicnewmemberform">';
163 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
166 print
'<div class="divmainbodylarge">';
178 global $conf, $langs;
184 if (!empty($conf->use_javascript_ajax)) {
185 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
186 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
199$parameters = array();
201$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
207if (empty($reshook) && $action ==
'add') {
214 $langs->load(
'errors');
216 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email",
"aZ09arobase")).
"<br>\n";
220 $errmsg .= $langs->trans(
"ErrorFieldMinimumAmount",
getDolGlobalInt(
'DONATION_MIN_AMOUNT')).
"<br>\n";
225 if (
getDolGlobalString(
'MAIN_SECURITY_ENABLECAPTCHA_DONATION') && is_object($captchaobj)) {
226 if (method_exists($captchaobj,
'validateCodeAfterLoginSubmit')) {
227 $ok = $captchaobj->validateCodeAfterLoginSubmit();
229 print
'Error, the captcha handler '.get_class($captchaobj).
' does not have any method validateCodeAfterLoginSubmit()';
233 $langs->load(
"errors");
234 $errmsg .= $langs->trans(
"ErrorBadValueForCode").
"<br>\n";
239 $public = GETPOSTISSET(
'public') ? 1 : 0;
243 $result = $project->fetch(
GETPOSTINT(
'project_id'));
245 $projectId = $project->id;
250 $donation =
new Don($db);
252 $donation->amount = (float)
GETPOST(
'amount');
253 $donation->status = Don::STATUS_DRAFT;
254 $donation->public = $public;
256 $donation->firstname =
GETPOST(
'firstname');
257 $donation->lastname =
GETPOST(
'lastname');
258 $donation->company =
GETPOST(
'societe');
259 $donation->societe = $donation->company;
260 $donation->address =
GETPOST(
'address');
261 $donation->zip =
GETPOST(
'zipcode');
262 $donation->town =
GETPOST(
'town');
263 $donation->email =
GETPOST(
'email',
'aZ09arobase');
264 $donation->country_id =
GETPOSTINT(
'country_id');
266 if (!empty($projectId)) {
267 $donation->fk_project = $projectId;
271 $donation->note_private =
GETPOST(
'note_private');
275 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
280 if ($nb_post_max > 0) {
281 $sql =
"SELECT COUNT(rowid) as nb_don";
282 $sql .=
" FROM ".MAIN_DB_PREFIX.
"don";
283 $sql .=
" WHERE ip = '".$db->escape($donation->ip).
"'";
284 $sql .=
" AND datedon > '".$db->idate($minmonthpost).
"'";
285 $resql = $db->query($sql);
287 $num = $db->num_rows($resql);
291 $obj = $db->fetch_object($resql);
292 $nb_post_ip = $obj->nb_don;
297 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
299 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
300 array_push($donation->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
304 $extrafields->fetch_name_optionals_label($donation->table_element);
305 $ret = $extrafields->setOptionalsFromPost(
null, $donation);
308 $errmsg .= $donation->error;
312 $result = $donation->create($user);
314 if (!empty($backtopage)) {
315 $urlback = $backtopage;
317 $urlback = $_SERVER[
"PHP_SELF"].
"?action=added&token=".
newToken();
321 $urlback = getOnlinePaymentUrl(0,
'donation', (
string) $donation->id, 0,
'');
324 $urlback .=
'&email='.urlencode(
GETPOST(
'email'));
327 $urlback .=
'&paymentmethod='.urlencode(
getDolGlobalString(
'DONATION_NEWFORM_PAYONLINE'));
330 if (!empty($entity)) {
331 $urlback .=
'&entity='.((int) $entity);
336 $errmsg .= implode(
'<br>', $donation->errors);
344 header(
"Location: ".$urlback);
356if (empty($reshook) && $action ==
'added') {
361 print
'<div class="center">';
362 print $langs->trans(
"NewDonationbyWeb").
'<br>';
374$form =
new Form($db);
376$extrafields->fetch_name_optionals_label(
$object->table_element);
380 $result = $project->fetch(
GETPOSTINT(
'project_id'));
382 $projectId = $project->id;
383 $projectTitle = $project->title;
391print
load_fiche_titre(
img_picto(
'',
'',
'class="pictofixedwidth"').
' '.$langs->trans(
"NewDonation"),
'',
'', 0,
'',
'center');
394print
'<div align="center">';
395print
'<div id="divsubscribe">';
397print
'<div class="center subscriptionformhelptext opacitymedium justify">';
398print $langs->trans(
"NewDonationDesc",
getDolGlobalString(
"MAIN_INFO_SOCIETE_MAIL")).
"<br>\n";
406print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="newdonation">'.
"\n";
407print
'<input type="hidden" name="token" value="'.newToken().
'" />';
408print
'<input type="hidden" name="entity" value="'.$entity.
'" />';
409print
'<input type="hidden" name="page_y" value="" />';
410print
'<input type="hidden" name="project_id" value="'.GETPOST(
'project_id').
'" />';
412if (!$action || $action ==
'create') {
413 print
'<input type="hidden" name="action" value="add" />';
416 $messagemandatory =
'<span class="">'.$langs->trans(
"FieldsWithAreMandatory",
'*').
'</span>';
422 print
'<script type="text/javascript">
423 jQuery(document).ready(function () {
424 jQuery(document).ready(function () {
425 jQuery("#selectcountry_id").change(function() {
426 document.newdonation.action.value="create";
427 document.newdonation.submit();
433 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
438 print
'<td class="project-label">' . $langs->trans(
"project") .
'</td>';
471 print
'<tr id="tremail"><td class="fieldrequired" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
"Email").
'</td><td>';
473 print
'<input type="email" name="email" maxlength="255" class="minwidth200" value="'.dol_escape_htmltag(
GETPOST(
'email',
"aZ09arobase")).
'"></td></tr>'.
"\n";
476 print
'<tr id="trcompany" class="trcompany"><td>'.$langs->trans(
"Company").
'</td><td>';
477 print
img_picto(
'',
'company',
'class="pictofixedwidth paddingright"');
478 print
'<input type="text" name="societe" class="minwidth150 widthcentpercentminusx" value="'.dol_escape_htmltag(
GETPOST(
'societe')).
'"></td></tr>'.
"\n";
481 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";
484 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";
487 print
'<tr id="tradress"><td>'.$langs->trans(
"Address").
'</td><td>'.
"\n";
488 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";
491 print
'<tr id="trzip"><td>'.$langs->trans(
'Zip').
' / '.$langs->trans(
'Town').
'</td><td>';
492 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 1,
'',
'width75');
494 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
498 print
'<tr id="trcountry"><td>'.$langs->trans(
'Country').
'</td><td>';
499 print
img_picto(
'',
'country',
'class="pictofixedwidth paddingright"');
501 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
505 $new_country_id =
getCountry($country_code,
'3', $db, $langs);
507 if ($new_country_id) {
508 $country_id = $new_country_id;
512 $country_code =
getCountry($country_id,
'2', $db, $langs);
513 print $form->select_country($country_id,
'country_id');
518 print
'<tr id="trstate"><td>'.$langs->trans(
'State').
'</td><td>';
520 print
img_picto(
'',
'state',
'class="pictofixedwidth paddingright"');
521 print $formcompany->select_state(
GETPOSTINT(
"state_id"), $country_code);
527 $parameters[
'tpl_context'] =
'public';
528 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
530 print
'<tr id="trseparator"><td colspan="2"><hr></td></tr>';
533 $publiclabel = $langs->trans(
"publicDonationFieldHelp",
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM'));
534 print
'<tr><td><label for="public">'.$form->textwithpicto($langs->trans(
"donationPublic"), $publiclabel).
'</label></td>';
535 print
'<td><input type="checkbox" name="public" id="public"></td></tr>'.
"\n";
541 $amount = max(0, (
float) $amount, (
float)
getDolGlobalInt(
"DONATION_MIN_AMOUNT"));
545 $showedamount = $amount > 0 ? $amount : 0;
546 print
'<tr><td>'.$langs->trans(
"donationAmount");
547 print
' <span>*</span></td><td class="nowrap">';
549 print
'<input type="text" name="amount" id="amount" class="flat amount width50" value="'.$showedamount.
'">';
550 print
' '.$langs->trans(
"Currency".
getDolCurrency()).
'<span class="opacitymedium hideifautoturnover"> - ';
551 print $langs->trans(
"AnyAmountForDonation");
559 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
560 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>';
564 if (
getDolGlobalString(
'MAIN_SECURITY_ENABLECAPTCHA_DONATION') && is_object($captchaobj)) {
565 print
'<tr><td class="titlefield"><label><span class="fieldrequired">'.$langs->trans(
"SecurityCode").
'</span></label></td><td><br>';
566 if (method_exists($captchaobj,
'getCaptchaCodeForForm')) {
567 print $captchaobj->getCaptchaCodeForForm(
'');
569 print
'Error, the captcha handler '.get_class($captchaobj).
' does not have any method getCaptchaCodeForForm()';
571 print
'<br></td></tr>';
578 print
'<div class="center">';
579 print
'<input type="submit" value="'.$langs->trans(
"GetDonationButtonLabel").
'" id="submitsave" class="button">';
580 if (!empty($backtopage)) {
581 print
' <input type="submit" value="'.$langs->trans(
"Cancel").
'" id="submitcancel" class="button button-cancel">';
588 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=[])
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.