26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/paymentvat.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
32 $langs->loadLangs(array(
"banks",
"bills"));
35 $action =
GETPOST(
'action',
'alpha');
42 if ($user->socid > 0) {
43 $socid = $user->socid;
51 if ($action ==
'add_payment' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) {
55 $loc = DOL_URL_ROOT.
'/compta/tva/card.php?id='.$chid;
56 header(
"Location: ".$loc);
62 if (!(
GETPOST(
"paiementtype",
'int') > 0)) {
63 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode")),
null,
'errors');
67 if ($datepaye ==
'') {
68 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date")),
null,
'errors');
73 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountToDebit")),
null,
'errors');
79 foreach ($_POST as $key => $value) {
80 if (substr($key, 0, 7) ==
'amount_') {
81 $other_chid = substr($key, 7);
86 if (empty($amounts[key($amounts)])) {
88 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
100 $paiement->chid = $chid;
101 $paiement->datepaye = $datepaye;
102 $paiement->amounts = $amounts;
103 $paiement->paiementtype =
GETPOST(
"paiementtype",
'alphanohtml');
104 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
105 $paiement->note = (string)
GETPOST(
"note",
'restricthtml');
106 $paiement->note_private = (string)
GETPOST(
"note",
'restricthtml');
109 $paymentid = $paiement->create($user, (
GETPOST(
'closepaidvat') ==
'on' ? 1 : 0));
110 if ($paymentid < 0) {
118 $result = $paiement->addPaymentToBank($user,
'payment_vat',
'(VATPayment)',
GETPOST(
'accountid',
'int'),
'',
'');
119 if (!($result > 0)) {
128 $loc = DOL_URL_ROOT.
'/compta/tva/card.php?id='.$chid;
129 header(
'Location: '.$loc);
149 if ($action ==
'create') {
152 $tva->accountid = $tva->fk_account ? $tva->fk_account : $tva->accountid;
153 $tva->paiementtype = $tva->type_payment;
155 $total = $tva->amount;
156 if (!empty($conf->use_javascript_ajax)) {
157 print
"\n".
'<script type="text/javascript">';
160 print
' $(document).ready(function () {';
161 print
' $(".AutoFillAmount").on(\'click touchstart\', function(){
162 var amount = $(this).data("value");
163 document.getElementById($(this).data(\'rowid\')).value = amount ;
167 print
' </script>'.
"\n";
173 print
'<form name="add_payment" action="'.$_SERVER[
'PHP_SELF'].
'" method="post">';
174 print
'<input type="hidden" name="token" value="'.newToken().
'">';
175 print
'<input type="hidden" name="id" value="'.$chid.
'">';
176 print
'<input type="hidden" name="chid" value="'.$chid.
'">';
177 print
'<input type="hidden" name="action" value="add_payment">';
181 print
'<table class="border centpercent">';
183 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>';
185 print
'<tr><td>'.$langs->trans(
"Period").
"</td><td>".
dol_print_date($tva->datev,
'day').
"</td></tr>\n";
186 print
'<tr><td>'.$langs->trans(
"Label").
'</td><td>'.$tva->label.
"</td></tr>\n";
190 $sql =
"SELECT sum(p.amount) as total";
191 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_vat as p";
192 $sql .=
" WHERE p.fk_tva = ".((int) $chid);
193 $resql = $db->query($sql);
195 $obj = $db->fetch_object(
$resql);
196 $sumpaid = $obj->total;
202 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
204 $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (
GETPOST(
"remonth",
'int') ? $datepaye : -1) : 0;
205 print
$form->selectDate($datepayment,
'',
'',
'',
'',
"add_payment", 1, 1);
209 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
210 $form->select_types_paiements(
GETPOSTISSET(
"paiementtype") ?
GETPOST(
"paiementtype",
"int") : $tva->paiementtype,
"paiementtype",
'', 0, 1, 0, 0, 1,
'maxwidth500 widthcentpercentminusx');
215 print
'<td class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</td>';
217 print
img_picto(
'',
'bank_account',
'pictofixedwidth');
218 $form->select_comptes(
GETPOST(
"accountid",
"int") ?
GETPOST(
"accountid",
"int") : $tva->accountid,
"accountid", 0,
'', 1,
'', 0,
'maxwidth500 widthcentpercentminusx');
222 print
'<tr><td>'.$langs->trans(
'Numero');
223 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
225 print
'<td><input name="num_payment" type="text" value="'.GETPOST(
'num_payment',
'alphanohtml').
'"></td></tr>'.
"\n";
228 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
229 print
'<td class="tdtop"><textarea name="note" class="quatrevingtpercent" wrap="soft" rows="'.ROWS_3.
'"></textarea></td>';
242 print
'<div class="div-table-responsive-no-min">';
243 print
'<table class="noborder centpercent">';
244 print
'<tr class="liste_titre">';
246 print
'<td class="left">'.$langs->trans(
"DateDue").
'</td>';
247 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
248 print
'<td class="right">'.$langs->trans(
"AlreadyPaid").
'</td>';
249 print
'<td class="right">'.$langs->trans(
"RemainderToPay").
'</td>';
250 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
259 print
'<tr class="oddeven">';
261 if ($objp->datev > 0) {
262 print
'<td class="left">'.dol_print_date($objp->datev,
'day').
'</td>'.
"\n";
264 print
'<td class="center"><b>!!!</b></td>'.
"\n";
267 print
'<td class="right nowraponall"><span class="amount">'.price($objp->amount).
"</span></td>";
269 print
'<td class="right nowraponall"><span class="amount">'.price($sumpaid).
"</span></td>";
271 print
'<td class="right nowraponall"><span class="amount">'.price($objp->amount - $sumpaid).
"</span></td>";
273 print
'<td class="center">';
275 if ($sumpaid <> $objp->amount) {
276 $namef =
"amount_".$objp->id;
277 $nameRemain =
"remain_".$objp->id;
282 $remaintopay = $objp->amount - $sumpaid;
283 print
'<input type=hidden class="sum_remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
284 print
'<input type="text" class="right width75" name="'.$namef.
'" id="'.$namef.
'" value="'.$remaintopay.
'">';
291 $total += $objp->total;
292 $total_ttc += $objp->total_ttc;
293 $totalrecu += $objp->amount;
298 print
'<tr class="oddeven">';
299 print
'<td colspan="2" class="left">'.$langs->trans(
"Total").
':</td>';
300 print
'<td class="right"><b>'.price($total_ttc).
'</b></td>';
301 print
'<td class="right"><b>'.price($totalrecu).
'</b></td>';
302 print
'<td class="right"><b>'.price($total_ttc - $totalrecu).
'</b></td>';
303 print
'<td align="center"> </td>';
311 print
'<br><div class="center"><input type="checkbox" checked name="closepaidvat"> '.$langs->trans(
"ClosePaidVATAutomatically");
312 print
'<br><input type="submit" class="button" name="save" value="'.$langs->trans(
'ToMakePayment').
'">';
313 print
' ';
314 print
'<input type="submit" class="button" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Class to manage payments of social contributions.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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)
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.
isModEnabled($module)
Is Dolibarr module enabled.
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.
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.
Put here description of your class.