26require
'../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
34$action =
GETPOST(
'action',
'aZ09');
40if ($user->socid > 0) {
41 $socid = $user->socid;
44$object =
new Don($db);
51if ($action ==
'add_payment') {
55 $loc = DOL_URL_ROOT.
'/don/card.php?rowid='.$chid;
56 header(
"Location: ".$loc);
62 if (!(
GETPOST(
"paymenttype") > 0)) {
63 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode")),
null,
'errors');
66 if ($datepaid ==
'') {
67 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date")),
null,
'errors');
70 if (isModEnabled(
"banque") && !(
GETPOST(
"accountid",
'int') > 0)) {
71 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountToCredit")),
null,
'errors');
79 foreach ($_POST as $key => $value) {
80 if (substr($key, 0, 7) ==
'amount_') {
81 $other_chid = substr($key, 7);
86 if (count($amounts) <= 0) {
88 $errmsg =
'ErrorNoPaymentDefined';
97 $payment->chid = $chid;
98 $payment->datep = $datepaid;
99 $payment->amounts = $amounts;
100 $payment->paymenttype =
GETPOST(
"paymenttype",
'int');
101 $payment->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
102 $payment->note_public =
GETPOST(
"note_public",
'restricthtml');
105 $paymentid = $payment->create($user);
106 if ($paymentid < 0) {
107 $errmsg = $payment->error;
114 $result = $payment->addPaymentToBank($user,
'payment_donation',
'(DonationPayment)',
GETPOST(
'accountid',
'int'),
'',
'');
115 if (!($result > 0)) {
116 $errmsg = $payment->error;
124 $loc = DOL_URL_ROOT.
'/don/card.php?rowid='.$chid;
125 header(
'Location: '.$loc);
141$form =
new Form($db);
146$sql =
"SELECT sum(p.amount) as total";
147$sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_donation as p";
148$sql .=
" WHERE p.fk_donation = ".((int) $chid);
149$resql = $db->query($sql);
151 $obj = $db->fetch_object($resql);
152 $sumpaid = $obj->total;
158if ($action ==
'create') {
159 $object->fetch($chid);
161 $total = $object->amount;
165 if (!empty($conf->use_javascript_ajax)) {
166 print
"\n".
'<script type="text/javascript">';
168 print
' $(document).ready(function () {';
169 print
' $(".AutoFillAmout").on(\'click touchstart\', function(){
170 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
174 print
' </script>'.
"\n";
177 print
'<form name="add_payment" action="'.$_SERVER[
'PHP_SELF'].
'" method="post">';
178 print
'<input type="hidden" name="token" value="'.newToken().
'">';
179 print
'<input type="hidden" name="rowid" value="'.$chid.
'">';
180 print
'<input type="hidden" name="chid" value="'.$chid.
'">';
181 print
'<input type="hidden" name="action" value="add_payment">';
185 print
'<table class="border centpercent tableforfieldcreate">';
187 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td colspan="2">';
189 $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (
GETPOST(
"remonth") ? $datepaid : -1) : 0;
190 print $form->selectDate($datepayment,
'', 0, 0, 0,
"add_payment", 1, 1, 0,
'',
'', $object->date,
'', 1, $langs->trans(
"DonationDate"));
194 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td colspan="2">';
195 $form->select_types_paiements(GETPOSTISSET(
"paymenttype") ?
GETPOST(
"paymenttype") : $object->fk_typepayment,
"paymenttype");
200 print
'<td class="fieldrequired">'.$langs->trans(
'AccountToCredit').
'</td>';
201 print
'<td colspan="2">';
202 $form->select_comptes(GETPOSTISSET(
"accountid") ?
GETPOST(
"accountid") :
"0",
"accountid", 0,
'', 2);
206 print
'<tr><td>'.$langs->trans(
'Numero');
207 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
209 print
'<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST(
'num_payment').
'"></td></tr>'.
"\n";
212 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
213 print
'<td class="tdtop" colspan="2"><textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_3.
'"></textarea></td>';
227 print
'<table class="noborder centpercent">';
228 print
'<tr class="liste_titre">';
229 print
'<td>'.$langs->trans(
"Donation").
'</td>';
230 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
231 print
'<td class="right">'.$langs->trans(
"AlreadyPaid").
'</td>';
232 print
'<td class="right">'.$langs->trans(
"RemainderToPay").
'</td>';
233 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
242 print
'<tr class="oddeven">';
244 print
'<td>'.$object->getNomUrl(1).
"</td>";
246 print
'<td class="right">'.price($objp->amount).
"</td>";
248 print
'<td class="right">'.price($sumpaid).
"</td>";
250 print
'<td class="right">'.price($objp->amount - $sumpaid).
"</td>";
252 print
'<td class="center">';
253 if ($sumpaid < $objp->amount) {
254 $namef =
"amount_".$objp->id;
255 if (!empty($conf->use_javascript_ajax)) {
256 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmout' data-rowname='".$namef.
"' data-value='".
price($objp->amount - $sumpaid).
"'");
258 print
'<input type="text" size="8" name="'.$namef.
'">';
284 print $form->buttonsSaveCancel();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage donations.
Class to manage payments of donations.
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.
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_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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.