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");
33 $action =
GETPOST(
'action',
'aZ09');
38 if ($user->socid > 0) {
39 $socid = $user->socid;
42 $object =
new Don($db);
49 if ($action ==
'add_payment')
55 $loc = DOL_URL_ROOT.
'/don/card.php?rowid='.$chid;
56 header(
"Location: ".$loc);
60 $datepaid =
dol_mktime(12, 0, 0, $_POST[
"remonth"], $_POST[
"reday"], $_POST[
"reyear"]);
62 if (!$_POST[
"paymenttype"] > 0)
64 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode")), null,
'errors');
69 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date")), null,
'errors');
72 if (!empty($conf->banque->enabled) && !$_POST[
"accountid"] > 0)
74 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountToCredit")), null,
'errors');
83 foreach ($_POST as $key => $value)
85 if (substr($key, 0, 7) ==
'amount_')
87 $other_chid = substr($key, 7);
88 $amounts[$other_chid] =
price2num($_POST[$key]);
92 if (count($amounts) <= 0)
95 $errmsg =
'ErrorNoPaymentDefined';
105 $payment->chid = $chid;
106 $payment->datepaid = $datepaid;
107 $payment->amounts = $amounts;
108 $payment->paymenttype =
GETPOST(
"paymenttype",
'int');
109 $payment->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
110 $payment->note_public =
GETPOST(
"note_public",
'restricthtml');
114 $paymentid = $payment->create($user);
117 $errmsg = $payment->error;
125 $result = $payment->addPaymentToBank($user,
'payment_donation',
'(DonationPayment)', $_POST[
'accountid'],
'',
'');
128 $errmsg = $payment->error;
137 $loc = DOL_URL_ROOT.
'/don/card.php?rowid='.$chid;
138 header(
'Location: '.$loc);
154 $form =
new Form($db);
159 $sql =
"SELECT sum(p.amount) as total";
160 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_donation as p";
161 $sql .=
" WHERE p.fk_donation = ".$chid;
162 $resql = $db->query($sql);
165 $obj = $db->fetch_object(
$resql);
166 $sumpaid = $obj->total;
172 if ($action ==
'create')
174 $object->fetch($chid);
176 $total = $object->amount;
180 if (!empty($conf->use_javascript_ajax))
182 print "\n".
'<script type="text/javascript" language="javascript">';
184 print ' $(document).ready(function () {';
185 print ' $(".AutoFillAmout").on(\'click touchstart\', function(){
186 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
190 print ' </script>'.
"\n";
193 print '<form name="add_payment" action="'.$_SERVER[
'PHP_SELF'].
'" method="post">';
194 print '<input type="hidden" name="token" value="'.newToken().
'">';
195 print '<input type="hidden" name="rowid" value="'.$chid.
'">';
196 print '<input type="hidden" name="chid" value="'.$chid.
'">';
197 print '<input type="hidden" name="action" value="add_payment">';
201 print '<table class="border centpercent tableforfieldcreate">';
203 print '<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td colspan="2">';
204 $datepaid =
dol_mktime(12, 0, 0, $_POST[
"remonth"], $_POST[
"reday"], $_POST[
"reyear"]);
205 $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST[
"remonth"]) ?-1 : $datepaid) : 0;
206 print $form->selectDate($datepayment,
'', 0, 0, 0,
"add_payment", 1, 1, 0,
'',
'', $object->date,
'', 1, $langs->trans(
"DonationDate"));
210 print '<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td colspan="2">';
211 $form->select_types_paiements(
GETPOSTISSET(
"paymenttype") ?
GETPOST(
"paymenttype") : $object->paymenttype,
"paymenttype");
216 print '<td class="fieldrequired">'.$langs->trans(
'AccountToCredit').
'</td>';
217 print '<td colspan="2">';
218 $form->select_comptes(
GETPOSTISSET(
"accountid") ?
GETPOST(
"accountid") : $object->accountid,
"accountid", 0,
'', 2);
222 print '<tr><td>'.$langs->trans(
'Numero');
223 print ' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
225 print '<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST(
'num_payment').
'"></td></tr>'.
"\n";
228 print '<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
229 print '<td class="tdtop" colspan="2"><textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_3.
'"></textarea></td>';
243 print '<table class="noborder centpercent">';
244 print '<tr class="liste_titre">';
245 print '<td>'.$langs->trans(
"Donation").
'</td>';
246 print '<td class="right">'.$langs->trans(
"Amount").
'</td>';
247 print '<td class="right">'.$langs->trans(
"AlreadyPaid").
'</td>';
248 print '<td class="right">'.$langs->trans(
"RemainderToPay").
'</td>';
249 print '<td class="center">'.$langs->trans(
"Amount").
'</td>';
259 print '<tr class="oddeven">';
261 print '<td>'.$object->getNomUrl(1).
"</td>";
263 print '<td class="right">'.price($objp->amount).
"</td>";
265 print '<td class="right">'.price($sumpaid).
"</td>";
267 print '<td class="right">'.price($objp->amount - $sumpaid).
"</td>";
269 print '<td class="center">';
270 if ($sumpaid < $objp->amount)
272 $namef =
"amount_".$objp->id;
273 if (!empty($conf->use_javascript_ajax))
274 print img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmout' data-rowname='".$namef.
"' data-value='".
price($objp->amount - $sumpaid).
"'");
275 print '<input type="text" size="8" name="'.$namef.
'">';
301 print '<br><div class="center">';
302 print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans(
"Save").
'">';
303 print ' ';
304 print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
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)
Class to manage payments of donations.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Class to manage donations.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_get_fiche_end($notab=0)
Return tab footer of a card.