dolibarr 18.0.6
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
5 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
29// Load Dolibarr environment
30require '../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
32require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php';
33require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
35if (isModEnabled("banque")) {
36 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
37}
38
39// Load translation files required by the page
40$langs->loadLangs(array('bills', 'banks', 'companies'));
41
42// Security check
43$id = GETPOST("id", 'int');
44$action = GETPOST('action', 'aZ09');
45$confirm = GETPOST('confirm');
46if ($user->socid) {
47 $socid = $user->socid;
48}
49// TODO ajouter regle pour restreindre acces paiement
50//$result = restrictedArea($user, 'facture', $id,'');
51
52$object = new PaymentVAT($db);
53if ($id > 0) {
54 $result = $object->fetch($id);
55 if (!$result) {
56 dol_print_error($db, 'Failed to get payment id '.$id);
57 }
58}
59
60
61/*
62 * Actions
63 */
64
65// Delete payment
66if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->charges->supprimer) {
67 $db->begin();
68
69 $result = $object->delete($user);
70 if ($result > 0) {
71 $db->commit();
72 header("Location: ".DOL_URL_ROOT."/compta/tva/payments.php?mode=tvaonly");
73 exit;
74 } else {
75 setEventMessages($object->error, $object->errors, 'errors');
76 $db->rollback();
77 }
78}
79
80// Validate social contribution
81/*
82if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->charges->creer)
83{
84 $db->begin();
85
86 $result=$object->valide();
87
88 if ($result > 0)
89 {
90 $db->commit();
91
92 $factures=array(); // TODO Get all id of invoices linked to this payment
93 foreach($factures as $id)
94 {
95 $fac = new Facture($db);
96 $fac->fetch($id);
97
98 $outputlangs = $langs;
99 if (!empty($_REQUEST['lang_id']))
100 {
101 $outputlangs = new Translate("",$conf);
102 $outputlangs->setDefaultLang($_REQUEST['lang_id']);
103 }
104 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
105 $fac->generateDocument($fac->modelpdf, $outputlangs);
106 }
107 }
108
109 header('Location: card.php?id='.$object->id);
110 exit;
111 }
112 else
113 {
114 setEventMessages($object->error, $object->errors, 'errors');
115 $db->rollback();
116 }
117}
118*/
119
120
121/*
122 * View
123 */
124
125llxHeader();
126
127$tva = new Tva($db);
128$form = new Form($db);
129
130$h = 0;
131
132$head[$h][0] = DOL_URL_ROOT.'/compta/payment_vat/card.php?id='.$id;
133$head[$h][1] = $langs->trans("VATPayment");
134$hselected = $h;
135$h++;
136
137/*$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/info.php?id='.$id;
138$head[$h][1] = $langs->trans("Info");
139$h++;
140*/
141
142
143print dol_get_fiche_head($head, $hselected, $langs->trans("VATPayment"), -1, 'payment');
144
145/*
146 * Deletion confirmation of payment
147 */
148if ($action == 'delete') {
149 print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
150}
151
152/*
153 * Validation confirmation of payment
154 */
155/*
156if ($action == 'valide')
157{
158 $facid = $_GET['facid'];
159 print $form->formconfirm('card.php?id='.$object->id.'&amp;facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
160
161}
162*/
163
164
165$linkback = '<a href="'.DOL_URL_ROOT.'/compta/tva/payments.php">'.$langs->trans("BackToList").'</a>';
166
167dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', '');
168
169
170print '<div class="fichecenter">';
171print '<div class="underbanner clearboth"></div>';
172
173print '<table class="border centpercent">';
174
175// Date
176print '<tr><td>'.$langs->trans('Date').'</td><td>'.dol_print_date($object->datep, 'day').'</td></tr>';
177
178// Mode
179print '<tr><td>'.$langs->trans('Mode').'</td><td>'.$langs->trans("PaymentType".$object->type_code).'</td></tr>';
180
181// Numero
182print '<tr><td>'.$langs->trans('Numero').'</td><td>'.dol_escape_htmltag($object->num_payment).'</td></tr>';
183
184// Montant
185print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
186
187// Note
188print '<tr><td>'.$langs->trans('Note').'</td><td class="wordbreak sensiblehtmlcontent">'.dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_private)).'</td></tr>';
189
190// Bank account
191if (isModEnabled("banque")) {
192 if ($object->bank_account) {
193 $bankline = new AccountLine($db);
194 $bankline->fetch($object->bank_line);
195
196 print '<tr>';
197 print '<td>'.$langs->trans('BankTransactionLine').'</td>';
198 print '<td>';
199 print $bankline->getNomUrl(1, 0, 'showall');
200 print '</td>';
201 print '</tr>';
202 }
203}
204
205print '</table>';
206
207print '</div>';
208
209print dol_get_fiche_end();
210
211
212/*
213 * List of social contributions payed
214 */
215
216$disable_delete = 0;
217$sql = 'SELECT f.rowid as scid, f.label as label, f.paye, f.amount as tva_amount, pf.amount';
218$sql .= ' FROM '.MAIN_DB_PREFIX.'payment_vat as pf,'.MAIN_DB_PREFIX.'tva as f';
219$sql .= ' WHERE pf.fk_tva = f.rowid';
220$sql .= ' AND f.entity = '.$conf->entity;
221$sql .= ' AND pf.rowid = '.((int) $object->id);
222
223dol_syslog("compta/payment_vat/card.php", LOG_DEBUG);
224$resql = $db->query($sql);
225if ($resql) {
226 $num = $db->num_rows($resql);
227
228 $i = 0;
229 $total = 0;
230 print '<br><table class="noborder centpercent">';
231 print '<tr class="liste_titre">';
232 print '<td>'.$langs->trans('VATDeclaration').'</td>';
233 //print '<td>'.$langs->trans('Type').'</td>';
234 print '<td>'.$langs->trans('Label').'</td>';
235 print '<td class="right">'.$langs->trans('ExpectedToPay').'</td>';
236 print '<td class="center">'.$langs->trans('Status').'</td>';
237 print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
238 print "</tr>\n";
239
240 if ($num > 0) {
241 while ($i < $num) {
242 $objp = $db->fetch_object($resql);
243
244 print '<tr class="oddeven">';
245 // Ref
246 print '<td>';
247 $tva->fetch($objp->scid);
248 print $tva->getNomUrl(1);
249 print "</td>\n";
250 // Type
251 /* print '<td>';
252 print $tva->type_label;4
253 print "</td>\n";*/
254 // Label
255 print '<td>'.$objp->label.'</td>';
256 // Expected to pay
257 print '<td class="right"><span class="amount">'.price($objp->tva_amount).'</span></td>';
258 // Status
259 print '<td class="center">'.$tva->getLibStatut(4, $objp->amount).'</td>';
260 // Amount payed
261 print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
262 print "</tr>\n";
263 if ($objp->paye == 1) { // If at least one invoice is paid, disable delete
264 $disable_delete = 1;
265 }
266 $total = $total + $objp->amount;
267 $i++;
268 }
269 }
270
271
272 print "</table>\n";
273 $db->free($resql);
274} else {
275 dol_print_error($db);
276}
277
278
279
280/*
281 * Boutons Actions
282 */
283print '<div class="tabsAction">';
284
285/*
286if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
287{
288 if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '')
289 {
290 if ($user->hasRight('facture', 'paiement')) {
291 print '<a class="butAction" href="card.php?id='.GETPOST('id', 'int').'&amp;facid='.$objp->facid.'&amp;action=valide">'.$langs->trans('Valid').'</a>';
292 }
293 }
294}
295*/
296
297if ($action == '') {
298 if ($user->rights->tax->charges->supprimer) {
299 if (!$disable_delete) {
300 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 1);
301 } else {
302 print dolGetButtonAction($langs->trans("CantRemovePaymentVATPaid"), $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 0);
303 }
304 }
305}
306
307print '</div>';
308
309// End of page
310llxFooter();
311$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Class to manage bank transaction lines.
Class to manage generation of HTML components Only common components must be here.
Class to manage payments of social contributions.
Put here description of your class.
Definition tva.class.php:36
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0)
Clean a string to keep only desirable HTML tags.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...