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) 2022 Alexandre Spangaro <aspangaro@open-dsi.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/sociales/class/chargesociales.class.php';
32require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.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', 'aZ09');
46if ($user->socid) {
47 $socid = $user->socid;
48}
49
50$object = new PaymentSocialContribution($db);
51if ($id > 0) {
52 $result = $object->fetch($id);
53 if (!$result) {
54 dol_print_error($db, 'Failed to get payment id '.$id);
55 }
56}
57
58$result = restrictedArea($user, 'payment_sc', $object, '');
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/sociales/payments.php");
73 exit;
74 } else {
75 setEventMessages($object->error, $object->errors, 'errors');
76 $db->rollback();
77 }
78}
79
80/*if ($action == 'setdatep' && GETPOST('datepday') && $user->hasRight('tax', 'charges', 'creer')) {
81 $datepaye = dol_mktime(GETPOST('datephour', 'int'), GETPOST('datepmin', 'int'), GETPOST('datepsec', 'int'), GETPOST('datepmonth', 'int'), GETPOST('datepday', 'int'), GETPOST('datepyear', 'int'));
82 $res = $object->update_date($datepaye);
83 if ($res === 0) {
84 setEventMessages($langs->trans('PaymentDateUpdateSucceeded'), null, 'mesgs');
85 } else {
86 setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors');
87 }
88}*/
89
90
91/*
92 * View
93 */
94
95llxHeader();
96
97$socialcontrib = new ChargeSociales($db);
98
99$form = new Form($db);
100
101$h = 0;
102
103$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$id;
104$head[$h][1] = $langs->trans("PaymentSocialContribution");
105$hselected = $h;
106$h++;
107
108/*$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/info.php?id='.$id;
109$head[$h][1] = $langs->trans("Info");
110$h++;
111*/
112
113
114print dol_get_fiche_head($head, $hselected, $langs->trans("PaymentSocialContribution"), -1, 'payment');
115
116/*
117 * Deletion confirmation of payment
118 */
119if ($action == 'delete') {
120 print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
121}
122
123$linkback = '<a href="'.DOL_URL_ROOT.'/compta/sociales/payments.php">'.$langs->trans("BackToList").'</a>';
124
125dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', '');
126
127
128print '<div class="fichecenter">';
129print '<div class="underbanner clearboth"></div>';
130
131print '<table class="border centpercent">';
132
133// Date
134print '<tr><td>'.$langs->trans('Date').'</td><td>'.dol_print_date($object->datep, 'day').'</td></tr>';
135
136// Mode
137print '<tr><td>'.$langs->trans('Mode').'</td><td>'.$langs->trans("PaymentType".$object->type_code).'</td></tr>';
138
139// Numero
140print '<tr><td>'.$langs->trans('Numero').'</td><td>'.dol_escape_htmltag($object->num_payment).'</td></tr>';
141
142// Amount
143print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).'</td></tr>';
144
145// Note
146print '<tr><td>'.$langs->trans('Note').'</td><td class="wordbreak sensiblehtmlcontent">'.dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_private)).'</td></tr>';
147
148// Bank account
149if (isModEnabled("banque")) {
150 if ($object->bank_account) {
151 $bankline = new AccountLine($db);
152 $bankline->fetch($object->bank_line);
153
154 print '<tr>';
155 print '<td>'.$langs->trans('BankTransactionLine').'</td>';
156 print '<td>';
157 print $bankline->getNomUrl(1, 0, 'showall');
158 print '</td>';
159 print '</tr>';
160 }
161}
162
163print '</table>';
164
165print '</div>';
166
167print dol_get_fiche_end();
168
169
170/*
171 * List of social contributions paid
172 */
173
174$disable_delete = 0;
175$sql = 'SELECT f.rowid as scid, f.libelle as label, f.paye, f.amount as sc_amount, pf.amount, pc.libelle as sc_type';
176$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementcharge as pf,'.MAIN_DB_PREFIX.'chargesociales as f, '.MAIN_DB_PREFIX.'c_chargesociales as pc';
177$sql .= ' WHERE pf.fk_charge = f.rowid AND f.fk_type = pc.id';
178$sql .= ' AND f.entity = '.$conf->entity;
179$sql .= ' AND pf.rowid = '.((int) $object->id);
180
181dol_syslog("compta/payment_sc/card.php", LOG_DEBUG);
182$resql = $db->query($sql);
183if ($resql) {
184 $num = $db->num_rows($resql);
185
186 $i = 0;
187 $total = 0;
188 print '<br><table class="noborder centpercent">';
189 print '<tr class="liste_titre">';
190 print '<td>'.$langs->trans('SocialContribution').'</td>';
191 print '<td>'.$langs->trans('Type').'</td>';
192 print '<td>'.$langs->trans('Label').'</td>';
193 print '<td class="right">'.$langs->trans('ExpectedToPay').'</td>';
194 print '<td class="center">'.$langs->trans('Status').'</td>';
195 print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
196 print "</tr>\n";
197
198 if ($num > 0) {
199 while ($i < $num) {
200 $objp = $db->fetch_object($resql);
201
202 print '<tr class="oddeven">';
203 // Ref
204 print '<td>';
205 $socialcontrib->fetch($objp->scid);
206 print $socialcontrib->getNomUrl(1);
207 print "</td>\n";
208 // Type
209 print '<td>';
210 print $socialcontrib->type_label;
211 /*print $socialcontrib->type;*/
212 print "</td>\n";
213 // Label
214 print '<td>'.$objp->label.'</td>';
215 // Expected to pay
216 print '<td class="right"><span class="amount">'.price($objp->sc_amount).'</span></td>';
217 // Status
218 print '<td class="center">'.$socialcontrib->getLibStatut(4, $objp->amount).'</td>';
219 // Amount paid
220 print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
221 print "</tr>\n";
222 if ($objp->paye == 1) { // If at least one invoice is paid, disable delete
223 $disable_delete = 1;
224 }
225 $total = $total + $objp->amount;
226 $i++;
227 }
228 }
229
230
231 print "</table>\n";
232 $db->free($resql);
233} else {
234 dol_print_error($db);
235}
236
237
238
239/*
240 * Actions Buttons
241 */
242print '<div class="tabsAction">';
243
244/*
245if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
246{
247 if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '')
248 {
249 if ($user->hasRight('facture', 'paiement')){
250 print '<a class="butAction" href="card.php?id='.GETPOST('id', 'int').'&amp;facid='.$objp->facid.'&amp;action=valide">'.$langs->trans('Valid').'</a>';
251 }
252 }
253}
254*/
255
256if ($action == '') {
257 if ($user->rights->tax->charges->supprimer) {
258 if (!$disable_delete) {
259 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 1);
260 } else {
261 print dolGetButtonAction($langs->trans("CantRemovePaymentWithOneInvoicePaid"), $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 0);
262 }
263 }
264}
265
266print '</div>';
267
268// End of page
269llxFooter();
270$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.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
Class to manage generation of HTML components Only common components must be here.
Class to manage payments of social contributions.
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...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.