dolibarr  9.0.0
card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2016-2018 Frédéric France <frederic.france@netlogic.fr>
5  * Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.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 <http://www.gnu.org/licenses/>.
19  */
20 
27 require '../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
33 if (! empty($conf->projet->enabled))
34 {
35  include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
36  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
37 }
38 if (! empty($conf->accounting->enabled)) {
39  include_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
40 }
41 
42 // Load translation files required by the page
43 $langs->loadLangs(array('compta', 'bills', 'banks'));
44 
45 $id=GETPOST('id','int');
46 $action=GETPOST('action','aZ09');
47 $confirm=GETPOST('confirm');
48 $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
49 
50 // Security check
51 $socid = GETPOST('socid','int');
52 if ($user->societe_id) $socid=$user->societe_id;
53 $result = restrictedArea($user, 'tax', $id, 'chargesociales','charges');
54 
55 $object = new ChargeSociales($db);
56 
57 /* *************************************************************************** */
58 /* */
59 /* Actions */
60 /* */
61 /* *************************************************************************** */
62 
63 // Classify paid
64 if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes')
65 {
66  $object->fetch($id);
67  $result = $object->set_paid($user);
68 }
69 
70 if ($action == 'reopen' && $user->rights->tax->charges->creer) {
71  $result = $object->fetch($id);
72  if ($object->paye)
73  {
74  $result = $object->set_unpaid($user);
75  if ($result > 0)
76  {
77  header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
78  exit();
79  } else {
80  setEventMessages($object->error, $object->errors, 'errors');
81  }
82  }
83 }
84 
85 // Link to a project
86 if ($action == 'classin' && $user->rights->tax->charges->creer)
87 {
88  $object->fetch($id);
89  $object->setProject(GETPOST('projectid'));
90 }
91 
92 if ($action == 'setlib' && $user->rights->tax->charges->creer)
93 {
94  $object->fetch($id);
95  $result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY');
96  if ($result < 0)
97  setEventMessages($object->error, $object->errors, 'errors');
98 }
99 
100 // payment mode
101 if ($action == 'setmode' && $user->rights->tax->charges->creer) {
102  $object->fetch($id);
103  $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
104  if ($result < 0)
105  setEventMessages($object->error, $object->errors, 'errors');
106 }
107 
108 // bank account
109 if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) {
110  $object->fetch($id);
111  $result=$object->setBankAccount(GETPOST('fk_account', 'int'));
112  if ($result < 0) {
113  setEventMessages($object->error, $object->errors, 'errors');
114  }
115 }
116 
117 // Delete social contribution
118 if ($action == 'confirm_delete' && $confirm == 'yes')
119 {
120  $object->fetch($id);
121  $result=$object->delete($user);
122  if ($result > 0)
123  {
124  header("Location: index.php");
125  exit;
126  }
127  else
128  {
129  setEventMessages($object->error, $object->errors, 'errors');
130  }
131 }
132 
133 
134 // Add social contribution
135 if ($action == 'add' && $user->rights->tax->charges->creer)
136 {
137  $dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
138  $dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
139  $amount=price2num(GETPOST('amount'));
140  $actioncode=GETPOST('actioncode');
141 
142  if (! $dateech)
143  {
144  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")), null, 'errors');
145  $action = 'create';
146  }
147  elseif (! $dateperiod)
148  {
149  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors');
150  $action = 'create';
151  }
152  elseif (! $actioncode > 0)
153  {
154  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors');
155  $action = 'create';
156  }
157  elseif (empty($amount))
158  {
159  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
160  $action = 'create';
161  }
162  elseif (! is_numeric($amount))
163  {
164  setEventMessages($langs->trans("ErrorFieldMustBeANumeric",$langs->transnoentities("Amount")), null, 'errors');
165  $action = 'create';
166  }
167  else
168  {
169  $object->type = $actioncode;
170  $object->lib = GETPOST('label');
171  $object->date_ech = $dateech;
172  $object->periode = $dateperiod;
173  $object->amount = $amount;
174  $object->mode_reglement_id = GETPOST('mode_reglement_id');
175  $object->fk_account = GETPOST('fk_account', 'int');
176  $object->fk_project = GETPOST('fk_project');
177 
178  $id=$object->create($user);
179  if ($id <= 0)
180  {
181  setEventMessages($object->error, $object->errors, 'errors');
182  $action='create';
183  }
184  }
185 }
186 
187 
188 if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer)
189 {
190  $dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
191  $dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
192  $amount=price2num(GETPOST('amount'));
193 
194  if (! $dateech)
195  {
196  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")), null, 'errors');
197  $action = 'edit';
198  }
199  elseif (! $dateperiod)
200  {
201  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors');
202  $action = 'edit';
203  }
204  elseif (empty($amount))
205  {
206  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
207  $action = 'edit';
208  }
209  elseif (! is_numeric($amount))
210  {
211  setEventMessages($langs->trans("ErrorFieldMustBeANumeric",$langs->transnoentities("Amount")), null, 'errors');
212  $action = 'create';
213  }
214  else
215  {
216  $result=$object->fetch($id);
217 
218  $object->date_ech = $dateech;
219  $object->periode = $dateperiod;
220  $object->amount = price2num($amount);
221 
222  $result=$object->update($user);
223  if ($result <= 0)
224  {
225  setEventMessages($object->error, $object->errors, 'errors');
226  }
227  }
228 }
229 
230 // Action clone object
231 if ($action == 'confirm_clone' && $confirm != 'yes') { $action=''; }
232 
233 if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->charges->creer))
234 {
235  $db->begin();
236 
237  $originalId = $id;
238 
239  $object->fetch($id);
240 
241  if ($object->id > 0)
242  {
243  $object->paye = 0;
244  $object->id = $object->ref = null;
245  $object->lib = $langs->trans("CopyOf").' '.$object->lib;
246 
247  if (GETPOST('clone_for_next_month') != '')
248  {
249  $object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm');
250  $object->periode = dol_time_plus_duree($object->periode, 1, 'm');
251  }
252 
253  if ($object->check())
254  {
255  $id = $object->create($user);
256  if ($id > 0)
257  {
258  $db->commit();
259  $db->close();
260 
261  header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
262  exit;
263  }
264  else
265  {
266  $id=$originalId;
267  $db->rollback();
268 
269  setEventMessages($object->error,$object->errors, 'errors');
270  }
271  }
272  }
273  else
274  {
275  $db->rollback();
276  dol_print_error($db,$object->error);
277  }
278 }
279 
280 
281 
282 
283 
284 /*
285  * View
286  */
287 
288 $form = new Form($db);
289 $formsocialcontrib = new FormSocialContrib($db);
290 $bankaccountstatic = new Account($db);
291 if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
292 
293 $title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Card");
294 $help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)';
295 llxHeader("",$title,$help_url);
296 
297 
298 // Mode creation
299 if ($action == 'create')
300 {
301  print load_fiche_titre($langs->trans("NewSocialContribution"));
302 
303  print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';
304  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
305  print '<input type="hidden" name="action" value="add">';
306 
307  dol_fiche_head();
308 
309  print '<table class="border" width="100%">';
310 
311  // Label
312  print "<tr>";
313  print '<td class="titlefieldcreate fieldrequired">';
314  print $langs->trans("Label");
315  print '</td>';
316  print '<td><input type="text" size="34" name="label" class="flat" value="'.dol_escape_htmltag(GETPOST('label','alpha')).'" autofocus></td>';
317  print '</tr>';
318  print '<tr>';
319 
320  // Type
321  print '<td class="fieldrequired">';
322  print $langs->trans("Type");
323  print '</td>';
324  print '<td>';
325  $formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode",'alpha')?GETPOST("actioncode",'alpha'):'','actioncode',1);
326  print '</td>';
327  print '</tr>';
328 
329  // Date end period
330  print '<tr>';
331  print '<td class="fieldrequired">';
332  print $form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo"));
333  print '</td>';
334  print '<td>';
335  print $form->selectDate(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
336  print '</td>';
337  print '</tr>';
338 
339  // Date due
340  print '<tr>';
341  print '<td class="fieldrequired">';
342  print $langs->trans("DateDue");
343  print '</td>';
344  print '<td>';
345  print $form->selectDate(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
346  print '</td>';
347  print "</tr>\n";
348 
349  // Amount
350  print '<tr>';
351  print '<td class="fieldrequired">';
352  print $langs->trans("Amount");
353  print '</td>';
354  print '<td><input type="text" size="6" name="amount" class="flat" value="'.dol_escape_htmltag(GETPOST('amount','alpha')).'"></td>';
355  print '</tr>';
356 
357  // Project
358  if (! empty($conf->projet->enabled))
359  {
360  $formproject=new FormProjets($db);
361 
362  // Associated project
363  $langs->load("projects");
364 
365  print '<tr><td>'.$langs->trans("Project").'</td><td>';
366 
367  $numproject=$formproject->select_projects(-1, $projectid,'fk_project',0,0,1,1);
368 
369  print '</td></tr>';
370  }
371 
372  // Payment Mode
373  print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
374  $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
375  print '</td></tr>';
376 
377  // Bank Account
378  if (! empty($conf->banque->enabled))
379  {
380  print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
381  $form->select_comptes($fk_account, 'fk_account', 0, '', 1);
382  print '</td></tr>';
383  }
384 
385  print '</table>';
386 
387  dol_fiche_end();
388 
389  print '<div class="center">';
390  print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
391  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
392  print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
393  print '</div>';
394 
395  print '</form>';
396 }
397 
398 /* *************************************************************************** */
399 /* */
400 /* Card Mode */
401 /* */
402 /* *************************************************************************** */
403 if ($id > 0)
404 {
405  $object = new ChargeSociales($db);
406  $result=$object->fetch($id);
407 
408  if ($result > 0)
409  {
410  $head=tax_prepare_head($object);
411 
412  $totalpaye = $object->getSommePaiement();
413 
414  // Clone confirmation
415  if ($action === 'clone')
416  {
417  $formclone=array(
418  array('type' => 'checkbox', 'name' => 'clone_for_next_month','label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1),
419 
420  );
421 
422  print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneTax'),$langs->trans('ConfirmCloneTax',$object->ref),'confirm_clone',$formclone,'yes');
423  }
424 
425  // Confirmation de la suppression de la charge
426  if ($action == 'paid')
427  {
428  $text=$langs->trans('ConfirmPaySocialContribution');
429  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans('PaySocialContribution'),$text,"confirm_paid",'','',2);
430  }
431 
432  if ($action == 'delete')
433  {
434  $text=$langs->trans('ConfirmDeleteSocialContribution');
435  print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('DeleteSocialContribution'),$text,'confirm_delete','','',2);
436  }
437 
438  if ($action == 'edit')
439  {
440  print "<form name=\"charge\" action=\"".$_SERVER["PHP_SELF"]."?id=$object->id&amp;action=update\" method=\"post\">";
441  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
442  }
443 
444  dol_fiche_head($head, 'card', $langs->trans("SocialContribution"), -1, 'bill');
445 
446  $morehtmlref='<div class="refidno">';
447  // Ref customer
448  $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1);
449  $morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1);
450  // Project
451  if (! empty($conf->projet->enabled))
452  {
453  $langs->load("projects");
454  $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
455  if ($user->rights->tax->charges->creer)
456  {
457  if ($action != 'classify')
458  $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
459  if ($action == 'classify') {
460  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
461  $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
462  $morehtmlref.='<input type="hidden" name="action" value="classin">';
463  $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
464  $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
465  $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
466  $morehtmlref.='</form>';
467  } else {
468  $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
469  }
470  } else {
471  if (! empty($object->fk_project)) {
472  $proj = new Project($db);
473  $proj->fetch($object->fk_project);
474  $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
475  $morehtmlref.=$proj->ref;
476  $morehtmlref.='</a>';
477  } else {
478  $morehtmlref.='';
479  }
480  }
481  }
482  $morehtmlref.='</div>';
483 
484  $linkback = '<a href="' . DOL_URL_ROOT . '/compta/sociales/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
485 
486  $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status
487 
488  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
489 
490  print '<div class="fichecenter">';
491  print '<div class="fichehalfleft">';
492  print '<div class="underbanner clearboth"></div>';
493 
494  print '<table class="border" width="100%">';
495 
496  // Type
497  print '<tr><td class="titlefield">'.$langs->trans("Type")."</td><td>".$object->type_libelle."</td>";
498  print "</tr>";
499 
500  // Period end date
501  print "<tr><td>".$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo"))."</td>";
502  print "<td>";
503  if ($action == 'edit')
504  {
505  print $form->selectDate($object->periode, 'period', 0, 0, 0, 'charge', 1);
506  }
507  else
508  {
509  print dol_print_date($object->periode,"day");
510  }
511  print "</td></tr>";
512 
513  // Due date
514  if ($action == 'edit')
515  {
516  print '<tr><td>'.$langs->trans("DateDue")."</td><td>";
517  print $form->selectDate($object->date_ech, 'ech', 0, 0, 0, 'charge', 1);
518  print "</td></tr>";
519  } else {
520  print "<tr><td>".$langs->trans("DateDue")."</td><td>".dol_print_date($object->date_ech,'day')."</td></tr>";
521  }
522 
523  // Amount
524  if ($action == 'edit')
525  {
526  print '<tr><td>'.$langs->trans("AmountTTC")."</td><td>";
527  print '<input type="text" name="amount" size="12" class="flat" value="'.$object->amount.'">';
528  print "</td></tr>";
529  }
530  else {
531  print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
532  }
533 
534  // Mode of payment
535  print '<tr><td>';
536  print '<table class="nobordernopadding" width="100%"><tr><td>';
537  print $langs->trans('PaymentMode');
538  print '</td>';
539  if ($action != 'editmode')
540  print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
541  print '</tr></table>';
542  print '</td><td>';
543  if ($action == 'editmode') {
544  $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id');
545  } else {
546  $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none');
547  }
548  print '</td></tr>';
549 
550  // Bank Account
551  if (! empty($conf->banque->enabled))
552  {
553  print '<tr><td class="nowrap">';
554  print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
555  print $langs->trans('BankAccount');
556  print '<td>';
557  if ($action != 'editbankaccount' && $user->rights->tax->charges->creer)
558  print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
559  print '</tr></table>';
560  print '</td><td>';
561  if ($action == 'editbankaccount') {
562  $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
563  } else {
564  $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
565  }
566  print '</td>';
567  print '</tr>';
568  }
569 
570  print '</table>';
571 
572  print '</div>';
573  print '<div class="fichehalfright">';
574  print '<div class="ficheaddleft">';
575 
576  $nbcols = 3;
577  if (! empty($conf->banque->enabled)) {
578  $nbcols ++;
579  }
580 
581  /*
582  * Payments
583  */
584  $sql = "SELECT p.rowid, p.num_paiement, datep as dp, p.amount,";
585  $sql.= " c.code as type_code,c.libelle as paiement_type,";
586  $sql.= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
587  $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
588  $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid';
589  $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid';
590  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepaiement = c.id";
591  $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
592  $sql.= " WHERE p.fk_charge = ".$id;
593  $sql.= " AND p.fk_charge = cs.rowid";
594  $sql.= " AND cs.entity IN (".getEntity('tax').")";
595  $sql.= " ORDER BY dp DESC";
596 
597  //print $sql;
598  $resql = $db->query($sql);
599  if ($resql)
600  {
601  $totalpaye = 0;
602 
603  $num = $db->num_rows($resql);
604  $i = 0; $total = 0;
605  print '<table class="noborder paymenttable">';
606  print '<tr class="liste_titre">';
607  print '<td>'.$langs->trans("RefPayment").'</td>';
608  print '<td>'.$langs->trans("Date").'</td>';
609  print '<td>'.$langs->trans("Type").'</td>';
610  if (! empty($conf->banque->enabled)) {
611  print '<td class="liste_titre" align="right">' . $langs->trans('BankAccount') . '</td>';
612  }
613  print '<td align="right">'.$langs->trans("Amount").'</td>';
614  print '</tr>';
615 
616  if ($num > 0)
617  {
618  while ($i < $num)
619  {
620  $objp = $db->fetch_object($resql);
621 
622  print '<tr class="oddeven"><td>';
623  print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
624  print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
625  $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
626  print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
627  if (! empty($conf->banque->enabled))
628  {
629  $bankaccountstatic->id = $objp->baid;
630  $bankaccountstatic->ref = $objp->baref;
631  $bankaccountstatic->label = $objp->baref;
632  $bankaccountstatic->number = $objp->banumber;
633 
634  if (! empty($conf->accounting->enabled)) {
635  $bankaccountstatic->account_number = $objp->account_number;
636 
637  $accountingjournal = new AccountingJournal($db);
638  $accountingjournal->fetch($objp->fk_accountancy_journal);
639  $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1);
640  }
641 
642  print '<td align="right">';
643  if ($bankaccountstatic->id)
644  print $bankaccountstatic->getNomUrl(1, 'transactions');
645  print '</td>';
646  }
647  print '<td align="right">'.price($objp->amount)."</td>\n";
648  print "</tr>";
649  $totalpaye += $objp->amount;
650  $i++;
651  }
652  }
653  else
654  {
655 
656  print '<tr class="oddeven"><td class="opacitymedium">'.$langs->trans("None").'</td>';
657  print '<td></td><td></td><td></td><td></td>';
658  print '</tr>';
659  }
660 
661  print '<tr><td colspan="'.$nbcols.'" align="right">'.$langs->trans("AlreadyPaid")." :</td><td align=\"right\">".price($totalpaye)."</td></tr>\n";
662  print '<tr><td colspan="'.$nbcols.'" align="right">'.$langs->trans("AmountExpected")." :</td><td align=\"right\">".price($object->amount)."</td></tr>\n";
663 
664  $resteapayer = $object->amount - $totalpaye;
665  $cssforamountpaymentcomplete = 'amountpaymentcomplete';
666 
667  print '<tr><td colspan="'.$nbcols.'" align="right">'.$langs->trans("RemainderToPay")." :</td>";
668  print '<td align="right"'.($resteapayer?' class="amountremaintopay"':(' class="'.$cssforamountpaymentcomplete.'"')).'>'.price($resteapayer)."</td></tr>\n";
669 
670  print "</table>";
671  $db->free($resql);
672  }
673  else
674  {
675  dol_print_error($db);
676  }
677 
678  print '</div>';
679  print '</div>';
680  print '</div>';
681 
682  print '<div class="clearboth"></div>';
683 
684  dol_fiche_end();
685 
686  if ($action == 'edit')
687  {
688  print '<div align="center">';
689  print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
690  print ' &nbsp; ';
691  print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
692  print '</div>';
693  }
694 
695  if ($action == 'edit') print "</form>\n";
696 
697 
698 
699  /*
700  * Actions buttons
701  */
702  if ($action != 'edit')
703  {
704  print "<div class=\"tabsAction\">\n";
705 
706  // Reopen
707  if ($object->paye && $user->rights->tax->charges->creer)
708  {
709  print "<a class=\"butAction\" href=\"".dol_buildpath("/compta/sociales/card.php",1). "?id=$object->id&amp;action=reopen\">".$langs->trans("ReOpen")."</a>";
710  }
711 
712  // Edit
713  if ($object->paye == 0 && $user->rights->tax->charges->creer)
714  {
715  print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/card.php?id=$object->id&amp;action=edit\">".$langs->trans("Modify")."</a>";
716  }
717 
718  // Emit payment
719  if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->tax->charges->creer)
720  {
721  print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/paiement_charge.php?id=$object->id&amp;action=create\">".$langs->trans("DoPayment")."</a>";
722  }
723 
724  // Classify 'paid'
725  if ($object->paye == 0 && round($resteapayer) <=0 && $user->rights->tax->charges->creer)
726  {
727  print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/card.php?id=$object->id&amp;action=paid\">".$langs->trans("ClassifyPaid")."</a>";
728  }
729 
730  // Clone
731  if ($user->rights->tax->charges->creer)
732  {
733  print "<a class=\"butAction\" href=\"".dol_buildpath("/compta/sociales/card.php",1). "?id=$object->id&amp;action=clone\">".$langs->trans("ToClone")."</a>";
734  }
735 
736  // Delete
737  if ($user->rights->tax->charges->supprimer)
738  {
739  print "<a class=\"butActionDelete\" href=\"".DOL_URL_ROOT."/compta/sociales/card.php?id=$object->id&amp;action=delete\">".$langs->trans("Delete")."</a>";
740  }
741 
742  print "</div>";
743  }
744  }
745  else
746  {
747  /* Social contribution not found */
748  dol_print_error('',$object->error);
749  }
750 }
751 
752 // End of page
753 llxFooter();
754 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->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) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
img_edit($titlealt='default', $float=0, $other='class="pictoedit"')
Show logo editer/modifier fiche.
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_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
Class to manage bank accounts.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
Class to manage building of HTML components.
dol_fiche_end($notab=0)
Show tab footer of a card.
Class to manage generation of HTML components for social contributions management.
llxHeader()
Empty header.
Definition: wrapper.php:44
if($_POST["cancel"]==$langs->trans("Cancel") &&! $id) if($action=='add' && $_POST["cancel"]<> $langs->trans("Cancel")) if($action=='delete') if($id) $form
Actions.
Definition: card.php:153
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='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
tax_prepare_head(ChargeSociales $object)
Prepare array with list of tabs.
Definition: tax.lib.php:37
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
Class to manage accounting accounts.
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
Definition: date.lib.php:116
Classe permettant la gestion des paiements des charges La tva collectee n&#39;est calculee que sur les fa...
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)