<?php 
    $extra_sum = 0;
    if(!empty($data->priclist_detail)){
       $price_new_arr = json_decode($data->priclist_detail);
       if($price_new_arr != NULL){
           $price_new_arr = array_column($price_new_arr, 'value_field');
           $extra_sum = array_sum($price_new_arr);    
       }
    }
?>
<div class="row">
    <div class="col-12">
        <div class="card">
            <hr style="border: 1px solid grey;width: 250px;">
            <h3><i>Make Deal</i></h3>
            <hr style="border: 1px solid grey;width: 250px;">
            <div class="card-body mt-2">
                <div class="col-md-12">
                    <table class="table table-bordered table-striped" style="color:black!important;">
                        <tr> 
                            <td colspan="6" class="text-center"><b>Reverse Calculation</b></td>
                        </tr>
                        <tr>
                            <td><b>Booking Date</b></td>
                            <td colspan="2">{!! \Carbon\Carbon::parse($make_deal_data->booking_date)->format('d-m-Y') !!}</td>
                            <td><b>KEC</b></td>
                            <td colspan="2">{!! $make_deal_data->sales_person_name !!}</td>
                        </tr>
                        <tr>
                            <td><b>Customer Name</b></td>
                            <td colspan="2">{!! $make_deal_data->customer_name !!}</td>
                            <td><b>TL</b></td>
                            <td colspan="2">{!! strtoupper($make_deal_data->team_name) !!}</td>
                        </tr>
                        <tr>
                            <td><b>Location (Branch)</b></td>
                            <td colspan="5">{!! strtoupper($make_deal_data->branch_name) !!}</td>
                        </tr>
                        <tr>
                            <td><b>Vin No.</b></td>
                            <td colspan="5">{!! $make_deal_data->vin_number !!}</td>
                        </tr>
                        <tr class="light_gray">
                            <td class="text-center"><b>{!! $make_deal_data->car_model_name !!}</b></td>
                            <td class="text-center"><b>Purchase Price</b></td>
                            <td class="text-center"><b>Aging Days</b></td>
                            <td class="text-center"><b>Remark</b></td>
                            <td class="text-center"><b>Ex Showroom Price</b></td>
                            <td class="text-center"><b>Deal</b></td>
                        </tr>
                        <tr>
                            <td><b>{!! $make_deal_data->car_varient_name !!}</b></td>
                            <td class="right-align purchase_price">{!! $make_deal_data->purchase_price !!}</td>
                            <td class="right-align">{!! $make_deal_data->aging_days !!}</td>
                            <td class="right-align">{!! $make_deal_data->inventory_remark !!}</td>
                            <td class="right-align ex_showroom_price">{!! $price_list_name->basic ?? 0 !!}</td>
                            <td class="right-align ex_showroom_price_deal">{{ $make_deal_data->deal_amt ?? 0 }}</td> 
                            
                        </tr>
                        <tr>
                            <input type="hidden" name="gst_tax" id="hidden_gst_tax" value="{{ rtrim($price_list_name->gst_percentage, '.0') }}">
                            <td><b>GST @ {!! $price_list_name->gst_percentage !!}%</b></td>
                            <td class="right-align">{{ $make_deal_data->purchase_gst_tax_deal ?? 0 }}</td>
                            <td class="right-align gst_price" colspan="3">{!! $price_list_name->gst_amount !!}</td>
                            <td class="right-align gst_tax_deal">{{ $make_deal_data->gst_tax_deal ?? 0 }}</td>
                        </tr>
                        <tr>
                            <input type="hidden" name="cess_tax" id="hidden_cess_tax" value="{{ rtrim($price_list_name->cess_percentage, '.0') }}">
                            <td><b>Cess @ {!! $price_list_name->cess_percentage !!}%</b></td>
                            <td class="right-align cess_price" colspan="4">{!! $price_list_name->cess_amount !!}</td>
                            <td class="right-align cess_tax_deal">{{ $make_deal_data->cess_tax_deal ?? 0 }}</td>
                        </tr>
                        <tr>
                            <td><b>TCS @ 1%</b></td>
                            <td class="right-align tcs_price" colspan="4">{!! $make_deal_data->tcs_tax_id !!}</td>
                            <td class="right-align tcs_tax_deal">{{ $make_deal_data->tcs_tax_deal ?? 0 }}</td>
                        </tr>
                        <tr>
                            <td><b>Municipal Tax</b></td>
                            <td class="right-align municipal_price" colspan="4">{!! $make_deal_data->municipal_tax_id !!}</td>
                            <td class="right-align municipal_tax_deal">{{ $make_deal_data->municipal_tax_deal ?? 0 }}</td>
                        </tr>
                        <tr>
                            <td><b>Municipal Custom Handling Charges</b></td>
                            <td class="right-align municipal_custom_handling_charges" colspan="4">{!! $make_deal_data->municipal_custom_handling_charges !!}</td>
                            <td class="right-align municipal_custom_handling_charges_deal">{{ $make_deal_data->municipal_custom_handling_charges_deal ?? 0 }}</td>
                        </tr>
                        <tr>
                            <td><b>RTO</b></td>
                            <td class="right-align rto_price" colspan="4">{!! $make_deal_data->registration_tax_id !!}</td>
                            <td class="right-align rto_deal">{{ $make_deal_data->rto_deal ?? 0 }}</td>
                        </tr>
                        <tr>
                            <td><b>RTO Custom Handling Charges</b></td>
                            <td class="right-align rto_custom_handling_charges_price" colspan="4">{!! $make_deal_data->rto_custom_handling_charges ?? 0 !!}</td>
                            <td class="right-align rto_custom_handling_charges_deal">{{ $make_deal_data->rto_cutom_handling_charges_deal  ?? '' }}</td>
                        </tr>
                        <tr>
                            <td><b>INSURANCE</b></td>
                            <td class="right-align insurance_price" colspan="4">{!! $make_deal_data->insurance_id ?? 0 !!}</td>
                            <td class="right-align insurance_deal">{{ $make_deal_data->insurance_deal ?? 0 }}</td>
                        </tr>
                        <tr>
                            <td><b>Fastag</b></td>
                            <td class="right-align fastage_price" colspan="4">{!! $make_deal_data->fasttag_amount_new ?? 0 !!}</td>
                            <td class="right-align fastage_amt_deal">{!! $make_deal_data->fasttag_amount_new ?? 0 !!}</td>
                        </tr>
                        <tr>
                            <td><b>EW</b></td>
                            <td class="right-align extended_warranty" colspan="4">{!! $make_deal_data->extand_warranties_amount ?? 0!!}</td>
                            <td class="right-align ew_deal">{!! $make_deal_data->extand_warranties_amount ?? 0 !!}</td>
                        </tr>
                        <tr>
                            <td><b>Accessories</b></td>
                            <td class="right-align accessories_price" colspan="4">{!! $accessory_sum ?? 0 !!}</td>
                            <td class="right-align accessories_deal">{!! $accessory_sum ?? 0 !!}</td>
                        </tr>
                        <tr>
                            <td><b>Other Accessories</b></td>
                            <td class="right-align other_price" colspan="4">{!! $make_deal_data->other_accesssories_prise ?? 0 !!}</td>
                            <td class="right-align other_deal">{!! $make_deal_data->other_accesssories_prise ?? 0 !!}</td>
                        </tr>
                        <tr>
                            <td><b>
                                {{ $make_deal_data->rsa_type == 'RSA' ? 'RSA' : ($make_deal_data->ccs_type == 'CCS' ? 'CCS' : 'RSA / CCS') }}
                            </b></td>
                        
                            <td class="right-align rsa_price" colspan="4">{!! $make_deal_data->rsa_amount ?? $make_deal_data->ccs_amount ?? 0 !!}</td>
                            <td class="right-align rsa_deal">{!! $make_deal_data->rsa_amount ?? $make_deal_data->ccs_amount ?? 0 !!}</td> 
                        </tr>
                        <tr>
                            <td><b>MCP</b></td>
                            <td class="right-align mcp_price" colspan="4">{!! $make_deal_data->mcp_amount ?? 0 !!}</td>
                            <td class="right-align mcp_deal">{!! $make_deal_data->mcp_amount ?? 0 !!}</td>
                        </tr>
                        <tr>
                            <td colspan="6"> </td>
                        </tr>
                        <tr class="light_gray">
                            <td><b>Total On Road Price</b></td>
                            <td class="right-align on_road_price" colspan="4"></td>
                            <td class="right-align on_road_price_deal"></td>
                        </tr>
                        <tr class="final-deal">
                            <td><b>Accepted Deal</b></td>
                            <td class="right-align final_deal_amt" colspan="4">{{ $make_deal_data->final_deal_amt ?? $make_deal_data->final_on_road_price_after_way_off }}</td>
                            <td class="right-align final_deal_deal">{!! $make_deal_data->final_deal_amt  ?? '' !!}</td>
                        </tr>
                        <tr>
                            <td><b>Difference</b></td>
                            <td class="right-align diff_amount" colspan="4"></td>
                            <td class="right-align diff_amount_deal"></td>
                        </tr>
                    </table>
                    
                    <table class="table table-bordered table-striped" style="color:black!important;margin-top:7px;">
                        <tr>
                            <td class="left-align" colspan="6"><b>Remark : </b>{{ $make_deal_data->remark ?? '' }}</td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>    
