27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/paymentvat.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
33$langs->loadLangs(array(
"banks",
"bills"));
36$action =
GETPOST(
'action',
'alpha');
43if ($user->socid > 0) {
44 $socid = $user->socid;
52if ($action ==
'add_payment' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) {
56 $loc = DOL_URL_ROOT.
'/compta/tva/card.php?id='.$chid;
57 header(
"Location: ".$loc);
63 if (!(
GETPOST(
"paiementtype",
'int') > 0)) {
64 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode")),
null,
'errors');
68 if ($datepaye ==
'') {
69 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date")),
null,
'errors');
73 if (isModEnabled(
"banque") && !(
GETPOST(
"accountid",
'int') > 0)) {
74 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountToDebit")),
null,
'errors');
80 foreach ($_POST as $key => $value) {
81 if (substr($key, 0, 7) ==
'amount_') {
82 $other_chid = substr($key, 7);
87 if (empty($amounts[key($amounts)])) {
89 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
101 $paiement->chid = $chid;
102 $paiement->datepaye = $datepaye;
103 $paiement->amounts = $amounts;
104 $paiement->paiementtype =
GETPOST(
"paiementtype",
'alphanohtml');
105 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
106 $paiement->note = (string)
GETPOST(
"note",
'restricthtml');
107 $paiement->note_private = (string)
GETPOST(
"note",
'restricthtml');
110 $paymentid = $paiement->create($user, (
GETPOST(
'closepaidvat') ==
'on' ? 1 : 0));
111 if ($paymentid < 0) {
119 $result = $paiement->addPaymentToBank($user,
'payment_vat',
'(VATPayment)',
GETPOST(
'accountid',
'int'),
'',
'');
120 if (!($result > 0)) {
129 $loc = DOL_URL_ROOT.
'/compta/tva/card.php?id='.$chid;
130 header(
'Location: '.$loc);
146$form =
new Form($db);
150if ($action ==
'create') {
153 $tva->accountid = $tva->fk_account ? $tva->fk_account : $tva->accountid;
154 $tva->paiementtype = $tva->type_payment;
156 $total = $tva->amount;
157 if (!empty($conf->use_javascript_ajax)) {
158 print
"\n".
'<script type="text/javascript">';
161 print
' $(document).ready(function () {';
162 print
' $(".AutoFillAmount").on(\'click touchstart\', function(){
163 var amount = $(this).data("value");
164 document.getElementById($(this).data(\'rowid\')).value = amount ;
168 print
' </script>'.
"\n";
174 print
'<form name="add_payment" action="'.$_SERVER[
'PHP_SELF'].
'" method="post">';
175 print
'<input type="hidden" name="token" value="'.newToken().
'">';
176 print
'<input type="hidden" name="id" value="'.$chid.
'">';
177 print
'<input type="hidden" name="chid" value="'.$chid.
'">';
178 print
'<input type="hidden" name="action" value="add_payment">';
182 print
'<table class="border centpercent">';
184 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td><a href="'.DOL_URL_ROOT.
'/compta/tva/card.php?id='.$chid.
'">'.$chid.
'</a></td></tr>';
186 print
'<tr><td>'.$langs->trans(
"Period").
"</td><td>".
dol_print_date($tva->datev,
'day').
"</td></tr>\n";
187 print
'<tr><td>'.$langs->trans(
"Label").
'</td><td>'.$tva->label.
"</td></tr>\n";
191 $sql =
"SELECT sum(p.amount) as total";
192 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_vat as p";
193 $sql .=
" WHERE p.fk_tva = ".((int) $chid);
194 $resql = $db->query($sql);
196 $obj = $db->fetch_object($resql);
197 $sumpaid = $obj->total;
203 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
206 print $form->selectDate($datepayment,
'',
'',
'',
'',
"add_payment", 1, 1);
210 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
211 print $form->select_types_paiements(GETPOSTISSET(
"paiementtype") ?
GETPOST(
"paiementtype",
"int") : $tva->paiementtype,
"paiementtype",
'', 0, 1, 0, 0, 1,
'maxwidth500 widthcentpercentminusx', 1);
216 print
'<td class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</td>';
218 print
img_picto(
'',
'bank_account',
'pictofixedwidth');
219 $form->select_comptes(
GETPOST(
"accountid",
"int") ?
GETPOST(
"accountid",
"int") : $tva->accountid,
"accountid", 0,
'', 1,
'', 0,
'maxwidth500 widthcentpercentminusx');
223 print
'<tr><td>'.$langs->trans(
'Numero');
224 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
226 print
'<td><input name="num_payment" type="text" value="'.GETPOST(
'num_payment',
'alphanohtml').
'"></td></tr>'.
"\n";
229 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
230 print
'<td class="tdtop"><textarea name="note" class="quatrevingtpercent" wrap="soft" rows="'.ROWS_3.
'"></textarea></td>';
243 print
'<div class="div-table-responsive-no-min">';
244 print
'<table class="noborder centpercent">';
245 print
'<tr class="liste_titre">';
247 print
'<td class="left">'.$langs->trans(
"DateDue").
'</td>';
248 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
249 print
'<td class="right">'.$langs->trans(
"AlreadyPaid").
'</td>';
250 print
'<td class="right">'.$langs->trans(
"RemainderToPay").
'</td>';
251 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
260 print
'<tr class="oddeven">';
262 if ($objp->datev > 0) {
263 print
'<td class="left">'.dol_print_date($objp->datev,
'day').
'</td>'.
"\n";
265 print
'<td class="center"><b>!!!</b></td>'.
"\n";
268 print
'<td class="right nowraponall"><span class="amount">'.price($objp->amount).
"</span></td>";
270 print
'<td class="right nowraponall"><span class="amount">'.price($sumpaid).
"</span></td>";
272 print
'<td class="right nowraponall"><span class="amount">'.price($objp->amount - $sumpaid).
"</span></td>";
274 print
'<td class="center">';
276 if ($sumpaid != $objp->amount) {
277 $namef =
"amount_".$objp->id;
278 $nameRemain =
"remain_".$objp->id;
283 $remaintopay = $objp->amount - $sumpaid;
284 print
'<input type=hidden class="sum_remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
285 print
'<input type="text" class="right width75" name="'.$namef.
'" id="'.$namef.
'" value="'.$remaintopay.
'">';
292 $total += $objp->total;
293 $total_ttc += $objp->total_ttc;
294 $totalrecu += $objp->amount;
299 print
'<tr class="oddeven">';
300 print
'<td colspan="2" class="left">'.$langs->trans(
"Total").
':</td>';
301 print
'<td class="right"><b>'.price($total_ttc).
'</b></td>';
302 print
'<td class="right"><b>'.price($totalrecu).
'</b></td>';
303 print
'<td class="right"><b>'.price($total_ttc - $totalrecu).
'</b></td>';
304 print
'<td align="center"> </td>';
312 print
'<br><div class="center"><input type="checkbox" checked name="closepaidvat"> '.$langs->trans(
"ClosePaidVATAutomatically");
313 print
'<br><input type="submit" class="button" name="save" value="'.$langs->trans(
'ToMakePayment').
'">';
314 print
' ';
315 print
'<input type="submit" class="button" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage payments of social contributions.
Put here description of your class.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.