Exemple #1
0
<?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>
Exemple #2
0
<?php

$form = new Odf\Form('clients/new');
$form->validate();
if ($errors = $form->getErrors()) {
    return $Javascript->setErrors($errors)->output();
}
$form_input = $form->getInput();
// Check if client email hasn't been invited yet.
$client_requests_table = new Tables\ClientRequests();
$existing_request = $client_requests_table->by('email', $form_input['email'])->getFirst();
if ($existing_request) {
    if ($existing_request->coach_id == getUser()->id) {
        return $Javascript->setError(__('You have already invited this person before, on') . ' ' . strftime('%d %B %Y.', strtotime($existing_request->created)))->output();
    }
}
// Is this coach inviting an existing or a new user?
$users_table = new Tables\Users();
$existing_user = $users_table->by('email', $form_input['email'])->getFirst();
// Send client invitation email.
$mail_contents = $Template->get('emails/invite_new_client', $form_input);
$mail_headers = ['From: ' . get('main_email'), 'Reply-to: noreply@fit.com'];
// if (!mail($form_input['email'], getUser()->first_name . ' ' . __('would like to coach you on Fit'), $mail_contents, implode("\n", $mail_headers)))
// 	return $Template->output('validator/errors', __('Email could not be sent.'));
// Save client invitation.
$data = ['coach_id' => getUser()->id, 'email' => $form_input['email'], 'hash' => $Login->randomHash(24), 'message' => $form_input['message']];
if ($existing_user) {
    $data['client_id'] = $existing_user->id;
}
$client_requests_table->create($data);
$Javascript->setSuccessMessage(__('Invitation successfully sent.'))->output();
Exemple #3
0
<?php

$request_id = !empty($_GET['id']) ? (int) $_GET['id'] : null;
if (!$request_id) {
    return $Template->output('error');
}
// Get request with given ID.
$client_request_table = new Tables\ClientRequests();
$client_request = $client_request_table->by('id', $request_id)->by('client_id', getuser()->id)->getFirst();
if (!$client_request) {
    return $Template->output('error', 403);
}
// Forbidden, as the client request with the given ID apparently isn't meant for the current user.
$coach = $client_request->getCoach();
$page_title = __('Coach request by') . ' ' . $coach->getName();
$Crumbs->addCrumb($page_title);
$Template->output('header', ['title' => $page_title, 'nav_active' => 'schemes', 'page_controls' => [['text' => __('Back'), 'url' => $Crumbs->getPreviousPageUrl()]]]);
$Template->output('validator/status');
?>

<form action="action/coaches/handle_request" method="post">
	<table class="key_value">
		<tbody>
			<tr>
				<th><?php 
echo __('Coach');
?>
</th>
				<td><?php 
echo $coach->getName();
?>
Exemple #4
0
$page_title = __('Coach requests');
$Crumbs->addCrumb($page_title);
$Template->output('header', ['title' => $page_title, 'nav_active' => 'coaches', 'page_controls' => [['text' => __('Back'), 'url' => $Crumbs->getPreviousPageUrl()]]]);
$Template->output('validator/status');
?>

<p><?php 
echo __('People who would like to coach you.');
?>
</p>

<?php 
$Cache->cacheOutput(function ($data) {
    extract($data);
    $table = new Tables\ClientRequests();
    $requests = $table->getCoachRequests();
    if ($requests) {
        ?>
		<table class="overview">
			<thead>
				<tr>
					<th><?php 
        echo __('Name');
        ?>
</th>
					<th><?php 
        echo __('Since');
        ?>
</th>
				</tr>