dolibarr 21.0.0-beta
object_currency_amount.tpl.php
1<?php
2/* Copyright (C) 2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.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 * Needs the following variables defined:
19 * $object Proposal, order, invoice (including supplier versions)
20 * $usercancreate Permission to edit object
21 * $action
22 * $form
23 * $conf
24 * $langs
25 */
35// Protection to avoid direct call of template
36if (empty($conf) || !is_object($conf)) {
37 print "Error, template page can't be called as URL";
38 exit(1);
39}
40
41'
42@phan-var-force CommonObject $object
43@phan-var-force int $usercancreate
44@phan-var-force string $action
45@phan-var-force Form $form
46@phan-var-force Conf $conf
47@phan-var-force Translate $langs
48';
49
50
51print '<!-- BEGIN object_currency_amount.tpl.php -->'."\n";
52
53// Multicurrency
54if (isModEnabled('multicurrency')) {
55 $colspan = 1;
56 if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
57 $colspan = 2;
58 }
59 if ($object instanceof FactureFournisseurRec || $object instanceof FactureRec) {
60 $currencyIsEditable = ($object->suspended == $object::STATUS_SUSPENDED);
61 $colspan = 1;
62 } else {
63 // @phan-suppress-next-line PhanUndeclaredConstantOfClass
64 $currencyIsEditable = ($object->status == $object::STATUS_DRAFT);
65 }
66
67 // Multicurrency code
68 print '<tr>';
69 print '<td>';
70 print '<table class="nobordernopadding centpercent"><tr><td>';
71 print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0);
72 print '</td>';
73 if ($usercancreate && $action != 'editmulticurrencycode' && $currencyIsEditable) {
74 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencycode&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>';
75 }
76 print '</tr></table>';
77 print '</td><td'.($colspan == 2 ? ' colspan="2"' : '').'>';
78 $htmlname = (($usercancreate && $action == 'editmulticurrencycode' && $currencyIsEditable) ? 'multicurrency_code' : 'none');
79 $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, $htmlname);
80 print '</td></tr>';
81
82 // Multicurrency rate
83 if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) {
84 print '<tr>';
85 print '<td>';
86 print '<table class="nobordernopadding centpercent"><tr><td>';
87 print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0);
88 print '</td>';
89 if ($usercancreate && $action != 'editmulticurrencyrate' && $currencyIsEditable && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
90 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencyrate&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyRate'), 1).'</a></td>';
91 }
92 print '</tr></table>';
93 print '</td><td'.($colspan == 2 ? ' colspan="2"' : '').'>';
94 if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') {
95 if ($action == 'actualizemulticurrencyrate') {
96 list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code);
97 }
98 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, ($usercancreate ? 'multicurrency_tx' : 'none'), $object->multicurrency_code);
99 } else {
100 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
101 if ($object->status == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
102 print '<div class="inline-block"> &nbsp; &nbsp; &nbsp; &nbsp; ';
103 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate&token='.newToken().'" title="'.$langs->trans("ActualizeCurrency").'">';
104 //print $langs->trans("ActualizeCurrency");
105 print img_picto($langs->trans("ActualizeCurrency"), 'undo');
106 print '</a>';
107 print '</div>';
108 }
109 }
110 print '</td></tr>';
111 }
112}
113
114print '<!-- END template -->';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class to manage invoice templates.
Class to manage invoice templates.
static getIdAndTxFromCode($dbs, $code, $date_document='')
Get id and rate of currency from code.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79