dolibarr  13.0.2
card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
3  * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
25 require '../../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
33 if (!empty($conf->projet->enabled)) {
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 
38 // Load translation files required by the page
39 $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy", "categories"));
40 
41 // Get parameters
42 $id = GETPOST('id', 'int');
43 $action = GETPOST('action', 'alpha');
44 $confirm = GETPOST('confirm');
45 $cancel = GETPOST('cancel', 'aZ09');
46 $backtopage = GETPOST('backtopage', 'alpha');
47 
48 $accountid = GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0;
49 $label = GETPOST("label", "alpha");
50 $sens = GETPOST("sens", "int");
51 $amount = price2num(GETPOST("amount", "alpha"));
52 $paymenttype = GETPOST("paymenttype", "aZ09");
53 $accountancy_code = GETPOST("accountancy_code", "alpha");
54 $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
55 if (!empty($conf->accounting->enabled) && !empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
56  $subledger_account = GETPOST("subledger_account", "alpha") > 0 ? GETPOST("subledger_account", "alpha") : '';
57 } else {
58  $subledger_account = GETPOST("subledger_account", "alpha");
59 }
60 
61 // Security check
62 $socid = GETPOST("socid", "int");
63 if ($user->socid) $socid = $user->socid;
64 $result = restrictedArea($user, 'banque', '', '', '');
65 
66 $object = new PaymentVarious($db);
67 
68 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
69 $hookmanager->initHooks(array('variouscard', 'globalcard'));
70 
71 
76 $parameters = array();
77 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
78 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
79 
80 if (empty($reshook))
81 {
82  // Link to a project
83  if ($action == 'classin' && $user->rights->banque->modifier)
84  {
85  $object->fetch($id);
86  $object->setProject(GETPOST('projectid'));
87  }
88 
89  if ($cancel)
90  {
91  if ($action != 'addlink')
92  {
93  $urltogo = $backtopage ? $backtopage : dol_buildpath('/compta/bank/various_payment/list.php', 1);
94  header("Location: ".$urltogo);
95  exit;
96  }
97  if ($id > 0 || !empty($ref)) $ret = $object->fetch($id, $ref);
98  $action = '';
99  }
100 
101  if ($action == 'add')
102  {
103  $error = 0;
104 
105  $datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int'));
106  $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int'));
107  if (empty($datev)) $datev = $datep;
108 
109  $object->ref = ''; // TODO
110  $object->accountid = GETPOST("accountid", 'int') > 0 ? GETPOST("accountid", "int") : 0;
111  $object->datev = $datev;
112  $object->datep = $datep;
113  $object->amount = price2num(GETPOST("amount", 'alpha'));
114  $object->label = GETPOST("label", 'restricthtml');
115  $object->note = GETPOST("note", 'restricthtml');
116  $object->type_payment = dol_getIdFromCode($db, GETPOST('paymenttype'), 'c_paiement', 'code', 'id', 1);
117  $object->num_payment = GETPOST("num_payment", 'alpha');
118  $object->chqemetteur = GETPOST("chqemetteur", 'alpha');
119  $object->chqbank = GETPOST("chqbank", 'alpha');
120  $object->fk_user_author = $user->id;
121  $object->category_transaction = GETPOST("category_transaction", 'alpha');
122 
123  $object->accountancy_code = GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : "";
124  $object->subledger_account = $subledger_account;
125 
126  $object->sens = GETPOSTINT('sens');
127  $object->fk_project = GETPOSTINT('fk_project');
128 
129  if (empty($datep) || empty($datev))
130  {
131  $langs->load('errors');
132  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
133  $error++;
134  }
135  if (empty($object->amount))
136  {
137  $langs->load('errors');
138  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
139  $error++;
140  }
141  if (!empty($conf->banque->enabled) && !$object->accountid > 0)
142  {
143  $langs->load('errors');
144  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
145  $error++;
146  }
147  if (empty($object->type_payment) || $object->type_payment < 0)
148  {
149  $langs->load('errors');
150  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
151  $error++;
152  }
153  if (!empty($conf->accounting->enabled) && !$object->accountancy_code)
154  {
155  $langs->load('errors');
156  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors');
157  $error++;
158  }
159  if ($object->sens < 0)
160  {
161  $langs->load('errors');
162  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Sens")), null, 'errors');
163  $error++;
164  }
165 
166  if (!$error)
167  {
168  $db->begin();
169 
170  $ret = $object->create($user);
171  if ($ret > 0)
172  {
173  $db->commit();
174  $urltogo = ($backtopage ? $backtopage : DOL_URL_ROOT.'/compta/bank/various_payment/list.php');
175  header("Location: ".$urltogo);
176  exit;
177  } else {
178  $db->rollback();
179  setEventMessages($object->error, $object->errors, 'errors');
180  $action = "create";
181  }
182  }
183 
184  $action = 'create';
185  }
186 
187  if ($action == 'delete')
188  {
189  $result = $object->fetch($id);
190 
191  if ($object->rappro == 0)
192  {
193  $db->begin();
194 
195  $ret = $object->delete($user);
196  if ($ret > 0)
197  {
198  if ($object->fk_bank)
199  {
200  $accountline = new AccountLine($db);
201  $result = $accountline->fetch($object->fk_bank);
202  if ($result > 0) $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
203  }
204 
205  if ($result >= 0)
206  {
207  $db->commit();
208  header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/list.php');
209  exit;
210  } else {
211  $object->error = $accountline->error;
212  $db->rollback();
213  setEventMessages($object->error, $object->errors, 'errors');
214  }
215  } else {
216  $db->rollback();
217  setEventMessages($object->error, $object->errors, 'errors');
218  }
219  } else {
220  setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors');
221  }
222  }
223 
224  if ($action == 'setsubledger_account') {
225  $db->begin();
226 
227  $result = $object->fetch($id);
228 
229  $object->subledger_account = $subledger_account;
230 
231  $res = $object->update($user);
232  if ($res > 0) {
233  $db->commit();
234  } else {
235  $db->rollback();
236  setEventMessages($object->error, $object->errors, 'errors');
237  }
238  }
239 }
240 
241 // Action clone object
242 if ($action == 'confirm_clone' && $confirm != 'yes') { $action = ''; }
243 
244 if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->banque->modifier))
245 {
246  $db->begin();
247 
248  $originalId = $id;
249 
250  $object->fetch($id);
251 
252  if ($object->id > 0)
253  {
254  $object->id = $object->ref = null;
255 
256  if (GETPOST('clone_label', 'alphanohtml')) {
257  $object->label = GETPOST('clone_label', 'alphanohtml');
258  } else {
259  $object->label = $langs->trans("CopyOf").' '.$object->label;
260  }
261 
262  $newdatepayment = dol_mktime(0, 0, 0, GETPOST('clone_date_paymentmonth', 'int'), GETPOST('clone_date_paymentday', 'int'), GETPOST('clone_date_paymentyear', 'int'));
263  $newdatevalue = dol_mktime(0, 0, 0, GETPOST('clone_date_valuemonth', 'int'), GETPOST('clone_date_valueday', 'int'), GETPOST('clone_date_valueyear', 'int'));
264  if ($newdatepayment) $object->datep = $newdatepayment;
265  if (!empty($newdatevalue)) {
266  $object->datev = $newdatevalue;
267  } else {
268  $object->datev = $newdatepayment;
269  }
270 
271  if (GETPOSTISSET("clone_sens")) {
272  $object->sens = GETPOST("clone_sens", 'int');
273  } else {
274  $object->sens = $object->sens;
275  }
276 
277  if (GETPOST("clone_amount", "alpha")) {
278  $object->amount = price2num(GETPOST("clone_amount", "alpha"));
279  } else {
280  $object->amount = price2num($object->amount);
281  }
282 
283  if ($object->check())
284  {
285  $id = $object->create($user);
286  if ($id > 0)
287  {
288  $db->commit();
289  $db->close();
290 
291  header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
292  exit;
293  } else {
294  $id = $originalId;
295  $db->rollback();
296 
297  setEventMessages($object->error, $object->errors, 'errors');
298  }
299  } else {
300  $id = $originalId;
301  $db->rollback();
302 
303  setEventMessages($object->error, $object->errors, 'errors');
304  }
305  } else {
306  $db->rollback();
307  dol_print_error($db, $object->error);
308  }
309 }
310 
311 
312 /*
313  * View
314  */
315 
316 llxHeader("", $langs->trans("VariousPayment"));
317 
318 $form = new Form($db);
319 if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
320 if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db);
321 
322 if ($id)
323 {
324  $object = new PaymentVarious($db);
325  $result = $object->fetch($id);
326  if ($result <= 0)
327  {
328  dol_print_error($db);
329  exit;
330  }
331 }
332 
333 $options = array();
334 
335 // Load bank groups
336 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
337 $bankcateg = new BankCateg($db);
338 
339 foreach ($bankcateg->fetchAll() as $bankcategory) {
340  $options[$bankcategory->id] = $bankcategory->label;
341 }
342 
343 /* ************************************************************************** */
344 /* */
345 /* Create mode */
346 /* */
347 /* ************************************************************************** */
348 if ($action == 'create')
349 {
350  // Update fields properties in realtime
351  if (!empty($conf->use_javascript_ajax))
352  {
353  print "\n".'<script type="text/javascript" language="javascript">';
354  print '$(document).ready(function () {
355  setPaymentType();
356  $("#selectpaymenttype").change(function() {
357  setPaymentType();
358  });
359  function setPaymentType()
360  {
361  var code = $("#selectpaymenttype option:selected").val();
362  if (code == \'CHQ\' || code == \'VIR\')
363  {
364  if (code == \'CHQ\')
365  {
366  $(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
367  }
368  if ($(\'#fieldchqemetteur\').val() == \'\')
369  {
370  var emetteur = jQuery(\'#thirdpartylabel\').val();
371  $(\'#fieldchqemetteur\').val(emetteur);
372  }
373  }
374  else
375  {
376  $(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
377  $(\'#fieldchqemetteur\').val(\'\');
378  }
379  }
380  ';
381 
382  print ' });'."\n";
383 
384  print ' </script>'."\n";
385  }
386 
387  print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
388  print '<input type="hidden" name="token" value="'.newToken().'">';
389  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
390  print '<input type="hidden" name="action" value="add">';
391 
392  print load_fiche_titre($langs->trans("NewVariousPayment"), '', 'object_payment');
393 
394  print dol_get_fiche_head('', '');
395 
396  print '<table class="border centpercent">';
397 
398  // Date payment
399  print '<tr><td class="titlefieldcreate">';
400  print $form->editfieldkey('DatePayment', 'datep', '', $object, 0, 'string', '', 1).'</td><td>';
401  print $form->selectDate((empty($datep) ?-1 : $datep), "datep", '', '', '', 'add', 1, 1);
402  print '</td></tr>';
403 
404  // Date value for bank
405  print '<tr><td>';
406  print $form->editfieldkey('DateValue', 'datev', '', $object, 0).'</td><td>';
407  print $form->selectDate((empty($datev) ?-1 : $datev), "datev", '', '', '', 'add', 1, 1);
408  print '</td></tr>';
409 
410  // Label
411  print '<tr><td>';
412  print $form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).'</td><td>';
413  print '<input name="label" id="label" class="minwidth300 maxwidth150onsmartphone" value="'.($label ? $label : $langs->trans("VariousPayment")).'">';
414  print '</td></tr>';
415 
416  // Amount
417  print '<tr><td>';
418  print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).'</td><td>';
419  print '<input name="amount" id="amount" class="minwidth100 maxwidth150onsmartphone" value="'.$amount.'">';
420  print '</td></tr>';
421 
422  // Bank
423  if (!empty($conf->banque->enabled))
424  {
425  print '<tr><td>';
426  print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).'</td><td>';
427  $form->select_comptes($accountid, "accountid", 0, '', 2); // Affiche liste des comptes courant
428  print '</td></tr>';
429  }
430 
431  // Type payment
432  print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>';
433  $form->select_types_paiements($paymenttype, 'paymenttype', '', 2);
434  print "</td>\n";
435  print '</tr>';
436 
437  // Number
438  print '<tr><td><label for="num_payment">'.$langs->trans('Numero');
439  print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
440  print '</label></td>';
441  print '<td><input name="num_payment" class="maxwidth150onsmartphone" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
442 
443  // Check transmitter
444  print '<tr><td class="'.(GETPOST('paymenttype') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn"><label for="fieldchqemetteur">'.$langs->trans('CheckTransmitter');
445  print ' <em>('.$langs->trans("ChequeMaker").')</em>';
446  print '</label></td>';
447  print '<td><input id="fieldchqemetteur" name="chqemetteur" size="30" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>';
448 
449  // Bank name
450  print '<tr><td><label for="chqbank">'.$langs->trans('Bank');
451  print ' <em>('.$langs->trans("ChequeBank").')</em>';
452  print '</label></td>';
453  print '<td><input id="chqbank" name="chqbank" size="30" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>';
454 
455  // Accountancy account
456  if (!empty($conf->accounting->enabled)) {
457  // TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code
458  print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("AccountAccounting").'</td>';
459  print '<td>';
460  print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1);
461  print '</td></tr>';
462  } else { // For external software
463  print '<tr><td class="titlefieldcreate">'.$langs->trans("AccountAccounting").'</td>';
464  print '<td><input class="minwidth100 maxwidthonsmartphone" name="accountancy_code" value="'.$accountancy_code.'">';
465  print '</td></tr>';
466  }
467 
468  // Subledger account
469  if (!empty($conf->accounting->enabled)) {
470  print '<tr><td>'.$langs->trans("SubledgerAccount").'</td>';
471  print '<td>';
472  if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
473  print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, '');
474  } else {
475  print '<input type="text" class="maxwidth200 maxwidthonsmartphone" name="subledger_account" value="'.$subledger_account.'">';
476  }
477  print '</td></tr>';
478  } else { // For external software
479  print '<tr><td>'.$langs->trans("SubledgerAccount").'</td>';
480  print '<td><input class="minwidth100 maxwidthonsmartphone" name="subledger_account" value="'.$subledger_account.'">';
481  print '</td></tr>';
482  }
483 
484  // Sens
485  print '<tr><td>';
486  $labelsens = $form->textwithpicto('Sens', $langs->trans("AccountingDirectionHelp"));
487  print $form->editfieldkey($labelsens, 'sens', '', $object, 0, 'string', '', 1).'</td><td>';
488  $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit"));
489  print $form->selectarray('sens', $sensarray, $sens, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1);
490  print '</td></tr>';
491 
492  // Project
493  if (!empty($conf->projet->enabled))
494  {
495  $formproject = new FormProjets($db);
496 
497  // Associated project
498  $langs->load("projects");
499 
500  print '<tr><td>'.$langs->trans("Project").'</td><td>';
501 
502  $numproject = $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1);
503 
504  print '</td></tr>';
505  }
506 
507  // Other attributes
508  $parameters = array();
509  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
510  print $hookmanager->resPrint;
511 
512  // Category
513  if (is_array($options) && count($options) && $conf->categorie->enabled) {
514  print '<tr><td>'.$langs->trans("RubriquesTransactions").'</td><td>';
515  print img_picto('', 'category').Form::selectarray('category_transaction', $options, GETPOST('category_transaction'), 1, 0, 0, '', 0, 0, 0, '', 'minwidth300', 1);
516  print '</td></tr>';
517  }
518 
519  print '</table>';
520 
521  print dol_get_fiche_end();
522 
523  print '<div class="center">';
524  print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">';
525  print ' &nbsp; ';
526  print '<input type="button" class="button button-cancel" value="'.$langs->trans("Cancel").'" onclick="javascript:history.go(-1)">';
527  print '</div>';
528 
529  print '</form>';
530 }
531 
532 
533 /* ************************************************************************** */
534 /* */
535 /* View mode */
536 /* */
537 /* ************************************************************************** */
538 
539 if ($id)
540 {
541  $alreadyaccounted = $object->getVentilExportCompta();
542 
543  $head = various_payment_prepare_head($object);
544 
545  // Clone confirmation
546  if ($action === 'clone')
547  {
548  $set_value_help = $form->textwithpicto('', $langs->trans($langs->trans("AccountingDirectionHelp")));
549  $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit"));
550 
551  $formquestion = array(
552  array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label),
553  array('type' => 'date', 'tdclass'=>'fieldrequired', 'name' => 'clone_date_payment', 'label' => $langs->trans("DatePayment"), 'value' => -1),
554  array('type' => 'date', 'name' => 'clone_date_value', 'label' => $langs->trans("DateValue"), 'value' => -1),
555  array('type' => 'other', 'tdclass'=>'fieldrequired', 'name' => 'clone_accountid', 'label' => $langs->trans("BankAccount"), 'value' => $form->select_comptes($object->fk_account, "accountid", 0, '', 1, '', 0, 'minwidth200', 1)),
556  array('type' => 'text', 'name' => 'clone_amount', 'label' => $langs->trans("Amount"), 'value' => price($object->amount)),
557  array('type' => 'select', 'name' => 'clone_sens', 'label' => $langs->trans("Sens") . ' ' . $set_value_help, 'values' => $sensarray, 'default' => $object->sens),
558  );
559 
560  print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 350);
561  }
562 
563  print dol_get_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto);
564 
565  $morehtmlref = '<div class="refidno">';
566  // Project
567  if (!empty($conf->projet->enabled))
568  {
569  $langs->load("projects");
570  $morehtmlref .= $langs->trans('Project').' ';
571  if ($user->rights->banque->modifier)
572  {
573  if ($action != 'classify') {
574  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
575  }
576  if ($action == 'classify') {
577  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
578  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
579  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
580  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
581  $morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
582  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
583  $morehtmlref .= '</form>';
584  } else {
585  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
586  }
587  } else {
588  if (!empty($object->fk_project)) {
589  $proj = new Project($db);
590  $proj->fetch($object->fk_project);
591  $morehtmlref .= $proj->getNomUrl(1);
592  } else {
593  $morehtmlref .= '';
594  }
595  }
596  }
597  $morehtmlref .= '</div>';
598  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
599 
600  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
601 
602  print '<div class="fichecenter">';
603  print '<div class="underbanner clearboth"></div>';
604 
605  print '<table class="border centpercent tableforfield">';
606 
607  // Label
608  print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
609 
610  // Payment date
611  print "<tr>";
612  print '<td>'.$langs->trans("DatePayment").'</td><td>';
613  print dol_print_date($object->datep, 'day');
614  print '</td></tr>';
615 
616  // Value date
617  print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
618  print dol_print_date($object->datev, 'day');
619  print '</td></tr>';
620 
621  // Debit / Credit
622  if ($object->sens == '1') $sens = $langs->trans("Credit"); else $sens = $langs->trans("Debit");
623  print '<tr><td>'.$langs->trans("Sens").'</td><td>'.$sens.'</td></tr>';
624 
625  print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
626 
627  // Accountancy code
628  print '<tr><td class="nowrap">';
629  print $langs->trans("AccountAccounting");
630  print '</td><td>';
631  if (!empty($conf->accounting->enabled))
632  {
633  $accountingaccount = new AccountingAccount($db);
634  $accountingaccount->fetch('', $object->accountancy_code, 1);
635 
636  print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
637  } else {
638  print $object->accountancy_code;
639  }
640  print '</td></tr>';
641 
642  // Subledger account
643  print '<tr><td class="nowrap">';
644  print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
645  print '</td><td>';
646  print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
647  print '</td></tr>';
648 
649  if (!empty($conf->banque->enabled))
650  {
651  if ($object->fk_account > 0)
652  {
653  $bankline = new AccountLine($db);
654  $bankline->fetch($object->fk_bank);
655 
656  print '<tr>';
657  print '<td>'.$langs->trans('BankTransactionLine').'</td>';
658  print '<td colspan="3">';
659  print $bankline->getNomUrl(1, 0, 'showall');
660  print '</td>';
661  print '</tr>';
662  }
663  }
664 
665  // Other attributes
666  $parameters = array('socid'=>$object->id);
667  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
668 
669  print '</table>';
670 
671  print '</div>';
672 
673  print '<div class="clearboth"></div>';
674 
675  print dol_get_fiche_end();
676 
677 
678  /*
679  * Action buttons
680  */
681  print '<div class="tabsAction">'."\n";
682 
683  // TODO
684  // Add button modify
685 
686  // Clone
687  if ($user->rights->banque->modifier)
688  {
689  print '<div class="inline-block divButAction"><a class="butAction" href="'.dol_buildpath("/compta/bank/various_payment/card.php", 1).'?id='.$object->id.'&amp;action=clone">'.$langs->trans("ToClone")."</a></div>";
690  }
691 
692  // Delete
693  if (empty($object->rappro))
694  {
695  if (!empty($user->rights->banque->modifier))
696  {
697  if ($alreadyaccounted) {
698  print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("Accounted").'">'.$langs->trans("Delete").'</a></div>';
699  } else {
700  print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a></div>';
701  }
702  } else {
703  print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a></div>';
704  }
705  } else {
706  print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("LinkedToAConciliatedTransaction").'">'.$langs->trans("Delete").'</a></div>';
707  }
708 
709  print "</div>";
710 }
711 
712 // End of page
713 llxFooter();
714 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class to manage various payments.
various_payment_prepare_head($object)
Prepare array with list of tabs.
Definition: bank.lib.php:206
Class to manage bank transaction lines.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
Class to manage building of HTML components.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
Class to manage bank categories.
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.
print $_SERVER["PHP_SELF"]
Edit parameters.
GETPOSTINT($paramname, $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
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).
Class to manage generation of HTML components for accounting management.
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.
Class to manage accounting accounts.
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