.
This commit is contained in:
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
39
app/Http/Controllers/Auth/LoginController.php
Normal file
39
app/Http/Controllers/Auth/LoginController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
}
|
||||
17
app/Http/Controllers/Auth/RegisterController.php
Normal file
17
app/Http/Controllers/Auth/RegisterController.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
Redirect::to('/')->send();
|
||||
// $this->middleware('guest');
|
||||
}
|
||||
|
||||
}
|
||||
39
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
39
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
34
app/Http/Controllers/Configuration/CompanyController.php
Normal file
34
app/Http/Controllers/Configuration/CompanyController.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Configuration;
|
||||
|
||||
use App\Company;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CompanyController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$companies = Company::all();
|
||||
return view('configuration.companies', compact('companies'));
|
||||
}
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
if ($id) {
|
||||
$company = Company::find($id);
|
||||
} else {
|
||||
$company = Company::getModel();
|
||||
}
|
||||
if ($request->post()) {
|
||||
$company->name = $request->get('name');
|
||||
$company->monthly_payer = $request->get('monthly_payer');
|
||||
$company->save();
|
||||
return redirect()->route('company')->with('success', 'Uloženo');
|
||||
}
|
||||
|
||||
return view('configuration.company.edit', compact('company'));
|
||||
|
||||
}
|
||||
}
|
||||
38
app/Http/Controllers/Configuration/TermController.php
Normal file
38
app/Http/Controllers/Configuration/TermController.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Configuration;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Term;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TermController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$terms = Term::orderBy('id', 'desc')->get();
|
||||
return view('configuration.terms', compact('terms'));
|
||||
}
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
if ($id) {
|
||||
$term = Term::find($id);
|
||||
} else {
|
||||
$term = Term::getModel();
|
||||
}
|
||||
if ($request->post()) {
|
||||
$term->day = (int)$request->get('day');
|
||||
$term->month = $request->get('month');
|
||||
$term->inter = (int)$request->get('inter');
|
||||
$term->applies_to = (int)$request->get('applies_to');
|
||||
$term->name = (string)$request->get('name');
|
||||
$term->desc = (string)$request->get('desc');
|
||||
$term->save();
|
||||
return redirect()->route('terms')->with('success', 'Uloženo');
|
||||
}
|
||||
|
||||
return view('configuration.term.edit', compact('term'));
|
||||
|
||||
}
|
||||
}
|
||||
34
app/Http/Controllers/Controller.php
Normal file
34
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Route;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
|
||||
public $menu = [];
|
||||
public function __construct()
|
||||
{
|
||||
$this->menu = [
|
||||
'company' => ['link' => url('configuration'), 'name' => __('Firmy'), 'active' => false],
|
||||
'term' => ['link' => url('configuration/terms'), 'name' => __('Termíny'), 'active' => false],
|
||||
];
|
||||
|
||||
$controller = class_basename(Route::currentRouteAction());
|
||||
|
||||
list($controller) = explode('@', $controller);
|
||||
$controller = strtolower(str_replace('Controller', '', $controller));
|
||||
if (isset($this->menu[$controller])) {
|
||||
$this->menu[$controller]['active'] = true;
|
||||
}
|
||||
|
||||
\View::share('menu', $this->menu);
|
||||
}
|
||||
|
||||
}
|
||||
112
app/Http/Controllers/DashboardController.php
Normal file
112
app/Http/Controllers/DashboardController.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Company;
|
||||
use App\Confirm;
|
||||
use App\Term;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$terms = Term::all();
|
||||
$companies = Company::all();
|
||||
$q = [];
|
||||
$m = [];
|
||||
$comp = [];
|
||||
foreach ($companies as $company) {
|
||||
if ($company->monthly_payer) {
|
||||
$m[] = $company;
|
||||
} else {
|
||||
$q[] = $company;
|
||||
}
|
||||
$comp[] = $company->getAttributes() + ['checked' => false];
|
||||
}
|
||||
$confirms = Confirm::orderBy('term_date')->get();
|
||||
$list = [];
|
||||
$date = date('Y-01-01');
|
||||
while (true) {
|
||||
$c = [];
|
||||
foreach ($confirms as $confirm) {
|
||||
if ($confirm->term_date == $date) {
|
||||
$c[$confirm->company_id.'_'.$confirm->term_id] = $confirm;
|
||||
}
|
||||
}
|
||||
foreach ($terms as $term) {
|
||||
if ($term->applies_to) {
|
||||
if (($term->applies_to == 1 && ! count($m)) || ($term->applies_to == 2 && ! count($q))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
[$year, $month, $day] = explode('-', $date);
|
||||
if ($day == $term->day && $term->month == null && $term->inter == 0) {
|
||||
foreach ($comp as $item=>$value) {
|
||||
if (isset($c[$comp[$item]['id'] . '_' . $term->id])) {
|
||||
$comp[$item]['checked'] = true;
|
||||
} else {
|
||||
$comp[$item]['checked'] = false;
|
||||
}
|
||||
}
|
||||
$list[] =
|
||||
(object) ['id' => $term->id, 'div' => $year.(int)$month, 'date' => $date, 'name' => $term->name, 'desc' => $term->desc, 'companies' => $comp];
|
||||
} elseif ($day == $term->day && $term->month == $month && $term->inter == 2) {
|
||||
foreach ($comp as $item=>$value) {
|
||||
if (isset($c[$comp[$item]['id'] . '_' . $term->id])) {
|
||||
$comp[$item]['checked'] = true;
|
||||
} else {
|
||||
$comp[$item]['checked'] = false;
|
||||
}
|
||||
}
|
||||
$list[] =
|
||||
(object) ['id' => $term->id, 'div' => $year.(int)$month, 'date' => $date, 'name' => $term->name, 'desc' => $term->desc, 'companies' => (object)$comp];
|
||||
}
|
||||
}
|
||||
$date = date('Y-m-d', strtotime("$date +1 DAYS"));
|
||||
if ($year != date('Y')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return view('dashboard', compact('list'));
|
||||
}
|
||||
|
||||
public function ajax(Request $request)
|
||||
{
|
||||
$return = [
|
||||
'status' => 'error'
|
||||
];
|
||||
if ($request->isMethod('post')) {
|
||||
$date = $request->get('date');
|
||||
$company = (int)$request->get('company');
|
||||
$term = (int)$request->get('term');
|
||||
$checked = $request->get('checked');
|
||||
if ($date && $company && $term) {
|
||||
if ('true' == $checked) {
|
||||
$confirm = Confirm::firstOrNew([
|
||||
'term_date' => $date,
|
||||
'company_id' => $company,
|
||||
'term_id' => $term,
|
||||
]);
|
||||
$confirm->save();
|
||||
} else {
|
||||
$confirm = Confirm::where('term_date', $date)->where('company_id', $company)
|
||||
->where('term_id', $term)->first();
|
||||
$confirm->delete();
|
||||
}
|
||||
|
||||
$request->session()->flash('message', 'Uloženo');
|
||||
$request->session()->flash('message-type', 'success');
|
||||
return response()->json(['status' => 'success']);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($return);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user