This commit is contained in:
@@ -17,6 +17,7 @@ class ProductsCompareController extends Controller
|
|||||||
{
|
{
|
||||||
$codes = $request->input("codes");
|
$codes = $request->input("codes");
|
||||||
$countries = $request->input("countries");
|
$countries = $request->input("countries");
|
||||||
|
$currency = $request->input("currency");
|
||||||
|
|
||||||
Log::info("{codes} {countries}", ["codes" => $codes, "countries" => $countries]);
|
Log::info("{codes} {countries}", ["codes" => $codes, "countries" => $countries]);
|
||||||
|
|
||||||
@@ -45,9 +46,14 @@ class ProductsCompareController extends Controller
|
|||||||
$products = $products->get();
|
$products = $products->get();
|
||||||
|
|
||||||
$currencyRates = CurrencyRates::rates2EUR("Y");
|
$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) {
|
$products = $products->map(function ($product) use ($currencyRates, $coef) {
|
||||||
$product["salesPrice"] = round(floatval($product["salesPrice"]) / $currencyRates[$product["country"]], 2);
|
$product["salesPrice"] = round(floatval(($product["salesPrice"]) / $currencyRates[$product["country"]]) * $coef, 2);
|
||||||
return $product;
|
return $product;
|
||||||
});
|
});
|
||||||
Log::info("{products}", ["products" => $products]);
|
Log::info("{products}", ["products" => $products]);
|
||||||
|
|||||||
@@ -47,4 +47,17 @@ class CurrencyRates extends Model
|
|||||||
return [$item["country_code"] => $rates[$item["currency_code"]]];
|
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",
|
"about": "About",
|
||||||
"exachange": "Exachange",
|
"exachange": "Exachange",
|
||||||
"exchange": "Exchange",
|
"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 { FwbDropdown, FwbListGroup, FwbListGroupItem } from 'flowbite-vue';
|
||||||
import LogoIkea from '@/assets/Ikea_logo.svg';
|
import LogoIkea from '@/assets/Ikea_logo.svg';
|
||||||
import {
|
import {
|
||||||
|
FwbSelect,
|
||||||
FwbNavbar,
|
FwbNavbar,
|
||||||
FwbNavbarCollapse,
|
FwbNavbarCollapse,
|
||||||
FwbNavbarLink,
|
FwbNavbarLink,
|
||||||
@@ -57,7 +58,3 @@ onMounted(fetch_menu);
|
|||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</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({
|
const form = useForm({
|
||||||
countries: '',
|
countries: '',
|
||||||
codes: '',
|
codes: '',
|
||||||
|
currency: 'EUR',
|
||||||
});
|
});
|
||||||
const ccountry = ref([]);
|
const ccountry = ref([]);
|
||||||
const ccountry_filter = ref([['Country'],]);
|
const ccountry_filter = ref([['Country'],]);
|
||||||
const ccountry_list = ref(['TEST']);
|
const ccountry_list = ref(['TEST']);
|
||||||
const selected = ref(null);
|
const selected = ref(null);
|
||||||
const article = ref('');
|
const article = ref('');
|
||||||
|
const currency = ref([]);
|
||||||
const hrates = ref([
|
const hrates = ref([
|
||||||
{ text: "Currency", value: "currency", sortable: true },
|
{ text: "Currency", value: "currency", sortable: true },
|
||||||
{ text: "Country", value: "country_name", sortable: true },
|
{ text: "Country", value: "country_name", sortable: true },
|
||||||
@@ -112,6 +114,8 @@ const fetch_rates = async () => {
|
|||||||
try {
|
try {
|
||||||
const response = await axios.get(route('rates.index'))
|
const response = await axios.get(route('rates.index'))
|
||||||
rates.value = response.data;
|
rates.value = response.data;
|
||||||
|
currency.value = rates.value.map((currency) => currency.currency);
|
||||||
|
currency.value.unshift('EUR');
|
||||||
console.log("RATE=", rates.value);
|
console.log("RATE=", rates.value);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const response = await Swal.fire({
|
const response = await Swal.fire({
|
||||||
@@ -198,6 +202,13 @@ const submit = () => {
|
|||||||
<multiselect v-model="form.codes" label="item" track-by="item" :custom-label="customLabel"
|
<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" />
|
placeholder="Find item" :searchable="true" :options="options_items" @search-change="async_search" />
|
||||||
</div>
|
</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">
|
<div class="text-end mt-2">
|
||||||
<button type="submit"
|
<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"
|
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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</GuestLayout>
|
</GuestLayout>
|
||||||
</template>
|
</template>
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
Reference in New Issue
Block a user