
<?php 
$system_name = App\Setting::where('name', 'System name')->first()->value;
?>

<header class="app-header navbar">
    <button class="navbar-toggler sidebar-toggler d-lg-none mr-auto" type="button" data-toggle="sidebar-show">
        <span class="navbar-toggler-icon"></span>
    </button>
    <a class="navbar-brand" href="<?php echo e(url('/')); ?>">
        <span class="navbar-brand-full logo-text"><?php echo e($system_name); ?></span>
        <span class="navbar-brand-minimized logo-text"><?php echo e($system_name); ?></span>
        
    </a>
    <button class="navbar-toggler sidebar-toggler d-md-down-none" type="button" data-toggle="sidebar-lg-show">
        <span class="navbar-toggler-icon"></span>
    </button>
    <?php 
        $school = Auth::user();
        $authSetting = App\AuthSetting::first();
        if($authSetting == null || $authSetting->secure_key == null
        || $authSetting->u1 == null
        || $authSetting->u2 == null
        || $authSetting->u3 == null)
        {?>
            <div class="alert alert-danger ml-auto" role="alert">
                Please <strong><a href="/activation">activate</a></strong> your copy.
            </div>
        <?php
        }
        else
        {
            $google_maps_setting = App\Setting::where('name','Google maps API key')->first()->value;
            if ((!$school->is_super_admin_account))
            {
                if((!$school->address || !$school->latitude || !$school->longitude))
                    {?>
                        <div class="alert alert-danger ml-auto" role="alert">
                            Por favor actualice la direción del colegio
                        </div>
                <?php
                    }
            }
            else
            {
                if($google_maps_setting==null)
                { ?>
                <div class="alert alert-danger ml-auto" role="alert">
                    Please update your settings
                </div>
            <?php }
            }
        }
        ?>
        


    <ul class="nav navbar-nav ml-auto mr-3">
        <li class="nav-item dropdown">
            <a class="nav-link" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
                <img class="img-avatar" src="<?php echo e(Auth::user()->avatar_url); ?>">
            </a>
            <div class="dropdown-menu dropdown-menu-right shadow mt-2">
                <a class="dropdown-item">
                    <?php echo e(Auth::user()->name); ?><br>
                    <small class="text-muted"><?php echo e(Auth::user()->email); ?></small>
                </a>
                <a class="dropdown-item" href="/profile">
                    <i class="fas fa-user"></i> Perfil
                </a>
                <?php $school = Auth::user();
                if (!$school->is_super_admin_account) { ?>
                        <?php 
                        if($school->plan->is_pay_as_you_go != 1 && $school->plan->allowed_children > 0)
                        {
                            $current_children = 0;
                            for ($x = 0; $x < $school->parents->count(); $x++) {
                                for ($y = 0; $y < $school->parents[$x]->children->count(); $y++) {
                                    $current_children++;
                                }
                            }    
                            ?>
                            <a class="dropdown-item" href="/plan">
                                <div class="mb-2">
                                    <i class="fas fa-trophy"></i> Plan <span class="badge badge-primary"><?php echo e(Auth::user()->plan->name); ?></span>
                                </div>
                                <?php if($current_children < $school->plan->allowed_children) { ?>
                                    <i class="fas fa-chair"></i> Puestos <span class="badge badge-primary">
                                        <?php echo e($current_children); ?> / <?php echo e($school->plan->allowed_children); ?></span>
                                <?php } else { ?>
                                    <i class="fas fa-chair"></i> Puestos <span class="badge badge-danger">
                                        <?php echo e($current_children); ?> / <?php echo e($school->plan->allowed_children); ?></span>
                                <?php }  ?>
                            </a>
                        <?php }
                        else
                        { ?>
                            <a class="dropdown-item" href="/plan">
                                <i class="fas fa-trophy"></i> Plan <span class="badge badge-primary"><?php echo e(Auth::user()->plan->name); ?></span>
                            </a>
                        <?php } ?>
                    <?php } ?>
                <div class="divider"></div>
                <a class="dropdown-item" href="/password">
                    <i class="fas fa-key"></i> Contraseña
                </a>
                <div class="divider"></div>
                <a class="dropdown-item" href="<?php echo e(route('logout')); ?>" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
                    <i class="fas fa-sign-out-alt"></i> <?php echo e(__('Logout')); ?>

                </a>
                <form id="logout-form" action="<?php echo e(route('logout')); ?>" method="POST" style="display: none;">
                    <?php echo csrf_field(); ?>
                </form>
            </div>
        </li>
    </ul>
</header>
<?php /**PATH /home/dev/Documents/Projects/sburkbackend/resources/views/layouts/header.blade.php ENDPATH**/ ?>