@extends('layout.app')


@section('content')
    <div class="card card-default">
        <div class="card-body">
            @php
                $other_reseller_customer_recharge = $sms_data->where('sms_type','other_reseller_customer_recharge')->first();
                $other_reseller_customer_reminder = $sms_data->where('sms_type','other_reseller_customer_reminder')->first();
                $other_reseller_customer_expire = $sms_data->where('sms_type','other_reseller_customer_expire')->first();
                $other_reseller_customer_new_customer = $sms_data->where('sms_type','other_reseller_customer_create')->first();
                $customResellerSmsGatewaySetup_welcome_sms_setting = $sms_data->where('sms_type','own_reseller_customer_create')->first();
                $customResellerSmsGatewaySetup_payment_sms_setting = $sms_data->where('sms_type','own_reseller_customer_payment')->first();
                $customResellerSmsGatewaySetup_reminder_sms_setting = $sms_data->where('sms_type','own_reseller_customer_reminder')->first();
                $balance = checkSmsBalance($reseller->id);

                // dd($other_reseller_customer_new_customer);
            @endphp


            <form action="{{ route('reseller-sms-gateway-save') }}" method="POST">
                @csrf
                <div class="card mx-auto col-sm-6  col-lg-6">
                    <div class="card-body" style="text-align: center">
                        <span class="lead">Your sms balance</span>
                        <h2 class="text-center">{!! $balance['balance'] !!}</h2>
                        {{-- <h2 class="text-center">{{ $balance['status'] }}</h2> --}}
                    </div>
                </div>
                {{-- <p class="text-green">Balance : {{$balance['balance']}} {{$balance['status']}}</p> --}}
                <div class="row">
                    <div class="form-group col-md-12">
                        <label for="name" class="block text-sm font-medium text-gray-700">
                            Sms Gateway*
                        </label>
                        <input type="hidden" id="reseller_id" name="reseller_id" value="{{$reseller->id}}">
                        <input type="text" name="gatway" id="gatway" value="{{ $reseller_sms_getway->sms_gateway ?? "" }}" class="form-control"
                            placeholder="http://api{contactNumber}{messageBody}" autocomplete="off">
                        @error('gatway')
                            <div class="alert alert-danger">{{ $message }}</div>
                        @enderror
                    </div>
                </div>
                <div class="row">
                    <div class="form-group col-md-12">
                        <label for="name" class="block text-sm font-medium text-gray-700">
                            Sms Balance Url
                        </label>

                        <input type="text" name="sms_balance_url" id="sms_balance_url" value="{{ $reseller_sms_getway->sms_balance_url ?? "" }}" class="form-control"
                            placeholder="url;api_token;sid" autocomplete="off">
                        @error('sms_balance_url')
                            <div class="alert alert-danger">{{ $message }}</div>
                        @enderror
                    </div>
                </div>

                @if ($reseller->reseller_type == 'other')
                    <div class="container col-md-12">
                        <table>
                            <tr>
                                <td >From </td>
                                <td><strong>Other Reseller Customer Recharge</strong> </td>
                            </tr>
                            <tr>
                                <td >Send SMS?</td>
                                <td style="vertical-align: top">
                                    <div class="row">
                                        <div class="form-check">
                                            <input class="form-check-input" type="radio" name="other_reseller_customer_recharge_sms_setting" id="other_reseller_customer_recharge_setting_yes" @if ($other_reseller_customer_recharge->send_sms == 'Yes') checked  @endif  value="Yes">
                                            <label class="form-check-label" for="yes">
                                            Yes
                                            </label>
                                        </div>
                                        <div class="form-check">
                                            <input class="form-check-input" type="radio" name="other_reseller_customer_recharge_sms_setting" id="other_reseller_customer_recharge_setting_no" @if ($other_reseller_customer_recharge->send_sms == 'No') checked  @endif   value="No">
                                            <label class="form-check-label" for="no">
                                            No
                                            </label>
                                        </div>
                                    </div>

                                </td>
                            </tr>


                            <tr >
                                <td style="text-align: right;vertical-align: top">SMS Massage* <br>
                                    <span style="color:#FF0000;font-size:12px">Type Text here</span></td>
                                <td style="width: 70%">

                                    <textarea class="form-control" name="other_reseller_customer_recharge_sms_body" rows="10">{{$other_reseller_customer_recharge->sms_body}}</textarea>

                                </td>
                                <td style="width: 300px">
                                    <textarea class="form-control" id="other_reseller_customer_recharge_sms_field" rows="10" readonly>{c_id}&#10;{c_username}&#10;{c_name}&#10;{c_expire_date}&#10;{month}&#10;{package_price}&#10;{reseller_name}&#10;{reseller_mobile}</textarea>
                                </td>
                            </tr>
                        </table>



                    </div>


                    <div class="container col-md-12">
                        <table>
                            <tr>
                                <td >From </td>
                                <td><strong>Other Reseller Customer Reminder</strong> </td>
                            </tr>
                            <tr>
                                <td>Before Day</td>
                                <td><input type="number" name="other_reseller_customer_reminder_day" value="{{$other_reseller_customer_reminder->days_before ?? 2}}"></td>
                            </tr>
                            <tr>
                                <td >Send SMS?</td>
                                <td style="vertical-align: top">
                                    <div class="row">
                                        <div class="form-check">
                                            <input class="form-check-input" type="radio" name="other_reseller_customer_reminder_sms_setting" @if ($other_reseller_customer_reminder->send_sms == 'Yes') checked  @endif value="Yes">
                                            <label class="form-check-label" for="yes">
                                            Yes
                                            </label>
                                        </div>
                                        <div class="form-check">
                                            <input class="form-check-input" type="radio" name="other_reseller_customer_reminder_sms_setting"  @if ($other_reseller_customer_reminder->send_sms == 'No') checked  @endif value="No">
                                            <label class="form-check-label" for="no">
                                            No
                                            </label>
                                        </div>
                                    </div>

                                </td>
                            </tr>


                            <tr >
                                <td style="text-align: right;vertical-align: top">SMS Massage* <br>
                                    <span style="color:#FF0000;font-size:12px">Type Text here</span></td>
                                <td style="width: 70%">

                                    <textarea class="form-control" name="other_reseller_customer_reminder_sms_body" rows="10">{{$other_reseller_customer_reminder->sms_body}}</textarea>

                                </td>
                                <td style="width: 300px">
                                    <textarea class="form-control" id="other_reseller_customer_reminder_sms_field" rows="10" readonly>{c_id}&#10;{c_username}&#10;{c_name}&#10;{c_expire_date}&#10;{package_price}&#10;{reseller_name}&#10;{reseller_mobile}</textarea>
                                </td>
                            </tr>
                        </table>



                    </div>

                    <div class="container col-md-12">
                        <table>
                            <tr>
                                <td >From </td>
                                <td><strong>Other Reseller Customer Expire</strong> </td>
                            </tr>
                            <tr>
                                <td >Send SMS?</td>
                                <td style="vertical-align: top">
                                    <div class="row">
                                        <div class="form-check">
                                            <input class="form-check-input" type="radio" name="other_reseller_customer_expire_sms_setting"  @if ($other_reseller_customer_expire->send_sms == 'Yes') checked  @endif value="Yes">
                                            <label class="form-check-label" for="yes">
                                            Yes
                                            </label>
                                        </div>
                                        <div class="form-check">
                                            <input class="form-check-input" type="radio" name="other_reseller_customer_expire_sms_setting" @if ($other_reseller_customer_expire->send_sms == 'No') checked  @endif  value="No">
                                            <label class="form-check-label" for="no">
                                            No
                                            </label>
                                        </div>
                                    </div>

                                </td>
                            </tr>


                            <tr >
                                <td style="text-align: right;vertical-align: top">SMS Massage* <br>
                                    <span style="color:#FF0000;font-size:12px">Type Text here</span></td>
                                <td style="width: 70%">

                                    <textarea class="form-control" name="other_reseller_customer_expire_sms_body" rows="10">{{$other_reseller_customer_expire->sms_body}}</textarea>

                                </td>
                                <td style="width: 300px">
                                    <textarea class="form-control" id="other_reseller_customer_expire_sms_field" rows="10" readonly>{c_id}&#10;{c_username}&#10;{c_name}&#10;{c_expire_date}&#10;{package_price}&#10;{reseller_name}&#10;{reseller_mobile}</textarea>
                                </td>
                            </tr>
                        </table>



                    </div>

                    <div class="container col-md-12">
                        <table>
                            <tr>
                                <td >From </td>
                                <td><strong>Other Reseller Customer Create</strong> </td>
                            </tr>
                            <tr>
                                <td >Send SMS?</td>
                                <td style="vertical-align: top">
                                    <div class="row">
                                        <div class="form-check">
                                            <input class="form-check-input" type="radio" name="other_reseller_customer_create_sms_setting" @if ($other_reseller_customer_new_customer->send_sms == 'Yes') checked  @endif value="Yes">
                                            <label class="form-check-label" for="yes">
                                            Yes
                                            </label>
                                        </div>
                                        <div class="form-check">
                                            <input class="form-check-input" type="radio" name="other_reseller_customer_create_sms_setting" @if ($other_reseller_customer_new_customer->send_sms == 'No') checked  @endif value="No">
                                            <label class="form-check-label" for="no">
                                            No
                                            </label>
                                        </div>
                                    </div>

                                </td>
                            </tr>


                            <tr >
                                <td style="text-align: right;vertical-align: top">SMS Massage* <br>
                                    <span style="color:#FF0000;font-size:12px">Type Text here</span></td>
                                <td style="width: 70%">

                                    <textarea class="form-control" name="other_reseller_customer_create_sms_body" rows="10">{{$other_reseller_customer_new_customer->sms_body}}</textarea>

                                </td>
                                <td style="width: 300px">
                                    <textarea class="form-control" id="other_reseller_customer_create_sms_field" rows="10" readonly>{c_id}&#10;{c_name}&#10;{c_username}&#10;{c_password}&#10;{package_name}&#10;{package_price}&#10;{c_expire_date}&#10;{reseller_name}&#10;{reseller_mobile}</textarea>
                                </td>
                            </tr>
                        </table>



                    </div>

                @else
                    @if (globalPermission('customResellerSmsGatewaySetup'))
                        <div class="container col-md-12">
                            <table>
                                <tr>
                                    <td >From </td>
                                    <td><strong>Reseller Customer Create</strong> </td>
                                </tr>
                                <tr>
                                    <td >Send SMS?</td>
                                    <td style="vertical-align: top">
                                        <div class="row">
                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="customResellerSmsGatewaySetup_welcome_sms" @if ($customResellerSmsGatewaySetup_welcome_sms_setting->send_sms == 'Yes') checked  @endif value="Yes">
                                                <label class="form-check-label" for="yes">
                                                Yes
                                                </label>
                                            </div>
                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="customResellerSmsGatewaySetup_welcome_sms" @if ($customResellerSmsGatewaySetup_welcome_sms_setting->send_sms == 'No') checked  @endif value="No">
                                                <label class="form-check-label" for="no">
                                                No
                                                </label>
                                            </div>
                                        </div>

                                    </td>
                                </tr>


                                <tr >
                                    <td style="text-align: right;vertical-align: top">SMS Massage* <br>
                                        <span style="color:#FF0000;font-size:12px">Type Text here</span></td>
                                    <td style="width: 70%">

                                        <textarea class="form-control" name="customResellerSmsGatewaySetup_welcome_sms_body" rows="10">{{$customResellerSmsGatewaySetup_welcome_sms_setting->sms_body}}</textarea>

                                    </td>
                                    <td style="width: 300px">
                                        <textarea class="form-control" id="customResellerSmsGatewaySetup_welcome_sms_field" rows="10" readonly>{c_id}&#10;{c_code}&#10;{c_name}&#10;{c_username}&#10;{c_password}&#10;{c_package}&#10;{c_due}&#10;{c_deadline}&#10;{payment_url}</textarea>
                                    </td>
                                </tr>
                            </table>



                        </div>

                        <div class="container col-md-12">
                            <table>
                                <tr>
                                    <td >From </td>
                                    <td><strong>Reseller Customer Bill Payment </strong> </td>
                                </tr>
                                <tr>
                                    <td >Send SMS?</td>
                                    <td style="vertical-align: top">
                                        <div class="row">
                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="customResellerSmsGatewaySetup_payment_sms" @if ($customResellerSmsGatewaySetup_payment_sms_setting->send_sms == 'Yes') checked  @endif value="Yes">
                                                <label class="form-check-label" for="yes">
                                                Yes
                                                </label>
                                            </div>
                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="customResellerSmsGatewaySetup_payment_sms" @if ($customResellerSmsGatewaySetup_payment_sms_setting->send_sms == 'No') checked  @endif value="No">
                                                <label class="form-check-label" for="no">
                                                No
                                                </label>
                                            </div>
                                        </div>

                                    </td>
                                </tr>


                                <tr >
                                    <td style="text-align: right;vertical-align: top">SMS Massage* <br>
                                        <span style="color:#FF0000;font-size:12px">Type Text here</span></td>
                                    <td style="width: 70%">

                                        <textarea class="form-control" name="customResellerSmsGatewaySetup_payment_body" rows="10">{{$customResellerSmsGatewaySetup_payment_sms_setting->sms_body}}</textarea>

                                    </td>
                                    <td style="width: 300px">
                                        <textarea class="form-control" id="customResellerSmsGatewaySetup_payment_field" rows="10" readonly>{c_id}&#10;{c_code}&#10;{c_password}&#10;{c_username}&#10;{c_name}&#10;{c_expire_date}&#10;{PaymentAmount}&#10;{PaymentDiscount}&#10;{PaymentMethod}&#10;{TotalDue}&#10;{MoneyreciptNo}&#10;{TrxId}&#10;{payment_date}&#10;{payment_description}</textarea>
                                    </td>
                                </tr>
                            </table>



                        </div>

                        <div class="container col-md-12">
                            <table>
                                <tr>
                                    <td >From </td>
                                    <td><strong>Reseller Customer Reminder</strong> </td>
                                </tr>
                                <tr>
                                    <td>Before Day</td>
                                    <td><input type="number" name="customResellerSmsGatewaySetup_reminder_sms_day" value="{{$customResellerSmsGatewaySetup_reminder_sms_setting->days_before ?? 2}}"></td>
                                </tr>
                                <tr>
                                    <td >Send SMS?</td>
                                    <td style="vertical-align: top">
                                        <div class="row">
                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="customResellerSmsGatewaySetup_reminder_sms" @if ($customResellerSmsGatewaySetup_reminder_sms_setting->send_sms == 'Yes') checked  @endif value="Yes">
                                                <label class="form-check-label" for="yes">
                                                Yes
                                                </label>
                                            </div>
                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="customResellerSmsGatewaySetup_reminder_sms"  @if ($customResellerSmsGatewaySetup_reminder_sms_setting->send_sms == 'No') checked  @endif value="No">
                                                <label class="form-check-label" for="no">
                                                No
                                                </label>
                                            </div>
                                        </div>

                                    </td>
                                </tr>


                                <tr >
                                    <td style="text-align: right;vertical-align: top">SMS Massage* <br>
                                        <span style="color:#FF0000;font-size:12px">Type Text here</span></td>
                                    <td style="width: 70%">

                                        <textarea class="form-control" name="customResellerSmsGatewaySetup_reminder_sms_body" rows="10">{{$customResellerSmsGatewaySetup_reminder_sms_setting->sms_body}}</textarea>

                                    </td>
                                    <td style="width: 300px">
                                        <textarea class="form-control" rows="10" readonly>{c_id}&#10;{c_username}&#10;{c_name}&#10;{c_deadline}&#10;{total_due}</textarea>
                                    </td>
                                </tr>
                            </table>



                        </div>
                    @endif
                @endif









                <div class="col-sm-12">
                    <div class="form-group float-right">
                        <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> Save</button>

                    </div>
                </div>


            </form>


        </div>


    </div>
@endsection
