@extends('layouts.master')

@section('style')
<link href='{{ asset('assets\dropzone\dropzone.css') }}' type='text/css' rel='stylesheet'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/css/bootstrap-datepicker3.css"/>
<link rel="stylesheet" href="{{ URL::asset('assets/css/jquery.datetimepicker.css') }}">

<link rel="stylesheet" href="{{ asset('/assets/') }}/alert/pnotify.css">
<link rel="stylesheet" href="{{ asset('/assets/') }}/alert/sweetalert.css">
<link rel="stylesheet" href="{{ asset('/assets/') }}/alert/sweet-alert-animations.css">
<style>

    .dz-message{
     text-align: center;
     font-size: 28px;
    }
    .activity-btn:hover{
        color: #48C2A9;
        border-color: #48C2A9;
    }
    .remarks-div {
        height: 250px;
        /*background-color: #eee;*/
        overflow-y: auto;
    }
    .activity-div {
        height: 250px;
        overflow-y: auto;
    }
    .panel-service .panel-body{
        height:350px;
        overflow-y: auto;
    }
    .bg-grey{background: #ddd;}
    .table{font-size: 12px;}
    .table-company tr th,.table-company tr td{font-size: 12px;}
    .table-company tr th{ width: 25% !important; }
    .table-company tr td{ width:auto !important; }   
    .table-service tr th,.table-service tr td{font-size: 12px;vertical-align: middle !important;}

    @media screen and (min-width: 768px){
        #modalUpload .modal-content{ top:10%;width: 30%;margin: 0 auto; }
    }
    .remarks-footer{
        padding-top: 8px;
        font-size: 11px;
        color: #616A75;
    }
    #modalCompanyEdit .modal-content{width: 50%;margin: 0 auto;}
    .panel-default>.panel-heading {
      background-color: #ddd !important;
    }
</style>
@endsection

@section('content')
<!-- Main content -->
<section class="content">
    <!-- Main row -->
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
            <div class="panel panel-default">
             <div class="panel-heading">
                Company Info
                <a href="{{ route('edit_company',['id'=>$all->id]) }}" data-toggle='modal' data-target='#modalCompanyEdit' class='btn btn-xs btn-primary pull-right'><i style="padding-left: 2px;" class="fa fa-edit"></i></a>
             </div>
               <table class="table table-company">
                     <tr>
                         <th>
                             Company Name
                         </th>
                         <td>
                             {{$all->name}}
                             <input type="hidden" value="{{$all->id}}" id="company_id">
                         </td>
                     </tr>
                     <?php 
                     $ary_industry = [
                         1=>"Recreation",2=>"Food",3=>"Training",
                         4=>"Professionals",5=>"Industry",6=>"Agriculture",7=>"Germents",8=>"Health",9=>"Apperal",10=>"E-Commerce"
                         ];
                     ?>
                     <tr>
                         <th>Industry</th>
                         <td>
                             @foreach($ary_industry as $key=>$indus)
                                 @if($key == $all->industry)
                                     {{$indus}}
                                 @endif
                             @endforeach
                         </td>
                     </tr>
                     <tr>
                         <th>Mobile</th>
                         <td>{{$all->mob1}}, {{$all->mob2}}</td>
                     </tr>
                     <tr>
                         <th>Email</th>
                         <td>{{$all->email1}}, {{$all->email2}}</td>
                         <input type="hidden" class="hdn-email1" value="{{$all->email1}}">
                         <input type="hidden" class="hdn-email2" value="{{$all->email2}}">
                     </tr>
                     <tr>
                         <th>Website</th>
                         <td>{{$all->web}}</td>
                     </tr>
                     <tr>
                         <th>Address</th>
                         <td>{{$all->address}}</td>
                     </tr>
                     <tr>
                         <th>Remarks</th>
                         <td>{{$all->remarks}}</td>
                     </tr>
               </table>
            </div>

            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">Address Book  <button class="btn btn-success btn-xs pull-right" data-toggle="modal" data-target=".add-modal">Add Contract Person</button></div>
                <table class="table table-bordered">
                    <tr>
                        <th width="20%">Name</th>
                        <th width="20%">Designation</th>
                        <th width="20%">Mobile</th>
                        <th width="20%">Email</th>
                        <th width="20%">Action</th>
                    </tr>
                    @foreach($all->contact_persons as $cp)
                        <tr>
                            <td>
                            
                                {{$cp->name}}
                            </td>
                            <td>
                                {{$cp->designation}}
                            </td>
                            <td>
                                {{$cp->mob1}}<br>{{$cp->mob2}}
                            </td>
                            <td>
                                {{$cp->email1}}<br>{{$cp->email2}}
                            </td>
                            <td>
                                @if($cp->system_user==0)
                                    <?php
                                        $add1=$all->address?$all->address:'N/A';
                                        $web1=$all->web?$all->web:'N/A';
                                    ?>
                                    {{-- <span class="btn btn-sm btn-primary sub_btn" data-name="{{$cp->name}}" data-cp_id="{{$cp->id}}" data-phone="{{$cp->mob1}}" data-email="{{$cp->email1}}" data-address="{{$add1}}" data-web="{{$web1}}" data-company="{{$cp->company_id}}" data-designation="{{$cp->designation}}">Add As User</span> --}}
                                    <a href="{{url('admin/company/add_user/'.$cp->id)}}" class="btn btn-sm btn-primary sub_btn">Add As User</a>
                                @else
                                    {{ "N/A" }}
                                @endif
                            </td>
                        </tr>
                    @endforeach
                </table>
            </div>

            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">Account Manager</div>
                @if($manager)
                <table class="table table-bordered" id="table_div">
                    <tr>
                        <th>Name</th>
                        <th>Designation</th>
                        <th>Mobile</th>
                        <th>Email</th>
                        <th>Action</th>
                    </tr>
                        <tr>
                            <td>
                                {{$manager->name}}
                            </td>
                            <td>
                                {{$manager->designation}}
                            </td>
                            <td>
                                {{$manager->mob}}
                            </td>
                            <td>
                                {{$manager->email}}
                            </td>
                            <td>
                                <span class="btn btn-success btn-xs pull-right" id="change_manager">Change Manager</span>
                            </td>
                        </tr>
                </table>
                @endif
                <div class="row" @if($manager) style="display: none;" @endif id="select_div">
                  <div class="col-md-8">
                    <div class="form-group" style="margin-top: 15px;">
                      <select class="form-control" name="manager" placeholder="manager" id="manager">
                          <option>Select Account Manager</option>
                          @foreach($managers_all as $m_all)
                              <option value="{{ $m_all->id }}">{{ $m_all->name }}</option>
                          @endforeach
                      </select>
                    </div>
                  </div>
                  <div class="col-md-4">
                    <span class="btn btn-success btn-block pull-right" style="margin-top: 15px;" id="add_manager">Add Manager</span>
                  </div>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">Remarks</div>
                <div class="panel-body">
                     <textarea class="form-control" name="" id="remarkss" placeholder="Write down remarks"></textarea>
                     <button class="btn btn-success btn-xs remarks-btn" style="margin-top:10px;margin-bottom: 20px;"><i class="fa fa-comment-o"></i> Remark</button>
                     <div class="remarks-div"></div>
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading">Invoice <a href="{{url('invoice/new')}}" class="btn btn-success btn-xs pull-right">New Invoice</a></div>
                <div class="panel-body">
                  @if(!empty($invoice))                 
                  <table class="table table-bordered" id="table_div">
                    <tr>
                        <th>Company Name</th>
                        <th>Service</th>
                        <th>Date</th>
                        <th>Amount</th>
                        <th>Status</th>
                    </tr>
                      @foreach($invoice as $row)
                        <tr>
                            <td>{{$row->company->name}}</td>
                            <td>
                              @foreach($row->items as $item) 
                                {{ $item->service?$item->service->name:'' }} <br>
                              @endforeach
                            </td>
                            <td>{{ date('d-m-Y',strtotime($row->invoice_date)) }}</td>
                            <td>
                              <?php 
                                $total=$row->items?$row->items->sum('payable_amount'):0;;
                                $total1=$row->items?$row->items->sum('payable_amount'):0;
                                $total2=$row->items?$row->items->sum('payable_amount'):0;

                                $total_vat=($total1*$row->vat)/100;
                                $total_tax=($total2*$row->tax)/100;

                                $payable=$total+$total_vat+$total_tax;;
                                $paid=$row->items?$row->items->sum('paid_amount'):0;
                                $due=$payable-$paid;
                                ?>
                                {{ $payable }}
                            </td>
                            <td>
                              @if($row->status==0)
                                <span class='label label-danger'>Due</span>
                              @elseif($row->status==1)
                                <span class='label label-success'>Paid</span>
                              @endif
                            </td>
                        </tr>
                    @endforeach
                  </table>
                  @else
                  <p class="text-center"> Invoice Not Found! </p>
                  @endif
                </div>
            </div>
            
        </div>
        

        <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
          
            <div class="panel panel-default panel-service">
                <!-- Default panel contents -->
                <div class="panel-heading">
                Sevices Of {{$all->name}}
                <a href="#" id="lnkAssignService" data-company_id='{{ $all->id }}' data-company_name='{{ $all->name }}' class='btn btn-info btn-xs pull-right'>
                    <i class="fa fa-plus"></i> Add New Service
                </a>
                </div>
                <!-- Table -->
                <div class="panel-body">
                 
                    <table class="table table-bordered table-service">
                        <thead>
                            <tr>
                                <th>Name Of Service</th>
                                <th>Deployment Unit</th>
                                <th>Start Date</th>
                                <th style='width:30% !important'>Contact Info</th>
                                <th>Upload</th>
                            </tr>
                        </thead>
                        <tbody>
                        @if($company_services)
                        @foreach($company_services as $service)
                            <tr>
                                <td><a target="_blank" href="{{ url('admin/company/service/details') }}/{{ $service->id }}">{{ $service->services?$service->services->name:'--' }}</a></td>
                                <td>{{ $service->deployment_unit_details }}</td>
                                <td>{{ date('d M, Y',strtotime($service->start_date)) }}</td>
                                <td>
                                     <strong>Name : </strong>  {{ $service->contact_person }} <br>
                                    <strong>Phone : </strong>  {{ $service->contact_number }}
                                </td>
                                <td align="center">
                                    <a class='btn btn-info btn-xs' data-toggle='modal' data-target='#modalUpload' href="{{ url('admin/company/service/upload') }}/{{ $service->id }}">
                                    <i class="fa fa-cloud-upload"></i>
                                    </a>
                                </td>
                            </tr>
                        @endforeach
                        @else
                        <tr>
                            <td colspan="4">No Service Found !!</td>
                        </tr>
                        @endif
                        </tbody>
                    </table>
                </div>
              
            </div>
            <div class="panel panel-default">
              <div class="panel-heading">
                    <h3 class="panel-title">Add Task</h3>
              </div>
              <div class="panel-body">
                <div class="nav-tabs-custom">
                  <ul class="nav nav-tabs">
                    <li class="active">
                      <a href="#new_task" data-toggle="tab">
                        <i class="fa fa-list" style="margin-right: 5px;"></i>
                        New Task
                      </a>
                    </li>
                    <li>
                      <a href="#appointment" data-toggle="tab">
                        <i class="fa fa-calendar" style="margin-right: 5px;"></i>
                        Appointment
                      </a>
                    </li>
                    <li>
                      <a href="#phone" data-toggle="tab">
                        <i class="fa fa-phone" style="margin-right: 5px;"></i>
                        Phone
                      </a>
                    </li>
                    <li>
                      <a href="#email" data-toggle="tab">
                        <i class="fa fa-envelope" style="margin-right: 5px;"></i>
                        Email
                      </a>
                    </li>
                  </ul>
                  <div class="tab-content">
                    <div class="active tab-pane" id="new_task">
                      <form role="form" action="{{url('admin/company_task/manager_task')}}" method="POST">
                        {!! csrf_field() !!}
                        <input type="hidden" name="company_id" value="{{$all->id}}">
                        <div class="form-group">
                          <label>
                              Title
                          </label>
                          <input name="name" class="form-control" placeholder="Title" required="">
                          </input>
                        </div>
                        <div class="form-group">
                          <label>
                              Description
                          </label>
                          <textarea name="description" class="form-control" id="task_editor" placeholder="Description" rows="5"></textarea>
                        </div>
                        <div class="form-group">
                          <label>
                              Priority
                          </label>
                          <select name="priority" class="form-control">
                              <option value="1">Low</option>
                              <option value="2">Mid</option>
                              <option value="3">High</option>
                          </select>
                        </div>
                        <div class="form-group">
                          <label>
                              Dead Line
                          </label>
                          <input name="date" type="text" class="form-control date" placeholder="Select Date and Time" required="">
                          </input>
                        </div>
                        <button type="submit" class="btn btn-primary">Add</button>
                      </form>
                    </div>
                    <div class="tab-pane" id="appointment">
                      <form role="form" action="{{url('admin/company_task/manager_appointment')}}" method="POST">
                        {!! csrf_field() !!}
                        <input type="hidden" name="company_id" value="{{$all->id}}">
                        <div class="form-group">
                          <label>
                              Title
                          </label>
                          <input name="name" class="form-control" placeholder="Title" required="">
                          </input>
                        </div>
                        <div class="form-group">
                          <label>
                              Description
                          </label>
                          <textarea name="description" class="form-control" id="task_editor" placeholder="Description" rows="5"></textarea>
                        </div>
                        <div class="form-group">
                          <label>
                              Priority
                          </label>
                          <select name="priority" class="form-control">
                              <option value="1">Low</option>
                              <option value="2">Mid</option>
                              <option value="3">High</option>
                          </select>
                        </div>
                        <div class="form-group">
                          <label>
                              Appointment Date
                          </label>
                          <input name="date" type="text" class="form-control date" placeholder="Select Date and Time" required="">
                          </input>
                        </div>
                        <button type="submit" class="btn btn-primary">Add</button>
                      </form>
                    </div>
                    <div class="tab-pane" id="phone">
                      <form role="form" action="{{url('admin/company_task/manager_phone')}}" method="POST">
                        {!! csrf_field() !!}
                        <input type="hidden" name="company_id" value="{{$all->id}}">
                        <div class="form-group">
                          <label>
                              Title
                          </label>
                          <input name="name" class="form-control" placeholder="Title" required="">
                          </input>
                        </div>
                        <div class="form-group">
                          <label>
                              Description
                          </label>
                          <textarea name="description" class="form-control" id="task_editor" placeholder="Description" rows="5"></textarea>
                        </div>
                        <div class="form-group">
                          <label>
                              Priority
                          </label>
                          <select name="priority" class="form-control">
                              <option value="1">Low</option>
                              <option value="2">Mid</option>
                              <option value="3">High</option>
                          </select>
                        </div>
                        <div class="form-group">
                          <label>
                              Call Date
                          </label>
                          <input name="date" type="text" class="form-control date" placeholder="Select Date and Time" required="">
                          </input>
                        </div>
                        <button type="submit" class="btn btn-primary">Add</button>
                      </form>
                    </div>
                    <div class="tab-pane" id="email">
                      <form role="form" action="{{url('admin/company_task/send_email')}}" method="POST">
                        {!! csrf_field() !!}
                        <input type="hidden" name="company_id" value="{{$all->id}}">
                        <div class="form-group">
                          <label>
                              To
                          </label>
                          <select name="mail_to" class="form-control">
                              @if(count($all->contact_persons))
                                <option disabled="" selected="">Select One..</option>
                                @foreach($cilents as $clnt)
                                  <option value="{{ $clnt->id }}">{{ $clnt->name }}</option>
                                @endforeach
                              @else
                                <option disabled="" selected="">No Contact Person Added Yet.</option>
                              @endif
                          </select>
                        </div>
                        <div class="form-group">
                          <label>
                              Subject
                          </label>
                          <input name="subject" class="form-control" placeholder="Subject" required="">
                          </input>
                        </div>
                        <div class="form-group">
                          <label>
                              Message
                          </label>
                          <textarea name="message" class="form-control" id="task_editor" placeholder="Message" rows="5"></textarea>
                        </div>
                        <button type="submit" class="btn btn-primary">Send</button>
                      </form>
                    </div>
                  </div>
                  <!-- /.tab-content -->
                </div>
              </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">Activity</h3>
                </div>
                <div class="panel-body">
                    <div style="min-height: 250px;" class="activity-div"></div>
                </div>
             
                <div class="panel-footer">
                    <button class="btn btn-xs activity-btn" data-fullText="Already called.">
                         Mobile 
                         <i class="fa fa-mobile" aria-hidden="true"></i>
                    </button>
                    <button class="btn btn-xs activity-btn" data-toggle="modal" data-target=".modal-email" data-fullText="mail">
                         Email 
                         <i class="fa fa-envelope-o" aria-hidden="true"></i>
                    </button>
                    <button class="btn btn-xs activity-btn" data-fullText="Already send a sms.">
                         SMS             
                         <i class="fa fa-comments-o" aria-hidden="true"></i>
                    </button>
                </div>
            </div>
        </div>


    </div>

</section>

<!-- Modal to add services -->
@include('admin.company_info.service_modal')
<!-- end modal to add services -->

<!-- Modal Add Contract person -->
@include('admin.company_info.add_contact_info')
<!-- /.modal -->

<!-- Modal Email -->
@include('admin.company_info.modal_email')
<!-- /.modal -->

<!-- Modal File Upload -->
<div class="modal fade" id="modalUpload">
  <div class="modal-dialog modal-md">
    
  </div>
</div>
<!-- /.modal -->


<!--Edit Company Modal File Upload -->
<div class="modal fade" id="modalCompanyEdit">
  <div class="modal-dialog modal-md">
    
  </div>
</div>
<!-- /.modal -->

@endsection

@section('script')
<script src="{{URL::asset('assets/ckeditor/ckeditor.js')}}"></script>
<script type="text/javascript" src="{{ URL::asset('assets/js/jquery.datetimepicker.full.min.js') }}"></script>
<script src="{{URL::asset('assets/front_end/js/plugins/timepicker/bootstrap-timepicker.js')}}"></script>
<script src="{{ asset('/assets/') }}/alert/sweetalert.min.js"></script>
<script src="{{ asset('/assets/') }}/alert/pnotify.js"></script>
<script src="{{ asset('/assets/') }}/alert/notify.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $( ".date" ).datetimepicker({
          dateFormat: 'dd/mm/yy',
          timeFormat: 'HH:mm',
        });
        /*$('.date').timepicker({
            timeFormat: 'H:i',
            template: false,
            //showInputs: true,
        });*/
        CKEDITOR.replace( 'task_editor' );
        /*$( ".date" ).datepicker({
              changeMonth: true,
              changeYear: true,
              dateFormat:"dd-mm-yy",
              timeFormat: 'hh:mm'
        });*/
        $('body').on('click','.sub_btn',function(){
            var user_name=$(this).data('name');
            var phone=$(this).data('phone');
            var email=$(this).data('email');
            var address=$(this).data('address');
            var web=$(this).data('web');
            var company=$(this).data('company');
            var designation=$(this).data('designation');
            var cp_id=$(this).data('cp_id')

            $.ajax({
                url: "{{url('admin/company/add_user')}}",
                type: 'POST',
                data: {user_name: user_name, mob: phone, email: email, address: address, website: web, company: company, designation:designation, cp_id:cp_id},
            })
             console.log(data)
            .done(function(data) {
                alert(data);
                location.reload();
            }); 

        });
        $('body').on('click','#add_manager',function(){
            var user_id = $( "#manager option:selected" ).val();;
            var company = $('#company_id').val();
            $.ajax({
                url: "{{url('admin/company/add_manager')}}",
                type: 'POST',
                data: {user_id: user_id,company: company},
            })
            .done(function(data) {
                alert(data);
                location.reload();
            }); 

        });
        $('body').on('click','#change_manager',function(){
            $('#table_div').hide('fast');
            $('#select_div').show('slow');
        });
        $('body').on('hidden.bs.modal', '.modal', function () {
          $(this).removeData('bs.modal');
        });

        $('#lnkAssignService').click(function(e){
            e.preventDefault();
            var com_id=$(this).data('company_id');
            var com_name=$(this).data('company_name');
            $('span#company_name').text(com_name);
            $('input[name="hdn_com_id"]').val(com_id);

            $('#modalService').modal('show');

        });

        $('#btn_assign_service').click(function(){
            var com_id=$('input[name="hdn_com_id"]').val();
            var service=$('#ddlService').val();
            var contact_person=$('#contact_person').val();
            var contact_number=$('#contact_number').val();
            var deployement_unit=$('#deployement_unit').val();
            var po_details=$('#po_details').val();
            var renewal_cycle=$('#renewal_cycle').val();
            var free_session=$('#free_session').val();
            var start_date=$('#start_date').val();
            var token='{{ csrf_token() }}';
            if(com_id.length==0 || service.length==0){
                $('#spn_msg').text('Service name must be selected !'); 
                return false;
            }

            $.ajax({
                url: '{{ url('admin/company/service/assign') }}',
                type: 'POST',
                dataType: 'json',
                data: {com_id:com_id,service:service,contact_person:contact_person,contact_number:contact_number,deployement_unit:deployement_unit,po_details:po_details,renewal_cycle:renewal_cycle,free_session:free_session,start_date:start_date,_token:token}
            })
            .done(function(res) {
                if(res.ok)
                {
                    alert(res.msg);
                    $('#modalService').modal('hide');

                }
            });
            
        });

        var company_id = $('#company_id').val();
        //fetch remarks
        $.ajax({
            url: "{{url('admin/save_remarks')}}",
            type: 'POST',
            data: {remarks: '0', company_id: company_id},
        })
        .done(function(data) {
            
            $('.remarks-div').html(data);
        }); 

        //fetch activity
        $.ajax({
            url: "{{url('admin/save_activity')}}",
            type: 'POST',
            data: {val: '0', company_id: company_id},
        })
        .done(function(data) {
            
            $('.activity-div').html(data);
        });

        //ck editor
        CKEDITOR.replace( 'editor1' );
        CKEDITOR.replace( 'comment_txt' );

    });

    $('.activity-btn').click(function(event) {
        
        var email1 = $('.hdn-email1').val();
        var email2 = $('.hdn-email2').val();
        
        $('.to-email').val(email1+', '+email2);

        var val = $(this).attr("data-fullText");
        
        if(val != 'mail'){

            if(confirm('Want to add in activity list ?')){
                var company_id = $('#company_id').val();
                $.ajax({
                    url: "{{url('admin/save_activity')}}",
                    type: 'POST',
                    data: {val: val, company_id: company_id},
                })
                .done(function(data) {
                    
                    $('.activity-div').html(data);
                });
            }
        }
    });

    $('.email-send').click(function(event){

        var val = "An email sent.";
        var company_id = $('#company_id').val();
        var email1 = $('.hdn-email1').val();
        var email2 = $('.hdn-email2').val();
        var email_subj = $('.email_subj').val();
        var attachment_id = $('.attachment_id').val();
        var email_body = CKEDITOR.instances.editor1.getData();

        if(email1.length > 0){
            $.ajax({
                url: "{{url('admin/send_email_to_company')}}",
                type: 'POST',
                data: {email1: email1,email2: email2, subj: email_subj, email_body:email_body,attachment_id: attachment_id},
            })
            .done(function(data){
                
                if(data == 'success'){
                    $.ajax({
                        url: "{{url('admin/save_activity')}}",
                        type: 'POST',
                        data: {val: val, company_id: company_id},
                    })
                    .done(function(data) {
                        
                        $('.activity-div').html(data);
                    });

                    alert('Email Send successfully!!');
                }
                else{
                    alert('Sorry! email not send ...');
                }
            });
        }
        else{
            alert('Email 01 filed is mendatory. Email address not available!');
        }
    });

    $( ".activity-div" ).on( "click",".remove-activity",function() {
        
        var id = $(this).attr("data-id");
        var company_id = $('#company_id').val();

        if(confirm('Want to delete?'))
        {
            $.ajax({
                url: "{{url('admin/remove_activity')}}",
                type: 'POST',
                data: {id: id,company_id: company_id},
            })
            .done(function(data) {
                
                $('.activity-div').html(data);
                alert('Data removed successfully!');
            });
        }

    });
    
    $('.remarks-btn').click(function(event) {
        
        var remarks = $('#remarkss').val();
        var company_id = $('#company_id').val();

        if(remarks.length > 0){

            $.ajax({
                url: "{{url('admin/save_remarks')}}",
                type: 'POST',
                data: {remarks: remarks, company_id: company_id},
            })
            .done(function(data) {
                
                $('.remarks-div').html(data);
                $('#remarkss').val('');
            });
        }
        else{
            alert('Please fill up remarks field');
        }
    });

    $( ".remarks-div" ).on( "click",".remove-remarks",function() {
        
        var id = $(this).attr("data-id");
        var company_id = $('#company_id').val();

            if(confirm('Want to delete?'))
            {
                $.ajax({
                    url: "{{url('admin/remove_remarks')}}",
                    type: 'POST',
                    data: {id: id,company_id: company_id},
                })
                .done(function(data) {
                    
                    $('.remarks-div').html(data);
                    alert('Data removed successfully!');
                });
            }

    });
</script>
@endsection
@if(Session::has('msg'))
  <div class="alert alert-success center-block msg_alt" >
    <a class="close" data-dismiss="alert" href="#">&times;</a>
    <strong><i class="fa fa-check"></i></strong>&nbsp;
  {{Session::get('msg')}}
  </div>
@endif
