@extends('layouts.master')
@section('page_title')
    @if(isset($page_title))
        {{ $page_title }}
    @endif
@endsection

@section('content')
@include('network_ops.partials.newip')
@include('network_ops.partials.new_notes')
@include('network_ops.partials.finance')
@include('network_ops.partials.edit-finance')
<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('mnos') !!}">Network Operator</a></li>
        <li class="active">Update Network Operator</li>
      </ol>

    </div>
  </div>
  <div class="clearfix"></div>
    <div>@include('commons.notifications')</div>
    <div class="row">
      <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">
            <div class="x_title">
              <div class="clearfix"></div>
            </div>
            {{-- start of content --}}
            <div class="x_content">
              <br>
                {!! Form::model($network_arr, ['method' => 'PATCH', 'url' => ['mnos', $network_arr], 'class' => 'form-horizontal form-label-left', 'files' => 'true' ]) !!}
                <div class="row">
                  <div class="col-md-6">
                    <div class="row">
                      <div class="col-md-6">
                        <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 col-md-7 col-xs-12', 'placeholder'=>'Enter name' , 'id' => 'name']) !!}
                            {!! $errors->first('name', '<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 col-md-7 col-xs-12', 'placeholder'=>'Enter Country' , 'id' => 'country']) !!}
                            {!! $errors->first('country', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>

                        <div class="form-group">
                          <div class="{{ $errors->has('account_manager_id') ? 'has-error' : ''}}">
                            <label class="" for="account_manager_id">Click Account Manager</label>
                            {!! Form::select('account_manager_id', $account_manager ,old('account_manager_id'), ['class' => 'form-control col-md-7 col-xs-12', 'placeholder'=>'Enter Account Manager' , 'id' => 'account_manager_id']) !!}
                            {!! $errors->first('account_manager_id', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                        <div class="form-group">
                          <div class="{{ $errors->has('mno_account_manager') ? 'has-error' : ''}}">
                            <label class="" for="MnoAccountManager">MNO Account Manager</label>
                            {!! Form::text('mno_account_manager',old('mno_account_manager'), ['class' => 'form-control col-md-7 col-xs-12', 'placeholder'=>'Enter MNO Account Manager' , 'id' => 'MnoAccountManager']) !!}
                            {!! $errors->first('mno_account_manager', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                        <div class="form-group">
                        <div class=" {{ $errors->has('contact_person') ? 'has-error' : ''}}">
                          <label class="" for="contact_person">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('contact_person_phone') ? 'has-error' : ''}}">
                            <label class="" for="contactPersonPhone">Phone</label>
                            {!! Form::text('contact_person_phone', old('contact_person_phone'), ['class' => 'form-control', 'placeholder'=>'Enter Phone Number' , 'id' => 'contactPersonPhone']) !!}
                            {!! $errors->first('contact_person_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('contact_person_email', old('contact_person_email'), ['class' => 'form-control ', 'placeholder'=>'Enter email' , 'id' => 'email']) !!}
                            {!! $errors->first('contact_person_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('contact_person_skype', old('contact_person_skype'), ['class' => 'form-control', 'placeholder'=>'Enter Skype Name' , 'id' => 'skypeName']) !!}
                            {!! $errors->first('contact_person_skype', '<p class="help-block">:message</p>') !!}
                          </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="connection_status" id="statusLive" value="Active" <?php echo ($network_arr->connection_status == 'Active') ? "checked" : ""; ?> />
                                </p>
                                <p>
                                  Pending:
                                  <input type="radio" class="flat" name="connection_status" id="statusProspect" value="Pending" <?php echo ($network_arr->connection_status == 'Pending') ? "checked" : ""; ?> />
                                </p>
                                <p>
                                  Inactive
                                  <input type="radio" class="flat" name="connection_status" id="statusInactive" value="Inactive" <?php echo ($network_arr->connection_status == 'Inactive') ? "checked" : ""; ?> />
                                </p>
                              </div>
                          </div>
                      </div>
                      <div class="col-md-6">
                        <div class="form-group">
                          <div class=" {{ $errors->has('contact_person_finance') ? 'has-error' : ''}}">
                            <label class="" for="technicalPerson">Technical Support Person</label>
                            {!! Form::text('technical_support_person', old('technical_support_person'), ['class' => 'form-control', 'placeholder'=>'Enter Technical Support Person' , 'id' => 'technicalPerson']) !!}
                            {!! $errors->first('technical_support_person', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                        <div class="form-group">
                          <div class=" {{ $errors->has('contact_person_finance') ? 'has-error' : ''}}">
                            <label class="" for="contactPersonFinance">Finance Contact Person</label>
                            {!! Form::text('contact_person_finance', old('contact_person_finance'), ['class' => 'form-control', 'placeholder'=>'Enter Finance Contact Person' , 'id' => 'contactPersonFinance']) !!}
                            {!! $errors->first('contact_person', '<p class="help-block">:message</p>') !!}
                          </div>
                        </div>
                        <div class="form-group">
                            <div class=" {{ $errors->has('services') ? 'has-error' : ''}}">
                              <label class="" for="type">Services</label>
                              {!! Form::select('services[]', $services, $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('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('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('finance_emails') ? 'has-error' : ''}}">
                            <label class="" for="financeEmail">Finance Emails (Multiple) </label>
                            {!! Form::select('finance_emails[]', $finance_emails, $old_finance_emails, ['class' => 'form-control financeEmail', 'id' => 'financeEmail', 'multiple' => 'true']) !!}
                            {!! $errors->first('finance_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">
                          <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>
                    </div>
                    <div class="row">
                      <div class="col-md-12">
                        <h4>Recent Payments</h4>
                        @include('network_ops.partials.recent-payments')
                      </div>
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="form-group">
                      <div class=" {{ $errors->has('connection_type') ? 'has-error' : ''}}">
                        <label class="" for="connectionType">Connection Types</label>
                        {!! Form::select('connection_type[]', $connection_types, $old_connection_type, ['class' => 'form-control' , 'id' => 'connectionType', 'multiple'=> 'true']) !!}
                        {!! $errors->first('connection_type', '<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', '', ['class' => 'form-control' , 'id' => 'documentOneName']) !!}
                            {!! $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">File </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>
                    <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', '', ['class' => 'form-control' , 'id' => 'documentTwoName']) !!}
                            {!! $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">File</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>



                    <div class="">
                      <p><b>IP Addresses</b> <a href="" class="btn btn-primary btn-xs pull-right" id="addIpBtn" ><i class="fa fa-plus-square"></i> Add IP</a></p>
                      <table class="table table-striped table-bordered table-condensed">
                        <thead>
                          <tr>
                            <th scope="col active">Service</th>
                            <th scope="col success">IP</th>
                            <th scope="col warning">Port</th>
                            <th scope="col info">Status</th>
                          </tr>
                        </thead>
                        @foreach($ip_addresses as $row)
                        <tr>
                          <td class="">{{ $row->service }}</td>
                          <td class="">{{ $row->ip_address }}</td>
                          <td class="">{{ $row->port }}</td>
                          <td class="">{{ $row->status }}</td>
                        </tr>
                        @endforeach
                      </table>
                    </div>
                    <hr>
                    <div class="">
                      <p><b> Notes</b> <a class="btn btn-warning btn-xs pull-right" id="createNotesBtn"><i class="fa fa-plus-circle"></i> Add Notes</a></p>
                      <table class="table table-striped table-bordered table-condensed">
                        <thead>
                          <tr>
                            <th scope="col active">Services</th>
                            <th scope="col success">Notes</th>
                            <th scope="col info">Date Added</th>
                          </tr>
                        </thead>
                        @foreach($notes_arr as $row)
                        <tr>
                          <td class="">{{ $row->services }}</td>
                          <td class="">{{ $row->notes_body }}</td>
                          <td class="">{{ $row->created_at }}</td>
                        </tr>
                        @endforeach
                      </table>
                    </div>
                    <div class="">
                      <div class="row">
                        <div class="col-md-6">
                          <div class="form-group">
                            <div class=" {{ $errors->has('rate_type') ? 'has-error' : ''}}">
                              <label class="" for="rateTypeSel">Rate Types</label>
                              {!! Form::select('rate_type', $rate_types, old('rate_type'), ['class' => 'form-control' , 'id' => 'rateTypeSel']) !!}
                              {!! $errors->first('rate_type', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                        </div>

                        <div class="col-md-6">
                          <div class="form-group">
                            <div class="{{ $errors->has('buying_rate_flat') ? 'has-error' : ''}}" id="flatRateFileDiv">
                              <label class="" for="buyingRateFlat">Buying Rate</label>
                                {!! Form::text('buying_rate', old('buying_rate'), ['class' => 'form-control' , 'id' => 'buyingRateFlat']) !!}
                                {!! $errors->first('buying_rate', '<p class="help-block">:message</p>') !!}
                            </div>
                            <div class="hidden {{ $errors->has('sliding_rate_file') ? 'has-error' : ''}}" id="slidingRateFileDiv">
                              <label class="" for="slidingRateFile">Sliding Rate File</label>
                                {!! Form::file('sliding_rate_file', null, ['class' => 'form-control' , 'id' => 'slidingRateFile', 'placeholder' => 'Select file to upload']) !!}
                                {!! $errors->first('buying_rate_flat', '<p class="help-block">:message</p>') !!}
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="ln_solid"></div>
                <div class="form-group">
                  <div class="col-md-12 col-sm-12">
                    <button type="submit" class="btn btn-success btn-block"><i class="fa fa-save"></i> Update Operator</button>
                  </div>
                </div>
                {!! Form::close() !!}
            </div>
        </div>
      </div>
    </div>
</div>

@endsection

@section('javascript')
<script type="text/javascript" src="{{ url('public/assets/js/mnos.js') }}"></script>
<script type="text/javascript">
  $(function(){
    $('select').select2();
    $('.supportEmail').select2({
          tags : true
    });
    $('.supportPhones').select2({
          tags : true
    });
    $('.supportSkype').select2({
          tags : true
    });
    $('.financeEmail').select2({
      tags:true
    });
    $('#contractValidity').datetimepicker({
        format: 'YYYY-MM-DD'
    });

  });
</script>
@endsection
