@extends('front.layout.master')
@section('title','Filter Products | ')
@section('body')
@php
$last_cat = 0;
$first_cat = 0;
$price_login = App\Genral::first()->login;
$price_array = array();
$convert_price = 0;
$show_price = 0;
$all_brands_products = array();
if ($tag != '')
{
try
{
if ($chid != '')
{
if ($brand_names != '')
{
$get_all_products = App\Product::query();
if (is_array($brand_names))
{
foreach ($brand_names as $brands_all)
{
$all_products_brands = $get_all_products->where('brand_id', $brands_all)->where('tags', $tag)->where('grand_id', $chid)->get();
foreach ($all_products_brands as $zx)
{
array_push($all_brands_products, $zx);
}
}
}
if ($all_brands_products == null)
{
$first_cat = 0;
$last_cat = 0;
}
else
{
$productsfor_price = $all_brands_products;
}
}
else
{
$productsfor_price = App\Product::where('tags', $tag)->where('grand_id', $chid)->get();
}
foreach ($productsfor_price as $old)
{
foreach ($old->subvariants as $orivar)
{
if ($price_login == 0 || Auth::user())
{
$commision_setting = App\CommissionSetting::first();
if ($commision_setting->type == "flat")
{
$commission_amount = $commision_setting->rate;
if ($commision_setting->p_type == 'f')
{
if ($old->tax_r != '')
{
$cit = $commission_amount * $old->tax_r / 100;
$totalprice = $old->vender_price + $orivar->price + $commission_amount + $cit;
$totalsaleprice = $old->vender_offer_price + $orivar->price + $commission_amount + $cit;
}
else
{
$totalprice = $old->vender_price + $orivar->price + $commission_amount;
$totalsaleprice = $old->vender_offer_price + $orivar->price + $commission_amount;
}
if ($old->vender_offer_price == 0)
{
$totalprice;
array_push($price_array, $totalprice);
}
else
{
$totalsaleprice;
$convert_price = $totalsaleprice == '' ? $totalprice : $totalsaleprice;
$show_price = $totalprice;
array_push($price_array, $totalsaleprice);
}
}
else
{
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = $buyerprice;
array_push($price_array, $bsprice);
}
}
}
else
{
$comm = App\Commission::where('category_id', $old->category_id)
->first();
if (isset($comm))
{
if ($comm->type == 'f')
{
if ($old->tax_r != '')
{
$cit = $comm->rate * $old->tax_r / 100;
$price = $old->vender_price + $comm->rate + $orivar->price + $cit;
$offer = $old->vender_offer_price + $comm->rate + $orivar->price + $cit;
}
else
{
$price = $old->vender_price + $comm->rate + $orivar->price;
$offer = $old->vender_offer_price + $comm->rate + $orivar->price;
}
$convert_price = $offer == '' ? $price : $offer;
$show_price = $price;
if ($old->vender_offer_price == 0)
{
array_push($price_array, $price);
}
else
{
array_push($price_array, $offer);
}
}
else
{
$commission_amount = $comm->rate;
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = round($buyerprice, 2);
array_push($price_array, $bsprice);
}
}
}
}
}
}
}
if ($price_array != null)
{
$first_cat = min($price_array);
$last_cat = max($price_array);
}
unset($price_array);
$price_array = array();
}
else
{
if ($sid != '')
{
if ($brand_names != '')
{
$get_all_products = App\Product::query();
if (is_array($brand_names))
{
foreach ($brand_names as $brands_all)
{
$all_products_brands = $get_all_products->where('brand_id', $brands_all)->where('tags', $tag)->where('child', $sid)->get();
foreach ($all_products_brands as $zx)
{
array_push($all_brands_products, $zx);
}
}
}
if ($all_brands_products == null)
{
$first_cat = 0;
$last_cat = 0;
}
else
{
$productsfor_price = $all_brands_products;
}
}
else
{
$productsfor_price = App\Product::where('tags', $tag)->where('child', $sid)->get();
}
foreach ($productsfor_price as $old)
{
foreach ($old->subvariants as $orivar)
{
if ($price_login == 0 || Auth::user())
{
$convert_price = 0;
$show_price = 0;
$commision_setting = App\CommissionSetting::first();
if ($commision_setting->type == "flat")
{
$commission_amount = $commision_setting->rate;
if ($commision_setting->p_type == 'f')
{
if ($old->tax_r != '')
{
$cit = $commission_amount * $old->tax_r / 100;
$totalprice = $old->vender_price + $orivar->price + $commission_amount + $cit;
$totalsaleprice = $old->vender_offer_price + $orivar->price + $commission_amount + $cit;
}
else
{
$totalprice = $old->vender_price + $orivar->price + $commission_amount;
$totalsaleprice = $old->vender_offer_price + $orivar->price + $commission_amount;
}
if ($old->vender_offer_price == 0)
{
$totalprice;
array_push($price_array, $totalprice);
}
else
{
$totalsaleprice;
$convert_price = $totalsaleprice == '' ? $totalprice : $totalsaleprice;
$show_price = $totalprice;
array_push($price_array, $totalsaleprice);
}
}
else
{
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = $buyerprice;
array_push($price_array, $bsprice);
}
}
}
else
{
$comm = App\Commission::where('category_id', $old->category_id)
->first();
if (isset($comm))
{
if ($comm->type == 'f')
{
if ($old->tax_r != '')
{
$cit = $comm->rate * $old->tax_r / 100;
$price = $old->vender_price + $comm->rate + $orivar->price + $cit;
$offer = $old->vender_offer_price + $comm->rate + $orivar->price + $cit;
}
else
{
$price = $old->vender_price + $comm->rate + $orivar->price;
$offer = $old->vender_offer_price + $comm->rate + $orivar->price;
}
$convert_price = $offer == '' ? $price : $offer;
$show_price = $price;
if ($old->vender_offer_price == 0)
{
array_push($price_array, $price);
}
else
{
array_push($price_array, $offer);
}
}
else
{
$commission_amount = $comm->rate;
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = round($buyerprice, 2);
array_push($price_array, $bsprice);
}
}
}else{
$commission_amount = 0;
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = round($buyerprice, 2);
array_push($price_array, $bsprice);
}
}
}
}
}
}
if ($price_array != null)
{
$first_cat = min($price_array);
$last_cat = max($price_array);
}
unset($price_array);
$price_array = array();
}
else
{
if ($brand_names != '')
{
$get_all_products = App\Product::query();
if (is_array($brand_names))
{
foreach ($brand_names as $brands_all)
{
$all_products_brands = $get_all_products->where('brand_id', $brands_all)->where('tags', $tag)->where('category_id', $catid)->get();
foreach ($all_products_brands as $zx)
{
array_push($all_brands_products, $zx);
}
}
}
if ($all_brands_products == null)
{
$first_cat = 0;
$last_cat = 0;
}
else
{
$productsfor_price = $all_brands_products;
}
}
else
{
$productsfor_price = App\Product::where('tags', $tag)->where('category_id', $catid)->get();
}
foreach ($productsfor_price as $old)
{
foreach ($old->subvariants as $orivar)
{
if ($price_login == 0 || Auth::user())
{
$commision_setting = App\CommissionSetting::first();
if ($commision_setting->type == "flat")
{
$commission_amount = $commision_setting->rate;
if ($commision_setting->p_type == 'f')
{
if ($old->tax_r != '')
{
$cit = $commission_amount * $old->tax_r / 100;
$totalprice = $old->vender_price + $orivar->price + $commission_amount + $cit;
$totalsaleprice = $old->vender_offer_price + $orivar->price + $commission_amount + $cit;
}
else
{
$totalprice = $old->vender_price + $orivar->price + $commission_amount;
$totalsaleprice = $old->vender_offer_price + $orivar->price + $commission_amount;
}
if ($old->vender_offer_price == 0)
{
$totalprice;
array_push($price_array, $totalprice);
}
else
{
$totalsaleprice;
$convert_price = $totalsaleprice == '' ? $totalprice : $totalsaleprice;
$show_price = $totalprice;
array_push($price_array, $totalsaleprice);
}
}
else
{
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = $buyerprice;
array_push($price_array, $bsprice);
}
}
}
else
{
$comm = App\Commission::where('category_id', $old->category_id)
->first();
if (isset($comm))
{
if ($comm->type == 'f')
{
if ($old->tax_r != '')
{
$cit = $comm->rate * $old->tax_r / 100;
$price = $old->vender_price + $comm->rate + $orivar->price + $cit;
$offer = $old->vender_offer_price + $comm->rate + $orivar->price + $cit;
}
else
{
$price = $old->vender_price + $comm->rate + $orivar->price;
$offer = $old->vender_offer_price + $comm->rate + $orivar->price;
}
$convert_price = $offer == '' ? $price : $offer;
$show_price = $price;
if ($old->vender_offer_price == 0)
{
array_push($price_array, $price);
}
else
{
array_push($price_array, $offer);
}
}
else
{
$commission_amount = $comm->rate;
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = round($buyerprice, 2);
array_push($price_array, $bsprice);
}
}
}else{
$commission_amount = 0;
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = round($buyerprice, 2);
array_push($price_array, $bsprice);
}
}
}
}
}
}
if ($price_array != null)
{
$first_cat = min($price_array);
$last_cat = max($price_array);
}
unset($price_array);
$price_array = array();
}
}
}
catch(Exception $e)
{
$last_cat = 0;
$first_cat = 0;
}
}
else
{
try
{
if ($chid != '')
{
if ($brand_names != '')
{
$get_all_products = App\Product::query();
if (is_array($brand_names))
{
foreach ($brand_names as $brands_all)
{
$all_products_brands = $get_all_products->where('brand_id', $brands_all)->where('grand_id', $chid)->get();
foreach ($all_products_brands as $zx)
{
array_push($all_brands_products, $zx);
}
}
}
if ($all_brands_products == null)
{
$first_cat = 0;
$last_cat = 0;
}
else
{
$productsfor_price = $all_brands_products;
}
}
else
{
$productsfor_price = App\Product::where('grand_id', $chid)->get();
}
foreach ($productsfor_price as $old)
{
foreach ($old->subvariants as $orivar)
{
if ($price_login == 0 || Auth::user())
{
$commision_setting = App\CommissionSetting::first();
if ($commision_setting->type == "flat")
{
$commission_amount = $commision_setting->rate;
if ($commision_setting->p_type == 'f')
{
if ($old->tax_r != '')
{
$cit = $commission_amount * $old->tax_r / 100;
$totalprice = $old->vender_price + $orivar->price + $commission_amount + $cit;
$totalsaleprice = $old->vender_offer_price + $orivar->price + $commission_amount + $cit;
}
else
{
$totalprice = $old->vender_price + $orivar->price + $commission_amount;
$totalsaleprice = $old->vender_offer_price + $orivar->price + $commission_amount;
}
if ($old->vender_offer_price == 0)
{
$totalprice;
array_push($price_array, $totalprice);
}
else
{
$totalsaleprice;
$convert_price = $totalsaleprice == '' ? $totalprice : $totalsaleprice;
$show_price = $totalprice;
array_push($price_array, $totalsaleprice);
}
}
else
{
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = $buyerprice;
array_push($price_array, $bsprice);
}
}
}
else
{
$comm = App\Commission::where('category_id', $old->category_id)
->first();
if (isset($comm))
{
if ($comm->type == 'f')
{
if ($old->tax_r != '')
{
$cit = $comm->rate * $old->tax_r / 100;
$price = $old->vender_price + $comm->rate + $orivar->price + $cit;
$offer = $old->vender_offer_price + $comm->rate + $orivar->price + $cit;
}
else
{
$price = $old->vender_price + $comm->rate + $orivar->price;
$offer = $old->vender_offer_price + $comm->rate + $orivar->price;
}
$convert_price = $offer == '' ? $price : $offer;
$show_price = $price;
if ($old->vender_offer_price == 0)
{
array_push($price_array, $price);
}
else
{
array_push($price_array, $offer);
}
}
else
{
$commission_amount = $comm->rate;
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = round($buyerprice, 2);
array_push($price_array, $bsprice);
}
}
}else{
$commission_amount = 0;
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = round($buyerprice, 2);
array_push($price_array, $bsprice);
}
}
}
}
}
}
if ($price_array != null)
{
$first_cat = min($price_array);
$last_cat = max($price_array);
}
unset($price_array);
$price_array = array();
}
else
{
if ($sid != '')
{
if ($brand_names != '')
{
$get_all_products = App\Product::query();
if (is_array($brand_names))
{
foreach ($brand_names as $brands_all)
{
$all_products_brands = $get_all_products->where('brand_id', $brands_all)->where('child', $sid)->get();
foreach ($all_products_brands as $zx)
{
array_push($all_brands_products, $zx);
}
}
}
if ($all_brands_products == null)
{
$first_cat = 0;
$last_cat = 0;
}
else
{
$productsfor_price = $all_brands_products;
}
}
else
{
$productsfor_price = App\Product::where('child', $sid)->get();
}
foreach ($productsfor_price as $old)
{
foreach ($old->subvariants as $orivar)
{
if ($price_login == 0 || Auth::user())
{
$commision_setting = App\CommissionSetting::first();
if ($commision_setting->type == "flat")
{
$commission_amount = $commision_setting->rate;
if ($commision_setting->p_type == 'f')
{
if ($old->tax_r != '')
{
$cit = $commission_amount * $old->tax_r / 100;
$totalprice = $old->vender_price + $orivar->price + $commission_amount + $cit;
$totalsaleprice = $old->vender_offer_price + $orivar->price + $commission_amount + $cit;
}
else
{
$totalprice = $old->vender_price + $orivar->price + $commission_amount;
$totalsaleprice = $old->vender_offer_price + $orivar->price + $commission_amount;
}
if ($old->vender_offer_price == 0)
{
$totalprice;
array_push($price_array, $totalprice);
}
else
{
$totalsaleprice;
$convert_price = $totalsaleprice == '' ? $totalprice : $totalsaleprice;
$show_price = $totalprice;
array_push($price_array, $totalsaleprice);
}
}
else
{
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = $buyerprice;
array_push($price_array, $bsprice);
}
}
}
else
{
$comm = App\Commission::where('category_id', $old->category_id)
->first();
if (isset($comm))
{
if ($comm->type == 'f')
{
if ($old->tax_r != '')
{
$cit = $comm->rate * $old->tax_r / 100;
$price = $old->vender_price + $comm->rate + $orivar->price + $cit;
$offer = $old->vender_offer_price + $comm->rate + $orivar->price + $cit;
}
else
{
$price = $old->vender_price + $comm->rate + $orivar->price;
$offer = $old->vender_offer_price + $comm->rate + $orivar->price;
}
$convert_price = $offer == '' ? $price : $offer;
$show_price = $price;
if ($old->vender_offer_price == 0)
{
array_push($price_array, $price);
}
else
{
array_push($price_array, $offer);
}
}
else
{
$commission_amount = $comm->rate;
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = round($buyerprice, 2);
array_push($price_array, $bsprice);
}
}
}else{
$commission_amount = 0;
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = round($buyerprice, 2);
array_push($price_array, $bsprice);
}
}
}
}
}
}
if ($price_array != null)
{
$first_cat = min($price_array);
$last_cat = max($price_array);
}
unset($price_array);
$price_array = array();
}
else
{
if ($brand_names != '')
{
$get_all_products = App\Product::query();
if (is_array($brand_names))
{
foreach ($brand_names as $brands_all)
{
$all_products_brands = $get_all_products->where('brand_id', $brands_all)->where('category_id', $catid)->get();
foreach ($all_products_brands as $zx)
{
array_push($all_brands_products, $zx);
}
}
}
if ($all_brands_products == null)
{
$first_cat = 0;
$last_cat = 0;
}
else
{
$productsfor_price = $all_brands_products;
}
}
else
{
$productsfor_price = App\Product::where('category_id', $catid)->get();
}
foreach ($productsfor_price as $old)
{
foreach ($old->subvariants as $orivar)
{
if ($price_login == 0 || Auth::user())
{
$commision_setting = App\CommissionSetting::first();
if ($commision_setting->type == "flat")
{
$commission_amount = $commision_setting->rate;
if ($commision_setting->p_type == 'f')
{
if ($old->tax_r != '')
{
$cit = $commission_amount * $old->tax_r / 100;
$totalprice = $old->vender_price + $orivar->price + $commission_amount + $cit;
$totalsaleprice = $old->vender_offer_price + $orivar->price + $commission_amount + $cit;
}
else
{
$totalprice = $old->vender_price + $orivar->price + $commission_amount;
$totalsaleprice = $old->vender_offer_price + $orivar->price + $commission_amount;
}
if ($old->vender_offer_price == 0)
{
$totalprice;
array_push($price_array, $totalprice);
}
else
{
$totalsaleprice;
$convert_price = $totalsaleprice == '' ? $totalprice : $totalsaleprice;
$show_price = $totalprice;
array_push($price_array, $totalsaleprice);
}
}
else
{
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = $buyerprice;
array_push($price_array, $bsprice);
}
}
}
else
{
$comm = App\Commission::where('category_id', $old->category_id)
->first();
if (isset($comm))
{
if ($comm->type == 'f')
{
if ($old->tax_r != '')
{
$cit = $comm->rate * $old->tax_r / 100;
$price = $old->vender_price + $comm->rate + $orivar->price + $cit;
$offer = $old->vender_offer_price + $comm->rate + $orivar->price + $cit;
}
else
{
$price = $old->vender_price + $comm->rate + $orivar->price;
$offer = $old->vender_offer_price + $comm->rate + $orivar->price;
}
$convert_price = $offer == '' ? $price : $offer;
$show_price = $price;
if ($old->vender_offer_price == 0)
{
array_push($price_array, $price);
}
else
{
array_push($price_array, $offer);
}
}
else
{
$commission_amount = $comm->rate;
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = round($buyerprice, 2);
array_push($price_array, $bsprice);
}
}
}else{
$commission_amount = 0;
$totalprice = ($old->vender_price + $orivar->price) * $commission_amount;
$totalsaleprice = ($old->vender_offer_price + $orivar->price) * $commission_amount;
$buyerprice = ($old->vender_price + $orivar->price) + ($totalprice / 100);
$buyersaleprice = ($old->vender_offer_price + $orivar->price) + ($totalsaleprice / 100);
if ($old->vender_offer_price == 0)
{
$bprice = round($buyerprice, 2);
array_push($price_array, $bprice);
}
else
{
$bsprice = round($buyersaleprice, 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = round($buyerprice, 2);
array_push($price_array, $bsprice);
}
}
}
}
}
}
if ($price_array != null)
{
$first_cat = min($price_array);
$last_cat = max($price_array);
}
unset($price_array);
$price_array = array();
}
}
}
catch(Exception $e)
{
$last_cat = 0;
$first_cat = 0;
}
}
@endphp