31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/modules/dons/modules_don.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/donation.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
42if (isModEnabled(
'project')) {
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
48$langs->loadLangs(array(
'bills',
'companies',
'donations',
'users'));
52$action =
GETPOST(
'action',
'aZ09');
53$cancel =
GETPOST(
'cancel',
'alpha');
54$confirm =
GETPOST(
'confirm',
'alpha');
55$backtopage =
GETPOST(
'backtopage',
'alpha');
56$socid =
GETPOST(
'socid',
'int');
59$projectid = (
GETPOST(
'projectid') ?
GETPOST(
'projectid',
'int') : 0);
60$public_donation = (int)
GETPOST(
"public",
'int');
62$object =
new Don($db);
64 $object->fetch($id, $ref);
67if (!empty($socid) && $socid > 0) {
77$extrafields->fetch_name_optionals_label($object->table_element);
78$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
81$hookmanager->initHooks(array($object->element.
'card',
'globalcard'));
83$upload_dir = $conf->don->dir_output;
89$permissiontoadd = $user->rights->don->creer;
98$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
103if (empty($reshook)) {
104 $backurlforlist = DOL_URL_ROOT.
'/don/list.php';
106 if (empty($backtopage) || ($cancel && empty($id))) {
107 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
108 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
109 $backtopage = $backurlforlist;
111 $backtopage = DOL_URL_ROOT.
'/don/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
117 if (!empty($backtopageforcancel)) {
118 header(
"Location: ".$backtopageforcancel);
120 } elseif (!empty($backtopage)) {
121 header(
"Location: ".$backtopage);
128 if ($action ==
'confirm_reopen' && $confirm ==
'yes' && $permissiontoadd) {
131 $result = $object->reopen($user);
135 if (method_exists($object,
'generateDocument')) {
136 $outputlangs = $langs;
139 $newlang =
GETPOST(
'lang_id',
'aZ09');
142 $newlang = $object->thirdparty->default_lang;
144 if (!empty($newlang)) {
146 $outputlangs->setDefaultLang($newlang);
148 $model = $object->model_pdf;
149 $ret = $object->fetch($id);
151 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
155 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
165 if ($action ==
'update') {
166 if (!empty($cancel)) {
167 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".urlencode($id));
173 if (empty($donation_date)) {
174 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
179 if (empty($amount)) {
180 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
188 $object->firstname = (string)
GETPOST(
"firstname",
'alpha');
189 $object->lastname = (string)
GETPOST(
"lastname",
'alpha');
190 $object->societe = (string)
GETPOST(
"societe",
'alpha');
191 $object->address = (string)
GETPOST(
"address",
'alpha');
193 $object->town = (string)
GETPOST(
"town",
'alpha');
194 $object->zip = (string)
GETPOST(
"zipcode",
'alpha');
195 $object->country_id = (int)
GETPOST(
'country_id',
'int');
196 $object->email = (string)
GETPOST(
"email",
'alpha');
197 $object->date = $donation_date;
198 $object->public = $public_donation;
199 $object->fk_project = (int)
GETPOST(
"fk_project",
'int');
200 $object->modepaymentid = (int)
GETPOST(
'modepayment',
'int');
203 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
208 if ($object->update($user) > 0) {
209 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
220 if ($action ==
'add') {
221 if (!empty($cancel)) {
222 header(
"Location: index.php");
229 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
233 if (empty($donation_date)) {
234 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
239 if (empty($amount)) {
240 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
246 $object->socid = (int)
GETPOST(
"socid",
'int');
247 $object->firstname = (string)
GETPOST(
"firstname",
'alpha');
248 $object->lastname = (string)
GETPOST(
"lastname",
'alpha');
249 $object->societe = (string)
GETPOST(
"societe",
'alpha');
250 $object->address = (string)
GETPOST(
"address",
'alpha');
252 $object->zip = (string)
GETPOST(
"zipcode",
'alpha');
253 $object->town = (string)
GETPOST(
"town",
'alpha');
254 $object->country_id = (int)
GETPOST(
'country_id',
'int');
255 $object->email = (string)
GETPOST(
'email',
'alpha');
256 $object->date = $donation_date;
257 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
258 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
259 $object->public = $public_donation;
260 $object->fk_project = (int)
GETPOST(
"fk_project",
'int');
261 $object->modepaymentid = (int)
GETPOST(
'modepayment',
'int');
264 $ret = $extrafields->setOptionalsFromPost(
null, $object);
269 $res = $object->create($user);
271 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$res);
281 if ($action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
"yes" && $user->hasRight(
'don',
'supprimer')) {
283 $result = $object->delete($user);
285 header(
"Location: index.php");
294 if ($action ==
'valid_promesse') {
296 if ($object->valid_promesse($id, $user->id) >= 0) {
305 if ($action ==
'set_cancel') {
307 if ($object->set_cancel($id) >= 0) {
315 if ($action ==
'set_paid') {
317 if ($object->setPaid($id, $modepayment) >= 0) {
322 } elseif ($action ==
'classin' && $user->hasRight(
'don',
'creer')) {
324 $object->setProject($projectid);
327 if ($action ==
'update_extras') {
333 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
340 $result = $object->insertExtraFields(
'DON_MODIFY');
348 $action =
'edit_extras';
353 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
414$title = $langs->trans(
"Donation");
416$help_url =
'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
420$form =
new Form($db);
423if (isModEnabled(
'project')) {
427if ($action ==
'create') {
428 print
load_fiche_titre($langs->trans(
"AddDonation"),
'',
'object_donation');
430 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
431 print
'<input type="hidden" name="token" value="'.newToken().
'">';
432 print
'<input type="hidden" name="action" value="add">';
433 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
437 print
'<table class="border centpercent">';
441 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
'Draft').
'</td></tr>';
447 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
449 print $soc->getNomUrl(1);
450 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
452 $arrayoutstandingbills = $soc->getOutstandingBills();
453 $outstandingBills = $arrayoutstandingbills[
'opened'];
454 print
' ('.$langs->trans(
'CurrentOutstandingBill').
': ';
455 print
price($outstandingBills,
'', $langs, 0, 0, -1, $conf->currency);
456 if ($soc->outstanding_limit !=
'') {
457 if ($outstandingBills > $soc->outstanding_limit) {
458 print
img_warning($langs->trans(
"OutstandingBillReached"));
460 print
' / '.price($soc->outstanding_limit,
'', $langs, 0, 0, -1, $conf->currency);
465 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
467 $filter =
'((s.client:IN:1,2,3) AND (status:=:1))';
468 print $form->select_company($soc->id,
'socid', $filter,
'SelectThirdParty', 0, 0,
null, 0,
'minwidth300');
471 print
'<script type="text/javascript">
472 $(document).ready(function() {
473 $("#socid").change(function() {
474 console.log("We have changed the company - Reload page");
475 var socid = $(this).val();
476 var fac_rec = $(\'#fac_rec\').val();
478 $("input[name=action]").val("create");
479 $("form[name=add]").submit();
484 print
' <a href="'.DOL_URL_ROOT.
'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span></a>';
491 print
'<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans(
"Date").
'</td><td>';
492 print $form->selectDate($donation_date ? $donation_date : -1,
'',
'',
'',
'',
"add", 1, 1);
496 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>';
499 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PublicDonation").
"</td><td>";
500 print $form->selectyesno(
"public", $public_donation, 1);
501 print
"</td></tr>\n";
504 print
"<tr>".
'<td>'.$langs->trans(
"Company").
'</td><td><input type="text" name="societe" value="'.
dol_escape_htmltag(
GETPOST(
"societe")).
'" class="maxwidth200"></td></tr>';
505 print
"<tr>".
'<td>'.$langs->trans(
"Lastname").
'</td><td><input type="text" name="lastname" value="'.
dol_escape_htmltag(
GETPOST(
"lastname")).
'" class="maxwidth200"></td></tr>';
506 print
"<tr>".
'<td>'.$langs->trans(
"Firstname").
'</td><td><input type="text" name="firstname" value="'.
dol_escape_htmltag(
GETPOST(
"firstname")).
'" class="maxwidth200"></td></tr>';
507 print
"<tr>".
'<td>'.$langs->trans(
"Address").
'</td><td>';
508 print
'<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="3">'.dol_escape_htmltag(
GETPOST(
"address",
"alphanohtml"), 0, 1).
'</textarea></td></tr>';
511 print
'<tr><td>'.$langs->trans(
"Zip").
' / '.$langs->trans(
"Town").
'</td><td>';
512 print $formcompany->select_ziptown((GETPOSTISSET(
"zipcode") ?
GETPOST(
"zipcode") : $object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
514 print $formcompany->select_ziptown((GETPOSTISSET(
"town") ?
GETPOST(
"town") : $object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
518 print
'<tr><td><label for="selectcountry_id">'.$langs->trans(
'Country').
'</label></td><td class="maxwidthonsmartphone">';
519 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"').$form->select_country(
GETPOST(
'country_id') !=
'' ?
GETPOST(
'country_id') : $object->country_id);
521 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
525 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>';
529 print
"<tr><td>".$langs->trans(
"PaymentMode").
"</td><td>\n";
530 $selected =
GETPOST(
'modepayment',
'int');
531 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
532 print $form->select_types_paiements($selected,
'modepayment',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
533 print
"</td></tr>\n";
537 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
539 if (!isset($note_public)) {
540 $note_public = $object->getDefaultCreateValueFor(
'note_public');
542 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
543 print $doleditor->Create(1);
547 if (empty($user->socid)) {
549 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
551 if (!isset($note_private)) {
552 $note_private = $object->getDefaultCreateValueFor(
'note_private');
554 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
555 print $doleditor->Create(1);
559 if (isModEnabled(
'project')) {
560 print
"<tr><td>".$langs->trans(
"Project").
"</td><td>";
561 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
562 print $formproject->select_projects(-1, $projectid,
'fk_project', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
563 print
"</td></tr>\n";
567 $parameters = array();
568 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
569 print $hookmanager->resPrint;
570 if (empty($reshook)) {
571 print $object->showOptionals($extrafields,
'create', $parameters);
579 print $form->buttonsSaveCancel();
591if (!empty($id) && $action ==
'edit') {
592 $result = $object->fetch($id);
597 $result = $object->fetch_optionals();
606 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
607 print
'<input type="hidden" name="token" value="'.newToken().
'">';
608 print
'<input type="hidden" name="action" value="update">';
609 print
'<input type="hidden" name="rowid" value="'.$object->id.
'">';
610 print
'<input type="hidden" name="amount" value="'.$object->amount.
'">';
611 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
613 print
dol_get_fiche_head($head, $hselected, $langs->trans(
"Donation"), 0,
'donation');
615 print
'<table class="border centpercent">';
618 print
'<tr><td>'.$langs->trans(
"Ref").
'</td><td colspan="2">';
619 print $object->getNomUrl();
624 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
625 print $form->selectDate($object->date,
'',
'',
'',
'',
"update");
629 if ($object->statut == 0) {
630 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>';
632 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td>';
633 print
price($object->amount, 0, $langs, 0, 0, -1, $conf->currency);
637 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PublicDonation").
"</td><td>";
638 print $form->selectyesno(
"public", $object->public, 1);
645 print
'<tr><td>'.$langs->trans(
"ThirdParty").
'</td><td colspan="2">';
646 if ($object->socid > 0) {
647 $result = $company->fetch($object->socid);
648 print $company->getNomUrl(1);
652 $langs->load(
"companies");
653 print
'<tr><td>'.$langs->trans(
"Company").
'</td><td><input type="text" name="societe" class="maxwidth200" value="'.
dol_escape_htmltag($object->societe).
'"></td></tr>';
654 print
'<tr><td>'.$langs->trans(
"Lastname").
'</td><td><input type="text" name="lastname" class="maxwidth200" value="'.
dol_escape_htmltag($object->lastname).
'"></td></tr>';
655 print
'<tr><td>'.$langs->trans(
"Firstname").
'</td><td><input type="text" name="firstname" class="maxwidth200" value="'.
dol_escape_htmltag($object->firstname).
'"></td></tr>';
656 print
'<tr><td>'.$langs->trans(
"Address").
'</td><td>';
657 print
'<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
dol_escape_htmltag($object->address, 0, 1).
'</textarea></td></tr>';
660 print
'<tr><td>'.$langs->trans(
"Zip").
' / '.$langs->trans(
"Town").
'</td><td>';
661 print $formcompany->select_ziptown((GETPOSTISSET(
"zipcode") ? GETPOSTISSET(
"zipcode") : $object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
663 print $formcompany->select_ziptown((GETPOSTISSET(
"town") ?
GETPOST(
"town") : $object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
667 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Country').
'</td><td>';
668 print $form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code),
'country_id');
670 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
674 print
"<tr>".
'<td>'.$langs->trans(
"EMail").
'</td><td><input type="text" name="email" class="maxwidth200" value="'.
dol_escape_htmltag($object->email).
'"></td></tr>';
677 print
"<tr><td>".$langs->trans(
"PaymentMode").
"</td><td>\n";
678 if ($object->mode_reglement_id) {
679 $selected = $object->mode_reglement_id;
683 $form->select_types_paiements($selected,
'modepayment',
'CRDT', 0, 1);
684 print
"</td></tr>\n";
687 print
"<tr>".
'<td>'.$langs->trans(
"Status").
'</td><td>'.$object->getLibStatut(4).
'</td></tr>';
690 if (isModEnabled(
'project')) {
693 $langs->load(
'projects');
694 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
695 $formproject->select_projects(-1, $object->fk_project,
'fk_project', 0, 0, 1, 1, 0, 0, 0,
'', 0, 0,
'maxwidth500');
700 $parameters = array();
701 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
702 print $hookmanager->resPrint;
703 if (empty($reshook)) {
704 print $object->showOptionals($extrafields,
'edit', $parameters);
711 print $form->buttonsSaveCancel();
723if (!empty($id) && $action !=
'edit') {
726 if ($action ==
'delete') {
727 $text = $langs->trans(
"ConfirmDeleteADonation");
728 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"DeleteADonation"), $text,
"confirm_delete",
'',
'', 1);
731 $result = $object->fetch($id);
736 $result = $object->fetch_optionals();
745 print
dol_get_fiche_head($head, $hselected, $langs->trans(
"Donation"), -1,
'donation');
750 $linkback =
'<a href="'.DOL_URL_ROOT.
'/don/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
752 $morehtmlref =
'<div class="refidno">';
754 if (isModEnabled(
'project')) {
755 $langs->load(
"projects");
756 $morehtmlref .= $langs->trans(
'Project').
' ';
757 if ($user->hasRight(
'don',
'creer')) {
758 if ($action !=
'classify') {
759 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
761 if ($action ==
'classify') {
763 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
764 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
765 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
766 $morehtmlref .=
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
767 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', 0, 0, 1, 0, 1, 0, 0,
'', 1, 0,
'maxwidth500');
768 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
769 $morehtmlref .=
'</form>';
771 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
774 if (!empty($object->fk_project)) {
776 $proj->fetch($object->fk_project);
777 $morehtmlref .=
' : '.$proj->getNomUrl(1);
779 $morehtmlref .=
' - '.$proj->title;
786 $morehtmlref .=
'</div>';
789 dol_banner_tab($object,
'rowid', $linkback, 1,
'rowid',
'ref', $morehtmlref);
792 print
'<div class="fichecenter">';
793 print
'<div class="fichehalfleft">';
794 print
'<div class="underbanner clearboth"></div>';
796 print
'<table class="border tableforfield" width="100%">';
799 print
'<tr><td class="titlefield">'.$langs->trans(
"Date").
'</td><td colspan="2">';
803 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td colspan="2">';
804 print
price($object->amount, 0, $langs, 0, 0, -1, $conf->currency);
807 print
'<tr><td>'.$langs->trans(
"PublicDonation").
'</td><td colspan="2">';
808 print
yn($object->public);
814 print
'<tr><td>'.$langs->trans(
"ThirdParty").
'</td><td colspan="2">';
815 if ($object->socid > 0) {
816 $result = $company->fetch($object->socid);
817 print $company->getNomUrl(1);
821 print
'<tr><td>'.$langs->trans(
"Company").
'</td><td colspan="2">'.$object->societe.
'</td></tr>';
822 print
'<tr><td>'.$langs->trans(
"Lastname").
'</td><td colspan="2">'.$object->lastname.
'</td></tr>';
823 print
'<tr><td>'.$langs->trans(
"Firstname").
'</td><td colspan="2">'.$object->firstname.
'</td></tr>';
827 print
"<tr><td>".$langs->trans(
"PaymentMode").
"</td><td>";
828 $form->form_modes_reglement(
null, $object->mode_reglement_id,
'none');
829 print
"</td></tr>\n";
833 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
838 print
'<div class="fichehalfright">';
843 $sql =
"SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,";
844 $sql .=
"c.code as type_code,c.libelle as paiement_type";
845 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_donation as p";
846 $sql .=
", ".MAIN_DB_PREFIX.
"c_paiement as c ";
847 $sql .=
", ".MAIN_DB_PREFIX.
"don as d";
848 $sql .=
" WHERE d.rowid = ".((int) $id);
849 $sql .=
" AND p.fk_donation = d.rowid";
850 $sql .=
" AND d.entity IN (".getEntity(
'donation').
")";
851 $sql .=
" AND p.fk_typepayment = c.id";
852 $sql .=
" ORDER BY dp";
855 $resql = $db->query($sql);
857 $num = $db->num_rows($resql);
861 print
'<table class="noborder paymenttable centpercent">';
862 print
'<tr class="liste_titre">';
863 print
'<td>'.$langs->trans(
"RefPayment").
'</td>';
864 print
'<td>'.$langs->trans(
"Date").
'</td>';
865 print
'<td>'.$langs->trans(
"Type").
'</td>';
866 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
870 $objp = $db->fetch_object($resql);
872 print
'<tr class="oddeven"><td>';
873 print
'<a href="'.DOL_URL_ROOT.
'/don/payment/card.php?id='.$objp->rowid.
'">'.
img_object($langs->trans(
"Payment"),
"payment").
' '.$objp->rowid.
'</a></td>';
874 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
875 $labeltype = ($langs->trans(
"PaymentType".$objp->type_code) !=
"PaymentType".$objp->type_code) ? $langs->trans(
"PaymentType".$objp->type_code) : $objp->paiement_type;
876 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
877 print
'<td class="right">'.price($objp->amount).
"</td>\n";
879 $totalpaid += $objp->amount;
883 if ($object->paid == 0) {
884 print
"<tr><td colspan=\"3\" class=\"right\">".$langs->trans(
"AlreadyPaid").
" :</td><td class=\"right\">".
price($totalpaid).
"</td></tr>\n";
885 print
"<tr><td colspan=\"3\" class=\"right\">".$langs->trans(
"AmountExpected").
" :</td><td class=\"right\">".
price($object->amount).
"</td></tr>\n";
887 $remaintopay = $object->amount - $totalpaid;
889 print
"<tr><td colspan=\"3\" class=\"right\">".$langs->trans(
"RemainderToPay").
" :</td>";
890 print
'<td class="right'.(!empty($resteapayeraffiche) ?
' amountremaintopay' :
'').
'">'.
price($remaintopay).
"</td></tr>\n";
901 print
'<div class="clearboth"></div>';
905 $remaintopay = $object->amount - $totalpaid;
909 print
'<div class="tabsAction">';
910 $parameters = array();
911 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
912 if (empty($reshook)) {
914 if ($permissiontoadd && $object->statut == $object::STATUS_CANCELED) {
915 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_reopen&confirm=yes&token='.newToken().
'">'.$langs->trans(
"ReOpen").
'</a>';
918 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>';
920 if ($object->statut == $object::STATUS_DRAFT) {
921 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>';
924 if (($object->statut == $object::STATUS_DRAFT || $object->statut == $object::STATUS_VALIDATED) && $totalpaid == 0 && $object->paid == 0) {
925 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>";
929 if ($object->statut == $object::STATUS_VALIDATED && $object->paid == 0 && $user->hasRight(
'don',
'creer')) {
930 if ($remaintopay == 0) {
931 print
'<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPayment').
'</span></div>';
933 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>';
938 if ($object->statut == $object::STATUS_VALIDATED && round($remaintopay) == 0 && $object->paid == 0 && $user->hasRight(
'don',
'creer')) {
939 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>";
943 if ($user->hasRight(
'don',
'supprimer')) {
944 if ($object->statut == $object::STATUS_CANCELED || $object->statut == $object::STATUS_DRAFT) {
945 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.
'&action=delete&token='.newToken().
'">'.$langs->trans(
"Delete").
"</a></div>";
947 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"CantRemovePaymentWithOneInvoicePaid").
'">'.$langs->trans(
"Delete").
"</a></div>";
950 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Delete").
"</a></div>";
957 print
'<div class="fichecenter"><div class="fichehalfleft">';
964 $urlsource = $_SERVER[
'PHP_SELF'].
'?rowid='.$object->id;
965 $genallowed = (($object->paid == 0 || $user->admin) && $user->rights->don->lire);
966 $delallowed = $user->rights->don->creer;
968 print $formfile->showdocuments(
'donation', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf);
971 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'don'));
972 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
975 $useonlinepayment = (isModEnabled(
'paypal') || isModEnabled(
'stripe') || isModEnabled(
'paybox'));
977 if ($useonlinepayment) {
978 print
'<br><!-- Link to pay -->'.
"\n";
979 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
980 print showOnlinePaymentUrl(
'donation', $object->ref).
'<br>';
983 print
'</div><div class="fichehalfright">';
985 print
'</div></div>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
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_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier 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...
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.