@extends('adminlte::page')
@section('content')
    <?php Fun::lang()?>

    <?php
   
    $h = [];
    $mn = [];
    for($hours=1; $hours<=12; $hours++){
        $h[sprintf('%02d', $hours)] = sprintf('%02d', $hours);
    }
    for($m=0; $m<60; $m++){
        $mn[ sprintf('%02d', $m)] = sprintf('%02d', $m);
    }
    ?>
    <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="#">Add Task</a></li>
            </ul> 
        </div>
    </div>
    <div class="page">
<div class=container-fluid>
        <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.add_task')}}</h3>
                        </div>
                    </div>
                </div>
            </div>
        </div>
       
        {!! Form::open(array('route' => 'agent-task.store','method'=>'POST')) !!}
        <div class="row">
               
            <div class="col-sm-12">
                <div class="master-form">
                    <div class="title-note">
                        <h3><span class="fa fa-exclamation-triangle"></span>​​​​ {{__('administrator.add_task')}} <i>({{__('administrator.fields_in_red_are_required')}})</i></h3>
                    </div>
                    <div class="row">
                        <div class="form-group col-sm-6 col-xs-12">
                            <div class="form-group col-sm-12 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name" class="required">{{__('administrator.gender')}}</label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('sex', $lead_name->sex, array('placeholder' => __('administrator.sex'),'class' => 'form-control select2','readonly')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-12 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('lead_email', $lead_name->email, array('placeholder' => __('administrator.email'),'class' => 'form-control date_picker','readonly','')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-12 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name" class="required">{{__('administrator.subject')}}</label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('subject', null, array('placeholder' => __('administrator.subject'),'class' => 'form-control','required','maxlength'=>'50')) !!}

                                </div>
                            </div>
                            <div class="form-group col-sm-12 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label class="required" for="name">{{__('administrator.time')}} </label>
                                </div>
                                <div class="col-sm-3 col-xs-12">
                                    {!! Form::select('admin_hour', $h, null,array('placeholder'=> __('administrator.hour'),'class' => 'select2 form-control','required')) !!}
                                </div>
                                <div class="col-sm-3 col-xs-12">
                                    {!! Form::select('admin_minutes', $mn, null,array('placeholder'=>__('administrator.minute'),'class' => 'select2 form-control','required')) !!}
                                </div>
                                <div class="col-sm-3 col-xs-12">
                                    {!! Form::select('admin_shift', ['AM'=>'AM','PM'=>'PM'], null,array('placeholder'=>'Shift','class' => 'select2 form-control','required')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-12 col-xs-12" id="to_append">

                            </div>
                            <div class="form-group col-sm-12 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name" class="required">{{__('administrator.follower')}}</label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::select('agent_id', $agent,null, array('class' => 'form-control ','required')) !!}
                                </div>
                            </div>
                        </div>
                        <div class="form-group col-sm-6 col-xs-12">
                            <div class="form-group col-sm-12 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name" class="required">{{__('administrator.lead_name')}}</label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('lead_name', $lead_name->name, array('placeholder' => __('administrator.lead_name'),'class' => 'form-control date_picker','readonly','')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-12 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name" class="required">{{__('administrator.contact')}}</label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('lead_contact', $lead_name->contact, array('placeholder' => __('administrator.contact'),'class' => 'form-control date_picker','readonly','')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-12 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label class="required" for="name">{{__('administrator.task_type')}} </label>
                                </div>
                                <div class="col-sm-9 col-xs-12">
                                    {!! Form::select('task_type', [''=>__('administrator.please_select'),'Appointment'=>'Appointment','Call_log'=>'Call_Log','Meeting'=>'Meeting'], null,array('class' => 'select2 form-control','required','id'=>'appointment')) !!}
                                </div>
                            </div>
                            <div class="form-group col-sm-12 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name" class="required">{{__('administrator.date')}}</label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::text('admin_date', date('d-m-Y'), array('placeholder' => __('administrator.date'),'class' => 'form-control date_picker hasDatepicker','required','')) !!}
                                    <input type="hidden" value="{{$lead_name->id}}" name="lead_id">
                                </div>
                            </div>
                            <div class="form-group col-sm-12 col-xs-12">
                                <div class="col-sm-3 col-xs-12 ">
                                    <label for="name">{{__('administrator.note')}}</label>
                                </div>
                                <div class="col-sm-9">
                                    {!! Form::textarea('admin_note', null, array('placeholder' =>__('administrator.note'),'class' => 'form-control','','rows'=>'4','maxlength'=>'255')) !!}
                                </div>
                            </div>

                        </div>
                    </div>
                    <div class="col-sm-12 col-xs-12">
                        <div class="form-group footer-save">
                            <button type="submit" class="button_sm button_primary pull-right"><span class="fa fa-save"></span> {{__('administrator.save')}}</button>
                            <button type="button"  onClick="javascript:history.go(-1)" class="button_sm button_warning pull-right">
                                <span class=" fa fa-arrow-circle-left"></span> {{__('administrator.back')}}</button>
                        </div>
                    </div>
                </div>

            </div>
        </div>
        {!! Form::close() !!}
    </div>
@endsection
    @section('adminlte_js')
    <script>
        $(document).ready(function(){
            $('#appointment').prop('selectedIndex',0);
        });
        $(document).on('change','#appointment',function(){
            var value = $(this).val();
            $('#to_append').empty();
            if(value=="Meeting" || value=="Appointment"){
                var box = '<div class="col-sm-3 col-xs-12 "><label for="name" class="required">{{__('administrator.place')}}</label></div><div class="col-sm-9">{!! Form::text('where', null, array('placeholder' => __('administrator.place'),'class' => 'form-control','required','maxlength'=>'50')) !!}</div>';
                $('#to_append').append(box);
            }
        });
    </script>
@endsection