27require
'../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
35$action =
GETPOST(
'action',
'aZ09');
41if ($user->socid > 0) {
42 $socid = $user->socid;
52if ($action ==
'add_payment') {
56 $loc = DOL_URL_ROOT.
'/don/card.php?rowid='.$chid;
57 header(
"Location: ".$loc);
63 if (!(
GETPOST(
"paymenttype") > 0)) {
64 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode")),
null,
'errors');
67 if ($datepaid ==
'') {
68 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date")),
null,
'errors');
71 if (isModEnabled(
"bank") && !(
GETPOSTINT(
"accountid") > 0)) {
72 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountToCredit")),
null,
'errors');
80 foreach ($_POST as $key => $value) {
81 if (substr($key, 0, 7) ==
'amount_') {
82 $other_chid = substr($key, 7);
87 if (count($amounts) <= 0) {
89 $errmsg =
'ErrorNoPaymentDefined';
98 $payment->chid = $chid;
99 $payment->datep = $datepaid;
100 $payment->amounts = $amounts;
101 $payment->paymenttype =
GETPOSTINT(
"paymenttype");
102 $payment->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
103 $payment->note_public =
GETPOST(
"note_public",
'restricthtml');
106 $paymentid = $payment->create($user);
107 if ($paymentid < 0) {
108 $errmsg = $payment->error;
115 $result = $payment->addPaymentToBank($user,
'payment_donation',
'(DonationPayment)',
GETPOSTINT(
'accountid'),
'',
'');
116 if (!($result > 0)) {
117 $errmsg = $payment->error;
125 $loc = DOL_URL_ROOT.
'/don/card.php?rowid='.$chid;
126 header(
'Location: '.$loc);
142$form =
new Form($db);
143$title = $langs->trans(
"Payment");
144llxHeader(
'', $title,
'',
'', 0, 0,
'',
'',
'',
'mod-donation page-payment');
147$sql =
"SELECT sum(p.amount) as total";
148$sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_donation as p";
149$sql .=
" WHERE p.fk_donation = ".((int) $chid);
150$resql = $db->query($sql);
152 $obj = $db->fetch_object($resql);
153 $sumpaid = $obj->total;
159if ($action ==
'create') {
166 if (!empty($conf->use_javascript_ajax)) {
167 print
"\n".
'<script type="text/javascript">';
169 print
' $(document).ready(function () {';
170 print
' $(".AutoFillAmount").on(\'click touchstart\', function(){
171 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
175 print
' </script>'.
"\n";
178 print
'<form name="add_payment" action="'.$_SERVER[
'PHP_SELF'].
'" method="post">';
179 print
'<input type="hidden" name="token" value="'.newToken().
'">';
180 print
'<input type="hidden" name="rowid" value="'.$chid.
'">';
181 print
'<input type="hidden" name="chid" value="'.$chid.
'">';
182 print
'<input type="hidden" name="action" value="add_payment">';
186 print
'<table class="border centpercent tableforfieldcreate">';
188 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td colspan="2">';
191 print $form->selectDate($datepayment,
'', 0, 0, 0,
"add_payment", 1, 1, 0,
'',
'',
$object->date,
'', 1, $langs->trans(
"DonationDate"));
195 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td colspan="2">';
196 $form->select_types_paiements(GETPOSTISSET(
"paymenttype") ?
GETPOST(
"paymenttype") :
$object->fk_typepayment,
"paymenttype");
201 print
'<td class="fieldrequired">'.$langs->trans(
'AccountToCredit').
'</td>';
202 print
'<td colspan="2">';
203 $form->select_comptes(GETPOSTISSET(
"accountid") ?
GETPOST(
"accountid") :
"0",
"accountid", 0,
'', 2);
207 print
'<tr><td>'.$langs->trans(
'Numero');
208 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
210 print
'<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST(
'num_payment').
'"></td></tr>'.
"\n";
213 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
214 print
'<td class="tdtop" colspan="2"><textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_3.
'"></textarea></td>';
228 print
'<table class="noborder centpercent">';
229 print
'<tr class="liste_titre">';
230 print
'<td>'.$langs->trans(
"Donation").
'</td>';
231 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
232 print
'<td class="right">'.$langs->trans(
"AlreadyPaid").
'</td>';
233 print
'<td class="right">'.$langs->trans(
"RemainderToPay").
'</td>';
234 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
243 print
'<tr class="oddeven">';
245 print
'<td>'.$object->getNomUrl(1).
"</td>";
247 print
'<td class="right">'.price($objp->amount).
"</td>";
249 print
'<td class="right">'.price($sumpaid).
"</td>";
251 print
'<td class="right">'.price($objp->amount - $sumpaid).
"</td>";
253 print
'<td class="center">';
254 if ($sumpaid < $objp->amount) {
255 $namef =
"amount_".$objp->id;
256 if (!empty($conf->use_javascript_ajax)) {
257 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmount' data-rowname='".$namef.
"' data-value='".
price($objp->amount - $sumpaid).
"'");
259 print
'<input type="text" size="8" name="'.$namef.
'">';
285 print $form->buttonsSaveCancel();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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)
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.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.