@extends('backend.layout.main')

@section('content')
@if(session()->has('not_permitted'))
    <div class="alert alert-danger alert-dismissible text-center"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>{{ session()->get('not_permitted') }}</div>
@endif
<section class="forms">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <div class="modal-content">
                    <div class="modal-header">
                    <h5 id="exampleModalLabel" class="modal-title">{{trans('Order Details')}}</h5>
                    <a id="print-btn" target="_blank" class="btn btn-default btn-sm ml-3" href="{{ route('tailoringproducts.print',$product->id) }}">
                        <i class="fa fa-print"></i> {{trans('file.Print')}}
                    </a>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-md-5 offset-1" id="product-content">
                                <p><strong>{{trans("file.Code")}}: </strong>{{ $product->code }}</p>
                                <p><strong>{{trans("file.category")}}: </strong>{{ $product->type }}</p>
                                <p><strong>{{trans("file.order type")}}: </strong>{{ $product->getCompositionLabel() }}</p>
                                <p><strong>{{trans("file.Total_Price")}}: </strong>{{ $product->total_price }}</p>
                                <p><strong>{{trans("file.Paid Amount")}}: </strong>{{ $product->paid_amount }}</p>
                                <p><strong>{{trans("file.Due Amount")}}: </strong>{{ $product->due_amount }}</p>
                                <p><strong>{{trans("file.Issue Date")}}: </strong>{{ $product->created_at->format('d-m-Y') }}</p>
                                <p><strong>{{trans("file.Completion Date")}}: </strong>{{ $product->completion_date->format('d-m-Y') }}</p>
                            </div>
                            <div class="col-md-5 offset-1" id="customer-content">
                                <h3 class='mb-2 mt-1'><strong>{{trans("file.Customer Information")}}</strong></h3>
                                <p class='mt-3'><strong>{{trans("file.Customer Name")}}: </strong>{{ $product->customer->name }}</p>
                                <p><strong>{{trans("file.Customer Phone")}}: </strong>{{ $product->customer->phone_number }}</p>
                                <p><strong>{{trans("file.Address")}}: </strong>{{ $product->customer->city }}, {{ $product->customer->address }}</p>

                            </div>
                        </div>

                        <h5 id="combo-header" class="text-center">{{ trans('file.customer_order') }}</h5>
                        <div class="row" style="background-color: #f3f2f7;">
                            <div class="col-1 border py-2">#</div>
                            <div class="col-2 border py-2">{{ trans('file.Order') }}</div>
                            <div class="col-2 border py-2">{{ trans('file.Color') }}</div>
                            <div class="col-1 border py-2">{{ trans('file.Type') }}</div>
                            <div class="col-1 border py-2">{{ trans('file.Qty') }}</div>
                            <div class="col-2 border py-2">{{ trans('file.Tailors') }}</div>
                            <div class="col-1 border py-2">{{ trans('file.Tailor fee') }}</div>
                            <div class="col-1 border py-2">{{ trans('file.Unit Price') }}</div>
                            <div class="col-1 border py-2">{{ trans('file.details') }}</div>
                        </div>
                        <div class="details_rows_container" id="details_rows_container">
                            <?php
                            $i = 1;
                            $type = 'N/A';
                            $color = 'N/A';

                            if($product->product && $product->product->is_variant){
                                $options = json_decode($product->product->variant_option, true);
                                $values = json_decode($product->product->variant_value, true);

                                foreach ($options as $index => $option) {
                                    if ($option === 'type') {
                                        $type = $values[$index] ?? 'N/A';
                                    }
                                    if ($option === 'color') {
                                        $color = $values[$index] ?? 'N/A';
                                    }
                                }
                            }
                            ?>
                            @if($product->waiscoat)
                                <div class="row">
                                    <div class="col-1 border py-2">{{ $i }}</div>
                                    <div class="col-2 border py-2">{{ trans('file.Waiscoat Order') }}</div>
                                    <div class="col-2 border py-2">{{ $color }}</div>
                                    <div class="col-1 border py-2">{{ $type }}</div>
                                    <div class="col-1 border py-2">{{ $product->waiscoat->qty }}</div>
                                    <div class="col-2 border py-2">{{ $product->waiscoat->tailor->name }}</div>
                                    <div class="col-1 border py-2">{{ $product->waiscoat->tailor->tailor_fee }}</div>
                                    <div class="col-1 border py-2">{{ number_format($product->total_price, 2, '.', '') }}</div>
                                    <div class="col-1 border py-2 text-center order_details_toggle">
                                        <button><i class="fa fa-plus"></i></button>
                                    </div>
                                </div>
                                <div class="row order_details_toggler" style='display:none;'>
                                    <div class="col-12 px-3">
                                        <div class="row" style="background-color: #f3f2f7;">
                                            <div class="col-6 border py-2">{{ trans('file.Waiscoat Size') }}</div>
                                            <div class="col-6 border py-2">{{ trans('file.Waiscoat Design') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Waiscoat Height') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->waiscoat->waiscoat_height }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Design V-Neck Collar') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->waiscoat->design_v_neck_collar == 1 ? 'fa fa-check' : 'dripicons-cross' }}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Waiscoat Shoulder') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->waiscoat->waiscoat_shoulder }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Design Round Neck Collar') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->waiscoat->design_round_neck_collar == 1 ? 'fa fa-check' : 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Waiscoat Side') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->waiscoat->waiscoat_side }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Design Pakistani Collar') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->waiscoat->design_pakistani_collar == 1 ? 'fa fa-check': 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Waiscoat Waist') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->waiscoat->waiscoat_waist }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Design Zippered Pocket') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->waiscoat->design_zippered_pocket == 1 ? 'fa fa-check': 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Waiscoat Abdomen') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->waiscoat->waiscoat_abdomen }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Design Plain Pocket') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->waiscoat->design_plain_pocket == 1 ? 'fa fa-check': 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Waiscoat Hip') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->waiscoat->waiscoat_hip }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Design Four Side Pockets') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->waiscoat->design_four_side_pocket == 1 ? 'fa fa-check': 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.vest_chest_circumference') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->waiscoat->vest_chest_circumference }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Design Two Side Pockets') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->waiscoat->design_two_side_pocket == 1 ? 'fa fa-check': 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-2 border py-2">{{ trans('file.Order Details') }}</div>
                                            <div class="col-10 border py-2">{!! $product->waiscoat->waiscoat_order_details !!} </div>
                                        </div>

                                    </div>

                                </div>
                                <?php $i++; ?>
                            @endif
                            @if($product->coat)
                                <div class="row">
                                    <div class="col-1 border py-2">{{ $i }}</div>
                                    <div class="col-2 border py-2">{{ trans('file.Coat Order') }}</div>
                                    <div class="col-2 border py-2">{{ $color }}</div>
                                    <div class="col-1 border py-2">{{ $type }}</div>
                                    <div class="col-1 border py-2">{{ $product->coat->qty }}</div>
                                    <div class="col-2 border py-2">{{ $product->coat->tailor->name }}</div>
                                    <div class="col-1 border py-2">{{ $product->coat->tailor->tailor_fee }}</div>
                                    <div class="col-1 border py-2">{{ number_format($product->total_price, 2, '.', '') }}</div>
                                    <div class="col-1 border py-2 text-center order_details_toggle">
                                        <button><i class="fa fa-plus"></i></button>
                                    </div>
                                </div>

                                <div class="row order_details_toggler" style='display:none;'>
                                    <div class="col-12 px-3">
                                        <div class="row" style="background-color: #f3f2f7;">
                                            <div class="col-6 border py-2">{{ trans('file.Coat Size') }}</div>
                                            <div class="col-6 border py-2">{{ trans('file.Coat Design') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Coat Height') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->coat_height }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Coat Style One Button') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->waiscoat->coat_style_one_button == 1 ? 'fa fa-check': 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Coat Shoulder') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->coat_shoulder }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Coat Style Two Button') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->waiscoat->coat_style_two_button == 1 ? 'fa fa-check': 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Coat Sleeve') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->coat_sleeve }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Coat Style three Button') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->waiscoat->coat_style_three_button == 1 ? 'fa fa-check': 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Coat Armhole Circumference') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->coat_armhole_circumference }} {{ trans('file.(cm)') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Coat Bicep Circumference') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->coat_bicep_circumference }} {{ trans('file.(cm)') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Coat Cuff') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->coat_cuff }} {{ trans('file.(cm)') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Coat Side Width') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->coat_side_width }} {{ trans('file.(cm)') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Coat Waist') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->coat_waist }} {{ trans('file.(cm)') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Coat Abdomen Circumference') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->coat_abdomen_circumference }} {{ trans('file.(cm)') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Coat Hip Width') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->coat_hip_width }} {{ trans('file.(cm)') }}</div>
                                        </div>
                                        
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.UpperBody Front Length') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->upperbody_front_length }} {{ trans('file.(cm)') }}</div>
                                        </div><div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.UpperBody Back Length') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->upperbody_back_length }} {{ trans('file.(cm)') }}</div>
                                        </div><div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Chest Distance') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->chest_distance }} {{ trans('file.(cm)') }}</div>
                                        </div><div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Coat Collar') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->coat->coat_collar }} {{ trans('file.(cm)') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-2 border py-2">{{ trans('file.Order Details') }}</div>
                                            <div class="col-10 border py-2">{!! $product->coat->coat_order_details !!} </div>
                                        </div>

                                    </div>

                                </div>
                                <?php $i++; ?>
                            @endif

                            @if($product->pant)
                                <div class="row">
                                    <div class="col-1 border py-2">{{ $i }}</div>
                                    <div class="col-2 border py-2">{{ trans('file.Pant Order') }}</div>
                                    <div class="col-2 border py-2">{{ $color }}</div>
                                    <div class="col-1 border py-2">{{ $type }}</div>
                                    <div class="col-1 border py-2">{{ $product->pant->qty }}</div>
                                    <div class="col-2 border py-2">{{ $product->pant->tailor->name }}</div>
                                    <div class="col-1 border py-2">{{ $product->pant->tailor->tailor_fee }}</div>
                                    <div class="col-1 border py-2">{{ number_format($product->total_price, 2, '.', '') }}</div>
                                    <div class="col-1 border py-2 text-center order_details_toggle">
                                        <button><i class="fa fa-plus"></i></button>
                                    </div>
                                </div>
                                <div class="row order_details_toggler" style='display:none;'>
                                    <div class="col-12 px-3">
                                        <div class="row" style="background-color: #f3f2f7;">
                                            <div class="col-6 border py-2">{{ trans('file.Pant Size') }}</div>
                                            <div class="col-6 border py-2">{{ trans('file.Pant Design') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Pant Length') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->pant->pant_length }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Pant Straight Loose') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->pant->pant_straight_loose == 1 ? 'fa fa-check': 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Pant Waist') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ trans('file.'.Str::title(str_replace('_', ' ', $product->pant->pant_waist))) }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Pant Straight Medium') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->pant->pant_straight_medium == 1 ? 'fa fa-check': 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Pant Thigh') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->pant->pant_thigh }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Pant Straight Military') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->pant->pant_straight_military == 1 ? 'fa fa-check': 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Pant Rise') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->pant->pant_rise }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Pant Straight Cuban Pocket') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->pant->pant_straight_cuban_pocket == 1 ? 'fa fa-check': 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Pant Hem') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->pant->pant_hem }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-5 border py-2">{{ trans('file.Pant Straight Classic') }}</div>
                                            <div class="col-1 border py-2 text-center"><i class="{{ $product->pant->pant_straight_classic == 1 ? 'fa fa-check': 'dripicons-cross'}}"></i></div>{{-- dripicons-cross --}}
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Pant Hip') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->pant->pant_hip }} {{ trans('file.(cm)') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.trouser_crotch_depth') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->pant->trouser_crotch_depth }} {{ trans('file.(cm)') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-2 border py-2">{{ trans('file.Order Details') }}</div>
                                            <div class="col-10 border py-2">{!! $product->pant->pant_order_details !!} </div>
                                        </div>

                                    </div>

                                </div>
                            @endif
                            @if($product->dress)
                                <div class="row">
                                    <div class="col-1 border py-2">1</div>
                                    <div class="col-2 border py-2">{{ trans('file.Dress Order') }}</div>
                                    <div class="col-2 border py-2">{{ $color }}</div>
                                    <div class="col-1 border py-2">{{ $type }}</div>
                                    <div class="col-1 border py-2">{{ $product->dress->qty }}</div>
                                    <div class="col-2 border py-2">{{ $product->dress->tailor->name }}</div>
                                    <div class="col-1 border py-2">{{ $product->dress->tailor->tailor_fee }}</div>
                                    <div class="col-1 border py-2">{{ number_format($product->total_price, 2, '.', '') }}</div>
                                    <div class="col-1 border py-2 text-center order_details_toggle">
                                        <button><i class="fa fa-plus"></i></button>
                                    </div>
                                </div>

                                <div class="row order_details_toggler" style='display:none;'>
                                    <div class="col-12 px-3">
                                        <div class="row" style="background-color: #f3f2f7;">
                                            <div class="col-12 border py-2 text-center">{{ trans('file.Dress Size') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Dress Shirt Length') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->dress->dress_shirt_length }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-4 border py-2">{{ trans('file.Dress Sleeve') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->dress->dress_sleeve }} {{ trans('file.(cm)') }}</div>

                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Dress Shoulder Width') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->dress->dress_shoulder_width }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-4 border py-2">{{ trans('file.Dress Collar') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->dress->dress_collar }} {{ trans('file.(cm)') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Dress Side Width') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->dress->dress_side_width }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-4 border py-2">{{ trans('file.Dress Armhole Circumference') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->dress->dress_armhole_circumference }} {{ trans('file.(cm)') }}</div>

                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Dress Waist') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->dress->dress_waist }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-4 border py-2">{{ trans('file.Dress Hem') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->dress->dress_hem }} {{ trans('file.(cm)') }}</div>

                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Dress Skirt Length') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->dress->dress_skirt_length }} {{ trans('file.(cm)') }}</div>
                                            <div class="col-4 border py-2">{{ trans('file.Dress Cuff') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->dress->dress_cuff }} {{ trans('file.(cm)') }}</div>

                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Dress Skirt Width') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->dress->dress_skirt_width }} {{ trans('file.(cm)') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.shirt_trouser_crotch_depth') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->dress->shirt_trouser_crotch_depth }} {{ trans('file.(cm)') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-2 border py-2">{{ trans('file.Order Details') }}</div>
                                            <div class="col-10 border py-2">{!! $product->dress->dress_order_details !!} </div>
                                        </div>

                                    </div>

                                </div>
                            @endif
                            @if($product->curtain)
                                @php
                                    $curtainFeeBreakdown = $product->curtain->tailor->curtainFeeBreakdown($product->curtain);
                                @endphp
                                <div class="row">
                                    <div class="col-1 border py-2">{{ $i }}</div>
                                    <div class="col-2 border py-2">{{ trans('file.Curtain Order') }}</div>
                                    <div class="col-2 border py-2">N/A</div>
                                    <div class="col-1 border py-2">{{ trans('file.Curtain') }}</div>
                                    <div class="col-1 border py-2">{{ $product->curtain->qty }}</div>
                                    <div class="col-2 border py-2">{{ $product->curtain->tailor->name }}</div>
                                    <div class="col-1 border py-2">{{ number_format((float) $curtainFeeBreakdown['total'], 2, '.', '') }}</div>
                                    <div class="col-1 border py-2">{{ number_format($product->total_price, 2, '.', '') }}</div>
                                    <div class="col-1 border py-2 text-center order_details_toggle">
                                        <button><i class="fa fa-plus"></i></button>
                                    </div>
                                </div>
                                <div class="row order_details_toggler" style='display:none;'>
                                    <div class="col-12 px-3">
                                        <div class="row" style="background-color: #f3f2f7;">
                                            <div class="col-12 border py-2 text-center">{{ trans('file.Curtain Information') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-3 border py-2">{{ trans('file.Material Total') }}</div>
                                            <div class="col-3 border py-2 text-center">{{ number_format((float) ($product->material_total ?? $product->total_price), 2, '.', '') }}</div>
                                            <div class="col-3 border py-2">{{ trans('file.Customer Tailoring Service') }}</div>
                                            <div class="col-3 border py-2 text-center">{{ number_format((float) ($product->service_charge ?? 0), 2, '.', '') }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-3 border py-2">{{ trans('file.Tailor Cost') }}</div>
                                            <div class="col-3 border py-2 text-center">{{ number_format((float) ($product->tailor_fabric_meter_fee !== null ? $product->tailor_cost : $curtainFeeBreakdown['total']), 2, '.', '') }}</div>
                                            <div class="col-6 border py-2"></div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Window Count') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->curtain->window_count }}</div>
                                            <div class="col-4 border py-2">{{ trans('file.Door Count') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->curtain->door_count }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Curtain Panels') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->curtain->panel_count }}</div>
                                            <div class="col-4 border py-2">{{ trans('file.Panel Meter') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->curtain->panel_meter }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Middle Netting') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->curtain->middle_netting_meter }}</div>
                                            <div class="col-4 border py-2">{{ trans('file.Sewing Type') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ collect([$product->curtain->pleating_type, $product->curtain->ring_stitch_type])->filter()->implode('، ') }}</div>
                                        </div>
                                        @if($product->curtain->windowDetails->count())
                                            <div class="row" style="background-color: #f3f2f7;">
                                                <div class="col-12 border py-2 text-center">{{ trans('file.Window Measurements') }}</div>
                                            </div>
                                            <div class="row">
                                                <div class="col-2 border py-2 text-center">{{ trans('file.Window Name / Location') }}</div>
                                                <div class="col-3 border py-2 text-center">{{ trans('file.Fabric Product') }}</div>
                                                <div class="col-3 border py-2 text-center">{{ trans('file.Netting Product') }}</div>
                                                <div class="col-1 border py-2 text-center">{{ trans('file.Window Count') }}</div>
                                                <div class="col-1 border py-2 text-center">{{ trans('file.Curtain Panels') }}</div>
                                                <div class="col-1 border py-2 text-center">{{ trans('file.Panel Meter') }}</div>
                                                <div class="col-1 border py-2 text-center">{{ trans('file.Middle Netting') }}</div>
                                            </div>
                                            @foreach($product->curtain->windowDetails as $detail)
                                                <div class="row">
                                                    <div class="col-2 border py-2 text-center">{{ $detail->label ?: trans('file.Group') . ' ' . $loop->iteration }}</div>
                                                    <div class="col-3 border py-2 text-center">{{ optional($detail->fabricProduct)->name ?: '—' }} — {{ optional($detail->fabricProduct)->code ?: '—' }}</div>
                                                    <div class="col-3 border py-2 text-center">{{ optional($detail->nettingProduct)->name ?: '—' }} — {{ optional($detail->nettingProduct)->code ?: '—' }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ $detail->window_count }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ $detail->panel_count }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ $detail->panel_meter }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ $detail->middle_netting_meter }}</div>
                                                </div>
                                            @endforeach
                                        @endif
                                        @if($product->curtain->doorDetails->count())
                                            <div class="row" style="background-color: #f3f2f7;">
                                                <div class="col-12 border py-2 text-center">{{ trans('file.Door Requirements') }}</div>
                                            </div>
                                            <div class="row">
                                                <div class="col-3 border py-2 text-center">{{ trans('file.Door Name') }}</div>
                                                <div class="col-5 border py-2 text-center">{{ trans('file.Product') }}</div>
                                                <div class="col-2 border py-2 text-center">{{ trans('file.Door Count') }}</div>
                                                <div class="col-2 border py-2 text-center">{{ trans('file.Meterage') }}</div>
                                            </div>
                                            @foreach($product->curtain->doorDetails as $detail)
                                                <div class="row">
                                                    <div class="col-3 border py-2 text-center">{{ $detail->label ?: trans('file.Group') . ' ' . $loop->iteration }}</div>
                                                    <div class="col-5 border py-2 text-center">{{ optional($detail->product)->name ?: '—' }} — {{ optional($detail->product)->code ?: '—' }}</div>
                                                    <div class="col-2 border py-2 text-center">{{ $detail->door_count }}</div>
                                                    <div class="col-2 border py-2 text-center">{{ $detail->meterage }}</div>
                                                </div>
                                            @endforeach
                                        @endif
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Curtain Model') }}</div>
                                            <div class="col-8 border py-2 text-center">{{ $product->curtain->curtain_model }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Mattress Count') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->curtain->mattress_count }}</div>
                                            <div class="col-4 border py-2">{{ trans('file.Pillow Count') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->curtain->pillow_count }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Bolster Count') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->curtain->bolster_count }}</div>
                                            <div class="col-4 border py-2">{{ trans('file.Mattress & Pillow Size') }}</div>
                                            <div class="col-2 border py-2 text-center">{{ $product->curtain->mattress_pillow_size }}</div>
                                        </div>
                                        <div class="row">
                                            <div class="col-4 border py-2">{{ trans('file.Pillow & Mattress Model') }}</div>
                                            <div class="col-8 border py-2">{{ $product->curtain->pillow_mattress_model }}</div>
                                        </div>
                                        @if($product->curtain->beddingDetails->count())
                                            <div class="row" style="background-color: #f3f2f7;">
                                                <div class="col-12 border py-2 text-center">{{ trans('file.Bedding Details') }}</div>
                                            </div>
                                                <div class="row">
                                                    <div class="col-1 border py-2 text-center">{{ trans('file.Type') }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ trans('file.name') }}</div>
                                                    <div class="col-3 border py-2 text-center">{{ trans('file.Product') }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ trans('file.Qty') }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ trans('file.Height') }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ trans('file.Width') }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ trans('file.Meterage') }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ trans('file.Bedding Model') }}</div>
                                                    <div class="col-2 border py-2 text-center">{{ trans('file.Under Cover') }}</div>
                                            </div>
                                            @foreach($product->curtain->beddingDetails as $detail)
                                                @php
                                                    $beddingTypeLabel = $detail->type == 'mattress'
                                                        ? trans('file.Mattress Count')
                                                        : ($detail->type == 'bolster' ? trans('file.Bolster Count') : trans('file.Pillow Count'));
                                                @endphp
                                                <div class="row">
                                                    <div class="col-1 border py-2 text-center">{{ $beddingTypeLabel }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ $detail->label ?: trans('file.Group') . ' ' . $loop->iteration }}</div>
                                                    <div class="col-3 border py-2 text-center">{{ optional($detail->product)->name ?: '—' }} — {{ optional($detail->product)->code ?: '—' }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ $detail->count }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ $detail->height }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ $detail->width }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ $detail->meterage ?? '' }}</div>
                                                    <div class="col-1 border py-2 text-center">{{ $detail->model }}</div>
                                                    <div class="col-2 border py-2 text-center">@if($detail->has_under_cover){{ optional($detail->underCoverProduct)->name ?: '—' }} ({{ $detail->under_cover_count }} × {{ $detail->under_cover_meterage }} m)@else—@endif</div>
                                                </div>
                                            @endforeach
                                        @endif
                                        <div class="row">
                                            <div class="col-2 border py-2">{{ trans('file.Order Details') }}</div>
                                            <div class="col-10 border py-2">{!! $product->curtain->curtain_order_details !!}</div>
                                        </div>
                                    </div>
                                </div>
                            @endif

                        </div>

                    </div>
                    <form action="{{ route('tailoringproducts.active',$product->id) }}" method="POST">
                        @csrf
                        @method('PUT')
                    <div class="form-group col-4 mt-2 py-2 offset-8">
                        <input type="submit" value="{{ trans('file.Submit_order') }}" id="submit-btn" class="btn btn-primary w-100">
                    </div>
                    </form>
                </div>

            </div>
        </div>
    </div>
</section>
@endsection
@push('scripts')
    <script>
        $(document).ready(function () {
        $(window).on('load', function() {
            $('#print-btn').trigger('click');
        });


    // Hide all toggler sections initially
    $('#details_rows_container').find('.order_details_toggler').hide();

    // Delegate click event for dynamically added toggles
    $('#details_rows_container').on('click', '.order_details_toggle', function () {
        const toggler = $(this).parent().next('.order_details_toggler');
        const icon = $(this).find('i');

        // Hide all togglers and reset icons
        $('.order_details_toggler').hide(100);
        $('#details_rows_container .order_details_toggle i').removeClass('fa-minus').addClass('fa-plus');

        // Toggle the clicked one
        if (toggler.is(':visible')) {
            toggler.hide(300);
            icon.removeClass('fa-minus').addClass('fa-plus');
        } else {
            toggler.show(300);
            icon.removeClass('fa-plus').addClass('fa-minus');
        }


    });
});

$('#print-btn').on('click', function(e) {
    e.preventDefault();
    var href = $(this).attr('href');
    var printWindow = window.open(href, 'PrintWindow', 'width=600,height=400,top=100,left=100,resizable=yes,scrollbars=yes');
    if (printWindow) {
        printWindow.focus();
    }
});




    </script>
@endpush
