dolibarr 24.0.0-beta
multicurrency_rate.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
5 * Copyright (C) 2012-2016 Marcos García <marcosgdf@gmail.com>
6 * Copyright (C) 2013-2019 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
8 * Copyright (C) 2013 Jean Heimburger <jean@tiaris.info>
9 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
10 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
11 * Copyright (C) 2013 Adolfo segura <adolfo.segura@gmail.com>
12 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
13 * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
14 * Copyright (C) 2023-2026 Lenin Rivas <lenin.rivas777@gmail.com>
15 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
16 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 3 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <https://www.gnu.org/licenses/>.
30 */
31
38// Load Dolibarr environment
39require '../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php';
42
51// Load translation files required by the page
52$langs->loadLangs(array('admin', 'multicurrency'));
53
54// Get Parameters
55$action = GETPOST('action', 'alpha');
56$massaction = GETPOST('massaction', 'alpha');
57$show_files = GETPOSTINT('show_files');
58$confirm = GETPOST('confirm', 'alpha');
59$toselect = GETPOST('toselect', 'array:int');
60$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
61$optioncss = GETPOST('optioncss', 'alpha');
62$mode = GETPOST('mode', 'aZ'); // The display mode ('list', 'kanban', 'hierarchy', 'calendar', 'gantt', ...)
63
64// Load variable for pagination
65$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
66$sortfield = GETPOST('sortfield', 'aZ09comma');
67$sortorder = GETPOST('sortorder', 'aZ09comma');
68$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
69if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
70 // If $page is not defined, or '' or -1 or if we click on clear filters
71 $page = 0;
72}
73$offset = $limit * $page;
74$pageprev = $page - 1;
75$pagenext = $page + 1;
76
77if (!$sortfield) {
78 $sortfield = "cr.date_sync";
79}
80if (!$sortorder) {
81 $sortorder = "DESC";
82}
83
84$id_rate_selected = GETPOSTINT('id_rate');
85$search_all = trim(GETPOST('search_all', 'alphanohtml'));
86$search_date_sync = dol_mktime(0, 0, 0, GETPOSTINT('search_date_syncmonth'), GETPOSTINT('search_date_syncday'), GETPOSTINT('search_date_syncyear'));
87$search_date_sync_end = dol_mktime(0, 0, 0, GETPOSTINT('search_date_sync_endmonth'), GETPOSTINT('search_date_sync_endday'), GETPOSTINT('search_date_sync_endyear'));
88$search_rate = GETPOST('search_rate', 'alpha');
89$search_rate_direct = GETPOST('search_rate_direct', 'alpha');
90$search_code = GETPOST('search_code', 'alpha');
91$multicurrency_code = GETPOST('multicurrency_code', 'alpha');
92$dateinput = dol_mktime(0, 0, 0, GETPOSTINT('dateinputmonth'), GETPOSTINT('dateinputday'), GETPOSTINT('dateinputyear'));
93$rateinput = (float) price2num(GETPOST('rateinput', 'alpha'));
94$ratedirectinput = (float) price2num(GETPOST('ratedirectinput', 'alpha')); // Fix Direct
95$type = '';
96$texte = '';
97$newcardbutton = '';
98
99// Initialize technical objects
101$form = new Form($db);
102$extrafields = new ExtraFields($db);
103$hookmanager->initHooks(array('EditorRatelist', 'globallist'));
104
105if (empty($action)) {
106 $action = 'list';
107}
108
109// List of fields to search into when doing a "search in all"
110$fieldstosearchall = array(
111 'cr.date_sync' => "date_sync",
112 'cr.rate' => "rate",
113 'cr.rate_direct' => "rate_direct",
114 'm.code' => "code",
115);
116
117// Definition of fields for lists
118$arrayfields = array(
119 'cr.date_sync' => array('label' => 'Date', 'checked' => '1'),
120 'cr.rate' => array('label' => 'Rate', 'checked' => '1'),
121 'cr.rate_direct' => array('label' => 'RateDirect', 'checked' => '0', 'enabled' => (!getDolGlobalString('MULTICURRENCY_USE_RATE_DIRECT') ? '0' : '1')),
122 'm.code' => array('label' => 'Code', 'checked' => '1'),
123);
124
125
126$object->fields = dol_sort_array($object->fields, 'position');
127$arrayfields = dol_sort_array($arrayfields, 'position');
128
129// Access control
130// TODO Open this page to a given permission so a sale representative can modify change rates. Permission should be added into module multicurrency.
131// One permission to read rates (history) and one to add/edit rates.
132if (!$user->admin || !isModEnabled("multicurrency")) {
134}
135
136$error = 0;
137
138
139/*
140 * Actions
141 */
142
143if ($action == "create" && $user->hasRight('multicurrency', 'currency', 'read')) {
144 if (empty($multicurrency_code) || $multicurrency_code == '-1') {
145 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Currency")), null, "errors");
146 $error++;
147 }
148 if ($rateinput == 0) {
149 setEventMessages($langs->trans('NoEmptyRate'), null, "errors");
150 $error++;
151 } elseif (empty($rateinput)) {
152 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, "errors");
153 $error++;
154 }
155
156 if (!$error) {
157 $currencyRate_static = new CurrencyRate($db);
158 $currency_static = new MultiCurrency($db);
159 $fk_currency = $currency_static->getIdFromCode($db, $multicurrency_code);
160
161 $currencyRate_static->fk_multicurrency = $fk_currency;
162 $currencyRate_static->entity = $conf->entity;
163 $currencyRate_static->date_sync = $dateinput;
164 $currencyRate_static->rate = $rateinput;
165 $currencyRate_static->rate_direct = $ratedirectinput;
166
167 $result = $currencyRate_static->create($user, intval($fk_currency));
168 if ($result > 0) {
169 setEventMessages($langs->trans('successRateCreate', $multicurrency_code), null);
170 } else {
171 dol_syslog("currencyRate:createRate", LOG_WARNING);
172 setEventMessages($currencyRate_static->error, $currencyRate_static->errors, 'errors');
173 }
174 }
175}
176
177if ($action == 'update' && $user->hasRight('multicurrency', 'currency', 'read')) {
178 $currencyRate = new CurrencyRate($db);
179 $result = $currencyRate->fetch($id_rate_selected);
180 if ($result > 0) {
181 $currency_static = new MultiCurrency($db);
182 $fk_currency = $currency_static->getIdFromCode($db, $multicurrency_code);
183 $currencyRate->date_sync = $dateinput;
184 $currencyRate->fk_multicurrency = $fk_currency;
185 $currencyRate->rate = $rateinput;
186 $currencyRate->rate_direct = $ratedirectinput;
187 $res = $currencyRate->update($user);
188 if ($res) {
189 setEventMessages($langs->trans('successUpdateRate'), null);
190 } else {
191 setEventMessages($currencyRate->error, $currencyRate->errors, "errors");
192 }
193 } else {
194 setEventMessages($langs->trans('Error'), null, "warnings");
195 }
196}
197
198if ($action == "deleteRate" && $user->hasRight('multicurrency', 'currency', 'read')) {
199 $current_rate = new CurrencyRate($db);
200 $current_rate->fetch((int) $id_rate_selected);
201
202 if ($current_rate) {
203 $current_currency = new MultiCurrency($db);
204 $current_currency->fetch($current_rate->fk_multicurrency);
205 if ($current_currency) {
206 $delayedhtmlcontent = $form->formconfirm(
207 $_SERVER["PHP_SELF"].'?id_rate='.$id_rate_selected,
208 $langs->trans('DeleteLineRate'),
209 $langs->trans('ConfirmDeleteLineRate', $current_rate->rate, $current_currency->name, $current_rate->date_sync),
210 'confirm_delete',
211 '',
212 0,
213 1
214 );
215 } else {
216 dol_syslog("Multicurrency::fetch", LOG_WARNING);
217 }
218 } else {
219 setEventMessage($langs->trans('NoCurrencyRateSelected'), "warnings");
220 }
221}
222
223if ($action == "confirm_delete" && $user->hasRight('multicurrency', 'currency', 'read')) {
224 $current_rate = new CurrencyRate($db);
225 $current_rate->fetch((int) $id_rate_selected);
226 if ($current_rate) {
227 $result = $current_rate->delete($user);
228 if ($result) {
229 setEventMessages($langs->trans('successRateDelete'), null);
230 } else {
231 setEventMessages($current_rate->error, $current_rate->errors, 'errors');
232 }
233 } else {
234 setEventMessages($langs->trans('NoCurrencyRateSelected'), null, "warnings");
235 dol_syslog($langs->trans('NoCurrencyRateSelected'), LOG_WARNING);
236 }
237}
238
239
240if (GETPOST('cancel', 'alpha')) {
241 $action = 'list';
242 $massaction = '';
243}
244if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
245 $massaction = '';
246}
247
248$parameters = array();
249$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
250if ($reshook < 0) {
251 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
252}
253if (empty($reshook)) {
254 // Selection of new fields
255 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
256
257 // Purge search criteria
258 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
259 $search_all = "";
260 $search_date_sync = "";
261 $search_date_sync_end = "";
262 $search_rate = "";
263 $search_code = "";
264 $search_array_options = array();
265 }
266
267 // Mass actions
268 $objectclass = "CurrencyRate";
269 $uploaddir = $conf->multicurrency->multidir_output; // define only because core/actions_massactions.inc.php want it
270 $permissiontoread = $user->admin;
271 $permissiontodelete = $user->admin;
272 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
273}
274
275
276/*
277 * View
278 */
279
280$form = new Form($db);
281
282$title = $langs->trans("CurrencyRate");
283$page_name = "MultiCurrencySetup";
284$help_url = '';
285
286llxHeader('', $title, $help_url, '');
287// Subheader
288$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
289print load_fiche_titre($langs->trans($page_name), $linkback);
290
291// Configuration header
293print dol_get_fiche_head($head, 'ratelist', $langs->trans("ModuleSetup"), -1, "multicurrency");
294
295// ACTION
296
297if (!in_array($action, array("updateRate", "deleteRate"))) {
298 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">';
299 print '<input type="hidden" name="token" value="'.newToken().'">';
300
301 print '<div class="div-table-responsive-no-min">';
302 print '<table class="noborder centpercent"><tr>';
303
304 print ' <td>'.$langs->trans('Date').'</td>';
305 print ' <td>';
306 print $form->selectDate($dateinput, 'dateinput', 0, 0, 1, '', 1, 1);
307 print '</td>';
308
309 print '<td> '.$langs->trans('Currency').'</td>';
310 print '<td>'.$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 1, "(code:<>:'".$db->escape(getDolCurrency())."')", true).'</td>';
311
312 print ' <td>'.$langs->trans('Rate').' / '.$langs->getCurrencySymbol(getDolCurrency()).'</td>';
313 print ' <td><input type="text" min="0" step="any" class="maxwidth75" id="rateinput" name="rateinput" value="'.dol_escape_htmltag((string) $rateinput).'"></td>';
314
321 if (getDolGlobalString('MULTICURRENCY_USE_RATE_DIRECT')) {
322 print ' <td>'.$langs->trans('RateDirect').' / '.$langs->getCurrencySymbol(getDolCurrency()).'</td>';
323 print ' <td><input type="text" min="0" step="any" class="maxwidth75" id="ratedirectinput" name="ratedirectinput" value="'.dol_escape_htmltag((string) $ratedirectinput).'"></td>';
324 // LRR Calculate Rate Direct
325 print '<script type="text/javascript">';
326 print 'jQuery(document).ready(function () {
327 //alert("TC");
328 jQuery("#ratedirectinput").keyup(function () {
329 var valdirect = jQuery(this).val();
330 valindirect = 1 / parseFloat(valdirect);
331 jQuery("#rateinput").val(valindirect);
332 console.log("Rate Indirect:"+valindirect)
333 });
334 });';
335 print '</script>';
336 }
337
338 /* if (getDolGlobalString('MULTICURRENCY_USE_RATE_INDIRECT')) {
339 print ' <td>'.$langs->trans('RateIndirect').' / '.$langs->getCurrencySymbol(getDolCurrency()).'</td>';
340 print ' <td><input type="text" min="0" step="any" class="maxwidth75" id="rateindirectinput" name="rateindirectinput" value="'.dol_escape_htmltag((string) $rateindirectinput).'"></td>';
341 // LRR Calculate Rate Direct
342 print '<script type="text/javascript">';
343 print 'jQuery(document).ready(function () {
344 //alert("TC");
345 jQuery("#rateindirectinput").keyup(function () {
346 var valindirect = jQuery(this).val();
347 valdirect = 1 / parseFloat(valindirect);
348 jQuery("#rateinput").val(valdirect);
349 console.log("Rate Direct:"+valdirect)
350 });
351 });';
352 print '</script>';
353 } */
354
355 print '<td>';
356 print '<input type="hidden" name="action" value="create">';
357 print '<input type="submit" class="button button-add small" name="btnCreateCurrencyRate" value="'.$langs->trans('CreateRate').'">';
358 print '</td>';
359
360 print '</tr></table>';
361 print '</div>';
362
363 print '</form>';
364
365 print '<br>';
366}
367
368
369
370
371$sql = 'SELECT cr.rowid, cr.date_sync, cr.rate, cr.rate_direct, cr.entity, m.code, m.name';
372// Add fields from hooks
373$parameters = array();
374$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
375$sql .= $hookmanager->resPrint;
376$sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr ';
377$sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid";
378if ($search_all) {
379 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
380}
381if ($search_date_sync && $search_date_sync_end) {
382 $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')";
383} elseif ($search_date_sync && !$search_date_sync_end) {
384 $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync));
385}
386if ($search_rate) {
387 $sql .= natural_search('cr.rate', $search_rate, 1);
388}
389if ($search_code) {
390 $sql .= natural_search('m.code', $search_code);
391}
392$sql .= " WHERE cr.entity IN (".getEntity('multicurrency').")";
393$sql .= " AND m.code <> '".$db->escape(getDolCurrency())."'";
394
395// Add where from hooks
396$parameters = array();
397$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
398$sql .= $hookmanager->resPrint;
399$sql .= " GROUP BY cr.rowid, cr.date_sync, cr.rate, cr.rate_direct, m.code, cr.entity, m.code, m.name";
400
401// Add fields from hooks
402$parameters = array();
403$reshook = $hookmanager->executeHooks('printFieldSelect', $parameters); // Note that $action and $object may have been modified by hook
404$sql .= $hookmanager->resPrint;
405
406$sql .= $db->order($sortfield, $sortorder);
407
408
409$nbtotalofrecords = '';
410if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
411 $result = $db->query($sql);
412
413 if ($result) {
414 $nbtotalofrecords = $db->num_rows($result);
415 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
416 $page = 0;
417 $offset = 0;
418 }
419 } else {
420 setEventMessage($langs->trans('No_record_on_multicurrency_rate'), 'warnings');
421 }
422}
423
424$sql .= $db->plimit($limit + 1, $offset);
425
426$resql = $db->query($sql);
427if ($resql) {
428 $num = $db->num_rows($resql);
429 $arrayofselected = is_array($toselect) ? $toselect : array();
430
431 $param = '';
432 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
433 $param .= '&contextpage='.urlencode($contextpage);
434 }
435 if ($limit > 0 && $limit != $conf->liste_limit) {
436 $param .= '&limit='.((int) $limit);
437 }
438 if ($search_all) {
439 $param .= "&search_all=".urlencode($search_all);
440 }
441
442 if ($search_date_sync) {
443 $param = "&search_date_sync=".$search_date_sync;
444 }
445 if ($search_date_sync_end) {
446 $param = "&search_date_sync_end=".$search_date_sync_end;
447 }
448 if ($search_rate) {
449 $param = "&search_rate=".urlencode($search_rate);
450 }
451 if ($search_code != '') {
452 $param .= "&search_code=".urlencode($search_code);
453 }
454
455 // Add $param from extra fields
456 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
457
458 if ($user->admin) {
459 $arrayofmassactions['predelete'] = $langs->trans("Delete");
460 }
461 if (in_array($massaction, array('presend', 'predelete'))) {
462 $arrayofmassactions = array();
463 }
464 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
465
466 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" name="formulaire">'."\n";
467 if ($optioncss != '') {
468 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
469 }
470 print '<input type="hidden" name="token" value="'.newToken().'">';
471 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
472 print '<input type="hidden" name="action" value="list">';
473 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
474 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
475 print '<input type="hidden" name="page" value="'.$page.'">';
476 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
477 print '<input type="hidden" name="page_y" value="">';
478 print '<input type="hidden" name="type" value="'.$type.'">';
479
480 print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_currency.png', 0, $newcardbutton, '', $limit);
481
482 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
483
484 if ($search_all) {
485 $setupstring = '';
486 foreach ($fieldstosearchall as $key => $val) {
487 $fieldstosearchall[$key] = $langs->trans($val);
488 $setupstring .= $key."=".$val.";";
489 }
490 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
491 }
492
493 $moreforfilter = '';
494
495 $parameters = array();
496 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
497 if (empty($reshook)) {
498 $moreforfilter .= $hookmanager->resPrint;
499 } else {
500 $moreforfilter = $hookmanager->resPrint;
501 }
502 $parameters = array(
503 'arrayfields' => &$arrayfields,
504 );
505
506 if (!empty($moreforfilter)) {
507 print '<div class="liste_titre liste_titre_bydiv centpercent">';
508 print $moreforfilter;
509 print '</div>';
510 }
511
512 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
513 $htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
514 $selectedfields = (($mode != 'kanban' && $mode != 'kanbangroupby') ? $htmlofselectarray : '');
515 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
516
517 print '<div class="div-table-responsive">';
518 print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
519
520 // Fields title search
521 // --------------------------------------------------------------------
522 print '<tr class="liste_titre_filter">';
523
524 // Action column
525 if ($conf->main_checkbox_left_column) {
526 print '<td class="liste_titre center maxwidthsearch">';
527 $searchpicto = $form->showFilterButtons('left');
528 print $searchpicto;
529 print '</td>';
530 }
531 // date
532 if (!empty($arrayfields['cr.date_sync']['checked'])) {
533 print '<td class="liste_titre" align="left">';
534 print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d"), 'search_date_sync', 0, 0, 1);
535 print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1);
536 print '</td>';
537 }
538 // code
539 if (!empty($arrayfields['m.code']['checked'])) {
540 print '<td class="liste_titre" align="left">';
541 print $form->selectMultiCurrency($multicurrency_code, 'search_code', 1, "(code:<>:'".getDolCurrency()."')", true);
542 print '</td>';
543 }
544 // rate
545 if (!empty($arrayfields['cr.rate']['checked'])) {
546 print '<td class="liste_titre" align="left">';
547 print '<input class="flat maxwidth75" type="text" name="search_rate" value="'.dol_escape_htmltag($search_rate).'">';
548 print '</td>';
549 }
550 // rate
551 if (!empty($arrayfields['cr.rate_direct']['checked'])) {
552 print '<td class="liste_titre" align="left">';
553 print '<input class="flat maxwidth75" type="text" name="search_rate_direct" value="'.dol_escape_htmltag($search_rate_direct).'">';
554 print '</td>';
555 }
556
557 // Fields from hook
558 $parameters = array('arrayfields' => $arrayfields);
559 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
560 print $hookmanager->resPrint;
561
562 // Action column
563 if (!$conf->main_checkbox_left_column) {
564 print '<td class="liste_titre center">';
565 $searchpicto = $form->showFilterButtons();
566 print $searchpicto;
567 print '</td>';
568 }
569 print '</tr>';
570
571 print '<tr class="liste_titre">';
572 // Action column
573 if ($conf->main_checkbox_left_column) {
574 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ');
575 }
576 if (!empty($arrayfields['cr.date_sync']['checked'])) {
577 // @phan-suppress-next-line PhanTypeInvalidDimOffset
578 print_liste_field_titre($arrayfields['cr.date_sync']['label'], $_SERVER["PHP_SELF"], "cr.date_sync", "", $param, "", $sortfield, $sortorder);
579 }
580 if (!empty($arrayfields['m.code']['checked'])) {
581 print_liste_field_titre($arrayfields['m.code']['label'], $_SERVER["PHP_SELF"], "m.code", "", $param, "", $sortfield, $sortorder);
582 }
583 if (!empty($arrayfields['cr.rate']['checked'])) {
584 print_liste_field_titre($arrayfields['cr.rate']['label'], $_SERVER["PHP_SELF"], "cr.rate", "", $param, "", $sortfield, $sortorder);
585 }
586 if (!empty($arrayfields['cr.rate_direct']['checked'])) {
587 print_liste_field_titre($arrayfields['cr.rate_direct']['label'], $_SERVER["PHP_SELF"], "cr.rate_direct", "", $param, "", $sortfield, $sortorder);
588 }
589
590 // Hook fields
591 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
592 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
593 print $hookmanager->resPrint;
594 // Action column
595 if (!$conf->main_checkbox_left_column) {
596 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch center ');
597 }
598 print "</tr>\n";
599
600 $i = 0;
601 $totalarray = array();
602 $totalarray['nbfield'] = 0;
603 while ($i < min($num, $limit)) {
604 $obj = $db->fetch_object($resql);
605
606 print '<tr class="oddeven">';
607
608 // USER REQUEST UPDATE FOR THIS LINE
609 if ($action == "updateRate" && $obj->rowid == $id_rate_selected) {
610 if ($conf->main_checkbox_left_column) {
611 print '<td class="center">';
612 print '</td>';
613 }
614 print '<td><input class="minwidth200" name="dateinput" value="'. date('Y-m-d', dol_stringtotime($obj->date_sync)) .'" type="date"></td>';
615 print '<td>' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, "(code:<>:'".getDolCurrency()."')", true) . '</td>';
616 print '<td><input type="text" min="0" step="any" class="maxwidth100" name="rateinput" value="' . dol_escape_htmltag($obj->rate) . '">';
617 print '<input type="hidden" name="page" value="'.dol_escape_htmltag((string) $page).'">';
618 print '<input type="hidden" name="id_rate" value="'.dol_escape_htmltag($obj->rowid).'">';
619 print '<button type="submit" class="button small reposition" name="action" value="update">'.$langs->trans("Modify").'</button>';
620 print '<button type="submit" class="button small reposition" name="action" value="cancel">'.$langs->trans("Cancel").'</button>';
621 print '</td>';
622 if (!$conf->main_checkbox_left_column) {
623 print '<td class="center">';
624 print '</td>';
625 }
626 } else {
627 // Action
628 if ($conf->main_checkbox_left_column) {
629 print '<td class="nowrap center">';
630 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
631 $selected = 0;
632 if (in_array($obj->rowid, $arrayofselected)) {
633 $selected = 1;
634 }
635 print '<a class="editfielda marginleftonly marginrightonly reposition" href="'.$_SERVER["PHP_SELF"].'?action=updateRate&token='.newToken().'&id_rate='.$obj->rowid.'">'.img_picto('edit', 'edit').'</a>';
636 print '<a class="marginleftonly marginrightonly reposition" href="'.$_SERVER["PHP_SELF"].'?action=deleteRate&token='.newToken().'&id_rate='.$obj->rowid.'">'.img_picto('delete', 'delete').'</a>';
637 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
638 }
639 print '</td>';
640 if (!$i) {
641 $totalarray['nbfield']++;
642 }
643 }
644
645 // date_sync
646 if (!empty($arrayfields['cr.date_sync']['checked'])) {
647 print '<td class="tdoverflowmax200">';
648 print $obj->date_sync;
649 print "</td>\n";
650 if (!$i) {
651 $totalarray['nbfield']++;
652 }
653 }
654
655 // code
656 if (!empty($arrayfields['m.code']['checked'])) {
657 print '<td class="tdoverflowmax200">';
658 print $obj->code;
659 print ' - <span class="opacitymedium">'.$obj->name.'</span>';
660 print "</td>\n";
661
662 if (! $i) {
663 $totalarray['nbfield']++;
664 }
665 }
666
667 // rate
668 if (!empty($arrayfields['cr.rate']['checked'])) {
669 print '<td class="tdoverflowmax200">';
670 print $obj->rate;
671 print "</td>\n";
672 if (! $i) {
673 $totalarray['nbfield']++;
674 }
675 }
676
677 // rate direct
678 if (!empty($arrayfields['cr.rate_direct']['checked'])) {
679 print '<td class="tdoverflowmax200">';
680 print $obj->rate_direct;
681 print "</td>\n";
682 if (! $i) {
683 $totalarray['nbfield']++;
684 }
685 }
686
687
688 // Fields from hook
689 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj);
690 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
691 print $hookmanager->resPrint;
692
693 // Action
694 if (!$conf->main_checkbox_left_column) {
695 print '<td class="nowrap center">';
696 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
697 $selected = 0;
698 if (in_array($obj->rowid, $arrayofselected)) {
699 $selected = 1;
700 }
701 print '<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER["PHP_SELF"].'?action=updateRate&token='.newToken().'&id_rate='.$obj->rowid.'">'.img_picto('edit', 'edit').'</a>';
702 print '<a class="marginleftonly marginrightonly" href="'.$_SERVER["PHP_SELF"].'?action=deleteRate&token='.newToken().'&id_rate='.$obj->rowid.'">'.img_picto('delete', 'delete').'</a>';
703 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
704 }
705 print '</td>';
706 if (!$i) {
707 $totalarray['nbfield']++;
708 }
709 }
710
711 print "</tr>\n";
712 $i++;
713 }
714 }
715
716 $db->free($resql);
717
718 print "</table>";
719 print "</div>";
720
721 print '</form>';
722} else {
724}
725
726
727llxFooter();
728$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:497
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class CurrencyRate.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class Currency.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
Definition date.lib.php:435
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
multicurrencyAdminPrepareHead()
Prepare array with list of tabs.
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
Definition receipt.php:487
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.