@extends('adminlte::page')
@section('content')
    <?php Fun::lang()?>
    <style>
        .select2-container--default .select2-selection--single {
            border: none;
        }
        .select2-container--default .select2-selection--single .select2-selection__arrow b {
            border-style: none;
        }
    </style>
    <div class="title-add">
        <div class="page-bar"> 
            <ul class="page-breadcrumb"> 
                <li> <a class="ng-binding" href="#"><i class="fa fa-dashboard"></i> Dashboard</a> </li>
                <li><a href="#">Operation</a></li>
                <li><a href="#">Manage Client</a></li>
                <li><a href="#">Manage CRM</a></li>
                <li><a href="#">Lead</a></li>
                <li><a href="#">View Lead</a></li>
            </ul> 
        </div>
    </div>
    <div class="page">
        <div class="top-content">
            <div class="row">
                <div class="col-sm-12 col-xs-12">
                    <div class="title-add">
                        <div class="pull-left">
                            <h3>{{__('administrator.lead')}} {!! $lead->convert_status==1?('<span class="label label-success">'.__('administrator.close_deal').' '.__('administrator.success').'</span>'):($lead->convert_status==2?('<span class="label label-danger">'.__('administrator.close_deal').' '.__('administrator.fail').'</span>'):'<span class="label label-warning">'.__('administrator.close_deal').' '.__('administrator.pending').'</span>') !!}</h3>
                        </div>
                        <div class="pull-right">
                            <a href="{{route('lead.index')}}" class="button_sm button_warning pull-right">
                                <span class=" fa fa-arrow-circle-left"></span> {{__('administrator.back')}}</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="master-form">
                    <div class="form-group col-sm-12 col-xs-12">
                        <fieldset>
                            <legend>
                                {{__('administrator.lead_info')}}
                            </legend>
                            <div class="form-group col-sm-6 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name">{{__('administrator.date')}} </label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('date',date('d-m-Y',strtotime($lead->date)), array('placeholder' =>__('administrator.date'),'class' => 'form-control no-border','readonly')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-6 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name">{{__('administrator.follower')}} </label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('agent', optional($lead->agent)->user_firstname.' '.optional($lead->agent)->user_lastname, array('placeholder' =>__('administrator.agent'),'class' => 'form-control no-border','readonly')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-6 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name">{{__('administrator.lead')}}</label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('lead', $lead->family_name.' '.$lead->name, array('placeholder' =>__('administrator.lead_source'),'class' => 'form-control no-border','readonly')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-6 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name">{{__('administrator.gender')}} </label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('sex',__('administrator.'.strtolower($lead->sex)), array('placeholder' =>__('administrator.sex'),'class' => 'form-control no-border','readonly')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-6 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name">{{__('administrator.contact')}} </label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('contact', $lead->contact, array('placeholder' =>__('administrator.contact'),'class' => 'form-control no-border','readonly')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-6 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name">{{__('administrator.email')}} </label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('email', $lead->email, array('placeholder' =>__('administrator.email'),'class' => 'form-control no-border','readonly')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-6 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name">{{__('administrator.address')}} </label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('address', $lead->address, array('placeholder' =>__('administrator.address'),'class' => 'form-control no-border','readonly')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-6 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name">{{__('administrator.lead_source')}} </label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('lead_sources', optional($lead->lead_sources)->source_name, array('placeholder' =>__('administrator.lead_source'),'class' => 'form-control no-border','readonly')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-6 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name">{{__('administrator.job')}} </label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('job', $lead->job, array('placeholder' =>__('administrator.job'),'class' => 'form-control no-border','readonly')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-6 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name">{{__('administrator.workplace')}} </label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('workplace', $lead->workplace, array('placeholder' =>__('administrator.workplace'),'class' => 'form-control no-border','readonly')) !!}
                                </div>
                            </div>
                        </fieldset>
                    </div>
                    <div class="form-group col-sm-12 col-xs-12">
                        <fieldset>
                            <legend>
                                {{__('administrator.call_log')}}
                            </legend>
                            <div class="form-group col-sm-12 col-xs-12">
                                <table class="table table-hover">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>{{__('administrator.follower')}}</th>
                                        <th>{{__('administrator.date')}}</th>
                                        <th>{{__('administrator.time')}}</th>
                                        <th>{{__('administrator.subject')}}</th>
                                        <th>{{__('administrator.status')}}</th>
                                        <th>{{__('administrator.call_type')}}</th>
                                        <th>{{__('administrator.call_duration')}}</th>
                                        <th>{{__('administrator.out_come')}}</th>
                                        <th width="16%">{{__('administrator.result_percentage')}}</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    @if($call_log->count()>0)
                                        @foreach($call_log as $k => $row)
                                            <tr>
                                                <td>{{$k+1}}</td>
                                                <td>{{optional($row->agent)->user_firstname.' '.optional($row->agent)->user_lastname}}</td>
                                                <td>{{date('d-m-Y',strtotime($row->date))}}</td>
                                                <td>{{$row->hour.':'.$row->minutes.':'.$row->shift}}</td>
                                                <td>{{$row->subject}}</td>
                                                <td>{!! $row->complete_status==1?'<span class="label label-success">'.__('administrator.complete').'</span>':'<span class="label label-warning">'.__('administrator.pending').'</span>'!!}</td>
                                                <td>{{$row->call_type?$row->call_type:'N/A'}}</td>
                                                <td>{{$row->call_duration?$row->call_duration:'N/A'}}</td>
                                                <td>{{$row->out_come?$row->out_come:'N/A'}}</td>
                                                <td>{{$row->result_percentage?$row->result_percentage.'%':'N/A'}}</td>
                                            </tr>
                                        @endforeach
                                    @else
                                        <tr>
                                            <td colspan="10" class="text-center">No Data</td>
                                        </tr>
                                    @endif
                                    </tbody>
                                </table>
                            </div>
                        </fieldset>
                    </div>
                    <div class="form-group col-sm-12 col-xs-12">
                        <fieldset>
                            <legend>
                                {{__('administrator.appointment_log')}}
                            </legend>
                            <div class="form-group col-sm-12 col-xs-12">
                                <table class="table table-hover">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>{{__('administrator.follower')}}</th>
                                        <th>{{__('administrator.date')}}</th>
                                        <th>{{__('administrator.time')}}</th>
                                        <th>{{__('administrator.subject')}}</th>
                                        <th>{{__('administrator.place')}}</th>
                                        <th>{{__('administrator.status')}}</th>
                                        <th>{{__('administrator.out_come')}}</th>
                                        <th width="16%">{{__('administrator.result_percentage')}}</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    @if($appointment->count()>0)
                                        @foreach($appointment as $k => $row)
                                            <tr>
                                                <td>{{$k+1}}</td>
                                                <td>{{optional($row->agent)->user_firstname.' '.optional($row->agent)->user_lastname}}</td>
                                                <td>{{date('d-m-Y',strtotime($row->date))}}</td>
                                                <td>{{$row->hour.':'.$row->minutes.':'.$row->shift}}</td>
                                                <td>{{$row->subject}}</td>
                                                <td>{{$row->where}}</td>
                                                <td>{!! $row->complete_status==1?'<span class="label label-success">'.__('administrator.complete').'</span>':'<span class="label label-warning">'.__('administrator.pending').'</span>'!!}</td>
                                                <td>{{$row->out_come?$row->out_come:'N/A'}}</td>
                                                <td>{{$row->result_percentage?$row->result_percentage.'%':'N/A'}}</td>
                                            </tr>
                                        @endforeach
                                    @else
                                        <tr>
                                            <td colspan="9" class="text-center">No Data</td>
                                        </tr>
                                    @endif

                                    </tbody>
                                </table>
                            </div>
                        </fieldset>
                    </div>
                    <div class="form-group col-sm-12 col-xs-12">
                        <fieldset>
                            <legend>
                                {{__('administrator.meeting_log')}}
                            </legend>
                            <div class="form-group col-sm-12 col-xs-12">
                                <table class="table table-hover">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>{{__('administrator.follower')}}</th>
                                        <th>{{__('administrator.date')}}</th>
                                        <th>{{__('administrator.time')}}</th>
                                        <th>{{__('administrator.subject')}}</th>
                                        <th>{{__('administrator.place')}}</th>
                                        <th>{{__('administrator.status')}}</th>
                                        <th>{{__('administrator.out_come')}}</th>
                                        <th width="16%">{{__('administrator.result_percentage')}}</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    @if($meeting->count()>0)
                                        @foreach($meeting as $k => $row)
                                            <tr>
                                                <td>{{$k+1}}</td>
                                                <td>{{optional($row->agent)->user_firstname.' '.optional($row->agent)->user_lastname}}</td>
                                                <td>{{date('d-m-Y',strtotime($row->date))}}</td>
                                                <td>{{$row->hour.':'.$row->minutes.':'.$row->shift}}</td>
                                                <td>{{$row->subject}}</td>
                                                <td>{{$row->where}}</td>
                                                <td>{!! $row->complete_status==1?'<span class="label label-success">'.__('administrator.complete').'</span>':'<span class="label label-warning">'.__('administrator.pending').'</span>'!!}</td>
                                                <td>{{$row->out_come?$row->out_come:'N/A'}}</td>
                                                <td>{{$row->result_percentage?$row->result_percentage.'%':'N/A'}}</td>
                                            </tr>
                                        @endforeach
                                    @else
                                        <tr>
                                            <td colspan="9" class="text-center">No Data</td>
                                        </tr>
                                    @endif
                                    </tbody>
                                </table>
                            </div>
                        </fieldset>
                    </div>
                    @if($lead->convert_status>0)
                    <div class="form-group col-sm-12 col-xs-12">
                        <fieldset>
                            <legend>
                                {{__('administrator.close_deal')}}
                            </legend>
                            <div class="form-group col-sm-6 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label>{{__('administrator.result')}} </label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::select('close_deal', [''=>__('administrator.please_select'),'1'=>__('administrator.success'),'2'=>__('administrator.fail')],$lead->convert_status, array('class' => 'form-control select2','disabled')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-6 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label>{{__('administrator.note')}} </label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::textarea('close_deal_note',$lead->close_deal_note, array('class' => 'form-control no-resize no-border','rows'=>'4','readonly')) !!}
                                </div>
                            </div>
                        </fieldset>
                    </div>
                    <div class="form-group col-sm-12 col-xs-12">
                        <a href="{{route('lead.index')}}"
                           class="button_sm button_warning pull-right">
                            <span class=" fa fa-arrow-circle-left"></span> {{__('administrator.back')}}</a>
                    </div>
                    @endif
                </div>
            </div>
        </div>
    </div>
@endsection
@section('script')
    <script type="text/javascript">
        $(document).ready(function () {

        });
    </script>
@endsection