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) 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("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', 'aZ09');
46if ($user->socid) {
47 $socid = $user->socid;
48}
49
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 = array();
104$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$id;
105$head[$h][1] = $langs->trans("PaymentSocialContribution");
106$hselected = $h;
107$h++;
108
109/*$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/info.php?id='.$id;
110$head[$h][1] = $langs->trans("Info");
111$h++;
112*/
113
114
115print dol_get_fiche_head($head, $hselected, $langs->trans("PaymentSocialContribution"), -1, 'payment');
116
117/*
118 * Deletion confirmation of payment
119 */
120if ($action == 'delete') {
121 print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
122}
123
124$linkback = '<a href="'.DOL_URL_ROOT.'/compta/sociales/payments.php">'.$langs->trans("BackToList").'</a>';
125
126dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', '');
127
128
129print '<div class="fichecenter">';
130print '<div class="underbanner clearboth"></div>';
131
132print '<table class="border centpercent">';
133
134// Date
135print '<tr><td>'.$langs->trans('Date').'</td><td>'.dol_print_date($object->datep, 'day').'</td></tr>';
136
137// Mode
138print '<tr><td>'.$langs->trans('Mode').'</td><td>'.$langs->trans("PaymentType".$object->type_code).'</td></tr>';
139
140// Numero
141print '<tr><td>'.$langs->trans('Numero').'</td><td>'.dol_escape_htmltag($object->num_payment).'</td></tr>';
142
143// Amount
144print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).'</td></tr>';
145
146// Note
147print '<tr><td>'.$langs->trans('Note').'</td><td class="wordbreak sensiblehtmlcontent">'.dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_private)).'</td></tr>';
148
149// Bank account
150if (isModEnabled("bank")) {
151 if ($object->bank_account) {
152 $bankline = new AccountLine($db);
153 $bankline->fetch($object->bank_line);
154
155 print '<tr>';
156 print '<td>'.$langs->trans('BankTransactionLine').'</td>';
157 print '<td>';
158 print $bankline->getNomUrl(1, 0, 'showall');
159 print '</td>';
160 print '</tr>';
161 }
162}
163
164print '</table>';
165
166print '</div>';
167
168print dol_get_fiche_end();
169
170
171/*
172 * List of social contributions paid
173 */
174
175$disable_delete = 0;
176$sql = 'SELECT f.rowid as scid, f.libelle as label, f.paye, f.amount as sc_amount, pf.amount, pc.libelle as sc_type';
177$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementcharge as pf,'.MAIN_DB_PREFIX.'chargesociales as f, '.MAIN_DB_PREFIX.'c_chargesociales as pc';
178$sql .= ' WHERE pf.fk_charge = f.rowid AND f.fk_type = pc.id';
179$sql .= ' AND f.entity = '.$conf->entity;
180$sql .= ' AND pf.rowid = '.((int) $object->id);
181
182dol_syslog("compta/payment_sc/card.php", LOG_DEBUG);
183$resql = $db->query($sql);
184if ($resql) {
185 $num = $db->num_rows($resql);
186
187 $i = 0;
188 $total = 0;
189 print '<br><table class="noborder centpercent">';
190 print '<tr class="liste_titre">';
191 print '<td>'.$langs->trans('SocialContribution').'</td>';
192 print '<td>'.$langs->trans('Type').'</td>';
193 print '<td>'.$langs->trans('Label').'</td>';
194 print '<td class="right">'.$langs->trans('ExpectedToPay').'</td>';
195 print '<td class="center">'.$langs->trans('Status').'</td>';
196 print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
197 print "</tr>\n";
198
199 if ($num > 0) {
200 while ($i < $num) {
201 $objp = $db->fetch_object($resql);
202
203 print '<tr class="oddeven">';
204 // Ref
205 print '<td>';
206 $socialcontrib->fetch($objp->scid);
207 print $socialcontrib->getNomUrl(1);
208 print "</td>\n";
209 // Type
210 print '<td>';
211 print $socialcontrib->type_label;
212 /*print $socialcontrib->type;*/
213 print "</td>\n";
214 // Label
215 print '<td>'.$objp->label.'</td>';
216 // Expected to pay
217 print '<td class="right"><span class="amount">'.price($objp->sc_amount).'</span></td>';
218 // Status
219 print '<td class="center">'.$socialcontrib->getLibStatut(4, $objp->amount).'</td>';
220 // Amount paid
221 print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
222 print "</tr>\n";
223 if ($objp->paye == 1) { // If at least one invoice is paid, disable delete
224 $disable_delete = 1;
225 }
226 $total = $total + $objp->amount;
227 $i++;
228 }
229 }
230
231
232 print "</table>\n";
233 $db->free($resql);
234} else {
235 dol_print_error($db);
236}
237
238
239
240/*
241 * Actions Buttons
242 */
243print '<div class="tabsAction">';
244
245/*
246if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
247{
248 if ($user->socid == 0 && $object->statut == 0 && $action == '')
249 {
250 if ($user->hasRight('facture', 'paiement')){
251 print '<a class="butAction" href="card.php?id='.GETPOST('id', 'int').'&amp;facid='.$objp->facid.'&amp;action=valide">'.$langs->trans('Valid').'</a>';
252 }
253 }
254}
255*/
256
257if ($action == '') {
258 if ($user->hasRight('tax', 'charges', 'supprimer')) {
259 if (!$disable_delete) {
260 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 1);
261 } else {
262 print dolGetButtonAction($langs->trans("CantRemovePaymentWithOneInvoicePaid"), $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 0);
263 }
264 }
265}
266
267print '</div>';
268
269// End of page
270llxFooter();
271$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 for managing the social charges.
Class to manage generation of HTML components Only common components must be here.
Class to manage payments of social contributions.
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...
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.