dolibarr 21.0.0-alpha
object_currency_amount.tpl.php
1<?php
2/* Copyright (C) 2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 * Needs the following variables defined:
18 * $object Proposal, order, invoice (including supplier versions)
19 * $usercancreate Permission to edit object
20 * $action
21 * $form
22 * $conf
23 * $langs
24 */
25
26// Protection to avoid direct call of template
27if (empty($conf) || !is_object($conf)) {
28 print "Error, template page can't be called as URL";
29 exit(1);
30}
31
32'
33@phan-var-force CommonObject $object
34@phan-var-force int $usercancreate
35@phan-var-force string $action
36@phan-var-force Form $form
37@phan-var-force Conf $conf
38@phan-var-force Translate $langs
39';
40
41
42print '<!-- BEGIN object_currency_amount.tpl.php -->'."\n";
43
44// Multicurrency
45if (isModEnabled('multicurrency')) {
46 $colspan = 1;
47 if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
48 $colspan = 2;
49 }
50 if ($object instanceof FactureFournisseurRec || $object instanceof FactureRec) {
51 $currencyIsEditable = ($object->suspended == $object::STATUS_SUSPENDED);
52 $colspan = 1;
53 } else {
54 // @phan-suppress-next-line PhanUndeclaredConstantOfClass
55 $currencyIsEditable = ($object->status == $object::STATUS_DRAFT);
56 }
57
58 // Multicurrency code
59 print '<tr>';
60 print '<td>';
61 print '<table class="nobordernopadding centpercent"><tr><td>';
62 print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0);
63 print '</td>';
64 if ($usercancreate && $action != 'editmulticurrencycode' && $currencyIsEditable) {
65 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>';
66 }
67 print '</tr></table>';
68 print '</td><td'.($colspan == 2 ? ' colspan="2"' : '').'>';
69 $htmlname = (($usercancreate && $action == 'editmulticurrencycode' && $currencyIsEditable) ? 'multicurrency_code' : 'none');
70 $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, $htmlname);
71 print '</td></tr>';
72
73 // Multicurrency rate
74 if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) {
75 print '<tr>';
76 print '<td>';
77 print '<table class="nobordernopadding centpercent"><tr><td>';
78 print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0);
79 print '</td>';
80 if ($usercancreate && $action != 'editmulticurrencyrate' && $currencyIsEditable && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
81 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>';
82 }
83 print '</tr></table>';
84 print '</td><td'.($colspan == 2 ? ' colspan="2"' : '').'>';
85 if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') {
86 if ($action == 'actualizemulticurrencyrate') {
87 list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code);
88 }
89 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, ($usercancreate ? 'multicurrency_tx' : 'none'), $object->multicurrency_code);
90 } else {
91 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
92 if ($object->status == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
93 print '<div class="inline-block"> &nbsp; &nbsp; &nbsp; &nbsp; ';
94 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate&token='.newToken().'" title="'.$langs->trans("ActualizeCurrency").'">';
95 //print $langs->trans("ActualizeCurrency");
96 print img_picto($langs->trans("ActualizeCurrency"), 'undo');
97 print '</a>';
98 print '</div>';
99 }
100 }
101 print '</td></tr>';
102 }
103}
104
105print '<!-- END template -->';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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.