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