@extends('layouts.master')
@section('page_title')
    @if(isset($page_title))
        {{ $page_title }}
    @endif
@endsection
@section('content')
<div class="">
  <div class="page-title">
    <div class="title_left" style="width:800px !important;">
      <ol class="breadcrumb">
        <li><a href="{!! url('dashboard') !!}">Dashboard</a></li>
        <li><a href="{!! url('clients') !!}">Clients</a></li>
        <li><a href="{{ url('clients',  $client->id) }}">{{ $client->name }}</a></li>
        <li class="active">Update Client Details</li>
      </ol>
    </div>
  </div>
  <div class="clearfix"></div>
  <div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
      <div class="x_panel">
          <div class="x_title">
            Update Client Details
            @include('commons.notifications')
            <div class="clearfix"></div>
          </div>
          {{-- start of content --}}
          <div class="x_content">
              <br>
                  {!! Form::model($client, [ 'method' => 'PATCH', 'files' => 'true', 'url' => ['clients', $client], 'class' => 'form-horizontal form-label-left']) !!}
                  <input type="hidden" name="current_pending_stage" value="{{ $current_pending_stage }}">
                  <div class="row">
                      <div class="col-md-4">
                        <div class="form-group">
                          <div class="{{ $errors->has('name') ? 'has-error' : ''}}">
                            <label class="" for="name">Name</label>
                            {!! Form::text('name', old('name'), ['class' => 'form-control ', 'placeholder'=>'Enter client name' , 'id' => 'name']) !!}
                            {!! $errors->first('name', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                        <div class="form-group ">
                            <div class=" {{ $errors->has('auth_user_id') ? 'has-error' : ''}}">
                              <label class="" for="auth_user_id">Account Manager</label>
                              {!! Form::select('auth_user_id', $auth_users ,old('auth_user_id'), ['class' => 'form-control ', 'placeholder'=>'Enter Account Manager ' , 'id' => 'auth_user_id']) !!}
                              {!! $errors->first('auth_user_id', '<p class="help-block">:message</p>') !!}
                            </div>
                        </div>
                        <div class="form-group">
                          <div class=" {{ $errors->has('contact_person') ? 'has-error' : ''}}">
                            <label class="" for="email">Contact Person</label>
                            {!! Form::text('contact_person', old('contact_person'), ['class' => 'form-control', 'placeholder'=>'Enter Contact Person' , 'id' => 'contact_person']) !!}
                            {!! $errors->first('contact_person', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                        <div class="form-group">
                          <div class=" {{ $errors->has('phone') ? 'has-error' : ''}}">
                            <label class="" for="email">Phone</label>
                            {!! Form::text('phone', old('phone'), ['class' => 'form-control', 'placeholder'=>'Enter Phone Number' , 'id' => 'phone']) !!}
                            {!! $errors->first('phone', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>

                        <div class="form-group">
                          <div class=" {{ $errors->has('email') ? 'has-error' : ''}}">
                            <label class="" for="email">Email</label>
                            {!! Form::text('email', old('email'), ['class' => 'form-control ', 'placeholder'=>'Enter email' , 'id' => 'email']) !!}
                            {!! $errors->first('email', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                        <div class="form-group">
                          <div class=" {{ $errors->has('skype_name') ? 'has-error' : ''}}">
                            <label class="" for="skypeName">Skype Name</label>
                            {!! Form::text('skype_name', old('skype_name'), ['class' => 'form-control', 'placeholder'=>'Enter Skype Name' , 'id' => 'skypeName']) !!}
                            {!! $errors->first('skype_name', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                        <div class="form-group">
                          <div class=" {{ $errors->has('linkedin_name') ? 'has-error' : ''}}">
                            <label class="" for="linkedIn">Linked In</label>
                            {!! Form::text('linkedin_name', old('linkedin_name'), ['class' => 'form-control ', 'placeholder'=>'Enter LinkedIn Name' , 'id' => 'linkedIn']) !!}
                            {!! $errors->first('linkedin_name', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                        <div class="form-group">
                          <div class=" {{ $errors->has('finance_email') ? 'has-error' : ''}}">
                            <label class="" for="financeEmail">Finance Emails (Multiple) </label>
                            {!! Form::select('finance_email[]', $finance_emails, $old_finance_emails, ['class' => 'form-control financeEmail', 'id' => 'financeEmail', 'multiple' => 'true']) !!}
                            {!! $errors->first('finance_email', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                        <div class="form-group">
                          <div class=" {{ $errors->has('support_email') ? 'has-error' : ''}}">
                            <label class="" for="supportEmail">Support Emails (Multiple) </label>
                            {!! Form::select('support_emails[]', $support_emails, $old_support_emails, ['class' => 'form-control supportEmail', 'id' => 'supportEmail', 'multiple' => 'true']) !!}
                            {!! $errors->first('support_emails', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>

                        <div class="form-group">
                          <div class=" {{ $errors->has('support_phones') ? 'has-error' : ''}}">
                            <label class="" for="supportPhones">Support Phone Numbers (Multiple) </label>
                            {!! Form::select('support_phones[]', $support_phones, $old_support_phones, ['class' => 'form-control supportPhones', 'id' => 'supportPhones', 'multiple' => 'true']) !!}
                            {!! $errors->first('support_phones', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                        <div class="form-group">
                          <div class=" {{ $errors->has('country') ? 'has-error' : ''}}">
                            <label class="" for="country">Country</label>
                            {!! Form::select('country', $countries, old('country'), ['class' => 'form-control ', 'placeholder'=>'Enter Country ' , 'id' => 'country']) !!}
                            {!! $errors->first('country', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                        <div class="form-group">
                          <div class=" {{ $errors->has('currency') ? 'has-error' : ''}}">
                            <label class="" for="currency">Currency</label>
                            {!! Form::select('currency', $currency ,old('currency'), ['class' => 'form-control ' , 'id' => 'currency']) !!}
                            {!! $errors->first('currency', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                      </div>
                      <div class="col-md-4">
                          <div class="form-group">
                            <div class=" {{ $errors->has('services') ? 'has-error' : ''}}">
                              <label class="" for="type">Services</label>
                              {!! Form::select('services[]', $service_type, $current_services, ['class' => 'form-control typeServices' , 'id' => 'services', 'multiple'=> 'true']) !!}
                              {!! $errors->first('services', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                          <div class="form-group">
                            <div class=" {{ $errors->has('name') ? 'has-error' : ''}}">
                              <label class="" for="companyType">Company Type</label>
                              {!! Form::select('company_type', $company_types, old('company_type'),  ['class' => 'form-control', 'placeholder'=>'Enter  Company Type' , 'id' => 'companyType']) !!}
                              {!! $errors->first('company_type', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                          <div class="form-group">
                            <div class="{{ $errors->has('name') ? 'has-error' : ''}}">
                            <label class="" for="industryType">Industry Type</label>
                              {!! Form::select('industry', $industries, old('industry'),  ['class' => 'form-control', 'placeholder'=>'Enter Industry Type' , 'id' => 'industryType', 'required' => 'true']) !!}
                              {!! $errors->first('industry', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                          <div class="form-group">
                            <label class="" for="contractType">Contract Type</label>
                            <div class=" {{ $errors->has('contract_type') ? 'has-error' : ''}}">
                              {!! Form::select('contract_type', $contract_types, old('contract_type'), ['class' => 'form-control ', 'placeholder'=>'Select Contract type' , 'id' => 'contractType']) !!}
                              {!! $errors->first('contract_type', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                          <div class="form-group">
                            <label class="" for="contractValidity">Contract Validity</label>
                            <div class=" {{ $errors->has('contract_validity') ? 'has-error' : ''}}">
                              {!! Form::text('contract_validity', old('contract_validity'), ['class' => 'form-control', 'placeholder'=>'Enter Contract Date' , 'id' => 'contractValidity']) !!}
                              {!! $errors->first('contract_validity', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                          <div class="form-group">
                            <div class=" {{ $errors->has('contract_auto_renew') ? 'has-error' : ''}}">
                              <label class="" for="contractAutoRenew">Contract Auto Renewal</label>
                              {!! Form::select('contract_auto_renew', ['YES' => 'YES','NO' => 'NO'], old('contract_auto_renew'),  ['class' => 'form-control ' , 'id' => 'contractAutoRenew' ]) !!}
                              {!! $errors->first('contract_auto_renew', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                          <div class="form-group">
                            <div class=" {{ $errors->has('connections') ? 'has-error' : ''}}">
                              <label class="" for="connections">Connection</label>
                              {!! Form::select('connections[]', $connections_arr, json_decode($client->connections, true),  ['class' => 'form-control ' , 'id' => 'connections', 'multiple' => 'true' ]) !!}
                              {!! $errors->first('connections', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                          <div class="form-group">
                            <div class=" {{ $errors->has('connections') ? 'has-error' : ''}}">
                              <label class="" for="connections">Message Type</label>
                              {!! Form::select('message_types[]', $message_types_arr, json_decode($client->message_types, true),  ['class' => 'form-control ' , 'id' => 'connections', 'multiple' => 'true' ]) !!}
                              {!! $errors->first('connections', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                          <div class="form-group">
                            <div class=" {{ $errors->has('smpp_username') ? 'has-error' : ''}}">
                              <label class="" for="smppUsername">SMPP Connections Details</label>
                              {!! Form::text('smpp_username', old('smpp_username'), ['class' => 'form-control' , 'id' => 'smppUsername', 'placeholder' => 'SMPP Username']) !!}
                              {!! $errors->first('smpp_username', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                           <div class="form-group">
                          <div class=" {{ $errors->has('support_skype') ? 'has-error' : ''}}">
                            <label class="" for="rateEmail">Support Skype IDs (Multiple) </label>
                            {!! Form::select('support_skype[]', $support_skype_arr, $old_support_skype_arr, ['class' => 'form-control supportSkype', 'id' => 'supportSkype', 'multiple' => 'true']) !!}
                            {!! $errors->first('support_skype', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                        <div class="form-group">
                          <div class=" {{ $errors->has('rate_email') ? 'has-error' : ''}}">
                            <label class="" for="rateEmail">Rate Emails (Multiple) </label>
                            {!! Form::select('rate_emails[]', $rate_emails, $old_rate_emails, ['class' => 'form-control rateEmail', 'id' => 'rateEmail', 'multiple' => 'true']) !!}
                            {!! $errors->first('rate_emails', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>

                      </div>
                      <div class="col-md-4">
                        <div class="form-group">
                            <div class=" {{ $errors->has('payment_mode') ? 'has-error' : ''}}">
                              <label class="" for="payment_mode">Payment Mode</label>
                              {!! Form::select('payment_mode', $payment_type, old('pay_mode'), ['class' => 'form-control' , 'id' => 'payment_mode']) !!}
                              {!! $errors->first('payment_mode', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                          <!-- <div class="form-group">
                            <div class=" {{ $errors->has('sender_ids') ? 'has-error' : ''}}">
                              <label class="" for="senderIds">Requested Sender IDs</label>
                              {!! Form::select('sender_ids[]', $sender_ids, $old_sender_ids, ['class' => 'form-control senderIds' , 'id' => 'senderIds', 'multiple' => 'true' ]) !!}
                              {!! $errors->first('sender_ids', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div> -->
                          <div class="form-group">
                            <div class=" {{ $errors->has('how_we_got_client') ? 'has-error' : ''}}">
                              <label class="" for="howWeGotClient">How We got Client</label>
                              {!! Form::select('how_we_got_client', $how_we_got_clients_arr, old('how_we_got_client'), ['class' => 'form-control' , 'id' => 'howWeGotClient' ]) !!}
                              {!! $errors->first('how_we_got_client', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                          <div class="form-group">
                            <div class=" {{ $errors->has('how_we_got_client_other') ? 'has-error' : ''}}">
                              <label class="" for="howWeGotClientOther">Other</label>
                              {!! Form::text('how_we_got_client_other', null, ['class' => 'form-control' , 'id' => 'howWeGotClientOther', 'placeholder' => 'Specify how we got the client']) !!}
                              {!! $errors->first('how_we_got_client_other', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                          <div class="form-group">
                              <div class=" {{ $errors->has('notes') ? 'has-error' : ''}}">
                                <label class="" for="clientNotes">Notes</label>
                                {!! Form::textarea('notes', old('notes'), ['class' => 'form-control ', 'placeholder'=>'Enter additional information here', 'rows' => '3', 'id' => 'clientNotes']) !!}
                                {!! $errors->first('notes', '<p class="help-block">:message</p>') !!}
                              </div>
                          </div>
                          <div class="row">
                            <div class="col-md-6">
                              <div class="form-group">
                                <div class=" {{ $errors->has('document_one_name') ? 'has-error' : ''}}">
                                  <label class="" for="documentOneName">Document Name</label>
                                  {!! Form::text('document_one_name', 'Contract', ['class' => 'form-control' , 'id' => 'documentOneName', 'readonly' => 'true']) !!}
                                  {!! $errors->first('document_one_name', '<p class="help-block">:message</p>') !!}
                                </div>
                              </div>
                            </div>
                            <div class="col-md-6">
                              <div class="form-group">
                                <div class=" {{ $errors->has('document_one') ? 'has-error' : ''}}">
                                  <label class="" for="documentOne">Contract Document</label>
                                  {!! Form::file('document_one', null, ['class' => 'form-control' , 'id' => 'documentOne', 'placeholder' => 'Select file to upload']) !!}
                                  {!! $errors->first('document_one', '<p class="help-block">:message</p>') !!}
                                </div>
                              </div>
                            </div>
                            <div class="col-md-12">
                              @if($files['contract'] == 'YES')
                              <p class="text-danger">Uploading a new Contract will overwrite the existing file</p>
                              @endif
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-6">
                              <div class="form-group">
                                <div class=" {{ $errors->has('document_two_name') ? 'has-error' : ''}}">
                                  <label class="" for="documentOneName">Document Name</label>
                                  {!! Form::text('document_two_name', 'Non Disclosure', ['class' => 'form-control' , 'id' => 'documentTwoName', 'readonly' => 'true']) !!}
                                  {!! $errors->first('document_two_name', '<p class="help-block">:message</p>') !!}
                                </div>
                              </div>
                            </div>
                            <div class="col-md-6">
                              <div class="form-group">
                                <div class=" {{ $errors->has('document_two') ? 'has-error' : ''}}">
                                  <label class="" for="documentTwo">Non Disclosure Document</label>
                                  {!! Form::file('document_two', null, ['class' => 'form-control' , 'id' => 'documentTwo', 'placeholder' => 'Select file to upload']) !!}
                                  {!! $errors->first('document_two', '<p class="help-block">:message</p>') !!}
                                </div>
                              </div>
                            </div>
                            <div class="col-md-12">
                              @if($files['non_disclosure'] == 'YES')
                              <p class="text-danger">Uploading a new Non Disclosure will overwrite the existing file</p>
                              @endif
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-6">
                              <div class="form-group">
                                <div class=" {{ $errors->has('how_we_got_client_other') ? 'has-error' : ''}}">
                                  <label class="" for="documentThreeName">Document Name</label>
                                  {!! Form::text('document_three_name', 'Technical Document', ['class' => 'form-control' , 'id' => 'documentThreeName', 'readonly' => 'true']) !!}
                                  {!! $errors->first('document_three_name', '<p class="help-block">:message</p>') !!}
                                </div>
                              </div>
                            </div>
                            <div class="col-md-6">
                              <div class="form-group">
                                <div class=" {{ $errors->has('document_three') ? 'has-error' : ''}}">
                                  <label class="" for="documentThree">Technical Document</label>
                                  {!! Form::file('document_three', null, ['class' => 'form-control' , 'id' => 'documentThree']) !!}
                                  {!! $errors->first('document_three', '<p class="help-block">:message</p>') !!}
                                </div>
                              </div>
                            </div>
                            <div class="col-md-12">
                              @if($files['technical_doc'] == 'YES')
                              <p class="text-danger">Uploading a Technical Document file will overwrite the existing file</p>
                              @endif
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-6">
                              <div class="form-group">
                                <div class=" {{ $errors->has('how_we_got_client_other') ? 'has-error' : ''}}">
                                  <label class="" for="otherdocumentName">Other Document</label>
                                  {!! Form::text('other_document_name', null, ['class' => 'form-control' , 'id' => 'otherdocumentName', 'placeholder' => 'Enter name of document']) !!}
                                  {!! $errors->first('document_three_name', '<p class="help-block">:message</p>') !!}
                                </div>
                              </div>
                            </div>
                            <div class="col-md-6">
                              <div class="form-group">
                                <div class=" {{ $errors->has('other_document') ? 'has-error' : ''}}">
                                  <label class="" for="otherDocument">Other Document</label>
                                  {!! Form::file('other_document', null, ['class' => 'form-control' , 'id' => 'otherDocument']) !!}
                                  {!! $errors->first('other_document', '<p class="help-block">:message</p>') !!}
                                </div>
                              </div>
                            </div>
                          </div>



                          <div class="form-group">
                              <label>Status *:</label>
                              <div class="bg-<?php echo $status_bg; ?> " style="border-radius: 5px; border: 1px solid black; padding: 10px;">
                                <p >
                                    Live:
                                    <input type="radio" class="flat" name="status" id="statusLive" value="Live" <?php echo ($client->status == 'Live') ? "checked" : ""; ?> />
                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                    Prospective:
                                    <input type="radio" class="flat" name="status" id="statusProspect" value="Prospective" <?php echo ($client->status == 'Prospective') ? "checked" : ""; ?> />
                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                    Inactive
                                    <input type="radio" class="flat" name="status" id="statusInactive" value="Inactive" <?php echo ($client->status == 'Inactive') ? "checked" : ""; ?> />
                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                    Cancelled
                                    <input type="radio" class="flat" name="status" id="statusCancelled" value="Cancelled" <?php echo ($client->status == 'Cancelled') ? "checked" : ""; ?> />
                                </p>
                                <p>

                                </p>
                                <p>

                                </p>
                              </div>
                          </div>
                      </div>
                      @if($current_pending_stage !== 'COMPLETED')
                      <div class="col-md-12">
                        <div class="form-group" >
                            <!-- style="background-color: skyblue;"-->
                            <div class=" {{ $errors->has('onboarding_sub_items') ? 'has-error' : ''}}">
                              <label class="" for="payment_mode">Onboarding Stage ({{ $current_pending_stage }}) | Click below to select </label>
                              {!! Form::select('onboarding_sub_items_progress[]', $onboarding_sub_items, $onboarding_sub_items_progress, ['class' => 'form-control' , 'id' => 'progressIndicators', 'multiple' => 'true']) !!}
                              {!! $errors->first('onboarding_sub_items', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                      </div>
                      @endif
                  </div>
                  <div class="ln_solid"></div>
                  <div class="form-group">
                    <div class="col-md-12">
                      <button type="submit" class="btn btn-success btn-block"><i class="fa fa-save"></i> Update</button>
                    </div>
                  </div>
              {!! Form::close() !!}
          </div>
          {{-- end of x_content --}}
      </div>
      {{-- end of x_panel --}}
    </div>
  </div>
</div>

@endsection

@section('javascript')
<script type="text/javascript">
  $(function(){
    $('select').select2();
    // var PRESELECTED_FRUITS = ['A2P','USSD'];

    // $('.typeServices').select2({}).select2('val', PRESELECTED_FRUITS);

    $('.senderIds').select2({
          tags : true
    });
    $('.supportEmail').select2({
          tags : true
    });
    $('.supportPhones').select2({
          tags : true
    });
    $('.supportSkype').select2({
          tags : true
    });
    $('.rateEmail').select2({
          tags : true
    });
    $('.financeEmail').select2({
          tags : true
    });
    $('#contractValidity').datetimepicker({
        format: 'YYYY-MM-DD'
    });    
    //
    //
  });
</script>
@endsection
