32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/modules/dons/modules_don.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/donation.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
44if (isModEnabled(
'project')) {
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
59$langs->loadLangs(array(
'bills',
'companies',
'donations',
'users'));
63$action =
GETPOST(
'action',
'aZ09');
64$cancel =
GETPOST(
'cancel',
'alpha');
65$confirm =
GETPOST(
'confirm',
'alpha');
66$backtopage =
GETPOST(
'backtopage',
'alpha');
79if (!empty($socid) && $socid > 0) {
89$extrafields->fetch_name_optionals_label(
$object->table_element);
90$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
93$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
95$upload_dir =
$conf->don->dir_output;
101$permissiontoread = $user->hasRight(
'don',
'lire');
102$permissiontoadd = $user->hasRight(
'don',
'creer');
103$permissiontodelete = $user->hasRight(
'don',
'supprimer');
104$permissiontoeditextra = $permissiontoadd;
105if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
107 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
117$parameters = array();
119$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
124if (empty($reshook)) {
125 $backurlforlist = DOL_URL_ROOT.
'/don/list.php';
127 if (empty($backtopage) || ($cancel && empty($id))) {
128 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
129 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
130 $backtopage = $backurlforlist;
132 $backtopage = DOL_URL_ROOT.
'/don/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
138 if (!empty($backtopageforcancel)) {
139 header(
"Location: ".$backtopageforcancel);
141 } elseif (!empty($backtopage)) {
142 header(
"Location: ".$backtopage);
149 if ($action ==
'confirm_reopen' && $confirm ==
'yes' && $permissiontoadd) {
150 $result =
$object->reopen($user);
154 if (method_exists(
$object,
'generateDocument')) {
155 $outputlangs = $langs;
158 $newlang =
GETPOST(
'lang_id',
'aZ09');
161 $newlang =
$object->thirdparty->default_lang;
163 if (!empty($newlang)) {
165 $outputlangs->setDefaultLang($newlang);
172 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
176 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
186 if ($action ==
'update' && $permissiontoadd) {
187 if (!empty($cancel)) {
188 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".urlencode((
string) ($id)));
192 if (empty($donation_date)) {
193 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
198 if (empty($amount)) {
199 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
216 $object->date = $donation_date;
217 $object->public = $public_donation;
222 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
227 if (
$object->update($user) > 0) {
228 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
239 if ($action ==
'add' && $permissiontoadd) {
240 if (!empty($cancel)) {
241 header(
"Location: index.php");
246 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
250 if (empty($donation_date)) {
251 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
256 if (empty($amount)) {
257 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
273 $object->date = $donation_date;
274 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
275 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
276 $object->public = $public_donation;
281 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
288 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$res);
298 if ($action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
"yes" && $permissiontodelete) {
299 $result =
$object->delete($user);
301 header(
"Location: index.php");
310 if ($action ==
'valid_promesse' && $permissiontoadd) {
312 if (
$object->valid_promesse($id, $user->id) >= 0) {
321 if ($action ==
'set_cancel' && $permissiontoadd) {
322 if (
$object->set_cancel($id) >= 0) {
330 if ($action ==
'set_paid' && $permissiontoadd) {
332 if (
$object->setPaid($id, $modepayment) >= 0) {
337 } elseif ($action ==
'classin' && $user->hasRight(
'don',
'creer')) {
338 $object->setProject($projectid);
341 if ($action ==
'set_validate' && $permissiontoadd) {
343 if (
$object->reopen($user) >= 0) {
350 if ($action ==
'update_extras' && $permissiontoeditextra) {
353 $attribute_name =
GETPOST(
'attribute',
'aZ09');
356 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
362 $result =
$object->updateExtraField($attribute_name,
'DON_MODIFY');
370 $action =
'edit_extras';
375 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
383$bankaccountstatic =
new Account($db);
385$title = $langs->trans(
"Donation");
387$help_url =
'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
389llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-donation page-card');
391$form =
new Form($db);
395if (isModEnabled(
'project')) {
399if ($action ==
'create') {
400 print
load_fiche_titre($langs->trans(
"AddDonation"),
'',
'object_donation');
402 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
403 print
'<input type="hidden" name="token" value="'.newToken().
'">';
404 print
'<input type="hidden" name="action" value="add">';
405 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
409 print
'<table class="border centpercent">';
413 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
'Draft').
'</td></tr>';
418 if (is_object($soc) && $soc->id > 0) {
419 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
421 print $soc->getNomUrl(1);
422 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
424 $arrayoutstandingbills = $soc->getOutstandingBills();
425 $outstandingBills = $arrayoutstandingbills[
'opened'];
426 print
' ('.$langs->trans(
'CurrentOutstandingBill').
': ';
427 print
price($outstandingBills, 0, $langs, 0, 0, -1,
$conf->currency);
428 if ($soc->outstanding_limit !=
'') {
429 if ($outstandingBills > $soc->outstanding_limit) {
430 print
img_warning($langs->trans(
"OutstandingBillReached"));
432 print
' / '.price($soc->outstanding_limit, 0, $langs, 0, 0, -1,
$conf->currency);
437 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
439 $filter =
'((s.client:IN:1,2,3) AND (status:=:1))';
440 print $form->select_company($socid,
'socid', $filter,
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300');
443 print
'<script type="text/javascript">
444 $(document).ready(function() {
445 $("#socid").change(function() {
446 console.log("We have changed the company - Reload page");
447 var socid = $(this).val();
448 var fac_rec = $(\'#fac_rec\').val();
450 $("input[name=action]").val("create");
451 $("form[name=add]").submit();
456 print
' <a href="'.DOL_URL_ROOT.
'/societe/card.php?action=create&customer=3&fournisseur=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span></a>';
463 print
'<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans(
"Date").
'</td><td>';
464 print $form->selectDate($donation_date ? $donation_date : -1,
'', 0, 0, 0,
"add", 1, 1);
468 print
"<tr>".
'<td class="fieldrequired">'.$langs->trans(
"Amount").
'</td><td><input type="text" name="amount" value="'.
dol_escape_htmltag(
GETPOST(
"amount")).
'" size="10"> '.$langs->trans(
"Currency".
$conf->currency).
'</td></tr>';
471 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PublicDonation").
"</td><td>";
472 print $form->selectyesno(
"public", $public_donation, 1);
473 print
"</td></tr>\n";
476 print
"<tr>".
'<td>'.$langs->trans(
"Company").
'</td><td><input type="text" name="societe" value="'.
dol_escape_htmltag(
GETPOST(
"societe")).
'" class="maxwidth200"></td></tr>';
477 print
"<tr>".
'<td>'.$langs->trans(
"Lastname").
'</td><td><input type="text" name="lastname" value="'.
dol_escape_htmltag(
GETPOST(
"lastname")).
'" class="maxwidth200"></td></tr>';
478 print
"<tr>".
'<td>'.$langs->trans(
"Firstname").
'</td><td><input type="text" name="firstname" value="'.
dol_escape_htmltag(
GETPOST(
"firstname")).
'" class="maxwidth200"></td></tr>';
479 print
"<tr>".
'<td>'.$langs->trans(
"Address").
'</td><td>';
480 print
'<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="3">'.dol_escape_htmltag(
GETPOST(
"address",
"alphanohtml"), 0, 1).
'</textarea></td></tr>';
483 print
'<tr><td>'.$langs->trans(
"Zip").
' / '.$langs->trans(
"Town").
'</td><td>';
484 print $formcompany->select_ziptown((GETPOSTISSET(
"zipcode") ?
GETPOST(
"zipcode") :
$object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
486 print $formcompany->select_ziptown((GETPOSTISSET(
"town") ?
GETPOST(
"town") :
$object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
490 print
'<tr><td><label for="selectcountry_id">'.$langs->trans(
'Country').
'</label></td><td class="maxwidthonsmartphone">';
491 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"').$form->select_country(
GETPOST(
'country_id') !=
'' ?
GETPOST(
'country_id') :
$object->country_id);
493 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
497 print
"<tr>".
'<td>'.$langs->trans(
"EMail").
'</td><td>'.
img_picto(
'',
'object_email',
'class="paddingrightonly"').
'<input type="text" name="email" value="'.
dol_escape_htmltag(
GETPOST(
"email")).
'" class="maxwidth200"></td></tr>';
501 print
"<tr><td>".$langs->trans(
"PaymentMode").
"</td><td>\n";
503 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
504 print $form->select_types_paiements((
string) $selected,
'modepayment',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
505 print
"</td></tr>\n";
509 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
511 if (!isset($note_public)) {
512 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
514 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
515 print $doleditor->Create(1);
519 if (empty($user->socid)) {
521 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
523 if (!isset($note_private)) {
524 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
526 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
527 print $doleditor->Create(1);
531 if (isModEnabled(
'project') && $formproject !==
null) {
532 print
"<tr><td>".$langs->trans(
"Project").
"</td><td>";
533 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
534 print $formproject->select_projects(-1, (
string) $projectid,
'fk_project', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
535 print
"</td></tr>\n";
539 $parameters = array();
540 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
541 print $hookmanager->resPrint;
542 if (empty($reshook)) {
543 print
$object->showOptionals($extrafields,
'create', $parameters);
551 print $form->buttonsSaveCancel();
563if (!empty($id) && $action ==
'edit') {
567 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
568 print
'<input type="hidden" name="token" value="'.newToken().
'">';
569 print
'<input type="hidden" name="action" value="update">';
570 print
'<input type="hidden" name="rowid" value="'.$object->id.
'">';
571 print
'<input type="hidden" name="amount" value="'.$object->amount.
'">';
572 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
574 print
dol_get_fiche_head($head, $hselected, $langs->trans(
"Donation"), 0,
'donation');
576 print
'<table class="border centpercent">';
579 print
'<tr><td>'.$langs->trans(
"Ref").
'</td><td colspan="2">';
585 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
586 print $form->selectDate(
$object->date,
'', 0, 0, 0,
"update");
591 print
"<tr>".
'<td class="fieldrequired">'.$langs->trans(
"Amount").
'</td><td><input type="text" name="amount" size="10" value="'.
price(
$object->amount).
'"> '.$langs->trans(
"Currency".
$conf->currency).
'</td></tr>';
593 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td>';
598 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PublicDonation").
"</td><td>";
599 print $form->selectyesno(
"public",
$object->public, 1);
606 print
'<tr><td>'.$langs->trans(
"ThirdParty").
'</td><td colspan="2">';
608 $result = $company->fetch(
$object->socid);
609 print $company->getNomUrl(1);
613 $langs->load(
"companies");
614 print
'<tr><td>'.$langs->trans(
"Company").
'</td><td><input type="text" name="societe" class="maxwidth200" value="'.
dol_escape_htmltag(
$object->societe).
'"></td></tr>';
615 print
'<tr><td>'.$langs->trans(
"Lastname").
'</td><td><input type="text" name="lastname" class="maxwidth200" value="'.
dol_escape_htmltag(
$object->lastname).
'"></td></tr>';
616 print
'<tr><td>'.$langs->trans(
"Firstname").
'</td><td><input type="text" name="firstname" class="maxwidth200" value="'.
dol_escape_htmltag(
$object->firstname).
'"></td></tr>';
617 print
'<tr><td>'.$langs->trans(
"Address").
'</td><td>';
618 print
'<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
dol_escape_htmltag(
$object->address, 0, 1).
'</textarea></td></tr>';
621 print
'<tr><td>'.$langs->trans(
"Zip").
' / '.$langs->trans(
"Town").
'</td><td>';
622 print $formcompany->select_ziptown((GETPOSTISSET(
"zipcode") ? GETPOSTISSET(
"zipcode") :
$object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
624 print $formcompany->select_ziptown((GETPOSTISSET(
"town") ?
GETPOST(
"town") :
$object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
628 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Country').
'</td><td>';
629 print $form->select_country((!empty(
$object->country_id) ?
$object->country_id : $mysoc->country_code),
'country_id');
631 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
635 print
"<tr>".
'<td>'.$langs->trans(
"EMail").
'</td><td><input type="text" name="email" class="maxwidth200" value="'.
dol_escape_htmltag(
$object->email).
'"></td></tr>';
638 print
"<tr><td>".$langs->trans(
"PaymentMode").
"</td><td>\n";
639 if (
$object->mode_reglement_id) {
640 $selected = (string)
$object->mode_reglement_id;
644 $form->select_types_paiements($selected,
'modepayment',
'CRDT', 0, 1);
645 print
"</td></tr>\n";
648 print
"<tr>".
'<td>'.$langs->trans(
"Status").
'</td><td>'.
$object->getLibStatut(4).
'</td></tr>';
651 if (isModEnabled(
'project')) {
654 $langs->load(
'projects');
655 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
656 $formproject->select_projects(-1, (
string)
$object->fk_project,
'fk_project', 0, 0, 1, 1, 0, 0, 0,
'', 0, 0,
'maxwidth500');
661 $parameters = array();
662 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
663 print $hookmanager->resPrint;
664 if (empty($reshook)) {
665 print
$object->showOptionals($extrafields,
'edit', $parameters);
672 print $form->buttonsSaveCancel();
684if (!empty($id) && $action !=
'edit') {
688 if ($action ==
'delete') {
689 $text = $langs->trans(
"ConfirmDeleteADonation");
690 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"DeleteADonation"), $text,
"confirm_delete",
'',
'', 1);
698 $result =
$object->fetch_optionals();
707 print
dol_get_fiche_head($head, $hselected, $langs->trans(
"Donation"), -1,
'donation');
712 $linkback =
'<a href="'.DOL_URL_ROOT.
'/don/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
714 $morehtmlref =
'<div class="refidno">';
716 if (isModEnabled(
'project') && $formproject !==
null) {
717 $langs->load(
"projects");
718 $morehtmlref .= $langs->trans(
'Project').
' ';
719 if ($user->hasRight(
'don',
'creer')) {
720 if ($action !=
'classify') {
721 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
723 if ($action ==
'classify') {
725 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
726 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
727 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
728 $morehtmlref .=
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
729 $morehtmlref .= $formproject->select_projects(
$object->socid, (
string)
$object->fk_project,
'projectid', 0, 0, 1, 0, 1, 0, 0,
'', 1, 0,
'maxwidth500');
730 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
731 $morehtmlref .=
'</form>';
733 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid, (
string)
$object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
736 if (!empty(
$object->fk_project)) {
738 $proj->fetch(
$object->fk_project);
739 $morehtmlref .=
' : '.$proj->getNomUrl(1);
741 $morehtmlref .=
' - '.$proj->title;
748 $morehtmlref .=
'</div>';
751 dol_banner_tab(
$object,
'rowid', $linkback, 1,
'rowid',
'ref', $morehtmlref);
754 print
'<div class="fichecenter">';
755 print
'<div class="fichehalfleft">';
756 print
'<div class="underbanner clearboth"></div>';
758 print
'<table class="border tableforfield" width="100%">';
761 print
'<tr><td class="titlefield">'.$langs->trans(
"Date").
'</td><td colspan="2">';
765 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td colspan="2">';
769 print
'<tr><td>'.$langs->trans(
"PublicDonation").
'</td><td colspan="2">';
776 print
'<tr><td>'.$langs->trans(
"ThirdParty").
'</td><td colspan="2">';
778 $result = $company->fetch(
$object->socid);
779 print $company->getNomUrl(1);
783 print
'<tr><td>'.$langs->trans(
"Company").
'</td><td colspan="2">'.
$object->societe.
'</td></tr>';
784 print
'<tr><td>'.$langs->trans(
"Lastname").
'</td><td colspan="2">'.
$object->lastname.
'</td></tr>';
785 print
'<tr><td>'.$langs->trans(
"Firstname").
'</td><td colspan="2">'.
$object->firstname.
'</td></tr>';
789 print
"<tr><td>".$langs->trans(
"PaymentMode").
"</td><td>";
790 $form->form_modes_reglement(
'', (
string)
$object->mode_reglement_id,
'none');
791 print
"</td></tr>\n";
795 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
800 print
'<div class="fichehalfright">';
805 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,";
806 $sql .=
" c.code as type_code, c.libelle as paiement_type,";
807 $sql .=
" b.fk_account";
808 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_donation as p";
809 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON p.fk_bank = b.rowid";
810 $sql .=
", ".MAIN_DB_PREFIX.
"c_paiement as c ";
811 $sql .=
", ".MAIN_DB_PREFIX.
"don as d";
812 $sql .=
" WHERE d.rowid = ".((int) $id);
813 $sql .=
" AND p.fk_donation = d.rowid";
814 $sql .=
" AND d.entity IN (".getEntity(
'donation').
")";
815 $sql .=
" AND p.fk_typepayment = c.id";
816 $sql .=
" ORDER BY dp";
819 $resql = $db->query($sql);
821 $num = $db->num_rows($resql);
824 print
'<table class="noborder paymenttable centpercent">';
825 print
'<tr class="liste_titre">';
826 print
'<td>'.$langs->trans(
"RefPayment").
'</td>';
827 print
'<td>'.$langs->trans(
"Date").
'</td>';
828 print
'<td>'.$langs->trans(
"Type").
'</td>';
829 if (isModEnabled(
"bank")) {
830 print
'<td>'.$langs->trans(
"BankAccount").
'</td>';
832 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
836 $objp = $db->fetch_object($resql);
838 print
'<tr class="oddeven"><td>';
839 print
'<a href="'.DOL_URL_ROOT.
'/don/payment/card.php?id='.$objp->rowid.
'">'.
img_object($langs->trans(
"Payment"),
"payment").
' '.$objp->rowid.
'</a></td>';
840 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
841 $labeltype = ($langs->trans(
"PaymentType".$objp->type_code) !=
"PaymentType".$objp->type_code) ? $langs->trans(
"PaymentType".$objp->type_code) : $objp->paiement_type;
842 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
843 if (isModEnabled(
"bank")) {
844 $bankaccountstatic->fetch($objp->fk_account);
859 print
'<td class="nowraponall">';
860 if ($bankaccountstatic->id) {
861 print $bankaccountstatic->getNomUrl(1,
'transactions');
865 print
'<td class="right">'.price($objp->amount).
"</td>\n";
867 $totalpaid += $objp->amount;
873 if (isModEnabled(
"bank")) {
876 print
'<tr><td colspan="'.$colspan.
'" class="right">'.$langs->trans(
"AlreadyPaid").
' :</td><td class="right">'.
price($totalpaid).
"</td></tr>\n";
877 print
'<tr><td colspan="'.$colspan.
'" class="right">'.$langs->trans(
"AmountExpected").
' :</td><td class="right">'.
price(
$object->amount).
"</td></tr>\n";
879 $remaintopay =
$object->amount - $totalpaid;
880 $resteapayeraffiche = $remaintopay;
882 print
'<tr><td colspan="'.$colspan.
'" class="right">'.$langs->trans(
"RemainderToPay").
" :</td>";
883 print
'<td class="right'.(!empty($resteapayeraffiche) ?
' amountremaintopay' :
'').
'">'.
price($resteapayeraffiche).
"</td></tr>\n";
894 print
'<div class="clearboth"></div>';
903 print
'<div class="tabsAction">';
904 $parameters = array();
905 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
906 if (empty($reshook)) {
908 if ($permissiontoadd &&
$object->status == $object::STATUS_CANCELED) {
909 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_reopen&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"ReOpen").
'</a>';
912 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&rowid='.
$object->id.
'">'.$langs->trans(
'Modify').
'</a></div>';
914 if (
$object->status == $object::STATUS_DRAFT) {
915 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.
$object->id.
'&action=valid_promesse&token='.
newToken().
'">'.$langs->trans(
"ValidPromess").
'</a></div>';
918 if ((
$object->status == $object::STATUS_DRAFT ||
$object->status == $object::STATUS_VALIDATED) && $totalpaid == 0 &&
$object->paid == 0) {
919 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.
$object->id.
'&action=set_cancel&token='.
newToken().
'">'.$langs->trans(
"ClassifyCanceled").
"</a></div>";
923 if (
$object->status == $object::STATUS_VALIDATED &&
$object->paid == 0 && $user->hasRight(
'don',
'creer')) {
924 if ($remaintopay == 0) {
925 print
'<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPayment').
'</span></div>';
927 print
'<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.
'/don/payment/payment.php?rowid='.
$object->id.
'&action=create&token='.
newToken().
'">'.$langs->trans(
'DoPayment').
'</a></div>';
932 if (
$object->status == $object::STATUS_VALIDATED && $remaintopay == 0 &&
$object->paid == 0 && $user->hasRight(
'don',
'creer')) {
933 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.
$object->id.
'&action=set_paid&token='.
newToken().
'">'.$langs->trans(
"ClassifyPaid").
"</a></div>";
935 if (
$object->status == $object::STATUS_PAID &&
$object->paid == 1 && $user->hasRight(
'don',
'creer')) {
936 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.
$object->id.
'&action=set_validate&token='.
newToken().
'">'.$langs->trans(
"ReOpen").
"</a></div>";
940 if ($user->hasRight(
'don',
'supprimer')) {
941 if (
$object->status != $object::STATUS_PAID && $remaintopay ==
$object->amount) {
942 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.
'&action=delete&token='.
newToken().
'">'.$langs->trans(
"Delete").
"</a></div>";
944 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"DeletionNotPossibleWhenAPaymentExists").
'">'.$langs->trans(
"Delete").
"</a></div>";
947 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Delete").
"</a></div>";
954 print
'<div class="fichecenter"><div class="fichehalfleft">';
961 $urlsource = $_SERVER[
'PHP_SELF'].
'?rowid='.
$object->id;
962 $genallowed = (int) ((
$object->paid == 0 || $user->admin) && $user->hasRight(
'don',
'lire'));
963 $delallowed = $user->hasRight(
'don',
'creer');
965 print $formfile->showdocuments(
'donation', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf);
968 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'don'), 1);
969 $linktoelem = $tmparray[
'linktoelem'];
970 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
971 print $htmltoenteralink;
973 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
977 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
978 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
979 $useonlinepayment = count($validpaymentmethod);
981 if ($useonlinepayment) {
982 print
'<br><!-- Link to pay -->'.
"\n";
983 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
984 print showOnlinePaymentUrl(
'donation',
$object->ref).
'<br>';
987 print
'</div><div class="fichehalfright">';
989 print
'</div></div>';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
Class to manage bank accounts.
Class to manage a WYSIWYG editor.
Class to manage donations.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
donation_prepare_head($object)
Prepare array with list of tabs.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.