Go to the documentation of this file.
25 require
'../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
30 $langs->load(
"bills");
32 $chid =
GETPOST(
"rowid",
'int');
33 $action =
GETPOST(
'action',
'aZ09');
39 if ($user->socid > 0) {
40 $socid = $user->socid;
43 $object =
new Don($db);
50 if ($action ==
'add_payment') {
54 $loc = DOL_URL_ROOT.
'/don/card.php?rowid='.$chid;
55 header(
"Location: ".$loc);
61 if (!(
GETPOST(
"paymenttype") > 0)) {
62 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode")),
null,
'errors');
65 if ($datepaid ==
'') {
66 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date")),
null,
'errors');
69 if (!empty($conf->banque->enabled) && !(
GETPOST(
"accountid",
'int') > 0)) {
70 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountToCredit")),
null,
'errors');
78 foreach ($_POST as $key => $value) {
79 if (substr($key, 0, 7) ==
'amount_') {
80 $other_chid = substr($key, 7);
85 if (count($amounts) <= 0) {
87 $errmsg =
'ErrorNoPaymentDefined';
96 $payment->chid = $chid;
97 $payment->datepaid = $datepaid;
98 $payment->amounts = $amounts;
99 $payment->paymenttype =
GETPOST(
"paymenttype",
'int');
100 $payment->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
101 $payment->note_public =
GETPOST(
"note_public",
'restricthtml');
104 $paymentid = $payment->create($user);
105 if ($paymentid < 0) {
106 $errmsg = $payment->error;
113 $result = $payment->addPaymentToBank($user,
'payment_donation',
'(DonationPayment)',
GETPOST(
'accountid',
'int'),
'',
'');
114 if (!($result > 0)) {
115 $errmsg = $payment->error;
123 $loc = DOL_URL_ROOT.
'/don/card.php?rowid='.$chid;
124 header(
'Location: '.$loc);
145 $sql =
"SELECT sum(p.amount) as total";
146 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_donation as p";
147 $sql .=
" WHERE p.fk_donation = ".((int) $chid);
148 $resql = $db->query($sql);
150 $obj = $db->fetch_object(
$resql);
151 $sumpaid = $obj->total;
157 if ($action ==
'create') {
158 $object->fetch($chid);
160 $total = $object->amount;
164 if (!empty($conf->use_javascript_ajax)) {
165 print
"\n".
'<script type="text/javascript">';
167 print
' $(document).ready(function () {';
168 print
' $(".AutoFillAmout").on(\'click touchstart\', function(){
169 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
173 print
' </script>'.
"\n";
176 print
'<form name="add_payment" action="'.$_SERVER[
'PHP_SELF'].
'" method="post">';
177 print
'<input type="hidden" name="token" value="'.newToken().
'">';
178 print
'<input type="hidden" name="rowid" value="'.$chid.
'">';
179 print
'<input type="hidden" name="chid" value="'.$chid.
'">';
180 print
'<input type="hidden" name="action" value="add_payment">';
184 print
'<table class="border centpercent tableforfieldcreate">';
186 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td colspan="2">';
188 $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (
GETPOST(
"remonth") ? $datepaid : -1) : 0;
189 print
$form->selectDate($datepayment,
'', 0, 0, 0,
"add_payment", 1, 1, 0,
'',
'', $object->date,
'', 1, $langs->trans(
"DonationDate"));
193 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td colspan="2">';
194 $form->select_types_paiements(
GETPOSTISSET(
"paymenttype") ?
GETPOST(
"paymenttype") : $object->paymenttype,
"paymenttype");
199 print
'<td class="fieldrequired">'.$langs->trans(
'AccountToCredit').
'</td>';
200 print
'<td colspan="2">';
201 $form->select_comptes(
GETPOSTISSET(
"accountid") ?
GETPOST(
"accountid") : $object->accountid,
"accountid", 0,
'', 2);
205 print
'<tr><td>'.$langs->trans(
'Numero');
206 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
208 print
'<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST(
'num_payment').
'"></td></tr>'.
"\n";
211 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
212 print
'<td class="tdtop" colspan="2"><textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_3.
'"></textarea></td>';
226 print
'<table class="noborder centpercent">';
227 print
'<tr class="liste_titre">';
228 print
'<td>'.$langs->trans(
"Donation").
'</td>';
229 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
230 print
'<td class="right">'.$langs->trans(
"AlreadyPaid").
'</td>';
231 print
'<td class="right">'.$langs->trans(
"RemainderToPay").
'</td>';
232 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
241 print
'<tr class="oddeven">';
243 print
'<td>'.$object->getNomUrl(1).
"</td>";
245 print
'<td class="right">'.price($objp->amount).
"</td>";
247 print
'<td class="right">'.price($sumpaid).
"</td>";
249 print
'<td class="right">'.price($objp->amount - $sumpaid).
"</td>";
251 print
'<td class="center">';
252 if ($sumpaid < $objp->amount) {
253 $namef =
"amount_".$objp->id;
254 if (!empty($conf->use_javascript_ajax)) {
255 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmout' data-rowname='".$namef.
"' data-value='".
price($objp->amount - $sumpaid).
"'");
257 print
'<input type="text" size="8" name="'.$namef.
'">';
283 print
$form->buttonsSaveCancel();
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage payments of donations.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Class to manage donations.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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...
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.