<?php $page_title = __('Coaches'); $Crumbs->setRoot($page_title); // Get number of coach requests for current user. $client_requests_table = new Tables\ClientRequests(); $coach_requests_count = $client_requests_table->by('client_id', getUser()->id)->count(); $Template->output('header', ['title' => $page_title, 'nav_active' => 'coaches', 'page_controls' => [['text' => __('Requests') . ' (' . $coach_requests_count . ')', 'url' => 'coaches/requests']]]); $Template->output('validator/status'); $Cache->cacheOutput(function ($data) { extract($data); $table = new Tables\Clients(); $coaches = $table->getCoaches(); if ($coaches) { ?> <table class="overview"> <thead> <tr> <th><?php echo __('Name'); ?> </th> <th><?php echo __('Since'); ?> </th> <th><?php echo __('Messages'); ?> </th> </tr>
<?php $page_title = __('Clients'); $Crumbs->setRoot($page_title); $Template->output('header', ['title' => $page_title, 'nav_active' => 'clients']); $Template->output('page_controls', [['text' => __('New'), 'url' => 'clients/new']]); $Template->output('validator/status'); $Cache->cacheOutput(function ($data) { extract($data); $table = new Tables\Clients(); $clients = $table->getClients(); ?> <table class="overview"> <thead> <tr> <th><?php echo __('Name'); ?> </th> <th><?php echo __('Since'); ?> </th> </tr> </thead> <tbody> <?php foreach ($clients as $client) { ?> <tr class="odf_href" data-href="clients/edit?id=<?php echo $client->id;
<?php $client_id = !empty($_GET['id']) ? (int) $_GET['id'] : null; $page_title = __(sprintf('%s scheme part', $client_id ? 'Edit' : 'New')); $Crumbs->addCrumb($page_title); $page_controls = [['text' => __('Back'), 'url' => $Crumbs->getPreviousPageUrl()]]; // Handle edit instead of new: if ($client_id) { $table = new Tables\Clients(); $client = $table->get($client_id); if (!$client) { return $Template->output('error', 404); } elseif ($client->user_id != getUser()->id) { return $Template->output('error', 403); } $page_controls[] = ['text' => __('Delete'), 'url' => 'action/clients/delete?id=' . $client_id, 'confirm_message' => true]; $client_foods = $client->getFoods(); } $Template->output('header', ['title' => $page_title, 'nav_active' => 'clients']); $Template->output('page_controls', $page_controls); $Template->output('validator/status'); ?> <script src="js/page_specific/clients/client.js"></script> <form action="ajaxa/clients/save" method="post" class="odf_ajax"> <?php if ($client_id) { ?> <input type="hidden" name="id" value="<?php echo $client_id;