From 26a40e30e3a452a8f11590bea4417754841f3655 Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 23 Dec 2020 14:46:07 +0100 Subject: [PATCH 01/18] multicurrency update online and change some behaviors --- htdocs/multicurrency/multicurrency_rate.php | 185 +++++++++----------- 1 file changed, 82 insertions(+), 103 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index eae788b0587..376269c0806 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -46,7 +46,8 @@ $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $id_rate_selected = GETPOST('id_rate', 'int'); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$search_date_sync = GETPOST('search_date_sync', 'alpha'); +$search_date_sync = dol_mktime(0, 0, 0, GETPOST('search_date_syncmonth', 'int'), GETPOST('search_date_syncday', 'int'), GETPOST('search_date_syncyear', 'int')); +$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')); $search_rate = GETPOST('search_rate', 'alpha'); $search_code = GETPOST('search_code', 'alpha'); $multicurrency_code = GETPOST('multicurrency_code', 'alpha'); @@ -58,12 +59,13 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); + if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortfield) $sortfield = "cr.date_sync"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortorder) $sortorder = "ASC"; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks @@ -200,6 +202,7 @@ if (empty($reshook)) { $sall = ""; $search_date_sync = ""; + $search_date_sync_end=""; $search_rate = ""; $search_code = ""; $search_array_options = array(); @@ -233,7 +236,7 @@ print dol_get_fiche_head($head, 'ratelist', $langs->trans("ModuleSetup"), -1, "m // ACTION -if ($action != "updateRate") { +if (!in_array( $action, array("updateRate", "deleteRate"))) { print ''; print ''; print ''."\n"; @@ -243,15 +246,15 @@ if ($action != "updateRate") { print ''; print ''; - print '
'.$langs->trans("FormCreateRate").'
'; + print '
'; print ' '; print ' '; print ''; - print ''; + print ''; print ' '; print ' '; @@ -267,54 +270,7 @@ if ($action != "updateRate") { print '
'; } -if ($action == "updateRate") { - $current_rate = new CurrencyRate($db); - $current_rate->fetch(intval($id_rate_selected)); - if ($current_rate) { - $curr = new MultiCurrency($db); - $resultcurrentCurrency = $curr->fetch($current_rate->fk_multicurrency); - - if ($resultcurrentCurrency) { - $currency_code = $curr->code; - } else { - $currency_code = ''; - } - - print '
'.$langs->trans('Date').''; - print $form->selectDate($dateinput, 'dateinput'); + print $form->selectDate($dateinput, 'dateinput', 0, 0, 1); print ' '.$langs->trans('Currency').''.$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 0, " code != '".$conf->currency."'", true).''.$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 1, " code != '".$conf->currency."'", true).''.$langs->trans('Rate').'
'; - print ''; - print ''."\n"; - print '
'.$langs->trans("FormUpdateRate").'
'; - - $form = new Form($db); - print ''; - print ''; - - print ''; - print ' '; - print ''; - - print ''; - print ''; - - print ''; - print ''; - - print ''; - print '
'.$langs->trans('Date').''; - print $form->selectDate($current_rate->date_sync, 'dateinput'); - print ' '.$langs->trans('Currency').''.$form->selectMultiCurrency($currency_code, 'multicurrency_code', 0, " code != '".$conf->currency."'", true).''.$langs->trans('Rate').''; - print ''; - print ''; - print ''; - print ''.$langs->trans('CancelUpdate').''; - - print '
'; - print ''; - } else { - dol_syslog("currency_rate:list:update", LOG_WARNING); - } -} $sql = 'SELECT cr.rowid, cr.date_sync, cr.rate, cr.entity, m.code, m.name '; @@ -325,7 +281,11 @@ $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr '; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($search_date_sync) $sql .= natural_search('cr.date_sync', $search_date_sync); +if ($search_date_sync && $search_date_sync_end ){ + $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')"; +} elseif ($search_date_sync && !$search_date_sync_end) { + $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync)); +} if ($search_rate) $sql .= natural_search('cr.rate', $search_rate); if ($search_code) $sql .= natural_search('m.code', $search_code); $sql .= " WHERE m.code <> '".$db->escape($conf->currency)."'"; @@ -374,9 +334,10 @@ if ($resql) if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($sall) $param .= "&sall=".urlencode($sall); - if ($search_date_sync) $param = "&search_date_sync=".urlencode($search_date_sync); + if ($search_date_sync) $param = "&search_date_sync=".$search_date_sync; + if ($search_date_sync_end) $param="&search_date_sync_end=".$search_date_sync_end; if ($search_rate) $param = "&search_rate=".urlencode($search_rate); - if ($search_code != '') $param .= "&search_code=".urlencode($search_code); + if ($search_code != '') $param.="&search_code=".urlencode($search_code); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -426,7 +387,7 @@ if ($resql) if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; - print ''."\n"; + print '
'."\n"; // Lines with input filters print ''; @@ -435,14 +396,15 @@ if ($resql) if (!empty($arrayfields['cr.date_sync']['checked'])) { print ''; } // code if (!empty($arrayfields['m.code']['checked'])) { print ''; } // rate @@ -486,52 +448,69 @@ if ($resql) print ''; - // date_sync - if (!empty($arrayfields['cr.date_sync']['checked'])) - { - print '\n"; - if (!$i) $totalarray['nbfield']++; + // USER REQUEST UPDATE FOR THIS LINE + if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { + // var_dump($obj); + print ' '; + print ''; + print ' '; + + print ''; + } + else { + // date_sync + if (!empty($arrayfields['cr.date_sync']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // code + if (! empty($arrayfields['m.code']['checked'])) + { + print '\n"; + + if (! $i) $totalarray['nbfield']++; + } + + // rate + if (! empty($arrayfields['cr.rate']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } + + + // Fields from hook + $parameters = ['arrayfields' => $arrayfields, 'obj' => $obj]; + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Action + print ''; + if (!$i) $totalarray['nbfield']++; } - // code - if (!empty($arrayfields['m.code']['checked'])) - { - print '\n"; - - if (!$i) $totalarray['nbfield']++; - } - - // rate - if (!empty($arrayfields['cr.rate']['checked'])) - { - print '\n"; - if (!$i) $totalarray['nbfield']++; - } - - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Action - print ''; - if (!$i) $totalarray['nbfield']++; - print "\n"; $i++; } From a37bb4c6f23c506b176d2c977a8e5a947294b582 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 23 Dec 2020 13:51:13 +0000 Subject: [PATCH 02/18] Fixing style errors. --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 376269c0806..b8aaf0064c8 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -236,7 +236,7 @@ print dol_get_fiche_head($head, 'ratelist', $langs->trans("ModuleSetup"), -1, "m // ACTION -if (!in_array( $action, array("updateRate", "deleteRate"))) { +if (!in_array($action, array("updateRate", "deleteRate"))) { print '
'; - print ''; + print $form->selectDate($search_date_sync, 'search_date_sync', 0, 0, 1); + print $form->selectDate($search_date_sync_end, 'search_date_sync_end', 0, 0, 1); print ''; - print ''; + print $form->selectMultiCurrency($multicurrency_code, 'search_code', 1, " code != '".$conf->currency."'", true); print '
'; - print $obj->date_sync; - print "' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $obj->date_sync; + print "'; + print $obj->code." ".$obj->name; + print "'; + print $obj->rate; + print "'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print 'rowid.'">'.img_picto('edit', 'edit').''; + print 'rowid.'">'.img_picto('delete', 'delete').''; + print ''; + } + print ''; - print $obj->code." ".$obj->name; - print "'; - print $obj->rate; - print "'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - print 'rowid.'">'.img_picto('edit', 'edit').''; - print 'rowid.'">'.img_picto('delete', 'delete').''; - print ''; - } - print '
'; print ''; print ''."\n"; From 367a038a1555b464ca5527be645f5947e9d59b20 Mon Sep 17 00:00:00 2001 From: jpb Date: Thu, 24 Dec 2020 09:55:09 +0100 Subject: [PATCH 03/18] hotfix : idate on create currency --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 376269c0806..a7bf7f2c7f7 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -109,7 +109,7 @@ if ($action == "create") { $currencyRate_static->fk_multicurrency = $fk_currency; $currencyRate_static->entity = $conf->entity; - $currencyRate_static->date_sync = $dateinput; + $currencyRate_static->date_sync = $db->idate($dateinput); $currencyRate_static->rate = $rateinput; $result = $currencyRate_static->create(intval($fk_currency)); From 20720ae0dd50ad9036f1b1f6103130fe1de77f4f Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 11 Jan 2021 14:06:21 +0100 Subject: [PATCH 04/18] remove idate --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 69d471c62dd..b8aaf0064c8 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -109,7 +109,7 @@ if ($action == "create") { $currencyRate_static->fk_multicurrency = $fk_currency; $currencyRate_static->entity = $conf->entity; - $currencyRate_static->date_sync = $db->idate($dateinput); + $currencyRate_static->date_sync = $dateinput; $currencyRate_static->rate = $rateinput; $result = $currencyRate_static->create(intval($fk_currency)); From 6b451bd870a55c33a40b5b55b5116d35d55018aa Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 1 Feb 2021 09:31:30 +0100 Subject: [PATCH 05/18] use form->selectdate --- htdocs/multicurrency/multicurrency_rate.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index b8aaf0064c8..21d64734f8b 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -396,8 +396,8 @@ if ($resql) if (!empty($arrayfields['cr.date_sync']['checked'])) { print ''; } // code @@ -503,7 +503,7 @@ if ($resql) { $selected = 0; if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - print 'rowid.'">'.img_picto('edit', 'edit').''; + print 'rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode='. '1'. '">'.img_picto('edit', 'edit').''; print 'rowid.'">'.img_picto('delete', 'delete').''; print ''; } From 7966c6ed6d7d9291e2f6c01fbaa03ddb74a83ab8 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 1 Feb 2021 08:34:12 +0000 Subject: [PATCH 06/18] Fixing style errors. --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 21d64734f8b..09749ae612e 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -396,7 +396,7 @@ if ($resql) if (!empty($arrayfields['cr.date_sync']['checked'])) { print ''; } From 584c09d62c3ec64162d4212dc143000997ceb131 Mon Sep 17 00:00:00 2001 From: x Date: Mon, 19 Apr 2021 11:50:03 +0200 Subject: [PATCH 07/18] shorten link to 509 lenght Stickler CI / stickler-ci --- htdocs/multicurrency/multicurrency_rate.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index fb597b2e07c..ca3ee91703c 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -535,8 +535,8 @@ if ($resql) { { $selected = 0; if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - $atag = 'rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode='. '1'. '">'.img_picto('edit', 'edit').'' - print $atag ; + $par = '&id_rate='.$obj->rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode=1'; + print ''.img_picto('edit', 'edit').''; print 'rowid.'">'.img_picto('delete', 'delete').''; print ''; } From 08787cf40fb883122265704b7a06c72518fadc5c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 19 Apr 2021 09:52:17 +0000 Subject: [PATCH 08/18] Fixing style errors. --- htdocs/multicurrency/multicurrency_rate.php | 121 ++++++++++---------- 1 file changed, 58 insertions(+), 63 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index ca3ee91703c..8a31a34b1f3 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -217,7 +217,7 @@ if (empty($reshook)) { 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 $sall = ""; $search_date_sync = ""; - $search_date_sync_end=""; + $search_date_sync_end=""; $search_rate = ""; $search_code = ""; $search_array_options = array(); @@ -298,10 +298,10 @@ $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr '; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($search_date_sync && $search_date_sync_end ){ - $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')"; +if ($search_date_sync && $search_date_sync_end ) { + $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')"; } elseif ($search_date_sync && !$search_date_sync_end) { - $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync)); + $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync)); } if ($search_rate) $sql .= natural_search('cr.rate', $search_rate); if ($search_code) $sql .= natural_search('m.code', $search_code); @@ -355,9 +355,9 @@ if ($resql) { } if ($search_date_sync) $param = "&search_date_sync=".$search_date_sync; - if ($search_date_sync_end) $param="&search_date_sync_end=".$search_date_sync_end; + if ($search_date_sync_end) $param="&search_date_sync_end=".$search_date_sync_end; if ($search_rate) $param = "&search_rate=".urlencode($search_rate); - if ($search_code != '') $param.="&search_code=".urlencode($search_code); + if ($search_code != '') $param.="&search_code=".urlencode($search_code); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -427,13 +427,13 @@ if ($resql) { if (!empty($arrayfields['cr.date_sync']['checked'])) { print ''; } // code if (!empty($arrayfields['m.code']['checked'])) { print ''; } // rate @@ -481,67 +481,62 @@ if ($resql) { print ''; - // USER REQUEST UPDATE FOR THIS LINE - if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { - // var_dump($obj); - print ' '; - print ''; - print ' '; + // USER REQUEST UPDATE FOR THIS LINE + if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { + // var_dump($obj); + print ' '; + print ''; + print ' '; - print ''; - } - else { - // date_sync - if (!empty($arrayfields['cr.date_sync']['checked'])) - { - print '\n"; - if (!$i) $totalarray['nbfield']++; - } + print ''; + } else { + // date_sync + if (!empty($arrayfields['cr.date_sync']['checked'])) { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } - // code - if (! empty($arrayfields['m.code']['checked'])) - { - print '\n"; + // code + if (! empty($arrayfields['m.code']['checked'])) { + print '\n"; - if (! $i) $totalarray['nbfield']++; - } + if (! $i) $totalarray['nbfield']++; + } - // rate - if (! empty($arrayfields['cr.rate']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - } + // rate + if (! empty($arrayfields['cr.rate']['checked'])) { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - // Action - print ''; - if (!$i) $totalarray['nbfield']++; + // Action + print ''; + if (!$i) $totalarray['nbfield']++; } print "\n"; From 8f1046fcb3096525c685f1f90d6906e4e9cc81f2 Mon Sep 17 00:00:00 2001 From: x Date: Mon, 19 Apr 2021 11:56:37 +0200 Subject: [PATCH 09/18] use form->selectDate instead of html input type date --- htdocs/multicurrency/multicurrency_rate.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index ca3ee91703c..6a553fc5abf 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -484,7 +484,10 @@ if ($resql) { // USER REQUEST UPDATE FOR THIS LINE if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { // var_dump($obj); - print ' '; + $form = new Form($db); + print ''; + + print ''; print ' '; From e78f6e3001a2ab55659d4cab6fe1192ba4af00fc Mon Sep 17 00:00:00 2001 From: x Date: Mon, 19 Apr 2021 12:03:52 +0200 Subject: [PATCH 10/18] replace urlencode --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 9f0a6af576b..0de0d0c458b 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -354,7 +354,7 @@ if ($resql) { $param .= "&sall=".urlencode($sall); } - if ($search_date_sync) $param = "&search_date_sync=".$search_date_sync; + if ($search_date_sync) $param = "&search_date_sync=".urlencode($search_date_sync); if ($search_date_sync_end) $param="&search_date_sync_end=".$search_date_sync_end; if ($search_rate) $param = "&search_rate=".urlencode($search_rate); if ($search_code != '') $param.="&search_code=".urlencode($search_code); From f71b15ac8ee9e665e6709194f48d3b513fcf19f8 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 19 Apr 2021 10:05:56 +0000 Subject: [PATCH 11/18] Fixing style errors. --- htdocs/multicurrency/multicurrency_rate.php | 104 +++++++++----------- 1 file changed, 49 insertions(+), 55 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 0de0d0c458b..7445a6ed274 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -482,71 +482,65 @@ if ($resql) { print ''; - // USER REQUEST UPDATE FOR THIS LINE - if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { - // var_dump($obj); + // USER REQUEST UPDATE FOR THIS LINE + if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { + // var_dump($obj); $form = new Form($db); print ''; - print ''; - print ' '; + print ''; + print ' '; - print ''; - } - else { - // date_sync - if (!empty($arrayfields['cr.date_sync']['checked'])) - { - print '\n"; - if (!$i) $totalarray['nbfield']++; - } + print ''; + } else { + // date_sync + if (!empty($arrayfields['cr.date_sync']['checked'])) { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } - // code - if (! empty($arrayfields['m.code']['checked'])) - { - print '\n"; + // code + if (! empty($arrayfields['m.code']['checked'])) { + print '\n"; - if (! $i) $totalarray['nbfield']++; - } + if (! $i) $totalarray['nbfield']++; + } - // rate - if (! empty($arrayfields['cr.rate']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - } + // rate + if (! empty($arrayfields['cr.rate']['checked'])) { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Action - print ''; - if (!$i) $totalarray['nbfield']++; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action + print ''; + if (!$i) $totalarray['nbfield']++; } print "\n"; From 62d71028407dd94e6d580bdf0a180769a8321f61 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 19 Apr 2021 12:22:31 +0200 Subject: [PATCH 12/18] commit git config --- htdocs/multicurrency/multicurrency_rate.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 0de0d0c458b..5ed206aa8dc 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -487,8 +487,6 @@ if ($resql) { // var_dump($obj); $form = new Form($db); print ''; - - print ''; print ' '; From 2c4e6da36a68f1e6da880585e3dc4ee2535a7d25 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 19 Apr 2021 14:02:46 +0200 Subject: [PATCH 13/18] add escape to date --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 7445a6ed274..373d2a23304 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -299,7 +299,7 @@ $sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr '; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($search_date_sync && $search_date_sync_end ) { - $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')"; + $sql .= " AND (cr.date_sync BETWEEN '".$db->escape($db->idate($search_date_sync))."' AND '".$db->escape($db->idate($search_date_sync_end))."')"; } elseif ($search_date_sync && !$search_date_sync_end) { $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync)); } From 31a3c623f436db634dc6e12667c3a040947d9390 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 19 Apr 2021 14:24:56 +0200 Subject: [PATCH 14/18] remove ->escape --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 373d2a23304..7445a6ed274 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -299,7 +299,7 @@ $sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr '; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($search_date_sync && $search_date_sync_end ) { - $sql .= " AND (cr.date_sync BETWEEN '".$db->escape($db->idate($search_date_sync))."' AND '".$db->escape($db->idate($search_date_sync_end))."')"; + $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')"; } elseif ($search_date_sync && !$search_date_sync_end) { $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync)); } From 3836481a1e67cb7b6cc3399da6e7a2d9a64fb41e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Apr 2021 21:15:09 +0200 Subject: [PATCH 15/18] Update multicurrency_rate.php --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 7445a6ed274..78600c6b327 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -530,7 +530,7 @@ if ($resql) { print $hookmanager->resPrint; // Action - print ''; print ' '; - print ' '; + print ' '; print ''; // date - if (!empty($arrayfields['cr.date_sync']['checked'])) { - print ''; - } +if (!empty($arrayfields['cr.date_sync']['checked'])) { + print ''; +} // code - if (!empty($arrayfields['m.code']['checked'])) { - print ''; - } +if (!empty($arrayfields['m.code']['checked'])) { + print ''; +} // rate - if (!empty($arrayfields['cr.rate']['checked'])) { - print ''; - } +if (!empty($arrayfields['cr.rate']['checked'])) { + print ''; +} // Fields from hook $parameters = array('arrayfields'=>$arrayfields); @@ -470,90 +469,86 @@ if ($resql) { $i = 0; $totalarray = array(); - while ($i < min($num, $limit)) { - $obj = $db->fetch_object($resql); +while ($i < min($num, $limit)) { + $obj = $db->fetch_object($resql); - print ''; + print ''; - // USER REQUEST UPDATE FOR THIS LINE - if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { - // var_dump($obj); - print ' '; - print ''; - print ' '; + // USER REQUEST UPDATE FOR THIS LINE + if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { + // var_dump($obj); + print ' '; + print ''; + print ' '; - print ''; - } - else { - // date_sync - if (!empty($arrayfields['cr.date_sync']['checked'])) - { - print '\n"; - if (!$i) $totalarray['nbfield']++; - } - - // code - if (! empty($arrayfields['m.code']['checked'])) - { - print '\n"; - - if (! $i) $totalarray['nbfield']++; - } - - // rate - if (! empty($arrayfields['cr.rate']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - } - - - // Fields from hook - $parameters = ['arrayfields' => $arrayfields, 'obj' => $obj]; - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Action - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - print "\n"; - $i++; - } - - $db->free($resql); - - print "
'.$langs->trans("FormCreateRate").''; - print $form->selectDate($search_date_sync, 'search_date_sync', 0, 0, 1); - print $form->selectDate($search_date_sync_end, 'search_date_sync_end', 0, 0, 1); + print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d" ), 'search_date_sync', 0, 0, 1); + print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1); print ''; - print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d" ), 'search_date_sync', 0, 0, 1); + print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d"), 'search_date_sync', 0, 0, 1); print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1); print ''; print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d"), 'search_date_sync', 0, 0, 1); - print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1); + print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1); print ''; - print $form->selectMultiCurrency($multicurrency_code, 'search_code', 1, " code != '".$conf->currency."'", true); + print $form->selectMultiCurrency($multicurrency_code, 'search_code', 1, " code != '".$conf->currency."'", true); print '
' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . '' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print $obj->date_sync; - print "'; + print ''; + print ''; + print ''; + print ''; + print ''; + print $obj->date_sync; + print "'; - print $obj->code." ".$obj->name; - print "'; + print $obj->code." ".$obj->name; + print "'; - print $obj->rate; - print "'; + print $obj->rate; + print "'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - $par = '&id_rate='.$obj->rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode=1'; - print ''.img_picto('edit', 'edit').''; - print 'rowid.'">'.img_picto('delete', 'delete').''; - print ''; - } - print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + $par = '&id_rate='.$obj->rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode=1'; + print ''.img_picto('edit', 'edit').''; + print 'rowid.'">'.img_picto('delete', 'delete').''; + print ''; + } + print '
' . $form->selectDate($obj->date_sync, 'dateinput', 0, 0, 1).'' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . '
' . $form->selectDate($obj->date_sync, 'dateinput', 0, 0, 1).'' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . '' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print $obj->date_sync; - print "'; + print ''; + print ''; + print ''; + print ''; + print ''; + print $obj->date_sync; + print "'; - print $obj->code." ".$obj->name; - print "'; + print $obj->code." ".$obj->name; + print "'; - print $obj->rate; - print "'; + print $obj->rate; + print "'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - $par = '&id_rate='.$obj->rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode=1'; - print ''.img_picto('edit', 'edit').''; - print 'rowid.'">'.img_picto('delete', 'delete').''; - print ''; - } - print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + $par = '&id_rate='.$obj->rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode=1'; + print ''.img_picto('edit', 'edit').''; + print 'rowid.'">'.img_picto('delete', 'delete').''; + print ''; + } + print '
' . $form->selectDate($obj->date_sync, 'dateinput', 0, 0, 1).'' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; + print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; if (in_array($obj->rowid, $arrayofselected)) $selected = 1; From 330c08ac139ebe8ed74e64461242a97172dec1f7 Mon Sep 17 00:00:00 2001 From: jpb Date: Thu, 29 Apr 2021 15:59:55 +0200 Subject: [PATCH 16/18] remove number to text type input --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 09749ae612e..e25570e4b42 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -257,7 +257,7 @@ if (!in_array($action, array("updateRate", "deleteRate"))) { print ''.$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 1, " code != '".$conf->currency."'", true).''.$langs->trans('Rate').''; print ''; From d5af15a1020ba94b8e6f61bf9aab60d8e8efa751 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 29 Apr 2021 15:37:19 +0000 Subject: [PATCH 17/18] Fixing style errors. --- htdocs/multicurrency/multicurrency_rate.php | 189 ++++++++++---------- 1 file changed, 92 insertions(+), 97 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 94a36dcba3c..3e99a19cc57 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -202,8 +202,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -292,7 +291,7 @@ $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr '; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($search_date_sync && $search_date_sync_end ){ +if ($search_date_sync && $search_date_sync_end ) { $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')"; } elseif ($search_date_sync && !$search_date_sync_end) { $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync)); @@ -418,24 +417,24 @@ if ($resql) { print '
'; - print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d"), 'search_date_sync', 0, 0, 1); - print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1); - print ''; + print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d"), 'search_date_sync', 0, 0, 1); + print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1); + print ''; - print $form->selectMultiCurrency($multicurrency_code, 'search_code', 1, " code != '".$conf->currency."'", true); - print ''; + print $form->selectMultiCurrency($multicurrency_code, 'search_code', 1, " code != '".$conf->currency."'", true); + print ''; - print ''; - print ''; + print ''; + print '
' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . '' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print $obj->date_sync; - print "'; - print $obj->code." ".$obj->name; - print "'; - print $obj->rate; - print "'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print 'rowid.'">'.img_picto('edit', 'edit').''; - print 'rowid.'">'.img_picto('delete', 'delete').''; - print ''; - } - print '
"; - print "
"; - - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } else { - dol_print_error($db); + // date_sync + if (!empty($arrayfields['cr.date_sync']['checked'])) { + print ''; + print $obj->date_sync; + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + + // code + if (! empty($arrayfields['m.code']['checked'])) { + print ''; + print $obj->code." ".$obj->name; + print "\n"; + + if (! $i) $totalarray['nbfield']++; + } + + // rate + if (! empty($arrayfields['cr.rate']['checked'])) { + print ''; + print $obj->rate; + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + + + // Fields from hook + $parameters = ['arrayfields' => $arrayfields, 'obj' => $obj]; + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Action + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print 'rowid.'">'.img_picto('edit', 'edit').''; + print 'rowid.'">'.img_picto('delete', 'delete').''; + print ''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; + $i++; } + $db->free($resql); + + print ""; + print ""; + + print ''; +} else { + dol_print_error($db); +} + llxFooter(); $db->close(); From 9e5fdfdec36f97a3bf76e16b223e71f9e3a8405d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 May 2021 23:01:05 +0200 Subject: [PATCH 18/18] Update multicurrency_rate.php --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 3e99a19cc57..d0ad3419090 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -515,7 +515,7 @@ while ($i < min($num, $limit)) { // Fields from hook - $parameters = ['arrayfields' => $arrayfields, 'obj' => $obj]; + $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint;