This commit is contained in:
@@ -17,6 +17,7 @@ class ProductsCompareController extends Controller
|
||||
{
|
||||
$codes = $request->input("codes");
|
||||
$countries = $request->input("countries");
|
||||
$currency = $request->input("currency");
|
||||
|
||||
Log::info("{codes} {countries}", ["codes" => $codes, "countries" => $countries]);
|
||||
|
||||
@@ -45,9 +46,14 @@ class ProductsCompareController extends Controller
|
||||
$products = $products->get();
|
||||
|
||||
$currencyRates = CurrencyRates::rates2EUR("Y");
|
||||
if ($currency == "EUR") {
|
||||
$coef = 1;
|
||||
} else {
|
||||
$coef = floatval(CurrencyRates::where('currency',$currency)->first()->rate);
|
||||
}
|
||||
|
||||
$products = $products->map(function ($product) use ($currencyRates) {
|
||||
$product["salesPrice"] = round(floatval($product["salesPrice"]) / $currencyRates[$product["country"]], 2);
|
||||
$products = $products->map(function ($product) use ($currencyRates, $coef) {
|
||||
$product["salesPrice"] = round(floatval(($product["salesPrice"]) / $currencyRates[$product["country"]]) * $coef, 2);
|
||||
return $product;
|
||||
});
|
||||
Log::info("{products}", ["products" => $products]);
|
||||
|
||||
@@ -47,4 +47,17 @@ class CurrencyRates extends Model
|
||||
return [$item["country_code"] => $rates[$item["currency_code"]]];
|
||||
});
|
||||
}
|
||||
|
||||
protected function currencyCode() {
|
||||
return CountryCode::active("Y")->mapWithKeys(function ($item) {
|
||||
return [$item['currency_code'] => $item['country_code']];
|
||||
});
|
||||
}
|
||||
|
||||
protected function countryCurrency() {
|
||||
return CountryCode::active("Y")->mapWithKeys(function ($item) {
|
||||
return [$item["country_code"] => $item["currency_code"]];
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -105,5 +105,7 @@
|
||||
"about": "About",
|
||||
"exachange": "Exachange",
|
||||
"exchange": "Exchange",
|
||||
"referenceerror: rates is not defined": "ReferenceError: rates is not defined"
|
||||
"referenceerror: rates is not defined": "ReferenceError: rates is not defined",
|
||||
"referenceerror: currency is not defined": "ReferenceError: currency is not defined",
|
||||
"typeerror: can't access property \"unshift\", currency.velue is undefined": "TypeError: can't access property \"unshift\", currency.velue is undefined"
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { getCurrentInstance, ref, onMounted, onUnmounted, nextTick, computed } f
|
||||
import { FwbDropdown, FwbListGroup, FwbListGroupItem } from 'flowbite-vue';
|
||||
import LogoIkea from '@/assets/Ikea_logo.svg';
|
||||
import {
|
||||
FwbSelect,
|
||||
FwbNavbar,
|
||||
FwbNavbarCollapse,
|
||||
FwbNavbarLink,
|
||||
@@ -41,12 +42,12 @@ onMounted(fetch_menu);
|
||||
</template>
|
||||
|
||||
<template #default="{ isShowMenu }">
|
||||
<fwb-navbar-collapse :is-show-menu="isShowMenu" v-if="menu.length >0 ">
|
||||
<fwb-navbar-link :link="route(menu[0].route_or_url)" >
|
||||
<fwb-navbar-collapse :is-show-menu="isShowMenu" v-if="menu.length > 0">
|
||||
<fwb-navbar-link :link="route(menu[0].route_or_url)">
|
||||
Home
|
||||
</fwb-navbar-link>
|
||||
<template v-for="item in menu[0].childs" v-if="menu.length > 0">
|
||||
<fwb-navbar-link :link="route(item.route_or_url)" >
|
||||
<fwb-navbar-link :link="route(item.route_or_url)">
|
||||
{{ item.name }}
|
||||
</fwb-navbar-link>
|
||||
</template>
|
||||
@@ -57,7 +58,3 @@ onMounted(fetch_menu);
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
@import 'vue3-easy-data-table/dist/style.css';
|
||||
</style>
|
||||
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
||||
@@ -40,12 +40,14 @@ const type = 'GeoChart';
|
||||
const form = useForm({
|
||||
countries: '',
|
||||
codes: '',
|
||||
currency: 'EUR',
|
||||
});
|
||||
const ccountry = ref([]);
|
||||
const ccountry_filter = ref([['Country'],]);
|
||||
const ccountry_list = ref(['TEST']);
|
||||
const selected = ref(null);
|
||||
const article = ref('');
|
||||
const currency = ref([]);
|
||||
const hrates = ref([
|
||||
{ text: "Currency", value: "currency", sortable: true },
|
||||
{ text: "Country", value: "country_name", sortable: true },
|
||||
@@ -112,6 +114,8 @@ const fetch_rates = async () => {
|
||||
try {
|
||||
const response = await axios.get(route('rates.index'))
|
||||
rates.value = response.data;
|
||||
currency.value = rates.value.map((currency) => currency.currency);
|
||||
currency.value.unshift('EUR');
|
||||
console.log("RATE=", rates.value);
|
||||
} catch (e) {
|
||||
const response = await Swal.fire({
|
||||
@@ -198,6 +202,13 @@ const submit = () => {
|
||||
<multiselect v-model="form.codes" label="item" track-by="item" :custom-label="customLabel"
|
||||
placeholder="Find item" :searchable="true" :options="options_items" @search-change="async_search" />
|
||||
</div>
|
||||
<div>
|
||||
<span class="font-extrabold font-mono">Prepocet do meny</span>
|
||||
</div>
|
||||
<div>
|
||||
<multiselect v-model="form.currency" :multiple="flase" :allow-empty="false"
|
||||
placeholder="Currency" :searchable="true" :options="currency" />
|
||||
</div>
|
||||
<div class="text-end mt-2">
|
||||
<button type="submit"
|
||||
class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
||||
@@ -222,6 +233,7 @@ const submit = () => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</GuestLayout>
|
||||
</template>
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user