@extends('Dashboard.master_page')


@section('content')
    

            <!-- Hero -->
            <div class="content ">
                @if(session()->has('success_transfer'))
                    <div class="text-success alert-success" style="font-size:14px;padding:10px;">
                    {{ session()->get('success_transfer') }}
                    </div>
                @endif
                
                 @if(session()->has('transfer_session_response'))
                    <div class="text-success alert-success" style="font-size:14px;padding:10px;">
                    {{ session()->get('transfer_session_response') }}
                    </div>
                @endif
   
                
                <div
                    class="d-flex flex-column flex-md-row justify-content-md-between align-items-md-center py-2 text-center text-md-start">
                    <div class="flex-grow-1 mb-1 mb-md-0">
                        <h1 class="h3 fw-bold mb-2">
                            Dashboard
                        </h1>
                        <h2 class="h6 fw-medium fw-medium text-muted mb-0">
                            Welcome back,<a class="fw-semibold"> {{ Auth::user()->name }}  {{ Auth::user()->lastname }} </a>   👋
                        </h2>
                    </div>

                    <div class="mt-3 mt-md-0 ms-md-3 space-x-1">
                        <a class="btn btn-sm btn-alt-secondary space-x-1" >
                            <i class="fa-solid fa-money-bill"></i>
                            <span>Available Balance: {{ $available }}</span>
                        </a>
                        
                    </div>

                    

                    <div class="mt-3 mt-md-0 ms-md-3 space-x-1">
                        <a class="btn btn-sm btn-alt-secondary space-x-1" >
                            <i class="fa-solid fa-headset"></i>
                            <span>Support PIN: {{ Auth::user()->support_pin }}</span>
                        </a>
                        
                    </div>
                
                </div>
            </div>
            <!-- END Hero -->
            

            <!-- Page Content -->
            <div class="content">
                <!-- Overview -->
                
                
                
                <div class="row items-push">
                    <div class="col-sm-6 col-xxl-3">
                        <!-- Pending Orders -->
                        <div class="block block-rounded d-flex flex-column h-100 mb-0">
                            <div
                                class="block-content block-content-full flex-grow-1 d-flex justify-content-between align-items-center">
                                <dl class="mb-0">
                                    <dt class="fs-3 fw-bold">{{ $active_service }}</dt>
                                    <dd class="fs-sm fw-medium fs-sm fw-medium text-muted mb-0">Active Services</dd>
                                </dl>
                                <div class="item item-rounded-lg bg-body-light">
                                    <i class="far fa-gem fs-3 text-primary"></i>
                                </div>
                            </div>

                          
                           
                        </div>
                        <!-- END Pending Orders -->
                    </div>
                    <div class="col-sm-6 col-xxl-3">
                        <!-- New Customers -->
                        <div class="block block-rounded d-flex flex-column h-100 mb-0">
                            <div
                                class="block-content block-content-full flex-grow-1 d-flex justify-content-between align-items-center">
                                <dl class="mb-0">
                                    <dt class="fs-3 fw-bold">{{ $active_domain }}</dt>
                                    <dd class="fs-sm fw-medium fs-sm fw-medium text-muted mb-0">Active Domains</dd>
                                </dl>
                                <div class="item item-rounded-lg bg-body-light">
                                    <i class="far fa-solid fa-ethernet fs-3 text-primary"></i>
                                </div>
                            </div>
                           
                        </div>
                        <!-- END New Customers -->
                    </div>
                    <div class="col-sm-6 col-xxl-3">
                        <!-- Messages -->
                        <div class="block block-rounded d-flex flex-column h-100 mb-0">
                            <div
                                class="block-content block-content-full flex-grow-1 d-flex justify-content-between align-items-center">
                                <dl class="mb-0">
                                    <dt class="fw-bold" style="font-size: 1rem!important">{{ $paid }}</dt>
                                    <dd class="fs-sm fw-medium fs-sm fw-medium text-muted mb-0">Paid Invoices</dd>
                                </dl>
                                <div class="item item-rounded-lg bg-body-light">
                                    <i class="fa fa-solid fa-receipt fs-3 text-primary"></i>
                                </div>
                            </div>
                          
                        </div>
                        <!-- END Messages -->
                    </div>
                    <div class="col-sm-6 col-xxl-3">
                        <!-- Conversion Rate -->
                        <div class="block block-rounded d-flex flex-column h-100 mb-0">
                            <div
                                class="block-content block-content-full flex-grow-1 d-flex justify-content-between align-items-center">
                                <dl class="mb-0">
                                    <dt class="fw-bold" style="font-size: 1rem!important">{{ $unpaid }}</dt>
                                    <dd class="fs-sm fw-medium fs-sm fw-medium text-muted mb-0">Unpaid Invoices</dd>
                                </dl>
                                <div class="item item-rounded-lg bg-body-light">
                                    <i class="far fa-solid fa-file-invoice fs-3 text-primary"></i>
                                    </div>
                            </div>
                         
                        </div>
                        <!-- END Conversion Rate-->
                    </div>

                </div>
                <!-- END Overview -->
                
                
                @if(count($announces) > 0)
           
            <div class="col-md-12">
              <!-- Slider with Avatars -->
              
              <div class="block block-rounded">
                <div class="block-header block-header-default">
                  <h3 class="block-title">Announcements</h3>
                </div>
                <div class="block-content">
                  <div class="js-slider text-center" data-dots="true" data-arrows="true" data-autoplay="true">

                    @forelse($announces as $an)
                    <div class="py-3">
                      <div class="mt-2 fw-semibold">{{ $an->title }}</div>
                      <div class="fs-sm text-muted">{{ $an->message }}</div>
                    </div>
                      @empty
                        @endforelse
                    
                  </div>
                </div>
              </div>
             
              
            </div>
            @endif


                <div class="row">


                    <div class="col-xl-7">
                        <!-- Default Table -->
                        <div class="block block-rounded">
                          <div class="block-header block-header-default">
                            <h3 class="block-title">Account Login History</h3>
                          </div>
                          <div class="block-content">
                            <table class="table table-vcenter">
                              <thead>
                                <tr>
                                  <th class="text-center" style="width: 50px;">#</th>
                                  <th>Date & Time</th>
                                  <th class="d-sm-table-cell" style="width: 15%;">IP</th>
                                  <th class="text-center" style="width: 100px;">Result</th>
                                </tr>
                              </thead>
                              <tbody>
                                @foreach($histories as $key => $history)
                                <tr>
                                    <td >
                                        {{ ++$key }}
                                        </td>
                                    <td >{{ $history->date }}</td>
                                    <td ><a href="https://www.whois.af/?domain={{ $history->ip_address }}" target="_blank">{{ $history->ip_address }}</a></td>
                                    <td >{{ $history->result }}</td>
                                </tr>
                                    @endforeach

                                </tbody>
                            </table>
                          </div>
                        </div>
                        <!-- END Default Table -->
                      </div>


                      
                    <div class="col-xl-5">
                        <!-- Default Table -->
                        <div class="block block-rounded">
                          <div class="block-header block-header-default">
                            <h3 class="block-title">Recent Activities</h3>
                           
                          </div>
                          <div class="block-content">
                           

                            <table class="table table-vcenter">
                                @if($last_dates != null &&  $last_dates->change_password_date != '2020-02-03')
                               <tr>
                                   <td>
                                        <i class="fas fa-lock" style="font-size:17px;"></i>
                                   </td>
                                   <td style="font-size:10px;font-weight: bold">
                                      Password Changed -> Profile
                                   </td>
                                   <td style="font-size:10px;font-weight: bold">
                                       {{ $last_dates->change_password_date }}
                                   </td>
                               </tr>
                               @endif

                               @if($last_dates != null && $last_dates->forgot_password_date != '2020-02-03')
                               <tr>
                                   <td>
                                        <i class="fas fa-lock" style="font-size:17px;"></i>
                                   </td>
                                   <td style="font-size:10px;font-weight: bold">
                                      Forgot Password -> Email
                                   </td>
                                   <td style="font-size:10px;font-weight: bold">
                                       {{ $last_dates->forgot_password_date }}
                                   </td>
                               </tr>
                               @endif

                               @if(auth()->user()->google_date != '0')
                               <tr>
                                   <td>
                                        <i class="fa-solid fa-shield" style="font-size:17px;"></i>
                                   </td>
                                   <td style="font-size:10px;font-weight: bold">
                                      Two Factor - > Added / Updated 
                                   </td>
                                   <td style="font-size:10px;font-weight: bold">
                                       {{ auth()->user()->google_date }}
                                   </td>
                               </tr>
                               @endif

                               @if($last_dates != '' and  $last_dates->profile_update_date != '2020-02-03')
                               <tr>
                                   <td>
                                         <i class="fas fa-user-circle" style="font-size:17px;"></i>
                                   </td>
                                   <td style="font-size:10px;font-weight: bold">
                                      Profile Updated
                                   </td>
                                   <td style="font-size:10px;font-weight: bold">
                                       {{ $last_dates->profile_update_date }}
                                   </td>
                               </tr>
                               @endif


                               <tr>
                                   <td>
                                         <i class="fas fa-sign-in-alt" style="font-size:17px;"></i>
                                   </td>
                                   <td style="font-size:10px;font-weight: bold">
                                     Logged In
                                   </td>
                                   <td style="font-size:10px;font-weight: bold">
                                       {{ Carbon\Carbon::parse($last_login->date)->format('Y-m-d') }}
                                   </td>
                               </tr>
                               


                           </table>
                          </div>
                        </div>
                        <!-- END Default Table -->
                        
                                                <div class="block block-rounded">
                          <div class="block-header block-header-default">
                            <h3 class="block-title">AICT NOC Status</h3>
                           <a href="https://www.aryanict.com/noc-live-status.py?ref=myLEAP" target="_blank">
                          </div>
                          <div class="block-content">

                        <ul class="list-group push">
                            
                        @forelse(App\Models\StatusCategory::limit(5)->get() as $s_c)
                        <li class="list-group-item d-flex justify-content-between align-items-center fw-medium">
                            {{ $s_c->name }}
                            @if($s_c->status == 1)
                            <span class="fs-sm fw-semibold d-inline-block py-1 px-3 rounded-pill bg-success-light text-success">Operational</span>
                            @elseif($s_c->status == 2)
                            <span class="fs-sm fw-semibold d-inline-block py-1 px-3 rounded-pill bg-danger-light text-danger">Under maintenance</span>
                            @elseif($s_c->status == 3)
                            <span class="fs-sm fw-semibold d-inline-block py-1 px-3 rounded-pill bg-danger-light text-danger">Degraded performance</span>
                             @elseif($s_c->status == 4)
                            <span class="fs-sm fw-semibold d-inline-block py-1 px-3 rounded-pill bg-danger-light text-danger">Partial outage</span>
                            @else
                            <span class="fs-sm fw-semibold d-inline-block py-1 px-3 rounded-pill bg-danger-light text-danger">Major outage</span>
                            @endif
                        </li>
                        @empty
                        @endforelse
                        
                        
                     
                     
                    
                      

                    </ul>
                     </a>
                      </div>
                      
            
           
                      
                      




                    
                </div>
            </div>
            
            <!-- END Page Content -->
        
@endsection