dolibarr 18.0.6
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 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 */
28
35// Load Dolibarr environment
36require '../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php';
39
40
41// Load translation files required by the page
42$langs->loadLangs(array('multicurrency'));
43
44// Get Parameters
45$action = GETPOST('action', 'alpha');
46$massaction = GETPOST('massaction', 'alpha');
47$show_files = GETPOST('show_files', 'int');
48$confirm = GETPOST('confirm', 'alpha');
49$toselect = GETPOST('toselect', 'array');
50$id_rate_selected = GETPOST('id_rate', 'int');
51$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
52$search_date_sync = dol_mktime(0, 0, 0, GETPOST('search_date_syncmonth', 'int'), GETPOST('search_date_syncday', 'int'), GETPOST('search_date_syncyear', 'int'));
53$search_date_sync_end = dol_mktime(0, 0, 0, GETPOST('search_date_sync_endmonth', 'int'), GETPOST('search_date_sync_endday', 'int'), GETPOST('search_date_sync_endyear', 'int'));
54$search_rate = GETPOST('search_rate', 'alpha');
55$search_code = GETPOST('search_code', 'alpha');
56$multicurrency_code = GETPOST('multicurrency_code', 'alpha');
57$dateinput = dol_mktime(0, 0, 0, GETPOST('dateinputmonth', 'int'), GETPOST('dateinputday', 'int'), GETPOST('dateinputyear', 'int'));
58$rateinput = price2num(GETPOST('rateinput', 'alpha'));
59$optioncss = GETPOST('optioncss', 'alpha');
60$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
61$sortfield = GETPOST('sortfield', 'aZ09comma');
62$sortorder = GETPOST('sortorder', 'aZ09comma');
63$page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0);
64
65if (empty($page) || $page == -1) {
66 $page = 0;
67} // If $page is not defined, or '' or -1
68$offset = $limit * $page;
69$pageprev = $page - 1;
70$pagenext = $page + 1;
71if (!$sortfield) $sortfield = "cr.date_sync";
72if (!$sortorder) $sortorder = "DESC";
73
74
75// Initialize technical objects
76$object = new CurrencyRate($db);
77$form = new Form($db);
78$extrafields = new ExtraFields($db);
79
80
81// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
82$hookmanager->initHooks(array('EditorRatelist', 'globallist'));
83
84if (empty($action)) {
85 $action = 'list';
86}
87
88// List of fields to search into when doing a "search in all"
89$fieldstosearchall = array(
90 'cr.date_sync'=>"date_sync",
91 'cr.rate'=>"rate",
92 'm.code'=>"code",
93);
94
95// Definition of fields for lists
96$arrayfields = array(
97 'cr.date_sync'=>array('label'=>'Date', 'checked'=>1),
98 'cr.rate'=>array('label'=>'Rate', 'checked'=>1),
99 'm.code'=>array('label'=>'Code', 'checked'=>1),
100);
101
102
103$object->fields = dol_sort_array($object->fields, 'position');
104$arrayfields = dol_sort_array($arrayfields, 'position');
105
106// Access control
107// TODO Open this page to a given permission so a sale representative can modify change rates. Permission should be added into module multicurrency.
108// One permission to read rates (history) and one to add/edit rates.
109if (!$user->admin || !isModEnabled("multicurrency")) {
111}
112
113$error = 0;
114
115
116/*
117 * Actions
118 */
119
120if ($action == "create") {
121 if (empty($multicurrency_code) || $multicurrency_code == '-1') {
122 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Currency")), null, "errors");
123 $error++;
124 }
125 if ($rateinput === '0') {
126 setEventMessages($langs->trans('NoEmptyRate'), null, "errors");
127 $error++;
128 } elseif (empty($rateinput)) {
129 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, "errors");
130 $error++;
131 }
132
133 if (!$error) {
134 $currencyRate_static = new CurrencyRate($db);
135 $currency_static = new MultiCurrency($db);
136 $fk_currency = $currency_static->getIdFromCode($db, $multicurrency_code);
137
138 $currencyRate_static->fk_multicurrency = $fk_currency;
139 $currencyRate_static->entity = $conf->entity;
140 $currencyRate_static->date_sync = $dateinput;
141 $currencyRate_static->rate = $rateinput;
142
143 $result = $currencyRate_static->create(intval($fk_currency));
144 if ($result > 0) {
145 setEventMessages($langs->trans('successRateCreate', $multicurrency_code), null);
146 } else {
147 dol_syslog("currencyRate:createRate", LOG_WARNING);
148 setEventMessages($currencyRate_static->error, $currencyRate_static->errors, 'errors');
149 }
150 }
151}
152
153if ($action == 'update') {
154 $currencyRate = new CurrencyRate($db);
155 $result = $currencyRate->fetch($id_rate_selected);
156 if ($result > 0) {
157 $currency_static = new MultiCurrency($db);
158 $fk_currency = $currency_static->getIdFromCode($db, $multicurrency_code);
159 $currencyRate->date_sync = $dateinput;
160 $currencyRate->fk_multicurrency = $fk_currency;
161 $currencyRate->rate = $rateinput;
162 $res = $currencyRate->update();
163 if ($res) {
164 setEventMessages($langs->trans('successUpdateRate'), null);
165 } else {
166 setEventMessages($currencyRate->error, $currencyRate->errors, "errors");
167 }
168 } else {
169 setEventMessages($langs->trans('Error'), null, "warnings");
170 }
171}
172
173if ($action == "deleteRate") {
174 $current_rate = new CurrencyRate($db);
175 $current_rate->fetch(intval($id_rate_selected));
176
177 if ($current_rate) {
178 $current_currency = new MultiCurrency($db);
179 $current_currency->fetch($current_rate->fk_multicurrency);
180 if ($current_currency) {
181 $delayedhtmlcontent = $form->formconfirm(
182 $_SERVER["PHP_SELF"].'?id_rate='.$id_rate_selected,
183 $langs->trans('DeleteLineRate'),
184 $langs->trans('ConfirmDeleteLineRate', $current_rate->rate, $current_currency->name, $current_rate->date_sync),
185 'confirm_delete',
186 '',
187 0,
188 1
189 );
190 } else {
191 dol_syslog("Multicurrency::fetch", LOG_WARNING);
192 }
193 } else {
194 setEventMessage($langs->trans('NoCurrencyRateSelected'), "warnings");
195 }
196}
197
198if ($action == "confirm_delete") {
199 $current_rate = new CurrencyRate($db);
200 $current_rate->fetch(intval($id_rate_selected));
201 if ($current_rate) {
202 $result = $current_rate->delete();
203 if ($result) {
204 setEventMessages($langs->trans('successRateDelete'), null);
205 } else {
206 setEventMessages($current_rate->error, $current_rate->errors, 'errors');
207 }
208 } else {
209 setEventMessages($langs->trans('NoCurrencyRateSelected'), null, "warnings");
210 dol_syslog($langs->trans('NoCurrencyRateSelected'), LOG_WARNING);
211 }
212}
213
214
215if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
216if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
217
218$parameters = array();
219$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
220if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
221if (empty($reshook)) {
222 // Selection of new fields
223 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
224
225 // Purge search criteria
226 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
227 $sall = "";
228 $search_date_sync = "";
229 $search_date_sync_end="";
230 $search_rate = "";
231 $search_code = "";
232 $search_array_options = array();
233 }
234
235 // Mass actions
236 $objectclass = "CurrencyRate";
237 $uploaddir = $conf->multicurrency->multidir_output; // define only because core/actions_massactions.inc.php want it
238 $permissiontoread = $user->admin;
239 $permissiontodelete = $user->admin;
240 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
241}
242
243
244/*
245 * View
246 */
247
248$form = new Form($db);
249
250$title = $langs->trans("CurrencyRate");
251$page_name = "MultiCurrencySetup";
252$help_url = '';
253
254llxHeader('', $title, $help_url, '');
255// Subheader
256$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
257print load_fiche_titre($langs->trans($page_name), $linkback);
258
259// Configuration header
261print dol_get_fiche_head($head, 'ratelist', $langs->trans("ModuleSetup"), -1, "multicurrency");
262
263// ACTION
264
265if (!in_array($action, array("updateRate", "deleteRate"))) {
266 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">';
267 print '<input type="hidden" name="token" value="'.newToken().'">';
268
269 print '<div class="div-table-responsive-no-min">';
270 print '<table class="noborder centpercent"><tr>';
271
272 print ' <td>'.$langs->trans('Date').'</td>';
273 print ' <td>';
274 print $form->selectDate($dateinput, 'dateinput', 0, 0, 1, '', 1, 1);
275 print '</td>';
276
277 print '<td> '.$langs->trans('Currency').'</td>';
278 print '<td>'.$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 1, " code != '".$db->escape($conf->currency)."'", true).'</td>';
279
280 print ' <td>'.$langs->trans('Rate').' / '.$langs->getCurrencySymbol($conf->currency).'</td>';
281 print ' <td><input type="text" min="0" step="any" class="maxwidth75" name="rateinput" value="'.dol_escape_htmltag($rateinput).'"></td>';
282
283 print '<td>';
284 print '<input type="hidden" name="action" value="create">';
285 print '<input type="submit" class="button button-add small" name="btnCreateCurrencyRate" value="'.$langs->trans('CreateRate').'">';
286 print '</td>';
287
288 print '</tr></table>';
289 print '</div>';
290
291 print '</form>';
292
293 print '<br>';
294}
295
296
297
298
299$sql = 'SELECT cr.rowid, cr.date_sync, cr.rate, cr.entity, m.code, m.name';
300// Add fields from hooks
301$parameters = array();
302$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
303$sql .= $hookmanager->resPrint;
304$sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr ';
305$sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid";
306if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
307if ($search_date_sync && $search_date_sync_end ) {
308 $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')";
309} elseif ($search_date_sync && !$search_date_sync_end) {
310 $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync));
311}
312if ($search_rate) $sql .= natural_search('cr.rate', $search_rate);
313if ($search_code) $sql .= natural_search('m.code', $search_code);
314$sql .= " WHERE m.code <> '".$db->escape($conf->currency)."'";
315
316// Add where from hooks
317$parameters = array();
318$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
319$sql .= $hookmanager->resPrint;
320$sql .= " GROUP BY cr.rowid, cr.date_sync, cr.rate, m.code, cr.entity, m.code, m.name";
321
322// Add fields from hooks
323$parameters = array();
324$reshook = $hookmanager->executeHooks('printFieldSelect', $parameters); // Note that $action and $object may have been modified by hook
325$sql .= $hookmanager->resPrint;
326
327$sql .= $db->order($sortfield, $sortorder);
328
329
330$nbtotalofrecords = '';
331if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
332 $result = $db->query($sql);
333
334 if ($result) {
335 $nbtotalofrecords = $db->num_rows($result);
336 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
337 $page = 0;
338 $offset = 0;
339 }
340 } else {
341 setEventMessage($langs->trans('No_record_on_multicurrency_rate'), 'warnings');
342 }
343}
344
345$sql .= $db->plimit($limit + 1, $offset);
346
347$resql = $db->query($sql);
348if ($resql) {
349 $num = $db->num_rows($resql);
350 $arrayofselected = is_array($toselect) ? $toselect : array();
351
352 $param = '';
353 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
354 $param .= '&contextpage='.urlencode($contextpage);
355 }
356 if ($limit > 0 && $limit != $conf->liste_limit) {
357 $param .= '&limit='.((int) $limit);
358 }
359 if ($sall) {
360 $param .= "&sall=".urlencode($sall);
361 }
362
363 if ($search_date_sync) $param = "&search_date_sync=".$search_date_sync;
364 if ($search_date_sync_end) $param="&search_date_sync_end=".$search_date_sync_end;
365 if ($search_rate) $param = "&search_rate=".urlencode($search_rate);
366 if ($search_code != '') $param.="&search_code=".urlencode($search_code);
367
368 // Add $param from extra fields
369 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
370
371 if ($user->admin) {
372 $arrayofmassactions['predelete'] = $langs->trans("Delete");
373 }
374 if (in_array($massaction, array('presend', 'predelete'))) {
375 $arrayofmassactions = array();
376 }
377 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
378
379 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="formulaire">';
380 if ($optioncss != '') {
381 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
382 }
383 print '<input type="hidden" name="token" value="'.newToken().'">';
384 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
385 print '<input type="hidden" name="action" value="list">';
386 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
387 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
388 print '<input type="hidden" name="page" value="'.$page.'">';
389 print '<input type="hidden" name="type" value="'.$type.'">';
390
391 print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_currency.png', 0, $newcardbutton, '', $limit);
392
393 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
394
395 if ($sall) {
396 foreach ($fieldstosearchall as $key => $val) {
397 $fieldstosearchall[$key] = $langs->trans($val);
398 }
399 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
400 }
401
402 // Filter on categories
403 $moreforfilter = '';
404
405
406 $parameters = array();
407 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
408 if (empty($reshook)) {
409 $moreforfilter .= $hookmanager->resPrint;
410 } else {
411 $moreforfilter = $hookmanager->resPrint;
412 }
413
414 if ($moreforfilter) {
415 print '<div class="liste_titre liste_titre_bydiv centpercent">';
416 print $moreforfilter;
417 print '</div>';
418 }
419
420 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
421 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
422 if ($massactionbutton) {
423 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
424 }
425
426 print '<div class="div-table-responsive">';
427 print '<table class="tagtable centpercent nomarginbottom liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
428
429 // Lines with input filters
430 print '<tr class="liste_titre_filter">';
431
432 // date
433 if (!empty($arrayfields['cr.date_sync']['checked'])) {
434 print '<td class="liste_titre" align="left">';
435 print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d"), 'search_date_sync', 0, 0, 1);
436 print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1);
437 print '</td>';
438 }
439 // code
440 if (!empty($arrayfields['m.code']['checked'])) {
441 print '<td class="liste_titre" align="left">';
442 print $form->selectMultiCurrency($multicurrency_code, 'search_code', 1, " code != '".$conf->currency."'", true);
443 print '</td>';
444 }
445 // rate
446 if (!empty($arrayfields['cr.rate']['checked'])) {
447 print '<td class="liste_titre" align="left">';
448 print '<input class="flat maxwidth75" type="text" name="search_rate" value="'.dol_escape_htmltag($search_rate).'">';
449 print '</td>';
450 }
451
452 // Fields from hook
453 $parameters = array('arrayfields'=>$arrayfields);
454 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
455 print $hookmanager->resPrint;
456
457 print '<td class="liste_titre" align="middle">';
458 $searchpicto = $form->showFilterButtons();
459 print $searchpicto;
460 print '</td>';
461
462 print '</tr>';
463
464 print '<tr class="liste_titre">';
465 if (!empty($arrayfields['cr.date_sync']['checked'])) {
466 print_liste_field_titre($arrayfields['cr.date_sync']['label'], $_SERVER["PHP_SELF"], "cr.date_sync", "", $param, "", $sortfield, $sortorder);
467 }
468 if (!empty($arrayfields['m.code']['checked'])) {
469 print_liste_field_titre($arrayfields['m.code']['label'], $_SERVER["PHP_SELF"], "m.code", "", $param, "", $sortfield, $sortorder);
470 }
471 if (!empty($arrayfields['cr.rate']['checked'])) {
472 print_liste_field_titre($arrayfields['cr.rate']['label'], $_SERVER["PHP_SELF"], "cr.rate", "", $param, "", $sortfield, $sortorder);
473 }
474
475 // Hook fields
476 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
477 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
478 print $hookmanager->resPrint;
479
480 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
481 print "</tr>\n";
482
483 $i = 0;
484 $totalarray = array();
485 while ($i < min($num, $limit)) {
486 $obj = $db->fetch_object($resql);
487
488 print '<tr class="oddeven">';
489
490 // USER REQUEST UPDATE FOR THIS LINE
491 if ($action == "updateRate" && $obj->rowid == $id_rate_selected) {
492 // var_dump($obj);
493 print ' <td><input class="minwidth200" name="dateinput" value="'. date('Y-m-d', dol_stringtotime($obj->date_sync)) .'" type="date"></td>';
494 print '<td>' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . '</td>';
495 print ' <td><input type="text" min ="0" step="any" class="minwidth200" name="rateinput" value="' . dol_escape_htmltag($obj->rate) . '"></td>';
496
497 print '<td class="center nowrap ">';
498 print '<input type="hidden" name="page" value="'.dol_escape_htmltag($page).'">';
499 print '<input type="hidden" name="id_rate" value="'.dol_escape_htmltag($obj->rowid).'">';
500 print '<button type="submit" class="button" name="action" value="update">'.$langs->trans("Modify").'</button>';
501 print '<button type="submit" class="button" name="action" value="cancel">'.$langs->trans("Cancel").'</button>';
502 print '</td>';
503 } else {
504 // date_sync
505 if (!empty($arrayfields['cr.date_sync']['checked'])) {
506 print '<td class="tdoverflowmax200">';
507 print $obj->date_sync;
508 print "</td>\n";
509 if (!$i) $totalarray['nbfield']++;
510 }
511
512 // code
513 if (!empty($arrayfields['m.code']['checked'])) {
514 print '<td class="tdoverflowmax200">';
515 print $obj->code;
516 print ' - <span class="opacitymedium">'.$obj->name.'</span>';
517 print "</td>\n";
518
519 if (! $i) $totalarray['nbfield']++;
520 }
521
522 // rate
523 if (!empty($arrayfields['cr.rate']['checked'])) {
524 print '<td class="tdoverflowmax200">';
525 print $obj->rate;
526 print "</td>\n";
527 if (! $i) $totalarray['nbfield']++;
528 }
529
530
531 // Fields from hook
532 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj);
533 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
534 print $hookmanager->resPrint;
535
536 // Action
537 print '<td class="nowrap" align="center">';
538 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
539 $selected = 0;
540 if (in_array($obj->rowid, $arrayofselected)) {
541 $selected = 1;
542 }
543 print '<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER["PHP_SELF"].'?action=updateRate&token='.newToken().'&id_rate='.$obj->rowid.'">'.img_picto('edit', 'edit').'</a>';
544 print '<a class="marginleftonly marginrightonly" href="'.$_SERVER["PHP_SELF"].'?action=deleteRate&token='.newToken().'&id_rate='.$obj->rowid.'">'.img_picto('delete', 'delete').'</a>';
545 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
546 }
547 print '</td>';
548 if (!$i) {
549 $totalarray['nbfield']++;
550 }
551
552 print "</tr>\n";
553 $i++;
554 }
555 }
556
557 $db->free($resql);
558
559 print "</table>";
560 print "</div>";
561
562 print '</form>';
563} else {
564 dol_print_error($db);
565}
566
567
568 llxFooter();
569 $db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
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:410
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...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.