dolibarr 20.0.0
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("bank")) {
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 = GETPOSTINT("id");
44$action = GETPOST('action', 'aZ09');
45$confirm = GETPOST('confirm');
46if ($user->socid) {
47 $socid = $user->socid;
48}
49// TODO ajouter regle pour restreindre access 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->hasRight('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->model_pdf, $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 = array();
133$head[$h][0] = DOL_URL_ROOT.'/compta/payment_vat/card.php?id='.$id;
134$head[$h][1] = $langs->trans("VATPayment");
135$hselected = $h;
136$h++;
137
138/*$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/info.php?id='.$id;
139$head[$h][1] = $langs->trans("Info");
140$h++;
141*/
142
143
144print dol_get_fiche_head($head, $hselected, $langs->trans("VATPayment"), -1, 'payment');
145
146/*
147 * Deletion confirmation of payment
148 */
149if ($action == 'delete') {
150 print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
151}
152
153
154
155$linkback = '<a href="'.DOL_URL_ROOT.'/compta/tva/payments.php">'.$langs->trans("BackToList").'</a>';
156
157dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', '');
158
159
160print '<div class="fichecenter">';
161print '<div class="underbanner clearboth"></div>';
162
163print '<table class="border centpercent">';
164
165// Date
166print '<tr><td>'.$langs->trans('Date').'</td><td>'.dol_print_date($object->datep, 'day').'</td></tr>';
167
168// Mode
169print '<tr><td>'.$langs->trans('Mode').'</td><td>'.$langs->trans("PaymentType".$object->type_code).'</td></tr>';
170
171// Numero
172print '<tr><td>'.$langs->trans('Numero').'</td><td>'.dol_escape_htmltag($object->num_payment).'</td></tr>';
173
174// Montant
175print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
176
177// Note
178print '<tr><td>'.$langs->trans('Note').'</td><td class="wordbreak sensiblehtmlcontent">'.dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_private)).'</td></tr>';
179
180// Bank account
181if (isModEnabled("bank")) {
182 if ($object->bank_account) {
183 $bankline = new AccountLine($db);
184 $bankline->fetch($object->bank_line);
185
186 print '<tr>';
187 print '<td>'.$langs->trans('BankTransactionLine').'</td>';
188 print '<td>';
189 print $bankline->getNomUrl(1, 0, 'showall');
190 print '</td>';
191 print '</tr>';
192 }
193}
194
195print '</table>';
196
197print '</div>';
198
199print dol_get_fiche_end();
200
201
202/*
203 * List of social contributions paid
204 */
205
206$disable_delete = 0;
207$sql = 'SELECT f.rowid as scid, f.label as label, f.paye, f.amount as tva_amount, pf.amount';
208$sql .= ' FROM '.MAIN_DB_PREFIX.'payment_vat as pf,'.MAIN_DB_PREFIX.'tva as f';
209$sql .= ' WHERE pf.fk_tva = f.rowid';
210$sql .= ' AND f.entity = '.$conf->entity;
211$sql .= ' AND pf.rowid = '.((int) $object->id);
212
213dol_syslog("compta/payment_vat/card.php", LOG_DEBUG);
214$resql = $db->query($sql);
215if ($resql) {
216 $num = $db->num_rows($resql);
217
218 $i = 0;
219 $total = 0;
220 print '<br><table class="noborder centpercent">';
221 print '<tr class="liste_titre">';
222 print '<td>'.$langs->trans('VATDeclaration').'</td>';
223 //print '<td>'.$langs->trans('Type').'</td>';
224 print '<td>'.$langs->trans('Label').'</td>';
225 print '<td class="right">'.$langs->trans('ExpectedToPay').'</td>';
226 print '<td class="center">'.$langs->trans('Status').'</td>';
227 print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
228 print "</tr>\n";
229
230 if ($num > 0) {
231 while ($i < $num) {
232 $objp = $db->fetch_object($resql);
233
234 print '<tr class="oddeven">';
235 // Ref
236 print '<td>';
237 $tva->fetch($objp->scid);
238 print $tva->getNomUrl(1);
239 print "</td>\n";
240 // Type
241 /* print '<td>';
242 print $tva->type_label;4
243 print "</td>\n";*/
244 // Label
245 print '<td>'.$objp->label.'</td>';
246 // Expected to pay
247 print '<td class="right"><span class="amount">'.price($objp->tva_amount).'</span></td>';
248 // Status
249 print '<td class="center">'.$tva->getLibStatut(4, $objp->amount).'</td>';
250 // Amount paid
251 print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
252 print "</tr>\n";
253 if ($objp->paye == 1) { // If at least one invoice is paid, disable delete
254 $disable_delete = 1;
255 }
256 $total = $total + $objp->amount;
257 $i++;
258 }
259 }
260
261
262 print "</table>\n";
263 $db->free($resql);
264} else {
265 dol_print_error($db);
266}
267
268
269
270/*
271 * Boutons Actions
272 */
273print '<div class="tabsAction">';
274
275if ($action == '') {
276 if ($user->hasRight('tax', 'charges', 'supprimer')) {
277 if (!$disable_delete) {
278 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 1);
279 } else {
280 print dolGetButtonAction($langs->trans("CantRemovePaymentVATPaid"), $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 0);
281 }
282 }
283}
284
285print '</div>';
286
287// End of page
288llxFooter();
289$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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:37
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_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_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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...