dolibarr  13.0.2
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  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
33 if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
34 
35 // Load translation files required by the page
36 $langs->loadLangs(array('bills', 'banks', 'companies'));
37 
38 // Security check
39 $id = GETPOST("id", 'int');
40 $action = GETPOST('action', 'aZ09');
41 $confirm = GETPOST('confirm', 'aZ09');
42 if ($user->socid) $socid = $user->socid;
43 // TODO ajouter regle pour restreindre acces paiement
44 //$result = restrictedArea($user, 'facture', $id,'');
45 
46 $object = new PaymentSocialContribution($db);
47 if ($id > 0)
48 {
49  $result = $object->fetch($id);
50  if (!$result) dol_print_error($db, 'Failed to get payment id '.$id);
51 }
52 
53 
54 /*
55  * Actions
56  */
57 
58 // Delete payment
59 if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->charges->supprimer)
60 {
61  $db->begin();
62 
63  $result = $object->delete($user);
64  if ($result > 0)
65  {
66  $db->commit();
67  header("Location: ".DOL_URL_ROOT."/compta/sociales/payments.php");
68  exit;
69  } else {
70  setEventMessages($object->error, $object->errors, 'errors');
71  $db->rollback();
72  }
73 }
74 
75 
76 /*
77  * View
78  */
79 
80 llxHeader();
81 
82 $socialcontrib = new ChargeSociales($db);
83 
84 $form = new Form($db);
85 
86 $h = 0;
87 
88 $head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$id;
89 $head[$h][1] = $langs->trans("PaymentSocialContribution");
90 $hselected = $h;
91 $h++;
92 
93 /*$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/info.php?id='.$id;
94 $head[$h][1] = $langs->trans("Info");
95 $h++;
96 */
97 
98 
99 print dol_get_fiche_head($head, $hselected, $langs->trans("PaymentSocialContribution"), -1, 'payment');
100 
101 /*
102  * Deletion confirmation of payment
103  */
104 if ($action == 'delete')
105 {
106  print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
107 }
108 
109 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/sociales/payments.php">'.$langs->trans("BackToList").'</a>';
110 
111 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', '');
112 
113 
114 print '<div class="fichecenter">';
115 print '<div class="underbanner clearboth"></div>';
116 
117 print '<table class="border centpercent">';
118 
119 // Ref
120 /*print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td>';
121 print '<td colspan="3">';
122 print $form->showrefnav($object,'id','',1,'rowid','id');
123 print '</td></tr>';*/
124 
125 // Date
126 print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($object->datep, 'day').'</td></tr>';
127 
128 // Mode
129 print '<tr><td>'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$object->type_code).'</td></tr>';
130 
131 // Numero
132 print '<tr><td>'.$langs->trans('Numero').'</td><td colspan="3">'.$object->num_payment.'</td></tr>';
133 
134 // Amount
135 print '<tr><td>'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
136 
137 // Note
138 print '<tr><td>'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($object->note).'</td></tr>';
139 
140 // Bank account
141 if (!empty($conf->banque->enabled))
142 {
143  if ($object->bank_account)
144  {
145  $bankline = new AccountLine($db);
146  $bankline->fetch($object->bank_line);
147 
148  print '<tr>';
149  print '<td>'.$langs->trans('BankTransactionLine').'</td>';
150  print '<td colspan="3">';
151  print $bankline->getNomUrl(1, 0, 'showall');
152  print '</td>';
153  print '</tr>';
154  }
155 }
156 
157 print '</table>';
158 
159 print '</div>';
160 
162 
163 
164 /*
165  * List of social contributions paid
166  */
167 
168 $disable_delete = 0;
169 $sql = 'SELECT f.rowid as scid, f.libelle as label, f.paye, f.amount as sc_amount, pf.amount, pc.libelle as sc_type';
170 $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementcharge as pf,'.MAIN_DB_PREFIX.'chargesociales as f, '.MAIN_DB_PREFIX.'c_chargesociales as pc';
171 $sql .= ' WHERE pf.fk_charge = f.rowid AND f.fk_type = pc.id';
172 $sql .= ' AND f.entity = '.$conf->entity;
173 $sql .= ' AND pf.rowid = '.$object->id;
174 
175 dol_syslog("compta/payment_sc/card.php", LOG_DEBUG);
176 $resql = $db->query($sql);
177 if ($resql)
178 {
179  $num = $db->num_rows($resql);
180 
181  $i = 0;
182  $total = 0;
183  print '<br><table class="noborder centpercent">';
184  print '<tr class="liste_titre">';
185  print '<td>'.$langs->trans('SocialContribution').'</td>';
186  print '<td>'.$langs->trans('Type').'</td>';
187  print '<td>'.$langs->trans('Label').'</td>';
188  print '<td class="right">'.$langs->trans('ExpectedToPay').'</td>';
189  print '<td class="center">'.$langs->trans('Status').'</td>';
190  print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
191  print "</tr>\n";
192 
193  if ($num > 0)
194  {
195  while ($i < $num)
196  {
197  $objp = $db->fetch_object($resql);
198 
199  print '<tr class="oddeven">';
200  // Ref
201  print '<td>';
202  $socialcontrib->fetch($objp->scid);
203  print $socialcontrib->getNomUrl(1);
204  print "</td>\n";
205  // Type
206  print '<td>';
207  print $socialcontrib->type_label;
208  /*print $socialcontrib->type;*/
209  print "</td>\n";
210  // Label
211  print '<td>'.$objp->label.'</td>';
212  // Expected to pay
213  print '<td class="right">'.price($objp->sc_amount).'</td>';
214  // Status
215  print '<td class="center">'.$socialcontrib->getLibStatut(4, $objp->amount).'</td>';
216  // Amount paid
217  print '<td class="right">'.price($objp->amount).'</td>';
218  print "</tr>\n";
219  if ($objp->paye == 1) // If at least one invoice is paid, disable delete
220  {
221  $disable_delete = 1;
222  }
223  $total = $total + $objp->amount;
224  $i++;
225  }
226  }
227 
228 
229  print "</table>\n";
230  $db->free($resql);
231 } else {
232  dol_print_error($db);
233 }
234 
235 
236 
237 /*
238  * Actions Buttons
239  */
240 print '<div class="tabsAction">';
241 
242 /*
243 if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
244 {
245  if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '')
246  {
247  if ($user->rights->facture->paiement)
248  {
249  print '<a class="butAction" href="card.php?id='.$_GET['id'].'&amp;facid='.$objp->facid.'&amp;action=valide">'.$langs->trans('Valid').'</a>';
250  }
251  }
252 }
253 */
254 
255 if ($action == '')
256 {
257  if ($user->rights->tax->charges->supprimer)
258  {
259  if (!$disable_delete)
260  {
261  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.GETPOST('id', 'int').'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a>';
262  } else {
263  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>';
264  }
265  }
266 }
267 
268 print '</div>';
269 
270 // End of page
271 llxFooter();
272 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage payments of social contributions.
Class to manage bank transaction lines.
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...
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59
Classe permettant la gestion des paiements des charges La tva collectee n&#39;est calculee que sur les fa...