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