@extends('layouts.app')
@section('title', __('vrc::lang.service_plans'))
@section('content')
<section class="content-header"><h1>@lang('vrc::lang.service_plans')</h1></section>
<section class="content">
    @component('components.widget', ['class' => 'box-primary'])
        @slot('tool')<div class="box-tools">
            <button class="btn btn-default" data-toggle="modal" data-target="#vrc_enroll_modal"><i class="fa fa-user-plus"></i> @lang('vrc::lang.enroll_customer')</button>
            <button class="btn btn-primary vrc-modal-btn" data-href="{{ route('vrc.service-plans.create') }}"><i class="fa fa-plus"></i> @lang('messages.add')</button>
        </div>@endslot
        <table class="table table-bordered table-striped" id="vrc_plans_table">
            <thead><tr><th>@lang('vrc::lang.plan')</th><th>@lang('vrc::lang.price')</th><th>@lang('vrc::lang.visits')</th><th>@lang('vrc::lang.validity_months')</th><th>@lang('vrc::lang.status')</th><th>@lang('messages.action')</th></tr></thead>
        </table>
    @endcomponent

    <div class="modal fade vrc_modal" tabindex="-1" role="dialog"></div>

    <div class="modal fade" id="vrc_enroll_modal" tabindex="-1" role="dialog"><div class="modal-dialog"><div class="modal-content">
        {!! Form::open(['route' => 'vrc.service-plans.enroll', 'class' => 'vrc-form']) !!}
        <div class="modal-header"><button type="button" class="close" data-dismiss="modal">&times;</button><h4 class="modal-title">@lang('vrc::lang.enroll_customer')</h4></div>
        <div class="modal-body">
            <div class="form-group">{!! Form::label('erp_customer_id', __('vrc::lang.customer') . ':*') !!}{!! Form::select('erp_customer_id', $customers, null, ['class' => 'form-control vrc-select2', 'required', 'placeholder' => __('messages.please_select')]) !!}</div>
            <div class="form-group">{!! Form::label('plan_id', __('vrc::lang.plan') . ':*') !!}{!! Form::number('plan_id', null, ['class' => 'form-control', 'required', 'placeholder' => 'Plan id']) !!}</div>
        </div>
        <div class="modal-footer"><button type="submit" class="btn btn-primary">@lang('vrc::lang.enroll')</button><button type="button" class="btn btn-default" data-dismiss="modal">@lang('messages.close')</button></div>
        {!! Form::close() !!}
    </div></div></div>
</section>
@endsection
@section('javascript')
<script>
$(function () {
    var t = $('#vrc_plans_table').DataTable({ processing:true, serverSide:true, ajax:'{{ route('vrc.service-plans.index') }}',
        columns:[{data:'name',name:'name'},{data:'price',name:'price'},{data:'visit_count',name:'visit_count'},{data:'validity_months',name:'validity_months'},{data:'is_active',name:'is_active',orderable:false},{data:'action',name:'action',orderable:false,searchable:false}]});
    window.__vrcTables = window.__vrcTables || []; window.__vrcTables.push(t);
});
</script>
@include('vrc::partials.crud_scripts')
@endsection
